Files
2025-11-21 17:06:21 +08:00

353 lines
1.6 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["angular-html.js","html.js","javascript.js","css.js","angular-ts.js","scss.js","apl.js","xml.js","java.js","json.js","astro.js","typescript.js","postcss.js","tsx.js","blade.js","html-derivative.js","sql.js","bsl.js","sdbl.js","cairo.js","python.js","cobol.js","coffee.js","cpp.js","regexp.js","glsl.js","c.js","crystal.js","shellscript.js","edge.js","elixir.js","elm.js","erb.js","ruby.js","haml.js","graphql.js","jsx.js","lua.js","yaml.js","erlang.js","markdown.js","fortran-fixed-form.js","fortran-free-form.js","fsharp.js","gdresource.js","gdshader.js","gdscript.js","git-commit.js","diff.js","git-rebase.js","glimmer-js.js","glimmer-ts.js","hack.js","handlebars.js","http.js","hxml.js","haxe.js","jinja.js","jison.js","julia.js","r.js","latex.js","tex.js","liquid.js","marko.js","less.js","mdc.js","nginx.js","nim.js","perl.js","php.js","pug.js","qml.js","razor.js","csharp.js","rst.js","cmake.js","sas.js","shaderlab.js","hlsl.js","shellsession.js","soy.js","sparql.js","turtle.js","stata.js","svelte.js","templ.js","go.js","ts-tags.js","twig.js","vue.js","vue-html.js","vue-vine.js","stylus.js","xsl.js"])))=>i.map(i=>d[i]);
function OK(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var R0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var MS={exports:{}},dd={};/**
* @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 PK(){if(iD)return dd;iD=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,s){var o=null;if(s!==void 0&&(o=""+s),i.key!==void 0&&(o=""+i.key),"key"in i){s={};for(var a in i)a!=="key"&&(s[a]=i[a])}else s=i;return i=s.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:s}}return dd.Fragment=e,dd.jsx=n,dd.jsxs=n,dd}var sD;function DK(){return sD||(sD=1,MS.exports=PK()),MS.exports}var C=DK(),OS={exports:{}},Je={};/**
* @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 oD;function IK(){if(oD)return Je;oD=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),d=Symbol.iterator;function m(T){return T===null||typeof T!="object"?null:(T=d&&T[d]||T["@@iterator"],typeof T=="function"?T:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,w={};function S(T,Z,ue){this.props=T,this.context=Z,this.refs=w,this.updater=ue||y}S.prototype.isReactComponent={},S.prototype.setState=function(T,Z){if(typeof T!="object"&&typeof T!="function"&&T!=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,T,Z,"setState")},S.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function _(){}_.prototype=S.prototype;function A(T,Z,ue){this.props=T,this.context=Z,this.refs=w,this.updater=ue||y}var E=A.prototype=new _;E.constructor=A,b(E,S.prototype),E.isPureReactComponent=!0;var P=Array.isArray,O={H:null,A:null,T:null,S:null,V:null},M=Object.prototype.hasOwnProperty;function D(T,Z,ue,L,pe,ke){return ue=ke.ref,{$$typeof:t,type:T,key:Z,ref:ue!==void 0?ue:null,props:ke}}function $(T,Z){return D(T.type,Z,void 0,void 0,void 0,T.props)}function F(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function N(T){var Z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(ue){return Z[ue]})}var U=/\/+/g;function q(T,Z){return typeof T=="object"&&T!==null&&T.key!=null?N(""+T.key):Z.toString(36)}function K(){}function X(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(K,K):(T.status="pending",T.then(function(Z){T.status==="pending"&&(T.status="fulfilled",T.value=Z)},function(Z){T.status==="pending"&&(T.status="rejected",T.reason=Z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function ee(T,Z,ue,L,pe){var ke=typeof T;(ke==="undefined"||ke==="boolean")&&(T=null);var be=!1;if(T===null)be=!0;else switch(ke){case"bigint":case"string":case"number":be=!0;break;case"object":switch(T.$$typeof){case t:case e:be=!0;break;case f:return be=T._init,ee(be(T._payload),Z,ue,L,pe)}}if(be)return pe=pe(T),be=L===""?"."+q(T,0):L,P(pe)?(ue="",be!=null&&(ue=be.replace(U,"$&/")+"/"),ee(pe,Z,ue,"",function(Pt){return Pt})):pe!=null&&(F(pe)&&(pe=$(pe,ue+(pe.key==null||T&&T.key===pe.key?"":(""+pe.key).replace(U,"$&/")+"/")+be)),Z.push(pe)),1;be=0;var Ee=L===""?".":L+":";if(P(T))for(var Ue=0;Ue<T.length;Ue++)L=T[Ue],ke=Ee+q(L,Ue),be+=ee(L,Z,ue,ke,pe);else if(Ue=m(T),typeof Ue=="function")for(T=Ue.call(T),Ue=0;!(L=T.next()).done;)L=L.value,ke=Ee+q(L,Ue++),be+=ee(L,Z,ue,ke,pe);else if(ke==="object"){if(typeof T.then=="function")return ee(X(T),Z,ue,L,pe);throw Z=String(T),Error("Objects are not valid as a React child (found: "+(Z==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":Z)+"). If you meant to render a collection of children, use an array instead.")}return be}function V(T,Z,ue){if(T==null)return T;var L=[],pe=0;return ee(T,L,"","",function(ke){return Z.call(ue,ke,pe++)}),L}function G(T){if(T._status===-1){var Z=T._result;Z=Z(),Z.then(function(ue){(T._status===0||T._status===-1)&&(T._status=1,T._result=ue)},function(ue){(T._status===0||T._status===-1)&&(T._status=2,T._result=ue)}),T._status===-1&&(T._status=0,T._result=Z)}if(T._status===1)return T._result.default;throw T._result}var H=typeof reportError=="function"?reportError:function(T){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof T=="object"&&T!==null&&typeof T.message=="string"?String(T.message):String(T),error:T});if(!window.dispatchEvent(Z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",T);return}console.error(T)};function se(){}return Je.Children={map:V,forEach:function(T,Z,ue){V(T,function(){Z.apply(this,arguments)},ue)},count:function(T){var Z=0;return V(T,function(){Z++}),Z},toArray:function(T){return V(T,function(Z){return Z})||[]},only:function(T){if(!F(T))throw Error("React.Children.only expected to receive a single React element child.");return T}},Je.Component=S,Je.Fragment=n,Je.Profiler=i,Je.PureComponent=A,Je.StrictMode=r,Je.Suspense=c,Je.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,Je.__COMPILER_RUNTIME={__proto__:null,c:function(T){return O.H.useMemoCache(T)}},Je.cache=function(T){return function(){return T.apply(null,arguments)}},Je.cloneElement=function(T,Z,ue){if(T==null)throw Error("The argument must be a React element, but you passed "+T+".");var L=b({},T.props),pe=T.key,ke=void 0;if(Z!=null)for(be in Z.ref!==void 0&&(ke=void 0),Z.key!==void 0&&(pe=""+Z.key),Z)!M.call(Z,be)||be==="key"||be==="__self"||be==="__source"||be==="ref"&&Z.ref===void 0||(L[be]=Z[be]);var be=arguments.length-2;if(be===1)L.children=ue;else if(1<be){for(var Ee=Array(be),Ue=0;Ue<be;Ue++)Ee[Ue]=arguments[Ue+2];L.children=Ee}return D(T.type,pe,void 0,void 0,ke,L)},Je.createContext=function(T){return T={$$typeof:o,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null},T.Provider=T,T.Consumer={$$typeof:s,_context:T},T},Je.createElement=function(T,Z,ue){var L,pe={},ke=null;if(Z!=null)for(L in Z.key!==void 0&&(ke=""+Z.key),Z)M.call(Z,L)&&L!=="key"&&L!=="__self"&&L!=="__source"&&(pe[L]=Z[L]);var be=arguments.length-2;if(be===1)pe.children=ue;else if(1<be){for(var Ee=Array(be),Ue=0;Ue<be;Ue++)Ee[Ue]=arguments[Ue+2];pe.children=Ee}if(T&&T.defaultProps)for(L in be=T.defaultProps,be)pe[L]===void 0&&(pe[L]=be[L]);return D(T,ke,void 0,void 0,null,pe)},Je.createRef=function(){return{current:null}},Je.forwardRef=function(T){return{$$typeof:a,render:T}},Je.isValidElement=F,Je.lazy=function(T){return{$$typeof:f,_payload:{_status:-1,_result:T},_init:G}},Je.memo=function(T,Z){return{$$typeof:h,type:T,compare:Z===void 0?null:Z}},Je.startTransition=function(T){var Z=O.T,ue={};O.T=ue;try{var L=T(),pe=O.S;pe!==null&&pe(ue,L),typeof L=="object"&&L!==null&&typeof L.then=="function"&&L.then(se,H)}catch(ke){H(ke)}finally{O.T=Z}},Je.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},Je.use=function(T){return O.H.use(T)},Je.useActionState=function(T,Z,ue){return O.H.useActionState(T,Z,ue)},Je.useCallback=function(T,Z){return O.H.useCallback(T,Z)},Je.useContext=function(T){return O.H.useContext(T)},Je.useDebugValue=function(){},Je.useDeferredValue=function(T,Z){return O.H.useDeferredValue(T,Z)},Je.useEffect=function(T,Z,ue){var L=O.H;if(typeof ue=="function")throw Error("useEffect CRUD overload is not enabled in this build of React.");return L.useEffect(T,Z)},Je.useId=function(){return O.H.useId()},Je.useImperativeHandle=function(T,Z,ue){return O.H.useImperativeHandle(T,Z,ue)},Je.useInsertionEffect=function(T,Z){return O.H.useInsertionEffect(T,Z)},Je.useLayoutEffect=function(T,Z){return O.H.useLayoutEffect(T,Z)},Je.useMemo=function(T,Z){return O.H.useMemo(T,Z)},Je.useOptimistic=function(T,Z){return O.H.useOptimistic(T,Z)},Je.useReducer=function(T,Z,ue){return O.H.useReducer(T,Z,ue)},Je.useRef=function(T){return O.H.useRef(T)},Je.useState=function(T){return O.H.useState(T)},Je.useSyncExternalStore=function(T,Z,ue){return O.H.useSyncExternalStore(T,Z,ue)},Je.useTransition=function(){return O.H.useTransition()},Je.version="19.1.1",Je}var aD;function kE(){return aD||(aD=1,OS.exports=IK()),OS.exports}var k=kE();const de=Pc(k),k5=OK({__proto__:null,default:de},[k]);var PS={exports:{}},pd={},DS={exports:{}},IS={};/**
* @license React
* scheduler.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 lD;function LK(){return lD||(lD=1,(function(t){function e(V,G){var H=V.length;V.push(G);e:for(;0<H;){var se=H-1>>>1,T=V[se];if(0<i(T,G))V[se]=G,V[H]=T,H=se;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var G=V[0],H=V.pop();if(H!==G){V[0]=H;e:for(var se=0,T=V.length,Z=T>>>1;se<Z;){var ue=2*(se+1)-1,L=V[ue],pe=ue+1,ke=V[pe];if(0>i(L,H))pe<T&&0>i(ke,L)?(V[se]=ke,V[pe]=H,se=pe):(V[se]=L,V[ue]=H,se=ue);else if(pe<T&&0>i(ke,H))V[se]=ke,V[pe]=H,se=pe;else break e}}return G}function i(V,G){var H=V.sortIndex-G.sortIndex;return H!==0?H:V.id-G.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();t.unstable_now=function(){return o.now()-a}}var c=[],h=[],f=1,d=null,m=3,y=!1,b=!1,w=!1,S=!1,_=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function P(V){for(var G=n(h);G!==null;){if(G.callback===null)r(h);else if(G.startTime<=V)r(h),G.sortIndex=G.expirationTime,e(c,G);else break;G=n(h)}}function O(V){if(w=!1,P(V),!b)if(n(c)!==null)b=!0,M||(M=!0,q());else{var G=n(h);G!==null&&ee(O,G.startTime-V)}}var M=!1,D=-1,$=5,F=-1;function N(){return S?!0:!(t.unstable_now()-F<$)}function U(){if(S=!1,M){var V=t.unstable_now();F=V;var G=!0;try{e:{b=!1,w&&(w=!1,A(D),D=-1),y=!0;var H=m;try{t:{for(P(V),d=n(c);d!==null&&!(d.expirationTime>V&&N());){var se=d.callback;if(typeof se=="function"){d.callback=null,m=d.priorityLevel;var T=se(d.expirationTime<=V);if(V=t.unstable_now(),typeof T=="function"){d.callback=T,P(V),G=!0;break t}d===n(c)&&r(c),P(V)}else r(c);d=n(c)}if(d!==null)G=!0;else{var Z=n(h);Z!==null&&ee(O,Z.startTime-V),G=!1}}break e}finally{d=null,m=H,y=!1}G=void 0}}finally{G?q():M=!1}}}var q;if(typeof E=="function")q=function(){E(U)};else if(typeof MessageChannel<"u"){var K=new MessageChannel,X=K.port2;K.port1.onmessage=U,q=function(){X.postMessage(null)}}else q=function(){_(U,0)};function ee(V,G){D=_(function(){V(t.unstable_now())},G)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(V){V.callback=null},t.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<V?Math.floor(1e3/V):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_next=function(V){switch(m){case 1:case 2:case 3:var G=3;break;default:G=m}var H=m;m=G;try{return V()}finally{m=H}},t.unstable_requestPaint=function(){S=!0},t.unstable_runWithPriority=function(V,G){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var H=m;m=V;try{return G()}finally{m=H}},t.unstable_scheduleCallback=function(V,G,H){var se=t.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?se+H:se):H=se,V){case 1:var T=-1;break;case 2:T=250;break;case 5:T=1073741823;break;case 4:T=1e4;break;default:T=5e3}return T=H+T,V={id:f++,callback:G,priorityLevel:V,startTime:H,expirationTime:T,sortIndex:-1},H>se?(V.sortIndex=H,e(h,V),n(c)===null&&V===n(h)&&(w?(A(D),D=-1):w=!0,ee(O,H-se))):(V.sortIndex=T,e(c,V),b||y||(b=!0,M||(M=!0,q()))),V},t.unstable_shouldYield=N,t.unstable_wrapCallback=function(V){var G=m;return function(){var H=m;m=G;try{return V.apply(this,arguments)}finally{m=H}}}})(IS)),IS}var cD;function NK(){return cD||(cD=1,DS.exports=LK()),DS.exports}var LS={exports:{}},cr={};/**
* @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 uD;function $K(){if(uD)return cr;uD=1;var t=kE();function e(c){var h="https://react.dev/errors/"+c;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var f=2;f<arguments.length;f++)h+="&args[]="+encodeURIComponent(arguments[f])}return"Minified React error #"+c+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function s(c,h,f){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:d==null?null:""+d,children:c,containerInfo:h,implementation:f}}var o=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function a(c,h){if(c==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return cr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,cr.createPortal=function(c,h){var f=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(e(299));return s(c,h,null,f)},cr.flushSync=function(c){var h=o.T,f=r.p;try{if(o.T=null,r.p=2,c)return c()}finally{o.T=h,r.p=f,r.d.f()}},cr.preconnect=function(c,h){typeof c=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,r.d.C(c,h))},cr.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},cr.preinit=function(c,h){if(typeof c=="string"&&h&&typeof h.as=="string"){var f=h.as,d=a(f,h.crossOrigin),m=typeof h.integrity=="string"?h.integrity:void 0,y=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;f==="style"?r.d.S(c,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:d,integrity:m,fetchPriority:y}):f==="script"&&r.d.X(c,{crossOrigin:d,integrity:m,fetchPriority:y,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},cr.preinitModule=function(c,h){if(typeof c=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var f=a(h.as,h.crossOrigin);r.d.M(c,{crossOrigin:f,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&r.d.M(c)},cr.preload=function(c,h){if(typeof c=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var f=h.as,d=a(f,h.crossOrigin);r.d.L(c,f,{crossOrigin:d,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},cr.preloadModule=function(c,h){if(typeof c=="string")if(h){var f=a(h.as,h.crossOrigin);r.d.m(c,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:f,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else r.d.m(c)},cr.requestFormReset=function(c){r.d.r(c)},cr.unstable_batchedUpdates=function(c,h){return c(h)},cr.useFormState=function(c,h,f){return o.H.useFormState(c,h,f)},cr.useFormStatus=function(){return o.H.useHostTransitionStatus()},cr.version="19.1.1",cr}var hD;function T5(){if(hD)return LS.exports;hD=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),LS.exports=$K(),LS.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 fD;function jK(){if(fD)return pd;fD=1;var t=NK(),e=kE(),n=T5();function r(l){var u="https://react.dev/errors/"+l;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)u+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+l+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function s(l){var u=l,p=l;if(l.alternate)for(;u.return;)u=u.return;else{l=u;do u=l,(u.flags&4098)!==0&&(p=u.return),l=u.return;while(l)}return u.tag===3?p:null}function o(l){if(l.tag===13){var u=l.memoizedState;if(u===null&&(l=l.alternate,l!==null&&(u=l.memoizedState)),u!==null)return u.dehydrated}return null}function a(l){if(s(l)!==l)throw Error(r(188))}function c(l){var u=l.alternate;if(!u){if(u=s(l),u===null)throw Error(r(188));return u!==l?null:l}for(var p=l,g=u;;){var v=p.return;if(v===null)break;var x=v.alternate;if(x===null){if(g=v.return,g!==null){p=g;continue}break}if(v.child===x.child){for(x=v.child;x;){if(x===p)return a(v),l;if(x===g)return a(v),u;x=x.sibling}throw Error(r(188))}if(p.return!==g.return)p=v,g=x;else{for(var R=!1,I=v.child;I;){if(I===p){R=!0,p=v,g=x;break}if(I===g){R=!0,g=v,p=x;break}I=I.sibling}if(!R){for(I=x.child;I;){if(I===p){R=!0,p=x,g=v;break}if(I===g){R=!0,g=x,p=v;break}I=I.sibling}if(!R)throw Error(r(189))}}if(p.alternate!==g)throw Error(r(190))}if(p.tag!==3)throw Error(r(188));return p.stateNode.current===p?l:u}function h(l){var u=l.tag;if(u===5||u===26||u===27||u===6)return l;for(l=l.child;l!==null;){if(u=h(l),u!==null)return u;l=l.sibling}return null}var f=Object.assign,d=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),_=Symbol.for("react.provider"),A=Symbol.for("react.consumer"),E=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),N=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function q(l){return l===null||typeof l!="object"?null:(l=U&&l[U]||l["@@iterator"],typeof l=="function"?l:null)}var K=Symbol.for("react.client.reference");function X(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===K?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case b:return"Fragment";case S:return"Profiler";case w:return"StrictMode";case O:return"Suspense";case M:return"SuspenseList";case F:return"Activity"}if(typeof l=="object")switch(l.$$typeof){case y:return"Portal";case E:return(l.displayName||"Context")+".Provider";case A:return(l._context.displayName||"Context")+".Consumer";case P:var u=l.render;return l=l.displayName,l||(l=u.displayName||u.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case D:return u=l.displayName||null,u!==null?u:X(l.type)||"Memo";case $:u=l._payload,l=l._init;try{return X(l(u))}catch{}}return null}var ee=Array.isArray,V=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H={pending:!1,data:null,method:null,action:null},se=[],T=-1;function Z(l){return{current:l}}function ue(l){0>T||(l.current=se[T],se[T]=null,T--)}function L(l,u){T++,se[T]=l.current,l.current=u}var pe=Z(null),ke=Z(null),be=Z(null),Ee=Z(null);function Ue(l,u){switch(L(be,u),L(ke,l),L(pe,null),u.nodeType){case 9:case 11:l=(l=u.documentElement)&&(l=l.namespaceURI)?PP(l):0;break;default:if(l=u.tagName,u=u.namespaceURI)u=PP(u),l=DP(u,l);else switch(l){case"svg":l=1;break;case"math":l=2;break;default:l=0}}ue(pe),L(pe,l)}function Pt(){ue(pe),ue(ke),ue(be)}function Kt(l){l.memoizedState!==null&&L(Ee,l);var u=pe.current,p=DP(u,l.type);u!==p&&(L(ke,l),L(pe,p))}function Yt(l){ke.current===l&&(ue(pe),ue(ke)),Ee.current===l&&(ue(Ee),ld._currentValue=H)}var er=Object.prototype.hasOwnProperty,tr=t.unstable_scheduleCallback,ti=t.unstable_cancelCallback,_o=t.unstable_shouldYield,ss=t.unstable_requestPaint,nr=t.unstable_now,lf=t.unstable_getCurrentPriorityLevel,kl=t.unstable_ImmediatePriority,Ps=t.unstable_UserBlockingPriority,Ds=t.unstable_NormalPriority,Bc=t.unstable_LowPriority,Tl=t.unstable_IdlePriority,Mi=t.log,aa=t.unstable_setDisableYieldValue,oe=null,ge=null;function De(l){if(typeof Mi=="function"&&aa(l),ge&&typeof ge.setStrictMode=="function")try{ge.setStrictMode(oe,l)}catch{}}var $e=Math.clz32?Math.clz32:os,yt=Math.log,Sr=Math.LN2;function os(l){return l>>>=0,l===0?32:31-(yt(l)/Sr|0)|0}var rr=256,ni=4194304;function _r(l){var u=l&42;if(u!==0)return u;switch(l&-l){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:case 262144:case 524288:case 1048576:case 2097152:return l&4194048;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function on(l,u,p){var g=l.pendingLanes;if(g===0)return 0;var v=0,x=l.suspendedLanes,R=l.pingedLanes;l=l.warmLanes;var I=g&134217727;return I!==0?(g=I&~x,g!==0?v=_r(g):(R&=I,R!==0?v=_r(R):p||(p=I&~l,p!==0&&(v=_r(p))))):(I=g&~x,I!==0?v=_r(I):R!==0?v=_r(R):p||(p=g&~l,p!==0&&(v=_r(p)))),v===0?0:u!==0&&u!==v&&(u&x)===0&&(x=v&-v,p=u&-u,x>=p||x===32&&(p&4194048)!==0)?u:v}function ir(l,u){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&u)===0}function Bn(l,u){switch(l){case 1:case 2:case 4:case 8:case 64:return u+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 u+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 Fc(){var l=rr;return rr<<=1,(rr&4194048)===0&&(rr=256),l}function zc(){var l=ni;return ni<<=1,(ni&62914560)===0&&(ni=4194304),l}function Rl(l){for(var u=[],p=0;31>p;p++)u.push(l);return u}function as(l,u){l.pendingLanes|=u,u!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function Mx(l,u,p,g,v,x){var R=l.pendingLanes;l.pendingLanes=p,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=p,l.entangledLanes&=p,l.errorRecoveryDisabledLanes&=p,l.shellSuspendCounter=0;var I=l.entanglements,z=l.expirationTimes,te=l.hiddenUpdates;for(p=R&~p;0<p;){var ae=31-$e(p),he=1<<ae;I[ae]=0,z[ae]=-1;var re=te[ae];if(re!==null)for(te[ae]=null,ae=0;ae<re.length;ae++){var ie=re[ae];ie!==null&&(ie.lane&=-536870913)}p&=~he}g!==0&&hg(l,g,0),x!==0&&v===0&&l.tag!==0&&(l.suspendedLanes|=x&~(R&~u))}function hg(l,u,p){l.pendingLanes|=u,l.suspendedLanes&=~u;var g=31-$e(u);l.entangledLanes|=u,l.entanglements[g]=l.entanglements[g]|1073741824|p&4194090}function fg(l,u){var p=l.entangledLanes|=u;for(l=l.entanglements;p;){var g=31-$e(p),v=1<<g;v&u|l[g]&u&&(l[g]|=u),p&=~v}}function cf(l){switch(l){case 2:l=1;break;case 8:l=4;break;case 32:l=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:l=128;break;case 268435456:l=134217728;break;default:l=0}return l}function uf(l){return l&=-l,2<l?8<l?(l&134217727)!==0?32:268435456:8:2}function hf(){var l=G.p;return l!==0?l:(l=window.event,l===void 0?32:QP(l.type))}function dg(l,u){var p=G.p;try{return G.p=l,u()}finally{G.p=p}}var sr=Math.random().toString(36).slice(2),Mn="__reactFiber$"+sr,or="__reactProps$"+sr,la="__reactContainer$"+sr,ff="__reactEvents$"+sr,Ox="__reactListeners$"+sr,ls="__reactHandles$"+sr,pg="__reactResources$"+sr,Ml="__reactMarker$"+sr;function df(l){delete l[Mn],delete l[or],delete l[ff],delete l[Ox],delete l[ls]}function ca(l){var u=l[Mn];if(u)return u;for(var p=l.parentNode;p;){if(u=p[la]||p[Mn]){if(p=u.alternate,u.child!==null||p!==null&&p.child!==null)for(l=$P(l);l!==null;){if(p=l[Mn])return p;l=$P(l)}return u}l=p,p=l.parentNode}return null}function ua(l){if(l=l[Mn]||l[la]){var u=l.tag;if(u===5||u===6||u===13||u===26||u===27||u===3)return l}return null}function Oi(l){var u=l.tag;if(u===5||u===26||u===27||u===6)return l.stateNode;throw Error(r(33))}function ha(l){var u=l[pg];return u||(u=l[pg]={hoistableStyles:new Map,hoistableScripts:new Map}),u}function an(l){l[Ml]=!0}var mg=new Set,gg={};function Co(l,u){ri(l,u),ri(l+"Capture",u)}function ri(l,u){for(gg[l]=u,l=0;l<u.length;l++)mg.add(u[l])}var Px=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),yg={},bg={};function Dx(l){return er.call(bg,l)?!0:er.call(yg,l)?!1:Px.test(l)?bg[l]=!0:(yg[l]=!0,!1)}function Vc(l,u,p){if(Dx(u))if(p===null)l.removeAttribute(u);else{switch(typeof p){case"undefined":case"function":case"symbol":l.removeAttribute(u);return;case"boolean":var g=u.toLowerCase().slice(0,5);if(g!=="data-"&&g!=="aria-"){l.removeAttribute(u);return}}l.setAttribute(u,""+p)}}function Uc(l,u,p){if(p===null)l.removeAttribute(u);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":l.removeAttribute(u);return}l.setAttribute(u,""+p)}}function Pi(l,u,p,g){if(g===null)l.removeAttribute(p);else{switch(typeof g){case"undefined":case"function":case"symbol":case"boolean":l.removeAttribute(p);return}l.setAttributeNS(u,p,""+g)}}var fa,vg;function Is(l){if(fa===void 0)try{throw Error()}catch(p){var u=p.stack.trim().match(/\n( *(at )?)/);fa=u&&u[1]||"",vg=-1<p.stack.indexOf(`
at`)?" (<anonymous>)":-1<p.stack.indexOf("@")?"@unknown:0:0":""}return`
`+fa+l+vg}var pf=!1;function mf(l,u){if(!l||pf)return"";pf=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var g={DetermineComponentFrameRoot:function(){try{if(u){var he=function(){throw Error()};if(Object.defineProperty(he.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(he,[])}catch(ie){var re=ie}Reflect.construct(l,[],he)}else{try{he.call()}catch(ie){re=ie}l.call(he.prototype)}}else{try{throw Error()}catch(ie){re=ie}(he=l())&&typeof he.catch=="function"&&he.catch(function(){})}}catch(ie){if(ie&&re&&typeof ie.stack=="string")return[ie.stack,re.stack]}return[null,null]}};g.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var v=Object.getOwnPropertyDescriptor(g.DetermineComponentFrameRoot,"name");v&&v.configurable&&Object.defineProperty(g.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var x=g.DetermineComponentFrameRoot(),R=x[0],I=x[1];if(R&&I){var z=R.split(`
`),te=I.split(`
`);for(v=g=0;g<z.length&&!z[g].includes("DetermineComponentFrameRoot");)g++;for(;v<te.length&&!te[v].includes("DetermineComponentFrameRoot");)v++;if(g===z.length||v===te.length)for(g=z.length-1,v=te.length-1;1<=g&&0<=v&&z[g]!==te[v];)v--;for(;1<=g&&0<=v;g--,v--)if(z[g]!==te[v]){if(g!==1||v!==1)do if(g--,v--,0>v||z[g]!==te[v]){var ae=`
`+z[g].replace(" at new "," at ");return l.displayName&&ae.includes("<anonymous>")&&(ae=ae.replace("<anonymous>",l.displayName)),ae}while(1<=g&&0<=v);break}}}finally{pf=!1,Error.prepareStackTrace=p}return(p=l?l.displayName||l.name:"")?Is(p):""}function Ix(l){switch(l.tag){case 26:case 27:case 5:return Is(l.type);case 16:return Is("Lazy");case 13:return Is("Suspense");case 19:return Is("SuspenseList");case 0:case 15:return mf(l.type,!1);case 11:return mf(l.type.render,!1);case 1:return mf(l.type,!0);case 31:return Is("Activity");default:return""}}function wg(l){try{var u="";do u+=Ix(l),l=l.return;while(l);return u}catch(p){return`
Error generating stack: `+p.message+`
`+p.stack}}function $r(l){switch(typeof l){case"bigint":case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function xg(l){var u=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function gf(l){var u=xg(l)?"checked":"value",p=Object.getOwnPropertyDescriptor(l.constructor.prototype,u),g=""+l[u];if(!l.hasOwnProperty(u)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var v=p.get,x=p.set;return Object.defineProperty(l,u,{configurable:!0,get:function(){return v.call(this)},set:function(R){g=""+R,x.call(this,R)}}),Object.defineProperty(l,u,{enumerable:p.enumerable}),{getValue:function(){return g},setValue:function(R){g=""+R},stopTracking:function(){l._valueTracker=null,delete l[u]}}}}function Hc(l){l._valueTracker||(l._valueTracker=gf(l))}function Sg(l){if(!l)return!1;var u=l._valueTracker;if(!u)return!0;var p=u.getValue(),g="";return l&&(g=xg(l)?l.checked?"true":"false":l.value),l=g,l!==p?(u.setValue(l),!0):!1}function Wc(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}var Lx=/[\n"\\]/g;function jr(l){return l.replace(Lx,function(u){return"\\"+u.charCodeAt(0).toString(16)+" "})}function yf(l,u,p,g,v,x,R,I){l.name="",R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?l.type=R:l.removeAttribute("type"),u!=null?R==="number"?(u===0&&l.value===""||l.value!=u)&&(l.value=""+$r(u)):l.value!==""+$r(u)&&(l.value=""+$r(u)):R!=="submit"&&R!=="reset"||l.removeAttribute("value"),u!=null?qc(l,R,$r(u)):p!=null?qc(l,R,$r(p)):g!=null&&l.removeAttribute("value"),v==null&&x!=null&&(l.defaultChecked=!!x),v!=null&&(l.checked=v&&typeof v!="function"&&typeof v!="symbol"),I!=null&&typeof I!="function"&&typeof I!="symbol"&&typeof I!="boolean"?l.name=""+$r(I):l.removeAttribute("name")}function _g(l,u,p,g,v,x,R,I){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(l.type=x),u!=null||p!=null){if(!(x!=="submit"&&x!=="reset"||u!=null))return;p=p!=null?""+$r(p):"",u=u!=null?""+$r(u):p,I||u===l.value||(l.value=u),l.defaultValue=u}g=g??v,g=typeof g!="function"&&typeof g!="symbol"&&!!g,l.checked=I?l.checked:!!g,l.defaultChecked=!!g,R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"&&(l.name=R)}function qc(l,u,p){u==="number"&&Wc(l.ownerDocument)===l||l.defaultValue===""+p||(l.defaultValue=""+p)}function da(l,u,p,g){if(l=l.options,u){u={};for(var v=0;v<p.length;v++)u["$"+p[v]]=!0;for(p=0;p<l.length;p++)v=u.hasOwnProperty("$"+l[p].value),l[p].selected!==v&&(l[p].selected=v),v&&g&&(l[p].defaultSelected=!0)}else{for(p=""+$r(p),u=null,v=0;v<l.length;v++){if(l[v].value===p){l[v].selected=!0,g&&(l[v].defaultSelected=!0);return}u!==null||l[v].disabled||(u=l[v])}u!==null&&(u.selected=!0)}}function Cg(l,u,p){if(u!=null&&(u=""+$r(u),u!==l.value&&(l.value=u),p==null)){l.defaultValue!==u&&(l.defaultValue=u);return}l.defaultValue=p!=null?""+$r(p):""}function Ol(l,u,p,g){if(u==null){if(g!=null){if(p!=null)throw Error(r(92));if(ee(g)){if(1<g.length)throw Error(r(93));g=g[0]}p=g}p==null&&(p=""),u=p}p=$r(u),l.defaultValue=p,g=l.textContent,g===p&&g!==""&&g!==null&&(l.value=g)}function ii(l,u){if(u){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=u;return}}l.textContent=u}var Ag=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Ls(l,u,p){var g=u.indexOf("--")===0;p==null||typeof p=="boolean"||p===""?g?l.setProperty(u,""):u==="float"?l.cssFloat="":l[u]="":g?l.setProperty(u,p):typeof p!="number"||p===0||Ag.has(u)?u==="float"?l.cssFloat=p:l[u]=(""+p).trim():l[u]=p+"px"}function Eg(l,u,p){if(u!=null&&typeof u!="object")throw Error(r(62));if(l=l.style,p!=null){for(var g in p)!p.hasOwnProperty(g)||u!=null&&u.hasOwnProperty(g)||(g.indexOf("--")===0?l.setProperty(g,""):g==="float"?l.cssFloat="":l[g]="");for(var v in u)g=u[v],u.hasOwnProperty(v)&&p[v]!==g&&Ls(l,v,g)}else for(var x in u)u.hasOwnProperty(x)&&Ls(l,x,u[x])}function bf(l){if(l.indexOf("-")===-1)return!1;switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Nx=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),$x=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Gc(l){return $x.test(""+l)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":l}var vf=null;function Kc(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var Br=null,pa=null;function wf(l){var u=ua(l);if(u&&(l=u.stateNode)){var p=l[or]||null;e:switch(l=u.stateNode,u.type){case"input":if(yf(l,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name),u=p.name,p.type==="radio"&&u!=null){for(p=l;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll('input[name="'+jr(""+u)+'"][type="radio"]'),u=0;u<p.length;u++){var g=p[u];if(g!==l&&g.form===l.form){var v=g[or]||null;if(!v)throw Error(r(90));yf(g,v.value,v.defaultValue,v.defaultValue,v.checked,v.defaultChecked,v.type,v.name)}}for(u=0;u<p.length;u++)g=p[u],g.form===l.form&&Sg(g)}break e;case"textarea":Cg(l,p.value,p.defaultValue);break e;case"select":u=p.value,u!=null&&da(l,!!p.multiple,u,!1)}}}var xf=!1;function Yc(l,u,p){if(xf)return l(u,p);xf=!0;try{var g=l(u);return g}finally{if(xf=!1,(Br!==null||pa!==null)&&(l0(),Br&&(u=Br,l=pa,pa=Br=null,wf(u),l)))for(u=0;u<l.length;u++)wf(l[u])}}function ma(l,u){var p=l.stateNode;if(p===null)return null;var g=p[or]||null;if(g===null)return null;p=g[u];e:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(l=l.type,g=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!g;break e;default:l=!1}if(l)return null;if(p&&typeof p!="function")throw Error(r(231,u,typeof p));return p}var cs=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Sf=!1;if(cs)try{var ga={};Object.defineProperty(ga,"passive",{get:function(){Sf=!0}}),window.addEventListener("test",ga,ga),window.removeEventListener("test",ga,ga)}catch{Sf=!1}var Ns=null,ya=null,Xc=null;function Jc(){if(Xc)return Xc;var l,u=ya,p=u.length,g,v="value"in Ns?Ns.value:Ns.textContent,x=v.length;for(l=0;l<p&&u[l]===v[l];l++);var R=p-l;for(g=1;g<=R&&u[p-g]===v[x-g];g++);return Xc=v.slice(l,1<g?1-g:void 0)}function Qc(l){var u=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&u===13&&(l=13)):l=u,l===10&&(l=13),32<=l||l===13?l:0}function Zc(){return!0}function j(){return!1}function Q(l){function u(p,g,v,x,R){this._reactName=p,this._targetInst=v,this.type=g,this.nativeEvent=x,this.target=R,this.currentTarget=null;for(var I in l)l.hasOwnProperty(I)&&(p=l[I],this[I]=p?p(x):x[I]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?Zc:j,this.isPropagationStopped=j,this}return f(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=Zc)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=Zc)},persist:function(){},isPersistent:Zc}),u}var le={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Oe=Q(le),Wt=f({},le,{view:0,detail:0}),ar=Q(Wt),si,On,ba,us=f({},Wt,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:jx,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==ba&&(ba&&l.type==="mousemove"?(si=l.screenX-ba.screenX,On=l.screenY-ba.screenY):On=si=0,ba=l),si)},movementY:function(l){return"movementY"in l?l.movementY:On}}),_f=Q(us),kg=f({},us,{dataTransfer:0}),Tg=Q(kg),Cf=f({},Wt,{relatedTarget:0}),va=Q(Cf),Lq=f({},le,{animationName:0,elapsedTime:0,pseudoElement:0}),Nq=Q(Lq),$q=f({},le,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),jq=Q($q),Bq=f({},le,{data:0}),BR=Q(Bq),Fq={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},zq={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Vq={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Uq(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=Vq[l])?!!u[l]:!1}function jx(){return Uq}var Hq=f({},Wt,{key:function(l){if(l.key){var u=Fq[l.key]||l.key;if(u!=="Unidentified")return u}return l.type==="keypress"?(l=Qc(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?zq[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:jx,charCode:function(l){return l.type==="keypress"?Qc(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?Qc(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),Wq=Q(Hq),qq=f({},us,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),FR=Q(qq),Gq=f({},Wt,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:jx}),Kq=Q(Gq),Yq=f({},le,{propertyName:0,elapsedTime:0,pseudoElement:0}),Xq=Q(Yq),Jq=f({},us,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),Qq=Q(Jq),Zq=f({},le,{newState:0,oldState:0}),eG=Q(Zq),tG=[9,13,27,32],Bx=cs&&"CompositionEvent"in window,Af=null;cs&&"documentMode"in document&&(Af=document.documentMode);var nG=cs&&"TextEvent"in window&&!Af,zR=cs&&(!Bx||Af&&8<Af&&11>=Af),VR=" ",UR=!1;function HR(l,u){switch(l){case"keyup":return tG.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function WR(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var eu=!1;function rG(l,u){switch(l){case"compositionend":return WR(u);case"keypress":return u.which!==32?null:(UR=!0,VR);case"textInput":return l=u.data,l===VR&&UR?null:l;default:return null}}function iG(l,u){if(eu)return l==="compositionend"||!Bx&&HR(l,u)?(l=Jc(),Xc=ya=Ns=null,eu=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return zR&&u.locale!=="ko"?null:u.data;default:return null}}var sG={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function qR(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u==="input"?!!sG[l.type]:u==="textarea"}function GR(l,u,p,g){Br?pa?pa.push(g):pa=[g]:Br=g,u=p0(u,"onChange"),0<u.length&&(p=new Oe("onChange","change",null,p,g),l.push({event:p,listeners:u}))}var Ef=null,kf=null;function oG(l){kP(l,0)}function Rg(l){var u=Oi(l);if(Sg(u))return l}function KR(l,u){if(l==="change")return u}var YR=!1;if(cs){var Fx;if(cs){var zx="oninput"in document;if(!zx){var XR=document.createElement("div");XR.setAttribute("oninput","return;"),zx=typeof XR.oninput=="function"}Fx=zx}else Fx=!1;YR=Fx&&(!document.documentMode||9<document.documentMode)}function JR(){Ef&&(Ef.detachEvent("onpropertychange",QR),kf=Ef=null)}function QR(l){if(l.propertyName==="value"&&Rg(kf)){var u=[];GR(u,kf,l,Kc(l)),Yc(oG,u)}}function aG(l,u,p){l==="focusin"?(JR(),Ef=u,kf=p,Ef.attachEvent("onpropertychange",QR)):l==="focusout"&&JR()}function lG(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return Rg(kf)}function cG(l,u){if(l==="click")return Rg(u)}function uG(l,u){if(l==="input"||l==="change")return Rg(u)}function hG(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var oi=typeof Object.is=="function"?Object.is:hG;function Tf(l,u){if(oi(l,u))return!0;if(typeof l!="object"||l===null||typeof u!="object"||u===null)return!1;var p=Object.keys(l),g=Object.keys(u);if(p.length!==g.length)return!1;for(g=0;g<p.length;g++){var v=p[g];if(!er.call(u,v)||!oi(l[v],u[v]))return!1}return!0}function ZR(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function eM(l,u){var p=ZR(l);l=0;for(var g;p;){if(p.nodeType===3){if(g=l+p.textContent.length,l<=u&&g>=u)return{node:p,offset:u-l};l=g}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=ZR(p)}}function tM(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?tM(l,u.parentNode):"contains"in l?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function nM(l){l=l!=null&&l.ownerDocument!=null&&l.ownerDocument.defaultView!=null?l.ownerDocument.defaultView:window;for(var u=Wc(l.document);u instanceof l.HTMLIFrameElement;){try{var p=typeof u.contentWindow.location.href=="string"}catch{p=!1}if(p)l=u.contentWindow;else break;u=Wc(l.document)}return u}function Vx(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u&&(u==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||u==="textarea"||l.contentEditable==="true")}var fG=cs&&"documentMode"in document&&11>=document.documentMode,tu=null,Ux=null,Rf=null,Hx=!1;function rM(l,u,p){var g=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Hx||tu==null||tu!==Wc(g)||(g=tu,"selectionStart"in g&&Vx(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),Rf&&Tf(Rf,g)||(Rf=g,g=p0(Ux,"onSelect"),0<g.length&&(u=new Oe("onSelect","select",null,u,p),l.push({event:u,listeners:g}),u.target=tu)))}function Pl(l,u){var p={};return p[l.toLowerCase()]=u.toLowerCase(),p["Webkit"+l]="webkit"+u,p["Moz"+l]="moz"+u,p}var nu={animationend:Pl("Animation","AnimationEnd"),animationiteration:Pl("Animation","AnimationIteration"),animationstart:Pl("Animation","AnimationStart"),transitionrun:Pl("Transition","TransitionRun"),transitionstart:Pl("Transition","TransitionStart"),transitioncancel:Pl("Transition","TransitionCancel"),transitionend:Pl("Transition","TransitionEnd")},Wx={},iM={};cs&&(iM=document.createElement("div").style,"AnimationEvent"in window||(delete nu.animationend.animation,delete nu.animationiteration.animation,delete nu.animationstart.animation),"TransitionEvent"in window||delete nu.transitionend.transition);function Dl(l){if(Wx[l])return Wx[l];if(!nu[l])return l;var u=nu[l],p;for(p in u)if(u.hasOwnProperty(p)&&p in iM)return Wx[l]=u[p];return l}var sM=Dl("animationend"),oM=Dl("animationiteration"),aM=Dl("animationstart"),dG=Dl("transitionrun"),pG=Dl("transitionstart"),mG=Dl("transitioncancel"),lM=Dl("transitionend"),cM=new Map,qx="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");qx.push("scrollEnd");function hs(l,u){cM.set(l,u),Co(u,[l])}var uM=new WeakMap;function Di(l,u){if(typeof l=="object"&&l!==null){var p=uM.get(l);return p!==void 0?p:(u={value:l,source:u,stack:wg(u)},uM.set(l,u),u)}return{value:l,source:u,stack:wg(u)}}var Ii=[],ru=0,Gx=0;function Mg(){for(var l=ru,u=Gx=ru=0;u<l;){var p=Ii[u];Ii[u++]=null;var g=Ii[u];Ii[u++]=null;var v=Ii[u];Ii[u++]=null;var x=Ii[u];if(Ii[u++]=null,g!==null&&v!==null){var R=g.pending;R===null?v.next=v:(v.next=R.next,R.next=v),g.pending=v}x!==0&&hM(p,v,x)}}function Og(l,u,p,g){Ii[ru++]=l,Ii[ru++]=u,Ii[ru++]=p,Ii[ru++]=g,Gx|=g,l.lanes|=g,l=l.alternate,l!==null&&(l.lanes|=g)}function Kx(l,u,p,g){return Og(l,u,p,g),Pg(l)}function iu(l,u){return Og(l,null,null,u),Pg(l)}function hM(l,u,p){l.lanes|=p;var g=l.alternate;g!==null&&(g.lanes|=p);for(var v=!1,x=l.return;x!==null;)x.childLanes|=p,g=x.alternate,g!==null&&(g.childLanes|=p),x.tag===22&&(l=x.stateNode,l===null||l._visibility&1||(v=!0)),l=x,x=x.return;return l.tag===3?(x=l.stateNode,v&&u!==null&&(v=31-$e(p),l=x.hiddenUpdates,g=l[v],g===null?l[v]=[u]:g.push(u),u.lane=p|536870912),x):null}function Pg(l){if(50<ed)throw ed=0,eS=null,Error(r(185));for(var u=l.return;u!==null;)l=u,u=l.return;return l.tag===3?l.stateNode:null}var su={};function gG(l,u,p,g){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ai(l,u,p,g){return new gG(l,u,p,g)}function Yx(l){return l=l.prototype,!(!l||!l.isReactComponent)}function Ao(l,u){var p=l.alternate;return p===null?(p=ai(l.tag,u,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=u,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&65011712,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,u=l.dependencies,p.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p.refCleanup=l.refCleanup,p}function fM(l,u){l.flags&=65011714;var p=l.alternate;return p===null?(l.childLanes=0,l.lanes=u,l.child=null,l.subtreeFlags=0,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=p.childLanes,l.lanes=p.lanes,l.child=p.child,l.subtreeFlags=0,l.deletions=null,l.memoizedProps=p.memoizedProps,l.memoizedState=p.memoizedState,l.updateQueue=p.updateQueue,l.type=p.type,u=p.dependencies,l.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),l}function Dg(l,u,p,g,v,x){var R=0;if(g=l,typeof l=="function")Yx(l)&&(R=1);else if(typeof l=="string")R=bK(l,p,pe.current)?26:l==="html"||l==="head"||l==="body"?27:5;else e:switch(l){case F:return l=ai(31,p,u,v),l.elementType=F,l.lanes=x,l;case b:return Il(p.children,v,x,u);case w:R=8,v|=24;break;case S:return l=ai(12,p,u,v|2),l.elementType=S,l.lanes=x,l;case O:return l=ai(13,p,u,v),l.elementType=O,l.lanes=x,l;case M:return l=ai(19,p,u,v),l.elementType=M,l.lanes=x,l;default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case _:case E:R=10;break e;case A:R=9;break e;case P:R=11;break e;case D:R=14;break e;case $:R=16,g=null;break e}R=29,p=Error(r(130,l===null?"null":typeof l,"")),g=null}return u=ai(R,p,u,v),u.elementType=l,u.type=g,u.lanes=x,u}function Il(l,u,p,g){return l=ai(7,l,g,u),l.lanes=p,l}function Xx(l,u,p){return l=ai(6,l,null,u),l.lanes=p,l}function Jx(l,u,p){return u=ai(4,l.children!==null?l.children:[],l.key,u),u.lanes=p,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}var ou=[],au=0,Ig=null,Lg=0,Li=[],Ni=0,Ll=null,Eo=1,ko="";function Nl(l,u){ou[au++]=Lg,ou[au++]=Ig,Ig=l,Lg=u}function dM(l,u,p){Li[Ni++]=Eo,Li[Ni++]=ko,Li[Ni++]=Ll,Ll=l;var g=Eo;l=ko;var v=32-$e(g)-1;g&=~(1<<v),p+=1;var x=32-$e(u)+v;if(30<x){var R=v-v%5;x=(g&(1<<R)-1).toString(32),g>>=R,v-=R,Eo=1<<32-$e(u)+v|p<<v|g,ko=x+l}else Eo=1<<x|p<<v|g,ko=l}function Qx(l){l.return!==null&&(Nl(l,1),dM(l,1,0))}function Zx(l){for(;l===Ig;)Ig=ou[--au],ou[au]=null,Lg=ou[--au],ou[au]=null;for(;l===Ll;)Ll=Li[--Ni],Li[Ni]=null,ko=Li[--Ni],Li[Ni]=null,Eo=Li[--Ni],Li[Ni]=null}var Cr=null,Xt=null,bt=!1,$l=null,$s=!1,e1=Error(r(519));function jl(l){var u=Error(r(418,""));throw Pf(Di(u,l)),e1}function pM(l){var u=l.stateNode,p=l.type,g=l.memoizedProps;switch(u[Mn]=l,u[or]=g,p){case"dialog":at("cancel",u),at("close",u);break;case"iframe":case"object":case"embed":at("load",u);break;case"video":case"audio":for(p=0;p<nd.length;p++)at(nd[p],u);break;case"source":at("error",u);break;case"img":case"image":case"link":at("error",u),at("load",u);break;case"details":at("toggle",u);break;case"input":at("invalid",u),_g(u,g.value,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name,!0),Hc(u);break;case"select":at("invalid",u);break;case"textarea":at("invalid",u),Ol(u,g.value,g.defaultValue,g.children),Hc(u)}p=g.children,typeof p!="string"&&typeof p!="number"&&typeof p!="bigint"||u.textContent===""+p||g.suppressHydrationWarning===!0||OP(u.textContent,p)?(g.popover!=null&&(at("beforetoggle",u),at("toggle",u)),g.onScroll!=null&&at("scroll",u),g.onScrollEnd!=null&&at("scrollend",u),g.onClick!=null&&(u.onclick=m0),u=!0):u=!1,u||jl(l)}function mM(l){for(Cr=l.return;Cr;)switch(Cr.tag){case 5:case 13:$s=!1;return;case 27:case 3:$s=!0;return;default:Cr=Cr.return}}function Mf(l){if(l!==Cr)return!1;if(!bt)return mM(l),bt=!0,!1;var u=l.tag,p;if((p=u!==3&&u!==27)&&((p=u===5)&&(p=l.type,p=!(p!=="form"&&p!=="button")||gS(l.type,l.memoizedProps)),p=!p),p&&Xt&&jl(l),mM(l),u===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(r(317));e:{for(l=l.nextSibling,u=0;l;){if(l.nodeType===8)if(p=l.data,p==="/$"){if(u===0){Xt=ds(l.nextSibling);break e}u--}else p!=="$"&&p!=="$!"&&p!=="$?"||u++;l=l.nextSibling}Xt=null}}else u===27?(u=Xt,La(l.type)?(l=wS,wS=null,Xt=l):Xt=u):Xt=Cr?ds(l.stateNode.nextSibling):null;return!0}function Of(){Xt=Cr=null,bt=!1}function gM(){var l=$l;return l!==null&&(Vr===null?Vr=l:Vr.push.apply(Vr,l),$l=null),l}function Pf(l){$l===null?$l=[l]:$l.push(l)}var t1=Z(null),Bl=null,To=null;function wa(l,u,p){L(t1,u._currentValue),u._currentValue=p}function Ro(l){l._currentValue=t1.current,ue(t1)}function n1(l,u,p){for(;l!==null;){var g=l.alternate;if((l.childLanes&u)!==u?(l.childLanes|=u,g!==null&&(g.childLanes|=u)):g!==null&&(g.childLanes&u)!==u&&(g.childLanes|=u),l===p)break;l=l.return}}function r1(l,u,p,g){var v=l.child;for(v!==null&&(v.return=l);v!==null;){var x=v.dependencies;if(x!==null){var R=v.child;x=x.firstContext;e:for(;x!==null;){var I=x;x=v;for(var z=0;z<u.length;z++)if(I.context===u[z]){x.lanes|=p,I=x.alternate,I!==null&&(I.lanes|=p),n1(x.return,p,l),g||(R=null);break e}x=I.next}}else if(v.tag===18){if(R=v.return,R===null)throw Error(r(341));R.lanes|=p,x=R.alternate,x!==null&&(x.lanes|=p),n1(R,p,l),R=null}else R=v.child;if(R!==null)R.return=v;else for(R=v;R!==null;){if(R===l){R=null;break}if(v=R.sibling,v!==null){v.return=R.return,R=v;break}R=R.return}v=R}}function Df(l,u,p,g){l=null;for(var v=u,x=!1;v!==null;){if(!x){if((v.flags&524288)!==0)x=!0;else if((v.flags&262144)!==0)break}if(v.tag===10){var R=v.alternate;if(R===null)throw Error(r(387));if(R=R.memoizedProps,R!==null){var I=v.type;oi(v.pendingProps.value,R.value)||(l!==null?l.push(I):l=[I])}}else if(v===Ee.current){if(R=v.alternate,R===null)throw Error(r(387));R.memoizedState.memoizedState!==v.memoizedState.memoizedState&&(l!==null?l.push(ld):l=[ld])}v=v.return}l!==null&&r1(u,l,p,g),u.flags|=262144}function Ng(l){for(l=l.firstContext;l!==null;){if(!oi(l.context._currentValue,l.memoizedValue))return!0;l=l.next}return!1}function Fl(l){Bl=l,To=null,l=l.dependencies,l!==null&&(l.firstContext=null)}function lr(l){return yM(Bl,l)}function $g(l,u){return Bl===null&&Fl(l),yM(l,u)}function yM(l,u){var p=u._currentValue;if(u={context:u,memoizedValue:p,next:null},To===null){if(l===null)throw Error(r(308));To=u,l.dependencies={lanes:0,firstContext:u},l.flags|=524288}else To=To.next=u;return p}var yG=typeof AbortController<"u"?AbortController:function(){var l=[],u=this.signal={aborted:!1,addEventListener:function(p,g){l.push(g)}};this.abort=function(){u.aborted=!0,l.forEach(function(p){return p()})}},bG=t.unstable_scheduleCallback,vG=t.unstable_NormalPriority,vn={$$typeof:E,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function i1(){return{controller:new yG,data:new Map,refCount:0}}function If(l){l.refCount--,l.refCount===0&&bG(vG,function(){l.controller.abort()})}var Lf=null,s1=0,lu=0,cu=null;function wG(l,u){if(Lf===null){var p=Lf=[];s1=0,lu=aS(),cu={status:"pending",value:void 0,then:function(g){p.push(g)}}}return s1++,u.then(bM,bM),u}function bM(){if(--s1===0&&Lf!==null){cu!==null&&(cu.status="fulfilled");var l=Lf;Lf=null,lu=0,cu=null;for(var u=0;u<l.length;u++)(0,l[u])()}}function xG(l,u){var p=[],g={status:"pending",value:null,reason:null,then:function(v){p.push(v)}};return l.then(function(){g.status="fulfilled",g.value=u;for(var v=0;v<p.length;v++)(0,p[v])(u)},function(v){for(g.status="rejected",g.reason=v,v=0;v<p.length;v++)(0,p[v])(void 0)}),g}var vM=V.S;V.S=function(l,u){typeof u=="object"&&u!==null&&typeof u.then=="function"&&wG(l,u),vM!==null&&vM(l,u)};var zl=Z(null);function o1(){var l=zl.current;return l!==null?l:Dt.pooledCache}function jg(l,u){u===null?L(zl,zl.current):L(zl,u.pool)}function wM(){var l=o1();return l===null?null:{parent:vn._currentValue,pool:l}}var Nf=Error(r(460)),xM=Error(r(474)),Bg=Error(r(542)),a1={then:function(){}};function SM(l){return l=l.status,l==="fulfilled"||l==="rejected"}function Fg(){}function _M(l,u,p){switch(p=l[p],p===void 0?l.push(u):p!==u&&(u.then(Fg,Fg),u=p),u.status){case"fulfilled":return u.value;case"rejected":throw l=u.reason,AM(l),l;default:if(typeof u.status=="string")u.then(Fg,Fg);else{if(l=Dt,l!==null&&100<l.shellSuspendCounter)throw Error(r(482));l=u,l.status="pending",l.then(function(g){if(u.status==="pending"){var v=u;v.status="fulfilled",v.value=g}},function(g){if(u.status==="pending"){var v=u;v.status="rejected",v.reason=g}})}switch(u.status){case"fulfilled":return u.value;case"rejected":throw l=u.reason,AM(l),l}throw $f=u,Nf}}var $f=null;function CM(){if($f===null)throw Error(r(459));var l=$f;return $f=null,l}function AM(l){if(l===Nf||l===Bg)throw Error(r(483))}var xa=!1;function l1(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function c1(l,u){l=l.updateQueue,u.updateQueue===l&&(u.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function Sa(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function _a(l,u,p){var g=l.updateQueue;if(g===null)return null;if(g=g.shared,(wt&2)!==0){var v=g.pending;return v===null?u.next=u:(u.next=v.next,v.next=u),g.pending=u,u=Pg(l),hM(l,null,p),u}return Og(l,g,u,p),Pg(l)}function jf(l,u,p){if(u=u.updateQueue,u!==null&&(u=u.shared,(p&4194048)!==0)){var g=u.lanes;g&=l.pendingLanes,p|=g,u.lanes=p,fg(l,p)}}function u1(l,u){var p=l.updateQueue,g=l.alternate;if(g!==null&&(g=g.updateQueue,p===g)){var v=null,x=null;if(p=p.firstBaseUpdate,p!==null){do{var R={lane:p.lane,tag:p.tag,payload:p.payload,callback:null,next:null};x===null?v=x=R:x=x.next=R,p=p.next}while(p!==null);x===null?v=x=u:x=x.next=u}else v=x=u;p={baseState:g.baseState,firstBaseUpdate:v,lastBaseUpdate:x,shared:g.shared,callbacks:g.callbacks},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=u:l.next=u,p.lastBaseUpdate=u}var h1=!1;function Bf(){if(h1){var l=cu;if(l!==null)throw l}}function Ff(l,u,p,g){h1=!1;var v=l.updateQueue;xa=!1;var x=v.firstBaseUpdate,R=v.lastBaseUpdate,I=v.shared.pending;if(I!==null){v.shared.pending=null;var z=I,te=z.next;z.next=null,R===null?x=te:R.next=te,R=z;var ae=l.alternate;ae!==null&&(ae=ae.updateQueue,I=ae.lastBaseUpdate,I!==R&&(I===null?ae.firstBaseUpdate=te:I.next=te,ae.lastBaseUpdate=z))}if(x!==null){var he=v.baseState;R=0,ae=te=z=null,I=x;do{var re=I.lane&-536870913,ie=re!==I.lane;if(ie?(ct&re)===re:(g&re)===re){re!==0&&re===lu&&(h1=!0),ae!==null&&(ae=ae.next={lane:0,tag:I.tag,payload:I.payload,callback:null,next:null});e:{var We=l,Fe=I;re=u;var Ct=p;switch(Fe.tag){case 1:if(We=Fe.payload,typeof We=="function"){he=We.call(Ct,he,re);break e}he=We;break e;case 3:We.flags=We.flags&-65537|128;case 0:if(We=Fe.payload,re=typeof We=="function"?We.call(Ct,he,re):We,re==null)break e;he=f({},he,re);break e;case 2:xa=!0}}re=I.callback,re!==null&&(l.flags|=64,ie&&(l.flags|=8192),ie=v.callbacks,ie===null?v.callbacks=[re]:ie.push(re))}else ie={lane:re,tag:I.tag,payload:I.payload,callback:I.callback,next:null},ae===null?(te=ae=ie,z=he):ae=ae.next=ie,R|=re;if(I=I.next,I===null){if(I=v.shared.pending,I===null)break;ie=I,I=ie.next,ie.next=null,v.lastBaseUpdate=ie,v.shared.pending=null}}while(!0);ae===null&&(z=he),v.baseState=z,v.firstBaseUpdate=te,v.lastBaseUpdate=ae,x===null&&(v.shared.lanes=0),Oa|=R,l.lanes=R,l.memoizedState=he}}function EM(l,u){if(typeof l!="function")throw Error(r(191,l));l.call(u)}function kM(l,u){var p=l.callbacks;if(p!==null)for(l.callbacks=null,l=0;l<p.length;l++)EM(p[l],u)}var uu=Z(null),zg=Z(0);function TM(l,u){l=No,L(zg,l),L(uu,u),No=l|u.baseLanes}function f1(){L(zg,No),L(uu,uu.current)}function d1(){No=zg.current,ue(uu),ue(zg)}var Ca=0,et=null,St=null,ln=null,Vg=!1,hu=!1,Vl=!1,Ug=0,zf=0,fu=null,SG=0;function tn(){throw Error(r(321))}function p1(l,u){if(u===null)return!1;for(var p=0;p<u.length&&p<l.length;p++)if(!oi(l[p],u[p]))return!1;return!0}function m1(l,u,p,g,v,x){return Ca=x,et=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,V.H=l===null||l.memoizedState===null?hO:fO,Vl=!1,x=p(g,v),Vl=!1,hu&&(x=MM(u,p,g,v)),RM(l),x}function RM(l){V.H=Yg;var u=St!==null&&St.next!==null;if(Ca=0,ln=St=et=null,Vg=!1,zf=0,fu=null,u)throw Error(r(300));l===null||Pn||(l=l.dependencies,l!==null&&Ng(l)&&(Pn=!0))}function MM(l,u,p,g){et=l;var v=0;do{if(hu&&(fu=null),zf=0,hu=!1,25<=v)throw Error(r(301));if(v+=1,ln=St=null,l.updateQueue!=null){var x=l.updateQueue;x.lastEffect=null,x.events=null,x.stores=null,x.memoCache!=null&&(x.memoCache.index=0)}V.H=RG,x=u(p,g)}while(hu);return x}function _G(){var l=V.H,u=l.useState()[0];return u=typeof u.then=="function"?Vf(u):u,l=l.useState()[0],(St!==null?St.memoizedState:null)!==l&&(et.flags|=1024),u}function g1(){var l=Ug!==0;return Ug=0,l}function y1(l,u,p){u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~p}function b1(l){if(Vg){for(l=l.memoizedState;l!==null;){var u=l.queue;u!==null&&(u.pending=null),l=l.next}Vg=!1}Ca=0,ln=St=et=null,hu=!1,zf=Ug=0,fu=null}function Fr(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ln===null?et.memoizedState=ln=l:ln=ln.next=l,ln}function cn(){if(St===null){var l=et.alternate;l=l!==null?l.memoizedState:null}else l=St.next;var u=ln===null?et.memoizedState:ln.next;if(u!==null)ln=u,St=l;else{if(l===null)throw et.alternate===null?Error(r(467)):Error(r(310));St=l,l={memoizedState:St.memoizedState,baseState:St.baseState,baseQueue:St.baseQueue,queue:St.queue,next:null},ln===null?et.memoizedState=ln=l:ln=ln.next=l}return ln}function v1(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Vf(l){var u=zf;return zf+=1,fu===null&&(fu=[]),l=_M(fu,l,u),u=et,(ln===null?u.memoizedState:ln.next)===null&&(u=u.alternate,V.H=u===null||u.memoizedState===null?hO:fO),l}function Hg(l){if(l!==null&&typeof l=="object"){if(typeof l.then=="function")return Vf(l);if(l.$$typeof===E)return lr(l)}throw Error(r(438,String(l)))}function w1(l){var u=null,p=et.updateQueue;if(p!==null&&(u=p.memoCache),u==null){var g=et.alternate;g!==null&&(g=g.updateQueue,g!==null&&(g=g.memoCache,g!=null&&(u={data:g.data.map(function(v){return v.slice()}),index:0})))}if(u==null&&(u={data:[],index:0}),p===null&&(p=v1(),et.updateQueue=p),p.memoCache=u,p=u.data[u.index],p===void 0)for(p=u.data[u.index]=Array(l),g=0;g<l;g++)p[g]=N;return u.index++,p}function Mo(l,u){return typeof u=="function"?u(l):u}function Wg(l){var u=cn();return x1(u,St,l)}function x1(l,u,p){var g=l.queue;if(g===null)throw Error(r(311));g.lastRenderedReducer=p;var v=l.baseQueue,x=g.pending;if(x!==null){if(v!==null){var R=v.next;v.next=x.next,x.next=R}u.baseQueue=v=x,g.pending=null}if(x=l.baseState,v===null)l.memoizedState=x;else{u=v.next;var I=R=null,z=null,te=u,ae=!1;do{var he=te.lane&-536870913;if(he!==te.lane?(ct&he)===he:(Ca&he)===he){var re=te.revertLane;if(re===0)z!==null&&(z=z.next={lane:0,revertLane:0,action:te.action,hasEagerState:te.hasEagerState,eagerState:te.eagerState,next:null}),he===lu&&(ae=!0);else if((Ca&re)===re){te=te.next,re===lu&&(ae=!0);continue}else he={lane:0,revertLane:te.revertLane,action:te.action,hasEagerState:te.hasEagerState,eagerState:te.eagerState,next:null},z===null?(I=z=he,R=x):z=z.next=he,et.lanes|=re,Oa|=re;he=te.action,Vl&&p(x,he),x=te.hasEagerState?te.eagerState:p(x,he)}else re={lane:he,revertLane:te.revertLane,action:te.action,hasEagerState:te.hasEagerState,eagerState:te.eagerState,next:null},z===null?(I=z=re,R=x):z=z.next=re,et.lanes|=he,Oa|=he;te=te.next}while(te!==null&&te!==u);if(z===null?R=x:z.next=I,!oi(x,l.memoizedState)&&(Pn=!0,ae&&(p=cu,p!==null)))throw p;l.memoizedState=x,l.baseState=R,l.baseQueue=z,g.lastRenderedState=x}return v===null&&(g.lanes=0),[l.memoizedState,g.dispatch]}function S1(l){var u=cn(),p=u.queue;if(p===null)throw Error(r(311));p.lastRenderedReducer=l;var g=p.dispatch,v=p.pending,x=u.memoizedState;if(v!==null){p.pending=null;var R=v=v.next;do x=l(x,R.action),R=R.next;while(R!==v);oi(x,u.memoizedState)||(Pn=!0),u.memoizedState=x,u.baseQueue===null&&(u.baseState=x),p.lastRenderedState=x}return[x,g]}function OM(l,u,p){var g=et,v=cn(),x=bt;if(x){if(p===void 0)throw Error(r(407));p=p()}else p=u();var R=!oi((St||v).memoizedState,p);R&&(v.memoizedState=p,Pn=!0),v=v.queue;var I=IM.bind(null,g,v,l);if(Uf(2048,8,I,[l]),v.getSnapshot!==u||R||ln!==null&&ln.memoizedState.tag&1){if(g.flags|=2048,du(9,qg(),DM.bind(null,g,v,p,u),null),Dt===null)throw Error(r(349));x||(Ca&124)!==0||PM(g,u,p)}return p}function PM(l,u,p){l.flags|=16384,l={getSnapshot:u,value:p},u=et.updateQueue,u===null?(u=v1(),et.updateQueue=u,u.stores=[l]):(p=u.stores,p===null?u.stores=[l]:p.push(l))}function DM(l,u,p,g){u.value=p,u.getSnapshot=g,LM(u)&&NM(l)}function IM(l,u,p){return p(function(){LM(u)&&NM(l)})}function LM(l){var u=l.getSnapshot;l=l.value;try{var p=u();return!oi(l,p)}catch{return!0}}function NM(l){var u=iu(l,2);u!==null&&fi(u,l,2)}function _1(l){var u=Fr();if(typeof l=="function"){var p=l;if(l=p(),Vl){De(!0);try{p()}finally{De(!1)}}}return u.memoizedState=u.baseState=l,u.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mo,lastRenderedState:l},u}function $M(l,u,p,g){return l.baseState=p,x1(l,St,typeof g=="function"?g:Mo)}function CG(l,u,p,g,v){if(Kg(l))throw Error(r(485));if(l=u.action,l!==null){var x={payload:v,action:l,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(R){x.listeners.push(R)}};V.T!==null?p(!0):x.isTransition=!1,g(x),p=u.pending,p===null?(x.next=u.pending=x,jM(u,x)):(x.next=p.next,u.pending=p.next=x)}}function jM(l,u){var p=u.action,g=u.payload,v=l.state;if(u.isTransition){var x=V.T,R={};V.T=R;try{var I=p(v,g),z=V.S;z!==null&&z(R,I),BM(l,u,I)}catch(te){C1(l,u,te)}finally{V.T=x}}else try{x=p(v,g),BM(l,u,x)}catch(te){C1(l,u,te)}}function BM(l,u,p){p!==null&&typeof p=="object"&&typeof p.then=="function"?p.then(function(g){FM(l,u,g)},function(g){return C1(l,u,g)}):FM(l,u,p)}function FM(l,u,p){u.status="fulfilled",u.value=p,zM(u),l.state=p,u=l.pending,u!==null&&(p=u.next,p===u?l.pending=null:(p=p.next,u.next=p,jM(l,p)))}function C1(l,u,p){var g=l.pending;if(l.pending=null,g!==null){g=g.next;do u.status="rejected",u.reason=p,zM(u),u=u.next;while(u!==g)}l.action=null}function zM(l){l=l.listeners;for(var u=0;u<l.length;u++)(0,l[u])()}function VM(l,u){return u}function UM(l,u){if(bt){var p=Dt.formState;if(p!==null){e:{var g=et;if(bt){if(Xt){t:{for(var v=Xt,x=$s;v.nodeType!==8;){if(!x){v=null;break t}if(v=ds(v.nextSibling),v===null){v=null;break t}}x=v.data,v=x==="F!"||x==="F"?v:null}if(v){Xt=ds(v.nextSibling),g=v.data==="F!";break e}}jl(g)}g=!1}g&&(u=p[0])}}return p=Fr(),p.memoizedState=p.baseState=u,g={pending:null,lanes:0,dispatch:null,lastRenderedReducer:VM,lastRenderedState:u},p.queue=g,p=lO.bind(null,et,g),g.dispatch=p,g=_1(!1),x=R1.bind(null,et,!1,g.queue),g=Fr(),v={state:u,dispatch:null,action:l,pending:null},g.queue=v,p=CG.bind(null,et,v,x,p),v.dispatch=p,g.memoizedState=l,[u,p,!1]}function HM(l){var u=cn();return WM(u,St,l)}function WM(l,u,p){if(u=x1(l,u,VM)[0],l=Wg(Mo)[0],typeof u=="object"&&u!==null&&typeof u.then=="function")try{var g=Vf(u)}catch(R){throw R===Nf?Bg:R}else g=u;u=cn();var v=u.queue,x=v.dispatch;return p!==u.memoizedState&&(et.flags|=2048,du(9,qg(),AG.bind(null,v,p),null)),[g,x,l]}function AG(l,u){l.action=u}function qM(l){var u=cn(),p=St;if(p!==null)return WM(u,p,l);cn(),u=u.memoizedState,p=cn();var g=p.queue.dispatch;return p.memoizedState=l,[u,g,!1]}function du(l,u,p,g){return l={tag:l,create:p,deps:g,inst:u,next:null},u=et.updateQueue,u===null&&(u=v1(),et.updateQueue=u),p=u.lastEffect,p===null?u.lastEffect=l.next=l:(g=p.next,p.next=l,l.next=g,u.lastEffect=l),l}function qg(){return{destroy:void 0,resource:void 0}}function GM(){return cn().memoizedState}function Gg(l,u,p,g){var v=Fr();g=g===void 0?null:g,et.flags|=l,v.memoizedState=du(1|u,qg(),p,g)}function Uf(l,u,p,g){var v=cn();g=g===void 0?null:g;var x=v.memoizedState.inst;St!==null&&g!==null&&p1(g,St.memoizedState.deps)?v.memoizedState=du(u,x,p,g):(et.flags|=l,v.memoizedState=du(1|u,x,p,g))}function KM(l,u){Gg(8390656,8,l,u)}function YM(l,u){Uf(2048,8,l,u)}function XM(l,u){return Uf(4,2,l,u)}function JM(l,u){return Uf(4,4,l,u)}function QM(l,u){if(typeof u=="function"){l=l();var p=u(l);return function(){typeof p=="function"?p():u(null)}}if(u!=null)return l=l(),u.current=l,function(){u.current=null}}function ZM(l,u,p){p=p!=null?p.concat([l]):null,Uf(4,4,QM.bind(null,u,l),p)}function A1(){}function eO(l,u){var p=cn();u=u===void 0?null:u;var g=p.memoizedState;return u!==null&&p1(u,g[1])?g[0]:(p.memoizedState=[l,u],l)}function tO(l,u){var p=cn();u=u===void 0?null:u;var g=p.memoizedState;if(u!==null&&p1(u,g[1]))return g[0];if(g=l(),Vl){De(!0);try{l()}finally{De(!1)}}return p.memoizedState=[g,u],g}function E1(l,u,p){return p===void 0||(Ca&1073741824)!==0?l.memoizedState=u:(l.memoizedState=p,l=iP(),et.lanes|=l,Oa|=l,p)}function nO(l,u,p,g){return oi(p,u)?p:uu.current!==null?(l=E1(l,p,g),oi(l,u)||(Pn=!0),l):(Ca&42)===0?(Pn=!0,l.memoizedState=p):(l=iP(),et.lanes|=l,Oa|=l,u)}function rO(l,u,p,g,v){var x=G.p;G.p=x!==0&&8>x?x:8;var R=V.T,I={};V.T=I,R1(l,!1,u,p);try{var z=v(),te=V.S;if(te!==null&&te(I,z),z!==null&&typeof z=="object"&&typeof z.then=="function"){var ae=xG(z,g);Hf(l,u,ae,hi(l))}else Hf(l,u,g,hi(l))}catch(he){Hf(l,u,{then:function(){},status:"rejected",reason:he},hi())}finally{G.p=x,V.T=R}}function EG(){}function k1(l,u,p,g){if(l.tag!==5)throw Error(r(476));var v=iO(l).queue;rO(l,v,u,H,p===null?EG:function(){return sO(l),p(g)})}function iO(l){var u=l.memoizedState;if(u!==null)return u;u={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mo,lastRenderedState:H},next:null};var p={};return u.next={memoizedState:p,baseState:p,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mo,lastRenderedState:p},next:null},l.memoizedState=u,l=l.alternate,l!==null&&(l.memoizedState=u),u}function sO(l){var u=iO(l).next.queue;Hf(l,u,{},hi())}function T1(){return lr(ld)}function oO(){return cn().memoizedState}function aO(){return cn().memoizedState}function kG(l){for(var u=l.return;u!==null;){switch(u.tag){case 24:case 3:var p=hi();l=Sa(p);var g=_a(u,l,p);g!==null&&(fi(g,u,p),jf(g,u,p)),u={cache:i1()},l.payload=u;return}u=u.return}}function TG(l,u,p){var g=hi();p={lane:g,revertLane:0,action:p,hasEagerState:!1,eagerState:null,next:null},Kg(l)?cO(u,p):(p=Kx(l,u,p,g),p!==null&&(fi(p,l,g),uO(p,u,g)))}function lO(l,u,p){var g=hi();Hf(l,u,p,g)}function Hf(l,u,p,g){var v={lane:g,revertLane:0,action:p,hasEagerState:!1,eagerState:null,next:null};if(Kg(l))cO(u,v);else{var x=l.alternate;if(l.lanes===0&&(x===null||x.lanes===0)&&(x=u.lastRenderedReducer,x!==null))try{var R=u.lastRenderedState,I=x(R,p);if(v.hasEagerState=!0,v.eagerState=I,oi(I,R))return Og(l,u,v,0),Dt===null&&Mg(),!1}catch{}finally{}if(p=Kx(l,u,v,g),p!==null)return fi(p,l,g),uO(p,u,g),!0}return!1}function R1(l,u,p,g){if(g={lane:2,revertLane:aS(),action:g,hasEagerState:!1,eagerState:null,next:null},Kg(l)){if(u)throw Error(r(479))}else u=Kx(l,p,g,2),u!==null&&fi(u,l,2)}function Kg(l){var u=l.alternate;return l===et||u!==null&&u===et}function cO(l,u){hu=Vg=!0;var p=l.pending;p===null?u.next=u:(u.next=p.next,p.next=u),l.pending=u}function uO(l,u,p){if((p&4194048)!==0){var g=u.lanes;g&=l.pendingLanes,p|=g,u.lanes=p,fg(l,p)}}var Yg={readContext:lr,use:Hg,useCallback:tn,useContext:tn,useEffect:tn,useImperativeHandle:tn,useLayoutEffect:tn,useInsertionEffect:tn,useMemo:tn,useReducer:tn,useRef:tn,useState:tn,useDebugValue:tn,useDeferredValue:tn,useTransition:tn,useSyncExternalStore:tn,useId:tn,useHostTransitionStatus:tn,useFormState:tn,useActionState:tn,useOptimistic:tn,useMemoCache:tn,useCacheRefresh:tn},hO={readContext:lr,use:Hg,useCallback:function(l,u){return Fr().memoizedState=[l,u===void 0?null:u],l},useContext:lr,useEffect:KM,useImperativeHandle:function(l,u,p){p=p!=null?p.concat([l]):null,Gg(4194308,4,QM.bind(null,u,l),p)},useLayoutEffect:function(l,u){return Gg(4194308,4,l,u)},useInsertionEffect:function(l,u){Gg(4,2,l,u)},useMemo:function(l,u){var p=Fr();u=u===void 0?null:u;var g=l();if(Vl){De(!0);try{l()}finally{De(!1)}}return p.memoizedState=[g,u],g},useReducer:function(l,u,p){var g=Fr();if(p!==void 0){var v=p(u);if(Vl){De(!0);try{p(u)}finally{De(!1)}}}else v=u;return g.memoizedState=g.baseState=v,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:v},g.queue=l,l=l.dispatch=TG.bind(null,et,l),[g.memoizedState,l]},useRef:function(l){var u=Fr();return l={current:l},u.memoizedState=l},useState:function(l){l=_1(l);var u=l.queue,p=lO.bind(null,et,u);return u.dispatch=p,[l.memoizedState,p]},useDebugValue:A1,useDeferredValue:function(l,u){var p=Fr();return E1(p,l,u)},useTransition:function(){var l=_1(!1);return l=rO.bind(null,et,l.queue,!0,!1),Fr().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,u,p){var g=et,v=Fr();if(bt){if(p===void 0)throw Error(r(407));p=p()}else{if(p=u(),Dt===null)throw Error(r(349));(ct&124)!==0||PM(g,u,p)}v.memoizedState=p;var x={value:p,getSnapshot:u};return v.queue=x,KM(IM.bind(null,g,x,l),[l]),g.flags|=2048,du(9,qg(),DM.bind(null,g,x,p,u),null),p},useId:function(){var l=Fr(),u=Dt.identifierPrefix;if(bt){var p=ko,g=Eo;p=(g&~(1<<32-$e(g)-1)).toString(32)+p,u="«"+u+"R"+p,p=Ug++,0<p&&(u+="H"+p.toString(32)),u+="»"}else p=SG++,u="«"+u+"r"+p.toString(32)+"»";return l.memoizedState=u},useHostTransitionStatus:T1,useFormState:UM,useActionState:UM,useOptimistic:function(l){var u=Fr();u.memoizedState=u.baseState=l;var p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return u.queue=p,u=R1.bind(null,et,!0,p),p.dispatch=u,[l,u]},useMemoCache:w1,useCacheRefresh:function(){return Fr().memoizedState=kG.bind(null,et)}},fO={readContext:lr,use:Hg,useCallback:eO,useContext:lr,useEffect:YM,useImperativeHandle:ZM,useInsertionEffect:XM,useLayoutEffect:JM,useMemo:tO,useReducer:Wg,useRef:GM,useState:function(){return Wg(Mo)},useDebugValue:A1,useDeferredValue:function(l,u){var p=cn();return nO(p,St.memoizedState,l,u)},useTransition:function(){var l=Wg(Mo)[0],u=cn().memoizedState;return[typeof l=="boolean"?l:Vf(l),u]},useSyncExternalStore:OM,useId:oO,useHostTransitionStatus:T1,useFormState:HM,useActionState:HM,useOptimistic:function(l,u){var p=cn();return $M(p,St,l,u)},useMemoCache:w1,useCacheRefresh:aO},RG={readContext:lr,use:Hg,useCallback:eO,useContext:lr,useEffect:YM,useImperativeHandle:ZM,useInsertionEffect:XM,useLayoutEffect:JM,useMemo:tO,useReducer:S1,useRef:GM,useState:function(){return S1(Mo)},useDebugValue:A1,useDeferredValue:function(l,u){var p=cn();return St===null?E1(p,l,u):nO(p,St.memoizedState,l,u)},useTransition:function(){var l=S1(Mo)[0],u=cn().memoizedState;return[typeof l=="boolean"?l:Vf(l),u]},useSyncExternalStore:OM,useId:oO,useHostTransitionStatus:T1,useFormState:qM,useActionState:qM,useOptimistic:function(l,u){var p=cn();return St!==null?$M(p,St,l,u):(p.baseState=l,[l,p.queue.dispatch])},useMemoCache:w1,useCacheRefresh:aO},pu=null,Wf=0;function Xg(l){var u=Wf;return Wf+=1,pu===null&&(pu=[]),_M(pu,l,u)}function qf(l,u){u=u.props.ref,l.ref=u!==void 0?u:null}function Jg(l,u){throw u.$$typeof===d?Error(r(525)):(l=Object.prototype.toString.call(u),Error(r(31,l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l)))}function dO(l){var u=l._init;return u(l._payload)}function pO(l){function u(Y,W){if(l){var J=Y.deletions;J===null?(Y.deletions=[W],Y.flags|=16):J.push(W)}}function p(Y,W){if(!l)return null;for(;W!==null;)u(Y,W),W=W.sibling;return null}function g(Y){for(var W=new Map;Y!==null;)Y.key!==null?W.set(Y.key,Y):W.set(Y.index,Y),Y=Y.sibling;return W}function v(Y,W){return Y=Ao(Y,W),Y.index=0,Y.sibling=null,Y}function x(Y,W,J){return Y.index=J,l?(J=Y.alternate,J!==null?(J=J.index,J<W?(Y.flags|=67108866,W):J):(Y.flags|=67108866,W)):(Y.flags|=1048576,W)}function R(Y){return l&&Y.alternate===null&&(Y.flags|=67108866),Y}function I(Y,W,J,ce){return W===null||W.tag!==6?(W=Xx(J,Y.mode,ce),W.return=Y,W):(W=v(W,J),W.return=Y,W)}function z(Y,W,J,ce){var Te=J.type;return Te===b?ae(Y,W,J.props.children,ce,J.key):W!==null&&(W.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===$&&dO(Te)===W.type)?(W=v(W,J.props),qf(W,J),W.return=Y,W):(W=Dg(J.type,J.key,J.props,null,Y.mode,ce),qf(W,J),W.return=Y,W)}function te(Y,W,J,ce){return W===null||W.tag!==4||W.stateNode.containerInfo!==J.containerInfo||W.stateNode.implementation!==J.implementation?(W=Jx(J,Y.mode,ce),W.return=Y,W):(W=v(W,J.children||[]),W.return=Y,W)}function ae(Y,W,J,ce,Te){return W===null||W.tag!==7?(W=Il(J,Y.mode,ce,Te),W.return=Y,W):(W=v(W,J),W.return=Y,W)}function he(Y,W,J){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return W=Xx(""+W,Y.mode,J),W.return=Y,W;if(typeof W=="object"&&W!==null){switch(W.$$typeof){case m:return J=Dg(W.type,W.key,W.props,null,Y.mode,J),qf(J,W),J.return=Y,J;case y:return W=Jx(W,Y.mode,J),W.return=Y,W;case $:var ce=W._init;return W=ce(W._payload),he(Y,W,J)}if(ee(W)||q(W))return W=Il(W,Y.mode,J,null),W.return=Y,W;if(typeof W.then=="function")return he(Y,Xg(W),J);if(W.$$typeof===E)return he(Y,$g(Y,W),J);Jg(Y,W)}return null}function re(Y,W,J,ce){var Te=W!==null?W.key:null;if(typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint")return Te!==null?null:I(Y,W,""+J,ce);if(typeof J=="object"&&J!==null){switch(J.$$typeof){case m:return J.key===Te?z(Y,W,J,ce):null;case y:return J.key===Te?te(Y,W,J,ce):null;case $:return Te=J._init,J=Te(J._payload),re(Y,W,J,ce)}if(ee(J)||q(J))return Te!==null?null:ae(Y,W,J,ce,null);if(typeof J.then=="function")return re(Y,W,Xg(J),ce);if(J.$$typeof===E)return re(Y,W,$g(Y,J),ce);Jg(Y,J)}return null}function ie(Y,W,J,ce,Te){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return Y=Y.get(J)||null,I(W,Y,""+ce,Te);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case m:return Y=Y.get(ce.key===null?J:ce.key)||null,z(W,Y,ce,Te);case y:return Y=Y.get(ce.key===null?J:ce.key)||null,te(W,Y,ce,Te);case $:var rt=ce._init;return ce=rt(ce._payload),ie(Y,W,J,ce,Te)}if(ee(ce)||q(ce))return Y=Y.get(J)||null,ae(W,Y,ce,Te,null);if(typeof ce.then=="function")return ie(Y,W,J,Xg(ce),Te);if(ce.$$typeof===E)return ie(Y,W,J,$g(W,ce),Te);Jg(W,ce)}return null}function We(Y,W,J,ce){for(var Te=null,rt=null,Pe=W,Ve=W=0,In=null;Pe!==null&&Ve<J.length;Ve++){Pe.index>Ve?(In=Pe,Pe=null):In=Pe.sibling;var mt=re(Y,Pe,J[Ve],ce);if(mt===null){Pe===null&&(Pe=In);break}l&&Pe&&mt.alternate===null&&u(Y,Pe),W=x(mt,W,Ve),rt===null?Te=mt:rt.sibling=mt,rt=mt,Pe=In}if(Ve===J.length)return p(Y,Pe),bt&&Nl(Y,Ve),Te;if(Pe===null){for(;Ve<J.length;Ve++)Pe=he(Y,J[Ve],ce),Pe!==null&&(W=x(Pe,W,Ve),rt===null?Te=Pe:rt.sibling=Pe,rt=Pe);return bt&&Nl(Y,Ve),Te}for(Pe=g(Pe);Ve<J.length;Ve++)In=ie(Pe,Y,Ve,J[Ve],ce),In!==null&&(l&&In.alternate!==null&&Pe.delete(In.key===null?Ve:In.key),W=x(In,W,Ve),rt===null?Te=In:rt.sibling=In,rt=In);return l&&Pe.forEach(function(Fa){return u(Y,Fa)}),bt&&Nl(Y,Ve),Te}function Fe(Y,W,J,ce){if(J==null)throw Error(r(151));for(var Te=null,rt=null,Pe=W,Ve=W=0,In=null,mt=J.next();Pe!==null&&!mt.done;Ve++,mt=J.next()){Pe.index>Ve?(In=Pe,Pe=null):In=Pe.sibling;var Fa=re(Y,Pe,mt.value,ce);if(Fa===null){Pe===null&&(Pe=In);break}l&&Pe&&Fa.alternate===null&&u(Y,Pe),W=x(Fa,W,Ve),rt===null?Te=Fa:rt.sibling=Fa,rt=Fa,Pe=In}if(mt.done)return p(Y,Pe),bt&&Nl(Y,Ve),Te;if(Pe===null){for(;!mt.done;Ve++,mt=J.next())mt=he(Y,mt.value,ce),mt!==null&&(W=x(mt,W,Ve),rt===null?Te=mt:rt.sibling=mt,rt=mt);return bt&&Nl(Y,Ve),Te}for(Pe=g(Pe);!mt.done;Ve++,mt=J.next())mt=ie(Pe,Y,Ve,mt.value,ce),mt!==null&&(l&&mt.alternate!==null&&Pe.delete(mt.key===null?Ve:mt.key),W=x(mt,W,Ve),rt===null?Te=mt:rt.sibling=mt,rt=mt);return l&&Pe.forEach(function(MK){return u(Y,MK)}),bt&&Nl(Y,Ve),Te}function Ct(Y,W,J,ce){if(typeof J=="object"&&J!==null&&J.type===b&&J.key===null&&(J=J.props.children),typeof J=="object"&&J!==null){switch(J.$$typeof){case m:e:{for(var Te=J.key;W!==null;){if(W.key===Te){if(Te=J.type,Te===b){if(W.tag===7){p(Y,W.sibling),ce=v(W,J.props.children),ce.return=Y,Y=ce;break e}}else if(W.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===$&&dO(Te)===W.type){p(Y,W.sibling),ce=v(W,J.props),qf(ce,J),ce.return=Y,Y=ce;break e}p(Y,W);break}else u(Y,W);W=W.sibling}J.type===b?(ce=Il(J.props.children,Y.mode,ce,J.key),ce.return=Y,Y=ce):(ce=Dg(J.type,J.key,J.props,null,Y.mode,ce),qf(ce,J),ce.return=Y,Y=ce)}return R(Y);case y:e:{for(Te=J.key;W!==null;){if(W.key===Te)if(W.tag===4&&W.stateNode.containerInfo===J.containerInfo&&W.stateNode.implementation===J.implementation){p(Y,W.sibling),ce=v(W,J.children||[]),ce.return=Y,Y=ce;break e}else{p(Y,W);break}else u(Y,W);W=W.sibling}ce=Jx(J,Y.mode,ce),ce.return=Y,Y=ce}return R(Y);case $:return Te=J._init,J=Te(J._payload),Ct(Y,W,J,ce)}if(ee(J))return We(Y,W,J,ce);if(q(J)){if(Te=q(J),typeof Te!="function")throw Error(r(150));return J=Te.call(J),Fe(Y,W,J,ce)}if(typeof J.then=="function")return Ct(Y,W,Xg(J),ce);if(J.$$typeof===E)return Ct(Y,W,$g(Y,J),ce);Jg(Y,J)}return typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint"?(J=""+J,W!==null&&W.tag===6?(p(Y,W.sibling),ce=v(W,J),ce.return=Y,Y=ce):(p(Y,W),ce=Xx(J,Y.mode,ce),ce.return=Y,Y=ce),R(Y)):p(Y,W)}return function(Y,W,J,ce){try{Wf=0;var Te=Ct(Y,W,J,ce);return pu=null,Te}catch(Pe){if(Pe===Nf||Pe===Bg)throw Pe;var rt=ai(29,Pe,null,Y.mode);return rt.lanes=ce,rt.return=Y,rt}finally{}}}var mu=pO(!0),mO=pO(!1),$i=Z(null),js=null;function Aa(l){var u=l.alternate;L(wn,wn.current&1),L($i,l),js===null&&(u===null||uu.current!==null||u.memoizedState!==null)&&(js=l)}function gO(l){if(l.tag===22){if(L(wn,wn.current),L($i,l),js===null){var u=l.alternate;u!==null&&u.memoizedState!==null&&(js=l)}}else Ea()}function Ea(){L(wn,wn.current),L($i,$i.current)}function Oo(l){ue($i),js===l&&(js=null),ue(wn)}var wn=Z(0);function Qg(l){for(var u=l;u!==null;){if(u.tag===13){var p=u.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||vS(p)))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}function M1(l,u,p,g){u=l.memoizedState,p=p(g,u),p=p==null?u:f({},u,p),l.memoizedState=p,l.lanes===0&&(l.updateQueue.baseState=p)}var O1={enqueueSetState:function(l,u,p){l=l._reactInternals;var g=hi(),v=Sa(g);v.payload=u,p!=null&&(v.callback=p),u=_a(l,v,g),u!==null&&(fi(u,l,g),jf(u,l,g))},enqueueReplaceState:function(l,u,p){l=l._reactInternals;var g=hi(),v=Sa(g);v.tag=1,v.payload=u,p!=null&&(v.callback=p),u=_a(l,v,g),u!==null&&(fi(u,l,g),jf(u,l,g))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var p=hi(),g=Sa(p);g.tag=2,u!=null&&(g.callback=u),u=_a(l,g,p),u!==null&&(fi(u,l,p),jf(u,l,p))}};function yO(l,u,p,g,v,x,R){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(g,x,R):u.prototype&&u.prototype.isPureReactComponent?!Tf(p,g)||!Tf(v,x):!0}function bO(l,u,p,g){l=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(p,g),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(p,g),u.state!==l&&O1.enqueueReplaceState(u,u.state,null)}function Ul(l,u){var p=u;if("ref"in u){p={};for(var g in u)g!=="ref"&&(p[g]=u[g])}if(l=l.defaultProps){p===u&&(p=f({},p));for(var v in l)p[v]===void 0&&(p[v]=l[v])}return p}var Zg=typeof reportError=="function"?reportError:function(l){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var u=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof l=="object"&&l!==null&&typeof l.message=="string"?String(l.message):String(l),error:l});if(!window.dispatchEvent(u))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",l);return}console.error(l)};function vO(l){Zg(l)}function wO(l){console.error(l)}function xO(l){Zg(l)}function e0(l,u){try{var p=l.onUncaughtError;p(u.value,{componentStack:u.stack})}catch(g){setTimeout(function(){throw g})}}function SO(l,u,p){try{var g=l.onCaughtError;g(p.value,{componentStack:p.stack,errorBoundary:u.tag===1?u.stateNode:null})}catch(v){setTimeout(function(){throw v})}}function P1(l,u,p){return p=Sa(p),p.tag=3,p.payload={element:null},p.callback=function(){e0(l,u)},p}function _O(l){return l=Sa(l),l.tag=3,l}function CO(l,u,p,g){var v=p.type.getDerivedStateFromError;if(typeof v=="function"){var x=g.value;l.payload=function(){return v(x)},l.callback=function(){SO(u,p,g)}}var R=p.stateNode;R!==null&&typeof R.componentDidCatch=="function"&&(l.callback=function(){SO(u,p,g),typeof v!="function"&&(Pa===null?Pa=new Set([this]):Pa.add(this));var I=g.stack;this.componentDidCatch(g.value,{componentStack:I!==null?I:""})})}function MG(l,u,p,g,v){if(p.flags|=32768,g!==null&&typeof g=="object"&&typeof g.then=="function"){if(u=p.alternate,u!==null&&Df(u,p,v,!0),p=$i.current,p!==null){switch(p.tag){case 13:return js===null?nS():p.alternate===null&&Jt===0&&(Jt=3),p.flags&=-257,p.flags|=65536,p.lanes=v,g===a1?p.flags|=16384:(u=p.updateQueue,u===null?p.updateQueue=new Set([g]):u.add(g),iS(l,g,v)),!1;case 22:return p.flags|=65536,g===a1?p.flags|=16384:(u=p.updateQueue,u===null?(u={transitions:null,markerInstances:null,retryQueue:new Set([g])},p.updateQueue=u):(p=u.retryQueue,p===null?u.retryQueue=new Set([g]):p.add(g)),iS(l,g,v)),!1}throw Error(r(435,p.tag))}return iS(l,g,v),nS(),!1}if(bt)return u=$i.current,u!==null?((u.flags&65536)===0&&(u.flags|=256),u.flags|=65536,u.lanes=v,g!==e1&&(l=Error(r(422),{cause:g}),Pf(Di(l,p)))):(g!==e1&&(u=Error(r(423),{cause:g}),Pf(Di(u,p))),l=l.current.alternate,l.flags|=65536,v&=-v,l.lanes|=v,g=Di(g,p),v=P1(l.stateNode,g,v),u1(l,v),Jt!==4&&(Jt=2)),!1;var x=Error(r(520),{cause:g});if(x=Di(x,p),Zf===null?Zf=[x]:Zf.push(x),Jt!==4&&(Jt=2),u===null)return!0;g=Di(g,p),p=u;do{switch(p.tag){case 3:return p.flags|=65536,l=v&-v,p.lanes|=l,l=P1(p.stateNode,g,l),u1(p,l),!1;case 1:if(u=p.type,x=p.stateNode,(p.flags&128)===0&&(typeof u.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Pa===null||!Pa.has(x))))return p.flags|=65536,v&=-v,p.lanes|=v,v=_O(v),CO(v,l,p,g),u1(p,v),!1}p=p.return}while(p!==null);return!1}var AO=Error(r(461)),Pn=!1;function Fn(l,u,p,g){u.child=l===null?mO(u,null,p,g):mu(u,l.child,p,g)}function EO(l,u,p,g,v){p=p.render;var x=u.ref;if("ref"in g){var R={};for(var I in g)I!=="ref"&&(R[I]=g[I])}else R=g;return Fl(u),g=m1(l,u,p,R,x,v),I=g1(),l!==null&&!Pn?(y1(l,u,v),Po(l,u,v)):(bt&&I&&Qx(u),u.flags|=1,Fn(l,u,g,v),u.child)}function kO(l,u,p,g,v){if(l===null){var x=p.type;return typeof x=="function"&&!Yx(x)&&x.defaultProps===void 0&&p.compare===null?(u.tag=15,u.type=x,TO(l,u,x,g,v)):(l=Dg(p.type,null,g,u,u.mode,v),l.ref=u.ref,l.return=u,u.child=l)}if(x=l.child,!F1(l,v)){var R=x.memoizedProps;if(p=p.compare,p=p!==null?p:Tf,p(R,g)&&l.ref===u.ref)return Po(l,u,v)}return u.flags|=1,l=Ao(x,g),l.ref=u.ref,l.return=u,u.child=l}function TO(l,u,p,g,v){if(l!==null){var x=l.memoizedProps;if(Tf(x,g)&&l.ref===u.ref)if(Pn=!1,u.pendingProps=g=x,F1(l,v))(l.flags&131072)!==0&&(Pn=!0);else return u.lanes=l.lanes,Po(l,u,v)}return D1(l,u,p,g,v)}function RO(l,u,p){var g=u.pendingProps,v=g.children,x=l!==null?l.memoizedState:null;if(g.mode==="hidden"){if((u.flags&128)!==0){if(g=x!==null?x.baseLanes|p:p,l!==null){for(v=u.child=l.child,x=0;v!==null;)x=x|v.lanes|v.childLanes,v=v.sibling;u.childLanes=x&~g}else u.childLanes=0,u.child=null;return MO(l,u,g,p)}if((p&536870912)!==0)u.memoizedState={baseLanes:0,cachePool:null},l!==null&&jg(u,x!==null?x.cachePool:null),x!==null?TM(u,x):f1(),gO(u);else return u.lanes=u.childLanes=536870912,MO(l,u,x!==null?x.baseLanes|p:p,p)}else x!==null?(jg(u,x.cachePool),TM(u,x),Ea(),u.memoizedState=null):(l!==null&&jg(u,null),f1(),Ea());return Fn(l,u,v,p),u.child}function MO(l,u,p,g){var v=o1();return v=v===null?null:{parent:vn._currentValue,pool:v},u.memoizedState={baseLanes:p,cachePool:v},l!==null&&jg(u,null),f1(),gO(u),l!==null&&Df(l,u,g,!0),null}function t0(l,u){var p=u.ref;if(p===null)l!==null&&l.ref!==null&&(u.flags|=4194816);else{if(typeof p!="function"&&typeof p!="object")throw Error(r(284));(l===null||l.ref!==p)&&(u.flags|=4194816)}}function D1(l,u,p,g,v){return Fl(u),p=m1(l,u,p,g,void 0,v),g=g1(),l!==null&&!Pn?(y1(l,u,v),Po(l,u,v)):(bt&&g&&Qx(u),u.flags|=1,Fn(l,u,p,v),u.child)}function OO(l,u,p,g,v,x){return Fl(u),u.updateQueue=null,p=MM(u,g,p,v),RM(l),g=g1(),l!==null&&!Pn?(y1(l,u,x),Po(l,u,x)):(bt&&g&&Qx(u),u.flags|=1,Fn(l,u,p,x),u.child)}function PO(l,u,p,g,v){if(Fl(u),u.stateNode===null){var x=su,R=p.contextType;typeof R=="object"&&R!==null&&(x=lr(R)),x=new p(g,x),u.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,x.updater=O1,u.stateNode=x,x._reactInternals=u,x=u.stateNode,x.props=g,x.state=u.memoizedState,x.refs={},l1(u),R=p.contextType,x.context=typeof R=="object"&&R!==null?lr(R):su,x.state=u.memoizedState,R=p.getDerivedStateFromProps,typeof R=="function"&&(M1(u,p,R,g),x.state=u.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(R=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),R!==x.state&&O1.enqueueReplaceState(x,x.state,null),Ff(u,g,x,v),Bf(),x.state=u.memoizedState),typeof x.componentDidMount=="function"&&(u.flags|=4194308),g=!0}else if(l===null){x=u.stateNode;var I=u.memoizedProps,z=Ul(p,I);x.props=z;var te=x.context,ae=p.contextType;R=su,typeof ae=="object"&&ae!==null&&(R=lr(ae));var he=p.getDerivedStateFromProps;ae=typeof he=="function"||typeof x.getSnapshotBeforeUpdate=="function",I=u.pendingProps!==I,ae||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(I||te!==R)&&bO(u,x,g,R),xa=!1;var re=u.memoizedState;x.state=re,Ff(u,g,x,v),Bf(),te=u.memoizedState,I||re!==te||xa?(typeof he=="function"&&(M1(u,p,he,g),te=u.memoizedState),(z=xa||yO(u,p,z,g,re,te,R))?(ae||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(u.flags|=4194308)):(typeof x.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=g,u.memoizedState=te),x.props=g,x.state=te,x.context=R,g=z):(typeof x.componentDidMount=="function"&&(u.flags|=4194308),g=!1)}else{x=u.stateNode,c1(l,u),R=u.memoizedProps,ae=Ul(p,R),x.props=ae,he=u.pendingProps,re=x.context,te=p.contextType,z=su,typeof te=="object"&&te!==null&&(z=lr(te)),I=p.getDerivedStateFromProps,(te=typeof I=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(R!==he||re!==z)&&bO(u,x,g,z),xa=!1,re=u.memoizedState,x.state=re,Ff(u,g,x,v),Bf();var ie=u.memoizedState;R!==he||re!==ie||xa||l!==null&&l.dependencies!==null&&Ng(l.dependencies)?(typeof I=="function"&&(M1(u,p,I,g),ie=u.memoizedState),(ae=xa||yO(u,p,ae,g,re,ie,z)||l!==null&&l.dependencies!==null&&Ng(l.dependencies))?(te||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(g,ie,z),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(g,ie,z)),typeof x.componentDidUpdate=="function"&&(u.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof x.componentDidUpdate!="function"||R===l.memoizedProps&&re===l.memoizedState||(u.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||R===l.memoizedProps&&re===l.memoizedState||(u.flags|=1024),u.memoizedProps=g,u.memoizedState=ie),x.props=g,x.state=ie,x.context=z,g=ae):(typeof x.componentDidUpdate!="function"||R===l.memoizedProps&&re===l.memoizedState||(u.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||R===l.memoizedProps&&re===l.memoizedState||(u.flags|=1024),g=!1)}return x=g,t0(l,u),g=(u.flags&128)!==0,x||g?(x=u.stateNode,p=g&&typeof p.getDerivedStateFromError!="function"?null:x.render(),u.flags|=1,l!==null&&g?(u.child=mu(u,l.child,null,v),u.child=mu(u,null,p,v)):Fn(l,u,p,v),u.memoizedState=x.state,l=u.child):l=Po(l,u,v),l}function DO(l,u,p,g){return Of(),u.flags|=256,Fn(l,u,p,g),u.child}var I1={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function L1(l){return{baseLanes:l,cachePool:wM()}}function N1(l,u,p){return l=l!==null?l.childLanes&~p:0,u&&(l|=ji),l}function IO(l,u,p){var g=u.pendingProps,v=!1,x=(u.flags&128)!==0,R;if((R=x)||(R=l!==null&&l.memoizedState===null?!1:(wn.current&2)!==0),R&&(v=!0,u.flags&=-129),R=(u.flags&32)!==0,u.flags&=-33,l===null){if(bt){if(v?Aa(u):Ea(),bt){var I=Xt,z;if(z=I){e:{for(z=I,I=$s;z.nodeType!==8;){if(!I){I=null;break e}if(z=ds(z.nextSibling),z===null){I=null;break e}}I=z}I!==null?(u.memoizedState={dehydrated:I,treeContext:Ll!==null?{id:Eo,overflow:ko}:null,retryLane:536870912,hydrationErrors:null},z=ai(18,null,null,0),z.stateNode=I,z.return=u,u.child=z,Cr=u,Xt=null,z=!0):z=!1}z||jl(u)}if(I=u.memoizedState,I!==null&&(I=I.dehydrated,I!==null))return vS(I)?u.lanes=32:u.lanes=536870912,null;Oo(u)}return I=g.children,g=g.fallback,v?(Ea(),v=u.mode,I=n0({mode:"hidden",children:I},v),g=Il(g,v,p,null),I.return=u,g.return=u,I.sibling=g,u.child=I,v=u.child,v.memoizedState=L1(p),v.childLanes=N1(l,R,p),u.memoizedState=I1,g):(Aa(u),$1(u,I))}if(z=l.memoizedState,z!==null&&(I=z.dehydrated,I!==null)){if(x)u.flags&256?(Aa(u),u.flags&=-257,u=j1(l,u,p)):u.memoizedState!==null?(Ea(),u.child=l.child,u.flags|=128,u=null):(Ea(),v=g.fallback,I=u.mode,g=n0({mode:"visible",children:g.children},I),v=Il(v,I,p,null),v.flags|=2,g.return=u,v.return=u,g.sibling=v,u.child=g,mu(u,l.child,null,p),g=u.child,g.memoizedState=L1(p),g.childLanes=N1(l,R,p),u.memoizedState=I1,u=v);else if(Aa(u),vS(I)){if(R=I.nextSibling&&I.nextSibling.dataset,R)var te=R.dgst;R=te,g=Error(r(419)),g.stack="",g.digest=R,Pf({value:g,source:null,stack:null}),u=j1(l,u,p)}else if(Pn||Df(l,u,p,!1),R=(p&l.childLanes)!==0,Pn||R){if(R=Dt,R!==null&&(g=p&-p,g=(g&42)!==0?1:cf(g),g=(g&(R.suspendedLanes|p))!==0?0:g,g!==0&&g!==z.retryLane))throw z.retryLane=g,iu(l,g),fi(R,l,g),AO;I.data==="$?"||nS(),u=j1(l,u,p)}else I.data==="$?"?(u.flags|=192,u.child=l.child,u=null):(l=z.treeContext,Xt=ds(I.nextSibling),Cr=u,bt=!0,$l=null,$s=!1,l!==null&&(Li[Ni++]=Eo,Li[Ni++]=ko,Li[Ni++]=Ll,Eo=l.id,ko=l.overflow,Ll=u),u=$1(u,g.children),u.flags|=4096);return u}return v?(Ea(),v=g.fallback,I=u.mode,z=l.child,te=z.sibling,g=Ao(z,{mode:"hidden",children:g.children}),g.subtreeFlags=z.subtreeFlags&65011712,te!==null?v=Ao(te,v):(v=Il(v,I,p,null),v.flags|=2),v.return=u,g.return=u,g.sibling=v,u.child=g,g=v,v=u.child,I=l.child.memoizedState,I===null?I=L1(p):(z=I.cachePool,z!==null?(te=vn._currentValue,z=z.parent!==te?{parent:te,pool:te}:z):z=wM(),I={baseLanes:I.baseLanes|p,cachePool:z}),v.memoizedState=I,v.childLanes=N1(l,R,p),u.memoizedState=I1,g):(Aa(u),p=l.child,l=p.sibling,p=Ao(p,{mode:"visible",children:g.children}),p.return=u,p.sibling=null,l!==null&&(R=u.deletions,R===null?(u.deletions=[l],u.flags|=16):R.push(l)),u.child=p,u.memoizedState=null,p)}function $1(l,u){return u=n0({mode:"visible",children:u},l.mode),u.return=l,l.child=u}function n0(l,u){return l=ai(22,l,null,u),l.lanes=0,l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},l}function j1(l,u,p){return mu(u,l.child,null,p),l=$1(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function LO(l,u,p){l.lanes|=u;var g=l.alternate;g!==null&&(g.lanes|=u),n1(l.return,u,p)}function B1(l,u,p,g,v){var x=l.memoizedState;x===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:g,tail:p,tailMode:v}:(x.isBackwards=u,x.rendering=null,x.renderingStartTime=0,x.last=g,x.tail=p,x.tailMode=v)}function NO(l,u,p){var g=u.pendingProps,v=g.revealOrder,x=g.tail;if(Fn(l,u,g.children,p),g=wn.current,(g&2)!==0)g=g&1|2,u.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=u.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&LO(l,p,u);else if(l.tag===19)LO(l,p,u);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===u)break e;for(;l.sibling===null;){if(l.return===null||l.return===u)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}g&=1}switch(L(wn,g),v){case"forwards":for(p=u.child,v=null;p!==null;)l=p.alternate,l!==null&&Qg(l)===null&&(v=p),p=p.sibling;p=v,p===null?(v=u.child,u.child=null):(v=p.sibling,p.sibling=null),B1(u,!1,v,p,x);break;case"backwards":for(p=null,v=u.child,u.child=null;v!==null;){if(l=v.alternate,l!==null&&Qg(l)===null){u.child=v;break}l=v.sibling,v.sibling=p,p=v,v=l}B1(u,!0,p,null,x);break;case"together":B1(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function Po(l,u,p){if(l!==null&&(u.dependencies=l.dependencies),Oa|=u.lanes,(p&u.childLanes)===0)if(l!==null){if(Df(l,u,p,!1),(p&u.childLanes)===0)return null}else return null;if(l!==null&&u.child!==l.child)throw Error(r(153));if(u.child!==null){for(l=u.child,p=Ao(l,l.pendingProps),u.child=p,p.return=u;l.sibling!==null;)l=l.sibling,p=p.sibling=Ao(l,l.pendingProps),p.return=u;p.sibling=null}return u.child}function F1(l,u){return(l.lanes&u)!==0?!0:(l=l.dependencies,!!(l!==null&&Ng(l)))}function OG(l,u,p){switch(u.tag){case 3:Ue(u,u.stateNode.containerInfo),wa(u,vn,l.memoizedState.cache),Of();break;case 27:case 5:Kt(u);break;case 4:Ue(u,u.stateNode.containerInfo);break;case 10:wa(u,u.type,u.memoizedProps.value);break;case 13:var g=u.memoizedState;if(g!==null)return g.dehydrated!==null?(Aa(u),u.flags|=128,null):(p&u.child.childLanes)!==0?IO(l,u,p):(Aa(u),l=Po(l,u,p),l!==null?l.sibling:null);Aa(u);break;case 19:var v=(l.flags&128)!==0;if(g=(p&u.childLanes)!==0,g||(Df(l,u,p,!1),g=(p&u.childLanes)!==0),v){if(g)return NO(l,u,p);u.flags|=128}if(v=u.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),L(wn,wn.current),g)break;return null;case 22:case 23:return u.lanes=0,RO(l,u,p);case 24:wa(u,vn,l.memoizedState.cache)}return Po(l,u,p)}function $O(l,u,p){if(l!==null)if(l.memoizedProps!==u.pendingProps)Pn=!0;else{if(!F1(l,p)&&(u.flags&128)===0)return Pn=!1,OG(l,u,p);Pn=(l.flags&131072)!==0}else Pn=!1,bt&&(u.flags&1048576)!==0&&dM(u,Lg,u.index);switch(u.lanes=0,u.tag){case 16:e:{l=u.pendingProps;var g=u.elementType,v=g._init;if(g=v(g._payload),u.type=g,typeof g=="function")Yx(g)?(l=Ul(g,l),u.tag=1,u=PO(null,u,g,l,p)):(u.tag=0,u=D1(null,u,g,l,p));else{if(g!=null){if(v=g.$$typeof,v===P){u.tag=11,u=EO(null,u,g,l,p);break e}else if(v===D){u.tag=14,u=kO(null,u,g,l,p);break e}}throw u=X(g)||g,Error(r(306,u,""))}}return u;case 0:return D1(l,u,u.type,u.pendingProps,p);case 1:return g=u.type,v=Ul(g,u.pendingProps),PO(l,u,g,v,p);case 3:e:{if(Ue(u,u.stateNode.containerInfo),l===null)throw Error(r(387));g=u.pendingProps;var x=u.memoizedState;v=x.element,c1(l,u),Ff(u,g,null,p);var R=u.memoizedState;if(g=R.cache,wa(u,vn,g),g!==x.cache&&r1(u,[vn],p,!0),Bf(),g=R.element,x.isDehydrated)if(x={element:g,isDehydrated:!1,cache:R.cache},u.updateQueue.baseState=x,u.memoizedState=x,u.flags&256){u=DO(l,u,g,p);break e}else if(g!==v){v=Di(Error(r(424)),u),Pf(v),u=DO(l,u,g,p);break e}else{switch(l=u.stateNode.containerInfo,l.nodeType){case 9:l=l.body;break;default:l=l.nodeName==="HTML"?l.ownerDocument.body:l}for(Xt=ds(l.firstChild),Cr=u,bt=!0,$l=null,$s=!0,p=mO(u,null,g,p),u.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling}else{if(Of(),g===v){u=Po(l,u,p);break e}Fn(l,u,g,p)}u=u.child}return u;case 26:return t0(l,u),l===null?(p=zP(u.type,null,u.pendingProps,null))?u.memoizedState=p:bt||(p=u.type,l=u.pendingProps,g=g0(be.current).createElement(p),g[Mn]=u,g[or]=l,Vn(g,p,l),an(g),u.stateNode=g):u.memoizedState=zP(u.type,l.memoizedProps,u.pendingProps,l.memoizedState),null;case 27:return Kt(u),l===null&&bt&&(g=u.stateNode=jP(u.type,u.pendingProps,be.current),Cr=u,$s=!0,v=Xt,La(u.type)?(wS=v,Xt=ds(g.firstChild)):Xt=v),Fn(l,u,u.pendingProps.children,p),t0(l,u),l===null&&(u.flags|=4194304),u.child;case 5:return l===null&&bt&&((v=g=Xt)&&(g=sK(g,u.type,u.pendingProps,$s),g!==null?(u.stateNode=g,Cr=u,Xt=ds(g.firstChild),$s=!1,v=!0):v=!1),v||jl(u)),Kt(u),v=u.type,x=u.pendingProps,R=l!==null?l.memoizedProps:null,g=x.children,gS(v,x)?g=null:R!==null&&gS(v,R)&&(u.flags|=32),u.memoizedState!==null&&(v=m1(l,u,_G,null,null,p),ld._currentValue=v),t0(l,u),Fn(l,u,g,p),u.child;case 6:return l===null&&bt&&((l=p=Xt)&&(p=oK(p,u.pendingProps,$s),p!==null?(u.stateNode=p,Cr=u,Xt=null,l=!0):l=!1),l||jl(u)),null;case 13:return IO(l,u,p);case 4:return Ue(u,u.stateNode.containerInfo),g=u.pendingProps,l===null?u.child=mu(u,null,g,p):Fn(l,u,g,p),u.child;case 11:return EO(l,u,u.type,u.pendingProps,p);case 7:return Fn(l,u,u.pendingProps,p),u.child;case 8:return Fn(l,u,u.pendingProps.children,p),u.child;case 12:return Fn(l,u,u.pendingProps.children,p),u.child;case 10:return g=u.pendingProps,wa(u,u.type,g.value),Fn(l,u,g.children,p),u.child;case 9:return v=u.type._context,g=u.pendingProps.children,Fl(u),v=lr(v),g=g(v),u.flags|=1,Fn(l,u,g,p),u.child;case 14:return kO(l,u,u.type,u.pendingProps,p);case 15:return TO(l,u,u.type,u.pendingProps,p);case 19:return NO(l,u,p);case 31:return g=u.pendingProps,p=u.mode,g={mode:g.mode,children:g.children},l===null?(p=n0(g,p),p.ref=u.ref,u.child=p,p.return=u,u=p):(p=Ao(l.child,g),p.ref=u.ref,u.child=p,p.return=u,u=p),u;case 22:return RO(l,u,p);case 24:return Fl(u),g=lr(vn),l===null?(v=o1(),v===null&&(v=Dt,x=i1(),v.pooledCache=x,x.refCount++,x!==null&&(v.pooledCacheLanes|=p),v=x),u.memoizedState={parent:g,cache:v},l1(u),wa(u,vn,v)):((l.lanes&p)!==0&&(c1(l,u),Ff(u,null,null,p),Bf()),v=l.memoizedState,x=u.memoizedState,v.parent!==g?(v={parent:g,cache:g},u.memoizedState=v,u.lanes===0&&(u.memoizedState=u.updateQueue.baseState=v),wa(u,vn,g)):(g=x.cache,wa(u,vn,g),g!==v.cache&&r1(u,[vn],p,!0))),Fn(l,u,u.pendingProps.children,p),u.child;case 29:throw u.pendingProps}throw Error(r(156,u.tag))}function Do(l){l.flags|=4}function jO(l,u){if(u.type!=="stylesheet"||(u.state.loading&4)!==0)l.flags&=-16777217;else if(l.flags|=16777216,!qP(u)){if(u=$i.current,u!==null&&((ct&4194048)===ct?js!==null:(ct&62914560)!==ct&&(ct&536870912)===0||u!==js))throw $f=a1,xM;l.flags|=8192}}function r0(l,u){u!==null&&(l.flags|=4),l.flags&16384&&(u=l.tag!==22?zc():536870912,l.lanes|=u,vu|=u)}function Gf(l,u){if(!bt)switch(l.tailMode){case"hidden":u=l.tail;for(var p=null;u!==null;)u.alternate!==null&&(p=u),u=u.sibling;p===null?l.tail=null:p.sibling=null;break;case"collapsed":p=l.tail;for(var g=null;p!==null;)p.alternate!==null&&(g=p),p=p.sibling;g===null?u||l.tail===null?l.tail=null:l.tail.sibling=null:g.sibling=null}}function qt(l){var u=l.alternate!==null&&l.alternate.child===l.child,p=0,g=0;if(u)for(var v=l.child;v!==null;)p|=v.lanes|v.childLanes,g|=v.subtreeFlags&65011712,g|=v.flags&65011712,v.return=l,v=v.sibling;else for(v=l.child;v!==null;)p|=v.lanes|v.childLanes,g|=v.subtreeFlags,g|=v.flags,v.return=l,v=v.sibling;return l.subtreeFlags|=g,l.childLanes=p,u}function PG(l,u,p){var g=u.pendingProps;switch(Zx(u),u.tag){case 31:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qt(u),null;case 1:return qt(u),null;case 3:return p=u.stateNode,g=null,l!==null&&(g=l.memoizedState.cache),u.memoizedState.cache!==g&&(u.flags|=2048),Ro(vn),Pt(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(l===null||l.child===null)&&(Mf(u)?Do(u):l===null||l.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,gM())),qt(u),null;case 26:return p=u.memoizedState,l===null?(Do(u),p!==null?(qt(u),jO(u,p)):(qt(u),u.flags&=-16777217)):p?p!==l.memoizedState?(Do(u),qt(u),jO(u,p)):(qt(u),u.flags&=-16777217):(l.memoizedProps!==g&&Do(u),qt(u),u.flags&=-16777217),null;case 27:Yt(u),p=be.current;var v=u.type;if(l!==null&&u.stateNode!=null)l.memoizedProps!==g&&Do(u);else{if(!g){if(u.stateNode===null)throw Error(r(166));return qt(u),null}l=pe.current,Mf(u)?pM(u):(l=jP(v,g,p),u.stateNode=l,Do(u))}return qt(u),null;case 5:if(Yt(u),p=u.type,l!==null&&u.stateNode!=null)l.memoizedProps!==g&&Do(u);else{if(!g){if(u.stateNode===null)throw Error(r(166));return qt(u),null}if(l=pe.current,Mf(u))pM(u);else{switch(v=g0(be.current),l){case 1:l=v.createElementNS("http://www.w3.org/2000/svg",p);break;case 2:l=v.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;default:switch(p){case"svg":l=v.createElementNS("http://www.w3.org/2000/svg",p);break;case"math":l=v.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;case"script":l=v.createElement("div"),l.innerHTML="<script><\/script>",l=l.removeChild(l.firstChild);break;case"select":l=typeof g.is=="string"?v.createElement("select",{is:g.is}):v.createElement("select"),g.multiple?l.multiple=!0:g.size&&(l.size=g.size);break;default:l=typeof g.is=="string"?v.createElement(p,{is:g.is}):v.createElement(p)}}l[Mn]=u,l[or]=g;e:for(v=u.child;v!==null;){if(v.tag===5||v.tag===6)l.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===u)break e;for(;v.sibling===null;){if(v.return===null||v.return===u)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}u.stateNode=l;e:switch(Vn(l,p,g),p){case"button":case"input":case"select":case"textarea":l=!!g.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Do(u)}}return qt(u),u.flags&=-16777217,null;case 6:if(l&&u.stateNode!=null)l.memoizedProps!==g&&Do(u);else{if(typeof g!="string"&&u.stateNode===null)throw Error(r(166));if(l=be.current,Mf(u)){if(l=u.stateNode,p=u.memoizedProps,g=null,v=Cr,v!==null)switch(v.tag){case 27:case 5:g=v.memoizedProps}l[Mn]=u,l=!!(l.nodeValue===p||g!==null&&g.suppressHydrationWarning===!0||OP(l.nodeValue,p)),l||jl(u)}else l=g0(l).createTextNode(g),l[Mn]=u,u.stateNode=l}return qt(u),null;case 13:if(g=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(v=Mf(u),g!==null&&g.dehydrated!==null){if(l===null){if(!v)throw Error(r(318));if(v=u.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(r(317));v[Mn]=u}else Of(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;qt(u),v=!1}else v=gM(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=v),v=!0;if(!v)return u.flags&256?(Oo(u),u):(Oo(u),null)}if(Oo(u),(u.flags&128)!==0)return u.lanes=p,u;if(p=g!==null,l=l!==null&&l.memoizedState!==null,p){g=u.child,v=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(v=g.alternate.memoizedState.cachePool.pool);var x=null;g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(x=g.memoizedState.cachePool.pool),x!==v&&(g.flags|=2048)}return p!==l&&p&&(u.child.flags|=8192),r0(u,u.updateQueue),qt(u),null;case 4:return Pt(),l===null&&hS(u.stateNode.containerInfo),qt(u),null;case 10:return Ro(u.type),qt(u),null;case 19:if(ue(wn),v=u.memoizedState,v===null)return qt(u),null;if(g=(u.flags&128)!==0,x=v.rendering,x===null)if(g)Gf(v,!1);else{if(Jt!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(x=Qg(l),x!==null){for(u.flags|=128,Gf(v,!1),l=x.updateQueue,u.updateQueue=l,r0(u,l),u.subtreeFlags=0,l=p,p=u.child;p!==null;)fM(p,l),p=p.sibling;return L(wn,wn.current&1|2),u.child}l=l.sibling}v.tail!==null&&nr()>o0&&(u.flags|=128,g=!0,Gf(v,!1),u.lanes=4194304)}else{if(!g)if(l=Qg(x),l!==null){if(u.flags|=128,g=!0,l=l.updateQueue,u.updateQueue=l,r0(u,l),Gf(v,!0),v.tail===null&&v.tailMode==="hidden"&&!x.alternate&&!bt)return qt(u),null}else 2*nr()-v.renderingStartTime>o0&&p!==536870912&&(u.flags|=128,g=!0,Gf(v,!1),u.lanes=4194304);v.isBackwards?(x.sibling=u.child,u.child=x):(l=v.last,l!==null?l.sibling=x:u.child=x,v.last=x)}return v.tail!==null?(u=v.tail,v.rendering=u,v.tail=u.sibling,v.renderingStartTime=nr(),u.sibling=null,l=wn.current,L(wn,g?l&1|2:l&1),u):(qt(u),null);case 22:case 23:return Oo(u),d1(),g=u.memoizedState!==null,l!==null?l.memoizedState!==null!==g&&(u.flags|=8192):g&&(u.flags|=8192),g?(p&536870912)!==0&&(u.flags&128)===0&&(qt(u),u.subtreeFlags&6&&(u.flags|=8192)):qt(u),p=u.updateQueue,p!==null&&r0(u,p.retryQueue),p=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),g=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),g!==p&&(u.flags|=2048),l!==null&&ue(zl),null;case 24:return p=null,l!==null&&(p=l.memoizedState.cache),u.memoizedState.cache!==p&&(u.flags|=2048),Ro(vn),qt(u),null;case 25:return null;case 30:return null}throw Error(r(156,u.tag))}function DG(l,u){switch(Zx(u),u.tag){case 1:return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return Ro(vn),Pt(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 26:case 27:case 5:return Yt(u),null;case 13:if(Oo(u),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(r(340));Of()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return ue(wn),null;case 4:return Pt(),null;case 10:return Ro(u.type),null;case 22:case 23:return Oo(u),d1(),l!==null&&ue(zl),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 24:return Ro(vn),null;case 25:return null;default:return null}}function BO(l,u){switch(Zx(u),u.tag){case 3:Ro(vn),Pt();break;case 26:case 27:case 5:Yt(u);break;case 4:Pt();break;case 13:Oo(u);break;case 19:ue(wn);break;case 10:Ro(u.type);break;case 22:case 23:Oo(u),d1(),l!==null&&ue(zl);break;case 24:Ro(vn)}}function Kf(l,u){try{var p=u.updateQueue,g=p!==null?p.lastEffect:null;if(g!==null){var v=g.next;p=v;do{if((p.tag&l)===l){g=void 0;var x=p.create,R=p.inst;g=x(),R.destroy=g}p=p.next}while(p!==v)}}catch(I){Et(u,u.return,I)}}function ka(l,u,p){try{var g=u.updateQueue,v=g!==null?g.lastEffect:null;if(v!==null){var x=v.next;g=x;do{if((g.tag&l)===l){var R=g.inst,I=R.destroy;if(I!==void 0){R.destroy=void 0,v=u;var z=p,te=I;try{te()}catch(ae){Et(v,z,ae)}}}g=g.next}while(g!==x)}}catch(ae){Et(u,u.return,ae)}}function FO(l){var u=l.updateQueue;if(u!==null){var p=l.stateNode;try{kM(u,p)}catch(g){Et(l,l.return,g)}}}function zO(l,u,p){p.props=Ul(l.type,l.memoizedProps),p.state=l.memoizedState;try{p.componentWillUnmount()}catch(g){Et(l,u,g)}}function Yf(l,u){try{var p=l.ref;if(p!==null){switch(l.tag){case 26:case 27:case 5:var g=l.stateNode;break;case 30:g=l.stateNode;break;default:g=l.stateNode}typeof p=="function"?l.refCleanup=p(g):p.current=g}}catch(v){Et(l,u,v)}}function Bs(l,u){var p=l.ref,g=l.refCleanup;if(p!==null)if(typeof g=="function")try{g()}catch(v){Et(l,u,v)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof p=="function")try{p(null)}catch(v){Et(l,u,v)}else p.current=null}function VO(l){var u=l.type,p=l.memoizedProps,g=l.stateNode;try{e:switch(u){case"button":case"input":case"select":case"textarea":p.autoFocus&&g.focus();break e;case"img":p.src?g.src=p.src:p.srcSet&&(g.srcset=p.srcSet)}}catch(v){Et(l,l.return,v)}}function z1(l,u,p){try{var g=l.stateNode;eK(g,l.type,p,u),g[or]=u}catch(v){Et(l,l.return,v)}}function UO(l){return l.tag===5||l.tag===3||l.tag===26||l.tag===27&&La(l.type)||l.tag===4}function V1(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||UO(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.tag===27&&La(l.type)||l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function U1(l,u,p){var g=l.tag;if(g===5||g===6)l=l.stateNode,u?(p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p).insertBefore(l,u):(u=p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p,u.appendChild(l),p=p._reactRootContainer,p!=null||u.onclick!==null||(u.onclick=m0));else if(g!==4&&(g===27&&La(l.type)&&(p=l.stateNode,u=null),l=l.child,l!==null))for(U1(l,u,p),l=l.sibling;l!==null;)U1(l,u,p),l=l.sibling}function i0(l,u,p){var g=l.tag;if(g===5||g===6)l=l.stateNode,u?p.insertBefore(l,u):p.appendChild(l);else if(g!==4&&(g===27&&La(l.type)&&(p=l.stateNode),l=l.child,l!==null))for(i0(l,u,p),l=l.sibling;l!==null;)i0(l,u,p),l=l.sibling}function HO(l){var u=l.stateNode,p=l.memoizedProps;try{for(var g=l.type,v=u.attributes;v.length;)u.removeAttributeNode(v[0]);Vn(u,g,p),u[Mn]=l,u[or]=p}catch(x){Et(l,l.return,x)}}var Io=!1,nn=!1,H1=!1,WO=typeof WeakSet=="function"?WeakSet:Set,Dn=null;function IG(l,u){if(l=l.containerInfo,pS=S0,l=nM(l),Vx(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var g=p.getSelection&&p.getSelection();if(g&&g.rangeCount!==0){p=g.anchorNode;var v=g.anchorOffset,x=g.focusNode;g=g.focusOffset;try{p.nodeType,x.nodeType}catch{p=null;break e}var R=0,I=-1,z=-1,te=0,ae=0,he=l,re=null;t:for(;;){for(var ie;he!==p||v!==0&&he.nodeType!==3||(I=R+v),he!==x||g!==0&&he.nodeType!==3||(z=R+g),he.nodeType===3&&(R+=he.nodeValue.length),(ie=he.firstChild)!==null;)re=he,he=ie;for(;;){if(he===l)break t;if(re===p&&++te===v&&(I=R),re===x&&++ae===g&&(z=R),(ie=he.nextSibling)!==null)break;he=re,re=he.parentNode}he=ie}p=I===-1||z===-1?null:{start:I,end:z}}else p=null}p=p||{start:0,end:0}}else p=null;for(mS={focusedElem:l,selectionRange:p},S0=!1,Dn=u;Dn!==null;)if(u=Dn,l=u.child,(u.subtreeFlags&1024)!==0&&l!==null)l.return=u,Dn=l;else for(;Dn!==null;){switch(u=Dn,x=u.alternate,l=u.flags,u.tag){case 0:break;case 11:case 15:break;case 1:if((l&1024)!==0&&x!==null){l=void 0,p=u,v=x.memoizedProps,x=x.memoizedState,g=p.stateNode;try{var We=Ul(p.type,v,p.elementType===p.type);l=g.getSnapshotBeforeUpdate(We,x),g.__reactInternalSnapshotBeforeUpdate=l}catch(Fe){Et(p,p.return,Fe)}}break;case 3:if((l&1024)!==0){if(l=u.stateNode.containerInfo,p=l.nodeType,p===9)bS(l);else if(p===1)switch(l.nodeName){case"HEAD":case"HTML":case"BODY":bS(l);break;default:l.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((l&1024)!==0)throw Error(r(163))}if(l=u.sibling,l!==null){l.return=u.return,Dn=l;break}Dn=u.return}}function qO(l,u,p){var g=p.flags;switch(p.tag){case 0:case 11:case 15:Ta(l,p),g&4&&Kf(5,p);break;case 1:if(Ta(l,p),g&4)if(l=p.stateNode,u===null)try{l.componentDidMount()}catch(R){Et(p,p.return,R)}else{var v=Ul(p.type,u.memoizedProps);u=u.memoizedState;try{l.componentDidUpdate(v,u,l.__reactInternalSnapshotBeforeUpdate)}catch(R){Et(p,p.return,R)}}g&64&&FO(p),g&512&&Yf(p,p.return);break;case 3:if(Ta(l,p),g&64&&(l=p.updateQueue,l!==null)){if(u=null,p.child!==null)switch(p.child.tag){case 27:case 5:u=p.child.stateNode;break;case 1:u=p.child.stateNode}try{kM(l,u)}catch(R){Et(p,p.return,R)}}break;case 27:u===null&&g&4&&HO(p);case 26:case 5:Ta(l,p),u===null&&g&4&&VO(p),g&512&&Yf(p,p.return);break;case 12:Ta(l,p);break;case 13:Ta(l,p),g&4&&YO(l,p),g&64&&(l=p.memoizedState,l!==null&&(l=l.dehydrated,l!==null&&(p=UG.bind(null,p),aK(l,p))));break;case 22:if(g=p.memoizedState!==null||Io,!g){u=u!==null&&u.memoizedState!==null||nn,v=Io;var x=nn;Io=g,(nn=u)&&!x?Ra(l,p,(p.subtreeFlags&8772)!==0):Ta(l,p),Io=v,nn=x}break;case 30:break;default:Ta(l,p)}}function GO(l){var u=l.alternate;u!==null&&(l.alternate=null,GO(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&df(u)),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}var Ft=null,zr=!1;function Lo(l,u,p){for(p=p.child;p!==null;)KO(l,u,p),p=p.sibling}function KO(l,u,p){if(ge&&typeof ge.onCommitFiberUnmount=="function")try{ge.onCommitFiberUnmount(oe,p)}catch{}switch(p.tag){case 26:nn||Bs(p,u),Lo(l,u,p),p.memoizedState?p.memoizedState.count--:p.stateNode&&(p=p.stateNode,p.parentNode.removeChild(p));break;case 27:nn||Bs(p,u);var g=Ft,v=zr;La(p.type)&&(Ft=p.stateNode,zr=!1),Lo(l,u,p),id(p.stateNode),Ft=g,zr=v;break;case 5:nn||Bs(p,u);case 6:if(g=Ft,v=zr,Ft=null,Lo(l,u,p),Ft=g,zr=v,Ft!==null)if(zr)try{(Ft.nodeType===9?Ft.body:Ft.nodeName==="HTML"?Ft.ownerDocument.body:Ft).removeChild(p.stateNode)}catch(x){Et(p,u,x)}else try{Ft.removeChild(p.stateNode)}catch(x){Et(p,u,x)}break;case 18:Ft!==null&&(zr?(l=Ft,NP(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,p.stateNode),fd(l)):NP(Ft,p.stateNode));break;case 4:g=Ft,v=zr,Ft=p.stateNode.containerInfo,zr=!0,Lo(l,u,p),Ft=g,zr=v;break;case 0:case 11:case 14:case 15:nn||ka(2,p,u),nn||ka(4,p,u),Lo(l,u,p);break;case 1:nn||(Bs(p,u),g=p.stateNode,typeof g.componentWillUnmount=="function"&&zO(p,u,g)),Lo(l,u,p);break;case 21:Lo(l,u,p);break;case 22:nn=(g=nn)||p.memoizedState!==null,Lo(l,u,p),nn=g;break;default:Lo(l,u,p)}}function YO(l,u){if(u.memoizedState===null&&(l=u.alternate,l!==null&&(l=l.memoizedState,l!==null&&(l=l.dehydrated,l!==null))))try{fd(l)}catch(p){Et(u,u.return,p)}}function LG(l){switch(l.tag){case 13:case 19:var u=l.stateNode;return u===null&&(u=l.stateNode=new WO),u;case 22:return l=l.stateNode,u=l._retryCache,u===null&&(u=l._retryCache=new WO),u;default:throw Error(r(435,l.tag))}}function W1(l,u){var p=LG(l);u.forEach(function(g){var v=HG.bind(null,l,g);p.has(g)||(p.add(g),g.then(v,v))})}function li(l,u){var p=u.deletions;if(p!==null)for(var g=0;g<p.length;g++){var v=p[g],x=l,R=u,I=R;e:for(;I!==null;){switch(I.tag){case 27:if(La(I.type)){Ft=I.stateNode,zr=!1;break e}break;case 5:Ft=I.stateNode,zr=!1;break e;case 3:case 4:Ft=I.stateNode.containerInfo,zr=!0;break e}I=I.return}if(Ft===null)throw Error(r(160));KO(x,R,v),Ft=null,zr=!1,x=v.alternate,x!==null&&(x.return=null),v.return=null}if(u.subtreeFlags&13878)for(u=u.child;u!==null;)XO(u,l),u=u.sibling}var fs=null;function XO(l,u){var p=l.alternate,g=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:li(u,l),ci(l),g&4&&(ka(3,l,l.return),Kf(3,l),ka(5,l,l.return));break;case 1:li(u,l),ci(l),g&512&&(nn||p===null||Bs(p,p.return)),g&64&&Io&&(l=l.updateQueue,l!==null&&(g=l.callbacks,g!==null&&(p=l.shared.hiddenCallbacks,l.shared.hiddenCallbacks=p===null?g:p.concat(g))));break;case 26:var v=fs;if(li(u,l),ci(l),g&512&&(nn||p===null||Bs(p,p.return)),g&4){var x=p!==null?p.memoizedState:null;if(g=l.memoizedState,p===null)if(g===null)if(l.stateNode===null){e:{g=l.type,p=l.memoizedProps,v=v.ownerDocument||v;t:switch(g){case"title":x=v.getElementsByTagName("title")[0],(!x||x[Ml]||x[Mn]||x.namespaceURI==="http://www.w3.org/2000/svg"||x.hasAttribute("itemprop"))&&(x=v.createElement(g),v.head.insertBefore(x,v.querySelector("head > title"))),Vn(x,g,p),x[Mn]=l,an(x),g=x;break e;case"link":var R=HP("link","href",v).get(g+(p.href||""));if(R){for(var I=0;I<R.length;I++)if(x=R[I],x.getAttribute("href")===(p.href==null||p.href===""?null:p.href)&&x.getAttribute("rel")===(p.rel==null?null:p.rel)&&x.getAttribute("title")===(p.title==null?null:p.title)&&x.getAttribute("crossorigin")===(p.crossOrigin==null?null:p.crossOrigin)){R.splice(I,1);break t}}x=v.createElement(g),Vn(x,g,p),v.head.appendChild(x);break;case"meta":if(R=HP("meta","content",v).get(g+(p.content||""))){for(I=0;I<R.length;I++)if(x=R[I],x.getAttribute("content")===(p.content==null?null:""+p.content)&&x.getAttribute("name")===(p.name==null?null:p.name)&&x.getAttribute("property")===(p.property==null?null:p.property)&&x.getAttribute("http-equiv")===(p.httpEquiv==null?null:p.httpEquiv)&&x.getAttribute("charset")===(p.charSet==null?null:p.charSet)){R.splice(I,1);break t}}x=v.createElement(g),Vn(x,g,p),v.head.appendChild(x);break;default:throw Error(r(468,g))}x[Mn]=l,an(x),g=x}l.stateNode=g}else WP(v,l.type,l.stateNode);else l.stateNode=UP(v,g,l.memoizedProps);else x!==g?(x===null?p.stateNode!==null&&(p=p.stateNode,p.parentNode.removeChild(p)):x.count--,g===null?WP(v,l.type,l.stateNode):UP(v,g,l.memoizedProps)):g===null&&l.stateNode!==null&&z1(l,l.memoizedProps,p.memoizedProps)}break;case 27:li(u,l),ci(l),g&512&&(nn||p===null||Bs(p,p.return)),p!==null&&g&4&&z1(l,l.memoizedProps,p.memoizedProps);break;case 5:if(li(u,l),ci(l),g&512&&(nn||p===null||Bs(p,p.return)),l.flags&32){v=l.stateNode;try{ii(v,"")}catch(ie){Et(l,l.return,ie)}}g&4&&l.stateNode!=null&&(v=l.memoizedProps,z1(l,v,p!==null?p.memoizedProps:v)),g&1024&&(H1=!0);break;case 6:if(li(u,l),ci(l),g&4){if(l.stateNode===null)throw Error(r(162));g=l.memoizedProps,p=l.stateNode;try{p.nodeValue=g}catch(ie){Et(l,l.return,ie)}}break;case 3:if(v0=null,v=fs,fs=y0(u.containerInfo),li(u,l),fs=v,ci(l),g&4&&p!==null&&p.memoizedState.isDehydrated)try{fd(u.containerInfo)}catch(ie){Et(l,l.return,ie)}H1&&(H1=!1,JO(l));break;case 4:g=fs,fs=y0(l.stateNode.containerInfo),li(u,l),ci(l),fs=g;break;case 12:li(u,l),ci(l);break;case 13:li(u,l),ci(l),l.child.flags&8192&&l.memoizedState!==null!=(p!==null&&p.memoizedState!==null)&&(J1=nr()),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,W1(l,g)));break;case 22:v=l.memoizedState!==null;var z=p!==null&&p.memoizedState!==null,te=Io,ae=nn;if(Io=te||v,nn=ae||z,li(u,l),nn=ae,Io=te,ci(l),g&8192)e:for(u=l.stateNode,u._visibility=v?u._visibility&-2:u._visibility|1,v&&(p===null||z||Io||nn||Hl(l)),p=null,u=l;;){if(u.tag===5||u.tag===26){if(p===null){z=p=u;try{if(x=z.stateNode,v)R=x.style,typeof R.setProperty=="function"?R.setProperty("display","none","important"):R.display="none";else{I=z.stateNode;var he=z.memoizedProps.style,re=he!=null&&he.hasOwnProperty("display")?he.display:null;I.style.display=re==null||typeof re=="boolean"?"":(""+re).trim()}}catch(ie){Et(z,z.return,ie)}}}else if(u.tag===6){if(p===null){z=u;try{z.stateNode.nodeValue=v?"":z.memoizedProps}catch(ie){Et(z,z.return,ie)}}}else if((u.tag!==22&&u.tag!==23||u.memoizedState===null||u===l)&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break e;for(;u.sibling===null;){if(u.return===null||u.return===l)break e;p===u&&(p=null),u=u.return}p===u&&(p=null),u.sibling.return=u.return,u=u.sibling}g&4&&(g=l.updateQueue,g!==null&&(p=g.retryQueue,p!==null&&(g.retryQueue=null,W1(l,p))));break;case 19:li(u,l),ci(l),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,W1(l,g)));break;case 30:break;case 21:break;default:li(u,l),ci(l)}}function ci(l){var u=l.flags;if(u&2){try{for(var p,g=l.return;g!==null;){if(UO(g)){p=g;break}g=g.return}if(p==null)throw Error(r(160));switch(p.tag){case 27:var v=p.stateNode,x=V1(l);i0(l,x,v);break;case 5:var R=p.stateNode;p.flags&32&&(ii(R,""),p.flags&=-33);var I=V1(l);i0(l,I,R);break;case 3:case 4:var z=p.stateNode.containerInfo,te=V1(l);U1(l,te,z);break;default:throw Error(r(161))}}catch(ae){Et(l,l.return,ae)}l.flags&=-3}u&4096&&(l.flags&=-4097)}function JO(l){if(l.subtreeFlags&1024)for(l=l.child;l!==null;){var u=l;JO(u),u.tag===5&&u.flags&1024&&u.stateNode.reset(),l=l.sibling}}function Ta(l,u){if(u.subtreeFlags&8772)for(u=u.child;u!==null;)qO(l,u.alternate,u),u=u.sibling}function Hl(l){for(l=l.child;l!==null;){var u=l;switch(u.tag){case 0:case 11:case 14:case 15:ka(4,u,u.return),Hl(u);break;case 1:Bs(u,u.return);var p=u.stateNode;typeof p.componentWillUnmount=="function"&&zO(u,u.return,p),Hl(u);break;case 27:id(u.stateNode);case 26:case 5:Bs(u,u.return),Hl(u);break;case 22:u.memoizedState===null&&Hl(u);break;case 30:Hl(u);break;default:Hl(u)}l=l.sibling}}function Ra(l,u,p){for(p=p&&(u.subtreeFlags&8772)!==0,u=u.child;u!==null;){var g=u.alternate,v=l,x=u,R=x.flags;switch(x.tag){case 0:case 11:case 15:Ra(v,x,p),Kf(4,x);break;case 1:if(Ra(v,x,p),g=x,v=g.stateNode,typeof v.componentDidMount=="function")try{v.componentDidMount()}catch(te){Et(g,g.return,te)}if(g=x,v=g.updateQueue,v!==null){var I=g.stateNode;try{var z=v.shared.hiddenCallbacks;if(z!==null)for(v.shared.hiddenCallbacks=null,v=0;v<z.length;v++)EM(z[v],I)}catch(te){Et(g,g.return,te)}}p&&R&64&&FO(x),Yf(x,x.return);break;case 27:HO(x);case 26:case 5:Ra(v,x,p),p&&g===null&&R&4&&VO(x),Yf(x,x.return);break;case 12:Ra(v,x,p);break;case 13:Ra(v,x,p),p&&R&4&&YO(v,x);break;case 22:x.memoizedState===null&&Ra(v,x,p),Yf(x,x.return);break;case 30:break;default:Ra(v,x,p)}u=u.sibling}}function q1(l,u){var p=null;l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),l=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(l=u.memoizedState.cachePool.pool),l!==p&&(l!=null&&l.refCount++,p!=null&&If(p))}function G1(l,u){l=null,u.alternate!==null&&(l=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==l&&(u.refCount++,l!=null&&If(l))}function Fs(l,u,p,g){if(u.subtreeFlags&10256)for(u=u.child;u!==null;)QO(l,u,p,g),u=u.sibling}function QO(l,u,p,g){var v=u.flags;switch(u.tag){case 0:case 11:case 15:Fs(l,u,p,g),v&2048&&Kf(9,u);break;case 1:Fs(l,u,p,g);break;case 3:Fs(l,u,p,g),v&2048&&(l=null,u.alternate!==null&&(l=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==l&&(u.refCount++,l!=null&&If(l)));break;case 12:if(v&2048){Fs(l,u,p,g),l=u.stateNode;try{var x=u.memoizedProps,R=x.id,I=x.onPostCommit;typeof I=="function"&&I(R,u.alternate===null?"mount":"update",l.passiveEffectDuration,-0)}catch(z){Et(u,u.return,z)}}else Fs(l,u,p,g);break;case 13:Fs(l,u,p,g);break;case 23:break;case 22:x=u.stateNode,R=u.alternate,u.memoizedState!==null?x._visibility&2?Fs(l,u,p,g):Xf(l,u):x._visibility&2?Fs(l,u,p,g):(x._visibility|=2,gu(l,u,p,g,(u.subtreeFlags&10256)!==0)),v&2048&&q1(R,u);break;case 24:Fs(l,u,p,g),v&2048&&G1(u.alternate,u);break;default:Fs(l,u,p,g)}}function gu(l,u,p,g,v){for(v=v&&(u.subtreeFlags&10256)!==0,u=u.child;u!==null;){var x=l,R=u,I=p,z=g,te=R.flags;switch(R.tag){case 0:case 11:case 15:gu(x,R,I,z,v),Kf(8,R);break;case 23:break;case 22:var ae=R.stateNode;R.memoizedState!==null?ae._visibility&2?gu(x,R,I,z,v):Xf(x,R):(ae._visibility|=2,gu(x,R,I,z,v)),v&&te&2048&&q1(R.alternate,R);break;case 24:gu(x,R,I,z,v),v&&te&2048&&G1(R.alternate,R);break;default:gu(x,R,I,z,v)}u=u.sibling}}function Xf(l,u){if(u.subtreeFlags&10256)for(u=u.child;u!==null;){var p=l,g=u,v=g.flags;switch(g.tag){case 22:Xf(p,g),v&2048&&q1(g.alternate,g);break;case 24:Xf(p,g),v&2048&&G1(g.alternate,g);break;default:Xf(p,g)}u=u.sibling}}var Jf=8192;function yu(l){if(l.subtreeFlags&Jf)for(l=l.child;l!==null;)ZO(l),l=l.sibling}function ZO(l){switch(l.tag){case 26:yu(l),l.flags&Jf&&l.memoizedState!==null&&wK(fs,l.memoizedState,l.memoizedProps);break;case 5:yu(l);break;case 3:case 4:var u=fs;fs=y0(l.stateNode.containerInfo),yu(l),fs=u;break;case 22:l.memoizedState===null&&(u=l.alternate,u!==null&&u.memoizedState!==null?(u=Jf,Jf=16777216,yu(l),Jf=u):yu(l));break;default:yu(l)}}function eP(l){var u=l.alternate;if(u!==null&&(l=u.child,l!==null)){u.child=null;do u=l.sibling,l.sibling=null,l=u;while(l!==null)}}function Qf(l){var u=l.deletions;if((l.flags&16)!==0){if(u!==null)for(var p=0;p<u.length;p++){var g=u[p];Dn=g,nP(g,l)}eP(l)}if(l.subtreeFlags&10256)for(l=l.child;l!==null;)tP(l),l=l.sibling}function tP(l){switch(l.tag){case 0:case 11:case 15:Qf(l),l.flags&2048&&ka(9,l,l.return);break;case 3:Qf(l);break;case 12:Qf(l);break;case 22:var u=l.stateNode;l.memoizedState!==null&&u._visibility&2&&(l.return===null||l.return.tag!==13)?(u._visibility&=-3,s0(l)):Qf(l);break;default:Qf(l)}}function s0(l){var u=l.deletions;if((l.flags&16)!==0){if(u!==null)for(var p=0;p<u.length;p++){var g=u[p];Dn=g,nP(g,l)}eP(l)}for(l=l.child;l!==null;){switch(u=l,u.tag){case 0:case 11:case 15:ka(8,u,u.return),s0(u);break;case 22:p=u.stateNode,p._visibility&2&&(p._visibility&=-3,s0(u));break;default:s0(u)}l=l.sibling}}function nP(l,u){for(;Dn!==null;){var p=Dn;switch(p.tag){case 0:case 11:case 15:ka(8,p,u);break;case 23:case 22:if(p.memoizedState!==null&&p.memoizedState.cachePool!==null){var g=p.memoizedState.cachePool.pool;g!=null&&g.refCount++}break;case 24:If(p.memoizedState.cache)}if(g=p.child,g!==null)g.return=p,Dn=g;else e:for(p=l;Dn!==null;){g=Dn;var v=g.sibling,x=g.return;if(GO(g),g===p){Dn=null;break e}if(v!==null){v.return=x,Dn=v;break e}Dn=x}}}var NG={getCacheForType:function(l){var u=lr(vn),p=u.data.get(l);return p===void 0&&(p=l(),u.data.set(l,p)),p}},$G=typeof WeakMap=="function"?WeakMap:Map,wt=0,Dt=null,ot=null,ct=0,xt=0,ui=null,Ma=!1,bu=!1,K1=!1,No=0,Jt=0,Oa=0,Wl=0,Y1=0,ji=0,vu=0,Zf=null,Vr=null,X1=!1,J1=0,o0=1/0,a0=null,Pa=null,zn=0,Da=null,wu=null,xu=0,Q1=0,Z1=null,rP=null,ed=0,eS=null;function hi(){if((wt&2)!==0&&ct!==0)return ct&-ct;if(V.T!==null){var l=lu;return l!==0?l:aS()}return hf()}function iP(){ji===0&&(ji=(ct&536870912)===0||bt?Fc():536870912);var l=$i.current;return l!==null&&(l.flags|=32),ji}function fi(l,u,p){(l===Dt&&(xt===2||xt===9)||l.cancelPendingCommit!==null)&&(Su(l,0),Ia(l,ct,ji,!1)),as(l,p),((wt&2)===0||l!==Dt)&&(l===Dt&&((wt&2)===0&&(Wl|=p),Jt===4&&Ia(l,ct,ji,!1)),zs(l))}function sP(l,u,p){if((wt&6)!==0)throw Error(r(327));var g=!p&&(u&124)===0&&(u&l.expiredLanes)===0||ir(l,u),v=g?FG(l,u):rS(l,u,!0),x=g;do{if(v===0){bu&&!g&&Ia(l,u,0,!1);break}else{if(p=l.current.alternate,x&&!jG(p)){v=rS(l,u,!1),x=!1;continue}if(v===2){if(x=u,l.errorRecoveryDisabledLanes&x)var R=0;else R=l.pendingLanes&-536870913,R=R!==0?R:R&536870912?536870912:0;if(R!==0){u=R;e:{var I=l;v=Zf;var z=I.current.memoizedState.isDehydrated;if(z&&(Su(I,R).flags|=256),R=rS(I,R,!1),R!==2){if(K1&&!z){I.errorRecoveryDisabledLanes|=x,Wl|=x,v=4;break e}x=Vr,Vr=v,x!==null&&(Vr===null?Vr=x:Vr.push.apply(Vr,x))}v=R}if(x=!1,v!==2)continue}}if(v===1){Su(l,0),Ia(l,u,0,!0);break}e:{switch(g=l,x=v,x){case 0:case 1:throw Error(r(345));case 4:if((u&4194048)!==u)break;case 6:Ia(g,u,ji,!Ma);break e;case 2:Vr=null;break;case 3:case 5:break;default:throw Error(r(329))}if((u&62914560)===u&&(v=J1+300-nr(),10<v)){if(Ia(g,u,ji,!Ma),on(g,0,!0)!==0)break e;g.timeoutHandle=IP(oP.bind(null,g,p,Vr,a0,X1,u,ji,Wl,vu,Ma,x,2,-0,0),v);break e}oP(g,p,Vr,a0,X1,u,ji,Wl,vu,Ma,x,0,-0,0)}}break}while(!0);zs(l)}function oP(l,u,p,g,v,x,R,I,z,te,ae,he,re,ie){if(l.timeoutHandle=-1,he=u.subtreeFlags,(he&8192||(he&16785408)===16785408)&&(ad={stylesheets:null,count:0,unsuspend:vK},ZO(u),he=xK(),he!==null)){l.cancelPendingCommit=he(dP.bind(null,l,u,x,p,g,v,R,I,z,ae,1,re,ie)),Ia(l,x,R,!te);return}dP(l,u,x,p,g,v,R,I,z)}function jG(l){for(var u=l;;){var p=u.tag;if((p===0||p===11||p===15)&&u.flags&16384&&(p=u.updateQueue,p!==null&&(p=p.stores,p!==null)))for(var g=0;g<p.length;g++){var v=p[g],x=v.getSnapshot;v=v.value;try{if(!oi(x(),v))return!1}catch{return!1}}if(p=u.child,u.subtreeFlags&16384&&p!==null)p.return=u,u=p;else{if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function Ia(l,u,p,g){u&=~Y1,u&=~Wl,l.suspendedLanes|=u,l.pingedLanes&=~u,g&&(l.warmLanes|=u),g=l.expirationTimes;for(var v=u;0<v;){var x=31-$e(v),R=1<<x;g[x]=-1,v&=~R}p!==0&&hg(l,p,u)}function l0(){return(wt&6)===0?(td(0),!1):!0}function tS(){if(ot!==null){if(xt===0)var l=ot.return;else l=ot,To=Bl=null,b1(l),pu=null,Wf=0,l=ot;for(;l!==null;)BO(l.alternate,l),l=l.return;ot=null}}function Su(l,u){var p=l.timeoutHandle;p!==-1&&(l.timeoutHandle=-1,nK(p)),p=l.cancelPendingCommit,p!==null&&(l.cancelPendingCommit=null,p()),tS(),Dt=l,ot=p=Ao(l.current,null),ct=u,xt=0,ui=null,Ma=!1,bu=ir(l,u),K1=!1,vu=ji=Y1=Wl=Oa=Jt=0,Vr=Zf=null,X1=!1,(u&8)!==0&&(u|=u&32);var g=l.entangledLanes;if(g!==0)for(l=l.entanglements,g&=u;0<g;){var v=31-$e(g),x=1<<v;u|=l[v],g&=~x}return No=u,Mg(),p}function aP(l,u){et=null,V.H=Yg,u===Nf||u===Bg?(u=CM(),xt=3):u===xM?(u=CM(),xt=4):xt=u===AO?8:u!==null&&typeof u=="object"&&typeof u.then=="function"?6:1,ui=u,ot===null&&(Jt=1,e0(l,Di(u,l.current)))}function lP(){var l=V.H;return V.H=Yg,l===null?Yg:l}function cP(){var l=V.A;return V.A=NG,l}function nS(){Jt=4,Ma||(ct&4194048)!==ct&&$i.current!==null||(bu=!0),(Oa&134217727)===0&&(Wl&134217727)===0||Dt===null||Ia(Dt,ct,ji,!1)}function rS(l,u,p){var g=wt;wt|=2;var v=lP(),x=cP();(Dt!==l||ct!==u)&&(a0=null,Su(l,u)),u=!1;var R=Jt;e:do try{if(xt!==0&&ot!==null){var I=ot,z=ui;switch(xt){case 8:tS(),R=6;break e;case 3:case 2:case 9:case 6:$i.current===null&&(u=!0);var te=xt;if(xt=0,ui=null,_u(l,I,z,te),p&&bu){R=0;break e}break;default:te=xt,xt=0,ui=null,_u(l,I,z,te)}}BG(),R=Jt;break}catch(ae){aP(l,ae)}while(!0);return u&&l.shellSuspendCounter++,To=Bl=null,wt=g,V.H=v,V.A=x,ot===null&&(Dt=null,ct=0,Mg()),R}function BG(){for(;ot!==null;)uP(ot)}function FG(l,u){var p=wt;wt|=2;var g=lP(),v=cP();Dt!==l||ct!==u?(a0=null,o0=nr()+500,Su(l,u)):bu=ir(l,u);e:do try{if(xt!==0&&ot!==null){u=ot;var x=ui;t:switch(xt){case 1:xt=0,ui=null,_u(l,u,x,1);break;case 2:case 9:if(SM(x)){xt=0,ui=null,hP(u);break}u=function(){xt!==2&&xt!==9||Dt!==l||(xt=7),zs(l)},x.then(u,u);break e;case 3:xt=7;break e;case 4:xt=5;break e;case 7:SM(x)?(xt=0,ui=null,hP(u)):(xt=0,ui=null,_u(l,u,x,7));break;case 5:var R=null;switch(ot.tag){case 26:R=ot.memoizedState;case 5:case 27:var I=ot;if(!R||qP(R)){xt=0,ui=null;var z=I.sibling;if(z!==null)ot=z;else{var te=I.return;te!==null?(ot=te,c0(te)):ot=null}break t}}xt=0,ui=null,_u(l,u,x,5);break;case 6:xt=0,ui=null,_u(l,u,x,6);break;case 8:tS(),Jt=6;break e;default:throw Error(r(462))}}zG();break}catch(ae){aP(l,ae)}while(!0);return To=Bl=null,V.H=g,V.A=v,wt=p,ot!==null?0:(Dt=null,ct=0,Mg(),Jt)}function zG(){for(;ot!==null&&!_o();)uP(ot)}function uP(l){var u=$O(l.alternate,l,No);l.memoizedProps=l.pendingProps,u===null?c0(l):ot=u}function hP(l){var u=l,p=u.alternate;switch(u.tag){case 15:case 0:u=OO(p,u,u.pendingProps,u.type,void 0,ct);break;case 11:u=OO(p,u,u.pendingProps,u.type.render,u.ref,ct);break;case 5:b1(u);default:BO(p,u),u=ot=fM(u,No),u=$O(p,u,No)}l.memoizedProps=l.pendingProps,u===null?c0(l):ot=u}function _u(l,u,p,g){To=Bl=null,b1(u),pu=null,Wf=0;var v=u.return;try{if(MG(l,v,u,p,ct)){Jt=1,e0(l,Di(p,l.current)),ot=null;return}}catch(x){if(v!==null)throw ot=v,x;Jt=1,e0(l,Di(p,l.current)),ot=null;return}u.flags&32768?(bt||g===1?l=!0:bu||(ct&536870912)!==0?l=!1:(Ma=l=!0,(g===2||g===9||g===3||g===6)&&(g=$i.current,g!==null&&g.tag===13&&(g.flags|=16384))),fP(u,l)):c0(u)}function c0(l){var u=l;do{if((u.flags&32768)!==0){fP(u,Ma);return}l=u.return;var p=PG(u.alternate,u,No);if(p!==null){ot=p;return}if(u=u.sibling,u!==null){ot=u;return}ot=u=l}while(u!==null);Jt===0&&(Jt=5)}function fP(l,u){do{var p=DG(l.alternate,l);if(p!==null){p.flags&=32767,ot=p;return}if(p=l.return,p!==null&&(p.flags|=32768,p.subtreeFlags=0,p.deletions=null),!u&&(l=l.sibling,l!==null)){ot=l;return}ot=l=p}while(l!==null);Jt=6,ot=null}function dP(l,u,p,g,v,x,R,I,z){l.cancelPendingCommit=null;do u0();while(zn!==0);if((wt&6)!==0)throw Error(r(327));if(u!==null){if(u===l.current)throw Error(r(177));if(x=u.lanes|u.childLanes,x|=Gx,Mx(l,p,x,R,I,z),l===Dt&&(ot=Dt=null,ct=0),wu=u,Da=l,xu=p,Q1=x,Z1=v,rP=g,(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?(l.callbackNode=null,l.callbackPriority=0,WG(Ds,function(){return bP(),null})):(l.callbackNode=null,l.callbackPriority=0),g=(u.flags&13878)!==0,(u.subtreeFlags&13878)!==0||g){g=V.T,V.T=null,v=G.p,G.p=2,R=wt,wt|=4;try{IG(l,u,p)}finally{wt=R,G.p=v,V.T=g}}zn=1,pP(),mP(),gP()}}function pP(){if(zn===1){zn=0;var l=Da,u=wu,p=(u.flags&13878)!==0;if((u.subtreeFlags&13878)!==0||p){p=V.T,V.T=null;var g=G.p;G.p=2;var v=wt;wt|=4;try{XO(u,l);var x=mS,R=nM(l.containerInfo),I=x.focusedElem,z=x.selectionRange;if(R!==I&&I&&I.ownerDocument&&tM(I.ownerDocument.documentElement,I)){if(z!==null&&Vx(I)){var te=z.start,ae=z.end;if(ae===void 0&&(ae=te),"selectionStart"in I)I.selectionStart=te,I.selectionEnd=Math.min(ae,I.value.length);else{var he=I.ownerDocument||document,re=he&&he.defaultView||window;if(re.getSelection){var ie=re.getSelection(),We=I.textContent.length,Fe=Math.min(z.start,We),Ct=z.end===void 0?Fe:Math.min(z.end,We);!ie.extend&&Fe>Ct&&(R=Ct,Ct=Fe,Fe=R);var Y=eM(I,Fe),W=eM(I,Ct);if(Y&&W&&(ie.rangeCount!==1||ie.anchorNode!==Y.node||ie.anchorOffset!==Y.offset||ie.focusNode!==W.node||ie.focusOffset!==W.offset)){var J=he.createRange();J.setStart(Y.node,Y.offset),ie.removeAllRanges(),Fe>Ct?(ie.addRange(J),ie.extend(W.node,W.offset)):(J.setEnd(W.node,W.offset),ie.addRange(J))}}}}for(he=[],ie=I;ie=ie.parentNode;)ie.nodeType===1&&he.push({element:ie,left:ie.scrollLeft,top:ie.scrollTop});for(typeof I.focus=="function"&&I.focus(),I=0;I<he.length;I++){var ce=he[I];ce.element.scrollLeft=ce.left,ce.element.scrollTop=ce.top}}S0=!!pS,mS=pS=null}finally{wt=v,G.p=g,V.T=p}}l.current=u,zn=2}}function mP(){if(zn===2){zn=0;var l=Da,u=wu,p=(u.flags&8772)!==0;if((u.subtreeFlags&8772)!==0||p){p=V.T,V.T=null;var g=G.p;G.p=2;var v=wt;wt|=4;try{qO(l,u.alternate,u)}finally{wt=v,G.p=g,V.T=p}}zn=3}}function gP(){if(zn===4||zn===3){zn=0,ss();var l=Da,u=wu,p=xu,g=rP;(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?zn=5:(zn=0,wu=Da=null,yP(l,l.pendingLanes));var v=l.pendingLanes;if(v===0&&(Pa=null),uf(p),u=u.stateNode,ge&&typeof ge.onCommitFiberRoot=="function")try{ge.onCommitFiberRoot(oe,u,void 0,(u.current.flags&128)===128)}catch{}if(g!==null){u=V.T,v=G.p,G.p=2,V.T=null;try{for(var x=l.onRecoverableError,R=0;R<g.length;R++){var I=g[R];x(I.value,{componentStack:I.stack})}}finally{V.T=u,G.p=v}}(xu&3)!==0&&u0(),zs(l),v=l.pendingLanes,(p&4194090)!==0&&(v&42)!==0?l===eS?ed++:(ed=0,eS=l):ed=0,td(0)}}function yP(l,u){(l.pooledCacheLanes&=u)===0&&(u=l.pooledCache,u!=null&&(l.pooledCache=null,If(u)))}function u0(l){return pP(),mP(),gP(),bP()}function bP(){if(zn!==5)return!1;var l=Da,u=Q1;Q1=0;var p=uf(xu),g=V.T,v=G.p;try{G.p=32>p?32:p,V.T=null,p=Z1,Z1=null;var x=Da,R=xu;if(zn=0,wu=Da=null,xu=0,(wt&6)!==0)throw Error(r(331));var I=wt;if(wt|=4,tP(x.current),QO(x,x.current,R,p),wt=I,td(0,!1),ge&&typeof ge.onPostCommitFiberRoot=="function")try{ge.onPostCommitFiberRoot(oe,x)}catch{}return!0}finally{G.p=v,V.T=g,yP(l,u)}}function vP(l,u,p){u=Di(p,u),u=P1(l.stateNode,u,2),l=_a(l,u,2),l!==null&&(as(l,2),zs(l))}function Et(l,u,p){if(l.tag===3)vP(l,l,p);else for(;u!==null;){if(u.tag===3){vP(u,l,p);break}else if(u.tag===1){var g=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Pa===null||!Pa.has(g))){l=Di(p,l),p=_O(2),g=_a(u,p,2),g!==null&&(CO(p,g,u,l),as(g,2),zs(g));break}}u=u.return}}function iS(l,u,p){var g=l.pingCache;if(g===null){g=l.pingCache=new $G;var v=new Set;g.set(u,v)}else v=g.get(u),v===void 0&&(v=new Set,g.set(u,v));v.has(p)||(K1=!0,v.add(p),l=VG.bind(null,l,u,p),u.then(l,l))}function VG(l,u,p){var g=l.pingCache;g!==null&&g.delete(u),l.pingedLanes|=l.suspendedLanes&p,l.warmLanes&=~p,Dt===l&&(ct&p)===p&&(Jt===4||Jt===3&&(ct&62914560)===ct&&300>nr()-J1?(wt&2)===0&&Su(l,0):Y1|=p,vu===ct&&(vu=0)),zs(l)}function wP(l,u){u===0&&(u=zc()),l=iu(l,u),l!==null&&(as(l,u),zs(l))}function UG(l){var u=l.memoizedState,p=0;u!==null&&(p=u.retryLane),wP(l,p)}function HG(l,u){var p=0;switch(l.tag){case 13:var g=l.stateNode,v=l.memoizedState;v!==null&&(p=v.retryLane);break;case 19:g=l.stateNode;break;case 22:g=l.stateNode._retryCache;break;default:throw Error(r(314))}g!==null&&g.delete(u),wP(l,p)}function WG(l,u){return tr(l,u)}var h0=null,Cu=null,sS=!1,f0=!1,oS=!1,ql=0;function zs(l){l!==Cu&&l.next===null&&(Cu===null?h0=Cu=l:Cu=Cu.next=l),f0=!0,sS||(sS=!0,GG())}function td(l,u){if(!oS&&f0){oS=!0;do for(var p=!1,g=h0;g!==null;){if(l!==0){var v=g.pendingLanes;if(v===0)var x=0;else{var R=g.suspendedLanes,I=g.pingedLanes;x=(1<<31-$e(42|l)+1)-1,x&=v&~(R&~I),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(p=!0,CP(g,x))}else x=ct,x=on(g,g===Dt?x:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(x&3)===0||ir(g,x)||(p=!0,CP(g,x));g=g.next}while(p);oS=!1}}function qG(){xP()}function xP(){f0=sS=!1;var l=0;ql!==0&&(tK()&&(l=ql),ql=0);for(var u=nr(),p=null,g=h0;g!==null;){var v=g.next,x=SP(g,u);x===0?(g.next=null,p===null?h0=v:p.next=v,v===null&&(Cu=p)):(p=g,(l!==0||(x&3)!==0)&&(f0=!0)),g=v}td(l)}function SP(l,u){for(var p=l.suspendedLanes,g=l.pingedLanes,v=l.expirationTimes,x=l.pendingLanes&-62914561;0<x;){var R=31-$e(x),I=1<<R,z=v[R];z===-1?((I&p)===0||(I&g)!==0)&&(v[R]=Bn(I,u)):z<=u&&(l.expiredLanes|=I),x&=~I}if(u=Dt,p=ct,p=on(l,l===u?p:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),g=l.callbackNode,p===0||l===u&&(xt===2||xt===9)||l.cancelPendingCommit!==null)return g!==null&&g!==null&&ti(g),l.callbackNode=null,l.callbackPriority=0;if((p&3)===0||ir(l,p)){if(u=p&-p,u===l.callbackPriority)return u;switch(g!==null&&ti(g),uf(p)){case 2:case 8:p=Ps;break;case 32:p=Ds;break;case 268435456:p=Tl;break;default:p=Ds}return g=_P.bind(null,l),p=tr(p,g),l.callbackPriority=u,l.callbackNode=p,u}return g!==null&&g!==null&&ti(g),l.callbackPriority=2,l.callbackNode=null,2}function _P(l,u){if(zn!==0&&zn!==5)return l.callbackNode=null,l.callbackPriority=0,null;var p=l.callbackNode;if(u0()&&l.callbackNode!==p)return null;var g=ct;return g=on(l,l===Dt?g:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),g===0?null:(sP(l,g,u),SP(l,nr()),l.callbackNode!=null&&l.callbackNode===p?_P.bind(null,l):null)}function CP(l,u){if(u0())return null;sP(l,u,!0)}function GG(){rK(function(){(wt&6)!==0?tr(kl,qG):xP()})}function aS(){return ql===0&&(ql=Fc()),ql}function AP(l){return l==null||typeof l=="symbol"||typeof l=="boolean"?null:typeof l=="function"?l:Gc(""+l)}function EP(l,u){var p=u.ownerDocument.createElement("input");return p.name=u.name,p.value=u.value,l.id&&p.setAttribute("form",l.id),u.parentNode.insertBefore(p,u),l=new FormData(l),p.parentNode.removeChild(p),l}function KG(l,u,p,g,v){if(u==="submit"&&p&&p.stateNode===v){var x=AP((v[or]||null).action),R=g.submitter;R&&(u=(u=R[or]||null)?AP(u.formAction):R.getAttribute("formAction"),u!==null&&(x=u,R=null));var I=new Oe("action","action",null,g,v);l.push({event:I,listeners:[{instance:null,listener:function(){if(g.defaultPrevented){if(ql!==0){var z=R?EP(v,R):new FormData(v);k1(p,{pending:!0,data:z,method:v.method,action:x},null,z)}}else typeof x=="function"&&(I.preventDefault(),z=R?EP(v,R):new FormData(v),k1(p,{pending:!0,data:z,method:v.method,action:x},x,z))},currentTarget:v}]})}}for(var lS=0;lS<qx.length;lS++){var cS=qx[lS],YG=cS.toLowerCase(),XG=cS[0].toUpperCase()+cS.slice(1);hs(YG,"on"+XG)}hs(sM,"onAnimationEnd"),hs(oM,"onAnimationIteration"),hs(aM,"onAnimationStart"),hs("dblclick","onDoubleClick"),hs("focusin","onFocus"),hs("focusout","onBlur"),hs(dG,"onTransitionRun"),hs(pG,"onTransitionStart"),hs(mG,"onTransitionCancel"),hs(lM,"onTransitionEnd"),ri("onMouseEnter",["mouseout","mouseover"]),ri("onMouseLeave",["mouseout","mouseover"]),ri("onPointerEnter",["pointerout","pointerover"]),ri("onPointerLeave",["pointerout","pointerover"]),Co("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Co("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Co("onBeforeInput",["compositionend","keypress","textInput","paste"]),Co("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Co("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Co("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var nd="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),JG=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(nd));function kP(l,u){u=(u&4)!==0;for(var p=0;p<l.length;p++){var g=l[p],v=g.event;g=g.listeners;e:{var x=void 0;if(u)for(var R=g.length-1;0<=R;R--){var I=g[R],z=I.instance,te=I.currentTarget;if(I=I.listener,z!==x&&v.isPropagationStopped())break e;x=I,v.currentTarget=te;try{x(v)}catch(ae){Zg(ae)}v.currentTarget=null,x=z}else for(R=0;R<g.length;R++){if(I=g[R],z=I.instance,te=I.currentTarget,I=I.listener,z!==x&&v.isPropagationStopped())break e;x=I,v.currentTarget=te;try{x(v)}catch(ae){Zg(ae)}v.currentTarget=null,x=z}}}}function at(l,u){var p=u[ff];p===void 0&&(p=u[ff]=new Set);var g=l+"__bubble";p.has(g)||(TP(u,l,2,!1),p.add(g))}function uS(l,u,p){var g=0;u&&(g|=4),TP(p,l,g,u)}var d0="_reactListening"+Math.random().toString(36).slice(2);function hS(l){if(!l[d0]){l[d0]=!0,mg.forEach(function(p){p!=="selectionchange"&&(JG.has(p)||uS(p,!1,l),uS(p,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[d0]||(u[d0]=!0,uS("selectionchange",!1,u))}}function TP(l,u,p,g){switch(QP(u)){case 2:var v=CK;break;case 8:v=AK;break;default:v=AS}p=v.bind(null,u,p,l),v=void 0,!Sf||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(v=!0),g?v!==void 0?l.addEventListener(u,p,{capture:!0,passive:v}):l.addEventListener(u,p,!0):v!==void 0?l.addEventListener(u,p,{passive:v}):l.addEventListener(u,p,!1)}function fS(l,u,p,g,v){var x=g;if((u&1)===0&&(u&2)===0&&g!==null)e:for(;;){if(g===null)return;var R=g.tag;if(R===3||R===4){var I=g.stateNode.containerInfo;if(I===v)break;if(R===4)for(R=g.return;R!==null;){var z=R.tag;if((z===3||z===4)&&R.stateNode.containerInfo===v)return;R=R.return}for(;I!==null;){if(R=ca(I),R===null)return;if(z=R.tag,z===5||z===6||z===26||z===27){g=x=R;continue e}I=I.parentNode}}g=g.return}Yc(function(){var te=x,ae=Kc(p),he=[];e:{var re=cM.get(l);if(re!==void 0){var ie=Oe,We=l;switch(l){case"keypress":if(Qc(p)===0)break e;case"keydown":case"keyup":ie=Wq;break;case"focusin":We="focus",ie=va;break;case"focusout":We="blur",ie=va;break;case"beforeblur":case"afterblur":ie=va;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ie=_f;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ie=Tg;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ie=Kq;break;case sM:case oM:case aM:ie=Nq;break;case lM:ie=Xq;break;case"scroll":case"scrollend":ie=ar;break;case"wheel":ie=Qq;break;case"copy":case"cut":case"paste":ie=jq;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ie=FR;break;case"toggle":case"beforetoggle":ie=eG}var Fe=(u&4)!==0,Ct=!Fe&&(l==="scroll"||l==="scrollend"),Y=Fe?re!==null?re+"Capture":null:re;Fe=[];for(var W=te,J;W!==null;){var ce=W;if(J=ce.stateNode,ce=ce.tag,ce!==5&&ce!==26&&ce!==27||J===null||Y===null||(ce=ma(W,Y),ce!=null&&Fe.push(rd(W,ce,J))),Ct)break;W=W.return}0<Fe.length&&(re=new ie(re,We,null,p,ae),he.push({event:re,listeners:Fe}))}}if((u&7)===0){e:{if(re=l==="mouseover"||l==="pointerover",ie=l==="mouseout"||l==="pointerout",re&&p!==vf&&(We=p.relatedTarget||p.fromElement)&&(ca(We)||We[la]))break e;if((ie||re)&&(re=ae.window===ae?ae:(re=ae.ownerDocument)?re.defaultView||re.parentWindow:window,ie?(We=p.relatedTarget||p.toElement,ie=te,We=We?ca(We):null,We!==null&&(Ct=s(We),Fe=We.tag,We!==Ct||Fe!==5&&Fe!==27&&Fe!==6)&&(We=null)):(ie=null,We=te),ie!==We)){if(Fe=_f,ce="onMouseLeave",Y="onMouseEnter",W="mouse",(l==="pointerout"||l==="pointerover")&&(Fe=FR,ce="onPointerLeave",Y="onPointerEnter",W="pointer"),Ct=ie==null?re:Oi(ie),J=We==null?re:Oi(We),re=new Fe(ce,W+"leave",ie,p,ae),re.target=Ct,re.relatedTarget=J,ce=null,ca(ae)===te&&(Fe=new Fe(Y,W+"enter",We,p,ae),Fe.target=J,Fe.relatedTarget=Ct,ce=Fe),Ct=ce,ie&&We)t:{for(Fe=ie,Y=We,W=0,J=Fe;J;J=Au(J))W++;for(J=0,ce=Y;ce;ce=Au(ce))J++;for(;0<W-J;)Fe=Au(Fe),W--;for(;0<J-W;)Y=Au(Y),J--;for(;W--;){if(Fe===Y||Y!==null&&Fe===Y.alternate)break t;Fe=Au(Fe),Y=Au(Y)}Fe=null}else Fe=null;ie!==null&&RP(he,re,ie,Fe,!1),We!==null&&Ct!==null&&RP(he,Ct,We,Fe,!0)}}e:{if(re=te?Oi(te):window,ie=re.nodeName&&re.nodeName.toLowerCase(),ie==="select"||ie==="input"&&re.type==="file")var Te=KR;else if(qR(re))if(YR)Te=uG;else{Te=lG;var rt=aG}else ie=re.nodeName,!ie||ie.toLowerCase()!=="input"||re.type!=="checkbox"&&re.type!=="radio"?te&&bf(te.elementType)&&(Te=KR):Te=cG;if(Te&&(Te=Te(l,te))){GR(he,Te,p,ae);break e}rt&&rt(l,re,te),l==="focusout"&&te&&re.type==="number"&&te.memoizedProps.value!=null&&qc(re,"number",re.value)}switch(rt=te?Oi(te):window,l){case"focusin":(qR(rt)||rt.contentEditable==="true")&&(tu=rt,Ux=te,Rf=null);break;case"focusout":Rf=Ux=tu=null;break;case"mousedown":Hx=!0;break;case"contextmenu":case"mouseup":case"dragend":Hx=!1,rM(he,p,ae);break;case"selectionchange":if(fG)break;case"keydown":case"keyup":rM(he,p,ae)}var Pe;if(Bx)e:{switch(l){case"compositionstart":var Ve="onCompositionStart";break e;case"compositionend":Ve="onCompositionEnd";break e;case"compositionupdate":Ve="onCompositionUpdate";break e}Ve=void 0}else eu?HR(l,p)&&(Ve="onCompositionEnd"):l==="keydown"&&p.keyCode===229&&(Ve="onCompositionStart");Ve&&(zR&&p.locale!=="ko"&&(eu||Ve!=="onCompositionStart"?Ve==="onCompositionEnd"&&eu&&(Pe=Jc()):(Ns=ae,ya="value"in Ns?Ns.value:Ns.textContent,eu=!0)),rt=p0(te,Ve),0<rt.length&&(Ve=new BR(Ve,l,null,p,ae),he.push({event:Ve,listeners:rt}),Pe?Ve.data=Pe:(Pe=WR(p),Pe!==null&&(Ve.data=Pe)))),(Pe=nG?rG(l,p):iG(l,p))&&(Ve=p0(te,"onBeforeInput"),0<Ve.length&&(rt=new BR("onBeforeInput","beforeinput",null,p,ae),he.push({event:rt,listeners:Ve}),rt.data=Pe)),KG(he,l,te,p,ae)}kP(he,u)})}function rd(l,u,p){return{instance:l,listener:u,currentTarget:p}}function p0(l,u){for(var p=u+"Capture",g=[];l!==null;){var v=l,x=v.stateNode;if(v=v.tag,v!==5&&v!==26&&v!==27||x===null||(v=ma(l,p),v!=null&&g.unshift(rd(l,v,x)),v=ma(l,u),v!=null&&g.push(rd(l,v,x))),l.tag===3)return g;l=l.return}return[]}function Au(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5&&l.tag!==27);return l||null}function RP(l,u,p,g,v){for(var x=u._reactName,R=[];p!==null&&p!==g;){var I=p,z=I.alternate,te=I.stateNode;if(I=I.tag,z!==null&&z===g)break;I!==5&&I!==26&&I!==27||te===null||(z=te,v?(te=ma(p,x),te!=null&&R.unshift(rd(p,te,z))):v||(te=ma(p,x),te!=null&&R.push(rd(p,te,z)))),p=p.return}R.length!==0&&l.push({event:u,listeners:R})}var QG=/\r\n?/g,ZG=/\u0000|\uFFFD/g;function MP(l){return(typeof l=="string"?l:""+l).replace(QG,`
`).replace(ZG,"")}function OP(l,u){return u=MP(u),MP(l)===u}function m0(){}function _t(l,u,p,g,v,x){switch(p){case"children":typeof g=="string"?u==="body"||u==="textarea"&&g===""||ii(l,g):(typeof g=="number"||typeof g=="bigint")&&u!=="body"&&ii(l,""+g);break;case"className":Uc(l,"class",g);break;case"tabIndex":Uc(l,"tabindex",g);break;case"dir":case"role":case"viewBox":case"width":case"height":Uc(l,p,g);break;case"style":Eg(l,g,x);break;case"data":if(u!=="object"){Uc(l,"data",g);break}case"src":case"href":if(g===""&&(u!=="a"||p!=="href")){l.removeAttribute(p);break}if(g==null||typeof g=="function"||typeof g=="symbol"||typeof g=="boolean"){l.removeAttribute(p);break}g=Gc(""+g),l.setAttribute(p,g);break;case"action":case"formAction":if(typeof g=="function"){l.setAttribute(p,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof x=="function"&&(p==="formAction"?(u!=="input"&&_t(l,u,"name",v.name,v,null),_t(l,u,"formEncType",v.formEncType,v,null),_t(l,u,"formMethod",v.formMethod,v,null),_t(l,u,"formTarget",v.formTarget,v,null)):(_t(l,u,"encType",v.encType,v,null),_t(l,u,"method",v.method,v,null),_t(l,u,"target",v.target,v,null)));if(g==null||typeof g=="symbol"||typeof g=="boolean"){l.removeAttribute(p);break}g=Gc(""+g),l.setAttribute(p,g);break;case"onClick":g!=null&&(l.onclick=m0);break;case"onScroll":g!=null&&at("scroll",l);break;case"onScrollEnd":g!=null&&at("scrollend",l);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(r(61));if(p=g.__html,p!=null){if(v.children!=null)throw Error(r(60));l.innerHTML=p}}break;case"multiple":l.multiple=g&&typeof g!="function"&&typeof g!="symbol";break;case"muted":l.muted=g&&typeof g!="function"&&typeof g!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(g==null||typeof g=="function"||typeof g=="boolean"||typeof g=="symbol"){l.removeAttribute("xlink:href");break}p=Gc(""+g),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",p);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":g!=null&&typeof g!="function"&&typeof g!="symbol"?l.setAttribute(p,""+g):l.removeAttribute(p);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":g&&typeof g!="function"&&typeof g!="symbol"?l.setAttribute(p,""):l.removeAttribute(p);break;case"capture":case"download":g===!0?l.setAttribute(p,""):g!==!1&&g!=null&&typeof g!="function"&&typeof g!="symbol"?l.setAttribute(p,g):l.removeAttribute(p);break;case"cols":case"rows":case"size":case"span":g!=null&&typeof g!="function"&&typeof g!="symbol"&&!isNaN(g)&&1<=g?l.setAttribute(p,g):l.removeAttribute(p);break;case"rowSpan":case"start":g==null||typeof g=="function"||typeof g=="symbol"||isNaN(g)?l.removeAttribute(p):l.setAttribute(p,g);break;case"popover":at("beforetoggle",l),at("toggle",l),Vc(l,"popover",g);break;case"xlinkActuate":Pi(l,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":Pi(l,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":Pi(l,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":Pi(l,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":Pi(l,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":Pi(l,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":Pi(l,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":Pi(l,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":Pi(l,"http://www.w3.org/XML/1998/namespace","xml:space",g);break;case"is":Vc(l,"is",g);break;case"innerText":case"textContent":break;default:(!(2<p.length)||p[0]!=="o"&&p[0]!=="O"||p[1]!=="n"&&p[1]!=="N")&&(p=Nx.get(p)||p,Vc(l,p,g))}}function dS(l,u,p,g,v,x){switch(p){case"style":Eg(l,g,x);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(r(61));if(p=g.__html,p!=null){if(v.children!=null)throw Error(r(60));l.innerHTML=p}}break;case"children":typeof g=="string"?ii(l,g):(typeof g=="number"||typeof g=="bigint")&&ii(l,""+g);break;case"onScroll":g!=null&&at("scroll",l);break;case"onScrollEnd":g!=null&&at("scrollend",l);break;case"onClick":g!=null&&(l.onclick=m0);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!gg.hasOwnProperty(p))e:{if(p[0]==="o"&&p[1]==="n"&&(v=p.endsWith("Capture"),u=p.slice(2,v?p.length-7:void 0),x=l[or]||null,x=x!=null?x[p]:null,typeof x=="function"&&l.removeEventListener(u,x,v),typeof g=="function")){typeof x!="function"&&x!==null&&(p in l?l[p]=null:l.hasAttribute(p)&&l.removeAttribute(p)),l.addEventListener(u,g,v);break e}p in l?l[p]=g:g===!0?l.setAttribute(p,""):Vc(l,p,g)}}}function Vn(l,u,p){switch(u){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":at("error",l),at("load",l);var g=!1,v=!1,x;for(x in p)if(p.hasOwnProperty(x)){var R=p[x];if(R!=null)switch(x){case"src":g=!0;break;case"srcSet":v=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,u));default:_t(l,u,x,R,p,null)}}v&&_t(l,u,"srcSet",p.srcSet,p,null),g&&_t(l,u,"src",p.src,p,null);return;case"input":at("invalid",l);var I=x=R=v=null,z=null,te=null;for(g in p)if(p.hasOwnProperty(g)){var ae=p[g];if(ae!=null)switch(g){case"name":v=ae;break;case"type":R=ae;break;case"checked":z=ae;break;case"defaultChecked":te=ae;break;case"value":x=ae;break;case"defaultValue":I=ae;break;case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(r(137,u));break;default:_t(l,u,g,ae,p,null)}}_g(l,x,I,z,te,R,v,!1),Hc(l);return;case"select":at("invalid",l),g=R=x=null;for(v in p)if(p.hasOwnProperty(v)&&(I=p[v],I!=null))switch(v){case"value":x=I;break;case"defaultValue":R=I;break;case"multiple":g=I;default:_t(l,u,v,I,p,null)}u=x,p=R,l.multiple=!!g,u!=null?da(l,!!g,u,!1):p!=null&&da(l,!!g,p,!0);return;case"textarea":at("invalid",l),x=v=g=null;for(R in p)if(p.hasOwnProperty(R)&&(I=p[R],I!=null))switch(R){case"value":g=I;break;case"defaultValue":v=I;break;case"children":x=I;break;case"dangerouslySetInnerHTML":if(I!=null)throw Error(r(91));break;default:_t(l,u,R,I,p,null)}Ol(l,g,v,x),Hc(l);return;case"option":for(z in p)if(p.hasOwnProperty(z)&&(g=p[z],g!=null))switch(z){case"selected":l.selected=g&&typeof g!="function"&&typeof g!="symbol";break;default:_t(l,u,z,g,p,null)}return;case"dialog":at("beforetoggle",l),at("toggle",l),at("cancel",l),at("close",l);break;case"iframe":case"object":at("load",l);break;case"video":case"audio":for(g=0;g<nd.length;g++)at(nd[g],l);break;case"image":at("error",l),at("load",l);break;case"details":at("toggle",l);break;case"embed":case"source":case"link":at("error",l),at("load",l);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(te in p)if(p.hasOwnProperty(te)&&(g=p[te],g!=null))switch(te){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,u));default:_t(l,u,te,g,p,null)}return;default:if(bf(u)){for(ae in p)p.hasOwnProperty(ae)&&(g=p[ae],g!==void 0&&dS(l,u,ae,g,p,void 0));return}}for(I in p)p.hasOwnProperty(I)&&(g=p[I],g!=null&&_t(l,u,I,g,p,null))}function eK(l,u,p,g){switch(u){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var v=null,x=null,R=null,I=null,z=null,te=null,ae=null;for(ie in p){var he=p[ie];if(p.hasOwnProperty(ie)&&he!=null)switch(ie){case"checked":break;case"value":break;case"defaultValue":z=he;default:g.hasOwnProperty(ie)||_t(l,u,ie,null,g,he)}}for(var re in g){var ie=g[re];if(he=p[re],g.hasOwnProperty(re)&&(ie!=null||he!=null))switch(re){case"type":x=ie;break;case"name":v=ie;break;case"checked":te=ie;break;case"defaultChecked":ae=ie;break;case"value":R=ie;break;case"defaultValue":I=ie;break;case"children":case"dangerouslySetInnerHTML":if(ie!=null)throw Error(r(137,u));break;default:ie!==he&&_t(l,u,re,ie,g,he)}}yf(l,R,I,z,te,ae,x,v);return;case"select":ie=R=I=re=null;for(x in p)if(z=p[x],p.hasOwnProperty(x)&&z!=null)switch(x){case"value":break;case"multiple":ie=z;default:g.hasOwnProperty(x)||_t(l,u,x,null,g,z)}for(v in g)if(x=g[v],z=p[v],g.hasOwnProperty(v)&&(x!=null||z!=null))switch(v){case"value":re=x;break;case"defaultValue":I=x;break;case"multiple":R=x;default:x!==z&&_t(l,u,v,x,g,z)}u=I,p=R,g=ie,re!=null?da(l,!!p,re,!1):!!g!=!!p&&(u!=null?da(l,!!p,u,!0):da(l,!!p,p?[]:"",!1));return;case"textarea":ie=re=null;for(I in p)if(v=p[I],p.hasOwnProperty(I)&&v!=null&&!g.hasOwnProperty(I))switch(I){case"value":break;case"children":break;default:_t(l,u,I,null,g,v)}for(R in g)if(v=g[R],x=p[R],g.hasOwnProperty(R)&&(v!=null||x!=null))switch(R){case"value":re=v;break;case"defaultValue":ie=v;break;case"children":break;case"dangerouslySetInnerHTML":if(v!=null)throw Error(r(91));break;default:v!==x&&_t(l,u,R,v,g,x)}Cg(l,re,ie);return;case"option":for(var We in p)if(re=p[We],p.hasOwnProperty(We)&&re!=null&&!g.hasOwnProperty(We))switch(We){case"selected":l.selected=!1;break;default:_t(l,u,We,null,g,re)}for(z in g)if(re=g[z],ie=p[z],g.hasOwnProperty(z)&&re!==ie&&(re!=null||ie!=null))switch(z){case"selected":l.selected=re&&typeof re!="function"&&typeof re!="symbol";break;default:_t(l,u,z,re,g,ie)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Fe in p)re=p[Fe],p.hasOwnProperty(Fe)&&re!=null&&!g.hasOwnProperty(Fe)&&_t(l,u,Fe,null,g,re);for(te in g)if(re=g[te],ie=p[te],g.hasOwnProperty(te)&&re!==ie&&(re!=null||ie!=null))switch(te){case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(r(137,u));break;default:_t(l,u,te,re,g,ie)}return;default:if(bf(u)){for(var Ct in p)re=p[Ct],p.hasOwnProperty(Ct)&&re!==void 0&&!g.hasOwnProperty(Ct)&&dS(l,u,Ct,void 0,g,re);for(ae in g)re=g[ae],ie=p[ae],!g.hasOwnProperty(ae)||re===ie||re===void 0&&ie===void 0||dS(l,u,ae,re,g,ie);return}}for(var Y in p)re=p[Y],p.hasOwnProperty(Y)&&re!=null&&!g.hasOwnProperty(Y)&&_t(l,u,Y,null,g,re);for(he in g)re=g[he],ie=p[he],!g.hasOwnProperty(he)||re===ie||re==null&&ie==null||_t(l,u,he,re,g,ie)}var pS=null,mS=null;function g0(l){return l.nodeType===9?l:l.ownerDocument}function PP(l){switch(l){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function DP(l,u){if(l===0)switch(u){case"svg":return 1;case"math":return 2;default:return 0}return l===1&&u==="foreignObject"?0:l}function gS(l,u){return l==="textarea"||l==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.children=="bigint"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var yS=null;function tK(){var l=window.event;return l&&l.type==="popstate"?l===yS?!1:(yS=l,!0):(yS=null,!1)}var IP=typeof setTimeout=="function"?setTimeout:void 0,nK=typeof clearTimeout=="function"?clearTimeout:void 0,LP=typeof Promise=="function"?Promise:void 0,rK=typeof queueMicrotask=="function"?queueMicrotask:typeof LP<"u"?function(l){return LP.resolve(null).then(l).catch(iK)}:IP;function iK(l){setTimeout(function(){throw l})}function La(l){return l==="head"}function NP(l,u){var p=u,g=0,v=0;do{var x=p.nextSibling;if(l.removeChild(p),x&&x.nodeType===8)if(p=x.data,p==="/$"){if(0<g&&8>g){p=g;var R=l.ownerDocument;if(p&1&&id(R.documentElement),p&2&&id(R.body),p&4)for(p=R.head,id(p),R=p.firstChild;R;){var I=R.nextSibling,z=R.nodeName;R[Ml]||z==="SCRIPT"||z==="STYLE"||z==="LINK"&&R.rel.toLowerCase()==="stylesheet"||p.removeChild(R),R=I}}if(v===0){l.removeChild(x),fd(u);return}v--}else p==="$"||p==="$?"||p==="$!"?v++:g=p.charCodeAt(0)-48;else g=0;p=x}while(p);fd(u)}function bS(l){var u=l.firstChild;for(u&&u.nodeType===10&&(u=u.nextSibling);u;){var p=u;switch(u=u.nextSibling,p.nodeName){case"HTML":case"HEAD":case"BODY":bS(p),df(p);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(p.rel.toLowerCase()==="stylesheet")continue}l.removeChild(p)}}function sK(l,u,p,g){for(;l.nodeType===1;){var v=p;if(l.nodeName.toLowerCase()!==u.toLowerCase()){if(!g&&(l.nodeName!=="INPUT"||l.type!=="hidden"))break}else if(g){if(!l[Ml])switch(u){case"meta":if(!l.hasAttribute("itemprop"))break;return l;case"link":if(x=l.getAttribute("rel"),x==="stylesheet"&&l.hasAttribute("data-precedence"))break;if(x!==v.rel||l.getAttribute("href")!==(v.href==null||v.href===""?null:v.href)||l.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin)||l.getAttribute("title")!==(v.title==null?null:v.title))break;return l;case"style":if(l.hasAttribute("data-precedence"))break;return l;case"script":if(x=l.getAttribute("src"),(x!==(v.src==null?null:v.src)||l.getAttribute("type")!==(v.type==null?null:v.type)||l.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin))&&x&&l.hasAttribute("async")&&!l.hasAttribute("itemprop"))break;return l;default:return l}}else if(u==="input"&&l.type==="hidden"){var x=v.name==null?null:""+v.name;if(v.type==="hidden"&&l.getAttribute("name")===x)return l}else return l;if(l=ds(l.nextSibling),l===null)break}return null}function oK(l,u,p){if(u==="")return null;for(;l.nodeType!==3;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!p||(l=ds(l.nextSibling),l===null))return null;return l}function vS(l){return l.data==="$!"||l.data==="$?"&&l.ownerDocument.readyState==="complete"}function aK(l,u){var p=l.ownerDocument;if(l.data!=="$?"||p.readyState==="complete")u();else{var g=function(){u(),p.removeEventListener("DOMContentLoaded",g)};p.addEventListener("DOMContentLoaded",g),l._reactRetry=g}}function ds(l){for(;l!=null;l=l.nextSibling){var u=l.nodeType;if(u===1||u===3)break;if(u===8){if(u=l.data,u==="$"||u==="$!"||u==="$?"||u==="F!"||u==="F")break;if(u==="/$")return null}}return l}var wS=null;function $P(l){l=l.previousSibling;for(var u=0;l;){if(l.nodeType===8){var p=l.data;if(p==="$"||p==="$!"||p==="$?"){if(u===0)return l;u--}else p==="/$"&&u++}l=l.previousSibling}return null}function jP(l,u,p){switch(u=g0(p),l){case"html":if(l=u.documentElement,!l)throw Error(r(452));return l;case"head":if(l=u.head,!l)throw Error(r(453));return l;case"body":if(l=u.body,!l)throw Error(r(454));return l;default:throw Error(r(451))}}function id(l){for(var u=l.attributes;u.length;)l.removeAttributeNode(u[0]);df(l)}var Bi=new Map,BP=new Set;function y0(l){return typeof l.getRootNode=="function"?l.getRootNode():l.nodeType===9?l:l.ownerDocument}var $o=G.d;G.d={f:lK,r:cK,D:uK,C:hK,L:fK,m:dK,X:mK,S:pK,M:gK};function lK(){var l=$o.f(),u=l0();return l||u}function cK(l){var u=ua(l);u!==null&&u.tag===5&&u.type==="form"?sO(u):$o.r(l)}var Eu=typeof document>"u"?null:document;function FP(l,u,p){var g=Eu;if(g&&typeof u=="string"&&u){var v=jr(u);v='link[rel="'+l+'"][href="'+v+'"]',typeof p=="string"&&(v+='[crossorigin="'+p+'"]'),BP.has(v)||(BP.add(v),l={rel:l,crossOrigin:p,href:u},g.querySelector(v)===null&&(u=g.createElement("link"),Vn(u,"link",l),an(u),g.head.appendChild(u)))}}function uK(l){$o.D(l),FP("dns-prefetch",l,null)}function hK(l,u){$o.C(l,u),FP("preconnect",l,u)}function fK(l,u,p){$o.L(l,u,p);var g=Eu;if(g&&l&&u){var v='link[rel="preload"][as="'+jr(u)+'"]';u==="image"&&p&&p.imageSrcSet?(v+='[imagesrcset="'+jr(p.imageSrcSet)+'"]',typeof p.imageSizes=="string"&&(v+='[imagesizes="'+jr(p.imageSizes)+'"]')):v+='[href="'+jr(l)+'"]';var x=v;switch(u){case"style":x=ku(l);break;case"script":x=Tu(l)}Bi.has(x)||(l=f({rel:"preload",href:u==="image"&&p&&p.imageSrcSet?void 0:l,as:u},p),Bi.set(x,l),g.querySelector(v)!==null||u==="style"&&g.querySelector(sd(x))||u==="script"&&g.querySelector(od(x))||(u=g.createElement("link"),Vn(u,"link",l),an(u),g.head.appendChild(u)))}}function dK(l,u){$o.m(l,u);var p=Eu;if(p&&l){var g=u&&typeof u.as=="string"?u.as:"script",v='link[rel="modulepreload"][as="'+jr(g)+'"][href="'+jr(l)+'"]',x=v;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Tu(l)}if(!Bi.has(x)&&(l=f({rel:"modulepreload",href:l},u),Bi.set(x,l),p.querySelector(v)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(p.querySelector(od(x)))return}g=p.createElement("link"),Vn(g,"link",l),an(g),p.head.appendChild(g)}}}function pK(l,u,p){$o.S(l,u,p);var g=Eu;if(g&&l){var v=ha(g).hoistableStyles,x=ku(l);u=u||"default";var R=v.get(x);if(!R){var I={loading:0,preload:null};if(R=g.querySelector(sd(x)))I.loading=5;else{l=f({rel:"stylesheet",href:l,"data-precedence":u},p),(p=Bi.get(x))&&xS(l,p);var z=R=g.createElement("link");an(z),Vn(z,"link",l),z._p=new Promise(function(te,ae){z.onload=te,z.onerror=ae}),z.addEventListener("load",function(){I.loading|=1}),z.addEventListener("error",function(){I.loading|=2}),I.loading|=4,b0(R,u,g)}R={type:"stylesheet",instance:R,count:1,state:I},v.set(x,R)}}}function mK(l,u){$o.X(l,u);var p=Eu;if(p&&l){var g=ha(p).hoistableScripts,v=Tu(l),x=g.get(v);x||(x=p.querySelector(od(v)),x||(l=f({src:l,async:!0},u),(u=Bi.get(v))&&SS(l,u),x=p.createElement("script"),an(x),Vn(x,"link",l),p.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},g.set(v,x))}}function gK(l,u){$o.M(l,u);var p=Eu;if(p&&l){var g=ha(p).hoistableScripts,v=Tu(l),x=g.get(v);x||(x=p.querySelector(od(v)),x||(l=f({src:l,async:!0,type:"module"},u),(u=Bi.get(v))&&SS(l,u),x=p.createElement("script"),an(x),Vn(x,"link",l),p.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},g.set(v,x))}}function zP(l,u,p,g){var v=(v=be.current)?y0(v):null;if(!v)throw Error(r(446));switch(l){case"meta":case"title":return null;case"style":return typeof p.precedence=="string"&&typeof p.href=="string"?(u=ku(p.href),p=ha(v).hoistableStyles,g=p.get(u),g||(g={type:"style",instance:null,count:0,state:null},p.set(u,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(p.rel==="stylesheet"&&typeof p.href=="string"&&typeof p.precedence=="string"){l=ku(p.href);var x=ha(v).hoistableStyles,R=x.get(l);if(R||(v=v.ownerDocument||v,R={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(l,R),(x=v.querySelector(sd(l)))&&!x._p&&(R.instance=x,R.state.loading=5),Bi.has(l)||(p={rel:"preload",as:"style",href:p.href,crossOrigin:p.crossOrigin,integrity:p.integrity,media:p.media,hrefLang:p.hrefLang,referrerPolicy:p.referrerPolicy},Bi.set(l,p),x||yK(v,l,p,R.state))),u&&g===null)throw Error(r(528,""));return R}if(u&&g!==null)throw Error(r(529,""));return null;case"script":return u=p.async,p=p.src,typeof p=="string"&&u&&typeof u!="function"&&typeof u!="symbol"?(u=Tu(p),p=ha(v).hoistableScripts,g=p.get(u),g||(g={type:"script",instance:null,count:0,state:null},p.set(u,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,l))}}function ku(l){return'href="'+jr(l)+'"'}function sd(l){return'link[rel="stylesheet"]['+l+"]"}function VP(l){return f({},l,{"data-precedence":l.precedence,precedence:null})}function yK(l,u,p,g){l.querySelector('link[rel="preload"][as="style"]['+u+"]")?g.loading=1:(u=l.createElement("link"),g.preload=u,u.addEventListener("load",function(){return g.loading|=1}),u.addEventListener("error",function(){return g.loading|=2}),Vn(u,"link",p),an(u),l.head.appendChild(u))}function Tu(l){return'[src="'+jr(l)+'"]'}function od(l){return"script[async]"+l}function UP(l,u,p){if(u.count++,u.instance===null)switch(u.type){case"style":var g=l.querySelector('style[data-href~="'+jr(p.href)+'"]');if(g)return u.instance=g,an(g),g;var v=f({},p,{"data-href":p.href,"data-precedence":p.precedence,href:null,precedence:null});return g=(l.ownerDocument||l).createElement("style"),an(g),Vn(g,"style",v),b0(g,p.precedence,l),u.instance=g;case"stylesheet":v=ku(p.href);var x=l.querySelector(sd(v));if(x)return u.state.loading|=4,u.instance=x,an(x),x;g=VP(p),(v=Bi.get(v))&&xS(g,v),x=(l.ownerDocument||l).createElement("link"),an(x);var R=x;return R._p=new Promise(function(I,z){R.onload=I,R.onerror=z}),Vn(x,"link",g),u.state.loading|=4,b0(x,p.precedence,l),u.instance=x;case"script":return x=Tu(p.src),(v=l.querySelector(od(x)))?(u.instance=v,an(v),v):(g=p,(v=Bi.get(x))&&(g=f({},p),SS(g,v)),l=l.ownerDocument||l,v=l.createElement("script"),an(v),Vn(v,"link",g),l.head.appendChild(v),u.instance=v);case"void":return null;default:throw Error(r(443,u.type))}else u.type==="stylesheet"&&(u.state.loading&4)===0&&(g=u.instance,u.state.loading|=4,b0(g,p.precedence,l));return u.instance}function b0(l,u,p){for(var g=p.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),v=g.length?g[g.length-1]:null,x=v,R=0;R<g.length;R++){var I=g[R];if(I.dataset.precedence===u)x=I;else if(x!==v)break}x?x.parentNode.insertBefore(l,x.nextSibling):(u=p.nodeType===9?p.head:p,u.insertBefore(l,u.firstChild))}function xS(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.title==null&&(l.title=u.title)}function SS(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.integrity==null&&(l.integrity=u.integrity)}var v0=null;function HP(l,u,p){if(v0===null){var g=new Map,v=v0=new Map;v.set(p,g)}else v=v0,g=v.get(p),g||(g=new Map,v.set(p,g));if(g.has(l))return g;for(g.set(l,null),p=p.getElementsByTagName(l),v=0;v<p.length;v++){var x=p[v];if(!(x[Ml]||x[Mn]||l==="link"&&x.getAttribute("rel")==="stylesheet")&&x.namespaceURI!=="http://www.w3.org/2000/svg"){var R=x.getAttribute(u)||"";R=l+R;var I=g.get(R);I?I.push(x):g.set(R,[x])}}return g}function WP(l,u,p){l=l.ownerDocument||l,l.head.insertBefore(p,u==="title"?l.querySelector("head > title"):null)}function bK(l,u,p){if(p===1||u.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof u.precedence!="string"||typeof u.href!="string"||u.href==="")break;return!0;case"link":if(typeof u.rel!="string"||typeof u.href!="string"||u.href===""||u.onLoad||u.onError)break;switch(u.rel){case"stylesheet":return l=u.disabled,typeof u.precedence=="string"&&l==null;default:return!0}case"script":if(u.async&&typeof u.async!="function"&&typeof u.async!="symbol"&&!u.onLoad&&!u.onError&&u.src&&typeof u.src=="string")return!0}return!1}function qP(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}var ad=null;function vK(){}function wK(l,u,p){if(ad===null)throw Error(r(475));var g=ad;if(u.type==="stylesheet"&&(typeof p.media!="string"||matchMedia(p.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var v=ku(p.href),x=l.querySelector(sd(v));if(x){l=x._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(g.count++,g=w0.bind(g),l.then(g,g)),u.state.loading|=4,u.instance=x,an(x);return}x=l.ownerDocument||l,p=VP(p),(v=Bi.get(v))&&xS(p,v),x=x.createElement("link"),an(x);var R=x;R._p=new Promise(function(I,z){R.onload=I,R.onerror=z}),Vn(x,"link",p),u.instance=x}g.stylesheets===null&&(g.stylesheets=new Map),g.stylesheets.set(u,l),(l=u.state.preload)&&(u.state.loading&3)===0&&(g.count++,u=w0.bind(g),l.addEventListener("load",u),l.addEventListener("error",u))}}function xK(){if(ad===null)throw Error(r(475));var l=ad;return l.stylesheets&&l.count===0&&_S(l,l.stylesheets),0<l.count?function(u){var p=setTimeout(function(){if(l.stylesheets&&_S(l,l.stylesheets),l.unsuspend){var g=l.unsuspend;l.unsuspend=null,g()}},6e4);return l.unsuspend=u,function(){l.unsuspend=null,clearTimeout(p)}}:null}function w0(){if(this.count--,this.count===0){if(this.stylesheets)_S(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var x0=null;function _S(l,u){l.stylesheets=null,l.unsuspend!==null&&(l.count++,x0=new Map,u.forEach(SK,l),x0=null,w0.call(l))}function SK(l,u){if(!(u.state.loading&4)){var p=x0.get(l);if(p)var g=p.get(null);else{p=new Map,x0.set(l,p);for(var v=l.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x<v.length;x++){var R=v[x];(R.nodeName==="LINK"||R.getAttribute("media")!=="not all")&&(p.set(R.dataset.precedence,R),g=R)}g&&p.set(null,g)}v=u.instance,R=v.getAttribute("data-precedence"),x=p.get(R)||g,x===g&&p.set(null,v),p.set(R,v),this.count++,g=w0.bind(this),v.addEventListener("load",g),v.addEventListener("error",g),x?x.parentNode.insertBefore(v,x.nextSibling):(l=l.nodeType===9?l.head:l,l.insertBefore(v,l.firstChild)),u.state.loading|=4}}var ld={$$typeof:E,Provider:null,Consumer:null,_currentValue:H,_currentValue2:H,_threadCount:0};function _K(l,u,p,g,v,x,R,I){this.tag=1,this.containerInfo=l,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Rl(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Rl(0),this.hiddenUpdates=Rl(null),this.identifierPrefix=g,this.onUncaughtError=v,this.onCaughtError=x,this.onRecoverableError=R,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=I,this.incompleteTransitions=new Map}function GP(l,u,p,g,v,x,R,I,z,te,ae,he){return l=new _K(l,u,p,R,I,z,te,he),u=1,x===!0&&(u|=24),x=ai(3,null,null,u),l.current=x,x.stateNode=l,u=i1(),u.refCount++,l.pooledCache=u,u.refCount++,x.memoizedState={element:g,isDehydrated:p,cache:u},l1(x),l}function KP(l){return l?(l=su,l):su}function YP(l,u,p,g,v,x){v=KP(v),g.context===null?g.context=v:g.pendingContext=v,g=Sa(u),g.payload={element:p},x=x===void 0?null:x,x!==null&&(g.callback=x),p=_a(l,g,u),p!==null&&(fi(p,l,u),jf(p,l,u))}function XP(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var p=l.retryLane;l.retryLane=p!==0&&p<u?p:u}}function CS(l,u){XP(l,u),(l=l.alternate)&&XP(l,u)}function JP(l){if(l.tag===13){var u=iu(l,67108864);u!==null&&fi(u,l,67108864),CS(l,67108864)}}var S0=!0;function CK(l,u,p,g){var v=V.T;V.T=null;var x=G.p;try{G.p=2,AS(l,u,p,g)}finally{G.p=x,V.T=v}}function AK(l,u,p,g){var v=V.T;V.T=null;var x=G.p;try{G.p=8,AS(l,u,p,g)}finally{G.p=x,V.T=v}}function AS(l,u,p,g){if(S0){var v=ES(g);if(v===null)fS(l,u,g,_0,p),ZP(l,g);else if(kK(v,l,u,p,g))g.stopPropagation();else if(ZP(l,g),u&4&&-1<EK.indexOf(l)){for(;v!==null;){var x=ua(v);if(x!==null)switch(x.tag){case 3:if(x=x.stateNode,x.current.memoizedState.isDehydrated){var R=_r(x.pendingLanes);if(R!==0){var I=x;for(I.pendingLanes|=2,I.entangledLanes|=2;R;){var z=1<<31-$e(R);I.entanglements[1]|=z,R&=~z}zs(x),(wt&6)===0&&(o0=nr()+500,td(0))}}break;case 13:I=iu(x,2),I!==null&&fi(I,x,2),l0(),CS(x,2)}if(x=ES(g),x===null&&fS(l,u,g,_0,p),x===v)break;v=x}v!==null&&g.stopPropagation()}else fS(l,u,g,null,p)}}function ES(l){return l=Kc(l),kS(l)}var _0=null;function kS(l){if(_0=null,l=ca(l),l!==null){var u=s(l);if(u===null)l=null;else{var p=u.tag;if(p===13){if(l=o(u),l!==null)return l;l=null}else if(p===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;l=null}else u!==l&&(l=null)}}return _0=l,null}function QP(l){switch(l){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(lf()){case kl:return 2;case Ps:return 8;case Ds:case Bc:return 32;case Tl:return 268435456;default:return 32}default:return 32}}var TS=!1,Na=null,$a=null,ja=null,cd=new Map,ud=new Map,Ba=[],EK="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function ZP(l,u){switch(l){case"focusin":case"focusout":Na=null;break;case"dragenter":case"dragleave":$a=null;break;case"mouseover":case"mouseout":ja=null;break;case"pointerover":case"pointerout":cd.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":ud.delete(u.pointerId)}}function hd(l,u,p,g,v,x){return l===null||l.nativeEvent!==x?(l={blockedOn:u,domEventName:p,eventSystemFlags:g,nativeEvent:x,targetContainers:[v]},u!==null&&(u=ua(u),u!==null&&JP(u)),l):(l.eventSystemFlags|=g,u=l.targetContainers,v!==null&&u.indexOf(v)===-1&&u.push(v),l)}function kK(l,u,p,g,v){switch(u){case"focusin":return Na=hd(Na,l,u,p,g,v),!0;case"dragenter":return $a=hd($a,l,u,p,g,v),!0;case"mouseover":return ja=hd(ja,l,u,p,g,v),!0;case"pointerover":var x=v.pointerId;return cd.set(x,hd(cd.get(x)||null,l,u,p,g,v)),!0;case"gotpointercapture":return x=v.pointerId,ud.set(x,hd(ud.get(x)||null,l,u,p,g,v)),!0}return!1}function eD(l){var u=ca(l.target);if(u!==null){var p=s(u);if(p!==null){if(u=p.tag,u===13){if(u=o(p),u!==null){l.blockedOn=u,dg(l.priority,function(){if(p.tag===13){var g=hi();g=cf(g);var v=iu(p,g);v!==null&&fi(v,p,g),CS(p,g)}});return}}else if(u===3&&p.stateNode.current.memoizedState.isDehydrated){l.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}l.blockedOn=null}function C0(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var p=ES(l.nativeEvent);if(p===null){p=l.nativeEvent;var g=new p.constructor(p.type,p);vf=g,p.target.dispatchEvent(g),vf=null}else return u=ua(p),u!==null&&JP(u),l.blockedOn=p,!1;u.shift()}return!0}function tD(l,u,p){C0(l)&&p.delete(u)}function TK(){TS=!1,Na!==null&&C0(Na)&&(Na=null),$a!==null&&C0($a)&&($a=null),ja!==null&&C0(ja)&&(ja=null),cd.forEach(tD),ud.forEach(tD)}function A0(l,u){l.blockedOn===u&&(l.blockedOn=null,TS||(TS=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,TK)))}var E0=null;function nD(l){E0!==l&&(E0=l,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){E0===l&&(E0=null);for(var u=0;u<l.length;u+=3){var p=l[u],g=l[u+1],v=l[u+2];if(typeof g!="function"){if(kS(g||p)===null)continue;break}var x=ua(p);x!==null&&(l.splice(u,3),u-=3,k1(x,{pending:!0,data:v,method:p.method,action:g},g,v))}}))}function fd(l){function u(z){return A0(z,l)}Na!==null&&A0(Na,l),$a!==null&&A0($a,l),ja!==null&&A0(ja,l),cd.forEach(u),ud.forEach(u);for(var p=0;p<Ba.length;p++){var g=Ba[p];g.blockedOn===l&&(g.blockedOn=null)}for(;0<Ba.length&&(p=Ba[0],p.blockedOn===null);)eD(p),p.blockedOn===null&&Ba.shift();if(p=(l.ownerDocument||l).$$reactFormReplay,p!=null)for(g=0;g<p.length;g+=3){var v=p[g],x=p[g+1],R=v[or]||null;if(typeof x=="function")R||nD(p);else if(R){var I=null;if(x&&x.hasAttribute("formAction")){if(v=x,R=x[or]||null)I=R.formAction;else if(kS(v)!==null)continue}else I=R.action;typeof I=="function"?p[g+1]=I:(p.splice(g,3),g-=3),nD(p)}}}function RS(l){this._internalRoot=l}k0.prototype.render=RS.prototype.render=function(l){var u=this._internalRoot;if(u===null)throw Error(r(409));var p=u.current,g=hi();YP(p,g,l,u,null,null)},k0.prototype.unmount=RS.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var u=l.containerInfo;YP(l.current,2,null,l,null,null),l0(),u[la]=null}};function k0(l){this._internalRoot=l}k0.prototype.unstable_scheduleHydration=function(l){if(l){var u=hf();l={blockedOn:null,target:l,priority:u};for(var p=0;p<Ba.length&&u!==0&&u<Ba[p].priority;p++);Ba.splice(p,0,l),p===0&&eD(l)}};var rD=e.version;if(rD!=="19.1.1")throw Error(r(527,rD,"19.1.1"));G.findDOMNode=function(l){var u=l._reactInternals;if(u===void 0)throw typeof l.render=="function"?Error(r(188)):(l=Object.keys(l).join(","),Error(r(268,l)));return l=c(u),l=l!==null?h(l):null,l=l===null?null:l.stateNode,l};var RK={bundleType:0,version:"19.1.1",rendererPackageName:"react-dom",currentDispatcherRef:V,reconcilerVersion:"19.1.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var T0=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!T0.isDisabled&&T0.supportsFiber)try{oe=T0.inject(RK),ge=T0}catch{}}return pd.createRoot=function(l,u){if(!i(l))throw Error(r(299));var p=!1,g="",v=vO,x=wO,R=xO,I=null;return u!=null&&(u.unstable_strictMode===!0&&(p=!0),u.identifierPrefix!==void 0&&(g=u.identifierPrefix),u.onUncaughtError!==void 0&&(v=u.onUncaughtError),u.onCaughtError!==void 0&&(x=u.onCaughtError),u.onRecoverableError!==void 0&&(R=u.onRecoverableError),u.unstable_transitionCallbacks!==void 0&&(I=u.unstable_transitionCallbacks)),u=GP(l,1,!1,null,null,p,g,v,x,R,I,null),l[la]=u.current,hS(l),new RS(u)},pd.hydrateRoot=function(l,u,p){if(!i(l))throw Error(r(299));var g=!1,v="",x=vO,R=wO,I=xO,z=null,te=null;return p!=null&&(p.unstable_strictMode===!0&&(g=!0),p.identifierPrefix!==void 0&&(v=p.identifierPrefix),p.onUncaughtError!==void 0&&(x=p.onUncaughtError),p.onCaughtError!==void 0&&(R=p.onCaughtError),p.onRecoverableError!==void 0&&(I=p.onRecoverableError),p.unstable_transitionCallbacks!==void 0&&(z=p.unstable_transitionCallbacks),p.formState!==void 0&&(te=p.formState)),u=GP(l,1,!0,u,p??null,g,v,x,R,I,z,te),u.context=KP(null),p=u.current,g=hi(),g=cf(g),v=Sa(g),v.callback=null,_a(p,v,g),p=g,u.current.lanes=p,as(u,p),zs(u),l[la]=u.current,hS(l),new k0(u)},pd.version="19.1.1",pd}var dD;function BK(){if(dD)return PS.exports;dD=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),PS.exports=jK(),PS.exports}var FK=BK(),zK=t=>Array.from(t).map(n=>n.getModelContext()).sort((n,r)=>(r.priority??0)-(n.priority??0)).reduce((n,r)=>{if(r.system&&(n.system?n.system+=`
${r.system}`:n.system=r.system),r.tools)for(const[i,s]of Object.entries(r.tools)){const o=n.tools?.[i];if(o&&o!==s)throw new Error(`You tried to define a tool with the name ${i}, but it already exists.`);n.tools||(n.tools={}),n.tools[i]=s}return r.config&&(n.config={...n.config,...r.config}),r.callSettings&&(n.callSettings={...n.callSettings,...r.callSettings}),n},{}),R5=class{_providers=new Set;getModelContext(){return zK(this._providers)}registerModelContextProvider(t){this._providers.add(t);const e=t.subscribe?.(()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(t),e?.(),this.notifySubscribers()}}_subscribers=new Set;notifySubscribers(){for(const t of this._subscribers)t()}subscribe(t){return this._subscribers.add(t),()=>this._subscribers.delete(t)}},M5=class{_contextProvider=new R5;registerModelContextProvider(t){return this._contextProvider.registerModelContextProvider(t)}},VK=class{_subscribers=new Set;subscribe(t){return this._subscribers.add(t),()=>this._subscribers.delete(t)}waitForUpdate(){return new Promise(t=>{const e=this.subscribe(()=>{e(),t()})})}_notifySubscribers(){const t=[];for(const e of this._subscribers)try{e()}catch(n){t.push(n)}if(t.length>0)throw t.length===1?t[0]:new AggregateError(t)}},UK=t=>t.status.type==="complete",O5=class extends VK{isEditing=!0;get attachmentAccept(){return this.getAttachmentAdapter()?.accept??"*"}_attachments=[];get attachments(){return this._attachments}setAttachments(t){this._attachments=t,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text="";get text(){return this._text}_role="user";get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}setText(t){this._text!==t&&(this._text=t,this._notifySubscribers())}setRole(t){this._role!==t&&(this._role=t,this._notifySubscribers())}setRunConfig(t){this._runConfig!==t&&(this._runConfig=t,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text="",this._notifySubscribers()}async _onClearAttachments(){const t=this.getAttachmentAdapter();t&&await Promise.all(this._attachments.map(e=>t.remove(e)))}async reset(){if(this._attachments.length===0&&this._text===""&&this._role==="user"&&Object.keys(this._runConfig).length===0)return;this._role="user",this._runConfig={};const t=this._onClearAttachments();this._emptyTextAndAttachments(),await t}async clearAttachments(){const t=this._onClearAttachments();this.setAttachments([]),await t}async send(){const t=this.getAttachmentAdapter(),e=t&&this.attachments.length>0?Promise.all(this.attachments.map(async i=>UK(i)?i:await t.send(i))):[],n=this.text;this._emptyTextAndAttachments();const r={createdAt:new Date,role:this.role,content:n?[{type:"text",text:n}]:[],attachments:await e,runConfig:this.runConfig,metadata:{custom:{}}};this.handleSend(r),this._notifyEventSubscribers("send")}cancel(){this.handleCancel()}async addAttachment(t){const e=this.getAttachmentAdapter();if(!e)throw new Error("Attachments are not supported");const n=i=>{const s=this._attachments.findIndex(o=>o.id===i.id);s!==-1?this._attachments=[...this._attachments.slice(0,s),i,...this._attachments.slice(s+1)]:this._attachments=[...this._attachments,i],this._notifySubscribers()},r=e.add({file:t});if(Symbol.asyncIterator in r)for await(const i of r)n(i);else n(await r);this._notifyEventSubscribers("attachment-add"),this._notifySubscribers()}async removeAttachment(t){const e=this.getAttachmentAdapter();if(!e)throw new Error("Attachments are not supported");const n=this._attachments.findIndex(i=>i.id===t);if(n===-1)throw new Error("Attachment not found");const r=this._attachments[n];await e.remove(r),this._attachments=[...this._attachments.slice(0,n),...this._attachments.slice(n+1)],this._notifySubscribers()}_eventSubscribers=new Map;_notifyEventSubscribers(t){const e=this._eventSubscribers.get(t);if(e)for(const n of e)n()}unstable_on(t,e){const n=this._eventSubscribers.get(t);return n?n.add(e):this._eventSubscribers.set(t,new Set([e])),()=>{const r=this._eventSubscribers.get(t);r&&r.delete(e)}}},P5=class extends O5{constructor(t){super(),this.runtime=t,this.connect()}_canCancel=!1;get canCancel(){return this._canCancel}get attachments(){return super.attachments}getAttachmentAdapter(){return this.runtime.adapters?.attachments}connect(){return this.runtime.subscribe(()=>{this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,this._notifySubscribers())})}async handleSend(t){this.runtime.append({...t,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null})}async handleCancel(){this.runtime.cancelRun()}};let HK=(t,e=21)=>(n=e)=>{let r="",i=n|0;for(;i--;)r+=t[Math.random()*t.length|0];return r};var vw=HK("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),WK="__optimistic__",qK=()=>`${WK}${vw()}`,D5=Object.freeze({type:"running"}),I5=Object.freeze({type:"complete",reason:"unknown"}),GK=Object.freeze({type:"requires-action",reason:"tool-calls"}),KK=t=>t===D5||t===I5,TE=(t,e,n)=>t&&e?D5:n?GK:I5,Gl={exports:{}},pD;function YK(){if(pD)return Gl.exports;pD=1;const t=typeof Buffer<"u",e=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,n=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function r(a,c,h){h==null&&c!==null&&typeof c=="object"&&(h=c,c=void 0),t&&Buffer.isBuffer(a)&&(a=a.toString()),a&&a.charCodeAt(0)===65279&&(a=a.slice(1));const f=JSON.parse(a,c);if(f===null||typeof f!="object")return f;const d=h&&h.protoAction||"error",m=h&&h.constructorAction||"error";if(d==="ignore"&&m==="ignore")return f;if(d!=="ignore"&&m!=="ignore"){if(e.test(a)===!1&&n.test(a)===!1)return f}else if(d!=="ignore"&&m==="ignore"){if(e.test(a)===!1)return f}else if(n.test(a)===!1)return f;return i(f,{protoAction:d,constructorAction:m,safe:h&&h.safe})}function i(a,{protoAction:c="error",constructorAction:h="error",safe:f}={}){let d=[a];for(;d.length;){const m=d;d=[];for(const y of m){if(c!=="ignore"&&Object.prototype.hasOwnProperty.call(y,"__proto__")){if(f===!0)return null;if(c==="error")throw new SyntaxError("Object contains forbidden prototype property");delete y.__proto__}if(h!=="ignore"&&Object.prototype.hasOwnProperty.call(y,"constructor")&&Object.prototype.hasOwnProperty.call(y.constructor,"prototype")){if(f===!0)return null;if(h==="error")throw new SyntaxError("Object contains forbidden prototype property");delete y.constructor}for(const b in y){const w=y[b];w&&typeof w=="object"&&d.push(w)}}}return a}function s(a,c,h){const{stackTraceLimit:f}=Error;Error.stackTraceLimit=0;try{return r(a,c,h)}finally{Error.stackTraceLimit=f}}function o(a,c){const{stackTraceLimit:h}=Error;Error.stackTraceLimit=0;try{return r(a,c,{safe:!0})}catch{return}finally{Error.stackTraceLimit=h}}return Gl.exports=s,Gl.exports.default=s,Gl.exports.parse=s,Gl.exports.safeParse=o,Gl.exports.scan=i,Gl.exports}var XK=YK();const mD=Pc(XK);function JK(t){const e=["ROOT"];let n=-1,r=null;const i=[];let s;function o(){s!==void 0&&(i.push(JSON.parse('"'+s+'"')),s=void 0)}function a(d,m,y){switch(d){case'"':{n=m,e.pop(),e.push(y),e.push("INSIDE_STRING"),o();break}case"f":case"t":case"n":{n=m,r=m,e.pop(),e.push(y),e.push("INSIDE_LITERAL");break}case"-":{e.pop(),e.push(y),e.push("INSIDE_NUMBER"),o();break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=m,e.pop(),e.push(y),e.push("INSIDE_NUMBER"),o();break}case"{":{n=m,e.pop(),e.push(y),e.push("INSIDE_OBJECT_START"),o();break}case"[":{n=m,e.pop(),e.push(y),e.push("INSIDE_ARRAY_START"),o();break}}}function c(d,m){switch(d){case",":{e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=m,e.pop(),s=i.pop();break}}}function h(d,m){switch(d){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA"),s=(Number(s)+1).toString();break}case"]":{n=m,e.pop(),s=i.pop();break}}}for(let d=0;d<t.length;d++){const m=t[d];switch(e[e.length-1]){case"ROOT":a(m,d,"FINISH");break;case"INSIDE_OBJECT_START":{switch(m){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY"),s="";break}case"}":{n=d,e.pop(),s=i.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(m){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY"),s="";break}}break}case"INSIDE_OBJECT_KEY":{switch(m){case'"':{e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY");break}case"\\":{e.push("INSIDE_STRING_ESCAPE"),s+=m;break}default:{s+=m;break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(m){case":":{e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{a(m,d,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{c(m,d);break}case"INSIDE_STRING":{switch(m){case'"':{e.pop(),n=d,s=i.pop();break}case"\\":{e.push("INSIDE_STRING_ESCAPE");break}default:n=d}break}case"INSIDE_ARRAY_START":{switch(m){case"]":{n=d,e.pop(),s=i.pop();break}default:{n=d,s="0",a(m,d,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(m){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA"),s=(Number(s)+1).toString();break}case"]":{n=d,e.pop(),s=i.pop();break}default:{n=d;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{a(m,d,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{e.pop(),e[e.length-1]==="INSIDE_STRING"?n=d:e[e.length-1]==="INSIDE_OBJECT_KEY"&&(s+=m);break}case"INSIDE_NUMBER":{switch(m){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=d;break}case"e":case"E":case"-":case".":break;case",":{e.pop(),s=i.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&h(m,d),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&c(m,d);break}case"}":{e.pop(),s=i.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&c(m,d);break}case"]":{e.pop(),s=i.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&h(m,d);break}default:{e.pop(),s=i.pop();break}}break}case"INSIDE_LITERAL":{const b=t.substring(r,d+1);!"false".startsWith(b)&&!"true".startsWith(b)&&!"null".startsWith(b)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?c(m,d):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&h(m,d)):n=d;break}}}let f=t.slice(0,n+1);for(let d=e.length-1;d>=0;d--)switch(e[d]){case"INSIDE_STRING":{f+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{f+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{f+="]";break}case"INSIDE_LITERAL":{const y=t.substring(r,t.length);"true".startsWith(y)?f+="true".slice(y.length):"false".startsWith(y)?f+="false".slice(y.length):"null".startsWith(y)&&(f+="null".slice(y.length))}}return[f,i]}var NS=Symbol("aui.parse-partial-json-object.meta"),QK=t=>{if(t.length===0)return{[NS]:{state:"partial",partialPath:[]}};try{const e=mD.parse(t);if(typeof e!="object"||e===null)throw new Error("argsText is expected to be an object");return e[NS]={state:"complete",partialPath:[]},e}catch{try{const[e,n]=JK(t),r=mD.parse(e);if(typeof r!="object"||r===null)throw new Error("argsText is expected to be an object");return r[NS]={state:"partial",partialPath:n},r}catch{return}}},ww=(t,e,n)=>{const{role:r,id:i,createdAt:s,attachments:o,status:a,metadata:c}=t,h={id:i??e,createdAt:s??new Date},f=typeof t.content=="string"?[{type:"text",text:t.content}]:t.content,d=({image:m,...y})=>m.match(/^data:image\/(png|jpeg|jpg|gif|webp);base64,(.*)$/)?{...y,image:m}:(console.warn("Invalid image data format detected"),null);if(r!=="user"&&o?.length)throw new Error("attachments are only supported for user messages");if(r!=="assistant"&&a)throw new Error("status is only supported for assistant messages");if(r!=="assistant"&&c?.steps)throw new Error("metadata.steps is only supported for assistant messages");switch(r){case"assistant":return{...h,role:r,content:f.map(m=>{const y=m.type;switch(y){case"text":case"reasoning":return m.text.trim().length===0?null:m;case"file":case"source":return m;case"image":return d(m);case"tool-call":{const{parentId:b,...w}=m,S={...w,toolCallId:m.toolCallId??"tool-"+vw(),...b!==void 0&&{parentId:b}};return m.args?{...S,args:m.args,argsText:m.argsText??JSON.stringify(m.args)}:{...S,args:QK(m.argsText??"")??{},argsText:m.argsText??""}}default:{const b=y;throw new Error(`Unsupported assistant message part type: ${b}`)}}}).filter(m=>!!m),status:a??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[]}};case"user":return{...h,role:r,content:f.map(m=>{const y=m.type;switch(y){case"text":case"image":case"audio":case"file":return m;default:{const b=y;throw new Error(`Unsupported user message part type: ${b}`)}}}),attachments:o??[],metadata:{custom:c?.custom??{}}};case"system":if(f.length!==1||f[0].type!=="text")throw new Error("System messages must have exactly one text message part.");return{...h,role:r,content:f,metadata:{custom:c?.custom??{}}};default:{const m=r;throw new Error(`Unknown message role: ${m}`)}}},RE={fromArray:t=>{const e=t.map(n=>ww(n,vw(),TE(!1,!1,!1)));return{messages:e.map((n,r)=>({parentId:r>0?e[r-1].id:null,message:n}))}}},ib=t=>t.next?ib(t.next):"current"in t?t:null,ZK=class{constructor(t){this.func=t}_value=null;get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},ME=class{messages=new Map;head=null;root={children:[],next:null};performOp(t,e,n){const r=e.prev??this.root,i=t??this.root;if(!(n==="relink"&&r===i)){if(n!=="link"&&(r.children=r.children.filter(s=>s!==e.current.id),r.next===e)){const s=r.children.at(-1),o=s?this.messages.get(s):null;if(o===void 0)throw new Error("MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.");r.next=o}if(n!=="cut"){for(let s=t;s;s=s.prev)if(s.current.id===e.current.id)throw new Error("MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.");i.children=[...i.children,e.current.id],(ib(e)===this.head||i.next===null)&&(i.next=e),e.prev=t}}}_messages=new ZK(()=>{const t=new Array(this.head?.level??0);for(let e=this.head;e;e=e.prev)t[e.level]=e.current;return t});get headId(){return this.head?.current.id??null}getMessages(){return this._messages.value}addOrUpdateMessage(t,e){const n=this.messages.get(e.id),r=t?this.messages.get(t):null;if(r===void 0)throw new Error("MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.");if(n){n.current=e,this.performOp(r,n,"relink"),this._messages.dirty();return}const i={prev:r,current:e,next:null,children:[],level:r?r.level+1:0};this.messages.set(e.id,i),this.performOp(r,i,"link"),this.head===r&&(this.head=i),this._messages.dirty()}getMessage(t){const e=this.messages.get(t);if(!e)throw new Error("MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.");return{parentId:e.prev?.current.id??null,message:e.current}}appendOptimisticMessage(t,e){let n;do n=qK();while(this.messages.has(n));return this.addOrUpdateMessage(t,ww(e,n,{type:"running"})),n}deleteMessage(t,e){const n=this.messages.get(t);if(!n)throw new Error("MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.");const r=e===void 0?n.prev:e===null?null:this.messages.get(e);if(r===void 0)throw new Error("MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.");for(const i of n.children){const s=this.messages.get(i);if(!s)throw new Error("MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.");this.performOp(r,s,"relink")}this.performOp(null,n,"cut"),this.messages.delete(t),this.head===n&&(this.head=ib(r??this.root)),this._messages.dirty()}getBranches(t){const e=this.messages.get(t);if(!e)throw new Error("MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.");const{children:n}=e.prev??this.root;return n}switchToBranch(t){const e=this.messages.get(t);if(!e)throw new Error("MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.");const n=e.prev??this.root;n.next=e,this.head=ib(e),this._messages.dirty()}resetHead(t){if(t===null){this.clear();return}const e=this.messages.get(t);if(!e)throw new Error("MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.");if(e.children.length>0){const n=r=>{for(const i of r.children){const s=this.messages.get(i);s&&(n(s),this.messages.delete(i))}};n(e),e.children=[],e.next=null}this.head=e;for(let n=e;n;n=n.prev)n.prev&&(n.prev.next=n);this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){const t=[];for(const[,e]of this.messages)t.push({message:e.current,parentId:e.prev?.current.id??null});return{headId:this.head?.current.id??null,messages:t}}import({headId:t,messages:e}){for(const{message:n,parentId:r}of e)this.addOrUpdateMessage(r,n);this.resetHead(t??e.at(-1)?.message.id??null)}},xw=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(){for(const t of this._subscriptions)t()}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else this._connection?.(),this._connection=void 0}subscribe(t){return this._subscriptions.add(t),this._updateConnection(),()=>{this._subscriptions.delete(t),this._updateConnection()}}},xs=Symbol("skip-update"),OE=class extends xw{constructor(t){super(),this.binding=t}get path(){return this.binding.path}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){const t=this.binding.getState();t!==xs&&(this._previousState=t),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState};_connect(){const t=()=>{this._previousStateDirty=!0,this.notifySubscribers()};return this.binding.subscribe(t)}},M0=class{constructor(t,e){this._core=t,this._threadListBinding=e,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(){const t=this._core.getState();return this._threadListBinding.switchToThread(t.id)}rename(t){const e=this._core.getState();return this._threadListBinding.rename(e.id,t)}archive(){const t=this._core.getState();return this._threadListBinding.archive(t.id)}unarchive(){const t=this._core.getState();return this._threadListBinding.unarchive(t.id)}delete(){const t=this._core.getState();return this._threadListBinding.delete(t.id)}initialize(){const t=this._core.getState();return this._threadListBinding.initialize(t.id)}generateTitle(){const t=this._core.getState();return this._threadListBinding.generateTitle(t.id)}unstable_on(t,e){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{const i=this._core.getState(),s=i.isMain,o=i.id;n===s&&r===o||(n=s,r=o,!(t==="switched-to"&&!s)&&(t==="switched-away"&&s||e()))})}subscribe(t){return this._core.subscribe(t)}detach(){const t=this._core.getState();this._threadListBinding.detach(t.id)}__internal_getRuntime(){return this}};function eY(t,e){if(t===void 0&&e===void 0)return!0;if(t===void 0||e===void 0)return!1;for(const n of Object.keys(t)){const r=t[n],i=e[n];if(!Object.is(r,i))return!1}return!0}var gs=class extends xw{constructor(t){super(),this.binding=t;const e=t.getState();if(e===xs)throw new Error("Entry not available in the store");this._previousState=e}get path(){return this.binding.path}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){const t=this.binding.getState();return t===xs||eY(t,this._previousState)?!1:(this._previousState=t,!0)}_connect(){const t=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(t)}},Th=Symbol("innerMessage"),tY=t=>t[Th],Vp=t=>t.content.filter(n=>n.type==="text").map(n=>n.text).join(`
`),L5=class{constructor(t){this._core=t,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(t){return this._core.subscribe(t)}},N5=class extends L5{constructor(t,e){super(t),this._composerApi=e}remove(){const t=this._composerApi.getState();if(!t)throw new Error("Composer is not available");return t.removeAttachment(this.getState().id)}},nY=class extends N5{get source(){return"thread-composer"}},rY=class extends N5{get source(){return"edit-composer"}},iY=class extends L5{get source(){return"message"}constructor(t){super(t)}remove(){throw new Error("Message attachments cannot be removed")}},$5=class extends xw{constructor(t){super(),this.config=t}getState(){return this.config.binding.getState()}outerSubscribe(t){return this.config.binding.subscribe(t)}_connect(){const t=()=>{this.notifySubscribers()};let e=this.config.binding.getState(),n=e?.unstable_on(this.config.event,t);const r=()=>{const s=this.config.binding.getState();s!==e&&(e=s,n?.(),n=this.config.binding.getState()?.unstable_on(this.config.event,t))},i=this.outerSubscribe(r);return()=>{i?.(),n?.()}}},j5=Object.freeze([]),B5=Object.freeze({}),sY=t=>Object.freeze({type:"thread",isEditing:t?.isEditing??!1,canCancel:t?.canCancel??!1,isEmpty:t?.isEmpty??!0,attachments:t?.attachments??j5,text:t?.text??"",role:t?.role??"user",runConfig:t?.runConfig??B5,attachmentAccept:t?.attachmentAccept??"",value:t?.text??""}),oY=t=>Object.freeze({type:"edit",isEditing:t?.isEditing??!1,canCancel:t?.canCancel??!1,isEmpty:t?.isEmpty??!0,text:t?.text??"",role:t?.role??"user",attachments:t?.attachments??j5,runConfig:t?.runConfig??B5,attachmentAccept:t?.attachmentAccept??"",value:t?.text??""}),F5=class{constructor(t){this._core=t}get path(){return this._core.path}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setText(t)}setRunConfig(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setRunConfig(t)}addAttachment(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");return e.addAttachment(t)}reset(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.reset()}clearAttachments(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.clearAttachments()}send(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.send()}cancel(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.cancel()}setRole(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setRole(t)}subscribe(t){return this._core.subscribe(t)}_eventSubscriptionSubjects=new Map;unstable_on(t,e){let n=this._eventSubscriptionSubjects.get(t);return n||(n=new $5({event:t,binding:this._core}),this._eventSubscriptionSubjects.set(t,n)),n.subscribe(e)}},aY=class extends F5{get path(){return this._core.path}get type(){return"thread"}_getState;constructor(t){const e=new OE({path:t.path,getState:()=>sY(t.getState()),subscribe:n=>t.subscribe(n)});super({path:t.path,getState:()=>t.getState(),subscribe:n=>e.subscribe(n)}),this._getState=e.getState.bind(e),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(t){return new nY(new gs({path:{...this.path,attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:t},ref:this.path.ref+`${this.path.ref}.attachments[${t}]`},getState:()=>{const n=this.getState().attachments[t];return n?{...n,source:"thread-composer"}:xs},subscribe:e=>this._core.subscribe(e)}),this._core)}},lY=class extends F5{constructor(t,e){const n=new OE({path:t.path,getState:()=>oY(t.getState()),subscribe:r=>t.subscribe(r)});super({path:t.path,getState:()=>t.getState(),subscribe:r=>n.subscribe(r)}),this._beginEdit=e,this._getState=n.getState.bind(n),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"edit"}_getState;__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(t){return new rY(new gs({path:{...this.path,attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:t},ref:this.path.ref+`${this.path.ref}.attachments[${t}]`},getState:()=>{const n=this.getState().attachments[t];return n?{...n,source:"edit-composer"}:xs},subscribe:e=>this._core.subscribe(e)}),this._core)}},gD=Symbol.for("aui.tool-response"),cY=class F2{get[gD](){return!0}artifact;result;isError;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact),this.result=e.result,this.isError=e.isError??!1}static[Symbol.hasInstance](e){return typeof e=="object"&&e!==null&&gD in e}static toResponse(e){return e instanceof F2?e:new F2({result:e===void 0?"<no result>":e})}},yD=class{constructor(t,e,n){this.contentBinding=t,this.messageApi=e,this.threadApi=n,this.__internal_bindMethods()}get path(){return this.contentBinding.path}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(t){const e=this.contentBinding.getState();if(!e)throw new Error("Message part is not available");if(e.type!=="tool-call")throw new Error("Tried to add tool result to non-tool message part");if(!this.messageApi)throw new Error("Message API is not available. This is likely a bug in assistant-ui.");if(!this.threadApi)throw new Error("Thread API is not available");const n=this.messageApi.getState();if(!n)throw new Error("Message is not available");const r=e.toolName,i=e.toolCallId,s=cY.toResponse(t);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:s.result,artifact:s.artifact,isError:s.isError})}subscribe(t){return this.contentBinding.subscribe(t)}},Kb=class extends xw{constructor(t){super(),this.binding=t}get path(){return this.binding.path}getState(){return this.binding.getState()}outerSubscribe(t){return this.binding.subscribe(t)}_connect(){const t=()=>{this.notifySubscribers()};let e=this.binding.getState(),n=e?.subscribe(t);const r=()=>{const s=this.binding.getState();s!==e&&(e=s,n?.(),n=this.binding.getState()?.subscribe(t),t())},i=this.outerSubscribe(r);return()=>{i?.(),n?.()}}},O0=Object.freeze({type:"complete"}),uY=(t,e,n)=>{if(t.role!=="assistant")return O0;if(n.type==="tool-call")return n.result?O0:t.status;const r=e===Math.max(0,t.content.length-1);return t.status.type==="requires-action"?O0:r?t.status:O0},bD=(t,e)=>{const n=t.content[e];if(!n)return xs;const r=uY(t,e,n);return Object.freeze({...n,[Th]:n[Th],status:r})},hY=class{constructor(t,e){this._core=t,this._threadBinding=e,this.composer=new lY(new Kb({path:{...this.path,ref:this.path.ref+`${this.path.ref}.composer`,composerSource:"edit"},getState:this._getEditComposerRuntimeCore,subscribe:n=>this._threadBinding.subscribe(n)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.reload=this.reload.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}reload(t={}){const e=this._getEditComposerRuntimeCore(),n=e??this._threadBinding.getState().composer,r=e??n,{runConfig:i=r.runConfig}=t,s=this._core.getState();if(s.role!=="assistant")throw new Error("Can only reload assistant messages");this._threadBinding.getState().startRun({parentId:s.parentId,sourceId:s.id,runConfig:i})}speak(){const t=this._core.getState();return this._threadBinding.getState().speak(t.id)}stopSpeaking(){const t=this._core.getState();if(this._threadBinding.getState().speech?.messageId===t.id)this._threadBinding.getState().stopSpeaking();else throw new Error("Message is not being spoken")}submitFeedback({type:t}){const e=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:e.id,type:t})}switchToBranch({position:t,branchId:e}){const n=this._core.getState();if(e&&t)throw new Error("May not specify both branchId and position");if(!e&&!t)throw new Error("Must specify either branchId or position");const i=this._threadBinding.getState().getBranches(n.id);let s=e;if(t==="previous"?s=i[n.branchNumber-2]:t==="next"&&(s=i[n.branchNumber]),!s)throw new Error("Branch not found");this._threadBinding.getState().switchToBranch(s)}unstable_getCopyText(){return Vp(this.getState())}subscribe(t){return this._core.subscribe(t)}getMessagePartByIndex(t){if(t<0)throw new Error("Message part index must be >= 0");return new yD(new gs({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[${t}]`,messagePartSelector:{type:"index",index:t}},getState:()=>bD(this.getState(),t),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(t){return new yD(new gs({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(t)}]`,messagePartSelector:{type:"toolCallId",toolCallId:t}},getState:()=>{const e=this._core.getState(),n=e.content.findIndex(r=>r.type==="tool-call"&&r.toolCallId===t);return n===-1?xs:bD(e,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(t){return new iY(new gs({path:{...this.path,ref:this.path.ref+`${this.path.ref}.attachments[${t}]`,attachmentSource:"message",attachmentSelector:{type:"index",index:t}},getState:()=>{const n=this.getState().attachments?.[t];return n?{...n,source:"message"}:xs},subscribe:e=>this._core.subscribe(e)}))}},fY=t=>({parentId:t.parentId??null,sourceId:t.sourceId??null,runConfig:t.runConfig??{},...t.stream?{stream:t.stream}:{}}),dY=t=>({parentId:t.parentId??null,sourceId:t.sourceId??null,runConfig:t.runConfig??{}}),pY=(t,e)=>typeof e=="string"?{createdAt:new Date,parentId:t.at(-1)?.id??null,sourceId:null,runConfig:{},role:"user",content:[{type:"text",text:e}],attachments:[],metadata:{custom:{}}}:{createdAt:e.createdAt??new Date,parentId:e.parentId??t.at(-1)?.id??null,sourceId:e.sourceId??null,role:e.role??"user",content:e.content,attachments:e.attachments??[],metadata:e.metadata??{custom:{}},runConfig:e.runConfig??{},startRun:e.startRun},mY=(t,e)=>{const n=t.messages.at(-1);return Object.freeze({threadId:e.id,metadata:e,capabilities:t.capabilities,isDisabled:t.isDisabled,isLoading:t.isLoading,isRunning:n?.role!=="assistant"?!1:n.status.type==="running",messages:t.messages,state:t.state,suggestions:t.suggestions,extras:t.extras,speech:t.speech})},z5=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;constructor(t,e){const n=new gs({path:t.path,getState:()=>mY(t.getState(),e.getState()),subscribe:r=>{const i=t.subscribe(r),s=e.subscribe(r);return()=>{i(),s()}}});this._threadBinding={path:t.path,getState:()=>t.getState(),getStateState:()=>n.getState(),outerSubscribe:r=>t.outerSubscribe(r),subscribe:r=>t.subscribe(r)},this.composer=new aY(new Kb({path:{...this.path,ref:this.path.ref+`${this.path.ref}.composer`,composerSource:"thread"},getState:()=>this._threadBinding.getState().composer,subscribe:r=>this._threadBinding.subscribe(r)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.unstable_resumeRun=this.unstable_resumeRun.bind(this),this.unstable_loadExternalState=this.unstable_loadExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getModelConfig=this.getModelConfig.bind(this),this.getState=this.getState.bind(this)}composer;getState(){return this._threadBinding.getStateState()}append(t){this._threadBinding.getState().append(pY(this._threadBinding.getState().messages,t))}subscribe(t){return this._threadBinding.subscribe(t)}getModelContext(){return this._threadBinding.getState().getModelContext()}getModelConfig(){return this.getModelContext()}startRun(t){const e=t===null||typeof t=="string"?{parentId:t}:t;return this._threadBinding.getState().startRun(dY(e))}unstable_resumeRun(t){return this._threadBinding.getState().resumeRun(fY(t))}unstable_loadExternalState(t){this._threadBinding.getState().unstable_loadExternalState(t)}cancelRun(){this._threadBinding.getState().cancelRun()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}export(){return this._threadBinding.getState().export()}import(t){this._threadBinding.getState().import(t)}reset(t){this._threadBinding.getState().reset(t)}getMessageByIndex(t){if(t<0)throw new Error("Message index must be >= 0");return this._getMessageRuntime({...this.path,ref:this.path.ref+`${this.path.ref}.messages[${t}]`,messageSelector:{type:"index",index:t}},()=>{const e=this._threadBinding.getState().messages,n=e[t];if(n)return{message:n,parentId:e[t-1]?.id??null}})}getMessageById(t){return this._getMessageRuntime({...this.path,ref:this.path.ref+`${this.path.ref}.messages[messageId=${JSON.stringify(t)}]`,messageSelector:{type:"messageId",messageId:t}},()=>this._threadBinding.getState().getMessageById(t))}_getMessageRuntime(t,e){return new hY(new gs({path:t,getState:()=>{const{message:n,parentId:r}=e()??{},{messages:i,speech:s}=this._threadBinding.getState();if(!n||r===void 0)return xs;const o=this._threadBinding.getState(),a=o.getBranches(n.id),c=o.getSubmittedFeedback(n.id);return{...n,[Th]:n[Th],isLast:i.at(-1)?.id===n.id,parentId:r,branchNumber:a.indexOf(n.id)+1,branchCount:a.length,speech:s?.messageId===n.id?s:void 0,submittedFeedback:c}},subscribe:n=>this._threadBinding.subscribe(n)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(t,e){let n=this._eventSubscriptionSubjects.get(t);return n||(n=new $5({event:t,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(t,n)),n.subscribe(e)}},gY=t=>({mainThreadId:t.mainThreadId,newThread:t.newThreadId,threads:t.threadIds,archivedThreads:t.archivedThreadIds,isLoading:t.isLoading,threadItems:t.threadData}),P0=(t,e)=>{if(e===void 0)return xs;const n=t.getItemById(e);return n?{id:n.id,threadId:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,isMain:n.id===t.mainThreadId}:xs},yY=class{constructor(t,e=z5){this._core=t,this._runtimeFactory=e;const n=new OE({path:{},getState:()=>gY(t),subscribe:r=>t.subscribe(r)});this._getState=n.getState.bind(n),this._mainThreadListItemRuntime=new M0(new gs({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>P0(this._core,this._core.mainThreadId),subscribe:r=>this._core.subscribe(r)}),this._core),this.main=new e(new Kb({path:{ref:"threads.main",threadSelector:{type:"main"}},getState:()=>t.getMainThreadRuntimeCore(),subscribe:r=>t.subscribe(r)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}_getState;__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(t){return this._core.switchToThread(t)}switchToNewThread(){return this._core.switchToNewThread()}getState(){return this._getState()}subscribe(t){return this._core.subscribe(t)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}getById(t){return new this._runtimeFactory(new Kb({path:{ref:"threads[threadId="+JSON.stringify(t)+"]",threadSelector:{type:"threadId",threadId:t}},getState:()=>this._core.getThreadRuntimeCore(t),subscribe:e=>this._core.subscribe(e)}),this.mainItem)}getItemByIndex(t){return new M0(new gs({path:{ref:`threadItems[${t}]`,threadSelector:{type:"index",index:t}},getState:()=>P0(this._core,this._core.threadIds[t]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(t){return new M0(new gs({path:{ref:`archivedThreadItems[${t}]`,threadSelector:{type:"archiveIndex",index:t}},getState:()=>P0(this._core,this._core.archivedThreadIds[t]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(t){return new M0(new gs({path:{ref:`threadItems[threadId=${t}]`,threadSelector:{type:"threadId",threadId:t}},getState:()=>P0(this._core,t),subscribe:e=>this._core.subscribe(e)}),this._core)}},bY=class{accept="image/*";async add(t){return{id:t.file.name,type:"image",name:t.file.name,contentType:t.file.type,file:t.file,status:{type:"requires-action",reason:"composer-send"}}}async send(t){return{...t,status:{type:"complete"},content:[{type:"image",image:await vY(t.file)}]}}async remove(){}},vY=t=>new Promise((e,n)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=i=>n(i),r.readAsDataURL(t)}),wY=class{accept="text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css";async add(t){return{id:t.file.name,type:"document",name:t.file.name,contentType:t.file.type,file:t.file,status:{type:"requires-action",reason:"composer-send"}}}async send(t){return{...t,status:{type:"complete"},content:[{type:"text",text:`<attachment name=${t.name}>
${await xY(t.file)}
</attachment>`}]}}async remove(){}},xY=t=>new Promise((e,n)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=i=>n(i),r.readAsText(t)});function $S(t,e){if(e==="*")return!0;const n=e.split(",").map(s=>s.trim().toLowerCase()),r="."+t.name.split(".").pop().toLowerCase(),i=t.type.toLowerCase();for(const s of n){if(s.startsWith(".")&&s===r||s.includes("/")&&s===i)return!0;if((s==="image/*"||s==="video/*"||s==="audio/*")&&s.endsWith("/*")){const o=s.split("/")[0];if(i.startsWith(o+"/"))return!0}}return!1}var SY=class{_adapters;accept;constructor(t){this._adapters=t;const e=t.findIndex(n=>n.accept==="*");if(e!==-1){if(e!==t.length-1)throw new Error("A wildcard adapter (handling all files) can only be specified as the last adapter.");this.accept="*"}else this.accept=t.map(n=>n.accept).join(",")}add(t){for(const e of this._adapters)if($S(t.file,e.accept))return e.add(t);throw new Error("No matching adapter found for file")}async send(t){const e=this._adapters.slice();for(const n of e)if($S(t.file,n.accept))return n.send(t);throw new Error("No matching adapter found for attachment")}async remove(t){const e=this._adapters.slice();for(const n of e)if($S({name:t.name,type:t.contentType},n.accept))return n.remove(t);throw new Error("No matching adapter found for attachment")}},_Y=k.createContext(null),CY=()=>k.useContext(_Y),Kl=Object.freeze([]),lc="DEFAULT_THREAD_ID",AY=Object.freeze([lc]),V5=Object.freeze({id:lc,remoteId:void 0,externalId:void 0,status:"regular"}),EY=Promise.resolve(),vD=Object.freeze({[lc]:V5}),kY=class{constructor(t={},e){this.adapter=t,this.threadFactory=e,this._mainThread=this.threadFactory(),this.__internal_setAdapter(t,!0)}_mainThreadId=lc;_threads=AY;_archivedThreads=Kl;_threadData=vD;get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadData(){return this._threadData}getLoadThreadsPromise(){return EY}_mainThread;get mainThreadId(){return this._mainThreadId}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw new Error("Method not implemented.")}getItemById(t){for(const e of this.adapter.threads??[])if(e.id===t)return e;for(const e of this.adapter.archivedThreads??[])if(e.id===t)return e;if(t===lc)return V5}__internal_setAdapter(t,e=!1){const n=this.adapter;this.adapter=t;const r=t.threadId??lc,i=t.threads??Kl,s=t.archivedThreads??Kl,o=n.threadId??lc,a=n.threads??Kl,c=n.archivedThreads??Kl;!e&&o===r&&a===i&&c===s||(this._threadData={...vD,...Object.fromEntries(t.threads?.map(h=>[h.id,{...h,remoteId:h.remoteId,externalId:h.externalId,status:"regular"}])??[]),...Object.fromEntries(t.archivedThreads?.map(h=>[h.id,{...h,remoteId:h.remoteId,externalId:h.externalId,status:"archived"}])??[])},a!==i&&(this._threads=this.adapter.threads?.map(h=>h.id)??Kl),c!==s&&(this._archivedThreads=this.adapter.archivedThreads?.map(h=>h.id)??Kl),o!==r&&(this._mainThreadId=r,this._mainThread=this.threadFactory()),this._notifySubscribers())}async switchToThread(t){if(this._mainThreadId===t)return;const e=this.adapter.onSwitchToThread;if(!e)throw new Error("External store adapter does not support switching to thread");e(t)}async switchToNewThread(){const t=this.adapter.onSwitchToNewThread;if(!t)throw new Error("External store adapter does not support switching to new thread");t()}async rename(t,e){const n=this.adapter.onRename;if(!n)throw new Error("External store adapter does not support renaming");n(t,e)}async detach(){}async archive(t){const e=this.adapter.onArchive;if(!e)throw new Error("External store adapter does not support archiving");e(t)}async unarchive(t){const e=this.adapter.onUnarchive;if(!e)throw new Error("External store adapter does not support unarchiving");e(t)}async delete(t){const e=this.adapter.onDelete;if(!e)throw new Error("External store adapter does not support deleting");e(t)}initialize(){throw new Error("Method not implemented.")}generateTitle(){throw new Error("Method not implemented.")}_subscriptions=new Set;subscribe(t){return this._subscriptions.add(t),()=>this._subscriptions.delete(t)}_notifySubscribers(){for(const t of this._subscriptions)t()}},wD=class{cache=new WeakMap;convertMessages(t,e){return t.map((n,r)=>{const i=this.cache.get(n),s=e(i,n,r);return this.cache.set(n,s),s})}},TY=class extends O5{constructor(t,e,{parentId:n,message:r}){super(),this.runtime=t,this.endEditCallback=e,this._parentId=n,this._sourceId=r.id,this._previousText=Vp(r),this.setText(this._previousText),this.setRole(r.role),this.setAttachments(r.attachments??[]),this._nonTextParts=r.content.filter(i=>i.type!=="text"),this.setRunConfig({...t.composer.runConfig})}get canCancel(){return!0}getAttachmentAdapter(){return this.runtime.adapters?.attachments}_nonTextParts;_previousText;_parentId;_sourceId;async handleSend(t){Vp(t)!==this._previousText&&this.runtime.append({...t,content:[...t.content,...this._nonTextParts],parentId:this._parentId,sourceId:this._sourceId}),this.handleCancel()}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},RY=class{constructor(t){this._contextProvider=t}_subscriptions=new Set;_isInitialized=!1;repository=new ME;get messages(){return this.repository.getMessages()}get state(){let t;for(const e of this.messages)if(e.role==="assistant"){t=e;break}return t?.metadata.unstable_state??null}composer=new P5(this);getModelContext(){return this._contextProvider.getModelContext()}_editComposers=new Map;getEditComposer(t){return this._editComposers.get(t)}beginEdit(t){if(this._editComposers.has(t))throw new Error("Edit already in progress");this._editComposers.set(t,new TY(this,()=>this._editComposers.delete(t),this.repository.getMessage(t))),this._notifySubscribers()}getMessageById(t){try{return this.repository.getMessage(t)}catch{return}}getBranches(t){return this.repository.getBranches(t)}switchToBranch(t){this.repository.switchToBranch(t),this._notifySubscribers()}_notifySubscribers(){for(const t of this._subscriptions)t()}_notifyEventSubscribers(t){const e=this._eventSubscribers.get(t);if(e)for(const n of e)n()}subscribe(t){return this._subscriptions.add(t),()=>this._subscriptions.delete(t)}_submittedFeedback={};getSubmittedFeedback(t){return this._submittedFeedback[t]}submitFeedback({messageId:t,type:e}){const n=this.adapters?.feedback;if(!n)throw new Error("Feedback adapter not configured");const{message:r}=this.repository.getMessage(t);n.submit({message:r,type:e}),this._submittedFeedback[t]={type:e},this._notifySubscribers()}_stopSpeaking;speech;speak(t){const e=this.adapters?.speech;if(!e)throw new Error("Speech adapter not configured");const{message:n}=this.repository.getMessage(t);this._stopSpeaking?.();const r=e.speak(Vp(n)),i=r.subscribe(()=>{r.status.type==="ended"?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:t,status:r.status},this._notifySubscribers()});this.speech={messageId:t,status:r.status},this._notifySubscribers(),this._stopSpeaking=()=>{r.cancel(),i(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw new Error("No message is being spoken");this._stopSpeaking(),this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers("initialize"))}export(){return this.repository.export()}import(t){this.ensureInitialized(),this.repository.clear(),this.repository.import(t),this._notifySubscribers()}reset(t){this.import(RE.fromArray(t??[]))}_eventSubscribers=new Map;unstable_on(t,e){if(t==="model-context-update")return this._contextProvider.subscribe?.(e)??(()=>{});const n=this._eventSubscribers.get(t);return n?n.add(e):this._eventSubscribers.set(t,new Set([e])),()=>{this._eventSubscribers.get(t).delete(e)}}},MY=Object.freeze([]),OY=(t,e)=>t&&e[e.length-1]?.role!=="assistant",PY=class extends RY{_assistantOptimisticId=null;_capabilities={switchToBranch:!1,edit:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,attachments:!1,feedback:!1};get capabilities(){return this._capabilities}_messages;isDisabled;get isLoading(){return this._store.isLoading??!1}get messages(){return this._messages}get adapters(){return this._store.adapters}suggestions=[];extras=void 0;_converter=new wD;_store;beginEdit(t){if(!this._store.onEdit)throw new Error("Runtime does not support editing.");super.beginEdit(t)}constructor(t,e){super(t),this.__internal_setAdapter(e)}__internal_setAdapter(t){if(this._store===t)return;const e=t.isRunning??!1;this.isDisabled=t.isDisabled??!1;const n=this._store;this._store=t,this.extras=t.extras,this.suggestions=t.suggestions??MY,this._capabilities={switchToBranch:this._store.setMessages!==void 0,edit:this._store.onEdit!==void 0,reload:this._store.onReload!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback};let r;if(t.messageRepository){if(n&&n.isRunning===t.isRunning&&n.messageRepository===t.messageRepository){this._notifySubscribers();return}this.repository.clear(),this._assistantOptimisticId=null,this.repository.import(t.messageRepository),r=this.repository.getMessages()}else if(t.messages){if(n){if(n.convertMessage!==t.convertMessage)this._converter=new wD;else if(n.isRunning===t.isRunning&&n.messages===t.messages){this._notifySubscribers();return}}r=t.convertMessage?this._converter.convertMessages(t.messages,(i,s,o)=>{if(!t.convertMessage)return s;const a=o===t.messages.length-1,c=TE(a,e,!1);if(i&&(i.role!=="assistant"||!KK(i.status)||i.status===c))return i;const h=t.convertMessage(s,o),f=ww(h,o.toString(),c);return f[Th]=s,f}):t.messages;for(let i=0;i<r.length;i++){const s=r[i],o=r[i-1];this.repository.addOrUpdateMessage(o?.id??null,s)}}else throw new Error("ExternalStoreAdapter must provide either 'messages' or 'messageRepository'");r.length>0&&this.ensureInitialized(),(n?.isRunning??!1)!==(t.isRunning??!1)&&(t.isRunning?this._notifyEventSubscribers("run-start"):this._notifyEventSubscribers("run-end")),this._assistantOptimisticId&&(this.repository.deleteMessage(this._assistantOptimisticId),this._assistantOptimisticId=null),OY(e,r)&&(this._assistantOptimisticId=this.repository.appendOptimisticMessage(r.at(-1)?.id??null,{role:"assistant",content:[]})),this.repository.resetHead(this._assistantOptimisticId??r.at(-1)?.id??null),this._messages=this.repository.getMessages(),this._notifySubscribers()}switchToBranch(t){if(!this._store.setMessages)throw new Error("Runtime does not support switching branches.");this.repository.switchToBranch(t),this.updateMessages(this.repository.getMessages())}async append(t){if(t.parentId!==(this.messages.at(-1)?.id??null)){if(!this._store.onEdit)throw new Error("Runtime does not support editing messages.");await this._store.onEdit(t)}else await this._store.onNew(t)}async startRun(t){if(!this._store.onReload)throw new Error("Runtime does not support reloading messages.");await this._store.onReload(t.parentId,t)}async resumeRun(t){if(!this._store.onResume)throw new Error("Runtime does not support resuming runs.");await this._store.onResume(t)}unstable_loadExternalState(t){if(!this._store.onLoadExternalState)throw new Error("Runtime does not support importing states.");this._store.onLoadExternalState(t)}cancelRun(){if(!this._store.onCancel)throw new Error("Runtime does not support cancelling runs.");this._store.onCancel(),this._assistantOptimisticId&&(this.repository.deleteMessage(this._assistantOptimisticId),this._assistantOptimisticId=null);let t=this.repository.getMessages();const e=t[t.length-1];e?.role==="user"&&e.id===t.at(-1)?.id?(this.repository.deleteMessage(e.id),this.composer.text.trim()||this.composer.setText(Vp(e)),t=this.repository.getMessages()):this._notifySubscribers(),setTimeout(()=>{this.updateMessages(t)},0)}addToolResult(t){if(!this._store.onAddToolResult&&!this._store.onAddToolResult)throw new Error("Runtime does not support tool results.");this._store.onAddToolResult?.(t)}reset(t){const e=new ME;e.import(RE.fromArray(t??[])),this.updateMessages(e.getMessages())}import(t){this._assistantOptimisticId=null,super.import(t),this._store.onImport&&this._store.onImport(this.repository.getMessages())}updateMessages=t=>{this._store.convertMessage!==void 0?this._store.setMessages?.(t.flatMap(tY).filter(n=>n!=null)):this._store.setMessages?.(t)}},xD=t=>t.adapters?.threadList??{},DY=class extends M5{threads;constructor(t){super(),this.threads=new kY(xD(t),()=>new PY(this._contextProvider,t))}setAdapter(t){this.threads.__internal_setAdapter(xD(t)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(t)}},IY=t=>{const[e]=k.useState(()=>new DY(t));k.useEffect(()=>{e.setAdapter(t)});const{modelContext:n}=CY()??{};return k.useEffect(()=>{if(n)return e.registerModelContextProvider(n)},[n,e]),k.useMemo(()=>new tj(e),[e])},Sw=t=>typeof t=="string"?{scope:t.split(".")[0],event:t}:{scope:t.scope,event:t.event},gp=(t,e,n)=>e===t;const SD=t=>{let e;const n=new Set,r=(h,f)=>{const d=typeof h=="function"?h(e):h;if(!Object.is(d,e)){const m=e;e=f??(typeof d!="object"||d===null)?d:Object.assign({},e,d),n.forEach(y=>y(e,m))}},i=()=>e,a={setState:r,getState:i,getInitialState:()=>c,subscribe:h=>(n.add(h),()=>n.delete(h))},c=e=t(r,i,a);return a},LY=(t=>t?SD(t):SD),NY=t=>t;function $Y(t,e=NY){const n=de.useSyncExternalStore(t.subscribe,de.useCallback(()=>e(t.getState()),[t,e]),de.useCallback(()=>e(t.getInitialState()),[t,e]));return de.useDebugValue(n),n}const _D=t=>{const e=LY(t),n=r=>$Y(e,r);return Object.assign(n,e),n},na=(t=>t?_D(t):_D);var jY=()=>{const t=new Set;return na(()=>({isAtBottom:!0,scrollToBottom:()=>{for(const e of t)e()},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)})}))};function BY(t,e){function n(r){const i=k.useContext(t);if(!r?.optional&&!i)throw new Error(`This component must be used within ${e}.`);return i}return n}function U5(t,e){function n(i){const s=t(i);return s?s[e]:null}function r(i){let s=!1,o;typeof i=="function"?o=i:i&&typeof i=="object"&&(s=!!i.optional,o=i.selector);const a=n({optional:s});return a?o?a(o):a():null}return{[e]:r,[`${e}Store`]:n}}var H5=k.createContext(null),FY=BY(H5,"ThreadPrimitive.Viewport"),{useThreadViewport:zY,useThreadViewportStore:W5}=U5(FY,"useThreadViewport"),Yb=t=>t,VY=()=>{const t=W5({optional:!0}),[e]=k.useState(()=>jY());return k.useEffect(()=>t?.getState().onScrollToBottom(()=>{e.getState().scrollToBottom()}),[t,e]),k.useEffect(()=>{if(t)return e.subscribe(n=>{t.getState().isAtBottom!==n.isAtBottom&&Yb(t).setState({isAtBottom:n.isAtBottom})})},[e,t]),e},q5=({children:t})=>{const e=VY(),[n]=k.useState(()=>({useThreadViewport:e}));return C.jsx(H5.Provider,{value:n,children:t})},Gn=t=>{const e=t.get;return e.source=t.source,e.query=t.query,e},ul=()=>()=>{},G5=k.createContext({threads:Gn({source:null,query:{},get:()=>{throw new Error("Threads is only available inside <AssistantProvider />")}}),toolUIs:Gn({source:null,query:{},get:()=>{throw new Error("ToolUIs is only available inside <AssistantProvider />")}}),threadListItem:Gn({source:null,query:{},get:()=>{throw new Error("ThreadListItem is only available inside <AssistantProvider />")}}),thread:Gn({source:null,query:{},get:()=>{throw new Error("Thread is only available inside <AssistantProvider />")}}),composer:Gn({source:null,query:{},get:()=>{throw new Error("Composer is only available inside <AssistantProvider />")}}),message:Gn({source:null,query:{},get:()=>{throw new Error("Message is only available inside <ThreadPrimitive.Messages />")}}),part:Gn({source:null,query:{},get:()=>{throw new Error("Part is only available inside <MessagePrimitive.Parts />")}}),attachment:Gn({source:null,query:{},get:()=>{throw new Error("Attachment is only available inside <MessagePrimitive.Attachments /> or <ComposerPrimitive.Attachments />")}}),subscribe:ul,flushSync:ul,on:t=>{const{scope:e}=Sw(t);throw new Error(`Event scope is not available in this component: ${e}`)},registerModelContextProvider:()=>{throw new Error("Registering model context providers is only available inside <AssistantProvider />")},__internal_getRuntime:()=>null}),Ti=()=>k.useContext(G5),UY=(t,e)=>t===ul?e:e===ul?t:(...n)=>{t(...n),e(...n)},HY=(t,e)=>t===ul?e:e===ul?t:(...n)=>{const r=t(...n),i=e(...n);return()=>{r(),i()}},WY=(t,e)=>{const n=e.subscribe,r=e.flushSync;return{...t,...e,subscribe:HY(t.subscribe,n??ul),flushSync:UY(t.flushSync,r??ul)}},_w=({api:t,children:e})=>{const n=Ti(),r=k.useMemo(()=>WY(n,t),[n,t]);return C.jsx(G5,{value:r,children:C.jsx(q5,{children:e})})};function Jn(t){return(e,n)=>({type:t,props:e,...n?.key!==void 0&&{key:n.key}})}var yp=null;function qY(t,e){t.currentIndex=0;const n=yp;yp=t;try{if(e(),t.isFirstRender=!1,t.cells.length!==t.currentIndex)throw new Error(`Rendered ${t.currentIndex} hooks but expected ${t.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{yp=n}}function PE(){if(!yp)throw new Error("No resource fiber available");return yp}var GY=t=>{if(t.renderContext)throw new Error("Resource updated during render");if(t.isNeverMounted)throw new Error("Resource updated before mount");t.isMounted&&t.scheduleRerender()};function KY(t){const e=PE(),n=e.currentIndex++;if(!e.isFirstRender&&n>=e.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");if(!e.cells[n]){const s={type:"state",value:typeof t=="function"?t():t,set:o=>{const a=s.value,c=typeof o=="function"?o(a):o;Object.is(a,c)||(s.value=c,GY(e))}};e.cells[n]=s}const r=e.cells[n];if(r.type!=="state")throw new Error("Hook order changed between renders");return r}function Go(t){const e=KY(t);return[e.value,e.set]}function YY(){const t=PE(),e=t.currentIndex++;if(!t.isFirstRender&&e>=t.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");if(!t.cells[e]){const r={type:"effect",mounted:!1};t.cells[e]=r}if(t.cells[e].type!=="effect")throw new Error("Hook order changed between renders");return e}function Ss(t,e){const n=PE(),r=YY();n.renderContext.commitTasks.push({effect:t,deps:e,cellIndex:r})}function Xb(t){const[e]=Go(()=>({current:t!==void 0&&typeof t=="function"?t():t}));return e}var XY=(t,e)=>{if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Object.is(t[n],e[n]))return!1;return!0},Ht=(t,e)=>{const n=Xb(()=>({value:t(),deps:e}));return XY(n.current.deps,e)||(n.current.value=t(),n.current.deps=e),n.current.value};function JY(t,e){t.commitTasks.forEach(n=>{const r=n.cellIndex,i=e.cells[r];if(i.type!=="effect")throw new Error("Cannot find effect cell");let s=!0;if(i.deps!==void 0&&n.deps!==void 0&&(s=i.deps.length!==n.deps.length||i.deps.some((o,a)=>!Object.is(o,n.deps[a]))),s){if(i.mounted){if(typeof i.deps!=typeof n.deps)throw new Error("tapEffect called with and without dependencies across re-renders");try{i.mounted&&i.cleanup&&i.cleanup()}finally{i.mounted=!1}}try{const o=n.effect();if(o!==void 0&&typeof o!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof o}`);i.mounted=!0,i.cleanup=typeof o=="function"?o:void 0,i.deps=n.deps}catch(o){throw o}}})}function QY(t){let e=null;for(let n=t.cells.length-1;n>=0;n--){const r=t.cells[n];if(r?.type==="effect"&&r.mounted&&r.cleanup)try{r.cleanup()}catch(i){e==null&&(e=i)}finally{r.mounted=!1}}if(e!=null)throw e}function Cw(t,e){return{resourceFn:t,scheduleRerender:e,cells:[],currentIndex:0,renderContext:void 0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function fh(t){t.isMounted=!1,QY(t)}function Up(t,e){const n={commitTasks:[],props:e,state:void 0};return qY(t,()=>{t.renderContext=n;try{n.state=t.resourceFn(e)}finally{t.renderContext=void 0}}),n}function dh(t,e){t.isMounted=!0,t.isNeverMounted=!1,JY(e,t)}function ZY(t,e){const[n,r]=Go({}),i=Ht(()=>Cw(t.type,()=>r({})),[t.type]),s=e?Ht(()=>t.props,e):t.props,o=Ht(()=>Up(i,s),[i,s,n]);return Ss(()=>()=>fh(i),[i]),Ss(()=>{dh(i,o)},[i,o]),o.state}function _s(t){return t.type(t.props)}function eX(t){const e=new Set;t.forEach((a,c)=>{if(a.key===void 0)throw new Error(`tapResources: All resource elements must have a key. Element at index ${c} is missing a key.`);if(e.has(a.key))throw new Error(`tapResources: Duplicate key "${a.key}" found. All keys must be unique.`);e.add(a.key)});const[n,r]=Go({}),i=Ht(()=>new Map(t.map(a=>[a.key,a])),[t]),[s]=Go(()=>new Map),o=Ht(()=>{const a=new Map,c=new Set;return i.forEach((h,f)=>{c.add(f);let d=s.get(f);(!d||d.resourceFn!==h.type)&&(d&&fh(d),d=Cw(h.type,()=>r({})),s.set(f,d));const m=Up(d,h.props);a.set(f,m)}),s.forEach((h,f)=>{c.has(f)||(fh(h),s.delete(f))}),a},[i,n]);return Ss(()=>{o.forEach((a,c)=>{const h=s.get(c);h&&dh(h,a)})},[o,s]),Ss(()=>()=>{s.forEach(a=>{fh(a)}),s.clear()},[s]),Ht(()=>t.map(a=>o.get(a.key)?.state),[t,o])}var z2=[],V2=!1;function tX(){V2=!1;const t=z2;z2=[];for(const e of t)try{e()}catch(n){console.error("Error in scheduled task:",n)}}function nX(t){z2.push(t),V2||(V2=!0,queueMicrotask(tX))}var rX=class K5{constructor(e){this._task=e}_isDirty=!1;_hasScheduledTask=!1;_isFlushing=!1;static MAX_FLUSH_DEPTH=50;get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,!(this._hasScheduledTask||this._isFlushing)&&(this._hasScheduledTask=!0,nX(()=>{this._hasScheduledTask=!1,this.flushSync()}))}flushSync(){if(this._isFlushing)return;this._isFlushing=!0;let e=0;try{for(;this._isDirty;){if(e++,e>K5.MAX_FLUSH_DEPTH)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside tapEffect.");this._isDirty=!1,this._task()}}finally{this._isFlushing=!1}}},iX=({element:t,onUpdateInput:e,onFlushSync:n,onDispose:r})=>{const[i,s]=Go(t.props),o=_s({type:t.type,props:i}),a=Xb(new Set).current,c=Xb(o);return Ss(()=>{o!==c.current&&(c.current=o,a.forEach(f=>f()))}),Ht(()=>({getState:()=>c.current,subscribe:f=>(a.add(f),()=>a.delete(f)),updateInput:f=>{e(),s(()=>f)},flushSync:n,dispose:r}),[])},sX=(t,e=!1)=>{let n=!e;const r={element:t,onUpdateInput:()=>{n||(n=!0,dh(s,o))},onFlushSync:()=>{i.flushSync()},onDispose:()=>fh(s)},i=new rX(()=>{o=Up(s,r),n&&dh(s,o)}),s=Cw(iX,()=>i.markDirty());let o=Up(s,r);return n&&dh(s,o),o.state},bp=Symbol("tap.Context"),oX=t=>({[bp]:t}),aX=(t,e,n)=>{const r=t[bp];t[bp]=e;try{return n()}finally{t[bp]=r}},lX=t=>t[bp],Y5=Jn(t=>{const e=Ht(()=>sX(t,!0),[t.type]);return Ss(()=>{e.updateInput(t.props)}),e}),cX=class{constructor(t){this.getApi=t}get(t,e){return this.getApi()[e]}ownKeys(){return Object.keys(this.getApi())}has(t,e){return e in this.getApi()}getOwnPropertyDescriptor(t,e){return Object.getOwnPropertyDescriptor(this.getApi(),e)}set(){return!1}defineProperty(){return!1}deleteProperty(){return!1}},bo=(t,e)=>{const n=Xb(()=>t);Ss(()=>{n.current=t});const r=Ht(()=>new Proxy({},new cX(()=>n.current)),[]),i=e?.key,s=t.getState();return Ht(()=>({key:i,state:s,api:r}),[s,i])},uX=globalThis.__ASSISTANT_UI_DISABLE_LAYOUT_EFFECT__===!0,CD=uX?k.useEffect:k.useLayoutEffect;function X5(t){const[,e]=k.useState({}),n=k.useMemo(()=>Cw(t.type,()=>e({})),[t.type]),r=Up(n,t.props);return CD(()=>()=>fh(n),[]),CD(()=>{dh(n,r)}),r.state}var hX=Jn(()=>Ht(()=>{const e=new Map;return{on:(n,r)=>{e.has(n)||e.set(n,new Set);const i=e.get(n);return i.add(r),()=>{i.delete(r),i.size===0&&e.delete(n)}},emit:(n,r)=>{const i=e.get(n),s=e.get("*");!i&&!s||queueMicrotask(()=>{if(i)for(const o of i)o(r);if(s)for(const o of s)o({event:n,payload:r})})}}},[])),fX=Jn(()=>{const[t,e]=Go(()=>({}));return bo({getState:()=>t,setToolUI:(n,r)=>(e(i=>({...i,[n]:[...i[n]??[],r]})),()=>{e(i=>({...i,[n]:i[n]?.filter(s=>s!==r)??[]}))})})}),J5=oX(null),dX=(t,e)=>aX(J5,t,e),DE=()=>{const t=lX(J5);if(!t)throw new Error("Events context is not available");return t},pX=Jn(({threads:t,registerModelContextProvider:e,__internal_runtime:n})=>{const r=_s(hX()),{threads:i,toolUIs:s}=dX(r,()=>({toolUIs:_s(fX()),threads:ZY(t,[t])})),o=Ht(()=>({threads:i.state,toolUIs:s.state}),[i.state,s.state]);return bo({getState:()=>o,threads:i.api,toolUIs:s.api,on:r.on,registerModelContextProvider:e,__internal_getRuntime:()=>n??null})}),mX=t=>{const e=()=>t.getState().api.threads.item("main");return{threads:Gn({source:"root",query:{},get:()=>t.getState().api.threads}),toolUIs:Gn({source:"root",query:{},get:()=>t.getState().api.toolUIs}),thread:Gn({source:"threads",query:{type:"main"},get:()=>t.getState().api.threads.thread("main")}),threadListItem:Gn({source:"threads",query:{type:"main"},get:()=>e()}),composer:Gn({source:"thread",query:{},get:()=>t.getState().api.threads.thread("main").composer}),registerModelContextProvider(n){return t.getState().api.registerModelContextProvider(n)},__internal_getRuntime(){return t.getState().api.__internal_getRuntime()},on(n,r){const{event:i,scope:s}=Sw(n);if(s==="*")return t.getState().api.on(i,r);if(gp("thread",s)||gp("thread-list-item",s)||gp("composer",s))return t.getState().api.on(i,o=>{o.threadId===e().getState().id&&r(o)});throw new Error(`Event scope is not available in this component: ${s}`)},subscribe:t.subscribe,flushSync:t.flushSync}},gX=t=>{const e=X5(Y5(pX(t)));return k.useMemo(()=>mX(e),[e])},Dc=t=>{const[,e]=Go(t.getState);return Ss(()=>(e(t.getState()),t.subscribe(()=>{e(t.getState())})),[t]),t.getState()},yX=Jn(({runtime:t})=>{const e=Dc(t),n=DE();return Ss(()=>{const r=[],i=["switched-to","switched-away"];for(const s of i){const o=t.unstable_on(s,()=>{n.emit(`thread-list-item.${s}`,{threadId:t.getState().id})});r.push(o)}return()=>{for(const s of r)s()}},[t,n]),bo({getState:()=>e,switchTo:t.switchTo,rename:t.rename,archive:t.archive,unarchive:t.unarchive,delete:t.delete,generateTitle:t.generateTitle,initialize:t.initialize,detach:t.detach,__internal_getRuntime:()=>t},{key:e.id})}),Hp=t=>{const e=eX(t);return{state:e.map(n=>n.state),api:n=>{const r="index"in n?e[n.index]?.api:e.find(i=>i.key===n.key)?.api;if(!r)throw new Error(`tapLookupResources: Resource not found for lookup: ${JSON.stringify(n)}`);return r}}},Q5=Jn(({runtime:t})=>{const e=Dc(t);return bo({getState:()=>e,remove:t.remove,__internal_getRuntime:()=>t},{key:e.id})}),bX=Jn(({runtime:t,index:e})=>{const n=Ht(()=>t.getAttachmentByIndex(e),[t,e]);return _s(Q5({runtime:n}))}),Z5=Jn(({threadIdRef:t,messageIdRef:e,runtime:n})=>{const r=Dc(n),i=DE();Ss(()=>{const a=[],c=["send","attachment-add"];for(const h of c){const f=n.unstable_on(h,()=>{i.emit(`composer.${h}`,{threadId:t.current,...e&&{messageId:e.current}})});a.push(f)}return()=>{for(const h of a)h()}},[n,i,t,e]);const s=Hp(r.attachments.map((a,c)=>bX({runtime:n,index:c},{key:c}))),o=Ht(()=>({text:r.text,role:r.role,attachments:s.state,runConfig:r.runConfig,isEditing:r.isEditing,canCancel:r.canCancel,attachmentAccept:r.attachmentAccept,isEmpty:r.isEmpty,type:r.type??"thread"}),[r,s.state]);return bo({getState:()=>o,setText:n.setText,setRole:n.setRole,setRunConfig:n.setRunConfig,addAttachment:n.addAttachment,reset:n.reset,clearAttachments:n.clearAttachments,send:n.send,cancel:n.cancel,beginEdit:n.beginEdit??(()=>{throw new Error("beginEdit is not supported in this runtime")}),attachment:a=>"id"in a?s.api({key:a.id}):s.api(a),__internal_getRuntime:()=>n})}),vX=Jn(({runtime:t})=>{const e=Dc(t);return bo({getState:()=>e,addToolResult:n=>t.addToolResult(n),__internal_getRuntime:()=>t},{key:e.type==="tool-call"?"toolCallId-"+e.toolCallId:void 0})}),wX=Jn(({runtime:t,index:e})=>{const n=Ht(()=>t.getAttachmentByIndex(e),[t,e]);return _s(Q5({runtime:n}))}),xX=Jn(({runtime:t,index:e})=>{const n=Ht(()=>t.getMessagePartByIndex(e),[t,e]);return _s(vX({runtime:n}))}),SX=Jn(({runtime:t,threadIdRef:e})=>{const n=Dc(t),[r,i]=Go(!1),[s,o]=Go(!1),a=Ht(()=>({get current(){return t.getState().id}}),[t]),c=_s(Z5({runtime:t.composer,threadIdRef:e,messageIdRef:a})),h=Hp(n.content.map((m,y)=>xX({runtime:t,index:y},{key:y}))),f=Hp(n.attachments?.map((m,y)=>wX({runtime:t,index:y},{key:y}))??[]),d=Ht(()=>({...n,parts:h.state,composer:c.state,isCopied:r,isHovering:s}),[n,h.state,c.state,r,s]);return bo({getState:()=>d,composer:c.api,reload:m=>t.reload(m),speak:()=>t.speak(),stopSpeaking:()=>t.stopSpeaking(),submitFeedback:m=>t.submitFeedback(m),switchToBranch:m=>t.switchToBranch(m),getCopyText:()=>t.unstable_getCopyText(),part:m=>"index"in m?h.api({index:m.index}):h.api({key:"toolCallId-"+m.toolCallId}),attachment:m=>"id"in m?f.api({key:m.id}):f.api(m),setIsCopied:i,setIsHovering:o,__internal_getRuntime:()=>t},{key:n.id})}),_X=Jn(({runtime:t,id:e,threadIdRef:n})=>{const r=Ht(()=>t.getMessageById(e),[t,e]);return _s(SX({runtime:r,threadIdRef:n}))}),CX=Jn(({runtime:t})=>{const e=Dc(t),n=DE();Ss(()=>{const a=[],c=["run-start","run-end","initialize","model-context-update"];for(const h of c){const f=t.unstable_on(h,()=>{const d=t.getState()?.threadId||"unknown";n.emit(`thread.${h}`,{threadId:d})});a.push(f)}return()=>{for(const h of a)h()}},[t]);const r=Ht(()=>({get current(){return t.getState().threadId}}),[t]),i=_s(Z5({runtime:t.composer,threadIdRef:r})),s=Hp(e.messages.map(a=>_X({runtime:t,id:a.id,threadIdRef:r},{key:a.id}))),o=Ht(()=>({isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:e.isRunning,capabilities:e.capabilities,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,composer:i.state,messages:s.state}),[e,s,i.state]);return bo({getState:()=>o,composer:i.api,append:t.append,startRun:t.startRun,unstable_resumeRun:t.unstable_resumeRun,cancelRun:t.cancelRun,getModelContext:t.getModelContext,export:t.export,import:t.import,reset:t.reset,stopSpeaking:t.stopSpeaking,message:a=>"id"in a?s.api({key:a.id}):s.api(a),__internal_getRuntime:()=>t})}),AX=Jn(({runtime:t,id:e})=>{const n=Ht(()=>t.getItemById(e),[t,e]);return _s(yX({runtime:n}))}),EX=Jn(({runtime:t})=>{const e=Dc(t),n=_s(CX({runtime:t.main})),r=Hp(Object.keys(e.threadItems).map(s=>AX({runtime:t,id:s},{key:s}))),i=Ht(()=>({mainThreadId:e.mainThreadId,newThreadId:e.newThread??null,isLoading:e.isLoading,threadIds:e.threads,archivedThreadIds:e.archivedThreads,threadItems:r.state,main:n.state}),[e,r.state,n.state]);return bo({getState:()=>i,thread:()=>n.api,item:s=>{if(s==="main")return r.api({key:i.mainThreadId});if("id"in s)return r.api({key:s.id});const{index:o,archived:a=!1}=s,c=a?i.archivedThreadIds[o]:i.threadIds[o];return r.api({key:c})},switchToThread:s=>{t.switchToThread(s)},switchToNewThread:()=>{t.switchToNewThread()}})}),kX=t=>t._core?.RenderComponent,TX=({children:t,runtime:e})=>{const n=gX({threads:EX({runtime:e.threads}),registerModelContextProvider:e.registerModelContextProvider,__internal_runtime:e}),r=kX(e);return C.jsxs(_w,{api:n,children:[r&&C.jsx(r,{}),t]})},RX=k.memo(TX),MX=({index:t,children:e})=>{const n=Ti(),r=k.useMemo(()=>{const i=()=>n.thread().message({index:t});return{message:Gn({source:"thread",query:{type:"index",index:t},get:()=>i()}),composer:Gn({source:"message",query:{},get:()=>i().composer}),on(s,o){const{event:a,scope:c}=Sw(s);return!gp("composer",c)&&!gp("message",c)?n.on(s,o):n.on({scope:"thread",event:a},h=>{h.messageId===i().getState().id&&o(h)})}}},[n,t]);return C.jsx(_w,{api:r,children:e})},OX=({index:t,children:e})=>{const n=Ti(),r=k.useMemo(()=>({part:Gn({source:"message",query:{type:"index",index:t},get:()=>n.message().part({index:t})})}),[n,t]);return C.jsx(_w,{api:r,children:e})},PX=Jn(({text:t,isRunning:e})=>{const n=Ht(()=>({type:"text",text:t,status:e?{type:"running"}:{type:"complete"}}),[t,e]);return bo({getState:()=>n,addToolResult:()=>{throw new Error("Not supported")},__internal_getRuntime:()=>null})}),DX=({text:t,isRunning:e=!1,children:n})=>{const r=X5(Y5(PX({text:t,isRunning:e}))),i=k.useMemo(()=>({part:Gn({source:"root",query:{},get:()=>r.getState().api}),subscribe:r.subscribe,flushSync:r.flushSync}),[r]);return C.jsx(_w,{api:i,children:n})},AD=class{#e;constructor(t){this.#e=t}get threads(){return this.#e.threads().getState()}get toolUIs(){return this.#e.toolUIs().getState()}get threadListItem(){return this.#e.threadListItem().getState()}get thread(){return this.#e.thread().getState()}get composer(){return this.#e.composer().getState()}get message(){return this.#e.message().getState()}get part(){return this.#e.part().getState()}get attachment(){return this.#e.attachment().getState()}},Mt=t=>{const e=Ti(),n=k.useMemo(()=>new AD(e),[e]),r=k.useSyncExternalStore(e.subscribe,()=>t(n),()=>t(n));if(k.useDebugValue(r),r instanceof AD)throw new Error("You tried to return the entire AssistantState. This is not supported due to technical limitations.");return r},IX=(t,e)=>{const n=Ti(),r=k.useRef(e);k.useEffect(()=>{r.current=e});const{scope:i,event:s}=Sw(t);k.useEffect(()=>n.on({scope:i,event:s},o=>r.current(o)),[n,i,s])},LX=t=>{const e=t;e.__isBound||(e.__internal_bindMethods?.(),e.__isBound=!0)};function NX(t,e=$X){LX(t);const n=k.useSyncExternalStore(t.subscribe,()=>e(t.getState()),()=>e(t.getState()));return k.useDebugValue(n),n}var $X=t=>t;function jX(t){function e(n){let r=!1,i;typeof n=="function"?i=n:n&&(r=!!n.optional,i=n.selector);const s=t({optional:r});return s?NX(s,i):null}return e}function BX(t){const e=Ti(),n=e.message.source?e.message().__internal_getRuntime():null;if(!n&&!t?.optional)throw new Error("MessageRuntime is not available");return n}var ej=jX(BX),tj=class{constructor(t){this._core=t,this.threads=new yY(t.threads),this._thread=this.threads.main,this.__internal_bindMethods()}threads;get threadList(){return this.threads}_thread;__internal_bindMethods(){this.switchToNewThread=this.switchToNewThread.bind(this),this.switchToThread=this.switchToThread.bind(this),this.registerModelContextProvider=this.registerModelContextProvider.bind(this),this.registerModelConfigProvider=this.registerModelConfigProvider.bind(this),this.reset=this.reset.bind(this)}get thread(){return this._thread}switchToNewThread(){return this._core.threads.switchToNewThread()}switchToThread(t){return this._core.threads.switchToThread(t)}registerModelContextProvider(t){return this._core.registerModelContextProvider(t)}registerModelConfigProvider(t){return this.registerModelContextProvider(t)}reset({initialMessages:t}={}){return this._core.threads.getMainThreadRuntimeCore().import(RE.fromArray(t??[]))}},FX=t=>{const{cloud:e,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:s,...o}=t;return{localRuntimeOptions:{cloud:e,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:s},otherOptions:o}};function Lr(t){const e=k.useRef(t);return k.useEffect(()=>{e.current=t}),k.useMemo(()=>(...n)=>e.current?.(...n),[])}var nj=k.createContext(null),zX=t=>({useSmoothStatus:na(()=>t)}),VX=({children:t})=>{const e=rj({optional:!0}),n=Ti(),[r]=k.useState(()=>zX(n.part().getState().status));return e?t:C.jsx(nj.Provider,{value:r,children:t})},UX=t=>{const e=k.forwardRef((n,r)=>C.jsx(VX,{children:C.jsx(t,{...n,ref:r})}));return e.displayName=t.displayName,e};function rj(t){const e=k.useContext(nj);if(!t?.optional&&!e)throw new Error("This component must be used within a SmoothContextProvider.");return e}var{useSmoothStatus:HX,useSmoothStatusStore:WX}=U5(rj,"useSmoothStatus"),qX=class{constructor(t,e){this.currentText=t,this.setText=e}animationFrameId=null;lastUpdateTime=Date.now();targetText="";start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{const t=Date.now();let n=t-this.lastUpdateTime;const r=this.targetText.length-this.currentText.length,i=Math.min(5,250/r);let s=0;for(;n>=i&&s<r;)s++,n-=i;s!==r?this.animationFrameId=requestAnimationFrame(this.animate):this.animationFrameId=null,s!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+s),this.lastUpdateTime=t-n,this.setText(this.currentText))}},jS=Object.freeze({type:"running"}),ij=(t,e=!1)=>{const{text:n}=t,r=Mt(({message:f})=>f.id),i=k.useRef(r),[s,o]=k.useState(n),a=WX({optional:!0}),c=Lr(f=>{if(o(f),a){const d=s!==f||t.status.type==="running"?jS:t.status;Yb(a).setState(d,!0)}});k.useEffect(()=>{if(a){const f=s!==n||t.status.type==="running"?jS:t.status;Yb(a).setState(f,!0)}},[a,n,s,t.status]);const[h]=k.useState(new qX(n,c));return k.useEffect(()=>{if(!e){h.stop();return}if(i.current!==r||!n.startsWith(h.targetText)){i.current=r,c(n),h.currentText=n,h.targetText=n,h.stop();return}h.targetText=n,h.start()},[c,h,r,e,n]),k.useEffect(()=>()=>{h.stop()},[h]),k.useMemo(()=>e?{type:"text",text:s,status:n===s?t.status:jS}:t,[e,s,t,n])};const GX=Object.freeze(Object.defineProperty({__proto__:null,AssistantRuntimeImpl:tj,BaseAssistantRuntimeCore:M5,CompositeContextProvider:R5,DefaultThreadComposerRuntimeCore:P5,MessageRepository:ME,ThreadRuntimeImpl:z5,fromThreadMessageLike:ww,generateId:vw,getAutoStatus:TE,splitLocalRuntimeOptions:FX,useSmooth:ij,useSmoothStatus:HX,withSmoothContextProvider:UX},Symbol.toStringTag,{value:"Module"}));function ED(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Aw(...t){return e=>{let n=!1;const r=t.map(i=>{const s=ED(i,e);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():ED(t[i],null)}}}}function Bt(...t){return k.useCallback(Aw(...t),t)}var IE=T5();const KX=Pc(IE);function Rh(t){const e=YX(t),n=k.forwardRef((r,i)=>{const{children:s,...o}=r,a=k.Children.toArray(s),c=a.find(JX);if(c){const h=c.props.children,f=a.map(d=>d===c?k.Children.count(h)>1?k.Children.only(null):k.isValidElement(h)?h.props.children:null:d);return C.jsx(e,{...o,ref:i,children:k.isValidElement(h)?k.cloneElement(h,void 0,f):null})}return C.jsx(e,{...o,ref:i,children:s})});return n.displayName=`${t}.Slot`,n}var sj=Rh("Slot");function YX(t){const e=k.forwardRef((n,r)=>{const{children:i,...s}=n;if(k.isValidElement(i)){const o=ZX(i),a=QX(s,i.props);return i.type!==k.Fragment&&(a.ref=r?Aw(r,o):o),k.cloneElement(i,a)}return k.Children.count(i)>1?k.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var oj=Symbol("radix.slottable");function XX(t){const e=({children:n})=>C.jsx(C.Fragment,{children:n});return e.displayName=`${t}.Slottable`,e.__radixId=oj,e}function JX(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===oj}function QX(t,e){const n={...e};for(const r in e){const i=t[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const c=s(...a);return i(...a),c}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...t,...n}}function ZX(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var eJ=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],st=eJ.reduce((t,e)=>{const n=Rh(`Primitive.${e}`),r=k.forwardRef((i,s)=>{const{asChild:o,...a}=i,c=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),C.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function aj(t,e){t&&IE.flushSync(()=>t.dispatchEvent(e))}var U2=(t=>(t.Hidden="hidden",t.Floating="floating",t.Normal="normal",t))(U2||{}),tJ=({hideWhenRunning:t,autohide:e,autohideFloat:n})=>Mt(({thread:r,message:i})=>t&&r.isRunning?"hidden":e==="always"||e==="not-last"&&!i.isLast?i.isHovering?n==="always"||n==="single-branch"&&i.branchCount<=1?"floating":"normal":"hidden":"normal"),lj=k.forwardRef(({hideWhenRunning:t,autohide:e,autohideFloat:n,...r},i)=>{const s=tJ({hideWhenRunning:t,autohide:e,autohideFloat:n});return s===U2.Hidden?null:C.jsx(st.div,{...s===U2.Floating?{"data-floating":"true"}:null,...r,ref:i})});lj.displayName="ActionBarPrimitive.Root";function Le(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t?.(i),n===!1||!i.defaultPrevented)return e?.(i)}}var nJ=({copiedDuration:t=3e3}={})=>{const e=Ti(),n=Mt(({message:o})=>(o.role!=="assistant"||o.status?.type!=="running")&&o.parts.some(a=>a.type==="text"&&a.text.length>0)),r=Mt(({composer:o})=>o.isEditing),i=Mt(({composer:o})=>o.text),s=k.useCallback(()=>{const o=r?i:e.message().getCopyText();o&&navigator.clipboard.writeText(o).then(()=>{e.message().setIsCopied(!0),setTimeout(()=>e.message().setIsCopied(!1),t)})},[e,r,i,t]);return n?s:null},cj=k.forwardRef(({copiedDuration:t,onClick:e,disabled:n,...r},i)=>{const s=Mt(({message:a})=>a.isCopied),o=nJ({copiedDuration:t});return C.jsx(st.button,{type:"button",...s?{"data-copied":"true"}:{},...r,ref:i,disabled:n||!o,onClick:Le(e,()=>{o?.()})})});cj.displayName="ActionBarPrimitive.Copy";var uj=(t,e,n=[])=>{const r=k.forwardRef((i,s)=>{const o={},a={};Object.keys(i).forEach(h=>{n.includes(h)?o[h]=i[h]:a[h]=i[h]});const c=e(o)??void 0;return C.jsx(st.button,{type:"button",...a,ref:s,disabled:a.disabled||!c,onClick:Le(a.onClick,c)})});return r.displayName=t,r};function hj(t,e=globalThis?.document){const n=Lr(t);k.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}function rJ(t,e){const n=k.createContext(e),r=s=>{const{children:o,...a}=s,c=k.useMemo(()=>a,Object.values(a));return C.jsx(n.Provider,{value:c,children:o})};r.displayName=t+"Provider";function i(s){const o=k.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${s}\` must be used within \`${t}\``)}return[r,i]}function ra(t,e=[]){let n=[];function r(s,o){const a=k.createContext(o),c=n.length;n=[...n,o];const h=d=>{const{scope:m,children:y,...b}=d,w=m?.[t]?.[c]||a,S=k.useMemo(()=>b,Object.values(b));return C.jsx(w.Provider,{value:S,children:y})};h.displayName=s+"Provider";function f(d,m){const y=m?.[t]?.[c]||a,b=k.useContext(y);if(b)return b;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[h,f]}const i=()=>{const s=n.map(o=>k.createContext(o));return function(a){const c=a?.[t]||s;return k.useMemo(()=>({[`__scope${t}`]:{...a,[t]:c}}),[a,c])}};return i.scopeName=t,[r,iJ(i,...e)]}function iJ(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:c,scopeName:h})=>{const d=c(s)[`__scope${h}`];return{...a,...d}},{});return k.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var sJ="DismissableLayer",H2="dismissableLayer.update",oJ="dismissableLayer.pointerDownOutside",aJ="dismissableLayer.focusOutside",kD,fj=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ew=k.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...c}=t,h=k.useContext(fj),[f,d]=k.useState(null),m=f?.ownerDocument??globalThis?.document,[,y]=k.useState({}),b=Bt(e,D=>d(D)),w=Array.from(h.layers),[S]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),_=w.indexOf(S),A=f?w.indexOf(f):-1,E=h.layersWithOutsidePointerEventsDisabled.size>0,P=A>=_,O=uJ(D=>{const $=D.target,F=[...h.branches].some(N=>N.contains($));!P||F||(i?.(D),o?.(D),D.defaultPrevented||a?.())},m),M=hJ(D=>{const $=D.target;[...h.branches].some(N=>N.contains($))||(s?.(D),o?.(D),D.defaultPrevented||a?.())},m);return hj(D=>{A===h.layers.size-1&&(r?.(D),!D.defaultPrevented&&a&&(D.preventDefault(),a()))},m),k.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(kD=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),TD(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=kD)}},[f,m,n,h]),k.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),TD())},[f,h]),k.useEffect(()=>{const D=()=>y({});return document.addEventListener(H2,D),()=>document.removeEventListener(H2,D)},[]),C.jsx(st.div,{...c,ref:b,style:{pointerEvents:E?P?"auto":"none":void 0,...t.style},onFocusCapture:Le(t.onFocusCapture,M.onFocusCapture),onBlurCapture:Le(t.onBlurCapture,M.onBlurCapture),onPointerDownCapture:Le(t.onPointerDownCapture,O.onPointerDownCapture)})});Ew.displayName=sJ;var lJ="DismissableLayerBranch",cJ=k.forwardRef((t,e)=>{const n=k.useContext(fj),r=k.useRef(null),i=Bt(e,r);return k.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),C.jsx(st.div,{...t,ref:i})});cJ.displayName=lJ;function uJ(t,e=globalThis?.document){const n=Lr(t),r=k.useRef(!1),i=k.useRef(()=>{});return k.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){dj(oJ,n,h,{discrete:!0})};const h={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=c,e.addEventListener("click",i.current,{once:!0})):c()}else e.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",s),e.removeEventListener("click",i.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function hJ(t,e=globalThis?.document){const n=Lr(t),r=k.useRef(!1);return k.useEffect(()=>{const i=s=>{s.target&&!r.current&&dj(aJ,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function TD(){const t=new CustomEvent(H2);document.dispatchEvent(t)}function dj(t,e,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?aj(i,s):i.dispatchEvent(s)}var BS=0;function pj(){k.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??RD()),document.body.insertAdjacentElement("beforeend",t[1]??RD()),BS++,()=>{BS===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),BS--}},[])}function RD(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var FS="focusScope.autoFocusOnMount",zS="focusScope.autoFocusOnUnmount",MD={bubbles:!1,cancelable:!0},fJ="FocusScope",LE=k.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=t,[a,c]=k.useState(null),h=Lr(i),f=Lr(s),d=k.useRef(null),m=Bt(e,w=>c(w)),y=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(r){let w=function(E){if(y.paused||!a)return;const P=E.target;a.contains(P)?d.current=P:Ka(d.current,{select:!0})},S=function(E){if(y.paused||!a)return;const P=E.relatedTarget;P!==null&&(a.contains(P)||Ka(d.current,{select:!0}))},_=function(E){if(document.activeElement===document.body)for(const O of E)O.removedNodes.length>0&&Ka(a)};document.addEventListener("focusin",w),document.addEventListener("focusout",S);const A=new MutationObserver(_);return a&&A.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",S),A.disconnect()}}},[r,a,y.paused]),k.useEffect(()=>{if(a){PD.add(y);const w=document.activeElement;if(!a.contains(w)){const _=new CustomEvent(FS,MD);a.addEventListener(FS,h),a.dispatchEvent(_),_.defaultPrevented||(dJ(bJ(mj(a)),{select:!0}),document.activeElement===w&&Ka(a))}return()=>{a.removeEventListener(FS,h),setTimeout(()=>{const _=new CustomEvent(zS,MD);a.addEventListener(zS,f),a.dispatchEvent(_),_.defaultPrevented||Ka(w??document.body,{select:!0}),a.removeEventListener(zS,f),PD.remove(y)},0)}}},[a,h,f,y]);const b=k.useCallback(w=>{if(!n&&!r||y.paused)return;const S=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,_=document.activeElement;if(S&&_){const A=w.currentTarget,[E,P]=pJ(A);E&&P?!w.shiftKey&&_===P?(w.preventDefault(),n&&Ka(E,{select:!0})):w.shiftKey&&_===E&&(w.preventDefault(),n&&Ka(P,{select:!0})):_===A&&w.preventDefault()}},[n,r,y.paused]);return C.jsx(st.div,{tabIndex:-1,...o,ref:m,onKeyDown:b})});LE.displayName=fJ;function dJ(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Ka(r,{select:e}),document.activeElement!==n)return}function pJ(t){const e=mj(t),n=OD(e,t),r=OD(e.reverse(),t);return[n,r]}function mj(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function OD(t,e){for(const n of t)if(!mJ(n,{upTo:e}))return n}function mJ(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function gJ(t){return t instanceof HTMLInputElement&&"select"in t}function Ka(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&gJ(t)&&e&&t.select()}}var PD=yJ();function yJ(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=DD(t,e),t.unshift(e)},remove(e){t=DD(t,e),t[0]?.resume()}}}function DD(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function bJ(t){return t.filter(e=>e.tagName!=="A")}var hl=globalThis?.document?k.useLayoutEffect:()=>{},vJ=k5[" useId ".trim().toString()]||(()=>{}),wJ=0;function ol(t){const[e,n]=k.useState(vJ());return hl(()=>{n(r=>r??String(wJ++))},[t]),e?`radix-${e}`:""}const xJ=["top","right","bottom","left"],fl=Math.min,Ci=Math.max,Jb=Math.round,D0=Math.floor,lo=t=>({x:t,y:t}),SJ={left:"right",right:"left",bottom:"top",top:"bottom"},_J={start:"end",end:"start"};function W2(t,e,n){return Ci(t,fl(e,n))}function Ko(t,e){return typeof t=="function"?t(e):t}function Yo(t){return t.split("-")[0]}function Hh(t){return t.split("-")[1]}function NE(t){return t==="x"?"y":"x"}function $E(t){return t==="y"?"height":"width"}const CJ=new Set(["top","bottom"]);function ro(t){return CJ.has(Yo(t))?"y":"x"}function jE(t){return NE(ro(t))}function AJ(t,e,n){n===void 0&&(n=!1);const r=Hh(t),i=jE(t),s=$E(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=Qb(o)),[o,Qb(o)]}function EJ(t){const e=Qb(t);return[q2(t),e,q2(e)]}function q2(t){return t.replace(/start|end/g,e=>_J[e])}const ID=["left","right"],LD=["right","left"],kJ=["top","bottom"],TJ=["bottom","top"];function RJ(t,e,n){switch(t){case"top":case"bottom":return n?e?LD:ID:e?ID:LD;case"left":case"right":return e?kJ:TJ;default:return[]}}function MJ(t,e,n,r){const i=Hh(t);let s=RJ(Yo(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(q2)))),s}function Qb(t){return t.replace(/left|right|bottom|top/g,e=>SJ[e])}function OJ(t){return{top:0,right:0,bottom:0,left:0,...t}}function gj(t){return typeof t!="number"?OJ(t):{top:t,right:t,bottom:t,left:t}}function Zb(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function ND(t,e,n){let{reference:r,floating:i}=t;const s=ro(e),o=jE(e),a=$E(o),c=Yo(e),h=s==="y",f=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,m=r[a]/2-i[a]/2;let y;switch(c){case"top":y={x:f,y:r.y-i.height};break;case"bottom":y={x:f,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:d};break;case"left":y={x:r.x-i.width,y:d};break;default:y={x:r.x,y:r.y}}switch(Hh(e)){case"start":y[o]-=m*(n&&h?-1:1);break;case"end":y[o]+=m*(n&&h?-1:1);break}return y}const PJ=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(e));let h=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:d}=ND(h,r,c),m=r,y={},b=0;for(let w=0;w<a.length;w++){const{name:S,fn:_}=a[w],{x:A,y:E,data:P,reset:O}=await _({x:f,y:d,initialPlacement:r,placement:m,strategy:i,middlewareData:y,rects:h,platform:o,elements:{reference:t,floating:e}});f=A??f,d=E??d,y={...y,[S]:{...y[S],...P}},O&&b<=50&&(b++,typeof O=="object"&&(O.placement&&(m=O.placement),O.rects&&(h=O.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):O.rects),{x:f,y:d}=ND(h,m,c)),w=-1)}return{x:f,y:d,placement:m,strategy:i,middlewareData:y}};async function Wp(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:c}=t,{boundary:h="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:m=!1,padding:y=0}=Ko(e,t),b=gj(y),S=a[m?d==="floating"?"reference":"floating":d],_=Zb(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(S)))==null||n?S:S.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:h,rootBoundary:f,strategy:c})),A=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),P=await(s.isElement==null?void 0:s.isElement(E))?await(s.getScale==null?void 0:s.getScale(E))||{x:1,y:1}:{x:1,y:1},O=Zb(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:A,offsetParent:E,strategy:c}):A);return{top:(_.top-O.top+b.top)/P.y,bottom:(O.bottom-_.bottom+b.bottom)/P.y,left:(_.left-O.left+b.left)/P.x,right:(O.right-_.right+b.right)/P.x}}const DJ=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:c}=e,{element:h,padding:f=0}=Ko(t,e)||{};if(h==null)return{};const d=gj(f),m={x:n,y:r},y=jE(i),b=$E(y),w=await o.getDimensions(h),S=y==="y",_=S?"top":"left",A=S?"bottom":"right",E=S?"clientHeight":"clientWidth",P=s.reference[b]+s.reference[y]-m[y]-s.floating[b],O=m[y]-s.reference[y],M=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let D=M?M[E]:0;(!D||!await(o.isElement==null?void 0:o.isElement(M)))&&(D=a.floating[E]||s.floating[b]);const $=P/2-O/2,F=D/2-w[b]/2-1,N=fl(d[_],F),U=fl(d[A],F),q=N,K=D-w[b]-U,X=D/2-w[b]/2+$,ee=W2(q,X,K),V=!c.arrow&&Hh(i)!=null&&X!==ee&&s.reference[b]/2-(X<q?N:U)-w[b]/2<0,G=V?X<q?X-q:X-K:0;return{[y]:m[y]+G,data:{[y]:ee,centerOffset:X-ee-G,...V&&{alignmentOffset:G}},reset:V}}}),IJ=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:c,elements:h}=e,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:w=!0,...S}=Ko(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const _=Yo(i),A=ro(a),E=Yo(a)===a,P=await(c.isRTL==null?void 0:c.isRTL(h.floating)),O=m||(E||!w?[Qb(a)]:EJ(a)),M=b!=="none";!m&&M&&O.push(...MJ(a,w,b,P));const D=[a,...O],$=await Wp(e,S),F=[];let N=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&F.push($[_]),d){const X=AJ(i,o,P);F.push($[X[0]],$[X[1]])}if(N=[...N,{placement:i,overflows:F}],!F.every(X=>X<=0)){var U,q;const X=(((U=s.flip)==null?void 0:U.index)||0)+1,ee=D[X];if(ee&&(!(d==="alignment"?A!==ro(ee):!1)||N.every(H=>ro(H.placement)===A?H.overflows[0]>0:!0)))return{data:{index:X,overflows:N},reset:{placement:ee}};let V=(q=N.filter(G=>G.overflows[0]<=0).sort((G,H)=>G.overflows[1]-H.overflows[1])[0])==null?void 0:q.placement;if(!V)switch(y){case"bestFit":{var K;const G=(K=N.filter(H=>{if(M){const se=ro(H.placement);return se===A||se==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(se=>se>0).reduce((se,T)=>se+T,0)]).sort((H,se)=>H[1]-se[1])[0])==null?void 0:K[0];G&&(V=G);break}case"initialPlacement":V=a;break}if(i!==V)return{reset:{placement:V}}}return{}}}};function $D(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function jD(t){return xJ.some(e=>t[e]>=0)}const LJ=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...i}=Ko(t,e);switch(r){case"referenceHidden":{const s=await Wp(e,{...i,elementContext:"reference"}),o=$D(s,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:jD(o)}}}case"escaped":{const s=await Wp(e,{...i,altBoundary:!0}),o=$D(s,n.floating);return{data:{escapedOffsets:o,escaped:jD(o)}}}default:return{}}}}},yj=new Set(["left","top"]);async function NJ(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Yo(n),a=Hh(n),c=ro(n)==="y",h=yj.has(o)?-1:1,f=s&&c?-1:1,d=Ko(e,t);let{mainAxis:m,crossAxis:y,alignmentAxis:b}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof b=="number"&&(y=a==="end"?b*-1:b),c?{x:y*f,y:m*h}:{x:m*h,y:y*f}}const $J=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=e,c=await NJ(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:s+c.y,data:{...c,placement:o}}}}},jJ=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:a={fn:S=>{let{x:_,y:A}=S;return{x:_,y:A}}},...c}=Ko(t,e),h={x:n,y:r},f=await Wp(e,c),d=ro(Yo(i)),m=NE(d);let y=h[m],b=h[d];if(s){const S=m==="y"?"top":"left",_=m==="y"?"bottom":"right",A=y+f[S],E=y-f[_];y=W2(A,y,E)}if(o){const S=d==="y"?"top":"left",_=d==="y"?"bottom":"right",A=b+f[S],E=b-f[_];b=W2(A,b,E)}const w=a.fn({...e,[m]:y,[d]:b});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[m]:s,[d]:o}}}}}},BJ=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=e,{offset:a=0,mainAxis:c=!0,crossAxis:h=!0}=Ko(t,e),f={x:n,y:r},d=ro(i),m=NE(d);let y=f[m],b=f[d];const w=Ko(a,e),S=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(c){const E=m==="y"?"height":"width",P=s.reference[m]-s.floating[E]+S.mainAxis,O=s.reference[m]+s.reference[E]-S.mainAxis;y<P?y=P:y>O&&(y=O)}if(h){var _,A;const E=m==="y"?"width":"height",P=yj.has(Yo(i)),O=s.reference[d]-s.floating[E]+(P&&((_=o.offset)==null?void 0:_[d])||0)+(P?0:S.crossAxis),M=s.reference[d]+s.reference[E]+(P?0:((A=o.offset)==null?void 0:A[d])||0)-(P?S.crossAxis:0);b<O?b=O:b>M&&(b=M)}return{[m]:y,[d]:b}}}},FJ=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:s,platform:o,elements:a}=e,{apply:c=()=>{},...h}=Ko(t,e),f=await Wp(e,h),d=Yo(i),m=Hh(i),y=ro(i)==="y",{width:b,height:w}=s.floating;let S,_;d==="top"||d==="bottom"?(S=d,_=m===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(_=d,S=m==="end"?"top":"bottom");const A=w-f.top-f.bottom,E=b-f.left-f.right,P=fl(w-f[S],A),O=fl(b-f[_],E),M=!e.middlewareData.shift;let D=P,$=O;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&($=E),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(D=A),M&&!m){const N=Ci(f.left,0),U=Ci(f.right,0),q=Ci(f.top,0),K=Ci(f.bottom,0);y?$=b-2*(N!==0||U!==0?N+U:Ci(f.left,f.right)):D=w-2*(q!==0||K!==0?q+K:Ci(f.top,f.bottom))}await c({...e,availableWidth:$,availableHeight:D});const F=await o.getDimensions(a.floating);return b!==F.width||w!==F.height?{reset:{rects:!0}}:{}}}};function kw(){return typeof window<"u"}function Wh(t){return bj(t)?(t.nodeName||"").toLowerCase():"#document"}function Ei(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function vo(t){var e;return(e=(bj(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function bj(t){return kw()?t instanceof Node||t instanceof Ei(t).Node:!1}function Cs(t){return kw()?t instanceof Element||t instanceof Ei(t).Element:!1}function mo(t){return kw()?t instanceof HTMLElement||t instanceof Ei(t).HTMLElement:!1}function BD(t){return!kw()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ei(t).ShadowRoot}const zJ=new Set(["inline","contents"]);function Dm(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=As(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!zJ.has(i)}const VJ=new Set(["table","td","th"]);function UJ(t){return VJ.has(Wh(t))}const HJ=[":popover-open",":modal"];function Tw(t){return HJ.some(e=>{try{return t.matches(e)}catch{return!1}})}const WJ=["transform","translate","scale","rotate","perspective"],qJ=["transform","translate","scale","rotate","perspective","filter"],GJ=["paint","layout","strict","content"];function BE(t){const e=FE(),n=Cs(t)?As(t):t;return WJ.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||qJ.some(r=>(n.willChange||"").includes(r))||GJ.some(r=>(n.contain||"").includes(r))}function KJ(t){let e=dl(t);for(;mo(e)&&!Mh(e);){if(BE(e))return e;if(Tw(e))return null;e=dl(e)}return null}function FE(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const YJ=new Set(["html","body","#document"]);function Mh(t){return YJ.has(Wh(t))}function As(t){return Ei(t).getComputedStyle(t)}function Rw(t){return Cs(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function dl(t){if(Wh(t)==="html")return t;const e=t.assignedSlot||t.parentNode||BD(t)&&t.host||vo(t);return BD(e)?e.host:e}function vj(t){const e=dl(t);return Mh(e)?t.ownerDocument?t.ownerDocument.body:t.body:mo(e)&&Dm(e)?e:vj(e)}function qp(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=vj(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=Ei(i);if(s){const a=G2(o);return e.concat(o,o.visualViewport||[],Dm(i)?i:[],a&&n?qp(a):[])}return e.concat(i,qp(i,[],n))}function G2(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function wj(t){const e=As(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=mo(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,a=Jb(n)!==s||Jb(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function zE(t){return Cs(t)?t:t.contextElement}function ph(t){const e=zE(t);if(!mo(e))return lo(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=wj(e);let o=(s?Jb(n.width):n.width)/r,a=(s?Jb(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const XJ=lo(0);function xj(t){const e=Ei(t);return!FE()||!e.visualViewport?XJ:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function JJ(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ei(t)?!1:e}function xc(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=zE(t);let o=lo(1);e&&(r?Cs(r)&&(o=ph(r)):o=ph(t));const a=JJ(s,n,r)?xj(s):lo(0);let c=(i.left+a.x)/o.x,h=(i.top+a.y)/o.y,f=i.width/o.x,d=i.height/o.y;if(s){const m=Ei(s),y=r&&Cs(r)?Ei(r):r;let b=m,w=G2(b);for(;w&&r&&y!==b;){const S=ph(w),_=w.getBoundingClientRect(),A=As(w),E=_.left+(w.clientLeft+parseFloat(A.paddingLeft))*S.x,P=_.top+(w.clientTop+parseFloat(A.paddingTop))*S.y;c*=S.x,h*=S.y,f*=S.x,d*=S.y,c+=E,h+=P,b=Ei(w),w=G2(b)}}return Zb({width:f,height:d,x:c,y:h})}function Mw(t,e){const n=Rw(t).scrollLeft;return e?e.left+n:xc(vo(t)).left+n}function Sj(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Mw(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function QJ(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=vo(r),a=e?Tw(e.floating):!1;if(r===o||a&&s)return n;let c={scrollLeft:0,scrollTop:0},h=lo(1);const f=lo(0),d=mo(r);if((d||!d&&!s)&&((Wh(r)!=="body"||Dm(o))&&(c=Rw(r)),mo(r))){const y=xc(r);h=ph(r),f.x=y.x+r.clientLeft,f.y=y.y+r.clientTop}const m=o&&!d&&!s?Sj(o,c):lo(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-c.scrollLeft*h.x+f.x+m.x,y:n.y*h.y-c.scrollTop*h.y+f.y+m.y}}function ZJ(t){return Array.from(t.getClientRects())}function eQ(t){const e=vo(t),n=Rw(t),r=t.ownerDocument.body,i=Ci(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Ci(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Mw(t);const a=-n.scrollTop;return As(r).direction==="rtl"&&(o+=Ci(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}const FD=25;function tQ(t,e){const n=Ei(t),r=vo(t),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,c=0;if(i){s=i.width,o=i.height;const f=FE();(!f||f&&e==="fixed")&&(a=i.offsetLeft,c=i.offsetTop)}const h=Mw(r);if(h<=0){const f=r.ownerDocument,d=f.body,m=getComputedStyle(d),y=f.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,b=Math.abs(r.clientWidth-d.clientWidth-y);b<=FD&&(s-=b)}else h<=FD&&(s+=h);return{width:s,height:o,x:a,y:c}}const nQ=new Set(["absolute","fixed"]);function rQ(t,e){const n=xc(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=mo(t)?ph(t):lo(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y,c=i*s.x,h=r*s.y;return{width:o,height:a,x:c,y:h}}function zD(t,e,n){let r;if(e==="viewport")r=tQ(t,n);else if(e==="document")r=eQ(vo(t));else if(Cs(e))r=rQ(e,n);else{const i=xj(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return Zb(r)}function _j(t,e){const n=dl(t);return n===e||!Cs(n)||Mh(n)?!1:As(n).position==="fixed"||_j(n,e)}function iQ(t,e){const n=e.get(t);if(n)return n;let r=qp(t,[],!1).filter(a=>Cs(a)&&Wh(a)!=="body"),i=null;const s=As(t).position==="fixed";let o=s?dl(t):t;for(;Cs(o)&&!Mh(o);){const a=As(o),c=BE(o);!c&&a.position==="fixed"&&(i=null),(s?!c&&!i:!c&&a.position==="static"&&!!i&&nQ.has(i.position)||Dm(o)&&!c&&_j(t,o))?r=r.filter(f=>f!==o):i=a,o=dl(o)}return e.set(t,r),r}function sQ(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?Tw(e)?[]:iQ(e,this._c):[].concat(n),r],a=o[0],c=o.reduce((h,f)=>{const d=zD(e,f,i);return h.top=Ci(d.top,h.top),h.right=fl(d.right,h.right),h.bottom=fl(d.bottom,h.bottom),h.left=Ci(d.left,h.left),h},zD(e,a,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function oQ(t){const{width:e,height:n}=wj(t);return{width:e,height:n}}function aQ(t,e,n){const r=mo(e),i=vo(e),s=n==="fixed",o=xc(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const c=lo(0);function h(){c.x=Mw(i)}if(r||!r&&!s)if((Wh(e)!=="body"||Dm(i))&&(a=Rw(e)),r){const y=xc(e,!0,s,e);c.x=y.x+e.clientLeft,c.y=y.y+e.clientTop}else i&&h();s&&!r&&i&&h();const f=i&&!r&&!s?Sj(i,a):lo(0),d=o.left+a.scrollLeft-c.x-f.x,m=o.top+a.scrollTop-c.y-f.y;return{x:d,y:m,width:o.width,height:o.height}}function VS(t){return As(t).position==="static"}function VD(t,e){if(!mo(t)||As(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return vo(t)===n&&(n=n.ownerDocument.body),n}function Cj(t,e){const n=Ei(t);if(Tw(t))return n;if(!mo(t)){let i=dl(t);for(;i&&!Mh(i);){if(Cs(i)&&!VS(i))return i;i=dl(i)}return n}let r=VD(t,e);for(;r&&UJ(r)&&VS(r);)r=VD(r,e);return r&&Mh(r)&&VS(r)&&!BE(r)?n:r||KJ(t)||n}const lQ=async function(t){const e=this.getOffsetParent||Cj,n=this.getDimensions,r=await n(t.floating);return{reference:aQ(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function cQ(t){return As(t).direction==="rtl"}const uQ={convertOffsetParentRelativeRectToViewportRelativeRect:QJ,getDocumentElement:vo,getClippingRect:sQ,getOffsetParent:Cj,getElementRects:lQ,getClientRects:ZJ,getDimensions:oQ,getScale:ph,isElement:Cs,isRTL:cQ};function Aj(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function hQ(t,e){let n=null,r;const i=vo(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const h=t.getBoundingClientRect(),{left:f,top:d,width:m,height:y}=h;if(a||e(),!m||!y)return;const b=D0(d),w=D0(i.clientWidth-(f+m)),S=D0(i.clientHeight-(d+y)),_=D0(f),E={rootMargin:-b+"px "+-w+"px "+-S+"px "+-_+"px",threshold:Ci(0,fl(1,c))||1};let P=!0;function O(M){const D=M[0].intersectionRatio;if(D!==c){if(!P)return o();D?o(!1,D):r=setTimeout(()=>{o(!1,1e-7)},1e3)}D===1&&!Aj(h,t.getBoundingClientRect())&&o(),P=!1}try{n=new IntersectionObserver(O,{...E,root:i.ownerDocument})}catch{n=new IntersectionObserver(O,E)}n.observe(t)}return o(!0),s}function fQ(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,h=zE(t),f=i||s?[...h?qp(h):[],...qp(e)]:[];f.forEach(_=>{i&&_.addEventListener("scroll",n,{passive:!0}),s&&_.addEventListener("resize",n)});const d=h&&a?hQ(h,n):null;let m=-1,y=null;o&&(y=new ResizeObserver(_=>{let[A]=_;A&&A.target===h&&y&&(y.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var E;(E=y)==null||E.observe(e)})),n()}),h&&!c&&y.observe(h),y.observe(e));let b,w=c?xc(t):null;c&&S();function S(){const _=xc(t);w&&!Aj(w,_)&&n(),w=_,b=requestAnimationFrame(S)}return n(),()=>{var _;f.forEach(A=>{i&&A.removeEventListener("scroll",n),s&&A.removeEventListener("resize",n)}),d?.(),(_=y)==null||_.disconnect(),y=null,c&&cancelAnimationFrame(b)}}const dQ=$J,pQ=jJ,mQ=IJ,gQ=FJ,yQ=LJ,UD=DJ,bQ=BJ,vQ=(t,e,n)=>{const r=new Map,i={platform:uQ,...n},s={...i.platform,_c:r};return PJ(t,e,{...i,platform:s})};var wQ=typeof document<"u",xQ=function(){},sb=wQ?k.useLayoutEffect:xQ;function ev(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!ev(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&t.$$typeof)&&!ev(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function Ej(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function HD(t,e){const n=Ej(t);return Math.round(e*n)/n}function US(t){const e=k.useRef(t);return sb(()=>{e.current=t}),e}function SQ(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:c,open:h}=t,[f,d]=k.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[m,y]=k.useState(r);ev(m,r)||y(r);const[b,w]=k.useState(null),[S,_]=k.useState(null),A=k.useCallback(H=>{H!==M.current&&(M.current=H,w(H))},[]),E=k.useCallback(H=>{H!==D.current&&(D.current=H,_(H))},[]),P=s||b,O=o||S,M=k.useRef(null),D=k.useRef(null),$=k.useRef(f),F=c!=null,N=US(c),U=US(i),q=US(h),K=k.useCallback(()=>{if(!M.current||!D.current)return;const H={placement:e,strategy:n,middleware:m};U.current&&(H.platform=U.current),vQ(M.current,D.current,H).then(se=>{const T={...se,isPositioned:q.current!==!1};X.current&&!ev($.current,T)&&($.current=T,IE.flushSync(()=>{d(T)}))})},[m,e,n,U,q]);sb(()=>{h===!1&&$.current.isPositioned&&($.current.isPositioned=!1,d(H=>({...H,isPositioned:!1})))},[h]);const X=k.useRef(!1);sb(()=>(X.current=!0,()=>{X.current=!1}),[]),sb(()=>{if(P&&(M.current=P),O&&(D.current=O),P&&O){if(N.current)return N.current(P,O,K);K()}},[P,O,K,N,F]);const ee=k.useMemo(()=>({reference:M,floating:D,setReference:A,setFloating:E}),[A,E]),V=k.useMemo(()=>({reference:P,floating:O}),[P,O]),G=k.useMemo(()=>{const H={position:n,left:0,top:0};if(!V.floating)return H;const se=HD(V.floating,f.x),T=HD(V.floating,f.y);return a?{...H,transform:"translate("+se+"px, "+T+"px)",...Ej(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:se,top:T}},[n,a,V.floating,f.x,f.y]);return k.useMemo(()=>({...f,update:K,refs:ee,elements:V,floatingStyles:G}),[f,K,ee,V,G])}const _Q=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?UD({element:r.current,padding:i}).fn(n):{}:r?UD({element:r,padding:i}).fn(n):{}}}},CQ=(t,e)=>({...dQ(t),options:[t,e]}),AQ=(t,e)=>({...pQ(t),options:[t,e]}),EQ=(t,e)=>({...bQ(t),options:[t,e]}),kQ=(t,e)=>({...mQ(t),options:[t,e]}),TQ=(t,e)=>({...gQ(t),options:[t,e]}),RQ=(t,e)=>({...yQ(t),options:[t,e]}),MQ=(t,e)=>({..._Q(t),options:[t,e]});var OQ="Arrow",kj=k.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...s}=t;return C.jsx(st.svg,{...s,ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:C.jsx("polygon",{points:"0,0 30,0 15,10"})})});kj.displayName=OQ;var PQ=kj;function Tj(t){const[e,n]=k.useState(void 0);return hl(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const c=s.borderBoxSize,h=Array.isArray(c)?c[0]:c;o=h.inlineSize,a=h.blockSize}else o=t.offsetWidth,a=t.offsetHeight;n({width:o,height:a})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var VE="Popper",[Rj,Ow]=ra(VE),[DQ,Mj]=Rj(VE),Oj=t=>{const{__scopePopper:e,children:n}=t,[r,i]=k.useState(null);return C.jsx(DQ,{scope:e,anchor:r,onAnchorChange:i,children:n})};Oj.displayName=VE;var Pj="PopperAnchor",Dj=k.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,s=Mj(Pj,n),o=k.useRef(null),a=Bt(e,o),c=k.useRef(null);return k.useEffect(()=>{const h=c.current;c.current=r?.current||o.current,h!==c.current&&s.onAnchorChange(c.current)}),r?null:C.jsx(st.div,{...i,ref:a})});Dj.displayName=Pj;var UE="PopperContent",[IQ,LQ]=Rj(UE),Ij=k.forwardRef((t,e)=>{const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:h=[],collisionPadding:f=0,sticky:d="partial",hideWhenDetached:m=!1,updatePositionStrategy:y="optimized",onPlaced:b,...w}=t,S=Mj(UE,n),[_,A]=k.useState(null),E=Bt(e,Ee=>A(Ee)),[P,O]=k.useState(null),M=Tj(P),D=M?.width??0,$=M?.height??0,F=r+(s!=="center"?"-"+s:""),N=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},U=Array.isArray(h)?h:[h],q=U.length>0,K={padding:N,boundary:U.filter($Q),altBoundary:q},{refs:X,floatingStyles:ee,placement:V,isPositioned:G,middlewareData:H}=SQ({strategy:"fixed",placement:F,whileElementsMounted:(...Ee)=>fQ(...Ee,{animationFrame:y==="always"}),elements:{reference:S.anchor},middleware:[CQ({mainAxis:i+$,alignmentAxis:o}),c&&AQ({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?EQ():void 0,...K}),c&&kQ({...K}),TQ({...K,apply:({elements:Ee,rects:Ue,availableWidth:Pt,availableHeight:Kt})=>{const{width:Yt,height:er}=Ue.reference,tr=Ee.floating.style;tr.setProperty("--radix-popper-available-width",`${Pt}px`),tr.setProperty("--radix-popper-available-height",`${Kt}px`),tr.setProperty("--radix-popper-anchor-width",`${Yt}px`),tr.setProperty("--radix-popper-anchor-height",`${er}px`)}}),P&&MQ({element:P,padding:a}),jQ({arrowWidth:D,arrowHeight:$}),m&&RQ({strategy:"referenceHidden",...K})]}),[se,T]=$j(V),Z=Lr(b);hl(()=>{G&&Z?.()},[G,Z]);const ue=H.arrow?.x,L=H.arrow?.y,pe=H.arrow?.centerOffset!==0,[ke,be]=k.useState();return hl(()=>{_&&be(window.getComputedStyle(_).zIndex)},[_]),C.jsx("div",{ref:X.setFloating,"data-radix-popper-content-wrapper":"",style:{...ee,transform:G?ee.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ke,"--radix-popper-transform-origin":[H.transformOrigin?.x,H.transformOrigin?.y].join(" "),...H.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:C.jsx(IQ,{scope:n,placedSide:se,onArrowChange:O,arrowX:ue,arrowY:L,shouldHideArrow:pe,children:C.jsx(st.div,{"data-side":se,"data-align":T,...w,ref:E,style:{...w.style,animation:G?void 0:"none"}})})})});Ij.displayName=UE;var Lj="PopperArrow",NQ={top:"bottom",right:"left",bottom:"top",left:"right"},Nj=k.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=LQ(Lj,r),o=NQ[s.placedSide];return C.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:C.jsx(PQ,{...i,ref:n,style:{...i.style,display:"block"}})})});Nj.displayName=Lj;function $Q(t){return t!==null}var jQ=t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:r,middlewareData:i}=e,o=i.arrow?.centerOffset!==0,a=o?0:t.arrowWidth,c=o?0:t.arrowHeight,[h,f]=$j(n),d={start:"0%",center:"50%",end:"100%"}[f],m=(i.arrow?.x??0)+a/2,y=(i.arrow?.y??0)+c/2;let b="",w="";return h==="bottom"?(b=o?d:`${m}px`,w=`${-c}px`):h==="top"?(b=o?d:`${m}px`,w=`${r.floating.height+c}px`):h==="right"?(b=`${-c}px`,w=o?d:`${y}px`):h==="left"&&(b=`${r.floating.width+c}px`,w=o?d:`${y}px`),{data:{x:b,y:w}}}});function $j(t){const[e,n="center"]=t.split("-");return[e,n]}var jj=Oj,Bj=Dj,Fj=Ij,zj=Nj,BQ="Portal",Pw=k.forwardRef((t,e)=>{const{container:n,...r}=t,[i,s]=k.useState(!1);hl(()=>s(!0),[]);const o=n||i&&globalThis?.document?.body;return o?KX.createPortal(C.jsx(st.div,{...r,ref:e}),o):null});Pw.displayName=BQ;function FQ(t,e){return k.useReducer((n,r)=>e[n][r]??n,t)}var Ts=t=>{const{present:e,children:n}=t,r=zQ(e),i=typeof n=="function"?n({present:r.isPresent}):k.Children.only(n),s=Bt(r.ref,VQ(i));return typeof n=="function"||r.isPresent?k.cloneElement(i,{ref:s}):null};Ts.displayName="Presence";function zQ(t){const[e,n]=k.useState(),r=k.useRef(null),i=k.useRef(t),s=k.useRef("none"),o=t?"mounted":"unmounted",[a,c]=FQ(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const h=I0(r.current);s.current=a==="mounted"?h:"none"},[a]),hl(()=>{const h=r.current,f=i.current;if(f!==t){const m=s.current,y=I0(h);t?c("MOUNT"):y==="none"||h?.display==="none"?c("UNMOUNT"):c(f&&m!==y?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,c]),hl(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,d=y=>{const w=I0(r.current).includes(CSS.escape(y.animationName));if(y.target===e&&w&&(c("ANIMATION_END"),!i.current)){const S=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=S)})}},m=y=>{y.target===e&&(s.current=I0(r.current))};return e.addEventListener("animationstart",m),e.addEventListener("animationcancel",d),e.addEventListener("animationend",d),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",m),e.removeEventListener("animationcancel",d),e.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:k.useCallback(h=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function I0(t){return t?.animationName||"none"}function VQ(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var UQ=k5[" useInsertionEffect ".trim().toString()]||hl;function qh({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[i,s,o]=HQ({defaultProp:e,onChange:n}),a=t!==void 0,c=a?t:i;{const f=k.useRef(t!==void 0);k.useEffect(()=>{const d=f.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=a},[a,r])}const h=k.useCallback(f=>{if(a){const d=WQ(f)?f(t):f;d!==t&&o.current?.(d)}else s(f)},[a,t,s,o]);return[c,h]}function HQ({defaultProp:t,onChange:e}){const[n,r]=k.useState(t),i=k.useRef(n),s=k.useRef(e);return UQ(()=>{s.current=e},[e]),k.useEffect(()=>{i.current!==n&&(s.current?.(n),i.current=n)},[n,i]),[n,r,s]}function WQ(t){return typeof t=="function"}var qQ=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Ru=new WeakMap,L0=new WeakMap,N0={},HS=0,Vj=function(t){return t&&(t.host||Vj(t.parentNode))},GQ=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=Vj(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},KQ=function(t,e,n,r){var i=GQ(e,Array.isArray(t)?t:[t]);N0[n]||(N0[n]=new WeakMap);var s=N0[n],o=[],a=new Set,c=new Set(i),h=function(d){!d||a.has(d)||(a.add(d),h(d.parentNode))};i.forEach(h);var f=function(d){!d||c.has(d)||Array.prototype.forEach.call(d.children,function(m){if(a.has(m))f(m);else try{var y=m.getAttribute(r),b=y!==null&&y!=="false",w=(Ru.get(m)||0)+1,S=(s.get(m)||0)+1;Ru.set(m,w),s.set(m,S),o.push(m),w===1&&b&&L0.set(m,!0),S===1&&m.setAttribute(n,"true"),b||m.setAttribute(r,"true")}catch(_){console.error("aria-hidden: cannot operate on ",m,_)}})};return f(e),a.clear(),HS++,function(){o.forEach(function(d){var m=Ru.get(d)-1,y=s.get(d)-1;Ru.set(d,m),s.set(d,y),m||(L0.has(d)||d.removeAttribute(r),L0.delete(d)),y||d.removeAttribute(n)}),HS--,HS||(Ru=new WeakMap,Ru=new WeakMap,L0=new WeakMap,N0={})}},Uj=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),i=qQ(t);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),KQ(r,i,n,"aria-hidden")):function(){return null}},Zs=function(){return Zs=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Zs.apply(this,arguments)};function Hj(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function ob(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}var ab="right-scroll-bar-position",lb="width-before-scroll-bar",YQ="with-scroll-bars-hidden",XQ="--removed-body-scroll-bar-size";function WS(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function JQ(t,e){var n=k.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=e,n.facade}var QQ=typeof window<"u"?k.useLayoutEffect:k.useEffect,WD=new WeakMap;function ZQ(t,e){var n=JQ(null,function(r){return t.forEach(function(i){return WS(i,r)})});return QQ(function(){var r=WD.get(n);if(r){var i=new Set(r),s=new Set(t),o=n.current;i.forEach(function(a){s.has(a)||WS(a,null)}),s.forEach(function(a){i.has(a)||WS(a,o)})}WD.set(n,t)},[t]),n}function eZ(t){return t}function tZ(t,e){e===void 0&&(e=eZ);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(s){var o=e(s,r);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(s){for(r=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(s),o=n}var c=function(){var f=o;o=[],f.forEach(s)},h=function(){return Promise.resolve().then(c)};h(),n={push:function(f){o.push(f),h()},filter:function(f){return o=o.filter(f),n}}}};return i}function nZ(t){t===void 0&&(t={});var e=tZ(null);return e.options=Zs({async:!0,ssr:!1},t),e}var Wj=function(t){var e=t.sideCar,n=Hj(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return k.createElement(r,Zs({},n))};Wj.isSideCarExport=!0;function rZ(t,e){return t.useMedium(e),Wj}var qj=nZ(),qS=function(){},Dw=k.forwardRef(function(t,e){var n=k.useRef(null),r=k.useState({onScrollCapture:qS,onWheelCapture:qS,onTouchMoveCapture:qS}),i=r[0],s=r[1],o=t.forwardProps,a=t.children,c=t.className,h=t.removeScrollBar,f=t.enabled,d=t.shards,m=t.sideCar,y=t.noRelative,b=t.noIsolation,w=t.inert,S=t.allowPinchZoom,_=t.as,A=_===void 0?"div":_,E=t.gapMode,P=Hj(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),O=m,M=ZQ([n,e]),D=Zs(Zs({},P),i);return k.createElement(k.Fragment,null,f&&k.createElement(O,{sideCar:qj,removeScrollBar:h,shards:d,noRelative:y,noIsolation:b,inert:w,setCallbacks:s,allowPinchZoom:!!S,lockRef:n,gapMode:E}),o?k.cloneElement(k.Children.only(a),Zs(Zs({},D),{ref:M})):k.createElement(A,Zs({},D,{className:c,ref:M}),a))});Dw.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Dw.classNames={fullWidth:lb,zeroRight:ab};var iZ=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function sZ(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=iZ();return e&&t.setAttribute("nonce",e),t}function oZ(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function aZ(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var lZ=function(){var t=0,e=null;return{add:function(n){t==0&&(e=sZ())&&(oZ(e,n),aZ(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},cZ=function(){var t=lZ();return function(e,n){k.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},Gj=function(){var t=cZ(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},uZ={left:0,top:0,right:0,gap:0},GS=function(t){return parseInt(t||"",10)||0},hZ=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],i=e[t==="padding"?"paddingRight":"marginRight"];return[GS(n),GS(r),GS(i)]},fZ=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return uZ;var e=hZ(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},dZ=Gj(),mh="data-scroll-locked",pZ=function(t,e,n,r){var i=t.left,s=t.top,o=t.right,a=t.gap;return n===void 0&&(n="margin"),`
.`.concat(YQ,` {
overflow: hidden `).concat(r,`;
padding-right: `).concat(a,"px ").concat(r,`;
}
body[`).concat(mh,`] {
overflow: hidden `).concat(r,`;
overscroll-behavior: contain;
`).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
padding-left: `.concat(i,`px;
padding-top: `).concat(s,`px;
padding-right: `).concat(o,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(a,"px ").concat(r,`;
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
}
.`).concat(ab,` {
right: `).concat(a,"px ").concat(r,`;
}
.`).concat(lb,` {
margin-right: `).concat(a,"px ").concat(r,`;
}
.`).concat(ab," .").concat(ab,` {
right: 0 `).concat(r,`;
}
.`).concat(lb," .").concat(lb,` {
margin-right: 0 `).concat(r,`;
}
body[`).concat(mh,`] {
`).concat(XQ,": ").concat(a,`px;
}
`)},qD=function(){var t=parseInt(document.body.getAttribute(mh)||"0",10);return isFinite(t)?t:0},mZ=function(){k.useEffect(function(){return document.body.setAttribute(mh,(qD()+1).toString()),function(){var t=qD()-1;t<=0?document.body.removeAttribute(mh):document.body.setAttribute(mh,t.toString())}},[])},gZ=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,i=r===void 0?"margin":r;mZ();var s=k.useMemo(function(){return fZ(i)},[i]);return k.createElement(dZ,{styles:pZ(s,!e,i,n?"":"!important")})},K2=!1;if(typeof window<"u")try{var $0=Object.defineProperty({},"passive",{get:function(){return K2=!0,!0}});window.addEventListener("test",$0,$0),window.removeEventListener("test",$0,$0)}catch{K2=!1}var Mu=K2?{passive:!1}:!1,yZ=function(t){return t.tagName==="TEXTAREA"},Kj=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!yZ(t)&&n[e]==="visible")},bZ=function(t){return Kj(t,"overflowY")},vZ=function(t){return Kj(t,"overflowX")},GD=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=Yj(t,r);if(i){var s=Xj(t,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},wZ=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},xZ=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},Yj=function(t,e){return t==="v"?bZ(e):vZ(e)},Xj=function(t,e){return t==="v"?wZ(e):xZ(e)},SZ=function(t,e){return t==="h"&&e==="rtl"?-1:1},_Z=function(t,e,n,r,i){var s=SZ(t,window.getComputedStyle(e).direction),o=s*r,a=n.target,c=e.contains(a),h=!1,f=o>0,d=0,m=0;do{if(!a)break;var y=Xj(t,a),b=y[0],w=y[1],S=y[2],_=w-S-s*b;(b||_)&&Yj(t,a)&&(d+=_,m+=b);var A=a.parentNode;a=A&&A.nodeType===Node.DOCUMENT_FRAGMENT_NODE?A.host:A}while(!c&&a!==document.body||c&&(e.contains(a)||e===a));return(f&&Math.abs(d)<1||!f&&Math.abs(m)<1)&&(h=!0),h},j0=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},KD=function(t){return[t.deltaX,t.deltaY]},YD=function(t){return t&&"current"in t?t.current:t},CZ=function(t,e){return t[0]===e[0]&&t[1]===e[1]},AZ=function(t){return`
.block-interactivity-`.concat(t,` {pointer-events: none;}
.allow-interactivity-`).concat(t,` {pointer-events: all;}
`)},EZ=0,Ou=[];function kZ(t){var e=k.useRef([]),n=k.useRef([0,0]),r=k.useRef(),i=k.useState(EZ++)[0],s=k.useState(Gj)[0],o=k.useRef(t);k.useEffect(function(){o.current=t},[t]),k.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(i));var w=ob([t.lockRef.current],(t.shards||[]).map(YD),!0).filter(Boolean);return w.forEach(function(S){return S.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),w.forEach(function(S){return S.classList.remove("allow-interactivity-".concat(i))})}}},[t.inert,t.lockRef.current,t.shards]);var a=k.useCallback(function(w,S){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var _=j0(w),A=n.current,E="deltaX"in w?w.deltaX:A[0]-_[0],P="deltaY"in w?w.deltaY:A[1]-_[1],O,M=w.target,D=Math.abs(E)>Math.abs(P)?"h":"v";if("touches"in w&&D==="h"&&M.type==="range")return!1;var $=GD(D,M);if(!$)return!0;if($?O=D:(O=D==="v"?"h":"v",$=GD(D,M)),!$)return!1;if(!r.current&&"changedTouches"in w&&(E||P)&&(r.current=O),!O)return!0;var F=r.current||O;return _Z(F,S,w,F==="h"?E:P)},[]),c=k.useCallback(function(w){var S=w;if(!(!Ou.length||Ou[Ou.length-1]!==s)){var _="deltaY"in S?KD(S):j0(S),A=e.current.filter(function(O){return O.name===S.type&&(O.target===S.target||S.target===O.shadowParent)&&CZ(O.delta,_)})[0];if(A&&A.should){S.cancelable&&S.preventDefault();return}if(!A){var E=(o.current.shards||[]).map(YD).filter(Boolean).filter(function(O){return O.contains(S.target)}),P=E.length>0?a(S,E[0]):!o.current.noIsolation;P&&S.cancelable&&S.preventDefault()}}},[]),h=k.useCallback(function(w,S,_,A){var E={name:w,delta:S,target:_,should:A,shadowParent:TZ(_)};e.current.push(E),setTimeout(function(){e.current=e.current.filter(function(P){return P!==E})},1)},[]),f=k.useCallback(function(w){n.current=j0(w),r.current=void 0},[]),d=k.useCallback(function(w){h(w.type,KD(w),w.target,a(w,t.lockRef.current))},[]),m=k.useCallback(function(w){h(w.type,j0(w),w.target,a(w,t.lockRef.current))},[]);k.useEffect(function(){return Ou.push(s),t.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:m}),document.addEventListener("wheel",c,Mu),document.addEventListener("touchmove",c,Mu),document.addEventListener("touchstart",f,Mu),function(){Ou=Ou.filter(function(w){return w!==s}),document.removeEventListener("wheel",c,Mu),document.removeEventListener("touchmove",c,Mu),document.removeEventListener("touchstart",f,Mu)}},[]);var y=t.removeScrollBar,b=t.inert;return k.createElement(k.Fragment,null,b?k.createElement(s,{styles:AZ(i)}):null,y?k.createElement(gZ,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function TZ(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const RZ=rZ(qj,kZ);var HE=k.forwardRef(function(t,e){return k.createElement(Dw,Zs({},t,{ref:e,sideCar:RZ}))});HE.classNames=Dw.classNames;var WE=t=>{const e=k.useRef(void 0);return k.useCallback(r=>{e.current&&e.current(),r&&(e.current=t(r))},[t])},MZ=()=>{const t=Ti(),e=Mt(()=>t.message()),n=k.useCallback(r=>{const i=()=>{e.setIsHovering(!0)},s=()=>{e.setIsHovering(!1)};return r.addEventListener("mouseenter",i),r.addEventListener("mouseleave",s),r.matches(":hover")&&e.setIsHovering(!0),()=>{r.removeEventListener("mouseenter",i),r.removeEventListener("mouseleave",s),e.setIsHovering(!1)}},[e]);return WE(n)},qE=k.forwardRef((t,e)=>{const n=MZ(),r=Bt(e,n);return C.jsx(st.div,{...t,ref:r})});qE.displayName="MessagePrimitive.Root";var Jj=()=>Mt(({part:e})=>{if(e.type!=="text"&&e.type!=="reasoning")throw new Error("MessagePartText can only be used inside text or reasoning message parts.");return e}),Qj=k.forwardRef(({smooth:t=!0,component:e="span",...n},r)=>{const{text:i,status:s}=ij(Jj(),t);return C.jsx(e,{"data-status":s.type,...n,ref:r,children:i})});Qj.displayName="MessagePartPrimitive.Text";var OZ=()=>Mt(({part:e})=>{if(e.type!=="image")throw new Error("MessagePartImage can only be used inside image message parts.");return e}),Zj=k.forwardRef((t,e)=>{const{image:n}=OZ();return C.jsx(st.img,{src:n,...t,ref:e})});Zj.displayName="MessagePartPrimitive.Image";var eB=({children:t})=>Mt(({part:n})=>n.status.type==="running")?t:null;eB.displayName="MessagePartPrimitive.InProgress";const XD=t=>Symbol.iterator in t,JD=t=>"entries"in t,QD=(t,e)=>{const n=t instanceof Map?t:new Map(t.entries()),r=e instanceof Map?e:new Map(e.entries());if(n.size!==r.size)return!1;for(const[i,s]of n)if(!r.has(i)||!Object.is(s,r.get(i)))return!1;return!0},PZ=(t,e)=>{const n=t[Symbol.iterator](),r=e[Symbol.iterator]();let i=n.next(),s=r.next();for(;!i.done&&!s.done;){if(!Object.is(i.value,s.value))return!1;i=n.next(),s=r.next()}return!!i.done&&!!s.done};function DZ(t,e){return Object.is(t,e)?!0:typeof t!="object"||t===null||typeof e!="object"||e===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e)?!1:XD(t)&&XD(e)?JD(t)&&JD(e)?QD(t,e):PZ(t,e):QD({entries:()=>Object.entries(t)},{entries:()=>Object.entries(e)})}function IZ(t){const e=de.useRef(void 0);return n=>{const r=t(n);return DZ(e.current,r)?e.current:e.current=r}}var LZ=t=>{const e=[];let n=-1;for(let r=0;r<t.length;r++)t[r]==="tool-call"?n===-1&&(n=r):(n!==-1&&(e.push({type:"toolGroup",startIndex:n,endIndex:r-1}),n=-1),e.push({type:"single",index:r}));return n!==-1&&e.push({type:"toolGroup",startIndex:n,endIndex:t.length-1}),e},NZ=()=>{const t=Mt(IZ(e=>e.message.parts.map(n=>n.type)));return k.useMemo(()=>t.length===0?[]:LZ(t),[t])},$Z=({Fallback:t,...e})=>{const n=Mt(({toolUIs:r})=>{const i=r[e.toolName]??t;return Array.isArray(i)?i[0]:i});return n?C.jsx(n,{...e}):null},Xa={Text:()=>C.jsxs("p",{style:{whiteSpace:"pre-line"},children:[C.jsx(Qj,{}),C.jsx(eB,{children:C.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>C.jsx(Zj,{}),File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:t})=>t},jZ=({components:{Text:t=Xa.Text,Reasoning:e=Xa.Reasoning,Image:n=Xa.Image,Source:r=Xa.Source,File:i=Xa.File,Unstable_Audio:s=Xa.Unstable_Audio,tools:o={}}={}})=>{const a=Ti(),c=Mt(({part:f})=>f),h=c.type;if(h==="tool-call"){const f=m=>a.part().addToolResult(m);if("Override"in o)return C.jsx(o.Override,{...c,addResult:f});const d=o.by_name?.[c.toolName]??o.Fallback;return C.jsx($Z,{...c,Fallback:d,addResult:f})}if(c.status?.type==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(h){case"text":return C.jsx(t,{...c});case"reasoning":return C.jsx(e,{...c});case"source":return C.jsx(r,{...c});case"image":return C.jsx(n,{...c});case"file":return C.jsx(i,{...c});case"audio":return C.jsx(s,{...c});default:const f=h;throw new Error(`Unknown message part type: ${f}`)}},Y2=k.memo(({index:t,components:e})=>C.jsx(OX,{index:t,children:C.jsx(jZ,{components:e})}),(t,e)=>t.index===e.index&&t.components?.Text===e.components?.Text&&t.components?.Reasoning===e.components?.Reasoning&&t.components?.Source===e.components?.Source&&t.components?.Image===e.components?.Image&&t.components?.File===e.components?.File&&t.components?.Unstable_Audio===e.components?.Unstable_Audio&&t.components?.tools===e.components?.tools&&t.components?.ToolGroup===e.components?.ToolGroup);Y2.displayName="MessagePrimitive.PartByIndex";var BZ=({status:t,component:e})=>C.jsx(DX,{text:"",isRunning:t.type==="running",children:C.jsx(e,{type:"text",text:"",status:t})}),FZ=Object.freeze({type:"complete"}),zZ=({components:t})=>{const e=Mt(n=>n.message.status??FZ);return t?.Empty?C.jsx(t.Empty,{status:e}):C.jsx(BZ,{status:e,component:t?.Text??Xa.Text})},VZ=k.memo(zZ,(t,e)=>t.components?.Empty===e.components?.Empty&&t.components?.Text===e.components?.Text),GE=({components:t})=>{const e=Mt(({message:i})=>i.parts.length),n=NZ(),r=k.useMemo(()=>e===0?C.jsx(VZ,{components:t}):n.map(i=>{if(i.type==="single")return C.jsx(Y2,{index:i.index,components:t},i.index);{const s=t.ToolGroup??Xa.ToolGroup;return C.jsx(s,{startIndex:i.startIndex,endIndex:i.endIndex,children:Array.from({length:i.endIndex-i.startIndex+1},(o,a)=>C.jsx(Y2,{index:i.startIndex+a,components:t},a))},i.startIndex)}}),[n,t,e]);return C.jsx(C.Fragment,{children:r})};GE.displayName="MessagePrimitive.Parts";var UZ=t=>Mt(({message:e})=>{const{role:n,attachments:r,parts:i,branchCount:s,isLast:o,speech:a,submittedFeedback:c,isCopied:h,isHovering:f}=e;return!(t.hasBranches===!0&&s<2||t.user&&n!=="user"||t.assistant&&n!=="assistant"||t.system&&n!=="system"||t.lastOrHover===!0&&!f&&!o||t.last!==void 0&&t.last!==o||t.copied===!0&&!h||t.copied===!1&&h||t.speaking===!0&&a==null||t.speaking===!1&&a!=null||t.hasAttachments===!0&&(n!=="user"||!r?.length)||t.hasAttachments===!1&&n==="user"&&r?.length||t.hasContent===!0&&i.length===0||t.hasContent===!1&&i.length>0||t.submittedFeedback!==void 0&&(c?.type??null)!==t.submittedFeedback)}),X2=({children:t,...e})=>UZ(e)?t:null;X2.displayName="MessagePrimitive.If";var tB=({children:t})=>Mt(({message:n})=>n.status?.type==="incomplete"&&n.status.reason==="error")?C.jsx(C.Fragment,{children:t}):null;tB.displayName="MessagePrimitive.Error";var nB=()=>{const t=Ti(),e=Mt(r=>r.thread.isRunning||!r.composer.isEditing||r.composer.isEmpty),n=k.useCallback(()=>{t.composer().send()},[t]);return e?null:n},HZ=uj("ComposerPrimitive.Send",nB),rB=k.forwardRef(({onSubmit:t,...e},n)=>{const r=nB(),i=s=>{s.preventDefault(),r&&r()};return C.jsx(st.form,{...e,ref:n,onSubmit:Le(t,i)})});rB.displayName="ComposerPrimitive.Root";function Gp(){return Gp=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Gp.apply(null,arguments)}function iB(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var WZ=k.useLayoutEffect,qZ=function(e){var n=de.useRef(e);return WZ(function(){n.current=e}),n},ZD=function(e,n){if(typeof e=="function"){e(n);return}e.current=n},GZ=function(e,n){var r=de.useRef();return de.useCallback(function(i){e.current=i,r.current&&ZD(r.current,null),r.current=n,n&&ZD(n,i)},[n])},eI={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},KZ=function(e){Object.keys(eI).forEach(function(n){e.style.setProperty(n,eI[n],"important")})},tI=KZ,Ar=null,nI=function(e,n){var r=e.scrollHeight;return n.sizingStyle.boxSizing==="border-box"?r+n.borderSize:r-n.paddingSize};function YZ(t,e,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),Ar||(Ar=document.createElement("textarea"),Ar.setAttribute("tabindex","-1"),Ar.setAttribute("aria-hidden","true"),tI(Ar)),Ar.parentNode===null&&document.body.appendChild(Ar);var i=t.paddingSize,s=t.borderSize,o=t.sizingStyle,a=o.boxSizing;Object.keys(o).forEach(function(m){var y=m;Ar.style[y]=o[y]}),tI(Ar),Ar.value=e;var c=nI(Ar,t);Ar.value=e,c=nI(Ar,t),Ar.value="x";var h=Ar.scrollHeight-i,f=h*n;a==="border-box"&&(f=f+i+s),c=Math.max(f,c);var d=h*r;return a==="border-box"&&(d=d+i+s),c=Math.min(d,c),[c,h]}var rI=function(){},XZ=function(e,n){return e.reduce(function(r,i){return r[i]=n[i],r},{})},JZ=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],QZ=!!document.documentElement.currentStyle,ZZ=function(e){var n=window.getComputedStyle(e);if(n===null)return null;var r=XZ(JZ,n),i=r.boxSizing;if(i==="")return null;QZ&&i==="border-box"&&(r.width=parseFloat(r.width)+parseFloat(r.borderRightWidth)+parseFloat(r.borderLeftWidth)+parseFloat(r.paddingRight)+parseFloat(r.paddingLeft)+"px");var s=parseFloat(r.paddingBottom)+parseFloat(r.paddingTop),o=parseFloat(r.borderBottomWidth)+parseFloat(r.borderTopWidth);return{sizingStyle:r,paddingSize:s,borderSize:o}},eee=ZZ;function KE(t,e,n){var r=qZ(n);k.useLayoutEffect(function(){var i=function(o){return r.current(o)};if(t)return t.addEventListener(e,i),function(){return t.removeEventListener(e,i)}},[])}var tee=function(e,n){KE(document.body,"reset",function(r){e.current.form===r.target&&n(r)})},nee=function(e){KE(window,"resize",e)},ree=function(e){KE(document.fonts,"loadingdone",e)},iee=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],see=function(e,n){var r=e.cacheMeasurements,i=e.maxRows,s=e.minRows,o=e.onChange,a=o===void 0?rI:o,c=e.onHeightChange,h=c===void 0?rI:c,f=iB(e,iee),d=f.value!==void 0,m=k.useRef(null),y=GZ(m,n),b=k.useRef(0),w=k.useRef(),S=function(){var E=m.current,P=r&&w.current?w.current:eee(E);if(P){w.current=P;var O=YZ(P,E.value||E.placeholder||"x",s,i),M=O[0],D=O[1];b.current!==M&&(b.current=M,E.style.setProperty("height",M+"px","important"),h(M,{rowHeight:D}))}},_=function(E){d||S(),a(E)};return k.useLayoutEffect(S),tee(m,function(){if(!d){var A=m.current.value;requestAnimationFrame(function(){var E=m.current;E&&A!==E.value&&S()})}}),nee(S),ree(S),k.createElement("textarea",Gp({},f,{onChange:_,ref:y}))},oee=k.forwardRef(see),sB=t=>{const e=Lr(t),n=zY(r=>r.onScrollToBottom);k.useEffect(()=>n(e),[n,e])},oB=k.forwardRef(({autoFocus:t=!1,asChild:e,disabled:n,onChange:r,onKeyDown:i,onPaste:s,submitOnEnter:o=!0,cancelOnEscape:a=!0,unstable_focusOnRunStart:c=!0,unstable_focusOnScrollToBottom:h=!0,unstable_focusOnThreadSwitched:f=!0,addAttachmentOnPaste:d=!0,...m},y)=>{const b=Ti(),w=Mt(({composer:$})=>$.isEditing?$.text:""),S=e?sj:oee,_=Mt(({thread:$})=>$.isDisabled)||n,A=k.useRef(null),E=Bt(y,A);hj($=>{if(!a)return;const F=b.composer();F.getState().canCancel&&(F.cancel(),$.preventDefault())});const P=$=>{_||!o||$.nativeEvent.isComposing||$.key==="Enter"&&$.shiftKey===!1&&(b.thread().getState().isRunning||($.preventDefault(),A.current?.closest("form")?.requestSubmit()))},O=async $=>{if(!d)return;const F=b.thread().getState().capabilities,N=Array.from($.clipboardData?.files||[]);if(F.attachments&&N.length>0)try{$.preventDefault(),await Promise.all(N.map(U=>b.composer().addAttachment(U)))}catch(U){console.error("Error adding attachment:",U)}},M=t&&!_,D=k.useCallback(()=>{const $=A.current;!$||!M||($.focus({preventScroll:!0}),$.setSelectionRange($.value.length,$.value.length))},[M]);return k.useEffect(()=>D(),[D]),sB(()=>{b.composer().getState().type==="thread"&&h&&D()}),k.useEffect(()=>{if(!(b.composer().getState().type!=="thread"||!c))return b.on("thread.run-start",D)},[c,D,b]),k.useEffect(()=>{if(!(b.composer().getState().type!=="thread"||!f))return b.on("thread-list-item.switched-to",D)},[f,D,b]),C.jsx(S,{name:"input",value:w,...m,ref:E,disabled:_,onChange:Le(r,$=>{b.composer().getState().isEditing&&(b.composer().setText($.target.value),b.flushSync())}),onKeyDown:Le(i,P),onPaste:Le(s,O)})});oB.displayName="ComposerPrimitive.Input";var aee=()=>{const t=Ti(),e=Mt(({composer:r})=>!r.canCancel),n=k.useCallback(()=>{t.composer().cancel()},[t]);return e?null:n},lee=uj("ComposerPrimitive.Cancel",aee),aB=k.forwardRef((t,e)=>C.jsx(st.div,{role:"alert",...t,ref:e}));aB.displayName="ErrorPrimitive.Root";var lB=k.forwardRef(({children:t,...e},n)=>{const r=Mt(({message:i})=>i.status?.type==="incomplete"&&i.status.reason==="error"?i.status.error:void 0);return r===void 0?null:C.jsx(st.span,{...e,ref:n,children:t??String(r)})});lB.displayName="ErrorPrimitive.Message";var cB=k.forwardRef((t,e)=>C.jsx(st.div,{...t,ref:e}));cB.displayName="ThreadPrimitive.Root";var uB=({children:t})=>Mt(({thread:n})=>n.messages.length===0)?t:null;uB.displayName="ThreadPrimitive.Empty";var cee=t=>Mt(({thread:e})=>!(t.empty===!0&&e.messages.length!==0||t.empty===!1&&e.messages.length===0||t.running===!0&&!e.isRunning||t.running===!1&&e.isRunning||t.disabled===!0&&!e.isDisabled||t.disabled===!1&&e.isDisabled)),tv=({children:t,...e})=>cee(e)?t:null;tv.displayName="ThreadPrimitive.If";var uee=t=>{const e=Lr(t),n=k.useCallback(r=>{const i=new ResizeObserver(()=>{e()}),s=new MutationObserver(()=>{e()});return i.observe(r),s.observe(r,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{i.disconnect(),s.disconnect()}},[e]);return WE(n)},hee=({autoScroll:t=!0})=>{const e=k.useRef(null),n=W5(),r=k.useRef(0),i=k.useRef(!1),s=k.useCallback(f=>{const d=e.current;!d||!t||(i.current=!0,d.scrollTo({top:d.scrollHeight,behavior:f}))},[t]),o=()=>{const f=e.current;if(!f)return;const d=n.getState().isAtBottom,m=f.scrollHeight-f.scrollTop<=f.clientHeight+1;!m&&r.current<f.scrollTop||(m&&(i.current=!1),m!==d&&Yb(n).setState({isAtBottom:m})),r.current=f.scrollTop},a=uee(()=>{(i.current||n.getState().isAtBottom)&&s("instant"),o()}),c=WE(f=>(f.addEventListener("scroll",o),()=>{f.removeEventListener("scroll",o)}));return sB(()=>{s("auto")}),IX("thread.run-start",()=>s("auto")),Bt(a,c,e)},hB=k.forwardRef(({autoScroll:t,children:e,...n},r)=>{const i=hee({autoScroll:t}),s=Bt(r,i);return C.jsx(st.div,{...n,ref:s,children:e})});hB.displayName="ThreadPrimitive.ViewportScrollable";var J2=k.forwardRef((t,e)=>C.jsx(q5,{children:C.jsx(hB,{...t,ref:e})}));J2.displayName="ThreadPrimitive.Viewport";var fB=(t,e)=>t.Message===e.Message&&t.EditComposer===e.EditComposer&&t.UserEditComposer===e.UserEditComposer&&t.AssistantEditComposer===e.AssistantEditComposer&&t.SystemEditComposer===e.SystemEditComposer&&t.UserMessage===e.UserMessage&&t.AssistantMessage===e.AssistantMessage&&t.SystemMessage===e.SystemMessage,fee=()=>null,dee=(t,e,n)=>{switch(e){case"user":return n?t.UserEditComposer??t.EditComposer??t.UserMessage??t.Message:t.UserMessage??t.Message;case"assistant":return n?t.AssistantEditComposer??t.EditComposer??t.AssistantMessage??t.Message:t.AssistantMessage??t.Message;case"system":return n?t.SystemEditComposer??t.EditComposer??t.SystemMessage??t.Message:t.SystemMessage??fee;default:const r=e;throw new Error(`Unknown message role: ${r}`)}},pee=({components:t})=>{const e=Mt(({message:i})=>i.role),n=Mt(({message:i})=>i.composer.isEditing),r=dee(t,e,n);return C.jsx(r,{})},dB=k.memo(({index:t,components:e})=>C.jsx(MX,{index:t,children:C.jsx(pee,{components:e})}),(t,e)=>t.index===e.index&&fB(t.components,e.components));dB.displayName="ThreadPrimitive.MessageByIndex";var pB=({components:t})=>{const e=Mt(({thread:r})=>r.messages.length);return k.useMemo(()=>e===0?null:Array.from({length:e},(r,i)=>C.jsx(dB,{index:i,components:t},i)),[e,t])};pB.displayName="ThreadPrimitive.Messages";var mee=k.memo(pB,(t,e)=>fB(t.components,e.components));function Ye(t,e,n,r,i){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}function me(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)}let mB=function(){const{crypto:t}=globalThis;if(t?.randomUUID)return mB=t.randomUUID.bind(t),t.randomUUID();const e=new Uint8Array(1),n=t?()=>t.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^n()&15>>+r/4).toString(16))};function Kp(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}const Q2=t=>{if(t instanceof Error)return t;if(typeof t=="object"&&t!==null){try{if(Object.prototype.toString.call(t)==="[object Error]"){const e=new Error(t.message,t.cause?{cause:t.cause}:{});return t.stack&&(e.stack=t.stack),t.cause&&!e.cause&&(e.cause=t.cause),t.name&&(e.name=t.name),e}}catch{}try{return new Error(JSON.stringify(t))}catch{}}return new Error(t)};class nt extends Error{}let Ri=class Z2 extends nt{constructor(e,n,r,i){super(`${Z2.makeMessage(e,n,r)}`),this.status=e,this.headers=i,this.requestID=i?.get("request-id"),this.error=n}static makeMessage(e,n,r){const i=n?.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):r;return e&&i?`${e} ${i}`:e?`${e} status code (no body)`:i||"(no status code or body)"}static generate(e,n,r,i){if(!e||!i)return new Iw({message:r,cause:Q2(n)});const s=n;return e===400?new yB(e,s,r,i):e===401?new bB(e,s,r,i):e===403?new vB(e,s,r,i):e===404?new wB(e,s,r,i):e===409?new xB(e,s,r,i):e===422?new SB(e,s,r,i):e===429?new _B(e,s,r,i):e>=500?new CB(e,s,r,i):new Z2(e,s,r,i)}},ys=class extends Ri{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},Iw=class extends Ri{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}},gB=class extends Iw{constructor({message:e}={}){super({message:e??"Request timed out."})}},yB=class extends Ri{},bB=class extends Ri{},vB=class extends Ri{},wB=class extends Ri{},xB=class extends Ri{},SB=class extends Ri{},_B=class extends Ri{},CB=class extends Ri{};const gee=/^[a-z][a-z0-9+.-]*:/i,yee=t=>gee.test(t);let eC=t=>(eC=Array.isArray,eC(t)),iI=eC;function sI(t){return typeof t!="object"?{}:t??{}}function bee(t){if(!t)return!0;for(const e in t)return!1;return!0}function vee(t,e){return Object.prototype.hasOwnProperty.call(t,e)}const wee=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new nt(`${t} must be an integer`);if(e<0)throw new nt(`${t} must be a positive integer`);return e},AB=t=>{try{return JSON.parse(t)}catch{return}},xee=t=>new Promise(e=>setTimeout(e,t)),Hu="0.60.0",See=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function _ee(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}const Cee=()=>{const t=_ee();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Hu,"X-Stainless-OS":aI(Deno.build.os),"X-Stainless-Arch":oI(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Hu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(t==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Hu,"X-Stainless-OS":aI(globalThis.process.platform??"unknown"),"X-Stainless-Arch":oI(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const e=Aee();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Hu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Hu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Aee(){if(typeof navigator>"u"||!navigator)return null;const t=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:e,pattern:n}of t){const r=n.exec(navigator.userAgent);if(r){const i=r[1]||0,s=r[2]||0,o=r[3]||0;return{browser:e,version:`${i}.${s}.${o}`}}}return null}const oI=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",aI=t=>(t=t.toLowerCase(),t.includes("ios")?"iOS":t==="android"?"Android":t==="darwin"?"MacOS":t==="win32"?"Windows":t==="freebsd"?"FreeBSD":t==="openbsd"?"OpenBSD":t==="linux"?"Linux":t?`Other:${t}`:"Unknown");let lI;const Eee=()=>lI??(lI=Cee());function kee(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function EB(...t){const e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...t)}function kB(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return EB({start(){},async pull(n){const{done:r,value:i}=await e.next();r?n.close():n.enqueue(i)},async cancel(){await e.return?.()}})}function YE(t){if(t[Symbol.asyncIterator])return t;const e=t.getReader();return{async next(){try{const n=await e.read();return n?.done&&e.releaseLock(),n}catch(n){throw e.releaseLock(),n}},async return(){const n=e.cancel();return e.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Tee(t){if(t===null||typeof t!="object")return;if(t[Symbol.asyncIterator]){await t[Symbol.asyncIterator]().return?.();return}const e=t.getReader(),n=e.cancel();e.releaseLock(),await n}const Ree=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});function Mee(t){let e=0;for(const i of t)e+=i.length;const n=new Uint8Array(e);let r=0;for(const i of t)n.set(i,r),r+=i.length;return n}let cI;function XE(t){let e;return(cI??(e=new globalThis.TextEncoder,cI=e.encode.bind(e)))(t)}let uI;function hI(t){let e;return(uI??(e=new globalThis.TextDecoder,uI=e.decode.bind(e)))(t)}var mi,gi;let Im=class{constructor(){mi.set(this,void 0),gi.set(this,void 0),Ye(this,mi,new Uint8Array),Ye(this,gi,null)}decode(e){if(e==null)return[];const n=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?XE(e):e;Ye(this,mi,Mee([me(this,mi,"f"),n]));const r=[];let i;for(;(i=Oee(me(this,mi,"f"),me(this,gi,"f")))!=null;){if(i.carriage&&me(this,gi,"f")==null){Ye(this,gi,i.index);continue}if(me(this,gi,"f")!=null&&(i.index!==me(this,gi,"f")+1||i.carriage)){r.push(hI(me(this,mi,"f").subarray(0,me(this,gi,"f")-1))),Ye(this,mi,me(this,mi,"f").subarray(me(this,gi,"f"))),Ye(this,gi,null);continue}const s=me(this,gi,"f")!==null?i.preceding-1:i.preceding,o=hI(me(this,mi,"f").subarray(0,s));r.push(o),Ye(this,mi,me(this,mi,"f").subarray(i.index)),Ye(this,gi,null)}return r}flush(){return me(this,mi,"f").length?this.decode(`
`):[]}};mi=new WeakMap,gi=new WeakMap;Im.NEWLINE_CHARS=new Set([`
`,"\r"]);Im.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Oee(t,e){for(let i=e??0;i<t.length;i++){if(t[i]===10)return{preceding:i,index:i+1,carriage:!1};if(t[i]===13)return{preceding:i,index:i+1,carriage:!0}}return null}function Pee(t){for(let r=0;r<t.length-1;r++){if(t[r]===10&&t[r+1]===10||t[r]===13&&t[r+1]===13)return r+2;if(t[r]===13&&t[r+1]===10&&r+3<t.length&&t[r+2]===13&&t[r+3]===10)return r+4}return-1}const nv={off:0,error:200,warn:300,info:400,debug:500},fI=(t,e,n)=>{if(t){if(vee(nv,t))return t;kr(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(nv))}`)}};function Ud(){}function B0(t,e,n){return!e||nv[t]>nv[n]?Ud:e[t].bind(e)}const Dee={error:Ud,warn:Ud,info:Ud,debug:Ud};let dI=new WeakMap;function kr(t){const e=t.logger,n=t.logLevel??"off";if(!e)return Dee;const r=dI.get(e);if(r&&r[0]===n)return r[1];const i={error:B0("error",e,n),warn:B0("warn",e,n),info:B0("info",e,n),debug:B0("debug",e,n)};return dI.set(e,[n,i]),i}const Zl=t=>(t.options&&(t.options={...t.options},delete t.options.headers),t.headers&&(t.headers=Object.fromEntries((t.headers instanceof Headers?[...t.headers]:Object.entries(t.headers)).map(([e,n])=>[e,e.toLowerCase()==="x-api-key"||e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in t&&(t.retryOfRequestLogID&&(t.retryOf=t.retryOfRequestLogID),delete t.retryOfRequestLogID),t);var md;let Yp=class Hd{constructor(e,n,r){this.iterator=e,md.set(this,void 0),this.controller=n,Ye(this,md,r)}static fromSSEResponse(e,n,r){let i=!1;const s=r?kr(r):console;async function*o(){if(i)throw new nt("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let a=!1;try{for await(const c of Iee(e,n)){if(c.event==="completion")try{yield JSON.parse(c.data)}catch(h){throw s.error("Could not parse message into JSON:",c.data),s.error("From chunk:",c.raw),h}if(c.event==="message_start"||c.event==="message_delta"||c.event==="message_stop"||c.event==="content_block_start"||c.event==="content_block_delta"||c.event==="content_block_stop")try{yield JSON.parse(c.data)}catch(h){throw s.error("Could not parse message into JSON:",c.data),s.error("From chunk:",c.raw),h}if(c.event!=="ping"&&c.event==="error")throw new Ri(void 0,AB(c.data)??c.data,void 0,e.headers)}a=!0}catch(c){if(Kp(c))return;throw c}finally{a||n.abort()}}return new Hd(o,n,r)}static fromReadableStream(e,n,r){let i=!1;async function*s(){const a=new Im,c=YE(e);for await(const h of c)for(const f of a.decode(h))yield f;for(const h of a.flush())yield h}async function*o(){if(i)throw new nt("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let a=!1;try{for await(const c of s())a||c&&(yield JSON.parse(c));a=!0}catch(c){if(Kp(c))return;throw c}finally{a||n.abort()}}return new Hd(o,n,r)}[(md=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){const e=[],n=[],r=this.iterator(),i=s=>({next:()=>{if(s.length===0){const o=r.next();e.push(o),n.push(o)}return s.shift()}});return[new Hd(()=>i(e),this.controller,me(this,md,"f")),new Hd(()=>i(n),this.controller,me(this,md,"f"))]}toReadableStream(){const e=this;let n;return EB({async start(){n=e[Symbol.asyncIterator]()},async pull(r){try{const{value:i,done:s}=await n.next();if(s)return r.close();const o=XE(JSON.stringify(i)+`
`);r.enqueue(o)}catch(i){r.error(i)}},async cancel(){await n.return?.()}})}};async function*Iee(t,e){if(!t.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new nt("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new nt("Attempted to iterate over a response with no body");const n=new Nee,r=new Im,i=YE(t.body);for await(const s of Lee(i))for(const o of r.decode(s)){const a=n.decode(o);a&&(yield a)}for(const s of r.flush()){const o=n.decode(s);o&&(yield o)}}async function*Lee(t){let e=new Uint8Array;for await(const n of t){if(n==null)continue;const r=n instanceof ArrayBuffer?new Uint8Array(n):typeof n=="string"?XE(n):n;let i=new Uint8Array(e.length+r.length);i.set(e),i.set(r,e.length),e=i;let s;for(;(s=Pee(e))!==-1;)yield e.slice(0,s),e=e.slice(s)}e.length>0&&(yield e)}let Nee=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const s={event:this.event,data:this.data.join(`
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],s}if(this.chunks.push(e),e.startsWith(":"))return null;let[n,r,i]=$ee(e,":");return i.startsWith(" ")&&(i=i.substring(1)),n==="event"?this.event=i:n==="data"&&this.data.push(i),null}};function $ee(t,e){const n=t.indexOf(e);return n!==-1?[t.substring(0,n),e,t.substring(n+e.length)]:[t,"",""]}async function TB(t,e){const{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:s}=e,o=await(async()=>{if(e.options.stream)return kr(t).debug("response",n.status,n.url,n.headers,n.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(n,e.controller):Yp.fromSSEResponse(n,e.controller);if(n.status===204)return null;if(e.options.__binaryResponse)return n;const c=n.headers.get("content-type")?.split(";")[0]?.trim();if(c?.includes("application/json")||c?.endsWith("+json")){const d=await n.json();return RB(d,n)}return await n.text()})();return kr(t).debug(`[${r}] response parsed`,Zl({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-s})),o}function RB(t,e){return!t||typeof t!="object"||Array.isArray(t)?t:Object.defineProperty(t,"_request_id",{value:e.headers.get("request-id"),enumerable:!1})}var Wd;let MB=class OB extends Promise{constructor(e,n,r=TB){super(i=>{i(null)}),this.responsePromise=n,this.parseResponse=r,Wd.set(this,void 0),Ye(this,Wd,e)}_thenUnwrap(e){return new OB(me(this,Wd,"f"),this.responsePromise,async(n,r)=>RB(e(await this.parseResponse(n,r),r),r.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){const[e,n]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:n,request_id:n.headers.get("request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(me(this,Wd,"f"),e))),this.parsedPromise}then(e,n){return this.parse().then(e,n)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};Wd=new WeakMap;var F0;let jee=class{constructor(e,n,r,i){F0.set(this,void 0),Ye(this,F0,e),this.options=i,this.response=n,this.body=r}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){const e=this.nextPageRequestOptions();if(!e)throw new nt("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await me(this,F0,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(F0=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const n of e.getPaginatedItems())yield n}},Bee=class extends MB{constructor(e,n,r){super(e,n,async(i,s)=>new r(i,s.response,await TB(i,s),s.options))}async*[Symbol.asyncIterator](){const e=await this;for await(const n of e)yield n}},Lm=class extends jee{constructor(e,n,r,i){super(e,n,r,i),this.data=r.data||[],this.has_more=r.has_more||!1,this.first_id=r.first_id||null,this.last_id=r.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){const n=this.first_id;return n?{...this.options,query:{...sI(this.options.query),before_id:n}}:null}const e=this.last_id;return e?{...this.options,query:{...sI(this.options.query),after_id:e}}:null}};const PB=()=>{if(typeof File>"u"){const{process:t}=globalThis,e=typeof t?.versions?.node=="string"&&parseInt(t.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(e?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function gh(t,e,n){return PB(),new File(t,e??"unknown_file",n)}function cb(t){return(typeof t=="object"&&t!==null&&("name"in t&&t.name&&String(t.name)||"url"in t&&t.url&&String(t.url)||"filename"in t&&t.filename&&String(t.filename)||"path"in t&&t.path&&String(t.path))||"").split(/[\\/]/).pop()||void 0}const DB=t=>t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function",Fee=async(t,e)=>({...t,body:await Vee(t.body,e)}),pI=new WeakMap;function zee(t){const e=typeof t=="function"?t:t.fetch,n=pI.get(e);if(n)return n;const r=(async()=>{try{const i="Response"in e?e.Response:(await e("data:,")).constructor,s=new FormData;return s.toString()!==await new i(s).text()}catch{return!0}})();return pI.set(e,r),r}const Vee=async(t,e)=>{if(!await zee(e))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");const n=new FormData;return await Promise.all(Object.entries(t||{}).map(([r,i])=>tC(n,r,i))),n},Uee=t=>t instanceof Blob&&"name"in t,tC=async(t,e,n)=>{if(n!==void 0){if(n==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")t.append(e,String(n));else if(n instanceof Response){let r={};const i=n.headers.get("Content-Type");i&&(r={type:i}),t.append(e,gh([await n.blob()],cb(n),r))}else if(DB(n))t.append(e,gh([await new Response(kB(n)).blob()],cb(n)));else if(Uee(n))t.append(e,gh([n],cb(n),{type:n.type}));else if(Array.isArray(n))await Promise.all(n.map(r=>tC(t,e+"[]",r)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([r,i])=>tC(t,`${e}[${r}]`,i)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}},IB=t=>t!=null&&typeof t=="object"&&typeof t.size=="number"&&typeof t.type=="string"&&typeof t.text=="function"&&typeof t.slice=="function"&&typeof t.arrayBuffer=="function",Hee=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&IB(t),Wee=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function qee(t,e,n){if(PB(),t=await t,e||(e=cb(t)),Hee(t))return t instanceof File&&e==null&&n==null?t:gh([await t.arrayBuffer()],e??t.name,{type:t.type,lastModified:t.lastModified,...n});if(Wee(t)){const i=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),gh(await nC(i),e,n)}const r=await nC(t);if(!n?.type){const i=r.find(s=>typeof s=="object"&&"type"in s&&s.type);typeof i=="string"&&(n={...n,type:i})}return gh(r,e,n)}async function nC(t){let e=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)e.push(t);else if(IB(t))e.push(t instanceof Blob?t:await t.arrayBuffer());else if(DB(t))for await(const n of t)e.push(...await nC(n));else{const n=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${n?`; constructor: ${n}`:""}${Gee(t)}`)}return e}function Gee(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(n=>`"${n}"`).join(", ")}]`}let ia=class{constructor(e){this._client=e}};const LB=Symbol.for("brand.privateNullableHeaders");function*Kee(t){if(!t)return;if(LB in t){const{values:r,nulls:i}=t;yield*r.entries();for(const s of i)yield[s,null];return}let e=!1,n;t instanceof Headers?n=t.entries():iI(t)?n=t:(e=!0,n=Object.entries(t??{}));for(let r of n){const i=r[0];if(typeof i!="string")throw new TypeError("expected header name to be a string");const s=iI(r[1])?r[1]:[r[1]];let o=!1;for(const a of s)a!==void 0&&(e&&!o&&(o=!0,yield[i,null]),yield[i,a])}}const zt=t=>{const e=new Headers,n=new Set;for(const r of t){const i=new Set;for(const[s,o]of Kee(r)){const a=s.toLowerCase();i.has(a)||(e.delete(s),i.add(a)),o===null?(e.delete(s),n.add(a)):(e.append(s,o),n.delete(a))}}return{[LB]:!0,values:e,nulls:n}};function NB(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const mI=Object.freeze(Object.create(null)),Yee=(t=NB)=>function(n,...r){if(n.length===1)return n[0];let i=!1;const s=[],o=n.reduce((f,d,m)=>{/[?#]/.test(d)&&(i=!0);const y=r[m];let b=(i?encodeURIComponent:t)(""+y);return m!==r.length&&(y==null||typeof y=="object"&&y.toString===Object.getPrototypeOf(Object.getPrototypeOf(y.hasOwnProperty??mI)??mI)?.toString)&&(b=y+"",s.push({start:f.length+d.length,length:b.length,error:`Value of type ${Object.prototype.toString.call(y).slice(8,-1)} is not a valid path parameter`})),f+d+(m===r.length?"":b)},""),a=o.split(/[?#]/,1)[0],c=new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)","gi");let h;for(;(h=c.exec(a))!==null;)s.push({start:h.index,length:h[0].length,error:`Value "${h[0]}" can't be safely passed as a path parameter`});if(s.sort((f,d)=>f.start-d.start),s.length>0){let f=0;const d=s.reduce((m,y)=>{const b=" ".repeat(y.start-f),w="^".repeat(y.length);return f=y.start+y.length,m+b+w},"");throw new nt(`Path parameters result in path with invalid segments:
${s.map(m=>m.error).join(`
`)}
${o}
${d}`)}return o},vs=Yee(NB);let $B=class extends ia{list(e={},n){const{betas:r,...i}=e??{};return this._client.getAPIList("/v1/files",Lm,{query:i,...n,headers:zt([{"anthropic-beta":[...r??[],"files-api-2025-04-14"].toString()},n?.headers])})}delete(e,n={},r){const{betas:i}=n??{};return this._client.delete(vs`/v1/files/${e}`,{...r,headers:zt([{"anthropic-beta":[...i??[],"files-api-2025-04-14"].toString()},r?.headers])})}download(e,n={},r){const{betas:i}=n??{};return this._client.get(vs`/v1/files/${e}/content`,{...r,headers:zt([{"anthropic-beta":[...i??[],"files-api-2025-04-14"].toString(),Accept:"application/binary"},r?.headers]),__binaryResponse:!0})}retrieveMetadata(e,n={},r){const{betas:i}=n??{};return this._client.get(vs`/v1/files/${e}`,{...r,headers:zt([{"anthropic-beta":[...i??[],"files-api-2025-04-14"].toString()},r?.headers])})}upload(e,n){const{betas:r,...i}=e;return this._client.post("/v1/files",Fee({body:i,...n,headers:zt([{"anthropic-beta":[...r??[],"files-api-2025-04-14"].toString()},n?.headers])},this._client))}},jB=class extends ia{retrieve(e,n={},r){const{betas:i}=n??{};return this._client.get(vs`/v1/models/${e}?beta=true`,{...r,headers:zt([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers])})}list(e={},n){const{betas:r,...i}=e??{};return this._client.getAPIList("/v1/models?beta=true",Lm,{query:i,...n,headers:zt([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},n?.headers])})}};class Lw{constructor(e,n){this.iterator=e,this.controller=n}async*decoder(){const e=new Im;for await(const n of this.iterator)for(const r of e.decode(n))yield JSON.parse(r);for(const n of e.flush())yield JSON.parse(n)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,n){if(!e.body)throw n.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new nt("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new nt("Attempted to iterate over a response with no body");return new Lw(YE(e.body),n)}}let BB=class extends ia{create(e,n){const{betas:r,...i}=e;return this._client.post("/v1/messages/batches?beta=true",{body:i,...n,headers:zt([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString()},n?.headers])})}retrieve(e,n={},r){const{betas:i}=n??{};return this._client.get(vs`/v1/messages/batches/${e}?beta=true`,{...r,headers:zt([{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString()},r?.headers])})}list(e={},n){const{betas:r,...i}=e??{};return this._client.getAPIList("/v1/messages/batches?beta=true",Lm,{query:i,...n,headers:zt([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString()},n?.headers])})}delete(e,n={},r){const{betas:i}=n??{};return this._client.delete(vs`/v1/messages/batches/${e}?beta=true`,{...r,headers:zt([{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString()},r?.headers])})}cancel(e,n={},r){const{betas:i}=n??{};return this._client.post(vs`/v1/messages/batches/${e}/cancel?beta=true`,{...r,headers:zt([{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString()},r?.headers])})}async results(e,n={},r){const i=await this.retrieve(e);if(!i.results_url)throw new nt(`No batch \`results_url\`; Has it finished processing? ${i.processing_status} - ${i.id}`);const{betas:s}=n??{};return this._client.get(i.results_url,{...r,headers:zt([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary"},r?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((o,a)=>Lw.fromResponse(a.response,a.controller))}};const Xee=t=>{let e=0,n=[];for(;e<t.length;){let r=t[e];if(r==="\\"){e++;continue}if(r==="{"){n.push({type:"brace",value:"{"}),e++;continue}if(r==="}"){n.push({type:"brace",value:"}"}),e++;continue}if(r==="["){n.push({type:"paren",value:"["}),e++;continue}if(r==="]"){n.push({type:"paren",value:"]"}),e++;continue}if(r===":"){n.push({type:"separator",value:":"}),e++;continue}if(r===","){n.push({type:"delimiter",value:","}),e++;continue}if(r==='"'){let a="",c=!1;for(r=t[++e];r!=='"';){if(e===t.length){c=!0;break}if(r==="\\"){if(e++,e===t.length){c=!0;break}a+=r+t[e],r=t[++e]}else a+=r,r=t[++e]}r=t[++e],c||n.push({type:"string",value:a});continue}if(r&&/\s/.test(r)){e++;continue}let s=/[0-9]/;if(r&&s.test(r)||r==="-"||r==="."){let a="";for(r==="-"&&(a+=r,r=t[++e]);r&&s.test(r)||r===".";)a+=r,r=t[++e];n.push({type:"number",value:a});continue}let o=/[a-z]/i;if(r&&o.test(r)){let a="";for(;r&&o.test(r)&&e!==t.length;)a+=r,r=t[++e];if(a=="true"||a=="false"||a==="null")n.push({type:"name",value:a});else{e++;continue}continue}e++}return n},Wu=t=>{if(t.length===0)return t;let e=t[t.length-1];switch(e.type){case"separator":return t=t.slice(0,t.length-1),Wu(t);case"number":let n=e.value[e.value.length-1];if(n==="."||n==="-")return t=t.slice(0,t.length-1),Wu(t);case"string":let r=t[t.length-2];if(r?.type==="delimiter")return t=t.slice(0,t.length-1),Wu(t);if(r?.type==="brace"&&r.value==="{")return t=t.slice(0,t.length-1),Wu(t);break;case"delimiter":return t=t.slice(0,t.length-1),Wu(t)}return t},Jee=t=>{let e=[];return t.map(n=>{n.type==="brace"&&(n.value==="{"?e.push("}"):e.splice(e.lastIndexOf("}"),1)),n.type==="paren"&&(n.value==="["?e.push("]"):e.splice(e.lastIndexOf("]"),1))}),e.length>0&&e.reverse().map(n=>{n==="}"?t.push({type:"brace",value:"}"}):n==="]"&&t.push({type:"paren",value:"]"})}),t},Qee=t=>{let e="";return t.map(n=>{switch(n.type){case"string":e+='"'+n.value+'"';break;default:e+=n.value;break}}),e},FB=t=>JSON.parse(Qee(Jee(Wu(Xee(t)))));var Fi,za,gd,z0,yd,bd,V0,vd,jo,wd,U0,H0,Pu,W0,q0,KS,gI,G0,YS,XS,JS,yI;const bI="__json_buf";function vI(t){return t.type==="tool_use"||t.type==="server_tool_use"||t.type==="mcp_tool_use"}class rv{constructor(){Fi.add(this),this.messages=[],this.receivedMessages=[],za.set(this,void 0),this.controller=new AbortController,gd.set(this,void 0),z0.set(this,()=>{}),yd.set(this,()=>{}),bd.set(this,void 0),V0.set(this,()=>{}),vd.set(this,()=>{}),jo.set(this,{}),wd.set(this,!1),U0.set(this,!1),H0.set(this,!1),Pu.set(this,!1),W0.set(this,void 0),q0.set(this,void 0),G0.set(this,e=>{if(Ye(this,U0,!0),Kp(e)&&(e=new ys),e instanceof ys)return Ye(this,H0,!0),this._emit("abort",e);if(e instanceof nt)return this._emit("error",e);if(e instanceof Error){const n=new nt(e.message);return n.cause=e,this._emit("error",n)}return this._emit("error",new nt(String(e)))}),Ye(this,gd,new Promise((e,n)=>{Ye(this,z0,e,"f"),Ye(this,yd,n,"f")})),Ye(this,bd,new Promise((e,n)=>{Ye(this,V0,e,"f"),Ye(this,vd,n,"f")})),me(this,gd,"f").catch(()=>{}),me(this,bd,"f").catch(()=>{})}get response(){return me(this,W0,"f")}get request_id(){return me(this,q0,"f")}async withResponse(){const e=await me(this,gd,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){const n=new rv;return n._run(()=>n._fromReadableStream(e)),n}static createMessage(e,n,r){const i=new rv;for(const s of n.messages)i._addMessageParam(s);return i._run(()=>i._createMessage(e,{...n,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},me(this,G0,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,n=!0){this.receivedMessages.push(e),n&&this._emit("message",e)}async _createMessage(e,n,r){const i=r?.signal;let s;i&&(i.aborted&&this.controller.abort(),s=this.controller.abort.bind(this.controller),i.addEventListener("abort",s));try{me(this,Fi,"m",YS).call(this);const{response:o,data:a}=await e.create({...n,stream:!0},{...r,signal:this.controller.signal}).withResponse();this._connected(o);for await(const c of a)me(this,Fi,"m",XS).call(this,c);if(a.controller.signal?.aborted)throw new ys;me(this,Fi,"m",JS).call(this)}finally{i&&s&&i.removeEventListener("abort",s)}}_connected(e){this.ended||(Ye(this,W0,e),Ye(this,q0,e?.headers.get("request-id")),me(this,z0,"f").call(this,e),this._emit("connect"))}get ended(){return me(this,wd,"f")}get errored(){return me(this,U0,"f")}get aborted(){return me(this,H0,"f")}abort(){this.controller.abort()}on(e,n){return(me(this,jo,"f")[e]||(me(this,jo,"f")[e]=[])).push({listener:n}),this}off(e,n){const r=me(this,jo,"f")[e];if(!r)return this;const i=r.findIndex(s=>s.listener===n);return i>=0&&r.splice(i,1),this}once(e,n){return(me(this,jo,"f")[e]||(me(this,jo,"f")[e]=[])).push({listener:n,once:!0}),this}emitted(e){return new Promise((n,r)=>{Ye(this,Pu,!0),e!=="error"&&this.once("error",r),this.once(e,n)})}async done(){Ye(this,Pu,!0),await me(this,bd,"f")}get currentMessage(){return me(this,za,"f")}async finalMessage(){return await this.done(),me(this,Fi,"m",KS).call(this)}async finalText(){return await this.done(),me(this,Fi,"m",gI).call(this)}_emit(e,...n){if(me(this,wd,"f"))return;e==="end"&&(Ye(this,wd,!0),me(this,V0,"f").call(this));const r=me(this,jo,"f")[e];if(r&&(me(this,jo,"f")[e]=r.filter(i=>!i.once),r.forEach(({listener:i})=>i(...n))),e==="abort"){const i=n[0];!me(this,Pu,"f")&&!r?.length&&Promise.reject(i),me(this,yd,"f").call(this,i),me(this,vd,"f").call(this,i),this._emit("end");return}if(e==="error"){const i=n[0];!me(this,Pu,"f")&&!r?.length&&Promise.reject(i),me(this,yd,"f").call(this,i),me(this,vd,"f").call(this,i),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",me(this,Fi,"m",KS).call(this))}async _fromReadableStream(e,n){const r=n?.signal;let i;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener("abort",i));try{me(this,Fi,"m",YS).call(this),this._connected(null);const s=Yp.fromReadableStream(e,this.controller);for await(const o of s)me(this,Fi,"m",XS).call(this,o);if(s.controller.signal?.aborted)throw new ys;me(this,Fi,"m",JS).call(this)}finally{r&&i&&r.removeEventListener("abort",i)}}[(za=new WeakMap,gd=new WeakMap,z0=new WeakMap,yd=new WeakMap,bd=new WeakMap,V0=new WeakMap,vd=new WeakMap,jo=new WeakMap,wd=new WeakMap,U0=new WeakMap,H0=new WeakMap,Pu=new WeakMap,W0=new WeakMap,q0=new WeakMap,G0=new WeakMap,Fi=new WeakSet,KS=function(){if(this.receivedMessages.length===0)throw new nt("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},gI=function(){if(this.receivedMessages.length===0)throw new nt("stream ended without producing a Message with role=assistant");const n=this.receivedMessages.at(-1).content.filter(r=>r.type==="text").map(r=>r.text);if(n.length===0)throw new nt("stream ended without producing a content block with type=text");return n.join(" ")},YS=function(){this.ended||Ye(this,za,void 0)},XS=function(n){if(this.ended)return;const r=me(this,Fi,"m",yI).call(this,n);switch(this._emit("streamEvent",n,r),n.type){case"content_block_delta":{const i=r.content.at(-1);switch(n.delta.type){case"text_delta":{i.type==="text"&&this._emit("text",n.delta.text,i.text||"");break}case"citations_delta":{i.type==="text"&&this._emit("citation",n.delta.citation,i.citations??[]);break}case"input_json_delta":{vI(i)&&i.input&&this._emit("inputJson",n.delta.partial_json,i.input);break}case"thinking_delta":{i.type==="thinking"&&this._emit("thinking",n.delta.thinking,i.thinking);break}case"signature_delta":{i.type==="thinking"&&this._emit("signature",i.signature);break}default:n.delta}break}case"message_stop":{this._addMessageParam(r),this._addMessage(r,!0);break}case"content_block_stop":{this._emit("contentBlock",r.content.at(-1));break}case"message_start":{Ye(this,za,r);break}}},JS=function(){if(this.ended)throw new nt("stream has ended, this shouldn't happen");const n=me(this,za,"f");if(!n)throw new nt("request ended without sending any chunks");return Ye(this,za,void 0),n},yI=function(n){let r=me(this,za,"f");if(n.type==="message_start"){if(r)throw new nt(`Unexpected event order, got ${n.type} before receiving "message_stop"`);return n.message}if(!r)throw new nt(`Unexpected event order, got ${n.type} before "message_start"`);switch(n.type){case"message_stop":return r;case"message_delta":return r.container=n.delta.container,r.stop_reason=n.delta.stop_reason,r.stop_sequence=n.delta.stop_sequence,r.usage.output_tokens=n.usage.output_tokens,n.usage.input_tokens!=null&&(r.usage.input_tokens=n.usage.input_tokens),n.usage.cache_creation_input_tokens!=null&&(r.usage.cache_creation_input_tokens=n.usage.cache_creation_input_tokens),n.usage.cache_read_input_tokens!=null&&(r.usage.cache_read_input_tokens=n.usage.cache_read_input_tokens),n.usage.server_tool_use!=null&&(r.usage.server_tool_use=n.usage.server_tool_use),r;case"content_block_start":return r.content.push(n.content_block),r;case"content_block_delta":{const i=r.content.at(n.index);switch(n.delta.type){case"text_delta":{i?.type==="text"&&(r.content[n.index]={...i,text:(i.text||"")+n.delta.text});break}case"citations_delta":{i?.type==="text"&&(r.content[n.index]={...i,citations:[...i.citations??[],n.delta.citation]});break}case"input_json_delta":{if(i&&vI(i)){let s=i[bI]||"";s+=n.delta.partial_json;const o={...i};if(Object.defineProperty(o,bI,{value:s,enumerable:!1,writable:!0}),s)try{o.input=FB(s)}catch(a){const c=new nt(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${a}. JSON: ${s}`);me(this,G0,"f").call(this,c)}r.content[n.index]=o}break}case"thinking_delta":{i?.type==="thinking"&&(r.content[n.index]={...i,thinking:i.thinking+n.delta.thinking});break}case"signature_delta":{i?.type==="thinking"&&(r.content[n.index]={...i,signature:n.delta.signature});break}default:n.delta}return r}case"content_block_stop":return r}},Symbol.asyncIterator)](){const e=[],n=[];let r=!1;return this.on("streamEvent",i=>{const s=n.shift();s?s.resolve(i):e.push(i)}),this.on("end",()=>{r=!0;for(const i of n)i.resolve(void 0);n.length=0}),this.on("abort",i=>{r=!0;for(const s of n)s.reject(i);n.length=0}),this.on("error",i=>{r=!0;for(const s of n)s.reject(i);n.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((s,o)=>n.push({resolve:s,reject:o})).then(s=>s?{value:s,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Yp(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}const zB={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192},wI={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-5-sonnet-20241022":"October 22, 2025","claude-3-5-sonnet-20240620":"October 22, 2025"};let JE=class extends ia{constructor(){super(...arguments),this.batches=new BB(this._client)}create(e,n){const{betas:r,...i}=e;i.model in wI&&console.warn(`The model '${i.model}' is deprecated and will reach end-of-life on ${wI[i.model]}
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);let s=this._client._options.timeout;if(!i.stream&&s==null){const o=zB[i.model]??void 0;s=this._client.calculateNonstreamingTimeout(i.max_tokens,o)}return this._client.post("/v1/messages?beta=true",{body:i,timeout:s??6e5,...n,headers:zt([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},n?.headers]),stream:e.stream??!1})}stream(e,n){return rv.createMessage(this,e,n)}countTokens(e,n){const{betas:r,...i}=e;return this._client.post("/v1/messages/count_tokens?beta=true",{body:i,...n,headers:zt([{"anthropic-beta":[...r??[],"token-counting-2024-11-01"].toString()},n?.headers])})}};JE.Batches=BB;let Nm=class extends ia{constructor(){super(...arguments),this.models=new jB(this._client),this.messages=new JE(this._client),this.files=new $B(this._client)}};Nm.Models=jB;Nm.Messages=JE;Nm.Files=$B;let VB=class extends ia{create(e,n){const{betas:r,...i}=e;return this._client.post("/v1/complete",{body:i,timeout:this._client._options.timeout??6e5,...n,headers:zt([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},n?.headers]),stream:e.stream??!1})}};var zi,Va,xd,K0,Sd,_d,Y0,Cd,Bo,Ad,X0,J0,Du,Q0,Z0,QS,xI,ZS,e_,t_,n_,SI;const _I="__json_buf";function CI(t){return t.type==="tool_use"||t.type==="server_tool_use"}class iv{constructor(){zi.add(this),this.messages=[],this.receivedMessages=[],Va.set(this,void 0),this.controller=new AbortController,xd.set(this,void 0),K0.set(this,()=>{}),Sd.set(this,()=>{}),_d.set(this,void 0),Y0.set(this,()=>{}),Cd.set(this,()=>{}),Bo.set(this,{}),Ad.set(this,!1),X0.set(this,!1),J0.set(this,!1),Du.set(this,!1),Q0.set(this,void 0),Z0.set(this,void 0),ZS.set(this,e=>{if(Ye(this,X0,!0),Kp(e)&&(e=new ys),e instanceof ys)return Ye(this,J0,!0),this._emit("abort",e);if(e instanceof nt)return this._emit("error",e);if(e instanceof Error){const n=new nt(e.message);return n.cause=e,this._emit("error",n)}return this._emit("error",new nt(String(e)))}),Ye(this,xd,new Promise((e,n)=>{Ye(this,K0,e,"f"),Ye(this,Sd,n,"f")})),Ye(this,_d,new Promise((e,n)=>{Ye(this,Y0,e,"f"),Ye(this,Cd,n,"f")})),me(this,xd,"f").catch(()=>{}),me(this,_d,"f").catch(()=>{})}get response(){return me(this,Q0,"f")}get request_id(){return me(this,Z0,"f")}async withResponse(){const e=await me(this,xd,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){const n=new iv;return n._run(()=>n._fromReadableStream(e)),n}static createMessage(e,n,r){const i=new iv;for(const s of n.messages)i._addMessageParam(s);return i._run(()=>i._createMessage(e,{...n,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},me(this,ZS,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,n=!0){this.receivedMessages.push(e),n&&this._emit("message",e)}async _createMessage(e,n,r){const i=r?.signal;let s;i&&(i.aborted&&this.controller.abort(),s=this.controller.abort.bind(this.controller),i.addEventListener("abort",s));try{me(this,zi,"m",e_).call(this);const{response:o,data:a}=await e.create({...n,stream:!0},{...r,signal:this.controller.signal}).withResponse();this._connected(o);for await(const c of a)me(this,zi,"m",t_).call(this,c);if(a.controller.signal?.aborted)throw new ys;me(this,zi,"m",n_).call(this)}finally{i&&s&&i.removeEventListener("abort",s)}}_connected(e){this.ended||(Ye(this,Q0,e),Ye(this,Z0,e?.headers.get("request-id")),me(this,K0,"f").call(this,e),this._emit("connect"))}get ended(){return me(this,Ad,"f")}get errored(){return me(this,X0,"f")}get aborted(){return me(this,J0,"f")}abort(){this.controller.abort()}on(e,n){return(me(this,Bo,"f")[e]||(me(this,Bo,"f")[e]=[])).push({listener:n}),this}off(e,n){const r=me(this,Bo,"f")[e];if(!r)return this;const i=r.findIndex(s=>s.listener===n);return i>=0&&r.splice(i,1),this}once(e,n){return(me(this,Bo,"f")[e]||(me(this,Bo,"f")[e]=[])).push({listener:n,once:!0}),this}emitted(e){return new Promise((n,r)=>{Ye(this,Du,!0),e!=="error"&&this.once("error",r),this.once(e,n)})}async done(){Ye(this,Du,!0),await me(this,_d,"f")}get currentMessage(){return me(this,Va,"f")}async finalMessage(){return await this.done(),me(this,zi,"m",QS).call(this)}async finalText(){return await this.done(),me(this,zi,"m",xI).call(this)}_emit(e,...n){if(me(this,Ad,"f"))return;e==="end"&&(Ye(this,Ad,!0),me(this,Y0,"f").call(this));const r=me(this,Bo,"f")[e];if(r&&(me(this,Bo,"f")[e]=r.filter(i=>!i.once),r.forEach(({listener:i})=>i(...n))),e==="abort"){const i=n[0];!me(this,Du,"f")&&!r?.length&&Promise.reject(i),me(this,Sd,"f").call(this,i),me(this,Cd,"f").call(this,i),this._emit("end");return}if(e==="error"){const i=n[0];!me(this,Du,"f")&&!r?.length&&Promise.reject(i),me(this,Sd,"f").call(this,i),me(this,Cd,"f").call(this,i),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",me(this,zi,"m",QS).call(this))}async _fromReadableStream(e,n){const r=n?.signal;let i;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener("abort",i));try{me(this,zi,"m",e_).call(this),this._connected(null);const s=Yp.fromReadableStream(e,this.controller);for await(const o of s)me(this,zi,"m",t_).call(this,o);if(s.controller.signal?.aborted)throw new ys;me(this,zi,"m",n_).call(this)}finally{r&&i&&r.removeEventListener("abort",i)}}[(Va=new WeakMap,xd=new WeakMap,K0=new WeakMap,Sd=new WeakMap,_d=new WeakMap,Y0=new WeakMap,Cd=new WeakMap,Bo=new WeakMap,Ad=new WeakMap,X0=new WeakMap,J0=new WeakMap,Du=new WeakMap,Q0=new WeakMap,Z0=new WeakMap,ZS=new WeakMap,zi=new WeakSet,QS=function(){if(this.receivedMessages.length===0)throw new nt("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},xI=function(){if(this.receivedMessages.length===0)throw new nt("stream ended without producing a Message with role=assistant");const n=this.receivedMessages.at(-1).content.filter(r=>r.type==="text").map(r=>r.text);if(n.length===0)throw new nt("stream ended without producing a content block with type=text");return n.join(" ")},e_=function(){this.ended||Ye(this,Va,void 0)},t_=function(n){if(this.ended)return;const r=me(this,zi,"m",SI).call(this,n);switch(this._emit("streamEvent",n,r),n.type){case"content_block_delta":{const i=r.content.at(-1);switch(n.delta.type){case"text_delta":{i.type==="text"&&this._emit("text",n.delta.text,i.text||"");break}case"citations_delta":{i.type==="text"&&this._emit("citation",n.delta.citation,i.citations??[]);break}case"input_json_delta":{CI(i)&&i.input&&this._emit("inputJson",n.delta.partial_json,i.input);break}case"thinking_delta":{i.type==="thinking"&&this._emit("thinking",n.delta.thinking,i.thinking);break}case"signature_delta":{i.type==="thinking"&&this._emit("signature",i.signature);break}default:n.delta}break}case"message_stop":{this._addMessageParam(r),this._addMessage(r,!0);break}case"content_block_stop":{this._emit("contentBlock",r.content.at(-1));break}case"message_start":{Ye(this,Va,r);break}}},n_=function(){if(this.ended)throw new nt("stream has ended, this shouldn't happen");const n=me(this,Va,"f");if(!n)throw new nt("request ended without sending any chunks");return Ye(this,Va,void 0),n},SI=function(n){let r=me(this,Va,"f");if(n.type==="message_start"){if(r)throw new nt(`Unexpected event order, got ${n.type} before receiving "message_stop"`);return n.message}if(!r)throw new nt(`Unexpected event order, got ${n.type} before "message_start"`);switch(n.type){case"message_stop":return r;case"message_delta":return r.stop_reason=n.delta.stop_reason,r.stop_sequence=n.delta.stop_sequence,r.usage.output_tokens=n.usage.output_tokens,n.usage.input_tokens!=null&&(r.usage.input_tokens=n.usage.input_tokens),n.usage.cache_creation_input_tokens!=null&&(r.usage.cache_creation_input_tokens=n.usage.cache_creation_input_tokens),n.usage.cache_read_input_tokens!=null&&(r.usage.cache_read_input_tokens=n.usage.cache_read_input_tokens),n.usage.server_tool_use!=null&&(r.usage.server_tool_use=n.usage.server_tool_use),r;case"content_block_start":return r.content.push({...n.content_block}),r;case"content_block_delta":{const i=r.content.at(n.index);switch(n.delta.type){case"text_delta":{i?.type==="text"&&(r.content[n.index]={...i,text:(i.text||"")+n.delta.text});break}case"citations_delta":{i?.type==="text"&&(r.content[n.index]={...i,citations:[...i.citations??[],n.delta.citation]});break}case"input_json_delta":{if(i&&CI(i)){let s=i[_I]||"";s+=n.delta.partial_json;const o={...i};Object.defineProperty(o,_I,{value:s,enumerable:!1,writable:!0}),s&&(o.input=FB(s)),r.content[n.index]=o}break}case"thinking_delta":{i?.type==="thinking"&&(r.content[n.index]={...i,thinking:i.thinking+n.delta.thinking});break}case"signature_delta":{i?.type==="thinking"&&(r.content[n.index]={...i,signature:n.delta.signature});break}default:n.delta}return r}case"content_block_stop":return r}},Symbol.asyncIterator)](){const e=[],n=[];let r=!1;return this.on("streamEvent",i=>{const s=n.shift();s?s.resolve(i):e.push(i)}),this.on("end",()=>{r=!0;for(const i of n)i.resolve(void 0);n.length=0}),this.on("abort",i=>{r=!0;for(const s of n)s.reject(i);n.length=0}),this.on("error",i=>{r=!0;for(const s of n)s.reject(i);n.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((s,o)=>n.push({resolve:s,reject:o})).then(s=>s?{value:s,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Yp(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}let UB=class extends ia{create(e,n){return this._client.post("/v1/messages/batches",{body:e,...n})}retrieve(e,n){return this._client.get(vs`/v1/messages/batches/${e}`,n)}list(e={},n){return this._client.getAPIList("/v1/messages/batches",Lm,{query:e,...n})}delete(e,n){return this._client.delete(vs`/v1/messages/batches/${e}`,n)}cancel(e,n){return this._client.post(vs`/v1/messages/batches/${e}/cancel`,n)}async results(e,n){const r=await this.retrieve(e);if(!r.results_url)throw new nt(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);return this._client.get(r.results_url,{...n,headers:zt([{Accept:"application/binary"},n?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((i,s)=>Lw.fromResponse(s.response,s.controller))}},QE=class extends ia{constructor(){super(...arguments),this.batches=new UB(this._client)}create(e,n){e.model in AI&&console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${AI[e.model]}
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);let r=this._client._options.timeout;if(!e.stream&&r==null){const i=zB[e.model]??void 0;r=this._client.calculateNonstreamingTimeout(e.max_tokens,i)}return this._client.post("/v1/messages",{body:e,timeout:r??6e5,...n,stream:e.stream??!1})}stream(e,n){return iv.createMessage(this,e,n)}countTokens(e,n){return this._client.post("/v1/messages/count_tokens",{body:e,...n})}};const AI={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-5-sonnet-20241022":"October 22, 2025","claude-3-5-sonnet-20240620":"October 22, 2025"};QE.Batches=UB;let HB=class extends ia{retrieve(e,n={},r){const{betas:i}=n??{};return this._client.get(vs`/v1/models/${e}`,{...r,headers:zt([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers])})}list(e={},n){const{betas:r,...i}=e??{};return this._client.getAPIList("/v1/models",Lm,{query:i,...n,headers:zt([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},n?.headers])})}};var Zee={};const ey=t=>{if(typeof globalThis.process<"u")return Zee?.[t]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(t)?.trim()};var rC,ZE,ub,WB;class bn{constructor({baseURL:e=ey("ANTHROPIC_BASE_URL"),apiKey:n=ey("ANTHROPIC_API_KEY")??null,authToken:r=ey("ANTHROPIC_AUTH_TOKEN")??null,...i}={}){rC.add(this),ub.set(this,void 0);const s={apiKey:n,authToken:r,...i,baseURL:e||"https://api.anthropic.com"};if(!s.dangerouslyAllowBrowser&&See())throw new nt(`It looks like you're running in a browser-like environment.
This is disabled by default, as it risks exposing your secret API credentials to attackers.
If you understand the risks and have appropriate mitigations in place,
you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
`);this.baseURL=s.baseURL,this.timeout=s.timeout??ZE.DEFAULT_TIMEOUT,this.logger=s.logger??console;const o="warn";this.logLevel=o,this.logLevel=fI(s.logLevel,"ClientOptions.logLevel",this)??fI(ey("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??o,this.fetchOptions=s.fetchOptions,this.maxRetries=s.maxRetries??2,this.fetch=s.fetch??kee(),Ye(this,ub,Ree),this._options=s,this.apiKey=n,this.authToken=r}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:n}){if(!(this.apiKey&&e.get("x-api-key"))&&!n.has("x-api-key")&&!(this.authToken&&e.get("authorization"))&&!n.has("authorization"))throw new Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}async authHeaders(e){return zt([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(this.apiKey!=null)return zt([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(this.authToken!=null)return zt([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return Object.entries(e).filter(([n,r])=>typeof r<"u").map(([n,r])=>{if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return`${encodeURIComponent(n)}=${encodeURIComponent(r)}`;if(r===null)return`${encodeURIComponent(n)}=`;throw new nt(`Cannot stringify type ${typeof r}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${Hu}`}defaultIdempotencyKey(){return`stainless-node-retry-${mB()}`}makeStatusError(e,n,r,i){return Ri.generate(e,n,r,i)}buildURL(e,n,r){const i=!me(this,rC,"m",WB).call(this)&&r||this.baseURL,s=yee(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();return bee(o)||(n={...o,...n}),typeof n=="object"&&n&&!Array.isArray(n)&&(s.search=this.stringifyQuery(n)),s.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new nt("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 600*1e3}async prepareOptions(e){}async prepareRequest(e,{url:n,options:r}){}get(e,n){return this.methodRequest("get",e,n)}post(e,n){return this.methodRequest("post",e,n)}patch(e,n){return this.methodRequest("patch",e,n)}put(e,n){return this.methodRequest("put",e,n)}delete(e,n){return this.methodRequest("delete",e,n)}methodRequest(e,n,r){return this.request(Promise.resolve(r).then(i=>({method:e,path:n,...i})))}request(e,n=null){return new MB(this,this.makeRequest(e,n,void 0))}async makeRequest(e,n,r){const i=await e,s=i.maxRetries??this.maxRetries;n==null&&(n=s),await this.prepareOptions(i);const{req:o,url:a,timeout:c}=await this.buildRequest(i,{retryCount:s-n});await this.prepareRequest(o,{url:a,options:i});const h="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),f=r===void 0?"":`, retryOf: ${r}`,d=Date.now();if(kr(this).debug(`[${h}] sending request`,Zl({retryOfRequestLogID:r,method:i.method,url:a,options:i,headers:o.headers})),i.signal?.aborted)throw new ys;const m=new AbortController,y=await this.fetchWithTimeout(a,o,c,m).catch(Q2),b=Date.now();if(y instanceof Error){const _=`retrying, ${n} attempts remaining`;if(i.signal?.aborted)throw new ys;const A=Kp(y)||/timed? ?out/i.test(String(y)+("cause"in y?String(y.cause):""));if(n)return kr(this).info(`[${h}] connection ${A?"timed out":"failed"} - ${_}`),kr(this).debug(`[${h}] connection ${A?"timed out":"failed"} (${_})`,Zl({retryOfRequestLogID:r,url:a,durationMs:b-d,message:y.message})),this.retryRequest(i,n,r??h);throw kr(this).info(`[${h}] connection ${A?"timed out":"failed"} - error; no more retries left`),kr(this).debug(`[${h}] connection ${A?"timed out":"failed"} (error; no more retries left)`,Zl({retryOfRequestLogID:r,url:a,durationMs:b-d,message:y.message})),A?new gB:new Iw({cause:y})}const w=[...y.headers.entries()].filter(([_])=>_==="request-id").map(([_,A])=>", "+_+": "+JSON.stringify(A)).join(""),S=`[${h}${f}${w}] ${o.method} ${a} ${y.ok?"succeeded":"failed"} with status ${y.status} in ${b-d}ms`;if(!y.ok){const _=await this.shouldRetry(y);if(n&&_){const D=`retrying, ${n} attempts remaining`;return await Tee(y.body),kr(this).info(`${S} - ${D}`),kr(this).debug(`[${h}] response error (${D})`,Zl({retryOfRequestLogID:r,url:y.url,status:y.status,headers:y.headers,durationMs:b-d})),this.retryRequest(i,n,r??h,y.headers)}const A=_?"error; no more retries left":"error; not retryable";kr(this).info(`${S} - ${A}`);const E=await y.text().catch(D=>Q2(D).message),P=AB(E),O=P?void 0:E;throw kr(this).debug(`[${h}] response error (${A})`,Zl({retryOfRequestLogID:r,url:y.url,status:y.status,headers:y.headers,message:O,durationMs:Date.now()-d})),this.makeStatusError(y.status,P,O,y.headers)}return kr(this).info(S),kr(this).debug(`[${h}] response start`,Zl({retryOfRequestLogID:r,url:y.url,status:y.status,headers:y.headers,durationMs:b-d})),{response:y,options:i,controller:m,requestLogID:h,retryOfRequestLogID:r,startTime:d}}getAPIList(e,n,r){return this.requestAPIList(n,{method:"get",path:e,...r})}requestAPIList(e,n){const r=this.makeRequest(n,null,void 0);return new Bee(this,r,e)}async fetchWithTimeout(e,n,r,i){const{signal:s,method:o,...a}=n||{};s&&s.addEventListener("abort",()=>i.abort());const c=setTimeout(()=>i.abort(),r),h=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,f={signal:i.signal,...h?{duplex:"half"}:{},method:"GET",...a};o&&(f.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,f)}finally{clearTimeout(c)}}async shouldRetry(e){const n=e.headers.get("x-should-retry");return n==="true"?!0:n==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,n,r,i){let s;const o=i?.get("retry-after-ms");if(o){const c=parseFloat(o);Number.isNaN(c)||(s=c)}const a=i?.get("retry-after");if(a&&!s){const c=parseFloat(a);Number.isNaN(c)?s=Date.parse(a)-Date.now():s=c*1e3}if(!(s&&0<=s&&s<60*1e3)){const c=e.maxRetries??this.maxRetries;s=this.calculateDefaultRetryTimeoutMillis(n,c)}return await xee(s),this.makeRequest(e,n-1,r)}calculateDefaultRetryTimeoutMillis(e,n){const s=n-e,o=Math.min(.5*Math.pow(2,s),8),a=1-Math.random()*.25;return o*a*1e3}calculateNonstreamingTimeout(e,n){if(36e5*e/128e3>6e5||n!=null&&e>n)throw new nt("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return 6e5}async buildRequest(e,{retryCount:n=0}={}){const r={...e},{method:i,path:s,query:o,defaultBaseURL:a}=r,c=this.buildURL(s,o,a);"timeout"in r&&wee("timeout",r.timeout),r.timeout=r.timeout??this.timeout;const{bodyHeaders:h,body:f}=this.buildBody({options:r}),d=await this.buildHeaders({options:e,method:i,bodyHeaders:h,retryCount:n});return{req:{method:i,headers:d,...r.signal&&{signal:r.signal},...globalThis.ReadableStream&&f instanceof globalThis.ReadableStream&&{duplex:"half"},...f&&{body:f},...this.fetchOptions??{},...r.fetchOptions??{}},url:c,timeout:r.timeout}}async buildHeaders({options:e,method:n,bodyHeaders:r,retryCount:i}){let s={};this.idempotencyHeader&&n!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=e.idempotencyKey);const o=zt([s,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Eee(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders(e),this._options.defaultHeaders,r,e.headers]);return this.validateHeaders(o),o.values}buildBody({options:{body:e,headers:n}}){if(!e)return{bodyHeaders:void 0,body:void 0};const r=zt([n]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&r.values.has("content-type")||e instanceof Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:kB(e)}:me(this,ub,"f").call(this,{body:e,headers:r})}}ZE=bn,ub=new WeakMap,rC=new WeakSet,WB=function(){return this.baseURL!=="https://api.anthropic.com"};bn.Anthropic=ZE;bn.HUMAN_PROMPT=`
Human:`;bn.AI_PROMPT=`
Assistant:`;bn.DEFAULT_TIMEOUT=6e5;bn.AnthropicError=nt;bn.APIError=Ri;bn.APIConnectionError=Iw;bn.APIConnectionTimeoutError=gB;bn.APIUserAbortError=ys;bn.NotFoundError=wB;bn.ConflictError=xB;bn.RateLimitError=_B;bn.BadRequestError=yB;bn.AuthenticationError=bB;bn.InternalServerError=CB;bn.PermissionDeniedError=vB;bn.UnprocessableEntityError=SB;bn.toFile=qee;class al extends bn{constructor(){super(...arguments),this.completions=new VB(this),this.messages=new QE(this),this.models=new HB(this),this.beta=new Nm(this)}}al.Completions=VB;al.Messages=QE;al.Models=HB;al.Beta=Nm;const{HUMAN_PROMPT:o6e,AI_PROMPT:a6e}=al;var qd={exports:{}};qd.exports;var EI;function ete(){return EI||(EI=1,(function(t,e){var n=200,r="__lodash_hash_undefined__",i=9007199254740991,s="[object Arguments]",o="[object Array]",a="[object Boolean]",c="[object Date]",h="[object Error]",f="[object Function]",d="[object GeneratorFunction]",m="[object Map]",y="[object Number]",b="[object Object]",w="[object Promise]",S="[object RegExp]",_="[object Set]",A="[object String]",E="[object Symbol]",P="[object WeakMap]",O="[object ArrayBuffer]",M="[object DataView]",D="[object Float32Array]",$="[object Float64Array]",F="[object Int8Array]",N="[object Int16Array]",U="[object Int32Array]",q="[object Uint8Array]",K="[object Uint8ClampedArray]",X="[object Uint16Array]",ee="[object Uint32Array]",V=/[\\^$.*+?()[\]{}|]/g,G=/\w*$/,H=/^\[object .+?Constructor\]$/,se=/^(?:0|[1-9]\d*)$/,T={};T[s]=T[o]=T[O]=T[M]=T[a]=T[c]=T[D]=T[$]=T[F]=T[N]=T[U]=T[m]=T[y]=T[b]=T[S]=T[_]=T[A]=T[E]=T[q]=T[K]=T[X]=T[ee]=!0,T[h]=T[f]=T[P]=!1;var Z=typeof R0=="object"&&R0&&R0.Object===Object&&R0,ue=typeof self=="object"&&self&&self.Object===Object&&self,L=Z||ue||Function("return this")(),pe=e&&!e.nodeType&&e,ke=pe&&!0&&t&&!t.nodeType&&t,be=ke&&ke.exports===pe;function Ee(j,Q){return j.set(Q[0],Q[1]),j}function Ue(j,Q){return j.add(Q),j}function Pt(j,Q){for(var le=-1,Oe=j?j.length:0;++le<Oe&&Q(j[le],le,j)!==!1;);return j}function Kt(j,Q){for(var le=-1,Oe=Q.length,Wt=j.length;++le<Oe;)j[Wt+le]=Q[le];return j}function Yt(j,Q,le,Oe){for(var Wt=-1,ar=j?j.length:0;++Wt<ar;)le=Q(le,j[Wt],Wt,j);return le}function er(j,Q){for(var le=-1,Oe=Array(j);++le<j;)Oe[le]=Q(le);return Oe}function tr(j,Q){return j?.[Q]}function ti(j){var Q=!1;if(j!=null&&typeof j.toString!="function")try{Q=!!(j+"")}catch{}return Q}function _o(j){var Q=-1,le=Array(j.size);return j.forEach(function(Oe,Wt){le[++Q]=[Wt,Oe]}),le}function ss(j,Q){return function(le){return j(Q(le))}}function nr(j){var Q=-1,le=Array(j.size);return j.forEach(function(Oe){le[++Q]=Oe}),le}var lf=Array.prototype,kl=Function.prototype,Ps=Object.prototype,Ds=L["__core-js_shared__"],Bc=(function(){var j=/[^.]+$/.exec(Ds&&Ds.keys&&Ds.keys.IE_PROTO||"");return j?"Symbol(src)_1."+j:""})(),Tl=kl.toString,Mi=Ps.hasOwnProperty,aa=Ps.toString,oe=RegExp("^"+Tl.call(Mi).replace(V,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ge=be?L.Buffer:void 0,De=L.Symbol,$e=L.Uint8Array,yt=ss(Object.getPrototypeOf,Object),Sr=Object.create,os=Ps.propertyIsEnumerable,rr=lf.splice,ni=Object.getOwnPropertySymbols,_r=ge?ge.isBuffer:void 0,on=ss(Object.keys,Object),ir=ii(L,"DataView"),Bn=ii(L,"Map"),Fc=ii(L,"Promise"),zc=ii(L,"Set"),Rl=ii(L,"WeakMap"),as=ii(Object,"create"),Mx=Br(ir),hg=Br(Bn),fg=Br(Fc),cf=Br(zc),uf=Br(Rl),hf=De?De.prototype:void 0,dg=hf?hf.valueOf:void 0;function sr(j){var Q=-1,le=j?j.length:0;for(this.clear();++Q<le;){var Oe=j[Q];this.set(Oe[0],Oe[1])}}function Mn(){this.__data__=as?as(null):{}}function or(j){return this.has(j)&&delete this.__data__[j]}function la(j){var Q=this.__data__;if(as){var le=Q[j];return le===r?void 0:le}return Mi.call(Q,j)?Q[j]:void 0}function ff(j){var Q=this.__data__;return as?Q[j]!==void 0:Mi.call(Q,j)}function Ox(j,Q){var le=this.__data__;return le[j]=as&&Q===void 0?r:Q,this}sr.prototype.clear=Mn,sr.prototype.delete=or,sr.prototype.get=la,sr.prototype.has=ff,sr.prototype.set=Ox;function ls(j){var Q=-1,le=j?j.length:0;for(this.clear();++Q<le;){var Oe=j[Q];this.set(Oe[0],Oe[1])}}function pg(){this.__data__=[]}function Ml(j){var Q=this.__data__,le=fa(Q,j);if(le<0)return!1;var Oe=Q.length-1;return le==Oe?Q.pop():rr.call(Q,le,1),!0}function df(j){var Q=this.__data__,le=fa(Q,j);return le<0?void 0:Q[le][1]}function ca(j){return fa(this.__data__,j)>-1}function ua(j,Q){var le=this.__data__,Oe=fa(le,j);return Oe<0?le.push([j,Q]):le[Oe][1]=Q,this}ls.prototype.clear=pg,ls.prototype.delete=Ml,ls.prototype.get=df,ls.prototype.has=ca,ls.prototype.set=ua;function Oi(j){var Q=-1,le=j?j.length:0;for(this.clear();++Q<le;){var Oe=j[Q];this.set(Oe[0],Oe[1])}}function ha(){this.__data__={hash:new sr,map:new(Bn||ls),string:new sr}}function an(j){return Ol(this,j).delete(j)}function mg(j){return Ol(this,j).get(j)}function gg(j){return Ol(this,j).has(j)}function Co(j,Q){return Ol(this,j).set(j,Q),this}Oi.prototype.clear=ha,Oi.prototype.delete=an,Oi.prototype.get=mg,Oi.prototype.has=gg,Oi.prototype.set=Co;function ri(j){this.__data__=new ls(j)}function Px(){this.__data__=new ls}function yg(j){return this.__data__.delete(j)}function bg(j){return this.__data__.get(j)}function Dx(j){return this.__data__.has(j)}function Vc(j,Q){var le=this.__data__;if(le instanceof ls){var Oe=le.__data__;if(!Bn||Oe.length<n-1)return Oe.push([j,Q]),this;le=this.__data__=new Oi(Oe)}return le.set(j,Q),this}ri.prototype.clear=Px,ri.prototype.delete=yg,ri.prototype.get=bg,ri.prototype.has=Dx,ri.prototype.set=Vc;function Uc(j,Q){var le=Yc(j)||xf(j)?er(j.length,String):[],Oe=le.length,Wt=!!Oe;for(var ar in j)Mi.call(j,ar)&&!(Wt&&(ar=="length"||$x(ar,Oe)))&&le.push(ar);return le}function Pi(j,Q,le){var Oe=j[Q];(!(Mi.call(j,Q)&&wf(Oe,le))||le===void 0&&!(Q in j))&&(j[Q]=le)}function fa(j,Q){for(var le=j.length;le--;)if(wf(j[le][0],Q))return le;return-1}function vg(j,Q){return j&&qc(Q,Jc(Q),j)}function Is(j,Q,le,Oe,Wt,ar,si){var On;if(Oe&&(On=ar?Oe(j,Wt,ar,si):Oe(j)),On!==void 0)return On;if(!ya(j))return j;var ba=Yc(j);if(ba){if(On=Eg(j),!Q)return _g(j,On)}else{var us=Ls(j),_f=us==f||us==d;if(Sf(j))return xg(j,Q);if(us==b||us==s||_f&&!ar){if(ti(j))return ar?j:{};if(On=bf(_f?{}:j),!Q)return da(j,vg(On,j))}else{if(!T[us])return ar?j:{};On=Nx(j,us,Is,Q)}}si||(si=new ri);var kg=si.get(j);if(kg)return kg;if(si.set(j,On),!ba)var Tg=le?Cg(j):Jc(j);return Pt(Tg||j,function(Cf,va){Tg&&(va=Cf,Cf=j[va]),Pi(On,va,Is(Cf,Q,le,Oe,va,j,si))}),On}function pf(j){return ya(j)?Sr(j):{}}function mf(j,Q,le){var Oe=Q(j);return Yc(j)?Oe:Kt(Oe,le(j))}function Ix(j){return aa.call(j)}function wg(j){if(!ya(j)||vf(j))return!1;var Q=ga(j)||ti(j)?oe:H;return Q.test(Br(j))}function $r(j){if(!Kc(j))return on(j);var Q=[];for(var le in Object(j))Mi.call(j,le)&&le!="constructor"&&Q.push(le);return Q}function xg(j,Q){if(Q)return j.slice();var le=new j.constructor(j.length);return j.copy(le),le}function gf(j){var Q=new j.constructor(j.byteLength);return new $e(Q).set(new $e(j)),Q}function Hc(j,Q){var le=Q?gf(j.buffer):j.buffer;return new j.constructor(le,j.byteOffset,j.byteLength)}function Sg(j,Q,le){var Oe=Q?le(_o(j),!0):_o(j);return Yt(Oe,Ee,new j.constructor)}function Wc(j){var Q=new j.constructor(j.source,G.exec(j));return Q.lastIndex=j.lastIndex,Q}function Lx(j,Q,le){var Oe=Q?le(nr(j),!0):nr(j);return Yt(Oe,Ue,new j.constructor)}function jr(j){return dg?Object(dg.call(j)):{}}function yf(j,Q){var le=Q?gf(j.buffer):j.buffer;return new j.constructor(le,j.byteOffset,j.length)}function _g(j,Q){var le=-1,Oe=j.length;for(Q||(Q=Array(Oe));++le<Oe;)Q[le]=j[le];return Q}function qc(j,Q,le,Oe){le||(le={});for(var Wt=-1,ar=Q.length;++Wt<ar;){var si=Q[Wt],On=void 0;Pi(le,si,On===void 0?j[si]:On)}return le}function da(j,Q){return qc(j,Ag(j),Q)}function Cg(j){return mf(j,Jc,Ag)}function Ol(j,Q){var le=j.__data__;return Gc(Q)?le[typeof Q=="string"?"string":"hash"]:le.map}function ii(j,Q){var le=tr(j,Q);return wg(le)?le:void 0}var Ag=ni?ss(ni,Object):Qc,Ls=Ix;(ir&&Ls(new ir(new ArrayBuffer(1)))!=M||Bn&&Ls(new Bn)!=m||Fc&&Ls(Fc.resolve())!=w||zc&&Ls(new zc)!=_||Rl&&Ls(new Rl)!=P)&&(Ls=function(j){var Q=aa.call(j),le=Q==b?j.constructor:void 0,Oe=le?Br(le):void 0;if(Oe)switch(Oe){case Mx:return M;case hg:return m;case fg:return w;case cf:return _;case uf:return P}return Q});function Eg(j){var Q=j.length,le=j.constructor(Q);return Q&&typeof j[0]=="string"&&Mi.call(j,"index")&&(le.index=j.index,le.input=j.input),le}function bf(j){return typeof j.constructor=="function"&&!Kc(j)?pf(yt(j)):{}}function Nx(j,Q,le,Oe){var Wt=j.constructor;switch(Q){case O:return gf(j);case a:case c:return new Wt(+j);case M:return Hc(j,Oe);case D:case $:case F:case N:case U:case q:case K:case X:case ee:return yf(j,Oe);case m:return Sg(j,Oe,le);case y:case A:return new Wt(j);case S:return Wc(j);case _:return Lx(j,Oe,le);case E:return jr(j)}}function $x(j,Q){return Q=Q??i,!!Q&&(typeof j=="number"||se.test(j))&&j>-1&&j%1==0&&j<Q}function Gc(j){var Q=typeof j;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?j!=="__proto__":j===null}function vf(j){return!!Bc&&Bc in j}function Kc(j){var Q=j&&j.constructor,le=typeof Q=="function"&&Q.prototype||Ps;return j===le}function Br(j){if(j!=null){try{return Tl.call(j)}catch{}try{return j+""}catch{}}return""}function pa(j){return Is(j,!0,!0)}function wf(j,Q){return j===Q||j!==j&&Q!==Q}function xf(j){return cs(j)&&Mi.call(j,"callee")&&(!os.call(j,"callee")||aa.call(j)==s)}var Yc=Array.isArray;function ma(j){return j!=null&&Ns(j.length)&&!ga(j)}function cs(j){return Xc(j)&&ma(j)}var Sf=_r||Zc;function ga(j){var Q=ya(j)?aa.call(j):"";return Q==f||Q==d}function Ns(j){return typeof j=="number"&&j>-1&&j%1==0&&j<=i}function ya(j){var Q=typeof j;return!!j&&(Q=="object"||Q=="function")}function Xc(j){return!!j&&typeof j=="object"}function Jc(j){return ma(j)?Uc(j):$r(j)}function Qc(){return[]}function Zc(){return!1}t.exports=pa})(qd,qd.exports)),qd.exports}var tte=ete();const Jr=Pc(tte),nte=`You are an AI assistant with access to a set of MCP tools.
Your default behavior is to act as a helpful, conversational LLM assistant: answer questions, explain concepts, brainstorm, or chat naturally.
Only call a tool when the users request clearly indicates the need for it (e.g., "search", "open URL", "analyze file", "plot data", etc.).
If the users intent is ambiguous, respond conversationally instead of calling a tool.
Do not push the user toward tools unnecessarily.
When you do use a tool, explain in natural language what youre doing if appropriate.
Otherwise, behave as if you are a standalone LLM chat without tools`,$m=`You are an assistant that generates short, clear chat titles.
Instructions:
Read the users message.
Create a concise chat title summarizing the topic.
Limit the title to 37 words.
Use sentence case (capitalize only first word unless proper nouns).
Do not include punctuation, emojis, or quotes.
If the message is unclear, create a reasonable general title.
Output only the title.
Example behavior:
User: How do I fix TypeScript errors in VSCode?
Assistant: Fixing TypeScript errors in VSCode
User: write me a poem about a dragon in a cave
Assistant: Poem about a dragon`,rte=t=>{const e=[];return t.forEach(({content:n})=>{n.forEach(r=>{if(r.type==="image"){const i=r.image,s=i.split(",")[1],o=i.split(";")[0].split(":")[1];let a;o==="image/jpeg"||o==="image/jpg"?a="image/jpeg":o==="image/png"?a="image/png":o==="image/gif"?a="image/gif":o==="image/webp"?a="image/webp":a="image/jpeg",e.push({type:"image",source:{type:"base64",media_type:a,data:s}})}})}),e},ite=t=>t.map(e=>({name:e.name,description:e.description,input_schema:{type:"object",...e.inputSchema}})),Ed=t=>{const e=[];return t.forEach(n=>{if(n.role==="user"){const r=typeof n.content=="string"?n.content:n.content.map(i=>i.type==="text"?{type:"text",text:i.text}:i.type==="file"?{type:"document",source:{type:"text",media_type:"text/plain",data:i.data},context:JSON.parse(i.mimeType).path}:{type:"text",text:""});if(n.attachments?.length){const i=rte(n.attachments);Array.isArray(r)&&r.push(...i)}e.push({role:"user",content:r})}else if(n.role==="system"){const r=typeof n.content=="string"?n.content:n.content.map(i=>i.type==="text"?{type:"text",text:i.text}:{type:"text",text:""});e.push({role:"user",content:r})}else{let r=typeof n.content=="string"?n.content:[],i=[];Array.isArray(n.content)&&n.content.forEach(s=>{if(Array.isArray(r)&&(s.type==="text"&&r.push({type:"text",text:s.text}),s.type==="tool-call")){s.result&&i.push({type:"tool_result",content:s.result,tool_use_id:s.toolCallId}),r.push({type:"tool_use",id:s.toolCallId,name:s.toolName,input:s.args||{}}),e.push({role:"assistant",content:r}),i.length&&(e.push({role:"user",content:i}),i=[]),r=[];return}}),r.length&&e.push({role:"assistant",content:r})}}),e},ste=t=>{const{message:e}=t;return{role:e.role,content:[]}},ote=(t,e)=>{const n={...e},{content_block:r}=t;if(r.type==="text"&&Array.isArray(n.content)){const i={type:"text",text:r.text};n.content.push(i)}if(r.type==="tool_use"&&Array.isArray(n.content)){const i={type:"tool-call",toolCallId:r.id,toolName:r.name,args:{},argsText:""};n.content.push(i)}return n},ate=(t,e)=>{const n={...e},{delta:r}=t;if(r.type==="text_delta"&&Array.isArray(n.content)){const i=n.content[n.content.length-1];if(i.type!=="text")return n;const s={type:"text",text:i.text+r.text};n.content[n.content.length-1]=s}if(r.type==="input_json_delta"&&Array.isArray(n.content)){const i=n.content[n.content.length-1];if(i.type!=="tool-call")return n;const s=i.argsText+r.partial_json;let o={};if(s.trim().endsWith("}"))try{o=JSON.parse(s)}catch(c){console.log(c)}const a={...i,args:o,argsText:s};n.content[n.content.length-1]=a}return n};class lte{modelKey="claude-3-7-sonnet-latest";systemPrompt="";apiKey;url;provider;messageStopped=!1;prevMessages=[];tools=[];client;constructor(){}setProvider=e=>{this.provider=e,this.client=new al({apiKey:e.key,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0}),e.key&&this.setApiKey(e.key),e.baseUrl&&this.setUrl(e.baseUrl)};setModelKey=e=>{this.modelKey=e};setSystemPrompt=e=>{this.systemPrompt=e};setApiKey=e=>{this.apiKey=e,this.client&&(this.client.apiKey=e)};setUrl=e=>{this.url=e,this.client&&(this.client.baseURL=e)};setPrevMessages=e=>{this.prevMessages=Ed(e)};setTools=e=>{this.tools=ite(e)};async createChatName(e){try{return this.client?(await this.client.messages.create({messages:[{role:"user",content:e}],model:this.modelKey,system:$m,max_tokens:2048,stream:!1})).content.find(i=>i.type==="text")?.text??e.substring(0,25):""}catch{return""}}async*sendMessage(e,n,r){try{if(!this.client)return;const i=Ed(e),s=await this.client.messages.create({messages:[...this.prevMessages,...i],model:this.modelKey,system:this.systemPrompt,tools:this.tools,stream:!0,max_tokens:3e4,tool_choice:{disable_parallel_tool_use:!0,type:"auto"}});this.prevMessages.push(...i);let o=n&&r?Jr(r):{role:"assistant",content:[]};for await(const a of s){const{type:c}=a;if(c==="message_start"){if(n&&r){yield r;continue}o=ste(a)}if(c==="content_block_start"&&(o=ote(a,o)),c==="content_block_delta"&&(o=ate(a,o)),c==="message_stop"){if(n&&r){const f=o.content.slice(r.content.length),d={...o,content:f},m=Ed([d]);this.prevMessages.push(...m),yield{isEnd:!0,responseMessage:o};continue}const h=Ed([o]);this.prevMessages.push(...h),yield{isEnd:!0,responseMessage:o};continue}if(this.messageStopped){this.messageStopped=!1;const h=Ed([o]);this.prevMessages.push(...h),s.controller.abort(),yield{isEnd:!0,responseMessage:o};continue}yield o}}catch(i){yield{isEnd:!0,responseMessage:{role:"assistant",content:"",status:{type:"incomplete",reason:"error",error:i}}}}}async*sendMessageAfterToolCall(e){if(typeof e.content=="string")return e;const n=e.content.filter(i=>i.type==="tool-call").reverse()[0];if(!n)return e;const r={type:"tool_result",content:n.result,tool_use_id:n.toolCallId??""};return this.prevMessages.push({role:"user",content:[r]}),yield*this.sendMessage([],!0,e),e}stopMessage=()=>{this.messageStopped=!0};getBaseUrl=()=>"https://api.anthropic.com";getName=()=>"Anthropic";checkProvider=async e=>{const n=new al({apiKey:e.apiKey,baseURL:e.url,dangerouslyAllowBrowser:!0});try{return await n.models.list(),!0}catch(r){if(console.log(JSON.stringify(r)),typeof r=="object"&&r){if("status"in r&&r.status===401)return{field:"key",message:"error"in r&&typeof r.error=="object"&&r.error&&"error"in r.error&&typeof r.error.error=="object"&&r.error.error&&"message"in r.error.error?r.error.error.message:"Invalid API key"};if("status"in r&&r.status===404)return{field:"url",message:"Invalid URL"}}return e.apiKey?{field:"key",message:"Invalid API key"}:{field:"key",message:"Empty key"}}};getProviderModels=async e=>{const n=new al({apiKey:e.apiKey,baseURL:e.url,dangerouslyAllowBrowser:!0});try{return(await n.models.list()).data.filter(s=>s.id.includes("claude-haiku-4-5")||s.id.includes("claude-sonnet-4-5")||s.id.includes("claude-opus-4-1")).map(s=>({id:s.id,name:s.display_name,provider:"anthropic"}))}catch(r){return console.log(r),[]}}}const kI=new lte;var Kn=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof global<"u"&&global||{},Rr={searchParams:"URLSearchParams"in Kn,iterable:"Symbol"in Kn&&"iterator"in Symbol,blob:"FileReader"in Kn&&"Blob"in Kn&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in Kn,arrayBuffer:"ArrayBuffer"in Kn};function cte(t){return t&&DataView.prototype.isPrototypeOf(t)}if(Rr.arrayBuffer)var ute=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],hte=ArrayBuffer.isView||function(t){return t&&ute.indexOf(Object.prototype.toString.call(t))>-1};function Gh(t){if(typeof t!="string"&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||t==="")throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function ek(t){return typeof t!="string"&&(t=String(t)),t}function tk(t){var e={next:function(){var n=t.shift();return{done:n===void 0,value:n}}};return Rr.iterable&&(e[Symbol.iterator]=function(){return e}),e}function Tn(t){this.map={},t instanceof Tn?t.forEach(function(e,n){this.append(n,e)},this):Array.isArray(t)?t.forEach(function(e){if(e.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}Tn.prototype.append=function(t,e){t=Gh(t),e=ek(e);var n=this.map[t];this.map[t]=n?n+", "+e:e};Tn.prototype.delete=function(t){delete this.map[Gh(t)]};Tn.prototype.get=function(t){return t=Gh(t),this.has(t)?this.map[t]:null};Tn.prototype.has=function(t){return this.map.hasOwnProperty(Gh(t))};Tn.prototype.set=function(t,e){this.map[Gh(t)]=ek(e)};Tn.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)};Tn.prototype.keys=function(){var t=[];return this.forEach(function(e,n){t.push(n)}),tk(t)};Tn.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),tk(t)};Tn.prototype.entries=function(){var t=[];return this.forEach(function(e,n){t.push([n,e])}),tk(t)};Rr.iterable&&(Tn.prototype[Symbol.iterator]=Tn.prototype.entries);function r_(t){if(!t._noBody){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}}function qB(t){return new Promise(function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}})}function fte(t){var e=new FileReader,n=qB(e);return e.readAsArrayBuffer(t),n}function dte(t){var e=new FileReader,n=qB(e),r=/charset=([A-Za-z0-9_-]+)/.exec(t.type),i=r?r[1]:"utf-8";return e.readAsText(t,i),n}function pte(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r<e.length;r++)n[r]=String.fromCharCode(e[r]);return n.join("")}function TI(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function GB(){return this.bodyUsed=!1,this._initBody=function(t){this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?typeof t=="string"?this._bodyText=t:Rr.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:Rr.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:Rr.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():Rr.arrayBuffer&&Rr.blob&&cte(t)?(this._bodyArrayBuffer=TI(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Rr.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||hte(t))?this._bodyArrayBuffer=TI(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof t=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):Rr.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},Rr.blob&&(this.blob=function(){var t=r_(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=r_(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(Rr.blob)return this.blob().then(fte);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var t=r_(this);if(t)return t;if(this._bodyBlob)return dte(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(pte(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},Rr.formData&&(this.formData=function(){return this.text().then(yte)}),this.json=function(){return this.text().then(JSON.parse)},this}var mte=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function gte(t){var e=t.toUpperCase();return mte.indexOf(e)>-1?e:t}function Sc(t,e){if(!(this instanceof Sc))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e=e||{};var n=e.body;if(t instanceof Sc){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new Tn(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,!n&&t._bodyInit!=null&&(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",(e.headers||!this.headers)&&(this.headers=new Tn(e.headers)),this.method=gte(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||(function(){if("AbortController"in Kn){var s=new AbortController;return s.signal}})(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&n)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(n),(this.method==="GET"||this.method==="HEAD")&&(e.cache==="no-store"||e.cache==="no-cache")){var r=/([?&])_=[^&]*/;if(r.test(this.url))this.url=this.url.replace(r,"$1_="+new Date().getTime());else{var i=/\?/;this.url+=(i.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}Sc.prototype.clone=function(){return new Sc(this,{body:this._bodyInit})};function yte(t){var e=new FormData;return t.trim().split("&").forEach(function(n){if(n){var r=n.split("="),i=r.shift().replace(/\+/g," "),s=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(s))}}),e}function bte(t){var e=new Tn,n=t.replace(/\r?\n[\t ]+/g," ");return n.split("\r").map(function(r){return r.indexOf(`
`)===0?r.substr(1,r.length):r}).forEach(function(r){var i=r.split(":"),s=i.shift().trim();if(s){var o=i.join(":").trim();try{e.append(s,o)}catch(a){console.warn("Response "+a.message)}}}),e}GB.call(Sc.prototype);function go(t,e){if(!(this instanceof go))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=e.status===void 0?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText===void 0?"":""+e.statusText,this.headers=new Tn(e.headers),this.url=e.url||"",this._initBody(t)}GB.call(go.prototype);go.prototype.clone=function(){return new go(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Tn(this.headers),url:this.url})};go.error=function(){var t=new go(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var vte=[301,302,303,307,308];go.redirect=function(t,e){if(vte.indexOf(e)===-1)throw new RangeError("Invalid status code");return new go(null,{status:e,headers:{location:t}})};var ic=Kn.DOMException;try{new ic}catch{ic=function(e,n){this.message=e,this.name=n;var r=Error(e);this.stack=r.stack},ic.prototype=Object.create(Error.prototype),ic.prototype.constructor=ic}function KB(t,e){return new Promise(function(n,r){var i=new Sc(t,e);if(i.signal&&i.signal.aborted)return r(new ic("Aborted","AbortError"));var s=new XMLHttpRequest;function o(){s.abort()}s.onload=function(){var h={statusText:s.statusText,headers:bte(s.getAllResponseHeaders()||"")};i.url.indexOf("file://")===0&&(s.status<200||s.status>599)?h.status=200:h.status=s.status,h.url="responseURL"in s?s.responseURL:h.headers.get("X-Request-URL");var f="response"in s?s.response:s.responseText;setTimeout(function(){n(new go(f,h))},0)},s.onerror=function(){setTimeout(function(){r(new TypeError("Network request failed"))},0)},s.ontimeout=function(){setTimeout(function(){r(new TypeError("Network request timed out"))},0)},s.onabort=function(){setTimeout(function(){r(new ic("Aborted","AbortError"))},0)};function a(h){try{return h===""&&Kn.location.href?Kn.location.href:h}catch{return h}}if(s.open(i.method,a(i.url),!0),i.credentials==="include"?s.withCredentials=!0:i.credentials==="omit"&&(s.withCredentials=!1),"responseType"in s&&(Rr.blob?s.responseType="blob":Rr.arrayBuffer&&(s.responseType="arraybuffer")),e&&typeof e.headers=="object"&&!(e.headers instanceof Tn||Kn.Headers&&e.headers instanceof Kn.Headers)){var c=[];Object.getOwnPropertyNames(e.headers).forEach(function(h){c.push(Gh(h)),s.setRequestHeader(h,ek(e.headers[h]))}),i.headers.forEach(function(h,f){c.indexOf(f)===-1&&s.setRequestHeader(f,h)})}else i.headers.forEach(function(h,f){s.setRequestHeader(f,h)});i.signal&&(i.signal.addEventListener("abort",o),s.onreadystatechange=function(){s.readyState===4&&i.signal.removeEventListener("abort",o)}),s.send(typeof i._bodyInit>"u"?null:i._bodyInit)})}KB.polyfill=!0;Kn.fetch||(Kn.fetch=KB,Kn.Headers=Tn,Kn.Request=Sc,Kn.Response=go);const YB="11434",XB=`http://127.0.0.1:${YB}`,wte="0.5.18";var xte=Object.defineProperty,Ste=(t,e,n)=>e in t?xte(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,i_=(t,e,n)=>(Ste(t,typeof e!="symbol"?e+"":e,n),n);class nk extends Error{constructor(e,n){super(e),this.error=e,this.status_code=n,this.name="ResponseError",Error.captureStackTrace&&Error.captureStackTrace(this,nk)}}class _te{constructor(e,n,r){i_(this,"abortController"),i_(this,"itr"),i_(this,"doneCallback"),this.abortController=e,this.itr=n,this.doneCallback=r}abort(){this.abortController.abort()}async*[Symbol.asyncIterator](){for await(const e of this.itr){if("error"in e)throw new Error(e.error);if(yield e,e.done||e.status==="success"){this.doneCallback();return}}throw new Error("Did not receive done or success response in stream.")}}const rk=async t=>{if(t.ok)return;let e=`Error ${t.status}: ${t.statusText}`,n=null;if(t.headers.get("content-type")?.includes("application/json"))try{n=await t.json(),e=n.error||e}catch{console.log("Failed to parse error response as JSON")}else try{console.log("Getting text from response"),e=await t.text()||e}catch{console.log("Failed to get text from error response")}throw new nk(e,t.status)};function Cte(){if(typeof window<"u"&&window.navigator){const t=navigator;return"userAgentData"in t&&t.userAgentData?.platform?`${t.userAgentData.platform.toLowerCase()} Browser/${navigator.userAgent};`:navigator.platform?`${navigator.platform.toLowerCase()} Browser/${navigator.userAgent};`:`unknown Browser/${navigator.userAgent};`}else if(typeof process<"u")return`${process.arch} ${process.platform} Node.js/${process.version}`;return""}function Ate(t){if(t instanceof Headers){const e={};return t.forEach((n,r)=>{e[r]=n}),e}else return Array.isArray(t)?Object.fromEntries(t):t||{}}const ik=async(t,e,n={})=>{const r={"Content-Type":"application/json",Accept:"application/json","User-Agent":`ollama-js/${wte} (${Cte()})`};n.headers=Ate(n.headers);const i=Object.fromEntries(Object.entries(n.headers).filter(([s])=>!Object.keys(r).some(o=>o.toLowerCase()===s.toLowerCase())));return n.headers={...r,...i},t(e,n)},RI=async(t,e,n)=>{const r=await ik(t,e,{headers:n?.headers});return await rk(r),r},Iu=async(t,e,n,r)=>{const s=(a=>a!==null&&typeof a=="object"&&!Array.isArray(a))(n)?JSON.stringify(n):n,o=await ik(t,e,{method:"POST",body:s,signal:r?.signal,headers:r?.headers});return await rk(o),o},Ete=async(t,e,n,r)=>{const i=await ik(t,e,{method:"DELETE",body:JSON.stringify(n),headers:r?.headers});return await rk(i),i},kte=async function*(t){const e=new TextDecoder("utf-8");let n="";const r=t.getReader();for(;;){const{done:i,value:s}=await r.read();if(i)break;n+=e.decode(s);const o=n.split(`
`);n=o.pop()??"";for(const a of o)try{yield JSON.parse(a)}catch{console.warn("invalid json: ",a)}}for(const i of n.split(`
`).filter(s=>s!==""))try{yield JSON.parse(i)}catch{console.warn("invalid json: ",i)}},Tte=t=>{if(!t)return XB;let e=t.includes("://");t.startsWith(":")&&(t=`http://127.0.0.1${t}`,e=!0),e||(t=`http://${t}`);const n=new URL(t);let r=n.port;r||(e?r=n.protocol==="https:"?"443":"80":r=YB);let i="";n.username&&(i=n.username,n.password&&(i+=`:${n.password}`),i+="@");let s=`${n.protocol}//${i}${n.hostname}:${r}${n.pathname}`;return s.endsWith("/")&&(s=s.slice(0,-1)),s};var Rte=Object.defineProperty,Mte=(t,e,n)=>e in t?Rte(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,s_=(t,e,n)=>(Mte(t,typeof e!="symbol"?e+"":e,n),n);let hb=class{constructor(e){s_(this,"config"),s_(this,"fetch"),s_(this,"ongoingStreamedRequests",[]),this.config={host:"",headers:e?.headers},e?.proxy||(this.config.host=Tte(e?.host??XB)),this.fetch=e?.fetch??fetch}abort(){for(const e of this.ongoingStreamedRequests)e.abort();this.ongoingStreamedRequests.length=0}async processStreamableRequest(e,n){n.stream=n.stream??!1;const r=`${this.config.host}/api/${e}`;if(n.stream){const s=new AbortController,o=await Iu(this.fetch,r,n,{signal:s.signal,headers:this.config.headers});if(!o.body)throw new Error("Missing body");const a=kte(o.body),c=new _te(s,a,()=>{const h=this.ongoingStreamedRequests.indexOf(c);h>-1&&this.ongoingStreamedRequests.splice(h,1)});return this.ongoingStreamedRequests.push(c),c}return await(await Iu(this.fetch,r,n,{headers:this.config.headers})).json()}async encodeImage(e){if(typeof e!="string"){const n=new Uint8Array(e);let r="";const i=n.byteLength;for(let s=0;s<i;s++)r+=String.fromCharCode(n[s]);return btoa(r)}return e}async generate(e){return e.images&&(e.images=await Promise.all(e.images.map(this.encodeImage.bind(this)))),this.processStreamableRequest("generate",e)}async chat(e){if(e.messages)for(const n of e.messages)n.images&&(n.images=await Promise.all(n.images.map(this.encodeImage.bind(this))));return this.processStreamableRequest("chat",e)}async create(e){return this.processStreamableRequest("create",{...e})}async pull(e){return this.processStreamableRequest("pull",{name:e.model,stream:e.stream,insecure:e.insecure})}async push(e){return this.processStreamableRequest("push",{name:e.model,stream:e.stream,insecure:e.insecure})}async delete(e){return await Ete(this.fetch,`${this.config.host}/api/delete`,{name:e.model},{headers:this.config.headers}),{status:"success"}}async copy(e){return await Iu(this.fetch,`${this.config.host}/api/copy`,{...e},{headers:this.config.headers}),{status:"success"}}async list(){return await(await RI(this.fetch,`${this.config.host}/api/tags`,{headers:this.config.headers})).json()}async show(e){return await(await Iu(this.fetch,`${this.config.host}/api/show`,{...e},{headers:this.config.headers})).json()}async embed(e){return await(await Iu(this.fetch,`${this.config.host}/api/embed`,{...e},{headers:this.config.headers})).json()}async embeddings(e){return await(await Iu(this.fetch,`${this.config.host}/api/embeddings`,{...e},{headers:this.config.headers})).json()}async ps(){return await(await RI(this.fetch,`${this.config.host}/api/ps`,{headers:this.config.headers})).json()}};new hb;const vp="<TOOL_CALL>",sv="</TOOL_CALL>",Ote=t=>t.map(e=>({type:"string",function:{name:e.name,description:e.description,parameters:e.inputSchema}})),Pte=t=>{let e=`
Available tools:
`;const n=JSON.stringify(t);e+=n;const i=JSON.stringify({name:"toolName",args:{arg1:"arg1",arg2:"arg2"}});return e+=`
When you call a tool, output must look EXACTLY like this:
${vp}
${i}
${sv}
Do not add explanations, markdown, or extra text outside the tags.`,e},MI=t=>{const e=[];return t.forEach(n=>{if(n.role==="user"){const r=typeof n.content=="string"?n.content:n.content.map(i=>{if(i.type==="text")return i.text;if(i.type==="file"){const s=JSON.parse(i.mimeType).path;return`File: ${s.includes("\\")?s.split("\\").pop():s.split("/").pop()}
File content:
${i.data}`}return""}).filter(i=>i!=="").join(`
`);e.push({role:"user",content:r})}else if(n.role==="system"){const r=typeof n.content=="string"?n.content:n.content.find(i=>i.type==="text")?.text??"";e.push({role:"user",content:r})}else{let r="";const i=Array.isArray(n.content)?n.content.map(o=>{if(o.type==="text")return o.text;if(o.type==="tool-call"){const a={name:o.toolName,result:o.result};return r=`${JSON.stringify(a)}
`,`${vp}${o.argsText}${sv}`}}).join(""):"",s=typeof n.content=="string"?n.content:i;e.push({role:"assistant",content:s}),r&&e.push({role:"user",content:r})}}),e},Dte=t=>{let e=!1,n=!1,r="";if(t.includes(vp)&&(e=!0,r=t.split(vp)[1]),!e)return{content:t};t.includes(sv)&&(n=!0,r=r.split(sv)[0]);const i=t.split(vp)[0];if(n){const o={type:"tool-call",toolCallId:"",toolName:JSON.parse(r).name,args:JSON.parse(r).args,argsText:r};return{content:i,toolContent:o}}return{toolContent:{type:"tool-call",toolCallId:"",toolName:"",args:{},argsText:r},content:i}};class Ite{modelKey="";systemPrompt="";apiKey;url;provider;prevMessages=[];tools=[];client;messageStopped=!1;constructor(){}setProvider=e=>{this.provider=e,this.client=new hb({host:e.baseUrl}),e.key&&this.setAPIKey(e.key),e.baseUrl&&this.setURL(e.baseUrl)};setModelKey=e=>{this.modelKey=e};setSystemPrompt=e=>{this.systemPrompt=e};setAPIKey=e=>{this.apiKey=e};setURL=e=>{this.url=e};setPrevMessages=e=>{this.prevMessages=MI(e)};setTools=e=>{this.tools=Ote(e)};async createChatName(e){try{if(!this.client)return"";const n={role:"system",content:$m};return(await this.client.chat({messages:[n,{role:"user",content:e}],model:this.modelKey,stream:!1})).message.content??e.substring(0,25)}catch{return""}}async*sendMessage(e,n,r){try{if(!this.client)return;const i=MI(e),s=Pte(this.tools),o={role:"system",content:this.systemPrompt+s},a=await this.client.chat({model:this.modelKey,messages:[o,...this.prevMessages,...i],stream:!0});this.prevMessages.push(...i);const c=n&&r?Jr(r):{role:"assistant",content:[]};let h="";for await(const f of a){h+=f.message.content;const{toolContent:d,content:m}=Dte(h);if(Array.isArray(c.content)&&(c.content.length===0?c.content.push({type:"text",text:m}):d?c.content[c.content.length-1].type!=="tool-call"?(c.content[c.content.length-1]={type:"text",text:m},c.content.push(d)):c.content[c.content.length-1]=d:c.content[c.content.length-1].type==="tool-call"?c.content.push({type:"text",text:m}):c.content[c.content.length-1]={type:"text",text:m}),f.done&&(this.prevMessages.push({role:"assistant",content:h}),yield{isEnd:!0,responseMessage:c}),this.messageStopped){this.messageStopped=!1,this.prevMessages.push({role:"assistant",content:h}),yield{isEnd:!0,responseMessage:c},this.client.abort();continue}yield c}}catch(i){yield{isEnd:!0,responseMessage:{role:"assistant",content:"",status:{type:"incomplete",reason:"error",error:i}}}}}async*sendMessageAfterToolCall(e){if(typeof e.content=="string")return e;const n=e.content.filter(i=>i.type==="tool-call").reverse()[0];if(!n)return e;const r=JSON.stringify({name:n.toolName,result:n.result});return this.prevMessages.push({role:"user",content:r}),yield*this.sendMessage([],!0,e),e}stopMessage=()=>{this.client&&(this.messageStopped=!0)};getName=()=>"Ollama";getBaseUrl=()=>"http://localhost:11434";checkProvider=async e=>{const n=new hb({host:e.url});try{return await n.list(),!0}catch(r){return console.log(r),{field:"url",message:"Invalid URL"}}};getProviderModels=async e=>(await new hb({host:e.url}).list()).models.map(i=>({id:i.model,name:i.name,provider:"ollama"}))}const OI=new Ite;function Ge(t,e,n,r,i){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}function ne(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)}let JB=function(){const{crypto:t}=globalThis;if(t?.randomUUID)return JB=t.randomUUID.bind(t),t.randomUUID();const e=new Uint8Array(1),n=t?()=>t.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^n()&15>>+r/4).toString(16))};function iC(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}const sC=t=>{if(t instanceof Error)return t;if(typeof t=="object"&&t!==null){try{if(Object.prototype.toString.call(t)==="[object Error]"){const e=new Error(t.message,t.cause?{cause:t.cause}:{});return t.stack&&(e.stack=t.stack),t.cause&&!e.cause&&(e.cause=t.cause),t.name&&(e.name=t.name),e}}catch{}try{return new Error(JSON.stringify(t))}catch{}}return new Error(t)};class Ie extends Error{}let Qr=class oC extends Ie{constructor(e,n,r,i){super(`${oC.makeMessage(e,n,r)}`),this.status=e,this.headers=i,this.requestID=i?.get("x-request-id"),this.error=n;const s=n;this.code=s?.code,this.param=s?.param,this.type=s?.type}static makeMessage(e,n,r){const i=n?.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):r;return e&&i?`${e} ${i}`:e?`${e} status code (no body)`:i||"(no status code or body)"}static generate(e,n,r,i){if(!e||!i)return new Nw({message:r,cause:sC(n)});const s=n?.error;return e===400?new QB(e,s,r,i):e===401?new ZB(e,s,r,i):e===403?new e8(e,s,r,i):e===404?new t8(e,s,r,i):e===409?new n8(e,s,r,i):e===422?new r8(e,s,r,i):e===429?new i8(e,s,r,i):e>=500?new s8(e,s,r,i):new oC(e,s,r,i)}},Gi=class extends Qr{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},Nw=class extends Qr{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}},sk=class extends Nw{constructor({message:e}={}){super({message:e??"Request timed out."})}},QB=class extends Qr{},ZB=class extends Qr{},e8=class extends Qr{},t8=class extends Qr{},n8=class extends Qr{},r8=class extends Qr{},i8=class extends Qr{},s8=class extends Qr{};class o8 extends Ie{constructor(){super("Could not parse response content as the length limit was reached")}}class a8 extends Ie{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class Gd extends Error{constructor(e){super(e)}}const Lte=/^[a-z][a-z0-9+.-]*:/i,Nte=t=>Lte.test(t);let Hr=t=>(Hr=Array.isArray,Hr(t)),PI=Hr;function l8(t){return typeof t!="object"?{}:t??{}}function $te(t){if(!t)return!0;for(const e in t)return!1;return!0}function jte(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function o_(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}const Bte=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new Ie(`${t} must be an integer`);if(e<0)throw new Ie(`${t} must be a positive integer`);return e},Fte=t=>{try{return JSON.parse(t)}catch{return}},jm=t=>new Promise(e=>setTimeout(e,t)),qu="5.22.0",zte=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Vte(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}const Ute=()=>{const t=Vte();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":qu,"X-Stainless-OS":II(Deno.build.os),"X-Stainless-Arch":DI(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":qu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(t==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":qu,"X-Stainless-OS":II(globalThis.process.platform??"unknown"),"X-Stainless-Arch":DI(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const e=Hte();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":qu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":qu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Hte(){if(typeof navigator>"u"||!navigator)return null;const t=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:e,pattern:n}of t){const r=n.exec(navigator.userAgent);if(r){const i=r[1]||0,s=r[2]||0,o=r[3]||0;return{browser:e,version:`${i}.${s}.${o}`}}}return null}const DI=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",II=t=>(t=t.toLowerCase(),t.includes("ios")?"iOS":t==="android"?"Android":t==="darwin"?"MacOS":t==="win32"?"Windows":t==="freebsd"?"FreeBSD":t==="openbsd"?"OpenBSD":t==="linux"?"Linux":t?`Other:${t}`:"Unknown");let LI;const Wte=()=>LI??(LI=Ute());function qte(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function c8(...t){const e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...t)}function u8(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return c8({start(){},async pull(n){const{done:r,value:i}=await e.next();r?n.close():n.enqueue(i)},async cancel(){await e.return?.()}})}function h8(t){if(t[Symbol.asyncIterator])return t;const e=t.getReader();return{async next(){try{const n=await e.read();return n?.done&&e.releaseLock(),n}catch(n){throw e.releaseLock(),n}},async return(){const n=e.cancel();return e.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Gte(t){if(t===null||typeof t!="object")return;if(t[Symbol.asyncIterator]){await t[Symbol.asyncIterator]().return?.();return}const e=t.getReader(),n=e.cancel();e.releaseLock(),await n}const Kte=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)}),f8="RFC3986",d8=t=>String(t),NI={RFC1738:t=>String(t).replace(/%20/g,"+"),RFC3986:d8},Yte="RFC1738";let aC=(t,e)=>(aC=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),aC(t,e));const Vs=(()=>{const t=[];for(let e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t})(),a_=1024,Xte=(t,e,n,r,i)=>{if(t.length===0)return t;let s=t;if(typeof t=="symbol"?s=Symbol.prototype.toString.call(t):typeof t!="string"&&(s=String(t)),n==="iso-8859-1")return escape(s).replace(/%u[0-9a-f]{4}/gi,function(a){return"%26%23"+parseInt(a.slice(2),16)+"%3B"});let o="";for(let a=0;a<s.length;a+=a_){const c=s.length>=a_?s.slice(a,a+a_):s,h=[];for(let f=0;f<c.length;++f){let d=c.charCodeAt(f);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||i===Yte&&(d===40||d===41)){h[h.length]=c.charAt(f);continue}if(d<128){h[h.length]=Vs[d];continue}if(d<2048){h[h.length]=Vs[192|d>>6]+Vs[128|d&63];continue}if(d<55296||d>=57344){h[h.length]=Vs[224|d>>12]+Vs[128|d>>6&63]+Vs[128|d&63];continue}f+=1,d=65536+((d&1023)<<10|c.charCodeAt(f)&1023),h[h.length]=Vs[240|d>>18]+Vs[128|d>>12&63]+Vs[128|d>>6&63]+Vs[128|d&63]}o+=h.join("")}return o};function Jte(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}function $I(t,e){if(Hr(t)){const n=[];for(let r=0;r<t.length;r+=1)n.push(e(t[r]));return n}return e(t)}const p8={brackets(t){return String(t)+"[]"},comma:"comma",indices(t,e){return String(t)+"["+e+"]"},repeat(t){return String(t)}},m8=function(t,e){Array.prototype.push.apply(t,Hr(e)?e:[e])};let jI;const Cn={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Xte,encodeValuesOnly:!1,format:f8,formatter:d8,indices:!1,serializeDate(t){return(jI??(jI=Function.prototype.call.bind(Date.prototype.toISOString)))(t)},skipNulls:!1,strictNullHandling:!1};function Qte(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"}const l_={};function g8(t,e,n,r,i,s,o,a,c,h,f,d,m,y,b,w,S,_){let A=t,E=_,P=0,O=!1;for(;(E=E.get(l_))!==void 0&&!O;){const N=E.get(t);if(P+=1,typeof N<"u"){if(N===P)throw new RangeError("Cyclic object value");O=!0}typeof E.get(l_)>"u"&&(P=0)}if(typeof h=="function"?A=h(e,A):A instanceof Date?A=m?.(A):n==="comma"&&Hr(A)&&(A=$I(A,function(N){return N instanceof Date?m?.(N):N})),A===null){if(s)return c&&!w?c(e,Cn.encoder,S,"key",y):e;A=""}if(Qte(A)||Jte(A)){if(c){const N=w?e:c(e,Cn.encoder,S,"key",y);return[b?.(N)+"="+b?.(c(A,Cn.encoder,S,"value",y))]}return[b?.(e)+"="+b?.(String(A))]}const M=[];if(typeof A>"u")return M;let D;if(n==="comma"&&Hr(A))w&&c&&(A=$I(A,c)),D=[{value:A.length>0?A.join(",")||null:void 0}];else if(Hr(h))D=h;else{const N=Object.keys(A);D=f?N.sort(f):N}const $=a?String(e).replace(/\./g,"%2E"):String(e),F=r&&Hr(A)&&A.length===1?$+"[]":$;if(i&&Hr(A)&&A.length===0)return F+"[]";for(let N=0;N<D.length;++N){const U=D[N],q=typeof U=="object"&&typeof U.value<"u"?U.value:A[U];if(o&&q===null)continue;const K=d&&a?U.replace(/\./g,"%2E"):U,X=Hr(A)?typeof n=="function"?n(F,K):F:F+(d?"."+K:"["+K+"]");_.set(t,P);const ee=new WeakMap;ee.set(l_,_),m8(M,g8(q,X,n,r,i,s,o,a,n==="comma"&&w&&Hr(A)?null:c,h,f,d,m,y,b,w,S,ee))}return M}function Zte(t=Cn){if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.encodeDotInKeys<"u"&&typeof t.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");const e=t.charset||Cn.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=f8;if(typeof t.format<"u"){if(!aC(NI,t.format))throw new TypeError("Unknown format option provided.");n=t.format}const r=NI[n];let i=Cn.filter;(typeof t.filter=="function"||Hr(t.filter))&&(i=t.filter);let s;if(t.arrayFormat&&t.arrayFormat in p8?s=t.arrayFormat:"indices"in t?s=t.indices?"indices":"repeat":s=Cn.arrayFormat,"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const o=typeof t.allowDots>"u"?t.encodeDotInKeys?!0:Cn.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Cn.addQueryPrefix,allowDots:o,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Cn.allowEmptyArrays,arrayFormat:s,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Cn.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?Cn.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Cn.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:Cn.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:Cn.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Cn.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:Cn.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Cn.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Cn.strictNullHandling}}function ene(t,e={}){let n=t;const r=Zte(e);let i,s;typeof r.filter=="function"?(s=r.filter,n=s("",n)):Hr(r.filter)&&(s=r.filter,i=s);const o=[];if(typeof n!="object"||n===null)return"";const a=p8[r.arrayFormat],c=a==="comma"&&r.commaRoundTrip;i||(i=Object.keys(n)),r.sort&&i.sort(r.sort);const h=new WeakMap;for(let m=0;m<i.length;++m){const y=i[m];r.skipNulls&&n[y]===null||m8(o,g8(n[y],y,a,c,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,h))}const f=o.join(r.delimiter);let d=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),f.length>0?d+f:""}function tne(t){let e=0;for(const i of t)e+=i.length;const n=new Uint8Array(e);let r=0;for(const i of t)n.set(i,r),r+=i.length;return n}let BI;function ok(t){let e;return(BI??(e=new globalThis.TextEncoder,BI=e.encode.bind(e)))(t)}let FI;function zI(t){let e;return(FI??(e=new globalThis.TextDecoder,FI=e.decode.bind(e)))(t)}var yi,bi;let $w=class{constructor(){yi.set(this,void 0),bi.set(this,void 0),Ge(this,yi,new Uint8Array),Ge(this,bi,null)}decode(e){if(e==null)return[];const n=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?ok(e):e;Ge(this,yi,tne([ne(this,yi,"f"),n]));const r=[];let i;for(;(i=nne(ne(this,yi,"f"),ne(this,bi,"f")))!=null;){if(i.carriage&&ne(this,bi,"f")==null){Ge(this,bi,i.index);continue}if(ne(this,bi,"f")!=null&&(i.index!==ne(this,bi,"f")+1||i.carriage)){r.push(zI(ne(this,yi,"f").subarray(0,ne(this,bi,"f")-1))),Ge(this,yi,ne(this,yi,"f").subarray(ne(this,bi,"f"))),Ge(this,bi,null);continue}const s=ne(this,bi,"f")!==null?i.preceding-1:i.preceding,o=zI(ne(this,yi,"f").subarray(0,s));r.push(o),Ge(this,yi,ne(this,yi,"f").subarray(i.index)),Ge(this,bi,null)}return r}flush(){return ne(this,yi,"f").length?this.decode(`
`):[]}};yi=new WeakMap,bi=new WeakMap;$w.NEWLINE_CHARS=new Set([`
`,"\r"]);$w.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function nne(t,e){for(let i=e??0;i<t.length;i++){if(t[i]===10)return{preceding:i,index:i+1,carriage:!1};if(t[i]===13)return{preceding:i,index:i+1,carriage:!0}}return null}function rne(t){for(let r=0;r<t.length-1;r++){if(t[r]===10&&t[r+1]===10||t[r]===13&&t[r+1]===13)return r+2;if(t[r]===13&&t[r+1]===10&&r+3<t.length&&t[r+2]===13&&t[r+3]===10)return r+4}return-1}const ov={off:0,error:200,warn:300,info:400,debug:500},VI=(t,e,n)=>{if(t){if(jte(ov,t))return t;Un(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(ov))}`)}};function Kd(){}function ty(t,e,n){return!e||ov[t]>ov[n]?Kd:e[t].bind(e)}const ine={error:Kd,warn:Kd,info:Kd,debug:Kd};let UI=new WeakMap;function Un(t){const e=t.logger,n=t.logLevel??"off";if(!e)return ine;const r=UI.get(e);if(r&&r[0]===n)return r[1];const i={error:ty("error",e,n),warn:ty("warn",e,n),info:ty("info",e,n),debug:ty("debug",e,n)};return UI.set(e,[n,i]),i}const ec=t=>(t.options&&(t.options={...t.options},delete t.options.headers),t.headers&&(t.headers=Object.fromEntries((t.headers instanceof Headers?[...t.headers]:Object.entries(t.headers)).map(([e,n])=>[e,e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in t&&(t.retryOfRequestLogID&&(t.retryOf=t.retryOfRequestLogID),delete t.retryOfRequestLogID),t);var kd;let Xp=class Yd{constructor(e,n,r){this.iterator=e,kd.set(this,void 0),this.controller=n,Ge(this,kd,r)}static fromSSEResponse(e,n,r){let i=!1;const s=r?Un(r):console;async function*o(){if(i)throw new Ie("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let a=!1;try{for await(const c of sne(e,n))if(!a){if(c.data.startsWith("[DONE]")){a=!0;continue}if(c.event===null||!c.event.startsWith("thread.")){let h;try{h=JSON.parse(c.data)}catch(f){throw s.error("Could not parse message into JSON:",c.data),s.error("From chunk:",c.raw),f}if(h&&h.error)throw new Qr(void 0,h.error,void 0,e.headers);yield h}else{let h;try{h=JSON.parse(c.data)}catch(f){throw console.error("Could not parse message into JSON:",c.data),console.error("From chunk:",c.raw),f}if(c.event=="error")throw new Qr(void 0,h.error,h.message,void 0);yield{event:c.event,data:h}}}a=!0}catch(c){if(iC(c))return;throw c}finally{a||n.abort()}}return new Yd(o,n,r)}static fromReadableStream(e,n,r){let i=!1;async function*s(){const a=new $w,c=h8(e);for await(const h of c)for(const f of a.decode(h))yield f;for(const h of a.flush())yield h}async function*o(){if(i)throw new Ie("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let a=!1;try{for await(const c of s())a||c&&(yield JSON.parse(c));a=!0}catch(c){if(iC(c))return;throw c}finally{a||n.abort()}}return new Yd(o,n,r)}[(kd=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){const e=[],n=[],r=this.iterator(),i=s=>({next:()=>{if(s.length===0){const o=r.next();e.push(o),n.push(o)}return s.shift()}});return[new Yd(()=>i(e),this.controller,ne(this,kd,"f")),new Yd(()=>i(n),this.controller,ne(this,kd,"f"))]}toReadableStream(){const e=this;let n;return c8({async start(){n=e[Symbol.asyncIterator]()},async pull(r){try{const{value:i,done:s}=await n.next();if(s)return r.close();const o=ok(JSON.stringify(i)+`
`);r.enqueue(o)}catch(i){r.error(i)}},async cancel(){await n.return?.()}})}};async function*sne(t,e){if(!t.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new Ie("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new Ie("Attempted to iterate over a response with no body");const n=new ane,r=new $w,i=h8(t.body);for await(const s of one(i))for(const o of r.decode(s)){const a=n.decode(o);a&&(yield a)}for(const s of r.flush()){const o=n.decode(s);o&&(yield o)}}async function*one(t){let e=new Uint8Array;for await(const n of t){if(n==null)continue;const r=n instanceof ArrayBuffer?new Uint8Array(n):typeof n=="string"?ok(n):n;let i=new Uint8Array(e.length+r.length);i.set(e),i.set(r,e.length),e=i;let s;for(;(s=rne(e))!==-1;)yield e.slice(0,s),e=e.slice(s)}e.length>0&&(yield e)}let ane=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const s={event:this.event,data:this.data.join(`
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],s}if(this.chunks.push(e),e.startsWith(":"))return null;let[n,r,i]=lne(e,":");return i.startsWith(" ")&&(i=i.substring(1)),n==="event"?this.event=i:n==="data"&&this.data.push(i),null}};function lne(t,e){const n=t.indexOf(e);return n!==-1?[t.substring(0,n),e,t.substring(n+e.length)]:[t,"",""]}async function y8(t,e){const{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:s}=e,o=await(async()=>{if(e.options.stream)return Un(t).debug("response",n.status,n.url,n.headers,n.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(n,e.controller,t):Xp.fromSSEResponse(n,e.controller,t);if(n.status===204)return null;if(e.options.__binaryResponse)return n;const c=n.headers.get("content-type")?.split(";")[0]?.trim();if(c?.includes("application/json")||c?.endsWith("+json")){const d=await n.json();return b8(d,n)}return await n.text()})();return Un(t).debug(`[${r}] response parsed`,ec({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-s})),o}function b8(t,e){return!t||typeof t!="object"||Array.isArray(t)?t:Object.defineProperty(t,"_request_id",{value:e.headers.get("x-request-id"),enumerable:!1})}var Xd;let v8=class w8 extends Promise{constructor(e,n,r=y8){super(i=>{i(null)}),this.responsePromise=n,this.parseResponse=r,Xd.set(this,void 0),Ge(this,Xd,e)}_thenUnwrap(e){return new w8(ne(this,Xd,"f"),this.responsePromise,async(n,r)=>b8(e(await this.parseResponse(n,r),r),r.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){const[e,n]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:n,request_id:n.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(ne(this,Xd,"f"),e))),this.parsedPromise}then(e,n){return this.parse().then(e,n)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};Xd=new WeakMap;var ny;class ak{constructor(e,n,r,i){ny.set(this,void 0),Ge(this,ny,e),this.options=i,this.response=n,this.body=r}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){const e=this.nextPageRequestOptions();if(!e)throw new Ie("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await ne(this,ny,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(ny=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const n of e.getPaginatedItems())yield n}}class cne extends v8{constructor(e,n,r){super(e,n,async(i,s)=>new r(i,s.response,await y8(i,s),s.options))}async*[Symbol.asyncIterator](){const e=await this;for await(const n of e)yield n}}class jw extends ak{constructor(e,n,r,i){super(e,n,r,i),this.data=r.data||[],this.object=r.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}}class gn extends ak{constructor(e,n,r,i){super(e,n,r,i),this.data=r.data||[],this.has_more=r.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){const e=this.getPaginatedItems(),n=e[e.length-1]?.id;return n?{...this.options,query:{...l8(this.options.query),after:n}}:null}}class une extends ak{constructor(e,n,r,i){super(e,n,r,i),this.data=r.data||[],this.has_more=r.has_more||!1,this.last_id=r.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){const e=this.last_id;return e?{...this.options,query:{...l8(this.options.query),after:e}}:null}}const x8=()=>{if(typeof File>"u"){const{process:t}=globalThis,e=typeof t?.versions?.node=="string"&&parseInt(t.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(e?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function wp(t,e,n){return x8(),new File(t,e??"unknown_file",n)}function fb(t){return(typeof t=="object"&&t!==null&&("name"in t&&t.name&&String(t.name)||"url"in t&&t.url&&String(t.url)||"filename"in t&&t.filename&&String(t.filename)||"path"in t&&t.path&&String(t.path))||"").split(/[\\/]/).pop()||void 0}const S8=t=>t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function",_c=async(t,e)=>({...t,body:await fne(t.body,e)}),HI=new WeakMap;function hne(t){const e=typeof t=="function"?t:t.fetch,n=HI.get(e);if(n)return n;const r=(async()=>{try{const i="Response"in e?e.Response:(await e("data:,")).constructor,s=new FormData;return s.toString()!==await new i(s).text()}catch{return!0}})();return HI.set(e,r),r}const fne=async(t,e)=>{if(!await hne(e))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");const n=new FormData;return await Promise.all(Object.entries(t||{}).map(([r,i])=>lC(n,r,i))),n},dne=t=>t instanceof Blob&&"name"in t,lC=async(t,e,n)=>{if(n!==void 0){if(n==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")t.append(e,String(n));else if(n instanceof Response)t.append(e,wp([await n.blob()],fb(n)));else if(S8(n))t.append(e,wp([await new Response(u8(n)).blob()],fb(n)));else if(dne(n))t.append(e,n,fb(n));else if(Array.isArray(n))await Promise.all(n.map(r=>lC(t,e+"[]",r)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([r,i])=>lC(t,`${e}[${r}]`,i)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}},_8=t=>t!=null&&typeof t=="object"&&typeof t.size=="number"&&typeof t.type=="string"&&typeof t.text=="function"&&typeof t.slice=="function"&&typeof t.arrayBuffer=="function",pne=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&_8(t),mne=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function gne(t,e,n){if(x8(),t=await t,pne(t))return t instanceof File?t:wp([await t.arrayBuffer()],t.name);if(mne(t)){const i=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),wp(await cC(i),e,n)}const r=await cC(t);if(e||(e=fb(t)),!n?.type){const i=r.find(s=>typeof s=="object"&&"type"in s&&s.type);typeof i=="string"&&(n={...n,type:i})}return wp(r,e,n)}async function cC(t){let e=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)e.push(t);else if(_8(t))e.push(t instanceof Blob?t:await t.arrayBuffer());else if(S8(t))for await(const n of t)e.push(...await cC(n));else{const n=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${n?`; constructor: ${n}`:""}${yne(t)}`)}return e}function yne(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(n=>`"${n}"`).join(", ")}]`}let ze=class{constructor(e){this._client=e}};function C8(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const WI=Object.freeze(Object.create(null)),bne=(t=C8)=>function(n,...r){if(n.length===1)return n[0];let i=!1;const s=[],o=n.reduce((f,d,m)=>{/[?#]/.test(d)&&(i=!0);const y=r[m];let b=(i?encodeURIComponent:t)(""+y);return m!==r.length&&(y==null||typeof y=="object"&&y.toString===Object.getPrototypeOf(Object.getPrototypeOf(y.hasOwnProperty??WI)??WI)?.toString)&&(b=y+"",s.push({start:f.length+d.length,length:b.length,error:`Value of type ${Object.prototype.toString.call(y).slice(8,-1)} is not a valid path parameter`})),f+d+(m===r.length?"":b)},""),a=o.split(/[?#]/,1)[0],c=new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)","gi");let h;for(;(h=c.exec(a))!==null;)s.push({start:h.index,length:h[0].length,error:`Value "${h[0]}" can't be safely passed as a path parameter`});if(s.sort((f,d)=>f.start-d.start),s.length>0){let f=0;const d=s.reduce((m,y)=>{const b=" ".repeat(y.start-f),w="^".repeat(y.length);return f=y.start+y.length,m+b+w},"");throw new Ie(`Path parameters result in path with invalid segments:
${s.map(m=>m.error).join(`
`)}
${o}
${d}`)}return o},ve=bne(C8);let A8=class extends ze{list(e,n={},r){return this._client.getAPIList(ve`/chat/completions/${e}/messages`,gn,{query:n,...r})}};function av(t){return t!==void 0&&"function"in t&&t.function!==void 0}function lk(t){return t?.$brand==="auto-parseable-response-format"}function Bm(t){return t?.$brand==="auto-parseable-tool"}function vne(t,e){return!e||!E8(e)?{...t,choices:t.choices.map(n=>(k8(n.message.tool_calls),{...n,message:{...n.message,parsed:null,...n.message.tool_calls?{tool_calls:n.message.tool_calls}:void 0}}))}:ck(t,e)}function ck(t,e){const n=t.choices.map(r=>{if(r.finish_reason==="length")throw new o8;if(r.finish_reason==="content_filter")throw new a8;return k8(r.message.tool_calls),{...r,message:{...r.message,...r.message.tool_calls?{tool_calls:r.message.tool_calls?.map(i=>xne(e,i))??void 0}:void 0,parsed:r.message.content&&!r.message.refusal?wne(e,r.message.content):null}}});return{...t,choices:n}}function wne(t,e){return t.response_format?.type!=="json_schema"?null:t.response_format?.type==="json_schema"?"$parseRaw"in t.response_format?t.response_format.$parseRaw(e):JSON.parse(e):null}function xne(t,e){const n=t.tools?.find(r=>av(r)&&r.function?.name===e.function.name);return{...e,function:{...e.function,parsed_arguments:Bm(n)?n.$parseRaw(e.function.arguments):n?.function.strict?JSON.parse(e.function.arguments):null}}}function Sne(t,e){if(!t||!("tools"in t)||!t.tools)return!1;const n=t.tools?.find(r=>av(r)&&r.function?.name===e.function.name);return av(n)&&(Bm(n)||n?.function.strict||!1)}function E8(t){return lk(t.response_format)?!0:t.tools?.some(e=>Bm(e)||e.type==="function"&&e.function.strict===!0)??!1}function k8(t){for(const e of t||[])if(e.type!=="function")throw new Ie(`Currently only \`function\` tool calls are supported; Received \`${e.type}\``)}function _ne(t){for(const e of t??[]){if(e.type!=="function")throw new Ie(`Currently only \`function\` tool types support auto-parsing; Received \`${e.type}\``);if(e.function.strict!==!0)throw new Ie(`The \`${e.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}const lv=t=>t?.role==="assistant",T8=t=>t?.role==="tool";var uC,db,pb,Jd,Qd,mb,Zd,Vo,ep,cv,uv,Gu,R8;class uk{constructor(){uC.add(this),this.controller=new AbortController,db.set(this,void 0),pb.set(this,()=>{}),Jd.set(this,()=>{}),Qd.set(this,void 0),mb.set(this,()=>{}),Zd.set(this,()=>{}),Vo.set(this,{}),ep.set(this,!1),cv.set(this,!1),uv.set(this,!1),Gu.set(this,!1),Ge(this,db,new Promise((e,n)=>{Ge(this,pb,e,"f"),Ge(this,Jd,n,"f")})),Ge(this,Qd,new Promise((e,n)=>{Ge(this,mb,e,"f"),Ge(this,Zd,n,"f")})),ne(this,db,"f").catch(()=>{}),ne(this,Qd,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},ne(this,uC,"m",R8).bind(this))},0)}_connected(){this.ended||(ne(this,pb,"f").call(this),this._emit("connect"))}get ended(){return ne(this,ep,"f")}get errored(){return ne(this,cv,"f")}get aborted(){return ne(this,uv,"f")}abort(){this.controller.abort()}on(e,n){return(ne(this,Vo,"f")[e]||(ne(this,Vo,"f")[e]=[])).push({listener:n}),this}off(e,n){const r=ne(this,Vo,"f")[e];if(!r)return this;const i=r.findIndex(s=>s.listener===n);return i>=0&&r.splice(i,1),this}once(e,n){return(ne(this,Vo,"f")[e]||(ne(this,Vo,"f")[e]=[])).push({listener:n,once:!0}),this}emitted(e){return new Promise((n,r)=>{Ge(this,Gu,!0),e!=="error"&&this.once("error",r),this.once(e,n)})}async done(){Ge(this,Gu,!0),await ne(this,Qd,"f")}_emit(e,...n){if(ne(this,ep,"f"))return;e==="end"&&(Ge(this,ep,!0),ne(this,mb,"f").call(this));const r=ne(this,Vo,"f")[e];if(r&&(ne(this,Vo,"f")[e]=r.filter(i=>!i.once),r.forEach(({listener:i})=>i(...n))),e==="abort"){const i=n[0];!ne(this,Gu,"f")&&!r?.length&&Promise.reject(i),ne(this,Jd,"f").call(this,i),ne(this,Zd,"f").call(this,i),this._emit("end");return}if(e==="error"){const i=n[0];!ne(this,Gu,"f")&&!r?.length&&Promise.reject(i),ne(this,Jd,"f").call(this,i),ne(this,Zd,"f").call(this,i),this._emit("end")}}_emitFinal(){}}db=new WeakMap,pb=new WeakMap,Jd=new WeakMap,Qd=new WeakMap,mb=new WeakMap,Zd=new WeakMap,Vo=new WeakMap,ep=new WeakMap,cv=new WeakMap,uv=new WeakMap,Gu=new WeakMap,uC=new WeakSet,R8=function(e){if(Ge(this,cv,!0),e instanceof Error&&e.name==="AbortError"&&(e=new Gi),e instanceof Gi)return Ge(this,uv,!0),this._emit("abort",e);if(e instanceof Ie)return this._emit("error",e);if(e instanceof Error){const n=new Ie(e.message);return n.cause=e,this._emit("error",n)}return this._emit("error",new Ie(String(e)))};function Cne(t){return typeof t.parse=="function"}var Er,hC,hv,fC,dC,pC,M8,O8;const Ane=10;let P8=class extends uk{constructor(){super(...arguments),Er.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){this._chatCompletions.push(e),this._emit("chatCompletion",e);const n=e.choices[0]?.message;return n&&this._addMessage(n),e}_addMessage(e,n=!0){if("content"in e||(e.content=null),this.messages.push(e),n){if(this._emit("message",e),T8(e)&&e.content)this._emit("functionToolCallResult",e.content);else if(lv(e)&&e.tool_calls)for(const r of e.tool_calls)r.type==="function"&&this._emit("functionToolCall",r.function)}}async finalChatCompletion(){await this.done();const e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new Ie("stream ended without producing a ChatCompletion");return e}async finalContent(){return await this.done(),ne(this,Er,"m",hC).call(this)}async finalMessage(){return await this.done(),ne(this,Er,"m",hv).call(this)}async finalFunctionToolCall(){return await this.done(),ne(this,Er,"m",fC).call(this)}async finalFunctionToolCallResult(){return await this.done(),ne(this,Er,"m",dC).call(this)}async totalUsage(){return await this.done(),ne(this,Er,"m",pC).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){const e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit("finalChatCompletion",e);const n=ne(this,Er,"m",hv).call(this);n&&this._emit("finalMessage",n);const r=ne(this,Er,"m",hC).call(this);r&&this._emit("finalContent",r);const i=ne(this,Er,"m",fC).call(this);i&&this._emit("finalFunctionToolCall",i);const s=ne(this,Er,"m",dC).call(this);s!=null&&this._emit("finalFunctionToolCallResult",s),this._chatCompletions.some(o=>o.usage)&&this._emit("totalUsage",ne(this,Er,"m",pC).call(this))}async _createChatCompletion(e,n,r){const i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),ne(this,Er,"m",M8).call(this,n);const s=await e.chat.completions.create({...n,stream:!1},{...r,signal:this.controller.signal});return this._connected(),this._addChatCompletion(ck(s,n))}async _runChatCompletion(e,n,r){for(const i of n.messages)this._addMessage(i,!1);return await this._createChatCompletion(e,n,r)}async _runTools(e,n,r){const i="tool",{tool_choice:s="auto",stream:o,...a}=n,c=typeof s!="string"&&s.type==="function"&&s?.function?.name,{maxChatCompletions:h=Ane}=r||{},f=n.tools.map(y=>{if(Bm(y)){if(!y.$callback)throw new Ie("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:y.$callback,name:y.function.name,description:y.function.description||"",parameters:y.function.parameters,parse:y.$parseRaw,strict:!0}}}return y}),d={};for(const y of f)y.type==="function"&&(d[y.function.name||y.function.function.name]=y.function);const m="tools"in n?f.map(y=>y.type==="function"?{type:"function",function:{name:y.function.name||y.function.function.name,parameters:y.function.parameters,description:y.function.description,strict:y.function.strict}}:y):void 0;for(const y of n.messages)this._addMessage(y,!1);for(let y=0;y<h;++y){const w=(await this._createChatCompletion(e,{...a,tool_choice:s,tools:m,messages:[...this.messages]},r)).choices[0]?.message;if(!w)throw new Ie("missing message in ChatCompletion response");if(!w.tool_calls?.length)return;for(const S of w.tool_calls){if(S.type!=="function")continue;const _=S.id,{name:A,arguments:E}=S.function,P=d[A];if(P){if(c&&c!==A){const $=`Invalid tool_call: ${JSON.stringify(A)}. ${JSON.stringify(c)} requested. Please try again`;this._addMessage({role:i,tool_call_id:_,content:$});continue}}else{const $=`Invalid tool_call: ${JSON.stringify(A)}. Available options are: ${Object.keys(d).map(F=>JSON.stringify(F)).join(", ")}. Please try again`;this._addMessage({role:i,tool_call_id:_,content:$});continue}let O;try{O=Cne(P)?await P.parse(E):E}catch($){const F=$ instanceof Error?$.message:String($);this._addMessage({role:i,tool_call_id:_,content:F});continue}const M=await P.function(O,this),D=ne(this,Er,"m",O8).call(this,M);if(this._addMessage({role:i,tool_call_id:_,content:D}),c)return}}}};Er=new WeakSet,hC=function(){return ne(this,Er,"m",hv).call(this).content??null},hv=function(){let e=this.messages.length;for(;e-- >0;){const n=this.messages[e];if(lv(n))return{...n,content:n.content??null,refusal:n.refusal??null}}throw new Ie("stream ended without producing a ChatCompletionMessage with role=assistant")},fC=function(){for(let e=this.messages.length-1;e>=0;e--){const n=this.messages[e];if(lv(n)&&n?.tool_calls?.length)return n.tool_calls.filter(r=>r.type==="function").at(-1)?.function}},dC=function(){for(let e=this.messages.length-1;e>=0;e--){const n=this.messages[e];if(T8(n)&&n.content!=null&&typeof n.content=="string"&&this.messages.some(r=>r.role==="assistant"&&r.tool_calls?.some(i=>i.type==="function"&&i.id===n.tool_call_id)))return n.content}},pC=function(){const e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(const{usage:n}of this._chatCompletions)n&&(e.completion_tokens+=n.completion_tokens,e.prompt_tokens+=n.prompt_tokens,e.total_tokens+=n.total_tokens);return e},M8=function(e){if(e.n!=null&&e.n>1)throw new Ie("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},O8=function(e){return typeof e=="string"?e:e===void 0?"undefined":JSON.stringify(e)};class hk extends P8{static runTools(e,n,r){const i=new hk,s={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"runTools"}};return i._run(()=>i._runTools(e,n,s)),i}_addMessage(e,n=!0){super._addMessage(e,n),lv(e)&&e.content&&this._emit("content",e.content)}}const D8=1,I8=2,L8=4,N8=8,$8=16,j8=32,B8=64,F8=128,z8=256,V8=F8|z8,U8=$8|j8|V8|B8,H8=D8|I8|U8,W8=L8|N8,Ene=H8|W8,Ln={STR:D8,NUM:I8,ARR:L8,OBJ:N8,NULL:$8,BOOL:j8,NAN:B8,INFINITY:F8,MINUS_INFINITY:z8,INF:V8,SPECIAL:U8,ATOM:H8,COLLECTION:W8,ALL:Ene};class kne extends Error{}class Tne extends Error{}function Rne(t,e=Ln.ALL){if(typeof t!="string")throw new TypeError(`expecting str, got ${typeof t}`);if(!t.trim())throw new Error(`${t} is empty`);return Mne(t.trim(),e)}const Mne=(t,e)=>{const n=t.length;let r=0;const i=m=>{throw new kne(`${m} at position ${r}`)},s=m=>{throw new Tne(`${m} at position ${r}`)},o=()=>(d(),r>=n&&i("Unexpected end of input"),t[r]==='"'?a():t[r]==="{"?c():t[r]==="["?h():t.substring(r,r+4)==="null"||Ln.NULL&e&&n-r<4&&"null".startsWith(t.substring(r))?(r+=4,null):t.substring(r,r+4)==="true"||Ln.BOOL&e&&n-r<4&&"true".startsWith(t.substring(r))?(r+=4,!0):t.substring(r,r+5)==="false"||Ln.BOOL&e&&n-r<5&&"false".startsWith(t.substring(r))?(r+=5,!1):t.substring(r,r+8)==="Infinity"||Ln.INFINITY&e&&n-r<8&&"Infinity".startsWith(t.substring(r))?(r+=8,1/0):t.substring(r,r+9)==="-Infinity"||Ln.MINUS_INFINITY&e&&1<n-r&&n-r<9&&"-Infinity".startsWith(t.substring(r))?(r+=9,-1/0):t.substring(r,r+3)==="NaN"||Ln.NAN&e&&n-r<3&&"NaN".startsWith(t.substring(r))?(r+=3,NaN):f()),a=()=>{const m=r;let y=!1;for(r++;r<n&&(t[r]!=='"'||y&&t[r-1]==="\\");)y=t[r]==="\\"?!y:!1,r++;if(t.charAt(r)=='"')try{return JSON.parse(t.substring(m,++r-Number(y)))}catch(b){s(String(b))}else if(Ln.STR&e)try{return JSON.parse(t.substring(m,r-Number(y))+'"')}catch{return JSON.parse(t.substring(m,t.lastIndexOf("\\"))+'"')}i("Unterminated string literal")},c=()=>{r++,d();const m={};try{for(;t[r]!=="}";){if(d(),r>=n&&Ln.OBJ&e)return m;const y=a();d(),r++;try{const b=o();Object.defineProperty(m,y,{value:b,writable:!0,enumerable:!0,configurable:!0})}catch(b){if(Ln.OBJ&e)return m;throw b}d(),t[r]===","&&r++}}catch{if(Ln.OBJ&e)return m;i("Expected '}' at end of object")}return r++,m},h=()=>{r++;const m=[];try{for(;t[r]!=="]";)m.push(o()),d(),t[r]===","&&r++}catch{if(Ln.ARR&e)return m;i("Expected ']' at end of array")}return r++,m},f=()=>{if(r===0){t==="-"&&Ln.NUM&e&&i("Not sure what '-' is");try{return JSON.parse(t)}catch(y){if(Ln.NUM&e)try{return t[t.length-1]==="."?JSON.parse(t.substring(0,t.lastIndexOf("."))):JSON.parse(t.substring(0,t.lastIndexOf("e")))}catch{}s(String(y))}}const m=r;for(t[r]==="-"&&r++;t[r]&&!",]}".includes(t[r]);)r++;r==n&&!(Ln.NUM&e)&&i("Unterminated number literal");try{return JSON.parse(t.substring(m,r))}catch{t.substring(m,r)==="-"&&Ln.NUM&e&&i("Not sure what '-' is");try{return JSON.parse(t.substring(m,t.lastIndexOf("e")))}catch(b){s(String(b))}}},d=()=>{for(;r<n&&`
\r `.includes(t[r]);)r++};return o()},qI=t=>Rne(t,Ln.ALL^Ln.NUM);var xn,Fo,Lu,Ua,c_,ry,u_,h_,f_,iy,d_,GI;let q8=class mC extends P8{constructor(e){super(),xn.add(this),Fo.set(this,void 0),Lu.set(this,void 0),Ua.set(this,void 0),Ge(this,Fo,e),Ge(this,Lu,[])}get currentChatCompletionSnapshot(){return ne(this,Ua,"f")}static fromReadableStream(e){const n=new mC(null);return n._run(()=>n._fromReadableStream(e)),n}static createChatCompletion(e,n,r){const i=new mC(n);return i._run(()=>i._runChatCompletion(e,{...n,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createChatCompletion(e,n,r){super._createChatCompletion;const i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),ne(this,xn,"m",c_).call(this);const s=await e.chat.completions.create({...n,stream:!0},{...r,signal:this.controller.signal});this._connected();for await(const o of s)ne(this,xn,"m",u_).call(this,o);if(s.controller.signal?.aborted)throw new Gi;return this._addChatCompletion(ne(this,xn,"m",iy).call(this))}async _fromReadableStream(e,n){const r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),ne(this,xn,"m",c_).call(this),this._connected();const i=Xp.fromReadableStream(e,this.controller);let s;for await(const o of i)s&&s!==o.id&&this._addChatCompletion(ne(this,xn,"m",iy).call(this)),ne(this,xn,"m",u_).call(this,o),s=o.id;if(i.controller.signal?.aborted)throw new Gi;return this._addChatCompletion(ne(this,xn,"m",iy).call(this))}[(Fo=new WeakMap,Lu=new WeakMap,Ua=new WeakMap,xn=new WeakSet,c_=function(){this.ended||Ge(this,Ua,void 0)},ry=function(n){let r=ne(this,Lu,"f")[n.index];return r||(r={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},ne(this,Lu,"f")[n.index]=r,r)},u_=function(n){if(this.ended)return;const r=ne(this,xn,"m",GI).call(this,n);this._emit("chunk",n,r);for(const i of n.choices){const s=r.choices[i.index];i.delta.content!=null&&s.message?.role==="assistant"&&s.message?.content&&(this._emit("content",i.delta.content,s.message.content),this._emit("content.delta",{delta:i.delta.content,snapshot:s.message.content,parsed:s.message.parsed})),i.delta.refusal!=null&&s.message?.role==="assistant"&&s.message?.refusal&&this._emit("refusal.delta",{delta:i.delta.refusal,snapshot:s.message.refusal}),i.logprobs?.content!=null&&s.message?.role==="assistant"&&this._emit("logprobs.content.delta",{content:i.logprobs?.content,snapshot:s.logprobs?.content??[]}),i.logprobs?.refusal!=null&&s.message?.role==="assistant"&&this._emit("logprobs.refusal.delta",{refusal:i.logprobs?.refusal,snapshot:s.logprobs?.refusal??[]});const o=ne(this,xn,"m",ry).call(this,s);s.finish_reason&&(ne(this,xn,"m",f_).call(this,s),o.current_tool_call_index!=null&&ne(this,xn,"m",h_).call(this,s,o.current_tool_call_index));for(const a of i.delta.tool_calls??[])o.current_tool_call_index!==a.index&&(ne(this,xn,"m",f_).call(this,s),o.current_tool_call_index!=null&&ne(this,xn,"m",h_).call(this,s,o.current_tool_call_index)),o.current_tool_call_index=a.index;for(const a of i.delta.tool_calls??[]){const c=s.message.tool_calls?.[a.index];c?.type&&(c?.type==="function"?this._emit("tool_calls.function.arguments.delta",{name:c.function?.name,index:a.index,arguments:c.function.arguments,parsed_arguments:c.function.parsed_arguments,arguments_delta:a.function?.arguments??""}):(c?.type,void 0))}}},h_=function(n,r){if(ne(this,xn,"m",ry).call(this,n).done_tool_calls.has(r))return;const s=n.message.tool_calls?.[r];if(!s)throw new Error("no tool call snapshot");if(!s.type)throw new Error("tool call snapshot missing `type`");if(s.type==="function"){const o=ne(this,Fo,"f")?.tools?.find(a=>av(a)&&a.function.name===s.function.name);this._emit("tool_calls.function.arguments.done",{name:s.function.name,index:r,arguments:s.function.arguments,parsed_arguments:Bm(o)?o.$parseRaw(s.function.arguments):o?.function.strict?JSON.parse(s.function.arguments):null})}else s.type},f_=function(n){const r=ne(this,xn,"m",ry).call(this,n);if(n.message.content&&!r.content_done){r.content_done=!0;const i=ne(this,xn,"m",d_).call(this);this._emit("content.done",{content:n.message.content,parsed:i?i.$parseRaw(n.message.content):null})}n.message.refusal&&!r.refusal_done&&(r.refusal_done=!0,this._emit("refusal.done",{refusal:n.message.refusal})),n.logprobs?.content&&!r.logprobs_content_done&&(r.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:n.logprobs.content})),n.logprobs?.refusal&&!r.logprobs_refusal_done&&(r.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:n.logprobs.refusal}))},iy=function(){if(this.ended)throw new Ie("stream has ended, this shouldn't happen");const n=ne(this,Ua,"f");if(!n)throw new Ie("request ended without sending any chunks");return Ge(this,Ua,void 0),Ge(this,Lu,[]),One(n,ne(this,Fo,"f"))},d_=function(){const n=ne(this,Fo,"f")?.response_format;return lk(n)?n:null},GI=function(n){var r,i,s,o;let a=ne(this,Ua,"f");const{choices:c,...h}=n;a?Object.assign(a,h):a=Ge(this,Ua,{...h,choices:[]});for(const{delta:f,finish_reason:d,index:m,logprobs:y=null,...b}of n.choices){let w=a.choices[m];if(w||(w=a.choices[m]={finish_reason:d,index:m,message:{},logprobs:y,...b}),y)if(!w.logprobs)w.logprobs=Object.assign({},y);else{const{content:M,refusal:D,...$}=y;Object.assign(w.logprobs,$),M&&((r=w.logprobs).content??(r.content=[]),w.logprobs.content.push(...M)),D&&((i=w.logprobs).refusal??(i.refusal=[]),w.logprobs.refusal.push(...D))}if(d&&(w.finish_reason=d,ne(this,Fo,"f")&&E8(ne(this,Fo,"f")))){if(d==="length")throw new o8;if(d==="content_filter")throw new a8}if(Object.assign(w,b),!f)continue;const{content:S,refusal:_,function_call:A,role:E,tool_calls:P,...O}=f;if(Object.assign(w.message,O),_&&(w.message.refusal=(w.message.refusal||"")+_),E&&(w.message.role=E),A&&(w.message.function_call?(A.name&&(w.message.function_call.name=A.name),A.arguments&&((s=w.message.function_call).arguments??(s.arguments=""),w.message.function_call.arguments+=A.arguments)):w.message.function_call=A),S&&(w.message.content=(w.message.content||"")+S,!w.message.refusal&&ne(this,xn,"m",d_).call(this)&&(w.message.parsed=qI(w.message.content))),P){w.message.tool_calls||(w.message.tool_calls=[]);for(const{index:M,id:D,type:$,function:F,...N}of P){const U=(o=w.message.tool_calls)[M]??(o[M]={});Object.assign(U,N),D&&(U.id=D),$&&(U.type=$),F&&(U.function??(U.function={name:F.name??"",arguments:""})),F?.name&&(U.function.name=F.name),F?.arguments&&(U.function.arguments+=F.arguments,Sne(ne(this,Fo,"f"),U)&&(U.function.parsed_arguments=qI(U.function.arguments)))}}}return a},Symbol.asyncIterator)](){const e=[],n=[];let r=!1;return this.on("chunk",i=>{const s=n.shift();s?s.resolve(i):e.push(i)}),this.on("end",()=>{r=!0;for(const i of n)i.resolve(void 0);n.length=0}),this.on("abort",i=>{r=!0;for(const s of n)s.reject(i);n.length=0}),this.on("error",i=>{r=!0;for(const s of n)s.reject(i);n.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((s,o)=>n.push({resolve:s,reject:o})).then(s=>s?{value:s,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Xp(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};function One(t,e){const{id:n,choices:r,created:i,model:s,system_fingerprint:o,...a}=t,c={...a,id:n,choices:r.map(({message:h,finish_reason:f,index:d,logprobs:m,...y})=>{if(!f)throw new Ie(`missing finish_reason for choice ${d}`);const{content:b=null,function_call:w,tool_calls:S,..._}=h,A=h.role;if(!A)throw new Ie(`missing role for choice ${d}`);if(w){const{arguments:E,name:P}=w;if(E==null)throw new Ie(`missing function_call.arguments for choice ${d}`);if(!P)throw new Ie(`missing function_call.name for choice ${d}`);return{...y,message:{content:b,function_call:{arguments:E,name:P},role:A,refusal:h.refusal??null},finish_reason:f,index:d,logprobs:m}}return S?{...y,index:d,finish_reason:f,logprobs:m,message:{..._,role:A,content:b,refusal:h.refusal??null,tool_calls:S.map((E,P)=>{const{function:O,type:M,id:D,...$}=E,{arguments:F,name:N,...U}=O||{};if(D==null)throw new Ie(`missing choices[${d}].tool_calls[${P}].id
${sy(t)}`);if(M==null)throw new Ie(`missing choices[${d}].tool_calls[${P}].type
${sy(t)}`);if(N==null)throw new Ie(`missing choices[${d}].tool_calls[${P}].function.name
${sy(t)}`);if(F==null)throw new Ie(`missing choices[${d}].tool_calls[${P}].function.arguments
${sy(t)}`);return{...$,id:D,type:M,function:{...U,name:N,arguments:F}}})}}:{...y,message:{..._,content:b,role:A,refusal:h.refusal??null},finish_reason:f,index:d,logprobs:m}}),created:i,model:s,object:"chat.completion",...o?{system_fingerprint:o}:{}};return vne(c,e)}function sy(t){return JSON.stringify(t)}class fv extends q8{static fromReadableStream(e){const n=new fv(null);return n._run(()=>n._fromReadableStream(e)),n}static runTools(e,n,r){const i=new fv(n),s={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"runTools"}};return i._run(()=>i._runTools(e,n,s)),i}}let fk=class extends ze{constructor(){super(...arguments),this.messages=new A8(this._client)}create(e,n){return this._client.post("/chat/completions",{body:e,...n,stream:e.stream??!1})}retrieve(e,n){return this._client.get(ve`/chat/completions/${e}`,n)}update(e,n,r){return this._client.post(ve`/chat/completions/${e}`,{body:n,...r})}list(e={},n){return this._client.getAPIList("/chat/completions",gn,{query:e,...n})}delete(e,n){return this._client.delete(ve`/chat/completions/${e}`,n)}parse(e,n){return _ne(e.tools),this._client.chat.completions.create(e,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(r=>ck(r,e))}runTools(e,n){return e.stream?fv.runTools(this._client,e,n):hk.runTools(this._client,e,n)}stream(e,n){return q8.createChatCompletion(this._client,e,n)}};fk.Messages=A8;let dk=class extends ze{constructor(){super(...arguments),this.completions=new fk(this._client)}};dk.Completions=fk;const G8=Symbol("brand.privateNullableHeaders");function*Pne(t){if(!t)return;if(G8 in t){const{values:r,nulls:i}=t;yield*r.entries();for(const s of i)yield[s,null];return}let e=!1,n;t instanceof Headers?n=t.entries():PI(t)?n=t:(e=!0,n=Object.entries(t??{}));for(let r of n){const i=r[0];if(typeof i!="string")throw new TypeError("expected header name to be a string");const s=PI(r[1])?r[1]:[r[1]];let o=!1;for(const a of s)a!==void 0&&(e&&!o&&(o=!0,yield[i,null]),yield[i,a])}}const Ne=t=>{const e=new Headers,n=new Set;for(const r of t){const i=new Set;for(const[s,o]of Pne(r)){const a=s.toLowerCase();i.has(a)||(e.delete(s),i.add(a)),o===null?(e.delete(s),n.add(a)):(e.append(s,o),n.delete(a))}}return{[G8]:!0,values:e,nulls:n}};class K8 extends ze{create(e,n){return this._client.post("/audio/speech",{body:e,...n,headers:Ne([{Accept:"application/octet-stream"},n?.headers]),__binaryResponse:!0})}}let Y8=class extends ze{create(e,n){return this._client.post("/audio/transcriptions",_c({body:e,...n,stream:e.stream??!1,__metadata:{model:e.model}},this._client))}},X8=class extends ze{create(e,n){return this._client.post("/audio/translations",_c({body:e,...n,__metadata:{model:e.model}},this._client))}},Fm=class extends ze{constructor(){super(...arguments),this.transcriptions=new Y8(this._client),this.translations=new X8(this._client),this.speech=new K8(this._client)}};Fm.Transcriptions=Y8;Fm.Translations=X8;Fm.Speech=K8;let J8=class extends ze{create(e,n){return this._client.post("/batches",{body:e,...n})}retrieve(e,n){return this._client.get(ve`/batches/${e}`,n)}list(e={},n){return this._client.getAPIList("/batches",gn,{query:e,...n})}cancel(e,n){return this._client.post(ve`/batches/${e}/cancel`,n)}};class Q8 extends ze{create(e,n){return this._client.post("/assistants",{body:e,...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,n){return this._client.get(ve`/assistants/${e}`,{...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,n,r){return this._client.post(ve`/assistants/${e}`,{body:n,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}list(e={},n){return this._client.getAPIList("/assistants",gn,{query:e,...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,n){return this._client.delete(ve`/assistants/${e}`,{...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}let Z8=class extends ze{create(e,n){return this._client.post("/realtime/sessions",{body:e,...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};class e6 extends ze{create(e,n){return this._client.post("/realtime/transcription_sessions",{body:e,...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}let Bw=class extends ze{constructor(){super(...arguments),this.sessions=new Z8(this._client),this.transcriptionSessions=new e6(this._client)}};Bw.Sessions=Z8;Bw.TranscriptionSessions=e6;class t6 extends ze{create(e,n,r){return this._client.post(ve`/threads/${e}/messages`,{body:n,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(e,n,r){const{thread_id:i}=n;return this._client.get(ve`/threads/${i}/messages/${e}`,{...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(e,n,r){const{thread_id:i,...s}=n;return this._client.post(ve`/threads/${i}/messages/${e}`,{body:s,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}list(e,n={},r){return this._client.getAPIList(ve`/threads/${e}/messages`,gn,{query:n,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}delete(e,n,r){const{thread_id:i}=n;return this._client.delete(ve`/threads/${i}/messages/${e}`,{...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}}class n6 extends ze{retrieve(e,n,r){const{thread_id:i,run_id:s,...o}=n;return this._client.get(ve`/threads/${i}/runs/${s}/steps/${e}`,{query:o,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}list(e,n,r){const{thread_id:i,...s}=n;return this._client.getAPIList(ve`/threads/${i}/runs/${e}/steps`,gn,{query:s,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}}const Dne=t=>{if(typeof Buffer<"u"){const e=Buffer.from(t,"base64");return Array.from(new Float32Array(e.buffer,e.byteOffset,e.length/Float32Array.BYTES_PER_ELEMENT))}else{const e=atob(t),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.charCodeAt(i);return Array.from(new Float32Array(r.buffer))}};var Ine={};const Nu=t=>{if(typeof globalThis.process<"u")return Ine?.[t]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(t)?.trim()};var Wn,cc,gC,Qs,gb,ms,uc,th,sc,dv,Si,yb,bb,xp,tp,np,KI,YI,XI,JI,QI,ZI,eL;class Sp extends uk{constructor(){super(...arguments),Wn.add(this),gC.set(this,[]),Qs.set(this,{}),gb.set(this,{}),ms.set(this,void 0),uc.set(this,void 0),th.set(this,void 0),sc.set(this,void 0),dv.set(this,void 0),Si.set(this,void 0),yb.set(this,void 0),bb.set(this,void 0),xp.set(this,void 0)}[(gC=new WeakMap,Qs=new WeakMap,gb=new WeakMap,ms=new WeakMap,uc=new WeakMap,th=new WeakMap,sc=new WeakMap,dv=new WeakMap,Si=new WeakMap,yb=new WeakMap,bb=new WeakMap,xp=new WeakMap,Wn=new WeakSet,Symbol.asyncIterator)](){const e=[],n=[];let r=!1;return this.on("event",i=>{const s=n.shift();s?s.resolve(i):e.push(i)}),this.on("end",()=>{r=!0;for(const i of n)i.resolve(void 0);n.length=0}),this.on("abort",i=>{r=!0;for(const s of n)s.reject(i);n.length=0}),this.on("error",i=>{r=!0;for(const s of n)s.reject(i);n.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((s,o)=>n.push({resolve:s,reject:o})).then(s=>s?{value:s,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){const n=new cc;return n._run(()=>n._fromReadableStream(e)),n}async _fromReadableStream(e,n){const r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),this._connected();const i=Xp.fromReadableStream(e,this.controller);for await(const s of i)ne(this,Wn,"m",tp).call(this,s);if(i.controller.signal?.aborted)throw new Gi;return this._addRun(ne(this,Wn,"m",np).call(this))}toReadableStream(){return new Xp(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,n,r,i){const s=new cc;return s._run(()=>s._runToolAssistantStream(e,n,r,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}})),s}async _createToolAssistantStream(e,n,r,i){const s=i?.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort()));const o={...r,stream:!0},a=await e.submitToolOutputs(n,o,{...i,signal:this.controller.signal});this._connected();for await(const c of a)ne(this,Wn,"m",tp).call(this,c);if(a.controller.signal?.aborted)throw new Gi;return this._addRun(ne(this,Wn,"m",np).call(this))}static createThreadAssistantStream(e,n,r){const i=new cc;return i._run(()=>i._threadAssistantStream(e,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}static createAssistantStream(e,n,r,i){const s=new cc;return s._run(()=>s._runAssistantStream(e,n,r,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}})),s}currentEvent(){return ne(this,yb,"f")}currentRun(){return ne(this,bb,"f")}currentMessageSnapshot(){return ne(this,ms,"f")}currentRunStepSnapshot(){return ne(this,xp,"f")}async finalRunSteps(){return await this.done(),Object.values(ne(this,Qs,"f"))}async finalMessages(){return await this.done(),Object.values(ne(this,gb,"f"))}async finalRun(){if(await this.done(),!ne(this,uc,"f"))throw Error("Final run was not received.");return ne(this,uc,"f")}async _createThreadAssistantStream(e,n,r){const i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));const s={...n,stream:!0},o=await e.createAndRun(s,{...r,signal:this.controller.signal});this._connected();for await(const a of o)ne(this,Wn,"m",tp).call(this,a);if(o.controller.signal?.aborted)throw new Gi;return this._addRun(ne(this,Wn,"m",np).call(this))}async _createAssistantStream(e,n,r,i){const s=i?.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort()));const o={...r,stream:!0},a=await e.create(n,o,{...i,signal:this.controller.signal});this._connected();for await(const c of a)ne(this,Wn,"m",tp).call(this,c);if(a.controller.signal?.aborted)throw new Gi;return this._addRun(ne(this,Wn,"m",np).call(this))}static accumulateDelta(e,n){for(const[r,i]of Object.entries(n)){if(!e.hasOwnProperty(r)){e[r]=i;continue}let s=e[r];if(s==null){e[r]=i;continue}if(r==="index"||r==="type"){e[r]=i;continue}if(typeof s=="string"&&typeof i=="string")s+=i;else if(typeof s=="number"&&typeof i=="number")s+=i;else if(o_(s)&&o_(i))s=this.accumulateDelta(s,i);else if(Array.isArray(s)&&Array.isArray(i)){if(s.every(o=>typeof o=="string"||typeof o=="number")){s.push(...i);continue}for(const o of i){if(!o_(o))throw new Error(`Expected array delta entry to be an object but got: ${o}`);const a=o.index;if(a==null)throw console.error(o),new Error("Expected array delta entry to have an `index` property");if(typeof a!="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${a}`);const c=s[a];c==null?s.push(o):s[a]=this.accumulateDelta(c,o)}continue}else throw Error(`Unhandled record type: ${r}, deltaValue: ${i}, accValue: ${s}`);e[r]=s}return e}_addRun(e){return e}async _threadAssistantStream(e,n,r){return await this._createThreadAssistantStream(n,e,r)}async _runAssistantStream(e,n,r,i){return await this._createAssistantStream(n,e,r,i)}async _runToolAssistantStream(e,n,r,i){return await this._createToolAssistantStream(n,e,r,i)}}cc=Sp,tp=function(e){if(!this.ended)switch(Ge(this,yb,e),ne(this,Wn,"m",XI).call(this,e),e.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":ne(this,Wn,"m",eL).call(this,e);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":ne(this,Wn,"m",YI).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":ne(this,Wn,"m",KI).call(this,e);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier")}},np=function(){if(this.ended)throw new Ie("stream has ended, this shouldn't happen");if(!ne(this,uc,"f"))throw Error("Final run has not been received");return ne(this,uc,"f")},KI=function(e){const[n,r]=ne(this,Wn,"m",QI).call(this,e,ne(this,ms,"f"));Ge(this,ms,n),ne(this,gb,"f")[n.id]=n;for(const i of r){const s=n.content[i.index];s?.type=="text"&&this._emit("textCreated",s.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,n),e.data.delta.content)for(const i of e.data.delta.content){if(i.type=="text"&&i.text){let s=i.text,o=n.content[i.index];if(o&&o.type=="text")this._emit("textDelta",s,o.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(i.index!=ne(this,th,"f")){if(ne(this,sc,"f"))switch(ne(this,sc,"f").type){case"text":this._emit("textDone",ne(this,sc,"f").text,ne(this,ms,"f"));break;case"image_file":this._emit("imageFileDone",ne(this,sc,"f").image_file,ne(this,ms,"f"));break}Ge(this,th,i.index)}Ge(this,sc,n.content[i.index])}break;case"thread.message.completed":case"thread.message.incomplete":if(ne(this,th,"f")!==void 0){const i=e.data.content[ne(this,th,"f")];if(i)switch(i.type){case"image_file":this._emit("imageFileDone",i.image_file,ne(this,ms,"f"));break;case"text":this._emit("textDone",i.text,ne(this,ms,"f"));break}}ne(this,ms,"f")&&this._emit("messageDone",e.data),Ge(this,ms,void 0)}},YI=function(e){const n=ne(this,Wn,"m",JI).call(this,e);switch(Ge(this,xp,n),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":const r=e.data.delta;if(r.step_details&&r.step_details.type=="tool_calls"&&r.step_details.tool_calls&&n.step_details.type=="tool_calls")for(const s of r.step_details.tool_calls)s.index==ne(this,dv,"f")?this._emit("toolCallDelta",s,n.step_details.tool_calls[s.index]):(ne(this,Si,"f")&&this._emit("toolCallDone",ne(this,Si,"f")),Ge(this,dv,s.index),Ge(this,Si,n.step_details.tool_calls[s.index]),ne(this,Si,"f")&&this._emit("toolCallCreated",ne(this,Si,"f")));this._emit("runStepDelta",e.data.delta,n);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":Ge(this,xp,void 0),e.data.step_details.type=="tool_calls"&&ne(this,Si,"f")&&(this._emit("toolCallDone",ne(this,Si,"f")),Ge(this,Si,void 0)),this._emit("runStepDone",e.data,n);break}},XI=function(e){ne(this,gC,"f").push(e),this._emit("event",e)},JI=function(e){switch(e.event){case"thread.run.step.created":return ne(this,Qs,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let n=ne(this,Qs,"f")[e.data.id];if(!n)throw Error("Received a RunStepDelta before creation of a snapshot");let r=e.data;if(r.delta){const i=cc.accumulateDelta(n,r.delta);ne(this,Qs,"f")[e.data.id]=i}return ne(this,Qs,"f")[e.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":ne(this,Qs,"f")[e.data.id]=e.data;break}if(ne(this,Qs,"f")[e.data.id])return ne(this,Qs,"f")[e.data.id];throw new Error("No snapshot available")},QI=function(e,n){let r=[];switch(e.event){case"thread.message.created":return[e.data,r];case"thread.message.delta":if(!n)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let i=e.data;if(i.delta.content)for(const s of i.delta.content)if(s.index in n.content){let o=n.content[s.index];n.content[s.index]=ne(this,Wn,"m",ZI).call(this,s,o)}else n.content[s.index]=s,r.push(s);return[n,r];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(n)return[n,r];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},ZI=function(e,n){return cc.accumulateDelta(n,e)},eL=function(e){switch(Ge(this,bb,e.data),e.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":Ge(this,uc,e.data),ne(this,Si,"f")&&(this._emit("toolCallDone",ne(this,Si,"f")),Ge(this,Si,void 0));break}};let pk=class extends ze{constructor(){super(...arguments),this.steps=new n6(this._client)}create(e,n,r){const{include:i,...s}=n;return this._client.post(ve`/threads/${e}/runs`,{query:{include:i},body:s,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers]),stream:n.stream??!1})}retrieve(e,n,r){const{thread_id:i}=n;return this._client.get(ve`/threads/${i}/runs/${e}`,{...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(e,n,r){const{thread_id:i,...s}=n;return this._client.post(ve`/threads/${i}/runs/${e}`,{body:s,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}list(e,n={},r){return this._client.getAPIList(ve`/threads/${e}/runs`,gn,{query:n,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}cancel(e,n,r){const{thread_id:i}=n;return this._client.post(ve`/threads/${i}/runs/${e}/cancel`,{...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}async createAndPoll(e,n,r){const i=await this.create(e,n,r);return await this.poll(i.id,{thread_id:e},r)}createAndStream(e,n,r){return Sp.createAssistantStream(e,this._client.beta.threads.runs,n,r)}async poll(e,n,r){const i=Ne([r?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":r?.pollIntervalMs?.toString()??void 0}]);for(;;){const{data:s,response:o}=await this.retrieve(e,n,{...r,headers:{...r?.headers,...i}}).withResponse();switch(s.status){case"queued":case"in_progress":case"cancelling":let a=5e3;if(r?.pollIntervalMs)a=r.pollIntervalMs;else{const c=o.headers.get("openai-poll-after-ms");if(c){const h=parseInt(c);isNaN(h)||(a=h)}}await jm(a);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return s}}}stream(e,n,r){return Sp.createAssistantStream(e,this._client.beta.threads.runs,n,r)}submitToolOutputs(e,n,r){const{thread_id:i,...s}=n;return this._client.post(ve`/threads/${i}/runs/${e}/submit_tool_outputs`,{body:s,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers]),stream:n.stream??!1})}async submitToolOutputsAndPoll(e,n,r){const i=await this.submitToolOutputs(e,n,r);return await this.poll(i.id,n,r)}submitToolOutputsStream(e,n,r){return Sp.createToolAssistantStream(e,this._client.beta.threads.runs,n,r)}};pk.Steps=n6;class Fw extends ze{constructor(){super(...arguments),this.runs=new pk(this._client),this.messages=new t6(this._client)}create(e={},n){return this._client.post("/threads",{body:e,...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,n){return this._client.get(ve`/threads/${e}`,{...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,n,r){return this._client.post(ve`/threads/${e}`,{body:n,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}delete(e,n){return this._client.delete(ve`/threads/${e}`,{...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}createAndRun(e,n){return this._client.post("/threads/runs",{body:e,...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:e.stream??!1})}async createAndRunPoll(e,n){const r=await this.createAndRun(e,n);return await this.runs.poll(r.id,{thread_id:r.thread_id},n)}createAndRunStream(e,n){return Sp.createThreadAssistantStream(e,this._client.beta.threads,n)}}Fw.Runs=pk;Fw.Messages=t6;class zm extends ze{constructor(){super(...arguments),this.realtime=new Bw(this._client),this.assistants=new Q8(this._client),this.threads=new Fw(this._client)}}zm.Realtime=Bw;zm.Assistants=Q8;zm.Threads=Fw;let r6=class extends ze{create(e,n){return this._client.post("/completions",{body:e,...n,stream:e.stream??!1})}},i6=class extends ze{retrieve(e,n,r){const{container_id:i}=n;return this._client.get(ve`/containers/${i}/files/${e}/content`,{...r,headers:Ne([{Accept:"application/binary"},r?.headers]),__binaryResponse:!0})}},mk=class extends ze{constructor(){super(...arguments),this.content=new i6(this._client)}create(e,n,r){return this._client.post(ve`/containers/${e}/files`,_c({body:n,...r},this._client))}retrieve(e,n,r){const{container_id:i}=n;return this._client.get(ve`/containers/${i}/files/${e}`,r)}list(e,n={},r){return this._client.getAPIList(ve`/containers/${e}/files`,gn,{query:n,...r})}delete(e,n,r){const{container_id:i}=n;return this._client.delete(ve`/containers/${i}/files/${e}`,{...r,headers:Ne([{Accept:"*/*"},r?.headers])})}};mk.Content=i6;class gk extends ze{constructor(){super(...arguments),this.files=new mk(this._client)}create(e,n){return this._client.post("/containers",{body:e,...n})}retrieve(e,n){return this._client.get(ve`/containers/${e}`,n)}list(e={},n){return this._client.getAPIList("/containers",gn,{query:e,...n})}delete(e,n){return this._client.delete(ve`/containers/${e}`,{...n,headers:Ne([{Accept:"*/*"},n?.headers])})}}gk.Files=mk;class s6 extends ze{create(e,n,r){const{include:i,...s}=n;return this._client.post(ve`/conversations/${e}/items`,{query:{include:i},body:s,...r})}retrieve(e,n,r){const{conversation_id:i,...s}=n;return this._client.get(ve`/conversations/${i}/items/${e}`,{query:s,...r})}list(e,n={},r){return this._client.getAPIList(ve`/conversations/${e}/items`,une,{query:n,...r})}delete(e,n,r){const{conversation_id:i}=n;return this._client.delete(ve`/conversations/${i}/items/${e}`,r)}}class yk extends ze{constructor(){super(...arguments),this.items=new s6(this._client)}create(e,n){return this._client.post("/conversations",{body:e,...n})}retrieve(e,n){return this._client.get(ve`/conversations/${e}`,n)}update(e,n,r){return this._client.post(ve`/conversations/${e}`,{body:n,...r})}delete(e,n){return this._client.delete(ve`/conversations/${e}`,n)}}yk.Items=s6;let o6=class extends ze{create(e,n){const r=!!e.encoding_format;let i=r?e.encoding_format:"base64";r&&Un(this._client).debug("embeddings/user defined encoding_format:",e.encoding_format);const s=this._client.post("/embeddings",{body:{...e,encoding_format:i},...n});return r?s:(Un(this._client).debug("embeddings/decoding base64 embeddings from base64"),s._thenUnwrap(o=>(o&&o.data&&o.data.forEach(a=>{const c=a.embedding;a.embedding=Dne(c)}),o)))}};class a6 extends ze{retrieve(e,n,r){const{eval_id:i,run_id:s}=n;return this._client.get(ve`/evals/${i}/runs/${s}/output_items/${e}`,r)}list(e,n,r){const{eval_id:i,...s}=n;return this._client.getAPIList(ve`/evals/${i}/runs/${e}/output_items`,gn,{query:s,...r})}}class bk extends ze{constructor(){super(...arguments),this.outputItems=new a6(this._client)}create(e,n,r){return this._client.post(ve`/evals/${e}/runs`,{body:n,...r})}retrieve(e,n,r){const{eval_id:i}=n;return this._client.get(ve`/evals/${i}/runs/${e}`,r)}list(e,n={},r){return this._client.getAPIList(ve`/evals/${e}/runs`,gn,{query:n,...r})}delete(e,n,r){const{eval_id:i}=n;return this._client.delete(ve`/evals/${i}/runs/${e}`,r)}cancel(e,n,r){const{eval_id:i}=n;return this._client.post(ve`/evals/${i}/runs/${e}`,r)}}bk.OutputItems=a6;class vk extends ze{constructor(){super(...arguments),this.runs=new bk(this._client)}create(e,n){return this._client.post("/evals",{body:e,...n})}retrieve(e,n){return this._client.get(ve`/evals/${e}`,n)}update(e,n,r){return this._client.post(ve`/evals/${e}`,{body:n,...r})}list(e={},n){return this._client.getAPIList("/evals",gn,{query:e,...n})}delete(e,n){return this._client.delete(ve`/evals/${e}`,n)}}vk.Runs=bk;let l6=class extends ze{create(e,n){return this._client.post("/files",_c({body:e,...n},this._client))}retrieve(e,n){return this._client.get(ve`/files/${e}`,n)}list(e={},n){return this._client.getAPIList("/files",gn,{query:e,...n})}delete(e,n){return this._client.delete(ve`/files/${e}`,n)}content(e,n){return this._client.get(ve`/files/${e}/content`,{...n,headers:Ne([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}async waitForProcessing(e,{pollInterval:n=5e3,maxWait:r=1800*1e3}={}){const i=new Set(["processed","error","deleted"]),s=Date.now();let o=await this.retrieve(e);for(;!o.status||!i.has(o.status);)if(await jm(n),o=await this.retrieve(e),Date.now()-s>r)throw new sk({message:`Giving up on waiting for file ${e} to finish processing after ${r} milliseconds.`});return o}};class c6 extends ze{}let u6=class extends ze{run(e,n){return this._client.post("/fine_tuning/alpha/graders/run",{body:e,...n})}validate(e,n){return this._client.post("/fine_tuning/alpha/graders/validate",{body:e,...n})}};class wk extends ze{constructor(){super(...arguments),this.graders=new u6(this._client)}}wk.Graders=u6;class h6 extends ze{create(e,n,r){return this._client.getAPIList(ve`/fine_tuning/checkpoints/${e}/permissions`,jw,{body:n,method:"post",...r})}retrieve(e,n={},r){return this._client.get(ve`/fine_tuning/checkpoints/${e}/permissions`,{query:n,...r})}delete(e,n,r){const{fine_tuned_model_checkpoint:i}=n;return this._client.delete(ve`/fine_tuning/checkpoints/${i}/permissions/${e}`,r)}}let xk=class extends ze{constructor(){super(...arguments),this.permissions=new h6(this._client)}};xk.Permissions=h6;class f6 extends ze{list(e,n={},r){return this._client.getAPIList(ve`/fine_tuning/jobs/${e}/checkpoints`,gn,{query:n,...r})}}let Sk=class extends ze{constructor(){super(...arguments),this.checkpoints=new f6(this._client)}create(e,n){return this._client.post("/fine_tuning/jobs",{body:e,...n})}retrieve(e,n){return this._client.get(ve`/fine_tuning/jobs/${e}`,n)}list(e={},n){return this._client.getAPIList("/fine_tuning/jobs",gn,{query:e,...n})}cancel(e,n){return this._client.post(ve`/fine_tuning/jobs/${e}/cancel`,n)}listEvents(e,n={},r){return this._client.getAPIList(ve`/fine_tuning/jobs/${e}/events`,gn,{query:n,...r})}pause(e,n){return this._client.post(ve`/fine_tuning/jobs/${e}/pause`,n)}resume(e,n){return this._client.post(ve`/fine_tuning/jobs/${e}/resume`,n)}};Sk.Checkpoints=f6;class Kh extends ze{constructor(){super(...arguments),this.methods=new c6(this._client),this.jobs=new Sk(this._client),this.checkpoints=new xk(this._client),this.alpha=new wk(this._client)}}Kh.Methods=c6;Kh.Jobs=Sk;Kh.Checkpoints=xk;Kh.Alpha=wk;class d6 extends ze{}class _k extends ze{constructor(){super(...arguments),this.graderModels=new d6(this._client)}}_k.GraderModels=d6;let p6=class extends ze{createVariation(e,n){return this._client.post("/images/variations",_c({body:e,...n},this._client))}edit(e,n){return this._client.post("/images/edits",_c({body:e,...n,stream:e.stream??!1},this._client))}generate(e,n){return this._client.post("/images/generations",{body:e,...n,stream:e.stream??!1})}},m6=class extends ze{retrieve(e,n){return this._client.get(ve`/models/${e}`,n)}list(e){return this._client.getAPIList("/models",jw,e)}delete(e,n){return this._client.delete(ve`/models/${e}`,n)}};class g6 extends ze{create(e,n){return this._client.post("/moderations",{body:e,...n})}}class y6 extends ze{create(e,n){return this._client.post("/realtime/client_secrets",{body:e,...n})}}class Ck extends ze{constructor(){super(...arguments),this.clientSecrets=new y6(this._client)}}Ck.ClientSecrets=y6;function Lne(t,e){return!e||!$ne(e)?{...t,output_parsed:null,output:t.output.map(n=>n.type==="function_call"?{...n,parsed_arguments:null}:n.type==="message"?{...n,content:n.content.map(r=>({...r,parsed:null}))}:n)}:b6(t,e)}function b6(t,e){const n=t.output.map(i=>{if(i.type==="function_call")return{...i,parsed_arguments:Fne(e,i)};if(i.type==="message"){const s=i.content.map(o=>o.type==="output_text"?{...o,parsed:Nne(e,o.text)}:o);return{...i,content:s}}return i}),r=Object.assign({},t,{output:n});return Object.getOwnPropertyDescriptor(t,"output_text")||yC(r),Object.defineProperty(r,"output_parsed",{enumerable:!0,get(){for(const i of r.output)if(i.type==="message"){for(const s of i.content)if(s.type==="output_text"&&s.parsed!==null)return s.parsed}return null}}),r}function Nne(t,e){return t.text?.format?.type!=="json_schema"?null:"$parseRaw"in t.text?.format?(t.text?.format).$parseRaw(e):JSON.parse(e)}function $ne(t){return!!lk(t.text?.format)}function jne(t){return t?.$brand==="auto-parseable-tool"}function Bne(t,e){return t.find(n=>n.type==="function"&&n.name===e)}function Fne(t,e){const n=Bne(t.tools??[],e.name);return{...e,...e,parsed_arguments:jne(n)?n.$parseRaw(e.arguments):n?.strict?JSON.parse(e.arguments):null}}function yC(t){const e=[];for(const n of t.output)if(n.type==="message")for(const r of n.content)r.type==="output_text"&&e.push(r.text);t.output_text=e.join("")}var $u,oy,Ha,ay,tL,nL,rL,iL;class Ak extends uk{constructor(e){super(),$u.add(this),oy.set(this,void 0),Ha.set(this,void 0),ay.set(this,void 0),Ge(this,oy,e)}static createResponse(e,n,r){const i=new Ak(n);return i._run(()=>i._createOrRetrieveResponse(e,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createOrRetrieveResponse(e,n,r){const i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),ne(this,$u,"m",tL).call(this);let s,o=null;"response_id"in n?(s=await e.responses.retrieve(n.response_id,{stream:!0},{...r,signal:this.controller.signal,stream:!0}),o=n.starting_after??null):s=await e.responses.create({...n,stream:!0},{...r,signal:this.controller.signal}),this._connected();for await(const a of s)ne(this,$u,"m",nL).call(this,a,o);if(s.controller.signal?.aborted)throw new Gi;return ne(this,$u,"m",rL).call(this)}[(oy=new WeakMap,Ha=new WeakMap,ay=new WeakMap,$u=new WeakSet,tL=function(){this.ended||Ge(this,Ha,void 0)},nL=function(n,r){if(this.ended)return;const i=(o,a)=>{(r==null||a.sequence_number>r)&&this._emit(o,a)},s=ne(this,$u,"m",iL).call(this,n);switch(i("event",n),n.type){case"response.output_text.delta":{const o=s.output[n.output_index];if(!o)throw new Ie(`missing output at index ${n.output_index}`);if(o.type==="message"){const a=o.content[n.content_index];if(!a)throw new Ie(`missing content at index ${n.content_index}`);if(a.type!=="output_text")throw new Ie(`expected content to be 'output_text', got ${a.type}`);i("response.output_text.delta",{...n,snapshot:a.text})}break}case"response.function_call_arguments.delta":{const o=s.output[n.output_index];if(!o)throw new Ie(`missing output at index ${n.output_index}`);o.type==="function_call"&&i("response.function_call_arguments.delta",{...n,snapshot:o.arguments});break}default:i(n.type,n);break}},rL=function(){if(this.ended)throw new Ie("stream has ended, this shouldn't happen");const n=ne(this,Ha,"f");if(!n)throw new Ie("request ended without sending any events");Ge(this,Ha,void 0);const r=zne(n,ne(this,oy,"f"));return Ge(this,ay,r),r},iL=function(n){let r=ne(this,Ha,"f");if(!r){if(n.type!=="response.created")throw new Ie(`When snapshot hasn't been set yet, expected 'response.created' event, got ${n.type}`);return r=Ge(this,Ha,n.response),r}switch(n.type){case"response.output_item.added":{r.output.push(n.item);break}case"response.content_part.added":{const i=r.output[n.output_index];if(!i)throw new Ie(`missing output at index ${n.output_index}`);const s=i.type,o=n.part;s==="message"&&o.type!=="reasoning_text"?i.content.push(o):s==="reasoning"&&o.type==="reasoning_text"&&(i.content||(i.content=[]),i.content.push(o));break}case"response.output_text.delta":{const i=r.output[n.output_index];if(!i)throw new Ie(`missing output at index ${n.output_index}`);if(i.type==="message"){const s=i.content[n.content_index];if(!s)throw new Ie(`missing content at index ${n.content_index}`);if(s.type!=="output_text")throw new Ie(`expected content to be 'output_text', got ${s.type}`);s.text+=n.delta}break}case"response.function_call_arguments.delta":{const i=r.output[n.output_index];if(!i)throw new Ie(`missing output at index ${n.output_index}`);i.type==="function_call"&&(i.arguments+=n.delta);break}case"response.reasoning_text.delta":{const i=r.output[n.output_index];if(!i)throw new Ie(`missing output at index ${n.output_index}`);if(i.type==="reasoning"){const s=i.content?.[n.content_index];if(!s)throw new Ie(`missing content at index ${n.content_index}`);if(s.type!=="reasoning_text")throw new Ie(`expected content to be 'reasoning_text', got ${s.type}`);s.text+=n.delta}break}case"response.completed":{Ge(this,Ha,n.response);break}}return r},Symbol.asyncIterator)](){const e=[],n=[];let r=!1;return this.on("event",i=>{const s=n.shift();s?s.resolve(i):e.push(i)}),this.on("end",()=>{r=!0;for(const i of n)i.resolve(void 0);n.length=0}),this.on("abort",i=>{r=!0;for(const s of n)s.reject(i);n.length=0}),this.on("error",i=>{r=!0;for(const s of n)s.reject(i);n.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((s,o)=>n.push({resolve:s,reject:o})).then(s=>s?{value:s,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();const e=ne(this,ay,"f");if(!e)throw new Ie("stream ended without producing a ChatCompletion");return e}}function zne(t,e){return Lne(t,e)}class v6 extends ze{list(e,n={},r){return this._client.getAPIList(ve`/responses/${e}/input_items`,gn,{query:n,...r})}}class Ek extends ze{constructor(){super(...arguments),this.inputItems=new v6(this._client)}create(e,n){return this._client.post("/responses",{body:e,...n,stream:e.stream??!1})._thenUnwrap(r=>("object"in r&&r.object==="response"&&yC(r),r))}retrieve(e,n={},r){return this._client.get(ve`/responses/${e}`,{query:n,...r,stream:n?.stream??!1})._thenUnwrap(i=>("object"in i&&i.object==="response"&&yC(i),i))}delete(e,n){return this._client.delete(ve`/responses/${e}`,{...n,headers:Ne([{Accept:"*/*"},n?.headers])})}parse(e,n){return this._client.responses.create(e,n)._thenUnwrap(r=>b6(r,e))}stream(e,n){return Ak.createResponse(this._client,e,n)}cancel(e,n){return this._client.post(ve`/responses/${e}/cancel`,n)}}Ek.InputItems=v6;class w6 extends ze{create(e,n,r){return this._client.post(ve`/uploads/${e}/parts`,_c({body:n,...r},this._client))}}class kk extends ze{constructor(){super(...arguments),this.parts=new w6(this._client)}create(e,n){return this._client.post("/uploads",{body:e,...n})}cancel(e,n){return this._client.post(ve`/uploads/${e}/cancel`,n)}complete(e,n,r){return this._client.post(ve`/uploads/${e}/complete`,{body:n,...r})}}kk.Parts=w6;const Vne=async t=>{const e=await Promise.allSettled(t),n=e.filter(i=>i.status==="rejected");if(n.length){for(const i of n)console.error(i.reason);throw new Error(`${n.length} promise(s) failed - see the above errors`)}const r=[];for(const i of e)i.status==="fulfilled"&&r.push(i.value);return r};class x6 extends ze{create(e,n,r){return this._client.post(ve`/vector_stores/${e}/file_batches`,{body:n,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(e,n,r){const{vector_store_id:i}=n;return this._client.get(ve`/vector_stores/${i}/file_batches/${e}`,{...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}cancel(e,n,r){const{vector_store_id:i}=n;return this._client.post(ve`/vector_stores/${i}/file_batches/${e}/cancel`,{...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}async createAndPoll(e,n,r){const i=await this.create(e,n);return await this.poll(e,i.id,r)}listFiles(e,n,r){const{vector_store_id:i,...s}=n;return this._client.getAPIList(ve`/vector_stores/${i}/file_batches/${e}/files`,gn,{query:s,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}async poll(e,n,r){const i=Ne([r?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":r?.pollIntervalMs?.toString()??void 0}]);for(;;){const{data:s,response:o}=await this.retrieve(n,{vector_store_id:e},{...r,headers:i}).withResponse();switch(s.status){case"in_progress":let a=5e3;if(r?.pollIntervalMs)a=r.pollIntervalMs;else{const c=o.headers.get("openai-poll-after-ms");if(c){const h=parseInt(c);isNaN(h)||(a=h)}}await jm(a);break;case"failed":case"cancelled":case"completed":return s}}}async uploadAndPoll(e,{files:n,fileIds:r=[]},i){if(n==null||n.length==0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");const s=i?.maxConcurrency??5,o=Math.min(s,n.length),a=this._client,c=n.values(),h=[...r];async function f(m){for(let y of m){const b=await a.files.create({file:y,purpose:"assistants"},i);h.push(b.id)}}const d=Array(o).fill(c).map(f);return await Vne(d),await this.createAndPoll(e,{file_ids:h})}}let S6=class extends ze{create(e,n,r){return this._client.post(ve`/vector_stores/${e}/files`,{body:n,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(e,n,r){const{vector_store_id:i}=n;return this._client.get(ve`/vector_stores/${i}/files/${e}`,{...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(e,n,r){const{vector_store_id:i,...s}=n;return this._client.post(ve`/vector_stores/${i}/files/${e}`,{body:s,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}list(e,n={},r){return this._client.getAPIList(ve`/vector_stores/${e}/files`,gn,{query:n,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}delete(e,n,r){const{vector_store_id:i}=n;return this._client.delete(ve`/vector_stores/${i}/files/${e}`,{...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}async createAndPoll(e,n,r){const i=await this.create(e,n,r);return await this.poll(e,i.id,r)}async poll(e,n,r){const i=Ne([r?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":r?.pollIntervalMs?.toString()??void 0}]);for(;;){const s=await this.retrieve(n,{vector_store_id:e},{...r,headers:i}).withResponse(),o=s.data;switch(o.status){case"in_progress":let a=5e3;if(r?.pollIntervalMs)a=r.pollIntervalMs;else{const c=s.response.headers.get("openai-poll-after-ms");if(c){const h=parseInt(c);isNaN(h)||(a=h)}}await jm(a);break;case"failed":case"completed":return o}}}async upload(e,n,r){const i=await this._client.files.create({file:n,purpose:"assistants"},r);return this.create(e,{file_id:i.id},r)}async uploadAndPoll(e,n,r){const i=await this.upload(e,n,r);return await this.poll(e,i.id,r)}content(e,n,r){const{vector_store_id:i}=n;return this._client.getAPIList(ve`/vector_stores/${i}/files/${e}/content`,jw,{...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};class zw extends ze{constructor(){super(...arguments),this.files=new S6(this._client),this.fileBatches=new x6(this._client)}create(e,n){return this._client.post("/vector_stores",{body:e,...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,n){return this._client.get(ve`/vector_stores/${e}`,{...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,n,r){return this._client.post(ve`/vector_stores/${e}`,{body:n,...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}list(e={},n){return this._client.getAPIList("/vector_stores",gn,{query:e,...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,n){return this._client.delete(ve`/vector_stores/${e}`,{...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}search(e,n,r){return this._client.getAPIList(ve`/vector_stores/${e}/search`,jw,{body:n,method:"post",...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}}zw.Files=S6;zw.FileBatches=x6;var Ku,_6,vb;class C6 extends ze{constructor(){super(...arguments),Ku.add(this)}async unwrap(e,n,r=this._client.webhookSecret,i=300){return await this.verifySignature(e,n,r,i),JSON.parse(e)}async verifySignature(e,n,r=this._client.webhookSecret,i=300){if(typeof crypto>"u"||typeof crypto.subtle.importKey!="function"||typeof crypto.subtle.verify!="function")throw new Error("Webhook signature verification is only supported when the `crypto` global is defined");ne(this,Ku,"m",_6).call(this,r);const s=Ne([n]).values,o=ne(this,Ku,"m",vb).call(this,s,"webhook-signature"),a=ne(this,Ku,"m",vb).call(this,s,"webhook-timestamp"),c=ne(this,Ku,"m",vb).call(this,s,"webhook-id"),h=parseInt(a,10);if(isNaN(h))throw new Gd("Invalid webhook timestamp format");const f=Math.floor(Date.now()/1e3);if(f-h>i)throw new Gd("Webhook timestamp is too old");if(h>f+i)throw new Gd("Webhook timestamp is too new");const d=o.split(" ").map(w=>w.startsWith("v1,")?w.substring(3):w),m=r.startsWith("whsec_")?Buffer.from(r.replace("whsec_",""),"base64"):Buffer.from(r,"utf-8"),y=c?`${c}.${a}.${e}`:`${a}.${e}`,b=await crypto.subtle.importKey("raw",m,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(const w of d)try{const S=Buffer.from(w,"base64");if(await crypto.subtle.verify("HMAC",b,S,new TextEncoder().encode(y)))return}catch{continue}throw new Gd("The given webhook signature does not match the expected signature")}}Ku=new WeakSet,_6=function(e){if(typeof e!="string"||e.length===0)throw new Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},vb=function(e,n){if(!e)throw new Error("Headers are required");const r=e.get(n);if(r==null)throw new Error(`Missing required header: ${n}`);return r};var bC,Tk,wb,A6;class Xe{constructor({baseURL:e=Nu("OPENAI_BASE_URL"),apiKey:n=Nu("OPENAI_API_KEY"),organization:r=Nu("OPENAI_ORG_ID")??null,project:i=Nu("OPENAI_PROJECT_ID")??null,webhookSecret:s=Nu("OPENAI_WEBHOOK_SECRET")??null,...o}={}){if(bC.add(this),wb.set(this,void 0),this.completions=new r6(this),this.chat=new dk(this),this.embeddings=new o6(this),this.files=new l6(this),this.images=new p6(this),this.audio=new Fm(this),this.moderations=new g6(this),this.models=new m6(this),this.fineTuning=new Kh(this),this.graders=new _k(this),this.vectorStores=new zw(this),this.webhooks=new C6(this),this.beta=new zm(this),this.batches=new J8(this),this.uploads=new kk(this),this.responses=new Ek(this),this.realtime=new Ck(this),this.conversations=new yk(this),this.evals=new vk(this),this.containers=new gk(this),n===void 0)throw new Ie("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");const a={apiKey:n,organization:r,project:i,webhookSecret:s,...o,baseURL:e||"https://api.openai.com/v1"};if(!a.dangerouslyAllowBrowser&&zte())throw new Ie(`It looks like you're running in a browser-like environment.
This is disabled by default, as it risks exposing your secret API credentials to attackers.
If you understand the risks and have appropriate mitigations in place,
you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
`);this.baseURL=a.baseURL,this.timeout=a.timeout??Tk.DEFAULT_TIMEOUT,this.logger=a.logger??console;const c="warn";this.logLevel=c,this.logLevel=VI(a.logLevel,"ClientOptions.logLevel",this)??VI(Nu("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??c,this.fetchOptions=a.fetchOptions,this.maxRetries=a.maxRetries??2,this.fetch=a.fetch??qte(),Ge(this,wb,Kte),this._options=a,this.apiKey=typeof n=="string"?n:"Missing Key",this.organization=r,this.project=i,this.webhookSecret=s}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:n}){}async authHeaders(e){return Ne([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return ene(e,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${qu}`}defaultIdempotencyKey(){return`stainless-node-retry-${JB()}`}makeStatusError(e,n,r,i){return Qr.generate(e,n,r,i)}async _callApiKey(){const e=this._options.apiKey;if(typeof e!="function")return!1;let n;try{n=await e()}catch(r){throw r instanceof Ie?r:new Ie(`Failed to get token from 'apiKey' function: ${r.message}`,{cause:r})}if(typeof n!="string"||!n)throw new Ie(`Expected 'apiKey' function argument to return a string but it returned ${n}`);return this.apiKey=n,!0}buildURL(e,n,r){const i=!ne(this,bC,"m",A6).call(this)&&r||this.baseURL,s=Nte(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();return $te(o)||(n={...o,...n}),typeof n=="object"&&n&&!Array.isArray(n)&&(s.search=this.stringifyQuery(n)),s.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:n,options:r}){}get(e,n){return this.methodRequest("get",e,n)}post(e,n){return this.methodRequest("post",e,n)}patch(e,n){return this.methodRequest("patch",e,n)}put(e,n){return this.methodRequest("put",e,n)}delete(e,n){return this.methodRequest("delete",e,n)}methodRequest(e,n,r){return this.request(Promise.resolve(r).then(i=>({method:e,path:n,...i})))}request(e,n=null){return new v8(this,this.makeRequest(e,n,void 0))}async makeRequest(e,n,r){const i=await e,s=i.maxRetries??this.maxRetries;n==null&&(n=s),await this.prepareOptions(i);const{req:o,url:a,timeout:c}=await this.buildRequest(i,{retryCount:s-n});await this.prepareRequest(o,{url:a,options:i});const h="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),f=r===void 0?"":`, retryOf: ${r}`,d=Date.now();if(Un(this).debug(`[${h}] sending request`,ec({retryOfRequestLogID:r,method:i.method,url:a,options:i,headers:o.headers})),i.signal?.aborted)throw new Gi;const m=new AbortController,y=await this.fetchWithTimeout(a,o,c,m).catch(sC),b=Date.now();if(y instanceof globalThis.Error){const _=`retrying, ${n} attempts remaining`;if(i.signal?.aborted)throw new Gi;const A=iC(y)||/timed? ?out/i.test(String(y)+("cause"in y?String(y.cause):""));if(n)return Un(this).info(`[${h}] connection ${A?"timed out":"failed"} - ${_}`),Un(this).debug(`[${h}] connection ${A?"timed out":"failed"} (${_})`,ec({retryOfRequestLogID:r,url:a,durationMs:b-d,message:y.message})),this.retryRequest(i,n,r??h);throw Un(this).info(`[${h}] connection ${A?"timed out":"failed"} - error; no more retries left`),Un(this).debug(`[${h}] connection ${A?"timed out":"failed"} (error; no more retries left)`,ec({retryOfRequestLogID:r,url:a,durationMs:b-d,message:y.message})),A?new sk:new Nw({cause:y})}const w=[...y.headers.entries()].filter(([_])=>_==="x-request-id").map(([_,A])=>", "+_+": "+JSON.stringify(A)).join(""),S=`[${h}${f}${w}] ${o.method} ${a} ${y.ok?"succeeded":"failed"} with status ${y.status} in ${b-d}ms`;if(!y.ok){const _=await this.shouldRetry(y);if(n&&_){const D=`retrying, ${n} attempts remaining`;return await Gte(y.body),Un(this).info(`${S} - ${D}`),Un(this).debug(`[${h}] response error (${D})`,ec({retryOfRequestLogID:r,url:y.url,status:y.status,headers:y.headers,durationMs:b-d})),this.retryRequest(i,n,r??h,y.headers)}const A=_?"error; no more retries left":"error; not retryable";Un(this).info(`${S} - ${A}`);const E=await y.text().catch(D=>sC(D).message),P=Fte(E),O=P?void 0:E;throw Un(this).debug(`[${h}] response error (${A})`,ec({retryOfRequestLogID:r,url:y.url,status:y.status,headers:y.headers,message:O,durationMs:Date.now()-d})),this.makeStatusError(y.status,P,O,y.headers)}return Un(this).info(S),Un(this).debug(`[${h}] response start`,ec({retryOfRequestLogID:r,url:y.url,status:y.status,headers:y.headers,durationMs:b-d})),{response:y,options:i,controller:m,requestLogID:h,retryOfRequestLogID:r,startTime:d}}getAPIList(e,n,r){return this.requestAPIList(n,{method:"get",path:e,...r})}requestAPIList(e,n){const r=this.makeRequest(n,null,void 0);return new cne(this,r,e)}async fetchWithTimeout(e,n,r,i){const{signal:s,method:o,...a}=n||{};s&&s.addEventListener("abort",()=>i.abort());const c=setTimeout(()=>i.abort(),r),h=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,f={signal:i.signal,...h?{duplex:"half"}:{},method:"GET",...a};o&&(f.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,f)}finally{clearTimeout(c)}}async shouldRetry(e){const n=e.headers.get("x-should-retry");return n==="true"?!0:n==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,n,r,i){let s;const o=i?.get("retry-after-ms");if(o){const c=parseFloat(o);Number.isNaN(c)||(s=c)}const a=i?.get("retry-after");if(a&&!s){const c=parseFloat(a);Number.isNaN(c)?s=Date.parse(a)-Date.now():s=c*1e3}if(!(s&&0<=s&&s<60*1e3)){const c=e.maxRetries??this.maxRetries;s=this.calculateDefaultRetryTimeoutMillis(n,c)}return await jm(s),this.makeRequest(e,n-1,r)}calculateDefaultRetryTimeoutMillis(e,n){const s=n-e,o=Math.min(.5*Math.pow(2,s),8),a=1-Math.random()*.25;return o*a*1e3}async buildRequest(e,{retryCount:n=0}={}){const r={...e},{method:i,path:s,query:o,defaultBaseURL:a}=r,c=this.buildURL(s,o,a);"timeout"in r&&Bte("timeout",r.timeout),r.timeout=r.timeout??this.timeout;const{bodyHeaders:h,body:f}=this.buildBody({options:r}),d=await this.buildHeaders({options:e,method:i,bodyHeaders:h,retryCount:n});return{req:{method:i,headers:d,...r.signal&&{signal:r.signal},...globalThis.ReadableStream&&f instanceof globalThis.ReadableStream&&{duplex:"half"},...f&&{body:f},...this.fetchOptions??{},...r.fetchOptions??{}},url:c,timeout:r.timeout}}async buildHeaders({options:e,method:n,bodyHeaders:r,retryCount:i}){let s={};this.idempotencyHeader&&n!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=e.idempotencyKey);const o=Ne([s,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Wte(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,r,e.headers]);return this.validateHeaders(o),o.values}buildBody({options:{body:e,headers:n}}){if(!e)return{bodyHeaders:void 0,body:void 0};const r=Ne([n]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&r.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:u8(e)}:ne(this,wb,"f").call(this,{body:e,headers:r})}}Tk=Xe,wb=new WeakMap,bC=new WeakSet,A6=function(){return this.baseURL!=="https://api.openai.com/v1"};Xe.OpenAI=Tk;Xe.DEFAULT_TIMEOUT=6e5;Xe.OpenAIError=Ie;Xe.APIError=Qr;Xe.APIConnectionError=Nw;Xe.APIConnectionTimeoutError=sk;Xe.APIUserAbortError=Gi;Xe.NotFoundError=t8;Xe.ConflictError=n8;Xe.RateLimitError=i8;Xe.BadRequestError=QB;Xe.AuthenticationError=ZB;Xe.InternalServerError=s8;Xe.PermissionDeniedError=e8;Xe.UnprocessableEntityError=r8;Xe.InvalidWebhookSignatureError=Gd;Xe.toFile=gne;Xe.Completions=r6;Xe.Chat=dk;Xe.Embeddings=o6;Xe.Files=l6;Xe.Images=p6;Xe.Audio=Fm;Xe.Moderations=g6;Xe.Models=m6;Xe.FineTuning=Kh;Xe.Graders=_k;Xe.VectorStores=zw;Xe.Webhooks=C6;Xe.Beta=zm;Xe.Batches=J8;Xe.Uploads=kk;Xe.Responses=Ek;Xe.Realtime=Ck;Xe.Conversations=yk;Xe.Evals=vk;Xe.Containers=gk;const Une=t=>t.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:{...e.inputSchema}}})),ly=t=>{const e=[];return t.forEach(n=>{if(n.role==="user"||n.role==="system"){const r=typeof n.content=="string"?n.content:n.content.map(i=>i.type==="text"?{type:"text",text:i.text}:i.type==="file"?{type:"text",text:JSON.stringify({file_data:i.data,filename:JSON.parse(i.mimeType).path,file_id:JSON.parse(i.mimeType).path})}:{type:"text",text:""});e.push({role:"user",content:r})}else{const r=typeof n.content=="string"?n.content:[],i=[],s=[],o=n.content;typeof o!="string"&&typeof r!="string"&&o.forEach(c=>{if(Array.isArray(r)&&(c.type==="text"&&r.push({type:"text",text:c.text}),c.type==="tool-call")){c.result&&i.push({role:"tool",content:c.result,tool_call_id:c.toolCallId}),s.push({id:c.toolCallId,type:"function",function:{arguments:c.argsText??"",name:c.toolName}});return}});const a={role:"assistant",content:r};s.length&&(a.tool_calls=s),e.push(a),i.length&&e.push(...i)}}),e},Hne=(t,e,n)=>{if(!e.delta.content)return t;let r=Jr(t);const i=r.content;if(typeof i=="string")return r;const s=i[i.length-1];if((!s||n)&&typeof t.content!="string"&&(r={...r,content:[...i,{type:"text",text:e.delta.content}]}),s&&typeof s!="string"&&typeof i!="string"&&s.type==="text"){const o=s.text+e.delta.content,a=Jr({...s,text:o});r={...r,content:[...i.slice(0,-1),a]}}return r},Wne=(t,e)=>{let n=Jr(t);if(!e.delta.tool_calls||typeof n.content=="string")return n;const r=e.delta.tool_calls[0],i=n.content[n.content.length-1];if(!i||i?.type!=="tool-call"){const s={type:"tool-call",args:{},argsText:r?.function?.arguments??"",toolName:r?.function?.name??"",toolCallId:r?.id??""};n={...n,content:[...n.content,s]}}else{const s=i,o=s.argsText+(r?.function?.arguments??""),a=s.toolName||r?.function?.name||"",c=s.toolCallId||r?.id||"";let h={};try{h=JSON.parse(o??"{}")}catch{}const f={...s,args:h,argsText:o,toolName:a,toolCallId:c};n={...n,content:[...n.content.slice(0,-1),f]}}return n};class qne{modelKey="";systemPrompt="";apiKey;url;provider;prevMessages=[];tools=[];client;stopStream=!1;constructor(){}setProvider=e=>{this.provider=e,this.client=new Xe({apiKey:e.key,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0}),e.key&&this.setApiKey(e.key),e.baseUrl&&this.setUrl(e.baseUrl)};setModelKey=e=>{this.modelKey=e};setSystemPrompt=e=>{this.systemPrompt=e};setApiKey=e=>{this.apiKey=e,this.client&&(this.client.apiKey=e)};setUrl=e=>{this.url=e,this.client&&(this.client.baseURL=e)};setPrevMessages=e=>{this.prevMessages=ly(e)};setTools=e=>{this.tools=Une(e)};async createChatName(e){try{if(!this.client)return"";const n={role:"system",content:$m};return(await this.client.chat.completions.create({messages:[n,{role:"user",content:e}],model:this.modelKey,stream:!1})).choices[0].message.content??e.substring(0,25)}catch{return""}}async*sendMessage(e,n,r){try{if(!this.client)return;const i=ly(e),s={role:"system",content:this.systemPrompt},o=await this.client.chat.completions.create({messages:[s,...this.prevMessages,...i],model:this.modelKey,tools:this.tools,stream:!0});this.prevMessages.push(...i);let a=n&&r?Jr(r):{role:"assistant",content:[]},c=!1;for await(const h of o){if(h.choices.forEach(d=>{if(!c){if(d.finish_reason){c=!0;const m=n?{...a,content:typeof a.content=="string"?a.content:a.content.filter((b,w)=>{if(b.type==="tool-call")return!0;const S=r?.content.length??0;return w>=S})}:a,y=ly([m]);this.prevMessages.push(...y);return}d.delta.content&&(a=Hne(a,d,n)),d.delta.tool_calls&&typeof a.content!="string"&&(a=Wne(a,d))}}),this.stopStream){const d=ly([a]);this.prevMessages.push(...d),o.controller.abort(),this.stopStream=!1,yield{isEnd:!0,responseMessage:a};continue}if(c){yield{isEnd:!0,responseMessage:a};continue}else yield a}}catch(i){console.log(i),yield{isEnd:!0,responseMessage:{role:"assistant",content:"",status:{type:"incomplete",reason:"error",error:i}}}}}async*sendMessageAfterToolCall(e){if(typeof e.content=="string")return e;const n=e.content.filter(i=>i.type==="tool-call").reverse()[0];if(!n)return e;const r={role:"tool",content:n.result,tool_call_id:n.toolCallId};return this.prevMessages.push(r),yield*this.sendMessage([],!0,e),e}stopMessage=()=>{this.stopStream=!0};getName=()=>"OpenAI";getBaseUrl=()=>"https://api.openai.com/v1";checkProvider=async e=>{const n=new Xe({baseURL:e.url,apiKey:e.apiKey,dangerouslyAllowBrowser:!0});try{return await n.models.list(),!0}catch(r){if(console.log(JSON.stringify(r)),r.code==="invalid_api_key")return{field:"key",message:"Invalid API Key"}}return e.apiKey?{field:"url",message:"Invalid URL"}:{field:"key",message:"Empty key"}};getProviderModels=async e=>(await new Xe({baseURL:e.url,apiKey:e.apiKey,dangerouslyAllowBrowser:!0}).models.list()).data.filter(i=>i.id==="gpt-4.1"||i.id==="gpt-5"||i.id==="gpt-5.1-2025-11-13").map(i=>({id:i.id,name:i.id==="gpt-5.1-2025-11-13"?"GPT-5.1":i.id.toUpperCase(),provider:"openai"})).reverse()}const sL=new qne;function Nt(t,e,n,r,i){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}function Ae(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)}let E6=function(){const{crypto:t}=globalThis;if(t?.randomUUID)return E6=t.randomUUID.bind(t),t.randomUUID();const e=new Uint8Array(1),n=t?()=>t.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^n()&15>>+r/4).toString(16))};function vC(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}const wC=t=>{if(t instanceof Error)return t;if(typeof t=="object"&&t!==null){try{if(Object.prototype.toString.call(t)==="[object Error]"){const e=new Error(t.message,t.cause?{cause:t.cause}:{});return t.stack&&(e.stack=t.stack),t.cause&&!e.cause&&(e.cause=t.cause),t.name&&(e.name=t.name),e}}catch{}try{return new Error(JSON.stringify(t))}catch{}}return new Error(t)};class At extends Error{}class yr extends At{constructor(e,n,r,i){super(`${yr.makeMessage(e,n,r)}`),this.status=e,this.headers=i,this.error=n}static makeMessage(e,n,r){const i=n?.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):r;return e&&i?`${e} ${i}`:e?`${e} status code (no body)`:i||"(no status code or body)"}static generate(e,n,r,i){if(!e||!i)return new Vw({message:r,cause:wC(n)});const s=n;return e===400?new T6(e,s,r,i):e===401?new R6(e,s,r,i):e===403?new M6(e,s,r,i):e===404?new O6(e,s,r,i):e===409?new P6(e,s,r,i):e===422?new D6(e,s,r,i):e===429?new I6(e,s,r,i):e>=500?new L6(e,s,r,i):new yr(e,s,r,i)}}class Cc extends yr{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class Vw extends yr{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}}class k6 extends Vw{constructor({message:e}={}){super({message:e??"Request timed out."})}}class T6 extends yr{}class R6 extends yr{}class M6 extends yr{}class O6 extends yr{}class P6 extends yr{}class D6 extends yr{}class I6 extends yr{}class L6 extends yr{}const Gne=/^[a-z][a-z0-9+.-]*:/i,Kne=t=>Gne.test(t);let xC=t=>(xC=Array.isArray,xC(t)),oL=xC;function Yne(t){if(!t)return!0;for(const e in t)return!1;return!0}function Xne(t,e){return Object.prototype.hasOwnProperty.call(t,e)}const Jne=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new At(`${t} must be an integer`);if(e<0)throw new At(`${t} must be a positive integer`);return e},Qne=t=>{try{return JSON.parse(t)}catch{return}},Zne=t=>new Promise(e=>setTimeout(e,t)),Yu="0.22.0";function ere(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}const tre=()=>{const t=ere();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Yu,"X-Stainless-OS":lL(Deno.build.os),"X-Stainless-Arch":aL(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Yu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(t==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Yu,"X-Stainless-OS":lL(globalThis.process.platform??"unknown"),"X-Stainless-Arch":aL(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const e=nre();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Yu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Yu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function nre(){if(typeof navigator>"u"||!navigator)return null;const t=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:e,pattern:n}of t){const r=n.exec(navigator.userAgent);if(r){const i=r[1]||0,s=r[2]||0,o=r[3]||0;return{browser:e,version:`${i}.${s}.${o}`}}}return null}const aL=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",lL=t=>(t=t.toLowerCase(),t.includes("ios")?"iOS":t==="android"?"Android":t==="darwin"?"MacOS":t==="win32"?"Windows":t==="freebsd"?"FreeBSD":t==="openbsd"?"OpenBSD":t==="linux"?"Linux":t?`Other:${t}`:"Unknown");let cL;const rre=()=>cL??(cL=tre());function ire(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Together({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function N6(...t){const e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...t)}function $6(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return N6({start(){},async pull(n){const{done:r,value:i}=await e.next();r?n.close():n.enqueue(i)},async cancel(){await e.return?.()}})}function j6(t){if(t[Symbol.asyncIterator])return t;const e=t.getReader();return{async next(){try{const n=await e.read();return n?.done&&e.releaseLock(),n}catch(n){throw e.releaseLock(),n}},async return(){const n=e.cancel();return e.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function sre(t){if(t===null||typeof t!="object")return;if(t[Symbol.asyncIterator]){await t[Symbol.asyncIterator]().return?.();return}const e=t.getReader(),n=e.cancel();e.releaseLock(),await n}const ore=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)}),B6=()=>{if(typeof File>"u"){const{process:t}=globalThis,e=typeof t?.versions?.node=="string"&&parseInt(t.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(e?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function _p(t,e,n){return B6(),new File(t,e??"unknown_file",n)}function xb(t){return(typeof t=="object"&&t!==null&&("name"in t&&t.name&&String(t.name)||"url"in t&&t.url&&String(t.url)||"filename"in t&&t.filename&&String(t.filename)||"path"in t&&t.path&&String(t.path))||"").split(/[\\/]/).pop()||void 0}const F6=t=>t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function",z6=async(t,e)=>({...t,body:await lre(t.body,e)}),uL=new WeakMap;function are(t){const e=typeof t=="function"?t:t.fetch,n=uL.get(e);if(n)return n;const r=(async()=>{try{const i="Response"in e?e.Response:(await e("data:,")).constructor,s=new FormData;return s.toString()!==await new i(s).text()}catch{return!0}})();return uL.set(e,r),r}const lre=async(t,e)=>{if(!await are(e))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");const n=new FormData;return await Promise.all(Object.entries(t||{}).map(([r,i])=>SC(n,r,i))),n},cre=t=>t instanceof Blob&&"name"in t,SC=async(t,e,n)=>{if(n!==void 0){if(n==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")t.append(e,String(n));else if(n instanceof Response)t.append(e,_p([await n.blob()],xb(n)));else if(F6(n))t.append(e,_p([await new Response($6(n)).blob()],xb(n)));else if(cre(n))t.append(e,n,xb(n));else if(Array.isArray(n))await Promise.all(n.map(r=>SC(t,e+"[]",r)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([r,i])=>SC(t,`${e}[${r}]`,i)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}},V6=t=>t!=null&&typeof t=="object"&&typeof t.size=="number"&&typeof t.type=="string"&&typeof t.text=="function"&&typeof t.slice=="function"&&typeof t.arrayBuffer=="function",ure=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&V6(t),hre=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function fre(t,e,n){if(B6(),t=await t,ure(t))return t instanceof File?t:_p([await t.arrayBuffer()],t.name);if(hre(t)){const i=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),_p(await _C(i),e,n)}const r=await _C(t);if(e||(e=xb(t)),!n?.type){const i=r.find(s=>typeof s=="object"&&"type"in s&&s.type);typeof i=="string"&&(n={...n,type:i})}return _p(r,e,n)}async function _C(t){let e=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)e.push(t);else if(V6(t))e.push(t instanceof Blob?t:await t.arrayBuffer());else if(F6(t))for await(const n of t)e.push(...await _C(n));else{const n=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${n?`; constructor: ${n}`:""}${dre(t)}`)}return e}function dre(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(n=>`"${n}"`).join(", ")}]`}class Qn{constructor(e){this._client=e}}class U6 extends Qn{create(e,n){return this._client.post("/audio/transcriptions",z6({body:e,...n},this._client))}}class H6 extends Qn{create(e,n){return this._client.post("/audio/translations",z6({body:e,...n},this._client))}}const W6=Symbol("brand.privateNullableHeaders");function*pre(t){if(!t)return;if(W6 in t){const{values:r,nulls:i}=t;yield*r.entries();for(const s of i)yield[s,null];return}let e=!1,n;t instanceof Headers?n=t.entries():oL(t)?n=t:(e=!0,n=Object.entries(t??{}));for(let r of n){const i=r[0];if(typeof i!="string")throw new TypeError("expected header name to be a string");const s=oL(r[1])?r[1]:[r[1]];let o=!1;for(const a of s)a!==void 0&&(e&&!o&&(o=!0,yield[i,null]),yield[i,a])}}const yh=t=>{const e=new Headers,n=new Set;for(const r of t){const i=new Set;for(const[s,o]of pre(r)){const a=s.toLowerCase();i.has(a)||(e.delete(s),i.add(a)),o===null?(e.delete(s),n.add(a)):(e.append(s,o),n.delete(a))}}return{[W6]:!0,values:e,nulls:n}};class Uw extends Qn{constructor(){super(...arguments),this.transcriptions=new U6(this._client),this.translations=new H6(this._client)}create(e,n){return this._client.post("/audio/speech",{body:e,...n,headers:yh([{Accept:"application/octet-stream"},n?.headers]),stream:e.stream??!1,__binaryResponse:!0})}}Uw.Transcriptions=U6;Uw.Translations=H6;function q6(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const hL=Object.freeze(Object.create(null)),mre=(t=q6)=>function(n,...r){if(n.length===1)return n[0];let i=!1;const s=[],o=n.reduce((f,d,m)=>{/[?#]/.test(d)&&(i=!0);const y=r[m];let b=(i?encodeURIComponent:t)(""+y);return m!==r.length&&(y==null||typeof y=="object"&&y.toString===Object.getPrototypeOf(Object.getPrototypeOf(y.hasOwnProperty??hL)??hL)?.toString)&&(b=y+"",s.push({start:f.length+d.length,length:b.length,error:`Value of type ${Object.prototype.toString.call(y).slice(8,-1)} is not a valid path parameter`})),f+d+(m===r.length?"":b)},""),a=o.split(/[?#]/,1)[0],c=new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)","gi");let h;for(;(h=c.exec(a))!==null;)s.push({start:h.index,length:h[0].length,error:`Value "${h[0]}" can't be safely passed as a path parameter`});if(s.sort((f,d)=>f.start-d.start),s.length>0){let f=0;const d=s.reduce((m,y)=>{const b=" ".repeat(y.start-f),w="^".repeat(y.length);return f=y.start+y.length,m+b+w},"");throw new At(`Path parameters result in path with invalid segments:
${s.map(m=>m.error).join(`
`)}
${o}
${d}`)}return o},Ki=mre(q6);class G6 extends Qn{create(e,n){return this._client.post("/batches",{body:e,...n})}retrieve(e,n){return this._client.get(Ki`/batches/${e}`,n)}list(e){return this._client.get("/batches",e)}}function fL(t){return typeof t.parse=="function"}const Cp=t=>t?.role==="assistant",K6=t=>t?.role==="function",Y6=t=>t?.role==="tool";var hr,Sb,_b,rp,ip,Cb,sp,Uo,op,Ab,Eb,Xu,CC,pv,AC,EC,kC,TC,X6,RC;const dL=10;class gre{constructor(){hr.add(this),this.controller=new AbortController,Sb.set(this,void 0),_b.set(this,()=>{}),rp.set(this,()=>{}),ip.set(this,void 0),Cb.set(this,()=>{}),sp.set(this,()=>{}),Uo.set(this,{}),this._chatCompletions=[],this.messages=[],op.set(this,!1),Ab.set(this,!1),Eb.set(this,!1),Xu.set(this,!1),TC.set(this,e=>{if(Nt(this,Ab,!0),e instanceof Error&&e.name==="AbortError"&&(e=new Cc),e instanceof Cc)return Nt(this,Eb,!0),this._emit("abort",e);if(e instanceof At)return this._emit("error",e);if(e instanceof Error){const n=new n(e.message);return n.cause=e,this._emit("error",n)}return this._emit("error",new At(String(e)))}),Nt(this,Sb,new Promise((e,n)=>{Nt(this,_b,e,"f"),Nt(this,rp,n,"f")})),Nt(this,ip,new Promise((e,n)=>{Nt(this,Cb,e,"f"),Nt(this,sp,n,"f")})),Ae(this,Sb,"f").catch(()=>{}),Ae(this,ip,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},Ae(this,TC,"f"))},0)}_addChatCompletion(e){this._chatCompletions.push(e),this._emit("chatCompletion",e);const n=e.choices[0]?.message;return n&&this._addMessage(n),e}_addMessage(e,n=!0){if("content"in e||(e.content=null),this.messages.push(e),n){if(this._emit("message",e),(K6(e)||Y6(e))&&e.content)this._emit("functionCallResult",e.content);else if(Cp(e)&&e.function_call)this._emit("functionCall",e.function_call);else if(Cp(e)&&e.tool_calls)for(const r of e.tool_calls)r.type==="function"&&this._emit("functionCall",r.function)}}_connected(){this.ended||(Ae(this,_b,"f").call(this),this._emit("connect"))}get ended(){return Ae(this,op,"f")}get errored(){return Ae(this,Ab,"f")}get aborted(){return Ae(this,Eb,"f")}abort(){this.controller.abort()}on(e,n){return(Ae(this,Uo,"f")[e]||(Ae(this,Uo,"f")[e]=[])).push({listener:n}),this}off(e,n){const r=Ae(this,Uo,"f")[e];if(!r)return this;const i=r.findIndex(s=>s.listener===n);return i>=0&&r.splice(i,1),this}once(e,n){return(Ae(this,Uo,"f")[e]||(Ae(this,Uo,"f")[e]=[])).push({listener:n,once:!0}),this}emitted(e){return new Promise((n,r)=>{Nt(this,Xu,!0),e!=="error"&&this.once("error",r),this.once(e,n)})}async done(){Nt(this,Xu,!0),await Ae(this,ip,"f")}async finalChatCompletion(){await this.done();const e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new At("stream ended without producing a ChatCompletion");return e}async finalContent(){return await this.done(),Ae(this,hr,"m",CC).call(this)}async finalMessage(){return await this.done(),Ae(this,hr,"m",pv).call(this)}async finalFunctionCall(){return await this.done(),Ae(this,hr,"m",AC).call(this)}async finalFunctionCallResult(){return await this.done(),Ae(this,hr,"m",EC).call(this)}async totalUsage(){return await this.done(),Ae(this,hr,"m",kC).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emit(e,...n){if(Ae(this,op,"f"))return;e==="end"&&(Nt(this,op,!0),Ae(this,Cb,"f").call(this));const r=Ae(this,Uo,"f")[e];if(r&&(Ae(this,Uo,"f")[e]=r.filter(i=>!i.once),r.forEach(({listener:i})=>i(...n))),e==="abort"){const i=n[0];!Ae(this,Xu,"f")&&!r?.length&&Promise.reject(i),Ae(this,rp,"f").call(this,i),Ae(this,sp,"f").call(this,i),this._emit("end");return}if(e==="error"){const i=n[0];!Ae(this,Xu,"f")&&!r?.length&&Promise.reject(i),Ae(this,rp,"f").call(this,i),Ae(this,sp,"f").call(this,i),this._emit("end")}}_emitFinal(){const e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit("finalChatCompletion",e);const n=Ae(this,hr,"m",pv).call(this);n&&this._emit("finalMessage",n);const r=Ae(this,hr,"m",CC).call(this);r&&this._emit("finalContent",r);const i=Ae(this,hr,"m",AC).call(this);i&&this._emit("finalFunctionCall",i);const s=Ae(this,hr,"m",EC).call(this);s!=null&&this._emit("finalFunctionCallResult",s),this._chatCompletions.some(o=>o.usage)&&this._emit("totalUsage",Ae(this,hr,"m",kC).call(this))}async _createChatCompletion(e,n,r){const i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),Ae(this,hr,"m",X6).call(this,n);const s=await e.create({...n,stream:!1},{...r,signal:this.controller.signal});return this._connected(),this._addChatCompletion(s)}async _runChatCompletion(e,n,r){for(const i of n.messages)this._addMessage(i,!1);return await this._createChatCompletion(e,n,r)}async _runFunctions(e,n,r){const i="function",{function_call:s="auto",stream:o,...a}=n,c=typeof s!="string"&&s?.name,{maxChatCompletions:h=dL}=r||{},f={};for(const m of n.functions)f[m.name||m.function.name]=m;const d=n.functions.map(m=>({name:m.name||m.function.name,parameters:m.parameters,description:m.description}));for(const m of n.messages)this._addMessage(m,!1);for(let m=0;m<h;++m){const b=(await this._createChatCompletion(e,{...a,function_call:s,functions:d,messages:[...this.messages]},r)).choices[0]?.message;if(!b)throw new At("missing message in ChatCompletion response");if(!b.function_call)return;const{name:w,arguments:S}=b.function_call,_=f[w];if(_){if(c&&c!==w){const O=`Invalid function_call: ${JSON.stringify(w)}. ${JSON.stringify(c)} requested. Please try again`;this._addMessage({role:i,name:w,content:O});continue}}else{const O=`Invalid function_call: ${JSON.stringify(w)}. Available options are: ${d.map(M=>JSON.stringify(M.name)).join(", ")}. Please try again`;this._addMessage({role:i,name:w,content:O});continue}let A;try{A=fL(_)?await _.parse(S):S}catch(O){this._addMessage({role:i,name:w,content:O instanceof Error?O.message:String(O)});continue}const E=await _.function(A,this),P=Ae(this,hr,"m",RC).call(this,E);if(this._addMessage({role:i,name:w,content:P}),c)return}}async _runTools(e,n,r){const i="tool",{tool_choice:s="auto",stream:o,...a}=n,c=typeof s!="string"&&s?.function?.name,{maxChatCompletions:h=dL}=r||{},f={};for(const m of n.tools)m.type==="function"&&(f[m.function.name||m.function.function.name]=m.function);const d="tools"in n?n.tools.map(m=>m.type==="function"?{type:"function",function:{name:m.function.name||m.function.function.name,parameters:m.function.parameters,description:m.function.description}}:m):void 0;for(const m of n.messages)this._addMessage(m,!1);for(let m=0;m<h;++m){const b=(await this._createChatCompletion(e,{...a,tool_choice:s,tools:d,messages:[...this.messages]},r)).choices[0]?.message;if(!b)throw new At("missing message in ChatCompletion response");if(!b.tool_calls)return;for(const w of b.tool_calls){if(w.type!=="function")continue;const S=w.id,{name:_,arguments:A}=w.function,E=f[_];if(E){if(c&&c!==_){const D=`Invalid tool_call: ${JSON.stringify(_)}. ${JSON.stringify(c)} requested. Please try again`;this._addMessage({role:i,tool_call_id:S,content:D});continue}}else{const D=`Invalid tool_call: ${JSON.stringify(_)}. Available options are: ${d.map($=>JSON.stringify($.function.name)).join(", ")}. Please try again`;this._addMessage({role:i,tool_call_id:S,content:D});continue}let P;try{P=fL(E)?await E.parse(A):A}catch(D){const $=D instanceof Error?D.message:String(D);this._addMessage({role:i,tool_call_id:S,content:$});continue}const O=await E.function(P,this),M=Ae(this,hr,"m",RC).call(this,O);if(this._addMessage({role:i,tool_call_id:S,content:M}),c)return}}}}Sb=new WeakMap,_b=new WeakMap,rp=new WeakMap,ip=new WeakMap,Cb=new WeakMap,sp=new WeakMap,Uo=new WeakMap,op=new WeakMap,Ab=new WeakMap,Eb=new WeakMap,Xu=new WeakMap,TC=new WeakMap,hr=new WeakSet,CC=function(){return Ae(this,hr,"m",pv).call(this).content??null},pv=function(){let e=this.messages.length;for(;e-- >0;){const n=this.messages[e];if(Cp(n))return{...n,content:n.content??null}}throw new At("stream ended without producing a ChatCompletionMessage with role=assistant")},AC=function(){for(let e=this.messages.length-1;e>=0;e--){const n=this.messages[e];if(Cp(n)&&n?.function_call)return n.function_call;if(Cp(n)&&n?.tool_calls?.length)return n.tool_calls.at(-1)?.function}},EC=function(){for(let e=this.messages.length-1;e>=0;e--){const n=this.messages[e];if(K6(n)&&n.content!=null||Y6(n)&&n.content!=null&&this.messages.some(r=>r.role==="assistant"&&r.tool_calls?.some(i=>i.type==="function"&&i.id===n.tool_call_id)))return n.content}},kC=function(){const e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(const{usage:n}of this._chatCompletions)n&&(e.completion_tokens+=n.completion_tokens,e.prompt_tokens+=n.prompt_tokens,e.total_tokens+=n.total_tokens);return e},X6=function(e){if(e.n!=null&&e.n>1)throw new At("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},RC=function(e){return typeof e=="string"?e:e===void 0?"undefined":JSON.stringify(e)};function yre(t){let e=0;for(const i of t)e+=i.length;const n=new Uint8Array(e);let r=0;for(const i of t)n.set(i,r),r+=i.length;return n}let pL;function Rk(t){let e;return(pL??(e=new globalThis.TextEncoder,pL=e.encode.bind(e)))(t)}let mL;function gL(t){let e;return(mL??(e=new globalThis.TextDecoder,mL=e.decode.bind(e)))(t)}var vi,wi;class Hw{constructor(){vi.set(this,void 0),wi.set(this,void 0),Nt(this,vi,new Uint8Array),Nt(this,wi,null)}decode(e){if(e==null)return[];const n=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?Rk(e):e;Nt(this,vi,yre([Ae(this,vi,"f"),n]));const r=[];let i;for(;(i=bre(Ae(this,vi,"f"),Ae(this,wi,"f")))!=null;){if(i.carriage&&Ae(this,wi,"f")==null){Nt(this,wi,i.index);continue}if(Ae(this,wi,"f")!=null&&(i.index!==Ae(this,wi,"f")+1||i.carriage)){r.push(gL(Ae(this,vi,"f").subarray(0,Ae(this,wi,"f")-1))),Nt(this,vi,Ae(this,vi,"f").subarray(Ae(this,wi,"f"))),Nt(this,wi,null);continue}const s=Ae(this,wi,"f")!==null?i.preceding-1:i.preceding,o=gL(Ae(this,vi,"f").subarray(0,s));r.push(o),Nt(this,vi,Ae(this,vi,"f").subarray(i.index)),Nt(this,wi,null)}return r}flush(){return Ae(this,vi,"f").length?this.decode(`
`):[]}}vi=new WeakMap,wi=new WeakMap;Hw.NEWLINE_CHARS=new Set([`
`,"\r"]);Hw.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function bre(t,e){for(let i=e??0;i<t.length;i++){if(t[i]===10)return{preceding:i,index:i+1,carriage:!1};if(t[i]===13)return{preceding:i,index:i+1,carriage:!0}}return null}function vre(t){for(let r=0;r<t.length-1;r++){if(t[r]===10&&t[r+1]===10||t[r]===13&&t[r+1]===13)return r+2;if(t[r]===13&&t[r+1]===10&&r+3<t.length&&t[r+2]===13&&t[r+3]===10)return r+4}return-1}const mv={off:0,error:200,warn:300,info:400,debug:500},yL=(t,e,n)=>{if(t){if(Xne(mv,t))return t;Tr(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(mv))}`)}};function ap(){}function cy(t,e,n){return!e||mv[t]>mv[n]?ap:e[t].bind(e)}const wre={error:ap,warn:ap,info:ap,debug:ap};let bL=new WeakMap;function Tr(t){const e=t.logger,n=t.logLevel??"off";if(!e)return wre;const r=bL.get(e);if(r&&r[0]===n)return r[1];const i={error:cy("error",e,n),warn:cy("warn",e,n),info:cy("info",e,n),debug:cy("debug",e,n)};return bL.set(e,[n,i]),i}const tc=t=>(t.options&&(t.options={...t.options},delete t.options.headers),t.headers&&(t.headers=Object.fromEntries((t.headers instanceof Headers?[...t.headers]:Object.entries(t.headers)).map(([e,n])=>[e,e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in t&&(t.retryOfRequestLogID&&(t.retryOf=t.retryOfRequestLogID),delete t.retryOfRequestLogID),t);var Td;class tl{constructor(e,n,r){this.iterator=e,Td.set(this,void 0),this.controller=n,Nt(this,Td,r)}static fromSSEResponse(e,n,r){let i=!1;const s=r?Tr(r):console;async function*o(){if(i)throw new At("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let a=!1;try{for await(const c of xre(e,n))if(!a){if(c.data.startsWith("[DONE]")){a=!0;continue}if(c.event===null){let h;try{h=JSON.parse(c.data)}catch(f){throw s.error("Could not parse message into JSON:",c.data),s.error("From chunk:",c.raw),f}if(h&&h.error)throw new yr(void 0,h.error,void 0,e.headers);yield h}}a=!0}catch(c){if(vC(c))return;throw c}finally{a||n.abort()}}return new tl(o,n,r)}static fromReadableStream(e,n,r){let i=!1;async function*s(){const a=new Hw,c=j6(e);for await(const h of c)for(const f of a.decode(h))yield f;for(const h of a.flush())yield h}async function*o(){if(i)throw new At("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let a=!1;try{for await(const c of s())a||c&&(yield JSON.parse(c));a=!0}catch(c){if(vC(c))return;throw c}finally{a||n.abort()}}return new tl(o,n,r)}[(Td=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){const e=[],n=[],r=this.iterator(),i=s=>({next:()=>{if(s.length===0){const o=r.next();e.push(o),n.push(o)}return s.shift()}});return[new tl(()=>i(e),this.controller,Ae(this,Td,"f")),new tl(()=>i(n),this.controller,Ae(this,Td,"f"))]}toReadableStream(){const e=this;let n;return N6({async start(){n=e[Symbol.asyncIterator]()},async pull(r){try{const{value:i,done:s}=await n.next();if(s)return r.close();const o=Rk(JSON.stringify(i)+`
`);r.enqueue(o)}catch(i){r.error(i)}},async cancel(){await n.return?.()}})}}async function*xre(t,e){if(!t.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new At("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new At("Attempted to iterate over a response with no body");const n=new _re,r=new Hw,i=j6(t.body);for await(const s of Sre(i))for(const o of r.decode(s)){const a=n.decode(o);a&&(yield a)}for(const s of r.flush()){const o=n.decode(s);o&&(yield o)}}async function*Sre(t){let e=new Uint8Array;for await(const n of t){if(n==null)continue;const r=n instanceof ArrayBuffer?new Uint8Array(n):typeof n=="string"?Rk(n):n;let i=new Uint8Array(e.length+r.length);i.set(e),i.set(r,e.length),e=i;let s;for(;(s=vre(e))!==-1;)yield e.slice(0,s),e=e.slice(s)}e.length>0&&(yield e)}class _re{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const s={event:this.event,data:this.data.join(`
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],s}if(this.chunks.push(e),e.startsWith(":"))return null;let[n,r,i]=Cre(e,":");return i.startsWith(" ")&&(i=i.substring(1)),n==="event"?this.event=i:n==="data"&&this.data.push(i),null}}function Cre(t,e){const n=t.indexOf(e);return n!==-1?[t.substring(0,n),e,t.substring(n+e.length)]:[t,"",""]}var Us,Wa,p_,m_,uy,vL;class gv extends gre{constructor(){super(...arguments),Us.add(this),Wa.set(this,void 0)}get currentChatCompletionSnapshot(){return Ae(this,Wa,"f")}static fromReadableStream(e){const n=new gv;return n._run(()=>n._fromReadableStream(e)),n}static createChatCompletion(e,n,r){const i=new gv;return i._run(()=>i._runChatCompletion(e,{...n,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createChatCompletion(e,n,r){const i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),Ae(this,Us,"m",p_).call(this);const s=await e.create({...n,stream:!0},{...r,signal:this.controller.signal});this._connected();for await(const o of s)Ae(this,Us,"m",m_).call(this,o);if(s.controller.signal?.aborted)throw new Cc;return this._addChatCompletion(Ae(this,Us,"m",uy).call(this))}async _fromReadableStream(e,n){const r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),Ae(this,Us,"m",p_).call(this),this._connected();const i=tl.fromReadableStream(e,this.controller);let s;for await(const o of i)s&&s!==o.id&&this._addChatCompletion(Ae(this,Us,"m",uy).call(this)),Ae(this,Us,"m",m_).call(this,o),s=o.id;if(i.controller.signal?.aborted)throw new Cc;return this._addChatCompletion(Ae(this,Us,"m",uy).call(this))}[(Wa=new WeakMap,Us=new WeakSet,p_=function(){this.ended||Nt(this,Wa,void 0)},m_=function(n){if(this.ended)return;const r=Ae(this,Us,"m",vL).call(this,n);this._emit("chunk",n,r);const i=n.choices[0]?.delta?.content,s=r.choices[0]?.message;i!=null&&s?.role==="assistant"&&s?.content&&this._emit("content",i,s.content)},uy=function(){if(this.ended)throw new At("stream has ended, this shouldn't happen");const n=Ae(this,Wa,"f");if(!n)throw new At("request ended without sending any chunks");return Nt(this,Wa,void 0),Are(n)},vL=function(n){var r,i,s,o,a;let c=Ae(this,Wa,"f");const{choices:h,...f}=n;c?Object.assign(c,f):c=Nt(this,Wa,{...f,choices:[]});for(const{delta:d,finish_reason:m,index:y,logprobs:b=null,...w}of n.choices){let S=c.choices[y];if(S||(S=c.choices[y]={finish_reason:m,index:y,message:{},logprobs:{token_ids:[],token_logprobs:[],tokens:[]},...w}),b&&(console.log({logprobs:b}),S.logprobs||(S.logprobs={token_ids:[],token_logprobs:[],tokens:[]}),(r=S.logprobs).token_ids??(r.token_ids=[]),S.logprobs.token_ids.push(d.token_id??null),(i=S.logprobs).token_logprobs??(i.token_logprobs=[]),S.logprobs.token_logprobs.push(b??null),(s=S.logprobs).tokens??(s.tokens=[]),S.logprobs.tokens.push(d.content??null)),m&&(S.finish_reason=m),Object.assign(S,w),!d)continue;const{content:_,function_call:A,role:E,tool_calls:P,...O}=d;if(Object.assign(S.message,O),_&&(S.message.content=(S.message.content||"")+_),E&&(S.message.role=E),A&&(S.message.function_call?(A.name&&(S.message.function_call.name=A.name),A.arguments&&((o=S.message.function_call).arguments??(o.arguments=""),S.message.function_call.arguments+=A.arguments)):S.message.function_call=A),P){S.message.tool_calls||(S.message.tool_calls=[]);for(const{index:M,id:D,type:$,function:F,...N}of P){const U=(a=S.message.tool_calls)[M]??(a[M]={});Object.assign(U,N),D&&(U.id=D),$&&(U.type=$),F&&(U.function??(U.function={arguments:""})),F?.name&&(U.function.name=F.name),F?.arguments&&(U.function.arguments+=F.arguments)}}}return c},Symbol.asyncIterator)](){const e=[],n=[];let r=!1;return this.on("chunk",i=>{const s=n.shift();s?s.resolve(i):e.push(i)}),this.on("end",()=>{r=!0;for(const i of n)i.resolve(void 0);n.length=0}),this.on("abort",i=>{r=!0;for(const s of n)s.reject(i);n.length=0}),this.on("error",i=>{r=!0;for(const s of n)s.reject(i);n.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((s,o)=>n.push({resolve:s,reject:o})).then(s=>s?{value:s,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new tl(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function Are(t){const{id:e,choices:n,created:r,model:i,system_fingerprint:s,...o}=t;return{...o,id:e,choices:n.map(({message:a,finish_reason:c,index:h,logprobs:f,...d})=>{if(!c)throw new At(`missing finish_reason for choice ${h}`);const{content:m=null,function_call:y,tool_calls:b,...w}=a,S=a.role;if(!S)throw new At(`missing role for choice ${h}`);if(y){const{arguments:_,name:A}=y;if(_==null)throw new At(`missing function_call.arguments for choice ${h}`);if(!A)throw new At(`missing function_call.name for choice ${h}`);return{...d,message:{content:m,function_call:{arguments:_,name:A},role:S},finish_reason:c,index:h,logprobs:f}}return b?{...d,index:h,finish_reason:c,logprobs:f,message:{...w,role:S,content:m,tool_calls:b.map((_,A)=>{const{function:E,type:P,id:O,...M}=_,{arguments:D,name:$,...F}=E||{};if(O==null)throw new At(`missing choices[${h}].tool_calls[${A}].id
${hy(t)}`);if(P==null)throw new At(`missing choices[${h}].tool_calls[${A}].type
${hy(t)}`);if($==null)throw new At(`missing choices[${h}].tool_calls[${A}].function.name
${hy(t)}`);if(D==null)throw new At(`missing choices[${h}].tool_calls[${A}].function.arguments
${hy(t)}`);return{...M,id:O,type:P,function:{...F,name:$,arguments:D}}})}}:{...d,message:{...w,content:m,role:S},finish_reason:c,index:h,logprobs:f}}),created:r,model:i,object:"chat.completion",...s?{system_fingerprint:s}:{}}}function hy(t){return JSON.stringify(t)}let J6=class extends Qn{create(e,n){return this._client.post("/chat/completions",{body:e,...n,stream:e.stream??!1})}stream(e,n){return gv.createChatCompletion(this._client.chat.completions,e,n)}};class Mk extends Qn{constructor(){super(...arguments),this.completions=new J6(this._client)}}Mk.Completions=J6;class Q6 extends Qn{list(e){return this._client.get("/tci/sessions",e)}}class Ok extends Qn{constructor(){super(...arguments),this.sessions=new Q6(this._client)}execute(e,n){return this._client.post("/tci/execute",{body:e,...n})}}Ok.Sessions=Q6;class Z6 extends Qn{create(e,n){return this._client.post("/completions",{body:e,...n,stream:e.stream??!1})}}class e9 extends Qn{create(e,n){return this._client.post("/embeddings",{body:e,...n})}}class t9 extends Qn{create(e,n){return this._client.post("/endpoints",{body:e,...n})}retrieve(e,n){return this._client.get(Ki`/endpoints/${e}`,n)}update(e,n,r){return this._client.patch(Ki`/endpoints/${e}`,{body:n,...r})}list(e={},n){return this._client.get("/endpoints",{query:e,...n})}delete(e,n){return this._client.delete(Ki`/endpoints/${e}`,{...n,headers:yh([{Accept:"*/*"},n?.headers])})}}class n9 extends Qn{retrieve(e,n){return this._client.get(Ki`/files/${e}`,n)}list(e){return this._client.get("/files",e)}delete(e,n){return this._client.delete(Ki`/files/${e}`,n)}content(e,n){return this._client.get(Ki`/files/${e}/content`,{...n,headers:yh([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}upload(e){throw"please use together-ai/lib/upload"}}class r9 extends Qn{create(e,n){return this._client.post("/fine-tunes",{body:e,...n})}retrieve(e,n){return this._client.get(Ki`/fine-tunes/${e}`,n)}list(e){return this._client.get("/fine-tunes",e)}cancel(e,n){return this._client.post(Ki`/fine-tunes/${e}/cancel`,n)}download(e,n){return this._client.get("/finetune/download",{query:e,...n})}listEvents(e,n){return this._client.get(Ki`/fine-tunes/${e}/events`,n)}retrieveCheckpoints(e,n){return this._client.get(Ki`/fine-tunes/${e}/checkpoints`,n)}}class i9 extends Qn{list(e={},n){return this._client.get("/hardware",{query:e,...n})}}class s9 extends Qn{create(e,n){return this._client.post("/images/generations",{body:e,...n})}}class o9 extends Qn{retrieve(e,n){return this._client.get(Ki`/jobs/${e}`,n)}list(e){return this._client.get("/jobs",e)}}class a9 extends Qn{list(e){return this._client.get("/models",e)}upload(e,n){return this._client.post("/models",{body:e,...n})}}async function Ere(t,e){const{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:s}=e,o=await(async()=>{if(e.options.stream)return Tr(t).debug("response",n.status,n.url,n.headers,n.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(n,e.controller,t):tl.fromSSEResponse(n,e.controller,t);if(n.status===204)return null;if(e.options.__binaryResponse)return n;const c=n.headers.get("content-type")?.split(";")[0]?.trim();return c?.includes("application/json")||c?.endsWith("+json")?await n.json():await n.text()})();return Tr(t).debug(`[${r}] response parsed`,tc({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-s})),o}var lp;class Pk extends Promise{constructor(e,n,r=Ere){super(i=>{i(null)}),this.responsePromise=n,this.parseResponse=r,lp.set(this,void 0),Nt(this,lp,e)}_thenUnwrap(e){return new Pk(Ae(this,lp,"f"),this.responsePromise,async(n,r)=>e(await this.parseResponse(n,r),r))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){const[e,n]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:n}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(Ae(this,lp,"f"),e))),this.parsedPromise}then(e,n){return this.parse().then(e,n)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}lp=new WeakMap;var kre={};const g_=t=>{if(typeof globalThis.process<"u")return kre?.[t]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(t)?.trim()};var MC,Dk,kb,l9;class pt{constructor({baseURL:e=g_("TOGETHER_BASE_URL"),apiKey:n=g_("TOGETHER_API_KEY"),...r}={}){if(MC.add(this),kb.set(this,void 0),this.chat=new Mk(this),this.completions=new Z6(this),this.embeddings=new e9(this),this.files=new n9(this),this.fineTune=new r9(this),this.codeInterpreter=new Ok(this),this.images=new s9(this),this.audio=new Uw(this),this.models=new a9(this),this.jobs=new o9(this),this.endpoints=new t9(this),this.hardware=new i9(this),this.batches=new G6(this),n===void 0)throw new At("The TOGETHER_API_KEY environment variable is missing or empty; either provide it, or instantiate the Together client with an apiKey option, like new Together({ apiKey: 'My API Key' }).");const i={apiKey:n,...r,baseURL:e||"https://api.together.xyz/v1"};this.baseURL=i.baseURL,this.timeout=i.timeout??Dk.DEFAULT_TIMEOUT,this.logger=i.logger??console;const s="warn";this.logLevel=s,this.logLevel=yL(i.logLevel,"ClientOptions.logLevel",this)??yL(g_("TOGETHER_LOG"),"process.env['TOGETHER_LOG']",this)??s,this.fetchOptions=i.fetchOptions,this.maxRetries=i.maxRetries??5,this.fetch=i.fetch??ire(),Nt(this,kb,ore),this._options=i,this.apiKey=n}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,...e})}rerank(e,n){return this.post("/rerank",{body:e,...n})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:n}){}async authHeaders(e){return yh([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return Object.entries(e).filter(([n,r])=>typeof r<"u").map(([n,r])=>{if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return`${encodeURIComponent(n)}=${encodeURIComponent(r)}`;if(r===null)return`${encodeURIComponent(n)}=`;throw new At(`Cannot stringify type ${typeof r}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${Yu}`}defaultIdempotencyKey(){return`stainless-node-retry-${E6()}`}makeStatusError(e,n,r,i){return yr.generate(e,n,r,i)}buildURL(e,n,r){const i=!Ae(this,MC,"m",l9).call(this)&&r||this.baseURL,s=Kne(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();return Yne(o)||(n={...o,...n}),typeof n=="object"&&n&&!Array.isArray(n)&&(s.search=this.stringifyQuery(n)),s.toString()}async prepareOptions(e){}async prepareRequest(e,{url:n,options:r}){}get(e,n){return this.methodRequest("get",e,n)}post(e,n){return this.methodRequest("post",e,n)}patch(e,n){return this.methodRequest("patch",e,n)}put(e,n){return this.methodRequest("put",e,n)}delete(e,n){return this.methodRequest("delete",e,n)}methodRequest(e,n,r){return this.request(Promise.resolve(r).then(i=>({method:e,path:n,...i})))}request(e,n=null){return new Pk(this,this.makeRequest(e,n,void 0))}async makeRequest(e,n,r){const i=await e,s=i.maxRetries??this.maxRetries;n==null&&(n=s),await this.prepareOptions(i);const{req:o,url:a,timeout:c}=await this.buildRequest(i,{retryCount:s-n});await this.prepareRequest(o,{url:a,options:i});const h="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),f=r===void 0?"":`, retryOf: ${r}`,d=Date.now();if(Tr(this).debug(`[${h}] sending request`,tc({retryOfRequestLogID:r,method:i.method,url:a,options:i,headers:o.headers})),i.signal?.aborted)throw new Cc;const m=new AbortController,y=await this.fetchWithTimeout(a,o,c,m).catch(wC),b=Date.now();if(y instanceof Error){const S=`retrying, ${n} attempts remaining`;if(i.signal?.aborted)throw new Cc;const _=vC(y)||/timed? ?out/i.test(String(y)+("cause"in y?String(y.cause):""));if(n)return Tr(this).info(`[${h}] connection ${_?"timed out":"failed"} - ${S}`),Tr(this).debug(`[${h}] connection ${_?"timed out":"failed"} (${S})`,tc({retryOfRequestLogID:r,url:a,durationMs:b-d,message:y.message})),this.retryRequest(i,n,r??h);throw Tr(this).info(`[${h}] connection ${_?"timed out":"failed"} - error; no more retries left`),Tr(this).debug(`[${h}] connection ${_?"timed out":"failed"} (error; no more retries left)`,tc({retryOfRequestLogID:r,url:a,durationMs:b-d,message:y.message})),_?new k6:new Vw({cause:y})}const w=`[${h}${f}] ${o.method} ${a} ${y.ok?"succeeded":"failed"} with status ${y.status} in ${b-d}ms`;if(!y.ok){const S=await this.shouldRetry(y);if(n&&S){const M=`retrying, ${n} attempts remaining`;return await sre(y.body),Tr(this).info(`${w} - ${M}`),Tr(this).debug(`[${h}] response error (${M})`,tc({retryOfRequestLogID:r,url:y.url,status:y.status,headers:y.headers,durationMs:b-d})),this.retryRequest(i,n,r??h,y.headers)}const _=S?"error; no more retries left":"error; not retryable";Tr(this).info(`${w} - ${_}`);const A=await y.text().catch(M=>wC(M).message),E=Qne(A),P=E?void 0:A;throw Tr(this).debug(`[${h}] response error (${_})`,tc({retryOfRequestLogID:r,url:y.url,status:y.status,headers:y.headers,message:P,durationMs:Date.now()-d})),this.makeStatusError(y.status,E,P,y.headers)}return Tr(this).info(w),Tr(this).debug(`[${h}] response start`,tc({retryOfRequestLogID:r,url:y.url,status:y.status,headers:y.headers,durationMs:b-d})),{response:y,options:i,controller:m,requestLogID:h,retryOfRequestLogID:r,startTime:d}}async fetchWithTimeout(e,n,r,i){const{signal:s,method:o,...a}=n||{};s&&s.addEventListener("abort",()=>i.abort());const c=setTimeout(()=>i.abort(),r),h=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,f={signal:i.signal,...h?{duplex:"half"}:{},method:"GET",...a};o&&(f.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,f)}finally{clearTimeout(c)}}async shouldRetry(e){const n=e.headers.get("x-should-retry");return n==="true"?!0:n==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,n,r,i){let s;const o=i?.get("retry-after-ms");if(o){const c=parseFloat(o);Number.isNaN(c)||(s=c)}const a=i?.get("retry-after");if(a&&!s){const c=parseFloat(a);Number.isNaN(c)?s=Date.parse(a)-Date.now():s=c*1e3}if(!(s&&0<=s&&s<60*1e3)){const c=e.maxRetries??this.maxRetries;s=this.calculateDefaultRetryTimeoutMillis(n,c)}return await Zne(s),this.makeRequest(e,n-1,r)}calculateDefaultRetryTimeoutMillis(e,n){const s=n-e,o=Math.min(1*Math.pow(2,s),10),a=1-Math.random()*.25;return o*a*1e3}async buildRequest(e,{retryCount:n=0}={}){const r={...e},{method:i,path:s,query:o,defaultBaseURL:a}=r,c=this.buildURL(s,o,a);"timeout"in r&&Jne("timeout",r.timeout),r.timeout=r.timeout??this.timeout;const{bodyHeaders:h,body:f}=this.buildBody({options:r}),d=await this.buildHeaders({options:e,method:i,bodyHeaders:h,retryCount:n});return{req:{method:i,headers:d,...r.signal&&{signal:r.signal},...globalThis.ReadableStream&&f instanceof globalThis.ReadableStream&&{duplex:"half"},...f&&{body:f},...this.fetchOptions??{},...r.fetchOptions??{}},url:c,timeout:r.timeout}}async buildHeaders({options:e,method:n,bodyHeaders:r,retryCount:i}){let s={};this.idempotencyHeader&&n!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=e.idempotencyKey);const o=yh([s,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...rre()},await this.authHeaders(e),this._options.defaultHeaders,r,e.headers]);return this.validateHeaders(o),o.values}buildBody({options:{body:e,headers:n}}){if(!e)return{bodyHeaders:void 0,body:void 0};const r=yh([n]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&r.values.has("content-type")||e instanceof Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:$6(e)}:Ae(this,kb,"f").call(this,{body:e,headers:r})}}Dk=pt,kb=new WeakMap,MC=new WeakSet,l9=function(){return this.baseURL!=="https://api.together.xyz/v1"};pt.Together=Dk;pt.DEFAULT_TIMEOUT=6e4;pt.TogetherError=At;pt.APIError=yr;pt.APIConnectionError=Vw;pt.APIConnectionTimeoutError=k6;pt.APIUserAbortError=Cc;pt.NotFoundError=O6;pt.ConflictError=P6;pt.RateLimitError=I6;pt.BadRequestError=T6;pt.AuthenticationError=R6;pt.InternalServerError=L6;pt.PermissionDeniedError=M6;pt.UnprocessableEntityError=D6;pt.toFile=fre;pt.Chat=Mk;pt.Completions=Z6;pt.Embeddings=e9;pt.Files=n9;pt.FineTuneResource=r9;pt.CodeInterpreter=Ok;pt.Images=s9;pt.Audio=Uw;pt.Models=a9;pt.Jobs=o9;pt.Endpoints=t9;pt.Hardware=i9;pt.Batches=G6;const Tre=t=>{const e=[];return t.forEach(n=>{e.push({type:"function",function:{name:n.name,description:n.description,parameters:{type:"object",...n.inputSchema}}})}),e},fy=t=>{const e=[];return t.forEach(n=>{if(n.role==="user"||n.role==="system"){const r=typeof n.content=="string"?n.content:n.content.map(i=>{if(i.type==="text")return i.text;if(i.type==="file"){const s=JSON.parse(i.mimeType).path;return`File: ${s.includes("\\")?s.split("\\").pop():s.split("/").pop()}
File content:
${i.data}`}return""}).filter(i=>i!=="").join(`
`);e.push({role:"user",content:r})}else{let r=typeof n.content=="string"?n.content:"";const i=[],s=[];let o=0;const a=n.content;typeof a!="string"&&a.forEach(h=>{if(h.type==="text"&&(r+=h.text),h.type==="tool-call"){h.result&&i.push({role:"tool",content:h.result,tool_call_id:h.toolCallId}),s.push({id:h.toolCallId,index:o++,type:"function",function:{arguments:h.argsText??"",name:h.toolName}});return}});const c={role:"assistant",content:r};s.length&&(c.tool_calls=s),e.push(c),i.length&&e.push(...i)}}),e},Rre=(t,e,n)=>{if(!e.delta.content)return t;let r=Jr(t);const i=r.content;if(typeof i=="string")return r;const s=i[i.length-1];if((!s||n)&&typeof t.content!="string"&&(r={...r,content:[...i,{type:"text",text:e.delta.content}]}),s&&typeof s!="string"&&typeof i!="string"&&s.type==="text"){const o=s.text+e.delta.content,a=Jr({...s,text:o});r={...r,content:[...i.slice(0,-1),a]}}return r},Mre=(t,e)=>{let n=Jr(t);if(!e.delta.tool_calls||typeof n.content=="string")return n;const r=e.delta.tool_calls[0],i=n.content[n.content.length-1];if(!i||i?.type!=="tool-call"){const s={type:"tool-call",args:{},argsText:r?.function?.arguments??"",toolName:r?.function?.name??"",toolCallId:r?.id??""};n={...n,content:[...n.content,s]}}else{const s=i,o=s.argsText+(r?.function?.arguments??""),a=s.toolName||r?.function?.name||"",c=s.toolCallId||r?.id||"";let h={};try{h=JSON.parse(o??"{}")}catch{}const f={...s,args:h,argsText:o,toolName:a,toolCallId:c};n={...n,content:[...n.content.slice(0,-1),f]}}return n};class Ore{modelKey="";systemPrompt="";apiKey;url;provider;prevMessages=[];tools=[];client;stopStream=!1;constructor(){}setProvider=e=>{this.provider=e,this.client=new pt({apiKey:e.key,baseURL:e.baseUrl}),e.key&&this.setApiKey(e.key),e.baseUrl&&this.setUrl(e.baseUrl)};setModelKey=e=>{this.modelKey=e};setSystemPrompt=e=>{this.systemPrompt=e};setApiKey=e=>{this.apiKey=e,this.client&&(this.client.apiKey=e)};setUrl=e=>{this.url=e,this.client&&(this.client.baseURL=e)};setPrevMessages=e=>{this.prevMessages=fy(e)};setTools=e=>{this.tools=Tre(e)};async createChatName(e){try{if(!this.client)return"";const n={role:"system",content:$m};return(await this.client.chat.completions.create({messages:[n,{role:"user",content:e}],model:this.modelKey,stream:!1})).choices[0].message?.content??e.substring(0,25)}catch{return""}}async*sendMessage(e,n,r){try{if(!this.client)return;const i=fy(e),s={role:"system",content:this.systemPrompt},o=await this.client.chat.completions.create({messages:[s,...this.prevMessages,...i],model:this.modelKey,tools:this.tools,stream:!0});this.prevMessages.push(...i);let a=n&&r?Jr(r):{role:"assistant",content:[]},c=!1;for await(const h of o)if(h.choices.forEach(d=>{if(!c){if(d.finish_reason){c=!0;const m=n?{...a,content:typeof a.content=="string"?a.content:a.content.filter((b,w)=>{if(b.type==="tool-call")return!0;const S=r?.content.length??0;return w>=S})}:a,y=fy([m]);this.prevMessages.push(...y);return}d.delta.content&&(a=Rre(a,d,n)),d.delta.tool_calls&&typeof a.content!="string"&&(a=Mre(a,d))}}),this.stopStream){if(typeof a.content=="string",a.content.length>0){const m=fy([a]);this.prevMessages.push(...m)}o.controller.abort(),this.stopStream=!1,yield{isEnd:!0,responseMessage:a};continue}else if(c){yield{isEnd:!0,responseMessage:a};continue}else yield a}catch(i){console.log(i),yield{isEnd:!0,responseMessage:{role:"assistant",content:"",status:{type:"incomplete",reason:"error",error:i}}}}}async*sendMessageAfterToolCall(e){if(typeof e.content=="string")return e;const n=e.content.filter(i=>i.type==="tool-call").reverse()[0];if(!n)return e;const r={role:"tool",content:n.result||"",tool_call_id:n.toolCallId};return this.prevMessages.push(r),yield*this.sendMessage([],!0,e),e}stopMessage=()=>{this.stopStream=!0};getName=()=>"TogetherAI";getBaseUrl=()=>"https://api.together.xyz/v1";checkProvider=async e=>{const n=new pt({baseURL:e.url,apiKey:e.apiKey});try{return await n.models.list(),!0}catch(r){if(console.log(r),r.status===401||e.apiKey)return{field:"key",message:"Invalid API Key"}}return e.apiKey?{field:"url",message:"Invalid URL"}:{field:"key",message:"Empty key"}};getProviderModels=async e=>(await new pt({baseURL:e.url,apiKey:e.apiKey}).models.list()).filter(i=>i.type==="chat").filter(i=>i.id==="Qwen/Qwen3-235B-A22B-fp8-tput"||i.id==="deepseek-ai/DeepSeek-V3.1").map(i=>({id:i.id,name:i.display_name??i.id,provider:"together"}))}const wL=new Ore,Pre=t=>t.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:{...e.inputSchema}}})),dy=t=>{const e=[];return t.forEach(n=>{if(n.role==="user"||n.role==="system"){const r=typeof n.content=="string"?n.content:n.content.map(i=>i.type==="text"?{type:"text",text:i.text}:i.type==="file"?{type:"text",text:JSON.stringify({file_data:i.data,filename:JSON.parse(i.mimeType).path,file_id:JSON.parse(i.mimeType).path})}:{type:"text",text:""});e.push({role:"user",content:r})}else{const r=typeof n.content=="string"?n.content:[],i=[],s=[],o=n.content;typeof o!="string"&&typeof r!="string"&&o.forEach(c=>{if(Array.isArray(r)&&(c.type==="text"&&r.push({type:"text",text:c.text}),c.type==="tool-call")){c.result&&i.push({role:"tool",content:c.result,tool_call_id:c.toolCallId}),s.push({id:c.toolCallId,type:"function",function:{arguments:c.argsText??"",name:c.toolName}});return}});const a={role:"assistant",content:r};s.length&&(a.tool_calls=s),e.push(a),i.length&&e.push(...i)}}),e},Dre=(t,e,n)=>{if(!e.delta.content)return t;let r=Jr(t);const i=r.content;if(typeof i=="string")return r;const s=i[i.length-1];if((!s||n)&&typeof t.content!="string"&&(r={...r,content:[...i,{type:"text",text:e.delta.content}]}),s&&typeof s!="string"&&typeof i!="string"&&s.type==="text"){const o=s.text+e.delta.content,a=Jr({...s,text:o});r={...r,content:[...i.slice(0,-1),a]}}return r},Ire=(t,e)=>{let n=Jr(t);if(!e.delta.tool_calls||typeof n.content=="string")return n;const r=e.delta.tool_calls[0],i=n.content[n.content.length-1];if(!i||i?.type!=="tool-call"){const s={type:"tool-call",args:{},argsText:r?.function?.arguments??"",toolName:r?.function?.name??"",toolCallId:r?.id??""};n={...n,content:[...n.content,s]}}else{const s=i,o=s.argsText+(r?.function?.arguments??""),a=s.toolName||r?.function?.name||"",c=s.toolCallId||r?.id||"";let h={};try{h=JSON.parse(o??"{}")}catch{}const f={...s,args:h,argsText:o,toolName:a,toolCallId:c};n={...n,content:[...n.content.slice(0,-1),f]}}return n};class Lre{modelKey="";systemPrompt="";apiKey;url;provider;prevMessages=[];tools=[];client;stopStream=!1;constructor(){}setProvider=e=>{this.provider=e,this.client=new Xe({apiKey:e.key,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0}),e.key&&this.setApiKey(e.key),e.baseUrl&&this.setUrl(e.baseUrl)};setModelKey=e=>{this.modelKey=e};setSystemPrompt=e=>{this.systemPrompt=e};setApiKey=e=>{this.apiKey=e,this.client&&(this.client.apiKey=e)};setUrl=e=>{this.url=e,this.client&&(this.client.baseURL=e)};setPrevMessages=e=>{this.prevMessages=dy(e)};setTools=e=>{this.tools=Pre(e)};async createChatName(e){try{if(!this.client)return"";const n={role:"system",content:$m};return(await this.client.chat.completions.create({messages:[n,{role:"user",content:e}],model:this.modelKey,stream:!1})).choices[0].message.content??e.substring(0,25)}catch{return""}}async*sendMessage(e,n,r){try{if(!this.client)return;const i=dy(e),s={role:"system",content:this.systemPrompt},o=await this.client.chat.completions.create({messages:[s,...this.prevMessages,...i],model:this.modelKey,tools:this.tools,stream:!0,temperature:0});this.prevMessages.push(...i);let a=n&&r?Jr(r):{role:"assistant",content:[]},c=!1;for await(const h of o){if(h.choices.forEach(d=>{if(!c){if(d.finish_reason){c=!0;const m=n?{...a,content:typeof a.content=="string"?a.content:a.content.filter((b,w)=>{if(b.type==="tool-call")return!0;const S=r?.content.length??0;return w>=S})}:a,y=dy([m]);this.prevMessages.push(...y);return}d.delta.content&&(a=Dre(a,d,n)),d.delta.tool_calls&&typeof a.content!="string"&&(a=Ire(a,d))}}),this.stopStream){const d=dy([a]);this.prevMessages.push(...d),o.controller.abort(),this.stopStream=!1,yield{isEnd:!0,responseMessage:a};continue}if(c){yield{isEnd:!0,responseMessage:a};continue}else yield a}}catch(i){console.log(i),yield{isEnd:!0,responseMessage:{role:"assistant",content:"",status:{type:"incomplete",reason:"error",error:i}}}}}async*sendMessageAfterToolCall(e){if(typeof e.content=="string")return e;const n=e.content.filter(i=>i.type==="tool-call").reverse()[0];if(!n)return e;const r={role:"tool",content:n.result,tool_call_id:n.toolCallId};return this.prevMessages.push(r),yield*this.sendMessage([],!0,e),e}stopMessage=()=>{this.stopStream=!0};getName=()=>"OpenRouter";getBaseUrl=()=>"https://openrouter.ai/api/v1";checkProvider=async e=>{try{const n=await fetch(`${e.url}/models/user`,{headers:{Authorization:`Bearer ${e.apiKey}`}});return n.ok?!0:e.apiKey?n.status===401||e.apiKey?{field:"key",message:"Invalid API Key"}:{field:"url",message:"Invalid URL"}:{field:"key",message:"Empty key"}}catch(n){return console.log(n),{field:"url",message:"Failed to connect"}}};getProviderModels=async e=>(await new Xe({baseURL:e.url,apiKey:e.apiKey,dangerouslyAllowBrowser:!0}).models.list()).data.filter(i=>i.id==="openai/gpt-5.1"||i.id==="anthropic/claude-haiku-4.5"||i.id==="anthropic/claude-sonnet-4.5"||i.id==="anthropic/claude-opus-4.1"||i.id==="x-ai/grok-4"||i.id==="qwen/qwen3-235b-a22b-2507"||i.id==="deepseek/deepseek-v3.1-terminus"||i.id==="qwen/qwen3-max").map(i=>({id:i.id,name:i.id==="openai/gpt-5.1"?"GPT-5.1":i.id==="anthropic/claude-haiku-4.5"?"Claude Haiku 4.5":i.id==="anthropic/claude-sonnet-4.5"?"Claude Sonnet 4.5":i.id==="anthropic/claude-opus-4.1"?"Claude Opus 4.1":i.id==="x-ai/grok-4"?"Grok 4":i.id==="google/gemini-2.5-flash"?"Gemini 2.5 Flash":i.id==="google/gemini-2.5-pro"?"Gemini 2.5 Pro":i.id==="qwen/qwen3-235b-a22b-2507"?"Qwen3":i.id==="deepseek/deepseek-v3.1-terminus"?"DeepSeek V3.1 Terminus":i.id==="qwen/qwen3-max"?"Qwen3 Max":i.id.toUpperCase(),provider:"openrouter"}))}const xL=new Lre;let Nre=class{currentProvider;currentProviderInfo;currentProviderType;anthropicProvider;ollamaProvider;openaiProvider;togetherProvider;openrouterProvider;constructor(){this.anthropicProvider=kI,this.ollamaProvider=OI,this.openaiProvider=sL,this.togetherProvider=wL,this.openrouterProvider=xL}setCurrentProvider=e=>{if(!e){this.currentProvider=void 0,this.currentProviderInfo=void 0,this.currentProviderType=void 0;return}switch(this.currentProviderInfo=e,e.type){case"anthropic":this.currentProvider=kI,this.currentProviderType="anthropic";break;case"ollama":this.currentProvider=OI,this.currentProviderType="ollama";break;case"openai":this.currentProvider=sL,this.currentProviderType="openai";break;case"together":this.currentProvider=wL,this.currentProviderType="together";break;case"openrouter":this.currentProvider=xL,this.currentProviderType="openrouter";break;default:this.currentProvider=void 0,this.currentProviderType=void 0}this.currentProvider&&(this.currentProvider.setProvider(e),this.currentProvider.setSystemPrompt(nte))};setCurrentProviderModel=e=>{this.currentProvider&&this.currentProvider.setModelKey(e)};setCurrentProviderTools=e=>{this.currentProvider&&this.currentProvider.setTools(e)};setCurrentProviderPrevMessages=e=>{this.currentProvider&&this.currentProvider.setPrevMessages(e)};getCurrentProviderModel=()=>{if(this.currentProvider)return this.currentProvider.modelKey};createChatName=async e=>{if(!this.currentProvider)return"";const n=await this.currentProvider.createChatName(e);return n.includes("</think>")?n.split("</think>")[1].slice(0,128):n.slice(0,128)};sendMessage=e=>{if(this.currentProvider)return this.currentProvider.sendMessage(e)};sendMessageAfterToolCall=e=>{if(this.currentProvider)return this.currentProvider.sendMessageAfterToolCall(e)};stopMessage=()=>{this.currentProvider&&this.currentProvider.stopMessage()};getProvidersInfo=()=>{const e={type:"anthropic",name:this.anthropicProvider.getName(),baseUrl:this.anthropicProvider.getBaseUrl()},n={type:"ollama",name:this.ollamaProvider.getName(),baseUrl:this.ollamaProvider.getBaseUrl()},r={type:"openai",name:this.openaiProvider.getName(),baseUrl:this.openaiProvider.getBaseUrl()},i={type:"together",name:this.togetherProvider.getName(),baseUrl:this.togetherProvider.getBaseUrl()},s={type:"openrouter",name:this.openrouterProvider.getName(),baseUrl:this.openrouterProvider.getBaseUrl()};return[e,n,r,i,s]};getProviderInfo=e=>e==="anthropic"?{type:e,name:this.anthropicProvider.getName(),baseUrl:this.anthropicProvider.getBaseUrl()}:e==="ollama"?{type:e,name:this.ollamaProvider.getName(),baseUrl:this.ollamaProvider.getBaseUrl()}:e==="openai"?{type:e,name:this.openaiProvider.getName(),baseUrl:this.openaiProvider.getBaseUrl()}:e==="together"?{type:e,name:this.togetherProvider.getName(),baseUrl:this.togetherProvider.getBaseUrl()}:e==="openrouter"?{type:e,name:this.openrouterProvider.getName(),baseUrl:this.openrouterProvider.getBaseUrl()}:{name:"",baseUrl:""};checkNewProvider=(e,n)=>e==="anthropic"?this.anthropicProvider.checkProvider(n):e==="ollama"?this.ollamaProvider.checkProvider(n):e==="openai"?this.openaiProvider.checkProvider(n):e==="together"?this.togetherProvider.checkProvider(n):e==="openrouter"?this.openrouterProvider.checkProvider(n):!1;getProvidersModels=async e=>{const n=new Map,r=e.map(o=>o.type==="anthropic"?this.anthropicProvider.getProviderModels({url:o.baseUrl,apiKey:o.key}):o.type==="ollama"?this.ollamaProvider.getProviderModels({url:o.baseUrl,apiKey:o.key}):o.type==="openai"?this.openaiProvider.getProviderModels({url:o.baseUrl,apiKey:o.key}):o.type==="together"?this.togetherProvider.getProviderModels({url:o.baseUrl,apiKey:o.key}):o.type==="openrouter"?this.openrouterProvider.getProviderModels({url:o.baseUrl,apiKey:o.key}):null).filter(o=>o!==null),i=await Promise.allSettled(r);let s=0;return e.forEach(o=>{if(o.type==="anthropic"||o.type==="ollama"||o.type==="openai"||o.type==="together"||o.type==="openrouter"){const a=i[s];a.status==="fulfilled"&&a.value&&a.value.length>0&&n.set(o.name,a.value),s++}}),n}};const Lt=new Nre;class $re{dbName="ChatHistory";version=1;db=null;async init(){return new Promise((e,n)=>{const r=indexedDB.open(this.dbName,this.version);r.onerror=()=>n(r.error),r.onsuccess=()=>{this.db=r.result,e()},r.onupgradeneeded=i=>{const s=i.target.result;if(s.objectStoreNames.contains("threads")||s.createObjectStore("threads",{keyPath:"threadId"}).createIndex("updatedAt","updatedAt",{unique:!1}),!s.objectStoreNames.contains("messages")){const o=s.createObjectStore("messages",{keyPath:"id"});o.createIndex("threadId","threadId",{unique:!1}),o.createIndex("timestamp","timestamp",{unique:!1})}}})}getDB(){if(!this.db)throw new Error("Database not initialized");return this.db}async close(){this.db&&(this.db.close(),this.db=null)}}const ns=new $re,jre=()=>ns.init(),py=async(t,e,n)=>{const r=ns.getDB(),i={id:e,threadId:t,message:n,timestamp:Date.now()};return new Promise((s,o)=>{const h=r.transaction(["messages"],"readwrite").objectStore("messages").put(i);h.onerror=()=>o(h.error),h.onsuccess=()=>s()})},c9=async(t,e)=>{const n=ns.getDB();return new Promise((r,i)=>{const c=n.transaction(["messages"],"readonly").objectStore("messages").index("threadId").getAll(IDBKeyRange.only(t));c.onerror=()=>i(c.error),c.onsuccess=()=>{let h=c.result.sort((f,d)=>f.timestamp-d.timestamp).map(f=>f.message);r(h)}})},Bre=async(t,e)=>{const n=ns.getDB();return new Promise((r,i)=>{const o=n.transaction(["messages"],"readwrite").objectStore("messages"),a=o.get(t);a.onerror=()=>i(a.error),a.onsuccess=()=>{const c=a.result;if(!c){i(new Error("Message not found"));return}const h={...c,message:e,timestamp:Date.now()},f=o.put(h);f.onerror=()=>i(f.error),f.onsuccess=()=>r()}})},Fre=async t=>{const e=ns.getDB();return new Promise((n,r)=>{const a=e.transaction(["messages"],"readwrite").objectStore("messages").index("threadId").openCursor(IDBKeyRange.only(t));a.onsuccess=c=>{const h=c.target.result;h?(h.delete(),h.continue()):n()},a.onerror=()=>r(a.error)})},Yh=na((t,e)=>({messages:[],isStreamRunning:!1,isRequestRunning:!1,fetchPrevMessages:async n=>{const r=await c9(n);t({messages:r}),Lt.setCurrentProviderPrevMessages(r)},setIsStreamRunning:n=>{t({isStreamRunning:n})},setIsRequestRunning:n=>{t({isRequestRunning:n})},addMessage:n=>{const r=e();if(r.messages.length&&r.messages[r.messages.length-1].status?.type==="incomplete"){t({messages:[...r.messages.slice(0,-1),{...n}]});return}t({messages:[...r.messages,n]})},updateLastMessage:n=>{const r=e();t({messages:[...r.messages.slice(0,-1),n]})},stopMessage:()=>{e().setIsStreamRunning(!1),Lt.stopMessage()}})),Vm=na(t=>({currentPage:"chat",setCurrentPage:e=>t({currentPage:e}),goToChat:()=>t({currentPage:"chat"}),goToSettings:()=>t({currentPage:"settings"})})),my="providers",ju="current-provider",y_="current-model",bh=100,Tb=bh+2,rs=na()((t,e)=>({providers:(()=>{const n=localStorage.getItem(my);return n?JSON.parse(n):[]})(),currentProvider:(()=>{const n=localStorage.getItem(ju);if(!n)return null;const r=JSON.parse(n);Lt.setCurrentProvider(r);const i=Lt.checkNewProvider(r.type,{url:r.baseUrl,apiKey:r.key});if(i instanceof Promise)i.then(s=>{(typeof s!="boolean"||!s)&&localStorage.removeItem(ju)}).catch(s=>{console.error("Provider validation error:",s),localStorage.removeItem(ju)});else if(!i)return localStorage.removeItem(ju),null;return r})(),providersModels:new Map,fetchProvidersModels:async()=>{const n=e().providers,r=await Lt.getProvidersModels(n);t({providersModels:r})},setCurrentProvider:n=>{t({currentProvider:n}),Lt.setCurrentProvider(n),localStorage.setItem(ju,JSON.stringify(n))},addProvider:async n=>{if(e().providers.some(o=>o.name.toLowerCase()===n.name.toLowerCase()))return{field:"name",message:"Duplicate name"};const s=await Lt.checkNewProvider(n.type,{url:n.baseUrl,apiKey:n.key});return typeof s=="boolean"&&s?(t(o=>{const a=[...o.providers,n];return localStorage.setItem(my,JSON.stringify(a)),{providers:a}}),!0):s},editProvider:async(n,r)=>{if(e().providers.some(a=>a.name.toLowerCase()===n.name.toLowerCase()&&a.baseUrl!==n.baseUrl&&a.key!==n.key&&a.type!==n.type))return{field:"name",message:"Duplicate name"};const o=await Lt.checkNewProvider(n.type,{url:n.baseUrl,apiKey:n.key});return typeof o=="boolean"&&o?(t(a=>{const c=a.providers.map(h=>h.name===r?n:h);return localStorage.setItem(my,JSON.stringify(c)),{providers:c}}),!0):o},deleteProvider:async n=>{t(r=>{const i=r.providers.filter(s=>s.name!==n.name);return r.currentProvider?.name===n.name&&(r.currentProvider=null,localStorage.removeItem(ju),Lt.setCurrentProvider()),localStorage.setItem(my,JSON.stringify(i)),{providers:i}})}}));class zre{tools;constructor(){this.tools=[],this.initTools()}setTools=e=>{this.tools=e};getTools=()=>[...this.tools];callTools=async(e,n)=>{const r={...n};return await window.AscDesktopEditor?.callToolFunction(e,JSON.stringify(r))};initTools=()=>{try{const e=window.AscDesktopEditor?.getToolFunctions()??"",n=JSON.parse(e).map(r=>({name:r.name,description:r.description,inputSchema:r.parameters}));this.setTools(n)}catch(e){console.error("Error parsing tools:",e)}}}const SL=t=>{let e="";const n={};let r="";return Object.entries(t).map(([s,o])=>{s=="env"&&Object.entries(o).forEach(([a,c])=>{n[a]=c}),s==="command"&&(e=o),s=="args"&&(r=o.join(" "))}),{commandLine:e+" "+r,env:n}};class Vre{customServers;startedCustomServers;initedCustomServers;stopedCustomServers;customServersProcesses;customServersLogs;tools;constructor(){this.customServers={},this.startedCustomServers={},this.initedCustomServers={},this.customServersProcesses={},this.customServersLogs={},this.tools={},this.stopedCustomServers=[]}onProcess=(e,n,r)=>{try{const i=JSON.parse(r);i.jsonrpc==="2.0"&&i.id&&i.id.includes("init-"+e)&&(this.initedCustomServers[e]=!0,this.stopedCustomServers=this.stopedCustomServers.filter(s=>s!==e)),i.jsonrpc==="2.0"&&i.id&&i.id.includes("tools-"+e)&&(this.tools[e]=i.result.tools,window.dispatchEvent(new CustomEvent("tools-changed")))}catch{}switch(n){case 0:{this.customServersLogs[e].push(`${new Date().toLocaleString()}: ${r}
`);break}case 1:{this.customServersLogs[e].push(`${new Date().toLocaleString()}: ${r}
`);break}case 2:{this.customServersLogs[e].push(`${new Date().toLocaleString()}: [stop] ${r}
`),this.stopedCustomServers.push(e);break}}};setCustomServers=e=>{this.customServers=e.mcpServers};getServerType=e=>{let n="";return Object.keys(this.customServers).forEach(r=>{e.includes(`${r}_`)&&(n=r)}),n};startCustomServers=()=>{const e=[];Object.entries(this.customServers).forEach(([n,r])=>{e.push(n);const{commandLine:i,env:s}=SL(r);if(this.startedCustomServers[n]&&this.startedCustomServers[n]===i)return;this.customServersProcesses[n]&&this.customServersProcesses[n].end(),this.customServersLogs[n]=[`${new Date().toLocaleString()}: ${i}
`];const o=new window.ExternalProcess(i,s);o.onprocess=this.onProcess.bind(this,n),this.customServersProcesses[n]=o,o.start(),this.initCustomServer(n)}),Object.keys(this.customServersProcesses).forEach(n=>{e.includes(n)||this.deleteCustomServer(n)})};restartCustomServer=e=>{Object.entries(this.customServers).forEach(([n,r])=>{if(e!==n)return;this.customServersProcesses[e].end();const{commandLine:i,env:s}=SL(r);this.customServersLogs[e]=[`${new Date().toLocaleString()}: ${i}
`],this.tools[e]=[];const o=new window.ExternalProcess(i,s);o.onprocess=this.onProcess.bind(this,e),this.customServersProcesses[e]=o,o.start(),this.initCustomServer(e),window.dispatchEvent(new CustomEvent("tools-changed"))})};deleteCustomServer=e=>{this.customServersProcesses[e]&&(this.customServersProcesses[e].end(),delete this.customServersProcesses[e]),this.customServersLogs[e]&&delete this.customServersLogs[e],this.startedCustomServers[e]&&delete this.startedCustomServers[e],this.customServers[e]&&delete this.customServers[e],this.tools[e]&&delete this.tools[e],window.dispatchEvent(new CustomEvent("tools-changed"))};initCustomServer=e=>{const n=this.customServersProcesses[e];if(!n)return;const r=setInterval(()=>{if(this.initedCustomServers[e]){clearInterval(r),this.getToolsFromMCP(e);return}try{const i={jsonrpc:"2.0",id:`init-${e}`,method:"initialize",params:{protocolVersion:"2024-11-05",capabilities:{tools:{}},clientInfo:{name:"ai-agent",version:"1.0.0"}}},o=`${JSON.stringify(i)}
`;n.stdin(o)}catch(i){console.error(`Error initializing custom server ${e}:`,i)}},1e3)};getToolsFromMCP=async e=>{const n=this.customServersProcesses[e];try{const r={jsonrpc:"2.0",id:`tools-${e}-${Date.now()}`,method:"tools/list",params:{}},s=`${JSON.stringify(r)}
`;n.stdin(s)}catch(r){console.error(`Error getting tools from MCP server ${e}:`,r)}};callToolFromMCP=async(e,n,r)=>{const i=this.customServersProcesses[e];if(!i)throw new Error(`MCP server ${e} is not running`);if(!(this.tools[e]||[]).find(a=>a.name===n))throw new Error(`Tool ${n} not found on server ${e}`);try{const a={jsonrpc:"2.0",id:`call-${e}-${n}-${Date.now()}`,method:"tools/call",params:{name:n,arguments:r}},h=`${JSON.stringify(a)}
`;return i.stdin(h),new Promise((f,d)=>{const m=setTimeout(()=>{d(new Error(`Timeout waiting for tool response from ${e}`))},3e4),y=i.onprocess;i.onprocess=(b,w)=>{if(y(b,w),b===0)try{const S=JSON.parse(w);S.id&&S.id.startsWith(`call-${e}-${n}`)&&(i.onprocess=y,clearTimeout(m),S.error?(console.error("MCP tool error response:",S.error),d(new Error(`MCP tool error (${S.error.code}): ${S.error.message}`))):(console.log("MCP tool success response:",S.result),f(JSON.stringify(S.result))))}catch{}}})}catch(a){throw new Error(`Error calling MCP tool ${n} on server ${e}: ${a}`)}};getTools=()=>this.tools}const _L="webSearchProviderData";let Ure=class{tools;webSearchData=null;constructor(){this.tools=[];const e=localStorage.getItem(_L);e?this.webSearchData=JSON.parse(e):this.webSearchData=null,this.initTools()}setWebSearchData=e=>{this.webSearchData=e,localStorage.setItem(_L,e?JSON.stringify(e):""),this.initTools()};getWebSearchData=()=>this.webSearchData;setTools=e=>{this.tools=e};getTools=()=>[...this.tools];webSearch=async e=>{if(this.webSearchData?.provider==="Exa")try{const n=await new Promise(r=>{window.AscSimpleRequest.createRequest({url:"https://api.exa.ai/search",method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.webSearchData.key},body:JSON.stringify({query:e.query,text:!0,numResults:5,livecrawl:"preferred"}),complete:function(i){const s=JSON.parse(i.responseText),o=s.error?{error:s.error}:s.results;r({data:o})},error:function(i){console.log("Request failed with status:",i.statusCode),i.statusCode==-102&&(i.statusCode=404),r({error:i.statusCode,message:`Network error: ${i.statusCode}`})}})});return console.log(),JSON.stringify(n)}catch(n){console.error("WebSearch error:",n)}return JSON.stringify(e)};webCrawling=async e=>{if(this.webSearchData?.provider==="Exa")try{const n=await new Promise(r=>{window.AscSimpleRequest.createRequest({url:"https://api.exa.ai/contents",method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.webSearchData.key},body:JSON.stringify({urls:e.urls,text:!0}),complete:function(i){const s=JSON.parse(i.responseText),o=s.error?{error:s.error}:s.results;r({data:o})},error:function(i){console.log("Request failed with status:",i.statusCode),i.statusCode==-102&&(i.statusCode=404),r({error:i.statusCode,message:`Network error: ${i.statusCode}`})}})});return JSON.stringify(n)}catch(n){console.error(n)}return JSON.stringify(e)};callTools=async(e,n)=>{if(e==="web_search")return await this.webSearch(n);if(e==="web_crawling")return await this.webCrawling(n)};initTools=()=>{if(!this.webSearchData){this.setTools([]);return}this.setTools([{name:"web_search",description:"The search endpoint lets you intelligently search the web and extract contents from the results.",inputSchema:{type:"object",properties:{query:{type:"string",description:"The query string for the search."}}}},{name:"web_crawling",description:"Get the full page contents, summaries, and metadata for a list of URLs.",inputSchema:{type:"object",properties:{urls:{type:"array",items:{type:"string"},description:"Array of URLs to crawl"}}}}]),window.dispatchEvent(new CustomEvent("tools-changed"))};getWebSearchEnabled=()=>!!this.webSearchData};const CL="allowAlwaysTools";let Hre=class{desktopEditorTool;customServers;webSearch;allowAlways;constructor(){this.desktopEditorTool=new zre,this.customServers=new Vre,this.webSearch=new Ure,this.allowAlways=localStorage.getItem(CL)?.split(",")??[]}checkAllowAlways=(e,n)=>!!(e==="web-search"||this.allowAlways.includes(`${e}_${n}`));setAllowAlways=(e,n,r)=>{n!=="web-search"&&(e?this.allowAlways.push(`${n}_${r}`):this.allowAlways=this.allowAlways.filter(i=>i!==`${n}_${r}`),localStorage.setItem(CL,this.allowAlways.join(",")))};getTools=async()=>{const[e,n,r]=await Promise.all([this.desktopEditorTool.getTools(),this.webSearch.getTools(),this.customServers.getTools()]);return{"desktop-editor":e,"web-search":n,...r}};callTools=async(e,n,r)=>e==="desktop-editor"?this.desktopEditorTool.callTools(n,r):e==="web-search"?await this.webSearch.callTools(n,r):await this.customServers.callToolFromMCP(e,n,r);getServerType=e=>e.includes("desktop-editor_")?"desktop-editor":e.includes("web-search_")?"web-search":this.customServers.getServerType(e);setCustomServers=e=>{this.customServers.setCustomServers(e)};startCustomServers=()=>{this.customServers.startCustomServers()};restartCustomServer=e=>{this.customServers.restartCustomServer(e)};deleteCustomServer=e=>{this.customServers.deleteCustomServer(e)};getCustomServers=()=>this.customServers.customServers;getCustomServersStoped=()=>this.customServers.stopedCustomServers;getCustomServersLogs=()=>this.customServers.customServersLogs;setWebSearchData=e=>{this.webSearch.setWebSearchData(e)};getWebSearchData=()=>this.webSearch.getWebSearchData();getWebSearchEnabled=()=>this.webSearch.getWebSearchEnabled()};const Qt=new Hre,gy="disabledTools",yy="mcpServers",Rs=na((t,e)=>({servers:{},tools:[],disabledTools:{},manageToolData:void 0,webSearchEnabled:!1,initServers:()=>{const n=localStorage.getItem(yy);if(n){const r=JSON.parse(n);Qt.setCustomServers(r),Qt.startCustomServers()}},getTools:async()=>{const n=await Qt.getTools(),r=localStorage.getItem(gy),i=[],s={};let o=!1;if(r){const a=JSON.parse(r);Object.entries(n).map(([c,h])=>{if(c==="web-search"){if(s[c]=[...h],a["web-search"].length){t({webSearchEnabled:!1});return}const f=h.map(d=>({...d,name:`${c}_${d.name}`}));a[c]=[],i.push(...f),t({webSearchEnabled:h.length>0}),o=h.length>0;return}s[c]=h.map(f=>{a[c]||(a[c]=[]);const d=!a[c].includes(f.name);return(d&&o?i.length===Tb:i.length===bh)?(a[c].push(f.name),{...f,enabled:!1}):(d&&i.push({...f,name:`${c}_${f.name}`}),{...f,enabled:d})})}),t({disabledTools:a})}else{const a={};let c=!1;Object.entries(n).map(([h,f])=>{if(a[h]=[],h==="web-search"){s[h]=[...f];const m=f.map(y=>({...y,name:`${h}_${y.name}`,enabled:!0}));i.push(...m),t({webSearchEnabled:f.length>0}),c=f.length>0;return}const d=f.map((m,y)=>i.length+y>=(c?Tb:bh)?(a[h].push(m.name),{...m,enabled:!1}):{...m,enabled:!0});s[h]=d,i.push(...d.map(m=>({...m,name:`${h}_${m.name}`})))}),t({disabledTools:a})}t({tools:i,servers:s})},changeToolStatus:(n,r,i)=>{const s=e(),o=s.servers,a=o[n].find(c=>c.name===r);if(a){if(i){if(n==="web-search"){const h={...s.disabledTools,[n]:[]};t({disabledTools:h}),t({webSearchEnabled:!0}),t({servers:{...o,[n]:o[n].map(f=>({...f,enabled:!0}))}}),localStorage.setItem(gy,JSON.stringify(h));return}if(s.tools.length>=(s.webSearchEnabled?Tb:bh))return;const c={...s.disabledTools,[n]:s.disabledTools[n].filter(h=>h!==r)};t({tools:[...s.tools,{...a,name:`${n}_${a.name}`}],disabledTools:c}),localStorage.setItem(gy,JSON.stringify(c))}else{const c=[...s.disabledTools[n],r],h={...s.disabledTools,[n]:c};let f=[];n==="web-search"?(h[n]=[...s.servers[n].map(d=>d.name)],t({webSearchEnabled:!1}),f=s.tools.filter(d=>!d.name.includes(n))):f=s.tools.filter(d=>d.name!==`${n}_${r}`),t({tools:f,disabledTools:h}),localStorage.setItem(gy,JSON.stringify(h))}t({servers:{...o,[n]:o[n].map(c=>c.name===r?{...c,enabled:i}:c)}})}},checkAllowAlways:(n,r)=>Qt.checkAllowAlways(n,r),setAllowAlways:(n,r,i)=>{Qt.setAllowAlways(n,r,i)},callTools:async(n,r)=>{const i=e(),s=Qt.getServerType(n),o=n.replace(s+"_","");if(!i.disabledTools[s].find(c=>c===o))return await Qt.callTools(s,o,r)},setManageToolData:n=>{t({manageToolData:n})},getConfig:()=>JSON.parse(localStorage.getItem(yy)||JSON.stringify({mcpServers:{}})),saveConfig:n=>{const r=n.mcpServers?n:{mcpServers:{}};localStorage.setItem(yy,JSON.stringify(r)),Qt.setCustomServers(r),Qt.startCustomServers()},deleteCustomServer:n=>{Qt.deleteCustomServer(n);const r=e().getConfig();delete r.mcpServers[n],localStorage.setItem(yy,JSON.stringify(r))},getCustomServersLogs:()=>Qt.getCustomServersLogs(),getWebSearchEnabled:()=>Qt.getWebSearchEnabled()})),Wre=(t,e,n,r)=>{const i=[n,{code:e,...r||{}}];if(t?.services?.logger?.forward)return t.services.logger.forward(i,"warn","react-i18next::",!0);gc(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},AL={},OC=(t,e,n,r)=>{gc(n)&&AL[n]||(gc(n)&&(AL[n]=new Date),Wre(t,e,n,r))},u9=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},PC=(t,e,n)=>{t.loadNamespaces(e,u9(t,n))},EL=(t,e,n,r)=>{if(gc(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return PC(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,u9(t,r))},qre=(t,e,n={})=>!e.languages||!e.languages.length?(OC(e,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:e.languages}),!0):e.hasLoadedNamespace(t,{lng:n.lng,precheck:(r,i)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&r.services.backendConnector.backend&&r.isLanguageChangingTo&&!i(r.isLanguageChangingTo,t))return!1}}),gc=t=>typeof t=="string",Gre=t=>typeof t=="object"&&t!==null,Kre=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Yre={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},Xre=t=>Yre[t],Jre=t=>t.replace(Kre,Xre);let DC={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Jre};const Qre=(t={})=>{DC={...DC,...t}},Zre=()=>DC;let h9;const eie=t=>{h9=t},tie=()=>h9,nie={type:"3rdParty",init(t){Qre(t.options.react),eie(t)}},rie=k.createContext();class iie{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const sie=(t,e)=>{const n=k.useRef();return k.useEffect(()=>{n.current=t},[t,e]),n.current},f9=(t,e,n,r)=>t.getFixedT(e,n,r),oie=(t,e,n,r)=>k.useCallback(f9(t,e,n,r),[t,e,n,r]),vt=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=k.useContext(rie)||{},s=n||r||tie();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new iie),!s){OC(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const P=(M,D)=>gc(D)?D:Gre(D)&&gc(D.defaultValue)?D.defaultValue:Array.isArray(M)?M[M.length-1]:M,O=[P,{},!1];return O.t=P,O.i18n={},O.ready=!1,O}s.options.react?.wait&&OC(s,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...Zre(),...s.options.react,...e},{useSuspense:a,keyPrefix:c}=o;let h=i||s.options?.defaultNS;h=gc(h)?[h]:h||["translation"],s.reportNamespaces.addUsedNamespaces?.(h);const f=(s.isInitialized||s.initializedStoreOnce)&&h.every(P=>qre(P,s,o)),d=oie(s,e.lng||null,o.nsMode==="fallback"?h:h[0],c),m=()=>d,y=()=>f9(s,e.lng||null,o.nsMode==="fallback"?h:h[0],c),[b,w]=k.useState(m);let S=h.join();e.lng&&(S=`${e.lng}${S}`);const _=sie(S),A=k.useRef(!0);k.useEffect(()=>{const{bindI18n:P,bindI18nStore:O}=o;A.current=!0,!f&&!a&&(e.lng?EL(s,e.lng,h,()=>{A.current&&w(y)}):PC(s,h,()=>{A.current&&w(y)})),f&&_&&_!==S&&A.current&&w(y);const M=()=>{A.current&&w(y)};return P&&s?.on(P,M),O&&s?.store.on(O,M),()=>{A.current=!1,s&&P&&P?.split(" ").forEach(D=>s.off(D,M)),O&&s&&O.split(" ").forEach(D=>s.store.off(D,M))}},[s,S]),k.useEffect(()=>{A.current&&f&&w(m)},[s,c,f]);const E=[b,s,f];if(E.t=b,E.i18n=s,E.ready=f,f||!f&&!a)return E;throw new Promise(P=>{e.lng?EL(s,e.lng,h,()=>P()):PC(s,h,()=>P())})};function d9(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=d9(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function yv(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=d9(t))&&(r&&(r+=" "),r+=e);return r}const kL=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,TL=yv,aie=(t,e)=>n=>{var r;if(e?.variants==null)return TL(t,n?.class,n?.className);const{variants:i,defaultVariants:s}=e,o=Object.keys(i).map(h=>{const f=n?.[h],d=s?.[h];if(f===null)return null;const m=kL(f)||kL(d);return i[h][m]}),a=n&&Object.entries(n).reduce((h,f)=>{let[d,m]=f;return m===void 0||(h[d]=m),h},{}),c=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((h,f)=>{let{class:d,className:m,...y}=f;return Object.entries(y).every(b=>{let[w,S]=b;return Array.isArray(S)?S.includes({...s,...a}[w]):{...s,...a}[w]===S})?[...h,d,m]:h},[]);return TL(t,o,c,n?.class,n?.className)},Ik="-",lie=t=>{const e=uie(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const a=o.split(Ik);return a[0]===""&&a.length!==1&&a.shift(),p9(a,e)||cie(o)},getConflictingClassGroupIds:(o,a)=>{const c=n[o]||[];return a&&r[o]?[...c,...r[o]]:c}}},p9=(t,e)=>{if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?p9(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(Ik);return e.validators.find(({validator:o})=>o(s))?.classGroupId},RL=/^\[(.+)\]$/,cie=t=>{if(RL.test(t)){const e=RL.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},uie=t=>{const{theme:e,classGroups:n}=t,r={nextPart:new Map,validators:[]};for(const i in n)IC(n[i],r,i,e);return r},IC=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:ML(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(hie(i)){IC(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{IC(o,ML(e,s),n,r)})})},ML=(t,e)=>{let n=t;return e.split(Ik).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},hie=t=>t.isThemeGetter,fie=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const i=(s,o)=>{n.set(s,o),e++,e>t&&(e=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){n.has(s)?n.set(s,o):i(s,o)}}},LC="!",NC=":",die=NC.length,pie=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=i=>{const s=[];let o=0,a=0,c=0,h;for(let b=0;b<i.length;b++){let w=i[b];if(o===0&&a===0){if(w===NC){s.push(i.slice(c,b)),c=b+die;continue}if(w==="/"){h=b;continue}}w==="["?o++:w==="]"?o--:w==="("?a++:w===")"&&a--}const f=s.length===0?i:i.substring(c),d=mie(f),m=d!==f,y=h&&h>c?h-c:void 0;return{modifiers:s,hasImportantModifier:m,baseClassName:d,maybePostfixModifierPosition:y}};if(e){const i=e+NC,s=r;r=o=>o.startsWith(i)?s(o.substring(i.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(n){const i=r;r=s=>n({className:s,parseClassName:i})}return r},mie=t=>t.endsWith(LC)?t.substring(0,t.length-1):t.startsWith(LC)?t.substring(1):t,gie=t=>{const e=Object.fromEntries(t.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const i=[];let s=[];return r.forEach(o=>{o[0]==="["||e[o]?(i.push(...s.sort(),o),s=[]):s.push(o)}),i.push(...s.sort()),i}},yie=t=>({cache:fie(t.cacheSize),parseClassName:pie(t),sortModifiers:gie(t),...lie(t)}),bie=/\s+/,vie=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=e,o=[],a=t.trim().split(bie);let c="";for(let h=a.length-1;h>=0;h-=1){const f=a[h],{isExternal:d,modifiers:m,hasImportantModifier:y,baseClassName:b,maybePostfixModifierPosition:w}=n(f);if(d){c=f+(c.length>0?" "+c:c);continue}let S=!!w,_=r(S?b.substring(0,w):b);if(!_){if(!S){c=f+(c.length>0?" "+c:c);continue}if(_=r(b),!_){c=f+(c.length>0?" "+c:c);continue}S=!1}const A=s(m).join(":"),E=y?A+LC:A,P=E+_;if(o.includes(P))continue;o.push(P);const O=i(_,S);for(let M=0;M<O.length;++M){const D=O[M];o.push(E+D)}c=f+(c.length>0?" "+c:c)}return c};function wie(){let t=0,e,n,r="";for(;t<arguments.length;)(e=arguments[t++])&&(n=m9(e))&&(r&&(r+=" "),r+=n);return r}const m9=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=m9(t[r]))&&(n&&(n+=" "),n+=e);return n};function xie(t,...e){let n,r,i,s=o;function o(c){const h=e.reduce((f,d)=>d(f),t());return n=yie(h),r=n.cache.get,i=n.cache.set,s=a,a(c)}function a(c){const h=r(c);if(h)return h;const f=vie(c,n);return i(c,f),f}return function(){return s(wie.apply(null,arguments))}}const Sn=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},g9=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,y9=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Sie=/^\d+\/\d+$/,_ie=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Cie=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Aie=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Eie=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,kie=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Bu=t=>Sie.test(t),tt=t=>!!t&&!Number.isNaN(Number(t)),qa=t=>!!t&&Number.isInteger(Number(t)),b_=t=>t.endsWith("%")&&tt(t.slice(0,-1)),zo=t=>_ie.test(t),Tie=()=>!0,Rie=t=>Cie.test(t)&&!Aie.test(t),b9=()=>!1,Mie=t=>Eie.test(t),Oie=t=>kie.test(t),Pie=t=>!Re(t)&&!Me(t),Die=t=>Xh(t,x9,b9),Re=t=>g9.test(t),Yl=t=>Xh(t,S9,Rie),v_=t=>Xh(t,jie,tt),OL=t=>Xh(t,v9,b9),Iie=t=>Xh(t,w9,Oie),by=t=>Xh(t,_9,Mie),Me=t=>y9.test(t),Rd=t=>Jh(t,S9),Lie=t=>Jh(t,Bie),PL=t=>Jh(t,v9),Nie=t=>Jh(t,x9),$ie=t=>Jh(t,w9),vy=t=>Jh(t,_9,!0),Xh=(t,e,n)=>{const r=g9.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},Jh=(t,e,n=!1)=>{const r=y9.exec(t);return r?r[1]?e(r[1]):n:!1},v9=t=>t==="position"||t==="percentage",w9=t=>t==="image"||t==="url",x9=t=>t==="length"||t==="size"||t==="bg-size",S9=t=>t==="length",jie=t=>t==="number",Bie=t=>t==="family-name",_9=t=>t==="shadow",Fie=()=>{const t=Sn("color"),e=Sn("font"),n=Sn("text"),r=Sn("font-weight"),i=Sn("tracking"),s=Sn("leading"),o=Sn("breakpoint"),a=Sn("container"),c=Sn("spacing"),h=Sn("radius"),f=Sn("shadow"),d=Sn("inset-shadow"),m=Sn("text-shadow"),y=Sn("drop-shadow"),b=Sn("blur"),w=Sn("perspective"),S=Sn("aspect"),_=Sn("ease"),A=Sn("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],P=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],O=()=>[...P(),Me,Re],M=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto","contain","none"],$=()=>[Me,Re,c],F=()=>[Bu,"full","auto",...$()],N=()=>[qa,"none","subgrid",Me,Re],U=()=>["auto",{span:["full",qa,Me,Re]},qa,Me,Re],q=()=>[qa,"auto",Me,Re],K=()=>["auto","min","max","fr",Me,Re],X=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ee=()=>["start","end","center","stretch","center-safe","end-safe"],V=()=>["auto",...$()],G=()=>[Bu,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...$()],H=()=>[t,Me,Re],se=()=>[...P(),PL,OL,{position:[Me,Re]}],T=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Z=()=>["auto","cover","contain",Nie,Die,{size:[Me,Re]}],ue=()=>[b_,Rd,Yl],L=()=>["","none","full",h,Me,Re],pe=()=>["",tt,Rd,Yl],ke=()=>["solid","dashed","dotted","double"],be=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ee=()=>[tt,b_,PL,OL],Ue=()=>["","none",b,Me,Re],Pt=()=>["none",tt,Me,Re],Kt=()=>["none",tt,Me,Re],Yt=()=>[tt,Me,Re],er=()=>[Bu,"full",...$()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[zo],breakpoint:[zo],color:[Tie],container:[zo],"drop-shadow":[zo],ease:["in","out","in-out"],font:[Pie],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[zo],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[zo],shadow:[zo],spacing:["px",tt],text:[zo],"text-shadow":[zo],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Bu,Re,Me,S]}],container:["container"],columns:[{columns:[tt,Re,Me,a]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:O()}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:F()}],"inset-x":[{"inset-x":F()}],"inset-y":[{"inset-y":F()}],start:[{start:F()}],end:[{end:F()}],top:[{top:F()}],right:[{right:F()}],bottom:[{bottom:F()}],left:[{left:F()}],visibility:["visible","invisible","collapse"],z:[{z:[qa,"auto",Me,Re]}],basis:[{basis:[Bu,"full","auto",a,...$()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[tt,Bu,"auto","initial","none",Re]}],grow:[{grow:["",tt,Me,Re]}],shrink:[{shrink:["",tt,Me,Re]}],order:[{order:[qa,"first","last","none",Me,Re]}],"grid-cols":[{"grid-cols":N()}],"col-start-end":[{col:U()}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":N()}],"row-start-end":[{row:U()}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":K()}],"auto-rows":[{"auto-rows":K()}],gap:[{gap:$()}],"gap-x":[{"gap-x":$()}],"gap-y":[{"gap-y":$()}],"justify-content":[{justify:[...X(),"normal"]}],"justify-items":[{"justify-items":[...ee(),"normal"]}],"justify-self":[{"justify-self":["auto",...ee()]}],"align-content":[{content:["normal",...X()]}],"align-items":[{items:[...ee(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ee(),{baseline:["","last"]}]}],"place-content":[{"place-content":X()}],"place-items":[{"place-items":[...ee(),"baseline"]}],"place-self":[{"place-self":["auto",...ee()]}],p:[{p:$()}],px:[{px:$()}],py:[{py:$()}],ps:[{ps:$()}],pe:[{pe:$()}],pt:[{pt:$()}],pr:[{pr:$()}],pb:[{pb:$()}],pl:[{pl:$()}],m:[{m:V()}],mx:[{mx:V()}],my:[{my:V()}],ms:[{ms:V()}],me:[{me:V()}],mt:[{mt:V()}],mr:[{mr:V()}],mb:[{mb:V()}],ml:[{ml:V()}],"space-x":[{"space-x":$()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":$()}],"space-y-reverse":["space-y-reverse"],size:[{size:G()}],w:[{w:[a,"screen",...G()]}],"min-w":[{"min-w":[a,"screen","none",...G()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...G()]}],h:[{h:["screen","lh",...G()]}],"min-h":[{"min-h":["screen","lh","none",...G()]}],"max-h":[{"max-h":["screen","lh",...G()]}],"font-size":[{text:["base",n,Rd,Yl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Me,v_]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",b_,Re]}],"font-family":[{font:[Lie,Re,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,Me,Re]}],"line-clamp":[{"line-clamp":[tt,"none",Me,v_]}],leading:[{leading:[s,...$()]}],"list-image":[{"list-image":["none",Me,Re]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Me,Re]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:H()}],"text-color":[{text:H()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ke(),"wavy"]}],"text-decoration-thickness":[{decoration:[tt,"from-font","auto",Me,Yl]}],"text-decoration-color":[{decoration:H()}],"underline-offset":[{"underline-offset":[tt,"auto",Me,Re]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:$()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Me,Re]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Me,Re]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:se()}],"bg-repeat":[{bg:T()}],"bg-size":[{bg:Z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},qa,Me,Re],radial:["",Me,Re],conic:[qa,Me,Re]},$ie,Iie]}],"bg-color":[{bg:H()}],"gradient-from-pos":[{from:ue()}],"gradient-via-pos":[{via:ue()}],"gradient-to-pos":[{to:ue()}],"gradient-from":[{from:H()}],"gradient-via":[{via:H()}],"gradient-to":[{to:H()}],rounded:[{rounded:L()}],"rounded-s":[{"rounded-s":L()}],"rounded-e":[{"rounded-e":L()}],"rounded-t":[{"rounded-t":L()}],"rounded-r":[{"rounded-r":L()}],"rounded-b":[{"rounded-b":L()}],"rounded-l":[{"rounded-l":L()}],"rounded-ss":[{"rounded-ss":L()}],"rounded-se":[{"rounded-se":L()}],"rounded-ee":[{"rounded-ee":L()}],"rounded-es":[{"rounded-es":L()}],"rounded-tl":[{"rounded-tl":L()}],"rounded-tr":[{"rounded-tr":L()}],"rounded-br":[{"rounded-br":L()}],"rounded-bl":[{"rounded-bl":L()}],"border-w":[{border:pe()}],"border-w-x":[{"border-x":pe()}],"border-w-y":[{"border-y":pe()}],"border-w-s":[{"border-s":pe()}],"border-w-e":[{"border-e":pe()}],"border-w-t":[{"border-t":pe()}],"border-w-r":[{"border-r":pe()}],"border-w-b":[{"border-b":pe()}],"border-w-l":[{"border-l":pe()}],"divide-x":[{"divide-x":pe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":pe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ke(),"hidden","none"]}],"divide-style":[{divide:[...ke(),"hidden","none"]}],"border-color":[{border:H()}],"border-color-x":[{"border-x":H()}],"border-color-y":[{"border-y":H()}],"border-color-s":[{"border-s":H()}],"border-color-e":[{"border-e":H()}],"border-color-t":[{"border-t":H()}],"border-color-r":[{"border-r":H()}],"border-color-b":[{"border-b":H()}],"border-color-l":[{"border-l":H()}],"divide-color":[{divide:H()}],"outline-style":[{outline:[...ke(),"none","hidden"]}],"outline-offset":[{"outline-offset":[tt,Me,Re]}],"outline-w":[{outline:["",tt,Rd,Yl]}],"outline-color":[{outline:H()}],shadow:[{shadow:["","none",f,vy,by]}],"shadow-color":[{shadow:H()}],"inset-shadow":[{"inset-shadow":["none",d,vy,by]}],"inset-shadow-color":[{"inset-shadow":H()}],"ring-w":[{ring:pe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:H()}],"ring-offset-w":[{"ring-offset":[tt,Yl]}],"ring-offset-color":[{"ring-offset":H()}],"inset-ring-w":[{"inset-ring":pe()}],"inset-ring-color":[{"inset-ring":H()}],"text-shadow":[{"text-shadow":["none",m,vy,by]}],"text-shadow-color":[{"text-shadow":H()}],opacity:[{opacity:[tt,Me,Re]}],"mix-blend":[{"mix-blend":[...be(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":be()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[tt]}],"mask-image-linear-from-pos":[{"mask-linear-from":Ee()}],"mask-image-linear-to-pos":[{"mask-linear-to":Ee()}],"mask-image-linear-from-color":[{"mask-linear-from":H()}],"mask-image-linear-to-color":[{"mask-linear-to":H()}],"mask-image-t-from-pos":[{"mask-t-from":Ee()}],"mask-image-t-to-pos":[{"mask-t-to":Ee()}],"mask-image-t-from-color":[{"mask-t-from":H()}],"mask-image-t-to-color":[{"mask-t-to":H()}],"mask-image-r-from-pos":[{"mask-r-from":Ee()}],"mask-image-r-to-pos":[{"mask-r-to":Ee()}],"mask-image-r-from-color":[{"mask-r-from":H()}],"mask-image-r-to-color":[{"mask-r-to":H()}],"mask-image-b-from-pos":[{"mask-b-from":Ee()}],"mask-image-b-to-pos":[{"mask-b-to":Ee()}],"mask-image-b-from-color":[{"mask-b-from":H()}],"mask-image-b-to-color":[{"mask-b-to":H()}],"mask-image-l-from-pos":[{"mask-l-from":Ee()}],"mask-image-l-to-pos":[{"mask-l-to":Ee()}],"mask-image-l-from-color":[{"mask-l-from":H()}],"mask-image-l-to-color":[{"mask-l-to":H()}],"mask-image-x-from-pos":[{"mask-x-from":Ee()}],"mask-image-x-to-pos":[{"mask-x-to":Ee()}],"mask-image-x-from-color":[{"mask-x-from":H()}],"mask-image-x-to-color":[{"mask-x-to":H()}],"mask-image-y-from-pos":[{"mask-y-from":Ee()}],"mask-image-y-to-pos":[{"mask-y-to":Ee()}],"mask-image-y-from-color":[{"mask-y-from":H()}],"mask-image-y-to-color":[{"mask-y-to":H()}],"mask-image-radial":[{"mask-radial":[Me,Re]}],"mask-image-radial-from-pos":[{"mask-radial-from":Ee()}],"mask-image-radial-to-pos":[{"mask-radial-to":Ee()}],"mask-image-radial-from-color":[{"mask-radial-from":H()}],"mask-image-radial-to-color":[{"mask-radial-to":H()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":P()}],"mask-image-conic-pos":[{"mask-conic":[tt]}],"mask-image-conic-from-pos":[{"mask-conic-from":Ee()}],"mask-image-conic-to-pos":[{"mask-conic-to":Ee()}],"mask-image-conic-from-color":[{"mask-conic-from":H()}],"mask-image-conic-to-color":[{"mask-conic-to":H()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:se()}],"mask-repeat":[{mask:T()}],"mask-size":[{mask:Z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Me,Re]}],filter:[{filter:["","none",Me,Re]}],blur:[{blur:Ue()}],brightness:[{brightness:[tt,Me,Re]}],contrast:[{contrast:[tt,Me,Re]}],"drop-shadow":[{"drop-shadow":["","none",y,vy,by]}],"drop-shadow-color":[{"drop-shadow":H()}],grayscale:[{grayscale:["",tt,Me,Re]}],"hue-rotate":[{"hue-rotate":[tt,Me,Re]}],invert:[{invert:["",tt,Me,Re]}],saturate:[{saturate:[tt,Me,Re]}],sepia:[{sepia:["",tt,Me,Re]}],"backdrop-filter":[{"backdrop-filter":["","none",Me,Re]}],"backdrop-blur":[{"backdrop-blur":Ue()}],"backdrop-brightness":[{"backdrop-brightness":[tt,Me,Re]}],"backdrop-contrast":[{"backdrop-contrast":[tt,Me,Re]}],"backdrop-grayscale":[{"backdrop-grayscale":["",tt,Me,Re]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[tt,Me,Re]}],"backdrop-invert":[{"backdrop-invert":["",tt,Me,Re]}],"backdrop-opacity":[{"backdrop-opacity":[tt,Me,Re]}],"backdrop-saturate":[{"backdrop-saturate":[tt,Me,Re]}],"backdrop-sepia":[{"backdrop-sepia":["",tt,Me,Re]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":$()}],"border-spacing-x":[{"border-spacing-x":$()}],"border-spacing-y":[{"border-spacing-y":$()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Me,Re]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[tt,"initial",Me,Re]}],ease:[{ease:["linear","initial",_,Me,Re]}],delay:[{delay:[tt,Me,Re]}],animate:[{animate:["none",A,Me,Re]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,Me,Re]}],"perspective-origin":[{"perspective-origin":O()}],rotate:[{rotate:Pt()}],"rotate-x":[{"rotate-x":Pt()}],"rotate-y":[{"rotate-y":Pt()}],"rotate-z":[{"rotate-z":Pt()}],scale:[{scale:Kt()}],"scale-x":[{"scale-x":Kt()}],"scale-y":[{"scale-y":Kt()}],"scale-z":[{"scale-z":Kt()}],"scale-3d":["scale-3d"],skew:[{skew:Yt()}],"skew-x":[{"skew-x":Yt()}],"skew-y":[{"skew-y":Yt()}],transform:[{transform:[Me,Re,"","none","gpu","cpu"]}],"transform-origin":[{origin:O()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:er()}],"translate-x":[{"translate-x":er()}],"translate-y":[{"translate-y":er()}],"translate-z":[{"translate-z":er()}],"translate-none":["translate-none"],accent:[{accent:H()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:H()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Me,Re]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":$()}],"scroll-mx":[{"scroll-mx":$()}],"scroll-my":[{"scroll-my":$()}],"scroll-ms":[{"scroll-ms":$()}],"scroll-me":[{"scroll-me":$()}],"scroll-mt":[{"scroll-mt":$()}],"scroll-mr":[{"scroll-mr":$()}],"scroll-mb":[{"scroll-mb":$()}],"scroll-ml":[{"scroll-ml":$()}],"scroll-p":[{"scroll-p":$()}],"scroll-px":[{"scroll-px":$()}],"scroll-py":[{"scroll-py":$()}],"scroll-ps":[{"scroll-ps":$()}],"scroll-pe":[{"scroll-pe":$()}],"scroll-pt":[{"scroll-pt":$()}],"scroll-pr":[{"scroll-pr":$()}],"scroll-pb":[{"scroll-pb":$()}],"scroll-pl":[{"scroll-pl":$()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Me,Re]}],fill:[{fill:["none",...H()]}],"stroke-w":[{stroke:[tt,Rd,Yl,v_]}],stroke:[{stroke:["none",...H()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},zie=xie(Fie),je=(...t)=>zie(yv(t)),C9=t=>{let e="";return t.forEach(n=>{Array.isArray(n.content)?n.content.forEach(r=>{if(typeof r=="string"){e+=n.role==="user"?`## ${r}
`:`${r}
`;return}if(!(!r||typeof r!="object"||!("type"in r))){if(r.type==="text"&&"text"in r)e+=n.role==="user"?`## ${r.text}
`:`${r.text}
`;else if(r.type==="tool-call"&&"toolName"in r)return}}):typeof n.content=="string"&&(e+=n.role==="user"?`## ${n.content}
`:`${n.content}
`)}),e},A9=t=>t.replace(/[\\/:*"<>|?]/g,""),Vie=t=>{const n=t.split(`
`)[0].replace("## ","");return A9(n).substring(0,30)},E9=t=>!!(t&64),k9=t=>!!(t&128),Rb=t=>!!(t&256),T9=t=>t===513||t===521,Uie="inline-flex items-center justify-center rounded-[4px] min-w-[40px]",Hie="outline-none focus:outline-none focus-visible:outline-none",Wie="bg-[var(--button-default-background-color)] border border-[var(--button-default-border-color)] text-[var(--button-default-color)]",qie="hover:enabled:bg-[var(--button-default-hover-background-color)]",Gie="active:enabled:bg-[var(--button-default-pressed-background-color)]",Kie="focus:shadow-[var(--button-default-focus-shadow)]",Yie="disabled:bg-[var(--button-default-disabled-background-color)] disabled:text-[var(--button-default-disabled-color)] disabled:opacity-40 disabled:cursor-not-allowed",Xie="bg-[var(--button-background-color)] text-[var(--button-color)]",Jie="hover:enabled:bg-[var(--button-background-hover-color)]",Qie="active:enabled:bg-[var(--button-background-pressed-color)]",Zie="focus:bg-[var(--button-background-color)] focus:border-[var(--button-border-focus-color)] focus:shadow-[var(--button-shadow-focus)]",ese="disabled:opacity-50 disabled:cursor-not-allowed",tse="h-[32px] min-w-[40px] px-[12px] text-[14px] font-semibold leading-[16px]",nse=aie(`${Uie} ${Hie}`,{variants:{variant:{default:je(Wie,qie,Gie,Kie,Yie),primary:je(Xie,Jie,Qie,Zie,ese)},size:{default:tse},scale:{default:"w-fit",scale:"w-full"}},defaultVariants:{variant:"primary",size:"default",scale:"default"}}),en=({className:t,variant:e,size:n,asChild:r=!1,...i})=>{const s=r?sj:"button";return C.jsx(s,{"data-slot":"button",className:je("cursor-pointer",nse({variant:e,size:n,className:t})),...i})},rse=()=>{const{t}=vt(),{setCurrentPage:e}=Vm();return C.jsx("div",{className:"flex items-center justify-center h-full",children:C.jsxs("div",{className:"max-w-[573px] text-center flex flex-col items-center gap-[40px]",children:[C.jsxs("div",{className:"flex flex-col gap-[16px]",children:[C.jsx("h1",{className:"select-none text-center text-[32px] font-bold leading-[36px] text-[var(--empty-screen-color)]",children:t("ConnectAIModel")}),C.jsx("p",{className:"select-none text-center text-[16px] font-normal leading-[24px] text-[var(--empty-screen-description-color)]",children:t("ConnectAIModelDescription")})]}),C.jsx(en,{onClick:()=>e("settings"),children:t("ConnectAIModelBtn")})]})})};function R9(t){const e=t+"CollectionProvider",[n,r]=ra(e),[i,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:S,children:_}=w,A=de.useRef(null),E=de.useRef(new Map).current;return C.jsx(i,{scope:S,itemMap:E,collectionRef:A,children:_})};o.displayName=e;const a=t+"CollectionSlot",c=Rh(a),h=de.forwardRef((w,S)=>{const{scope:_,children:A}=w,E=s(a,_),P=Bt(S,E.collectionRef);return C.jsx(c,{ref:P,children:A})});h.displayName=a;const f=t+"CollectionItemSlot",d="data-radix-collection-item",m=Rh(f),y=de.forwardRef((w,S)=>{const{scope:_,children:A,...E}=w,P=de.useRef(null),O=Bt(S,P),M=s(f,_);return de.useEffect(()=>(M.itemMap.set(P,{ref:P,...E}),()=>void M.itemMap.delete(P))),C.jsx(m,{[d]:"",ref:O,children:A})});y.displayName=f;function b(w){const S=s(t+"CollectionConsumer",w);return de.useCallback(()=>{const A=S.collectionRef.current;if(!A)return[];const E=Array.from(A.querySelectorAll(`[${d}]`));return Array.from(S.itemMap.values()).sort((M,D)=>E.indexOf(M.ref.current)-E.indexOf(D.ref.current))},[S.collectionRef,S.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},b,r]}var ise=k.createContext(void 0);function Lk(t){const e=k.useContext(ise);return t||e||"ltr"}var w_="rovingFocusGroup.onEntryFocus",sse={bubbles:!1,cancelable:!0},Um="RovingFocusGroup",[$C,M9,ose]=R9(Um),[ase,Ww]=ra(Um,[ose]),[lse,cse]=ase(Um),O9=k.forwardRef((t,e)=>C.jsx($C.Provider,{scope:t.__scopeRovingFocusGroup,children:C.jsx($C.Slot,{scope:t.__scopeRovingFocusGroup,children:C.jsx(use,{...t,ref:e})})}));O9.displayName=Um;var use=k.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...d}=t,m=k.useRef(null),y=Bt(e,m),b=Lk(s),[w,S]=qh({prop:o,defaultProp:a??null,onChange:c,caller:Um}),[_,A]=k.useState(!1),E=Lr(h),P=M9(n),O=k.useRef(!1),[M,D]=k.useState(0);return k.useEffect(()=>{const $=m.current;if($)return $.addEventListener(w_,E),()=>$.removeEventListener(w_,E)},[E]),C.jsx(lse,{scope:n,orientation:r,dir:b,loop:i,currentTabStopId:w,onItemFocus:k.useCallback($=>S($),[S]),onItemShiftTab:k.useCallback(()=>A(!0),[]),onFocusableItemAdd:k.useCallback(()=>D($=>$+1),[]),onFocusableItemRemove:k.useCallback(()=>D($=>$-1),[]),children:C.jsx(st.div,{tabIndex:_||M===0?-1:0,"data-orientation":r,...d,ref:y,style:{outline:"none",...t.style},onMouseDown:Le(t.onMouseDown,()=>{O.current=!0}),onFocus:Le(t.onFocus,$=>{const F=!O.current;if($.target===$.currentTarget&&F&&!_){const N=new CustomEvent(w_,sse);if($.currentTarget.dispatchEvent(N),!N.defaultPrevented){const U=P().filter(V=>V.focusable),q=U.find(V=>V.active),K=U.find(V=>V.id===w),ee=[q,K,...U].filter(Boolean).map(V=>V.ref.current);I9(ee,f)}}O.current=!1}),onBlur:Le(t.onBlur,()=>A(!1))})})}),P9="RovingFocusGroupItem",D9=k.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...a}=t,c=ol(),h=s||c,f=cse(P9,n),d=f.currentTabStopId===h,m=M9(n),{onFocusableItemAdd:y,onFocusableItemRemove:b,currentTabStopId:w}=f;return k.useEffect(()=>{if(r)return y(),()=>b()},[r,y,b]),C.jsx($C.ItemSlot,{scope:n,id:h,focusable:r,active:i,children:C.jsx(st.span,{tabIndex:d?0:-1,"data-orientation":f.orientation,...a,ref:e,onMouseDown:Le(t.onMouseDown,S=>{r?f.onItemFocus(h):S.preventDefault()}),onFocus:Le(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:Le(t.onKeyDown,S=>{if(S.key==="Tab"&&S.shiftKey){f.onItemShiftTab();return}if(S.target!==S.currentTarget)return;const _=dse(S,f.orientation,f.dir);if(_!==void 0){if(S.metaKey||S.ctrlKey||S.altKey||S.shiftKey)return;S.preventDefault();let E=m().filter(P=>P.focusable).map(P=>P.ref.current);if(_==="last")E.reverse();else if(_==="prev"||_==="next"){_==="prev"&&E.reverse();const P=E.indexOf(S.currentTarget);E=f.loop?pse(E,P+1):E.slice(P+1)}setTimeout(()=>I9(E))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:w!=null}):o})})});D9.displayName=P9;var hse={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function fse(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function dse(t,e,n){const r=fse(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return hse[r]}function I9(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function pse(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var L9=O9,N9=D9,qw="Tabs",[mse]=ra(qw,[Ww]),$9=Ww(),[gse,Nk]=mse(qw),j9=k.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:o="horizontal",dir:a,activationMode:c="automatic",...h}=t,f=Lk(a),[d,m]=qh({prop:r,onChange:i,defaultProp:s??"",caller:qw});return C.jsx(gse,{scope:n,baseId:ol(),value:d,onValueChange:m,orientation:o,dir:f,activationMode:c,children:C.jsx(st.div,{dir:f,"data-orientation":o,...h,ref:e})})});j9.displayName=qw;var B9="TabsList",F9=k.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...i}=t,s=Nk(B9,n),o=$9(n);return C.jsx(L9,{asChild:!0,...o,orientation:s.orientation,dir:s.dir,loop:r,children:C.jsx(st.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:e})})});F9.displayName=B9;var z9="TabsTrigger",V9=k.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=t,o=Nk(z9,n),a=$9(n),c=W9(o.baseId,r),h=q9(o.baseId,r),f=r===o.value;return C.jsx(N9,{asChild:!0,...a,focusable:!i,active:f,children:C.jsx(st.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:c,...s,ref:e,onMouseDown:Le(t.onMouseDown,d=>{!i&&d.button===0&&d.ctrlKey===!1?o.onValueChange(r):d.preventDefault()}),onKeyDown:Le(t.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&o.onValueChange(r)}),onFocus:Le(t.onFocus,()=>{const d=o.activationMode!=="manual";!f&&!i&&d&&o.onValueChange(r)})})})});V9.displayName=z9;var U9="TabsContent",H9=k.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...o}=t,a=Nk(U9,n),c=W9(a.baseId,r),h=q9(a.baseId,r),f=r===a.value,d=k.useRef(f);return k.useEffect(()=>{const m=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(m)},[]),C.jsx(Ts,{present:i||f,children:({present:m})=>C.jsx(st.div,{"data-state":f?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:d.current?"0s":void 0},children:m&&s})})});H9.displayName=U9;function W9(t,e){return`${t}-trigger-${e}`}function q9(t,e){return`${t}-content-${e}`}var yse=j9,bse=F9,vse=V9,wse=H9;const xse=({items:t,defaultValue:e,value:n,onValueChange:r,className:i})=>C.jsxs(yse,{defaultValue:e||t[0]?.value,value:n,onValueChange:r,className:je("w-full",i),children:[C.jsx(bse,{className:"w-full inline-flex h-[32px] gap-[20px] items-center border-b-[1px] border-[var(--tabs-border-color)]",children:t.map(s=>C.jsx(vse,{value:s.value,disabled:s.disabled,className:je("font-normal text-[14px] leading-[20px] text-[var(--tabs-color)] cursor-pointer pb-[3px] relative","hover:enabled:data-[state=inactive]:after:content-[''] hover:enabled:data-[state=inactive]:after:absolute hover:enabled:data-[state=inactive]:after:bottom-[-5px] hover:enabled:data-[state=inactive]:after:left-1/2 hover:enabled:data-[state=inactive]:after:transform hover:enabled:data-[state=inactive]:after:-translate-x-1/2 hover:enabled:data-[state=inactive]:after:w-[24px] hover:enabled:data-[state=inactive]:after:h-[4px] hover:enabled:data-[state=inactive]:after:bg-[var(--tabs-hover-border-color)] hover:enabled:data-[state=inactive]:after:rounded-t-[3px]","data-[state=active]:font-bold data-[state=active]:after:content-[''] data-[state=active]:after:absolute data-[state=active]:after:bottom-[-5px] data-[state=active]:after:left-0 data-[state=active]:after:right-0 data-[state=active]:after:h-[4px] data-[state=active]:after:bg-[var(--tabs-active-border-color)] data-[state=active]:after:rounded-t-[3px]","disabled:opacity-50 disabled:cursor-not-allowed"),children:s.label},s.value))}),t.map(s=>C.jsx(wse,{value:s.value,className:"mt-[24px]",children:s.content},s.value))]}),$k="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='14.9998'%20cy='9.99975'%20r='0.999754'%20fill='%231C1B1F'/%3e%3ccircle%20cx='4.99975'%20cy='9.99975'%20r='0.999754'%20fill='%231C1B1F'/%3e%3ccircle%20cx='9.99975'%20cy='9.99975'%20r='0.999754'%20fill='%231C1B1F'/%3e%3c/svg%3e",jk="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M13.5%205C14.3284%205%2015%205.67157%2015%206.5V8H17.5C17.7761%208%2018%208.22386%2018%208.5C18%208.77614%2017.7761%209%2017.5%209H17V17.5C17%2018.3284%2016.3284%2019%2015.5%2019H8.5C7.67157%2019%207%2018.3284%207%2017.5V9H6.5C6.22386%209%206%208.77614%206%208.5C6%208.22386%206.22386%208%206.5%208H9V6.5C9%205.67157%209.67157%205%2010.5%205H13.5ZM8%2017.5C8%2017.7761%208.22386%2018%208.5%2018H15.5C15.7761%2018%2016%2017.7761%2016%2017.5V9H8V17.5ZM10.5%2011C10.7761%2011%2011%2011.2239%2011%2011.5V15.5C11%2015.7761%2010.7761%2016%2010.5%2016C10.2239%2016%2010%2015.7761%2010%2015.5V11.5C10%2011.2239%2010.2239%2011%2010.5%2011ZM13.5%2011C13.7761%2011%2014%2011.2239%2014%2011.5V15.5C14%2015.7761%2013.7761%2016%2013.5%2016C13.2239%2016%2013%2015.7761%2013%2015.5V11.5C13%2011.2239%2013.2239%2011%2013.5%2011ZM10.5%206C10.2239%206%2010%206.22386%2010%206.5V8H14V6.5C14%206.22386%2013.7761%206%2013.5%206H10.5Z'%20fill='%23383838'/%3e%3c/svg%3e",Sse="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12.5%207.49985L5.5%2014.4998V17.4998H8.5L15.5%2010.4998M12.5%207.49985L14.7929%205.20696C15.1834%204.81643%2015.8166%204.81643%2016.2071%205.20696L17.7929%206.79274C18.1834%207.18327%2018.1834%207.81643%2017.7929%208.20696L15.5%2010.4998M12.5%207.49985L15.5%2010.4998M12.5%2017.4998H18.5'%20stroke='%23383838'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",G9="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='8'%20cy='8'%20r='7'%20fill='%23EF4444'/%3e%3cpath%20d='M7%2011C7%2010.4477%207.44772%2010%208%2010C8.55228%2010%209%2010.4477%209%2011C9%2011.5523%208.55228%2012%208%2012C7.44772%2012%207%2011.5523%207%2011Z'%20fill='white'/%3e%3cpath%20d='M8%204.5C8.27614%204.5%208.5%204.72386%208.5%205V8C8.5%208.27614%208.27614%208.5%208%208.5C7.72386%208.5%207.5%208.27614%207.5%208V5C7.5%204.72386%207.72386%204.5%208%204.5Z'%20fill='white'%20stroke='white'/%3e%3c/svg%3e";function jC(t,e){return jC=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},jC(t,e)}function _se(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,jC(t,e)}var wy={};/*!
* content-type
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/var DL;function Cse(){if(DL)return wy;DL=1;var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,e=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,n=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,r=/\\([\u000b\u0020-\u00ff])/g,i=/([\\"])/g,s=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;wy.format=o,wy.parse=a;function o(d){if(!d||typeof d!="object")throw new TypeError("argument obj is required");var m=d.parameters,y=d.type;if(!y||!s.test(y))throw new TypeError("invalid type");var b=y;if(m&&typeof m=="object")for(var w,S=Object.keys(m).sort(),_=0;_<S.length;_++){if(w=S[_],!n.test(w))throw new TypeError("invalid parameter name");b+="; "+w+"="+h(m[w])}return b}function a(d){if(!d)throw new TypeError("argument string is required");var m=typeof d=="object"?c(d):d;if(typeof m!="string")throw new TypeError("argument string is required to be a string");var y=m.indexOf(";"),b=y!==-1?m.slice(0,y).trim():m.trim();if(!s.test(b))throw new TypeError("invalid media type");var w=new f(b.toLowerCase());if(y!==-1){var S,_,A;for(t.lastIndex=y;_=t.exec(m);){if(_.index!==y)throw new TypeError("invalid parameter format");y+=_[0].length,S=_[1].toLowerCase(),A=_[2],A.charCodeAt(0)===34&&(A=A.slice(1,-1),A.indexOf("\\")!==-1&&(A=A.replace(r,"$1"))),w.parameters[S]=A}if(y!==m.length)throw new TypeError("invalid parameter format")}return w}function c(d){var m;if(typeof d.getHeader=="function"?m=d.getHeader("content-type"):typeof d.headers=="object"&&(m=d.headers&&d.headers["content-type"]),typeof m!="string")throw new TypeError("content-type header is missing from object");return m}function h(d){var m=String(d);if(n.test(m))return m;if(m.length>0&&!e.test(m))throw new TypeError("invalid parameter value");return'"'+m.replace(i,"\\$1")+'"'}function f(d){this.parameters=Object.create(null),this.type=d}return wy}var Ase=Cse(),Ju=new Map,K9=function(e){return e.cloneNode(!0)},IL=function(){return window.location.protocol==="file:"},Y9=function(e,n,r){var i=new XMLHttpRequest;i.onreadystatechange=function(){try{if(!/\.svg/i.test(e)&&i.readyState===2){var s=i.getResponseHeader("Content-Type");if(!s)throw new Error("Content type not found");var o=Ase.parse(s).type;if(!(o==="image/svg+xml"||o==="text/plain"))throw new Error("Invalid content type: ".concat(o))}if(i.readyState===4){if(i.status===404||i.responseXML===null)throw new Error(IL()?"Note: SVG injection ajax calls do not work locally without adjusting security settings in your browser. Or consider using a local webserver.":"Unable to load SVG file: "+e);if(i.status===200||IL()&&i.status===0)r(null,i);else throw new Error("There was a problem injecting the SVG: "+i.status+" "+i.statusText)}}catch(a){if(i.abort(),a instanceof Error)r(a,i);else throw a}},i.open("GET",e),i.withCredentials=n,i.overrideMimeType&&i.overrideMimeType("text/xml"),i.send()},Za={},LL=function(e,n){Za[e]=Za[e]||[],Za[e].push(n)},Ese=function(e){for(var n=function(o,a){setTimeout(function(){if(Array.isArray(Za[e])){var c=Ju.get(e),h=Za[e][o];c instanceof SVGSVGElement&&h(null,K9(c)),c instanceof Error&&h(c),o===Za[e].length-1&&delete Za[e]}},0)},r=0,i=Za[e].length;r<i;r++)n(r)},kse=function(e,n,r){if(Ju.has(e)){var i=Ju.get(e);if(i===void 0){LL(e,r);return}if(i instanceof SVGSVGElement){r(null,K9(i));return}}Ju.set(e,void 0),LL(e,r),Y9(e,n,function(s,o){var a;s?Ju.set(e,s):((a=o.responseXML)===null||a===void 0?void 0:a.documentElement)instanceof SVGSVGElement&&Ju.set(e,o.responseXML.documentElement),Ese(e)})},Tse=function(e,n,r){Y9(e,n,function(i,s){var o;i?r(i):((o=s.responseXML)===null||o===void 0?void 0:o.documentElement)instanceof SVGSVGElement&&r(null,s.responseXML.documentElement)})},Rse=0,Mse=function(){return++Rse},Hs=[],NL={},Ose="http://www.w3.org/2000/svg",x_="http://www.w3.org/1999/xlink",$L=function(e,n,r,i,s,o,a){var c=e.getAttribute("data-src")||e.getAttribute("src");if(!c){a(new Error("Invalid data-src or src attribute"));return}if(Hs.indexOf(e)!==-1){Hs.splice(Hs.indexOf(e),1),e=null;return}Hs.push(e),e.setAttribute("src","");var h=i?kse:Tse;h(c,s,function(f,d){if(!d){Hs.splice(Hs.indexOf(e),1),e=null,a(f);return}var m=e.getAttribute("id");m&&d.setAttribute("id",m);var y=e.getAttribute("title");y&&d.setAttribute("title",y);var b=e.getAttribute("width");b&&d.setAttribute("width",b);var w=e.getAttribute("height");w&&d.setAttribute("height",w);var S=Array.from(new Set(ob(ob(ob([],(d.getAttribute("class")||"").split(" "),!0),["injected-svg"],!1),(e.getAttribute("class")||"").split(" "),!0))).join(" ").trim();d.setAttribute("class",S);var _=e.getAttribute("style");_&&d.setAttribute("style",_),d.setAttribute("data-src",c);var A=[].filter.call(e.attributes,function(H){return/^data-\w[\w-]*$/.test(H.name)});if(Array.prototype.forEach.call(A,function(H){H.name&&H.value&&d.setAttribute(H.name,H.value)}),r){var E={clipPath:["clip-path"],"color-profile":["color-profile"],cursor:["cursor"],filter:["filter"],linearGradient:["fill","stroke"],marker:["marker","marker-start","marker-mid","marker-end"],mask:["mask"],path:[],pattern:["fill","stroke"],radialGradient:["fill","stroke"]},P,O,M,D,$;Object.keys(E).forEach(function(H){P=H,M=E[H],O=d.querySelectorAll(P+"[id]");for(var se=function(L,pe){D=O[L].id,$=D+"-"+Mse();var ke;Array.prototype.forEach.call(M,function(tr){ke=d.querySelectorAll("["+tr+'*="'+D+'"]');for(var ti=0,_o=ke.length;ti<_o;ti++){var ss=ke[ti].getAttribute(tr);ss&&!ss.match(new RegExp('url\\("?#'+D+'"?\\)'))||ke[ti].setAttribute(tr,"url(#"+$+")")}});for(var be=d.querySelectorAll("[*|href]"),Ee=[],Ue=0,Pt=be.length;Ue<Pt;Ue++){var Kt=be[Ue].getAttributeNS(x_,"href");Kt&&Kt.toString()==="#"+O[L].id&&Ee.push(be[Ue])}for(var Yt=0,er=Ee.length;Yt<er;Yt++)Ee[Yt].setAttributeNS(x_,"href","#"+$);O[L].id=$},T=0,Z=O.length;T<Z;T++)se(T)})}d.removeAttribute("xmlns:a");for(var F=d.querySelectorAll("script"),N=[],U,q,K=0,X=F.length;K<X;K++)q=F[K].getAttribute("type"),(!q||q==="application/ecmascript"||q==="application/javascript"||q==="text/javascript")&&(U=F[K].innerText||F[K].textContent,U&&N.push(U),d.removeChild(F[K]));if(N.length>0&&(n==="always"||n==="once"&&!NL[c])){for(var ee=0,V=N.length;ee<V;ee++)new Function(N[ee])(window);NL[c]=!0}var G=d.querySelectorAll("style");if(Array.prototype.forEach.call(G,function(H){H.textContent+=""}),d.setAttribute("xmlns",Ose),d.setAttribute("xmlns:xlink",x_),o(d),!e.parentNode){Hs.splice(Hs.indexOf(e),1),e=null,a(new Error("Parent node is null"));return}e.parentNode.replaceChild(d,e),Hs.splice(Hs.indexOf(e),1),e=null,a(null,d)})},Pse=function(e,n){var r=n===void 0?{}:n,i=r.afterAll,s=i===void 0?function(){}:i,o=r.afterEach,a=o===void 0?function(){}:o,c=r.beforeEach,h=c===void 0?function(){}:c,f=r.cacheRequests,d=f===void 0?!0:f,m=r.evalScripts,y=m===void 0?"never":m,b=r.httpRequestWithCredentials,w=b===void 0?!1:b,S=r.renumerateIRIElements,_=S===void 0?!0:S;if(e&&"length"in e)for(var A=0,E=0,P=e.length;E<P;E++)$L(e[E],y,_,d,w,h,function(O,M){a(O,M),e&&"length"in e&&e.length===++A&&s(A)});else e?$L(e,y,_,d,w,h,function(O,M){a(O,M),s(1),e=null}):s(0)},S_={exports:{}},__,jL;function Dse(){if(jL)return __;jL=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return __=t,__}var C_,BL;function Ise(){if(BL)return C_;BL=1;var t=Dse();function e(){}function n(){}return n.resetWarningCache=e,C_=function(){function r(o,a,c,h,f,d){if(d!==t){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}}r.isRequired=r;function i(){return r}var s={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:e};return s.PropTypes=s,s},C_}var FL;function Lse(){return FL||(FL=1,S_.exports=Ise()()),S_.exports}var _n=Lse(),Nse=function(e){var n=e?.ownerDocument||document;return n.defaultView||window},$se=function(e,n){for(var r in e)if(!(r in n))return!0;for(var i in n)if(e[i]!==n[i])return!0;return!1},jse=["afterInjection","beforeInjection","desc","evalScripts","fallback","httpRequestWithCredentials","loading","renumerateIRIElements","src","title","useRequestCache","wrapper"],xy="http://www.w3.org/2000/svg",zL="http://www.w3.org/1999/xlink",dn=(function(t){function e(){for(var r,i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];return r=t.call.apply(t,[this].concat(s))||this,r.initialState={hasError:!1,isLoading:!0},r.state=r.initialState,r._isMounted=!1,r.reactWrapper=void 0,r.nonReactWrapper=void 0,r.refCallback=function(a){r.reactWrapper=a},r}_se(e,t);var n=e.prototype;return n.renderSVG=function(){var i=this;if(this.reactWrapper instanceof Nse(this.reactWrapper).Node){var s=this.props,o=s.desc,a=s.evalScripts,c=s.httpRequestWithCredentials,h=s.renumerateIRIElements,f=s.src,d=s.title,m=s.useRequestCache,y=this.props.onError,b=this.props.beforeInjection,w=this.props.afterInjection,S=this.props.wrapper,_,A;S==="svg"?(_=document.createElementNS(xy,S),_.setAttribute("xmlns",xy),_.setAttribute("xmlns:xlink",zL),A=document.createElementNS(xy,S)):(_=document.createElement(S),A=document.createElement(S)),_.appendChild(A),A.dataset.src=f,this.nonReactWrapper=this.reactWrapper.appendChild(_);var E=function(D){if(i.removeSVG(),!i._isMounted){y(D);return}i.setState(function(){return{hasError:!0,isLoading:!1}},function(){y(D)})},P=function(D,$){if(D){E(D);return}i._isMounted&&i.setState(function(){return{isLoading:!1}},function(){try{w($)}catch(F){E(F)}})},O=function(D){if(D.setAttribute("role","img"),o){var $=D.querySelector(":scope > desc");$&&D.removeChild($);var F=document.createElement("desc");F.innerHTML=o,D.prepend(F)}if(d){var N=D.querySelector(":scope > title");N&&D.removeChild(N);var U=document.createElement("title");U.innerHTML=d,D.prepend(U)}try{b(D)}catch(q){E(q)}};Pse(A,{afterEach:P,beforeEach:O,cacheRequests:m,evalScripts:a,httpRequestWithCredentials:c,renumerateIRIElements:h})}},n.removeSVG=function(){var i;(i=this.nonReactWrapper)!=null&&i.parentNode&&(this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper),this.nonReactWrapper=null)},n.componentDidMount=function(){this._isMounted=!0,this.renderSVG()},n.componentDidUpdate=function(i){var s=this;$se(Gp({},i),this.props)&&this.setState(function(){return s.initialState},function(){s.removeSVG(),s.renderSVG()})},n.componentWillUnmount=function(){this._isMounted=!1,this.removeSVG()},n.render=function(){var i=this.props;i.afterInjection,i.beforeInjection,i.desc,i.evalScripts;var s=i.fallback;i.httpRequestWithCredentials;var o=i.loading;i.renumerateIRIElements,i.src,i.title,i.useRequestCache;var a=i.wrapper,c=iB(i,jse),h=a;return k.createElement(h,Gp({},c,{ref:this.refCallback},a==="svg"?{xmlns:xy,xmlnsXlink:zL}:{}),this.state.isLoading&&o&&k.createElement(o,null),this.state.hasError&&s&&k.createElement(s,null))},e})(k.Component);dn.defaultProps={afterInjection:function(){},beforeInjection:function(){},desc:"",evalScripts:"never",fallback:null,httpRequestWithCredentials:!1,loading:null,onError:function(){},renumerateIRIElements:!0,title:"",useRequestCache:!0,wrapper:"div"};dn.propTypes={afterInjection:_n.func,beforeInjection:_n.func,desc:_n.string,evalScripts:_n.oneOf(["always","once","never"]),fallback:_n.oneOfType([_n.func,_n.object,_n.string]),httpRequestWithCredentials:_n.bool,loading:_n.oneOfType([_n.func,_n.object,_n.string]),onError:_n.func,renumerateIRIElements:_n.bool,src:_n.string.isRequired,title:_n.string,useRequestCache:_n.bool,wrapper:_n.oneOf(["div","span","svg"])};const gt=({iconName:t,size:e,isStroke:n,isTransform:r,isActive:i,className:s,insideElement:o,disableHover:a,color:c,noColor:h,...f})=>{const d=a?void 0:o?"hover:enabled:bg-[var(--icon-button-hover-on-active-background-color)]":"hover:enabled:bg-[var(--icon-button-hover-background-color)]",m=a?void 0:"active:enabled:bg-[var(--icon-button-pressed-background-color)]",y="border-none cursor-pointer rounded-[4px] bg-none p-0 m-0",b="flex items-center justify-center",w="disabled:cursor-not-allowed disabled:opacity-[0.5]",S="outline-none focus:outline-none focus-visible:outline-none",_=k.useCallback(A=>{if(h)return;A.querySelectorAll("path").forEach(O=>{n?O.setAttribute("stroke",c||"var(--icon-button-color)"):O.setAttribute("fill",c||"var(--icon-button-color)")}),A.querySelectorAll("circle").forEach(O=>{n?O.setAttribute("stroke",c||"var(--icon-button-color)"):O.setAttribute("fill",c||"var(--icon-button-color)")})},[n,c,h]);return C.jsx("button",{className:je(y,b,d,m,w,S,s),style:{width:`${e}px`,height:`${e}px`,...i?{backgroundColor:"var(--icon-button-pressed-background-color)"}:{}},...f,children:C.jsx(dn,{src:t,className:`flex items-center justify-center ${r?"rotate-90":""}`,beforeInjection:_})})};var BC=["Enter"," "],Bse=["ArrowDown","PageUp","Home"],X9=["ArrowUp","PageDown","End"],Fse=[...Bse,...X9],zse={ltr:[...BC,"ArrowRight"],rtl:[...BC,"ArrowLeft"]},Vse={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Hm="Menu",[Jp,Use,Hse]=R9(Hm),[Ic,J9]=ra(Hm,[Hse,Ow,Ww]),Gw=Ow(),Q9=Ww(),[Wse,Lc]=Ic(Hm),[qse,Wm]=Ic(Hm),Z9=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=t,a=Gw(e),[c,h]=k.useState(null),f=k.useRef(!1),d=Lr(s),m=Lk(i);return k.useEffect(()=>{const y=()=>{f.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>f.current=!1;return document.addEventListener("keydown",y,{capture:!0}),()=>{document.removeEventListener("keydown",y,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),C.jsx(jj,{...a,children:C.jsx(Wse,{scope:e,open:n,onOpenChange:d,content:c,onContentChange:h,children:C.jsx(qse,{scope:e,onClose:k.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:f,dir:m,modal:o,children:r})})})};Z9.displayName=Hm;var Gse="MenuAnchor",Bk=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=Gw(n);return C.jsx(Bj,{...i,...r,ref:e})});Bk.displayName=Gse;var Fk="MenuPortal",[Kse,eF]=Ic(Fk,{forceMount:void 0}),tF=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:i}=t,s=Lc(Fk,e);return C.jsx(Kse,{scope:e,forceMount:n,children:C.jsx(Ts,{present:n||s.open,children:C.jsx(Pw,{asChild:!0,container:i,children:r})})})};tF.displayName=Fk;var Ji="MenuContent",[Yse,zk]=Ic(Ji),nF=k.forwardRef((t,e)=>{const n=eF(Ji,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=Lc(Ji,t.__scopeMenu),o=Wm(Ji,t.__scopeMenu);return C.jsx(Jp.Provider,{scope:t.__scopeMenu,children:C.jsx(Ts,{present:r||s.open,children:C.jsx(Jp.Slot,{scope:t.__scopeMenu,children:o.modal?C.jsx(Xse,{...i,ref:e}):C.jsx(Jse,{...i,ref:e})})})})}),Xse=k.forwardRef((t,e)=>{const n=Lc(Ji,t.__scopeMenu),r=k.useRef(null),i=Bt(e,r);return k.useEffect(()=>{const s=r.current;if(s)return Uj(s)},[]),C.jsx(Vk,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Le(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Jse=k.forwardRef((t,e)=>{const n=Lc(Ji,t.__scopeMenu);return C.jsx(Vk,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Qse=Rh("MenuContent.ScrollLock"),Vk=k.forwardRef((t,e)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:d,onInteractOutside:m,onDismiss:y,disableOutsideScroll:b,...w}=t,S=Lc(Ji,n),_=Wm(Ji,n),A=Gw(n),E=Q9(n),P=Use(n),[O,M]=k.useState(null),D=k.useRef(null),$=Bt(e,D,S.onContentChange),F=k.useRef(0),N=k.useRef(""),U=k.useRef(0),q=k.useRef(null),K=k.useRef("right"),X=k.useRef(0),ee=b?HE:k.Fragment,V=b?{as:Qse,allowPinchZoom:!0}:void 0,G=se=>{const T=N.current+se,Z=P().filter(Ee=>!Ee.disabled),ue=document.activeElement,L=Z.find(Ee=>Ee.ref.current===ue)?.textValue,pe=Z.map(Ee=>Ee.textValue),ke=uoe(pe,T,L),be=Z.find(Ee=>Ee.textValue===ke)?.ref.current;(function Ee(Ue){N.current=Ue,window.clearTimeout(F.current),Ue!==""&&(F.current=window.setTimeout(()=>Ee(""),1e3))})(T),be&&setTimeout(()=>be.focus())};k.useEffect(()=>()=>window.clearTimeout(F.current),[]),pj();const H=k.useCallback(se=>K.current===q.current?.side&&foe(se,q.current?.area),[]);return C.jsx(Yse,{scope:n,searchRef:N,onItemEnter:k.useCallback(se=>{H(se)&&se.preventDefault()},[H]),onItemLeave:k.useCallback(se=>{H(se)||(D.current?.focus(),M(null))},[H]),onTriggerLeave:k.useCallback(se=>{H(se)&&se.preventDefault()},[H]),pointerGraceTimerRef:U,onPointerGraceIntentChange:k.useCallback(se=>{q.current=se},[]),children:C.jsx(ee,{...V,children:C.jsx(LE,{asChild:!0,trapped:i,onMountAutoFocus:Le(s,se=>{se.preventDefault(),D.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:C.jsx(Ew,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:d,onInteractOutside:m,onDismiss:y,children:C.jsx(L9,{asChild:!0,...E,dir:_.dir,orientation:"vertical",loop:r,currentTabStopId:O,onCurrentTabStopIdChange:M,onEntryFocus:Le(c,se=>{_.isUsingKeyboardRef.current||se.preventDefault()}),preventScrollOnEntryFocus:!0,children:C.jsx(Fj,{role:"menu","aria-orientation":"vertical","data-state":bF(S.open),"data-radix-menu-content":"",dir:_.dir,...A,...w,ref:$,style:{outline:"none",...w.style},onKeyDown:Le(w.onKeyDown,se=>{const Z=se.target.closest("[data-radix-menu-content]")===se.currentTarget,ue=se.ctrlKey||se.altKey||se.metaKey,L=se.key.length===1;Z&&(se.key==="Tab"&&se.preventDefault(),!ue&&L&&G(se.key));const pe=D.current;if(se.target!==pe||!Fse.includes(se.key))return;se.preventDefault();const be=P().filter(Ee=>!Ee.disabled).map(Ee=>Ee.ref.current);X9.includes(se.key)&&be.reverse(),loe(be)}),onBlur:Le(t.onBlur,se=>{se.currentTarget.contains(se.target)||(window.clearTimeout(F.current),N.current="")}),onPointerMove:Le(t.onPointerMove,Qp(se=>{const T=se.target,Z=X.current!==se.clientX;if(se.currentTarget.contains(T)&&Z){const ue=se.clientX>X.current?"right":"left";K.current=ue,X.current=se.clientX}}))})})})})})})});nF.displayName=Ji;var Zse="MenuGroup",Uk=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return C.jsx(st.div,{role:"group",...r,ref:e})});Uk.displayName=Zse;var eoe="MenuLabel",rF=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return C.jsx(st.div,{...r,ref:e})});rF.displayName=eoe;var bv="MenuItem",VL="menu.itemSelect",Kw=k.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...i}=t,s=k.useRef(null),o=Wm(bv,t.__scopeMenu),a=zk(bv,t.__scopeMenu),c=Bt(e,s),h=k.useRef(!1),f=()=>{const d=s.current;if(!n&&d){const m=new CustomEvent(VL,{bubbles:!0,cancelable:!0});d.addEventListener(VL,y=>r?.(y),{once:!0}),aj(d,m),m.defaultPrevented?h.current=!1:o.onClose()}};return C.jsx(iF,{...i,ref:c,disabled:n,onClick:Le(t.onClick,f),onPointerDown:d=>{t.onPointerDown?.(d),h.current=!0},onPointerUp:Le(t.onPointerUp,d=>{h.current||d.currentTarget?.click()}),onKeyDown:Le(t.onKeyDown,d=>{const m=a.searchRef.current!=="";n||m&&d.key===" "||BC.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Kw.displayName=bv;var iF=k.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=t,o=zk(bv,n),a=Q9(n),c=k.useRef(null),h=Bt(e,c),[f,d]=k.useState(!1),[m,y]=k.useState("");return k.useEffect(()=>{const b=c.current;b&&y((b.textContent??"").trim())},[s.children]),C.jsx(Jp.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:C.jsx(N9,{asChild:!0,...a,focusable:!r,children:C.jsx(st.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:h,onPointerMove:Le(t.onPointerMove,Qp(b=>{r?o.onItemLeave(b):(o.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Le(t.onPointerLeave,Qp(b=>o.onItemLeave(b))),onFocus:Le(t.onFocus,()=>d(!0)),onBlur:Le(t.onBlur,()=>d(!1))})})})}),toe="MenuCheckboxItem",sF=k.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...i}=t;return C.jsx(uF,{scope:t.__scopeMenu,checked:n,children:C.jsx(Kw,{role:"menuitemcheckbox","aria-checked":vv(n)?"mixed":n,...i,ref:e,"data-state":Wk(n),onSelect:Le(i.onSelect,()=>r?.(vv(n)?!0:!n),{checkForDefaultPrevented:!1})})})});sF.displayName=toe;var oF="MenuRadioGroup",[noe,roe]=Ic(oF,{value:void 0,onValueChange:()=>{}}),aF=k.forwardRef((t,e)=>{const{value:n,onValueChange:r,...i}=t,s=Lr(r);return C.jsx(noe,{scope:t.__scopeMenu,value:n,onValueChange:s,children:C.jsx(Uk,{...i,ref:e})})});aF.displayName=oF;var lF="MenuRadioItem",cF=k.forwardRef((t,e)=>{const{value:n,...r}=t,i=roe(lF,t.__scopeMenu),s=n===i.value;return C.jsx(uF,{scope:t.__scopeMenu,checked:s,children:C.jsx(Kw,{role:"menuitemradio","aria-checked":s,...r,ref:e,"data-state":Wk(s),onSelect:Le(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});cF.displayName=lF;var Hk="MenuItemIndicator",[uF,ioe]=Ic(Hk,{checked:!1}),hF=k.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...i}=t,s=ioe(Hk,n);return C.jsx(Ts,{present:r||vv(s.checked)||s.checked===!0,children:C.jsx(st.span,{...i,ref:e,"data-state":Wk(s.checked)})})});hF.displayName=Hk;var soe="MenuSeparator",fF=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return C.jsx(st.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});fF.displayName=soe;var ooe="MenuArrow",dF=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=Gw(n);return C.jsx(zj,{...i,...r,ref:e})});dF.displayName=ooe;var aoe="MenuSub",[Y6e,pF]=Ic(aoe),cp="MenuSubTrigger",mF=k.forwardRef((t,e)=>{const n=Lc(cp,t.__scopeMenu),r=Wm(cp,t.__scopeMenu),i=pF(cp,t.__scopeMenu),s=zk(cp,t.__scopeMenu),o=k.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,h={__scopeMenu:t.__scopeMenu},f=k.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return k.useEffect(()=>f,[f]),k.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),c(null)}},[a,c]),C.jsx(Bk,{asChild:!0,...h,children:C.jsx(iF,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":bF(n.open),...t,ref:Aw(e,i.onTriggerChange),onClick:d=>{t.onClick?.(d),!(t.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Le(t.onPointerMove,Qp(d=>{s.onItemEnter(d),!d.defaultPrevented&&!t.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:Le(t.onPointerLeave,Qp(d=>{f();const m=n.content?.getBoundingClientRect();if(m){const y=n.content?.dataset.side,b=y==="right",w=b?-5:5,S=m[b?"left":"right"],_=m[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+w,y:d.clientY},{x:S,y:m.top},{x:_,y:m.top},{x:_,y:m.bottom},{x:S,y:m.bottom}],side:y}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Le(t.onKeyDown,d=>{const m=s.searchRef.current!=="";t.disabled||m&&d.key===" "||zse[r.dir].includes(d.key)&&(n.onOpenChange(!0),n.content?.focus(),d.preventDefault())})})})});mF.displayName=cp;var gF="MenuSubContent",yF=k.forwardRef((t,e)=>{const n=eF(Ji,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=Lc(Ji,t.__scopeMenu),o=Wm(Ji,t.__scopeMenu),a=pF(gF,t.__scopeMenu),c=k.useRef(null),h=Bt(e,c);return C.jsx(Jp.Provider,{scope:t.__scopeMenu,children:C.jsx(Ts,{present:r||s.open,children:C.jsx(Jp.Slot,{scope:t.__scopeMenu,children:C.jsx(Vk,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:h,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{o.isUsingKeyboardRef.current&&c.current?.focus(),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:Le(t.onFocusOutside,f=>{f.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Le(t.onEscapeKeyDown,f=>{o.onClose(),f.preventDefault()}),onKeyDown:Le(t.onKeyDown,f=>{const d=f.currentTarget.contains(f.target),m=Vse[o.dir].includes(f.key);d&&m&&(s.onOpenChange(!1),a.trigger?.focus(),f.preventDefault())})})})})})});yF.displayName=gF;function bF(t){return t?"open":"closed"}function vv(t){return t==="indeterminate"}function Wk(t){return vv(t)?"indeterminate":t?"checked":"unchecked"}function loe(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function coe(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function uoe(t,e,n){const i=e.length>1&&Array.from(e).every(h=>h===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let o=coe(t,Math.max(s,0));i.length===1&&(o=o.filter(h=>h!==n));const c=o.find(h=>h.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}function hoe(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,o=e.length-1;s<e.length;o=s++){const a=e[s],c=e[o],h=a.x,f=a.y,d=c.x,m=c.y;f>r!=m>r&&n<(d-h)*(r-f)/(m-f)+h&&(i=!i)}return i}function foe(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return hoe(n,e)}function Qp(t){return e=>e.pointerType==="mouse"?t(e):void 0}var doe=Z9,poe=Bk,moe=tF,goe=nF,yoe=Uk,boe=rF,voe=Kw,woe=sF,xoe=aF,Soe=cF,_oe=hF,Coe=fF,Aoe=dF,Eoe=mF,koe=yF,Yw="DropdownMenu",[Toe]=ra(Yw,[J9]),Nr=J9(),[Roe,vF]=Toe(Yw),wF=t=>{const{__scopeDropdownMenu:e,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=t,c=Nr(e),h=k.useRef(null),[f,d]=qh({prop:i,defaultProp:s??!1,onChange:o,caller:Yw});return C.jsx(Roe,{scope:e,triggerId:ol(),triggerRef:h,contentId:ol(),open:f,onOpenChange:d,onOpenToggle:k.useCallback(()=>d(m=>!m),[d]),modal:a,children:C.jsx(doe,{...c,open:f,onOpenChange:d,dir:r,modal:a,children:n})})};wF.displayName=Yw;var xF="DropdownMenuTrigger",SF=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=t,s=vF(xF,n),o=Nr(n);return C.jsx(poe,{asChild:!0,...o,children:C.jsx(st.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:Aw(e,s.triggerRef),onPointerDown:Le(t.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Le(t.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});SF.displayName=xF;var Moe="DropdownMenuPortal",_F=t=>{const{__scopeDropdownMenu:e,...n}=t,r=Nr(e);return C.jsx(moe,{...r,...n})};_F.displayName=Moe;var CF="DropdownMenuContent",AF=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=vF(CF,n),s=Nr(n),o=k.useRef(!1);return C.jsx(goe,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:e,onCloseAutoFocus:Le(t.onCloseAutoFocus,a=>{o.current||i.triggerRef.current?.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Le(t.onInteractOutside,a=>{const c=a.detail.originalEvent,h=c.button===0&&c.ctrlKey===!0,f=c.button===2||h;(!i.modal||f)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});AF.displayName=CF;var Ooe="DropdownMenuGroup",Poe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(yoe,{...i,...r,ref:e})});Poe.displayName=Ooe;var Doe="DropdownMenuLabel",Ioe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(boe,{...i,...r,ref:e})});Ioe.displayName=Doe;var Loe="DropdownMenuItem",EF=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(voe,{...i,...r,ref:e})});EF.displayName=Loe;var Noe="DropdownMenuCheckboxItem",$oe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(woe,{...i,...r,ref:e})});$oe.displayName=Noe;var joe="DropdownMenuRadioGroup",Boe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(xoe,{...i,...r,ref:e})});Boe.displayName=joe;var Foe="DropdownMenuRadioItem",zoe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(Soe,{...i,...r,ref:e})});zoe.displayName=Foe;var Voe="DropdownMenuItemIndicator",Uoe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(_oe,{...i,...r,ref:e})});Uoe.displayName=Voe;var Hoe="DropdownMenuSeparator",Woe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(Coe,{...i,...r,ref:e})});Woe.displayName=Hoe;var qoe="DropdownMenuArrow",Goe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(Aoe,{...i,...r,ref:e})});Goe.displayName=qoe;var Koe="DropdownMenuSubTrigger",Yoe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(Eoe,{...i,...r,ref:e})});Yoe.displayName=Koe;var Xoe="DropdownMenuSubContent",Joe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(koe,{...i,...r,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Joe.displayName=Xoe;var Qoe=wF,Zoe=SF,eae=_F,tae=AF,nae=EF;const qk="data:image/svg+xml,%3csvg%20width='12'%20height='12'%20viewBox='0%200%2012%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4.5%209.5L7.5%206.5L4.5%203.5'%20stroke='%23383838'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Oh="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M17.5%208.5L10.5%2015.5L7.5%2012.5'%20stroke='%23444444'%20stroke-width='1.25'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e";var rae=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),iae="VisuallyHidden",kF=k.forwardRef((t,e)=>C.jsx(st.span,{...t,ref:e,style:{...rae,...t.style}}));kF.displayName=iae;var sae=kF,[Xw]=ra("Tooltip",[Ow]),Jw=Ow(),TF="TooltipProvider",oae=700,FC="tooltip.open",[aae,Gk]=Xw(TF),RF=t=>{const{__scopeTooltip:e,delayDuration:n=oae,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=t,o=k.useRef(!0),a=k.useRef(!1),c=k.useRef(0);return k.useEffect(()=>{const h=c.current;return()=>window.clearTimeout(h)},[]),C.jsx(aae,{scope:e,isOpenDelayedRef:o,delayDuration:n,onOpen:k.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:k.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:k.useCallback(h=>{a.current=h},[]),disableHoverableContent:i,children:s})};RF.displayName=TF;var Zp="Tooltip",[lae,qm]=Xw(Zp),MF=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=t,c=Gk(Zp,t.__scopeTooltip),h=Jw(e),[f,d]=k.useState(null),m=ol(),y=k.useRef(0),b=o??c.disableHoverableContent,w=a??c.delayDuration,S=k.useRef(!1),[_,A]=qh({prop:r,defaultProp:i??!1,onChange:D=>{D?(c.onOpen(),document.dispatchEvent(new CustomEvent(FC))):c.onClose(),s?.(D)},caller:Zp}),E=k.useMemo(()=>_?S.current?"delayed-open":"instant-open":"closed",[_]),P=k.useCallback(()=>{window.clearTimeout(y.current),y.current=0,S.current=!1,A(!0)},[A]),O=k.useCallback(()=>{window.clearTimeout(y.current),y.current=0,A(!1)},[A]),M=k.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{S.current=!0,A(!0),y.current=0},w)},[w,A]);return k.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)},[]),C.jsx(jj,{...h,children:C.jsx(lae,{scope:e,contentId:m,open:_,stateAttribute:E,trigger:f,onTriggerChange:d,onTriggerEnter:k.useCallback(()=>{c.isOpenDelayedRef.current?M():P()},[c.isOpenDelayedRef,M,P]),onTriggerLeave:k.useCallback(()=>{b?O():(window.clearTimeout(y.current),y.current=0)},[O,b]),onOpen:P,onClose:O,disableHoverableContent:b,children:n})})};MF.displayName=Zp;var zC="TooltipTrigger",OF=k.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=qm(zC,n),s=Gk(zC,n),o=Jw(n),a=k.useRef(null),c=Bt(e,a,i.onTriggerChange),h=k.useRef(!1),f=k.useRef(!1),d=k.useCallback(()=>h.current=!1,[]);return k.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),C.jsx(Bj,{asChild:!0,...o,children:C.jsx(st.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:Le(t.onPointerMove,m=>{m.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:Le(t.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:Le(t.onPointerDown,()=>{i.open&&i.onClose(),h.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Le(t.onFocus,()=>{h.current||i.onOpen()}),onBlur:Le(t.onBlur,i.onClose),onClick:Le(t.onClick,i.onClose)})})});OF.displayName=zC;var Kk="TooltipPortal",[cae,uae]=Xw(Kk,{forceMount:void 0}),PF=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:i}=t,s=qm(Kk,e);return C.jsx(cae,{scope:e,forceMount:n,children:C.jsx(Ts,{present:n||s.open,children:C.jsx(Pw,{asChild:!0,container:i,children:r})})})};PF.displayName=Kk;var Ph="TooltipContent",DF=k.forwardRef((t,e)=>{const n=uae(Ph,t.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=t,o=qm(Ph,t.__scopeTooltip);return C.jsx(Ts,{present:r||o.open,children:o.disableHoverableContent?C.jsx(IF,{side:i,...s,ref:e}):C.jsx(hae,{side:i,...s,ref:e})})}),hae=k.forwardRef((t,e)=>{const n=qm(Ph,t.__scopeTooltip),r=Gk(Ph,t.__scopeTooltip),i=k.useRef(null),s=Bt(e,i),[o,a]=k.useState(null),{trigger:c,onClose:h}=n,f=i.current,{onPointerInTransitChange:d}=r,m=k.useCallback(()=>{a(null),d(!1)},[d]),y=k.useCallback((b,w)=>{const S=b.currentTarget,_={x:b.clientX,y:b.clientY},A=gae(_,S.getBoundingClientRect()),E=yae(_,A),P=bae(w.getBoundingClientRect()),O=wae([...E,...P]);a(O),d(!0)},[d]);return k.useEffect(()=>()=>m(),[m]),k.useEffect(()=>{if(c&&f){const b=S=>y(S,f),w=S=>y(S,c);return c.addEventListener("pointerleave",b),f.addEventListener("pointerleave",w),()=>{c.removeEventListener("pointerleave",b),f.removeEventListener("pointerleave",w)}}},[c,f,y,m]),k.useEffect(()=>{if(o){const b=w=>{const S=w.target,_={x:w.clientX,y:w.clientY},A=c?.contains(S)||f?.contains(S),E=!vae(_,o);A?m():E&&(m(),h())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[c,f,o,h,m]),C.jsx(IF,{...t,ref:s})}),[fae,dae]=Xw(Zp,{isInside:!1}),pae=XX("TooltipContent"),IF=k.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=t,c=qm(Ph,n),h=Jw(n),{onClose:f}=c;return k.useEffect(()=>(document.addEventListener(FC,f),()=>document.removeEventListener(FC,f)),[f]),k.useEffect(()=>{if(c.trigger){const d=m=>{m.target?.contains(c.trigger)&&f()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[c.trigger,f]),C.jsx(Ew,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:f,children:C.jsxs(Fj,{"data-state":c.stateAttribute,...h,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[C.jsx(pae,{children:r}),C.jsx(fae,{scope:n,isInside:!0,children:C.jsx(sae,{id:c.contentId,role:"tooltip",children:i||r})})]})})});DF.displayName=Ph;var LF="TooltipArrow",mae=k.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Jw(n);return dae(LF,n).isInside?null:C.jsx(zj,{...i,...r,ref:e})});mae.displayName=LF;function gae(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function yae(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function bae(t){const{top:e,right:n,bottom:r,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:r},{x:i,y:r}]}function vae(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,o=e.length-1;s<e.length;o=s++){const a=e[s],c=e[o],h=a.x,f=a.y,d=c.x,m=c.y;f>r!=m>r&&n<(d-h)*(r-f)/(m-f)+h&&(i=!i)}return i}function wae(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),xae(e)}function xae(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const i=t[r];for(;e.length>=2;){const s=e[e.length-1],o=e[e.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const i=t[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var Sae=RF,_ae=MF,Cae=OF,Aae=PF,Eae=DF;const kae=({delayDuration:t=0,...e})=>C.jsx(Sae,{"data-slot":"tooltip-provider",delayDuration:t,...e}),em=({...t})=>C.jsx(kae,{children:C.jsx(_ae,{"data-slot":"tooltip",...t})}),tm=({...t})=>C.jsx(Cae,{"data-slot":"tooltip-trigger",...t}),nm=({className:t,sideOffset:e=0,children:n,...r})=>C.jsx(Aae,{container:document.getElementById("app"),children:C.jsx(Eae,{"data-slot":"tooltip-content",sideOffset:e,className:je("mt-[4px] z-[9999]","bg-[var(--tooltip-background-color)] text-[var(--tooltip-text-color)] border border-[var(--tooltip-border-color)] shadow-[var(--tooltip-shadow)] p-[4px] rounded-[4px] text-[12px] font-[400] leading-[16px]","whitespace-pre-line",t),...r,children:n})});function Tae(t){const e=k.useRef({value:t,previous:t});return k.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var Qw="Switch",[Rae]=ra(Qw),[Mae,Oae]=Rae(Qw),NF=k.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:s,required:o,disabled:a,value:c="on",onCheckedChange:h,form:f,...d}=t,[m,y]=k.useState(null),b=Bt(e,E=>y(E)),w=k.useRef(!1),S=m?f||!!m.closest("form"):!0,[_,A]=qh({prop:i,defaultProp:s??!1,onChange:h,caller:Qw});return C.jsxs(Mae,{scope:n,checked:_,disabled:a,children:[C.jsx(st.button,{type:"button",role:"switch","aria-checked":_,"aria-required":o,"data-state":FF(_),"data-disabled":a?"":void 0,disabled:a,value:c,...d,ref:b,onClick:Le(t.onClick,E=>{A(P=>!P),S&&(w.current=E.isPropagationStopped(),w.current||E.stopPropagation())})}),S&&C.jsx(BF,{control:m,bubbles:!w.current,name:r,value:c,checked:_,required:o,disabled:a,form:f,style:{transform:"translateX(-100%)"}})]})});NF.displayName=Qw;var $F="SwitchThumb",jF=k.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,i=Oae($F,n);return C.jsx(st.span,{"data-state":FF(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:e})});jF.displayName=$F;var Pae="SwitchBubbleInput",BF=k.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...i},s)=>{const o=k.useRef(null),a=Bt(o,s),c=Tae(n),h=Tj(e);return k.useEffect(()=>{const f=o.current;if(!f)return;const d=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(d,"checked").set;if(c!==n&&y){const b=new Event("click",{bubbles:r});y.call(f,n),f.dispatchEvent(b)}},[c,n,r]),C.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:a,style:{...i.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});BF.displayName=Pae;function FF(t){return t?"checked":"unchecked"}var Dae=NF,Iae=jF;const zF=({checked:t,onCheckedChange:e,disabled:n=!1,id:r,className:i})=>C.jsx("div",{className:"flex items-center gap-2",children:C.jsx(Dae,{id:r,checked:t,onCheckedChange:e,disabled:n,className:je("relative inline-flex align-center shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out","focus:outline-none","disabled:cursor-not-allowed disabled:opacity-50","bg-[var(--toggle-button-off-background-color)] data-[state=checked]:bg-[var(--toggle-button-background-color)]","data-[state=checked]:hover:enabled:bg-[var(--toggle-button-background-hover-color)]","w-[24px] h-[14px]",i),children:C.jsx(Iae,{className:je("pointer-events-none inline-block rounded-full bg-[var(--toggle-button-circle-color)] ring-0 transition-transform duration-200 ease-in-out","w-[10px] h-[10px] translate-x-[1px] data-[state=checked]:translate-x-[10px]")})})}),Lae=({text:t,icon:e,iconSize:n=16,onClick:r,isActive:i,isSeparator:s,withToggle:o,toggleChecked:a,onToggleChange:c,toggleDisabled:h,subMenu:f,checked:d,tooltipText:m,withSpace:y})=>{const[b,w]=k.useState(!1),[S,_]=k.useState("right"),A=k.useRef(null),E=k.useRef(null);if(s)return C.jsx("div",{className:"h-px min-h-[1px] w-full bg-[var(--drop-down-menu-separator-color)] my-[4px] flex-shrink-0"});const P=F=>{if(o){F.stopPropagation(),F.preventDefault();return}r(F)},O=F=>{F.stopPropagation(),F.preventDefault(),!h&&c?.(!a)},M=F=>{if(!A.current||!E.current)return;const N=F.clientX,U=F.clientY,q=A.current.getBoundingClientRect(),K=E.current?.getBoundingClientRect(),X=N>=q.left&&N<=q.right&&U>=q.top&&U<=q.bottom,ee=K&&N>=K.left&&N<=K.right&&U>=K.top&&U<=K.bottom;!X&&!ee&&(w(!1),window.removeEventListener("mousemove",M))},D=()=>{if(!(b||!f)){if(A.current){const F=A.current.getBoundingClientRect(),U=window.innerWidth-F.right,q=304;let K="right";U<q&&(K="left"),_(K),K==="left"&&setTimeout(()=>{E.current&&(E.current.style.position="fixed",K==="left"&&(E.current.style.left="unset",E.current.style.bottom="-19px",E.current.style.right="121px"))},0)}w(!0),window.addEventListener("mousemove",M)}},$=C.jsxs(nae,{className:je("dropdown-menu-item","flex items-center justify-between gap-[16px] min-w-0 w-full max-w-full min-h-[32px] h-[32px] px-[12px] select-none cursor-pointer","outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0 border-0","hover:bg-[var(--drop-down-menu-item-hover-color)] hover:text-[var(--drop-down-menu-item-hover-color)]","data-[disabled]:opacity-50 data-[disabled]:pointer-events-none",i||f&&b?"bg-[var(--drop-down-menu-item-active-color)] text-[var(--drop-down-menu-item-active-color)]":""),onSelect:o?F=>F.preventDefault():P,onClick:o?O:void 0,onMouseEnter:D,ref:A,children:[C.jsxs("div",{className:"flex items-center gap-[8px] min-w-0 flex-1",children:[e&&typeof e=="string"?C.jsx(gt,{iconName:e,size:n,disableHover:!0}):e??null,C.jsx("span",{className:je("truncate font-normal text-[14px] leading-[20px] text-[var(--drop-down-menu-item-color)]",y?"ms-[28px]":""),children:t})]}),f?C.jsx(Nc,{trigger:C.jsx(gt,{iconName:qk,size:12,insideElement:!0,isStroke:!0}),items:f,side:S,align:"start",sideOffset:4,open:b,contentClassName:"mt-[-15px] max-w-[300px]",containerRef:A.current,dropdownRef:E}):null,d?C.jsx(gt,{iconName:Oh,size:16,disableHover:!0,isStroke:!0}):null,o&&c?C.jsx("div",{onClick:F=>F.stopPropagation(),children:C.jsx(zF,{checked:a??!1,onCheckedChange:c,disabled:h})}):null]});return m?C.jsxs(em,{children:[C.jsx(tm,{asChild:!0,children:$}),C.jsx(nm,{children:m})]}):$},Nc=({trigger:t,items:e,side:n,align:r,sideOffset:i,contentClassName:s,maxWidth:o,matchTriggerWidth:a,open:c,containerRef:h,dropdownRef:f,onOpenChange:d})=>{const m=document.getElementById("app");return C.jsxs(Qoe,{open:c,onOpenChange:d,children:[C.jsx(Zoe,{asChild:!0,children:t}),C.jsx(eae,{container:h??m,children:C.jsx(tae,{ref:f,side:n??"bottom",align:r??"start",sideOffset:i??6,"data-side":n,"data-align":r,"data-orientation":"vertical",className:je("dropdown-menu z-50 border border-[var(--drop-down-menu-border-color)] rounded-[8px] shadow-[var(--drop-down-menu-shadow)] bg-[var(--drop-down-menu-background-color)] py-[8px] max-h-56 overflow-y-auto flex flex-col gap-[4px]",a?"min-w-[150px] w-[var(--radix-dropdown-menu-trigger-width)]":"w-fit",s),style:o?{maxWidth:o}:void 0,children:e.map((y,b)=>C.jsx(Lae,{...y},y.id||y.text||`item-${b}`))})})]})};var Zw="Dialog",[VF]=ra(Zw),[Nae,Ms]=VF(Zw),UF=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=t,a=k.useRef(null),c=k.useRef(null),[h,f]=qh({prop:r,defaultProp:i??!1,onChange:s,caller:Zw});return C.jsx(Nae,{scope:e,triggerRef:a,contentRef:c,contentId:ol(),titleId:ol(),descriptionId:ol(),open:h,onOpenChange:f,onOpenToggle:k.useCallback(()=>f(d=>!d),[f]),modal:o,children:n})};UF.displayName=Zw;var HF="DialogTrigger",$ae=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Ms(HF,n),s=Bt(e,i.triggerRef);return C.jsx(st.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Jk(i.open),...r,ref:s,onClick:Le(t.onClick,i.onOpenToggle)})});$ae.displayName=HF;var Yk="DialogPortal",[jae,WF]=VF(Yk,{forceMount:void 0}),qF=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:i}=t,s=Ms(Yk,e);return C.jsx(jae,{scope:e,forceMount:n,children:k.Children.map(r,o=>C.jsx(Ts,{present:n||s.open,children:C.jsx(Pw,{asChild:!0,container:i,children:o})}))})};qF.displayName=Yk;var wv="DialogOverlay",GF=k.forwardRef((t,e)=>{const n=WF(wv,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,s=Ms(wv,t.__scopeDialog);return s.modal?C.jsx(Ts,{present:r||s.open,children:C.jsx(Fae,{...i,ref:e})}):null});GF.displayName=wv;var Bae=Rh("DialogOverlay.RemoveScroll"),Fae=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Ms(wv,n);return C.jsx(HE,{as:Bae,allowPinchZoom:!0,shards:[i.contentRef],children:C.jsx(st.div,{"data-state":Jk(i.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Ac="DialogContent",KF=k.forwardRef((t,e)=>{const n=WF(Ac,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,s=Ms(Ac,t.__scopeDialog);return C.jsx(Ts,{present:r||s.open,children:s.modal?C.jsx(zae,{...i,ref:e}):C.jsx(Vae,{...i,ref:e})})});KF.displayName=Ac;var zae=k.forwardRef((t,e)=>{const n=Ms(Ac,t.__scopeDialog),r=k.useRef(null),i=Bt(e,n.contentRef,r);return k.useEffect(()=>{const s=r.current;if(s)return Uj(s)},[]),C.jsx(YF,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Le(t.onCloseAutoFocus,s=>{s.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Le(t.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:Le(t.onFocusOutside,s=>s.preventDefault())})}),Vae=k.forwardRef((t,e)=>{const n=Ms(Ac,t.__scopeDialog),r=k.useRef(!1),i=k.useRef(!1);return C.jsx(YF,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{t.onCloseAutoFocus?.(s),s.defaultPrevented||(r.current||n.triggerRef.current?.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{t.onInteractOutside?.(s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;n.triggerRef.current?.contains(o)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),YF=k.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=t,a=Ms(Ac,n),c=k.useRef(null),h=Bt(e,c);return pj(),C.jsxs(C.Fragment,{children:[C.jsx(LE,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:C.jsx(Ew,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Jk(a.open),...o,ref:h,onDismiss:()=>a.onOpenChange(!1)})}),C.jsxs(C.Fragment,{children:[C.jsx(Hae,{titleId:a.titleId}),C.jsx(qae,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Xk="DialogTitle",XF=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Ms(Xk,n);return C.jsx(st.h2,{id:i.titleId,...r,ref:e})});XF.displayName=Xk;var JF="DialogDescription",QF=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Ms(JF,n);return C.jsx(st.p,{id:i.descriptionId,...r,ref:e})});QF.displayName=JF;var ZF="DialogClose",Uae=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Ms(ZF,n);return C.jsx(st.button,{type:"button",...r,ref:e,onClick:Le(t.onClick,()=>i.onOpenChange(!1))})});Uae.displayName=ZF;function Jk(t){return t?"open":"closed"}var ez="DialogTitleWarning",[X6e,tz]=rJ(ez,{contentName:Ac,titleName:Xk,docsSlug:"dialog"}),Hae=({titleId:t})=>{const e=tz(ez),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return k.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},Wae="DialogDescriptionWarning",qae=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${tz(Wae).contentName}}.`;return k.useEffect(()=>{const i=t.current?.getAttribute("aria-describedby");e&&i&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},Gae=UF,Kae=qF,Yae=GF,Xae=KF,Jae=XF,Qae=QF;const xl=({...t})=>C.jsx(Gae,{"data-slot":"dialog",...t}),Zae="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M17.1475%206.14844C17.3428%205.95347%2017.6593%205.95325%2017.8545%206.14844C18.0495%206.34361%2018.0494%206.66023%2017.8545%206.85547L12.707%2012.001L17.8545%2017.1465C18.0495%2017.3417%2018.0494%2017.6583%2017.8545%2017.8535C17.6593%2018.0488%2017.3428%2018.0486%2017.1475%2017.8535L12%2012.708L6.85352%2017.8535C6.65826%2018.0487%206.34173%2018.0487%206.14648%2017.8535C5.95128%2017.6583%205.95129%2017.3417%206.14648%2017.1465L11.293%2012.001L6.14648%206.85645C5.9512%206.66121%205.95125%206.34372%206.14648%206.14844C6.34167%205.95358%206.65832%205.95357%206.85352%206.14844L12%2011.2939L17.1475%206.14844Z'%20fill='%23383838'/%3e%3c/svg%3e",ele="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M1.62623%2016.5952L9.18302%203.47138C9.54492%202.84288%2010.4551%202.84287%2010.817%203.47138L18.3738%2016.5952C18.7339%2017.2206%2018.2806%2018%2017.5568%2018H2.44321C1.7194%2018%201.26612%2017.2206%201.62623%2016.5952Z'%20fill='%23FFD112'/%3e%3cpath%20d='M11%2014.5V16.5H9V14.5H11ZM11%207V10L10.5%2013.5H9.5L9%2010V7H11Z'%20fill='black'%20fill-opacity='0.8'/%3e%3c/svg%3e",tle=({...t})=>C.jsx(Kae,{"data-slot":"dialog-portal",container:document.getElementById("app"),...t}),nle=({className:t,...e})=>C.jsx(Yae,{"data-slot":"dialog-overlay",className:je("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-[var(--modal-dialog-overlay-background)]",t),...e}),rle=({className:t,withWarningIcon:e,...n})=>C.jsx(Jae,{"data-slot":"dialog-title",className:je("font-bold text-[var(--modal-dialog-header-color)] select-none",t,e?"text-[14px] leading-[20px]":"text-[18px] leading-[24px]"),...n}),ile=()=>C.jsx(C.Fragment,{children:C.jsx(Qae,{className:"hidden",children:"Dialog content"})}),sle="w-[348px]",ole="w-[548px]",ale=" box-border h-fit-content fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-50 rounded-[8px]",lle="w-[352px] box-border h-fit-content fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-50 rounded-[8px]",cle="bg-[var(--modal-dialog-background-color)] shadow-[var(--modal-dialog-shadows)]",Sl=({className:t,children:e,header:n,onClose:r,isHuge:i=!1,withWarningIcon:s=!1,...o})=>{const a=i?ole:sle,c=s?lle:ale;return de.useEffect(()=>{const h=f=>{f.key==="Escape"&&r()};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[r]),C.jsxs(tle,{"data-slot":"dialog-portal",children:[C.jsx(nle,{}),C.jsxs(Xae,{id:"dialog-content","data-slot":"dialog-content",className:je(a,c,cle,"flex flex-col",t),onInteractOutside:h=>h.preventDefault(),...o,children:[C.jsx(ile,{}),C.jsxs("div",{className:je("flex items-center justify-between align-center",s?"h-[40px]":"h-[56px]",s?"ps-[16px] pe-[8px]":"ps-[32px] pe-[16px]"),children:[C.jsxs("div",{className:"flex items-center gap-[4px]",children:[s?C.jsx(dn,{src:ele}):null,C.jsx(rle,{withWarningIcon:s,children:n})]}),C.jsx(gt,{iconName:Zae,size:24,onClick:r})]}),C.jsx("div",{className:je("flex-1 min-h-0",s?"px-[16px]":"px-[32px]"),children:e})]})]})},io=({children:t,header:e,error:n})=>C.jsxs("div",{className:"flex flex-col gap-[4px]",children:[C.jsx("p",{className:"select-none text-[14px] leading-[20px] text-[var(--field-container-header-color)]",children:e}),t,n&&C.jsx("p",{className:"text-[var(--field-container-error-color)]",children:n})]}),nz="data:image/svg+xml,%3csvg%20width='8'%20height='8'%20viewBox='0%200%208%208'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203.66699L4.5%205.66699L6.5%203.66699'%20stroke='%23383838'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",ex=({placeholder:t,value:e,className:n,isError:r,withoutBg:i,items:s})=>{const[o,a]=de.useState(!1),c=de.useRef(null),h=de.useCallback(f=>{f.querySelectorAll("path").forEach(m=>{m.setAttribute("stroke","var(--input-color)")})},[]);return C.jsx(Nc,{onOpenChange:f=>a(f),trigger:C.jsxs("div",{ref:c,className:je("h-[32px] rounded-[4px] ps-[12px] pe-[12px] box-border","cursor-pointer flex items-center justify-between","text-[var(--input-color)] text-[14px] leading-[16px]",o?"border bg-[var(--input-background-color)] border-[var(--input-active-border-color)]":i?"hover:bg-[var(--input-hover-background-color)] hover:border-[var(--input-hover-border-color)]":"border bg-[var(--input-background-color)] border-[var(--input-border-color)] hover:bg-[var(--input-hover-background-color)] hover:border-[var(--input-hover-border-color)]",n,s.length===0?"cursor-not-allowed pointer-events-none opacity-50":""),style:{borderColor:r?"var(--border-error)":void 0},children:[C.jsx("span",{className:je(e?"text-[var(--input-color)]":"text-[var(--input-placeholder-color)]"),children:e||t}),C.jsx(dn,{src:nz,className:je("w-[15px] h-[24px] flex items-center justify-center transition-transform",o?"rotate-180":""),beforeInjection:h})]}),align:"start",side:"bottom",containerRef:c.current,matchTriggerWidth:!0,items:s})},ule="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%206L14%2014M14%206L6%2014'%20stroke='%23383838'/%3e%3c/svg%3e",co=de.forwardRef(({className:t,isError:e,icon:n,onClear:r,...i},s)=>{const o=k.useCallback(a=>{a.querySelectorAll("path").forEach(f=>{f.setAttribute("stroke","var(--input-color)")}),a.querySelectorAll("circle").forEach(f=>{f.setAttribute("fill","var(--input-color)")})},[]);return C.jsxs("div",{className:`relative ${t}`,children:[n&&C.jsx(dn,{className:"absolute left-[10px] top-[50%] translate-y-[-50%] w-[20px] h-[20px] flex items-center justify-center",src:n,beforeInjection:o}),C.jsx("input",{ref:s,type:i.type??"text",className:je("h-[32px] rounded-[4px] box-border border border-[var(--input-border-color)]","bg-[var(--input-background-color)]",i.disabled?"":"hover:bg-[var(--input-hover-background-color)] hover:border-[var(--input-hover-border-color)]","focus:bg-[var(--input-active-background-color)] focus:border focus:border-[var(--input-active-border-color)]","outline-none","placeholder:text-[var(--input-placeholder-color)] text-[var(--input-color)]","[&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden",n?"ps-[40px]":"ps-[12px]",i.type==="search"&&i.value?"pe-[40px]":"pe-[2px]",t),style:{border:e?"1px solid var(--input-error-color)":""},value:i.value,...i}),i.type==="search"&&i.value&&C.jsx("button",{type:"button",onClick:r,className:"absolute right-[10px] top-[50%] translate-y-[-50%] w-[20px] h-[20px] flex items-center justify-center cursor-pointer",children:C.jsx(dn,{src:ule,beforeInjection:o})})]})});co.displayName="Input";const Gm=({className:t,size:e=16})=>C.jsx("div",{className:je("inline-block animate-spin rounded-full border-2 border-solid border-[var(--loader-border-color)] border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]",t),style:{width:`${e}px`,height:`${e}px`},role:"status","aria-label":"loading"}),rz="flex flex-col justify-between h-full",iz="flex flex-col gap-[12px] mb-[32px]",sz="flex flex-row justify-end items-center gap-[8px] h-[64px] border-t-[1px] border-[var(--border-divider)] mx-[-32px] px-[32px]",hle=({name:t,onClose:e})=>{const{t:n}=vt(),{providers:r,editProvider:i,currentProvider:s,setCurrentProvider:o}=rs(),[a,c]=de.useState(()=>{const F=r.find(N=>N.name===t);return F||{name:"",type:"",icon:"",key:"",baseUrl:""}}),[h,f]=de.useState({name:a.name,url:a.baseUrl,key:a.key}),[d,m]=de.useState({key:"",url:"",name:""}),[y,b]=de.useState(!1),w=de.useRef(y),S=de.useRef(null),[_,A]=de.useState(void 0);de.useEffect(()=>{const F=r.find(N=>N.name===t);F&&(c(F),f({name:F.name,url:F.baseUrl,key:F.key}))},[r,t]),de.useEffect(()=>{f({name:a.name,url:a.baseUrl,key:a.key})},[a]);const E=de.useRef(null),P=F=>{f(N=>({...N,[F.target.name]:F.target.value})),m(N=>({...N,[F.target.name]:""}))},O=h.name===a.name&&h.url===a.baseUrl,D=h.key===a.key&&O||!!d.key||!!d.url||!!d.name,$=de.useCallback(async()=>{if(w.current||D)return;w.current=!0,b(!0);const F={type:a.type,name:h.name,key:h.key,baseUrl:h.url},N=await i(F,a.name);if(typeof N=="boolean"&&N){if(s?.name===a.name){const U={...a,...F};o(U),Lt.setCurrentProvider(U)}e()}else N&&m(U=>({...U,[N.field]:N.message}));w.current=!1,b(!1)},[D,i,a,h,e,s,o]);return de.useEffect(()=>{if(S.current&&_===void 0){const F=S.current.offsetWidth+1;A(F)}},[_]),de.useEffect(()=>{const F=N=>{N.key==="Enter"&&(N.preventDefault(),$())};return window.addEventListener("keydown",F),()=>{window.removeEventListener("keydown",F)}},[$]),C.jsx(xl,{open:!0,children:C.jsx(Sl,{header:n("EditAIProvider"),onClose:e,ref:E,children:C.jsxs("div",{className:rz,children:[C.jsxs("div",{className:iz,children:[C.jsx(io,{header:n("Provider"),children:C.jsx(ex,{value:a.type,items:[]})}),C.jsx(io,{header:n("Name"),error:d.name,children:C.jsx(co,{name:"name",onChange:P,value:h.name,isError:!!d.name,placeholder:n("EnterName"),className:"w-full"})}),C.jsx(io,{header:n("URL"),error:d.url,children:C.jsx(co,{name:"url",onChange:P,value:h.url,isError:!!d.url,placeholder:n("EnterURL"),className:"w-full"})}),C.jsx(io,{header:n("APIKey"),error:d.key,children:C.jsx(co,{name:"key",onChange:P,value:h.key,isError:!!d.key,placeholder:n("EnterKey"),className:"w-full",type:"password"})})]}),C.jsxs("div",{className:sz,children:[C.jsx(en,{variant:"default",onClick:e,children:n("Cancel")}),C.jsx(en,{ref:S,onClick:$,disabled:D||y,style:_?{width:`${_}px`}:void 0,children:y?C.jsx(Gm,{className:"border-[var(--text-contrast-background)] border-r-transparent"}):n("Save")})]})]})})})},fle=({name:t,onClose:e})=>{const{providers:n,deleteProvider:r}=rs(),[i,s]=de.useState(()=>{const c=n.find(h=>h.name===t);return c||{name:"",type:"",icon:"",key:"",baseUrl:""}}),{t:o}=vt();de.useEffect(()=>{const c=n.find(h=>h.name===t);c&&s(c)},[n,t]);const a=de.useCallback(async()=>{await r(i),e()},[r,i,e]);return de.useEffect(()=>{const c=h=>{h.key==="Enter"&&(h.preventDefault(),a())};return window.addEventListener("keydown",c),()=>{window.removeEventListener("keydown",c)}},[a]),C.jsx(xl,{open:!0,children:C.jsx(Sl,{header:o("Warning"),onClose:e,withWarningIcon:!0,children:C.jsxs("div",{className:"flex flex-col justify-between h-full",children:[C.jsx("p",{className:"select-none h-[40px] flex items-center text-[12px] leading-[16px] text-[var(--text-normal)]",children:o("WantDeleteProvider")}),C.jsxs("div",{className:"flex flex-row justify-end items-center gap-[8px] h-[48px]",children:[C.jsx(en,{variant:"default",onClick:e,children:o("No")}),C.jsx(en,{onClick:a,children:o("Yes")})]})]})})})},dle=({provider:t})=>{const{providersModels:e}=rs(),[n,r]=de.useState(!1),[i,s]=de.useState(!1),[o,a]=de.useState(null),[c,h]=de.useState(!1),f=de.useCallback(y=>{a(y)},[]),{t:d}=vt(),m=e.get(t.name)?.length??!1;return C.jsxs(C.Fragment,{children:[C.jsxs("div",{className:"flex flex-row justify-between gap-[12px] px-[16px] py-[12px] min-w-[274px] max-w-[312px] flex-1 rounded-[8px] bg-[var(--ai-provider-item-background-color)] shadow-[var(--ai-provider-item-shadow)]",children:[C.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[C.jsxs("div",{className:"flex flex-row items-center gap-[4px]",children:[C.jsxs(em,{children:[C.jsx(tm,{asChild:!0,children:C.jsx("p",{className:"font-normal text-[14px] leading-[20px] text-[var(--ai-provider-item-color)] truncate w-fit",children:t.name})}),C.jsx(nm,{side:"bottom",children:t.name})]}),!m&&C.jsxs(em,{children:[C.jsx(tm,{asChild:!0,children:C.jsx("div",{children:C.jsx(gt,{iconName:G9,size:16,disableHover:!0,noColor:!0})})}),C.jsx(nm,{side:"bottom",children:d("NoModelsAvailable")})]})]}),C.jsxs("p",{className:"text-[12px] leading-[14px] text-[var(--ai-provider-item-description-color)]",children:[t.type,C.jsx("br",{}),t.baseUrl]})]}),C.jsx("div",{className:"flex items-center justify-end",ref:f,children:C.jsx(Nc,{onOpenChange:h,trigger:C.jsx(gt,{iconName:$k,size:20,isActive:c}),items:[{icon:C.jsx(gt,{iconName:Sse,size:20,disableHover:!0,isStroke:!0}),text:d("Edit"),onClick:()=>r(!0)},{text:"",onClick:()=>{},isSeparator:!0},{icon:C.jsx(gt,{iconName:jk,size:20,disableHover:!0}),text:d("Delete"),onClick:()=>s(!0)}],side:"right",align:"start",sideOffset:0,containerRef:o})})]}),n?C.jsx(hle,{name:t.name,onClose:()=>r(!1)}):null,i?C.jsx(fle,{name:t.name,onClose:()=>s(!1)}):null]})},UL=Lt.getProvidersInfo(),ple=({onClose:t})=>{const{addProvider:e}=rs(),{t:n}=vt(),[r,i]=de.useState(UL[0]),[s,o]=de.useState({name:"",url:r.baseUrl,key:""}),[a,c]=de.useState({key:"",url:"",name:""}),[h,f]=de.useState(!1),d=de.useRef(h),m=de.useRef(null),y=de.useRef(null),[b,w]=de.useState(void 0),S=E=>{o(P=>({...P,[E.target.name]:E.target.value})),c(P=>({...P,[E.target.name]:""}))},_=!s.name||!s.url||!!a.key||!!a.url||!!a.name,A=de.useCallback(async()=>{if(d.current||_)return;d.current=!0,f(!0);const E=await e({type:r.type,name:s.name.trim(),key:s.key,baseUrl:s.url});typeof E=="boolean"&&E?t():E&&c(P=>({...P,[E.field]:E.message})),d.current=!1,f(!1)},[e,r,s,t,_]);return de.useEffect(()=>{o(E=>({...E,url:r.baseUrl,key:""})),c({key:"",url:"",name:""})},[r]),de.useEffect(()=>{if(y.current&&b===void 0){const E=y.current.offsetWidth+1;w(E)}},[b]),de.useEffect(()=>{const E=P=>{P.key==="Enter"&&(P.preventDefault(),A())};return window.addEventListener("keydown",E),()=>{window.removeEventListener("keydown",E)}},[A]),C.jsx(xl,{open:!0,children:C.jsx(Sl,{header:n("AddProvider"),onClose:t,ref:m,children:C.jsxs("div",{className:rz,children:[C.jsxs("div",{className:iz,children:[C.jsx(io,{header:n("Provider"),children:C.jsx(ex,{value:r.name,items:UL.map(E=>({text:E.name,id:E.name,onClick:()=>i(E)}))})}),C.jsx(io,{header:n("Name"),error:a.name,children:C.jsx(co,{name:"name",onChange:S,value:s.name,isError:!!a.name,placeholder:n("EnterName"),className:"w-full",maxLength:128})}),C.jsx(io,{header:n("URL"),error:a.url,children:C.jsx(co,{name:"url",onChange:S,value:s.url,isError:!!a.url,placeholder:n("EnterURL"),className:"w-full"})}),C.jsx(io,{header:n("APIKey"),error:a.key,children:C.jsx(co,{name:"key",onChange:S,value:s.key,isError:!!a.key,placeholder:n("EnterKey"),className:"w-full",type:"password"})})]}),C.jsxs("div",{className:sz,children:[C.jsx(en,{variant:"default",onClick:t,children:n("Cancel")}),C.jsx(en,{ref:y,onClick:A,disabled:_||h,style:b?{width:`${b}px`}:void 0,children:h?C.jsx(Gm,{className:"border-[var(--text-contrast-background)] border-r-transparent"}):n("AddProvider")})]})]})})})},mle=({isActive:t})=>{const[e,n]=de.useState(!1),{providers:r}=rs(),{t:i}=vt();return C.jsxs(C.Fragment,{children:[C.jsx(en,{className:"max-w-[fit-content]",onClick:()=>n(!0),disabled:!t,children:i("AddProvider")}),C.jsx("div",{className:je("flex flex-wrap gap-[16px]",t?"":"opacity-70 pointer-events-none"),children:r.map(s=>C.jsx(dle,{provider:s},s.name))}),e?C.jsx(ple,{onClose:()=>n(!1)}):null]})},gle=({isActive:t})=>{const{t:e}=vt();return C.jsx(en,{className:"max-w-[fit-content]",disabled:!t,children:e("RegisterConnectWallet")})};let VC=[],oz=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?oz:VC).push(n=n+t[e])})();function yle(t){if(t<768)return!1;for(let e=0,n=VC.length;;){let r=e+n>>1;if(t<VC[r])n=r;else if(t>=oz[r])e=r+1;else return!0;if(e==n)return!1}}function HL(t){return t>=127462&&t<=127487}const WL=8205;function ble(t,e,n=!0,r=!0){return(n?az:vle)(t,e,r)}function az(t,e,n){if(e==t.length)return e;e&&lz(t.charCodeAt(e))&&cz(t.charCodeAt(e-1))&&e--;let r=A_(t,e);for(e+=qL(r);e<t.length;){let i=A_(t,e);if(r==WL||i==WL||n&&yle(i))e+=qL(i),r=i;else if(HL(i)){let s=0,o=e-2;for(;o>=0&&HL(A_(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function vle(t,e,n){for(;e>0;){let r=az(t,e-2,n);if(r<e)return r;e--}return 0}function A_(t,e){let n=t.charCodeAt(e);if(!cz(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return lz(r)?(n-55296<<10)+(r-56320)+65536:n}function lz(t){return t>=56320&&t<57344}function cz(t){return t>=55296&&t<56320}function qL(t){return t<65536?1:2}class dt{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Dh(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),eo.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Dh(this,e,n);let r=[];return this.decompose(e,n,r,0),eo.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new Ap(this),s=new Ap(e);for(let o=n,a=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(a+=i.value.length,i.done||a>=r)return!0}}iter(e=1){return new Ap(this,e)}iterRange(e,n=this.length){return new uz(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new hz(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?dt.empty:e.length<=32?new sn(e):eo.from(sn.split(e,[]))}}class sn extends dt{constructor(e,n=wle(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],a=i+o.length;if((n?r:a)>=e)return new xle(i,a,r,o);i=a+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new sn(GL(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),a=Mb(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new sn(a,o.length+s.length));else{let c=a.length>>1;r.push(new sn(a.slice(0,c)),new sn(a.slice(c)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof sn))return super.replace(e,n,r);[e,n]=Dh(this,e,n);let i=Mb(this.text,Mb(r.text,GL(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new sn(i,s):eo.from(sn.split(i,[]),s)}sliceString(e,n=this.length,r=`
`){[e,n]=Dh(this,e,n);let i="";for(let s=0,o=0;s<=n&&o<this.text.length;o++){let a=this.text[o],c=s+a.length;s>e&&o&&(i+=r),e<c&&n>s&&(i+=a.slice(Math.max(0,e-s),n-s)),s=c+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new sn(r,i)),r=[],i=-1);return i>-1&&n.push(new sn(r,i)),n}}class eo extends dt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],a=i+o.length,c=r+o.lines-1;if((n?c:a)>=e)return o.lineInner(e,n,r,i);i=a+1,r=c+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s<this.children.length;s++){let a=this.children[s],c=o+a.length;if(e<=c&&n>=o){let h=i&((o<=e?1:0)|(c>=n?2:0));o>=e&&c<=n&&!h?r.push(a):a.decompose(e-o,n-o,r,h)}o=c+1}}replace(e,n,r){if([e,n]=Dh(this,e,n),r.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let o=this.children[i],a=s+o.length;if(e>=s&&n<=a){let c=o.replace(e-s,n-s,r),h=this.lines-o.lines+c.lines;if(c.lines<h>>4&&c.lines>h>>6){let f=this.children.slice();return f[i]=c,new eo(f,this.length-(n-e)+r.length)}return super.replace(s,a,c)}s=a+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=`
`){[e,n]=Dh(this,e,n);let i="";for(let s=0,o=0;s<this.children.length&&o<=n;s++){let a=this.children[s],c=o+a.length;o>e&&s&&(i+=r),e<c&&n>o&&(i+=a.sliceString(e-o,n-o,r)),o=c+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof eo))return 0;let r=0,[i,s,o,a]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==a)return r;let c=this.children[i],h=e.children[s];if(c!=h)return r+c.scanIdentical(h,n);r+=c.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let y of e)r+=y.lines;if(r<32){let y=[];for(let b of e)b.flatten(y);return new sn(y,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,a=[],c=0,h=-1,f=[];function d(y){let b;if(y.lines>s&&y instanceof eo)for(let w of y.children)d(w);else y.lines>o&&(c>o||!c)?(m(),a.push(y)):y instanceof sn&&c&&(b=f[f.length-1])instanceof sn&&y.lines+b.lines<=32?(c+=y.lines,h+=y.length+1,f[f.length-1]=new sn(b.text.concat(y.text),b.length+1+y.length)):(c+y.lines>i&&m(),c+=y.lines,h+=y.length+1,f.push(y))}function m(){c!=0&&(a.push(f.length==1?f[0]:eo.from(f,h)),h=-1,c=f.length=0)}for(let y of e)d(y);return m(),a.length==1?a[0]:new eo(a,n)}}dt.empty=new sn([""],0);function wle(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Mb(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s<t.length&&i<=r;s++){let a=t[s],c=i+a.length;c>=n&&(c>r&&(a=a.slice(0,r-i)),i<n&&(a=a.slice(n-i)),o?(e[e.length-1]+=a,o=!1):e.push(a)),i=c+1}return e}function GL(t,e,n){return Mb(t,[""],e,n)}class Ap{constructor(e,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof sn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,a=i instanceof sn?i.text.length:i.children.length;if(o==(n>0?a:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=`
`,this;e--}else if(i instanceof sn){let c=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,c.length>Math.max(0,e))return this.value=e==0?c:n>0?c.slice(e):c.slice(0,c.length-e),this;e-=c.length}else{let c=i.children[o+(n<0?-1:0)];e>c.length?(e-=c.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(c),this.offsets.push(n>0?1:(c instanceof sn?c.text.length:c.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class uz{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new Ap(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class hz{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(dt.prototype[Symbol.iterator]=function(){return this.iter()},Ap.prototype[Symbol.iterator]=uz.prototype[Symbol.iterator]=hz.prototype[Symbol.iterator]=function(){return this});class xle{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}}function Dh(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function Xn(t,e,n=!0,r=!0){return ble(t,e,n,r)}function Sle(t){return t>=56320&&t<57344}function _le(t){return t>=55296&&t<56320}function Wr(t,e){let n=t.charCodeAt(e);if(!_le(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return Sle(r)?(n-55296<<10)+(r-56320)+65536:n}function Qk(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function to(t){return t<65536?1:2}const UC=/\r\n?|\n/;var Mr=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Mr||(Mr={}));class uo{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n+1];e+=r<0?this.sections[n]:r}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,r=0,i=0;n<this.sections.length;){let s=this.sections[n++],o=this.sections[n++];o<0?(e(r,i,s),i+=s):i+=o,r+=s}}iterChangedRanges(e,n=!1){HC(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];i<0?e.push(r,i):e.push(i,r)}return new uo(e)}composeDesc(e){return this.empty?e:e.empty?this:fz(this,e)}mapDesc(e,n=!1){return e.empty?this:WC(this,e,n)}mapPos(e,n=-1,r=Mr.Simple){let i=0,s=0;for(let o=0;o<this.sections.length;){let a=this.sections[o++],c=this.sections[o++],h=i+a;if(c<0){if(h>e)return s+(e-i);s+=a}else{if(r!=Mr.Simple&&h>=e&&(r==Mr.TrackDel&&i<e&&h>e||r==Mr.TrackBefore&&i<e||r==Mr.TrackAfter&&h>e))return null;if(h>e||h==e&&n<0&&!a)return e==i||n<0?s:s+c;s+=c}i=h}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r<this.sections.length&&i<=n;){let s=this.sections[r++],o=this.sections[r++],a=i+s;if(o>=0&&i<=n&&a>=e)return i<e&&a>n?"cover":!0;i=a}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];e+=(e?" ":"")+r+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new uo(e)}static create(e){return new uo(e)}}class En extends uo{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return HC(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return WC(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,s=0;i<n.length;i+=2){let o=n[i],a=n[i+1];if(a>=0){n[i]=a,n[i+1]=o;let c=i>>1;for(;r.length<c;)r.push(dt.empty);r.push(o?e.slice(s,s+o):dt.empty)}s+=o}return new En(n,r)}compose(e){return this.empty?e:e.empty?this:fz(this,e,!0)}map(e,n=!1){return e.empty?this:WC(this,e,n,!0)}iterChanges(e,n=!1){HC(this,e,n)}get desc(){return uo.create(this.sections)}filter(e){let n=[],r=[],i=[],s=new rm(this);e:for(let o=0,a=0;;){let c=o==e.length?1e9:e[o++];for(;a<c||a==c&&s.len==0;){if(s.done)break e;let f=Math.min(s.len,c-a);fr(i,f,-1);let d=s.ins==-1?-1:s.off==0?s.ins:0;fr(n,f,d),d>0&&nl(r,n,s.text),s.forward(f),a+=f}let h=e[o++];for(;a<h;){if(s.done)break e;let f=Math.min(s.len,h-a);fr(n,f,-1),fr(i,f,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(f),a+=f}}return{changes:new En(n,r),filtered:uo.create(i)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],i=this.sections[n+1];i<0?e.push(r):i==0?e.push([r]):e.push([r].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,r){let i=[],s=[],o=0,a=null;function c(f=!1){if(!f&&!i.length)return;o<n&&fr(i,n-o,-1);let d=new En(i,s);a=a?a.compose(d.map(a)):d,i=[],s=[],o=0}function h(f){if(Array.isArray(f))for(let d of f)h(d);else if(f instanceof En){if(f.length!=n)throw new RangeError(`Mismatched change set length (got ${f.length}, expected ${n})`);c(),a=a?a.compose(f.map(a)):f}else{let{from:d,to:m=d,insert:y}=f;if(d>m||d<0||m>n)throw new RangeError(`Invalid change range ${d} to ${m} (in doc of length ${n})`);let b=y?typeof y=="string"?dt.of(y.split(r||UC)):y:dt.empty,w=b.length;if(d==m&&w==0)return;d<o&&c(),d>o&&fr(i,d-o,-1),fr(i,m-d,w),nl(s,i,b),o=m}}return h(e),c(!a),a}static empty(e){return new En(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;i<e.length;i++){let s=e[i];if(typeof s=="number")n.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,a)=>a&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length<i;)r.push(dt.empty);r[i]=dt.of(s.slice(1)),n.push(s[0],r[i].length)}}}return new En(n,r)}static createSet(e,n){return new En(e,n)}}function fr(t,e,n,r=!1){if(e==0&&n<=0)return;let i=t.length-2;i>=0&&n<=0&&n==t[i+1]?t[i]+=e:i>=0&&e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function nl(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<r;)t.push(dt.empty);t.push(n)}}function HC(t,e,n){let r=t.inserted;for(let i=0,s=0,o=0;o<t.sections.length;){let a=t.sections[o++],c=t.sections[o++];if(c<0)i+=a,s+=a;else{let h=i,f=s,d=dt.empty;for(;h+=a,f+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)a=t.sections[o++],c=t.sections[o++];e(i,h,s,f,d),i=h,s=f}}}function WC(t,e,n,r=!1){let i=[],s=r?[]:null,o=new rm(t),a=new rm(e);for(let c=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let h=Math.min(o.len,a.len);fr(i,h,-1),o.forward(h),a.forward(h)}else if(a.ins>=0&&(o.ins<0||c==o.i||o.off==0&&(a.len<o.len||a.len==o.len&&!n))){let h=a.len;for(fr(i,a.ins,-1);h;){let f=Math.min(o.len,h);o.ins>=0&&c<o.i&&o.len<=f&&(fr(i,0,o.ins),s&&nl(s,i,o.text),c=o.i),o.forward(f),h-=f}a.next()}else if(o.ins>=0){let h=0,f=o.len;for(;f;)if(a.ins==-1){let d=Math.min(f,a.len);h+=d,f-=d,a.forward(d)}else if(a.ins==0&&a.len<f)f-=a.len,a.next();else break;fr(i,h,c<o.i?o.ins:0),s&&c<o.i&&nl(s,i,o.text),c=o.i,o.forward(o.len-f)}else{if(o.done&&a.done)return s?En.createSet(i,s):uo.create(i);throw new Error("Mismatched change set lengths")}}}function fz(t,e,n=!1){let r=[],i=n?[]:null,s=new rm(t),o=new rm(e);for(let a=!1;;){if(s.done&&o.done)return i?En.createSet(r,i):uo.create(r);if(s.ins==0)fr(r,s.len,0,a),s.next();else if(o.len==0&&!o.done)fr(r,0,o.ins,a),i&&nl(i,r,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let c=Math.min(s.len2,o.len),h=r.length;if(s.ins==-1){let f=o.ins==-1?-1:o.off?0:o.ins;fr(r,c,f,a),i&&f&&nl(i,r,o.text)}else o.ins==-1?(fr(r,s.off?0:s.len,c,a),i&&nl(i,r,s.textBit(c))):(fr(r,s.off?0:s.len,o.off?0:o.ins,a),i&&!o.off&&nl(i,r,o.text));a=(s.ins>c||o.ins>=0&&o.len>c)&&(a||r.length>h),s.forward2(c),o.forward(c)}}}}class rm{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length?dt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?dt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class hc{constructor(e,n,r){this.from=e,this.to=n,this.flags=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new hc(r,i,this.flags)}extend(e,n=e){if(e<=this.anchor&&n>=this.anchor)return fe.range(e,n);let r=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return fe.range(this.anchor,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return fe.range(e.anchor,e.head)}static create(e,n,r){return new hc(e,n,r)}}class fe{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:fe.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(e.ranges[r],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new fe([this.main],0)}addRange(e,n=!0){return fe.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let r=this.ranges.slice();return r[n]=e,fe.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new fe(e.ranges.map(n=>hc.fromJSON(n)),e.main)}static single(e,n=e){return new fe([fe.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;i<e.length;i++){let s=e[i];if(s.empty?s.from<=r:s.from<r)return fe.normalized(e.slice(),n);r=s.to}return new fe(e,n)}static cursor(e,n=0,r,i){return hc.create(e,e,(n==0?0:n<0?8:16)|(r==null?7:Math.min(6,r))|(i??16777215)<<6)}static range(e,n,r,i){let s=(r??16777215)<<6|(i==null?7:Math.min(6,i));return n<e?hc.create(n,e,48|s):hc.create(e,n,(n>e?8:0)|s)}static normalized(e,n=0){let r=e[n];e.sort((i,s)=>i.from-s.from),n=e.indexOf(r);for(let i=1;i<e.length;i++){let s=e[i],o=e[i-1];if(s.empty?s.from<=o.to:s.from<o.to){let a=o.from,c=Math.max(s.to,o.to);i<=n&&n--,e.splice(--i,2,s.anchor>s.head?fe.range(c,a):fe.range(a,c))}}return new fe(e,n)}}function dz(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Zk=0;class Ce{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=Zk++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new Ce(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:eT),!!e.static,e.enables)}of(e){return new Ob([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ob(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ob(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function eT(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Ob{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=Zk++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,a=this.type==2,c=!1,h=!1,f=[];for(let d of this.dependencies)d=="doc"?c=!0:d=="selection"?h=!0:(((n=e[d.id])!==null&&n!==void 0?n:1)&1)==0&&f.push(e[d.id]);return{create(d){return d.values[o]=r(d),1},update(d,m){if(c&&m.docChanged||h&&(m.docChanged||m.selection)||qC(d,f)){let y=r(d);if(a?!KL(y,d.values[o],i):!i(y,d.values[o]))return d.values[o]=y,1}return 0},reconfigure:(d,m)=>{let y,b=m.config.address[s];if(b!=null){let w=Sv(m,b);if(this.dependencies.every(S=>S instanceof Ce?m.facet(S)===d.facet(S):S instanceof Zn?m.field(S,!1)==d.field(S,!1):!0)||(a?KL(y=r(d),w,i):i(y=r(d),w)))return d.values[o]=w,0}else y=r(d);return d.values[o]=y,1}}}}function KL(t,e,n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!n(t[r],e[r]))return!1;return!0}function qC(t,e){let n=!1;for(let r of e)Ep(t,r)&1&&(n=!0);return n}function Cle(t,e,n){let r=n.map(c=>t[c.id]),i=n.map(c=>c.type),s=r.filter(c=>!(c&1)),o=t[e.id]>>1;function a(c){let h=[];for(let f=0;f<r.length;f++){let d=Sv(c,r[f]);if(i[f]==2)for(let m of d)h.push(m);else h.push(d)}return e.combine(h)}return{create(c){for(let h of r)Ep(c,h);return c.values[o]=a(c),1},update(c,h){if(!qC(c,s))return 0;let f=a(c);return e.compare(f,c.values[o])?0:(c.values[o]=f,1)},reconfigure(c,h){let f=qC(c,r),d=h.config.facets[e.id],m=h.facet(e);if(d&&!f&&eT(n,d))return c.values[o]=m,0;let y=a(c);return e.compare(y,m)?(c.values[o]=m,0):(c.values[o]=y,1)}}}const Sy=Ce.define({static:!0});class Zn{constructor(e,n,r,i,s){this.id=e,this.createF=n,this.updateF=r,this.compareF=i,this.spec=s,this.provides=void 0}static define(e){let n=new Zn(Zk++,e.create,e.update,e.compare||((r,i)=>r===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Sy).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>{let s=r.facet(Sy),o=i.facet(Sy),a;return(a=s.find(c=>c.field==this))&&a!=o.find(c=>c.field==this)?(r.values[n]=a.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Sy.of({field:this,create:e})]}get extension(){return this}}const oc={lowest:4,low:3,default:2,high:1,highest:0};function Md(t){return e=>new pz(e,t)}const $c={highest:Md(oc.highest),high:Md(oc.high),default:Md(oc.default),low:Md(oc.low),lowest:Md(oc.lowest)};class pz{constructor(e,n){this.inner=e,this.prec=n}}class tx{of(e){return new GC(this,e)}reconfigure(e){return tx.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class GC{constructor(e,n){this.compartment=e,this.inner=n}}class xv{constructor(e,n,r,i,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,r){let i=[],s=Object.create(null),o=new Map;for(let m of Ale(e,n,o))m instanceof Zn?i.push(m):(s[m.facet.id]||(s[m.facet.id]=[])).push(m);let a=Object.create(null),c=[],h=[];for(let m of i)a[m.id]=h.length<<1,h.push(y=>m.slot(y));let f=r?.config.facets;for(let m in s){let y=s[m],b=y[0].facet,w=f&&f[m]||[];if(y.every(S=>S.type==0))if(a[b.id]=c.length<<1|1,eT(w,y))c.push(r.facet(b));else{let S=b.combine(y.map(_=>_.value));c.push(r&&b.compare(S,r.facet(b))?r.facet(b):S)}else{for(let S of y)S.type==0?(a[S.id]=c.length<<1|1,c.push(S.value)):(a[S.id]=h.length<<1,h.push(_=>S.dynamicSlot(_)));a[b.id]=h.length<<1,h.push(S=>Cle(S,b,y))}}let d=h.map(m=>m(a));return new xv(e,o,d,a,c,s)}}function Ale(t,e,n){let r=[[],[],[],[],[]],i=new Map;function s(o,a){let c=i.get(o);if(c!=null){if(c<=a)return;let h=r[c].indexOf(o);h>-1&&r[c].splice(h,1),o instanceof GC&&n.delete(o.compartment)}if(i.set(o,a),Array.isArray(o))for(let h of o)s(h,a);else if(o instanceof GC){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;n.set(o.compartment,h),s(h,a)}else if(o instanceof pz)s(o.inner,o.prec);else if(o instanceof Zn)r[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof Ob)r[a].push(o),o.facet.extensions&&s(o.facet.extensions,oc.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,a)}}return s(t,oc.default),r.reduce((o,a)=>o.concat(a))}function Ep(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function Sv(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const mz=Ce.define(),KC=Ce.define({combine:t=>t.some(e=>e),static:!0}),gz=Ce.define({combine:t=>t.length?t[0]:void 0,static:!0}),yz=Ce.define(),bz=Ce.define(),vz=Ce.define(),wz=Ce.define({combine:t=>t.length?t[0]:!1});class sa{constructor(e,n){this.type=e,this.value=n}static define(){return new Ele}}class Ele{of(e){return new sa(this,e)}}class kle{constructor(e){this.map=e}of(e){return new Ze(this,e)}}class Ze{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ze(this.type,n)}is(e){return this.type==e}static define(e={}){return new kle(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(n);s&&r.push(s)}return r}}Ze.reconfigure=Ze.define();Ze.appendConfig=Ze.define();class kn{constructor(e,n,r,i,s,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&dz(r,n.newLength),s.some(a=>a.type==kn.time)||(this.annotations=s.concat(kn.time.of(Date.now())))}static create(e,n,r,i,s,o){return new kn(e,n,r,i,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(kn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}kn.time=sa.define();kn.userEvent=sa.define();kn.addToHistory=sa.define();kn.remote=sa.define();function Tle(t,e){let n=[];for(let r=0,i=0;;){let s,o;if(r<t.length&&(i==e.length||e[i]>=t[r]))s=t[r++],o=t[r++];else if(i<e.length)s=e[i++],o=e[i++];else return n;!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function xz(t,e,n){var r;let i,s,o;return n?(i=e.changes,s=En.empty(e.changes.length),o=t.changes.compose(e.changes)):(i=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(i)),{changes:o,selection:e.selection?e.selection.map(s):(r=t.selection)===null||r===void 0?void 0:r.map(i),effects:Ze.mapEffects(t.effects,i).concat(Ze.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function YC(t,e,n){let r=e.selection,i=vh(e.annotations);return e.userEvent&&(i=i.concat(kn.userEvent.of(e.userEvent))),{changes:e.changes instanceof En?e.changes:En.of(e.changes||[],n,t.facet(gz)),selection:r&&(r instanceof fe?r:fe.single(r.anchor,r.head)),effects:vh(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function Sz(t,e,n){let r=YC(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(n=!1);let o=!!e[s].sequential;r=xz(r,YC(t,e[s],o?r.changes.newLength:t.doc.length),o)}let i=kn.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return Mle(n?Rle(i):i)}function Rle(t){let e=t.startState,n=!0;for(let i of e.facet(yz)){let s=i(t);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:Tle(n,s))}if(n!==!0){let i,s;if(n===!1)s=t.changes.invertedDesc,i=En.empty(e.doc.length);else{let o=t.changes.filter(n);i=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}t=kn.create(e,i,t.selection&&t.selection.map(s),Ze.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let r=e.facet(bz);for(let i=r.length-1;i>=0;i--){let s=r[i](t);s instanceof kn?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof kn?t=s[0]:t=Sz(e,vh(s),!1)}return t}function Mle(t){let e=t.startState,n=e.facet(vz),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=xz(r,YC(e,s,t.changes.newLength),!0))}return r==t?t:kn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const Ole=[];function vh(t){return t==null?Ole:Array.isArray(t)?t:[t]}var Vt=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(Vt||(Vt={}));const Ple=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let XC;try{XC=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Dle(t){if(XC)return XC.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||Ple.test(n)))return!0}return!1}function Ile(t){return e=>{if(!/\S/.test(e))return Vt.Space;if(Dle(e))return Vt.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return Vt.Word;return Vt.Other}}class ht{constructor(e,n,r,i,s,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)Ep(this,a<<1);this.computeSlot=null}field(e,n=!0){let r=this.config.address[e.id];if(r==null){if(n)throw new RangeError("Field is not present in this state");return}return Ep(this,r),Sv(this,r)}update(...e){return Sz(this,e,!0)}applyTransaction(e){let n=this.config,{base:r,compartments:i}=n;for(let a of e.effects)a.is(tx.reconfigure)?(n&&(i=new Map,n.compartments.forEach((c,h)=>i.set(h,c)),n=null),i.set(a.value.compartment,a.value.extension)):a.is(Ze.reconfigure)?(n=null,r=a.value):a.is(Ze.appendConfig)&&(n=null,r=vh(r).concat(a.value));let s;n?s=e.startState.values.slice():(n=xv.resolve(r,i,this),s=new ht(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(c,h)=>h.reconfigure(c,this),null).values);let o=e.startState.facet(KC)?e.newSelection:e.newSelection.asSingle();new ht(n,e.newDoc,o,s,(a,c)=>c.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:fe.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=vh(r.effects);for(let a=1;a<n.ranges.length;a++){let c=e(n.ranges[a]),h=this.changes(c.changes),f=h.map(i);for(let m=0;m<a;m++)s[m]=s[m].map(f);let d=i.mapDesc(h,!0);s.push(c.range.map(d)),i=i.compose(f),o=Ze.mapEffects(o,f).concat(Ze.mapEffects(vh(c.effects),d))}return{changes:i,selection:fe.create(s,n.mainIndex),effects:o}}changes(e=[]){return e instanceof En?e:En.of(e,this.doc.length,this.facet(ht.lineSeparator))}toText(e){return dt.of(e.split(this.facet(ht.lineSeparator)||UC))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(Ep(this,n),Sv(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let r in e){let i=e[r];i instanceof Zn&&this.config.address[i.id]!=null&&(n[r]=i.spec.toJSON(this.field(e[r]),this))}return n}static fromJSON(e,n={},r){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(r){for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)){let o=r[s],a=e[s];i.push(o.init(c=>o.spec.fromJSON(a,c)))}}return ht.create({doc:e.doc,selection:fe.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=xv.resolve(e.extensions||[],new Map),r=e.doc instanceof dt?e.doc:dt.of((e.doc||"").split(n.staticFacet(ht.lineSeparator)||UC)),i=e.selection?e.selection instanceof fe?e.selection:fe.single(e.selection.anchor,e.selection.head):fe.single(0);return dz(i,r.length),n.staticFacet(KC)||(i=i.asSingle()),new ht(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(ht.tabSize)}get lineBreak(){return this.facet(ht.lineSeparator)||`
`}get readOnly(){return this.facet(wz)}phrase(e,...n){for(let r of this.facet(ht.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,i)=>{if(i=="$")return"$";let s=+(i||1);return!s||s>n.length?r:n[s-1]})),e}languageDataAt(e,n,r=-1){let i=[];for(let s of this.facet(mz))for(let o of s(this,n,r))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){return Ile(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:n,from:r,length:i}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-r,a=e-r;for(;o>0;){let c=Xn(n,o,!1);if(s(n.slice(c,o))!=Vt.Word)break;o=c}for(;a<i;){let c=Xn(n,a);if(s(n.slice(a,c))!=Vt.Word)break;a=c}return o==a?null:fe.range(o+r,a+r)}}ht.allowMultipleSelections=KC;ht.tabSize=Ce.define({combine:t=>t.length?t[0]:4});ht.lineSeparator=gz;ht.readOnly=wz;ht.phrases=Ce.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(i=>t[i]==e[i])}});ht.languageData=mz;ht.changeFilter=yz;ht.transactionFilter=bz;ht.transactionExtender=vz;tx.reconfigure=Ze.define();function wo(t,e,n={}){let r={};for(let i of t)for(let s of Object.keys(i)){let o=i[s],a=r[s];if(a===void 0)r[s]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(n,s))r[s]=n[s](a,o);else throw new Error("Config merge conflict for field "+s)}for(let i in e)r[i]===void 0&&(r[i]=e[i]);return r}class Ec{eq(e){return this==e}range(e,n=e){return JC.create(e,n,this)}}Ec.prototype.startSide=Ec.prototype.endSide=0;Ec.prototype.point=!1;Ec.prototype.mapMode=Mr.TrackDel;let JC=class _z{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new _z(e,n,r)}};function QC(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class tT{constructor(e,n,r,i){this.from=e,this.to=n,this.value=r,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,n,r,i=0){let s=r?this.to:this.from;for(let o=i,a=s.length;;){if(o==a)return o;let c=o+a>>1,h=s[c]-e||(r?this.value[c].endSide:this.value[c].startSide)-n;if(c==o)return h>=0?o:a;h>=0?a=c:o=c+1}}between(e,n,r,i){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(r,1e9,!1,s);s<o;s++)if(i(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,n){let r=[],i=[],s=[],o=-1,a=-1;for(let c=0;c<this.value.length;c++){let h=this.value[c],f=this.from[c]+e,d=this.to[c]+e,m,y;if(f==d){let b=n.mapPos(f,h.startSide,h.mapMode);if(b==null||(m=y=b,h.startSide!=h.endSide&&(y=n.mapPos(f,h.endSide),y<m)))continue}else if(m=n.mapPos(f,h.startSide),y=n.mapPos(d,h.endSide),m>y||m==y&&h.startSide>0&&h.endSide<=0)continue;(y-m||h.endSide-h.startSide)<0||(o<0&&(o=m),h.point&&(a=Math.max(a,y-m)),r.push(h),i.push(m-o),s.push(y-o))}return{mapped:r.length?new tT(i,s,r,a):null,pos:o}}}class ft{constructor(e,n,r,i){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=i}static create(e,n,r,i){return new ft(e,n,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:s=this.length}=e,o=e.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(QC)),this.isEmpty)return n.length?ft.of(n):this;let a=new Cz(this,null,-1).goto(0),c=0,h=[],f=new Xo;for(;a.value||c<n.length;)if(c<n.length&&(a.from-n[c].from||a.startSide-n[c].value.startSide)>=0){let d=n[c++];f.addInner(d.from,d.to,d.value)||h.push(d)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(c==n.length||this.chunkEnd(a.chunkIndex)<n[c].from)&&(!o||i>this.chunkEnd(a.chunkIndex)||s<this.chunkPos[a.chunkIndex])&&f.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!o||i>a.to||s<a.from||o(a.from,a.to,a.value))&&(f.addInner(a.from,a.to,a.value)||h.push(JC.create(a.from,a.to,a.value))),a.next());return f.finishInner(this.nextLayer.isEmpty&&!h.length?ft.empty:this.nextLayer.update({add:h,filter:o,filterFrom:i,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let n=[],r=[],i=-1;for(let o=0;o<this.chunk.length;o++){let a=this.chunkPos[o],c=this.chunk[o],h=e.touchesRange(a,a+c.length);if(h===!1)i=Math.max(i,c.maxPoint),n.push(c),r.push(e.mapPos(a));else if(h===!0){let{mapped:f,pos:d}=c.map(a,e);f&&(i=Math.max(i,f.maxPoint),n.push(f),r.push(d))}}let s=this.nextLayer.map(e);return n.length==0?s:new ft(r,n,s||ft.empty,i)}between(e,n,r){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let s=this.chunkPos[i],o=this.chunk[i];if(n>=s&&e<=s+o.length&&o.between(s,e-s,n-s,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return im.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return im.from(e).goto(n)}static compare(e,n,r,i,s=-1){let o=e.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=s),a=n.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=s),c=YL(o,a,r),h=new Od(o,c,s),f=new Od(a,c,s);r.iterGaps((d,m,y)=>XL(h,d,f,m,y,i)),r.empty&&r.length==0&&XL(h,0,f,0,0,i)}static eq(e,n,r=0,i){i==null&&(i=999999999);let s=e.filter(f=>!f.isEmpty&&n.indexOf(f)<0),o=n.filter(f=>!f.isEmpty&&e.indexOf(f)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let a=YL(s,o),c=new Od(s,a,0).goto(r),h=new Od(o,a,0).goto(r);for(;;){if(c.to!=h.to||!ZC(c.active,h.active)||c.point&&(!h.point||!c.point.eq(h.point)))return!1;if(c.to>i)return!0;c.next(),h.next()}}static spans(e,n,r,i,s=-1){let o=new Od(e,null,s).goto(n),a=n,c=o.openStart;for(;;){let h=Math.min(o.to,r);if(o.point){let f=o.activeForPoint(o.to),d=o.pointFrom<n?f.length+1:o.point.startSide<0?f.length:Math.min(f.length,c);i.point(a,h,o.point,f,d,o.pointRank),c=Math.min(o.openEnd(h),f.length)}else h>a&&(i.span(a,h,o.active,c),c=o.openEnd(h));if(o.to>r)return c+(o.point&&o.to>r?1:0);a=o.to,o.next()}}static of(e,n=!1){let r=new Xo;for(let i of e instanceof JC?[e]:n?Lle(e):e)r.add(i.from,i.to,i.value);return r.finish()}static join(e){if(!e.length)return ft.empty;let n=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let i=e[r];i!=ft.empty;i=i.nextLayer)n=new ft(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}}ft.empty=new ft([],[],null,-1);function Lle(t){if(t.length>1)for(let e=t[0],n=1;n<t.length;n++){let r=t[n];if(QC(e,r)>0)return t.slice().sort(QC);e=r}return t}ft.empty.nextLayer=ft.empty;class Xo{finishChunk(e){this.chunks.push(new tT(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,r){this.addInner(e,n,r)||(this.nextLayer||(this.nextLayer=new Xo)).add(e,n,r)}addInner(e,n,r){let i=e-this.lastTo||r.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(ft.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=ft.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function YL(t,e,n){let r=new Map;for(let s of t)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&r.set(s.chunk[o],s.chunkPos[o]);let i=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let a=r.get(s.chunk[o]);a!=null&&(n?n.mapPos(a):a)==s.chunkPos[o]&&!n?.touchesRange(a,a+s.chunk[o].length)&&i.add(s.chunk[o])}return i}class Cz{constructor(e,n,r,i=0){this.layer=e,this.skip=n,this.minPoint=r,this.rank=i}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,n=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,n,!1),this}gotoInner(e,n,r){for(;this.chunkIndex<this.layer.chunk.length;){let i=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(i)||this.layer.chunkEnd(this.chunkIndex)<e||i.maxPoint<this.minPoint))break;this.chunkIndex++,r=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],n,!0);(!r||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(e,n){(this.to-e||this.endSide-n)<0&&this.gotoInner(e,n,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],n=this.layer.chunk[this.chunkIndex],r=e+n.from[this.rangeIndex];if(this.from=r,this.to=e+n.to[this.rangeIndex],this.value=n.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class im{constructor(e){this.heap=e}static from(e,n=null,r=-1){let i=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=r&&i.push(new Cz(o,n,r,s));return i.length==1?i[0]:new im(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)E_(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)E_(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),E_(this.heap,0)}}}function E_(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let i=t[r];if(r+1<t.length&&i.compare(t[r+1])>=0&&(i=t[r+1],r++),n.compare(i)<0)break;t[r]=n,t[e]=i,e=r}}class Od{constructor(e,n,r){this.minPoint=r,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=im.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){_y(this.active,e),_y(this.activeTo,e),_y(this.activeRank,e),this.minActive=JL(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:i,rank:s}=this.cursor;for(;n<this.activeRank.length&&(s-this.activeRank[n]||i-this.activeTo[n])>0;)n++;Cy(this.active,n,r),Cy(this.activeTo,n,i),Cy(this.activeRank,n,s),e&&Cy(e,n,this.cursor.from),this.minActive=JL(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),r&&_y(r,i)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(r){this.openStart=0;for(let i=r.length-1;i>=0&&r[i]<e;i--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let n=[];for(let r=this.active.length-1;r>=0&&!(this.activeRank[r]<this.pointRank);r--)(this.activeTo[r]>e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function XL(t,e,n,r,i,s){t.goto(e),n.goto(r);let o=r+i,a=r,c=r-e;for(;;){let h=t.to+c-n.to,f=h||t.endSide-n.endSide,d=f<0?t.to+c:n.to,m=Math.min(d,o);if(t.point||n.point?t.point&&n.point&&(t.point==n.point||t.point.eq(n.point))&&ZC(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(a,m,t.point,n.point):m>a&&!ZC(t.active,n.active)&&s.compareRange(a,m,t.active,n.active),d>o)break;(h||t.openEnd!=n.openEnd)&&s.boundChange&&s.boundChange(d),a=d,f<=0&&t.next(),f>=0&&n.next()}}function ZC(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!=e[n]&&!t[n].eq(e[n]))return!1;return!0}function _y(t,e){for(let n=e,r=t.length-1;n<r;n++)t[n]=t[n+1];t.pop()}function Cy(t,e,n){for(let r=t.length-1;r>=e;r--)t[r+1]=t[r];t[e]=n}function JL(t,e){let n=-1,r=1e9;for(let i=0;i<e.length;i++)(e[i]-r||t[i].endSide-t[n].endSide)<0&&(n=i,r=e[i]);return n}function Qh(t,e,n=t.length){let r=0;for(let i=0;i<n&&i<t.length;)t.charCodeAt(i)==9?(r+=e-r%e,i++):(r++,i=Xn(t,i));return r}function eA(t,e,n,r){for(let i=0,s=0;;){if(s>=e)return i;if(i==t.length)break;s+=t.charCodeAt(i)==9?n-s%n:1,i=Xn(t,i)}return r===!0?-1:t.length}const tA="ͼ",QL=typeof Symbol>"u"?"__"+tA:Symbol.for(tA),nA=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ZL=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class pl{constructor(e,n){this.rules=[];let{finish:r}=n||{};function i(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,a,c,h){let f=[],d=/^@(\w+)\b/.exec(o[0]),m=d&&d[1]=="keyframes";if(d&&a==null)return c.push(o[0]+";");for(let y in a){let b=a[y];if(/&/.test(y))s(y.split(/,\s*/).map(w=>o.map(S=>w.replace(/&/,S))).reduce((w,S)=>w.concat(S)),b,c);else if(b&&typeof b=="object"){if(!d)throw new RangeError("The value of a property ("+y+") should be a primitive value.");s(i(y),b,f,m)}else b!=null&&f.push(y.replace(/_.*/,"").replace(/[A-Z]/g,w=>"-"+w.toLowerCase())+": "+b+";")}(f.length||m)&&c.push((r&&!d&&!h?o.map(r):o).join(", ")+" {"+f.join(" ")+"}")}for(let o in e)s(i(o),e[o],this.rules)}getRules(){return this.rules.join(`
`)}static newName(){let e=ZL[QL]||1;return ZL[QL]=e+1,tA+e.toString(36)}static mount(e,n,r){let i=e[nA],s=r&&r.nonce;i?s&&i.setNonce(s):i=new Nle(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let eN=new Map;class Nle{constructor(e,n){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=eN.get(r);if(s)return e[nA]=s;this.sheet=new i.CSSStyleSheet,eN.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[nA]=this}mount(e,n){let r=this.sheet,i=0,s=0;for(let o=0;o<e.length;o++){let a=e[o],c=this.modules.indexOf(a);if(c<s&&c>-1&&(this.modules.splice(c,1),s--,c=-1),c==-1){if(this.modules.splice(s++,0,a),r)for(let h=0;h<a.rules.length;h++)r.insertRule(a.rules[h],i++)}else{for(;s<c;)i+=this.modules[s++].rules.length;i+=a.rules.length,s++}}if(r)n.adoptedStyleSheets.indexOf(this.sheet)<0&&(n.adoptedStyleSheets=[this.sheet,...n.adoptedStyleSheets]);else{let o="";for(let c=0;c<this.modules.length;c++)o+=this.modules[c].getRules()+`
`;this.styleTag.textContent=o;let a=n.head||n;this.styleTag.parentNode!=a&&a.insertBefore(this.styleTag,a.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var ml={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},sm={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},$le=typeof navigator<"u"&&/Mac/.test(navigator.platform),jle=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Yn=0;Yn<10;Yn++)ml[48+Yn]=ml[96+Yn]=String(Yn);for(var Yn=1;Yn<=24;Yn++)ml[Yn+111]="F"+Yn;for(var Yn=65;Yn<=90;Yn++)ml[Yn]=String.fromCharCode(Yn+32),sm[Yn]=String.fromCharCode(Yn);for(var k_ in ml)sm.hasOwnProperty(k_)||(sm[k_]=ml[k_]);function Ble(t){var e=$le&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||jle&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?sm:ml)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function kt(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i=="string"?t.setAttribute(r,i):i!=null&&(t[r]=i)}e++}for(;e<arguments.length;e++)Az(t,arguments[e]);return t}function Az(t,e){if(typeof e=="string")t.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)t.appendChild(e);else if(Array.isArray(e))for(var n=0;n<e.length;n++)Az(t,e[n]);else throw new RangeError("Unsupported child node: "+e)}function om(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function rA(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Pb(t,e){if(!e.anchorNode)return!1;try{return rA(t,e.anchorNode)}catch{return!1}}function am(t){return t.nodeType==3?Tc(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function kp(t,e,n,r){return n?tN(t,e,n,r,-1)||tN(t,e,n,r,1):!1}function kc(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function _v(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function tN(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:yo(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=kc(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=i<0?yo(t):0}else return!1}}function yo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function nx(t,e){let n=e?t.left:t.right;return{left:n,right:n,top:t.top,bottom:t.bottom}}function Fle(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function Ez(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function zle(t,e,n,r,i,s,o,a){let c=t.ownerDocument,h=c.defaultView||window;for(let f=t,d=!1;f&&!d;)if(f.nodeType==1){let m,y=f==c.body,b=1,w=1;if(y)m=Fle(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(f).position)&&(d=!0),f.scrollHeight<=f.clientHeight&&f.scrollWidth<=f.clientWidth){f=f.assignedSlot||f.parentNode;continue}let A=f.getBoundingClientRect();({scaleX:b,scaleY:w}=Ez(f,A)),m={left:A.left,right:A.left+f.clientWidth*b,top:A.top,bottom:A.top+f.clientHeight*w}}let S=0,_=0;if(i=="nearest")e.top<m.top?(_=e.top-(m.top+o),n>0&&e.bottom>m.bottom+_&&(_=e.bottom-m.bottom+o)):e.bottom>m.bottom&&(_=e.bottom-m.bottom+o,n<0&&e.top-_<m.top&&(_=e.top-(m.top+o)));else{let A=e.bottom-e.top,E=m.bottom-m.top;_=(i=="center"&&A<=E?e.top+A/2-E/2:i=="start"||i=="center"&&n<0?e.top-o:e.bottom-E+o)-m.top}if(r=="nearest"?e.left<m.left?(S=e.left-(m.left+s),n>0&&e.right>m.right+S&&(S=e.right-m.right+s)):e.right>m.right&&(S=e.right-m.right+s,n<0&&e.left<m.left+S&&(S=e.left-(m.left+s))):S=(r=="center"?e.left+(e.right-e.left)/2-(m.right-m.left)/2:r=="start"==a?e.left-s:e.right-(m.right-m.left)+s)-m.left,S||_)if(y)h.scrollBy(S,_);else{let A=0,E=0;if(_){let P=f.scrollTop;f.scrollTop+=_/w,E=(f.scrollTop-P)*w}if(S){let P=f.scrollLeft;f.scrollLeft+=S/b,A=(f.scrollLeft-P)*b}e={left:e.left-A,top:e.top-E,right:e.right-A,bottom:e.bottom-E},A&&Math.abs(A-S)<1&&(r="nearest"),E&&Math.abs(E-_)<1&&(i="nearest")}if(y)break;(e.top<m.top||e.bottom>m.bottom||e.left<m.left||e.right>m.right)&&(e={left:Math.max(e.left,m.left),right:Math.min(e.right,m.right),top:Math.max(e.top,m.top),bottom:Math.min(e.bottom,m.bottom)}),f=f.assignedSlot||f.parentNode}else if(f.nodeType==11)f=f.host;else break}function Vle(t){let e=t.ownerDocument,n,r;for(let i=t.parentNode;i&&!(i==e.body||n&&r);)if(i.nodeType==1)!r&&i.scrollHeight>i.clientHeight&&(r=i),!n&&i.scrollWidth>i.clientWidth&&(n=i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;return{x:n,y:r}}class Ule{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?yo(n):0),r,Math.min(e.focusOffset,r?yo(r):0))}set(e,n,r,i){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=i}}let Fu=null;function kz(t){if(t.setActive)return t.setActive();if(Fu)return t.focus(Fu);let e=[];for(let n=t;n&&(e.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(t.focus(Fu==null?{get preventScroll(){return Fu={preventScroll:!0},!0}}:void 0),!Fu){Fu=!1;for(let n=0;n<e.length;){let r=e[n++],i=e[n++],s=e[n++];r.scrollTop!=i&&(r.scrollTop=i),r.scrollLeft!=s&&(r.scrollLeft=s)}}}let nN;function Tc(t,e,n=e){let r=nN||(nN=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function wh(t,e,n,r){let i={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let s=new KeyboardEvent("keydown",i);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Hle(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function Tz(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function Wle(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,yo(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=yo(n))}else{if(n==t)return!0;r=kc(n),n=n.parentNode}}function Rz(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function Mz(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=yo(n)}else if(n.parentNode&&!_v(n))r=kc(n),n=n.parentNode;else return null}}function Oz(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r<n.nodeValue.length)return{node:n,offset:r};if(n.nodeType==1&&r<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[r],r=0}else if(n.parentNode&&!_v(n))r=kc(n)+1,n=n.parentNode;else return null}}class dr{constructor(e,n,r=!0){this.node=e,this.offset=n,this.precise=r}static before(e,n){return new dr(e.parentNode,kc(e),n)}static after(e,n){return new dr(e.parentNode,kc(e)+1,n)}}const nT=[];class Rt{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let n=this.posAtStart;for(let r of this.children){if(r==e)return n;n+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,n){if(this.flags&2){let r=this.dom,i=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=i?i.nextSibling:r.firstChild)){let a=Rt.get(s);(!a||!a.parent&&a.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,n),o.flags&=-8}if(s=i?i.nextSibling:r.firstChild,n&&!n.written&&n.node==r&&s!=o.dom&&(n.written=!0),o.dom.parentNode==r)for(;s&&s!=o.dom;)s=rN(s);else r.insertBefore(o.dom,s);i=o.dom}for(s=i?i.nextSibling:r.firstChild,s&&n&&n.node==r&&(n.written=!0);s;)s=rN(s)}else if(this.flags&1)for(let r of this.children)r.flags&7&&(r.sync(e,n),r.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,n){let r;if(e==this.dom)r=this.dom.childNodes[n];else{let i=yo(e)==0?0:n==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;i==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?i=-1:i=1),e=s}i<0?r=e:r=e.nextSibling}if(r==this.dom.firstChild)return 0;for(;r&&!Rt.get(r);)r=r.nextSibling;if(!r)return this.length;for(let i=0,s=0;;i++){let o=this.children[i];if(o.dom==r)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,n,r=0){let i=-1,s=-1,o=-1,a=-1;for(let c=0,h=r,f=r;c<this.children.length;c++){let d=this.children[c],m=h+d.length;if(h<e&&m>n)return d.domBoundsAround(e,n,h);if(m>=e&&i==-1&&(i=c,s=h),h>n&&d.dom.parentNode==this.dom){o=c,a=f;break}f=m,h=m+d.breakAfter}return{from:s,to:a<0?r+this.length:a,startDOM:(i?this.children[i-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let n=this.parent;n;n=n.parent){if(e&&(n.flags|=2),n.flags&1)return;n.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let n=e.parent;if(!n)return e;e=n}}replaceChildren(e,n,r=nT){this.markDirty();for(let i=e;i<n;i++){let s=this.children[i];s.parent==this&&r.indexOf(s)<0&&s.destroy()}r.length<250?this.children.splice(e,n-e,...r):this.children=[].concat(this.children.slice(0,e),r,this.children.slice(n));for(let i=0;i<r.length;i++)r[i].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new Pz(this.children,e,this.children.length)}childPos(e,n=1){return this.childCursor().findPos(e,n)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,n,r,i,s,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}Rt.prototype.breakAfter=0;function rN(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Pz{constructor(e,n,r){this.children=e,this.pos=n,this.i=r,this.off=0}findPos(e,n=1){for(;;){if(e>this.pos||e==this.pos&&(n>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let r=this.children[--this.i];this.pos-=r.length+r.breakAfter}}}function Dz(t,e,n,r,i,s,o,a,c){let{children:h}=t,f=h.length?h[e]:null,d=s.length?s[s.length-1]:null,m=d?d.breakAfter:o;if(!(e==r&&f&&!o&&!m&&s.length<2&&f.merge(n,i,s.length?d:null,n==0,a,c))){if(r<h.length){let y=h[r];y&&(i<y.length||y.breakAfter&&d?.breakAfter)?(e==r&&(y=y.split(i),i=0),!m&&d&&y.merge(0,i,d,!0,0,c)?s[s.length-1]=y:((i||y.children.length&&!y.children[0].length)&&y.merge(0,i,null,!1,0,c),s.push(y))):y?.breakAfter&&(d?d.breakAfter=1:o=1),r++}for(f&&(f.breakAfter=o,n>0&&(!o&&s.length&&f.merge(n,f.length,s[0],!1,a,0)?f.breakAfter=s.shift().breakAfter:(n<f.length||f.children.length&&f.children[f.children.length-1].length==0)&&f.merge(n,f.length,null,!1,a,0),e++));e<r&&s.length;)if(h[r-1].become(s[s.length-1]))r--,s.pop(),c=s.length?0:a;else if(h[e].become(s[0]))e++,s.shift(),a=s.length?0:c;else break;!s.length&&e&&r<h.length&&!h[e-1].breakAfter&&h[r].merge(0,0,h[e-1],!1,a,c)&&e--,(e<r||s.length)&&t.replaceChildren(e,r,s)}}function Iz(t,e,n,r,i,s){let o=t.childCursor(),{i:a,off:c}=o.findPos(n,1),{i:h,off:f}=o.findPos(e,-1),d=e-n;for(let m of r)d+=m.length;t.length+=d,Dz(t,h,f,a,c,r,0,i,s)}let qr=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},iA=typeof document<"u"?document:{documentElement:{style:{}}};const sA=/Edge\/(\d+)/.exec(qr.userAgent),Lz=/MSIE \d/.test(qr.userAgent),oA=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(qr.userAgent),rx=!!(Lz||oA||sA),iN=!rx&&/gecko\/(\d+)/i.test(qr.userAgent),T_=!rx&&/Chrome\/(\d+)/.exec(qr.userAgent),qle="webkitFontSmoothing"in iA.documentElement.style,Nz=!rx&&/Apple Computer/.test(qr.vendor),sN=Nz&&(/Mobile\/\w+/.test(qr.userAgent)||qr.maxTouchPoints>2);var Se={mac:sN||/Mac/.test(qr.platform),windows:/Win/.test(qr.platform),linux:/Linux|X11/.test(qr.platform),ie:rx,ie_version:Lz?iA.documentMode||6:oA?+oA[1]:sA?+sA[1]:0,gecko:iN,gecko_version:iN?+(/Firefox\/(\d+)/.exec(qr.userAgent)||[0,0])[1]:0,chrome:!!T_,chrome_version:T_?+T_[1]:0,ios:sN,android:/Android\b/.test(qr.userAgent),safari:Nz,webkit_version:qle?+(/\bAppleWebKit\/(\d+)/.exec(qr.userAgent)||[0,0])[1]:0,tabSize:iA.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const Gle=256;class Es extends Rt{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,n){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(n&&n.node==this.dom&&(n.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,n,r){return this.flags&8||r&&(!(r instanceof Es)||this.length-(n-e)+r.length>Gle||r.flags&8)?!1:(this.text=this.text.slice(0,e)+(r?r.text:"")+this.text.slice(n),this.markDirty(),!0)}split(e){let n=new Es(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),n.flags|=this.flags&8,n}localPosFromDOM(e,n){return e==this.dom?n:n?this.text.length:0}domAtPos(e){return new dr(this.dom,e)}domBoundsAround(e,n,r){return{from:r,to:r+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,n){return Kle(this.dom,e,n)}}class Jo extends Rt{constructor(e,n=[],r=0){super(),this.mark=e,this.children=n,this.length=r;for(let i of n)i.setParent(this)}setAttrs(e){if(Tz(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let n in this.mark.attrs)e.setAttribute(n,this.mark.attrs[n]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,n){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,n)}merge(e,n,r,i,s,o){return r&&(!(r instanceof Jo&&r.mark.eq(this.mark))||e&&s<=0||n<this.length&&o<=0)?!1:(Iz(this,e,n,r?r.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(e){let n=[],r=0,i=-1,s=0;for(let a of this.children){let c=r+a.length;c>e&&n.push(r<e?a.split(e-r):a),i<0&&r>=e&&(i=s),r=c,s++}let o=this.length-e;return this.length=e,i>-1&&(this.children.length=i,this.markDirty()),new Jo(this.mark,n,o)}domAtPos(e){return $z(this,e)}coordsAt(e,n){return Bz(this,e,n)}}function Kle(t,e,n){let r=t.nodeValue.length;e>r&&(e=r);let i=e,s=e,o=0;e==0&&n<0||e==r&&n>=0?Se.chrome||Se.gecko||(e?(i--,o=1):s<r&&(s++,o=-1)):n<0?i--:s<r&&s++;let a=Tc(t,i,s).getClientRects();if(!a.length)return null;let c=a[(o?o<0:n>=0)?0:a.length-1];return Se.safari&&!o&&c.width==0&&(c=Array.prototype.find.call(a,h=>h.width)||c),o?nx(c,o<0):c||null}class rl extends Rt{static create(e,n,r){return new rl(e,n,r)}constructor(e,n,r){super(),this.widget=e,this.length=n,this.side=r,this.prevWidget=null}split(e){let n=rl.create(this.widget,this.length-e,this.side);return this.length-=e,n}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,n,r,i,s,o){return r&&(!(r instanceof rl)||!this.widget.compare(r.widget)||e>0&&s<=0||n<this.length&&o<=0)?!1:(this.length=e+(r?r.length:0)+(this.length-n),!0)}become(e){return e instanceof rl&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return dt.empty;let e=this;for(;e.parent;)e=e.parent;let{view:n}=e,r=n&&n.state.doc,i=this.posAtStart;return r?r.slice(i,i+this.length):dt.empty}domAtPos(e){return(this.length?e==0:this.side>0)?dr.before(this.dom):dr.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,n){let r=this.widget.coordsAt(this.dom,e,n);if(r)return r;let i=this.dom.getClientRects(),s=null;if(!i.length)return null;let o=this.side?this.side<0:e>0;for(let a=o?i.length-1:0;s=i[a],!(e>0?a==0:a==i.length-1||s.top<s.bottom);a+=o?-1:1);return nx(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Ih extends Rt{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof Ih&&e.side==this.side}split(){return new Ih(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?dr.before(this.dom):dr.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return dt.empty}get isHidden(){return!0}}Es.prototype.children=rl.prototype.children=Ih.prototype.children=nT;function $z(t,e){let n=t.dom,{children:r}=t,i=0;for(let s=0;i<r.length;i++){let o=r[i],a=s+o.length;if(!(a==s&&o.getSide()<=0)){if(e>s&&e<a&&o.dom.parentNode==n)return o.domAtPos(e-s);if(e<=s)break;s=a}}for(let s=i;s>0;s--){let o=r[s-1];if(o.dom.parentNode==n)return o.domAtPos(o.length)}for(let s=i;s<r.length;s++){let o=r[s];if(o.dom.parentNode==n)return o.domAtPos(0)}return new dr(n,0)}function jz(t,e,n){let r,{children:i}=t;n>0&&e instanceof Jo&&i.length&&(r=i[i.length-1])instanceof Jo&&r.mark.eq(e.mark)?jz(r,e.children[0],n-1):(i.push(e),e.setParent(t)),t.length+=e.length}function Bz(t,e,n){let r=null,i=-1,s=null,o=-1;function a(h,f){for(let d=0,m=0;d<h.children.length&&m<=f;d++){let y=h.children[d],b=m+y.length;b>=f&&(y.children.length?a(y,f-m):(!s||s.isHidden&&(n>0||Xle(s,y)))&&(b>f||m==b&&y.getSide()>0)?(s=y,o=f-m):(m<f||m==b&&y.getSide()<0&&!y.isHidden)&&(r=y,i=f-m)),m=b}}a(t,e);let c=(n<0?r:s)||r||s;return c?c.coordsAt(Math.max(0,c==r?i:o),n):Yle(t)}function Yle(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=am(e);return n[n.length-1]||null}function Xle(t,e){let n=t.coordsAt(0,1),r=e.coordsAt(0,1);return n&&r&&r.top<n.bottom}function aA(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const oN=Object.create(null);function Cv(t,e,n){if(t==e)return!0;t||(t=oN),e||(e=oN);let r=Object.keys(t),i=Object.keys(e);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let s of r)if(s!=n&&(i.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function lA(t,e,n){let r=!1;if(e)for(let i in e)n&&i in n||(r=!0,i=="style"?t.style.cssText="":t.removeAttribute(i));if(n)for(let i in n)e&&e[i]==n[i]||(r=!0,i=="style"?t.style.cssText=n[i]:t.setAttribute(i,n[i]));return r}function Jle(t){let e=Object.create(null);for(let n=0;n<t.attributes.length;n++){let r=t.attributes[n];e[r.name]=r.value}return e}class _l{eq(e){return!1}updateDOM(e,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,n,r){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var Dr=(function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t})(Dr||(Dr={}));class He extends Ec{constructor(e,n,r,i){super(),this.startSide=e,this.endSide=n,this.widget=r,this.spec=i}get heightRelevant(){return!1}static mark(e){return new Km(e)}static widget(e){let n=Math.max(-1e4,Math.min(1e4,e.side||0)),r=!!e.block;return n+=r&&!e.inlineOrder?n>0?3e8:-4e8:n>0?1e8:-1e8,new gl(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,i;if(e.isBlockGap)r=-5e8,i=4e8;else{let{start:s,end:o}=Fz(e,n);r=(s?n?-3e8:-1:5e8)-1,i=(o?n?2e8:1:-6e8)+1}return new gl(e,r,i,n,e.widget||null,!0)}static line(e){return new Ym(e)}static set(e,n=!1){return ft.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}He.none=ft.empty;class Km extends He{constructor(e){let{start:n,end:r}=Fz(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var n,r;return this==e||e instanceof Km&&this.tagName==e.tagName&&(this.class||((n=this.attrs)===null||n===void 0?void 0:n.class))==(e.class||((r=e.attrs)===null||r===void 0?void 0:r.class))&&Cv(this.attrs,e.attrs,"class")}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Km.prototype.point=!1;class Ym extends He{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Ym&&this.spec.class==e.spec.class&&Cv(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Ym.prototype.mapMode=Mr.TrackBefore;Ym.prototype.point=!0;class gl extends He{constructor(e,n,r,i,s,o){super(n,r,s,e),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?Mr.TrackBefore:Mr.TrackAfter:Mr.TrackDel}get type(){return this.startSide!=this.endSide?Dr.WidgetRange:this.startSide<=0?Dr.WidgetBefore:Dr.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof gl&&Qle(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}gl.prototype.point=!0;function Fz(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function Qle(t,e){return t==e||!!(t&&e&&t.compare(e))}function Db(t,e,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=t?n[i]=Math.max(n[i],e):n.push(t,e)}class hn extends Rt{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,n,r,i,s,o){if(r){if(!(r instanceof hn))return!1;this.dom||r.transferDOM(this)}return i&&this.setDeco(r?r.attrs:null),Iz(this,e,n,r?r.children.slice():[],s,o),!0}split(e){let n=new hn;if(n.breakAfter=this.breakAfter,this.length==0)return n;let{i:r,off:i}=this.childPos(e);i&&(n.append(this.children[r].split(i),0),this.children[r].merge(i,this.children[r].length,null,!1,0,0),r++);for(let s=r;s<this.children.length;s++)n.append(this.children[s],0);for(;r>0&&this.children[r-1].length==0;)this.children[--r].destroy();return this.children.length=r,this.markDirty(),this.length=e,n}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Cv(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,n){jz(this,e,n)}addLineDeco(e){let n=e.spec.attributes,r=e.spec.class;n&&(this.attrs=aA(n,this.attrs||{})),r&&(this.attrs=aA({class:r},this.attrs||{}))}domAtPos(e){return $z(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,n){var r;this.dom?this.flags&4&&(Tz(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(lA(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,n);let i=this.dom.lastChild;for(;i&&Rt.get(i)instanceof Jo;)i=i.lastChild;if(!i||!this.length||i.nodeName!="BR"&&((r=Rt.get(i))===null||r===void 0?void 0:r.isEditable)==!1&&(!Se.ios||!this.children.some(s=>s instanceof Es))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,n;for(let r of this.children){if(!(r instanceof Es)||/[^ -~]/.test(r.text))return null;let i=am(r.dom);if(i.length!=1)return null;e+=i[0].width,n=i[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:n}:null}coordsAt(e,n){let r=Bz(this,e,n);if(!this.children.length&&r&&this.parent){let{heightOracle:i}=this.parent.view.viewState,s=r.bottom-r.top;if(Math.abs(s-i.lineHeight)<2&&i.textHeight<s){let o=(s-i.textHeight)/2;return{top:r.top+o,bottom:r.bottom-o,left:r.left,right:r.left}}}return r}become(e){return e instanceof hn&&this.children.length==0&&e.children.length==0&&Cv(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,n){for(let r=0,i=0;r<e.children.length;r++){let s=e.children[r],o=i+s.length;if(o>=n){if(s instanceof hn)return s;if(o>n)break}i=o+s.breakAfter}return null}}class qo extends Rt{constructor(e,n,r){super(),this.widget=e,this.length=n,this.deco=r,this.breakAfter=0,this.prevWidget=null}merge(e,n,r,i,s,o){return r&&(!(r instanceof qo)||!this.widget.compare(r.widget)||e>0&&s<=0||n<this.length&&o<=0)?!1:(this.length=e+(r?r.length:0)+(this.length-n),!0)}domAtPos(e){return e==0?dr.before(this.dom):dr.after(this.dom,e==this.length)}split(e){let n=this.length-e;this.length=e;let r=new qo(this.widget,n,this.deco);return r.breakAfter=this.breakAfter,r}get children(){return nT}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):dt.empty}domBoundsAround(){return null}become(e){return e instanceof qo&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,n){let r=this.widget.coordsAt(this.dom,e,n);return r||(this.widget instanceof cA?null:nx(this.dom.getBoundingClientRect(),this.length?e==0:n<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:n,endSide:r}=this.deco;return n==r?!1:e<0?n<0:r>0}}class cA extends _l{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class Tp{constructor(e,n,r,i){this.doc=e,this.pos=n,this.end=r,this.disallowBlockEffectsFor=i,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=n}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof qo&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new hn),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Ay(new Ih(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof qo)&&this.getLine()}buildText(e,n,r){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:a}=this.cursor.next(this.skip);if(this.skip=0,a)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let i=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(n.slice(n.length-r)),this.getLine().append(Ay(new Es(this.text.slice(this.textOff,this.textOff+i)),n),r),this.atCursorPos=!0,this.textOff+=i,e-=i,r=0}}span(e,n,r,i){this.buildText(n-e,r,i),this.pos=n,this.openStart<0&&(this.openStart=i)}point(e,n,r,i,s,o){if(this.disallowBlockEffectsFor[o]&&r instanceof gl){if(r.block)throw new RangeError("Block decorations may not be specified via plugins");if(n>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let a=n-e;if(r instanceof gl)if(r.block)r.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new qo(r.widget||Lh.block,a,r));else{let c=rl.create(r.widget||Lh.inline,a,a?0:r.startSide),h=this.atCursorPos&&!c.isEditable&&s<=i.length&&(e<n||r.startSide>0),f=!c.isEditable&&(e<n||s>i.length||r.startSide<=0),d=this.getLine();this.pendingBuffer==2&&!h&&!c.isEditable&&(this.pendingBuffer=0),this.flushBuffer(i),h&&(d.append(Ay(new Ih(1),i),s),s=i.length+Math.max(0,s-i.length)),d.append(Ay(c,i),s),this.atCursorPos=f,this.pendingBuffer=f?e<n||s>i.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=i.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(r);a&&(this.textOff+a<=this.text.length?this.textOff+=a:(this.skip+=a-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=n),this.openStart<0&&(this.openStart=s)}static build(e,n,r,i,s){let o=new Tp(e,n,r,s);return o.openEnd=ft.spans(i,n,r,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Ay(t,e){for(let n of e)t=new Jo(n,[t],t.length);return t}class Lh extends _l{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Lh.inline=new Lh("span");Lh.block=new Lh("div");var jt=(function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t})(jt||(jt={}));const Rc=jt.LTR,rT=jt.RTL;function zz(t){let e=[];for(let n=0;n<t.length;n++)e.push(1<<+t[n]);return e}const Zle=zz("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),ece=zz("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),uA=Object.create(null),Ws=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),n=t.charCodeAt(1);uA[e]=n,uA[n]=-e}function Vz(t){return t<=247?Zle[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?ece[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const tce=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class il{get dir(){return this.level%2?rT:Rc}constructor(e,n,r){this.from=e,this.to=n,this.level=r}side(e,n){return this.dir==n==e?this.to:this.from}forward(e,n){return e==(this.dir==n)}static find(e,n,r,i){let s=-1;for(let o=0;o<e.length;o++){let a=e[o];if(a.from<=n&&a.to>=n){if(a.level==r)return o;(s<0||(i!=0?i<0?a.from<n:a.to>n:e[s].level>a.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function Uz(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],i=e[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!Uz(r.inner,i.inner))return!1}return!0}const Tt=[];function nce(t,e,n,r,i){for(let s=0;s<=r.length;s++){let o=s?r[s-1].to:e,a=s<r.length?r[s].from:n,c=s?256:i;for(let h=o,f=c,d=c;h<a;h++){let m=Vz(t.charCodeAt(h));m==512?m=f:m==8&&d==4&&(m=16),Tt[h]=m==4?2:m,m&7&&(d=m),f=m}for(let h=o,f=c,d=c;h<a;h++){let m=Tt[h];if(m==128)h<a-1&&f==Tt[h+1]&&f&24?m=Tt[h]=f:Tt[h]=256;else if(m==64){let y=h+1;for(;y<a&&Tt[y]==64;)y++;let b=h&&f==8||y<n&&Tt[y]==8?d==1?1:8:256;for(let w=h;w<y;w++)Tt[w]=b;h=y-1}else m==8&&d==1&&(Tt[h]=1);f=m,m&7&&(d=m)}}}function rce(t,e,n,r,i){let s=i==1?2:1;for(let o=0,a=0,c=0;o<=r.length;o++){let h=o?r[o-1].to:e,f=o<r.length?r[o].from:n;for(let d=h,m,y,b;d<f;d++)if(y=uA[m=t.charCodeAt(d)])if(y<0){for(let w=a-3;w>=0;w-=3)if(Ws[w+1]==-y){let S=Ws[w+2],_=S&2?i:S&4?S&1?s:i:0;_&&(Tt[d]=Tt[Ws[w]]=_),a=w;break}}else{if(Ws.length==189)break;Ws[a++]=d,Ws[a++]=m,Ws[a++]=c}else if((b=Tt[d])==2||b==1){let w=b==i;c=w?0:1;for(let S=a-3;S>=0;S-=3){let _=Ws[S+2];if(_&2)break;if(w)Ws[S+2]|=2;else{if(_&4)break;Ws[S+2]|=4}}}}}function ice(t,e,n,r){for(let i=0,s=r;i<=n.length;i++){let o=i?n[i-1].to:t,a=i<n.length?n[i].from:e;for(let c=o;c<a;){let h=Tt[c];if(h==256){let f=c+1;for(;;)if(f==a){if(i==n.length)break;f=n[i++].to,a=i<n.length?n[i].from:e}else if(Tt[f]==256)f++;else break;let d=s==1,m=(f<e?Tt[f]:r)==1,y=d==m?d?1:2:r;for(let b=f,w=i,S=w?n[w-1].to:t;b>c;)b==S&&(b=n[--w].from,S=w?n[w-1].to:t),Tt[--b]=y;c=f}else s=h,c++}}}function hA(t,e,n,r,i,s,o){let a=r%2?2:1;if(r%2==i%2)for(let c=e,h=0;c<n;){let f=!0,d=!1;if(h==s.length||c<s[h].from){let w=Tt[c];w!=a&&(f=!1,d=w==16)}let m=!f&&a==1?[]:null,y=f?r:r+1,b=c;e:for(;;)if(h<s.length&&b==s[h].from){if(d)break e;let w=s[h];if(!f)for(let S=w.to,_=h+1;;){if(S==n)break e;if(_<s.length&&s[_].from==S)S=s[_++].to;else{if(Tt[S]==a)break e;break}}if(h++,m)m.push(w);else{w.from>c&&o.push(new il(c,w.from,y));let S=w.direction==Rc!=!(y%2);fA(t,S?r+1:r,i,w.inner,w.from,w.to,o),c=w.to}b=w.to}else{if(b==n||(f?Tt[b]!=a:Tt[b]==a))break;b++}m?hA(t,c,b,r+1,i,m,o):c<b&&o.push(new il(c,b,y)),c=b}else for(let c=n,h=s.length;c>e;){let f=!0,d=!1;if(!h||c>s[h-1].to){let w=Tt[c-1];w!=a&&(f=!1,d=w==16)}let m=!f&&a==1?[]:null,y=f?r:r+1,b=c;e:for(;;)if(h&&b==s[h-1].to){if(d)break e;let w=s[--h];if(!f)for(let S=w.from,_=h;;){if(S==e)break e;if(_&&s[_-1].to==S)S=s[--_].from;else{if(Tt[S-1]==a)break e;break}}if(m)m.push(w);else{w.to<c&&o.push(new il(w.to,c,y));let S=w.direction==Rc!=!(y%2);fA(t,S?r+1:r,i,w.inner,w.from,w.to,o),c=w.from}b=w.from}else{if(b==e||(f?Tt[b-1]!=a:Tt[b-1]==a))break;b--}m?hA(t,b,c,r+1,i,m,o):b<c&&o.push(new il(b,c,y)),c=b}}function fA(t,e,n,r,i,s,o){let a=e%2?2:1;nce(t,i,s,r,a),rce(t,i,s,r,a),ice(i,s,r,a),hA(t,i,s,e,n,r,o)}function sce(t,e,n){if(!t)return[new il(0,0,e==rT?1:0)];if(e==Rc&&!n.length&&!tce.test(t))return Hz(t.length);if(n.length)for(;t.length>Tt.length;)Tt[Tt.length]=256;let r=[],i=e==Rc?0:1;return fA(t,i,i,n,0,t.length,r),r}function Hz(t){return[new il(0,t,0)]}let Wz="";function oce(t,e,n,r,i){var s;let o=r.head-t.from,a=il.find(e,o,(s=r.bidiLevel)!==null&&s!==void 0?s:-1,r.assoc),c=e[a],h=c.side(i,n);if(o==h){let m=a+=i?1:-1;if(m<0||m>=e.length)return null;c=e[a=m],o=c.side(!i,n),h=c.side(i,n)}let f=Xn(t.text,o,c.forward(i,n));(f<c.from||f>c.to)&&(f=h),Wz=t.text.slice(Math.min(o,f),Math.max(o,f));let d=a==(i?e.length-1:0)?null:e[a+(i?1:-1)];return d&&f==h&&d.level+(i?0:1)<c.level?fe.cursor(d.side(!i,n)+t.from,d.forward(i,n)?1:-1,d.level):fe.cursor(f+t.from,c.forward(i,n)?-1:1,c.level)}function ace(t,e,n){for(let r=e;r<n;r++){let i=Vz(t.charCodeAt(r));if(i==1)return Rc;if(i==2||i==4)return rT}return Rc}const qz=Ce.define(),Gz=Ce.define(),Kz=Ce.define(),Yz=Ce.define(),dA=Ce.define(),Xz=Ce.define(),Jz=Ce.define(),iT=Ce.define(),sT=Ce.define(),Qz=Ce.define({combine:t=>t.some(e=>e)}),Zz=Ce.define({combine:t=>t.some(e=>e)}),eV=Ce.define();class xh{constructor(e,n="nearest",r="nearest",i=5,s=5,o=!1){this.range=e,this.y=n,this.x=r,this.yMargin=i,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new xh(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new xh(fe.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Ey=Ze.define({map:(t,e)=>t.map(e)}),tV=Ze.define();function Kr(t,e,n){let r=t.facet(Yz);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const Wo=Ce.define({combine:t=>t.length?t[0]:!0});let lce=0;const nh=Ce.define({combine(t){return t.filter((e,n)=>{for(let r=0;r<n;r++)if(t[r].plugin==e.plugin)return!1;return!0})}});class yn{constructor(e,n,r,i,s){this.id=e,this.create=n,this.domEventHandlers=r,this.domEventObservers=i,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(nh.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(nh.of({plugin:this,arg:e}))}static define(e,n){const{eventHandlers:r,eventObservers:i,provide:s,decorations:o}=n||{};return new yn(lce++,e,r,i,a=>{let c=[];return o&&c.push(lm.of(h=>{let f=h.plugin(a);return f?o(f):He.none})),s&&c.push(s(a)),c})}static fromClass(e,n){return yn.define((r,i)=>new e(r,i),n)}}class R_{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Kr(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Kr(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Kr(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const nV=Ce.define(),oT=Ce.define(),lm=Ce.define(),rV=Ce.define(),ix=Ce.define(),iV=Ce.define();function aN(t,e){let n=t.state.facet(iV);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(t):s),i=[];return ft.spans(r,e.from,e.to,{point(){},span(s,o,a,c){let h=s-e.from,f=o-e.from,d=i;for(let m=a.length-1;m>=0;m--,c--){let y=a[m].spec.bidiIsolate,b;if(y==null&&(y=ace(e.text,h,f)),c>0&&d.length&&(b=d[d.length-1]).to==h&&b.direction==y)b.to=f,d=b.inner;else{let w={from:h,to:f,direction:y,inner:[]};d.push(w),d=w.inner}}}}),i}const sV=Ce.define();function aT(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(sV)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:e,right:n,top:r,bottom:i}}const up=Ce.define();class Qi{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}join(e){return new Qi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let i=e[n-1];if(!(i.fromA>r.toA)){if(i.toA<r.fromA)break;r=r.join(i),e.splice(n-1,1)}}return e.splice(n,0,r),e}static extendWithRanges(e,n){if(n.length==0)return e;let r=[];for(let i=0,s=0,o=0,a=0;;i++){let c=i==e.length?null:e[i],h=o-a,f=c?c.fromB:1e9;for(;s<n.length&&n[s]<f;){let d=n[s],m=n[s+1],y=Math.max(a,d),b=Math.min(f,m);if(y<=b&&new Qi(y+h,b+h,y,b).addToSet(r),m>f)break;s+=2}if(!c)return r;new Qi(c.fromA,c.toA,c.fromB,c.toB).addToSet(r),o=c.toA,a=c.toB}}}class Av{constructor(e,n,r){this.view=e,this.state=n,this.transactions=r,this.flags=0,this.startState=e.state,this.changes=En.empty(this.startState.doc.length);for(let s of r)this.changes=this.changes.compose(s.changes);let i=[];this.changes.iterChangedRanges((s,o,a,c)=>i.push(new Qi(s,o,a,c))),this.changedRanges=i}static create(e,n,r){return new Av(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class lN extends Rt{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=He.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new hn],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Qi(0,0,0,e.state.doc.length)],0,null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:h,toA:f})=>f<this.minWidthFrom||h>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?i=this.domChanged.newSel.head:!mce(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?uce(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:f}=this.hasComposition;r=new Qi(h,f,e.changes.mapPos(h,-1),e.changes.mapPos(f,1)).addToSet(r.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Se.ie||Se.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,a=this.updateDeco(),c=dce(o,a,e.changes);return r=Qi.extendWithRanges(r,c),!(this.flags&7)&&r.length==0?!1:(this.updateInner(r,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n,r){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,n,r);let{observer:i}=this.view;i.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=Se.chrome||Se.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||i.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.children)o instanceof qo&&o.widget instanceof cA&&s.push(o.dom);i.updateGaps(s)}updateChildren(e,n,r){let i=r?r.range.addToSet(e.slice()):e,s=this.childCursor(n);for(let o=i.length-1;;o--){let a=o>=0?i[o]:null;if(!a)break;let{fromA:c,toA:h,fromB:f,toB:d}=a,m,y,b,w;if(r&&r.range.fromB<d&&r.range.toB>f){let P=Tp.build(this.view.state.doc,f,r.range.fromB,this.decorations,this.dynamicDecorationMap),O=Tp.build(this.view.state.doc,r.range.toB,d,this.decorations,this.dynamicDecorationMap);y=P.breakAtStart,b=P.openStart,w=O.openEnd;let M=this.compositionView(r);O.breakAtStart?M.breakAfter=1:O.content.length&&M.merge(M.length,M.length,O.content[0],!1,O.openStart,0)&&(M.breakAfter=O.content[0].breakAfter,O.content.shift()),P.content.length&&M.merge(0,0,P.content[P.content.length-1],!0,0,P.openEnd)&&P.content.pop(),m=P.content.concat(M).concat(O.content)}else({content:m,breakAtStart:y,openStart:b,openEnd:w}=Tp.build(this.view.state.doc,f,d,this.decorations,this.dynamicDecorationMap));let{i:S,off:_}=s.findPos(h,1),{i:A,off:E}=s.findPos(c,-1);Dz(this,A,E,S,_,m,y,b,w)}r&&this.fixCompositionDOM(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let n of e.transactions)for(let r of n.effects)r.is(tV)&&(this.editContextFormatting=r.value)}compositionView(e){let n=new Es(e.text.nodeValue);n.flags|=8;for(let{deco:i}of e.marks)n=new Jo(i,[n],n.length);let r=new hn;return r.append(n,0),r}fixCompositionDOM(e){let n=(s,o)=>{o.flags|=8|(o.children.some(c=>c.flags&7)?1:0),this.markedForComposition.add(o);let a=Rt.get(s);a&&a!=o&&(a.dom=null),o.setDOM(s)},r=this.childPos(e.range.fromB,1),i=this.children[r.i];n(e.line,i);for(let s=e.marks.length-1;s>=-1;s--)r=i.childPos(r.off,1),i=i.children[r.i],n(s>=0?e.marks[s].node:e.text,i)}updateSelection(e=!1,n=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let r=this.view.root.activeElement,i=r==this.dom,s=!i&&!(this.view.state.facet(Wo)||this.dom.tabIndex>-1)&&Pb(this.dom,this.view.observer.selectionRange)&&!(r&&this.dom.contains(r));if(!(i||n||s))return;let o=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,c=this.moveToLine(this.domAtPos(a.anchor)),h=a.empty?c:this.moveToLine(this.domAtPos(a.head));if(Se.gecko&&a.empty&&!this.hasComposition&&cce(c)){let d=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(d,c.node.childNodes[c.offset]||null)),c=h=new dr(d,0),o=!0}let f=this.view.observer.selectionRange;(o||!f.focusNode||(!kp(c.node,c.offset,f.anchorNode,f.anchorOffset)||!kp(h.node,h.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{Se.android&&Se.chrome&&this.dom.contains(f.focusNode)&&pce(f.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let d=om(this.view.root);if(d)if(a.empty){if(Se.gecko){let m=hce(c.node,c.offset);if(m&&m!=3){let y=(m==1?Mz:Oz)(c.node,c.offset);y&&(c=new dr(y.node,y.offset))}}d.collapse(c.node,c.offset),a.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=a.bidiLevel)}else if(d.extend){d.collapse(c.node,c.offset);try{d.extend(h.node,h.offset)}catch{}}else{let m=document.createRange();a.anchor>a.head&&([c,h]=[h,c]),m.setEnd(h.node,h.offset),m.setStart(c.node,c.offset),d.removeAllRanges(),d.addRange(m)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,h)),this.impreciseAnchor=c.precise?null:new dr(f.anchorNode,f.anchorOffset),this.impreciseHead=h.precise?null:new dr(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&kp(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=om(e.root),{anchorNode:i,anchorOffset:s}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let o=hn.find(this,n.head);if(!o)return;let a=o.posAtStart;if(n.head==a||n.head==a+o.length)return;let c=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!c||!h||c.bottom>h.top)return;let f=this.domAtPos(n.head+n.assoc);r.collapse(f.node,f.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let d=e.observer.selectionRange;e.docView.posFromDOM(d.anchorNode,d.anchorOffset)!=n.from&&r.collapse(i,s)}moveToLine(e){let n=this.dom,r;if(e.node!=n)return e;for(let i=e.offset;!r&&i<n.childNodes.length;i++){let s=Rt.get(n.childNodes[i]);s instanceof hn&&(r=s.domAtPos(0))}for(let i=e.offset-1;!r&&i>=0;i--){let s=Rt.get(n.childNodes[i]);s instanceof hn&&(r=s.domAtPos(s.length))}return r?new dr(r.node,r.offset,!0):e}nearest(e){for(let n=e;n;){let r=Rt.get(n);if(r&&r.rootView==this)return r;n=n.parentNode}return null}posFromDOM(e,n){let r=this.nearest(e);if(!r)throw new RangeError("Trying to find position for a DOM position outside of the document");return r.localPosFromDOM(e,n)+r.posAtStart}domAtPos(e){let{i:n,off:r}=this.childCursor().findPos(e,-1);for(;n<this.children.length-1;){let i=this.children[n];if(r<i.length||i instanceof hn)break;n++,r=0}return this.children[n].domAtPos(r)}coordsAt(e,n){let r=null,i=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let a=this.children[o],c=s-a.breakAfter,h=c-a.length;if(c<e)break;if(h<=e&&(h<e||a.covers(-1))&&(c>e||a.covers(1))&&(!r||a instanceof hn&&!(r instanceof hn&&n>=0)))r=a,i=h;else if(r&&h==e&&c==e&&a instanceof qo&&Math.abs(n)<2){if(a.deco.startSide<0)break;o&&(r=null)}s=h}return r?r.coordsAt(e-i,n):null}coordsForChar(e){let{i:n,off:r}=this.childPos(e,1),i=this.children[n];if(!(i instanceof hn))return null;for(;i.children.length;){let{i:a,off:c}=i.childPos(r,1);for(;;a++){if(a==i.children.length)return null;if((i=i.children[a]).length)break}r=c}if(!(i instanceof Es))return null;let s=Xn(i.text,r);if(s==r)return null;let o=Tc(i.dom,r,s).getClientRects();for(let a=0;a<o.length;a++){let c=o[a];if(a==o.length-1||c.top<c.bottom&&c.left<c.right)return c}return null}measureVisibleLineHeights(e){let n=[],{from:r,to:i}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,c=this.view.textDirection==jt.LTR;for(let h=0,f=0;f<this.children.length;f++){let d=this.children[f],m=h+d.length;if(m>i)break;if(h>=r){let y=d.dom.getBoundingClientRect();if(n.push(y.height),o){let b=d.dom.lastChild,w=b?am(b):[];if(w.length){let S=w[w.length-1],_=c?S.right-y.left:y.right-S.left;_>a&&(a=_,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=m)}}}h=m+d.breakAfter}return n}textDirectionAt(e){let{i:n}=this.childPos(e,1);return getComputedStyle(this.children[n].dom).direction=="rtl"?jt.RTL:jt.LTR}measureTextSize(){for(let s of this.children)if(s instanceof hn){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),n,r,i;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let s=am(e.firstChild)[0];n=e.getBoundingClientRect().height,r=s?s.width/27:7,i=s?s.height:n,e.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}childCursor(e=this.length){let n=this.children.length;return n&&(e-=this.children[--n].length),new Pz(this.children,e,n)}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,i=0;;i++){let s=i==n.viewports.length?null:n.viewports[i],o=s?s.from-1:this.length;if(o>r){let a=(n.lineBlockAt(o).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(He.replace({widget:new cA(a),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!s)break;r=s.to+1}return He.set(e)}updateDeco(){let e=1,n=this.view.state.facet(lm).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),r=!1,i=this.view.state.facet(rV).map((s,o)=>{let a=typeof s=="function";return a&&(r=!0),a?s(this.view):s});for(i.length&&(this.dynamicDecorationMap[e++]=r,n.push(ft.join(i))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(eV))try{if(h(this.view,e.range,e))return!0}catch(f){Kr(this.view.state,f,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1),i;if(!r)return;!n.empty&&(i=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,i.left),top:Math.min(r.top,i.top),right:Math.max(r.right,i.right),bottom:Math.max(r.bottom,i.bottom)});let s=aT(this.view),o={left:r.left-s.left,top:r.top-s.top,right:r.right+s.right,bottom:r.bottom+s.bottom},{offsetWidth:a,offsetHeight:c}=this.view.scrollDOM;zle(this.view.scrollDOM,o,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,a),-a),Math.max(Math.min(e.yMargin,c),-c),this.view.textDirection==jt.LTR)}}function cce(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function oV(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=Mz(n.focusNode,n.focusOffset),i=Oz(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let a=Rt.get(i.node);if(!a||a instanceof Es&&a.text!=i.node.nodeValue)s=i;else if(t.docView.lastCompositionAfterCursor){let c=Rt.get(r.node);!c||c instanceof Es&&c.text!=r.node.nodeValue||(s=i)}}if(t.docView.lastCompositionAfterCursor=s!=r,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function uce(t,e,n){let r=oV(t,n);if(!r)return null;let{node:i,from:s,to:o}=r,a=i.nodeValue;if(/[\n\r]/.test(a)||t.state.doc.sliceString(r.from,r.to)!=a)return null;let c=e.invertedDesc,h=new Qi(c.mapPos(s),c.mapPos(o),s,o),f=[];for(let d=i.parentNode;;d=d.parentNode){let m=Rt.get(d);if(m instanceof Jo)f.push({node:d,deco:m.mark});else{if(m instanceof hn||d.nodeName=="DIV"&&d.parentNode==t.contentDOM)return{range:h,text:i,marks:f,line:d};if(d!=t.contentDOM)f.push({node:d,deco:new Km({inclusive:!0,attributes:Jle(d),tagName:d.tagName.toLowerCase()})});else return null}}}function hce(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e<t.childNodes.length&&t.childNodes[e].contentEditable=="false"?2:0)}let fce=class{constructor(){this.changes=[]}compareRange(e,n){Db(e,n,this.changes)}comparePoint(e,n){Db(e,n,this.changes)}boundChange(e){Db(e,e,this.changes)}};function dce(t,e,n){let r=new fce;return ft.compare(t,e,n,r),r.changes}function pce(t,e){for(let n=t;n&&n!=e;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable=="false")return!0;return!1}function mce(t,e){let n=!1;return e&&t.iterChangedRanges((r,i)=>{r<e.to&&i>e.from&&(n=!0)}),n}function gce(t,e,n=1){let r=t.charCategorizer(e),i=t.doc.lineAt(e),s=e-i.from;if(i.length==0)return fe.cursor(e);s==0?n=1:s==i.length&&(n=-1);let o=s,a=s;n<0?o=Xn(i.text,s,!1):a=Xn(i.text,s);let c=r(i.text.slice(o,a));for(;o>0;){let h=Xn(i.text,o,!1);if(r(i.text.slice(h,o))!=c)break;o=h}for(;a<i.length;){let h=Xn(i.text,a);if(r(i.text.slice(a,h))!=c)break;a=h}return fe.range(o+i.from,a+i.from)}function yce(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function bce(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function M_(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function cN(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function uN(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function pA(t,e,n){let r,i,s,o,a=!1,c,h,f,d;for(let b=t.firstChild;b;b=b.nextSibling){let w=am(b);for(let S=0;S<w.length;S++){let _=w[S];i&&M_(i,_)&&(_=cN(uN(_,i.bottom),i.top));let A=yce(e,_),E=bce(n,_);if(A==0&&E==0)return b.nodeType==3?hN(b,e,n):pA(b,e,n);(!r||o>E||o==E&&s>A)&&(r=b,i=_,s=A,o=E,a=A?e<_.left?S>0:S<w.length-1:!0),A==0?n>_.bottom&&(!f||f.bottom<_.bottom)?(c=b,f=_):n<_.top&&(!d||d.top>_.top)&&(h=b,d=_):f&&M_(f,_)?f=uN(f,_.bottom):d&&M_(d,_)&&(d=cN(d,_.top))}}if(f&&f.bottom>=n?(r=c,i=f):d&&d.top<=n&&(r=h,i=d),!r)return{node:t,offset:0};let m=Math.max(i.left,Math.min(i.right,e));if(r.nodeType==3)return hN(r,m,n);if(a&&r.contentEditable!="false")return pA(r,m,n);let y=Array.prototype.indexOf.call(t.childNodes,r)+(e>=(i.left+i.right)/2?1:0);return{node:t,offset:y}}function hN(t,e,n){let r=t.nodeValue.length,i=-1,s=1e9,o=0;for(let a=0;a<r;a++){let c=Tc(t,a,a+1).getClientRects();for(let h=0;h<c.length;h++){let f=c[h];if(f.top==f.bottom)continue;o||(o=e-f.left);let d=(f.top>n?f.top-n:n-f.bottom)-1;if(f.left-1<=e&&f.right+1>=e&&d<s){let m=e>=(f.left+f.right)/2,y=m;if((Se.chrome||Se.gecko)&&Tc(t,a).getBoundingClientRect().left==f.right&&(y=!m),d<=0)return{node:t,offset:a+(y?1:0)};i=a+(y?1:0),s=d}}}return{node:t,offset:i>-1?i:o>0?t.nodeValue.length:0}}function aV(t,e,n,r=-1){var i,s;let o=t.contentDOM.getBoundingClientRect(),a=o.top+t.viewState.paddingTop,c,{docHeight:h}=t.viewState,{x:f,y:d}=e,m=d-a;if(m<0)return 0;if(m>h)return t.state.doc.length;for(let P=t.viewState.heightOracle.textHeight/2,O=!1;c=t.elementAtHeight(m),c.type!=Dr.Text;)for(;m=r>0?c.bottom+P:c.top-P,!(m>=0&&m<=h);){if(O)return n?null:0;O=!0,r=-r}d=a+m;let y=c.from;if(y<t.viewport.from)return t.viewport.from==0?0:n?null:fN(t,o,c,f,d);if(y>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:n?null:fN(t,o,c,f,d);let b=t.dom.ownerDocument,w=t.root.elementFromPoint?t.root:b,S=w.elementFromPoint(f,d);S&&!t.contentDOM.contains(S)&&(S=null),S||(f=Math.max(o.left+1,Math.min(o.right-1,f)),S=w.elementFromPoint(f,d),S&&!t.contentDOM.contains(S)&&(S=null));let _,A=-1;if(S&&((i=t.docView.nearest(S))===null||i===void 0?void 0:i.isEditable)!=!1){if(b.caretPositionFromPoint){let P=b.caretPositionFromPoint(f,d);P&&({offsetNode:_,offset:A}=P)}else if(b.caretRangeFromPoint){let P=b.caretRangeFromPoint(f,d);P&&({startContainer:_,startOffset:A}=P,(!t.contentDOM.contains(_)||Se.safari&&vce(_,A,f)||Se.chrome&&wce(_,A,f))&&(_=void 0))}_&&(A=Math.min(yo(_),A))}if(!_||!t.docView.dom.contains(_)){let P=hn.find(t.docView,y);if(!P)return m>c.top+c.height/2?c.to:c.from;({node:_,offset:A}=pA(P.dom,f,d))}let E=t.docView.nearest(_);if(!E)return null;if(E.isWidget&&((s=E.dom)===null||s===void 0?void 0:s.nodeType)==1){let P=E.dom.getBoundingClientRect();return e.y<P.top||e.y<=P.bottom&&e.x<=(P.left+P.right)/2?E.posAtStart:E.posAtEnd}else return E.localPosFromDOM(_,A)+E.posAtStart}function fN(t,e,n,r,i){let s=Math.round((r-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&n.height>t.defaultLineHeight*1.5){let a=t.viewState.heightOracle.textHeight,c=Math.floor((i-n.top-(t.defaultLineHeight-a)*.5)/a);s+=c*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+eA(o,s,t.state.tabSize)}function vce(t,e,n){let r,i=t;if(t.nodeType!=3||e!=(r=t.nodeValue.length))return!1;for(;;){let s=i.nextSibling;if(s){if(s.nodeName=="BR")break;return!1}else{let o=i.parentNode;if(!o||o.nodeName=="DIV")break;i=o}}return Tc(t,r-1,r).getBoundingClientRect().right>n}function wce(t,e,n){if(e!=0)return!1;for(let i=t;;){let s=i.parentNode;if(!s||s.nodeType!=1||s.firstChild!=i)return!1;if(s.classList.contains("cm-line"))break;i=s}let r=t.nodeType==1?t.getBoundingClientRect():Tc(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return n-r.left>5}function mA(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let i;for(let s of r.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!i||s.type==Dr.Text&&(i.type!=s.type||(n<0?s.from<e:s.to>e)))&&(i=s)}}return i||r}return r}function xce(t,e,n,r){let i=mA(t,e.head,e.assoc||-1),s=!r||i.type!=Dr.Text||!(t.lineWrapping||i.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),a=t.textDirectionAt(i.from),c=t.posAtCoords({x:n==(a==jt.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(c!=null)return fe.cursor(c,n?-1:1)}return fe.cursor(n?i.to:i.from,n?-1:1)}function dN(t,e,n,r){let i=t.state.doc.lineAt(e.head),s=t.bidiSpans(i),o=t.textDirectionAt(i.from);for(let a=e,c=null;;){let h=oce(i,s,o,a,n),f=Wz;if(!h){if(i.number==(n?t.state.doc.lines:1))return a;f=`
`,i=t.state.doc.line(i.number+(n?1:-1)),s=t.bidiSpans(i),h=t.visualLineSide(i,!n)}if(c){if(!c(f))return a}else{if(!r)return h;c=r(f)}a=h}}function Sce(t,e,n){let r=t.state.charCategorizer(e),i=r(n);return s=>{let o=r(s);return i==Vt.Space&&(i=o),i==o}}function _ce(t,e,n,r){let i=e.head,s=n?1:-1;if(i==(n?t.state.doc.length:0))return fe.cursor(i,e.assoc);let o=e.goalColumn,a,c=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(i,e.assoc||-1),f=t.documentTop;if(h)o==null&&(o=h.left-c.left),a=s<0?h.top:h.bottom;else{let y=t.viewState.lineBlockAt(i);o==null&&(o=Math.min(c.right-c.left,t.defaultCharacterWidth*(i-y.from))),a=(s<0?y.top:y.bottom)+f}let d=c.left+o,m=r??t.viewState.heightOracle.textHeight>>1;for(let y=0;;y+=10){let b=a+(m+y)*s,w=aV(t,{x:d,y:b},!1,s);if(b<c.top||b>c.bottom||(s<0?w<i:w>i)){let S=t.docView.coordsForChar(w),_=!S||b<S.top?-1:1;return fe.cursor(w,_,void 0,o)}}}function Ib(t,e,n){for(;;){let r=0;for(let i of t)i.between(e-1,e+1,(s,o,a)=>{if(e>s&&e<o){let c=r||n||(e-s<o-e?-1:1);e=c<0?s:o,r=c}});if(!r)return e}}function lV(t,e){let n=null;for(let r=0;r<e.ranges.length;r++){let i=e.ranges[r],s=null;if(i.empty){let o=Ib(t,i.from,0);o!=i.from&&(s=fe.cursor(o,-1))}else{let o=Ib(t,i.from,-1),a=Ib(t,i.to,1);(o!=i.from||a!=i.to)&&(s=fe.range(i.from==i.anchor?o:a,i.from==i.head?o:a))}s&&(n||(n=e.ranges.slice()),n[r]=s)}return n?fe.create(n,e.mainIndex):e}function O_(t,e,n){let r=Ib(t.state.facet(ix).map(i=>i(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:fe.cursor(r,r<n.from?1:-1)}const hp="￿";class Cce{constructor(e,n){this.points=e,this.text="",this.lineSeparator=n.facet(ht.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=hp}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let i=e;;){this.findPointBefore(r,i);let s=this.text.length;this.readNode(i);let o=i.nextSibling;if(o==n)break;let a=Rt.get(i),c=Rt.get(o);(a&&c?a.breakAfter:(a?a.breakAfter:_v(i))||_v(o)&&(i.nodeName!="BR"||i.cmIgnore)&&this.text.length>s)&&this.lineBreak(),i=o}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,a;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,r),o=this.lineSeparator.length):(a=i.exec(n))&&(s=a.index,o=a[0].length),this.append(n.slice(r,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let c of this.points)c.node==e&&c.pos>this.text.length&&(c.pos-=o-1);r=s+o}}readNode(e){if(e.cmIgnore)return;let n=Rt.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let i=r.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(Ace(e,r.node,r.offset)?n:0))}}function Ace(t,e,n){for(;;){if(!e||n<yo(e))return!1;if(e==t)return!0;n=kc(e)+1,e=e.parentNode}}class pN{constructor(e,n){this.node=e,this.offset=n,this.pos=-1}}class Ece{constructor(e,n,r,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=n>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=e.docView.domBoundsAround(n,r,0))){let a=s||o?[]:Rce(e),c=new Cce(a,e.state);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=Mce(a,this.bounds.from)}else{let a=e.observer.selectionRange,c=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!rA(e.contentDOM,a.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),h=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!rA(e.contentDOM,a.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((Se.ios||Se.chrome)&&e.state.selection.main.empty&&c!=h&&(f.from>0||f.to<e.state.doc.length)){let d=Math.min(c,h),m=Math.max(c,h),y=f.from-d,b=f.to-m;(y==0||y==1||d==0)&&(b==0||b==-1||m==e.state.doc.length)&&(c=0,h=e.state.doc.length)}this.newSel=fe.single(h,c)}}}function cV(t,e){let n,{newSel:r}=e,i=t.state.selection.main,s=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:a}=e.bounds,c=i.from,h=null;(s===8||Se.android&&e.text.length<a-o)&&(c=i.to,h="end");let f=Tce(t.state.doc.sliceString(o,a,hp),e.text,c-o,h);f&&(Se.chrome&&s==13&&f.toB==f.from+2&&e.text.slice(f.from,f.toB)==hp+hp&&f.toB--,n={from:o+f.from,to:o+f.toA,insert:dt.of(e.text.slice(f.from,f.toB).split(hp))})}else r&&(!t.hasFocus&&t.state.facet(Wo)||r.main.eq(i))&&(r=null);if(!n&&!r)return!1;if(!n&&e.typeOver&&!i.empty&&r&&r.main.empty?n={from:i.from,to:i.to,insert:t.state.doc.slice(i.from,i.to)}:(Se.mac||Se.android)&&n&&n.from==n.to&&n.from==i.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=fe.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:dt.of([n.insert.toString().replace("."," ")])}):n&&n.from>=i.from&&n.to<=i.to&&(n.from!=i.from||n.to!=i.to)&&i.to-i.from-(n.to-n.from)<=4?n={from:i.from,to:i.to,insert:t.state.doc.slice(i.from,n.from).append(n.insert).append(t.state.doc.slice(n.to,i.to))}:Se.chrome&&n&&n.from==n.to&&n.from==i.head&&n.insert.toString()==`
`&&t.lineWrapping&&(r&&(r=fe.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:dt.of([" "])}),n)return lT(t,n,r,s);if(r&&!r.main.eq(i)){let o=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(o=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(r=lV(t.state.facet(ix).map(c=>c(t)),r))),t.dispatch({selection:r,scrollIntoView:o,userEvent:a}),!0}else return!1}function lT(t,e,n,r=-1){if(Se.ios&&t.inputState.flushIOSKey(e))return!0;let i=t.state.selection.main;if(Se.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&t.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&wh(t.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.length<e.to-e.from&&e.to>i.head)&&wh(t.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&wh(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,a=()=>o||(o=kce(t,e,n));return t.state.facet(Xz).some(c=>c(t,e.from,e.to,s,a))||t.dispatch(a()),!0}function kce(t,e,n){let r,i=t.state,s=i.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=s.from<e.from?i.sliceDoc(s.from,e.from):"",c=s.to>e.to?i.sliceDoc(e.to,s.to):"";r=i.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+c))}else{let a=i.changes(e),c=n&&n.main.to<=a.newLength?n.main:void 0;if(i.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h=t.state.sliceDoc(e.from,e.to),f,d=n&&oV(t,n.main.head);if(d){let b=e.insert.length-(e.to-e.from);f={from:d.from,to:d.to-b}}else f=t.state.doc.lineAt(s.head);let m=s.to-e.to,y=s.to-s.from;r=i.changeByRange(b=>{if(b.from==s.from&&b.to==s.to)return{changes:a,range:c||b.map(a)};let w=b.to-m,S=w-h.length;if(b.to-b.from!=y||t.state.sliceDoc(S,w)!=h||b.to>=f.from&&b.from<=f.to)return{range:b};let _=i.changes({from:S,to:w,insert:e.insert}),A=b.to-s.to;return{changes:_,range:c?fe.range(Math.max(0,c.anchor+A),Math.max(0,c.head+A)):b.map(_)}})}else r={changes:a,selection:c&&i.selection.replaceRange(c)}}let o="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,o+=".compose",t.inputState.compositionFirstChange&&(o+=".start",t.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:o,scrollIntoView:!0})}function Tce(t,e,n,r){let i=Math.min(t.length,e.length),s=0;for(;s<i&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==i&&t.length==e.length)return null;let o=t.length,a=e.length;for(;o>0&&a>0&&t.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(r=="end"){let c=Math.max(0,s-Math.min(o,a));n-=o+c-s}if(o<s&&t.length<e.length){let c=n<=s&&n>=o?s-n:0;s-=c,a=s+(a-o),o=s}else if(a<s){let c=n<=s&&n>=a?s-n:0;s-=c,o=s+(o-a),a=s}return{from:s,toA:o,toB:a}}function Rce(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new pN(n,r)),(i!=n||s!=r)&&e.push(new pN(i,s))),e}function Mce(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?fe.single(n+e,r+e):null}class Oce{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Se.safari&&e.contentDOM.addEventListener("input",()=>null),Se.gecko&&Gce(e.contentDOM.ownerDocument)}handleEvent(e){!Bce(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let i of r.observers)i(this.view,n);for(let i of r.handlers){if(n.defaultPrevented)break;if(i(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=Pce(e),r=this.handlers,i=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,a=r[s];a&&o!=!a.handlers.length&&(i.removeEventListener(s,this.handleEvent),a=null),a||i.addEventListener(s,this.handleEvent,{passive:o})}for(let s in r)s!="scroll"&&!n[s]&&i.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&hV.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Se.android&&Se.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let n;return Se.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((n=uV.find(r=>r.keyCode==e.keyCode))&&!e.ctrlKey||Dce.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=n||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,wh(this.view.contentDOM,n.key,n.keyCode,n instanceof KeyboardEvent?n:void 0))}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:Se.safari&&!Se.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function mN(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){Kr(n.state,i)}}}function Pce(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let i=r.spec,s=i&&i.plugin.domEventHandlers,o=i&&i.plugin.domEventObservers;if(s)for(let a in s){let c=s[a];c&&n(a).handlers.push(mN(r.value,c))}if(o)for(let a in o){let c=o[a];c&&n(a).observers.push(mN(r.value,c))}}for(let r in ks)n(r).handlers.push(ks[r]);for(let r in ts)n(r).observers.push(ts[r]);return e}const uV=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Dce="dthko",hV=[16,17,18,20,91,92,224,225],ky=6;function Ty(t){return Math.max(0,t)*.7+8}function Ice(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class Lce{constructor(e,n,r,i){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=Vle(e.contentDOM),this.atoms=e.state.facet(ix).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(ht.allowMultipleSelections)&&Nce(e,n),this.dragging=jce(e,n)&&pV(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Ice(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,i=0,s=0,o=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:a}=this.scrollParents.y.getBoundingClientRect());let c=aT(this.view);e.clientX-c.left<=i+ky?n=-Ty(i-e.clientX):e.clientX+c.right>=o-ky&&(n=Ty(e.clientX-o)),e.clientY-c.top<=s+ky?r=-Ty(s-e.clientY):e.clientY+c.bottom>=a-ky&&(r=Ty(e.clientY-a)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=lV(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function Nce(t,e){let n=t.state.facet(qz);return n.length?n[0](e):Se.mac?e.metaKey:e.ctrlKey}function $ce(t,e){let n=t.state.facet(Gz);return n.length?n[0](e):Se.mac?!e.altKey:!e.ctrlKey}function jce(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=om(t.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let s=0;s<i.length;s++){let o=i[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Bce(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Rt.get(n))&&r.ignoreEvent(e))return!1;return!0}const ks=Object.create(null),ts=Object.create(null),fV=Se.ie&&Se.ie_version<15||Se.ios&&Se.webkit_version<604;function Fce(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),dV(t,n.value)},50)}function sx(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function dV(t,e){e=sx(t.state,iT,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(gA!=null&&n.selection.ranges.every(c=>c.empty)&&gA==s.toString()){let c=-1;r=n.changeByRange(h=>{let f=n.doc.lineAt(h.from);if(f.from==c)return{range:h};c=f.from;let d=n.toText((o?s.line(i++).text:e)+n.lineBreak);return{changes:{from:f.from,insert:d},range:fe.cursor(h.from+d.length)}})}else o?r=n.changeByRange(c=>{let h=s.line(i++);return{changes:{from:c.from,to:c.to,insert:h.text},range:fe.cursor(c.from+h.length)}}):r=n.replaceSelection(s);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}ts.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft};ks.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);ts.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")};ts.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};ks.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(Kz))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=Uce(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new Lce(t,e,n,r)),r&&t.observer.ignore(()=>{kz(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let i=t.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function gN(t,e,n,r){if(r==1)return fe.cursor(e,n);if(r==2)return gce(t.state,e,n);{let i=hn.find(t.docView,e),s=t.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:s.from,a=i?i.posAtEnd:s.to;return a<t.state.doc.length&&a==s.to&&a++,fe.range(o,a)}}let yN=(t,e,n)=>e>=n.top&&e<=n.bottom&&t>=n.left&&t<=n.right;function zce(t,e,n,r){let i=hn.find(t.docView,e);if(!i)return 1;let s=e-i.posAtStart;if(s==0)return 1;if(s==i.length)return-1;let o=i.coordsAt(s,-1);if(o&&yN(n,r,o))return-1;let a=i.coordsAt(s,1);return a&&yN(n,r,a)?1:o&&o.bottom>=r?-1:1}function bN(t,e){let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:n,bias:zce(t,n,e.clientX,e.clientY)}}const Vce=Se.ie&&Se.ie_version<=11;let vN=null,wN=0,xN=0;function pV(t){if(!Vce)return t.detail;let e=vN,n=xN;return vN=t,xN=Date.now(),wN=!e||n>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(wN+1)%3:1}function Uce(t,e){let n=bN(t,e),r=pV(e),i=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),i=i.map(s.changes))},get(s,o,a){let c=bN(t,s),h,f=gN(t,c.pos,c.bias,r);if(n.pos!=c.pos&&!o){let d=gN(t,n.pos,n.bias,r),m=Math.min(d.from,f.from),y=Math.max(d.to,f.to);f=m<f.from?fe.range(m,y):fe.range(y,m)}return o?i.replaceRange(i.main.extend(f.from,f.to)):a&&r==1&&i.ranges.length>1&&(h=Hce(i,c.pos))?h:a?i.addRange(f):fe.create([f])}}}function Hce(t,e){for(let n=0;n<t.ranges.length;n++){let{from:r,to:i}=t.ranges[n];if(r<=e&&i>=e)return fe.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}ks.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let i=t.docView.nearest(e.target);if(i&&i.isWidget){let s=i.posAtStart,o=s+i.length;(s>=n.to||o<=n.from)&&(n=fe.range(s,o))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",sx(t.state,sT,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};ks.dragend=t=>(t.inputState.draggedContent=null,!1);function SN(t,e,n,r){if(n=sx(t.state,iT,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&$ce(t,e)?{from:s.from,to:s.to}:null,a={from:i,insert:n},c=t.state.changes(o?[o,a]:a);t.focus(),t.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}ks.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,s=()=>{++i==n.length&&SN(t,e,r.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o<n.length;o++){let a=new FileReader;a.onerror=s,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(r[o]=a.result),s()},a.readAsText(n[o])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return SN(t,e,r,!0),!0}return!1};ks.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=fV?null:e.clipboardData;return n?(dV(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(Fce(t),!1)};function Wce(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function qce(t){let e=[],n=[],r=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),n.push(i));if(!e.length){let i=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>i&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),i=o.number}r=!0}return{text:sx(t,sT,e.join(t.lineBreak)),ranges:n,linewise:r}}let gA=null;ks.copy=ks.cut=(t,e)=>{let{text:n,ranges:r,linewise:i}=qce(t.state);if(!n&&!i)return!1;gA=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=fV?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(Wce(t,n),!1)};const mV=sa.define();function gV(t,e){let n=[];for(let r of t.facet(Jz)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:mV.of(!0)}):null}function yV(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=gV(t.state,e);n?t.dispatch(n):t.update([])}},10)}ts.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),yV(t)};ts.blur=t=>{t.observer.clearSelectionRange(),yV(t)};ts.compositionstart=ts.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};ts.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Se.chrome&&Se.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};ts.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};ks.beforeinput=(t,e)=>{var n,r;if(e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let a=o[0],c=t.posAtDOM(a.startContainer,a.startOffset),h=t.posAtDOM(a.endContainer,a.endOffset);return lT(t,{from:c,to:h,insert:t.state.toText(s)},null),!0}}let i;if(Se.chrome&&Se.android&&(i=uV.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Se.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Se.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>ts.compositionend(t,e),20),!1};const _N=new Set;function Gce(t){_N.has(t)||(_N.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const CN=["pre-wrap","normal","pre-line","break-spaces"];let Nh=!1;function AN(){Nh=!1}class Kce{constructor(e){this.lineWrapping=e,this.doc=dt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return CN.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];i<0?r++:this.heightSamples[Math.floor(i*10)]||(n=!0,this.heightSamples[Math.floor(i*10)]=!0)}return n}refresh(e,n,r,i,s,o){let a=CN.indexOf(e)>-1,c=Math.round(n)!=Math.round(this.lineHeight)||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=n,this.charWidth=r,this.textHeight=i,this.lineLength=s,c){this.heightSamples={};for(let h=0;h<o.length;h++){let f=o[h];f<0?h++:this.heightSamples[Math.floor(f*10)]=!0}}return c}}class Yce{constructor(e,n){this.from=e,this.heights=n,this.index=0}get more(){return this.index<this.heights.length}}class no{constructor(e,n,r,i,s){this.from=e,this.length=n,this.top=r,this.height=i,this._content=s}get type(){return typeof this._content=="number"?Dr.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof gl?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new no(this.from,this.length+e.length,this.top,this.height+e.height,n)}}var $t=(function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t})($t||($t={}));const Lb=.001;class Ir{constructor(e,n,r=2){this.length=e,this.height=n,this.flags=r}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Lb&&(Nh=!0),this.height=e)}replace(e,n,r){return Ir.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,i){let s=this,o=r.doc;for(let a=i.length-1;a>=0;a--){let{fromA:c,toA:h,fromB:f,toB:d}=i[a],m=s.lineAt(c,$t.ByPosNoHeight,r.setDoc(n),0,0),y=m.to>=h?m:s.lineAt(h,$t.ByPosNoHeight,r,0,0);for(d+=y.to-h,h=y.to;a>0&&m.from<=i[a-1].toA;)c=i[a-1].fromA,f=i[a-1].fromB,a--,c<m.from&&(m=s.lineAt(c,$t.ByPosNoHeight,r,0,0));f+=m.from-c,c=m.from;let b=cT.build(r.setDoc(o),e,f,d);s=Ev(s,s.replace(c,h,b))}return s.updateHeight(r,0)}static empty(){return new _i(0,0)}static of(e){if(e.length==1)return e[0];let n=0,r=e.length,i=0,s=0;for(;;)if(n==r)if(i>s*2){let a=e[n-1];a.break?e.splice(--n,1,a.left,null,a.right):e.splice(--n,1,a.left,a.right),r+=1+a.break,i-=a.size}else if(s>i*2){let a=e[r];a.break?e.splice(r,1,a.left,null,a.right):e.splice(r,1,a.left,a.right),r+=2+a.break,s-=a.size}else break;else if(i<s){let a=e[n++];a&&(i+=a.size)}else{let a=e[--r];a&&(s+=a.size)}let o=0;return e[n-1]==null?(o=1,n--):e[n]==null&&(o=1,r++),new Xce(Ir.of(e.slice(0,n)),o,Ir.of(e.slice(r)))}}function Ev(t,e){return t==e?t:(t.constructor!=e.constructor&&(Nh=!0),e)}Ir.prototype.size=1;class bV extends Ir{constructor(e,n,r){super(e,n),this.deco=r}blockAt(e,n,r,i){return new no(i,this.length,r,this.height,this.deco||0)}lineAt(e,n,r,i,s){return this.blockAt(0,r,i,s)}forEachLine(e,n,r,i,s,o){e<=s+this.length&&n>=s&&o(this.blockAt(0,r,i,s))}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more&&this.setHeight(i.heights[i.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class _i extends bV{constructor(e,n){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,n,r,i){return new no(i,this.length,r,this.height,this.breaks)}replace(e,n,r){let i=r[0];return r.length==1&&(i instanceof _i||i instanceof qn&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof qn?i=new _i(i.length,this.height):i.height=this.height,this.outdated||(i.outdated=!1),i):Ir.of(r)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more?this.setHeight(i.heights[i.index++]):(r||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class qn extends Ir{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,i=e.doc.lineAt(n+this.length).number,s=i-r+1,o,a=0;if(e.lineWrapping){let c=Math.min(this.height,e.lineHeight*s);o=c/s,this.length>s+1&&(a=(this.height-c)/(this.length-s-1))}else o=this.height/s;return{firstLine:r,lastLine:i,perLine:o,perChar:a}}blockAt(e,n,r,i){let{firstLine:s,lastLine:o,perLine:a,perChar:c}=this.heightMetrics(n,i);if(n.lineWrapping){let h=i+(e<n.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-r)/this.height))*this.length)),f=n.doc.lineAt(h),d=a+f.length*c,m=Math.max(r,e-d/2);return new no(f.from,f.length,m,d,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-r)/a))),{from:f,length:d}=n.doc.line(s+h);return new no(f,d,r+a*h,a,0)}}lineAt(e,n,r,i,s){if(n==$t.ByHeight)return this.blockAt(e,r,i,s);if(n==$t.ByPosNoHeight){let{from:y,to:b}=r.doc.lineAt(e);return new no(y,b-y,0,0,0)}let{firstLine:o,perLine:a,perChar:c}=this.heightMetrics(r,s),h=r.doc.lineAt(e),f=a+h.length*c,d=h.number-o,m=i+a*d+c*(h.from-s-d);return new no(h.from,h.length,Math.max(i,Math.min(m,i+this.height-f)),f,0)}forEachLine(e,n,r,i,s,o){e=Math.max(e,s),n=Math.min(n,s+this.length);let{firstLine:a,perLine:c,perChar:h}=this.heightMetrics(r,s);for(let f=e,d=i;f<=n;){let m=r.doc.lineAt(f);if(f==e){let b=m.number-a;d+=c*b+h*(e-s-b)}let y=c+h*m.length;o(new no(m.from,m.length,d,y,0)),d+=y,f=m.to+1}}replace(e,n,r){let i=this.length-n;if(i>0){let s=r[r.length-1];s instanceof qn?r[r.length-1]=new qn(s.length+i):r.push(null,new qn(i-1))}if(e>0){let s=r[0];s instanceof qn?r[0]=new qn(e+s.length):r.unshift(new qn(e-1),null)}return Ir.of(r)}decomposeLeft(e,n){n.push(new qn(e-1),null)}decomposeRight(e,n){n.push(null,new qn(this.length-e-1))}updateHeight(e,n=0,r=!1,i){let s=n+this.length;if(i&&i.from<=n+this.length&&i.more){let o=[],a=Math.max(n,i.from),c=-1;for(i.from>n&&o.push(new qn(i.from-n-1).updateHeight(e,n));a<=s&&i.more;){let f=e.doc.lineAt(a).length;o.length&&o.push(null);let d=i.heights[i.index++];c==-1?c=d:Math.abs(d-c)>=Lb&&(c=-2);let m=new _i(f,d);m.outdated=!1,o.push(m),a+=f+1}a<=s&&o.push(null,new qn(s-a).updateHeight(e,a));let h=Ir.of(o);return(c<0||Math.abs(h.height-this.height)>=Lb||Math.abs(c-this.heightMetrics(e,n).perLine)>=Lb)&&(Nh=!0),Ev(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Xce extends Ir{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,i){let s=r+this.left.height;return e<s?this.left.blockAt(e,n,r,i):this.right.blockAt(e,n,s,i+this.left.length+this.break)}lineAt(e,n,r,i,s){let o=i+this.left.height,a=s+this.left.length+this.break,c=n==$t.ByHeight?e<o:e<a,h=c?this.left.lineAt(e,n,r,i,s):this.right.lineAt(e,n,r,o,a);if(this.break||(c?h.to<a:h.from>a))return h;let f=n==$t.ByPosNoHeight?$t.ByPosNoHeight:$t.ByPos;return c?h.join(this.right.lineAt(a,f,r,o,a)):this.left.lineAt(a,f,r,i,s).join(h)}forEachLine(e,n,r,i,s,o){let a=i+this.left.height,c=s+this.left.length+this.break;if(this.break)e<c&&this.left.forEachLine(e,n,r,i,s,o),n>=c&&this.right.forEachLine(e,n,r,a,c,o);else{let h=this.lineAt(c,$t.ByPos,r,i,s);e<h.from&&this.left.forEachLine(e,h.from-1,r,i,s,o),h.to>=e&&h.from<=n&&o(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,a,c,o)}}replace(e,n,r){let i=this.left.length+this.break;if(n<i)return this.balanced(this.left.replace(e,n,r),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,n-i,r));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let a of r)s.push(a);if(e>0&&EN(s,o-1),n<this.length){let a=s.length;this.decomposeRight(n,s),EN(s,a)}return Ir.of(s)}decomposeLeft(e,n){let r=this.left.length;if(e<=r)return this.left.decomposeLeft(e,n);n.push(this.left),this.break&&(r++,e>=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,i=r+this.break;if(e>=i)return this.right.decomposeRight(e-i,n);e<r&&this.left.decomposeRight(e,n),this.break&&e<i&&n.push(null),n.push(this.right)}balanced(e,n){return e.size>2*n.size||n.size>2*e.size?Ir.of(this.break?[e,null,n]:[e,n]):(this.left=Ev(this.left,e),this.right=Ev(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,i){let{left:s,right:o}=this,a=n+s.length+this.break,c=null;return i&&i.from<=n+s.length&&i.more?c=s=s.updateHeight(e,n,r,i):s.updateHeight(e,n,r),i&&i.from<=a+o.length&&i.more?c=o=o.updateHeight(e,a,r,i):o.updateHeight(e,a,r),c?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function EN(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof qn&&(r=t[e+1])instanceof qn&&t.splice(e-1,3,new qn(n.length+1+r.length))}const Jce=5;class cT{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof _i?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new _i(r-this.pos,-1)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e<n||r.heightRelevant){let i=r.widget?r.widget.estimatedHeight:0,s=r.widget?r.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let o=n-e;r.block?this.addBlock(new bV(o,i,r)):(o||s||i>=Jce)&&this.addLineDeco(i,s,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new _i(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,n){let r=new qn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof _i)return e;let n=new _i(0,-1);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof _i)&&!this.isCovered?this.nodes.push(new _i(0,-1)):(this.writtenTo<this.pos||n==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let r=e;for(let i of this.nodes)i instanceof _i&&i.updateHeight(this.oracle,r),r+=i?i.length:1;return this.nodes}static build(e,n,r,i){let s=new cT(r,e);return ft.spans(n,r,i,s,0),s.finish(r)}}function Qce(t,e,n){let r=new Zce;return ft.compare(t,e,n,r,0),r.changes}class Zce{constructor(){this.changes=[]}compareRange(){}comparePoint(e,n,r,i){(e<n||r&&r.heightRelevant||i&&i.heightRelevant)&&Db(e,n,this.changes,5)}}function eue(t,e){let n=t.getBoundingClientRect(),r=t.ownerDocument,i=r.defaultView||window,s=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),a=Math.max(0,n.top),c=Math.min(i.innerHeight,n.bottom);for(let h=t.parentNode;h&&h!=r.body;)if(h.nodeType==1){let f=h,d=window.getComputedStyle(f);if((f.scrollHeight>f.clientHeight||f.scrollWidth>f.clientWidth)&&d.overflow!="visible"){let m=f.getBoundingClientRect();s=Math.max(s,m.left),o=Math.min(o,m.right),a=Math.max(a,m.top),c=Math.min(h==t.parentNode?i.innerHeight:c,m.bottom)}h=d.position=="absolute"||d.position=="fixed"?f.offsetParent:f.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:a-(n.top+e),bottom:Math.max(a,c)-(n.top+e)}}function tue(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left<n.innerWidth&&e.right>0&&e.top<n.innerHeight&&e.bottom>0}function nue(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class P_{constructor(e,n,r,i){this.from=e,this.to=n,this.size=r,this.displaySize=i}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++){let i=e[r],s=n[r];if(i.from!=s.from||i.to!=s.to||i.size!=s.size)return!1}return!0}draw(e,n){return He.replace({widget:new rue(this.displaySize*(n?e.scaleY:e.scaleX),n)}).range(this.from,this.to)}}class rue extends _l{constructor(e,n){super(),this.size=e,this.vertical=n}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class kN{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=TN,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=jt.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=e.facet(oT).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new Kce(n),this.stateDeco=e.facet(lm).filter(r=>typeof r!="function"),this.heightMap=Ir.empty().applyChanges(this.stateDeco,dt.empty,this.heightOracle.setDoc(e.doc),[new Qi(0,0,0,e.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=He.set(this.lineGaps.map(r=>r.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let i=r?n.head:n.anchor;if(!e.some(({from:s,to:o})=>i>=s&&i<=o)){let{from:s,to:o}=this.lineBlockAt(i);e.push(new Ry(s,o))}}return this.viewports=e.sort((r,i)=>r.from-i.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?TN:new uT(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(fp(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=this.state.facet(lm).filter(f=>typeof f!="function");let i=e.changedRanges,s=Qi.extendWithRanges(i,Qce(r,this.stateDeco,e?e.changes:En.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);AN(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Nh)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let c=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.head<c.from||n.range.head>c.to)||!this.viewportIsAppropriate(c))&&(c=this.getViewport(0,n));let h=c.from!=this.viewport.from||c.to!=this.viewport.to;this.viewport=c,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Zz)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let n=e.contentDOM,r=window.getComputedStyle(n),i=this.heightOracle,s=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?jt.RTL:jt.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),a=n.getBoundingClientRect(),c=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let h=0,f=0;if(a.width&&a.height){let{scaleX:P,scaleY:O}=Ez(n,a);(P>.005&&Math.abs(this.scaleX-P)>.005||O>.005&&Math.abs(this.scaleY-O)>.005)&&(this.scaleX=P,this.scaleY=O,h|=16,o=c=!0)}let d=(parseInt(r.paddingTop)||0)*this.scaleY,m=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=d||this.paddingBottom!=m)&&(this.paddingTop=d,this.paddingBottom=m,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(c=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let y=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=y&&(this.scrollAnchorHeight=-1,this.scrollTop=y),this.scrolledToBottom=Rz(e.scrollDOM);let b=(this.printing?nue:eue)(n,this.paddingTop),w=b.top-this.pixelViewport.top,S=b.bottom-this.pixelViewport.bottom;this.pixelViewport=b;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(c=!0)),!this.inView&&!this.scrollTarget&&!tue(e.dom))return 0;let A=a.width;if((this.contentDOMWidth!=A||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),c){let P=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(P)&&(o=!0),o||i.lineWrapping&&Math.abs(A-this.contentDOMWidth)>i.charWidth){let{lineHeight:O,charWidth:M,textHeight:D}=e.docView.measureTextSize();o=O>0&&i.refresh(s,O,M,D,Math.max(5,A/M),P),o&&(e.docView.minWidth=0,h|=16)}w>0&&S>0?f=Math.max(w,S):w<0&&S<0&&(f=Math.min(w,S)),AN();for(let O of this.viewports){let M=O.from==this.viewport.from?P:e.docView.measureVisibleLineHeights(O);this.heightMap=(o?Ir.empty().applyChanges(this.stateDeco,dt.empty,this.heightOracle,[new Qi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new Yce(O.from,M))}Nh&&(h|=2)}let E=!this.viewportIsAppropriate(this.viewport,f)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return E&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(f,this.scrollTarget),h|=this.updateForViewport()),(h&2||E)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,c=new Ry(i.lineAt(o-r*1e3,$t.ByHeight,s,0,0).from,i.lineAt(a+(1-r)*1e3,$t.ByHeight,s,0,0).to);if(n){let{head:h}=n.range;if(h<c.from||h>c.to){let f=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),d=i.lineAt(h,$t.ByPos,s,0,0),m;n.y=="center"?m=(d.top+d.bottom)/2-f/2:n.y=="start"||n.y=="nearest"&&h<c.from?m=d.top:m=d.bottom-f,c=new Ry(i.lineAt(m-1e3/2,$t.ByHeight,s,0,0).from,i.lineAt(m+f+1e3/2,$t.ByHeight,s,0,0).to)}}return c}mapViewport(e,n){let r=n.mapPos(e.from,-1),i=n.mapPos(e.to,1);return new Ry(this.heightMap.lineAt(r,$t.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,$t.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:n},r=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(e,$t.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(n,$t.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:a}=this;return(e==0||i<=o-Math.max(10,Math.min(-r,250)))&&(n==this.state.doc.length||s>=a+Math.max(10,Math.min(r,250)))&&i>o-2*1e3&&s<a+2*1e3}mapLineGaps(e,n){if(!e.length||n.empty)return e;let r=[];for(let i of e)n.touchesRange(i.from,i.to)||r.push(new P_(n.mapPos(i.from),n.mapPos(i.to),i.size,i.displaySize));return r}ensureLineGaps(e,n){let r=this.heightOracle.lineWrapping,i=r?1e4:2e3,s=i>>1,o=i<<1;if(this.defaultTextDirection!=jt.LTR&&!r)return[];let a=[],c=(f,d,m,y)=>{if(d-f<s)return;let b=this.state.selection.main,w=[b.from];b.empty||w.push(b.to);for(let _ of w)if(_>f&&_<d){c(f,_-10,m,y),c(_+10,d,m,y);return}let S=sue(e,_=>_.from>=m.from&&_.to<=m.to&&Math.abs(_.from-f)<s&&Math.abs(_.to-d)<s&&!w.some(A=>_.from<A&&_.to>A));if(!S){if(d<m.to&&n&&r&&n.visibleRanges.some(E=>E.from<=d&&E.to>=d)){let E=n.moveToLineBoundary(fe.cursor(d),!1,!0).head;E>f&&(d=E)}let _=this.gapSize(m,f,d,y),A=r||_<2e6?_:2e6;S=new P_(f,d,_,A)}a.push(S)},h=f=>{if(f.length<o||f.type!=Dr.Text)return;let d=iue(f.from,f.to,this.stateDeco);if(d.total<o)return;let m=this.scrollTarget?this.scrollTarget.range.head:null,y,b;if(r){let w=i/this.heightOracle.lineLength*this.heightOracle.lineHeight,S,_;if(m!=null){let A=Oy(d,m),E=((this.visibleBottom-this.visibleTop)/2+w)/f.height;S=A-E,_=A+E}else S=(this.visibleTop-f.top-w)/f.height,_=(this.visibleBottom-f.top+w)/f.height;y=My(d,S),b=My(d,_)}else{let w=d.total*this.heightOracle.charWidth,S=i*this.heightOracle.charWidth,_=0;if(w>2e6)for(let M of e)M.from>=f.from&&M.from<f.to&&M.size!=M.displaySize&&M.from*this.heightOracle.charWidth+_<this.pixelViewport.left&&(_=M.size-M.displaySize);let A=this.pixelViewport.left+_,E=this.pixelViewport.right+_,P,O;if(m!=null){let M=Oy(d,m),D=((E-A)/2+S)/w;P=M-D,O=M+D}else P=(A-S)/w,O=(E+S)/w;y=My(d,P),b=My(d,O)}y>f.from&&c(f.from,y,f,d),b<f.to&&c(b,f.to,f,d)};for(let f of this.viewportLines)Array.isArray(f.type)?f.type.forEach(h):h(f);return a}gapSize(e,n,r,i){let s=Oy(i,r)-Oy(i,n);return this.heightOracle.lineWrapping?e.height*s:i.total*this.heightOracle.charWidth*s}updateLineGaps(e){P_.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=He.set(e.map(n=>n.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];ft.spans(n,this.viewport.from,this.viewport.to,{span(s,o){r.push({from:s,to:o})},point(){}},20);let i=0;if(r.length!=this.visibleRanges.length)i=12;else for(let s=0;s<r.length&&!(i&8);s++){let o=this.visibleRanges[s],a=r[s];(o.from!=a.from||o.to!=a.to)&&(i|=4,e&&e.mapPos(o.from,-1)==a.from&&e.mapPos(o.to,1)==a.to||(i|=8))}return this.visibleRanges=r,i}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||fp(this.heightMap.lineAt(e,$t.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||fp(this.heightMap.lineAt(this.scaler.fromDOM(e),$t.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return fp(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Ry{constructor(e,n){this.from=e,this.to=n}}function iue(t,e,n){let r=[],i=t,s=0;return ft.spans(n,t,e,{span(){},point(o,a){o>i&&(r.push({from:i,to:o}),s+=o-i),i=a}},20),i<e&&(r.push({from:i,to:e}),s+=e-i),{total:s,ranges:r}}function My({total:t,ranges:e},n){if(n<=0)return e[0].from;if(n>=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let i=0;;i++){let{from:s,to:o}=e[i],a=o-s;if(r<=a)return s+r;r-=a}}function Oy(t,e){let n=0;for(let{from:r,to:i}of t.ranges){if(e<=i){n+=e-r;break}n+=i-r}return n/t.total}function sue(t,e){for(let n of t)if(e(n))return n}const TN={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};class uT{constructor(e,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:a,to:c})=>{let h=n.lineAt(a,$t.ByPos,e,0,0).top,f=n.lineAt(c,$t.ByPos,e,0,0).bottom;return i+=f-h,{from:a,to:c,top:h,bottom:f,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let a of this.viewports)a.domTop=o+(a.top-s)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(e){for(let n=0,r=0,i=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||e<s.top)return i+(e-r)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);r=s.bottom,i=s.domBottom}}fromDOM(e){for(let n=0,r=0,i=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||e<s.domTop)return r+(e-i)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);r=s.bottom,i=s.domBottom}}eq(e){return e instanceof uT?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((n,r)=>n.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function fp(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new no(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>fp(i,e)):t._content)}const Py=Ce.define({combine:t=>t.join(" ")}),yA=Ce.define({combine:t=>t.indexOf(!0)>-1}),bA=pl.newName(),vV=pl.newName(),wV=pl.newName(),xV={"&light":"."+vV,"&dark":"."+wV};function vA(t,e,n){return new pl(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return t;if(!n||!n[i])throw new RangeError(`Unsupported selector: ${i}`);return n[i]}):t+" "+r}})}const oue=vA("."+bA,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},xV),aue={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},D_=Se.ie&&Se.ie_version<=11;class lue{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Ule,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Se.ie&&Se.ie_version<=11||Se.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Se.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Se.chrome&&Se.chrome_version<126)&&(this.editContext=new uue(e),e.state.facet(Wo)&&(e.contentDOM.editContext=this.editContext.editContext)),D_&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(n=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(Wo)?r.root.activeElement!=this.dom:!Pb(this.dom,i))return;let s=i.anchorNode&&r.docView.nearest(i.anchorNode);if(s&&s.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Se.ie&&Se.ie_version<=11||Se.android&&Se.chrome)&&!r.state.selection.main.empty&&i.focusNode&&kp(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=om(e.root);if(!n)return!1;let r=Se.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&cue(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=Pb(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Wle(this.dom,r)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(r),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,n){this.selectionRange.set(e.node,e.offset,n.node,n.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,n=null;for(let r=this.dom;r;)if(r.nodeType==1)!n&&e<this.scrollTargets.length&&this.scrollTargets[e]==r?e++:n||(n=this.scrollTargets.slice(0,e)),n&&n.push(r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;if(e<this.scrollTargets.length&&!n&&(n=this.scrollTargets.slice(0,e)),n){for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);for(let r of this.scrollTargets=n)r.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,aue),D_&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),D_&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,n){var r;if(!this.delayedAndroidKey){let i=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&wh(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange<Date.now()-50||!!(!((r=this.delayedAndroidKey)===null||r===void 0)&&r.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,i=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(i=!0),n==-1?{from:n,to:r}=o:(n=Math.min(o.from,n),r=Math.max(o.to,r)))}return{from:n,to:r,typeOver:i}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),i=this.selectionChanged&&Pb(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Ece(this.view,e,n,r);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=cV(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!n.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),i}readMutation(e){let n=this.view.docView.nearest(e.target);if(!n||n.ignoreMutation(e))return null;if(n.markDirty(e.type=="attributes"),e.type=="attributes"&&(n.flags|=4),e.type=="childList"){let r=RN(n,e.previousSibling||e.target.previousSibling,-1),i=RN(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:i?n.posBefore(i):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Wo)!=e.state.facet(Wo)&&(e.view.contentDOM.editContext=e.state.facet(Wo)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function RN(t,e,n){for(;e;){let r=Rt.get(e);if(r&&r.parent==t)return r;let i=e.parentNode;e=i!=t.dom?i:n>0?e.nextSibling:e.previousSibling}return null}function MN(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return kp(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function cue(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return MN(t,i)}let n=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?MN(t,n):null}class uue{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let i=e.state.selection.main,{anchor:s,head:o}=i,a=this.toEditorPos(r.updateRangeStart),c=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:a,drifted:!1});let h={from:a,to:c,insert:dt.of(r.text.split(`
`))};if(h.from==this.from&&s<this.from?h.from=s:h.to==this.to&&s>this.to&&(h.to=s),h.from==h.to&&!h.insert.length){let f=fe.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));f.main.eq(i)||e.dispatch({selection:f,userEvent:"select"});return}if((Se.mac||Se.android)&&h.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(h={from:a,to:c,insert:dt.of([r.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let f=this.to-this.from+(h.to-h.from+h.insert.length);lT(e,h,fe.single(this.toEditorPos(r.selectionStart,f),this.toEditorPos(r.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state))},this.handlers.characterboundsupdate=r=>{let i=[],s=null;for(let o=this.toEditorPos(r.rangeStart),a=this.toEditorPos(r.rangeEnd);o<a;o++){let c=e.coordsForChar(o);s=c&&new DOMRect(c.left,c.top,c.right-c.left,c.bottom-c.top)||s||new DOMRect,i.push(s)}n.updateCharacterBounds(r.rangeStart,i)},this.handlers.textformatupdate=r=>{let i=[];for(let s of r.getTextFormats()){let o=s.underlineStyle,a=s.underlineThickness;if(o!="None"&&a!="None"){let c=this.toEditorPos(s.rangeStart),h=this.toEditorPos(s.rangeEnd);if(c<h){let f=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${a=="Thin"?1:2}px`;i.push(He.mark({attributes:{style:f}}).range(c,h))}}}e.dispatch({effects:tV.of(He.set(i))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{this.editContext.updateControlBounds(r.contentDOM.getBoundingClientRect());let i=om(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,i=this.pendingContextChange;return e.changes.iterChanges((s,o,a,c,h)=>{if(r)return;let f=h.length-(o-s);if(i&&o>=i.to)if(i.from==s&&i.to==o&&i.insert.eq(h)){i=this.pendingContextChange=null,n+=f,this.to+=f;return}else i=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=f,this.to+=f;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),h.toString()),this.to+=f}n+=f}),i&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to<e.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class _e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(i=>i.forEach(s=>r(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Hle(e.parent)||document,this.viewState=new kN(e.state||ht.create(e)),e.scrollTo&&e.scrollTo.is(Ey)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(nh).map(i=>new R_(i));for(let i of this.plugins)i.update(this);this.observer=new lue(this),this.inputState=new Oce(this),this.inputState.ensureHandlers(this.plugins),this.docView=new lN(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let n=e.length==1&&e[0]instanceof kn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,s=this.state;for(let m of e){if(m.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=m.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,a=0,c=null;e.some(m=>m.annotation(mV))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=gV(s,o),c||(a=1));let h=this.observer.delayedAndroidKey,f=null;if(h?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(f=null)):this.observer.clear(),s.facet(ht.phrases)!=this.state.facet(ht.phrases))return this.setState(s);i=Av.create(this,s,e),i.flags|=a;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let m of e){if(d&&(d=d.map(m.changes)),m.scrollIntoView){let{main:y}=m.state.selection;d=new xh(y.empty?y:fe.cursor(y.head,y.head>y.anchor?-1:1))}for(let y of m.effects)y.is(Ey)&&(d=y.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=kv.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(up)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(m=>m.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(Py)!=i.state.facet(Py)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let m of this.state.facet(dA))try{m(i)}catch(y){Kr(this.state,y,"update listener")}(c||f)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),f&&!cV(this,f)&&h.force&&wh(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new kN(e),this.plugins=e.facet(nh).map(r=>new R_(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new lN(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(nh),r=e.state.facet(nh);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new R_(s));else{let a=this.plugins[o];a.mustUpdate=e,i.push(a)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i<this.plugins.length;i++)this.plugins[i].update(this);n!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let n=e.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(r){Kr(this.state,r,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.scrollDOM,i=r.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(Rz(r))s=-1,o=this.viewState.heightMap.height;else{let y=this.viewState.scrollAnchorAt(i);s=y.from,o=y.top}this.updateState=1;let c=this.viewState.measure(this);if(!c&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];c&4||([this.measureRequests,h]=[h,this.measureRequests]);let f=h.map(y=>{try{return y.read(this)}catch(b){return Kr(this.state,b),ON}}),d=Av.create(this,this.state,[]),m=!1;d.flags|=c,n?n.flags|=c:n=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),m=this.docView.update(d),m&&this.docViewUpdate());for(let y=0;y<h.length;y++)if(f[y]!=ON)try{let b=h[y];b.write&&b.write(f[y],this)}catch(b){Kr(this.state,b)}if(m&&this.docView.updateSelection(!0),!d.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let b=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(b>1||b<-1){i=i+b,r.scrollTop=i/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let a of this.state.facet(dA))a(n)}get themeClasses(){return bA+" "+(this.state.facet(yA)?wV:vV)+" "+this.state.facet(Py)}updateAttrs(){let e=PN(this,nV,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Wo)?"true":"false",class:"cm-content",style:`${Se.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),PN(this,oT,n);let r=this.observer.ignore(()=>{let i=lA(this.contentDOM,this.contentAttrs,n),s=lA(this.dom,this.editorAttrs,e);return i||s});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let i of r.effects)if(i.is(_e.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(up);let e=this.state.facet(_e.cspNonce);pl.mount(this.root,this.styleModules.concat(oue).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===e.key){this.measureRequests[n]=e;return}}this.measureRequests.push(e)}}plugin(e){let n=this.pluginMap.get(e);return(n===void 0||n&&n.plugin!=e)&&this.pluginMap.set(e,n=this.plugins.find(r=>r.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,r){return O_(this,e,dN(this,e,n,r))}moveByGroup(e,n){return O_(this,e,dN(this,e,n,r=>Sce(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=r[n?r.length-1:0];return fe.cursor(s.side(n,i)+e.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(e,n,r=!0){return xce(this,e,n,r)}moveVertically(e,n,r){return O_(this,e,_ce(this,e,n,r))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){return this.readMeasured(),aV(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.docView.coordsAt(e,n);if(!r||r.left==r.right)return r;let i=this.state.doc.lineAt(e),s=this.bidiSpans(i),o=s[il.find(s,e-i.from,-1,n)];return nx(r,o.dir==jt.LTR==n>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Qz)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>hue)return Hz(e.length);let n=this.textDirectionAt(e.from),r;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||Uz(s.isolates,r=aN(this,e))))return s.order;r||(r=aN(this,e));let i=sce(e.text,n,r);return this.bidiCache.push(new kv(e.from,e.to,n,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Se.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{kz(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){return Ey.of(new xh(typeof e=="number"?fe.cursor(e):e,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return Ey.of(new xh(fe.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return yn.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return yn.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=pl.newName(),i=[Py.of(r),up.of(vA(`.${r}`,e))];return n&&n.dark&&i.push(yA.of(!0)),i}static baseTheme(e){return $c.lowest(up.of(vA("."+bA,e,xV)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),i=r&&Rt.get(r)||Rt.get(e);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}_e.styleModule=up;_e.inputHandler=Xz;_e.clipboardInputFilter=iT;_e.clipboardOutputFilter=sT;_e.scrollHandler=eV;_e.focusChangeEffect=Jz;_e.perLineTextDirection=Qz;_e.exceptionSink=Yz;_e.updateListener=dA;_e.editable=Wo;_e.mouseSelectionStyle=Kz;_e.dragMovesSelection=Gz;_e.clickAddsSelectionRange=qz;_e.decorations=lm;_e.outerDecorations=rV;_e.atomicRanges=ix;_e.bidiIsolatedRanges=iV;_e.scrollMargins=sV;_e.darkTheme=yA;_e.cspNonce=Ce.define({combine:t=>t.length?t[0]:""});_e.contentAttributes=oT;_e.editorAttributes=nV;_e.lineWrapping=_e.contentAttributes.of({class:"cm-lineWrapping"});_e.announce=Ze.define();const hue=4096,ON={};class kv{constructor(e,n,r,i,s,o){this.from=e,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let r=[],i=e.length?e[e.length-1].dir:jt.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new kv(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function PN(t,e,n){for(let r=t.state.facet(e),i=r.length-1;i>=0;i--){let s=r[i],o=typeof s=="function"?s(t):s;o&&aA(o,n)}return n}const fue=Se.mac?"mac":Se.windows?"win":Se.linux?"linux":"key";function due(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,o,a;for(let c=0;c<n.length-1;++c){const h=n[c];if(/^(cmd|meta|m)$/i.test(h))a=!0;else if(/^a(lt)?$/i.test(h))i=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return i&&(r="Alt-"+r),s&&(r="Ctrl-"+r),a&&(r="Meta-"+r),o&&(r="Shift-"+r),r}function Dy(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n!==!1&&e.shiftKey&&(t="Shift-"+t),t}const pue=$c.default(_e.domEventHandlers({keydown(t,e){return _V(SV(e.state),t,e,"editor")}})),hT=Ce.define({enables:pue}),DN=new WeakMap;function SV(t){let e=t.facet(hT),n=DN.get(e);return n||DN.set(e,n=yue(e.reduce((r,i)=>r.concat(i),[]))),n}function mue(t,e,n){return _V(SV(t.state),e,t,n)}let el=null;const gue=4e3;function yue(t,e=fue){let n=Object.create(null),r=Object.create(null),i=(o,a)=>{let c=r[o];if(c==null)r[o]=a;else if(c!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,a,c,h,f)=>{var d,m;let y=n[o]||(n[o]=Object.create(null)),b=a.split(/ (?!$)/).map(_=>due(_,e));for(let _=1;_<b.length;_++){let A=b.slice(0,_).join(" ");i(A,!0),y[A]||(y[A]={preventDefault:!0,stopPropagation:!1,run:[E=>{let P=el={view:E,prefix:A,scope:o};return setTimeout(()=>{el==P&&(el=null)},gue),!0}]})}let w=b.join(" ");i(w,!1);let S=y[w]||(y[w]={preventDefault:!1,stopPropagation:!1,run:((m=(d=y._any)===null||d===void 0?void 0:d.run)===null||m===void 0?void 0:m.slice())||[]});c&&S.run.push(c),h&&(S.preventDefault=!0),f&&(S.stopPropagation=!0)};for(let o of t){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of a){let f=n[h]||(n[h]=Object.create(null));f._any||(f._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:d}=o;for(let m in f)f[m].run.push(y=>d(y,wA))}let c=o[e]||o.key;if(c)for(let h of a)s(h,c,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+c,o.shift,o.preventDefault,o.stopPropagation)}return n}let wA=null;function _V(t,e,n,r){wA=e;let i=Ble(e),s=Wr(i,0),o=to(s)==i.length&&i!=" ",a="",c=!1,h=!1,f=!1;el&&el.view==n&&el.scope==r&&(a=el.prefix+" ",hV.indexOf(e.keyCode)<0&&(h=!0,el=null));let d=new Set,m=S=>{if(S){for(let _ of S.run)if(!d.has(_)&&(d.add(_),_(n)))return S.stopPropagation&&(f=!0),!0;S.preventDefault&&(S.stopPropagation&&(f=!0),h=!0)}return!1},y=t[r],b,w;return y&&(m(y[a+Dy(i,e,!o)])?c=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Se.windows&&e.ctrlKey&&e.altKey)&&!(Se.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(b=ml[e.keyCode])&&b!=i?(m(y[a+Dy(b,e,!0)])||e.shiftKey&&(w=sm[e.keyCode])!=i&&w!=b&&m(y[a+Dy(w,e,!1)]))&&(c=!0):o&&e.shiftKey&&m(y[a+Dy(i,e,!0)])&&(c=!0),!c&&m(y._any)&&(c=!0)),h&&(c=!0),c&&f&&e.stopPropagation(),wA=null,c}class Xm{constructor(e,n,r,i,s){this.className=e,this.left=n,this.top=r,this.width=i,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let i=e.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let s=CV(e);return[new Xm(n,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}else return bue(e,n,r)}}function CV(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==jt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function IN(t,e,n,r){let i=t.coordsAtPos(e,n*2);if(!i)return r;let s=t.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,a=t.posAtCoords({x:s.left+1,y:o}),c=t.posAtCoords({x:s.right-1,y:o});return a==null||c==null?r:{from:Math.max(r.from,Math.min(a,c)),to:Math.min(r.to,Math.max(a,c))}}function bue(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),i=Math.min(n.to,t.viewport.to),s=t.textDirection==jt.LTR,o=t.contentDOM,a=o.getBoundingClientRect(),c=CV(t),h=o.querySelector(".cm-line"),f=h&&window.getComputedStyle(h),d=a.left+(f?parseInt(f.paddingLeft)+Math.min(0,parseInt(f.textIndent)):0),m=a.right-(f?parseInt(f.paddingRight):0),y=mA(t,r,1),b=mA(t,i,-1),w=y.type==Dr.Text?y:null,S=b.type==Dr.Text?b:null;if(w&&(t.lineWrapping||y.widgetLineBreaks)&&(w=IN(t,r,1,w)),S&&(t.lineWrapping||b.widgetLineBreaks)&&(S=IN(t,i,-1,S)),w&&S&&w.from==S.from&&w.to==S.to)return A(E(n.from,n.to,w));{let O=w?E(n.from,null,w):P(y,!1),M=S?E(null,n.to,S):P(b,!0),D=[];return(w||y).to<(S||b).from-(w&&S?1:0)||y.widgetLineBreaks>1&&O.bottom+t.defaultLineHeight/2<M.top?D.push(_(d,O.bottom,m,M.top)):O.bottom<M.top&&t.elementAtHeight((O.bottom+M.top)/2).type==Dr.Text&&(O.bottom=M.top=(O.bottom+M.top)/2),A(O).concat(D).concat(A(M))}function _(O,M,D,$){return new Xm(e,O-c.left,M-c.top,D-O,$-M)}function A({top:O,bottom:M,horizontal:D}){let $=[];for(let F=0;F<D.length;F+=2)$.push(_(D[F],O,D[F+1],M));return $}function E(O,M,D){let $=1e9,F=-1e9,N=[];function U(X,ee,V,G,H){let se=t.coordsAtPos(X,X==D.to?-2:2),T=t.coordsAtPos(V,V==D.from?2:-2);!se||!T||($=Math.min(se.top,T.top,$),F=Math.max(se.bottom,T.bottom,F),H==jt.LTR?N.push(s&&ee?d:se.left,s&&G?m:T.right):N.push(!s&&G?d:T.left,!s&&ee?m:se.right))}let q=O??D.from,K=M??D.to;for(let X of t.visibleRanges)if(X.to>q&&X.from<K)for(let ee=Math.max(X.from,q),V=Math.min(X.to,K);;){let G=t.state.doc.lineAt(ee);for(let H of t.bidiSpans(G)){let se=H.from+G.from,T=H.to+G.from;if(se>=V)break;T>ee&&U(Math.max(se,ee),O==null&&se<=q,Math.min(T,V),M==null&&T>=K,H.dir)}if(ee=G.to+1,ee>=V)break}return N.length==0&&U(q,O==null,K,M==null,t.textDirection),{top:$,bottom:F,horizontal:N}}function P(O,M){let D=a.top+(M?O.top:O.bottom);return{top:D,bottom:D,horizontal:[]}}}function vue(t,e){return t.constructor==e.constructor&&t.eq(e)}class wue{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Nb)!=e.state.facet(Nb)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Nb);for(;n<r.length&&r[n]!=this.layer;)n++;this.dom.style.zIndex=String((this.layer.above?150:-1)-n)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:n}=this.view;(e!=this.scaleX||n!=this.scaleY)&&(this.scaleX=e,this.scaleY=n,this.dom.style.transform=`scale(${1/e}, ${1/n})`)}draw(e){if(e.length!=this.drawn.length||e.some((n,r)=>!vue(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let i of e)i.update&&n&&i.constructor&&this.drawn[r].constructor&&i.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(i.draw(),n);for(;n;){let i=n.nextSibling;n.remove(),n=i}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Nb=Ce.define();function AV(t){return[yn.define(e=>new wue(e,t)),Nb.of(t)]}const cm=Ce.define({combine(t){return wo(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function xue(t={}){return[cm.of(t),Sue,_ue,Cue,Zz.of(!0)]}function EV(t){return t.startState.facet(cm)!=t.state.facet(cm)}const Sue=AV({above:!0,markers(t){let{state:e}=t,n=e.facet(cm),r=[];for(let i of e.selection.ranges){let s=i==e.selection.main;if(i.empty||n.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=i.empty?i:fe.cursor(i.head,i.head>i.anchor?-1:1);for(let c of Xm.forRange(t,o,a))r.push(c)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=EV(t);return n&&LN(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){LN(e.state,t)},class:"cm-cursorLayer"});function LN(t,e){e.style.animationDuration=t.facet(cm).cursorBlinkRate+"ms"}const _ue=AV({above:!1,markers(t){return t.state.selection.ranges.map(e=>e.empty?[]:Xm.forRange(t,"cm-selectionBackground",e)).reduce((e,n)=>e.concat(n))},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||EV(t)},class:"cm-selectionLayer"}),Cue=$c.highest(_e.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),kV=Ze.define({map(t,e){return t==null?null:e.mapPos(t)}}),dp=Zn.define({create(){return null},update(t,e){return t!=null&&(t=e.changes.mapPos(t)),e.effects.reduce((n,r)=>r.is(kV)?r.value:n,t)}}),Aue=yn.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let n=t.state.field(dp);n==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(dp)!=n||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:t}=this,e=t.state.field(dp),n=e!=null&&t.coordsAtPos(e);if(!n)return null;let r=t.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+t.scrollDOM.scrollLeft*t.scaleX,top:n.top-r.top+t.scrollDOM.scrollTop*t.scaleY,height:n.bottom-n.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:n}=this.view;t?(this.cursor.style.left=t.left/e+"px",this.cursor.style.top=t.top/n+"px",this.cursor.style.height=t.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(dp)!=t&&this.view.dispatch({effects:kV.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){(t.target==this.view.contentDOM||!this.view.contentDOM.contains(t.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Eue(){return[dp,Aue]}function NN(t,e,n,r,i){e.lastIndex=0;for(let s=t.iterRange(n,r),o=n,a;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;a=e.exec(s.value);)i(o+a.index,a)}function kue(t,e){let n=t.visibleRanges;if(n.length==1&&n[0].from==t.viewport.from&&n[0].to==t.viewport.to)return n;let r=[];for(let{from:i,to:s}of n)i=Math.max(t.state.doc.lineAt(i).from,i-e),s=Math.min(t.state.doc.lineAt(s).to,s+e),r.length&&r[r.length-1].to>=i?r[r.length-1].to=s:r.push({from:i,to:s});return r}class Tue{constructor(e){const{regexp:n,decoration:r,decorate:i,boundary:s,maxLength:o=1e3}=e;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,i)this.addMatch=(a,c,h,f)=>i(f,h,h+a[0].length,a,c);else if(typeof r=="function")this.addMatch=(a,c,h,f)=>{let d=r(a,c,h);d&&f(h,h+a[0].length,d)};else if(r)this.addMatch=(a,c,h,f)=>f(h,h+a[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let n=new Xo,r=n.add.bind(n);for(let{from:i,to:s}of kue(e,this.maxLength))NN(e.state.doc,this.regexp,i,s,(o,a)=>this.addMatch(a,e,o,r));return n.finish()}updateDeco(e,n){let r=1e9,i=-1;return e.docChanged&&e.changes.iterChanges((s,o,a,c)=>{c>=e.view.viewport.from&&a<=e.view.viewport.to&&(r=Math.min(a,r),i=Math.max(c,i))}),e.viewportMoved||i-r>1e3?this.createDeco(e.view):i>-1?this.updateRange(e.view,n.map(e.changes),r,i):n}updateRange(e,n,r,i){for(let s of e.visibleRanges){let o=Math.max(s.from,r),a=Math.min(s.to,i);if(a>=o){let c=e.state.doc.lineAt(o),h=c.to<a?e.state.doc.lineAt(a):c,f=Math.max(s.from,c.from),d=Math.min(s.to,h.to);if(this.boundary){for(;o>c.from;o--)if(this.boundary.test(c.text[o-1-c.from])){f=o;break}for(;a<h.to;a++)if(this.boundary.test(h.text[a-h.from])){d=a;break}}let m=[],y,b=(w,S,_)=>m.push(_.range(w,S));if(c==h)for(this.regexp.lastIndex=f-c.from;(y=this.regexp.exec(c.text))&&y.index<d-c.from;)this.addMatch(y,e,y.index+c.from,b);else NN(e.state.doc,this.regexp,f,d,(w,S)=>this.addMatch(S,e,w,b));n=n.update({filterFrom:f,filterTo:d,filter:(w,S)=>w<f||S>d,add:m})}}return n}}const xA=/x/.unicode!=null?"gu":"g",Rue=new RegExp(`[\0-\b
--Ÿ­؜\u2028\u2029\uFEFF-]`,xA),Mue={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let I_=null;function Oue(){var t;if(I_==null&&typeof document<"u"&&document.body){let e=document.body.style;I_=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return I_||!1}const $b=Ce.define({combine(t){let e=wo(t,{render:null,specialChars:Rue,addSpecialChars:null});return(e.replaceTabs=!Oue())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,xA)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,xA)),e}});function Pue(t={}){return[$b.of(t),Due()]}let $N=null;function Due(){return $N||($N=yn.fromClass(class{constructor(t){this.view=t,this.decorations=He.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet($b)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new Tue({regexp:t.specialChars,decoration:(e,n,r)=>{let{doc:i}=n.state,s=Wr(e[0],0);if(s==9){let o=i.lineAt(r),a=n.state.tabSize,c=Qh(o.text,a,r-o.from);return He.replace({widget:new $ue((a-c%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=He.replace({widget:new Nue(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet($b);t.startState.facet($b)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const Iue="•";function Lue(t){return t>=32?Iue:t==10?"␤":String.fromCharCode(9216+t)}class Nue extends _l{constructor(e,n){super(),this.options=e,this.code=n}eq(e){return e.code==this.code}toDOM(e){let n=Lue(this.code),r=e.state.phrase("Control character")+" "+(Mue[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,n);if(i)return i;let s=document.createElement("span");return s.textContent=n,s.title=r,s.setAttribute("aria-label",r),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class $ue extends _l{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function jue(){return Fue}const Bue=He.line({class:"cm-activeLine"}),Fue=yn.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let i=t.lineBlockAt(r.head);i.from>e&&(n.push(Bue.range(i.from)),e=i.from)}return He.set(n)}},{decorations:t=>t.decorations}),SA=2e3;function zue(t,e,n){let r=Math.min(e.line,n.line),i=Math.max(e.line,n.line),s=[];if(e.off>SA||n.off>SA||e.col<0||n.col<0){let o=Math.min(e.off,n.off),a=Math.max(e.off,n.off);for(let c=r;c<=i;c++){let h=t.doc.line(c);h.length<=a&&s.push(fe.range(h.from+o,h.to+a))}}else{let o=Math.min(e.col,n.col),a=Math.max(e.col,n.col);for(let c=r;c<=i;c++){let h=t.doc.line(c),f=eA(h.text,o,t.tabSize,!0);if(f<0)s.push(fe.cursor(h.to));else{let d=eA(h.text,a,t.tabSize);s.push(fe.range(h.from+f,h.from+d))}}}return s}function Vue(t,e){let n=t.coordsAtPos(t.viewport.from);return n?Math.round(Math.abs((n.left-e)/t.defaultCharacterWidth)):-1}function jN(t,e){let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1),r=t.state.doc.lineAt(n),i=n-r.from,s=i>SA?-1:i==r.length?Vue(t,e.clientX):Qh(r.text,t.state.tabSize,n-r.from);return{line:r.number,col:s,off:i}}function Uue(t,e){let n=jN(t,e),r=t.state.selection;return n?{update(i){if(i.docChanged){let s=i.changes.mapPos(i.startState.doc.line(n.line).from),o=i.state.doc.lineAt(s);n={line:o.number,col:n.col,off:Math.min(n.off,o.length)},r=r.map(i.changes)}},get(i,s,o){let a=jN(t,i);if(!a)return r;let c=zue(t.state,n,a);return c.length?o?fe.create(c.concat(r.ranges)):fe.create(c):r}}:null}function Hue(t){let e=(n=>n.altKey&&n.button==0);return _e.mouseSelectionStyle.of((n,r)=>e(r)?Uue(n,r):null)}const Wue={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},que={style:"cursor: crosshair"};function Gue(t={}){let[e,n]=Wue[t.key||"Alt"],r=yn.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==e||n(i))},keyup(i){(i.keyCode==e||!n(i))&&this.set(!1)},mousemove(i){this.set(n(i))}}});return[r,_e.contentAttributes.of(i=>{var s;return!((s=i.plugin(r))===null||s===void 0)&&s.isDown?que:null})]}const Pd="-10000px";class TV{constructor(e,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=r(o,s))}update(e,n){var r;let i=e.state.facet(this.facet),s=i.filter(c=>c);if(i===this.input){for(let c of this.tooltipViews)c.update&&c.update(e);return!1}let o=[],a=n?[]:null;for(let c=0;c<s.length;c++){let h=s[c],f=-1;if(h){for(let d=0;d<this.tooltips.length;d++){let m=this.tooltips[d];m&&m.create==h.create&&(f=d)}if(f<0)o[c]=this.createTooltipView(h,c?o[c-1]:null),a&&(a[c]=!!h.above);else{let d=o[c]=this.tooltipViews[f];a&&(a[c]=n[f]),d.update&&d.update(e)}}}for(let c of this.tooltipViews)o.indexOf(c)<0&&(this.removeTooltipView(c),(r=c.destroy)===null||r===void 0||r.call(c));return n&&(a.forEach((c,h)=>n[h]=c),n.length=a.length),this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function Kue(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const L_=Ce.define({combine:t=>{var e,n,r;return{position:Se.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=t.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||Kue}}}),BN=new WeakMap,fT=yn.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(L_);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new TV(t,dT,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,r=t.state.facet(L_);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),r=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=Pd,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(t=r.destroy)===null||t===void 0||t.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Se.gecko)n=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==Pd&&s.style.left=="0px"){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=aT(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let a=this.manager.tooltipViews[o];return a.getCoords?a.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(L_).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=t,o=[];for(let a=0;a<this.manager.tooltips.length;a++){let c=this.manager.tooltips[a],h=this.manager.tooltipViews[a],{dom:f}=h,d=t.pos[a],m=t.size[a];if(!d||c.clip!==!1&&(d.bottom<=Math.max(n.top,r.top)||d.top>=Math.min(n.bottom,r.bottom)||d.right<Math.max(n.left,r.left)-.1||d.left>Math.min(n.right,r.right)+.1)){f.style.top=Pd;continue}let y=c.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,b=y?7:0,w=m.right-m.left,S=(e=BN.get(h))!==null&&e!==void 0?e:m.bottom-m.top,_=h.offset||Xue,A=this.view.textDirection==jt.LTR,E=m.width>r.right-r.left?A?r.left:r.right-m.width:A?Math.max(r.left,Math.min(d.left-(y?14:0)+_.x,r.right-w)):Math.min(Math.max(r.left,d.left-w+(y?14:0)-_.x),r.right-w),P=this.above[a];!c.strictSide&&(P?d.top-S-b-_.y<r.top:d.bottom+S+b+_.y>r.bottom)&&P==r.bottom-d.bottom>d.top-r.top&&(P=this.above[a]=!P);let O=(P?d.top-r.top:r.bottom-d.bottom)-b;if(O<S&&h.resize!==!1){if(O<this.view.defaultLineHeight){f.style.top=Pd;continue}BN.set(h,S),f.style.height=(S=O)/s+"px"}else f.style.height&&(f.style.height="");let M=P?d.top-S-b-_.y:d.bottom+b+_.y,D=E+w;if(h.overlap!==!0)for(let $ of o)$.left<D&&$.right>E&&$.top<M+S&&$.bottom>M&&(M=P?$.top-S-2-b:$.bottom+b+2);if(this.position=="absolute"?(f.style.top=(M-t.parent.top)/s+"px",FN(f,(E-t.parent.left)/i)):(f.style.top=M/s+"px",FN(f,E/i)),y){let $=d.left+(A?_.x:-_.x)-(E+14-7);y.style.left=$/i+"px"}h.overlap!==!0&&o.push({left:E,top:M,right:D,bottom:M+S}),f.classList.toggle("cm-tooltip-above",P),f.classList.toggle("cm-tooltip-below",!P),h.positioned&&h.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=Pd}},{eventObservers:{scroll(){this.maybeMeasure()}}});function FN(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const Yue=_e.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Xue={x:0,y:0},dT=Ce.define({enables:[fT,Yue]}),Tv=Ce.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class ox{static create(e){return new ox(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new TV(e,Tv,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(e,n){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Jue=dT.compute([Tv],t=>{let e=t.facet(Tv);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:ox.create,above:e[0].above,arrow:e.some(n=>n.arrow)}});class Que{constructor(e,n,r,i,s){this.view=e,this.source=n,this.field=r,this.setHover=i,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:n}=this,r=e.docView.nearest(n.target);if(!r)return;let i,s=1;if(r instanceof rl)i=r.posAtStart;else{if(i=e.posAtCoords(n),i==null)return;let a=e.coordsAtPos(i);if(!a||n.y<a.top||n.y>a.bottom||n.x<a.left-e.defaultCharacterWidth||n.x>a.right+e.defaultCharacterWidth)return;let c=e.bidiSpans(e.state.doc.lineAt(i)).find(f=>f.from<=i&&f.to>=i),h=c&&c.dir==jt.RTL?-1:1;s=n.x<a.left?-h:h}let o=this.source(e,i,s);if(o?.then){let a=this.pending={pos:i};o.then(c=>{this.pending==a&&(this.pending=null,c&&!(Array.isArray(c)&&!c.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(c)?c:[c])}))},c=>Kr(e.state,c,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(fT),n=e?e.manager.tooltips.findIndex(r=>r.create==ox.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&s&&!Zue(s.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,a=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!ehe(this.view,o,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=r=>{e.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Iy=4;function Zue(t,e){let{left:n,right:r,top:i,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let a=o.getBoundingClientRect();i=Math.min(a.top,i),s=Math.max(a.bottom,s)}return e.clientX>=n-Iy&&e.clientX<=r+Iy&&e.clientY>=i-Iy&&e.clientY<=s+Iy}function ehe(t,e,n,r,i,s){let o=t.scrollDOM.getBoundingClientRect(),a=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,a)<i)return!1;let c=t.posAtCoords({x:r,y:i},!1);return c>=e&&c<=n}function the(t,e={}){let n=Ze.define(),r=Zn.define({create(){return[]},update(i,s){if(i.length&&(e.hideOnChange&&(s.docChanged||s.selection)?i=[]:e.hideOn&&(i=i.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let a of i){let c=s.changes.mapPos(a.pos,-1,Mr.TrackDel);if(c!=null){let h=Object.assign(Object.create(null),a);h.pos=c,h.end!=null&&(h.end=s.changes.mapPos(h.end)),o.push(h)}}i=o}for(let o of s.effects)o.is(n)&&(i=o.value),o.is(nhe)&&(i=[]);return i},provide:i=>Tv.from(i)});return{active:r,extension:[r,yn.define(i=>new Que(i,t,r,n,e.hoverTime||300)),Jue]}}function RV(t,e){let n=t.plugin(fT);if(!n)return null;let r=n.manager.tooltips.indexOf(e);return r<0?null:n.manager.tooltipViews[r]}const nhe=Ze.define(),zN=Ce.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}});function um(t,e){let n=t.plugin(MV),r=n?n.specs.indexOf(e):-1;return r>-1?n.panels[r]:null}const MV=yn.fromClass(class{constructor(t){this.input=t.state.facet(hm),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(zN);this.top=new Ly(t,!0,e.topContainer),this.bottom=new Ly(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(zN);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Ly(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ly(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(hm);if(n!=this.input){let r=n.filter(c=>c),i=[],s=[],o=[],a=[];for(let c of r){let h=this.specs.indexOf(c),f;h<0?(f=c(t.view),a.push(f)):(f=this.panels[h],f.update&&f.update(t)),i.push(f),(f.top?s:o).push(f)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(o);for(let c of a)c.dom.classList.add("cm-panel"),c.mount&&c.mount()}else for(let r of this.panels)r.update&&r.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>_e.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Ly{constructor(e,n,r){this.view=e,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=VN(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=VN(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function VN(t){let e=t.nextSibling;return t.remove(),e}const hm=Ce.define({enables:MV});class Qo extends Ec{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Qo.prototype.elementClass="";Qo.prototype.toDOM=void 0;Qo.prototype.mapMode=Mr.TrackBefore;Qo.prototype.startSide=Qo.prototype.endSide=-1;Qo.prototype.point=!0;const jb=Ce.define(),rhe=Ce.define(),ihe={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ft.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Rp=Ce.define();function she(t){return[OV(),Rp.of({...ihe,...t})]}const UN=Ce.define({combine:t=>t.some(e=>e)});function OV(t){return[ohe]}const ohe=yn.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Rp).map(e=>new WN(t,e)),this.fixed=!t.state.facet(UN);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(UN)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=ft.iter(this.view.state.facet(jb),this.view.viewport.from),r=[],i=this.gutters.map(s=>new ahe(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(s.type)){let o=!0;for(let a of s.type)if(a.type==Dr.Text&&o){_A(n,r,a.from);for(let c of i)c.line(this.view,a,r);o=!1}else if(a.widget)for(let c of i)c.widget(this.view,a)}else if(s.type==Dr.Text){_A(n,r,s.from);for(let o of i)o.line(this.view,s,r)}else if(s.widget)for(let o of i)o.widget(this.view,s);for(let s of i)s.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Rp),n=t.state.facet(Rp),r=t.docChanged||t.heightChanged||t.viewportChanged||!ft.eq(t.startState.facet(jb),t.state.facet(jb),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let i of this.gutters)i.update(t)&&(r=!0);else{r=!0;let i=[];for(let s of n){let o=e.indexOf(s);o<0?i.push(new WN(this.view,s)):(this.gutters[o].update(t),i.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),i.indexOf(s)<0&&s.destroy();for(let s of i)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=i}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>_e.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,i=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==jt.LTR?{left:r,right:i}:{right:r,left:i}})});function HN(t){return Array.isArray(t)?t:[t]}function _A(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class ahe{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=ft.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:i}=this,s=(n.top-this.height)/e.scaleY,o=n.height/e.scaleY;if(this.i==i.elements.length){let a=new PV(e,o,s,r);i.elements.push(a),i.dom.appendChild(a.dom)}else i.elements[this.i].update(e,o,s,r);this.height=n.bottom,this.i++}line(e,n,r){let i=[];_A(this.cursor,i,n.from),r.length&&(i=i.concat(r));let s=this.gutter.config.lineMarker(e,n,i);s&&i.unshift(s);let o=this.gutter;i.length==0&&!o.config.renderEmptyElements||this.addElement(e,n,i)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),i=r?[r]:null;for(let s of e.state.facet(rhe)){let o=s(e,n.widget,n);o&&(i||(i=[])).push(o)}i&&this.addElement(e,n,i)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class WN{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,i=>{let s=i.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let c=s.getBoundingClientRect();o=(c.top+c.bottom)/2}else o=i.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);n.domEventHandlers[r](e,a,i)&&i.preventDefault()});this.markers=HN(n.markers(e)),n.initialSpacer&&(this.spacer=new PV(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=HN(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],e);i!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[i])}let r=e.view.viewport;return!ft.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class PV{constructor(e,n,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,i)}update(e,n,r,i){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),lhe(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,n){let r="cm-gutterElement",i=this.dom.firstChild;for(let s=0,o=0;;){let a=o,c=s<n.length?n[s++]:null,h=!1;if(c){let f=c.elementClass;f&&(r+=" "+f);for(let d=o;d<this.markers.length;d++)if(this.markers[d].compare(c)){a=d,h=!0;break}}else a=this.markers.length;for(;o<a;){let f=this.markers[o++];if(f.toDOM){f.destroy(i);let d=i.nextSibling;i.remove(),i=d}}if(!c)break;c.toDOM&&(h?i=i.nextSibling:this.dom.insertBefore(c.toDOM(e),i)),h&&o++}this.dom.className=r,this.markers=n}destroy(){this.setMarkers(null,[])}}function lhe(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].compare(e[n]))return!1;return!0}const che=Ce.define(),uhe=Ce.define(),rh=Ce.define({combine(t){return wo(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,n){let r=Object.assign({},e);for(let i in n){let s=r[i],o=n[i];r[i]=s?(a,c,h)=>s(a,c,h)||o(a,c,h):o}return r}})}});class N_ extends Qo{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function $_(t,e){return t.state.facet(rh).formatNumber(e,t.state)}const hhe=Rp.compute([rh],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(che)},lineMarker(e,n,r){return r.some(i=>i.toDOM)?null:new N_($_(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let i of e.state.facet(uhe)){let s=i(e,n,r);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(rh)!=e.state.facet(rh),initialSpacer(e){return new N_($_(e,qN(e.state.doc.lines)))},updateSpacer(e,n){let r=$_(n.view,qN(n.view.state.doc.lines));return r==e.number?e:new N_(r)},domEventHandlers:t.facet(rh).domEventHandlers,side:"before"}));function fhe(t={}){return[rh.of(t),OV(),hhe]}function qN(t){let e=9;for(;e<t;)e=e*10+9;return e}const dhe=new class extends Qo{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},phe=jb.compute(["selection"],t=>{let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.head).from;i>n&&(n=i,e.push(dhe.range(i)))}return ft.of(e)});function mhe(){return phe}const DV=1024;let ghe=0;class j_{constructor(e,n){this.from=e,this.to=n}}class it{constructor(e={}){this.id=ghe++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Zr.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}it.closedBy=new it({deserialize:t=>t.split(" ")});it.openedBy=new it({deserialize:t=>t.split(" ")});it.group=new it({deserialize:t=>t.split(" ")});it.isolate=new it({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});it.contextHash=new it({perNode:!0});it.lookAhead=new it({perNode:!0});it.mounted=new it({perNode:!0});class Rv{constructor(e,n,r){this.tree=e,this.overlay=n,this.parser=r}static get(e){return e&&e.props&&e.props[it.mounted.id]}}const yhe=Object.create(null);class Zr{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):yhe,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Zr(e.name||"",n,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(it.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(it.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}Zr.none=new Zr("",Object.create(null),0,8);class pT{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let r of this.types){let i=null;for(let s of e){let o=s(r);o&&(i||(i=Object.assign({},r.props)),i[o[0].id]=o[1])}n.push(i?new Zr(r.name,i,r.id,r.flags):r)}return new pT(n)}}const Ny=new WeakMap,GN=new WeakMap;var $n;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"})($n||($n={}));class mn{constructor(e,n,r,i,s){if(this.type=e,this.children=n,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,a]of s)this.props[typeof o=="number"?o:o.id]=a}}toString(){let e=Rv.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new AA(this.topNode,e)}cursorAt(e,n=0,r=0){let i=Ny.get(this)||this.topNode,s=new AA(i);return s.moveTo(e,n),Ny.set(this,s._tree),s}get topNode(){return new Zi(this,0,0,null)}resolve(e,n=0){let r=fm(Ny.get(this)||this.topNode,e,n,!1);return Ny.set(this,r),r}resolveInner(e,n=0){let r=fm(GN.get(this)||this.topNode,e,n,!0);return GN.set(this,r),r}resolveStack(e,n=0){return whe(this,e,n)}iterate(e){let{enter:n,leave:r,from:i=0,to:s=this.length}=e,o=e.mode||0,a=(o&$n.IncludeAnonymous)>0;for(let c=this.cursor(o|$n.IncludeAnonymous);;){let h=!1;if(c.from<=s&&c.to>=i&&(!a&&c.type.isAnonymous||n(c)!==!1)){if(c.firstChild())continue;h=!0}for(;h&&r&&(a||!c.type.isAnonymous)&&r(c),!c.nextSibling();){if(!c.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:yT(Zr.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new mn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new mn(Zr.none,n,r,i)))}static build(e){return xhe(e)}}mn.empty=new mn(Zr.none,[],[],0);class mT{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new mT(this.buffer,this.index)}}class yl{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Zr.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],r=this.buffer[e+3],i=this.set.types[n],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),e+=4,r==e)return s;let o=[];for(;e<r;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,n,r,i,s){let{buffer:o}=this,a=-1;for(let c=e;c!=n&&!(IV(s,i,o[c+1],o[c+2])&&(a=c,r>0));c=o[c+3]);return a}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let a=e,c=0;a<n;){s[c++]=i[a++],s[c++]=i[a++]-r;let h=s[c++]=i[a++]-r;s[c++]=i[a++]-e,o=Math.max(o,h)}return new yl(s,o,this.set)}}function IV(t,e,n,r){switch(t){case-2:return n<e;case-1:return r>=e&&n<e;case 0:return n<e&&r>e;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function fm(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let o=!r&&t instanceof Zi&&t.index<0?null:t.parent;if(!o)return t;t=o}let s=r?0:$n.IgnoreOverlays;if(r)for(let o=t,a=o.parent;a;o=a,a=o.parent)o instanceof Zi&&o.index<0&&((i=a.enter(e,n,s))===null||i===void 0?void 0:i.from)!=o.from&&(t=a);for(;;){let o=t.enter(e,n,s);if(!o)return t;t=o}}class LV{cursor(e=0){return new AA(this,e)}getChild(e,n=null,r=null){let i=KN(this,e,n,r);return i.length?i[0]:null}getChildren(e,n=null,r=null){return KN(this,e,n,r)}resolve(e,n=0){return fm(this,e,n,!1)}resolveInner(e,n=0){return fm(this,e,n,!0)}matchContext(e){return CA(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),r=this;for(;n;){let i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(r=n,n=i.prevSibling):n=i}return r}get node(){return this}get next(){return this.parent}}class Zi extends LV{constructor(e,n,r,i){super(),this._tree=e,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,r,i,s=0){for(let o=this;;){for(let{children:a,positions:c}=o._tree,h=n>0?a.length:-1;e!=h;e+=n){let f=a[e],d=c[e]+o.from;if(IV(i,r,d,d+f.length)){if(f instanceof yl){if(s&$n.ExcludeBuffers)continue;let m=f.findChild(0,f.buffer.length,n,r-d,i);if(m>-1)return new sl(new bhe(o,f,e,d),null,m)}else if(s&$n.IncludeAnonymous||!f.type.isAnonymous||gT(f)){let m;if(!(s&$n.IgnoreMounts)&&(m=Rv.get(f))&&!m.overlay)return new Zi(m.tree,d,e,o);let y=new Zi(f,d,e,o);return s&$n.IncludeAnonymous||!y.type.isAnonymous?y:y.nextChild(n<0?f.children.length-1:0,n,r,i)}}}if(s&$n.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,n,r=0){let i;if(!(r&$n.IgnoreOverlays)&&(i=Rv.get(this._tree))&&i.overlay){let s=e-this.from;for(let{from:o,to:a}of i.overlay)if((n>0?o<=s:o<s)&&(n<0?a>=s:a>s))return new Zi(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function KN(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function CA(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class bhe{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class sl extends LV{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new sl(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,n,r=0){if(r&$n.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new sl(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new sl(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new sl(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),n.push(0)}return new mn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function NV(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;s<t.length;s++){let o=t[s];(o.from>n.from||o.to<n.to)&&(n=o,e=s)}let r=n instanceof Zi&&n.index<0?null:n.parent,i=t.slice();return r?i[e]=r:i.splice(e,1),new vhe(i,n)}class vhe{constructor(e,n){this.heads=e,this.node=n}get next(){return NV(this.heads)}}function whe(t,e,n){let r=t.resolveInner(e,n),i=null;for(let s=r instanceof Zi?r:r.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(i||(i=[r])).push(o.resolve(e,n)),s=o}else{let o=Rv.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new Zi(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(fm(a,e,n,!1))}}return i?NV(i):r}class AA{get name(){return this.type.name}constructor(e,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Zi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof Zi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&$n.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&$n.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&$n.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:r}=i)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let a=r._tree.children[s];if(this.mode&$n.IncludeAnonymous||a instanceof yl||!a.type.isAnonymous||gT(a))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,r=0;if(e&&e.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i<this.stack.length;i++)n=new sl(this.buffer,n,this.stack[i]);return this.bufferNode=new sl(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let r=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&n&&n(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(e){if(!this.buffer)return CA(this.node.parent,e);let{buffer:n}=this.buffer,{types:r}=n.set;for(let i=e.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return CA(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function gT(t){return t.children.some(e=>e instanceof yl||!e.type.isAnonymous||gT(e))}function xhe(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=DV,reused:s=[],minRepeatType:o=r.types.length}=t,a=Array.isArray(n)?new mT(n,n.length):n,c=r.types,h=0,f=0;function d(O,M,D,$,F,N){let{id:U,start:q,end:K,size:X}=a,ee=f,V=h;for(;X<0;)if(a.next(),X==-1){let Z=s[U];D.push(Z),$.push(q-O);return}else if(X==-3){h=U;return}else if(X==-4){f=U;return}else throw new RangeError(`Unrecognized record size: ${X}`);let G=c[U],H,se,T=q-O;if(K-q<=i&&(se=S(a.pos-M,F))){let Z=new Uint16Array(se.size-se.skip),ue=a.pos-se.size,L=Z.length;for(;a.pos>ue;)L=_(se.start,Z,L);H=new yl(Z,K-se.start,r),T=se.start-O}else{let Z=a.pos-X;a.next();let ue=[],L=[],pe=U>=o?U:-1,ke=0,be=K;for(;a.pos>Z;)pe>=0&&a.id==pe&&a.size>=0?(a.end<=be-i&&(b(ue,L,q,ke,a.end,be,pe,ee,V),ke=ue.length,be=a.end),a.next()):N>2500?m(q,Z,ue,L):d(q,Z,ue,L,pe,N+1);if(pe>=0&&ke>0&&ke<ue.length&&b(ue,L,q,ke,q,be,pe,ee,V),ue.reverse(),L.reverse(),pe>-1&&ke>0){let Ee=y(G,V);H=yT(G,ue,L,0,ue.length,0,K-q,Ee,Ee)}else H=w(G,ue,L,K-q,ee-K,V)}D.push(H),$.push(T)}function m(O,M,D,$){let F=[],N=0,U=-1;for(;a.pos>M;){let{id:q,start:K,end:X,size:ee}=a;if(ee>4)a.next();else{if(U>-1&&K<U)break;U<0&&(U=X-i),F.push(q,K,X),N++,a.next()}}if(N){let q=new Uint16Array(N*4),K=F[F.length-2];for(let X=F.length-3,ee=0;X>=0;X-=3)q[ee++]=F[X],q[ee++]=F[X+1]-K,q[ee++]=F[X+2]-K,q[ee++]=ee;D.push(new yl(q,F[2]-K,r)),$.push(K-O)}}function y(O,M){return(D,$,F)=>{let N=0,U=D.length-1,q,K;if(U>=0&&(q=D[U])instanceof mn){if(!U&&q.type==O&&q.length==F)return q;(K=q.prop(it.lookAhead))&&(N=$[U]+q.length+K)}return w(O,D,$,F,N,M)}}function b(O,M,D,$,F,N,U,q,K){let X=[],ee=[];for(;O.length>$;)X.push(O.pop()),ee.push(M.pop()+D-F);O.push(w(r.types[U],X,ee,N-F,q-N,K)),M.push(F-D)}function w(O,M,D,$,F,N,U){if(N){let q=[it.contextHash,N];U=U?[q].concat(U):[q]}if(F>25){let q=[it.lookAhead,F];U=U?[q].concat(U):[q]}return new mn(O,M,D,$,U)}function S(O,M){let D=a.fork(),$=0,F=0,N=0,U=D.end-i,q={size:0,start:0,skip:0};e:for(let K=D.pos-O;D.pos>K;){let X=D.size;if(D.id==M&&X>=0){q.size=$,q.start=F,q.skip=N,N+=4,$+=4,D.next();continue}let ee=D.pos-X;if(X<0||ee<K||D.start<U)break;let V=D.id>=o?4:0,G=D.start;for(D.next();D.pos>ee;){if(D.size<0)if(D.size==-3)V+=4;else break e;else D.id>=o&&(V+=4);D.next()}F=G,$+=X,N+=V}return(M<0||$==O)&&(q.size=$,q.start=F,q.skip=N),q.size>4?q:void 0}function _(O,M,D){let{id:$,start:F,end:N,size:U}=a;if(a.next(),U>=0&&$<o){let q=D;if(U>4){let K=a.pos-(U-4);for(;a.pos>K;)D=_(O,M,D)}M[--D]=q,M[--D]=N-O,M[--D]=F-O,M[--D]=$}else U==-3?h=$:U==-4&&(f=$);return D}let A=[],E=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,A,E,-1,0);let P=(e=t.length)!==null&&e!==void 0?e:A.length?E[0]+A[0].length:0;return new mn(c[t.topID],A.reverse(),E.reverse(),P)}const YN=new WeakMap;function Bb(t,e){if(!t.isAnonymous||e instanceof yl||e.type!=t)return 1;let n=YN.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof mn)){n=1;break}n+=Bb(t,r)}YN.set(e,n)}return n}function yT(t,e,n,r,i,s,o,a,c){let h=0;for(let b=r;b<i;b++)h+=Bb(t,e[b]);let f=Math.ceil(h*1.5/8),d=[],m=[];function y(b,w,S,_,A){for(let E=S;E<_;){let P=E,O=w[E],M=Bb(t,b[E]);for(E++;E<_;E++){let D=Bb(t,b[E]);if(M+D>=f)break;M+=D}if(E==P+1){if(M>f){let D=b[P];y(D.children,D.positions,0,D.children.length,w[P]+A);continue}d.push(b[P])}else{let D=w[E-1]+b[E-1].length-O;d.push(yT(t,b,w,P,E,O,D,null,c))}m.push(O+A-s)}}return y(e,n,r,i,0),(a||c)(d,m,o)}class yc{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let i=[new yc(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let a=0,c=0,h=0;;a++){let f=a<n.length?n[a]:null,d=f?f.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let m=o;if(c>=m.from||d<=m.to||h){let y=Math.max(m.from,c)-h,b=Math.min(m.to,d)-h;m=y>=b?null:new yc(y,b,m.tree,m.offset+h,a>0,!!f)}if(m&&i.push(m),o.to>d)break;o=s<e.length?e[s++]:null}if(!f)break;c=f.toA,h=f.toA-f.toB}return i}}class $V{startParse(e,n,r){return typeof e=="string"&&(e=new She(e)),r=r?r.length?r.map(i=>new j_(i.from,i.to)):[new j_(0,0)]:[new j_(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class She{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new it({perNode:!0});let _he=0;class Wi{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=_he++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof Wi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let i=new Wi(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new Mv(e);return r=>r.modified.indexOf(n)>-1?r:Mv.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let Che=0;class Mv{constructor(e){this.name=e,this.instances=[],this.id=Che++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&Ahe(n,a.modified));if(r)return r;let i=[],s=new Wi(e.name,i,e,n);for(let a of n)a.instances.push(s);let o=Ehe(n);for(let a of e.set)if(!a.modified.length)for(let c of o)i.push(Mv.get(a,c));return s}}function Ahe(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function Ehe(t){let e=[[]];for(let n=0;n<t.length;n++)for(let r=0,i=e.length;r<i;r++)e.push(e[r].concat(t[n]));return e.sort((n,r)=>r.length-n.length)}function jV(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,a=i;for(let d=0;;){if(a=="..."&&d>0&&d+3==i.length){o=1;break}let m=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!m)throw new RangeError("Invalid path: "+i);if(s.push(m[0]=="*"?"":m[0][0]=='"'?JSON.parse(m[0]):m[0]),d+=m[0].length,d==i.length)break;let y=i[d++];if(d==i.length&&y=="!"){o=0;break}if(y!="/")throw new RangeError("Invalid path: "+i);a=i.slice(d)}let c=s.length-1,h=s[c];if(!h)throw new RangeError("Invalid path: "+i);let f=new Ov(r,o,c>0?s.slice(0,c):null);e[h]=f.sort(e[h])}}return BV.add(e)}const BV=new it;let Ov=class{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Ov.empty=new Ov([],2,null);function FV(t,e){let n=Object.create(null);for(let s of t)if(!Array.isArray(s.tag))n[s.tag.id]=s.class;else for(let o of s.tag)n[o.id]=s.class;let{scope:r,all:i=null}=e||{};return{style:s=>{let o=i;for(let a of s)for(let c of a.set){let h=n[c.id];if(h){o=o?o+" "+h:h;break}}return o},scope:r}}function khe(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function The(t,e,n,r=0,i=t.length){let s=new Rhe(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class Rhe{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:a,to:c}=e;if(a>=r||c<=n)return;o.isTop&&(s=this.highlighters.filter(y=>!y.scope||y.scope(o)));let h=i,f=Mhe(e)||Ov.empty,d=khe(s,f.tags);if(d&&(h&&(h+=" "),h+=d,f.mode==1&&(i+=(i?" ":"")+d)),this.startSpan(Math.max(n,a),h),f.opaque)return;let m=e.tree&&e.tree.prop(it.mounted);if(m&&m.overlay){let y=e.node.enter(m.overlay[0].from+a,1),b=this.highlighters.filter(S=>!S.scope||S.scope(m.tree.type)),w=e.firstChild();for(let S=0,_=a;;S++){let A=S<m.overlay.length?m.overlay[S]:null,E=A?A.from+a:c,P=Math.max(n,_),O=Math.min(r,E);if(P<O&&w)for(;e.from<O&&(this.highlightRange(e,P,O,i,s),this.startSpan(Math.min(O,e.to),h),!(e.to>=E||!e.nextSibling())););if(!A||E>r)break;_=A.to+a,_>n&&(this.highlightRange(y.cursor(),Math.max(n,A.from+a),Math.min(r,_),"",b),this.startSpan(Math.min(r,_),h))}w&&e.parent()}else if(e.firstChild()){m&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),h)}while(e.nextSibling());e.parent()}}}function Mhe(t){let e=t.type.prop(BV);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const xe=Wi.define,$y=xe(),Ja=xe(),XN=xe(Ja),JN=xe(Ja),Qa=xe(),jy=xe(Qa),B_=xe(Qa),Ks=xe(),Xl=xe(Ks),qs=xe(),Gs=xe(),EA=xe(),Dd=xe(EA),By=xe(),we={comment:$y,lineComment:xe($y),blockComment:xe($y),docComment:xe($y),name:Ja,variableName:xe(Ja),typeName:XN,tagName:xe(XN),propertyName:JN,attributeName:xe(JN),className:xe(Ja),labelName:xe(Ja),namespace:xe(Ja),macroName:xe(Ja),literal:Qa,string:jy,docString:xe(jy),character:xe(jy),attributeValue:xe(jy),number:B_,integer:xe(B_),float:xe(B_),bool:xe(Qa),regexp:xe(Qa),escape:xe(Qa),color:xe(Qa),url:xe(Qa),keyword:qs,self:xe(qs),null:xe(qs),atom:xe(qs),unit:xe(qs),modifier:xe(qs),operatorKeyword:xe(qs),controlKeyword:xe(qs),definitionKeyword:xe(qs),moduleKeyword:xe(qs),operator:Gs,derefOperator:xe(Gs),arithmeticOperator:xe(Gs),logicOperator:xe(Gs),bitwiseOperator:xe(Gs),compareOperator:xe(Gs),updateOperator:xe(Gs),definitionOperator:xe(Gs),typeOperator:xe(Gs),controlOperator:xe(Gs),punctuation:EA,separator:xe(EA),bracket:Dd,angleBracket:xe(Dd),squareBracket:xe(Dd),paren:xe(Dd),brace:xe(Dd),content:Ks,heading:Xl,heading1:xe(Xl),heading2:xe(Xl),heading3:xe(Xl),heading4:xe(Xl),heading5:xe(Xl),heading6:xe(Xl),contentSeparator:xe(Ks),list:xe(Ks),quote:xe(Ks),emphasis:xe(Ks),strong:xe(Ks),link:xe(Ks),monospace:xe(Ks),strikethrough:xe(Ks),inserted:xe(),deleted:xe(),changed:xe(),invalid:xe(),meta:By,documentMeta:xe(By),annotation:xe(By),processingInstruction:xe(By),definition:Wi.defineModifier("definition"),constant:Wi.defineModifier("constant"),function:Wi.defineModifier("function"),standard:Wi.defineModifier("standard"),local:Wi.defineModifier("local"),special:Wi.defineModifier("special")};for(let t in we){let e=we[t];e instanceof Wi&&(e.name=t)}FV([{tag:we.link,class:"tok-link"},{tag:we.heading,class:"tok-heading"},{tag:we.emphasis,class:"tok-emphasis"},{tag:we.strong,class:"tok-strong"},{tag:we.keyword,class:"tok-keyword"},{tag:we.atom,class:"tok-atom"},{tag:we.bool,class:"tok-bool"},{tag:we.url,class:"tok-url"},{tag:we.labelName,class:"tok-labelName"},{tag:we.inserted,class:"tok-inserted"},{tag:we.deleted,class:"tok-deleted"},{tag:we.literal,class:"tok-literal"},{tag:we.string,class:"tok-string"},{tag:we.number,class:"tok-number"},{tag:[we.regexp,we.escape,we.special(we.string)],class:"tok-string2"},{tag:we.variableName,class:"tok-variableName"},{tag:we.local(we.variableName),class:"tok-variableName tok-local"},{tag:we.definition(we.variableName),class:"tok-variableName tok-definition"},{tag:we.special(we.variableName),class:"tok-variableName2"},{tag:we.definition(we.propertyName),class:"tok-propertyName tok-definition"},{tag:we.typeName,class:"tok-typeName"},{tag:we.namespace,class:"tok-namespace"},{tag:we.className,class:"tok-className"},{tag:we.macroName,class:"tok-macroName"},{tag:we.propertyName,class:"tok-propertyName"},{tag:we.operator,class:"tok-operator"},{tag:we.comment,class:"tok-comment"},{tag:we.meta,class:"tok-meta"},{tag:we.invalid,class:"tok-invalid"},{tag:we.punctuation,class:"tok-punctuation"}]);var F_;const ih=new it;function Ohe(t){return Ce.define({combine:t?e=>e.concat(t):void 0})}const Phe=new it;class bs{constructor(e,n,r=[],i=""){this.data=e,this.name=i,ht.prototype.hasOwnProperty("tree")||Object.defineProperty(ht.prototype,"tree",{get(){return br(this)}}),this.parser=n,this.extension=[bl.of(this),ht.languageData.of((s,o,a)=>{let c=QN(s,o,a),h=c.type.prop(ih);if(!h)return[];let f=s.facet(h),d=c.type.prop(Phe);if(d){let m=c.resolve(o-c.from,a);for(let y of d)if(y.test(m,s)){let b=s.facet(y.facet);return y.type=="replace"?b:b.concat(f)}}return f})].concat(r)}isActiveAt(e,n,r=-1){return QN(e,n,r).type.prop(ih)==this.data}findRegions(e){let n=e.facet(bl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(ih)==this.data){r.push({from:o,to:o+s.length});return}let a=s.prop(it.mounted);if(a){if(a.tree.prop(ih)==this.data){if(a.overlay)for(let c of a.overlay)r.push({from:c.from+o,to:c.to+o});else r.push({from:o,to:o+s.length});return}else if(a.overlay){let c=r.length;if(i(a.tree,a.overlay[0].from+o),r.length>c)return}}for(let c=0;c<s.children.length;c++){let h=s.children[c];h instanceof mn&&i(h,s.positions[c]+o)}};return i(br(e),0),r}get allowsNesting(){return!0}}bs.setState=Ze.define();function QN(t,e,n){let r=t.facet(bl),i=br(t).topNode;if(!r||r.allowsNesting)for(let s=i;s;s=s.enter(e,n,$n.ExcludeBuffers))s.type.isTop&&(i=s);return i}class Pv extends bs{constructor(e,n,r){super(e,n,[],r),this.parser=n}static define(e){let n=Ohe(e.languageData);return new Pv(n,e.parser.configure({props:[ih.add(r=>r.isTop?n:void 0)]}),e.name)}configure(e,n){return new Pv(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function br(t){let e=t.field(bs.state,!1);return e?e.tree:mn.empty}class Dhe{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let r=this.cursorPos-this.string.length;return e<r||n>=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Id=null;class Dv{constructor(e,n,r=[],i,s,o,a,c){this.parser=e,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=c,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Dv(e,n,[],mn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Dhe(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=mn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(yc.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,n;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(yc.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Id;Id=this;try{return e()}finally{Id=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=ZN(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let c=[];if(e.iterChangedRanges((h,f,d,m)=>c.push({fromA:h,toA:f,fromB:d,toB:m})),r=yc.applyChanges(r,c),i=mn.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let h of this.skipped){let f=e.mapPos(h.from,1),d=e.mapPos(h.to,-1);f<d&&a.push({from:f,to:d})}}}return new Dv(this.parser,n,r,i,s,o,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let n=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:s}=this.skipped[r];i<e.to&&s>e.from&&(this.fragments=ZN(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends $V{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let c=Id;if(c){for(let h of i)c.tempSkipped.push(h);e&&(c.scheduleOn=c.scheduleOn?Promise.all([c.scheduleOn,e]):e)}return this.parsedPos=o,new mn(Zr.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Id}}function ZN(t,e,n){return yc.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class $h{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new $h(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Dv.create(e.facet(bl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new $h(r)}}bs.state=Zn.define({create:$h.init,update(t,e){for(let n of e.effects)if(n.is(bs.setState))return n.value;return e.startState.facet(bl)!=e.state.facet(bl)?$h.init(e.state):t.apply(e)}});let zV=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(zV=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const z_=typeof navigator<"u"&&(!((F_=navigator.scheduling)===null||F_===void 0)&&F_.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ihe=yn.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(bs.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(bs.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=zV(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,s=r.field(bs.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!z_?Math.max(25,e.timeRemaining()-5):1e9),a=s.context.treeLen<i&&r.doc.length>i+1e3,c=s.context.work(()=>z_&&z_()||Date.now()>o,i+(a?0:1e5));this.chunkBudget-=Date.now()-n,(c||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:bs.setState.of(new $h(s.context))})),this.chunkBudget>0&&!(c&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Kr(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),bl=Ce.define({combine(t){return t.length?t[0]:null},enables:t=>[bs.state,Ihe,_e.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class Lhe{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const Nhe=Ce.define(),bT=Ce.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Iv(t){let e=t.facet(bT);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function dm(t,e){let n="",r=t.tabSize,i=t.facet(bT)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s<e;s++)n+=i;return n}function vT(t,e){t instanceof ht&&(t=new ax(t));for(let r of t.state.facet(Nhe)){let i=r(t,e);if(i!==void 0)return i}let n=br(t.state);return n.length>=e?$he(t,n,e):null}class ax{constructor(e,n={}){this.state=e,this.options=n,this.unit=Iv(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==e?{text:"",from:e}:(n<0?i<e:i<=e)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(e,n=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(e,n);return r.slice(e-i,Math.min(r.length,e+100-i))}column(e,n=1){let{text:r,from:i}=this.lineAt(e,n),s=this.countColumn(r,e-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,n=e.length){return Qh(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:i}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const VV=new it;function $he(t,e,n){let r=e.resolveStack(n),i=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let o=i;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return UV(r,t,n)}function UV(t,e,n){for(let r=t;r;r=r.next){let i=Bhe(r.node);if(i)return i(wT.create(e,n,r))}return 0}function jhe(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function Bhe(t){let e=t.type.prop(VV);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(it.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>Uhe(o,!0,1,void 0,s&&!jhe(o)?i.from:void 0)}return t.parent==null?Fhe:null}function Fhe(){return 0}class wT extends ax{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new wT(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(zhe(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return UV(this.context.next,this.base,this.pos)}}function zhe(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function Vhe(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let a=n.to;;){let c=e.childAfter(a);if(!c||c==r)return null;if(!c.type.isSkipped){if(c.from>=o)return null;let h=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+h}}a=c.to}}function Uhe(t,e,n,r,i){let s=t.textAfter,o=s.match(/^\s*/)[0].length,a=r&&s.slice(o,o+r.length)==r||i==t.pos+o,c=Vhe(t);return c?a?t.column(c.from):t.column(c.to):t.baseIndent+(a?0:t.unit*n)}function e3({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const Hhe=200;function Whe(){return ht.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let n=t.newDoc,{head:r}=t.newSelection.main,i=n.lineAt(r);if(r>i.from+Hhe)return t;let s=n.sliceString(i.from,r);if(!e.some(h=>h.test(s)))return t;let{state:o}=t,a=-1,c=[];for(let{head:h}of o.selection.ranges){let f=o.doc.lineAt(h);if(f.from==a)continue;a=f.from;let d=vT(o,f.from);if(d==null)continue;let m=/^\s*/.exec(f.text)[0],y=dm(o,d);m!=y&&c.push({from:f.from,to:f.from+m.length,insert:y})}return c.length?[t,{changes:c,sequential:!0}]:t})}const qhe=Ce.define(),HV=new it;function Ghe(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}function Khe(t,e,n){let r=br(t);if(r.length<n)return null;let i=r.resolveStack(n,1),s=null;for(let o=i;o;o=o.next){let a=o.node;if(a.to<=n||a.from>n)continue;if(s&&a.from<e)break;let c=a.type.prop(HV);if(c&&(a.to<r.length-50||r.length==t.doc.length||!Yhe(a))){let h=c(a,t);h&&h.from<=n&&h.from>=e&&h.to>n&&(s=h)}}return s}function Yhe(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function Lv(t,e,n){for(let r of t.facet(qhe)){let i=r(t,e,n);if(i)return i}return Khe(t,e,n)}function WV(t,e){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);return n>=r?void 0:{from:n,to:r}}const lx=Ze.define({map:WV}),Jm=Ze.define({map:WV});function qV(t){let e=[];for(let{head:n}of t.state.selection.ranges)e.some(r=>r.from<=n&&r.to>=n)||e.push(t.lineBlockAt(n));return e}const Mc=Zn.define({create(){return He.none},update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((n,r)=>t=t3(t,n,r)),t=t.map(e.changes);for(let n of e.effects)if(n.is(lx)&&!Xhe(t,n.value.from,n.value.to)){let{preparePlaceholder:r}=e.state.facet(YV),i=r?He.replace({widget:new rfe(r(e.state,n.value))}):n3;t=t.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Jm)&&(t=t.update({filter:(r,i)=>n.value.from!=r||n.value.to!=i,filterFrom:n.value.from,filterTo:n.value.to}));return e.selection&&(t=t3(t,e.selection.main.head)),t},provide:t=>_e.decorations.from(t),toJSON(t,e){let n=[];return t.between(0,e.doc.length,(r,i)=>{n.push(r,i)}),n},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n<t.length;){let r=t[n++],i=t[n++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");e.push(n3.range(r,i))}return He.set(e,!0)}});function t3(t,e,n=e){let r=!1;return t.between(e,n,(i,s)=>{i<n&&s>e&&(r=!0)}),r?t.update({filterFrom:e,filterTo:n,filter:(i,s)=>i>=n||s<=e}):t}function Nv(t,e,n){var r;let i=null;return(r=t.field(Mc,!1))===null||r===void 0||r.between(e,n,(s,o)=>{(!i||i.from>s)&&(i={from:s,to:o})}),i}function Xhe(t,e,n){let r=!1;return t.between(e,e,(i,s)=>{i==e&&s==n&&(r=!0)}),r}function GV(t,e){return t.field(Mc,!1)?e:e.concat(Ze.appendConfig.of(XV()))}const Jhe=t=>{for(let e of qV(t)){let n=Lv(t.state,e.from,e.to);if(n)return t.dispatch({effects:GV(t.state,[lx.of(n),KV(t,n)])}),!0}return!1},Qhe=t=>{if(!t.state.field(Mc,!1))return!1;let e=[];for(let n of qV(t)){let r=Nv(t.state,n.from,n.to);r&&e.push(Jm.of(r),KV(t,r,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function KV(t,e,n=!0){let r=t.state.doc.lineAt(e.from).number,i=t.state.doc.lineAt(e.to).number;return _e.announce.of(`${t.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${t.state.phrase("to")} ${i}.`)}const Zhe=t=>{let{state:e}=t,n=[];for(let r=0;r<e.doc.length;){let i=t.lineBlockAt(r),s=Lv(e,i.from,i.to);s&&n.push(lx.of(s)),r=(s?t.lineBlockAt(s.to):i).to+1}return n.length&&t.dispatch({effects:GV(t.state,n)}),!!n.length},efe=t=>{let e=t.state.field(Mc,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,t.state.doc.length,(r,i)=>{n.push(Jm.of({from:r,to:i}))}),t.dispatch({effects:n}),!0},tfe=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Jhe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Qhe},{key:"Ctrl-Alt-[",run:Zhe},{key:"Ctrl-Alt-]",run:efe}],nfe={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},YV=Ce.define({combine(t){return wo(t,nfe)}});function XV(t){return[Mc,ofe]}function JV(t,e){let{state:n}=t,r=n.facet(YV),i=o=>{let a=t.lineBlockAt(t.posAtDOM(o.target)),c=Nv(t.state,a.from,a.to);c&&t.dispatch({effects:Jm.of(c)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(t,i,e);let s=document.createElement("span");return s.textContent=r.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const n3=He.replace({widget:new class extends _l{toDOM(t){return JV(t,null)}}});class rfe extends _l{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return JV(e,this.value)}}const ife={openText:"⌄",closedText:"",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class V_ extends Qo{constructor(e,n){super(),this.config=e,this.open=n}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=e.state.phrase(this.open?"Fold line":"Unfold line"),n}}function sfe(t={}){let e={...ife,...t},n=new V_(e,!0),r=new V_(e,!1),i=yn.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(bl)!=o.state.facet(bl)||o.startState.field(Mc,!1)!=o.state.field(Mc,!1)||br(o.startState)!=br(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new Xo;for(let c of o.viewportLineBlocks){let h=Nv(o.state,c.from,c.to)?r:Lv(o.state,c.from,c.to)?n:null;h&&a.add(c.from,c.from,h)}return a.finish()}}),{domEventHandlers:s}=e;return[i,she({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(i))===null||a===void 0?void 0:a.markers)||ft.empty},initialSpacer(){return new V_(e,!1)},domEventHandlers:{...s,click:(o,a,c)=>{if(s.click&&s.click(o,a,c))return!0;let h=Nv(o.state,a.from,a.to);if(h)return o.dispatch({effects:Jm.of(h)}),!0;let f=Lv(o.state,a.from,a.to);return f?(o.dispatch({effects:lx.of(f)}),!0):!1}}}),XV()]}const ofe=_e.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class cx{constructor(e,n){this.specs=e;let r;function i(a){let c=pl.newName();return(r||(r=Object.create(null)))["."+c]=a,c}const s=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,o=n.scope;this.scope=o instanceof bs?a=>a.prop(ih)==o.data:o?a=>a==o:void 0,this.style=FV(e.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=r?new pl(r):null,this.themeType=n.themeType}static define(e,n){return new cx(e,n||{})}}const kA=Ce.define(),QV=Ce.define({combine(t){return t.length?[t[0]]:null}});function U_(t){let e=t.facet(kA);return e.length?e:t.facet(QV)}function afe(t,e){let n=[cfe],r;return t instanceof cx&&(t.module&&n.push(_e.styleModule.of(t.module)),r=t.themeType),e?.fallback?n.push(QV.of(t)):r?n.push(kA.computeN([_e.darkTheme],i=>i.facet(_e.darkTheme)==(r=="dark")?[t]:[])):n.push(kA.of(t)),n}class lfe{constructor(e){this.markCache=Object.create(null),this.tree=br(e.state),this.decorations=this.buildDeco(e,U_(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=br(e.state),r=U_(e.state),i=r!=U_(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length<s.to&&!i&&n.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return He.none;let r=new Xo;for(let{from:i,to:s}of e.visibleRanges)The(this.tree,n,(o,a,c)=>{r.add(o,a,this.markCache[c]||(this.markCache[c]=He.mark({class:c})))},i,s);return r.finish()}}const cfe=$c.high(yn.fromClass(lfe,{decorations:t=>t.decorations})),ufe=cx.define([{tag:we.meta,color:"#404740"},{tag:we.link,textDecoration:"underline"},{tag:we.heading,textDecoration:"underline",fontWeight:"bold"},{tag:we.emphasis,fontStyle:"italic"},{tag:we.strong,fontWeight:"bold"},{tag:we.strikethrough,textDecoration:"line-through"},{tag:we.keyword,color:"#708"},{tag:[we.atom,we.bool,we.url,we.contentSeparator,we.labelName],color:"#219"},{tag:[we.literal,we.inserted],color:"#164"},{tag:[we.string,we.deleted],color:"#a11"},{tag:[we.regexp,we.escape,we.special(we.string)],color:"#e40"},{tag:we.definition(we.variableName),color:"#00f"},{tag:we.local(we.variableName),color:"#30a"},{tag:[we.typeName,we.namespace],color:"#085"},{tag:we.className,color:"#167"},{tag:[we.special(we.variableName),we.macroName],color:"#256"},{tag:we.definition(we.propertyName),color:"#00c"},{tag:we.comment,color:"#940"},{tag:we.invalid,color:"#f00"}]),hfe=_e.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),ZV=1e4,e7="()[]{}",t7=Ce.define({combine(t){return wo(t,{afterCursor:!0,brackets:e7,maxScanDistance:ZV,renderMatch:pfe})}}),ffe=He.mark({class:"cm-matchingBracket"}),dfe=He.mark({class:"cm-nonmatchingBracket"});function pfe(t){let e=[],n=t.matched?ffe:dfe;return e.push(n.range(t.start.from,t.start.to)),t.end&&e.push(n.range(t.end.from,t.end.to)),e}const mfe=Zn.define({create(){return He.none},update(t,e){if(!e.docChanged&&!e.selection)return t;let n=[],r=e.state.facet(t7);for(let i of e.state.selection.ranges){if(!i.empty)continue;let s=so(e.state,i.head,-1,r)||i.head>0&&so(e.state,i.head-1,1,r)||r.afterCursor&&(so(e.state,i.head,1,r)||i.head<e.state.doc.length&&so(e.state,i.head+1,-1,r));s&&(n=n.concat(r.renderMatch(s,e.state)))}return He.set(n,!0)},provide:t=>_e.decorations.from(t)}),gfe=[mfe,hfe];function yfe(t={}){return[t7.of(t),gfe]}const bfe=new it;function TA(t,e,n){let r=t.prop(e<0?it.openedBy:it.closedBy);if(r)return r;if(t.name.length==1){let i=n.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[n[i+e]]}return null}function RA(t){let e=t.type.prop(bfe);return e?e(t.node):t}function so(t,e,n,r={}){let i=r.maxScanDistance||ZV,s=r.brackets||e7,o=br(t),a=o.resolveInner(e,n);for(let c=a;c;c=c.parent){let h=TA(c.type,n,s);if(h&&c.from<c.to){let f=RA(c);if(f&&(n>0?e>=f.from&&e<f.to:e>f.from&&e<=f.to))return vfe(t,e,n,c,f,h,s)}}return wfe(t,e,n,o,a.type,i,s)}function vfe(t,e,n,r,i,s,o){let a=r.parent,c={from:i.from,to:i.to},h=0,f=a?.cursor();if(f&&(n<0?f.childBefore(r.from):f.childAfter(r.to)))do if(n<0?f.to<=r.from:f.from>=r.to){if(h==0&&s.indexOf(f.type.name)>-1&&f.from<f.to){let d=RA(f);return{start:c,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(TA(f.type,n,o))h++;else if(TA(f.type,-n,o)){if(h==0){let d=RA(f);return{start:c,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}h--}}while(n<0?f.prevSibling():f.nextSibling());return{start:c,matched:!1}}function wfe(t,e,n,r,i,s,o){let a=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),c=o.indexOf(a);if(c<0||c%2==0!=n>0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},f=t.doc.iterRange(e,n>0?t.doc.length:0),d=0;for(let m=0;!f.next().done&&m<=s;){let y=f.value;n<0&&(m+=y.length);let b=e+m*n;for(let w=n>0?0:y.length-1,S=n>0?y.length:-1;w!=S;w+=n){let _=o.indexOf(y[w]);if(!(_<0||r.resolveInner(b+w,1).type!=i))if(_%2==0==n>0)d++;else{if(d==1)return{start:h,end:{from:b+w,to:b+w+1},matched:_>>1==c>>1};d--}}n>0&&(m+=y.length)}return f.done?{start:h,matched:!1}:null}const xfe=Object.create(null),r3=[Zr.none],i3=[],s3=Object.create(null),Sfe=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Sfe[t]=_fe(xfe,e);function H_(t,e){i3.indexOf(t)>-1||(i3.push(t),console.warn(e))}function _fe(t,e){let n=[];for(let a of e.split(" ")){let c=[];for(let h of a.split(".")){let f=t[h]||we[h];f?typeof f=="function"?c.length?c=c.map(f):H_(h,`Modifier ${h} used at start of tag`):c.length?H_(h,`Tag ${h} used as modifier`):c=Array.isArray(f)?f:[f]:H_(h,`Unknown highlighting tag ${h}`)}for(let h of c)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+n.map(a=>a.id),s=s3[i];if(s)return s.id;let o=s3[i]=Zr.define({id:r3.length,name:r,props:[jV({[r]:n})]});return r3.push(o),o.id}jt.RTL,jt.LTR;const Cfe=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=ST(t.state,n.from);return r.line?Afe(t):r.block?kfe(t):!1};function xT(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=t(e,n);return i?(r(n.update(i)),!0):!1}}const Afe=xT(Mfe,0),Efe=xT(n7,0),kfe=xT((t,e)=>n7(t,e,Rfe(e)),0);function ST(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Ld=50;function Tfe(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-Ld,r),o=t.sliceDoc(i,i+Ld),a=/\s*$/.exec(s)[0].length,c=/^\s*/.exec(o)[0].length,h=s.length-a;if(s.slice(h-e.length,h)==e&&o.slice(c,c+n.length)==n)return{open:{pos:r-a,margin:a&&1},close:{pos:i+c,margin:c&&1}};let f,d;i-r<=2*Ld?f=d=t.sliceDoc(r,i):(f=t.sliceDoc(r,r+Ld),d=t.sliceDoc(i-Ld,i));let m=/^\s*/.exec(f)[0].length,y=/\s*$/.exec(d)[0].length,b=d.length-y-n.length;return f.slice(m,m+e.length)==e&&d.slice(b,b+n.length)==n?{open:{pos:r+m+e.length,margin:/\s/.test(f.charAt(m+e.length))?1:0},close:{pos:i-y-n.length,margin:/\s/.test(d.charAt(b-1))?1:0}}:null}function Rfe(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),i=n.to<=r.to?r:t.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>r.from?e[s].to=i.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return e}function n7(t,e,n=e.selection.ranges){let r=n.map(s=>ST(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>Tfe(e,r[o],s.from,s.to));if(t!=2&&!i.every(s=>s))return{changes:e.changes(n.map((s,o)=>i[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(t!=1&&i.some(s=>s)){let s=[];for(let o=0,a;o<i.length;o++)if(a=i[o]){let c=r[o],{open:h,close:f}=a;s.push({from:h.pos-c.open.length,to:h.pos+h.margin},{from:f.pos-f.margin,to:f.pos+c.close.length})}return{changes:s}}return null}function Mfe(t,e,n=e.selection.ranges){let r=[],i=-1;for(let{from:s,to:o}of n){let a=r.length,c=1e9,h=ST(e,s).line;if(h){for(let f=s;f<=o;){let d=e.doc.lineAt(f);if(d.from>i&&(s==o||o>d.from)){i=d.from;let m=/^\s*/.exec(d.text)[0].length,y=m==d.length,b=d.text.slice(m,m+h.length)==h?m:-1;m<d.text.length&&m<c&&(c=m),r.push({line:d,comment:b,token:h,indent:m,empty:y,single:!1})}f=d.to+1}if(c<1e9)for(let f=a;f<r.length;f++)r[f].indent<r[f].line.text.length&&(r[f].indent=c);r.length==a+1&&(r[a].single=!0)}}if(t!=2&&r.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:c,indent:h,empty:f,single:d}of r)(d||!f)&&s.push({from:a.from+h,insert:c+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:a,token:c}of r)if(a>=0){let h=o.from+a,f=h+c.length;o.text[f-o.from]==" "&&f++,s.push({from:h,to:f})}return{changes:s}}return null}const MA=sa.define(),Ofe=sa.define(),Pfe=Ce.define(),r7=Ce.define({combine(t){return wo(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,i)=>e(r,i)||n(r,i)})}}),i7=Zn.define({create(){return oo.empty},update(t,e){let n=e.state.facet(r7),r=e.annotation(MA);if(r){let c=Yr.fromTransaction(e,r.selection),h=r.side,f=h==0?t.undone:t.done;return c?f=$v(f,f.length,n.minDepth,c):f=a7(f,e.startState.selection),new oo(h==0?r.rest:f,h==0?f:r.rest)}let i=e.annotation(Ofe);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(kn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Yr.fromTransaction(e),o=e.annotation(kn.time),a=e.annotation(kn.userEvent);return s?t=t.addChanges(s,o,a,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,a,n.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new oo(t.done.map(Yr.fromJSON),t.undone.map(Yr.fromJSON))}});function Dfe(t={}){return[i7,r7.of(t),_e.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?s7:e.inputType=="historyRedo"?OA:null;return r?(e.preventDefault(),r(n)):!1}})]}function ux(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(i7,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const s7=ux(0,!1),OA=ux(1,!1),Ife=ux(0,!0),Lfe=ux(1,!0);class Yr{constructor(e,n,r,i,s){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new Yr(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new Yr(e.changes&&En.fromJSON(e.changes),[],e.mapped&&uo.fromJSON(e.mapped),e.startSelection&&fe.fromJSON(e.startSelection),e.selectionsAfter.map(fe.fromJSON))}static fromTransaction(e,n){let r=Yi;for(let i of e.startState.facet(Pfe)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new Yr(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,Yi)}static selection(e){return new Yr(void 0,Yi,void 0,void 0,e)}}function $v(t,e,n,r){let i=e+1>n+20?e-n-1:0,s=t.slice(i,e);return s.push(r),s}function Nfe(t,e){let n=[],r=!1;return t.iterChangedRanges((i,s)=>n.push(i,s)),e.iterChangedRanges((i,s,o,a)=>{for(let c=0;c<n.length;){let h=n[c++],f=n[c++];a>=h&&o<=f&&(r=!0)}}),r}function $fe(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function o7(t,e){return t.length?e.length?t.concat(e):t:e}const Yi=[],jfe=200;function a7(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-jfe));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),$v(t,t.length-1,1e9,n.setSelAfter(r)))}else return[Yr.selection([e])]}function Bfe(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function W_(t,e){if(!t.length)return t;let n=t.length,r=Yi;for(;n;){let i=Ffe(t[n-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let s=t.slice(0,n);return s[n-1]=i,s}else e=i.mapped,n--,r=i.selectionsAfter}return r.length?[Yr.selection(r)]:Yi}function Ffe(t,e,n){let r=o7(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):Yi,n);if(!t.changes)return Yr.selection(r);let i=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Yr(i,Ze.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const zfe=/^(input\.type|delete)($|\.)/;class oo{constructor(e,n,r=0,i=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new oo(this.done,this.undone):this}addChanges(e,n,r,i,s){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!r||zfe.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(s,Nfe(a.changes,e.changes))||r=="input.type.compose")?o=$v(o,o.length-1,i.minDepth,new Yr(e.changes.compose(a.changes),o7(Ze.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,Yi)):o=$v(o,o.length,i.minDepth,e),new oo(o,Yi,n,r)}addSelection(e,n,r,i){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Yi;return s.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&$fe(s[s.length-1],e)?this:new oo(a7(this.done,e),this.undone,n,r)}addMapping(e){return new oo(W_(this.done,e),W_(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,r){let i=e==0?this.done:this.undone;if(i.length==0)return null;let s=i[i.length-1],o=s.selectionsAfter[0]||n.selection;if(r&&s.selectionsAfter.length)return n.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:MA.of({side:e,rest:Bfe(i),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let a=i.length==1?Yi:i.slice(0,i.length-1);return s.mapped&&(a=W_(a,s.mapped)),n.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:MA.of({side:e,rest:a,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}oo.empty=new oo(Yi,Yi);const Vfe=[{key:"Mod-z",run:s7,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:OA,preventDefault:!0},{linux:"Ctrl-Shift-z",run:OA,preventDefault:!0},{key:"Mod-u",run:Ife,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Lfe,preventDefault:!0}];function Zh(t,e){return fe.create(t.ranges.map(e),t.mainIndex)}function xo(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Os({state:t,dispatch:e},n){let r=Zh(t.selection,n);return r.eq(t.selection,!0)?!1:(e(xo(t,r)),!0)}function hx(t,e){return fe.cursor(e?t.to:t.from)}function l7(t,e){return Os(t,n=>n.empty?t.moveByChar(n,e):hx(n,e))}function vr(t){return t.textDirectionAt(t.state.selection.main.head)==jt.LTR}const c7=t=>l7(t,!vr(t)),u7=t=>l7(t,vr(t));function h7(t,e){return Os(t,n=>n.empty?t.moveByGroup(n,e):hx(n,e))}const Ufe=t=>h7(t,!vr(t)),Hfe=t=>h7(t,vr(t));function Wfe(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function fx(t,e,n){let r=br(t).resolveInner(e.head),i=n?it.closedBy:it.openedBy;for(let c=e.head;;){let h=n?r.childAfter(c):r.childBefore(c);if(!h)break;Wfe(t,h,i)?r=h:c=n?h.to:h.from}let s=r.type.prop(i),o,a;return s&&(o=n?so(t,r.from,1):so(t,r.to,-1))&&o.matched?a=n?o.end.to:o.end.from:a=n?r.to:r.from,fe.cursor(a,n?-1:1)}const qfe=t=>Os(t,e=>fx(t.state,e,!vr(t))),Gfe=t=>Os(t,e=>fx(t.state,e,vr(t)));function f7(t,e){return Os(t,n=>{if(!n.empty)return hx(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const d7=t=>f7(t,!1),p7=t=>f7(t,!0);function m7(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,r=0,i;if(e){for(let s of t.state.facet(_e.scrollMargins)){let o=s(t);o?.top&&(n=Math.max(o?.top,n)),o?.bottom&&(r=Math.max(o?.bottom,r))}i=t.scrollDOM.clientHeight-n-r}else i=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:e,height:Math.max(t.defaultLineHeight,i-5)}}function g7(t,e){let n=m7(t),{state:r}=t,i=Zh(r.selection,o=>o.empty?t.moveVertically(o,e,n.height):hx(o,e));if(i.eq(r.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(r.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),c=a.top+n.marginTop,h=a.bottom-n.marginBottom;o&&o.top>c&&o.bottom<h&&(s=_e.scrollIntoView(i.main.head,{y:"start",yMargin:o.top-c}))}return t.dispatch(xo(r,i),{effects:s}),!0}const o3=t=>g7(t,!1),PA=t=>g7(t,!0);function Cl(t,e,n){let r=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,n);if(i.head==e.head&&i.head!=(n?r.to:r.from)&&(i=t.moveToLineBoundary(e,n,!1)),!n&&i.head==r.from&&r.length){let s=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(i=fe.cursor(r.from+s))}return i}const Kfe=t=>Os(t,e=>Cl(t,e,!0)),Yfe=t=>Os(t,e=>Cl(t,e,!1)),Xfe=t=>Os(t,e=>Cl(t,e,!vr(t))),Jfe=t=>Os(t,e=>Cl(t,e,vr(t))),Qfe=t=>Os(t,e=>fe.cursor(t.lineBlockAt(e.head).from,1)),Zfe=t=>Os(t,e=>fe.cursor(t.lineBlockAt(e.head).to,-1));function ede(t,e,n){let r=!1,i=Zh(t.selection,s=>{let o=so(t,s.head,-1)||so(t,s.head,1)||s.head>0&&so(t,s.head-1,1)||s.head<t.doc.length&&so(t,s.head+1,-1);if(!o||!o.end)return s;r=!0;let a=o.start.from==s.head?o.end.to:o.end.from;return fe.cursor(a)});return r?(e(xo(t,i)),!0):!1}const tde=({state:t,dispatch:e})=>ede(t,e);function is(t,e){let n=Zh(t.state.selection,r=>{let i=e(r);return fe.range(r.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return n.eq(t.state.selection)?!1:(t.dispatch(xo(t.state,n)),!0)}function y7(t,e){return is(t,n=>t.moveByChar(n,e))}const b7=t=>y7(t,!vr(t)),v7=t=>y7(t,vr(t));function w7(t,e){return is(t,n=>t.moveByGroup(n,e))}const nde=t=>w7(t,!vr(t)),rde=t=>w7(t,vr(t)),ide=t=>is(t,e=>fx(t.state,e,!vr(t))),sde=t=>is(t,e=>fx(t.state,e,vr(t)));function x7(t,e){return is(t,n=>t.moveVertically(n,e))}const S7=t=>x7(t,!1),_7=t=>x7(t,!0);function C7(t,e){return is(t,n=>t.moveVertically(n,e,m7(t).height))}const a3=t=>C7(t,!1),l3=t=>C7(t,!0),ode=t=>is(t,e=>Cl(t,e,!0)),ade=t=>is(t,e=>Cl(t,e,!1)),lde=t=>is(t,e=>Cl(t,e,!vr(t))),cde=t=>is(t,e=>Cl(t,e,vr(t))),ude=t=>is(t,e=>fe.cursor(t.lineBlockAt(e.head).from)),hde=t=>is(t,e=>fe.cursor(t.lineBlockAt(e.head).to)),c3=({state:t,dispatch:e})=>(e(xo(t,{anchor:0})),!0),u3=({state:t,dispatch:e})=>(e(xo(t,{anchor:t.doc.length})),!0),h3=({state:t,dispatch:e})=>(e(xo(t,{anchor:t.selection.main.anchor,head:0})),!0),f3=({state:t,dispatch:e})=>(e(xo(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),fde=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),dde=({state:t,dispatch:e})=>{let n=dx(t).map(({from:r,to:i})=>fe.range(r,Math.min(i+1,t.doc.length)));return e(t.update({selection:fe.create(n),userEvent:"select"})),!0},pde=({state:t,dispatch:e})=>{let n=Zh(t.selection,r=>{let i=br(t),s=i.resolveStack(r.from,1);if(r.empty){let o=i.resolveStack(r.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:a}=o;if((a.from<r.from&&a.to>=r.to||a.to>r.to&&a.from<=r.from)&&o.next)return fe.range(a.to,a.from)}return r});return n.eq(t.selection)?!1:(e(xo(t,n)),!0)},mde=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=fe.create([n.main]):n.main.empty||(r=fe.create([fe.cursor(n.main.head)])),r?(e(xo(t,r)),!0):!1};function Qm(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,i=r.changeByRange(s=>{let{from:o,to:a}=s;if(o==a){let c=e(s);c<o?(n="delete.backward",c=Fy(t,c,!1)):c>o&&(n="delete.forward",c=Fy(t,c,!0)),o=Math.min(o,c),a=Math.max(a,c)}else o=Fy(t,o,!1),a=Fy(t,a,!0);return o==a?{range:s}:{changes:{from:o,to:a},range:fe.cursor(o,o<s.head?-1:1)}});return i.changes.empty?!1:(t.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?_e.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function Fy(t,e,n){if(t instanceof _e)for(let r of t.state.facet(_e.atomicRanges).map(i=>i(t)))r.between(e,e,(i,s)=>{i<e&&s>e&&(e=n?s:i)});return e}const A7=(t,e,n)=>Qm(t,r=>{let i=r.from,{state:s}=t,o=s.doc.lineAt(i),a,c;if(n&&!e&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,i-o.from))){if(a[a.length-1]==" ")return i-1;let h=Qh(a,s.tabSize),f=h%Iv(s)||Iv(s);for(let d=0;d<f&&a[a.length-1-d]==" ";d++)i--;c=i}else c=Xn(o.text,i-o.from,e,e)+o.from,c==i&&o.number!=(e?s.doc.lines:1)?c+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=Xn(o.text,c-o.from,!1,!1)+o.from);return c}),DA=t=>A7(t,!1,!0),E7=t=>A7(t,!0,!1),k7=(t,e)=>Qm(t,n=>{let r=n.head,{state:i}=t,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let a=null;;){if(r==(e?s.to:s.from)){r==n.head&&s.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let c=Xn(s.text,r-s.from,e)+s.from,h=s.text.slice(Math.min(r,c)-s.from,Math.max(r,c)-s.from),f=o(h);if(a!=null&&f!=a)break;(h!=" "||r!=n.head)&&(a=f),r=c}return r}),T7=t=>k7(t,!1),gde=t=>k7(t,!0),yde=t=>Qm(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),bde=t=>Qm(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),vde=t=>Qm(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),wde=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:dt.of(["",""])},range:fe.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},xde=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let i=r.from,s=t.doc.lineAt(i),o=i==s.from?i-1:Xn(s.text,i-s.from,!1)+s.from,a=i==s.to?i+1:Xn(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:a,insert:t.doc.slice(i,a).append(t.doc.slice(o,i))},range:fe.cursor(a)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function dx(t){let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.from),s=t.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=t.doc.lineAt(r.to-1)),n>=i.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(r)}else e.push({from:i.from,to:s.to,ranges:[r]});n=s.number+1}return e}function R7(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of dx(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),a=o.length+1;if(n){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let c of s.ranges)i.push(fe.range(Math.min(t.doc.length,c.anchor+a),Math.min(t.doc.length,c.head+a)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let c of s.ranges)i.push(fe.range(c.anchor-a,c.head-a))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:fe.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Sde=({state:t,dispatch:e})=>R7(t,e,!1),_de=({state:t,dispatch:e})=>R7(t,e,!0);function M7(t,e,n){if(t.readOnly)return!1;let r=[];for(let i of dx(t))n?r.push({from:i.from,insert:t.doc.slice(i.from,i.to)+t.lineBreak}):r.push({from:i.to,insert:t.lineBreak+t.doc.slice(i.from,i.to)});return e(t.update({changes:r,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Cde=({state:t,dispatch:e})=>M7(t,e,!1),Ade=({state:t,dispatch:e})=>M7(t,e,!0),Ede=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(dx(e).map(({from:i,to:s})=>(i>0?i--:s<e.doc.length&&s++,{from:i,to:s}))),r=Zh(e.selection,i=>{let s;if(t.lineWrapping){let o=t.lineBlockAt(i.head),a=t.coordsAtPos(i.head,i.assoc||1);a&&(s=o.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(i,!0,s)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function kde(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=br(t).resolveInner(e),r=n.childBefore(e),i=n.childAfter(e),s;return r&&i&&r.to<=e&&i.from>=e&&(s=r.type.prop(it.closedBy))&&s.indexOf(i.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const d3=O7(!1),Tde=O7(!0);function O7(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:s,to:o}=i,a=e.doc.lineAt(s),c=!t&&s==o&&kde(e,s);t&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let h=new ax(e,{simulateBreak:s,simulateDoubleBreak:!!c}),f=vT(h,s);for(f==null&&(f=Qh(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;c?{from:s,to:o}=c:s>a.from&&s<a.from+100&&!/\S/.test(a.text.slice(0,s))&&(s=a.from);let d=["",dm(e,f)];return c&&d.push(dm(e,h.lineIndent(a.from,-1))),{changes:{from:s,to:o,insert:dt.of(d)},range:fe.cursor(s+1+d[1].length)}});return n(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function _T(t,e){let n=-1;return t.changeByRange(r=>{let i=[];for(let o=r.from;o<=r.to;){let a=t.doc.lineAt(o);a.number>n&&(r.empty||r.to>a.from)&&(e(a,i,r),n=a.number),o=a.to+1}let s=t.changes(i);return{changes:i,range:fe.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const Rde=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new ax(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=_T(t,(s,o,a)=>{let c=vT(r,s.from);if(c==null)return;/\S/.test(s.text)||(c=0);let h=/^\s*/.exec(s.text)[0],f=dm(t,c);(h!=f||a.from<s.from+h.length)&&(n[s.from]=c,o.push({from:s.from,to:s.from+h.length,insert:f}))});return i.changes.empty||e(t.update(i,{userEvent:"indent"})),!0},Mde=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(_T(t,(n,r)=>{r.push({from:n.from,insert:t.facet(bT)})}),{userEvent:"input.indent"})),!0),Ode=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(_T(t,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=Qh(i,t.tabSize),o=0,a=dm(t,Math.max(0,s-Iv(t)));for(;o<i.length&&o<a.length&&i.charCodeAt(o)==a.charCodeAt(o);)o++;r.push({from:n.from+o,to:n.from+i.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),Pde=t=>(t.setTabFocusMode(),!0),Dde=[{key:"Ctrl-b",run:c7,shift:b7,preventDefault:!0},{key:"Ctrl-f",run:u7,shift:v7},{key:"Ctrl-p",run:d7,shift:S7},{key:"Ctrl-n",run:p7,shift:_7},{key:"Ctrl-a",run:Qfe,shift:ude},{key:"Ctrl-e",run:Zfe,shift:hde},{key:"Ctrl-d",run:E7},{key:"Ctrl-h",run:DA},{key:"Ctrl-k",run:yde},{key:"Ctrl-Alt-h",run:T7},{key:"Ctrl-o",run:wde},{key:"Ctrl-t",run:xde},{key:"Ctrl-v",run:PA}],Ide=[{key:"ArrowLeft",run:c7,shift:b7,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Ufe,shift:nde,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Xfe,shift:lde,preventDefault:!0},{key:"ArrowRight",run:u7,shift:v7,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Hfe,shift:rde,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Jfe,shift:cde,preventDefault:!0},{key:"ArrowUp",run:d7,shift:S7,preventDefault:!0},{mac:"Cmd-ArrowUp",run:c3,shift:h3},{mac:"Ctrl-ArrowUp",run:o3,shift:a3},{key:"ArrowDown",run:p7,shift:_7,preventDefault:!0},{mac:"Cmd-ArrowDown",run:u3,shift:f3},{mac:"Ctrl-ArrowDown",run:PA,shift:l3},{key:"PageUp",run:o3,shift:a3},{key:"PageDown",run:PA,shift:l3},{key:"Home",run:Yfe,shift:ade,preventDefault:!0},{key:"Mod-Home",run:c3,shift:h3},{key:"End",run:Kfe,shift:ode,preventDefault:!0},{key:"Mod-End",run:u3,shift:f3},{key:"Enter",run:d3,shift:d3},{key:"Mod-a",run:fde},{key:"Backspace",run:DA,shift:DA},{key:"Delete",run:E7},{key:"Mod-Backspace",mac:"Alt-Backspace",run:T7},{key:"Mod-Delete",mac:"Alt-Delete",run:gde},{mac:"Mod-Backspace",run:bde},{mac:"Mod-Delete",run:vde}].concat(Dde.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Lde=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:qfe,shift:ide},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Gfe,shift:sde},{key:"Alt-ArrowUp",run:Sde},{key:"Shift-Alt-ArrowUp",run:Cde},{key:"Alt-ArrowDown",run:_de},{key:"Shift-Alt-ArrowDown",run:Ade},{key:"Escape",run:mde},{key:"Mod-Enter",run:Tde},{key:"Alt-l",mac:"Ctrl-l",run:dde},{key:"Mod-i",run:pde,preventDefault:!0},{key:"Mod-[",run:Ode},{key:"Mod-]",run:Mde},{key:"Mod-Alt-\\",run:Rde},{key:"Shift-Mod-k",run:Ede},{key:"Shift-Mod-\\",run:tde},{key:"Mod-/",run:Cfe},{key:"Alt-A",run:Efe},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Pde}].concat(Ide),p3=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class jh{constructor(e,n,r=0,i=e.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,i),this.bufferStart=r,this.normalize=s?a=>s(p3(a)):p3,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Wr(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let n=Qk(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=to(e);let i=this.normalize(n);if(i.length)for(let s=0,o=r;;s++){let a=i.charCodeAt(s),c=this.match(a,o,this.bufferPos+this.bufferStart);if(s==i.length-1){if(c)return this.value=c,this;break}o==r&&s<n.length&&n.charCodeAt(s)==a&&o++}}}match(e,n,r){let i=null;for(let s=0;s<this.matches.length;s+=2){let o=this.matches[s],a=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?i={from:this.matches[s+1],to:r}:(this.matches[s]++,a=!0)),a||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:n,to:r}:this.matches.push(1,n)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}typeof Symbol<"u"&&(jh.prototype[Symbol.iterator]=function(){return this});const P7={from:-1,to:-1,match:/.*/.exec("")},CT="gm"+(/x/.unicode==null?"":"u");class D7{constructor(e,n,r,i=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=P7,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new I7(e,n,r,i,s);this.re=new RegExp(n,CT+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=e.iter();let o=e.lineAt(i);this.curLineStart=o.from,this.matchPos=jv(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,i=r+n[0].length;if(this.matchPos=jv(this.text,i+(r==i?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<i||r>this.value.to)&&(!this.test||this.test(r,i,n)))return this.value={from:r,to:i,match:n},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const q_=new WeakMap;class Sh{constructor(e,n){this.from=e,this.text=n}get to(){return this.from+this.text.length}static get(e,n,r){let i=q_.get(e);if(!i||i.from>=r||i.to<=n){let a=new Sh(n,e.sliceString(n,r));return q_.set(e,a),a}if(i.from==n&&i.to==r)return i;let{text:s,from:o}=i;return o>n&&(s=e.sliceString(n,o)+s,o=n),i.to<r&&(s+=e.sliceString(i.to,r)),q_.set(e,new Sh(o,s)),new Sh(n,s.slice(n-o,r-o))}}class I7{constructor(e,n,r,i,s){this.text=e,this.to=s,this.done=!1,this.value=P7,this.matchPos=jv(e,i),this.re=new RegExp(n,CT+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=Sh.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,i=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,i,n)))return this.value={from:r,to:i,match:n},this.matchPos=jv(this.text,i+(r==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Sh.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(D7.prototype[Symbol.iterator]=I7.prototype[Symbol.iterator]=function(){return this});function Nde(t){try{return new RegExp(t,CT),!0}catch{return!1}}function jv(t,e){if(e>=t.length)return e;let n=t.lineAt(e),r;for(;e<n.to&&(r=n.text.charCodeAt(e-n.from))>=56320&&r<57344;)e++;return e}function IA(t){let e=String(t.state.doc.lineAt(t.state.selection.main.head).number),n=kt("input",{class:"cm-textfield",name:"line",value:e}),r=kt("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),t.dispatch({effects:Mp.of(!1)}),t.focus()):s.keyCode==13&&(s.preventDefault(),i())},onsubmit:s=>{s.preventDefault(),i()}},kt("label",t.state.phrase("Go to line"),": ",n)," ",kt("button",{class:"cm-button",type:"submit"},t.state.phrase("go")),kt("button",{name:"close",onclick:()=>{t.dispatch({effects:Mp.of(!1)}),t.focus()},"aria-label":t.state.phrase("close"),type:"button"},["×"]));function i(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.value);if(!s)return;let{state:o}=t,a=o.doc.lineAt(o.selection.main.head),[,c,h,f,d]=s,m=f?+f.slice(1):0,y=h?+h:a.number;if(h&&d){let S=y/100;c&&(S=S*(c=="-"?-1:1)+a.number/o.doc.lines),y=Math.round(o.doc.lines*S)}else h&&c&&(y=y*(c=="-"?-1:1)+a.number);let b=o.doc.line(Math.max(1,Math.min(o.doc.lines,y))),w=fe.cursor(b.from+Math.max(0,Math.min(m,b.length)));t.dispatch({effects:[Mp.of(!1),_e.scrollIntoView(w.from,{y:"center"})],selection:w}),t.focus()}return{dom:r}}const Mp=Ze.define(),m3=Zn.define({create(){return!0},update(t,e){for(let n of e.effects)n.is(Mp)&&(t=n.value);return t},provide:t=>hm.from(t,e=>e?IA:null)}),$de=t=>{let e=um(t,IA);if(!e){let n=[Mp.of(!0)];t.state.field(m3,!1)==null&&n.push(Ze.appendConfig.of([m3,jde])),t.dispatch({effects:n}),e=um(t,IA)}return e&&e.dom.querySelector("input").select(),!0},jde=_e.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),Bde={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Fde=Ce.define({combine(t){return wo(t,Bde,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function zde(t){return[qde,Wde]}const Vde=He.mark({class:"cm-selectionMatch"}),Ude=He.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function g3(t,e,n,r){return(n==0||t(e.sliceDoc(n-1,n))!=Vt.Word)&&(r==e.doc.length||t(e.sliceDoc(r,r+1))!=Vt.Word)}function Hde(t,e,n,r){return t(e.sliceDoc(n,n+1))==Vt.Word&&t(e.sliceDoc(r-1,r))==Vt.Word}const Wde=yn.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(Fde),{state:n}=t,r=n.selection;if(r.ranges.length>1)return He.none;let i=r.main,s,o=null;if(i.empty){if(!e.highlightWordAroundCursor)return He.none;let c=n.wordAt(i.head);if(!c)return He.none;o=n.charCategorizer(i.head),s=n.sliceDoc(c.from,c.to)}else{let c=i.to-i.from;if(c<e.minSelectionLength||c>200)return He.none;if(e.wholeWords){if(s=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(g3(o,n,i.from,i.to)&&Hde(o,n,i.from,i.to)))return He.none}else if(s=n.sliceDoc(i.from,i.to),!s)return He.none}let a=[];for(let c of t.visibleRanges){let h=new jh(n.doc,s,c.from,c.to);for(;!h.next().done;){let{from:f,to:d}=h.value;if((!o||g3(o,n,f,d))&&(i.empty&&f<=i.from&&d>=i.to?a.push(Ude.range(f,d)):(f>=i.to||d<=i.from)&&a.push(Vde.range(f,d)),a.length>e.maxMatches))return He.none}}return He.set(a)}},{decorations:t=>t.decorations}),qde=_e.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Gde=({state:t,dispatch:e})=>{let{selection:n}=t,r=fe.create(n.ranges.map(i=>t.wordAt(i.head)||fe.cursor(i.head)),n.mainIndex);return r.eq(n)?!1:(e(t.update({selection:r})),!0)};function Kde(t,e){let{main:n,ranges:r}=t.selection,i=t.wordAt(n.head),s=i&&i.from==n.from&&i.to==n.to;for(let o=!1,a=new jh(t.doc,e,r[r.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new jh(t.doc,e,0,Math.max(0,r[r.length-1].from-1)),o=!0}else{if(o&&r.some(c=>c.from==a.value.from))continue;if(s){let c=t.wordAt(a.value.from);if(!c||c.from!=a.value.from||c.to!=a.value.to)continue}return a.value}}const Yde=({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(s=>s.from===s.to))return Gde({state:t,dispatch:e});let r=t.sliceDoc(n[0].from,n[0].to);if(t.selection.ranges.some(s=>t.sliceDoc(s.from,s.to)!=r))return!1;let i=Kde(t,r);return i?(e(t.update({selection:t.selection.addRange(fe.range(i.from,i.to),!1),effects:_e.scrollIntoView(i.to)})),!0):!1},ef=Ce.define({combine(t){return wo(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ape(e),scrollToMatch:e=>_e.scrollIntoView(e)})}});class L7{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Nde(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(n,r)=>r=="n"?`
`:r=="r"?"\r":r=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new Zde(this):new Jde(this)}getCursor(e,n=0,r){let i=e.doc?e:ht.create({doc:e});return r==null&&(r=i.doc.length),this.regexp?Zu(this,i,n,r):Qu(this,i,n,r)}}class N7{constructor(e){this.spec=e}}function Qu(t,e,n,r){return new jh(e.doc,t.unquoted,n,r,t.caseSensitive?void 0:i=>i.toLowerCase(),t.wholeWord?Xde(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function Xde(t,e){return(n,r,i,s)=>((s>n||s+i.length<r)&&(s=Math.max(0,n-2),i=t.sliceString(s,Math.min(t.length,r+2))),(e(Bv(i,n-s))!=Vt.Word||e(Fv(i,n-s))!=Vt.Word)&&(e(Fv(i,r-s))!=Vt.Word||e(Bv(i,r-s))!=Vt.Word))}class Jde extends N7{constructor(e){super(e)}nextMatch(e,n,r){let i=Qu(this.spec,e,r,e.doc.length).nextOverlapping();if(i.done){let s=Math.min(e.doc.length,n+this.spec.unquoted.length);i=Qu(this.spec,e,0,s).nextOverlapping()}return i.done||i.value.from==n&&i.value.to==r?null:i.value}prevMatchInRange(e,n,r){for(let i=r;;){let s=Math.max(n,i-1e4-this.spec.unquoted.length),o=Qu(this.spec,e,s,i),a=null;for(;!o.nextOverlapping().done;)a=o.value;if(a)return a;if(s==n)return null;i-=1e4}}prevMatch(e,n,r){let i=this.prevMatchInRange(e,0,n);return i||(i=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=n||i.to!=r)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let r=Qu(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=n)return null;i.push(r.value)}return i}highlight(e,n,r,i){let s=Qu(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}function Zu(t,e,n,r){return new D7(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?Qde(e.charCategorizer(e.selection.main.head)):void 0},n,r)}function Bv(t,e){return t.slice(Xn(t,e,!1),e)}function Fv(t,e){return t.slice(e,Xn(t,e))}function Qde(t){return(e,n,r)=>!r[0].length||(t(Bv(r.input,r.index))!=Vt.Word||t(Fv(r.input,r.index))!=Vt.Word)&&(t(Fv(r.input,r.index+r[0].length))!=Vt.Word||t(Bv(r.input,r.index+r[0].length))!=Vt.Word)}class Zde extends N7{nextMatch(e,n,r){let i=Zu(this.spec,e,r,e.doc.length).next();return i.done&&(i=Zu(this.spec,e,0,n).next()),i.done?null:i.value}prevMatchInRange(e,n,r){for(let i=1;;i++){let s=Math.max(n,r-i*1e4),o=Zu(this.spec,e,s,r),a=null;for(;!o.next().done;)a=o.value;if(a&&(s==n||a.from>s+10))return a;if(s==n)return null}}prevMatch(e,n,r){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let i=r.length;i>0;i--){let s=+r.slice(0,i);if(s>0&&s<e.match.length)return e.match[s]+r.slice(i)}return n})}matchAll(e,n){let r=Zu(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=n)return null;i.push(r.value)}return i}highlight(e,n,r,i){let s=Zu(this.spec,e,Math.max(0,n-250),Math.min(r+250,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}const pm=Ze.define(),AT=Ze.define(),ll=Zn.define({create(t){return new G_(LA(t).create(),null)},update(t,e){for(let n of e.effects)n.is(pm)?t=new G_(n.value.create(),t.panel):n.is(AT)&&(t=new G_(t.query,n.value?ET:null));return t},provide:t=>hm.from(t,e=>e.panel)});class G_{constructor(e,n){this.query=e,this.panel=n}}const epe=He.mark({class:"cm-searchMatch"}),tpe=He.mark({class:"cm-searchMatch cm-searchMatch-selected"}),npe=yn.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(ll))}update(t){let e=t.state.field(ll);(e!=t.startState.field(ll)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return He.none;let{view:n}=this,r=new Xo;for(let i=0,s=n.visibleRanges,o=s.length;i<o;i++){let{from:a,to:c}=s[i];for(;i<o-1&&c>s[i+1].from-500;)c=s[++i].to;t.highlight(n.state,a,c,(h,f)=>{let d=n.state.selection.ranges.some(m=>m.from==h&&m.to==f);r.add(h,f,d?tpe:epe)})}return r.finish()}},{decorations:t=>t.decorations});function Zm(t){return e=>{let n=e.state.field(ll,!1);return n&&n.query.spec.valid?t(e,n):B7(e)}}const zv=Zm((t,{query:e})=>{let{to:n}=t.state.selection.main,r=e.nextMatch(t.state,n,n);if(!r)return!1;let i=fe.single(r.from,r.to),s=t.state.facet(ef);return t.dispatch({selection:i,effects:[kT(t,r),s.scrollToMatch(i.main,t)],userEvent:"select.search"}),j7(t),!0}),Vv=Zm((t,{query:e})=>{let{state:n}=t,{from:r}=n.selection.main,i=e.prevMatch(n,r,r);if(!i)return!1;let s=fe.single(i.from,i.to),o=t.state.facet(ef);return t.dispatch({selection:s,effects:[kT(t,i),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),j7(t),!0}),rpe=Zm((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:fe.create(n.map(r=>fe.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),ipe=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,s=[],o=0;for(let a=new jh(t.doc,t.sliceDoc(r,i));!a.next().done;){if(s.length>1e3)return!1;a.value.from==r&&(o=s.length),s.push(fe.range(a.value.from,a.value.to))}return e(t.update({selection:fe.create(s,o),userEvent:"select.search.matches"})),!0},y3=Zm((t,{query:e})=>{let{state:n}=t,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let s=e.nextMatch(n,r,r);if(!s)return!1;let o=s,a=[],c,h,f=[];o.from==r&&o.to==i&&(h=n.toText(e.getReplacement(o)),a.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(n,o.from,o.to),f.push(_e.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+".")));let d=t.state.changes(a);return o&&(c=fe.single(o.from,o.to).map(d),f.push(kT(t,o)),f.push(n.facet(ef).scrollToMatch(c.main,t))),t.dispatch({changes:d,selection:c,effects:f,userEvent:"input.replace"}),!0}),spe=Zm((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(i=>{let{from:s,to:o}=i;return{from:s,to:o,insert:e.getReplacement(i)}});if(!n.length)return!1;let r=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:_e.announce.of(r),userEvent:"input.replace.all"}),!0});function ET(t){return t.state.facet(ef).createPanel(t)}function LA(t,e){var n,r,i,s,o;let a=t.selection.main,c=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!c)return e;let h=t.facet(ef);return new L7({search:((n=e?.literal)!==null&&n!==void 0?n:h.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(r=e?.caseSensitive)!==null&&r!==void 0?r:h.caseSensitive,literal:(i=e?.literal)!==null&&i!==void 0?i:h.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function $7(t){let e=um(t,ET);return e&&e.dom.querySelector("[main-field]")}function j7(t){let e=$7(t);e&&e==t.root.activeElement&&e.select()}const B7=t=>{let e=t.state.field(ll,!1);if(e&&e.panel){let n=$7(t);if(n&&n!=t.root.activeElement){let r=LA(t.state,e.query.spec);r.valid&&t.dispatch({effects:pm.of(r)}),n.focus(),n.select()}}else t.dispatch({effects:[AT.of(!0),e?pm.of(LA(t.state,e.query.spec)):Ze.appendConfig.of(cpe)]});return!0},F7=t=>{let e=t.state.field(ll,!1);if(!e||!e.panel)return!1;let n=um(t,ET);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:AT.of(!1)}),!0},ope=[{key:"Mod-f",run:B7,scope:"editor search-panel"},{key:"F3",run:zv,shift:Vv,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:zv,shift:Vv,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:F7,scope:"editor search-panel"},{key:"Mod-Shift-l",run:ipe},{key:"Mod-Alt-g",run:$de},{key:"Mod-d",run:Yde,preventDefault:!0}];class ape{constructor(e){this.view=e;let n=this.query=e.state.field(ll).query.spec;this.commit=this.commit.bind(this),this.searchField=kt("input",{value:n.search,placeholder:di(e,"Find"),"aria-label":di(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=kt("input",{value:n.replace,placeholder:di(e,"Replace"),"aria-label":di(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=kt("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=kt("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=kt("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(i,s,o){return kt("button",{class:"cm-button",name:i,onclick:s,type:"button"},o)}this.dom=kt("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,r("next",()=>zv(e),[di(e,"next")]),r("prev",()=>Vv(e),[di(e,"previous")]),r("select",()=>rpe(e),[di(e,"all")]),kt("label",null,[this.caseField,di(e,"match case")]),kt("label",null,[this.reField,di(e,"regexp")]),kt("label",null,[this.wordField,di(e,"by word")]),...e.state.readOnly?[]:[kt("br"),this.replaceField,r("replace",()=>y3(e),[di(e,"replace")]),r("replaceAll",()=>spe(e),[di(e,"replace all")])],kt("button",{name:"close",onclick:()=>F7(e),"aria-label":di(e,"close"),type:"button"},["×"])])}commit(){let e=new L7({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:pm.of(e)}))}keydown(e){mue(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Vv:zv)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),y3(this.view))}update(e){for(let n of e.transactions)for(let r of n.effects)r.is(pm)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(ef).top}}function di(t,e){return t.state.phrase(e)}const zy=30,Vy=/[\s\.,:;?!]/;function kT(t,{from:e,to:n}){let r=t.state.doc.lineAt(e),i=t.state.doc.lineAt(n).to,s=Math.max(r.from,e-zy),o=Math.min(i,n+zy),a=t.state.sliceDoc(s,o);if(s!=r.from){for(let c=0;c<zy;c++)if(!Vy.test(a[c+1])&&Vy.test(a[c])){a=a.slice(c);break}}if(o!=i){for(let c=a.length-1;c>a.length-zy;c--)if(!Vy.test(a[c-1])&&Vy.test(a[c])){a=a.slice(0,c);break}}return _e.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${r.number}.`)}const lpe=_e.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),cpe=[ll,$c.low(npe),lpe];class z7{constructor(e,n,r,i){this.state=e,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=br(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),s=i.search(V7(e,!1));return s<0?null:{from:r+s,to:this.pos,text:i.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,r){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function b3(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function upe(t){let e=Object.create(null),n=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let s=1;s<i.length;s++)n[i[s]]=!0}let r=b3(e)+b3(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function hpe(t){let e=t.map(i=>typeof i=="string"?{label:i}:i),[n,r]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:upe(e);return i=>{let s=i.matchBefore(r);return s||i.explicit?{from:s?s.from:i.pos,options:e,validFor:n}:null}}class v3{constructor(e,n,r,i){this.completion=e,this.source=n,this.match=r,this.score=i}}function bc(t){return t.selection.main.from}function V7(t,e){var n;let{source:r}=t,i=e&&r[0]!="^",s=r[r.length-1]!="$";return!i&&!s?t:new RegExp(`${i?"^":""}(?:${r})${s?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const U7=sa.define();function fpe(t,e,n,r){let{main:i}=t.selection,s=n-i.from,o=r-i.from;return{...t.changeByRange(a=>{if(a!=i&&n!=r&&t.sliceDoc(a.from+s,a.from+o)!=t.sliceDoc(n,r))return{range:a};let c=t.toText(e);return{changes:{from:a.from+s,to:r==i.from?a.to:a.from+o,insert:c},range:fe.cursor(a.from+s+c.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const w3=new WeakMap;function dpe(t){if(!Array.isArray(t))return t;let e=w3.get(t);return e||w3.set(t,e=hpe(t)),e}const Uv=Ze.define(),mm=Ze.define();class ppe{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let r=Wr(e,n),i=to(r);this.chars.push(r);let s=e.slice(n,n+i),o=s.toUpperCase();this.folded.push(Wr(o==s?s.toLowerCase():o,0)),n+=i}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:s,byWord:o}=this;if(n.length==1){let A=Wr(e,0),E=to(A),P=E==e.length?0:-100;if(A!=n[0])if(A==r[0])P+=-200;else return null;return this.ret(P,[0,E])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=n.length,h=0;if(a<0){for(let A=0,E=Math.min(e.length,200);A<E&&h<c;){let P=Wr(e,A);(P==n[h]||P==r[h])&&(i[h++]=A),A+=to(P)}if(h<c)return null}let f=0,d=0,m=!1,y=0,b=-1,w=-1,S=/[a-z]/.test(e),_=!0;for(let A=0,E=Math.min(e.length,200),P=0;A<E&&d<c;){let O=Wr(e,A);a<0&&(f<c&&O==n[f]&&(s[f++]=A),y<c&&(O==n[y]||O==r[y]?(y==0&&(b=A),w=A+1,y++):y=0));let M,D=O<255?O>=48&&O<=57||O>=97&&O<=122?2:O>=65&&O<=90?1:0:(M=Qk(O))!=M.toLowerCase()?1:M!=M.toUpperCase()?2:0;(!A||D==1&&S||P==0&&D!=0)&&(n[d]==O||r[d]==O&&(m=!0)?o[d++]=A:o.length&&(_=!1)),P=D,A+=to(O)}return d==c&&o[0]==0&&_?this.result(-100+(m?-200:0),o,e):y==c&&b==0?this.ret(-200-e.length+(w==e.length?0:-100),[0,w]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):y==c?this.ret(-900-e.length,[b,w]):d==c?this.result(-100+(m?-200:0)+-700+(_?0:-1100),o,e):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,n,r){let i=[],s=0;for(let o of n){let a=o+(this.astral?to(Wr(r,o)):1);s&&i[s-1]==o?i[s-1]=a:(i[s++]=o,i[s++]=a)}return this.ret(e-r.length,i)}}class mpe{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let n=e.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(e.length==this.pattern.length?0:-100),this)}}const jn=Ce.define({combine(t){return wo(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:gpe,filterStrict:!1,compareCompletions:(e,n)=>e.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>r=>x3(e(r),n(r)),optionClass:(e,n)=>r=>x3(e(r),n(r)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function x3(t,e){return t?e?t+" "+e:t:e}function gpe(t,e,n,r,i,s){let o=t.textDirection==jt.RTL,a=o,c=!1,h="top",f,d,m=e.left-i.left,y=i.right-e.right,b=r.right-r.left,w=r.bottom-r.top;if(a&&m<Math.min(b,y)?a=!1:!a&&y<Math.min(b,m)&&(a=!0),b<=(a?m:y))f=Math.max(i.top,Math.min(n.top,i.bottom-w))-e.top,d=Math.min(400,a?m:y);else{c=!0,d=Math.min(400,(o?e.right:i.right-e.left)-30);let A=i.bottom-e.bottom;A>=w||A>e.top?f=n.bottom-e.top:(h="bottom",f=e.bottom-n.top)}let S=(e.bottom-e.top)/s.offsetHeight,_=(e.right-e.left)/s.offsetWidth;return{style:`${h}: ${f/S}px; max-width: ${d/_}px`,class:"cm-completionInfo-"+(c?o?"left-narrow":"right-narrow":a?"left":"right")}}function ype(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),e.push({render(n,r,i,s){let o=document.createElement("span");o.className="cm-completionLabel";let a=n.displayLabel||n.label,c=0;for(let h=0;h<s.length;){let f=s[h++],d=s[h++];f>c&&o.appendChild(document.createTextNode(a.slice(c,f)));let m=o.appendChild(document.createElement("span"));m.appendChild(document.createTextNode(a.slice(f,d))),m.className="cm-completionMatchedText",c=d}return c<a.length&&o.appendChild(document.createTextNode(a.slice(c))),o},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),e.sort((n,r)=>n.position-r.position).map(n=>n.render)}function K_(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let i=Math.floor(e/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((t-e)/n);return{from:t-(r+1)*n,to:t-r*n}}class bpe{constructor(e,n,r){this.view=e,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:c=>this.placeInfo(c),key:this},this.space=null,this.currentClass="";let i=e.state.field(n),{options:s,selected:o}=i.open,a=e.state.facet(jn);this.optionContent=ype(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=K_(s.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",c=>{let{options:h}=e.state.field(n).open;for(let f=c.target,d;f&&f!=this.dom;f=f.parentNode)if(f.nodeName=="LI"&&(d=/-(\d+)$/.exec(f.id))&&+d[1]<h.length){this.applyCompletion(e,h[+d[1]]),c.preventDefault();return}}),this.dom.addEventListener("focusout",c=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(jn).closeOnBlur&&c.relatedTarget!=e.contentDOM&&e.dispatch({effects:mm.of(null)})}),this.showOptions(s,i.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let r=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),r!=i){let{options:s,selected:o,disabled:a}=r.open;(!i.open||i.open.options!=s)&&(this.range=K_(s.length,o,e.state.facet(jn).maxRenderedOptions),this.showOptions(s,r.id)),this.updateSel(),a!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;if((n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=K_(n.options.length,n.selected,this.view.state.facet(jn).maxRenderedOptions),this.showOptions(n.options,e.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let s=typeof i=="string"?document.createTextNode(i):i(r);if(!s)return;"then"in s?s.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,r)}).catch(o=>Kr(this.view.state,o,"completion info")):this.addInfoPane(s,r)}}addInfoPane(e,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",e.nodeType!=null)r.appendChild(e),this.infoDestroy=null;else{let{dom:i,destroy:s}=e;r.appendChild(i),this.infoDestroy=s||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==e?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&wpe(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return i.top>Math.min(s.bottom,n.bottom)-10||i.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(jn).positionInfo(this.view,n,i,r,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",o=>{o.target==i&&o.preventDefault()});let s=null;for(let o=r.from;o<r.to;o++){let{completion:a,match:c}=e[o],{section:h}=a;if(h){let m=typeof h=="string"?h:h.name;if(m!=s&&(o>r.from||r.from==0))if(s=m,typeof h!="string"&&h.header)i.appendChild(h.header(h));else{let y=i.appendChild(document.createElement("completion-section"));y.textContent=m}}const f=i.appendChild(document.createElement("li"));f.id=n+"-"+o,f.setAttribute("role","option");let d=this.optionClass(a);d&&(f.className=d);for(let m of this.optionContent){let y=m(a,this.view.state,this.view,c);y&&f.appendChild(y)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function vpe(t,e){return n=>new bpe(n,t,e)}function wpe(t,e){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=n.height/t.offsetHeight;r.top<n.top?t.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(t.scrollTop+=(r.bottom-n.bottom)/i)}function S3(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function xpe(t,e){let n=[],r=null,i=h=>{n.push(h);let{section:f}=h.completion;if(f){r||(r=[]);let d=typeof f=="string"?f:f.name;r.some(m=>m.name==d)||r.push(typeof f=="string"?{name:d}:f)}},s=e.facet(jn);for(let h of t)if(h.hasResult()){let f=h.result.getMatch;if(h.result.filter===!1)for(let d of h.result.options)i(new v3(d,h.source,f?f(d):[],1e9-n.length));else{let d=e.sliceDoc(h.from,h.to),m,y=s.filterStrict?new mpe(d):new ppe(d);for(let b of h.result.options)if(m=y.match(b.label)){let w=b.displayLabel?f?f(b,m.matched):[]:m.matched;i(new v3(b,h.source,w,m.score+(b.boost||0)))}}}if(r){let h=Object.create(null),f=0,d=(m,y)=>{var b,w;return((b=m.rank)!==null&&b!==void 0?b:1e9)-((w=y.rank)!==null&&w!==void 0?w:1e9)||(m.name<y.name?-1:1)};for(let m of r.sort(d))f-=1e5,h[m.name]=f;for(let m of n){let{section:y}=m.completion;y&&(m.score+=h[typeof y=="string"?y:y.name])}}let o=[],a=null,c=s.compareCompletions;for(let h of n.sort((f,d)=>d.score-f.score||c(f.completion,d.completion))){let f=h.completion;!a||a.label!=f.label||a.detail!=f.detail||a.type!=null&&f.type!=null&&a.type!=f.type||a.apply!=f.apply||a.boost!=f.boost?o.push(h):S3(h.completion)>S3(a)&&(o[o.length-1]=h),a=h.completion}return o}class sh{constructor(e,n,r,i,s,o){this.options=e,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=s,this.disabled=o}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new sh(this.options,_3(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,r,i,s,o){if(i&&!o&&e.some(h=>h.isPending))return i.setDisabled();let a=xpe(e,n);if(!a.length)return i&&e.some(h=>h.isPending)?i.setDisabled():null;let c=n.facet(jn).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let h=i.options[i.selected].completion;for(let f=0;f<a.length;f++)if(a[f].completion==h){c=f;break}}return new sh(a,_3(r,c),{pos:e.reduce((h,f)=>f.hasResult()?Math.min(h,f.from):h,1e8),create:kpe,above:s.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(e){return new sh(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new sh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Hv{constructor(e,n,r){this.active=e,this.id=n,this.open=r}static start(){return new Hv(Ape,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,r=n.facet(jn),s=(r.override||n.languageDataAt("autocomplete",bc(n)).map(dpe)).map(c=>(this.active.find(f=>f.source==c)||new Xi(c,this.active.some(f=>f.state!=0)?1:0)).update(e,r));s.length==this.active.length&&s.every((c,h)=>c==this.active[h])&&(s=this.active);let o=this.open,a=e.effects.some(c=>c.is(TT));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(c=>c.hasResult()&&e.changes.touchesRange(c.from,c.to))||!Spe(s,this.active)||a?o=sh.build(s,n,this.id,o,r,a):o&&o.disabled&&!s.some(c=>c.isPending)&&(o=null),!o&&s.every(c=>!c.isPending)&&s.some(c=>c.hasResult())&&(s=s.map(c=>c.hasResult()?new Xi(c.source,0):c));for(let c of e.effects)c.is(W7)&&(o=o&&o.setSelected(c.value,this.id));return s==this.active&&o==this.open?this:new Hv(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?_pe:Cpe}}function Spe(t,e){if(t==e)return!0;for(let n=0,r=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;r<e.length&&!e[r].hasResult();)r++;let i=n==t.length,s=r==e.length;if(i||s)return i==s;if(t[n++].result!=e[r++].result)return!1}}const _pe={"aria-autocomplete":"list"},Cpe={};function _3(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const Ape=[];function H7(t,e){if(t.isUserEvent("input.complete")){let r=t.annotation(U7);if(r&&e.activateOnCompletion(r))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Xi{constructor(e,n,r=!1){this.source=e,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(e,n){let r=H7(e,n),i=this;(r&8||r&16&&this.touches(e))&&(i=new Xi(i.source,0)),r&4&&i.state==0&&(i=new Xi(this.source,1)),i=i.updateFor(e,r);for(let s of e.effects)if(s.is(Uv))i=new Xi(i.source,1,s.value);else if(s.is(mm))i=new Xi(i.source,0);else if(s.is(TT))for(let o of s.value)o.source==i.source&&(i=o);return i}updateFor(e,n){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(bc(e.state))}}class _h extends Xi{constructor(e,n,r,i,s,o){super(e,3,n),this.limit=r,this.result=i,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,n){var r;if(!(n&3))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),a=bc(e.state);if(a>o||!i||n&2&&(bc(e.startState)==this.from||a<this.limit))return new Xi(this.source,n&4?1:0);let c=e.changes.mapPos(this.limit);return Epe(i.validFor,e.state,s,o)?new _h(this.source,this.explicit,c,i,s,o):i.update&&(i=i.update(i,s,o,new z7(e.state,a,!1)))?new _h(this.source,this.explicit,c,i,i.from,(r=i.to)!==null&&r!==void 0?r:bc(e.state)):new Xi(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new _h(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Xi(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function Epe(t,e,n,r){if(!t)return!1;let i=e.sliceDoc(n,r);return typeof t=="function"?t(i,n,r,e):V7(t,!0).test(i)}const TT=Ze.define({map(t,e){return t.map(n=>n.map(e))}}),W7=Ze.define(),Gr=Zn.define({create(){return Hv.start()},update(t,e){return t.update(e)},provide:t=>[dT.from(t,e=>e.tooltip),_e.contentAttributes.from(t,e=>e.attrs)]});function RT(t,e){const n=e.completion.apply||e.completion.label;let r=t.state.field(Gr).active.find(i=>i.source==e.source);return r instanceof _h?(typeof n=="string"?t.dispatch({...fpe(t.state,n,r.from,r.to),annotations:U7.of(e.completion)}):n(t,e.completion,r.from,r.to),!0):!1}const kpe=vpe(Gr,RT);function Uy(t,e="option"){return n=>{let r=n.state.field(Gr,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(jn).interactionDelay)return!1;let i=1,s;e=="page"&&(s=RV(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,a=r.open.selected>-1?r.open.selected+i*(t?1:-1):t?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),n.dispatch({effects:W7.of(a)}),!0}}const Tpe=t=>{let e=t.state.field(Gr,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(jn).interactionDelay?!1:RT(t,e.open.options[e.open.selected])},Y_=t=>t.state.field(Gr,!1)?(t.dispatch({effects:Uv.of(!0)}),!0):!1,Rpe=t=>{let e=t.state.field(Gr,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:mm.of(null)}),!0)};class Mpe{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ope=50,Ppe=1e3,Dpe=yn.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(Gr).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(Gr),n=t.state.facet(jn);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Gr)==e)return;let r=t.transactions.some(s=>{let o=H7(s,n);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(r||o.context.abortOnDocChange&&t.docChanged||o.updates.length+t.transactions.length>Ope&&Date.now()-o.time>Ppe){for(let a of o.context.abortListeners)try{a()}catch(c){Kr(this.view.state,c)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(s=>s.effects.some(o=>o.is(Uv)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of t.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(Gr);for(let n of e.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(jn).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=bc(e),r=new z7(e,n,t.explicit,this.view),i=new Mpe(t,r);this.running.push(i),Promise.resolve(t.source(r)).then(s=>{i.context.aborted||(i.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:mm.of(null)}),Kr(this.view.state,s)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(jn).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(jn),r=this.view.state.field(Gr);for(let i=0;i<this.running.length;i++){let s=this.running[i];if(s.done===void 0)continue;if(this.running.splice(i--,1),s.done){let a=bc(s.updates.length?s.updates[0].startState:this.view.state),c=Math.min(a,s.done.from+(s.active.explicit?0:1)),h=new _h(s.active.source,s.active.explicit,c,s.done,s.done.from,(t=s.done.to)!==null&&t!==void 0?t:a);for(let f of s.updates)h=h.update(f,n);if(h.hasResult()){e.push(h);continue}}let o=r.active.find(a=>a.source==s.active.source);if(o&&o.isPending)if(s.done==null){let a=new Xi(s.active.source,0);for(let c of s.updates)a=a.update(c,n);a.isPending||e.push(a)}else this.startQuery(o)}(e.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:TT.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(Gr,!1);if(e&&e.tooltip&&this.view.state.facet(jn).closeOnBlur){let n=e.open&&RV(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:mm.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Uv.of(!1)}),20),this.composing=0}}}),Ipe=typeof navigator=="object"&&/Win/.test(navigator.platform),Lpe=$c.highest(_e.domEventHandlers({keydown(t,e){let n=e.state.field(Gr,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(Ipe&&t.altKey)||t.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(o=>o.source==r.source),s=r.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&RT(e,r),!1}})),Npe=_e.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"''"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),gm={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},fc=Ze.define({map(t,e){let n=e.mapPos(t,-1,Mr.TrackAfter);return n??void 0}}),MT=new class extends Ec{};MT.startSide=1;MT.endSide=-1;const q7=Zn.define({create(){return ft.empty},update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of e.effects)n.is(fc)&&(t=t.update({add:[MT.range(n.value,n.value+1)]}));return t}});function $pe(){return[Bpe,q7]}const X_="()[]{}<>«»»«[]{}";function G7(t){for(let e=0;e<X_.length;e+=2)if(X_.charCodeAt(e)==t)return X_.charAt(e+1);return Qk(t<128?t:t+1)}function K7(t,e){return t.languageDataAt("closeBrackets",e)[0]||gm}const jpe=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Bpe=_e.inputHandler.of((t,e,n,r)=>{if((jpe?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let i=t.state.selection.main;if(r.length>2||r.length==2&&to(Wr(r,0))==1||e!=i.from||n!=i.to)return!1;let s=Vpe(t.state,r);return s?(t.dispatch(s),!0):!1}),Fpe=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=K7(t,t.selection.main.head).brackets||gm.brackets,i=null,s=t.changeByRange(o=>{if(o.empty){let a=Upe(t.doc,o.head);for(let c of r)if(c==a&&px(t.doc,o.head)==G7(Wr(c,0)))return{changes:{from:o.head-c.length,to:o.head+c.length},range:fe.cursor(o.head-c.length)}}return{range:i=o}});return i||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},zpe=[{key:"Backspace",run:Fpe}];function Vpe(t,e){let n=K7(t,t.selection.main.head),r=n.brackets||gm.brackets;for(let i of r){let s=G7(Wr(i,0));if(e==i)return s==i?qpe(t,i,r.indexOf(i+i+i)>-1,n):Hpe(t,i,s,n.before||gm.before);if(e==s&&Y7(t,t.selection.main.from))return Wpe(t,i,s)}return null}function Y7(t,e){let n=!1;return t.field(q7).between(0,t.doc.length,r=>{r==e&&(n=!0)}),n}function px(t,e){let n=t.sliceString(e,e+2);return n.slice(0,to(Wr(n,0)))}function Upe(t,e){let n=t.sliceString(e-2,e);return to(Wr(n,0))==n.length?n:n.slice(1)}function Hpe(t,e,n,r){let i=null,s=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:fc.of(o.to+e.length),range:fe.range(o.anchor+e.length,o.head+e.length)};let a=px(t.doc,o.head);return!a||/\s/.test(a)||r.indexOf(a)>-1?{changes:{insert:e+n,from:o.head},effects:fc.of(o.head+e.length),range:fe.cursor(o.head+e.length)}:{range:i=o}});return i?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Wpe(t,e,n){let r=null,i=t.changeByRange(s=>s.empty&&px(t.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:fe.cursor(s.head+n.length)}:r={range:s});return r?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function qpe(t,e,n,r){let i=r.stringPrefixes||gm.stringPrefixes,s=null,o=t.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:fc.of(a.to+e.length),range:fe.range(a.anchor+e.length,a.head+e.length)};let c=a.head,h=px(t.doc,c),f;if(h==e){if(C3(t,c))return{changes:{insert:e+e,from:c},effects:fc.of(c+e.length),range:fe.cursor(c+e.length)};if(Y7(t,c)){let m=n&&t.sliceDoc(c,c+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:c,to:c+m.length,insert:m},range:fe.cursor(c+m.length)}}}else{if(n&&t.sliceDoc(c-2*e.length,c)==e+e&&(f=A3(t,c-2*e.length,i))>-1&&C3(t,f))return{changes:{insert:e+e+e+e,from:c},effects:fc.of(c+e.length),range:fe.cursor(c+e.length)};if(t.charCategorizer(c)(h)!=Vt.Word&&A3(t,c,i)>-1&&!Gpe(t,c,e,i))return{changes:{insert:e+e,from:c},effects:fc.of(c+e.length),range:fe.cursor(c+e.length)}}return{range:s=a}});return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function C3(t,e){let n=br(t).resolveInner(e+1);return n.parent&&n.from==e}function Gpe(t,e,n,r){let i=br(t).resolveInner(e,-1),s=r.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=t.sliceDoc(i.from,Math.min(i.to,i.from+n.length+s)),c=a.indexOf(n);if(!c||c>-1&&r.indexOf(a.slice(0,c))>-1){let f=i.firstChild;for(;f&&f.from==i.from&&f.to-f.from>n.length+c;){if(t.sliceDoc(f.to-n.length,f.to)==n)return!1;f=f.firstChild}return!0}let h=i.to==e&&i.parent;if(!h)break;i=h}return!1}function A3(t,e,n){let r=t.charCategorizer(e);if(r(t.sliceDoc(e-1,e))!=Vt.Word)return e;for(let i of n){let s=e-i.length;if(t.sliceDoc(s,e)==i&&r(t.sliceDoc(s-1,s))!=Vt.Word)return s}return-1}function Kpe(t={}){return[Lpe,Gr,jn.of(t),Dpe,Ype,Npe]}const X7=[{key:"Ctrl-Space",run:Y_},{mac:"Alt-`",run:Y_},{mac:"Alt-i",run:Y_},{key:"Escape",run:Rpe},{key:"ArrowDown",run:Uy(!0)},{key:"ArrowUp",run:Uy(!1)},{key:"PageDown",run:Uy(!0,"page")},{key:"PageUp",run:Uy(!1,"page")},{key:"Enter",run:Tpe}],Ype=$c.highest(hT.computeN([jn],t=>t.facet(jn).defaultKeymap?[X7]:[]));class E3{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class ac{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet(ym).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((f,d)=>f.from-d.from||f.to-d.to),o=new Xo,a=[],c=0;for(let f=0;;){let d=f==s.length?null:s[f];if(!d&&!a.length)break;let m,y;for(a.length?(m=c,y=a.reduce((w,S)=>Math.min(w,S.to),d&&d.from>m?d.from:1e8)):(m=d.from,y=d.to,a.push(d),f++);f<s.length;){let w=s[f];if(w.from==m&&(w.to>w.from||w.to==m))a.push(w),f++,y=Math.min(w.to,y);else{y=Math.min(w.from,y);break}}let b=lme(a);if(a.some(w=>w.from==w.to||w.from==w.to-1&&r.doc.lineAt(w.from).to==w.from))o.add(m,m,He.widget({widget:new ime(b),diagnostics:a.slice()}));else{let w=a.reduce((S,_)=>_.markClass?S+" "+_.markClass:S,"");o.add(m,y,He.mark({class:"cm-lintRange cm-lintRange-"+b+w,diagnostics:a.slice(),inclusiveEnd:a.some(S=>S.to>y)}))}c=y;for(let w=0;w<a.length;w++)a[w].to<=c&&a.splice(w--,1)}let h=o.finish();return new ac(h,n,Bh(h))}}function Bh(t,e=null,n=0){let r=null;return t.between(n,1e9,(i,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new E3(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new E3(r.from,s,r.diagnostic)}}),r}function Xpe(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(ym).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(J7))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function Jpe(t,e){return t.field(Ai,!1)?e:e.concat(Ze.appendConfig.of(cme))}const J7=Ze.define(),OT=Ze.define(),Q7=Ze.define(),Ai=Zn.define({create(){return new ac(He.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,i=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);r=Bh(n,t.selected.diagnostic,s)||Bh(n,null,s)}!n.size&&i&&e.state.facet(ym).autoPanel&&(i=null),t=new ac(n,i,r)}for(let n of e.effects)if(n.is(J7)){let r=e.state.facet(ym).autoPanel?n.value.length?bm.open:null:t.panel;t=ac.init(n.value,r,e.state)}else n.is(OT)?t=new ac(t.diagnostics,n.value?bm.open:null,t.selected):n.is(Q7)&&(t=new ac(t.diagnostics,t.panel,n.value));return t},provide:t=>[hm.from(t,e=>e.panel),_e.decorations.from(t,e=>e.diagnostics)]}),Qpe=He.mark({class:"cm-lintRange cm-lintRange-active"});function Zpe(t,e,n){let{diagnostics:r}=t.state.field(Ai),i,s=-1,o=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(c,h,{spec:f})=>{if(e>=c&&e<=h&&(c==h||(e>c||n>0)&&(e<h||n<0)))return i=f.diagnostics,s=c,o=h,!1});let a=t.state.facet(ym).tooltipFilter;return i&&a&&(i=a(i,t.state)),i?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create(){return{dom:eme(t,i)}}}:null}function eme(t,e){return kt("ul",{class:"cm-tooltip-lint"},e.map(n=>eU(t,n,!1)))}const tme=t=>{let e=t.state.field(Ai,!1);(!e||!e.panel)&&t.dispatch({effects:Jpe(t.state,[OT.of(!0)])});let n=um(t,bm.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},k3=t=>{let e=t.state.field(Ai,!1);return!e||!e.panel?!1:(t.dispatch({effects:OT.of(!1)}),!0)},nme=t=>{let e=t.state.field(Ai,!1);if(!e)return!1;let n=t.state.selection.main,r=e.diagnostics.iter(n.to+1);return!r.value&&(r=e.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to)?!1:(t.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},rme=[{key:"Mod-Shift-m",run:tme,preventDefault:!0},{key:"F8",run:nme}],ym=Ce.define({combine(t){return Object.assign({sources:t.map(e=>e.source).filter(e=>e!=null)},wo(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n}))}});function Z7(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;r<n.length;r++){let i=n[r];if(/[a-zA-Z]/.test(i)&&!e.some(s=>s.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function eU(t,e,n){var r;let i=n?Z7(e.actions):[];return kt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},kt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let a=!1,c=m=>{if(m.preventDefault(),a)return;a=!0;let y=Bh(t.state.field(Ai).diagnostics,e);y&&s.apply(t,y.from,y.to)},{name:h}=s,f=i[o]?h.indexOf(i[o]):-1,d=f<0?h:[h.slice(0,f),kt("u",h.slice(f,f+1)),h.slice(f+1)];return kt("button",{type:"button",class:"cm-diagnosticAction",onclick:c,onmousedown:c,"aria-label":` Action: ${h}${f<0?"":` (access key "${i[o]})"`}.`},d)}),e.source&&kt("div",{class:"cm-diagnosticSource"},e.source))}class ime extends _l{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return kt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class T3{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=eU(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class bm{constructor(e){this.view=e,this.items=[];let n=i=>{if(i.keyCode==27)k3(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=Z7(s.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==i.keyCode){let c=Bh(this.view.state.field(Ai).diagnostics,s);c&&s.actions[a].apply(e,c.from,c.to)}}else return;i.preventDefault()},r=i=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(i.target)&&this.moveSelection(s)};this.list=kt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=kt("div",{class:"cm-panel-lint"},this.list,kt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>k3(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Ai).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(Ai),r=0,i=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(a,c,{spec:h})=>{for(let f of h.diagnostics){if(o.has(f))continue;o.add(f);let d=-1,m;for(let y=r;y<this.items.length;y++)if(this.items[y].diagnostic==f){d=y;break}d<0?(m=new T3(this.view,f),this.items.splice(r,0,m),i=!0):(m=this.items[d],d>r&&(this.items.splice(r,d-r),i=!0)),n&&m.diagnostic==n.diagnostic?m.dom.hasAttribute("aria-selected")||(m.dom.setAttribute("aria-selected","true"),s=m):m.dom.hasAttribute("aria-selected")&&m.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new T3(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:c})=>{let h=c.height/this.list.offsetHeight;a.top<c.top?this.list.scrollTop-=(c.top-a.top)/h:a.bottom>c.bottom&&(this.list.scrollTop+=(a.bottom-c.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(Ai),r=Bh(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:Q7.of(r)})}static open(e){return new bm(e)}}function sme(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function Hy(t){return sme(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const ome=_e.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Hy("#d11")},".cm-lintRange-warning":{backgroundImage:Hy("orange")},".cm-lintRange-info":{backgroundImage:Hy("#999")},".cm-lintRange-hint":{backgroundImage:Hy("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function ame(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function lme(t){let e="hint",n=1;for(let r of t){let i=ame(r.severity);i>n&&(n=i,e=r.severity)}return e}const cme=[Ai,_e.decorations.compute([Ai],t=>{let{selected:e,panel:n}=t.field(Ai);return!e||!n||e.from==e.to?He.none:He.set([Qpe.range(e.from,e.to)])}),the(Zpe,{hideOn:Xpe}),ome],ume=[fhe(),mhe(),Pue(),Dfe(),sfe(),xue(),Eue(),ht.allowMultipleSelections.of(!0),Whe(),afe(ufe,{fallback:!0}),yfe(),$pe(),Kpe(),Hue(),Gue(),jue(),zde(),hT.of([...zpe,...Lde,...ope,...Vfe,...tfe,...X7,...rme])];var R3={};class Wv{constructor(e,n,r,i,s,o,a,c,h,f=0,d){this.p=e,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=a,this.bufferBase=c,this.curContext=h,this.lookAhead=f,this.parent=d}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let i=e.parser.context;return new Wv(e,[],n,r,r,0,[],0,i?new M3(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let a=s.dynamicPrecedence(i);if(a&&(this.score+=a),r==0){this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(i,this.reducePos);return}let c=this.stack.length-(r-1)*3-(e&262144?6:0),h=c?this.stack[c-2]:this.p.ranges[0].from,f=this.reducePos-h;f>=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=f):this.p.lastBigReductionSize<f&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=f));let d=c?this.stack[c-1]:0,m=this.bufferBase+this.buffer.length-d;if(i<s.minRepeatTerm||e&131072){let y=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,h,y,m+4,!0)}if(e&262144)this.state=this.stack[c];else{let y=this.stack[c-3];this.state=s.getGoto(y,i,!0)}for(;this.stack.length>c;)this.stack.pop();this.reduceContext(i,h)}storeNode(e,n,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,a=this.buffer.length;if(a==0&&o.parent&&(a=o.bufferBase-o.parent.bufferBase,o=o.parent),a>0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(n==r)return;if(o.buffer[a-2]>=n){o.buffer[a-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,n,r,i);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0){let a=!1;for(let c=o;c>0&&this.buffer[c-2]>r;c-=4)if(this.buffer[c-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,n,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;(i>this.pos||n<=o.maxNode)&&(this.pos=i,o.stateFlag(s,1)||(this.reducePos=i)),this.pushState(s,r),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}else this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4)}apply(e,n,r,i){e&65536?this.reduce(e):this.shift(e,n,r,i)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),i=e.bufferBase+n;for(;e&&i==e.bufferBase;)e=e.parent;return new Wv(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new hme(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if((r&65536)==0)return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,o;s<n.length;s+=2)(o=n[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&i.push(n[s],o);if(this.stack.length<120)for(let s=0;i.length<8&&s<n.length;s+=2){let o=n[s+1];i.some((a,c)=>c&1&&a==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i<n.length&&r.length<4;i+=2){let s=n[i+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[i],this.pos),o.reducePos=this.pos,o.score-=200,r.push(o)}return r}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!e.validAction(this.state,n)){let r=n>>19,i=n&65535,s=this.stack.length-r*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-s;if(a>1){let c=o&65535,h=this.stack.length-a*3;if(h>=0&&e.getGoto(this.stack[h],c,!1)>=0)return a<<19|65536|c}}else{let a=r(o,s+1);if(a!=null)return a}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new M3(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class M3{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class hme{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=i}}class qv{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new qv(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new qv(this.stack,this.pos,this.index)}}function Wy(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,i=0;r<t.length;){let s=0;for(;;){let o=t.charCodeAt(r++),a=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let c=o-32;if(c>=46&&(c-=46,a=!0),s+=c,a)break;s*=46}n?n[i++]=s:n=new e(s)}return n}class Fb{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const O3=new Fb;class fme{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=O3,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;s<r.from;){if(!i)return null;let o=this.ranges[--i];s-=r.from-o.to,r=o}for(;n<0?s>r.to:s>=r.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-r.to,r=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n<this.chunk.length)r=this.pos+e,i=this.chunk.charCodeAt(n);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(r=s,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let o=this.rangeIndex,a=this.range;for(;a.to<=r;)a=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=r}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=O3,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class Ch{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;dme(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Ch.prototype.contextual=Ch.prototype.fallback=Ch.prototype.extend=!1;Ch.prototype.fallback=Ch.prototype.extend=!1;function dme(t,e,n,r,i,s){let o=0,a=1<<r,{dialect:c}=n.p.parser;e:for(;(a&t[o])!=0;){let h=t[o+1];for(let y=o+3;y<h;y+=2)if((t[y+1]&a)>0){let b=t[y];if(c.allows(b)&&(e.token.value==-1||e.token.value==b||pme(b,e.token.value,i,s))){e.acceptToken(b);break}}let f=e.next,d=0,m=t[o+2];if(e.next<0&&m>d&&t[h+m*3-3]==65535){o=t[h+m*3-1];continue e}for(;d<m;){let y=d+m>>1,b=h+y+(y<<1),w=t[b],S=t[b+1]||65536;if(f<w)m=y;else if(f>=S)d=y+1;else{o=t[b+2],e.advance();continue e}}break}}function P3(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function pme(t,e,n,r){let i=P3(n,r,e);return i<0||P3(n,r,t)<i}const pi=typeof process<"u"&&R3&&/\bparse\b/.test(R3.LOG);let J_=null;function D3(t,e,n){let r=t.cursor($n.IncludeAnonymous);for(r.moveTo(e);;)if(!(n<0?r.childBefore(e):r.childAfter(e)))for(;;){if((n<0?r.to<e:r.from>e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class mme{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?D3(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?D3(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let r=this.trees[n],i=this.index[n];if(i==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=r.children[i],o=this.start[n]+r.positions[i];if(o>e)return this.nextStart=o,null;if(s instanceof mn){if(o==e){if(o<this.safeFrom)return null;let a=o+s.length;if(a<=this.safeTo){let c=s.prop(it.lookAhead);if(!c||a+c<this.fragment.to)return s}}this.index[n]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class gme{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new Fb)}getActions(e){let n=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,c=0;for(let h=0;h<s.length;h++){if((1<<h&o)==0)continue;let f=s[h],d=this.tokens[h];if(!(r&&!f.fallback)&&((f.contextual||d.start!=e.pos||d.mask!=o||d.context!=a)&&(this.updateCachedToken(d,f,e),d.mask=o,d.context=a),d.lookAhead>d.end+25&&(c=Math.max(d.lookAhead,c)),d.value!=0)){let m=n;if(d.extended>-1&&(n=this.addActions(e,d.extended,d.end,n)),n=this.addActions(e,d.value,d.end,n),!f.extend&&(r=d,n>m))break}}for(;this.actions.length>n;)this.actions.pop();return c&&e.setLookAhead(c),!r&&e.pos==this.stream.end&&(r=new Fb,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new Fb,{pos:r,p:i}=e;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(e,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let a=s.specializers[o](this.stream.read(e.start,e.end),r);if(a>=0&&r.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,n,r,i){for(let s=0;s<i;s+=3)if(this.actions[s]==e)return i;return this.actions[i++]=e,this.actions[i++]=n,this.actions[i++]=r,i}addActions(e,n,r,i){let{state:s}=e,{parser:o}=e.p,{data:a}=o;for(let c=0;c<2;c++)for(let h=o.stateSlot(s,c?2:1);;h+=3){if(a[h]==65535)if(a[h+1]==1)h=Ho(a,h+2);else{i==0&&a[h+1]==2&&(i=this.putAction(Ho(a,h+2),n,r,i));break}a[h]==n&&(i=this.putAction(Ho(a,h+1),n,r,i))}return i}}class yme{constructor(e,n,r,i){this.parser=e,this.input=n,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new fme(n,i),this.tokens=new gme(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[Wv.start(this,e.top[0],s)],this.fragments=r.length&&this.stream.end-s>e.bufferLength*4?new mme(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],i,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let a=e[o];for(;;){if(this.tokens.mainToken=null,a.pos>n)r.push(a);else{if(this.advanceStack(a,r,e))continue;{i||(i=[],s=[]),i.push(a);let c=this.tokens.getMainToken(a);s.push(c.value,c.end)}}break}}if(!r.length){let o=i&&vme(i);if(o)return pi&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw pi&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return pi&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((a,c)=>c.score-a.score);r.length>o;)r.pop();r.some(a=>a.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let o=0;o<r.length-1;o++){let a=r[o];for(let c=o+1;c<r.length;c++){let h=r[c];if(a.sameState(h)||a.buffer.length>500&&h.buffer.length>500)if((a.score-h.score||a.buffer.length-h.buffer.length)>0)r.splice(c--,1);else{r.splice(o--,1);continue e}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let o=1;o<r.length;o++)r[o].pos<this.minStackPos&&(this.minStackPos=r[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,r){let i=e.pos,{parser:s}=this,o=pi?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,f=h?e.curContext.hash:0;for(let d=this.fragments.nodeAt(i);d;){let m=this.parser.nodeSet.types[d.type.id]==d.type?s.getGoto(e.state,d.type.id):-1;if(m>-1&&d.length&&(!h||(d.prop(it.contextHash)||0)==f))return e.useNode(d,m),pi&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(d.type.id)})`),!0;if(!(d instanceof mn)||d.children.length==0||d.positions[0]>0)break;let y=d.children[0];if(y instanceof mn&&d.positions[0]==0)d=y;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),pi&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let c=this.tokens.getActions(e);for(let h=0;h<c.length;){let f=c[h++],d=c[h++],m=c[h++],y=h==c.length||!r,b=y?e:e.split(),w=this.tokens.mainToken;if(b.apply(f,d,w?w.start:b.pos,m),pi&&console.log(o+this.stackID(b)+` (via ${(f&65536)==0?"shift":`reduce of ${s.getName(f&65535)}`} for ${s.getName(d)} @ ${i}${b==e?"":", split"})`),y)return!0;b.pos>i?n.push(b):r.push(b)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return I3(e,n),!0}}runRecovery(e,n,r){let i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o],c=n[o<<1],h=n[(o<<1)+1],f=pi?this.stackID(a)+" -> ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),pi&&console.log(f+this.stackID(a)+" (restarted)"),this.advanceFully(a,r))))continue;let d=a.split(),m=f;for(let y=0;d.forceReduce()&&y<10&&(pi&&console.log(m+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,r));y++)pi&&(m=this.stackID(d)+" -> ");for(let y of a.recoverByInsert(c))pi&&console.log(f+this.stackID(y)+" (via recover-insert)"),this.advanceFully(y,r);this.stream.end>a.pos?(h==a.pos&&(h++,c=0),a.recoverByDelete(c,h),pi&&console.log(f+this.stackID(a)+` (via recover-delete ${this.parser.getName(c)})`),I3(a,r)):(!i||i.score<a.score)&&(i=a)}return i}stackToTree(e){return e.close(),mn.build({buffer:qv.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(J_||(J_=new WeakMap)).get(e);return n||J_.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function I3(t,e){for(let n=0;n<e.length;n++){let r=e[n];if(r.pos==t.pos&&r.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class bme{constructor(e,n,r){this.source=e,this.flags=n,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class Gv extends $V{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<e.repeatNodeCount;a++)n.push("");let r=Object.keys(e.topRules).map(a=>e.topRules[a][1]),i=[];for(let a=0;a<n.length;a++)i.push([]);function s(a,c,h){i[a].push([c,c.deserialize(String(h))])}if(e.nodeProps)for(let a of e.nodeProps){let c=a[0];typeof c=="string"&&(c=it[c]);for(let h=1;h<a.length;){let f=a[h++];if(f>=0)s(f,c,a[h++]);else{let d=a[h+-f];for(let m=-f;m>0;m--)s(a[h++],c,d);h++}}}this.nodeSet=new pT(n.map((a,c)=>Zr.define({name:c>=this.minRepeatTerm?void 0:a,id:c,props:i[c],top:r.indexOf(c)>-1,error:c==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(c)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=DV;let o=Wy(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(L3),this.states=Wy(e.states,Uint32Array),this.data=Wy(e.stateData),this.goto=Wy(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Ch(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let i=new yme(this,e,n,r);for(let s of this.wrappers)i=s(i,e,n,r);return i}getGoto(e,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],a=o&1,c=i[s++];if(a&&r)return c;for(let h=s+(o>>1);s<h;s++)if(i[s]==e)return c;if(a)return-1}}hasAction(e,n){let r=this.data;for(let i=0;i<2;i++)for(let s=this.stateSlot(e,i?2:1),o;;s+=3){if((o=r[s])==65535)if(r[s+1]==1)o=r[s=Ho(r,s+2)];else{if(r[s+1]==2)return Ho(r,s+2);break}if(o==n||o==0)return Ho(r,s+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),i=r?n(r):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Ho(this.data,s+2);else break;i=n(Ho(this.data,s+1))}return i}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Ho(this.data,r+2);else break;if((this.data[r+2]&1)==0){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(e){let n=Object.assign(Object.create(Gv.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(a=>a.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=L3(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;s<n.length;s++)if(!r[s])for(let o=this.dialects[n[s]],a;(a=this.data[o++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[a]=1;return new bme(e,r,i)}static deserialize(e){return new Gv(e)}}function Ho(t,e){return t[e]|t[e+1]<<16}function vme(t){let e=null;for(let n of t){let r=n.p.stoppedAt;(n.pos==n.p.stream.end||r!=null&&n.pos>r)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function L3(t){if(t.external){let e=t.extend?1:0;return(n,r)=>t.external(n,r)<<1|e}return t.get}const wme=jV({String:we.string,Number:we.number,"True False":we.bool,PropertyName:we.propertyName,Null:we.null,", :":we.separator,"[ ]":we.squareBracket,"{ }":we.brace}),xme=Gv.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[wme],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),Sme=Pv.define({name:"json",parser:xme.configure({props:[VV.add({Object:e3({except:/^\s*\}/}),Array:e3({except:/^\s*\]/})}),HV.add({"Object Array":Ghe})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function _me(){return new Lhe(Sme)}const Cme=({open:t,onClose:e})=>{const{t:n}=vt(),{saveConfig:r,getConfig:i}=Rs(),s=de.useRef(null),o=de.useRef(null),[a,c]=de.useState(""),[h,f]=de.useState(""),[d,m]=de.useState(!0),y=de.useCallback(w=>{try{return JSON.parse(w).mcpServers?(m(!0),f(""),!0):(m(!1),f(n("ConfigurationError")),!1)}catch(S){return f(`Invalid JSON format
${S instanceof Error?S.message:"Unknown error"}`),m(!1),!1}},[n]);de.useEffect(()=>{if(!t)return;const w=()=>{if(s.current&&!o.current){const S=JSON.stringify(i(),null,2);c(S),y(S);const _=ht.create({doc:S,extensions:[ume,_me(),_e.updateListener.of(A=>{if(A.docChanged){const E=A.state.doc.toString();c(E),y(E)}}),_e.theme({"&":{height:"200px",maxHeight:"200px"},".cm-content":{padding:"10px"},".cm-focused":{outline:"none"},".cm-editor":{height:"200px",maxHeight:"200px"},".cm-scroller":{fontFamily:"monospace",height:"200px",maxHeight:"200px"},".cm-gutters":{height:"200px",maxHeight:"200px"}})]});o.current=new _e({state:_,parent:s.current})}else setTimeout(w,100)};return setTimeout(w,50),()=>{o.current&&(o.current.destroy(),o.current=null)}},[t,n,y,i]);const b=de.useCallback(()=>{d&&(r(JSON.parse(a)),e())},[d,r,a,e]);return de.useEffect(()=>{if(!t)return;const w=S=>{S.key==="Enter"&&(S.ctrlKey||S.metaKey)&&(S.preventDefault(),b())};return window.addEventListener("keydown",w),()=>{window.removeEventListener("keydown",w)}},[t,b]),C.jsx(xl,{open:t,onOpenChange:()=>{},children:C.jsxs(Sl,{header:n("EditConfiguration"),onClose:e,className:"w-[564px] min-h-[400px]",children:[C.jsx("div",{className:"flex flex-col gap-[8px] min-h-[280px] pt-[8px] pb-[16px]",children:C.jsxs("div",{className:"flex flex-col gap-[8px] min-h-[256px] p-[12px] bg-[var(--servers-edit-config-json-background-color)] rounded-[12px]",children:[C.jsxs("div",{className:"flex flex-row justify-between",children:[C.jsx("p",{className:"font-bold text-[14px] leading-[20px] text-[var(--servers-edit-config-json-header-color)]",children:n("EnterYourJSONConfiguration")}),C.jsx("p",{className:"font-normal text-[14px] leading-[20px] text-[var(--servers-edit-config-json-lang-color)]",children:"json"})]}),C.jsx("div",{ref:s,className:"border border-[var(--servers-edit-config-json-editor-border-color)] bg-[var(--servers-edit-config-json-editor-background-color)] rounded-[4px] overflow-hidden h-full max-h-full"}),h?C.jsx("p",{className:"text-[var(--text-negative)] font-normal text-[14px] leading-[20px] whitespace-pre-line",children:h}):null]})}),C.jsxs("div",{className:"flex flex-row items-center justify-end gap-[16px] h-[64px] border-t border-[var(--servers-edit-config-buttons-border-color)] mx-[-32px] px-[32px]",children:[C.jsx(en,{onClick:e,variant:"default",children:n("Cancel")}),C.jsx(en,{disabled:!d,onClick:b,children:n("Save")})]})]})})},Ame="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5%209.3018C6.08346%206.49281%208.80901%204.5%2012%204.5C16.1421%204.5%2019.5%207.85786%2019.5%2012C19.5%2016.1421%2016.1421%2019.5%2012%2019.5C8.80901%2019.5%206.08346%2017.5072%205%2014.6982M7.5%209.5H4.5V6.5'%20stroke='%23383838'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Eme="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.5%2017.5H14.5M7.5%209.5H16.5M5.5%205.5H14.5M9.5%2013.5H18.5'%20stroke='%23383838'%20stroke-miterlimit='1.41421'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",kme=({type:t,open:e,onClose:n})=>{const{t:r}=vt(),[i,s]=de.useState([]),{getCustomServersLogs:o}=Rs();de.useEffect(()=>{const c=async()=>{const f=o();s(f[t])};c();const h=setInterval(()=>{c()},500);return()=>clearInterval(h)},[o,t]);const a=async()=>{await navigator.clipboard.writeText(i.join(`
`)),n()};return C.jsx(xl,{open:e,onOpenChange:()=>{},children:C.jsxs(Sl,{header:`${t} ${r("logs").toLowerCase()}`,onClose:n,className:"w-[720px] h-[520px]",children:[C.jsx("div",{className:"flex flex-col gap-[8px] h-[400px] py-[8px]",children:C.jsx("div",{className:"flex flex-col border h-[384px] border-[var(--servers-logs-dialog-border-color)] overflow-y-auto rounded-[8px]",children:i.map(c=>C.jsx("p",{className:"text-[var(--servers-logs-dialog-log-color)] font-normal text-[14px] leading-[20px]",children:c},c))})}),C.jsxs("div",{className:"flex flex-row items-center justify-end gap-[16px] h-[64px] border-t border-[var(--servers-edit-config-buttons-border-color)] mx-[-32px] px-[32px]",children:[C.jsx(en,{onClick:a,variant:"default",children:r("CopyToClipboard")}),C.jsx(en,{onClick:n,children:r("Close")})]})]})})},Tme=({name:t,onClose:e})=>{const{t:n}=vt(),{deleteCustomServer:r}=Rs(),i=de.useCallback(()=>{r(t),e()},[r,t,e]);return de.useEffect(()=>{const s=o=>{o.key==="Enter"&&(o.preventDefault(),i())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[i]),C.jsx(xl,{open:!0,children:C.jsx(Sl,{header:n("Warning"),onClose:e,withWarningIcon:!0,children:C.jsxs("div",{className:"flex flex-col justify-between h-full",children:[C.jsx("p",{className:"select-none h-[40px] flex items-center text-[12px] leading-[16px] text-[var(--text-normal)]",children:n("WantDeleteServer")}),C.jsxs("div",{className:"flex flex-row justify-end items-center gap-[8px] h-[48px]",children:[C.jsx(en,{variant:"default",onClick:e,children:n("No")}),C.jsx(en,{onClick:i,children:n("Yes")})]})]})})})},N3=({name:t,mcpItems:e,isLoading:n,isSystem:r,disableEnable:i})=>{const{t:s}=vt(),[o,a]=de.useState(!1),[c,h]=de.useState(!1),[f,d]=de.useState(!1),[m,y]=de.useState(!1),[b,w]=de.useState(!1),S=de.useRef(null),{changeToolStatus:_}=Rs(),A=()=>{e.filter(M=>!M.enabled).forEach(M=>{_(t,M.name,!0)})},E=()=>{e.filter(M=>M.enabled).forEach(M=>{_(t,M.name,!1)})},P=()=>d(!0);de.useEffect(()=>{n&&a(!1)},[n]),de.useEffect(()=>{const M=setInterval(()=>{y(Qt.getCustomServersStoped().includes(t))},1e3);return()=>clearInterval(M)},[t]);const O=m?!1:n;return C.jsxs("div",{className:"flex flex-col",children:[C.jsxs("div",{className:`h-[36px] px-[8px] rounded-[4px] flex items-center justify-between ${O?"":"cursor-pointer"} ${o?"bg-[var(--servers-available-tools-item-active-background-color)]":"bg-[var(--servers-available-tools-item-background-color)]"} ${!n&&!o?"hover:bg-[var(--servers-available-tools-item-hover-background-color)]":""}`,onClick:()=>{n||c||e.length===0||a(M=>!M)},children:[C.jsxs("div",{className:"flex items-center gap-[8px]",children:[C.jsx(gt,{iconName:qk,size:24,disableHover:!0,isStroke:!0,isTransform:o}),C.jsx("p",{className:"text-[var(--servers-available-tools-item-name-color)]",children:t}),!O&&m?C.jsx(gt,{iconName:G9,size:16,disableHover:!0,noColor:!0}):null,n?null:C.jsxs("p",{className:"font-normal text-[14px] text-[var(--servers-available-tools-sub-header-color)]",children:[C.jsx("span",{className:"text-[var(--servers-available-tools-current-tool-color)]",children:e.filter(M=>M.enabled).length}),"/",e.length," ",s("ToolsEnabled")]})]}),C.jsx("div",{ref:S,children:O?C.jsx(Gm,{}):C.jsx(Nc,{onOpenChange:h,trigger:C.jsx(gt,{iconName:$k,size:20,isActive:c,insideElement:!0}),items:[...e.length===0?[]:[{text:s("EnableAllTools"),onClick:A,withSpace:!r},{text:s("DisableAllTools"),onClick:E,withSpace:!r},...r?[]:[{text:"",onClick:()=>{},isSeparator:!0}]],...r?[]:[{icon:C.jsx(gt,{iconName:Ame,size:20,disableHover:!0,isStroke:!0}),text:s("Restart"),onClick:()=>{Qt.restartCustomServer(t)}},{icon:C.jsx(gt,{iconName:Eme,size:20,disableHover:!0,isStroke:!0}),text:s("Logs"),onClick:P},{text:"",onClick:()=>{},isSeparator:!0},{icon:C.jsx(gt,{iconName:jk,size:20,disableHover:!0}),text:s("Delete"),onClick:()=>{w(!0)}}]],side:"right",align:"start",sideOffset:0,containerRef:S.current})})]}),o?C.jsx("div",{className:"flex flex-col gap-[12px] mt-[4px]",children:e.map(M=>{const D=r?M.description?.split(". ")[0]+".":M.description;return C.jsxs("div",{className:"rounded-[4px] cursor-pointer flex flex-col ps-[40px] pe-[8px] hover:bg-[var(--servers-available-tools-item-hover-background-color)]",onClick:()=>{_(t,M.name,!M.enabled)},children:[C.jsxs("div",{className:"flex items-center justify-between w-full",children:[C.jsx("p",{className:"text-[var(--servers-available-tools-item-name-color)]",children:M.name}),C.jsx(zF,{checked:M.enabled??!1,disabled:i&&!M.enabled,onCheckedChange:()=>{}})]}),D&&C.jsxs(em,{children:[C.jsx(tm,{asChild:!0,children:C.jsx("p",{className:"text-[13px] leading-[18px] line-clamp-2 text-[var(--servers-available-tools-sub-header-color)]",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:D})}),C.jsx(nm,{children:C.jsx("div",{className:"max-w-[300px]",children:D})})]})]},M.name)})}):null,f?C.jsx(kme,{type:t,open:f,onClose:()=>d(!1)}):null,b?C.jsx(Tme,{name:t,onClose:()=>w(!1)}):null]})},Rme=()=>{const{t}=vt(),[e,n]=de.useState({}),{servers:r,tools:i,webSearchEnabled:s}=Rs(),[o,a]=de.useState(s?i.length-2:i.length);de.useEffect(()=>{a(s?i.length-2:i.length)},[i.length,s]),de.useEffect(()=>{n(Qt.getCustomServers());const h=setInterval(()=>{n(Qt.getCustomServers())},1e3);return()=>clearInterval(h)},[]);const c=s?i.length>=Tb:i.length>=bh;return C.jsxs("div",{className:"w-[640px] h-[560px] border border-[var(--servers-available-tools-border-color)] rounded-[8px] flex flex-col",children:[C.jsxs("div",{className:"min-h-[44px] h-[44px] flex items-center justify-between px-[16px] border-b border-[var(--servers-available-tools-border-color)]",children:[C.jsx("p",{className:"font-bold text-[14px] leading-[20px] text-[var(--servers-available-tools-header-color)]",children:t("AvailableTools")}),C.jsxs("p",{className:"font-normal text-[14px] leading-[20px] text-[var(--servers-available-tools-sub-header-color)]",children:[C.jsx("span",{className:"text-[var(--servers-available-tools-current-tool-color)]",children:o}),"/",bh," ",t("Tools")]})]}),C.jsxs("div",{className:"flex flex-col gap-[8px] pt-[12px] pb-[16px] px-[8px] overflow-y-auto",children:[C.jsx(N3,{name:"desktop-editor",mcpItems:r["desktop-editor"]??[],isLoading:!1,isSystem:!0,disableEnable:c}),Object.keys(e).map(h=>C.jsx(N3,{name:h,mcpItems:r[h]??[],isLoading:!r[h]?.length,isSystem:!1,disableEnable:c},h))]})]})},Mme=()=>{const{t}=vt(),[e,n]=de.useState(!1);return C.jsxs(C.Fragment,{children:[C.jsxs("div",{className:"flex flex-col gap-[16px] mt-[16px] pb-[32px]",children:[C.jsx("p",{className:"font-normal text-[14px] leading-[20px] text-[var(--servers-description-color)]",children:t("CustomServersDescription")}),C.jsx(en,{className:"w-fit",onClick:()=>n(!0),children:t("EditConfiguration")}),C.jsx(Rme,{})]}),C.jsx(Cme,{open:e,onClose:()=>n(!1)})]})},Ome=()=>{const{t}=vt(),[e,n]=de.useState(""),[r,i]=de.useState(""),[s,o]=de.useState(!1);de.useEffect(()=>{const h=Qt.getWebSearchData();h&&(n(h.provider),i(h.key),o(!0))},[]);const a=de.useCallback(()=>{!e||!r||(Qt.setWebSearchData({provider:e,key:r}),o(!0))},[e,r]),c=()=>{n(""),i(""),o(!1),Qt.setWebSearchData(null)};return de.useEffect(()=>{const h=f=>{f.key==="Enter"&&(f.preventDefault(),a())};return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[a]),C.jsx(C.Fragment,{children:C.jsxs("div",{className:"flex flex-col gap-[16px] mt-[16px]",children:[C.jsx("p",{className:"font-normal text-[14px] leading-[20px] text-[var(--servers-description-color)]",children:t("WebSearchDescription")}),C.jsxs("div",{className:"flex flex-col gap-[16px]",children:[C.jsx(io,{header:t("WebSearchEngine"),children:C.jsx(ex,{className:"w-[260px]",value:e||t("SelectEngine"),items:s?[]:[{text:"Exa",id:"Exa",onClick:()=>n("Exa")}]})}),C.jsx(io,{header:t("APIKey"),children:C.jsx(co,{className:"w-[260px]",type:"password",value:r,disabled:s,onChange:h=>i(h.target.value)})})]}),C.jsxs("div",{className:"flex flex-row gap-[8px]",children:[C.jsx(en,{className:"w-fit",onClick:a,disabled:!e||!r||s,children:t("Save")}),C.jsx(en,{className:"w-fit",disabled:!s,onClick:c,variant:"default",children:t("ResetSettings")})]})]})})},Pme=()=>{const{t}=vt(),[e,n]=de.useState("providers"),{providers:r}=rs(),i=C.jsxs("div",{className:"flex flex-col gap-[16px] select-none",children:[null,["providers"].map(s=>{const o=s==="wallet";return C.jsxs("div",{className:"flex gap-[12px]",children:[null,C.jsxs("div",{className:"select-none flex flex-col gap-[12px]",children:[C.jsxs("div",{className:"flex flex-col gap-[4px]",children:[null,C.jsx("p",{className:"text-[14px] leading-[20px] text-[var(--settings-description-color)]",children:t(o?"ONLYOFFICEWalletDescription":"AIProvidersDescription")})]}),o?C.jsx(gle,{isActive:e===s}):C.jsx(mle,{isActive:e===s})]})]},s)})]});return C.jsx(C.Fragment,{children:C.jsx("div",{className:"flex justify-center",children:C.jsxs("div",{className:"flex flex-col gap-[16px] box-border max-w-[640px] w-[640px] mx-[32px] mt-[32px]",children:[C.jsx("h1",{className:"select-none font-bold text-[20px] leading-[28px] text-[var(--settings-header-color)]",children:t("Settings")}),C.jsx(xse,{items:[{value:"ai-settings",label:t("Connection"),content:i},{value:"mcp-servers",label:t("MCPServers"),content:C.jsx(Mme,{}),disabled:!r.length},{value:"web-search",label:t("WebSearch"),content:C.jsx(Ome,{}),disabled:!r.length}]})]})})})},tU=k.createContext({});function Dme(t){const e=k.useRef(null);return e.current===null&&(e.current=t()),e.current}const PT=typeof window<"u",Ime=PT?k.useLayoutEffect:k.useEffect,DT=k.createContext(null);function IT(t,e){t.indexOf(e)===-1&&t.push(e)}function LT(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Zo=(t,e,n)=>n>e?e:n<t?t:n;let NT=()=>{};const ea={},nU=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function rU(t){return typeof t=="object"&&t!==null}const iU=t=>/^0[^.\s]+$/u.test(t);function $T(t){let e;return()=>(e===void 0&&(e=t()),e)}const es=t=>t,Lme=(t,e)=>n=>e(t(n)),eg=(...t)=>t.reduce(Lme),vm=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r};class jT{constructor(){this.subscriptions=[]}add(e){return IT(this.subscriptions,e),()=>LT(this.subscriptions,e)}notify(e,n,r){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,r);else for(let s=0;s<i;s++){const o=this.subscriptions[s];o&&o(e,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const ho=t=>t*1e3,fo=t=>t/1e3;function sU(t,e){return e?t*(1e3/e):0}const oU=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Nme=1e-7,$me=12;function jme(t,e,n,r,i){let s,o,a=0;do o=e+(n-e)/2,s=oU(o,r,i)-t,s>0?n=o:e=o;while(Math.abs(s)>Nme&&++a<$me);return o}function tg(t,e,n,r){if(t===e&&n===r)return es;const i=s=>jme(s,0,1,t,n);return s=>s===0||s===1?s:oU(i(s),e,r)}const aU=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,lU=t=>e=>1-t(1-e),cU=tg(.33,1.53,.69,.99),BT=lU(cU),uU=aU(BT),hU=t=>(t*=2)<1?.5*BT(t):.5*(2-Math.pow(2,-10*(t-1))),FT=t=>1-Math.sin(Math.acos(t)),fU=lU(FT),dU=aU(FT),Bme=tg(.42,0,1,1),Fme=tg(0,0,.58,1),pU=tg(.42,0,.58,1),zme=t=>Array.isArray(t)&&typeof t[0]!="number",mU=t=>Array.isArray(t)&&typeof t[0]=="number",Vme={linear:es,easeIn:Bme,easeInOut:pU,easeOut:Fme,circIn:FT,circInOut:dU,circOut:fU,backIn:BT,backInOut:uU,backOut:cU,anticipate:hU},Ume=t=>typeof t=="string",$3=t=>{if(mU(t)){NT(t.length===4);const[e,n,r,i]=t;return tg(e,n,r,i)}else if(Ume(t))return Vme[t];return t},qy=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Hme(t,e){let n=new Set,r=new Set,i=!1,s=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(f){o.has(f)&&(h.schedule(f),t()),f(a)}const h={schedule:(f,d=!1,m=!1)=>{const b=m&&i?n:r;return d&&o.add(f),b.has(f)||b.add(f),f},cancel:f=>{r.delete(f),o.delete(f)},process:f=>{if(a=f,i){s=!0;return}i=!0,[n,r]=[r,n],n.forEach(c),n.clear(),i=!1,s&&(s=!1,h.process(f))}};return h}const Wme=40;function gU(t,e){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,o=qy.reduce((E,P)=>(E[P]=Hme(s),E),{}),{setup:a,read:c,resolveKeyframes:h,preUpdate:f,update:d,preRender:m,render:y,postRender:b}=o,w=()=>{const E=ea.useManualTiming?i.timestamp:performance.now();n=!1,ea.useManualTiming||(i.delta=r?1e3/60:Math.max(Math.min(E-i.timestamp,Wme),1)),i.timestamp=E,i.isProcessing=!0,a.process(i),c.process(i),h.process(i),f.process(i),d.process(i),m.process(i),y.process(i),b.process(i),i.isProcessing=!1,n&&e&&(r=!1,t(w))},S=()=>{n=!0,r=!0,i.isProcessing||t(w)};return{schedule:qy.reduce((E,P)=>{const O=o[P];return E[P]=(M,D=!1,$=!1)=>(n||S(),O.schedule(M,D,$)),E},{}),cancel:E=>{for(let P=0;P<qy.length;P++)o[qy[P]].cancel(E)},state:i,steps:o}}const{schedule:Ut,cancel:vl,state:Hn,steps:Q_}=gU(typeof requestAnimationFrame<"u"?requestAnimationFrame:es,!0);let zb;function qme(){zb=void 0}const Xr={now:()=>(zb===void 0&&Xr.set(Hn.isProcessing||ea.useManualTiming?Hn.timestamp:performance.now()),zb),set:t=>{zb=t,queueMicrotask(qme)}},yU=t=>e=>typeof e=="string"&&e.startsWith(t),zT=yU("--"),Gme=yU("var(--"),VT=t=>Gme(t)?Kme.test(t.split("/*")[0].trim()):!1,Kme=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,tf={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},wm={...tf,transform:t=>Zo(0,1,t)},Gy={...tf,default:1},Op=t=>Math.round(t*1e5)/1e5,UT=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Yme(t){return t==null}const Xme=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,HT=(t,e)=>n=>!!(typeof n=="string"&&Xme.test(n)&&n.startsWith(t)||e&&!Yme(n)&&Object.prototype.hasOwnProperty.call(n,e)),bU=(t,e,n)=>r=>{if(typeof r!="string")return r;const[i,s,o,a]=r.match(UT);return{[t]:parseFloat(i),[e]:parseFloat(s),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Jme=t=>Zo(0,255,t),Z_={...tf,transform:t=>Math.round(Jme(t))},dc={test:HT("rgb","red"),parse:bU("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+Z_.transform(t)+", "+Z_.transform(e)+", "+Z_.transform(n)+", "+Op(wm.transform(r))+")"};function Qme(t){let e="",n="",r="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),r=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),r=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,r+=r,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const NA={test:HT("#"),parse:Qme,transform:dc.transform},ng=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Ya=ng("deg"),po=ng("%"),qe=ng("px"),Zme=ng("vh"),ege=ng("vw"),j3={...po,parse:t=>po.parse(t)/100,transform:t=>po.transform(t*100)},oh={test:HT("hsl","hue"),parse:bU("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+po.transform(Op(e))+", "+po.transform(Op(n))+", "+Op(wm.transform(r))+")"},fn={test:t=>dc.test(t)||NA.test(t)||oh.test(t),parse:t=>dc.test(t)?dc.parse(t):oh.test(t)?oh.parse(t):NA.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?dc.transform(t):oh.transform(t),getAnimatableNone:t=>{const e=fn.parse(t);return e.alpha=0,fn.transform(e)}},tge=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function nge(t){return isNaN(t)&&typeof t=="string"&&(t.match(UT)?.length||0)+(t.match(tge)?.length||0)>0}const vU="number",wU="color",rge="var",ige="var(",B3="${}",sge=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function xm(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},i=[];let s=0;const a=e.replace(sge,c=>(fn.test(c)?(r.color.push(s),i.push(wU),n.push(fn.parse(c))):c.startsWith(ige)?(r.var.push(s),i.push(rge),n.push(c)):(r.number.push(s),i.push(vU),n.push(parseFloat(c))),++s,B3)).split(B3);return{values:n,split:a,indexes:r,types:i}}function xU(t){return xm(t).values}function SU(t){const{split:e,types:n}=xm(t),r=e.length;return i=>{let s="";for(let o=0;o<r;o++)if(s+=e[o],i[o]!==void 0){const a=n[o];a===vU?s+=Op(i[o]):a===wU?s+=fn.transform(i[o]):s+=i[o]}return s}}const oge=t=>typeof t=="number"?0:fn.test(t)?fn.getAnimatableNone(t):t;function age(t){const e=xU(t);return SU(t)(e.map(oge))}const wl={test:nge,parse:xU,createTransformer:SU,getAnimatableNone:age};function e2(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function lge({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,e/=100,n/=100;let i=0,s=0,o=0;if(!e)i=s=o=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=e2(c,a,t+1/3),s=e2(c,a,t),o=e2(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(o*255),alpha:r}}function Kv(t,e){return n=>n>0?e:t}const Gt=(t,e,n)=>t+(e-t)*n,t2=(t,e,n)=>{const r=t*t,i=n*(e*e-r)+r;return i<0?0:Math.sqrt(i)},cge=[NA,dc,oh],uge=t=>cge.find(e=>e.test(t));function F3(t){const e=uge(t);if(!e)return!1;let n=e.parse(t);return e===oh&&(n=lge(n)),n}const z3=(t,e)=>{const n=F3(t),r=F3(e);if(!n||!r)return Kv(t,e);const i={...n};return s=>(i.red=t2(n.red,r.red,s),i.green=t2(n.green,r.green,s),i.blue=t2(n.blue,r.blue,s),i.alpha=Gt(n.alpha,r.alpha,s),dc.transform(i))},$A=new Set(["none","hidden"]);function hge(t,e){return $A.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function fge(t,e){return n=>Gt(t,e,n)}function WT(t){return typeof t=="number"?fge:typeof t=="string"?VT(t)?Kv:fn.test(t)?z3:mge:Array.isArray(t)?_U:typeof t=="object"?fn.test(t)?z3:dge:Kv}function _U(t,e){const n=[...t],r=n.length,i=t.map((s,o)=>WT(s)(s,e[o]));return s=>{for(let o=0;o<r;o++)n[o]=i[o](s);return n}}function dge(t,e){const n={...t,...e},r={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(r[i]=WT(t[i])(t[i],e[i]));return i=>{for(const s in r)n[s]=r[s](i);return n}}function pge(t,e){const n=[],r={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const s=e.types[i],o=t.indexes[s][r[s]],a=t.values[o]??0;n[i]=a,r[s]++}return n}const mge=(t,e)=>{const n=wl.createTransformer(e),r=xm(t),i=xm(e);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?$A.has(t)&&!i.values.length||$A.has(e)&&!r.values.length?hge(t,e):eg(_U(pge(r,i),i.values),n):Kv(t,e)};function CU(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?Gt(t,e,n):WT(t)(t,e)}const gge=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>Ut.update(e,n),stop:()=>vl(e),now:()=>Hn.isProcessing?Hn.timestamp:Xr.now()}},AU=(t,e,n=10)=>{let r="";const i=Math.max(Math.round(e/n),2);for(let s=0;s<i;s++)r+=Math.round(t(s/(i-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},Yv=2e4;function qT(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<Yv;)e+=n,r=t.next(e);return e>=Yv?1/0:e}function yge(t,e=100,n){const r=n({...t,keyframes:[0,e]}),i=Math.min(qT(r),Yv);return{type:"keyframes",ease:s=>r.next(i*s).value/e,duration:fo(i)}}const bge=5;function EU(t,e,n){const r=Math.max(e-bge,0);return sU(n-t(r),e-r)}const Zt={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},n2=.001;function vge({duration:t=Zt.duration,bounce:e=Zt.bounce,velocity:n=Zt.velocity,mass:r=Zt.mass}){let i,s,o=1-e;o=Zo(Zt.minDamping,Zt.maxDamping,o),t=Zo(Zt.minDuration,Zt.maxDuration,fo(t)),o<1?(i=h=>{const f=h*o,d=f*t,m=f-n,y=jA(h,o),b=Math.exp(-d);return n2-m/y*b},s=h=>{const d=h*o*t,m=d*n+n,y=Math.pow(o,2)*Math.pow(h,2)*t,b=Math.exp(-d),w=jA(Math.pow(h,2),o);return(-i(h)+n2>0?-1:1)*((m-y)*b)/w}):(i=h=>{const f=Math.exp(-h*t),d=(h-n)*t+1;return-n2+f*d},s=h=>{const f=Math.exp(-h*t),d=(n-h)*(t*t);return f*d});const a=5/t,c=xge(i,s,a);if(t=ho(t),isNaN(c))return{stiffness:Zt.stiffness,damping:Zt.damping,duration:t};{const h=Math.pow(c,2)*r;return{stiffness:h,damping:o*2*Math.sqrt(r*h),duration:t}}}const wge=12;function xge(t,e,n){let r=n;for(let i=1;i<wge;i++)r=r-t(r)/e(r);return r}function jA(t,e){return t*Math.sqrt(1-e*e)}const Sge=["duration","bounce"],_ge=["stiffness","damping","mass"];function V3(t,e){return e.some(n=>t[n]!==void 0)}function Cge(t){let e={velocity:Zt.velocity,stiffness:Zt.stiffness,damping:Zt.damping,mass:Zt.mass,isResolvedFromDuration:!1,...t};if(!V3(t,_ge)&&V3(t,Sge))if(t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,s=2*Zo(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:Zt.mass,stiffness:i,damping:s}}else{const n=vge(t);e={...e,...n,mass:Zt.mass},e.isResolvedFromDuration=!0}return e}function Xv(t=Zt.visualDuration,e=Zt.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:r,restDelta:i}=n;const s=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:s},{stiffness:c,damping:h,mass:f,duration:d,velocity:m,isResolvedFromDuration:y}=Cge({...n,velocity:-fo(n.velocity||0)}),b=m||0,w=h/(2*Math.sqrt(c*f)),S=o-s,_=fo(Math.sqrt(c/f)),A=Math.abs(S)<5;r||(r=A?Zt.restSpeed.granular:Zt.restSpeed.default),i||(i=A?Zt.restDelta.granular:Zt.restDelta.default);let E;if(w<1){const O=jA(_,w);E=M=>{const D=Math.exp(-w*_*M);return o-D*((b+w*_*S)/O*Math.sin(O*M)+S*Math.cos(O*M))}}else if(w===1)E=O=>o-Math.exp(-_*O)*(S+(b+_*S)*O);else{const O=_*Math.sqrt(w*w-1);E=M=>{const D=Math.exp(-w*_*M),$=Math.min(O*M,300);return o-D*((b+w*_*S)*Math.sinh($)+O*S*Math.cosh($))/O}}const P={calculatedDuration:y&&d||null,next:O=>{const M=E(O);if(y)a.done=O>=d;else{let D=O===0?b:0;w<1&&(D=O===0?ho(b):EU(E,O,M));const $=Math.abs(D)<=r,F=Math.abs(o-M)<=i;a.done=$&&F}return a.value=a.done?o:M,a},toString:()=>{const O=Math.min(qT(P),Yv),M=AU(D=>P.next(O*D).value,O,30);return O+"ms "+M},toTransition:()=>{}};return P}Xv.applyToOptions=t=>{const e=yge(t,100,Xv);return t.ease=e.ease,t.duration=ho(e.duration),t.type="keyframes",t};function BA({keyframes:t,velocity:e=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:s=500,modifyTarget:o,min:a,max:c,restDelta:h=.5,restSpeed:f}){const d=t[0],m={done:!1,value:d},y=$=>a!==void 0&&$<a||c!==void 0&&$>c,b=$=>a===void 0?c:c===void 0||Math.abs(a-$)<Math.abs(c-$)?a:c;let w=n*e;const S=d+w,_=o===void 0?S:o(S);_!==S&&(w=_-d);const A=$=>-w*Math.exp(-$/r),E=$=>_+A($),P=$=>{const F=A($),N=E($);m.done=Math.abs(F)<=h,m.value=m.done?_:N};let O,M;const D=$=>{y(m.value)&&(O=$,M=Xv({keyframes:[m.value,b(m.value)],velocity:EU(E,$,m.value),damping:i,stiffness:s,restDelta:h,restSpeed:f}))};return D(0),{calculatedDuration:null,next:$=>{let F=!1;return!M&&O===void 0&&(F=!0,P($),D($)),O!==void 0&&$>=O?M.next($-O):(!F&&P($),m)}}}function Age(t,e,n){const r=[],i=n||ea.mix||CU,s=t.length-1;for(let o=0;o<s;o++){let a=i(t[o],t[o+1]);if(e){const c=Array.isArray(e)?e[o]||es:e;a=eg(c,a)}r.push(a)}return r}function Ege(t,e,{clamp:n=!0,ease:r,mixer:i}={}){const s=t.length;if(NT(s===e.length),s===1)return()=>e[0];if(s===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[s-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Age(e,r,i),c=a.length,h=f=>{if(o&&f<t[0])return e[0];let d=0;if(c>1)for(;d<t.length-2&&!(f<t[d+1]);d++);const m=vm(t[d],t[d+1],f);return a[d](m)};return n?f=>h(Zo(t[0],t[s-1],f)):h}function kge(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const i=vm(0,e,r);t.push(Gt(n,1,i))}}function Tge(t){const e=[0];return kge(e,t.length-1),e}function Rge(t,e){return t.map(n=>n*e)}function Mge(t,e){return t.map(()=>e||pU).splice(0,t.length-1)}function Pp({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const i=zme(r)?r.map($3):$3(r),s={done:!1,value:e[0]},o=Rge(n&&n.length===e.length?n:Tge(e),t),a=Ege(o,e,{ease:Array.isArray(i)?i:Mge(e,i)});return{calculatedDuration:t,next:c=>(s.value=a(c),s.done=c>=t,s)}}const Oge=t=>t!==null;function GT(t,{repeat:e,repeatType:n="loop"},r,i=1){const s=t.filter(Oge),a=i<0||e&&n!=="loop"&&e%2===1?0:s.length-1;return!a||r===void 0?s[a]:r}const Pge={decay:BA,inertia:BA,tween:Pp,keyframes:Pp,spring:Xv};function kU(t){typeof t.type=="string"&&(t.type=Pge[t.type])}class KT{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const Dge=t=>t/100;class YT extends KT{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==Xr.now()&&this.tick(Xr.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;kU(e);const{type:n=Pp,repeat:r=0,repeatDelay:i=0,repeatType:s,velocity:o=0}=e;let{keyframes:a}=e;const c=n||Pp;c!==Pp&&typeof a[0]!="number"&&(this.mixKeyframes=eg(Dge,CU(a[0],a[1])),a=[0,100]);const h=c({...e,keyframes:a});s==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-o})),h.calculatedDuration===null&&(h.calculatedDuration=qT(h));const{calculatedDuration:f}=h;this.calculatedDuration=f,this.resolvedDuration=f+i,this.totalDuration=this.resolvedDuration*(r+1)-i,this.generator=h}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:r,totalDuration:i,mixKeyframes:s,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return r.next(0);const{delay:h=0,keyframes:f,repeat:d,repeatType:m,repeatDelay:y,type:b,onUpdate:w,finalKeyframe:S}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const _=this.currentTime-h*(this.playbackSpeed>=0?1:-1),A=this.playbackSpeed>=0?_<0:_>i;this.currentTime=Math.max(_,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let E=this.currentTime,P=r;if(d){const $=Math.min(this.currentTime,i)/a;let F=Math.floor($),N=$%1;!N&&$>=1&&(N=1),N===1&&F--,F=Math.min(F,d+1),!!(F%2)&&(m==="reverse"?(N=1-N,y&&(N-=y/a)):m==="mirror"&&(P=o)),E=Zo(0,1,N)*a}const O=A?{done:!1,value:f[0]}:P.next(E);s&&(O.value=s(O.value));let{done:M}=O;!A&&c!==null&&(M=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const D=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&M);return D&&b!==BA&&(O.value=GT(f,this.options,S,this.speed)),w&&w(O.value),D&&this.finish(),O}then(e,n){return this.finished.then(e,n)}get duration(){return fo(this.calculatedDuration)}get time(){return fo(this.currentTime)}set time(e){e=ho(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(Xr.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=fo(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=gge,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Xr.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function Ige(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const pc=t=>t*180/Math.PI,FA=t=>{const e=pc(Math.atan2(t[1],t[0]));return zA(e)},Lge={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:FA,rotateZ:FA,skewX:t=>pc(Math.atan(t[1])),skewY:t=>pc(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},zA=t=>(t=t%360,t<0&&(t+=360),t),U3=FA,H3=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),W3=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Nge={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:H3,scaleY:W3,scale:t=>(H3(t)+W3(t))/2,rotateX:t=>zA(pc(Math.atan2(t[6],t[5]))),rotateY:t=>zA(pc(Math.atan2(-t[2],t[0]))),rotateZ:U3,rotate:U3,skewX:t=>pc(Math.atan(t[4])),skewY:t=>pc(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function VA(t){return t.includes("scale")?1:0}function UA(t,e){if(!t||t==="none")return VA(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=Nge,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Lge,i=a}if(!i)return VA(e);const s=r[e],o=i[1].split(",").map(jge);return typeof s=="function"?s(o):o[s]}const $ge=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return UA(n,e)};function jge(t){return parseFloat(t.trim())}const nf=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],rf=new Set(nf),q3=t=>t===tf||t===qe,Bge=new Set(["x","y","z"]),Fge=nf.filter(t=>!Bge.has(t));function zge(t){const e=[];return Fge.forEach(n=>{const r=t.getValue(n);r!==void 0&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),e}const vc={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>UA(e,"x"),y:(t,{transform:e})=>UA(e,"y")};vc.translateX=vc.x;vc.translateY=vc.y;const wc=new Set;let HA=!1,WA=!1,qA=!1;function TU(){if(WA){const t=Array.from(wc).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),n=new Map;e.forEach(r=>{const i=zge(r);i.length&&(n.set(r,i),r.render())}),t.forEach(r=>r.measureInitialState()),e.forEach(r=>{r.render();const i=n.get(r);i&&i.forEach(([s,o])=>{r.getValue(s)?.set(o)})}),t.forEach(r=>r.measureEndState()),t.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}WA=!1,HA=!1,wc.forEach(t=>t.complete(qA)),wc.clear()}function RU(){wc.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(WA=!0)})}function Vge(){qA=!0,RU(),TU(),qA=!1}class XT{constructor(e,n,r,i,s,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=r,this.motionValue=i,this.element=s,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(wc.add(this),HA||(HA=!0,Ut.read(RU),Ut.resolveKeyframes(TU))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:r,motionValue:i}=this;if(e[0]===null){const s=i?.get(),o=e[e.length-1];if(s!==void 0)e[0]=s;else if(r&&n){const a=r.readValue(n,o);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=o),i&&s===void 0&&i.set(e[0])}Ige(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),wc.delete(this)}cancel(){this.state==="scheduled"&&(wc.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Uge=t=>t.startsWith("--");function Hge(t,e,n){Uge(e)?t.style.setProperty(e,n):t.style[e]=n}const Wge=$T(()=>window.ScrollTimeline!==void 0),qge={};function Gge(t,e){const n=$T(t);return()=>qge[e]??n()}const MU=Gge(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),pp=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,G3={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:pp([0,.65,.55,1]),circOut:pp([.55,0,1,.45]),backIn:pp([.31,.01,.66,-.59]),backOut:pp([.33,1.53,.69,.99])};function OU(t,e){if(t)return typeof t=="function"?MU()?AU(t,e):"ease-out":mU(t)?pp(t):Array.isArray(t)?t.map(n=>OU(n,e)||G3.easeOut):G3[t]}function Kge(t,e,n,{delay:r=0,duration:i=300,repeat:s=0,repeatType:o="loop",ease:a="easeOut",times:c}={},h=void 0){const f={[e]:n};c&&(f.offset=c);const d=OU(a,i);Array.isArray(d)&&(f.easing=d);const m={delay:r,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:s+1,direction:o==="reverse"?"alternate":"normal"};return h&&(m.pseudoElement=h),t.animate(f,m)}function PU(t){return typeof t=="function"&&"applyToOptions"in t}function Yge({type:t,...e}){return PU(t)&&MU()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Xge extends KT{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:r,keyframes:i,pseudoElement:s,allowFlatten:o=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!s,this.allowFlatten=o,this.options=e,NT(typeof e.type!="string");const h=Yge(e);this.animation=Kge(n,r,i,h,s),h.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!s){const f=GT(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(f):Hge(n,r,f),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return fo(Number(e))}get time(){return fo(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=ho(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&Wge()?(this.animation.timeline=e,es):n(this)}}const DU={anticipate:hU,backInOut:uU,circInOut:dU};function Jge(t){return t in DU}function Qge(t){typeof t.ease=="string"&&Jge(t.ease)&&(t.ease=DU[t.ease])}const K3=10;class Zge extends Xge{constructor(e){Qge(e),kU(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:r,onComplete:i,element:s,...o}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new YT({...o,autoplay:!1}),c=ho(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-K3).value,a.sample(c).value,K3),a.stop()}}const Y3=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(wl.test(t)||t==="0")&&!t.startsWith("url("));function e0e(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function t0e(t,e,n,r){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const s=t[t.length-1],o=Y3(i,e),a=Y3(s,e);return!o||!a?!1:e0e(t)||(n==="spring"||PU(n))&&r}function GA(t){t.duration=0,t.type}const n0e=new Set(["opacity","clipPath","filter","transform"]),r0e=$T(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function i0e(t){const{motionValue:e,name:n,repeatDelay:r,repeatType:i,damping:s,type:o}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:h}=e.owner.getProps();return r0e()&&n&&n0e.has(n)&&(n!=="transform"||!h)&&!c&&!r&&i!=="mirror"&&s!==0&&o!=="inertia"}const s0e=40;class o0e extends KT{constructor({autoplay:e=!0,delay:n=0,type:r="keyframes",repeat:i=0,repeatDelay:s=0,repeatType:o="loop",keyframes:a,name:c,motionValue:h,element:f,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Xr.now();const m={autoplay:e,delay:n,type:r,repeat:i,repeatDelay:s,repeatType:o,name:c,motionValue:h,element:f,...d},y=f?.KeyframeResolver||XT;this.keyframeResolver=new y(a,(b,w,S)=>this.onKeyframesResolved(b,w,m,!S),c,h,f),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,r,i){this.keyframeResolver=void 0;const{name:s,type:o,velocity:a,delay:c,isHandoff:h,onUpdate:f}=r;this.resolvedAt=Xr.now(),t0e(e,s,o,a)||((ea.instantAnimations||!c)&&f?.(GT(e,r,n)),e[0]=e[e.length-1],GA(r),r.repeat=0);const m={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>s0e?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:e},y=!h&&i0e(m)?new Zge({...m,element:m.motionValue.owner.current}):new YT(m);y.finished.then(()=>this.notifyFinished()).catch(es),this.pendingTimeline&&(this.stopTimeline=y.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=y}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Vge()),this._animation}get duration(){return this.animation.duration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const a0e=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function l0e(t){const e=a0e.exec(t);if(!e)return[,];const[,n,r,i]=e;return[`--${n??r}`,i]}function IU(t,e,n=1){const[r,i]=l0e(t);if(!r)return;const s=window.getComputedStyle(e).getPropertyValue(r);if(s){const o=s.trim();return nU(o)?parseFloat(o):o}return VT(i)?IU(i,e,n+1):i}function JT(t,e){return t?.[e]??t?.default??t}const LU=new Set(["width","height","top","left","right","bottom",...nf]),c0e={test:t=>t==="auto",parse:t=>t},NU=t=>e=>e.test(t),$U=[tf,qe,po,Ya,ege,Zme,c0e],X3=t=>$U.find(NU(t));function u0e(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||iU(t):!0}const h0e=new Set(["brightness","contrast","saturate","opacity"]);function f0e(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=n.match(UT)||[];if(!r)return t;const i=n.replace(r,"");let s=h0e.has(e)?1:0;return r!==n&&(s*=100),e+"("+s+i+")"}const d0e=/\b([a-z-]*)\(.*?\)/gu,KA={...wl,getAnimatableNone:t=>{const e=t.match(d0e);return e?e.map(f0e).join(" "):t}},J3={...tf,transform:Math.round},p0e={rotate:Ya,rotateX:Ya,rotateY:Ya,rotateZ:Ya,scale:Gy,scaleX:Gy,scaleY:Gy,scaleZ:Gy,skew:Ya,skewX:Ya,skewY:Ya,distance:qe,translateX:qe,translateY:qe,translateZ:qe,x:qe,y:qe,z:qe,perspective:qe,transformPerspective:qe,opacity:wm,originX:j3,originY:j3,originZ:qe},QT={borderWidth:qe,borderTopWidth:qe,borderRightWidth:qe,borderBottomWidth:qe,borderLeftWidth:qe,borderRadius:qe,radius:qe,borderTopLeftRadius:qe,borderTopRightRadius:qe,borderBottomRightRadius:qe,borderBottomLeftRadius:qe,width:qe,maxWidth:qe,height:qe,maxHeight:qe,top:qe,right:qe,bottom:qe,left:qe,padding:qe,paddingTop:qe,paddingRight:qe,paddingBottom:qe,paddingLeft:qe,margin:qe,marginTop:qe,marginRight:qe,marginBottom:qe,marginLeft:qe,backgroundPositionX:qe,backgroundPositionY:qe,...p0e,zIndex:J3,fillOpacity:wm,strokeOpacity:wm,numOctaves:J3},m0e={...QT,color:fn,backgroundColor:fn,outlineColor:fn,fill:fn,stroke:fn,borderColor:fn,borderTopColor:fn,borderRightColor:fn,borderBottomColor:fn,borderLeftColor:fn,filter:KA,WebkitFilter:KA},jU=t=>m0e[t];function BU(t,e){let n=jU(t);return n!==KA&&(n=wl),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const g0e=new Set(["auto","none","0"]);function y0e(t,e,n){let r=0,i;for(;r<t.length&&!i;){const s=t[r];typeof s=="string"&&!g0e.has(s)&&xm(s).values.length&&(i=t[r]),r++}if(i&&n)for(const s of e)t[s]=BU(n,i)}class b0e extends XT{constructor(e,n,r,i,s){super(e,n,r,i,s,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let h=e[c];if(typeof h=="string"&&(h=h.trim(),VT(h))){const f=IU(h,n.current);f!==void 0&&(e[c]=f),c===e.length-1&&(this.finalKeyframe=h)}}if(this.resolveNoneKeyframes(),!LU.has(r)||e.length!==2)return;const[i,s]=e,o=X3(i),a=X3(s);if(o!==a)if(q3(o)&&q3(a))for(let c=0;c<e.length;c++){const h=e[c];typeof h=="string"&&(e[c]=parseFloat(h))}else vc[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,r=[];for(let i=0;i<e.length;i++)(e[i]===null||u0e(e[i]))&&r.push(i);r.length&&y0e(e,r,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:r}=this;if(!e||!e.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=vc[r](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(r,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:r}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const s=r.length-1,o=r[s];r[s]=vc[n](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,c])=>{e.getValue(a).set(c)}),this.resolveNoneKeyframes()}}function v0e(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let r=document;const i=n?.[t]??r.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const FU=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function w0e(t){return rU(t)&&"offsetHeight"in t}const Q3=30,x0e=t=>!isNaN(parseFloat(t));class S0e{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const i=Xr.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const s of this.dependents)s.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=Xr.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=x0e(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new jT);const r=this.events[e].add(n);return e==="change"?()=>{r(),Ut.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=Xr.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Q3)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Q3);return sU(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Fh(t,e){return new S0e(t,e)}const{schedule:ZT}=gU(queueMicrotask,!1),ps={x:!1,y:!1};function zU(){return ps.x||ps.y}function _0e(t){return t==="x"||t==="y"?ps[t]?null:(ps[t]=!0,()=>{ps[t]=!1}):ps.x||ps.y?null:(ps.x=ps.y=!0,()=>{ps.x=ps.y=!1})}function VU(t,e){const n=v0e(t),r=new AbortController,i={passive:!0,...e,signal:r.signal};return[n,i,()=>r.abort()]}function Z3(t){return!(t.pointerType==="touch"||zU())}function C0e(t,e,n={}){const[r,i,s]=VU(t,n),o=a=>{if(!Z3(a))return;const{target:c}=a,h=e(c,a);if(typeof h!="function"||!c)return;const f=d=>{Z3(d)&&(h(d),c.removeEventListener("pointerleave",f))};c.addEventListener("pointerleave",f,i)};return r.forEach(a=>{a.addEventListener("pointerenter",o,i)}),s}const UU=(t,e)=>e?t===e?!0:UU(t,e.parentElement):!1,eR=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,A0e=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function E0e(t){return A0e.has(t.tagName)||t.tabIndex!==-1}const Vb=new WeakSet;function e4(t){return e=>{e.key==="Enter"&&t(e)}}function r2(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const k0e=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=e4(()=>{if(Vb.has(n))return;r2(n,"down");const i=e4(()=>{r2(n,"up")}),s=()=>r2(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",s,e)});n.addEventListener("keydown",r,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),e)};function t4(t){return eR(t)&&!zU()}function T0e(t,e,n={}){const[r,i,s]=VU(t,n),o=a=>{const c=a.currentTarget;if(!t4(a))return;Vb.add(c);const h=e(c,a),f=(y,b)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",m),Vb.has(c)&&Vb.delete(c),t4(y)&&typeof h=="function"&&h(y,{success:b})},d=y=>{f(y,c===window||c===document||n.useGlobalTarget||UU(c,y.target))},m=y=>{f(y,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",m,i)};return r.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),w0e(a)&&(a.addEventListener("focus",h=>k0e(h,i)),!E0e(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),s}function HU(t){return rU(t)&&"ownerSVGElement"in t}function R0e(t){return HU(t)&&t.tagName==="svg"}const mr=t=>!!(t&&t.getVelocity),M0e=[...$U,fn,wl],O0e=t=>M0e.find(NU(t)),WU=k.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function P0e(t=!0){const e=k.useContext(DT);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:i}=e,s=k.useId();k.useEffect(()=>{if(t)return i(s)},[t]);const o=k.useCallback(()=>t&&r&&r(s),[s,r,t]);return!n&&r?[!1,o]:[!0]}const qU=k.createContext({strict:!1}),n4={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},zh={};for(const t in n4)zh[t]={isEnabled:e=>n4[t].some(n=>!!e[n])};function D0e(t){for(const e in t)zh[e]={...zh[e],...t[e]}}const I0e=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function Jv(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||I0e.has(t)}let GU=t=>!Jv(t);function L0e(t){typeof t=="function"&&(GU=e=>e.startsWith("on")?!Jv(e):t(e))}try{L0e(require("@emotion/is-prop-valid").default)}catch{}function N0e(t,e,n){const r={};for(const i in t)i==="values"&&typeof t.values=="object"||(GU(i)||n===!0&&Jv(i)||!e&&!Jv(i)||t.draggable&&i.startsWith("onDrag"))&&(r[i]=t[i]);return r}const mx=k.createContext({});function gx(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Sm(t){return typeof t=="string"||Array.isArray(t)}const tR=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],nR=["initial",...tR];function yx(t){return gx(t.animate)||nR.some(e=>Sm(t[e]))}function KU(t){return!!(yx(t)||t.variants)}function $0e(t,e){if(yx(t)){const{initial:n,animate:r}=t;return{initial:n===!1||Sm(n)?n:void 0,animate:Sm(r)?r:void 0}}return t.inherit!==!1?e:{}}function j0e(t){const{initial:e,animate:n}=$0e(t,k.useContext(mx));return k.useMemo(()=>({initial:e,animate:n}),[r4(e),r4(n)])}function r4(t){return Array.isArray(t)?t.join(" "):t}const _m={};function B0e(t){for(const e in t)_m[e]=t[e],zT(e)&&(_m[e].isCSSVariable=!0)}function YU(t,{layout:e,layoutId:n}){return rf.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!_m[t]||t==="opacity")}const F0e={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},z0e=nf.length;function V0e(t,e,n){let r="",i=!0;for(let s=0;s<z0e;s++){const o=nf[s],a=t[o];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(o.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const h=FU(a,QT[o]);if(!c){i=!1;const f=F0e[o]||o;r+=`${f}(${h}) `}n&&(e[o]=h)}}return r=r.trim(),n?r=n(e,i?"":r):i&&(r="none"),r}function rR(t,e,n){const{style:r,vars:i,transformOrigin:s}=t;let o=!1,a=!1;for(const c in e){const h=e[c];if(rf.has(c)){o=!0;continue}else if(zT(c)){i[c]=h;continue}else{const f=FU(h,QT[c]);c.startsWith("origin")?(a=!0,s[c]=f):r[c]=f}}if(e.transform||(o||n?r.transform=V0e(e,t.transform,n):r.transform&&(r.transform="none")),a){const{originX:c="50%",originY:h="50%",originZ:f=0}=s;r.transformOrigin=`${c} ${h} ${f}`}}const iR=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function XU(t,e,n){for(const r in e)!mr(e[r])&&!YU(r,n)&&(t[r]=e[r])}function U0e({transformTemplate:t},e){return k.useMemo(()=>{const n=iR();return rR(n,e,t),Object.assign({},n.vars,n.style)},[e])}function H0e(t,e){const n=t.style||{},r={};return XU(r,n,t),Object.assign(r,U0e(t,e)),r}function W0e(t,e){const n={},r=H0e(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=r,n}const q0e={offset:"stroke-dashoffset",array:"stroke-dasharray"},G0e={offset:"strokeDashoffset",array:"strokeDasharray"};function K0e(t,e,n=1,r=0,i=!0){t.pathLength=1;const s=i?q0e:G0e;t[s.offset]=qe.transform(-r);const o=qe.transform(e),a=qe.transform(n);t[s.array]=`${o} ${a}`}function JU(t,{attrX:e,attrY:n,attrScale:r,pathLength:i,pathSpacing:s=1,pathOffset:o=0,...a},c,h,f){if(rR(t,a,h),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:m}=t;d.transform&&(m.transform=d.transform,delete d.transform),(m.transform||d.transformOrigin)&&(m.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),m.transform&&(m.transformBox=f?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&K0e(d,i,s,o,!1)}const QU=()=>({...iR(),attrs:{}}),ZU=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Y0e(t,e,n,r){const i=k.useMemo(()=>{const s=QU();return JU(s,e,ZU(r),t.transformTemplate,t.style),{...s.attrs,style:{...s.style}}},[e]);if(t.style){const s={};XU(s,t.style,t),i.style={...s,...i.style}}return i}const X0e=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function sR(t){return typeof t!="string"||t.includes("-")?!1:!!(X0e.indexOf(t)>-1||/[A-Z]/u.test(t))}function J0e(t,e,n,{latestValues:r},i,s=!1){const a=(sR(t)?Y0e:W0e)(e,r,i,t),c=N0e(e,typeof t=="string",s),h=t!==k.Fragment?{...c,...a,ref:n}:{},{children:f}=e,d=k.useMemo(()=>mr(f)?f.get():f,[f]);return k.createElement(t,{...h,children:d})}function i4(t){const e=[{},{}];return t?.values.forEach((n,r)=>{e[0][r]=n.get(),e[1][r]=n.getVelocity()}),e}function oR(t,e,n,r){if(typeof e=="function"){const[i,s]=i4(r);e=e(n!==void 0?n:t.custom,i,s)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,s]=i4(r);e=e(n!==void 0?n:t.custom,i,s)}return e}function Ub(t){return mr(t)?t.get():t}function Q0e({scrapeMotionValuesFromProps:t,createRenderState:e},n,r,i){return{latestValues:Z0e(n,r,i,t),renderState:e()}}function Z0e(t,e,n,r){const i={},s=r(t,{});for(const m in s)i[m]=Ub(s[m]);let{initial:o,animate:a}=t;const c=yx(t),h=KU(t);e&&h&&!c&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let f=n?n.initial===!1:!1;f=f||o===!1;const d=f?a:o;if(d&&typeof d!="boolean"&&!gx(d)){const m=Array.isArray(d)?d:[d];for(let y=0;y<m.length;y++){const b=oR(t,m[y]);if(b){const{transitionEnd:w,transition:S,..._}=b;for(const A in _){let E=_[A];if(Array.isArray(E)){const P=f?E.length-1:0;E=E[P]}E!==null&&(i[A]=E)}for(const A in w)i[A]=w[A]}}}return i}const eH=t=>(e,n)=>{const r=k.useContext(mx),i=k.useContext(DT),s=()=>Q0e(t,e,r,i);return n?s():Dme(s)};function aR(t,e,n){const{style:r}=t,i={};for(const s in r)(mr(r[s])||e.style&&mr(e.style[s])||YU(s,t)||n?.getValue(s)?.liveStyle!==void 0)&&(i[s]=r[s]);return i}const eye=eH({scrapeMotionValuesFromProps:aR,createRenderState:iR});function tH(t,e,n){const r=aR(t,e,n);for(const i in t)if(mr(t[i])||mr(e[i])){const s=nf.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[s]=t[i]}return r}const tye=eH({scrapeMotionValuesFromProps:tH,createRenderState:QU}),nye=Symbol.for("motionComponentSymbol");function ah(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function rye(t,e,n){return k.useCallback(r=>{r&&t.onMount&&t.onMount(r),e&&(r?e.mount(r):e.unmount()),n&&(typeof n=="function"?n(r):ah(n)&&(n.current=r))},[e,n])}const lR=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),iye="framerAppearId",nH="data-"+lR(iye),rH=k.createContext({});function sye(t,e,n,r,i){const{visualElement:s}=k.useContext(mx),o=k.useContext(qU),a=k.useContext(DT),c=k.useContext(WU).reducedMotion,h=k.useRef(null);r=r||o.renderer,!h.current&&r&&(h.current=r(t,{visualState:e,parent:s,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:c}));const f=h.current,d=k.useContext(rH);f&&!f.projection&&i&&(f.type==="html"||f.type==="svg")&&oye(h.current,n,i,d);const m=k.useRef(!1);k.useInsertionEffect(()=>{f&&m.current&&f.update(n,a)});const y=n[nH],b=k.useRef(!!y&&!window.MotionHandoffIsComplete?.(y)&&window.MotionHasOptimisedAnimation?.(y));return Ime(()=>{f&&(m.current=!0,window.MotionIsMounted=!0,f.updateFeatures(),f.scheduleRenderMicrotask(),b.current&&f.animationState&&f.animationState.animateChanges())}),k.useEffect(()=>{f&&(!b.current&&f.animationState&&f.animationState.animateChanges(),b.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(y)}),b.current=!1),f.enteringChildren=void 0)}),f}function oye(t,e,n,r){const{layoutId:i,layout:s,drag:o,dragConstraints:a,layoutScroll:c,layoutRoot:h,layoutCrossfade:f}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:iH(t.parent)),t.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!o||a&&ah(a),visualElement:t,animationType:typeof s=="string"?s:"both",initialPromotionConfig:r,crossfade:f,layoutScroll:c,layoutRoot:h})}function iH(t){if(t)return t.options.allowProjection!==!1?t.projection:iH(t.parent)}function i2(t,{forwardMotionProps:e=!1}={},n,r){n&&D0e(n);const i=sR(t)?tye:eye;function s(a,c){let h;const f={...k.useContext(WU),...a,layoutId:aye(a)},{isStatic:d}=f,m=j0e(a),y=i(a,d);if(!d&&PT){lye();const b=cye(f);h=b.MeasureLayout,m.visualElement=sye(t,y,f,r,b.ProjectionNode)}return C.jsxs(mx.Provider,{value:m,children:[h&&m.visualElement?C.jsx(h,{visualElement:m.visualElement,...f}):null,J0e(t,a,rye(y,m.visualElement,c),y,d,e)]})}s.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const o=k.forwardRef(s);return o[nye]=t,o}function aye({layoutId:t}){const e=k.useContext(tU).id;return e&&t!==void 0?e+"-"+t:t}function lye(t,e){k.useContext(qU).strict}function cye(t){const{drag:e,layout:n}=zh;if(!e&&!n)return{};const r={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function uye(t,e){if(typeof Proxy>"u")return i2;const n=new Map,r=(s,o)=>i2(s,o,t,e),i=(s,o)=>r(s,o);return new Proxy(i,{get:(s,o)=>o==="create"?r:(n.has(o)||n.set(o,i2(o,void 0,t,e)),n.get(o))})}function sH({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function hye({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function fye(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),r=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function s2(t){return t===void 0||t===1}function YA({scale:t,scaleX:e,scaleY:n}){return!s2(t)||!s2(e)||!s2(n)}function nc(t){return YA(t)||oH(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function oH(t){return s4(t.x)||s4(t.y)}function s4(t){return t&&t!=="0%"}function Qv(t,e,n){const r=t-n,i=e*r;return n+i}function o4(t,e,n,r,i){return i!==void 0&&(t=Qv(t,i,r)),Qv(t,n,r)+e}function XA(t,e=0,n=1,r,i){t.min=o4(t.min,e,n,r,i),t.max=o4(t.max,e,n,r,i)}function aH(t,{x:e,y:n}){XA(t.x,e.translate,e.scale,e.originPoint),XA(t.y,n.translate,n.scale,n.originPoint)}const a4=.999999999999,l4=1.0000000000001;function dye(t,e,n,r=!1){const i=n.length;if(!i)return;e.x=e.y=1;let s,o;for(let a=0;a<i;a++){s=n[a],o=s.projectionDelta;const{visualElement:c}=s.options;c&&c.props.style&&c.props.style.display==="contents"||(r&&s.options.layoutScroll&&s.scroll&&s!==s.root&&ch(t,{x:-s.scroll.offset.x,y:-s.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,aH(t,o)),r&&nc(s.latestValues)&&ch(t,s.latestValues))}e.x<l4&&e.x>a4&&(e.x=1),e.y<l4&&e.y>a4&&(e.y=1)}function lh(t,e){t.min=t.min+e,t.max=t.max+e}function c4(t,e,n,r,i=.5){const s=Gt(t.min,t.max,i);XA(t,e,n,s,r)}function ch(t,e){c4(t.x,e.x,e.scaleX,e.scale,e.originX),c4(t.y,e.y,e.scaleY,e.scale,e.originY)}function lH(t,e){return sH(fye(t.getBoundingClientRect(),e))}function pye(t,e,n){const r=lH(t,n),{scroll:i}=e;return i&&(lh(r.x,i.offset.x),lh(r.y,i.offset.y)),r}const u4=()=>({translate:0,scale:1,origin:0,originPoint:0}),uh=()=>({x:u4(),y:u4()}),h4=()=>({min:0,max:0}),rn=()=>({x:h4(),y:h4()}),JA={current:null},cH={current:!1};function mye(){if(cH.current=!0,!!PT)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>JA.current=t.matches;t.addEventListener("change",e),e()}else JA.current=!1}const gye=new WeakMap;function yye(t,e,n){for(const r in e){const i=e[r],s=n[r];if(mr(i))t.addValue(r,i);else if(mr(s))t.addValue(r,Fh(i,{owner:t}));else if(s!==i)if(t.hasValue(r)){const o=t.getValue(r);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=t.getStaticValue(r);t.addValue(r,Fh(o!==void 0?o:i,{owner:t}))}}for(const r in n)e[r]===void 0&&t.removeValue(r);return e}const f4=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class bye{scrapeMotionValuesFromProps(e,n,r){return{}}constructor({parent:e,props:n,presenceContext:r,reducedMotionConfig:i,blockInitialAnimation:s,visualState:o},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=XT,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=Xr.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,Ut.render(this.render,!1,!0))};const{latestValues:c,renderState:h}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=h,this.parent=e,this.props=n,this.presenceContext=r,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!s,this.isControllingVariants=yx(n),this.isVariantNode=KU(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:f,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in d){const y=d[m];c[m]!==void 0&&mr(y)&&y.set(c[m])}}mount(e){this.current=e,gye.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),cH.current||mye(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:JA.current,this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),vl(this.notifyUpdate),vl(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const r=rf.has(e);r&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&Ut.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let s;window.MotionCheckAppearSync&&(s=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),s&&s(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in zh){const n=zh[e];if(!n)continue;const{isEnabled:r,Feature:i}=n;if(!this.features[e]&&i&&r(this.props)&&(this.features[e]=new i(this)),this.features[e]){const s=this.features[e];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):rn()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<f4.length;r++){const i=f4[r];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const s="on"+i,o=e[s];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=yye(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const r=this.values.get(e);n!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return r===void 0&&n!==void 0&&(r=Fh(n===null?void 0:n,{owner:this}),this.addValue(e,r)),r}readValue(e,n){let r=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return r!=null&&(typeof r=="string"&&(nU(r)||iU(r))?r=parseFloat(r):!O0e(r)&&wl.test(n)&&(r=BU(e,n)),this.setBaseTarget(e,mr(r)?r.get():r)),mr(r)?r.get():r}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const s=oR(this.props,n,this.presenceContext?.custom);s&&(r=s[e])}if(n&&r!==void 0)return r;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!mr(i)?i:this.initialValues[e]!==void 0&&r===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new jT),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){ZT.render(this.render)}}class uH extends bye{constructor(){super(...arguments),this.KeyframeResolver=b0e}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:r}){delete n[e],delete r[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;mr(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function hH(t,{style:e,vars:n},r,i){const s=t.style;let o;for(o in e)s[o]=e[o];i?.applyProjectionStyles(s,r);for(o in n)s.setProperty(o,n[o])}function vye(t){return window.getComputedStyle(t)}class wye extends uH{constructor(){super(...arguments),this.type="html",this.renderInstance=hH}readValueFromInstance(e,n){if(rf.has(n))return this.projection?.isProjecting?VA(n):$ge(e,n);{const r=vye(e),i=(zT(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return lH(e,n)}build(e,n,r){rR(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return aR(e,n,r)}}const fH=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function xye(t,e,n,r){hH(t,e,void 0,r);for(const i in e.attrs)t.setAttribute(fH.has(i)?i:lR(i),e.attrs[i])}class Sye extends uH{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=rn}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(rf.has(n)){const r=jU(n);return r&&r.default||0}return n=fH.has(n)?n:lR(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return tH(e,n,r)}build(e,n,r){JU(e,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,n,r,i){xye(e,n,r,i)}mount(e){this.isSVGTag=ZU(e.tagName),super.mount(e)}}const _ye=(t,e)=>sR(t)?new Sye(e):new wye(e,{allowProjection:t!==k.Fragment});function Ah(t,e,n){const r=t.getProps();return oR(r,e,n!==void 0?n:r.custom,t)}const QA=t=>Array.isArray(t);function Cye(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Fh(n))}function Aye(t){return QA(t)?t[t.length-1]||0:t}function Eye(t,e){const n=Ah(t,e);let{transitionEnd:r={},transition:i={},...s}=n||{};s={...s,...r};for(const o in s){const a=Aye(s[o]);Cye(t,o,a)}}function kye(t){return!!(mr(t)&&t.add)}function ZA(t,e){const n=t.getValue("willChange");if(kye(n))return n.add(e);if(!n&&ea.WillChange){const r=new ea.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function dH(t){return t.props[nH]}const Tye=t=>t!==null;function Rye(t,{repeat:e,repeatType:n="loop"},r){const i=t.filter(Tye),s=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[s]}const Mye={type:"spring",stiffness:500,damping:25,restSpeed:10},Oye=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Pye={type:"keyframes",duration:.8},Dye={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Iye=(t,{keyframes:e})=>e.length>2?Pye:rf.has(t)?t.startsWith("scale")?Oye(e[1]):Mye:Dye;function Lye({when:t,delay:e,delayChildren:n,staggerChildren:r,staggerDirection:i,repeat:s,repeatType:o,repeatDelay:a,from:c,elapsed:h,...f}){return!!Object.keys(f).length}const cR=(t,e,n,r={},i,s)=>o=>{const a=JT(r,t)||{},c=a.delay||r.delay||0;let{elapsed:h=0}=r;h=h-ho(c);const f={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-h,onUpdate:m=>{e.set(m),a.onUpdate&&a.onUpdate(m)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:s?void 0:i};Lye(a)||Object.assign(f,Iye(t,f)),f.duration&&(f.duration=ho(f.duration)),f.repeatDelay&&(f.repeatDelay=ho(f.repeatDelay)),f.from!==void 0&&(f.keyframes[0]=f.from);let d=!1;if((f.type===!1||f.duration===0&&!f.repeatDelay)&&(GA(f),f.delay===0&&(d=!0)),(ea.instantAnimations||ea.skipAnimations)&&(d=!0,GA(f),f.delay=0),f.allowFlatten=!a.type&&!a.ease,d&&!s&&e.get()!==void 0){const m=Rye(f.keyframes,a);if(m!==void 0){Ut.update(()=>{f.onUpdate(m),f.onComplete()});return}}return a.isSync?new YT(f):new o0e(f)};function Nye({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function pH(t,e,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:s=t.getDefaultTransition(),transitionEnd:o,...a}=e;r&&(s=r);const c=[],h=i&&t.animationState&&t.animationState.getState()[i];for(const f in a){const d=t.getValue(f,t.latestValues[f]??null),m=a[f];if(m===void 0||h&&Nye(h,f))continue;const y={delay:n,...JT(s||{},f)},b=d.get();if(b!==void 0&&!d.isAnimating&&!Array.isArray(m)&&m===b&&!y.velocity)continue;let w=!1;if(window.MotionHandoffAnimation){const _=dH(t);if(_){const A=window.MotionHandoffAnimation(_,f,Ut);A!==null&&(y.startTime=A,w=!0)}}ZA(t,f),d.start(cR(f,d,m,t.shouldReduceMotion&&LU.has(f)?{type:!1}:y,t,w));const S=d.animation;S&&c.push(S)}return o&&Promise.all(c).then(()=>{Ut.update(()=>{o&&Eye(t,o)})}),c}function mH(t,e,n,r=0,i=1){const s=Array.from(t).sort((h,f)=>h.sortNodePosition(f)).indexOf(e),o=t.size,a=(o-1)*r;return typeof n=="function"?n(s,o):i===1?s*r:a-s*r}function eE(t,e,n={}){const r=Ah(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);const s=r?()=>Promise.all(pH(t,r,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:h=0,staggerChildren:f,staggerDirection:d}=i;return $ye(t,e,c,h,f,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,h]=a==="beforeChildren"?[s,o]:[o,s];return c().then(()=>h())}else return Promise.all([s(),o(n.delay)])}function $ye(t,e,n=0,r=0,i=0,s=1,o){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(eE(c,e,{...o,delay:n+(typeof r=="function"?0:r)+mH(t.variantChildren,c,r,i,s)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function jye(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const i=e.map(s=>eE(t,s,n));r=Promise.all(i)}else if(typeof e=="string")r=eE(t,e,n);else{const i=typeof e=="function"?Ah(t,e,n.custom):e;r=Promise.all(pH(t,i,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}function gH(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}const Bye=nR.length;function yH(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?yH(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<Bye;n++){const r=nR[n],i=t.props[r];(Sm(i)||i===!1)&&(e[r]=i)}return e}const Fye=[...tR].reverse(),zye=tR.length;function Vye(t){return e=>Promise.all(e.map(({animation:n,options:r})=>jye(t,n,r)))}function Uye(t){let e=Vye(t),n=d4(),r=!0;const i=c=>(h,f)=>{const d=Ah(t,f,c==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:m,transitionEnd:y,...b}=d;h={...h,...b,...y}}return h};function s(c){e=c(t)}function o(c){const{props:h}=t,f=yH(t.parent)||{},d=[],m=new Set;let y={},b=1/0;for(let S=0;S<zye;S++){const _=Fye[S],A=n[_],E=h[_]!==void 0?h[_]:f[_],P=Sm(E),O=_===c?A.isActive:null;O===!1&&(b=S);let M=E===f[_]&&E!==h[_]&&P;if(M&&r&&t.manuallyAnimateOnMount&&(M=!1),A.protectedKeys={...y},!A.isActive&&O===null||!E&&!A.prevProp||gx(E)||typeof E=="boolean")continue;const D=Hye(A.prevProp,E);let $=D||_===c&&A.isActive&&!M&&P||S>b&&P,F=!1;const N=Array.isArray(E)?E:[E];let U=N.reduce(i(_),{});O===!1&&(U={});const{prevResolvedValues:q={}}=A,K={...q,...U},X=G=>{$=!0,m.has(G)&&(F=!0,m.delete(G)),A.needsAnimating[G]=!0;const H=t.getValue(G);H&&(H.liveStyle=!1)};for(const G in K){const H=U[G],se=q[G];if(y.hasOwnProperty(G))continue;let T=!1;QA(H)&&QA(se)?T=!gH(H,se):T=H!==se,T?H!=null?X(G):m.add(G):H!==void 0&&m.has(G)?X(G):A.protectedKeys[G]=!0}A.prevProp=E,A.prevResolvedValues=U,A.isActive&&(y={...y,...U}),r&&t.blockInitialAnimation&&($=!1);const ee=M&&D;$&&(!ee||F)&&d.push(...N.map(G=>{const H={type:_};if(typeof G=="string"&&r&&!ee&&t.manuallyAnimateOnMount&&t.parent){const{parent:se}=t,T=Ah(se,G);if(se.enteringChildren&&T){const{delayChildren:Z}=T.transition||{};H.delay=mH(se.enteringChildren,t,Z)}}return{animation:G,options:H}}))}if(m.size){const S={};if(typeof h.initial!="boolean"){const _=Ah(t,Array.isArray(h.initial)?h.initial[0]:h.initial);_&&_.transition&&(S.transition=_.transition)}m.forEach(_=>{const A=t.getBaseTarget(_),E=t.getValue(_);E&&(E.liveStyle=!0),S[_]=A??null}),d.push({animation:S})}let w=!!d.length;return r&&(h.initial===!1||h.initial===h.animate)&&!t.manuallyAnimateOnMount&&(w=!1),r=!1,w?e(d):Promise.resolve()}function a(c,h){if(n[c].isActive===h)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(c,h)),n[c].isActive=h;const f=o(c);for(const d in n)n[d].protectedKeys={};return f}return{animateChanges:o,setActive:a,setAnimateFunction:s,getState:()=>n,reset:()=>{n=d4(),r=!0}}}function Hye(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!gH(e,t):!1}function Jl(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function d4(){return{animate:Jl(!0),whileInView:Jl(),whileHover:Jl(),whileTap:Jl(),whileDrag:Jl(),whileFocus:Jl(),exit:Jl()}}class Al{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Wye extends Al{constructor(e){super(e),e.animationState||(e.animationState=Uye(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();gx(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let qye=0;class Gye extends Al{constructor(){super(...arguments),this.id=qye++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===r)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const Kye={animation:{Feature:Wye},exit:{Feature:Gye}};function Cm(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}function rg(t){return{point:{x:t.pageX,y:t.pageY}}}const Yye=t=>e=>eR(e)&&t(e,rg(e));function Dp(t,e,n,r){return Cm(t,e,Yye(n),r)}const bH=1e-4,Xye=1-bH,Jye=1+bH,vH=.01,Qye=0-vH,Zye=0+vH;function Pr(t){return t.max-t.min}function ebe(t,e,n){return Math.abs(t-e)<=n}function p4(t,e,n,r=.5){t.origin=r,t.originPoint=Gt(e.min,e.max,t.origin),t.scale=Pr(n)/Pr(e),t.translate=Gt(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Xye&&t.scale<=Jye||isNaN(t.scale))&&(t.scale=1),(t.translate>=Qye&&t.translate<=Zye||isNaN(t.translate))&&(t.translate=0)}function Ip(t,e,n,r){p4(t.x,e.x,n.x,r?r.originX:void 0),p4(t.y,e.y,n.y,r?r.originY:void 0)}function m4(t,e,n){t.min=n.min+e.min,t.max=t.min+Pr(e)}function tbe(t,e,n){m4(t.x,e.x,n.x),m4(t.y,e.y,n.y)}function g4(t,e,n){t.min=e.min-n.min,t.max=t.min+Pr(e)}function Lp(t,e,n){g4(t.x,e.x,n.x),g4(t.y,e.y,n.y)}function Hi(t){return[t("x"),t("y")]}const wH=({current:t})=>t?t.ownerDocument.defaultView:null,y4=(t,e)=>Math.abs(t-e);function nbe(t,e){const n=y4(t.x,e.x),r=y4(t.y,e.y);return Math.sqrt(n**2+r**2)}class xH{constructor(e,n,{transformPagePoint:r,contextWindow:i=window,dragSnapToOrigin:s=!1,distanceThreshold:o=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const m=a2(this.lastMoveEventInfo,this.history),y=this.startEvent!==null,b=nbe(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!y&&!b)return;const{point:w}=m,{timestamp:S}=Hn;this.history.push({...w,timestamp:S});const{onStart:_,onMove:A}=this.handlers;y||(_&&_(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),A&&A(this.lastMoveEvent,m)},this.handlePointerMove=(m,y)=>{this.lastMoveEvent=m,this.lastMoveEventInfo=o2(y,this.transformPagePoint),Ut.update(this.updatePoint,!0)},this.handlePointerUp=(m,y)=>{this.end();const{onEnd:b,onSessionEnd:w,resumeAnimation:S}=this.handlers;if(this.dragSnapToOrigin&&S&&S(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const _=a2(m.type==="pointercancel"?this.lastMoveEventInfo:o2(y,this.transformPagePoint),this.history);this.startEvent&&b&&b(m,_),w&&w(m,_)},!eR(e))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=o,this.contextWindow=i||window;const a=rg(e),c=o2(a,this.transformPagePoint),{point:h}=c,{timestamp:f}=Hn;this.history=[{...h,timestamp:f}];const{onSessionStart:d}=n;d&&d(e,a2(c,this.history)),this.removeListeners=eg(Dp(this.contextWindow,"pointermove",this.handlePointerMove),Dp(this.contextWindow,"pointerup",this.handlePointerUp),Dp(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),vl(this.updatePoint)}}function o2(t,e){return e?{point:e(t.point)}:t}function b4(t,e){return{x:t.x-e.x,y:t.y-e.y}}function a2({point:t},e){return{point:t,delta:b4(t,SH(e)),offset:b4(t,rbe(e)),velocity:ibe(e,.1)}}function rbe(t){return t[0]}function SH(t){return t[t.length-1]}function ibe(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,r=null;const i=SH(t);for(;n>=0&&(r=t[n],!(i.timestamp-r.timestamp>ho(e)));)n--;if(!r)return{x:0,y:0};const s=fo(i.timestamp-r.timestamp);if(s===0)return{x:0,y:0};const o={x:(i.x-r.x)/s,y:(i.y-r.y)/s};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function sbe(t,{min:e,max:n},r){return e!==void 0&&t<e?t=r?Gt(e,t,r.min):Math.max(t,e):n!==void 0&&t>n&&(t=r?Gt(n,t,r.max):Math.min(t,n)),t}function v4(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function obe(t,{top:e,left:n,bottom:r,right:i}){return{x:v4(t.x,n,i),y:v4(t.y,e,r)}}function w4(t,e){let n=e.min-t.min,r=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,r]=[r,n]),{min:n,max:r}}function abe(t,e){return{x:w4(t.x,e.x),y:w4(t.y,e.y)}}function lbe(t,e){let n=.5;const r=Pr(t),i=Pr(e);return i>r?n=vm(e.min,e.max-r,t.min):r>i&&(n=vm(t.min,t.max-i,e.min)),Zo(0,1,n)}function cbe(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const tE=.35;function ube(t=tE){return t===!1?t=0:t===!0&&(t=tE),{x:x4(t,"left","right"),y:x4(t,"top","bottom")}}function x4(t,e,n){return{min:S4(t,e),max:S4(t,n)}}function S4(t,e){return typeof t=="number"?t:t[e]||0}const hbe=new WeakMap;class fbe{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=rn(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const s=d=>{const{dragSnapToOrigin:m}=this.getProps();m?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(rg(d).point)},o=(d,m)=>{const{drag:y,dragPropagation:b,onDragStart:w}=this.getProps();if(y&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=_0e(y),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Hi(_=>{let A=this.getAxisMotionValue(_).get()||0;if(po.test(A)){const{projection:E}=this.visualElement;if(E&&E.layout){const P=E.layout.layoutBox[_];P&&(A=Pr(P)*(parseFloat(A)/100))}}this.originPoint[_]=A}),w&&Ut.postRender(()=>w(d,m)),ZA(this.visualElement,"transform");const{animationState:S}=this.visualElement;S&&S.setActive("whileDrag",!0)},a=(d,m)=>{this.latestPointerEvent=d,this.latestPanInfo=m;const{dragPropagation:y,dragDirectionLock:b,onDirectionLock:w,onDrag:S}=this.getProps();if(!y&&!this.openDragLock)return;const{offset:_}=m;if(b&&this.currentDirection===null){this.currentDirection=dbe(_),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",m.point,_),this.updateAxis("y",m.point,_),this.visualElement.render(),S&&S(d,m)},c=(d,m)=>{this.latestPointerEvent=d,this.latestPanInfo=m,this.stop(d,m),this.latestPointerEvent=null,this.latestPanInfo=null},h=()=>Hi(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:f}=this.getProps();this.panSession=new xH(e,{onSessionStart:s,onStart:o,onMove:a,onSessionEnd:c,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:f,distanceThreshold:r,contextWindow:wH(this.visualElement)})}stop(e,n){const r=e||this.latestPointerEvent,i=n||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!i||!r)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&Ut.postRender(()=>a(r,i))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(e,n,r){const{drag:i}=this.getProps();if(!r||!Ky(e,i,this.currentDirection))return;const s=this.getAxisMotionValue(e);let o=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(o=sbe(o,this.constraints[e],this.elastic[e])),s.set(o)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&ah(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&r?this.constraints=obe(r.layoutBox,e):this.constraints=!1,this.elastic=ube(n),i!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&Hi(s=>{this.constraints!==!1&&this.getAxisMotionValue(s)&&(this.constraints[s]=cbe(r.layoutBox[s],this.constraints[s]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!ah(e))return!1;const r=e.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const s=pye(r,i.root,this.visualElement.getTransformPagePoint());let o=abe(i.layout.layoutBox,s);if(n){const a=n(hye(o));this.hasMutatedConstraints=!!a,a&&(o=sH(a))}return o}startAnimation(e){const{drag:n,dragMomentum:r,dragElastic:i,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},h=Hi(f=>{if(!Ky(f,n,this.currentDirection))return;let d=c&&c[f]||{};o&&(d={min:0,max:0});const m=i?200:1e6,y=i?40:1e7,b={type:"inertia",velocity:r?e[f]:0,bounceStiffness:m,bounceDamping:y,timeConstant:750,restDelta:1,restSpeed:10,...s,...d};return this.startAxisValueAnimation(f,b)});return Promise.all(h).then(a)}startAxisValueAnimation(e,n){const r=this.getAxisMotionValue(e);return ZA(this.visualElement,e),r.start(cR(e,r,0,n,this.visualElement,!1))}stopAnimation(){Hi(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){Hi(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,r=this.visualElement.getProps(),i=r[n];return i||this.visualElement.getValue(e,(r.initial?r.initial[e]:void 0)||0)}snapToCursor(e){Hi(n=>{const{drag:r}=this.getProps();if(!Ky(n,r,this.currentDirection))return;const{projection:i}=this.visualElement,s=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n];s.set(e[n]-Gt(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!ah(n)||!r||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Hi(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const c=a.get();i[o]=lbe({min:c,max:c},this.constraints[o])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),Hi(o=>{if(!Ky(o,e,null))return;const a=this.getAxisMotionValue(o),{min:c,max:h}=this.constraints[o];a.set(Gt(c,h,i[o]))})}addListeners(){if(!this.visualElement.current)return;hbe.set(this.visualElement,this);const e=this.visualElement.current,n=Dp(e,"pointerdown",c=>{const{drag:h,dragListener:f=!0}=this.getProps();h&&f&&this.start(c)}),r=()=>{const{dragConstraints:c}=this.getProps();ah(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,s=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Ut.read(r);const o=Cm(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",(({delta:c,hasLayoutChanged:h})=>{this.isDragging&&h&&(Hi(f=>{const d=this.getAxisMotionValue(f);d&&(this.originPoint[f]+=c[f].translate,d.set(d.get()+c[f].translate))}),this.visualElement.render())}));return()=>{o(),n(),s(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:i=!1,dragConstraints:s=!1,dragElastic:o=tE,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:r,dragPropagation:i,dragConstraints:s,dragElastic:o,dragMomentum:a}}}function Ky(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function dbe(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class pbe extends Al{constructor(e){super(e),this.removeGroupControls=es,this.removeListeners=es,this.controls=new fbe(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||es}unmount(){this.removeGroupControls(),this.removeListeners()}}const _4=t=>(e,n)=>{t&&Ut.postRender(()=>t(e,n))};class mbe extends Al{constructor(){super(...arguments),this.removePointerDownListener=es}onPointerDown(e){this.session=new xH(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:wH(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:r,onPanEnd:i}=this.node.getProps();return{onSessionStart:_4(e),onStart:_4(n),onMove:r,onEnd:(s,o)=>{delete this.session,i&&Ut.postRender(()=>i(s,o))}}}mount(){this.removePointerDownListener=Dp(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Hb={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function C4(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Nd={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(qe.test(t))t=parseFloat(t);else return t;const n=C4(t,e.target.x),r=C4(t,e.target.y);return`${n}% ${r}%`}},gbe={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,i=wl.parse(t);if(i.length>5)return r;const s=wl.createTransformer(t),o=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;i[0+o]/=a,i[1+o]/=c;const h=Gt(a,c,.5);return typeof i[2+o]=="number"&&(i[2+o]/=h),typeof i[3+o]=="number"&&(i[3+o]/=h),s(i)}};let l2=!1;class ybe extends k.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r,layoutId:i}=this.props,{projection:s}=e;B0e(bbe),s&&(n.group&&n.group.add(s),r&&r.register&&i&&r.register(s),l2&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),Hb.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:r,drag:i,isPresent:s}=this.props,{projection:o}=r;return o&&(o.isPresent=s,l2=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==s?o.willUpdate():this.safeToRemove(),e.isPresent!==s&&(s?o.promote():o.relegate()||Ut.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),ZT.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:i}=e;l2=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),r&&r.deregister&&r.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function _H(t){const[e,n]=P0e(),r=k.useContext(tU);return C.jsx(ybe,{...t,layoutGroup:r,switchLayoutGroup:k.useContext(rH),isPresent:e,safeToRemove:n})}const bbe={borderRadius:{...Nd,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Nd,borderTopRightRadius:Nd,borderBottomLeftRadius:Nd,borderBottomRightRadius:Nd,boxShadow:gbe};function vbe(t,e,n){const r=mr(t)?t:Fh(t);return r.start(cR("",r,e,n)),r.animation}const wbe=(t,e)=>t.depth-e.depth;class xbe{constructor(){this.children=[],this.isDirty=!1}add(e){IT(this.children,e),this.isDirty=!0}remove(e){LT(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(wbe),this.isDirty=!1,this.children.forEach(e)}}function Sbe(t,e){const n=Xr.now(),r=({timestamp:i})=>{const s=i-n;s>=e&&(vl(r),t(s-e))};return Ut.setup(r,!0),()=>vl(r)}const CH=["TopLeft","TopRight","BottomLeft","BottomRight"],_be=CH.length,A4=t=>typeof t=="string"?parseFloat(t):t,E4=t=>typeof t=="number"||qe.test(t);function Cbe(t,e,n,r,i,s){i?(t.opacity=Gt(0,n.opacity??1,Abe(r)),t.opacityExit=Gt(e.opacity??1,0,Ebe(r))):s&&(t.opacity=Gt(e.opacity??1,n.opacity??1,r));for(let o=0;o<_be;o++){const a=`border${CH[o]}Radius`;let c=k4(e,a),h=k4(n,a);if(c===void 0&&h===void 0)continue;c||(c=0),h||(h=0),c===0||h===0||E4(c)===E4(h)?(t[a]=Math.max(Gt(A4(c),A4(h),r),0),(po.test(h)||po.test(c))&&(t[a]+="%")):t[a]=h}(e.rotate||n.rotate)&&(t.rotate=Gt(e.rotate||0,n.rotate||0,r))}function k4(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Abe=AH(0,.5,fU),Ebe=AH(.5,.95,es);function AH(t,e,n){return r=>r<t?0:r>e?1:n(vm(t,e,r))}function T4(t,e){t.min=e.min,t.max=e.max}function Vi(t,e){T4(t.x,e.x),T4(t.y,e.y)}function R4(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function M4(t,e,n,r,i){return t-=e,t=Qv(t,1/n,r),i!==void 0&&(t=Qv(t,1/i,r)),t}function kbe(t,e=0,n=1,r=.5,i,s=t,o=t){if(po.test(e)&&(e=parseFloat(e),e=Gt(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=Gt(s.min,s.max,r);t===s&&(a-=e),t.min=M4(t.min,e,n,a,i),t.max=M4(t.max,e,n,a,i)}function O4(t,e,[n,r,i],s,o){kbe(t,e[n],e[r],e[i],e.scale,s,o)}const Tbe=["x","scaleX","originX"],Rbe=["y","scaleY","originY"];function P4(t,e,n,r){O4(t.x,e,Tbe,n?n.x:void 0,r?r.x:void 0),O4(t.y,e,Rbe,n?n.y:void 0,r?r.y:void 0)}function D4(t){return t.translate===0&&t.scale===1}function EH(t){return D4(t.x)&&D4(t.y)}function I4(t,e){return t.min===e.min&&t.max===e.max}function Mbe(t,e){return I4(t.x,e.x)&&I4(t.y,e.y)}function L4(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function kH(t,e){return L4(t.x,e.x)&&L4(t.y,e.y)}function N4(t){return Pr(t.x)/Pr(t.y)}function $4(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class Obe{constructor(){this.members=[]}add(e){IT(this.members,e),e.scheduleRender()}remove(e){if(LT(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let r;for(let i=n;i>=0;i--){const s=this.members[i];if(s.isPresent!==!1){r=s;break}}return r?(this.promote(r),!0):!1}promote(e,n){const r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.instance&&r.scheduleRender(),e.scheduleRender(),e.resumeFrom=r,n&&(e.resumeFrom.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:r}=e;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function Pbe(t,e,n){let r="";const i=t.x.translate/e.x,s=t.y.translate/e.y,o=n?.z||0;if((i||s||o)&&(r=`translate3d(${i}px, ${s}px, ${o}px) `),(e.x!==1||e.y!==1)&&(r+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:h,rotate:f,rotateX:d,rotateY:m,skewX:y,skewY:b}=n;h&&(r=`perspective(${h}px) ${r}`),f&&(r+=`rotate(${f}deg) `),d&&(r+=`rotateX(${d}deg) `),m&&(r+=`rotateY(${m}deg) `),y&&(r+=`skewX(${y}deg) `),b&&(r+=`skewY(${b}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(r+=`scale(${a}, ${c})`),r||"none"}const c2=["","X","Y","Z"],Dbe=1e3;let Ibe=0;function u2(t,e,n,r){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),r&&(r[t]=0))}function TH(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=dH(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:s}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",Ut,!(i||s))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&TH(r)}function RH({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=Ibe++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach($be),this.nodes.forEach(zbe),this.nodes.forEach(Vbe),this.nodes.forEach(jbe)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new xbe)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new jT),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const c=this.eventHandlers.get(o);c&&c.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=HU(o)&&!R0e(o),this.instance=o;const{layoutId:a,layout:c,visualElement:h}=this.options;if(h&&!h.current&&h.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let f,d=0;const m=()=>this.root.updateBlockedByResize=!1;Ut.read(()=>{d=window.innerWidth}),t(o,()=>{const y=window.innerWidth;y!==d&&(d=y,this.root.updateBlockedByResize=!0,f&&f(),f=Sbe(m,250),Hb.hasAnimatedSinceResize&&(Hb.hasAnimatedSinceResize=!1,this.nodes.forEach(F4)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&h&&(a||c)&&this.addEventListener("didUpdate",({delta:f,hasLayoutChanged:d,hasRelativeLayoutChanged:m,layout:y})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||h.getDefaultTransition()||Gbe,{onLayoutAnimationStart:w,onLayoutAnimationComplete:S}=h.getProps(),_=!this.targetLayout||!kH(this.targetLayout,y),A=!d&&m;if(this.options.layoutRoot||this.resumeFrom||A||d&&(_||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const E={...JT(b,"layout"),onPlay:w,onComplete:S};(h.shouldReduceMotion||this.options.layoutRoot)&&(E.delay=0,E.type=!1),this.startAnimation(E),this.setAnimationOrigin(f,A)}else d||F4(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=y})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),vl(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Ube),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&TH(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let f=0;f<this.path.length;f++){const d=this.path[f];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const h=this.getTransformTemplate();this.prevTransformTemplateValue=h?h(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(j4);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(B4);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Fbe),this.nodes.forEach(Lbe),this.nodes.forEach(Nbe)):this.nodes.forEach(B4),this.clearAllSnapshots();const a=Xr.now();Hn.delta=Zo(0,1e3/60,a-Hn.timestamp),Hn.timestamp=a,Hn.isProcessing=!0,Q_.update.process(Hn),Q_.preRender.process(Hn),Q_.render.process(Hn),Hn.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,ZT.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Bbe),this.sharedNodes.forEach(Hbe)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ut.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ut.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Pr(this.snapshot.measuredBox.x)&&!Pr(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=rn(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const c=r(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!EH(this.projectionDelta),c=this.getTransformTemplate(),h=c?c(this.latestValues,""):void 0,f=h!==this.prevTransformTemplateValue;o&&this.instance&&(a||nc(this.latestValues)||f)&&(i(this.instance,h),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return o&&(c=this.removeTransform(c)),Kbe(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return rn();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Ybe))){const{scroll:h}=this.root;h&&(lh(a.x,h.offset.x),lh(a.y,h.offset.y))}return a}removeElementScroll(o){const a=rn();if(Vi(a,o),this.scroll?.wasRoot)return a;for(let c=0;c<this.path.length;c++){const h=this.path[c],{scroll:f,options:d}=h;h!==this.root&&f&&d.layoutScroll&&(f.wasRoot&&Vi(a,o),lh(a.x,f.offset.x),lh(a.y,f.offset.y))}return a}applyTransform(o,a=!1){const c=rn();Vi(c,o);for(let h=0;h<this.path.length;h++){const f=this.path[h];!a&&f.options.layoutScroll&&f.scroll&&f!==f.root&&ch(c,{x:-f.scroll.offset.x,y:-f.scroll.offset.y}),nc(f.latestValues)&&ch(c,f.latestValues)}return nc(this.latestValues)&&ch(c,this.latestValues),c}removeTransform(o){const a=rn();Vi(a,o);for(let c=0;c<this.path.length;c++){const h=this.path[c];if(!h.instance||!nc(h.latestValues))continue;YA(h.latestValues)&&h.updateSnapshot();const f=rn(),d=h.measurePageBox();Vi(f,d),P4(a,h.latestValues,h.snapshot?h.snapshot.layoutBox:void 0,f)}return nc(this.latestValues)&&P4(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Hn.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(o||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:f,layoutId:d}=this.options;if(!(!this.layout||!(f||d))){if(this.resolvedRelativeTargetAt=Hn.timestamp,!this.targetDelta&&!this.relativeTarget){const m=this.getClosestProjectingParent();m&&m.layout&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=rn(),this.relativeTargetOrigin=rn(),Lp(this.relativeTargetOrigin,this.layout.layoutBox,m.layout.layoutBox),Vi(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=rn(),this.targetWithTransforms=rn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),tbe(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Vi(this.target,this.layout.layoutBox),aH(this.target,this.targetDelta)):Vi(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const m=this.getClosestProjectingParent();m&&!!m.resumingFrom==!!this.resumingFrom&&!m.options.layoutScroll&&m.target&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=rn(),this.relativeTargetOrigin=rn(),Lp(this.relativeTargetOrigin,this.target,m.target),Vi(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||YA(this.parent.latestValues)||oH(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const o=this.getLead(),a=!!this.resumingFrom||this!==o;let c=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===Hn.timestamp&&(c=!1),c)return;const{layout:h,layoutId:f}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(h||f))return;Vi(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,m=this.treeScale.y;dye(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=rn());const{target:y}=o;if(!y){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(R4(this.prevProjectionDelta.x,this.projectionDelta.x),R4(this.prevProjectionDelta.y,this.projectionDelta.y)),Ip(this.projectionDelta,this.layoutCorrected,y,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==m||!$4(this.projectionDelta.x,this.prevProjectionDelta.x)||!$4(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",y))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=uh(),this.projectionDelta=uh(),this.projectionDeltaWithTransform=uh()}setAnimationOrigin(o,a=!1){const c=this.snapshot,h=c?c.latestValues:{},f={...this.latestValues},d=uh();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const m=rn(),y=c?c.source:void 0,b=this.layout?this.layout.source:void 0,w=y!==b,S=this.getStack(),_=!S||S.members.length<=1,A=!!(w&&!_&&this.options.crossfade===!0&&!this.path.some(qbe));this.animationProgress=0;let E;this.mixTargetDelta=P=>{const O=P/1e3;z4(d.x,o.x,O),z4(d.y,o.y,O),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Lp(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Wbe(this.relativeTarget,this.relativeTargetOrigin,m,O),E&&Mbe(this.relativeTarget,E)&&(this.isProjectionDirty=!1),E||(E=rn()),Vi(E,this.relativeTarget)),w&&(this.animationValues=f,Cbe(f,h,this.latestValues,O,A,_)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=O},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(vl(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Ut.update(()=>{Hb.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Fh(0)),this.currentAnimation=vbe(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Dbe),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:c,layout:h,latestValues:f}=o;if(!(!a||!c||!h)){if(this!==o&&this.layout&&h&&MH(this.options.animationType,this.layout.layoutBox,h.layoutBox)){c=this.target||rn();const d=Pr(this.layout.layoutBox.x);c.x.min=o.target.x.min,c.x.max=c.x.min+d;const m=Pr(this.layout.layoutBox.y);c.y.min=o.target.y.min,c.y.max=c.y.min+m}Vi(a,c),ch(a,f),Ip(this.projectionDeltaWithTransform,this.layoutCorrected,a,f)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Obe),this.sharedNodes.get(o).add(a);const h=a.options.initialPromotionConfig;a.promote({transition:h?h.transition:void 0,preserveFollowOpacity:h&&h.shouldPreserveFollowOpacity?h.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){const{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:c}={}){const h=this.getStack();h&&h.promote(this,c),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:c}=o;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const h={};c.z&&u2("z",o,h,this.animationValues);for(let f=0;f<c2.length;f++)u2(`rotate${c2[f]}`,o,h,this.animationValues),u2(`skew${c2[f]}`,o,h,this.animationValues);o.render();for(const f in h)o.setStaticValue(f,h[f]),this.animationValues&&(this.animationValues[f]=h[f]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Ub(a?.pointerEvents)||"",o.transform=c?c(this.latestValues,""):"none";return}const h=this.getLead();if(!this.projectionDelta||!this.layout||!h.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Ub(a?.pointerEvents)||""),this.hasProjected&&!nc(this.latestValues)&&(o.transform=c?c({},""):"none",this.hasProjected=!1);return}o.visibility="";const f=h.animationValues||h.latestValues;this.applyTransformsToTarget();let d=Pbe(this.projectionDeltaWithTransform,this.treeScale,f);c&&(d=c(f,d)),o.transform=d;const{x:m,y}=this.projectionDelta;o.transformOrigin=`${m.origin*100}% ${y.origin*100}% 0`,h.animationValues?o.opacity=h===this?f.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:f.opacityExit:o.opacity=h===this?f.opacity!==void 0?f.opacity:"":f.opacityExit!==void 0?f.opacityExit:0;for(const b in _m){if(f[b]===void 0)continue;const{correct:w,applyTo:S,isCSSVariable:_}=_m[b],A=d==="none"?f[b]:w(f[b],h);if(S){const E=S.length;for(let P=0;P<E;P++)o[S[P]]=A}else _?this.options.visualElement.renderState.vars[b]=A:o[b]=A}this.options.layoutId&&(o.pointerEvents=h===this?Ub(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(j4),this.root.sharedNodes.clear()}}}function Lbe(t){t.updateLayout()}function Nbe(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=t.layout,{animationType:i}=t.options,s=e.source!==t.layout.source;i==="size"?Hi(f=>{const d=s?e.measuredBox[f]:e.layoutBox[f],m=Pr(d);d.min=n[f].min,d.max=d.min+m}):MH(i,e.layoutBox,n)&&Hi(f=>{const d=s?e.measuredBox[f]:e.layoutBox[f],m=Pr(n[f]);d.max=d.min+m,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[f].max=t.relativeTarget[f].min+m)});const o=uh();Ip(o,n,e.layoutBox);const a=uh();s?Ip(a,t.applyTransform(r,!0),e.measuredBox):Ip(a,n,e.layoutBox);const c=!EH(o);let h=!1;if(!t.resumeFrom){const f=t.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:d,layout:m}=f;if(d&&m){const y=rn();Lp(y,e.layoutBox,d.layoutBox);const b=rn();Lp(b,n,m.layoutBox),kH(y,b)||(h=!0),f.options.layoutRoot&&(t.relativeTarget=b,t.relativeTargetOrigin=y,t.relativeParent=f)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:h})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function $be(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function jbe(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Bbe(t){t.clearSnapshot()}function j4(t){t.clearMeasurements()}function B4(t){t.isLayoutDirty=!1}function Fbe(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function F4(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function zbe(t){t.resolveTargetDelta()}function Vbe(t){t.calcProjection()}function Ube(t){t.resetSkewAndRotation()}function Hbe(t){t.removeLeadSnapshot()}function z4(t,e,n){t.translate=Gt(e.translate,0,n),t.scale=Gt(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function V4(t,e,n,r){t.min=Gt(e.min,n.min,r),t.max=Gt(e.max,n.max,r)}function Wbe(t,e,n,r){V4(t.x,e.x,n.x,r),V4(t.y,e.y,n.y,r)}function qbe(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Gbe={duration:.45,ease:[.4,0,.1,1]},U4=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),H4=U4("applewebkit/")&&!U4("chrome/")?Math.round:es;function W4(t){t.min=H4(t.min),t.max=H4(t.max)}function Kbe(t){W4(t.x),W4(t.y)}function MH(t,e,n){return t==="position"||t==="preserve-aspect"&&!ebe(N4(e),N4(n),.2)}function Ybe(t){return t!==t.root&&t.scroll?.wasRoot}const Xbe=RH({attachResizeListener:(t,e)=>Cm(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),h2={current:void 0},OH=RH({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!h2.current){const t=new Xbe({});t.mount(window),t.setOptions({layoutScroll:!0}),h2.current=t}return h2.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Jbe={pan:{Feature:mbe},drag:{Feature:pbe,ProjectionNode:OH,MeasureLayout:_H}};function q4(t,e,n){const{props:r}=t;t.animationState&&r.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,s=r[i];s&&Ut.postRender(()=>s(e,rg(e)))}class Qbe extends Al{mount(){const{current:e}=this.node;e&&(this.unmount=C0e(e,(n,r)=>(q4(this.node,r,"Start"),i=>q4(this.node,i,"End"))))}unmount(){}}class Zbe extends Al{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=eg(Cm(this.node.current,"focus",()=>this.onFocus()),Cm(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function G4(t,e,n){const{props:r}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&r.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),s=r[i];s&&Ut.postRender(()=>s(e,rg(e)))}class eve extends Al{mount(){const{current:e}=this.node;e&&(this.unmount=T0e(e,(n,r)=>(G4(this.node,r,"Start"),(i,{success:s})=>G4(this.node,i,s?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const nE=new WeakMap,f2=new WeakMap,tve=t=>{const e=nE.get(t.target);e&&e(t)},nve=t=>{t.forEach(tve)};function rve({root:t,...e}){const n=t||document;f2.has(n)||f2.set(n,{});const r=f2.get(n),i=JSON.stringify(e);return r[i]||(r[i]=new IntersectionObserver(nve,{root:t,...e})),r[i]}function ive(t,e,n){const r=rve(e);return nE.set(t,n),r.observe(t),()=>{nE.delete(t),r.unobserve(t)}}const sve={some:0,all:1};class ove extends Al{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:r,amount:i="some",once:s}=e,o={root:n?n.current:void 0,rootMargin:r,threshold:typeof i=="number"?i:sve[i]},a=c=>{const{isIntersecting:h}=c;if(this.isInView===h||(this.isInView=h,s&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:f,onViewportLeave:d}=this.node.getProps(),m=h?f:d;m&&m(c)};return ive(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(ave(e,n))&&this.startObserver()}unmount(){}}function ave({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const lve={inView:{Feature:ove},tap:{Feature:eve},focus:{Feature:Zbe},hover:{Feature:Qbe}},cve={layout:{ProjectionNode:OH,MeasureLayout:_H}},uve={...Kye,...lve,...Jbe,...cve},uR=uye(uve,_ye),hve=()=>{const{t}=vt();return C.jsx(uB,{children:C.jsx("div",{className:"mx-auto flex w-full max-w-[var(--thread-max-width)] flex-col px-[var(--thread-padding-x)] justify-center items-center mb-[16px]",children:C.jsxs("div",{className:"max-w-[490px] flex flex-col items-center gap-[16px] text-center",children:[C.jsx("p",{className:"font-[700] text-[32px] leading-[24px]",style:{color:"var(--chat-welcome-color)"},children:t("WelcomeTitle")}),C.jsx("p",{className:"text-[20px] leading-[20px]",style:{color:"var(--chat-welcome-description-color)"},children:t("WelcomeDescription")})]})})})},bx=na((t,e)=>({attachmentFiles:[],addAttachmentFile:n=>{e().attachmentFiles.length>=5||t({attachmentFiles:[...e().attachmentFiles,n]})},deleteAttachmentFile:n=>{t({attachmentFiles:e().attachmentFiles.filter(r=>r.path!==n)})},clearAttachmentFiles:()=>{t({attachmentFiles:[]})}})),fve="data:image/svg+xml,%3csvg%20width='17'%20height='16'%20viewBox='0%200%2017%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.38672%205.07617L6.4082%206.0918L8.33008%208.00098L6.41016%209.91016L5.3877%2010.9258L4.87695%2011.4346L5.15918%2011.7178L5.44141%2012.002L5.95215%2011.4932L6.97461%2010.4775L8.89746%208.56543L11.7627%2011.4131L12.3135%2011.9619L12.5957%2011.6777L12.8779%2011.3945L12.3262%2010.8457L11.2227%209.74902L9.46484%208.00098L11.2246%206.25293L12.3281%205.15625L12.8799%204.6084L12.3154%204.04004L11.7637%204.58887L10.6611%205.68555L8.89746%207.4375L6.97266%205.52441L5.9502%204.50879L5.43945%204L4.875%204.56836L5.38672%205.07617Z'%20fill='%23444444'/%3e%3c/svg%3e",rE="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%204C2%202.89543%202.89543%202%204%202H20C21.1046%202%2022%202.89543%2022%204V20C22%2021.1046%2021.1046%2022%2020%2022H4C2.89543%2022%202%2021.1046%202%2020V4Z'%20fill='%232D8DBF'/%3e%3cpath%20d='M7%207.66699H17C17.1841%207.66699%2017.333%207.8159%2017.333%208C17.333%208.18409%2017.1841%208.33301%2017%208.33301H7C6.81591%208.33301%206.66699%208.1841%206.66699%208C6.66699%207.81591%206.81591%207.66699%207%207.66699Z'%20stroke='white'%20stroke-width='1.33333'/%3e%3cpath%20d='M7%2015.667H13C13.1841%2015.667%2013.333%2015.8159%2013.333%2016C13.333%2016.1841%2013.1841%2016.333%2013%2016.333H7C6.81591%2016.333%206.66699%2016.1841%206.66699%2016C6.66699%2015.8159%206.81591%2015.667%207%2015.667Z'%20stroke='white'%20stroke-width='1.33333'/%3e%3cpath%20d='M7%2011.667H17C17.1841%2011.667%2017.333%2011.8159%2017.333%2012C17.333%2012.1841%2017.1841%2012.333%2017%2012.333H7C6.81591%2012.333%206.66699%2012.1841%206.66699%2012C6.66699%2011.8159%206.81591%2011.667%207%2011.667Z'%20stroke='white'%20stroke-width='1.33333'/%3e%3c/svg%3e",PH="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%204C2%202.89543%202.89543%202%204%202H20C21.1046%202%2022%202.89543%2022%204V20C22%2021.1046%2021.1046%2022%2020%2022H4C2.89543%2022%202%2021.1046%202%2020V4Z'%20fill='%23F36653'/%3e%3cpath%20d='M13%208C13%207.44772%2013.4477%207%2014%207H17C17.5523%207%2018%207.44772%2018%208C18%208.55228%2017.5523%209%2017%209H14C13.4477%209%2013%208.55228%2013%208Z'%20fill='white'/%3e%3cpath%20d='M6%2016C6%2015.4477%206.44772%2015%207%2015H17C17.5523%2015%2018%2015.4477%2018%2016C18%2016.5523%2017.5523%2017%2017%2017H7C6.44772%2017%206%2016.5523%206%2016Z'%20fill='white'/%3e%3cpath%20d='M13%2012C13%2011.4477%2013.4477%2011%2014%2011H17C17.5523%2011%2018%2011.4477%2018%2012C18%2012.5523%2017.5523%2013%2017%2013H14C13.4477%2013%2013%2012.5523%2013%2012Z'%20fill='white'/%3e%3cpath%20d='M6%2010C6%208.34315%207.34315%207%209%207C10.6569%207%2012%208.34315%2012%2010C12%2011.6569%2010.6569%2013%209%2013C7.34315%2013%206%2011.6569%206%2010Z'%20fill='white'/%3e%3c/svg%3e",DH="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%204C2%202.89543%202.89543%202%204%202H20C21.1046%202%2022%202.89543%2022%204V20C22%2021.1046%2021.1046%2022%2020%2022H4C2.89543%2022%202%2021.1046%202%2020V4Z'%20fill='%235BB514'/%3e%3cpath%20d='M9%2014V16H7V14H9ZM17%2014V16H13V14H17ZM17%208V10H13V8H17ZM9%208V10H7V8H9Z'%20fill='white'%20stroke='white'%20stroke-width='2'/%3e%3c/svg%3e",IH="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%204C2%202.89543%202.89543%202%204%202H20C21.1046%202%2022%202.89543%2022%204V20C22%2021.1046%2021.1046%2022%2020%2022H4C2.89543%2022%202%2021.1046%202%2020V4Z'%20fill='%23F37C24'/%3e%3cpath%20d='M17.6878%209.11453C17.8191%209.43169%2017.9183%209.76034%2017.9843%2010.0955C18.0918%2010.6411%2017.6311%2011.096%2017.0751%2011.096H13.9108C13.3547%2011.096%2012.904%2010.6453%2012.904%2010.0892V6.92491C12.904%206.36886%2013.3589%205.90822%2013.9045%206.01567C14.2397%206.08168%2014.5683%206.18086%2014.8855%206.31224C15.5137%206.57245%2016.0845%206.95386%2016.5653%207.43468C17.0461%207.91549%2017.4275%208.48631%2017.6878%209.11453Z'%20fill='white'/%3e%3cpath%20d='M8.30124%208.51672C8.87211%208.13527%209.51023%207.87306%2010.1774%207.74166C10.723%207.63421%2011.1779%208.09485%2011.1779%208.6509L11.178%2011.8152C11.178%2012.3713%2011.6287%2012.822%2012.1848%2012.822L15.3491%2012.822C15.9051%2012.822%2016.3658%2013.277%2016.2583%2013.8225C16.1269%2014.4898%2015.8647%2015.1279%2015.4833%2015.6988C14.9143%2016.5503%2014.1056%2017.2139%2013.1595%2017.6058C12.2133%2017.9978%2011.1722%2018.1003%2010.1678%2017.9005C9.16336%2017.7007%208.24074%2017.2076%207.51659%2016.4834C6.79244%2015.7593%206.29929%2014.8366%206.0995%2013.8322C5.8997%2012.8278%206.00224%2011.7867%206.39415%2010.8405C6.78606%209.89437%207.44973%209.08568%208.30124%208.51672Z'%20fill='white'/%3e%3c/svg%3e",LH="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%204a2%202%200%200%201%202-2h16a2%202%200%200%201%202%202v16a2%202%200%200%201-2%202H4a2%202%200%200%201-2-2z'%20fill='%23969696'/%3e%3cpath%20d='M8%2011a1%201%200%201%201%200%202%201%201%200%200%201%200-2m4%200a1%201%200%201%201%200%202%201%201%200%200%201%200-2m4%200a1%201%200%201%201%200%202%201%201%200%200%201%200-2'%20fill='%23fff'/%3e%3c/svg%3e",NH=({file:t,withoutClose:e})=>{const{deleteAttachmentFile:n}=bx(),r=()=>{n(t.path)},i=t.path.includes("\\")?t.path.split("\\").pop()??"":t.path.split("/").pop()??"",s=i.split(".").pop()??"",o=i.replace(`.${s}`,""),a=E9(t.type),c=T9(t.type),h=Rb(t.type),f=k9(t.type),d=c?PH:a?rE:h?DH:f?IH:LH;return C.jsxs("div",{className:je(" w-fit flex flex-row items-center gap-[12px] h-[36px] rounded-[8px] p-[4px] box-border border-[var(--file-items-border-color)]",e?"cursor-pointer pe-[24px]":"",e?"bg-[var(--file-items-chat-background-color)]":"border bg-[var(--file-items-background-color)]",e?"hover:bg-[var(--file-items-chat-hover-background-color)]":"",e?"active:bg-[var(--file-items-chat-pressed-background-color)]":""),onClick:()=>{e&&window.AscDesktopEditor.openTemplate(t.path,i)},children:[t.isImage?C.jsx("img",{className:"h-[24px]",src:t.content,alt:""}):C.jsxs("div",{className:"flex flex-row items-center h-[24px] gap-[4px]",children:[C.jsx(dn,{className:"",src:d}),C.jsxs("p",{className:"text-[var(--file-items-color)] font-normal text-[14px] leading-[20px] whitespace-nowrap overflow-hidden text-ellipsis",children:[o,C.jsxs("span",{className:"text-[var(--file-items-ext-color)]",children:[".",s]})]})]}),e?null:C.jsx(gt,{iconName:fve,size:16,onClick:r})]})};function Zv(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(e);for(;i!==-1;)r++,i=n.indexOf(e,i+e.length);return r}const Or=El(/[A-Za-z]/),gr=El(/[\dA-Za-z]/),dve=El(/[#-'*+\--9=?A-Z^-~]/);function ew(t){return t!==null&&(t<32||t===127)}const iE=El(/\d/),pve=El(/[\dA-Fa-f]/),mve=El(/[!-/:-@[-`{-~]/);function Be(t){return t!==null&&t<-2}function Ot(t){return t!==null&&(t<0||t===32)}function lt(t){return t===-2||t===-1||t===32}const vx=El(new RegExp("\\p{P}|\\p{S}","u")),Oc=El(/\s/);function El(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function gve(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const wx=(function(t){if(t==null)return wve;if(typeof t=="function")return xx(t);if(typeof t=="object")return Array.isArray(t)?yve(t):bve(t);if(typeof t=="string")return vve(t);throw new Error("Expected function, string, or object as test")});function yve(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=wx(t[n]);return xx(r);function r(...i){let s=-1;for(;++s<e.length;)if(e[s].apply(this,i))return!0;return!1}}function bve(t){const e=t;return xx(n);function n(r){const i=r;let s;for(s in t)if(i[s]!==e[s])return!1;return!0}}function vve(t){return xx(e);function e(n){return n&&n.type===t}}function xx(t){return e;function e(n,r,i){return!!(xve(n)&&t.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function wve(){return!0}function xve(t){return t!==null&&typeof t=="object"&&"type"in t}const $H=[],Sve=!0,sE=!1,_ve="skip";function jH(t,e,n,r){let i;typeof e=="function"&&typeof n!="function"?(r=n,n=e):i=e;const s=wx(i),o=r?-1:1;a(t,void 0,[])();function a(c,h,f){const d=c&&typeof c=="object"?c:{};if(typeof d.type=="string"){const y=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(m,"name",{value:"node ("+(c.type+(y?"<"+y+">":""))+")"})}return m;function m(){let y=$H,b,w,S;if((!e||s(c,h,f[f.length-1]||void 0))&&(y=Cve(n(c,f)),y[0]===sE))return y;if("children"in c&&c.children){const _=c;if(_.children&&y[0]!==_ve)for(w=(r?_.children.length:-1)+o,S=f.concat(_);w>-1&&w<_.children.length;){const A=_.children[w];if(b=a(A,w,S)(),b[0]===sE)return b;w=typeof b[1]=="number"?b[1]:w+o}}return y}}}function Cve(t){return Array.isArray(t)?t:typeof t=="number"?[Sve,t]:t==null?$H:[t]}function Ave(t,e,n){const i=wx((n||{}).ignore||[]),s=Eve(e);let o=-1;for(;++o<s.length;)jH(t,"text",a);function a(h,f){let d=-1,m;for(;++d<f.length;){const y=f[d],b=m?m.children:void 0;if(i(y,b?b.indexOf(y):void 0,m))return;m=y}if(m)return c(h,f)}function c(h,f){const d=f[f.length-1],m=s[o][0],y=s[o][1];let b=0;const S=d.children.indexOf(h);let _=!1,A=[];m.lastIndex=0;let E=m.exec(h.value);for(;E;){const P=E.index,O={index:E.index,input:E.input,stack:[...f,h]};let M=y(...E,O);if(typeof M=="string"&&(M=M.length>0?{type:"text",value:M}:void 0),M===!1?m.lastIndex=P+1:(b!==P&&A.push({type:"text",value:h.value.slice(b,P)}),Array.isArray(M)?A.push(...M):M&&A.push(M),b=P+E[0].length,_=!0),!m.global)break;E=m.exec(h.value)}return _?(b<h.value.length&&A.push({type:"text",value:h.value.slice(b)}),d.children.splice(S,1,...A)):A=[h],S+A.length}}function Eve(t){const e=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!t[0]||Array.isArray(t[0])?t:[t];let r=-1;for(;++r<n.length;){const i=n[r];e.push([kve(i[0]),Tve(i[1])])}return e}function kve(t){return typeof t=="string"?new RegExp(gve(t),"g"):t}function Tve(t){return typeof t=="function"?t:function(){return t}}const d2="phrasing",p2=["autolink","link","image","label"];function Rve(){return{transforms:[Nve],enter:{literalAutolink:Ove,literalAutolinkEmail:m2,literalAutolinkHttp:m2,literalAutolinkWww:m2},exit:{literalAutolink:Lve,literalAutolinkEmail:Ive,literalAutolinkHttp:Pve,literalAutolinkWww:Dve}}}function Mve(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:d2,notInConstruct:p2},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:d2,notInConstruct:p2},{character:":",before:"[ps]",after:"\\/",inConstruct:d2,notInConstruct:p2}]}}function Ove(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function m2(t){this.config.enter.autolinkProtocol.call(this,t)}function Pve(t){this.config.exit.autolinkProtocol.call(this,t)}function Dve(t){this.config.exit.data.call(this,t);const e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function Ive(t){this.config.exit.autolinkEmail.call(this,t)}function Lve(t){this.exit(t)}function Nve(t){Ave(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,$ve],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),jve]],{ignore:["link","linkReference"]})}function $ve(t,e,n,r,i){let s="";if(!BH(i)||(/^w/i.test(e)&&(n=e+n,e="",s="http://"),!Bve(n)))return!1;const o=Fve(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:s+e+o[0],children:[{type:"text",value:e+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function jve(t,e,n,r){return!BH(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n}]}}function Bve(t){const e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function Fve(t){const e=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let n=e[0],r=n.indexOf(")");const i=Zv(t,"(");let s=Zv(t,")");for(;r!==-1&&i>s;)t+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[t,n]}function BH(t,e){const n=t.input.charCodeAt(t.index-1);return(t.index===0||Oc(n)||vx(n))&&(!e||n!==47)}function ws(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}FH.peek=Yve;function zve(){this.buffer()}function Vve(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function Uve(){this.buffer()}function Hve(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function Wve(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ws(this.sliceSerialize(t)).toLowerCase(),n.label=e}function qve(t){this.exit(t)}function Gve(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ws(this.sliceSerialize(t)).toLowerCase(),n.label=e}function Kve(t){this.exit(t)}function Yve(){return"["}function FH(t,e,n,r){const i=n.createTracker(r);let s=i.move("[^");const o=n.enter("footnoteReference"),a=n.enter("reference");return s+=i.move(n.safe(n.associationId(t),{after:"]",before:s})),a(),o(),s+=i.move("]"),s}function Xve(){return{enter:{gfmFootnoteCallString:zve,gfmFootnoteCall:Vve,gfmFootnoteDefinitionLabelString:Uve,gfmFootnoteDefinition:Hve},exit:{gfmFootnoteCallString:Wve,gfmFootnoteCall:qve,gfmFootnoteDefinitionLabelString:Gve,gfmFootnoteDefinition:Kve}}}function Jve(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:FH},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,o){const a=s.createTracker(o);let c=a.move("[^");const h=s.enter("footnoteDefinition"),f=s.enter("label");return c+=a.move(s.safe(s.associationId(r),{before:c,after:"]"})),f(),c+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),c+=a.move((e?`
`:" ")+s.indentLines(s.containerFlow(r,a.current()),e?zH:Qve))),h(),c}}function Qve(t,e,n){return e===0?t:zH(t,e,n)}function zH(t,e,n){return(n?"":" ")+t}const Zve=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];VH.peek=iwe;function ewe(){return{canContainEols:["delete"],enter:{strikethrough:nwe},exit:{strikethrough:rwe}}}function twe(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Zve}],handlers:{delete:VH}}}function nwe(t){this.enter({type:"delete",children:[]},t)}function rwe(t){this.exit(t)}function VH(t,e,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(t,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),s(),o}function iwe(){return"~"}function swe(t){return t.length}function owe(t,e){const n=e||{},r=(n.align||[]).concat(),i=n.stringLength||swe,s=[],o=[],a=[],c=[];let h=0,f=-1;for(;++f<t.length;){const w=[],S=[];let _=-1;for(t[f].length>h&&(h=t[f].length);++_<t[f].length;){const A=awe(t[f][_]);if(n.alignDelimiters!==!1){const E=i(A);S[_]=E,(c[_]===void 0||E>c[_])&&(c[_]=E)}w.push(A)}o[f]=w,a[f]=S}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<h;)s[d]=K4(r[d]);else{const w=K4(r);for(;++d<h;)s[d]=w}d=-1;const m=[],y=[];for(;++d<h;){const w=s[d];let S="",_="";w===99?(S=":",_=":"):w===108?S=":":w===114&&(_=":");let A=n.alignDelimiters===!1?1:Math.max(1,c[d]-S.length-_.length);const E=S+"-".repeat(A)+_;n.alignDelimiters!==!1&&(A=S.length+A+_.length,A>c[d]&&(c[d]=A),y[d]=A),m[d]=E}o.splice(1,0,m),a.splice(1,0,y),f=-1;const b=[];for(;++f<o.length;){const w=o[f],S=a[f];d=-1;const _=[];for(;++d<h;){const A=w[d]||"";let E="",P="";if(n.alignDelimiters!==!1){const O=c[d]-(S[d]||0),M=s[d];M===114?E=" ".repeat(O):M===99?O%2?(E=" ".repeat(O/2+.5),P=" ".repeat(O/2-.5)):(E=" ".repeat(O/2),P=E):P=" ".repeat(O)}n.delimiterStart!==!1&&!d&&_.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&A==="")&&(n.delimiterStart!==!1||d)&&_.push(" "),n.alignDelimiters!==!1&&_.push(E),_.push(A),n.alignDelimiters!==!1&&_.push(P),n.padding!==!1&&_.push(" "),(n.delimiterEnd!==!1||d!==h-1)&&_.push("|")}b.push(n.delimiterEnd===!1?_.join("").replace(/ +$/,""):_.join(""))}return b.join(`
`)}function awe(t){return t==null?"":String(t)}function K4(t){const e=typeof t=="string"?t.codePointAt(0):0;return e===67||e===99?99:e===76||e===108?108:e===82||e===114?114:0}const Y4={}.hasOwnProperty;function lwe(t,e){const n=e||{};function r(i,...s){let o=r.invalid;const a=r.handlers;if(i&&Y4.call(i,t)){const c=String(i[t]);o=Y4.call(a,c)?a[c]:r.unknown}if(o)return o.call(this,i,...s)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}function cwe(t,e,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const o=n.indentLines(n.containerFlow(t,s.current()),uwe);return i(),o}function uwe(t,e,n){return">"+(n?"":" ")+t}function hwe(t,e){return X4(t,e.inConstruct,!0)&&!X4(t,e.notInConstruct,!1)}function X4(t,e,n){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return n;let r=-1;for(;++r<e.length;)if(t.includes(e[r]))return!0;return!1}function J4(t,e,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
`&&hwe(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
`}function fwe(t,e){const n=String(t);let r=n.indexOf(e),i=r,s=0,o=0;if(typeof e!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>o&&(o=s):s=1,i=r+e.length,r=n.indexOf(e,i);return o}function dwe(t,e){return!!(e.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function pwe(t){const e=t.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function mwe(t,e,n,r){const i=pwe(n),s=t.value||"",o=i==="`"?"GraveAccent":"Tilde";if(dwe(t,n)){const d=n.enter("codeIndented"),m=n.indentLines(s,gwe);return d(),m}const a=n.createTracker(r),c=i.repeat(Math.max(fwe(s,i)+1,3)),h=n.enter("codeFenced");let f=a.move(c);if(t.lang){const d=n.enter(`codeFencedLang${o}`);f+=a.move(n.safe(t.lang,{before:f,after:" ",encode:["`"],...a.current()})),d()}if(t.lang&&t.meta){const d=n.enter(`codeFencedMeta${o}`);f+=a.move(" "),f+=a.move(n.safe(t.meta,{before:f,after:`
`,encode:["`"],...a.current()})),d()}return f+=a.move(`
`),s&&(f+=a.move(s+`
`)),f+=a.move(c),h(),f}function gwe(t,e,n){return(n?"":" ")+t}function hR(t){const e=t.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function ywe(t,e,n,r){const i=hR(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("definition");let a=n.enter("label");const c=n.createTracker(r);let h=c.move("[");return h+=c.move(n.safe(n.associationId(t),{before:h,after:"]",...c.current()})),h+=c.move("]: "),a(),!t.url||/[\0- \u007F]/.test(t.url)?(a=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(t.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(a=n.enter("destinationRaw"),h+=c.move(n.safe(t.url,{before:h,after:t.title?" ":`
`,...c.current()}))),a(),t.title&&(a=n.enter(`title${s}`),h+=c.move(" "+i),h+=c.move(n.safe(t.title,{before:h,after:i,...c.current()})),h+=c.move(i),a()),o(),h}function bwe(t){const e=t.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Am(t){return"&#x"+t.toString(16).toUpperCase()+";"}function Vh(t){if(t===null||Ot(t)||Oc(t))return 1;if(vx(t))return 2}function tw(t,e,n){const r=Vh(t),i=Vh(e);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}UH.peek=vwe;function UH(t,e,n,r){const i=bwe(n),s=n.enter("emphasis"),o=n.createTracker(r),a=o.move(i);let c=o.move(n.containerPhrasing(t,{after:i,before:a,...o.current()}));const h=c.charCodeAt(0),f=tw(r.before.charCodeAt(r.before.length-1),h,i);f.inside&&(c=Am(h)+c.slice(1));const d=c.charCodeAt(c.length-1),m=tw(r.after.charCodeAt(0),d,i);m.inside&&(c=c.slice(0,-1)+Am(d));const y=o.move(i);return s(),n.attentionEncodeSurroundingInfo={after:m.outside,before:f.outside},a+c+y}function vwe(t,e,n){return n.options.emphasis||"*"}function fR(t,e,n,r){let i,s,o;typeof e=="function"&&typeof n!="function"?(s=void 0,o=e,i=n):(s=e,o=n,i=r),jH(t,s,a,i);function a(c,h){const f=h[h.length-1],d=f?f.children.indexOf(c):void 0;return o(c,d,f)}}const wwe={};function dR(t,e){const n=wwe,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return HH(t,r,i)}function HH(t,e,n){if(xwe(t)){if("value"in t)return t.type==="html"&&!n?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return Q4(t.children,e,n)}return Array.isArray(t)?Q4(t,e,n):""}function Q4(t,e,n){const r=[];let i=-1;for(;++i<t.length;)r[i]=HH(t[i],e,n);return r.join("")}function xwe(t){return!!(t&&typeof t=="object")}function Swe(t,e){let n=!1;return fR(t,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,sE}),!!((!t.depth||t.depth<3)&&dR(t)&&(e.options.setext||n))}function _we(t,e,n,r){const i=Math.max(Math.min(6,t.depth||1),1),s=n.createTracker(r);if(Swe(t,n)){const f=n.enter("headingSetext"),d=n.enter("phrasing"),m=n.containerPhrasing(t,{...s.current(),before:`
`,after:`
`});return d(),f(),m+`
`+(i===1?"=":"-").repeat(m.length-(Math.max(m.lastIndexOf("\r"),m.lastIndexOf(`
`))+1))}const o="#".repeat(i),a=n.enter("headingAtx"),c=n.enter("phrasing");s.move(o+" ");let h=n.containerPhrasing(t,{before:"# ",after:`
`,...s.current()});return/^[\t ]/.test(h)&&(h=Am(h.charCodeAt(0))+h.slice(1)),h=h?o+" "+h:o,n.options.closeAtx&&(h+=" "+o),c(),a(),h}WH.peek=Cwe;function WH(t){return t.value||""}function Cwe(){return"<"}qH.peek=Awe;function qH(t,e,n,r){const i=hR(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const c=n.createTracker(r);let h=c.move("![");return h+=c.move(n.safe(t.alt,{before:h,after:"]",...c.current()})),h+=c.move("]("),a(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(a=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(t.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(a=n.enter("destinationRaw"),h+=c.move(n.safe(t.url,{before:h,after:t.title?" ":")",...c.current()}))),a(),t.title&&(a=n.enter(`title${s}`),h+=c.move(" "+i),h+=c.move(n.safe(t.title,{before:h,after:i,...c.current()})),h+=c.move(i),a()),h+=c.move(")"),o(),h}function Awe(){return"!"}GH.peek=Ewe;function GH(t,e,n,r){const i=t.referenceType,s=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let c=a.move("![");const h=n.safe(t.alt,{before:c,after:"]",...a.current()});c+=a.move(h+"]["),o();const f=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(t),{before:c,after:"]",...a.current()});return o(),n.stack=f,s(),i==="full"||!h||h!==d?c+=a.move(d+"]"):i==="shortcut"?c=c.slice(0,-1):c+=a.move("]"),c}function Ewe(){return"!"}KH.peek=kwe;function KH(t,e,n){let r=t.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const o=n.unsafe[s],a=n.compilePattern(o);let c;if(o.atBreak)for(;c=a.exec(r);){let h=c.index;r.charCodeAt(h)===10&&r.charCodeAt(h-1)===13&&h--,r=r.slice(0,h)+" "+r.slice(c.index+1)}}return i+r+i}function kwe(){return"`"}function YH(t,e){const n=dR(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}XH.peek=Twe;function XH(t,e,n,r){const i=hR(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,c;if(YH(t,n)){const f=n.stack;n.stack=[],a=n.enter("autolink");let d=o.move("<");return d+=o.move(n.containerPhrasing(t,{before:d,after:">",...o.current()})),d+=o.move(">"),a(),n.stack=f,d}a=n.enter("link"),c=n.enter("label");let h=o.move("[");return h+=o.move(n.containerPhrasing(t,{before:h,after:"](",...o.current()})),h+=o.move("]("),c(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(c=n.enter("destinationLiteral"),h+=o.move("<"),h+=o.move(n.safe(t.url,{before:h,after:">",...o.current()})),h+=o.move(">")):(c=n.enter("destinationRaw"),h+=o.move(n.safe(t.url,{before:h,after:t.title?" ":")",...o.current()}))),c(),t.title&&(c=n.enter(`title${s}`),h+=o.move(" "+i),h+=o.move(n.safe(t.title,{before:h,after:i,...o.current()})),h+=o.move(i),c()),h+=o.move(")"),a(),h}function Twe(t,e,n){return YH(t,n)?"<":"["}JH.peek=Rwe;function JH(t,e,n,r){const i=t.referenceType,s=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let c=a.move("[");const h=n.containerPhrasing(t,{before:c,after:"]",...a.current()});c+=a.move(h+"]["),o();const f=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(t),{before:c,after:"]",...a.current()});return o(),n.stack=f,s(),i==="full"||!h||h!==d?c+=a.move(d+"]"):i==="shortcut"?c=c.slice(0,-1):c+=a.move("]"),c}function Rwe(){return"["}function pR(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function Mwe(t){const e=pR(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Owe(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function QH(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function Pwe(t,e,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=t.ordered?Owe(n):pR(n);const a=t.ordered?o==="."?")":".":Mwe(n);let c=e&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!t.ordered){const f=t.children?t.children[0]:void 0;if((o==="*"||o==="-")&&f&&(!f.children||!f.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),QH(n)===o&&f){let d=-1;for(;++d<t.children.length;){const m=t.children[d];if(m&&m.type==="listItem"&&m.children&&m.children[0]&&m.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(o=a),n.bulletCurrent=o;const h=n.containerFlow(t,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),h}function Dwe(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function Iwe(t,e,n,r){const i=Dwe(n);let s=n.bulletCurrent||pR(n);e&&e.type==="list"&&e.ordered&&(s=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(o-s.length)),a.shift(o);const c=n.enter("listItem"),h=n.indentLines(n.containerFlow(t,a.current()),f);return c(),h;function f(d,m,y){return m?(y?"":" ".repeat(o))+d:(y?s:s+" ".repeat(o-s.length))+d}}function Lwe(t,e,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(t,r);return s(),i(),o}const Nwe=wx(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function $we(t,e,n,r){return(t.children.some(function(o){return Nwe(o)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function jwe(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}ZH.peek=Bwe;function ZH(t,e,n,r){const i=jwe(n),s=n.enter("strong"),o=n.createTracker(r),a=o.move(i+i);let c=o.move(n.containerPhrasing(t,{after:i,before:a,...o.current()}));const h=c.charCodeAt(0),f=tw(r.before.charCodeAt(r.before.length-1),h,i);f.inside&&(c=Am(h)+c.slice(1));const d=c.charCodeAt(c.length-1),m=tw(r.after.charCodeAt(0),d,i);m.inside&&(c=c.slice(0,-1)+Am(d));const y=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:m.outside,before:f.outside},a+c+y}function Bwe(t,e,n){return n.options.strong||"*"}function Fwe(t,e,n,r){return n.safe(t.value,r)}function zwe(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function Vwe(t,e,n){const r=(QH(n)+(n.options.ruleSpaces?" ":"")).repeat(zwe(n));return n.options.ruleSpaces?r.slice(0,-1):r}const eW={blockquote:cwe,break:J4,code:mwe,definition:ywe,emphasis:UH,hardBreak:J4,heading:_we,html:WH,image:qH,imageReference:GH,inlineCode:KH,link:XH,linkReference:JH,list:Pwe,listItem:Iwe,paragraph:Lwe,root:$we,strong:ZH,text:Fwe,thematicBreak:Vwe},Z4=document.createElement("i");function mR(t){const e="&"+t+";";Z4.innerHTML=e;const n=Z4.textContent;return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function tW(t,e){const n=Number.parseInt(t,e);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"<22>":String.fromCodePoint(n)}const Uwe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Hwe(t){return t.replace(Uwe,Wwe)}function Wwe(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return tW(n.slice(s?2:1),s?16:10)}return mR(n)||t}function qwe(){return{enter:{table:Gwe,tableData:e$,tableHeader:e$,tableRow:Ywe},exit:{codeText:Xwe,table:Kwe,tableData:g2,tableHeader:g2,tableRow:g2}}}function Gwe(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function Kwe(t){this.exit(t),this.data.inTable=void 0}function Ywe(t){this.enter({type:"tableRow",children:[]},t)}function g2(t){this.exit(t)}function e$(t){this.enter({type:"tableCell",children:[]},t)}function Xwe(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,Jwe));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function Jwe(t,e){return e==="|"?e:t}function Qwe(t){const e=t||{},n=e.tableCellPadding,r=e.tablePipeAlign,i=e.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:m,table:o,tableCell:c,tableRow:a}};function o(y,b,w,S){return h(f(y,w,S),y.align)}function a(y,b,w,S){const _=d(y,w,S),A=h([_]);return A.slice(0,A.indexOf(`
`))}function c(y,b,w,S){const _=w.enter("tableCell"),A=w.enter("phrasing"),E=w.containerPhrasing(y,{...S,before:s,after:s});return A(),_(),E}function h(y,b){return owe(y,{align:b,alignDelimiters:r,padding:n,stringLength:i})}function f(y,b,w){const S=y.children;let _=-1;const A=[],E=b.enter("table");for(;++_<S.length;)A[_]=d(S[_],b,w);return E(),A}function d(y,b,w){const S=y.children;let _=-1;const A=[],E=b.enter("tableRow");for(;++_<S.length;)A[_]=c(S[_],y,b,w);return E(),A}function m(y,b,w){let S=eW.inlineCode(y,b,w);return w.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function Zwe(){return{exit:{taskListCheckValueChecked:t$,taskListCheckValueUnchecked:t$,paragraph:txe}}}function exe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:nxe}}}function t$(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function txe(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function nxe(t,e,n,r){const i=t.children[0],s=typeof t.checked=="boolean"&&i&&i.type==="paragraph",o="["+(t.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let c=eW.listItem(t,e,n,{...r,...a.current()});return s&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),c;function h(f){return f+o}}function rxe(){return[Rve(),Xve(),ewe(),qwe(),Zwe()]}function ixe(t){return{extensions:[Mve(),Jve(t),twe(),Qwe(t),exe()]}}function ki(t,e,n,r){const i=t.length;let s=0,o;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(e,n),t.splice(...o);else for(n&&t.splice(e,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(e,0),t.splice(...o),s+=1e4,e+=1e4}function qi(t,e){return t.length>0?(ki(t,t.length,0,e),t):e}const n$={}.hasOwnProperty;function nW(t){const e={};let n=-1;for(;++n<t.length;)sxe(e,t[n]);return e}function sxe(t,e){let n;for(n in e){const i=(n$.call(t,n)?t[n]:void 0)||(t[n]={}),s=e[n];let o;if(s)for(o in s){n$.call(i,o)||(i[o]=[]);const a=s[o];oxe(i[o],Array.isArray(a)?a:a?[a]:[])}}}function oxe(t,e){let n=-1;const r=[];for(;++n<e.length;)(e[n].add==="after"?t:r).push(e[n]);ki(t,0,0,r)}const axe={tokenize:dxe,partial:!0},rW={tokenize:pxe,partial:!0},iW={tokenize:mxe,partial:!0},sW={tokenize:gxe,partial:!0},lxe={tokenize:yxe,partial:!0},oW={name:"wwwAutolink",tokenize:hxe,previous:lW},aW={name:"protocolAutolink",tokenize:fxe,previous:cW},oa={name:"emailAutolink",tokenize:uxe,previous:uW},So={};function cxe(){return{text:So}}let Ql=48;for(;Ql<123;)So[Ql]=oa,Ql++,Ql===58?Ql=65:Ql===91&&(Ql=97);So[43]=oa;So[45]=oa;So[46]=oa;So[95]=oa;So[72]=[oa,aW];So[104]=[oa,aW];So[87]=[oa,oW];So[119]=[oa,oW];function uxe(t,e,n){const r=this;let i,s;return o;function o(d){return!oE(d)||!uW.call(r,r.previous)||gR(r.events)?n(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),a(d))}function a(d){return oE(d)?(t.consume(d),a):d===64?(t.consume(d),c):n(d)}function c(d){return d===46?t.check(lxe,f,h)(d):d===45||d===95||gr(d)?(s=!0,t.consume(d),c):f(d)}function h(d){return t.consume(d),i=!0,c}function f(d){return s&&i&&Or(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(d)):n(d)}}function hxe(t,e,n){const r=this;return i;function i(o){return o!==87&&o!==119||!lW.call(r,r.previous)||gR(r.events)?n(o):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(axe,t.attempt(rW,t.attempt(iW,s),n),n)(o))}function s(o){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(o)}}function fxe(t,e,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&cW.call(r,r.previous)&&!gR(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),t.consume(d),a):n(d)}function a(d){if(Or(d)&&i.length<5)return i+=String.fromCodePoint(d),t.consume(d),a;if(d===58){const m=i.toLowerCase();if(m==="http"||m==="https")return t.consume(d),c}return n(d)}function c(d){return d===47?(t.consume(d),s?h:(s=!0,c)):n(d)}function h(d){return d===null||ew(d)||Ot(d)||Oc(d)||vx(d)?n(d):t.attempt(rW,t.attempt(iW,f),n)(d)}function f(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function dxe(t,e,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,t.consume(o),i):o===46&&r===3?(t.consume(o),s):n(o)}function s(o){return o===null?n(o):e(o)}}function pxe(t,e,n){let r,i,s;return o;function o(h){return h===46||h===95?t.check(sW,c,a)(h):h===null||Ot(h)||Oc(h)||h!==45&&vx(h)?c(h):(s=!0,t.consume(h),o)}function a(h){return h===95?r=!0:(i=r,r=void 0),t.consume(h),o}function c(h){return i||r||!s?n(h):e(h)}}function mxe(t,e){let n=0,r=0;return i;function i(o){return o===40?(n++,t.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?t.check(sW,e,s)(o):o===null||Ot(o)||Oc(o)?e(o):(t.consume(o),i)}function s(o){return o===41&&r++,t.consume(o),i}}function gxe(t,e,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(t.consume(a),r):a===38?(t.consume(a),s):a===93?(t.consume(a),i):a===60||a===null||Ot(a)||Oc(a)?e(a):n(a)}function i(a){return a===null||a===40||a===91||Ot(a)||Oc(a)?e(a):r(a)}function s(a){return Or(a)?o(a):n(a)}function o(a){return a===59?(t.consume(a),r):Or(a)?(t.consume(a),o):n(a)}}function yxe(t,e,n){return r;function r(s){return t.consume(s),i}function i(s){return gr(s)?n(s):e(s)}}function lW(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Ot(t)}function cW(t){return!Or(t)}function uW(t){return!(t===47||oE(t))}function oE(t){return t===43||t===45||t===46||t===95||gr(t)}function gR(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}function sf(t){const e=[];let n=-1,r=0,i=0;for(;++n<t.length;){const s=t.charCodeAt(n);let o="";if(s===37&&gr(t.charCodeAt(n+1))&&gr(t.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=t.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="<22>"}else o=String.fromCharCode(s);o&&(e.push(t.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return e.join("")+t.slice(r)}function Sx(t,e,n){const r=[];let i=-1;for(;++i<t.length;){const s=t[i].resolveAll;s&&!r.includes(s)&&(e=s(e,n),r.push(s))}return e}const aE={name:"attention",resolveAll:bxe,tokenize:vxe};function bxe(t,e){let n=-1,r,i,s,o,a,c,h,f;for(;++n<t.length;)if(t[n][0]==="enter"&&t[n][1].type==="attentionSequence"&&t[n][1]._close){for(r=n;r--;)if(t[r][0]==="exit"&&t[r][1].type==="attentionSequence"&&t[r][1]._open&&e.sliceSerialize(t[r][1]).charCodeAt(0)===e.sliceSerialize(t[n][1]).charCodeAt(0)){if((t[r][1]._close||t[n][1]._open)&&(t[n][1].end.offset-t[n][1].start.offset)%3&&!((t[r][1].end.offset-t[r][1].start.offset+t[n][1].end.offset-t[n][1].start.offset)%3))continue;c=t[r][1].end.offset-t[r][1].start.offset>1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1;const d={...t[r][1].end},m={...t[n][1].start};r$(d,-c),r$(m,c),o={type:c>1?"strongSequence":"emphasisSequence",start:d,end:{...t[r][1].end}},a={type:c>1?"strongSequence":"emphasisSequence",start:{...t[n][1].start},end:m},s={type:c>1?"strongText":"emphasisText",start:{...t[r][1].end},end:{...t[n][1].start}},i={type:c>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},t[r][1].end={...o.start},t[n][1].start={...a.end},h=[],t[r][1].end.offset-t[r][1].start.offset&&(h=qi(h,[["enter",t[r][1],e],["exit",t[r][1],e]])),h=qi(h,[["enter",i,e],["enter",o,e],["exit",o,e],["enter",s,e]]),h=qi(h,Sx(e.parser.constructs.insideSpan.null,t.slice(r+1,n),e)),h=qi(h,[["exit",s,e],["enter",a,e],["exit",a,e],["exit",i,e]]),t[n][1].end.offset-t[n][1].start.offset?(f=2,h=qi(h,[["enter",t[n][1],e],["exit",t[n][1],e]])):f=0,ki(t,r-1,n-r+3,h),n=r+h.length-f-2;break}}for(n=-1;++n<t.length;)t[n][1].type==="attentionSequence"&&(t[n][1].type="data");return t}function vxe(t,e){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Vh(r);let s;return o;function o(c){return s=c,t.enter("attentionSequence"),a(c)}function a(c){if(c===s)return t.consume(c),a;const h=t.exit("attentionSequence"),f=Vh(c),d=!f||f===2&&i||n.includes(c),m=!i||i===2&&f||n.includes(r);return h._open=!!(s===42?d:d&&(i||!m)),h._close=!!(s===42?m:m&&(f||!d)),e(c)}}function r$(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const wxe={name:"autolink",tokenize:xxe};function xxe(t,e,n){let r=0;return i;function i(y){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(y),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),s}function s(y){return Or(y)?(t.consume(y),o):y===64?n(y):h(y)}function o(y){return y===43||y===45||y===46||gr(y)?(r=1,a(y)):h(y)}function a(y){return y===58?(t.consume(y),r=0,c):(y===43||y===45||y===46||gr(y))&&r++<32?(t.consume(y),a):(r=0,h(y))}function c(y){return y===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(y),t.exit("autolinkMarker"),t.exit("autolink"),e):y===null||y===32||y===60||ew(y)?n(y):(t.consume(y),c)}function h(y){return y===64?(t.consume(y),f):dve(y)?(t.consume(y),h):n(y)}function f(y){return gr(y)?d(y):n(y)}function d(y){return y===46?(t.consume(y),r=0,f):y===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(y),t.exit("autolinkMarker"),t.exit("autolink"),e):m(y)}function m(y){if((y===45||gr(y))&&r++<63){const b=y===45?m:d;return t.consume(y),b}return n(y)}}function ut(t,e,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(c){return lt(c)?(t.enter(n),a(c)):e(c)}function a(c){return lt(c)&&s++<i?(t.consume(c),a):(t.exit(n),e(c))}}const ig={partial:!0,tokenize:Sxe};function Sxe(t,e,n){return r;function r(s){return lt(s)?ut(t,i,"linePrefix")(s):i(s)}function i(s){return s===null||Be(s)?e(s):n(s)}}const hW={continuation:{tokenize:Cxe},exit:Axe,name:"blockQuote",tokenize:_xe};function _xe(t,e,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(t.enter("blockQuote",{_container:!0}),a.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(o),t.exit("blockQuoteMarker"),s}return n(o)}function s(o){return lt(o)?(t.enter("blockQuotePrefixWhitespace"),t.consume(o),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(o))}}function Cxe(t,e,n){const r=this;return i;function i(o){return lt(o)?ut(t,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return t.attempt(hW,e,n)(o)}}function Axe(t){t.exit("blockQuote")}const fW={name:"characterEscape",tokenize:Exe};function Exe(t,e,n){return r;function r(s){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(s),t.exit("escapeMarker"),i}function i(s){return mve(s)?(t.enter("characterEscapeValue"),t.consume(s),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(s)}}const dW={name:"characterReference",tokenize:kxe};function kxe(t,e,n){const r=this;let i=0,s,o;return a;function a(d){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(d),t.exit("characterReferenceMarker"),c}function c(d){return d===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(d),t.exit("characterReferenceMarkerNumeric"),h):(t.enter("characterReferenceValue"),s=31,o=gr,f(d))}function h(d){return d===88||d===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(d),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),s=6,o=pve,f):(t.enter("characterReferenceValue"),s=7,o=iE,f(d))}function f(d){if(d===59&&i){const m=t.exit("characterReferenceValue");return o===gr&&!mR(r.sliceSerialize(m))?n(d):(t.enter("characterReferenceMarker"),t.consume(d),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return o(d)&&i++<s?(t.consume(d),f):n(d)}}const i$={partial:!0,tokenize:Rxe},s$={concrete:!0,name:"codeFenced",tokenize:Txe};function Txe(t,e,n){const r=this,i={partial:!0,tokenize:O};let s=0,o=0,a;return c;function c(M){return h(M)}function h(M){const D=r.events[r.events.length-1];return s=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[1],!0).length:0,a=M,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),f(M)}function f(M){return M===a?(o++,t.consume(M),f):o<3?n(M):(t.exit("codeFencedFenceSequence"),lt(M)?ut(t,d,"whitespace")(M):d(M))}function d(M){return M===null||Be(M)?(t.exit("codeFencedFence"),r.interrupt?e(M):t.check(i$,w,P)(M)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),m(M))}function m(M){return M===null||Be(M)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),d(M)):lt(M)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),ut(t,y,"whitespace")(M)):M===96&&M===a?n(M):(t.consume(M),m)}function y(M){return M===null||Be(M)?d(M):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),b(M))}function b(M){return M===null||Be(M)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),d(M)):M===96&&M===a?n(M):(t.consume(M),b)}function w(M){return t.attempt(i,P,S)(M)}function S(M){return t.enter("lineEnding"),t.consume(M),t.exit("lineEnding"),_}function _(M){return s>0&&lt(M)?ut(t,A,"linePrefix",s+1)(M):A(M)}function A(M){return M===null||Be(M)?t.check(i$,w,P)(M):(t.enter("codeFlowValue"),E(M))}function E(M){return M===null||Be(M)?(t.exit("codeFlowValue"),A(M)):(t.consume(M),E)}function P(M){return t.exit("codeFenced"),e(M)}function O(M,D,$){let F=0;return N;function N(ee){return M.enter("lineEnding"),M.consume(ee),M.exit("lineEnding"),U}function U(ee){return M.enter("codeFencedFence"),lt(ee)?ut(M,q,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ee):q(ee)}function q(ee){return ee===a?(M.enter("codeFencedFenceSequence"),K(ee)):$(ee)}function K(ee){return ee===a?(F++,M.consume(ee),K):F>=o?(M.exit("codeFencedFenceSequence"),lt(ee)?ut(M,X,"whitespace")(ee):X(ee)):$(ee)}function X(ee){return ee===null||Be(ee)?(M.exit("codeFencedFence"),D(ee)):$(ee)}}}function Rxe(t,e,n){const r=this;return i;function i(o){return o===null?n(o):(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):e(o)}}const y2={name:"codeIndented",tokenize:Oxe},Mxe={partial:!0,tokenize:Pxe};function Oxe(t,e,n){const r=this;return i;function i(h){return t.enter("codeIndented"),ut(t,s,"linePrefix",5)(h)}function s(h){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?o(h):n(h)}function o(h){return h===null?c(h):Be(h)?t.attempt(Mxe,o,c)(h):(t.enter("codeFlowValue"),a(h))}function a(h){return h===null||Be(h)?(t.exit("codeFlowValue"),o(h)):(t.consume(h),a)}function c(h){return t.exit("codeIndented"),e(h)}}function Pxe(t,e,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Be(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),i):ut(t,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):Be(o)?i(o):n(o)}}const Dxe={name:"codeText",previous:Lxe,resolve:Ixe,tokenize:Nxe};function Ixe(t){let e=t.length-4,n=3,r,i;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(r=n;++r<e;)if(t[r][1].type==="codeTextData"){t[n][1].type="codeTextPadding",t[e][1].type="codeTextPadding",n+=2,e-=2;break}}for(r=n-1,e++;++r<=e;)i===void 0?r!==e&&t[r][1].type!=="lineEnding"&&(i=r):(r===e||t[r][1].type==="lineEnding")&&(t[i][1].type="codeTextData",r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),e-=r-i-2,r=i+2),i=void 0);return t}function Lxe(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Nxe(t,e,n){let r=0,i,s;return o;function o(d){return t.enter("codeText"),t.enter("codeTextSequence"),a(d)}function a(d){return d===96?(t.consume(d),r++,a):(t.exit("codeTextSequence"),c(d))}function c(d){return d===null?n(d):d===32?(t.enter("space"),t.consume(d),t.exit("space"),c):d===96?(s=t.enter("codeTextSequence"),i=0,f(d)):Be(d)?(t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),c):(t.enter("codeTextData"),h(d))}function h(d){return d===null||d===32||d===96||Be(d)?(t.exit("codeTextData"),c(d)):(t.consume(d),h)}function f(d){return d===96?(t.consume(d),i++,f):i===r?(t.exit("codeTextSequence"),t.exit("codeText"),e(d)):(s.type="codeTextData",h(d))}}class $xe{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,n,r){const i=n||0;this.setCursor(Math.trunc(e));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&$d(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),$d(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),$d(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const n=this.left.splice(e,Number.POSITIVE_INFINITY);$d(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);$d(this.left,n.reverse())}}}function $d(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function pW(t){const e={};let n=-1,r,i,s,o,a,c,h;const f=new $xe(t);for(;++n<f.length;){for(;n in e;)n=e[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,s=0,s<c.length&&c[s][1].type==="lineEndingBlank"&&(s+=2),s<c.length&&c[s][1].type==="content"))for(;++s<c.length&&c[s][1].type!=="content";)c[s][1].type==="chunkText"&&(c[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,jxe(f,n)),n=e[n],h=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=f.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},a=f.slice(i,n),a.unshift(r),f.splice(i,n-i+1,a))}}return ki(t,0,Number.POSITIVE_INFINITY,f.slice(0)),!h}function jxe(t,e){const n=t.get(e)[1],r=t.get(e)[2];let i=e-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,c=[],h={};let f,d,m=-1,y=n,b=0,w=0;const S=[w];for(;y;){for(;t.get(++i)[1]!==y;);s.push(i),y._tokenizer||(f=r.sliceStream(y),y.next||f.push(null),d&&o.defineSkip(y.start),y._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(f),y._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=y,y=y.next}for(y=n;++m<a.length;)a[m][0]==="exit"&&a[m-1][0]==="enter"&&a[m][1].type===a[m-1][1].type&&a[m][1].start.line!==a[m][1].end.line&&(w=m+1,S.push(w),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(o.events=[],y?(y._tokenizer=void 0,y.previous=void 0):S.pop(),m=S.length;m--;){const _=a.slice(S[m],S[m+1]),A=s.pop();c.push([A,A+_.length-1]),t.splice(A,2,_)}for(c.reverse(),m=-1;++m<c.length;)h[b+c[m][0]]=b+c[m][1],b+=c[m][1]-c[m][0]-1;return h}const Bxe={resolve:zxe,tokenize:Vxe},Fxe={partial:!0,tokenize:Uxe};function zxe(t){return pW(t),t}function Vxe(t,e){let n;return r;function r(a){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):Be(a)?t.check(Fxe,o,s)(a):(t.consume(a),i)}function s(a){return t.exit("chunkContent"),t.exit("content"),e(a)}function o(a){return t.consume(a),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function Uxe(t,e,n){const r=this;return i;function i(o){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),ut(t,s,"linePrefix")}function s(o){if(o===null||Be(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):t.interrupt(r.parser.constructs.flow,n,e)(o)}}function mW(t,e,n,r,i,s,o,a,c){const h=c||Number.POSITIVE_INFINITY;let f=0;return d;function d(_){return _===60?(t.enter(r),t.enter(i),t.enter(s),t.consume(_),t.exit(s),m):_===null||_===32||_===41||ew(_)?n(_):(t.enter(r),t.enter(o),t.enter(a),t.enter("chunkString",{contentType:"string"}),w(_))}function m(_){return _===62?(t.enter(s),t.consume(_),t.exit(s),t.exit(i),t.exit(r),e):(t.enter(a),t.enter("chunkString",{contentType:"string"}),y(_))}function y(_){return _===62?(t.exit("chunkString"),t.exit(a),m(_)):_===null||_===60||Be(_)?n(_):(t.consume(_),_===92?b:y)}function b(_){return _===60||_===62||_===92?(t.consume(_),y):y(_)}function w(_){return!f&&(_===null||_===41||Ot(_))?(t.exit("chunkString"),t.exit(a),t.exit(o),t.exit(r),e(_)):f<h&&_===40?(t.consume(_),f++,w):_===41?(t.consume(_),f--,w):_===null||_===32||_===40||ew(_)?n(_):(t.consume(_),_===92?S:w)}function S(_){return _===40||_===41||_===92?(t.consume(_),w):w(_)}}function gW(t,e,n,r,i,s){const o=this;let a=0,c;return h;function h(y){return t.enter(r),t.enter(i),t.consume(y),t.exit(i),t.enter(s),f}function f(y){return a>999||y===null||y===91||y===93&&!c||y===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(y):y===93?(t.exit(s),t.enter(i),t.consume(y),t.exit(i),t.exit(r),e):Be(y)?(t.enter("lineEnding"),t.consume(y),t.exit("lineEnding"),f):(t.enter("chunkString",{contentType:"string"}),d(y))}function d(y){return y===null||y===91||y===93||Be(y)||a++>999?(t.exit("chunkString"),f(y)):(t.consume(y),c||(c=!lt(y)),y===92?m:d)}function m(y){return y===91||y===92||y===93?(t.consume(y),a++,d):d(y)}}function yW(t,e,n,r,i,s){let o;return a;function a(m){return m===34||m===39||m===40?(t.enter(r),t.enter(i),t.consume(m),t.exit(i),o=m===40?41:m,c):n(m)}function c(m){return m===o?(t.enter(i),t.consume(m),t.exit(i),t.exit(r),e):(t.enter(s),h(m))}function h(m){return m===o?(t.exit(s),c(o)):m===null?n(m):Be(m)?(t.enter("lineEnding"),t.consume(m),t.exit("lineEnding"),ut(t,h,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),f(m))}function f(m){return m===o||m===null||Be(m)?(t.exit("chunkString"),h(m)):(t.consume(m),m===92?d:f)}function d(m){return m===o||m===92?(t.consume(m),f):f(m)}}function Np(t,e){let n;return r;function r(i){return Be(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),n=!0,r):lt(i)?ut(t,r,n?"linePrefix":"lineSuffix")(i):e(i)}}const Hxe={name:"definition",tokenize:qxe},Wxe={partial:!0,tokenize:Gxe};function qxe(t,e,n){const r=this;let i;return s;function s(y){return t.enter("definition"),o(y)}function o(y){return gW.call(r,t,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function a(y){return i=ws(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),y===58?(t.enter("definitionMarker"),t.consume(y),t.exit("definitionMarker"),c):n(y)}function c(y){return Ot(y)?Np(t,h)(y):h(y)}function h(y){return mW(t,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function f(y){return t.attempt(Wxe,d,d)(y)}function d(y){return lt(y)?ut(t,m,"whitespace")(y):m(y)}function m(y){return y===null||Be(y)?(t.exit("definition"),r.parser.defined.push(i),e(y)):n(y)}}function Gxe(t,e,n){return r;function r(a){return Ot(a)?Np(t,i)(a):n(a)}function i(a){return yW(t,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return lt(a)?ut(t,o,"whitespace")(a):o(a)}function o(a){return a===null||Be(a)?e(a):n(a)}}const Kxe={name:"hardBreakEscape",tokenize:Yxe};function Yxe(t,e,n){return r;function r(s){return t.enter("hardBreakEscape"),t.consume(s),i}function i(s){return Be(s)?(t.exit("hardBreakEscape"),e(s)):n(s)}}const Xxe={name:"headingAtx",resolve:Jxe,tokenize:Qxe};function Jxe(t,e){let n=t.length-2,r=3,i,s;return t[r][1].type==="whitespace"&&(r+=2),n-2>r&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&t[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:t[r][1].start,end:t[n][1].end},s={type:"chunkText",start:t[r][1].start,end:t[n][1].end,contentType:"text"},ki(t,r,n-r+1,[["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e]])),t}function Qxe(t,e,n){let r=0;return i;function i(f){return t.enter("atxHeading"),s(f)}function s(f){return t.enter("atxHeadingSequence"),o(f)}function o(f){return f===35&&r++<6?(t.consume(f),o):f===null||Ot(f)?(t.exit("atxHeadingSequence"),a(f)):n(f)}function a(f){return f===35?(t.enter("atxHeadingSequence"),c(f)):f===null||Be(f)?(t.exit("atxHeading"),e(f)):lt(f)?ut(t,a,"whitespace")(f):(t.enter("atxHeadingText"),h(f))}function c(f){return f===35?(t.consume(f),c):(t.exit("atxHeadingSequence"),a(f))}function h(f){return f===null||f===35||Ot(f)?(t.exit("atxHeadingText"),a(f)):(t.consume(f),h)}}const Zxe=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],o$=["pre","script","style","textarea"],e1e={concrete:!0,name:"htmlFlow",resolveTo:r1e,tokenize:i1e},t1e={partial:!0,tokenize:o1e},n1e={partial:!0,tokenize:s1e};function r1e(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function i1e(t,e,n){const r=this;let i,s,o,a,c;return h;function h(L){return f(L)}function f(L){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(L),d}function d(L){return L===33?(t.consume(L),m):L===47?(t.consume(L),s=!0,w):L===63?(t.consume(L),i=3,r.interrupt?e:T):Or(L)?(t.consume(L),o=String.fromCharCode(L),S):n(L)}function m(L){return L===45?(t.consume(L),i=2,y):L===91?(t.consume(L),i=5,a=0,b):Or(L)?(t.consume(L),i=4,r.interrupt?e:T):n(L)}function y(L){return L===45?(t.consume(L),r.interrupt?e:T):n(L)}function b(L){const pe="CDATA[";return L===pe.charCodeAt(a++)?(t.consume(L),a===pe.length?r.interrupt?e:q:b):n(L)}function w(L){return Or(L)?(t.consume(L),o=String.fromCharCode(L),S):n(L)}function S(L){if(L===null||L===47||L===62||Ot(L)){const pe=L===47,ke=o.toLowerCase();return!pe&&!s&&o$.includes(ke)?(i=1,r.interrupt?e(L):q(L)):Zxe.includes(o.toLowerCase())?(i=6,pe?(t.consume(L),_):r.interrupt?e(L):q(L)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(L):s?A(L):E(L))}return L===45||gr(L)?(t.consume(L),o+=String.fromCharCode(L),S):n(L)}function _(L){return L===62?(t.consume(L),r.interrupt?e:q):n(L)}function A(L){return lt(L)?(t.consume(L),A):N(L)}function E(L){return L===47?(t.consume(L),N):L===58||L===95||Or(L)?(t.consume(L),P):lt(L)?(t.consume(L),E):N(L)}function P(L){return L===45||L===46||L===58||L===95||gr(L)?(t.consume(L),P):O(L)}function O(L){return L===61?(t.consume(L),M):lt(L)?(t.consume(L),O):E(L)}function M(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(t.consume(L),c=L,D):lt(L)?(t.consume(L),M):$(L)}function D(L){return L===c?(t.consume(L),c=null,F):L===null||Be(L)?n(L):(t.consume(L),D)}function $(L){return L===null||L===34||L===39||L===47||L===60||L===61||L===62||L===96||Ot(L)?O(L):(t.consume(L),$)}function F(L){return L===47||L===62||lt(L)?E(L):n(L)}function N(L){return L===62?(t.consume(L),U):n(L)}function U(L){return L===null||Be(L)?q(L):lt(L)?(t.consume(L),U):n(L)}function q(L){return L===45&&i===2?(t.consume(L),V):L===60&&i===1?(t.consume(L),G):L===62&&i===4?(t.consume(L),Z):L===63&&i===3?(t.consume(L),T):L===93&&i===5?(t.consume(L),se):Be(L)&&(i===6||i===7)?(t.exit("htmlFlowData"),t.check(t1e,ue,K)(L)):L===null||Be(L)?(t.exit("htmlFlowData"),K(L)):(t.consume(L),q)}function K(L){return t.check(n1e,X,ue)(L)}function X(L){return t.enter("lineEnding"),t.consume(L),t.exit("lineEnding"),ee}function ee(L){return L===null||Be(L)?K(L):(t.enter("htmlFlowData"),q(L))}function V(L){return L===45?(t.consume(L),T):q(L)}function G(L){return L===47?(t.consume(L),o="",H):q(L)}function H(L){if(L===62){const pe=o.toLowerCase();return o$.includes(pe)?(t.consume(L),Z):q(L)}return Or(L)&&o.length<8?(t.consume(L),o+=String.fromCharCode(L),H):q(L)}function se(L){return L===93?(t.consume(L),T):q(L)}function T(L){return L===62?(t.consume(L),Z):L===45&&i===2?(t.consume(L),T):q(L)}function Z(L){return L===null||Be(L)?(t.exit("htmlFlowData"),ue(L)):(t.consume(L),Z)}function ue(L){return t.exit("htmlFlow"),e(L)}}function s1e(t,e,n){const r=this;return i;function i(o){return Be(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):e(o)}}function o1e(t,e,n){return r;function r(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),t.attempt(ig,e,n)}}const a1e={name:"htmlText",tokenize:l1e};function l1e(t,e,n){const r=this;let i,s,o;return a;function a(T){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(T),c}function c(T){return T===33?(t.consume(T),h):T===47?(t.consume(T),O):T===63?(t.consume(T),E):Or(T)?(t.consume(T),$):n(T)}function h(T){return T===45?(t.consume(T),f):T===91?(t.consume(T),s=0,b):Or(T)?(t.consume(T),A):n(T)}function f(T){return T===45?(t.consume(T),y):n(T)}function d(T){return T===null?n(T):T===45?(t.consume(T),m):Be(T)?(o=d,G(T)):(t.consume(T),d)}function m(T){return T===45?(t.consume(T),y):d(T)}function y(T){return T===62?V(T):T===45?m(T):d(T)}function b(T){const Z="CDATA[";return T===Z.charCodeAt(s++)?(t.consume(T),s===Z.length?w:b):n(T)}function w(T){return T===null?n(T):T===93?(t.consume(T),S):Be(T)?(o=w,G(T)):(t.consume(T),w)}function S(T){return T===93?(t.consume(T),_):w(T)}function _(T){return T===62?V(T):T===93?(t.consume(T),_):w(T)}function A(T){return T===null||T===62?V(T):Be(T)?(o=A,G(T)):(t.consume(T),A)}function E(T){return T===null?n(T):T===63?(t.consume(T),P):Be(T)?(o=E,G(T)):(t.consume(T),E)}function P(T){return T===62?V(T):E(T)}function O(T){return Or(T)?(t.consume(T),M):n(T)}function M(T){return T===45||gr(T)?(t.consume(T),M):D(T)}function D(T){return Be(T)?(o=D,G(T)):lt(T)?(t.consume(T),D):V(T)}function $(T){return T===45||gr(T)?(t.consume(T),$):T===47||T===62||Ot(T)?F(T):n(T)}function F(T){return T===47?(t.consume(T),V):T===58||T===95||Or(T)?(t.consume(T),N):Be(T)?(o=F,G(T)):lt(T)?(t.consume(T),F):V(T)}function N(T){return T===45||T===46||T===58||T===95||gr(T)?(t.consume(T),N):U(T)}function U(T){return T===61?(t.consume(T),q):Be(T)?(o=U,G(T)):lt(T)?(t.consume(T),U):F(T)}function q(T){return T===null||T===60||T===61||T===62||T===96?n(T):T===34||T===39?(t.consume(T),i=T,K):Be(T)?(o=q,G(T)):lt(T)?(t.consume(T),q):(t.consume(T),X)}function K(T){return T===i?(t.consume(T),i=void 0,ee):T===null?n(T):Be(T)?(o=K,G(T)):(t.consume(T),K)}function X(T){return T===null||T===34||T===39||T===60||T===61||T===96?n(T):T===47||T===62||Ot(T)?F(T):(t.consume(T),X)}function ee(T){return T===47||T===62||Ot(T)?F(T):n(T)}function V(T){return T===62?(t.consume(T),t.exit("htmlTextData"),t.exit("htmlText"),e):n(T)}function G(T){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(T),t.exit("lineEnding"),H}function H(T){return lt(T)?ut(t,se,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):se(T)}function se(T){return t.enter("htmlTextData"),o(T)}}const yR={name:"labelEnd",resolveAll:f1e,resolveTo:d1e,tokenize:p1e},c1e={tokenize:m1e},u1e={tokenize:g1e},h1e={tokenize:y1e};function f1e(t){let e=-1;const n=[];for(;++e<t.length;){const r=t[e][1];if(n.push(t[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",e+=i}}return t.length!==n.length&&ki(t,0,t.length,n),t}function d1e(t,e){let n=t.length,r=0,i,s,o,a;for(;n--;)if(i=t[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;t[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(t[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const c={type:t[s][1].type==="labelLink"?"link":"image",start:{...t[s][1].start},end:{...t[t.length-1][1].end}},h={type:"label",start:{...t[s][1].start},end:{...t[o][1].end}},f={type:"labelText",start:{...t[s+r+2][1].end},end:{...t[o-2][1].start}};return a=[["enter",c,e],["enter",h,e]],a=qi(a,t.slice(s+1,s+r+3)),a=qi(a,[["enter",f,e]]),a=qi(a,Sx(e.parser.constructs.insideSpan.null,t.slice(s+r+4,o-3),e)),a=qi(a,[["exit",f,e],t[o-2],t[o-1],["exit",h,e]]),a=qi(a,t.slice(o+1)),a=qi(a,[["exit",c,e]]),ki(t,s,t.length,a),t}function p1e(t,e,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(m){return s?s._inactive?d(m):(o=r.parser.defined.includes(ws(r.sliceSerialize({start:s.end,end:r.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(m),t.exit("labelMarker"),t.exit("labelEnd"),c):n(m)}function c(m){return m===40?t.attempt(c1e,f,o?f:d)(m):m===91?t.attempt(u1e,f,o?h:d)(m):o?f(m):d(m)}function h(m){return t.attempt(h1e,f,d)(m)}function f(m){return e(m)}function d(m){return s._balanced=!0,n(m)}}function m1e(t,e,n){return r;function r(d){return t.enter("resource"),t.enter("resourceMarker"),t.consume(d),t.exit("resourceMarker"),i}function i(d){return Ot(d)?Np(t,s)(d):s(d)}function s(d){return d===41?f(d):mW(t,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return Ot(d)?Np(t,c)(d):f(d)}function a(d){return n(d)}function c(d){return d===34||d===39||d===40?yW(t,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):f(d)}function h(d){return Ot(d)?Np(t,f)(d):f(d)}function f(d){return d===41?(t.enter("resourceMarker"),t.consume(d),t.exit("resourceMarker"),t.exit("resource"),e):n(d)}}function g1e(t,e,n){const r=this;return i;function i(a){return gW.call(r,t,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(ws(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(a):n(a)}function o(a){return n(a)}}function y1e(t,e,n){return r;function r(s){return t.enter("reference"),t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),i}function i(s){return s===93?(t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),t.exit("reference"),e):n(s)}}const b1e={name:"labelStartImage",resolveAll:yR.resolveAll,tokenize:v1e};function v1e(t,e,n){const r=this;return i;function i(a){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(a),t.exit("labelImageMarker"),s}function s(a){return a===91?(t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),t.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):e(a)}}const w1e={name:"labelStartLink",resolveAll:yR.resolveAll,tokenize:x1e};function x1e(t,e,n){const r=this;return i;function i(o){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(o),t.exit("labelMarker"),t.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):e(o)}}const b2={name:"lineEnding",tokenize:S1e};function S1e(t,e){return n;function n(r){return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),ut(t,e,"linePrefix")}}const Wb={name:"thematicBreak",tokenize:_1e};function _1e(t,e,n){let r=0,i;return s;function s(h){return t.enter("thematicBreak"),o(h)}function o(h){return i=h,a(h)}function a(h){return h===i?(t.enter("thematicBreakSequence"),c(h)):r>=3&&(h===null||Be(h))?(t.exit("thematicBreak"),e(h)):n(h)}function c(h){return h===i?(t.consume(h),r++,c):(t.exit("thematicBreakSequence"),lt(h)?ut(t,a,"whitespace")(h):a(h))}}const Ur={continuation:{tokenize:k1e},exit:R1e,name:"list",tokenize:E1e},C1e={partial:!0,tokenize:M1e},A1e={partial:!0,tokenize:T1e};function E1e(t,e,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(y){const b=r.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(b==="listUnordered"?!r.containerState.marker||y===r.containerState.marker:iE(y)){if(r.containerState.type||(r.containerState.type=b,t.enter(b,{_container:!0})),b==="listUnordered")return t.enter("listItemPrefix"),y===42||y===45?t.check(Wb,n,h)(y):h(y);if(!r.interrupt||y===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),c(y)}return n(y)}function c(y){return iE(y)&&++o<10?(t.consume(y),c):(!r.interrupt||o<2)&&(r.containerState.marker?y===r.containerState.marker:y===41||y===46)?(t.exit("listItemValue"),h(y)):n(y)}function h(y){return t.enter("listItemMarker"),t.consume(y),t.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||y,t.check(ig,r.interrupt?n:f,t.attempt(C1e,m,d))}function f(y){return r.containerState.initialBlankLine=!0,s++,m(y)}function d(y){return lt(y)?(t.enter("listItemPrefixWhitespace"),t.consume(y),t.exit("listItemPrefixWhitespace"),m):n(y)}function m(y){return r.containerState.size=s+r.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(y)}}function k1e(t,e,n){const r=this;return r.containerState._closeFlow=void 0,t.check(ig,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ut(t,e,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!lt(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,t.attempt(A1e,e,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,ut(t,t.attempt(Ur,e,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function T1e(t,e,n){const r=this;return ut(t,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?e(s):n(s)}}function R1e(t){t.exit(this.containerState.type)}function M1e(t,e,n){const r=this;return ut(t,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!lt(s)&&o&&o[1].type==="listItemPrefixWhitespace"?e(s):n(s)}}const a$={name:"setextUnderline",resolveTo:O1e,tokenize:P1e};function O1e(t,e){let n=t.length,r,i,s;for(;n--;)if(t[n][0]==="enter"){if(t[n][1].type==="content"){r=n;break}t[n][1].type==="paragraph"&&(i=n)}else t[n][1].type==="content"&&t.splice(n,1),!s&&t[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...t[r][1].start},end:{...t[t.length-1][1].end}};return t[i][1].type="setextHeadingText",s?(t.splice(i,0,["enter",o,e]),t.splice(s+1,0,["exit",t[r][1],e]),t[r][1].end={...t[s][1].end}):t[r][1]=o,t.push(["exit",o,e]),t}function P1e(t,e,n){const r=this;let i;return s;function s(h){let f=r.events.length,d;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){d=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(t.enter("setextHeadingLine"),i=h,o(h)):n(h)}function o(h){return t.enter("setextHeadingLineSequence"),a(h)}function a(h){return h===i?(t.consume(h),a):(t.exit("setextHeadingLineSequence"),lt(h)?ut(t,c,"lineSuffix")(h):c(h))}function c(h){return h===null||Be(h)?(t.exit("setextHeadingLine"),e(h)):n(h)}}const D1e={tokenize:z1e,partial:!0};function I1e(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:j1e,continuation:{tokenize:B1e},exit:F1e}},text:{91:{name:"gfmFootnoteCall",tokenize:$1e},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:L1e,resolveTo:N1e}}}}function L1e(t,e,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const c=r.events[i][1];if(c.type==="labelImage"){o=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return a;function a(c){if(!o||!o._balanced)return n(c);const h=ws(r.sliceSerialize({start:o.end,end:r.now()}));return h.codePointAt(0)!==94||!s.includes(h.slice(1))?n(c):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(c),t.exit("gfmFootnoteCallLabelMarker"),e(c))}}function N1e(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",s,e],["enter",o,e],["exit",o,e],["exit",s,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...a),t}function $1e(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(d){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),c}function c(d){return d!==94?n(d):(t.enter("gfmFootnoteCallMarker"),t.consume(d),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",h)}function h(d){if(s>999||d===93&&!o||d===null||d===91||Ot(d))return n(d);if(d===93){t.exit("chunkString");const m=t.exit("gfmFootnoteCallString");return i.includes(ws(r.sliceSerialize(m)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(d)}return Ot(d)||(o=!0),s++,t.consume(d),d===92?f:h}function f(d){return d===91||d===92||d===93?(t.consume(d),s++,h):h(d)}}function j1e(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return c;function c(b){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(b),t.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(b){return b===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(b),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",f):n(b)}function f(b){if(o>999||b===93&&!a||b===null||b===91||Ot(b))return n(b);if(b===93){t.exit("chunkString");const w=t.exit("gfmFootnoteDefinitionLabelString");return s=ws(r.sliceSerialize(w)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(b),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),m}return Ot(b)||(a=!0),o++,t.consume(b),b===92?d:f}function d(b){return b===91||b===92||b===93?(t.consume(b),o++,f):f(b)}function m(b){return b===58?(t.enter("definitionMarker"),t.consume(b),t.exit("definitionMarker"),i.includes(s)||i.push(s),ut(t,y,"gfmFootnoteDefinitionWhitespace")):n(b)}function y(b){return e(b)}}function B1e(t,e,n){return t.check(ig,e,t.attempt(D1e,e,n))}function F1e(t){t.exit("gfmFootnoteDefinition")}function z1e(t,e,n){const r=this;return ut(t,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?e(s):n(s)}}function V1e(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let c=-1;for(;++c<o.length;)if(o[c][0]==="enter"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._close){let h=c;for(;h--;)if(o[h][0]==="exit"&&o[h][1].type==="strikethroughSequenceTemporary"&&o[h][1]._open&&o[c][1].end.offset-o[c][1].start.offset===o[h][1].end.offset-o[h][1].start.offset){o[c][1].type="strikethroughSequence",o[h][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},o[h][1].start),end:Object.assign({},o[c][1].end)},d={type:"strikethroughText",start:Object.assign({},o[h][1].end),end:Object.assign({},o[c][1].start)},m=[["enter",f,a],["enter",o[h][1],a],["exit",o[h][1],a],["enter",d,a]],y=a.parser.constructs.insideSpan.null;y&&ki(m,m.length,0,Sx(y,o.slice(h+1,c),a)),ki(m,m.length,0,[["exit",d,a],["enter",o[c][1],a],["exit",o[c][1],a],["exit",f,a]]),ki(o,h-1,c-h+3,m),c=h+m.length-2;break}}for(c=-1;++c<o.length;)o[c][1].type==="strikethroughSequenceTemporary"&&(o[c][1].type="data");return o}function s(o,a,c){const h=this.previous,f=this.events;let d=0;return m;function m(b){return h===126&&f[f.length-1][1].type!=="characterEscape"?c(b):(o.enter("strikethroughSequenceTemporary"),y(b))}function y(b){const w=Vh(h);if(b===126)return d>1?c(b):(o.consume(b),d++,y);if(d<2&&!n)return c(b);const S=o.exit("strikethroughSequenceTemporary"),_=Vh(b);return S._open=!_||_===2&&!!w,S._close=!w||w===2&&!!_,a(b)}}}class U1e{constructor(){this.map=[]}add(e,n,r){H1e(this,e,n,r)}consume(e){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const s of i)e.push(s);i=r.pop()}this.map.length=0}}function H1e(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function W1e(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function q1e(){return{flow:{null:{name:"table",tokenize:G1e,resolveAll:K1e}}}}function G1e(t,e,n){const r=this;let i=0,s=0,o;return a;function a(N){let U=r.events.length-1;for(;U>-1;){const X=r.events[U][1].type;if(X==="lineEnding"||X==="linePrefix")U--;else break}const q=U>-1?r.events[U][1].type:null,K=q==="tableHead"||q==="tableRow"?M:c;return K===M&&r.parser.lazy[r.now().line]?n(N):K(N)}function c(N){return t.enter("tableHead"),t.enter("tableRow"),h(N)}function h(N){return N===124||(o=!0,s+=1),f(N)}function f(N){return N===null?n(N):Be(N)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(N),t.exit("lineEnding"),y):n(N):lt(N)?ut(t,f,"whitespace")(N):(s+=1,o&&(o=!1,i+=1),N===124?(t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),o=!0,f):(t.enter("data"),d(N)))}function d(N){return N===null||N===124||Ot(N)?(t.exit("data"),f(N)):(t.consume(N),N===92?m:d)}function m(N){return N===92||N===124?(t.consume(N),d):d(N)}function y(N){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(N):(t.enter("tableDelimiterRow"),o=!1,lt(N)?ut(t,b,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):b(N))}function b(N){return N===45||N===58?S(N):N===124?(o=!0,t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),w):O(N)}function w(N){return lt(N)?ut(t,S,"whitespace")(N):S(N)}function S(N){return N===58?(s+=1,o=!0,t.enter("tableDelimiterMarker"),t.consume(N),t.exit("tableDelimiterMarker"),_):N===45?(s+=1,_(N)):N===null||Be(N)?P(N):O(N)}function _(N){return N===45?(t.enter("tableDelimiterFiller"),A(N)):O(N)}function A(N){return N===45?(t.consume(N),A):N===58?(o=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(N),t.exit("tableDelimiterMarker"),E):(t.exit("tableDelimiterFiller"),E(N))}function E(N){return lt(N)?ut(t,P,"whitespace")(N):P(N)}function P(N){return N===124?b(N):N===null||Be(N)?!o||i!==s?O(N):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(N)):O(N)}function O(N){return n(N)}function M(N){return t.enter("tableRow"),D(N)}function D(N){return N===124?(t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),D):N===null||Be(N)?(t.exit("tableRow"),e(N)):lt(N)?ut(t,D,"whitespace")(N):(t.enter("data"),$(N))}function $(N){return N===null||N===124||Ot(N)?(t.exit("data"),D(N)):(t.consume(N),N===92?F:$)}function F(N){return N===92||N===124?(t.consume(N),$):$(N)}}function K1e(t,e){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,c=0,h,f,d;const m=new U1e;for(;++n<t.length;){const y=t[n],b=y[1];y[0]==="enter"?b.type==="tableHead"?(a=!1,c!==0&&(l$(m,e,c,h,f),f=void 0,c=0),h={type:"table",start:Object.assign({},b.start),end:Object.assign({},b.end)},m.add(n,0,[["enter",h,e]])):b.type==="tableRow"||b.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,f={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},m.add(n,0,[["enter",f,e]])),i=b.type==="tableDelimiterRow"?2:f?3:1):i&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],d=Yy(m,e,s,i,void 0,d),s=[0,0,0,0]),o[2]=n)):b.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],d=Yy(m,e,s,i,void 0,d)),s=o,o=[s[1],n,0,0])):b.type==="tableHead"?(a=!0,c=n):b.type==="tableRow"||b.type==="tableDelimiterRow"?(c=n,s[1]!==0?(o[0]=o[1],d=Yy(m,e,s,i,n,d)):o[1]!==0&&(d=Yy(m,e,o,i,n,d)),i=0):i&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(o[3]=n)}for(c!==0&&l$(m,e,c,h,f),m.consume(e.events),n=-1;++n<e.events.length;){const y=e.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=W1e(e.events,n))}return t}function Yy(t,e,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},eh(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const c=eh(e.events,n[1]);if(s={type:o,start:Object.assign({},c),end:Object.assign({},c)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){const h=eh(e.events,n[2]),f=eh(e.events,n[3]),d={type:a,start:Object.assign({},h),end:Object.assign({},f)};if(t.add(n[2],0,[["enter",d,e]]),r!==2){const m=e.events[n[2]],y=e.events[n[3]];if(m[1].end=Object.assign({},y[1].end),m[1].type="chunkText",m[1].contentType="text",n[3]>n[2]+1){const b=n[2]+1,w=n[3]-n[2]-1;t.add(b,w,[])}}t.add(n[3]+1,0,[["exit",d,e]])}return i!==void 0&&(s.end=Object.assign({},eh(e.events,i)),t.add(i,0,[["exit",s,e]]),s=void 0),s}function l$(t,e,n,r,i){const s=[],o=eh(e.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,e])),r.end=Object.assign({},o),s.push(["exit",r,e]),t.add(n+1,0,s)}function eh(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const Y1e={name:"tasklistCheck",tokenize:J1e};function X1e(){return{text:{91:Y1e}}}function J1e(t,e,n){const r=this;return i;function i(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(c),t.exit("taskListCheckMarker"),s)}function s(c){return Ot(c)?(t.enter("taskListCheckValueUnchecked"),t.consume(c),t.exit("taskListCheckValueUnchecked"),o):c===88||c===120?(t.enter("taskListCheckValueChecked"),t.consume(c),t.exit("taskListCheckValueChecked"),o):n(c)}function o(c){return c===93?(t.enter("taskListCheckMarker"),t.consume(c),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),a):n(c)}function a(c){return Be(c)?e(c):lt(c)?t.check({tokenize:Q1e},e,n)(c):n(c)}}function Q1e(t,e,n){return ut(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function Z1e(t){return nW([cxe(),I1e(),V1e(t),q1e(),X1e()])}const eSe={};function tSe(t){const e=this,n=t||eSe,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Z1e(n)),s.push(rxe()),o.push(ixe(n))}function bW(t,e){const n=e||{};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const nSe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rSe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,iSe={};function c$(t,e){return(iSe.jsx?rSe:nSe).test(t)}const sSe=/[ \t\n\f\r]/g;function _x(t){return typeof t=="object"?t.type==="text"?u$(t.value):!1:u$(t)}function u$(t){return t.replace(sSe,"")===""}class sg{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}}sg.prototype.normal={};sg.prototype.property={};sg.prototype.space=void 0;function vW(t,e){const n={},r={};for(const i of t)Object.assign(n,i.property),Object.assign(r,i.normal);return new sg(n,r,e)}function lE(t){return t.toLowerCase()}class ei{constructor(e,n){this.attribute=n,this.property=e}}ei.prototype.attribute="";ei.prototype.booleanish=!1;ei.prototype.boolean=!1;ei.prototype.commaOrSpaceSeparated=!1;ei.prototype.commaSeparated=!1;ei.prototype.defined=!1;ei.prototype.mustUseProperty=!1;ei.prototype.number=!1;ei.prototype.overloadedBoolean=!1;ei.prototype.property="";ei.prototype.spaceSeparated=!1;ei.prototype.space=void 0;let oSe=0;const Qe=jc(),un=jc(),cE=jc(),ye=jc(),It=jc(),Eh=jc(),xi=jc();function jc(){return 2**++oSe}const uE=Object.freeze(Object.defineProperty({__proto__:null,boolean:Qe,booleanish:un,commaOrSpaceSeparated:xi,commaSeparated:Eh,number:ye,overloadedBoolean:cE,spaceSeparated:It},Symbol.toStringTag,{value:"Module"})),v2=Object.keys(uE);class bR extends ei{constructor(e,n,r,i){let s=-1;if(super(e,n),h$(this,"space",i),typeof r=="number")for(;++s<v2.length;){const o=v2[s];h$(this,v2[s],(r&uE[o])===uE[o])}}}bR.prototype.defined=!0;function h$(t,e,n){n&&(t[e]=n)}function of(t){const e={},n={};for(const[r,i]of Object.entries(t.properties)){const s=new bR(r,t.transform(t.attributes||{},r),i,t.space);t.mustUseProperty&&t.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),e[r]=s,n[lE(r)]=r,n[lE(s.attribute)]=r}return new sg(e,n,t.space)}const wW=of({properties:{ariaActiveDescendant:null,ariaAtomic:un,ariaAutoComplete:null,ariaBusy:un,ariaChecked:un,ariaColCount:ye,ariaColIndex:ye,ariaColSpan:ye,ariaControls:It,ariaCurrent:null,ariaDescribedBy:It,ariaDetails:null,ariaDisabled:un,ariaDropEffect:It,ariaErrorMessage:null,ariaExpanded:un,ariaFlowTo:It,ariaGrabbed:un,ariaHasPopup:null,ariaHidden:un,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:It,ariaLevel:ye,ariaLive:null,ariaModal:un,ariaMultiLine:un,ariaMultiSelectable:un,ariaOrientation:null,ariaOwns:It,ariaPlaceholder:null,ariaPosInSet:ye,ariaPressed:un,ariaReadOnly:un,ariaRelevant:null,ariaRequired:un,ariaRoleDescription:It,ariaRowCount:ye,ariaRowIndex:ye,ariaRowSpan:ye,ariaSelected:un,ariaSetSize:ye,ariaSort:null,ariaValueMax:ye,ariaValueMin:ye,ariaValueNow:ye,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function xW(t,e){return e in t?t[e]:e}function SW(t,e){return xW(t,e.toLowerCase())}const aSe=of({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Eh,acceptCharset:It,accessKey:It,action:null,allow:null,allowFullScreen:Qe,allowPaymentRequest:Qe,allowUserMedia:Qe,alt:null,as:null,async:Qe,autoCapitalize:null,autoComplete:It,autoFocus:Qe,autoPlay:Qe,blocking:It,capture:null,charSet:null,checked:Qe,cite:null,className:It,cols:ye,colSpan:null,content:null,contentEditable:un,controls:Qe,controlsList:It,coords:ye|Eh,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Qe,defer:Qe,dir:null,dirName:null,disabled:Qe,download:cE,draggable:un,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Qe,formTarget:null,headers:It,height:ye,hidden:cE,high:ye,href:null,hrefLang:null,htmlFor:It,httpEquiv:It,id:null,imageSizes:null,imageSrcSet:null,inert:Qe,inputMode:null,integrity:null,is:null,isMap:Qe,itemId:null,itemProp:It,itemRef:It,itemScope:Qe,itemType:It,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Qe,low:ye,manifest:null,max:null,maxLength:ye,media:null,method:null,min:null,minLength:ye,multiple:Qe,muted:Qe,name:null,nonce:null,noModule:Qe,noValidate:Qe,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Qe,optimum:ye,pattern:null,ping:It,placeholder:null,playsInline:Qe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Qe,referrerPolicy:null,rel:It,required:Qe,reversed:Qe,rows:ye,rowSpan:ye,sandbox:It,scope:null,scoped:Qe,seamless:Qe,selected:Qe,shadowRootClonable:Qe,shadowRootDelegatesFocus:Qe,shadowRootMode:null,shape:null,size:ye,sizes:null,slot:null,span:ye,spellCheck:un,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ye,step:null,style:null,tabIndex:ye,target:null,title:null,translate:null,type:null,typeMustMatch:Qe,useMap:null,value:un,width:ye,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:It,axis:null,background:null,bgColor:null,border:ye,borderColor:null,bottomMargin:ye,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Qe,declare:Qe,event:null,face:null,frame:null,frameBorder:null,hSpace:ye,leftMargin:ye,link:null,longDesc:null,lowSrc:null,marginHeight:ye,marginWidth:ye,noResize:Qe,noHref:Qe,noShade:Qe,noWrap:Qe,object:null,profile:null,prompt:null,rev:null,rightMargin:ye,rules:null,scheme:null,scrolling:un,standby:null,summary:null,text:null,topMargin:ye,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ye,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Qe,disableRemotePlayback:Qe,prefix:null,property:null,results:ye,security:null,unselectable:null},space:"html",transform:SW}),lSe=of({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:xi,accentHeight:ye,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ye,amplitude:ye,arabicForm:null,ascent:ye,attributeName:null,attributeType:null,azimuth:ye,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ye,by:null,calcMode:null,capHeight:ye,className:It,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ye,diffuseConstant:ye,direction:null,display:null,dur:null,divisor:ye,dominantBaseline:null,download:Qe,dx:null,dy:null,edgeMode:null,editable:null,elevation:ye,enableBackground:null,end:null,event:null,exponent:ye,externalResourcesRequired:null,fill:null,fillOpacity:ye,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Eh,g2:Eh,glyphName:Eh,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ye,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ye,horizOriginX:ye,horizOriginY:ye,id:null,ideographic:ye,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ye,k:ye,k1:ye,k2:ye,k3:ye,k4:ye,kernelMatrix:xi,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ye,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ye,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ye,overlineThickness:ye,paintOrder:null,panose1:null,path:null,pathLength:ye,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:It,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ye,pointsAtY:ye,pointsAtZ:ye,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:xi,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:xi,rev:xi,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:xi,requiredFeatures:xi,requiredFonts:xi,requiredFormats:xi,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ye,specularExponent:ye,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ye,strikethroughThickness:ye,string:null,stroke:null,strokeDashArray:xi,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ye,strokeOpacity:ye,strokeWidth:null,style:null,surfaceScale:ye,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:xi,tabIndex:ye,tableValues:null,target:null,targetX:ye,targetY:ye,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:xi,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ye,underlineThickness:ye,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ye,values:null,vAlphabetic:ye,vMathematical:ye,vectorEffect:null,vHanging:ye,vIdeographic:ye,version:null,vertAdvY:ye,vertOriginX:ye,vertOriginY:ye,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ye,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:xW}),_W=of({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),CW=of({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:SW}),AW=of({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),cSe={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},uSe=/[A-Z]/g,f$=/-[a-z]/g,hSe=/^data[-\w.:]+$/i;function EW(t,e){const n=lE(e);let r=e,i=ei;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&hSe.test(e)){if(e.charAt(4)==="-"){const s=e.slice(5).replace(f$,dSe);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=e.slice(4);if(!f$.test(s)){let o=s.replace(uSe,fSe);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}i=bR}return new i(r,e)}function fSe(t){return"-"+t.toLowerCase()}function dSe(t){return t.charAt(1).toUpperCase()}const kW=vW([wW,aSe,_W,CW,AW],"html"),og=vW([wW,lSe,_W,CW,AW],"svg");function TW(t){return t.join(" ").trim()}var zu={},w2,d$;function pSe(){if(d$)return w2;d$=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,e=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,c=`
`,h="/",f="*",d="",m="comment",y="declaration";w2=function(w,S){if(typeof w!="string")throw new TypeError("First argument must be a string");if(!w)return[];S=S||{};var _=1,A=1;function E(K){var X=K.match(e);X&&(_+=X.length);var ee=K.lastIndexOf(c);A=~ee?K.length-ee:A+K.length}function P(){var K={line:_,column:A};return function(X){return X.position=new O(K),$(),X}}function O(K){this.start=K,this.end={line:_,column:A},this.source=S.source}O.prototype.content=w;function M(K){var X=new Error(S.source+":"+_+":"+A+": "+K);if(X.reason=K,X.filename=S.source,X.line=_,X.column=A,X.source=w,!S.silent)throw X}function D(K){var X=K.exec(w);if(X){var ee=X[0];return E(ee),w=w.slice(ee.length),X}}function $(){D(n)}function F(K){var X;for(K=K||[];X=N();)X!==!1&&K.push(X);return K}function N(){var K=P();if(!(h!=w.charAt(0)||f!=w.charAt(1))){for(var X=2;d!=w.charAt(X)&&(f!=w.charAt(X)||h!=w.charAt(X+1));)++X;if(X+=2,d===w.charAt(X-1))return M("End of comment missing");var ee=w.slice(2,X-2);return A+=2,E(ee),w=w.slice(X),A+=2,K({type:m,comment:ee})}}function U(){var K=P(),X=D(r);if(X){if(N(),!D(i))return M("property missing ':'");var ee=D(s),V=K({type:y,property:b(X[0].replace(t,d)),value:ee?b(ee[0].replace(t,d)):d});return D(o),V}}function q(){var K=[];F(K);for(var X;X=U();)X!==!1&&(K.push(X),F(K));return K}return $(),q()};function b(w){return w?w.replace(a,d):d}return w2}var p$;function mSe(){if(p$)return zu;p$=1;var t=zu&&zu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(zu,"__esModule",{value:!0}),zu.default=n;var e=t(pSe());function n(r,i){var s=null;if(!r||typeof r!="string")return s;var o=(0,e.default)(r),a=typeof i=="function";return o.forEach(function(c){if(c.type==="declaration"){var h=c.property,f=c.value;a?i(h,f,c):f&&(s=s||{},s[h]=f)}}),s}return zu}var jd={},m$;function gSe(){if(m$)return jd;m$=1,Object.defineProperty(jd,"__esModule",{value:!0}),jd.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,e=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(h){return!h||n.test(h)||t.test(h)},o=function(h,f){return f.toUpperCase()},a=function(h,f){return"".concat(f,"-")},c=function(h,f){return f===void 0&&(f={}),s(h)?h:(h=h.toLowerCase(),f.reactCompat?h=h.replace(i,a):h=h.replace(r,a),h.replace(e,o))};return jd.camelCase=c,jd}var Bd,g$;function ySe(){if(g$)return Bd;g$=1;var t=Bd&&Bd.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},e=t(mSe()),n=gSe();function r(i,s){var o={};return!i||typeof i!="string"||(0,e.default)(i,function(a,c){a&&c&&(o[(0,n.camelCase)(a,s)]=c)}),o}return r.default=r,Bd=r,Bd}var bSe=ySe();const vSe=Pc(bSe),RW=MW("end"),vR=MW("start");function MW(t){return e;function e(n){const r=n&&n.position&&n.position[t]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function wSe(t){const e=vR(t),n=RW(t);if(e&&n)return{start:e,end:n}}function $p(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?y$(t.position):"start"in t||"end"in t?y$(t):"line"in t||"column"in t?hE(t):""}function hE(t){return b$(t&&t.line)+":"+b$(t&&t.column)}function y$(t){return hE(t&&t.start)+"-"+hE(t&&t.end)}function b$(t){return t&&typeof t=="number"?t:1}class wr extends Error{constructor(e,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof e=="string"?i=e:!s.cause&&e&&(o=!0,i=e.message,s.cause=e),!s.ruleId&&!s.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?s.ruleId=r:(s.source=r.slice(0,c),s.ruleId=r.slice(c+1))}if(!s.place&&s.ancestors&&s.ancestors){const c=s.ancestors[s.ancestors.length-1];c&&(s.place=c.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=$p(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}wr.prototype.file="";wr.prototype.name="";wr.prototype.reason="";wr.prototype.message="";wr.prototype.stack="";wr.prototype.column=void 0;wr.prototype.line=void 0;wr.prototype.ancestors=void 0;wr.prototype.cause=void 0;wr.prototype.fatal=void 0;wr.prototype.place=void 0;wr.prototype.ruleId=void 0;wr.prototype.source=void 0;const wR={}.hasOwnProperty,xSe=new Map,SSe=/[A-Z]/g,_Se=new Set(["table","tbody","thead","tfoot","tr"]),CSe=new Set(["td","th"]),OW="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function PW(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=e.filePath||void 0;let r;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=PSe(n,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=OSe(n,e.jsx,e.jsxs)}const i={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:r,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?og:kW,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},s=DW(i,t,void 0);return s&&typeof s!="string"?s:i.create(t,i.Fragment,{children:s||void 0},void 0)}function DW(t,e,n){if(e.type==="element")return ASe(t,e,n);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return ESe(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return TSe(t,e,n);if(e.type==="mdxjsEsm")return kSe(t,e);if(e.type==="root")return RSe(t,e,n);if(e.type==="text")return MSe(t,e)}function ASe(t,e,n){const r=t.schema;let i=r;e.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=og,t.schema=i),t.ancestors.push(e);const s=LW(t,e.tagName,!1),o=DSe(t,e);let a=SR(t,e);return _Se.has(e.tagName)&&(a=a.filter(function(c){return typeof c=="string"?!_x(c):!0})),IW(t,o,s,e),xR(o,a),t.ancestors.pop(),t.schema=r,t.create(e,s,o,n)}function ESe(t,e){if(e.data&&e.data.estree&&t.evaluater){const r=e.data.estree.body[0];return r.type,t.evaluater.evaluateExpression(r.expression)}Em(t,e.position)}function kSe(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);Em(t,e.position)}function TSe(t,e,n){const r=t.schema;let i=r;e.name==="svg"&&r.space==="html"&&(i=og,t.schema=i),t.ancestors.push(e);const s=e.name===null?t.Fragment:LW(t,e.name,!0),o=ISe(t,e),a=SR(t,e);return IW(t,o,s,e),xR(o,a),t.ancestors.pop(),t.schema=r,t.create(e,s,o,n)}function RSe(t,e,n){const r={};return xR(r,SR(t,e)),t.create(e,t.Fragment,r,n)}function MSe(t,e){return e.value}function IW(t,e,n,r){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=r)}function xR(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function OSe(t,e,n){return r;function r(i,s,o,a){const h=Array.isArray(o.children)?n:e;return a?h(s,o,a):h(s,o)}}function PSe(t,e){return n;function n(r,i,s,o){const a=Array.isArray(s.children),c=vR(r);return e(i,s,o,a,{columnNumber:c?c.column-1:void 0,fileName:t,lineNumber:c?c.line:void 0},void 0)}}function DSe(t,e){const n={};let r,i;for(i in e.properties)if(i!=="children"&&wR.call(e.properties,i)){const s=LSe(t,i,e.properties[i]);if(s){const[o,a]=s;t.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&CSe.has(e.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function ISe(t,e){const n={};for(const r of e.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&t.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,t.evaluater.evaluateExpression(a.argument))}else Em(t,e.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&t.evaluater){const a=r.value.data.estree.body[0];a.type,s=t.evaluater.evaluateExpression(a.expression)}else Em(t,e.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function SR(t,e){const n=[];let r=-1;const i=t.passKeys?new Map:xSe;for(;++r<e.children.length;){const s=e.children[r];let o;if(t.passKeys){const c=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(c){const h=i.get(c)||0;o=c+"-"+h,i.set(c,h+1)}}const a=DW(t,s,o);a!==void 0&&n.push(a)}return n}function LSe(t,e,n){const r=EW(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?bW(n):TW(n)),r.property==="style"){let i=typeof n=="object"?n:NSe(t,String(n));return t.stylePropertyNameCase==="css"&&(i=$Se(i)),["style",i]}return[t.elementAttributeNameCase==="react"&&r.space?cSe[r.property]||r.property:r.attribute,n]}}function NSe(t,e){try{return vSe(e,{reactCompat:!0})}catch(n){if(t.ignoreInvalidStyle)return{};const r=n,i=new wr("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=t.filePath||void 0,i.url=OW+"#cannot-parse-style-attribute",i}}function LW(t,e,n){let r;if(!n)r={type:"Literal",value:e};else if(e.includes(".")){const i=e.split(".");let s=-1,o;for(;++s<i.length;){const a=c$(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=c$(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(r.type==="Literal"){const i=r.value;return wR.call(t.components,i)?t.components[i]:i}if(t.evaluater)return t.evaluater.evaluateExpression(r);Em(t)}function Em(t,e){const n=new wr("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=t.filePath||void 0,n.url=OW+"#cannot-handle-mdx-estrees-without-createevaluater",n}function $Se(t){const e={};let n;for(n in t)wR.call(t,n)&&(e[jSe(n)]=t[n]);return e}function jSe(t){let e=t.replace(SSe,BSe);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function BSe(t){return"-"+t.toLowerCase()}const x2={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},FSe={tokenize:zSe};function zSe(t){const e=t.attempt(this.parser.constructs.contentInitial,r,i);let n;return e;function r(a){if(a===null){t.consume(a);return}return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),ut(t,e,"linePrefix")}function i(a){return t.enter("paragraph"),s(a)}function s(a){const c=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,o(a)}function o(a){if(a===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(a);return}return Be(a)?(t.consume(a),t.exit("chunkText"),s):(t.consume(a),o)}}const VSe={tokenize:USe},v$={tokenize:HSe};function USe(t){const e=this,n=[];let r=0,i,s,o;return a;function a(E){if(r<n.length){const P=n[r];return e.containerState=P[1],t.attempt(P[0].continuation,c,h)(E)}return h(E)}function c(E){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&A();const P=e.events.length;let O=P,M;for(;O--;)if(e.events[O][0]==="exit"&&e.events[O][1].type==="chunkFlow"){M=e.events[O][1].end;break}_(r);let D=P;for(;D<e.events.length;)e.events[D][1].end={...M},D++;return ki(e.events,O+1,0,e.events.slice(P)),e.events.length=D,h(E)}return a(E)}function h(E){if(r===n.length){if(!i)return m(E);if(i.currentConstruct&&i.currentConstruct.concrete)return b(E);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(v$,f,d)(E)}function f(E){return i&&A(),_(r),m(E)}function d(E){return e.parser.lazy[e.now().line]=r!==n.length,o=e.now().offset,b(E)}function m(E){return e.containerState={},t.attempt(v$,y,b)(E)}function y(E){return r++,n.push([e.currentConstruct,e.containerState]),m(E)}function b(E){if(E===null){i&&A(),_(0),t.consume(E);return}return i=i||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),w(E)}function w(E){if(E===null){S(t.exit("chunkFlow"),!0),_(0),t.consume(E);return}return Be(E)?(t.consume(E),S(t.exit("chunkFlow")),r=0,e.interrupt=void 0,a):(t.consume(E),w)}function S(E,P){const O=e.sliceStream(E);if(P&&O.push(null),E.previous=s,s&&(s.next=E),s=E,i.defineSkip(E.start),i.write(O),e.parser.lazy[E.start.line]){let M=i.events.length;for(;M--;)if(i.events[M][1].start.offset<o&&(!i.events[M][1].end||i.events[M][1].end.offset>o))return;const D=e.events.length;let $=D,F,N;for(;$--;)if(e.events[$][0]==="exit"&&e.events[$][1].type==="chunkFlow"){if(F){N=e.events[$][1].end;break}F=!0}for(_(r),M=D;M<e.events.length;)e.events[M][1].end={...N},M++;ki(e.events,$+1,0,e.events.slice(D)),e.events.length=M}}function _(E){let P=n.length;for(;P-- >E;){const O=n[P];e.containerState=O[1],O[0].exit.call(e,t)}n.length=E}function A(){i.write([null]),s=void 0,i=void 0,e.containerState._closeFlow=void 0}}function HSe(t,e,n){return ut(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}const WSe={tokenize:qSe};function qSe(t){const e=this,n=t.attempt(ig,r,t.attempt(this.parser.constructs.flowInitial,i,ut(t,t.attempt(this.parser.constructs.flow,i,t.attempt(Bxe,i)),"linePrefix")));return n;function r(s){if(s===null){t.consume(s);return}return t.enter("lineEndingBlank"),t.consume(s),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function i(s){if(s===null){t.consume(s);return}return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),e.currentConstruct=void 0,n}}const GSe={resolveAll:$W()},KSe=NW("string"),YSe=NW("text");function NW(t){return{resolveAll:$W(t==="text"?XSe:void 0),tokenize:e};function e(n){const r=this,i=this.parser.constructs[t],s=n.attempt(i,o,a);return o;function o(f){return h(f)?s(f):a(f)}function a(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),c}function c(f){return h(f)?(n.exit("data"),s(f)):(n.consume(f),c)}function h(f){if(f===null)return!0;const d=i[f];let m=-1;if(d)for(;++m<d.length;){const y=d[m];if(!y.previous||y.previous.call(r,r.previous))return!0}return!1}}}function $W(t){return e;function e(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return t?t(n,r):n}}function XSe(t,e){let n=0;for(;++n<=t.length;)if((n===t.length||t[n][1].type==="lineEnding")&&t[n-1][1].type==="data"){const r=t[n-1][1],i=e.sliceStream(r);let s=i.length,o=-1,a=0,c;for(;s--;){const h=i[s];if(typeof h=="string"){for(o=h.length;h.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(h===-2)c=!0,a++;else if(h!==-1){s++;break}}if(e._contentTypeTextTrailing&&n===t.length&&(a=0),a){const h={type:n===t.length||c||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...h.start},r.start.offset===r.end.offset?Object.assign(r,h):(t.splice(n,0,["enter",h,e],["exit",h,e]),n+=2)}n++}return t}const JSe={42:Ur,43:Ur,45:Ur,48:Ur,49:Ur,50:Ur,51:Ur,52:Ur,53:Ur,54:Ur,55:Ur,56:Ur,57:Ur,62:hW},QSe={91:Hxe},ZSe={[-2]:y2,[-1]:y2,32:y2},e_e={35:Xxe,42:Wb,45:[a$,Wb],60:e1e,61:a$,95:Wb,96:s$,126:s$},t_e={38:dW,92:fW},n_e={[-5]:b2,[-4]:b2,[-3]:b2,33:b1e,38:dW,42:aE,60:[wxe,a1e],91:w1e,92:[Kxe,fW],93:yR,95:aE,96:Dxe},r_e={null:[aE,GSe]},i_e={null:[42,95]},s_e={null:[]},o_e=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:i_e,contentInitial:QSe,disable:s_e,document:JSe,flow:e_e,flowInitial:ZSe,insideSpan:r_e,string:t_e,text:n_e},Symbol.toStringTag,{value:"Module"}));function a_e(t,e,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const c={attempt:D(O),check:D(M),consume:A,enter:E,exit:P,interrupt:D(M,{interrupt:!0})},h={code:null,containerState:{},defineSkip:w,events:[],now:b,parser:t,previous:null,sliceSerialize:m,sliceStream:y,write:d};let f=e.tokenize.call(h,c);return e.resolveAll&&s.push(e),h;function d(U){return o=qi(o,U),S(),o[o.length-1]!==null?[]:($(e,0),h.events=Sx(s,h.events,h),h.events)}function m(U,q){return c_e(y(U),q)}function y(U){return l_e(o,U)}function b(){const{_bufferIndex:U,_index:q,line:K,column:X,offset:ee}=r;return{_bufferIndex:U,_index:q,line:K,column:X,offset:ee}}function w(U){i[U.line]=U.column,N()}function S(){let U;for(;r._index<o.length;){const q=o[r._index];if(typeof q=="string")for(U=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===U&&r._bufferIndex<q.length;)_(q.charCodeAt(r._bufferIndex));else _(q)}}function _(U){f=f(U)}function A(U){Be(U)?(r.line++,r.column=1,r.offset+=U===-3?2:1,N()):U!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=U}function E(U,q){const K=q||{};return K.type=U,K.start=b(),h.events.push(["enter",K,h]),a.push(K),K}function P(U){const q=a.pop();return q.end=b(),h.events.push(["exit",q,h]),q}function O(U,q){$(U,q.from)}function M(U,q){q.restore()}function D(U,q){return K;function K(X,ee,V){let G,H,se,T;return Array.isArray(X)?ue(X):"tokenize"in X?ue([X]):Z(X);function Z(be){return Ee;function Ee(Ue){const Pt=Ue!==null&&be[Ue],Kt=Ue!==null&&be.null,Yt=[...Array.isArray(Pt)?Pt:Pt?[Pt]:[],...Array.isArray(Kt)?Kt:Kt?[Kt]:[]];return ue(Yt)(Ue)}}function ue(be){return G=be,H=0,be.length===0?V:L(be[H])}function L(be){return Ee;function Ee(Ue){return T=F(),se=be,be.partial||(h.currentConstruct=be),be.name&&h.parser.constructs.disable.null.includes(be.name)?ke():be.tokenize.call(q?Object.assign(Object.create(h),q):h,c,pe,ke)(Ue)}}function pe(be){return U(se,T),ee}function ke(be){return T.restore(),++H<G.length?L(G[H]):V}}}function $(U,q){U.resolveAll&&!s.includes(U)&&s.push(U),U.resolve&&ki(h.events,q,h.events.length-q,U.resolve(h.events.slice(q),h)),U.resolveTo&&(h.events=U.resolveTo(h.events,h))}function F(){const U=b(),q=h.previous,K=h.currentConstruct,X=h.events.length,ee=Array.from(a);return{from:X,restore:V};function V(){r=U,h.previous=q,h.currentConstruct=K,h.events.length=X,a=ee,N()}}function N(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function l_e(t,e){const n=e.start._index,r=e.start._bufferIndex,i=e.end._index,s=e.end._bufferIndex;let o;if(n===i)o=[t[n].slice(r,s)];else{if(o=t.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(t[i].slice(0,s))}return o}function c_e(t,e){let n=-1;const r=[];let i;for(;++n<t.length;){const s=t[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
`;break}case-3:{o=`\r
`;break}case-2:{o=e?" ":" ";break}case-1:{if(!e&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function u_e(t){const r={constructs:nW([o_e,...(t||{}).extensions||[]]),content:i(FSe),defined:[],document:i(VSe),flow:i(WSe),lazy:{},string:i(KSe),text:i(YSe)};return r;function i(s){return o;function o(a){return a_e(r,s,a)}}}function h_e(t){for(;!pW(t););return t}const w$=/[\0\t\n\r]/g;function f_e(){let t=1,e="",n=!0,r;return i;function i(s,o,a){const c=[];let h,f,d,m,y;for(s=e+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),d=0,e="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(w$.lastIndex=d,h=w$.exec(s),m=h&&h.index!==void 0?h.index:s.length,y=s.charCodeAt(m),!h){e=s.slice(d);break}if(y===10&&d===m&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),d<m&&(c.push(s.slice(d,m)),t+=m-d),y){case 0:{c.push(65533),t++;break}case 9:{for(f=Math.ceil(t/4)*4,c.push(-2);t++<f;)c.push(-1);break}case 10:{c.push(-4),t=1;break}default:r=!0,t=1}d=m+1}return a&&(r&&c.push(-5),e&&c.push(e),c.push(null)),c}}const jW={}.hasOwnProperty;function d_e(t,e,n){return typeof e!="string"&&(n=e,e=void 0),p_e(n)(h_e(u_e(n).document().write(f_e()(t,e,!0))))}function p_e(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(kl),autolinkProtocol:F,autolinkEmail:F,atxHeading:s(_o),blockQuote:s(Kt),characterEscape:F,characterReference:F,codeFenced:s(Yt),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Yt,o),codeText:s(er,o),codeTextData:F,data:F,codeFlowValue:F,definition:s(tr),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(ti),hardBreakEscape:s(ss),hardBreakTrailing:s(ss),htmlFlow:s(nr,o),htmlFlowData:F,htmlText:s(nr,o),htmlTextData:F,image:s(lf),label:o,link:s(kl),listItem:s(Ds),listItemValue:m,listOrdered:s(Ps,d),listUnordered:s(Ps),paragraph:s(Bc),reference:L,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(_o),strong:s(Tl),thematicBreak:s(aa)},exit:{atxHeading:c(),atxHeadingSequence:O,autolink:c(),autolinkEmail:Pt,autolinkProtocol:Ue,blockQuote:c(),characterEscapeValue:N,characterReferenceMarkerHexadecimal:ke,characterReferenceMarkerNumeric:ke,characterReferenceValue:be,characterReference:Ee,codeFenced:c(S),codeFencedFence:w,codeFencedFenceInfo:y,codeFencedFenceMeta:b,codeFlowValue:N,codeIndented:c(_),codeText:c(ee),codeTextData:N,data:N,definition:c(),definitionDestinationString:P,definitionLabelString:A,definitionTitleString:E,emphasis:c(),hardBreakEscape:c(q),hardBreakTrailing:c(q),htmlFlow:c(K),htmlFlowData:N,htmlText:c(X),htmlTextData:N,image:c(G),label:se,labelText:H,lineEnding:U,link:c(V),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:pe,resourceDestinationString:T,resourceTitleString:Z,resource:ue,setextHeading:c($),setextHeadingLineSequence:D,setextHeadingText:M,strong:c(),thematicBreak:c()}};BW(e,(t||{}).mdastExtensions||[]);const n={};return r;function r(oe){let ge={type:"root",children:[]};const De={stack:[ge],tokenStack:[],config:e,enter:a,exit:h,buffer:o,resume:f,data:n},$e=[];let yt=-1;for(;++yt<oe.length;)if(oe[yt][1].type==="listOrdered"||oe[yt][1].type==="listUnordered")if(oe[yt][0]==="enter")$e.push(yt);else{const Sr=$e.pop();yt=i(oe,Sr,yt)}for(yt=-1;++yt<oe.length;){const Sr=e[oe[yt][0]];jW.call(Sr,oe[yt][1].type)&&Sr[oe[yt][1].type].call(Object.assign({sliceSerialize:oe[yt][2].sliceSerialize},De),oe[yt][1])}if(De.tokenStack.length>0){const Sr=De.tokenStack[De.tokenStack.length-1];(Sr[1]||x$).call(De,void 0,Sr[0])}for(ge.position={start:Ga(oe.length>0?oe[0][1].start:{line:1,column:1,offset:0}),end:Ga(oe.length>0?oe[oe.length-2][1].end:{line:1,column:1,offset:0})},yt=-1;++yt<e.transforms.length;)ge=e.transforms[yt](ge)||ge;return ge}function i(oe,ge,De){let $e=ge-1,yt=-1,Sr=!1,os,rr,ni,_r;for(;++$e<=De;){const on=oe[$e];switch(on[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{on[0]==="enter"?yt++:yt--,_r=void 0;break}case"lineEndingBlank":{on[0]==="enter"&&(os&&!_r&&!yt&&!ni&&(ni=$e),_r=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:_r=void 0}if(!yt&&on[0]==="enter"&&on[1].type==="listItemPrefix"||yt===-1&&on[0]==="exit"&&(on[1].type==="listUnordered"||on[1].type==="listOrdered")){if(os){let ir=$e;for(rr=void 0;ir--;){const Bn=oe[ir];if(Bn[1].type==="lineEnding"||Bn[1].type==="lineEndingBlank"){if(Bn[0]==="exit")continue;rr&&(oe[rr][1].type="lineEndingBlank",Sr=!0),Bn[1].type="lineEnding",rr=ir}else if(!(Bn[1].type==="linePrefix"||Bn[1].type==="blockQuotePrefix"||Bn[1].type==="blockQuotePrefixWhitespace"||Bn[1].type==="blockQuoteMarker"||Bn[1].type==="listItemIndent"))break}ni&&(!rr||ni<rr)&&(os._spread=!0),os.end=Object.assign({},rr?oe[rr][1].start:on[1].end),oe.splice(rr||$e,0,["exit",os,on[2]]),$e++,De++}if(on[1].type==="listItemPrefix"){const ir={type:"listItem",_spread:!1,start:Object.assign({},on[1].start),end:void 0};os=ir,oe.splice($e,0,["enter",ir,on[2]]),$e++,De++,ni=void 0,_r=!0}}}return oe[ge][1]._spread=Sr,De}function s(oe,ge){return De;function De($e){a.call(this,oe($e),$e),ge&&ge.call(this,$e)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(oe,ge,De){this.stack[this.stack.length-1].children.push(oe),this.stack.push(oe),this.tokenStack.push([ge,De||void 0]),oe.position={start:Ga(ge.start),end:void 0}}function c(oe){return ge;function ge(De){oe&&oe.call(this,De),h.call(this,De)}}function h(oe,ge){const De=this.stack.pop(),$e=this.tokenStack.pop();if($e)$e[0].type!==oe.type&&(ge?ge.call(this,oe,$e[0]):($e[1]||x$).call(this,oe,$e[0]));else throw new Error("Cannot close `"+oe.type+"` ("+$p({start:oe.start,end:oe.end})+"): its not open");De.position.end=Ga(oe.end)}function f(){return dR(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function m(oe){if(this.data.expectingFirstListItemValue){const ge=this.stack[this.stack.length-2];ge.start=Number.parseInt(this.sliceSerialize(oe),10),this.data.expectingFirstListItemValue=void 0}}function y(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.lang=oe}function b(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.meta=oe}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.value=oe.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.value=oe.replace(/(\r?\n|\r)$/g,"")}function A(oe){const ge=this.resume(),De=this.stack[this.stack.length-1];De.label=ge,De.identifier=ws(this.sliceSerialize(oe)).toLowerCase()}function E(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.title=oe}function P(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.url=oe}function O(oe){const ge=this.stack[this.stack.length-1];if(!ge.depth){const De=this.sliceSerialize(oe).length;ge.depth=De}}function M(){this.data.setextHeadingSlurpLineEnding=!0}function D(oe){const ge=this.stack[this.stack.length-1];ge.depth=this.sliceSerialize(oe).codePointAt(0)===61?1:2}function $(){this.data.setextHeadingSlurpLineEnding=void 0}function F(oe){const De=this.stack[this.stack.length-1].children;let $e=De[De.length-1];(!$e||$e.type!=="text")&&($e=Mi(),$e.position={start:Ga(oe.start),end:void 0},De.push($e)),this.stack.push($e)}function N(oe){const ge=this.stack.pop();ge.value+=this.sliceSerialize(oe),ge.position.end=Ga(oe.end)}function U(oe){const ge=this.stack[this.stack.length-1];if(this.data.atHardBreak){const De=ge.children[ge.children.length-1];De.position.end=Ga(oe.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(ge.type)&&(F.call(this,oe),N.call(this,oe))}function q(){this.data.atHardBreak=!0}function K(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.value=oe}function X(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.value=oe}function ee(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.value=oe}function V(){const oe=this.stack[this.stack.length-1];if(this.data.inReference){const ge=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=ge,delete oe.url,delete oe.title}else delete oe.identifier,delete oe.label;this.data.referenceType=void 0}function G(){const oe=this.stack[this.stack.length-1];if(this.data.inReference){const ge=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=ge,delete oe.url,delete oe.title}else delete oe.identifier,delete oe.label;this.data.referenceType=void 0}function H(oe){const ge=this.sliceSerialize(oe),De=this.stack[this.stack.length-2];De.label=Hwe(ge),De.identifier=ws(ge).toLowerCase()}function se(){const oe=this.stack[this.stack.length-1],ge=this.resume(),De=this.stack[this.stack.length-1];if(this.data.inReference=!0,De.type==="link"){const $e=oe.children;De.children=$e}else De.alt=ge}function T(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.url=oe}function Z(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.title=oe}function ue(){this.data.inReference=void 0}function L(){this.data.referenceType="collapsed"}function pe(oe){const ge=this.resume(),De=this.stack[this.stack.length-1];De.label=ge,De.identifier=ws(this.sliceSerialize(oe)).toLowerCase(),this.data.referenceType="full"}function ke(oe){this.data.characterReferenceType=oe.type}function be(oe){const ge=this.sliceSerialize(oe),De=this.data.characterReferenceType;let $e;De?($e=tW(ge,De==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):$e=mR(ge);const yt=this.stack[this.stack.length-1];yt.value+=$e}function Ee(oe){const ge=this.stack.pop();ge.position.end=Ga(oe.end)}function Ue(oe){N.call(this,oe);const ge=this.stack[this.stack.length-1];ge.url=this.sliceSerialize(oe)}function Pt(oe){N.call(this,oe);const ge=this.stack[this.stack.length-1];ge.url="mailto:"+this.sliceSerialize(oe)}function Kt(){return{type:"blockquote",children:[]}}function Yt(){return{type:"code",lang:null,meta:null,value:""}}function er(){return{type:"inlineCode",value:""}}function tr(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ti(){return{type:"emphasis",children:[]}}function _o(){return{type:"heading",depth:0,children:[]}}function ss(){return{type:"break"}}function nr(){return{type:"html",value:""}}function lf(){return{type:"image",title:null,url:"",alt:null}}function kl(){return{type:"link",title:null,url:"",children:[]}}function Ps(oe){return{type:"list",ordered:oe.type==="listOrdered",start:null,spread:oe._spread,children:[]}}function Ds(oe){return{type:"listItem",spread:oe._spread,checked:null,children:[]}}function Bc(){return{type:"paragraph",children:[]}}function Tl(){return{type:"strong",children:[]}}function Mi(){return{type:"text",value:""}}function aa(){return{type:"thematicBreak"}}}function Ga(t){return{line:t.line,column:t.column,offset:t.offset}}function BW(t,e){let n=-1;for(;++n<e.length;){const r=e[n];Array.isArray(r)?BW(t,r):m_e(t,r)}}function m_e(t,e){let n;for(n in e)if(jW.call(e,n))switch(n){case"canContainEols":{const r=e[n];r&&t[n].push(...r);break}case"transforms":{const r=e[n];r&&t[n].push(...r);break}case"enter":case"exit":{const r=e[n];r&&Object.assign(t[n],r);break}}}function x$(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+$p({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+$p({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+$p({start:e.start,end:e.end})+") is still open")}function g_e(t){const e=this;e.parser=n;function n(r){return d_e(r,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function y_e(t,e){const n={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,n),t.applyData(e,n)}function b_e(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:`
`}]}function v_e(t,e){const n=e.value?e.value+`
`:"",r={};e.lang&&(r.className=["language-"+e.lang]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return e.meta&&(i.data={meta:e.meta}),t.patch(e,i),i=t.applyData(e,i),i={type:"element",tagName:"pre",properties:{},children:[i]},t.patch(e,i),i}function w_e(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function x_e(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function S_e(t,e){const n=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",r=String(e.identifier).toUpperCase(),i=sf(r.toLowerCase()),s=t.footnoteOrder.indexOf(r);let o,a=t.footnoteCounts.get(r);a===void 0?(a=0,t.footnoteOrder.push(r),o=t.footnoteOrder.length):o=s+1,a+=1,t.footnoteCounts.set(r,a);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};t.patch(e,c);const h={type:"element",tagName:"sup",properties:{},children:[c]};return t.patch(e,h),t.applyData(e,h)}function __e(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function C_e(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}}function FW(t,e){const n=e.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+r}];const i=t.all(e),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function A_e(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return FW(t,e);const i={src:sf(r.url||""),alt:e.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return t.patch(e,s),t.applyData(e,s)}function E_e(t,e){const n={src:sf(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,r),t.applyData(e,r)}function k_e(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,r),t.applyData(e,r)}function T_e(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return FW(t,e);const i={href:sf(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:t.all(e)};return t.patch(e,s),t.applyData(e,s)}function R_e(t,e){const n={href:sf(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function M_e(t,e,n){const r=t.all(e),i=n?O_e(n):zW(e),s={},o=[];if(typeof e.checked=="boolean"){const f=r[0];let d;f&&f.type==="element"&&f.tagName==="p"?d=f:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const f=r[a];(i||a!==0||f.type!=="element"||f.tagName!=="p")&&o.push({type:"text",value:`
`}),f.type==="element"&&f.tagName==="p"&&!i?o.push(...f.children):o.push(f)}const c=r[r.length-1];c&&(i||c.type!=="element"||c.tagName!=="p")&&o.push({type:"text",value:`
`});const h={type:"element",tagName:"li",properties:s,children:o};return t.patch(e,h),t.applyData(e,h)}function O_e(t){let e=!1;if(t.type==="list"){e=t.spread||!1;const n=t.children;let r=-1;for(;!e&&++r<n.length;)e=zW(n[r])}return e}function zW(t){const e=t.spread;return e??t.children.length>1}function P_e(t,e){const n={},r=t.all(e);let i=-1;for(typeof e.start=="number"&&e.start!==1&&(n.start=e.start);++i<r.length;){const o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:e.ordered?"ol":"ul",properties:n,children:t.wrap(r,!0)};return t.patch(e,s),t.applyData(e,s)}function D_e(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function I_e(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)}function L_e(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function N_e(t,e){const n=t.all(e),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:t.wrap([r],!0)};t.patch(e.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:t.wrap(n,!0)},a=vR(e.children[1]),c=RW(e.children[e.children.length-1]);a&&c&&(o.position={start:a,end:c}),i.push(o)}const s={type:"element",tagName:"table",properties:{},children:t.wrap(i,!0)};return t.patch(e,s),t.applyData(e,s)}function $_e(t,e,n){const r=n?n.children:void 0,s=(r?r.indexOf(e):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:e.children.length;let c=-1;const h=[];for(;++c<a;){const d=e.children[c],m={},y=o?o[c]:void 0;y&&(m.align=y);let b={type:"element",tagName:s,properties:m,children:[]};d&&(b.children=t.all(d),t.patch(d,b),b=t.applyData(d,b)),h.push(b)}const f={type:"element",tagName:"tr",properties:{},children:t.wrap(h,!0)};return t.patch(e,f),t.applyData(e,f)}function j_e(t,e){const n={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}const S$=9,_$=32;function B_e(t){const e=String(t),n=/\r?\n|\r/g;let r=n.exec(e),i=0;const s=[];for(;r;)s.push(C$(e.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(e);return s.push(C$(e.slice(i),i>0,!1)),s.join("")}function C$(t,e,n){let r=0,i=t.length;if(e){let s=t.codePointAt(r);for(;s===S$||s===_$;)r++,s=t.codePointAt(r)}if(n){let s=t.codePointAt(i-1);for(;s===S$||s===_$;)i--,s=t.codePointAt(i-1)}return i>r?t.slice(r,i):""}function F_e(t,e){const n={type:"text",value:B_e(String(e.value))};return t.patch(e,n),t.applyData(e,n)}function z_e(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)}const V_e={blockquote:y_e,break:b_e,code:v_e,delete:w_e,emphasis:x_e,footnoteReference:S_e,heading:__e,html:C_e,imageReference:A_e,image:E_e,inlineCode:k_e,linkReference:T_e,link:R_e,listItem:M_e,list:P_e,paragraph:D_e,root:I_e,strong:L_e,table:N_e,tableCell:j_e,tableRow:$_e,text:F_e,thematicBreak:z_e,toml:Xy,yaml:Xy,definition:Xy,footnoteDefinition:Xy};function Xy(){}const VW=-1,Cx=0,jp=1,nw=2,_R=3,CR=4,AR=5,ER=6,UW=7,HW=8,A$=typeof self=="object"?self:globalThis,U_e=(t,e)=>{const n=(i,s)=>(t.set(s,i),i),r=i=>{if(t.has(i))return t.get(i);const[s,o]=e[i];switch(s){case Cx:case VW:return n(o,i);case jp:{const a=n([],i);for(const c of o)a.push(r(c));return a}case nw:{const a=n({},i);for(const[c,h]of o)a[r(c)]=r(h);return a}case _R:return n(new Date(o),i);case CR:{const{source:a,flags:c}=o;return n(new RegExp(a,c),i)}case AR:{const a=n(new Map,i);for(const[c,h]of o)a.set(r(c),r(h));return a}case ER:{const a=n(new Set,i);for(const c of o)a.add(r(c));return a}case UW:{const{name:a,message:c}=o;return n(new A$[a](c),i)}case HW:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return n(new DataView(a),o)}}return n(new A$[s](o),i)};return r},E$=t=>U_e(new Map,t)(0),Vu="",{toString:H_e}={},{keys:W_e}=Object,Fd=t=>{const e=typeof t;if(e!=="object"||!t)return[Cx,e];const n=H_e.call(t).slice(8,-1);switch(n){case"Array":return[jp,Vu];case"Object":return[nw,Vu];case"Date":return[_R,Vu];case"RegExp":return[CR,Vu];case"Map":return[AR,Vu];case"Set":return[ER,Vu];case"DataView":return[jp,n]}return n.includes("Array")?[jp,n]:n.includes("Error")?[UW,n]:[nw,n]},Jy=([t,e])=>t===Cx&&(e==="function"||e==="symbol"),q_e=(t,e,n,r)=>{const i=(o,a)=>{const c=r.push(o)-1;return n.set(a,c),c},s=o=>{if(n.has(o))return n.get(o);let[a,c]=Fd(o);switch(a){case Cx:{let f=o;switch(c){case"bigint":a=HW,f=o.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+c);f=null;break;case"undefined":return i([VW],o)}return i([a,f],o)}case jp:{if(c){let m=o;return c==="DataView"?m=new Uint8Array(o.buffer):c==="ArrayBuffer"&&(m=new Uint8Array(o)),i([c,[...m]],o)}const f=[],d=i([a,f],o);for(const m of o)f.push(s(m));return d}case nw:{if(c)switch(c){case"BigInt":return i([c,o.toString()],o);case"Boolean":case"Number":case"String":return i([c,o.valueOf()],o)}if(e&&"toJSON"in o)return s(o.toJSON());const f=[],d=i([a,f],o);for(const m of W_e(o))(t||!Jy(Fd(o[m])))&&f.push([s(m),s(o[m])]);return d}case _R:return i([a,o.toISOString()],o);case CR:{const{source:f,flags:d}=o;return i([a,{source:f,flags:d}],o)}case AR:{const f=[],d=i([a,f],o);for(const[m,y]of o)(t||!(Jy(Fd(m))||Jy(Fd(y))))&&f.push([s(m),s(y)]);return d}case ER:{const f=[],d=i([a,f],o);for(const m of o)(t||!Jy(Fd(m)))&&f.push(s(m));return d}}const{message:h}=o;return i([a,{name:c,message:h}],o)};return s},k$=(t,{json:e,lossy:n}={})=>{const r=[];return q_e(!(e||n),!!e,new Map,r)(t),r},rw=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?E$(k$(t,e)):structuredClone(t):(t,e)=>E$(k$(t,e));function G_e(t,e){const n=[{type:"text",value:"↩"}];return e>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),n}function K_e(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function Y_e(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=t.options.footnoteBackContent||G_e,r=t.options.footnoteBackLabel||K_e,i=t.options.footnoteLabel||"Footnotes",s=t.options.footnoteLabelTagName||"h2",o=t.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let c=-1;for(;++c<t.footnoteOrder.length;){const h=t.footnoteById.get(t.footnoteOrder[c]);if(!h)continue;const f=t.all(h),d=String(h.identifier).toUpperCase(),m=sf(d.toLowerCase());let y=0;const b=[],w=t.footnoteCounts.get(d);for(;w!==void 0&&++y<=w;){b.length>0&&b.push({type:"text",value:" "});let A=typeof n=="string"?n:n(c,y);typeof A=="string"&&(A={type:"text",value:A}),b.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+m+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,y),className:["data-footnote-backref"]},children:Array.isArray(A)?A:[A]})}const S=f[f.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const A=S.children[S.children.length-1];A&&A.type==="text"?A.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...b)}else f.push(...b);const _={type:"element",tagName:"li",properties:{id:e+"fn-"+m},children:t.wrap(f,!0)};t.patch(h,_),a.push(_)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...rw(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
`},{type:"element",tagName:"ol",properties:{},children:t.wrap(a,!0)},{type:"text",value:`
`}]}}const fE={}.hasOwnProperty,X_e={};function J_e(t,e){const n=e||X_e,r=new Map,i=new Map,s=new Map,o={...V_e,...n.handlers},a={all:h,applyData:Z_e,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:c,options:n,patch:Q_e,wrap:t2e};return fR(t,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const d=f.type==="definition"?r:i,m=String(f.identifier).toUpperCase();d.has(m)||d.set(m,f)}}),a;function c(f,d){const m=f.type,y=a.handlers[m];if(fE.call(a.handlers,m)&&y)return y(a,f,d);if(a.options.passThrough&&a.options.passThrough.includes(m)){if("children"in f){const{children:w,...S}=f,_=rw(S);return _.children=a.all(f),_}return rw(f)}return(a.options.unknownHandler||e2e)(a,f,d)}function h(f){const d=[];if("children"in f){const m=f.children;let y=-1;for(;++y<m.length;){const b=a.one(m[y],f);if(b){if(y&&m[y-1].type==="break"&&(!Array.isArray(b)&&b.type==="text"&&(b.value=T$(b.value)),!Array.isArray(b)&&b.type==="element")){const w=b.children[0];w&&w.type==="text"&&(w.value=T$(w.value))}Array.isArray(b)?d.push(...b):d.push(b)}}}return d}}function Q_e(t,e){t.position&&(e.position=wSe(t))}function Z_e(t,e){let n=e;if(t&&t.data){const r=t.data.hName,i=t.data.hChildren,s=t.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&s&&Object.assign(n.properties,rw(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function e2e(t,e){const n=e.data||{},r="value"in e&&!(fE.call(n,"hProperties")||fE.call(n,"hChildren"))?{type:"text",value:e.value}:{type:"element",tagName:"div",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function t2e(t,e){const n=[];let r=-1;for(e&&n.push({type:"text",value:`
`});++r<t.length;)r&&n.push({type:"text",value:`
`}),n.push(t[r]);return e&&t.length>0&&n.push({type:"text",value:`
`}),n}function T$(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function R$(t,e){const n=J_e(t,e),r=n.one(t,void 0),i=Y_e(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
`},i),s}function n2e(t,e){return t&&"run"in t?async function(n,r){const i=R$(n,{file:r,...e});await t.run(i,r)}:function(n,r){return R$(n,{file:r,...t||e})}}function M$(t){if(t)throw t}var S2,O$;function r2e(){if(O$)return S2;O$=1;var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(h){return typeof Array.isArray=="function"?Array.isArray(h):e.call(h)==="[object Array]"},s=function(h){if(!h||e.call(h)!=="[object Object]")return!1;var f=t.call(h,"constructor"),d=h.constructor&&h.constructor.prototype&&t.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!f&&!d)return!1;var m;for(m in h);return typeof m>"u"||t.call(h,m)},o=function(h,f){n&&f.name==="__proto__"?n(h,f.name,{enumerable:!0,configurable:!0,value:f.newValue,writable:!0}):h[f.name]=f.newValue},a=function(h,f){if(f==="__proto__")if(t.call(h,f)){if(r)return r(h,f).value}else return;return h[f]};return S2=function c(){var h,f,d,m,y,b,w=arguments[0],S=1,_=arguments.length,A=!1;for(typeof w=="boolean"&&(A=w,w=arguments[1]||{},S=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});S<_;++S)if(h=arguments[S],h!=null)for(f in h)d=a(w,f),m=a(h,f),w!==m&&(A&&m&&(s(m)||(y=i(m)))?(y?(y=!1,b=d&&i(d)?d:[]):b=d&&s(d)?d:{},o(w,{name:f,newValue:c(A,b,m)})):typeof m<"u"&&o(w,{name:f,newValue:m}));return w},S2}var i2e=r2e();const _2=Pc(i2e);function dE(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function s2e(){const t=[],e={run:n,use:r};return e;function n(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(c,...h){const f=t[++s];let d=-1;if(c){o(c);return}for(;++d<i.length;)(h[d]===null||h[d]===void 0)&&(h[d]=i[d]);i=h,f?o2e(f,a)(...h):o(null,...h)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return t.push(i),e}}function o2e(t,e){let n;return r;function r(...o){const a=t.length>o.length;let c;a&&o.push(i);try{c=t.apply(this,o)}catch(h){const f=h;if(a&&n)throw f;return i(f)}a||(c&&c.then&&typeof c.then=="function"?c.then(s,i):c instanceof Error?i(c):s(c))}function i(o,...a){n||(n=!0,e(o,...a))}function s(o){i(null,o)}}const Js={basename:a2e,dirname:l2e,extname:c2e,join:u2e,sep:"/"};function a2e(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');ag(t);let n=0,r=-1,i=t.length,s;if(e===void 0||e.length===0||e.length>t.length){for(;i--;)if(t.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":t.slice(n,r)}if(e===t)return"";let o=-1,a=e.length-1;for(;i--;)if(t.codePointAt(i)===47){if(s){n=i+1;break}}else o<0&&(s=!0,o=i+1),a>-1&&(t.codePointAt(i)===e.codePointAt(a--)?a<0&&(r=i):(a=-1,r=o));return n===r?r=o:r<0&&(r=t.length),t.slice(n,r)}function l2e(t){if(ag(t),t.length===0)return".";let e=-1,n=t.length,r;for(;--n;)if(t.codePointAt(n)===47){if(r){e=n;break}}else r||(r=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function c2e(t){ag(t);let e=t.length,n=-1,r=0,i=-1,s=0,o;for(;e--;){const a=t.codePointAt(e);if(a===47){if(o){r=e+1;break}continue}n<0&&(o=!0,n=e+1),a===46?i<0?i=e:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":t.slice(i,n)}function u2e(...t){let e=-1,n;for(;++e<t.length;)ag(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":h2e(n)}function h2e(t){ag(t);const e=t.codePointAt(0)===47;let n=f2e(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function f2e(t,e){let n="",r=0,i=-1,s=0,o=-1,a,c;for(;++o<=t.length;){if(o<t.length)a=t.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||s===1))if(i!==o-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),i=o,s=0;continue}}else if(n.length>0){n="",r=0,i=o,s=0;continue}}e&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+t.slice(i+1,o):n=t.slice(i+1,o),r=o-i-1;i=o,s=0}else a===46&&s>-1?s++:s=-1}return n}function ag(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const d2e={cwd:p2e};function p2e(){return"/"}function pE(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function m2e(t){if(typeof t=="string")t=new URL(t);else if(!pE(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return g2e(t)}function g2e(t){if(t.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const e=t.pathname;let n=-1;for(;++n<e.length;)if(e.codePointAt(n)===37&&e.codePointAt(n+1)===50){const r=e.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}const C2=["history","path","basename","stem","extname","dirname"];class WW{constructor(e){let n;e?pE(e)?n={path:e}:typeof e=="string"||y2e(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":d2e.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<C2.length;){const s=C2[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)C2.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Js.basename(this.path):void 0}set basename(e){E2(e,"basename"),A2(e,"basename"),this.path=Js.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Js.dirname(this.path):void 0}set dirname(e){P$(this.basename,"dirname"),this.path=Js.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Js.extname(this.path):void 0}set extname(e){if(A2(e,"extname"),P$(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Js.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){pE(e)&&(e=m2e(e)),E2(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Js.basename(this.path,this.extname):void 0}set stem(e){E2(e,"stem"),A2(e,"stem"),this.path=Js.join(this.dirname||"",e+(this.extname||""))}fail(e,n,r){const i=this.message(e,n,r);throw i.fatal=!0,i}info(e,n,r){const i=this.message(e,n,r);return i.fatal=void 0,i}message(e,n,r){const i=new wr(e,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function A2(t,e){if(t&&t.includes(Js.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Js.sep+"`")}function E2(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function P$(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function y2e(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const b2e=(function(t){const r=this.constructor.prototype,i=r[t],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),v2e={}.hasOwnProperty;class kR extends b2e{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=s2e()}copy(){const e=new kR;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];e.use(...r)}return e.data(_2(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(R2("data",this.frozen),this.namespace[e]=n,this):v2e.call(this.namespace,e)&&this.namespace[e]||void 0:e?(R2("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(e,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const n=Qy(e),r=this.parser||this.Parser;return k2("parse",r),r(String(n),n)}process(e,n){const r=this;return this.freeze(),k2("process",this.parser||this.Parser),T2("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const a=Qy(e),c=r.parse(a);r.run(c,a,function(f,d,m){if(f||!d||!m)return h(f);const y=d,b=r.stringify(y,m);S2e(b)?m.value=b:m.result=b,h(f,m)});function h(f,d){f||!d?o(f):s?s(d):n(void 0,d)}}}processSync(e){let n=!1,r;return this.freeze(),k2("processSync",this.parser||this.Parser),T2("processSync",this.compiler||this.Compiler),this.process(e,i),I$("processSync","process",n),r;function i(s,o){n=!0,M$(s),r=o}}run(e,n,r){D$(e),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(o,a){const c=Qy(n);i.run(e,c,h);function h(f,d,m){const y=d||e;f?a(f):o?o(y):r(void 0,y,m)}}}runSync(e,n){let r=!1,i;return this.run(e,n,s),I$("runSync","run",r),i;function s(o,a){M$(o),i=a,r=!0}}stringify(e,n){this.freeze();const r=Qy(n),i=this.compiler||this.Compiler;return T2("stringify",i),D$(e),i(e,r)}use(e,...n){const r=this.attachers,i=this.namespace;if(R2("use",this.frozen),e!=null)if(typeof e=="function")c(e,n);else if(typeof e=="object")Array.isArray(e)?a(e):o(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function s(h){if(typeof h=="function")c(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[f,...d]=h;c(f,d)}else o(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function o(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(h.plugins),h.settings&&(i.settings=_2(!0,i.settings,h.settings))}function a(h){let f=-1;if(h!=null)if(Array.isArray(h))for(;++f<h.length;){const d=h[f];s(d)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function c(h,f){let d=-1,m=-1;for(;++d<r.length;)if(r[d][0]===h){m=d;break}if(m===-1)r.push([h,...f]);else if(f.length>0){let[y,...b]=f;const w=r[m][1];dE(w)&&dE(y)&&(y=_2(!0,w,y)),r[m]=[h,y,...b]}}}}const w2e=new kR().freeze();function k2(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function T2(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function R2(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function D$(t){if(!dE(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function I$(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Qy(t){return x2e(t)?t:new WW(t)}function x2e(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function S2e(t){return typeof t=="string"||_2e(t)}function _2e(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const C2e="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",L$=[],N$={allowDangerousHtml:!0},A2e=/^(https?|ircs?|mailto|xmpp)$/i,E2e=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function k2e(t){const e=T2e(t),n=R2e(t);return M2e(e.runSync(e.parse(n),n),t)}function T2e(t){const e=t.rehypePlugins||L$,n=t.remarkPlugins||L$,r=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...N$}:N$;return w2e().use(g_e).use(n).use(n2e,r).use(e)}function R2e(t){const e=t.children||"",n=new WW;return typeof e=="string"&&(n.value=e),n}function M2e(t,e){const n=e.allowedElements,r=e.allowElement,i=e.components,s=e.disallowedElements,o=e.skipHtml,a=e.unwrapDisallowed,c=e.urlTransform||O2e;for(const f of E2e)Object.hasOwn(e,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+C2e+f.id,void 0);return fR(t,h),PW(t,{Fragment:C.Fragment,components:i,ignoreInvalidStyle:!0,jsx:C.jsx,jsxs:C.jsxs,passKeys:!0,passNode:!0});function h(f,d,m){if(f.type==="raw"&&m&&typeof d=="number")return o?m.children.splice(d,1):m.children[d]={type:"text",value:f.value},d;if(f.type==="element"){let y;for(y in x2)if(Object.hasOwn(x2,y)&&Object.hasOwn(f.properties,y)){const b=f.properties[y],w=x2[y];(w===null||w.includes(f.tagName))&&(f.properties[y]=c(String(b||""),y,f))}}if(f.type==="element"){let y=n?!n.includes(f.tagName):s?s.includes(f.tagName):!1;if(!y&&r&&typeof d=="number"&&(y=!r(f,d,m)),y&&m&&typeof d=="number")return a&&f.children?m.children.splice(d,1,...f.children):m.children.splice(d,1),d}}}function O2e(t){const e=t.indexOf(":"),n=t.indexOf("?"),r=t.indexOf("#"),i=t.indexOf("/");return e===-1||i!==-1&&e>i||n!==-1&&e>n||r!==-1&&e>r||A2e.test(t.slice(0,e))?t:""}var P2e=(t,e)=>typeof t=="string"?t===e:JSON.stringify(t)===JSON.stringify(e),D2e=(t,e)=>{if(!t||!e)return!1;const n=r=>{const{position:i,data:s,...o}=r||{};return o};return JSON.stringify(n(t.properties))===JSON.stringify(n(e.properties))&&P2e(t.children,e.children)},TR=(t,e)=>D2e(t.node,e.node),I2e=(t={})=>Object.fromEntries(Object.entries(t??{}).map(([e,n])=>{if(!n)return[e,n];const r=n,i=({node:s,...o})=>C.jsx(r,{...o});return[e,k.memo(i,TR)]})),RR=k.createContext(null),qW=()=>k.useContext(RR)!==null,L2e=({children:t,...e})=>C.jsx(RR.Provider,{value:e,children:t}),N2e=k.memo(L2e,TR),$2e=({node:t,...e})=>C.jsx("pre",{...e}),j2e=({node:t,...e})=>C.jsx("code",{...e}),MR=({node:t,components:{Pre:e,Code:n},code:r})=>C.jsx(e,{children:C.jsx(n,{node:t,children:r})}),B2e=()=>null,F2e=({node:t,components:{Pre:e,Code:n,SyntaxHighlighter:r,CodeHeader:i},language:s,code:o})=>{const a=k.useMemo(()=>({Pre:e,Code:n}),[e,n]),c=s?r:MR;return C.jsxs(C.Fragment,{children:[C.jsx(i,{node:t,language:s,code:o}),C.jsx(c,{node:t,components:a,language:s??"unknown",code:o})]})},M2={exports:{}};/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/var $$;function z2e(){return $$||($$=1,(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o<arguments.length;o++){var a=arguments[o];a&&(s=i(s,r(a)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return n.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var o="";for(var a in s)e.call(s,a)&&s[a]&&(o=i(o,a));return o}function i(s,o){return o?s?s+" "+o:s+o:s}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(M2)),M2.exports}var V2e=z2e();const GW=Pc(V2e);var j$=({className:t,...e})=>({className:n,...r})=>({className:GW(t,n),...e,...r}),U2e=({node:t,components:{Pre:e,Code:n,SyntaxHighlighter:r,CodeHeader:i},componentsByLanguage:s={},children:o,...a})=>{const c=k.useContext(RR),h=j$(c),f=Lr(S=>C.jsx(e,{...h(S)})),d=j$(a),m=Lr(S=>C.jsx(n,{...d(S)})),y=/language-(\w+)/.exec(a.className||"")?.[1]??"";if(typeof o!="string")return C.jsx(MR,{node:t,components:{Pre:f,Code:m},code:o});const b=s[y]?.SyntaxHighlighter??r,w=s[y]?.CodeHeader??i;return C.jsx(F2e,{node:t,components:{Pre:f,Code:m,SyntaxHighlighter:b,CodeHeader:w},language:y||"unknown",code:o})},H2e=({node:t,components:e,componentsByLanguage:n,...r})=>qW()?C.jsx(U2e,{node:t,components:e,componentsByLanguage:n,...r}):C.jsx(e.Code,{...r}),W2e=k.memo(H2e,(t,e)=>t.components===e.components&&t.componentsByLanguage===e.componentsByLanguage&&TR(t,e)),{useSmooth:q2e,useSmoothStatus:G2e,withSmoothContextProvider:K2e}=GX,Y2e=({components:t,componentsByLanguage:e,smooth:n=!0,preprocess:r,...i})=>{const s=Jj(),o=k.useMemo(()=>r?{...s,text:r(s.text)}:s,[s,r]),{text:a}=q2e(o,n),{pre:c=$2e,code:h=j2e,SyntaxHighlighter:f=MR,CodeHeader:d=B2e}=t??{},m=k.useMemo(()=>({Pre:c,Code:h,SyntaxHighlighter:f,CodeHeader:d}),[c,h,f,d]),y=Lr(w=>C.jsx(W2e,{components:m,componentsByLanguage:e,...w})),b=k.useMemo(()=>{const{pre:w,code:S,SyntaxHighlighter:_,CodeHeader:A,...E}=t??{};return{...E,pre:N2e,code:y}},[y,t]);return C.jsx(k2e,{components:b,...i,children:a})},KW=k.forwardRef(({className:t,containerProps:e,containerComponent:n="div",...r},i)=>{const s=G2e();return C.jsx(n,{"data-status":s.type,...e,className:GW(t,e?.className),ref:i,children:C.jsx(Y2e,{...r})})});KW.displayName="MarkdownTextPrimitive";var X2e=K2e(KW),B$=Object.prototype.hasOwnProperty;function F$(t,e,n){for(n of t.keys())if(Bp(n,e))return n}function Bp(t,e){var n,r,i;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((r=t.length)===e.length)for(;r--&&Bp(t[r],e[r]););return r===-1}if(n===Set){if(t.size!==e.size)return!1;for(r of t)if(i=r,i&&typeof i=="object"&&(i=F$(e,i),!i)||!e.has(i))return!1;return!0}if(n===Map){if(t.size!==e.size)return!1;for(r of t)if(i=r[0],i&&typeof i=="object"&&(i=F$(e,i),!i)||!Bp(r[1],e.get(i)))return!1;return!0}if(n===ArrayBuffer)t=new Uint8Array(t),e=new Uint8Array(e);else if(n===DataView){if((r=t.byteLength)===e.byteLength)for(;r--&&t.getInt8(r)===e.getInt8(r););return r===-1}if(ArrayBuffer.isView(t)){if((r=t.byteLength)===e.byteLength)for(;r--&&t[r]===e[r];);return r===-1}if(!n||typeof t=="object"){r=0;for(n in t)if(B$.call(t,n)&&++r&&!B$.call(e,n)||!(n in e)||!Bp(t[n],e[n]))return!1;return Object.keys(e).length===r}}return t!==t&&e!==e}var O2=t=>{const e=k.useRef(t),n=k.useRef(0);return typeof t!="object"||t===null?(t!==e.current&&(e.current=t,n.current+=1),[t,n.current]):(t!==e.current&&(Bp(t,e.current)||(e.current=t,n.current+=1)),[e.current,n.current])},J2e=(t,e,n)=>{const r=Date.now();clearTimeout(e.current.timeoutId);const i=Math.max(0,e.current.nextAllowedTime-r);e.current.timeoutId=setTimeout(()=>{t().catch(console.error),e.current.nextAllowedTime=r+n},i)},YW=(t,e,n)=>{const r=e?Array.isArray(e)?e:[e]:[];if(t==null||typeof t=="string"&&!t.trim())return{languageId:"plaintext",displayLanguageId:"plaintext",langsToLoad:void 0};if(typeof t=="object")return{languageId:t.name,displayLanguageId:t.name||null,langsToLoad:t};const i=t.toLowerCase(),s=a=>a?.toLowerCase()===i,o=r.find(a=>s(a.name)||s(a.scopeName)||s(a.scopeName?.split(".").pop())||a.aliases?.some(s)||a.fileTypes?.some(s));return o?{languageId:o.name||t,displayLanguageId:t,langsToLoad:o}:n?.[t]?{languageId:n[t],displayLanguageId:t,langsToLoad:n[t]}:{languageId:t,displayLanguageId:t,langsToLoad:t}};function Q2e(t){const e=typeof t=="object"&&"tokenColors"in t&&Array.isArray(t.tokenColors),n=typeof t=="object"&&t!==null&&!e,r=typeof t=="object"&&t!==null&&!e&&Object.entries(t).some(([i,s])=>i&&s&&i.trim()!==""&&s!==""&&(typeof s=="string"||e));return n?{isMultiTheme:!0,themeId:r?`multi-${Object.values(t).map(s=>(typeof s=="string"?s:s?.name)||"custom").sort().join("-")}`:"multi-default",multiTheme:r?t:null,themesToLoad:r?Object.values(t):[]}:{isMultiTheme:!1,themeId:typeof t=="string"?t:t?.name||"custom",singleTheme:t,themesToLoad:[t]}}function Z2e(t=1){return{name:"react-shiki:line-numbers",code(e){if(this.addClassToHast(e,"has-line-numbers"),t!==1){const n=e.properties?.style||"",r=n?`${n}; --line-start: ${t}`:`--line-start: ${t}`;e.properties={...e.properties,style:r}}},line(e){return this.addClassToHast(e,"line-numbers"),e}}}var z$={light:"github-light",dark:"github-dark"},eCe=(t,e,n,r,i={})=>{const[s,o]=k.useState(null),[a,c]=O2(e),[h,f]=O2(n),[d,m]=O2(i),{languageId:y,langsToLoad:b}=k.useMemo(()=>YW(a,d.customLanguages,d.langAlias),[a,d.customLanguages,d.langAlias]),{isMultiTheme:w,themeId:S,multiTheme:_,singleTheme:A,themesToLoad:E}=k.useMemo(()=>Q2e(h),[h]),P=k.useRef({nextAllowedTime:0,timeoutId:void 0}),O=k.useMemo(()=>{const M={lang:y},{defaultColor:D,cssVariablePrefix:$,showLineNumbers:F,startingLineNumber:N,...U}=d,q=w?{themes:_||z$,defaultColor:D,cssVariablePrefix:$}:{theme:A||z$.dark},K=U.transformers||[];return F&&K.push(Z2e(N)),{...M,...q,...U,transformers:K}},[y,S,c,f,m]);return k.useEffect(()=>{let M=!0;const D=async()=>{if(!y)return;const F=d.highlighter?d.highlighter:await r(b,E),U=F.getLoadedLanguages().includes(y)?y:"plaintext",q={...O,lang:U};if(M){const K=d.outputFormat==="html"?F.codeToHtml(t,q):PW(F.codeToHast(t,q),{jsx:C.jsx,jsxs:C.jsxs,Fragment:C.Fragment});o(K)}},{delay:$}=d;return $?J2e(D,P,$):D().catch(console.error),()=>{M=!1,clearTimeout(P.current.timeoutId)}},[t,O,d.delay,d.highlighter,b,E]),s};function tCe(t,{insertAt:e}={}){if(typeof document>"u")return;const n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",e==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}tCe(`.relative {
position: relative;
}
.defaultStyles pre {
overflow: auto;
border-radius: 0.5rem;
padding-left: 1.5rem;
padding-right: 1.5rem;
padding-top: 1.25rem;
padding-bottom: 1.25rem;
}
.languageLabel {
position: absolute;
right: 0.75rem;
top: 0.5rem;
font-family: monospace;
font-size: 0.75rem;
letter-spacing: -0.05em;
color: rgba(107, 114, 128, 0.85);
}
.line-numbers::before {
counter-increment: line-number;
content: counter(line-number);
display: inline-flex;
justify-content: flex-end;
align-items: flex-start;
box-sizing: content-box;
min-width: var(--line-numbers-width, 2ch);
padding-left: var(--line-numbers-padding-left, 2ch);
padding-right: var(--line-numbers-padding-right, 2ch);
color: var(--line-numbers-foreground, rgba(107, 114, 128, 0.6));
font-size: var(--line-numbers-font-size, inherit);
font-weight: var(--line-numbers-font-weight, inherit);
line-height: var(--line-numbers-line-height, inherit);
font-family: var(--line-numbers-font-family, inherit);
opacity: var(--line-numbers-opacity, 1);
user-select: none;
pointer-events: none;
}
.has-line-numbers {
counter-reset: line-number calc(var(--line-start, 1) - 1);
--line-numbers-foreground: rgba(107, 114, 128, 0.5);
--line-numbers-width: 2ch;
--line-numbers-padding-left: 0ch;
--line-numbers-padding-right: 2ch;
--line-numbers-font-size: inherit;
--line-numbers-font-weight: inherit;
--line-numbers-line-height: inherit;
--line-numbers-font-family: inherit;
--line-numbers-opacity: 1;
}
`);var nCe=t=>k.forwardRef(({language:e,theme:n,delay:r,transformers:i,defaultColor:s,cssVariablePrefix:o,addDefaultStyles:a=!0,style:c,langStyle:h,className:f,langClassName:d,showLanguage:m=!0,showLineNumbers:y=!1,startingLineNumber:b=1,children:w,as:S="pre",customLanguages:_,...A},E)=>{const P={delay:r,transformers:i,customLanguages:_,showLineNumbers:y,defaultColor:s,cssVariablePrefix:o,startingLineNumber:b,...A},{displayLanguageId:O}=YW(e,_),M=t(w,e,n,P),D=typeof M=="string";return C.jsxs(S,{ref:E,"data-testid":"shiki-container",className:yv("relative","not-prose",a&&"defaultStyles",f),style:c,id:"shiki-container",children:[m&&O?C.jsx("span",{className:yv("languageLabel",d),style:h,id:"language-label",children:O}):null,D?C.jsx("div",{dangerouslySetInnerHTML:{__html:M}}):M]})});const rCe="modulepreload",iCe=function(t){return"/"+t},V$={},B=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let h=function(f){return Promise.all(f.map(d=>Promise.resolve(d).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};var o=h;document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),c=a?.nonce||a?.getAttribute("nonce");i=h(n.map(f=>{if(f=iCe(f),f in V$)return;V$[f]=!0;const d=f.endsWith(".css"),m=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const y=document.createElement("link");if(y.rel=d?"stylesheet":rCe,d||(y.as="script"),y.crossOrigin="",y.href=f,c&&y.setAttribute("nonce",c),document.head.appendChild(y),d)return new Promise((b,w)=>{y.addEventListener("load",b),y.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${f}`)))})}))}function s(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return i.then(a=>{for(const c of a||[])c.status==="rejected"&&s(c.reason);return e().catch(s)})};let pn=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function sCe(t){return OR(t)}function OR(t){return Array.isArray(t)?oCe(t):t instanceof RegExp?t:typeof t=="object"?aCe(t):t}function oCe(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=OR(t[n]);return e}function aCe(t){let e={};for(let n in t)e[n]=OR(t[n]);return e}function XW(t,...e){return e.forEach(n=>{for(let r in n)t[r]=n[r]}),t}function JW(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?JW(t.substring(0,t.length-1)):t.substr(~e+1)}var P2=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Zy=class{static hasCaptures(t){return t===null?!1:(P2.lastIndex=0,P2.test(t))}static replaceCaptures(t,e,n){return t.replace(P2,(r,i,s,o)=>{let a=n[parseInt(i||s,10)];if(a){let c=e.substring(a.start,a.end);for(;c[0]===".";)c=c.substring(1);switch(o){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function QW(t,e){return t<e?-1:t>e?1:0}function ZW(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,r=e.length;if(n===r){for(let i=0;i<n;i++){let s=QW(t[i],e[i]);if(s!==0)return s}return 0}return n-r}function U$(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function eq(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var tq=class{constructor(t){this.fn=t}cache=new Map;get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},iw=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(uCe(t),e)}static createFromParsedTheme(t,e){return fCe(t,e)}_cachedMatchRoot=new tq(t=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;const e=t.scopeName,r=this._cachedMatchRoot.get(e).find(i=>lCe(t.parent,i.parentScopes));return r?new nq(r.fontStyle,r.foreground,r.background):null}},D2=class qb{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const r of n)e=new qb(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new qb(n,e[r]);return n}push(e){return new qb(this,e)}getSegments(){let e=this;const n=[];for(;e;)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push(r.scopeName),r=r.parent;return r===e?n.reverse():void 0}};function lCe(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let r=e[n],i=!1;if(r===">"){if(n===e.length-1)return!1;r=e[++n],i=!0}for(;t&&!cCe(t.scopeName,r);){if(i)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function cCe(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var nq=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function uCe(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],r=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];if(!o.settings)continue;let a;if(typeof o.scope=="string"){let d=o.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),a=d.split(",")}else Array.isArray(o.scope)?a=o.scope:a=[""];let c=-1;if(typeof o.settings.fontStyle=="string"){c=0;let d=o.settings.fontStyle.split(" ");for(let m=0,y=d.length;m<y;m++)switch(d[m]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let h=null;typeof o.settings.foreground=="string"&&U$(o.settings.foreground)&&(h=o.settings.foreground);let f=null;typeof o.settings.background=="string"&&U$(o.settings.background)&&(f=o.settings.background);for(let d=0,m=a.length;d<m;d++){let b=a[d].trim().split(" "),w=b[b.length-1],S=null;b.length>1&&(S=b.slice(0,b.length-1),S.reverse()),n[r++]=new hCe(w,S,i,c,h,f)}}return n}var hCe=class{constructor(t,e,n,r,i,s){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=r,this.foreground=i,this.background=s}},pr=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(pr||{});function fCe(t,e){t.sort((c,h)=>{let f=QW(c.scope,h.scope);return f!==0||(f=ZW(c.parentScopes,h.parentScopes),f!==0)?f:c.index-h.index});let n=0,r="#000000",i="#ffffff";for(;t.length>=1&&t[0].scope==="";){let c=t.shift();c.fontStyle!==-1&&(n=c.fontStyle),c.foreground!==null&&(r=c.foreground),c.background!==null&&(i=c.background)}let s=new dCe(e),o=new nq(n,s.getId(r),s.getId(i)),a=new mCe(new mE(0,null,-1,0,0),[]);for(let c=0,h=t.length;c<h;c++){let f=t[c];a.insert(0,f.scope,f.parentScopes,f.fontStyle,s.getId(f.foreground),s.getId(f.background))}return new iw(s,o,a)}var dCe=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(t){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},pCe=Object.freeze([]),mE=class rq{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,i,s){this.scopeDepth=e,this.parentScopes=n||pCe,this.fontStyle=r,this.foreground=i,this.background=s}clone(){return new rq(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let r=0,i=e.length;r<i;r++)n[r]=e[r].clone();return n}acceptOverwrite(e,n,r,i){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),i!==0&&(this.background=i)}},mCe=class gE{constructor(e,n=[],r={}){this._mainRule=e,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let r=0,i=0;for(;e.parentScopes[r]===">"&&r++,n.parentScopes[i]===">"&&i++,!(r>=e.parentScopes.length||i>=n.parentScopes.length);){const s=n.parentScopes[i].length-e.parentScopes[r].length;if(s!==0)return s;r++,i++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let r=e.indexOf("."),i,s;if(r===-1?(i=e,s=""):(i=e.substring(0,r),s=e.substring(r+1)),this._children.hasOwnProperty(i))return this._children[i].match(s)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(gE._cmpBySpecificity),n}insert(e,n,r,i,s,o){if(n===""){this._doInsertHere(e,r,i,s,o);return}let a=n.indexOf("."),c,h;a===-1?(c=n,h=""):(c=n.substring(0,a),h=n.substring(a+1));let f;this._children.hasOwnProperty(c)?f=this._children[c]:(f=new gE(this._mainRule.clone(),mE.cloneArr(this._rulesWithParentScopes)),this._children[c]=f),f.insert(e+1,h,r,i,s,o)}_doInsertHere(e,n,r,i,s){if(n===null){this._mainRule.acceptOverwrite(e,r,i,s);return}for(let o=0,a=this._rulesWithParentScopes.length;o<a;o++){let c=this._rulesWithParentScopes[o];if(ZW(c.parentScopes,n)===0){c.acceptOverwrite(e,r,i,s);return}}r===-1&&(r=this._mainRule.fontStyle),i===0&&(i=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new mE(e,n,r,i,s))}},Uh=class Ui{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=Ui.getLanguageId(e),r=Ui.getTokenType(e),i=Ui.getFontStyle(e),s=Ui.getForeground(e),o=Ui.getBackground(e);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:s,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,n,r,i,s,o,a){let c=Ui.getLanguageId(e),h=Ui.getTokenType(e),f=Ui.containsBalancedBrackets(e)?1:0,d=Ui.getFontStyle(e),m=Ui.getForeground(e),y=Ui.getBackground(e);return n!==0&&(c=n),r!==8&&(h=r),i!==null&&(f=i?1:0),s!==-1&&(d=s),o!==0&&(m=o),a!==0&&(y=a),(c<<0|h<<8|f<<10|d<<11|m<<15|y<<24)>>>0}};function sw(t,e){const n=[],r=gCe(t);let i=r.next();for(;i!==null;){let c=0;if(i.length===2&&i.charAt(1)===":"){switch(i.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let h=o();if(n.push({matcher:h,priority:c}),i!==",")break;i=r.next()}return n;function s(){if(i==="-"){i=r.next();const c=s();return h=>!!c&&!c(h)}if(i==="("){i=r.next();const c=a();return i===")"&&(i=r.next()),c}if(H$(i)){const c=[];do c.push(i),i=r.next();while(H$(i));return h=>e(c,h)}return null}function o(){const c=[];let h=s();for(;h;)c.push(h),h=s();return f=>c.every(d=>d(f))}function a(){const c=[];let h=o();for(;h&&(c.push(h),i==="|"||i===",");){do i=r.next();while(i==="|"||i===",");h=o()}return f=>c.some(d=>d(f))}}function H$(t){return!!t&&!!t.match(/[\w\.:]+/)}function gCe(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;const r=n[0];return n=e.exec(t),r}}}function iq(t){typeof t.dispose=="function"&&t.dispose()}var km=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},yCe=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},bCe=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},vCe=class{constructor(t,e){this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new km(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const t=this.Q;this.Q=[];const e=new bCe;for(const n of t)wCe(n,this.initialScopeName,this.repo,e);for(const n of e.references)if(n instanceof km){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function wCe(t,e,n,r){const i=n.lookup(t.scopeName);if(!i){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const s=n.lookup(e);t instanceof km?Gb({baseGrammar:s,selfGrammar:i},r):yE(t.ruleName,{baseGrammar:s,selfGrammar:i,repository:i.repository},r);const o=n.injections(t.scopeName);if(o)for(const a of o)r.add(new km(a))}function yE(t,e,n){if(e.repository&&e.repository[t]){const r=e.repository[t];ow([r],e,n)}}function Gb(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&ow(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&ow(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function ow(t,e,n){for(const r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const i=r.repository?XW({},e.repository,r.repository):e.repository;Array.isArray(r.patterns)&&ow(r.patterns,{...e,repository:i},n);const s=r.include;if(!s)continue;const o=sq(s);switch(o.kind){case 0:Gb({...e,selfGrammar:e.baseGrammar},n);break;case 1:Gb(e,n);break;case 2:yE(o.ruleName,{...e,repository:i},n);break;case 3:case 4:const a=o.scopeName===e.selfGrammar.scopeName?e.selfGrammar:o.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(a){const c={baseGrammar:e.baseGrammar,selfGrammar:a,repository:i};o.kind===4?yE(o.ruleName,c,n):Gb(c,n)}else o.kind===4?n.add(new yCe(o.scopeName,o.ruleName)):n.add(new km(o.scopeName));break}}}var xCe=class{kind=0},SCe=class{kind=1},_Ce=class{constructor(t){this.ruleName=t}kind=2},CCe=class{constructor(t){this.scopeName=t}kind=3},ACe=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function sq(t){if(t==="$base")return new xCe;if(t==="$self")return new SCe;const e=t.indexOf("#");if(e===-1)return new CCe(t);if(e===0)return new _Ce(t.substring(1));{const n=t.substring(0,e),r=t.substring(e+1);return new ACe(n,r)}}var ECe=/\\(\d+)/,W$=/\\(\d+)/g,kCe=-1,oq=-2;var lg=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=Zy.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Zy.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${JW(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){return!this._nameIsCapturing||this._name===null||t===null||e===null?this._name:Zy.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Zy.replaceCaptures(this._contentName,t,e)}},TCe=class extends lg{retokenizeCapturedWithRuleId;constructor(t,e,n,r,i){super(t,e,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(t,e){throw new Error("Not supported!")}compile(t,e){throw new Error("Not supported!")}compileAG(t,e,n,r){throw new Error("Not supported!")}},RCe=class extends lg{_match;captures;_cachedCompiledPatterns;constructor(t,e,n,r,i){super(t,e,n,null),this._match=new Tm(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,e){e.push(this._match)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Rm,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},q$=class extends lg{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,i){super(t,e,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,e){for(const n of this.patterns)t.getRule(n).collectPatterns(t,e)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Rm,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},bE=class extends lg{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,i,s,o,a,c,h){super(t,e,n,r),this._begin=new Tm(i,this.id),this.beginCaptures=s,this._end=new Tm(o||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=c||!1,this.patterns=h.patterns,this.hasMissingPatterns=h.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,e){return this._end.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t,e).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t,e).compileAG(t,n,r)}_getCachedCompiledPatterns(t,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Rm;for(const n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},aw=class extends lg{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(t,e,n,r,i,s,o,a,c){super(t,e,n,r),this._begin=new Tm(i,this.id),this.beginCaptures=s,this.whileCaptures=a,this._while=new Tm(o,oq),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,e){return this._while.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Rm;for(const e of this.patterns)t.getRule(e).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,e){return this._getCachedCompiledWhilePatterns(t,e).compile(t)}compileWhileAG(t,e,n,r){return this._getCachedCompiledWhilePatterns(t,e).compileAG(t,n,r)}_getCachedCompiledWhilePatterns(t,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Rm,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||"￿"),this._cachedCompiledWhilePatterns}},aq=class ur{static createCaptureRule(e,n,r,i,s){return e.registerRule(o=>new TCe(n,o,r,i,s))}static getCompiledRuleId(e,n,r){return e.id||n.registerRule(i=>{if(e.id=i,e.match)return new RCe(e.$vscodeTextmateLocation,e.id,e.name,e.match,ur._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){e.repository&&(r=XW({},r,e.repository));let s=e.patterns;return typeof s>"u"&&e.include&&(s=[{include:e.include}]),new q$(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,ur._compilePatterns(s,n,r))}return e.while?new aw(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,ur._compileCaptures(e.beginCaptures||e.captures,n,r),e.while,ur._compileCaptures(e.whileCaptures||e.captures,n,r),ur._compilePatterns(e.patterns,n,r)):new bE(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,ur._compileCaptures(e.beginCaptures||e.captures,n,r),e.end,ur._compileCaptures(e.endCaptures||e.captures,n,r),e.applyEndPatternLast,ur._compilePatterns(e.patterns,n,r))}),e.id}static _compileCaptures(e,n,r){let i=[];if(e){let s=0;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const a=parseInt(o,10);a>s&&(s=a)}for(let o=0;o<=s;o++)i[o]=null;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const a=parseInt(o,10);let c=0;e[o].patterns&&(c=ur.getCompiledRuleId(e[o],n,r)),i[a]=ur.createCaptureRule(n,e[o].$vscodeTextmateLocation,e[o].name,e[o].contentName,c)}}return i}static _compilePatterns(e,n,r){let i=[];if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s];let c=-1;if(a.include){const h=sq(a.include);switch(h.kind){case 0:case 1:c=ur.getCompiledRuleId(r[a.include],n,r);break;case 2:let f=r[h.ruleName];f&&(c=ur.getCompiledRuleId(f,n,r));break;case 3:case 4:const d=h.scopeName,m=h.kind===4?h.ruleName:null,y=n.getExternalGrammar(d,r);if(y)if(m){let b=y.repository[m];b&&(c=ur.getCompiledRuleId(b,n,y.repository))}else c=ur.getCompiledRuleId(y.repository.$self,n,y.repository);break}}else c=ur.getCompiledRuleId(a,n,r);if(c!==-1){const h=n.getRule(c);let f=!1;if((h instanceof q$||h instanceof bE||h instanceof aw)&&h.hasMissingPatterns&&h.patterns.length===0&&(f=!0),f)continue;i.push(c)}}return{patterns:i,hasMissingPatterns:(e?e.length:0)!==i.length}}},Tm=class lq{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,n){if(e&&typeof e=="string"){const r=e.length;let i=0,s=[],o=!1;for(let a=0;a<r;a++)if(e.charAt(a)==="\\"&&a+1<r){const h=e.charAt(a+1);h==="z"?(s.push(e.substring(i,a)),s.push("$(?!\\n)(?<!\\n)"),i=a+2):(h==="A"||h==="G")&&(o=!0),a++}this.hasAnchor=o,i===0?this.source=e:(s.push(e.substring(i,r)),this.source=s.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=ECe.test(this.source):this.hasBackReferences=!1}clone(){return new lq(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(i=>e.substring(i.start,i.end));return W$.lastIndex=0,this.source.replace(W$,(i,s)=>eq(r[parseInt(s,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],n=[],r=[],i=[],s,o,a,c;for(s=0,o=this.source.length;s<o;s++)a=this.source.charAt(s),e[s]=a,n[s]=a,r[s]=a,i[s]=a,a==="\\"&&s+1<o&&(c=this.source.charAt(s+1),c==="A"?(e[s+1]="￿",n[s+1]="￿",r[s+1]="A",i[s+1]="A"):c==="G"?(e[s+1]="￿",n[s+1]="G",r[s+1]="￿",i[s+1]="G"):(e[s+1]=c,n[s+1]=c,r[s+1]=c,i[s+1]=c),s++);return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:i.join("")}}resolveAnchors(e,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Rm=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(n=>n.source);this._cached=new G$(t,e,this._items.map(n=>n.ruleId))}return this._cached}compileAG(t,e,n){return this._hasAnchors?e?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,n){let r=this._items.map(i=>i.resolveAnchors(e,n));return new G$(t,r,this._items.map(i=>i.ruleId))}},G$=class{constructor(t,e,n){this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
`)}findNextMatchSync(t,e,n){const r=this.scanner.findNextMatchSync(t,e,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},I2=class{constructor(t,e){this.languageId=t,this.tokenType=e}},MCe=class vE{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,n){this._defaultAttributes=new I2(e,8),this._embeddedLanguagesMatcher=new OCe(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?vE._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new I2(0,0);_getBasicScopeAttributes=new tq(e=>{const n=this._scopeToLanguage(e),r=this._toStandardTokenType(e);return new I2(n,r)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const n=e.match(vE.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},OCe=class{values;scopesRegExp;constructor(t){if(t.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(t);const e=t.map(([n,r])=>eq(n));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(t){if(!this.scopesRegExp)return;const e=t.match(this.scopesRegExp);if(e)return this.values.get(e[1])}},K$=class{constructor(t,e){this.stack=t,this.stoppedEarly=e}};function cq(t,e,n,r,i,s,o,a){const c=e.content.length;let h=!1,f=-1;if(o){const y=PCe(t,e,n,r,i,s);i=y.stack,r=y.linePos,n=y.isFirstLine,f=y.anchorPosition}const d=Date.now();for(;!h;){if(a!==0&&Date.now()-d>a)return new K$(i,!0);m()}return new K$(i,!1);function m(){const y=DCe(t,e,n,r,i,f);if(!y){s.produce(i,c),h=!0;return}const b=y.captureIndices,w=y.matchedRuleId,S=b&&b.length>0?b[0].end>r:!1;if(w===kCe){const _=i.getRule(t);s.produce(i,b[0].start),i=i.withContentNameScopesList(i.nameScopesList),mp(t,e,n,i,s,_.endCaptures,b),s.produce(i,b[0].end);const A=i;if(i=i.parent,f=A.getAnchorPos(),!S&&A.getEnterPos()===r){i=A,s.produce(i,c),h=!0;return}}else{const _=t.getRule(w);s.produce(i,b[0].start);const A=i,E=_.getName(e.content,b),P=i.contentNameScopesList.pushAttributed(E,t);if(i=i.push(w,r,f,b[0].end===c,null,P,P),_ instanceof bE){const O=_;mp(t,e,n,i,s,O.beginCaptures,b),s.produce(i,b[0].end),f=b[0].end;const M=O.getContentName(e.content,b),D=P.pushAttributed(M,t);if(i=i.withContentNameScopesList(D),O.endHasBackReferences&&(i=i.withEndRule(O.getEndWithResolvedBackReferences(e.content,b))),!S&&A.hasSameRuleAs(i)){i=i.pop(),s.produce(i,c),h=!0;return}}else if(_ instanceof aw){const O=_;mp(t,e,n,i,s,O.beginCaptures,b),s.produce(i,b[0].end),f=b[0].end;const M=O.getContentName(e.content,b),D=P.pushAttributed(M,t);if(i=i.withContentNameScopesList(D),O.whileHasBackReferences&&(i=i.withEndRule(O.getWhileWithResolvedBackReferences(e.content,b))),!S&&A.hasSameRuleAs(i)){i=i.pop(),s.produce(i,c),h=!0;return}}else if(mp(t,e,n,i,s,_.captures,b),s.produce(i,b[0].end),i=i.pop(),!S){i=i.safePop(),s.produce(i,c),h=!0;return}}b[0].end>r&&(r=b[0].end,n=!1)}}function PCe(t,e,n,r,i,s){let o=i.beginRuleCapturedEOL?0:-1;const a=[];for(let c=i;c;c=c.pop()){const h=c.getRule(t);h instanceof aw&&a.push({rule:h,stack:c})}for(let c=a.pop();c;c=a.pop()){const{ruleScanner:h,findOptions:f}=NCe(c.rule,t,c.stack.endRule,n,r===o),d=h.findNextMatchSync(e,r,f);if(d){if(d.ruleId!==oq){i=c.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(s.produce(c.stack,d.captureIndices[0].start),mp(t,e,n,c.stack,s,c.rule.whileCaptures,d.captureIndices),s.produce(c.stack,d.captureIndices[0].end),o=d.captureIndices[0].end,d.captureIndices[0].end>r&&(r=d.captureIndices[0].end,n=!1))}else{i=c.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:o,isFirstLine:n}}function DCe(t,e,n,r,i,s){const o=ICe(t,e,n,r,i,s),a=t.getInjections();if(a.length===0)return o;const c=LCe(a,t,e,n,r,i,s);if(!c)return o;if(!o)return c;const h=o.captureIndices[0].start,f=c.captureIndices[0].start;return f<h||c.priorityMatch&&f===h?c:o}function ICe(t,e,n,r,i,s){const o=i.getRule(t),{ruleScanner:a,findOptions:c}=uq(o,t,i.endRule,n,r===s),h=a.findNextMatchSync(e,r,c);return h?{captureIndices:h.captureIndices,matchedRuleId:h.ruleId}:null}function LCe(t,e,n,r,i,s,o){let a=Number.MAX_VALUE,c=null,h,f=0;const d=s.contentNameScopesList.getScopeNames();for(let m=0,y=t.length;m<y;m++){const b=t[m];if(!b.matcher(d))continue;const w=e.getRule(b.ruleId),{ruleScanner:S,findOptions:_}=uq(w,e,null,r,i===o),A=S.findNextMatchSync(n,i,_);if(!A)continue;const E=A.captureIndices[0].start;if(!(E>=a)&&(a=E,c=A.captureIndices,h=A.ruleId,f=b.priority,a===i))break}return c?{priorityMatch:f===-1,captureIndices:c,matchedRuleId:h}:null}function uq(t,e,n,r,i){return{ruleScanner:t.compileAG(e,n,r,i),findOptions:0}}function NCe(t,e,n,r,i){return{ruleScanner:t.compileWhileAG(e,n,r,i),findOptions:0}}function mp(t,e,n,r,i,s,o){if(s.length===0)return;const a=e.content,c=Math.min(s.length,o.length),h=[],f=o[0].end;for(let d=0;d<c;d++){const m=s[d];if(m===null)continue;const y=o[d];if(y.length===0)continue;if(y.start>f)break;for(;h.length>0&&h[h.length-1].endPos<=y.start;)i.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop();if(h.length>0?i.produceFromScopes(h[h.length-1].scopes,y.start):i.produce(r,y.start),m.retokenizeCapturedWithRuleId){const w=m.getName(a,o),S=r.contentNameScopesList.pushAttributed(w,t),_=m.getContentName(a,o),A=S.pushAttributed(_,t),E=r.push(m.retokenizeCapturedWithRuleId,y.start,-1,!1,null,S,A),P=t.createOnigString(a.substring(0,y.end));cq(t,P,n&&y.start===0,y.start,E,i,!1,0),iq(P);continue}const b=m.getName(a,o);if(b!==null){const S=(h.length>0?h[h.length-1].scopes:r.contentNameScopesList).pushAttributed(b,t);h.push(new $Ce(S,y.end))}}for(;h.length>0;)i.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop()}var $Ce=class{scopes;endPos;constructor(t,e){this.scopes=t,this.endPos=e}};function jCe(t,e,n,r,i,s,o,a){return new FCe(t,e,n,r,i,s,o,a)}function Y$(t,e,n,r,i){const s=sw(e,lw),o=aq.getCompiledRuleId(n,r,i.repository);for(const a of s)t.push({debugSelector:e,matcher:a.matcher,ruleId:o,grammar:i,priority:a.priority})}function lw(t,e){if(e.length<t.length)return!1;let n=0;return t.every(r=>{for(let i=n;i<e.length;i++)if(BCe(e[i],r))return n=i+1,!0;return!1})}function BCe(t,e){if(!t)return!1;if(t===e)return!0;const n=e.length;return t.length>n&&t.substr(0,n)===e&&t[n]==="."}var FCe=class{constructor(t,e,n,r,i,s,o,a){if(this._rootScopeName=t,this.balancedBracketSelectors=s,this._onigLib=a,this._basicScopeAttributesProvider=new MCe(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=X$(e,null),this._injections=null,this._tokenTypeMatchers=[],i)for(const c of Object.keys(i)){const h=sw(c,lw);for(const f of h)this._tokenTypeMatchers.push({matcher:f.matcher,type:i[c]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const t of this._ruleId2desc)t&&t.dispose()}createOnigScanner(t){return this._onigLib.createOnigScanner(t)}createOnigString(t){return this._onigLib.createOnigString(t)}getMetadataForScope(t){return this._basicScopeAttributesProvider.getBasicScopeAttributes(t)}_collectInjections(){const t={lookup:i=>i===this._rootScopeName?this._grammar:this.getExternalGrammar(i),injections:i=>this._grammarRepository.injections(i)},e=[],n=this._rootScopeName,r=t.lookup(n);if(r){const i=r.injections;if(i)for(let o in i)Y$(e,o,i[o],this,r);const s=this._grammarRepository.injections(n);s&&s.forEach(o=>{const a=this.getExternalGrammar(o);if(a){const c=a.injectionSelector;c&&Y$(e,c,a,this,a)}})}return e.sort((i,s)=>i.priority-s.priority),e}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(t){const e=++this._lastRuleId,n=t(e);return this._ruleId2desc[e]=n,n}getRule(t){return this._ruleId2desc[t]}getExternalGrammar(t,e){if(this._includedGrammars[t])return this._includedGrammars[t];if(this._grammarRepository){const n=this._grammarRepository.lookup(t);if(n)return this._includedGrammars[t]=X$(n,e&&e.$base),this._includedGrammars[t]}}tokenizeLine(t,e,n=0){const r=this._tokenize(t,e,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(t,e,n=0){const r=this._tokenize(t,e,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(t,e,n,r){this._rootId===-1&&(this._rootId=aq.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!e||e===wE.NULL){i=!0;const h=this._basicScopeAttributesProvider.getDefaultAttributes(),f=this.themeProvider.getDefaults(),d=Uh.set(0,h.languageId,h.tokenType,null,f.fontStyle,f.foregroundId,f.backgroundId),m=this.getRule(this._rootId).getName(null,null);let y;m?y=Fp.createRootAndLookUpScopeName(m,d,this):y=Fp.createRoot("unknown",d),e=new wE(null,this._rootId,-1,-1,!1,null,y,y)}else i=!1,e.reset();t=t+`
`;const s=this.createOnigString(t),o=s.content.length,a=new VCe(n,t,this._tokenTypeMatchers,this.balancedBracketSelectors),c=cq(this,s,i,0,e,a,!0,r);return iq(s),{lineLength:o,lineTokens:a,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function X$(t,e){return t=sCe(t),t.repository=t.repository||{},t.repository.$self={$vscodeTextmateLocation:t.$vscodeTextmateLocation,patterns:t.patterns,name:t.scopeName},t.repository.$base=e||t.repository.$self,t}var Fp=class Ys{constructor(e,n,r){this.parent=e,this.scopePath=n,this.tokenAttributes=r}static fromExtension(e,n){let r=e,i=e?.scopePath??null;for(const s of n)i=D2.push(i,s.scopeNames),r=new Ys(r,i,s.encodedTokenAttributes);return r}static createRoot(e,n){return new Ys(null,new D2(null,e),n)}static createRootAndLookUpScopeName(e,n,r){const i=r.getMetadataForScope(e),s=new D2(null,e),o=r.themeProvider.themeMatch(s),a=Ys.mergeAttributes(n,i,o);return new Ys(null,s,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return Ys.equals(this,e)}static equals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.scopeName!==n.scopeName||e.tokenAttributes!==n.tokenAttributes)return!1;e=e.parent,n=n.parent}while(!0)}static mergeAttributes(e,n,r){let i=-1,s=0,o=0;return r!==null&&(i=r.fontStyle,s=r.foregroundId,o=r.backgroundId),Uh.set(e,n.languageId,n.tokenType,null,i,s,o)}pushAttributed(e,n){if(e===null)return this;if(e.indexOf(" ")===-1)return Ys._pushAttributed(this,e,n);const r=e.split(/ /g);let i=this;for(const s of r)i=Ys._pushAttributed(i,s,n);return i}static _pushAttributed(e,n,r){const i=r.getMetadataForScope(n),s=e.scopePath.push(n),o=r.themeProvider.themeMatch(s),a=Ys.mergeAttributes(e.tokenAttributes,i,o);return new Ys(e,s,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===e?n.reverse():void 0}},wE=class rc{constructor(e,n,r,i,s,o,a,c){this.parent=e,this.ruleId=n,this.beginRuleCapturedEOL=s,this.endRule=o,this.nameScopesList=a,this.contentNameScopesList=c,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=i}_stackElementBrand=void 0;static NULL=new rc(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(e){return e===null?!1:rc._equals(this,e)}static _equals(e,n){return e===n?!0:this._structuralEquals(e,n)?Fp.equals(e.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.depth!==n.depth||e.ruleId!==n.ruleId||e.endRule!==n.endRule)return!1;e=e.parent,n=n.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){rc._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,n,r,i,s,o,a){return new rc(this,e,n,r,i,s,o,a)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,n){return this.parent&&(n=this.parent._writeString(e,n)),e[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new rc(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let n=this;for(;n&&n._enterPos===e._enterPos;){if(n.ruleId===e.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(e,n){const r=Fp.fromExtension(e?.nameScopesList??null,n.nameScopesList);return new rc(e,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Fp.fromExtension(r,n.contentNameScopesList))}},zCe=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(t,e){this.balancedBracketScopes=t.flatMap(n=>n==="*"?(this.allowAny=!0,[]):sw(n,lw).map(r=>r.matcher)),this.unbalancedBracketScopes=e.flatMap(n=>sw(n,lw).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(t){for(const e of this.unbalancedBracketScopes)if(e(t))return!1;for(const e of this.balancedBracketScopes)if(e(t))return!0;return this.allowAny}},VCe=class{constructor(t,e,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=t,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(t,e){this.produceFromScopes(t.contentNameScopesList,e)}produceFromScopes(t,e){if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let r=t?.tokenAttributes??0,i=!1;if(this.balancedBracketSelectors?.matchesAlways&&(i=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const s=t?.getScopeNames()??[];for(const o of this._tokenTypeOverrides)o.matcher(s)&&(r=Uh.set(r,0,o.type,null,-1,0,0));this.balancedBracketSelectors&&(i=this.balancedBracketSelectors.match(s))}if(i&&(r=Uh.set(r,0,8,i,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=e;return}const n=t?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:n}),this._lastTokenEndIndex=e}getResult(t,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(t,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,i=this._binaryTokens.length;r<i;r++)n[r]=this._binaryTokens[r];return n}},UCe=class{constructor(t,e){this._onigLib=e,this._theme=t}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const t of this._grammars.values())t.dispose()}setTheme(t){this._theme=t}getColorMap(){return this._theme.getColorMap()}addGrammar(t,e){this._rawGrammars.set(t.scopeName,t),e&&this._injectionGrammars.set(t.scopeName,e)}lookup(t){return this._rawGrammars.get(t)}injections(t){return this._injectionGrammars.get(t)}getDefaults(){return this._theme.getDefaults()}themeMatch(t){return this._theme.match(t)}grammarForScopeName(t,e,n,r,i){if(!this._grammars.has(t)){let s=this._rawGrammars.get(t);if(!s)return null;this._grammars.set(t,jCe(t,s,e,n,r,i,this,this._onigLib))}return this._grammars.get(t)}},HCe=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new UCe(iw.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,n){this._syncRegistry.setTheme(iw.createFromRawTheme(e,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,n,r){return this.loadGrammarWithConfiguration(e,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(e,n,r){return this._loadGrammar(e,n,r.embeddedLanguages,r.tokenTypes,new zCe(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,n,r,i,s){const o=new vCe(this._syncRegistry,e);for(;o.Q.length>0;)o.Q.map(a=>this._loadSingleGrammar(a.scopeName)),o.processQueue();return this._grammarForScopeName(e,n,r,i,s)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const n=this._options.loadGrammar(e);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(e,n=[],r=0,i=null){return this._syncRegistry.addGrammar(e,n),this._grammarForScopeName(e.scopeName,r,i)}_grammarForScopeName(e,n=0,r=null,i=null,s=null){return this._syncRegistry.grammarForScopeName(e,n,r,i,s)}},xE=wE.NULL;const WCe=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],qCe=/["&'<>`]/g,GCe=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,KCe=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,YCe=/[|\\{}()[\]^$+*?.]/g,J$=new WeakMap;function XCe(t,e){if(t=t.replace(e.subset?JCe(e.subset):qCe,r),e.subset||e.escapeOnly)return t;return t.replace(GCe,n).replace(KCe,r);function n(i,s,o){return e.format((i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)-56320+65536,o.charCodeAt(s+2),e)}function r(i,s,o){return e.format(i.charCodeAt(0),o.charCodeAt(s+1),e)}}function JCe(t){let e=J$.get(t);return e||(e=QCe(t),J$.set(t,e)),e}function QCe(t){const e=[];let n=-1;for(;++n<t.length;)e.push(t[n].replace(YCe,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const ZCe=/[\dA-Fa-f]/;function eAe(t,e,n){const r="&#x"+t.toString(16).toUpperCase();return n&&e&&!ZCe.test(String.fromCharCode(e))?r:r+";"}const tAe=/\d/;function nAe(t,e,n){const r="&#"+String(t);return n&&e&&!tAe.test(String.fromCharCode(e))?r:r+";"}const rAe=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],L2={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"",Prime:"″",oline:"‾",frasl:"",weierp:"℘",image:"",real:"",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"",lowast:"",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"",cap:"∩",cup:"",int:"∫",there4:"∴",sim:"",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:"",emsp:"",thinsp:"",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"",mdash:"—",lsquo:"",rsquo:"",sbquo:"",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"",rsaquo:"",euro:"€"},iAe=["cent","copy","divide","gt","lt","not","para","times"],hq={}.hasOwnProperty,SE={};let eb;for(eb in L2)hq.call(L2,eb)&&(SE[L2[eb]]=eb);const sAe=/[^\dA-Za-z]/;function oAe(t,e,n,r){const i=String.fromCharCode(t);if(hq.call(SE,i)){const s=SE[i],o="&"+s;return n&&rAe.includes(s)&&!iAe.includes(s)&&(!r||e&&e!==61&&sAe.test(String.fromCharCode(e)))?o:o+";"}return""}function aAe(t,e,n){let r=eAe(t,e,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=oAe(t,e,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){const s=nAe(t,e,n.omitOptionalSemicolons);s.length<r.length&&(r=s)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function kh(t,e){return XCe(t,Object.assign({format:aAe},e))}const lAe=/^>|^->|<!--|-->|--!>|<!-$/g,cAe=[">"],uAe=["<",">"];function hAe(t,e,n,r){return r.settings.bogusComments?"<?"+kh(t.value,Object.assign({},r.settings.characterReferences,{subset:cAe}))+">":"<!--"+t.value.replace(lAe,i)+"-->";function i(s){return kh(s,Object.assign({},r.settings.characterReferences,{subset:uAe}))}}function fAe(t,e,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}const Rn=dq(1),fq=dq(-1),dAe=[];function dq(t){return e;function e(n,r,i){const s=n?n.children:dAe;let o=(r||0)+t,a=s[o];if(!i)for(;a&&_x(a);)o+=t,a=s[o];return a}}const pAe={}.hasOwnProperty;function pq(t){return e;function e(n,r,i){return pAe.call(t,n.tagName)&&t[n.tagName](n,r,i)}}const PR=pq({body:gAe,caption:N2,colgroup:N2,dd:wAe,dt:vAe,head:N2,html:mAe,li:bAe,optgroup:xAe,option:SAe,p:yAe,rp:Q$,rt:Q$,tbody:CAe,td:Z$,tfoot:AAe,th:Z$,thead:_Ae,tr:EAe});function N2(t,e,n){const r=Rn(n,e,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&_x(r.value.charAt(0)))}function mAe(t,e,n){const r=Rn(n,e);return!r||r.type!=="comment"}function gAe(t,e,n){const r=Rn(n,e);return!r||r.type!=="comment"}function yAe(t,e,n){const r=Rn(n,e);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function bAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&r.tagName==="li"}function vAe(t,e,n){const r=Rn(n,e);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function wAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Q$(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function xAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&r.tagName==="optgroup"}function SAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function _Ae(t,e,n){const r=Rn(n,e);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function CAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function AAe(t,e,n){return!Rn(n,e)}function EAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&r.tagName==="tr"}function Z$(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const kAe=pq({body:MAe,colgroup:OAe,head:RAe,html:TAe,tbody:PAe});function TAe(t){const e=Rn(t,-1);return!e||e.type!=="comment"}function RAe(t){const e=new Set;for(const r of t.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(e.has(r.tagName))return!1;e.add(r.tagName)}const n=t.children[0];return!n||n.type==="element"}function MAe(t){const e=Rn(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&_x(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function OAe(t,e,n){const r=fq(n,e),i=Rn(t,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&PR(r,n.children.indexOf(r),n)?!1:!!(i&&i.type==="element"&&i.tagName==="col")}function PAe(t,e,n){const r=fq(n,e),i=Rn(t,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&PR(r,n.children.indexOf(r),n)?!1:!!(i&&i.type==="element"&&i.tagName==="tr")}const tb={name:[[`
\f\r &/=>`.split(""),`
\f\r "&'/=>\``.split("")],[`\0
\f\r "&'/<=>`.split(""),`\0
\f\r "&'/<=>\``.split("")]],unquoted:[[`
\f\r &>`.split(""),`\0
\f\r "&'<=>\``.split("")],[`\0
\f\r "&'<=>\``.split(""),`\0
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function DAe(t,e,n,r){const i=r.schema,s=i.space==="svg"?!1:r.settings.omitOptionalTags;let o=i.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(t.tagName.toLowerCase());const a=[];let c;i.space==="html"&&t.tagName==="svg"&&(r.schema=og);const h=IAe(r,t.properties),f=r.all(i.space==="html"&&t.tagName==="template"?t.content:t);return r.schema=i,f&&(o=!1),(h||!s||!kAe(t,e,n))&&(a.push("<",t.tagName,h?" "+h:""),o&&(i.space==="svg"||r.settings.closeSelfClosing)&&(c=h.charAt(h.length-1),(!r.settings.tightSelfClosing||c==="/"||c&&c!=='"'&&c!=="'")&&a.push(" "),a.push("/")),a.push(">")),a.push(f),!o&&(!s||!PR(t,e,n))&&a.push("</"+t.tagName+">"),a.join("")}function IAe(t,e){const n=[];let r=-1,i;if(e){for(i in e)if(e[i]!==null&&e[i]!==void 0){const s=LAe(t,i,e[i]);s&&n.push(s)}}for(;++r<n.length;){const s=t.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&s!=='"'&&s!=="'"&&(n[r]+=" ")}return n.join("")}function LAe(t,e,n){const r=EW(t.schema,e),i=t.settings.allowParseErrors&&t.schema.space==="html"?0:1,s=t.settings.allowDangerousCharacters?0:1;let o=t.quote,a;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const c=kh(r.attribute,Object.assign({},t.settings.characterReferences,{subset:tb.name[i][s]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?bW:TW)(n,{padLeft:!t.settings.tightCommaSeparatedLists}):String(n),t.settings.collapseEmptyAttributes&&!n)?c:(t.settings.preferUnquoted&&(a=kh(n,Object.assign({},t.settings.characterReferences,{attribute:!0,subset:tb.unquoted[i][s]}))),a!==n&&(t.settings.quoteSmart&&Zv(n,o)>Zv(n,t.alternative)&&(o=t.alternative),a=o+kh(n,Object.assign({},t.settings.characterReferences,{subset:(o==="'"?tb.single:tb.double)[i][s],attribute:!0}))+o),c+(a&&"="+a))}const NAe=["<","&"];function mq(t,e,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?t.value:kh(t.value,Object.assign({},r.settings.characterReferences,{subset:NAe}))}function $Ae(t,e,n,r){return r.settings.allowDangerousHtml?t.value:mq(t,e,n,r)}function jAe(t,e,n,r){return r.all(t)}const BAe=lwe("type",{invalid:FAe,unknown:zAe,handlers:{comment:hAe,doctype:fAe,element:DAe,raw:$Ae,root:jAe,text:mq}});function FAe(t){throw new Error("Expected node, not `"+t+"`")}function zAe(t){const e=t;throw new Error("Cannot compile unknown node `"+e.type+"`")}const VAe={},UAe={},HAe=[];function WAe(t,e){const n=e||VAe,r=n.quote||'"',i=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:qAe,all:GAe,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||WCe,characterReferences:n.characterReferences||UAe,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?og:kW,quote:r,alternative:i}.one(Array.isArray(t)?{type:"root",children:t}:t,void 0,void 0)}function qAe(t,e,n){return BAe(t,e,n,this)}function GAe(t){const e=[],n=t&&t.children||HAe;let r=-1;for(;++r<n.length;)e[r]=this.one(n[r],r,t);return e.join("")}function cw(t,e){const n=typeof t=="string"?{}:{...t.colorReplacements},r=typeof t=="string"?t:t.name;for(const[i,s]of Object.entries(e?.colorReplacements||{}))typeof s=="string"?n[i]=s:i===r&&Object.assign(n,s);return n}function cl(t,e){return t&&(e?.[t?.toLowerCase()]||t)}function KAe(t){return Array.isArray(t)?t:[t]}async function gq(t){return Promise.resolve(typeof t=="function"?t():t).then(e=>e.default||e)}function DR(t){return!t||["plaintext","txt","text","plain"].includes(t)}function yq(t){return t==="ansi"||DR(t)}function IR(t){return t==="none"}function bq(t){return IR(t)}function vq(t,e){if(!e)return t;t.properties||={},t.properties.class||=[],typeof t.properties.class=="string"&&(t.properties.class=t.properties.class.split(/\s+/g)),Array.isArray(t.properties.class)||(t.properties.class=[]);const n=Array.isArray(e)?e:e.split(/\s+/g);for(const r of n)r&&!t.properties.class.includes(r)&&t.properties.class.push(r);return t}function Ax(t,e=!1){const n=t.split(/(\r?\n)/g);let r=0;const i=[];for(let s=0;s<n.length;s+=2){const o=e?n[s]+(n[s+1]||""):n[s];i.push([o,r]),r+=n[s].length,r+=n[s+1]?.length||0}return i}function YAe(t){const e=Ax(t,!0).map(([i])=>i);function n(i){if(i===t.length)return{line:e.length-1,character:e[e.length-1].length};let s=i,o=0;for(const a of e){if(s<a.length)break;s-=a.length,o++}return{line:o,character:s}}function r(i,s){let o=0;for(let a=0;a<i;a++)o+=e[a].length;return o+=s,o}return{lines:e,indexToPos:n,posToIndex:r}}function XAe(t,e,n){const r=new Set;for(const s of t.matchAll(/lang=["']([\w-]+)["']/g))r.add(s[1]);for(const s of t.matchAll(/(?:```|~~~)([\w-]+)/g))r.add(s[1]);for(const s of t.matchAll(/\\begin\{([\w-]+)\}/g))r.add(s[1]);if(!n)return Array.from(r);const i=n.getBundledLanguages();return Array.from(r).filter(s=>s&&i[s])}const LR="light-dark()",JAe=["color","background-color"];function QAe(t,e){let n=0;const r=[];for(const i of e)i>n&&r.push({...t,content:t.content.slice(n,i),offset:t.offset+n}),n=i;return n<t.content.length&&r.push({...t,content:t.content.slice(n),offset:t.offset+n}),r}function ZAe(t,e){const n=Array.from(e instanceof Set?e:new Set(e)).sort((r,i)=>r-i);return n.length?t.map(r=>r.flatMap(i=>{const s=n.filter(o=>i.offset<o&&o<i.offset+i.content.length).map(o=>o-i.offset).sort((o,a)=>o-a);return s.length?QAe(i,s):i})):t}function eEe(t,e,n,r,i="css-vars"){const s={content:t.content,explanation:t.explanation,offset:t.offset},o=e.map(f=>uw(t.variants[f])),a=new Set(o.flatMap(f=>Object.keys(f))),c={},h=(f,d)=>{const m=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return n+e[f]+(d==="color"?"":m)};return o.forEach((f,d)=>{for(const m of a){const y=f[m]||"inherit";if(d===0&&r&&JAe.includes(m))if(r===LR&&o.length>1){const b=e.findIndex(A=>A==="light"),w=e.findIndex(A=>A==="dark");if(b===-1||w===-1)throw new pn('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const S=o[b][m]||"inherit",_=o[w][m]||"inherit";c[m]=`light-dark(${S}, ${_})`,i==="css-vars"&&(c[h(d,m)]=y)}else c[m]=y;else i==="css-vars"&&(c[h(d,m)]=y)}}),s.htmlStyle=c,s}function uw(t){const e={};if(t.color&&(e.color=t.color),t.bgColor&&(e["background-color"]=t.bgColor),t.fontStyle){t.fontStyle&pr.Italic&&(e["font-style"]="italic"),t.fontStyle&pr.Bold&&(e["font-weight"]="bold");const n=[];t.fontStyle&pr.Underline&&n.push("underline"),t.fontStyle&pr.Strikethrough&&n.push("line-through"),n.length&&(e["text-decoration"]=n.join(" "))}return e}function _E(t){return typeof t=="string"?t:Object.entries(t).map(([e,n])=>`${e}:${n}`).join(";")}const wq=new WeakMap;function Ex(t,e){wq.set(t,e)}function Mm(t){return wq.get(t)}class af{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,n){return new af(Object.fromEntries(KAe(n).map(r=>[r,xE])),e)}constructor(...e){if(e.length===2){const[n,r]=e;this.lang=r,this._stacks=n}else{const[n,r,i]=e;this.lang=r,this._stacks={[i]:n}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return tEe(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function tEe(t){const e=[],n=new Set;function r(i){if(n.has(i))return;n.add(i);const s=i?.nameScopesList?.scopeName;s&&e.push(s),i.parent&&r(i.parent)}return r(t),e}function nEe(t,e){if(!(t instanceof af))throw new pn("Invalid grammar state");return t.getInternalStack(e)}function rEe(){const t=new WeakMap;function e(n){if(!t.has(n.meta)){let r=function(o){if(typeof o=="number"){if(o<0||o>n.source.length)throw new pn(`Invalid decoration offset: ${o}. Code length: ${n.source.length}`);return{...i.indexToPos(o),offset:o}}else{const a=i.lines[o.line];if(a===void 0)throw new pn(`Invalid decoration position ${JSON.stringify(o)}. Lines length: ${i.lines.length}`);let c=o.character;if(c<0&&(c=a.length+c),c<0||c>a.length)throw new pn(`Invalid decoration position ${JSON.stringify(o)}. Line ${o.line} length: ${a.length}`);return{...o,character:c,offset:i.posToIndex(o.line,c)}}};const i=YAe(n.source),s=(n.options.decorations||[]).map(o=>({...o,start:r(o.start),end:r(o.end)}));iEe(s),t.set(n.meta,{decorations:s,converter:i,source:n.source})}return t.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(!this.options.decorations?.length)return;const i=e(this).decorations.flatMap(o=>[o.start.offset,o.end.offset]);return ZAe(n,i)},code(n){if(!this.options.decorations?.length)return;const r=e(this),i=Array.from(n.children).filter(f=>f.type==="element"&&f.tagName==="span");if(i.length!==r.converter.lines.length)throw new pn(`Number of lines in code element (${i.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function s(f,d,m,y){const b=i[f];let w="",S=-1,_=-1;if(d===0&&(S=0),m===0&&(_=0),m===Number.POSITIVE_INFINITY&&(_=b.children.length),S===-1||_===-1)for(let E=0;E<b.children.length;E++)w+=xq(b.children[E]),S===-1&&w.length===d&&(S=E+1),_===-1&&w.length===m&&(_=E+1);if(S===-1)throw new pn(`Failed to find start index for decoration ${JSON.stringify(y.start)}`);if(_===-1)throw new pn(`Failed to find end index for decoration ${JSON.stringify(y.end)}`);const A=b.children.slice(S,_);if(!y.alwaysWrap&&A.length===b.children.length)a(b,y,"line");else if(!y.alwaysWrap&&A.length===1&&A[0].type==="element")a(A[0],y,"token");else{const E={type:"element",tagName:"span",properties:{},children:A};a(E,y,"wrapper"),b.children.splice(S,A.length,E)}}function o(f,d){i[f]=a(i[f],d,"line")}function a(f,d,m){const y=d.properties||{},b=d.transform||(w=>w);return f.tagName=d.tagName||"span",f.properties={...f.properties,...y,class:f.properties.class},d.properties?.class&&vq(f,d.properties.class),f=b(f,m)||f,f}const c=[],h=r.decorations.sort((f,d)=>d.start.offset-f.start.offset||f.end.offset-d.end.offset);for(const f of h){const{start:d,end:m}=f;if(d.line===m.line)s(d.line,d.character,m.character,f);else if(d.line<m.line){s(d.line,d.character,Number.POSITIVE_INFINITY,f);for(let y=d.line+1;y<m.line;y++)c.unshift(()=>o(y,f));s(m.line,0,m.character,f)}}c.forEach(f=>f())}}}function iEe(t){for(let e=0;e<t.length;e++){const n=t[e];if(n.start.offset>n.end.offset)throw new pn(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=e+1;r<t.length;r++){const i=t[r],s=n.start.offset<=i.start.offset&&i.start.offset<n.end.offset,o=n.start.offset<i.end.offset&&i.end.offset<=n.end.offset,a=i.start.offset<=n.start.offset&&n.start.offset<i.end.offset,c=i.start.offset<n.end.offset&&n.end.offset<=i.end.offset;if(s||o||a||c){if(s&&o||a&&c||a&&n.start.offset===n.end.offset||o&&i.start.offset===i.end.offset)continue;throw new pn(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(i.start)} intersect.`)}}}}function xq(t){return t.type==="text"?t.value:t.type==="element"?t.children.map(xq).join(""):""}const sEe=[rEe()];function hw(t){const e=oEe(t.transformers||[]);return[...e.pre,...e.normal,...e.post,...sEe]}function oEe(t){const e=[],n=[],r=[];for(const i of t)switch(i.enforce){case"pre":e.push(i);break;case"post":n.push(i);break;default:r.push(i)}return{pre:e,post:n,normal:r}}var mc=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],$2={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function aEe(t,e){const n=t.indexOf("\x1B",e);if(n!==-1&&t[n+1]==="["){const r=t.indexOf("m",n);if(r!==-1)return{sequence:t.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:t.length}}function e5(t){const e=t.shift();if(e==="2"){const n=t.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(e==="5"){const n=t.shift();if(n)return{type:"table",index:Number(n)}}}function lEe(t){const e=[];for(;t.length>0;){const n=t.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)e.push({type:"resetAll"});else if(r<=9)$2[r]&&e.push({type:"setDecoration",value:$2[r]});else if(r<=29){const i=$2[r-20];i&&(e.push({type:"resetDecoration",value:i}),i==="dim"&&e.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)e.push({type:"setForegroundColor",value:{type:"named",name:mc[r-30]}});else if(r===38){const i=e5(t);i&&e.push({type:"setForegroundColor",value:i})}else if(r===39)e.push({type:"resetForegroundColor"});else if(r<=47)e.push({type:"setBackgroundColor",value:{type:"named",name:mc[r-40]}});else if(r===48){const i=e5(t);i&&e.push({type:"setBackgroundColor",value:i})}else r===49?e.push({type:"resetBackgroundColor"}):r===53?e.push({type:"setDecoration",value:"overline"}):r===55?e.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?e.push({type:"setForegroundColor",value:{type:"named",name:mc[r-90+8]}}):r>=100&&r<=107&&e.push({type:"setBackgroundColor",value:{type:"named",name:mc[r-100+8]}})}return e}function cEe(){let t=null,e=null,n=new Set;return{parse(r){const i=[];let s=0;do{const o=aEe(r,s),a=o.sequence?r.substring(s,o.startPosition):r.substring(s);if(a.length>0&&i.push({value:a,foreground:t,background:e,decorations:new Set(n)}),o.sequence){const c=lEe(o.sequence);for(const h of c)h.type==="resetAll"?(t=null,e=null,n.clear()):h.type==="resetForegroundColor"?t=null:h.type==="resetBackgroundColor"?e=null:h.type==="resetDecoration"&&n.delete(h.value);for(const h of c)h.type==="setForegroundColor"?t=h.value:h.type==="setBackgroundColor"?e=h.value:h.type==="setDecoration"&&n.add(h.value)}s=o.position}while(s<r.length);return i}}}var uEe={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function hEe(t=uEe){function e(a){return t[a]}function n(a){return`#${a.map(c=>Math.max(0,Math.min(c,255)).toString(16).padStart(2,"0")).join("")}`}let r;function i(){if(r)return r;r=[];for(let h=0;h<mc.length;h++)r.push(e(mc[h]));let a=[0,95,135,175,215,255];for(let h=0;h<6;h++)for(let f=0;f<6;f++)for(let d=0;d<6;d++)r.push(n([a[h],a[f],a[d]]));let c=8;for(let h=0;h<24;h++,c+=10)r.push(n([c,c,c]));return r}function s(a){return i()[a]}function o(a){switch(a.type){case"named":return e(a.name);case"rgb":return n(a.rgb);case"table":return s(a.index)}}return{value:o}}function fEe(t,e,n){const r=cw(t,n),i=Ax(e),s=hEe(Object.fromEntries(mc.map(a=>[a,t.colors?.[`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`]]))),o=cEe();return i.map(a=>o.parse(a[0]).map(c=>{let h,f;c.decorations.has("reverse")?(h=c.background?s.value(c.background):t.bg,f=c.foreground?s.value(c.foreground):t.fg):(h=c.foreground?s.value(c.foreground):t.fg,f=c.background?s.value(c.background):void 0),h=cl(h,r),f=cl(f,r),c.decorations.has("dim")&&(h=dEe(h));let d=pr.None;return c.decorations.has("bold")&&(d|=pr.Bold),c.decorations.has("italic")&&(d|=pr.Italic),c.decorations.has("underline")&&(d|=pr.Underline),c.decorations.has("strikethrough")&&(d|=pr.Strikethrough),{content:c.value,offset:a[1],color:h,bgColor:f,fontStyle:d}}))}function dEe(t){const e=t.match(/#([0-9a-f]{3})([0-9a-f]{3})?([0-9a-f]{2})?/);if(e)if(e[3]){const r=Math.round(Number.parseInt(e[3],16)/2).toString(16).padStart(2,"0");return`#${e[1]}${e[2]}${r}`}else return e[2]?`#${e[1]}${e[2]}80`:`#${Array.from(e[1]).map(r=>`${r}${r}`).join("")}80`;const n=t.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:t}function NR(t,e,n={}){const{lang:r="text",theme:i=t.getLoadedThemes()[0]}=n;if(DR(r)||IR(i))return Ax(e).map(c=>[{content:c[0],offset:c[1]}]);const{theme:s,colorMap:o}=t.setTheme(i);if(r==="ansi")return fEe(s,e,n);const a=t.getLanguage(r);if(n.grammarState){if(n.grammarState.lang!==a.name)throw new pn(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${a.name}"`);if(!n.grammarState.themes.includes(s.name))throw new pn(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return mEe(e,a,s,o,n)}function pEe(...t){if(t.length===2)return Mm(t[1]);const[e,n,r={}]=t,{lang:i="text",theme:s=e.getLoadedThemes()[0]}=r;if(DR(i)||IR(s))throw new pn("Plain language does not have grammar state");if(i==="ansi")throw new pn("ANSI language does not have grammar state");const{theme:o,colorMap:a}=e.setTheme(s),c=e.getLanguage(i);return new af(fw(n,c,o,a,r).stateStack,c.name,o.name)}function mEe(t,e,n,r,i){const s=fw(t,e,n,r,i),o=new af(fw(t,e,n,r,i).stateStack,e.name,n.name);return Ex(s.tokens,o),s.tokens}function fw(t,e,n,r,i){const s=cw(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:a=500}=i,c=Ax(t);let h=i.grammarState?nEe(i.grammarState,n.name)??xE:i.grammarContextCode!=null?fw(i.grammarContextCode,e,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack:xE,f=[];const d=[];for(let m=0,y=c.length;m<y;m++){const[b,w]=c[m];if(b===""){f=[],d.push([]);continue}if(o>0&&b.length>=o){f=[],d.push([{content:b,offset:w,color:"",fontStyle:0}]);continue}let S,_,A;i.includeExplanation&&(S=e.tokenizeLine(b,h,a),_=S.tokens,A=0);const E=e.tokenizeLine2(b,h,a),P=E.tokens.length/2;for(let O=0;O<P;O++){const M=E.tokens[2*O],D=O+1<P?E.tokens[2*O+2]:b.length;if(M===D)continue;const $=E.tokens[2*O+1],F=cl(r[Uh.getForeground($)],s),N=Uh.getFontStyle($),U={content:b.substring(M,D),offset:w+M,color:F,fontStyle:N};if(i.includeExplanation){const q=[];if(i.includeExplanation!=="scopeName")for(const X of n.settings){let ee;switch(typeof X.scope){case"string":ee=X.scope.split(/,/).map(V=>V.trim());break;case"object":ee=X.scope;break;default:continue}q.push({settings:X,selectors:ee.map(V=>V.split(/ /))})}U.explanation=[];let K=0;for(;M+K<D;){const X=_[A],ee=b.substring(X.startIndex,X.endIndex);K+=ee.length,U.explanation.push({content:ee,scopes:i.includeExplanation==="scopeName"?gEe(X.scopes):yEe(q,X.scopes)}),A+=1}}f.push(U)}d.push(f),f=[],h=E.ruleStack}return{tokens:d,stateStack:h}}function gEe(t){return t.map(e=>({scopeName:e}))}function yEe(t,e){const n=[];for(let r=0,i=e.length;r<i;r++){const s=e[r];n[r]={scopeName:s,themeMatches:vEe(t,s,e.slice(0,r))}}return n}function t5(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function bEe(t,e,n){if(!t5(t[t.length-1],e))return!1;let r=t.length-2,i=n.length-1;for(;r>=0&&i>=0;)t5(t[r],n[i])&&(r-=1),i-=1;return r===-1}function vEe(t,e,n){const r=[];for(const{selectors:i,settings:s}of t)for(const o of i)if(bEe(o,e,n)){r.push(s);break}return r}function Sq(t,e,n){const r=Object.entries(n.themes).filter(c=>c[1]).map(c=>({color:c[0],theme:c[1]})),i=r.map(c=>{const h=NR(t,e,{...n,theme:c.theme}),f=Mm(h),d=typeof c.theme=="string"?c.theme:c.theme.name;return{tokens:h,state:f,theme:d}}),s=wEe(...i.map(c=>c.tokens)),o=s[0].map((c,h)=>c.map((f,d)=>{const m={content:f.content,variants:{},offset:f.offset};return"includeExplanation"in n&&n.includeExplanation&&(m.explanation=f.explanation),s.forEach((y,b)=>{const{content:w,explanation:S,offset:_,...A}=y[h][d];m.variants[r[b].color]=A}),m})),a=i[0].state?new af(Object.fromEntries(i.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),i[0].state.lang):void 0;return a&&Ex(o,a),o}function wEe(...t){const e=t.map(()=>[]),n=t.length;for(let r=0;r<t[0].length;r++){const i=t.map(c=>c[r]),s=e.map(()=>[]);e.forEach((c,h)=>c.push(s[h]));const o=i.map(()=>0),a=i.map(c=>c[0]);for(;a.every(c=>c);){const c=Math.min(...a.map(h=>h.content.length));for(let h=0;h<n;h++){const f=a[h];f.content.length===c?(s[h].push(f),o[h]+=1,a[h]=i[h][o[h]]):(s[h].push({...f,content:f.content.slice(0,c)}),a[h]={...f,content:f.content.slice(c),offset:f.offset+c})}}}return e}function dw(t,e,n){let r,i,s,o,a,c;if("themes"in n){const{defaultColor:h="light",cssVariablePrefix:f="--shiki-",colorsRendering:d="css-vars"}=n,m=Object.entries(n.themes).filter(_=>_[1]).map(_=>({color:_[0],theme:_[1]})).sort((_,A)=>_.color===h?-1:A.color===h?1:0);if(m.length===0)throw new pn("`themes` option must not be empty");const y=Sq(t,e,n);if(c=Mm(y),h&&LR!==h&&!m.find(_=>_.color===h))throw new pn(`\`themes\` option must contain the defaultColor key \`${h}\``);const b=m.map(_=>t.getTheme(_.theme)),w=m.map(_=>_.color);s=y.map(_=>_.map(A=>eEe(A,w,f,h,d))),c&&Ex(s,c);const S=m.map(_=>cw(_.theme,n));i=n5(m,b,S,f,h,"fg",d),r=n5(m,b,S,f,h,"bg",d),o=`shiki-themes ${b.map(_=>_.name).join(" ")}`,a=h?void 0:[i,r].join(";")}else if("theme"in n){const h=cw(n.theme,n);s=NR(t,e,n);const f=t.getTheme(n.theme);r=cl(f.bg,h),i=cl(f.fg,h),o=f.name,c=Mm(s)}else throw new pn("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:i,bg:r,themeName:o,rootStyle:a,grammarState:c}}function n5(t,e,n,r,i,s,o){return t.map((a,c)=>{const h=cl(e[c][s],n[c])||"inherit",f=`${r+a.color}${s==="bg"?"-bg":""}:${h}`;if(c===0&&i){if(i===LR&&t.length>1){const d=t.findIndex(w=>w.color==="light"),m=t.findIndex(w=>w.color==="dark");if(d===-1||m===-1)throw new pn('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const y=cl(e[d][s],n[d])||"inherit",b=cl(e[m][s],n[m])||"inherit";return`light-dark(${y}, ${b});${f}`}return h}return o==="css-vars"?f:null}).filter(a=>!!a).join(";")}function pw(t,e,n,r={meta:{},options:n,codeToHast:(i,s)=>pw(t,i,s),codeToTokens:(i,s)=>dw(t,i,s)}){let i=e;for(const b of hw(n))i=b.preprocess?.call(r,i,n)||i;let{tokens:s,fg:o,bg:a,themeName:c,rootStyle:h,grammarState:f}=dw(t,i,n);const{mergeWhitespaces:d=!0,mergeSameStyleTokens:m=!1}=n;d===!0?s=SEe(s):d==="never"&&(s=_Ee(s)),m&&(s=CEe(s));const y={...r,get source(){return i}};for(const b of hw(n))s=b.tokens?.call(y,s)||s;return xEe(s,{...n,fg:o,bg:a,themeName:c,rootStyle:h},y,f)}function xEe(t,e,n,r=Mm(t)){const i=hw(e),s=[],o={type:"root",children:[]},{structure:a="classic",tabindex:c="0"}=e;let h={type:"element",tagName:"pre",properties:{class:`shiki ${e.themeName||""}`,style:e.rootStyle||`background-color:${e.bg};color:${e.fg}`,...c!==!1&&c!=null?{tabindex:c.toString()}:{},...Object.fromEntries(Array.from(Object.entries(e.meta||{})).filter(([b])=>!b.startsWith("_")))},children:[]},f={type:"element",tagName:"code",properties:{},children:s};const d=[],m={...n,structure:a,addClassToHast:vq,get source(){return n.source},get tokens(){return t},get options(){return e},get root(){return o},get pre(){return h},get code(){return f},get lines(){return d}};if(t.forEach((b,w)=>{w&&(a==="inline"?o.children.push({type:"element",tagName:"br",properties:{},children:[]}):a==="classic"&&s.push({type:"text",value:`
`}));let S={type:"element",tagName:"span",properties:{class:"line"},children:[]},_=0;for(const A of b){let E={type:"element",tagName:"span",properties:{...A.htmlAttrs},children:[{type:"text",value:A.content}]};const P=_E(A.htmlStyle||uw(A));P&&(E.properties.style=P);for(const O of i)E=O?.span?.call(m,E,w+1,_,S,A)||E;a==="inline"?o.children.push(E):a==="classic"&&S.children.push(E),_+=A.content.length}if(a==="classic"){for(const A of i)S=A?.line?.call(m,S,w+1)||S;d.push(S),s.push(S)}}),a==="classic"){for(const b of i)f=b?.code?.call(m,f)||f;h.children.push(f);for(const b of i)h=b?.pre?.call(m,h)||h;o.children.push(h)}let y=o;for(const b of i)y=b?.root?.call(m,y)||y;return r&&Ex(y,r),y}function SEe(t){return t.map(e=>{const n=[];let r="",i=0;return e.forEach((s,o)=>{const c=!(s.fontStyle&&(s.fontStyle&pr.Underline||s.fontStyle&pr.Strikethrough));c&&s.content.match(/^\s+$/)&&e[o+1]?(i||(i=s.offset),r+=s.content):r?(c?n.push({...s,offset:i,content:r+s.content}):n.push({content:r,offset:i},s),i=0,r=""):n.push(s)}),n})}function _Ee(t){return t.map(e=>e.flatMap(n=>{if(n.content.match(/^\s+$/))return n;const r=n.content.match(/^(\s*)(.*?)(\s*)$/);if(!r)return n;const[,i,s,o]=r;if(!i&&!o)return n;const a=[{...n,offset:n.offset+i.length,content:s}];return i&&a.unshift({content:i,offset:n.offset}),o&&a.push({content:o,offset:n.offset+i.length+s.length}),a}))}function CEe(t){return t.map(e=>{const n=[];for(const r of e){if(n.length===0){n.push({...r});continue}const i=n[n.length-1],s=_E(i.htmlStyle||uw(i)),o=_E(r.htmlStyle||uw(r)),a=i.fontStyle&&(i.fontStyle&pr.Underline||i.fontStyle&pr.Strikethrough),c=r.fontStyle&&(r.fontStyle&pr.Underline||r.fontStyle&pr.Strikethrough);!a&&!c&&s===o?i.content+=r.content:n.push({...r})}return n})}const AEe=WAe;function EEe(t,e,n){const r={meta:{},options:n,codeToHast:(s,o)=>pw(t,s,o),codeToTokens:(s,o)=>dw(t,s,o)};let i=AEe(pw(t,e,n,r));for(const s of hw(n))i=s.postprocess?.call(r,i,n)||i;return i}const r5={light:"#333333",dark:"#bbbbbb"},i5={light:"#fffffe",dark:"#1e1e1e"},s5="__shiki_resolved";function $R(t){if(t?.[s5])return t;const e={...t};e.tokenColors&&!e.settings&&(e.settings=e.tokenColors,delete e.tokenColors),e.type||="dark",e.colorReplacements={...e.colorReplacements},e.settings||=[];let{bg:n,fg:r}=e;if(!n||!r){const a=e.settings?e.settings.find(c=>!c.name&&!c.scope):void 0;a?.settings?.foreground&&(r=a.settings.foreground),a?.settings?.background&&(n=a.settings.background),!r&&e?.colors?.["editor.foreground"]&&(r=e.colors["editor.foreground"]),!n&&e?.colors?.["editor.background"]&&(n=e.colors["editor.background"]),r||(r=e.type==="light"?r5.light:r5.dark),n||(n=e.type==="light"?i5.light:i5.dark),e.fg=r,e.bg=n}e.settings[0]&&e.settings[0].settings&&!e.settings[0].scope||e.settings.unshift({settings:{foreground:e.fg,background:e.bg}});let i=0;const s=new Map;function o(a){if(s.has(a))return s.get(a);i+=1;const c=`#${i.toString(16).padStart(8,"0").toLowerCase()}`;return e.colorReplacements?.[`#${c}`]?o(a):(s.set(a,c),c)}e.settings=e.settings.map(a=>{const c=a.settings?.foreground&&!a.settings.foreground.startsWith("#"),h=a.settings?.background&&!a.settings.background.startsWith("#");if(!c&&!h)return a;const f={...a,settings:{...a.settings}};if(c){const d=o(a.settings.foreground);e.colorReplacements[d]=a.settings.foreground,f.settings.foreground=d}if(h){const d=o(a.settings.background);e.colorReplacements[d]=a.settings.background,f.settings.background=d}return f});for(const a of Object.keys(e.colors||{}))if((a==="editor.foreground"||a==="editor.background"||a.startsWith("terminal.ansi"))&&!e.colors[a]?.startsWith("#")){const c=o(e.colors[a]);e.colorReplacements[c]=e.colors[a],e.colors[a]=c}return Object.defineProperty(e,s5,{enumerable:!1,writable:!1,value:!0}),e}async function _q(t){return Array.from(new Set((await Promise.all(t.filter(e=>!yq(e)).map(async e=>await gq(e).then(n=>Array.isArray(n)?n:[n])))).flat()))}async function Cq(t){return(await Promise.all(t.map(async n=>bq(n)?null:$R(await gq(n))))).filter(n=>!!n)}let kEe=3;function TEe(t,e=3){e>kEe||console.trace(`[SHIKI DEPRECATE]: ${t}`)}let hh=class extends Error{constructor(e){super(e),this.name="ShikiError"}};class REe extends HCe{constructor(e,n,r,i={}){super(e),this._resolver=e,this._themes=n,this._langs=r,this._alias=i,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const n=$R(e);return n.name&&(this._resolvedThemes.set(n.name,n),this._loadedThemesCache=null),n}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let n=this._textmateThemeCache.get(e);n||(n=iw.createFromRawTheme(e),this._textmateThemeCache.set(e,n)),this._syncRegistry.setTheme(n)}getGrammar(e){if(this._alias[e]){const n=new Set([e]);for(;this._alias[e];){if(e=this._alias[e],n.has(e))throw new hh(`Circular alias \`${Array.from(n).join(" -> ")} -> ${e}\``);n.add(e)}}return this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const n=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const r={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const i=this.loadGrammarWithConfiguration(e.scopeName,1,r);if(i.name=e.name,this._resolvedGrammars.set(e.name,i),e.aliases&&e.aliases.forEach(s=>{this._alias[s]=e.name}),this._loadedLanguagesCache=null,n.size)for(const s of n)this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const i of e)this.resolveEmbeddedLanguages(i);const n=Array.from(this._langGraph.entries()),r=n.filter(([i,s])=>!s);if(r.length){const i=n.filter(([s,o])=>o&&o.embeddedLangs?.some(a=>r.map(([c])=>c).includes(a))).filter(s=>!r.includes(s));throw new hh(`Missing languages ${r.map(([s])=>`\`${s}\``).join(", ")}, required by ${i.map(([s])=>`\`${s}\``).join(", ")}`)}for(const[i,s]of n)this._resolver.addLanguage(s);for(const[i,s]of n)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){if(this._langMap.set(e.name,e),this._langGraph.set(e.name,e),e.embeddedLangs)for(const n of e.embeddedLangs)this._langGraph.set(n,this._langMap.get(n))}}class MEe{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,n){this._onigLib={createOnigScanner:r=>e.createScanner(r),createOnigString:r=>e.createString(r)},n.forEach(r=>this.addLanguage(r))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(n=>{this._langs.set(n,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(n=>{this._injections.get(n)||this._injections.set(n,[]),this._injections.get(n).push(e.scopeName)})}getInjections(e){const n=e.split(".");let r=[];for(let i=1;i<=n.length;i++){const s=n.slice(0,i).join(".");r=[...r,...this._injections.get(s)||[]]}return r}}let zd=0;function OEe(t){zd+=1,t.warnings!==!1&&zd>=10&&zd%10===0&&console.warn(`[Shiki] ${zd} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let e=!1;if(!t.engine)throw new hh("`engine` option is required for synchronous mode");const n=(t.langs||[]).flat(1),r=(t.themes||[]).flat(1).map($R),i=new MEe(t.engine,n),s=new REe(i,r,n,t.langAlias);let o;function a(A){S();const E=s.getGrammar(typeof A=="string"?A:A.name);if(!E)throw new hh(`Language \`${A}\` not found, you may need to load it first`);return E}function c(A){if(A==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};S();const E=s.getTheme(A);if(!E)throw new hh(`Theme \`${A}\` not found, you may need to load it first`);return E}function h(A){S();const E=c(A);o!==A&&(s.setTheme(E),o=A);const P=s.getColorMap();return{theme:E,colorMap:P}}function f(){return S(),s.getLoadedThemes()}function d(){return S(),s.getLoadedLanguages()}function m(...A){S(),s.loadLanguages(A.flat(1))}async function y(...A){return m(await _q(A))}function b(...A){S();for(const E of A.flat(1))s.loadTheme(E)}async function w(...A){return S(),b(await Cq(A))}function S(){if(e)throw new hh("Shiki instance has been disposed")}function _(){e||(e=!0,s.dispose(),zd-=1)}return{setTheme:h,getTheme:c,getLanguage:a,getLoadedThemes:f,getLoadedLanguages:d,loadLanguage:y,loadLanguageSync:m,loadTheme:w,loadThemeSync:b,dispose:_,[Symbol.dispose]:_}}async function PEe(t){t.engine||TEe("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[e,n,r]=await Promise.all([Cq(t.themes||[]),_q(t.langs||[]),t.engine]);return OEe({...t,themes:e,langs:n,engine:r})}async function DEe(t){const e=await PEe(t);return{getLastGrammarState:(...n)=>pEe(e,...n),codeToTokensBase:(n,r)=>NR(e,n,r),codeToTokensWithThemes:(n,r)=>Sq(e,n,r),codeToTokens:(n,r)=>dw(e,n,r),codeToHast:(n,r)=>pw(e,n,r),codeToHtml:(n,r)=>EEe(e,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...e,getInternalContext:()=>e}}function IEe(t){const e=t.langs,n=t.themes,r=t.engine;async function i(s){function o(d){if(typeof d=="string"){if(yq(d))return[];d=s.langAlias?.[d]||d;const m=e[d];if(!m)throw new pn(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return m}return d}function a(d){if(bq(d))return"none";if(typeof d=="string"){const m=n[d];if(!m)throw new pn(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return m}return d}const c=(s.themes??[]).map(d=>a(d)),h=(s.langs??[]).map(d=>o(d)),f=await DEe({engine:s.engine??r(),...s,themes:c,langs:h});return{...f,loadLanguage(...d){return f.loadLanguage(...d.map(o))},loadTheme(...d){return f.loadTheme(...d.map(a))},getBundledLanguages(){return e},getBundledThemes(){return n}}}return i}function LEe(t){let e;async function n(r={}){if(e){const i=await e;return await Promise.all([i.loadTheme(...r.themes||[]),i.loadLanguage(...r.langs||[])]),i}else return e=t({...r,themes:r.themes||[],langs:r.langs||[]}),e}return n}function NEe(t,e){const n=LEe(t);async function r(i,s){const o=await n({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),a=await e?.guessEmbeddedLanguages?.(i,s.lang,o);return a&&await o.loadLanguage(...a),o}return{getSingletonHighlighter(i){return n(i)},async codeToHtml(i,s){return(await r(i,s)).codeToHtml(i,s)},async codeToHast(i,s){return(await r(i,s)).codeToHast(i,s)},async codeToTokens(i,s){return(await r(i,s)).codeToTokens(i,s)},async codeToTokensBase(i,s){return(await r(i,s)).codeToTokensBase(i,s)},async codeToTokensWithThemes(i,s){return(await r(i,s)).codeToTokensWithThemes(i,s)},async getLastGrammarState(i,s){return(await n({langs:[s.lang],themes:[s.theme]})).getLastGrammarState(i,s)}}}const Aq=[{id:"abap",name:"ABAP",import:(()=>B(()=>import("./abap.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>B(()=>import("./actionscript-3.js"),[]))},{id:"ada",name:"Ada",import:(()=>B(()=>import("./ada.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>B(()=>import("./angular-html.js").then(t=>t.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>B(()=>import("./angular-ts.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>B(()=>import("./apache.js"),[]))},{id:"apex",name:"Apex",import:(()=>B(()=>import("./apex.js"),[]))},{id:"apl",name:"APL",import:(()=>B(()=>import("./apl.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>B(()=>import("./applescript.js"),[]))},{id:"ara",name:"Ara",import:(()=>B(()=>import("./ara.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>B(()=>import("./asciidoc.js"),[]))},{id:"asm",name:"Assembly",import:(()=>B(()=>import("./asm.js"),[]))},{id:"astro",name:"Astro",import:(()=>B(()=>import("./astro.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>B(()=>import("./awk.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>B(()=>import("./ballerina.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>B(()=>import("./bat.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>B(()=>import("./beancount.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>B(()=>import("./berry.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>B(()=>import("./bibtex.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>B(()=>import("./bicep.js"),[]))},{id:"blade",name:"Blade",import:(()=>B(()=>import("./blade.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>B(()=>import("./bsl.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>B(()=>import("./c.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>B(()=>import("./cadence.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>B(()=>import("./cairo.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>B(()=>import("./clarity.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>B(()=>import("./clojure.js"),[]))},{id:"cmake",name:"CMake",import:(()=>B(()=>import("./cmake.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>B(()=>import("./cobol.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>B(()=>import("./codeowners.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>B(()=>import("./codeql.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>B(()=>import("./coffee.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>B(()=>import("./common-lisp.js"),[]))},{id:"coq",name:"Coq",import:(()=>B(()=>import("./coq.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>B(()=>import("./cpp.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>B(()=>import("./crystal.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>B(()=>import("./csharp.js"),[]))},{id:"css",name:"CSS",import:(()=>B(()=>import("./css.js"),[]))},{id:"csv",name:"CSV",import:(()=>B(()=>import("./csv.js"),[]))},{id:"cue",name:"CUE",import:(()=>B(()=>import("./cue.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>B(()=>import("./cypher.js"),[]))},{id:"d",name:"D",import:(()=>B(()=>import("./d.js"),[]))},{id:"dart",name:"Dart",import:(()=>B(()=>import("./dart.js"),[]))},{id:"dax",name:"DAX",import:(()=>B(()=>import("./dax.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>B(()=>import("./desktop.js"),[]))},{id:"diff",name:"Diff",import:(()=>B(()=>import("./diff.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>B(()=>import("./docker.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>B(()=>import("./dotenv.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>B(()=>import("./dream-maker.js"),[]))},{id:"edge",name:"Edge",import:(()=>B(()=>import("./edge.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>B(()=>import("./elixir.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>B(()=>import("./elm.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>B(()=>import("./emacs-lisp.js"),[]))},{id:"erb",name:"ERB",import:(()=>B(()=>import("./erb.js"),__vite__mapDeps([32,1,2,3,33,34,7,8,16,35,11,36,13,23,24,25,26,28,37,38])))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>B(()=>import("./erlang.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>B(()=>import("./fennel.js"),[]))},{id:"fish",name:"Fish",import:(()=>B(()=>import("./fish.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>B(()=>import("./fluent.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>B(()=>import("./fortran-fixed-form.js"),__vite__mapDeps([41,42])))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>B(()=>import("./fortran-free-form.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>B(()=>import("./fsharp.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",import:(()=>B(()=>import("./gdresource.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",import:(()=>B(()=>import("./gdscript.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>B(()=>import("./gdshader.js"),[]))},{id:"genie",name:"Genie",import:(()=>B(()=>import("./genie.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>B(()=>import("./gherkin.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>B(()=>import("./git-commit.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>B(()=>import("./git-rebase.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>B(()=>import("./gleam.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>B(()=>import("./glimmer-js.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>B(()=>import("./glimmer-ts.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>B(()=>import("./glsl.js"),__vite__mapDeps([25,26])))},{id:"gnuplot",name:"Gnuplot",import:(()=>B(()=>import("./gnuplot.js"),[]))},{id:"go",name:"Go",import:(()=>B(()=>import("./go.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>B(()=>import("./graphql.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>B(()=>import("./groovy.js"),[]))},{id:"hack",name:"Hack",import:(()=>B(()=>import("./hack.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>B(()=>import("./haml.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>B(()=>import("./handlebars.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>B(()=>import("./haskell.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>B(()=>import("./haxe.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>B(()=>import("./hcl.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>B(()=>import("./hjson.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>B(()=>import("./hlsl.js"),[]))},{id:"html",name:"HTML",import:(()=>B(()=>import("./html.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>B(()=>import("./html-derivative.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>B(()=>import("./http.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hxml",name:"HXML",import:(()=>B(()=>import("./hxml.js"),__vite__mapDeps([55,56])))},{id:"hy",name:"Hy",import:(()=>B(()=>import("./hy.js"),[]))},{id:"imba",name:"Imba",import:(()=>B(()=>import("./imba.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>B(()=>import("./ini.js"),[]))},{id:"java",name:"Java",import:(()=>B(()=>import("./java.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js"],import:(()=>B(()=>import("./javascript.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>B(()=>import("./jinja.js"),__vite__mapDeps([57,1,2,3])))},{id:"jison",name:"Jison",import:(()=>B(()=>import("./jison.js"),__vite__mapDeps([58,2])))},{id:"json",name:"JSON",import:(()=>B(()=>import("./json.js"),[]))},{id:"json5",name:"JSON5",import:(()=>B(()=>import("./json5.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>B(()=>import("./jsonc.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>B(()=>import("./jsonl.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>B(()=>import("./jsonnet.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>B(()=>import("./jssm.js"),[]))},{id:"jsx",name:"JSX",import:(()=>B(()=>import("./jsx.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>B(()=>import("./julia.js"),__vite__mapDeps([59,23,24,25,26,16,20,2,60])))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>B(()=>import("./kotlin.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>B(()=>import("./kusto.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>B(()=>import("./latex.js"),__vite__mapDeps([61,62,60])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>B(()=>import("./lean.js"),[]))},{id:"less",name:"Less",import:(()=>B(()=>import("./less.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>B(()=>import("./liquid.js"),__vite__mapDeps([63,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>B(()=>import("./llvm.js"),[]))},{id:"log",name:"Log file",import:(()=>B(()=>import("./log.js"),[]))},{id:"logo",name:"Logo",import:(()=>B(()=>import("./logo.js"),[]))},{id:"lua",name:"Lua",import:(()=>B(()=>import("./lua.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>B(()=>import("./luau.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>B(()=>import("./make.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>B(()=>import("./markdown.js"),[]))},{id:"marko",name:"Marko",import:(()=>B(()=>import("./marko.js"),__vite__mapDeps([64,3,65,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>B(()=>import("./matlab.js"),[]))},{id:"mdc",name:"MDC",import:(()=>B(()=>import("./mdc.js"),__vite__mapDeps([66,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>B(()=>import("./mdx.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>B(()=>import("./mermaid.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>B(()=>import("./mipsasm.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>B(()=>import("./mojo.js"),[]))},{id:"move",name:"Move",import:(()=>B(()=>import("./move.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>B(()=>import("./narrat.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>B(()=>import("./nextflow.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>B(()=>import("./nginx.js"),__vite__mapDeps([67,37,26])))},{id:"nim",name:"Nim",import:(()=>B(()=>import("./nim.js"),__vite__mapDeps([68,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>B(()=>import("./nix.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>B(()=>import("./nushell.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>B(()=>import("./objective-c.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>B(()=>import("./objective-cpp.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>B(()=>import("./ocaml.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>B(()=>import("./pascal.js"),[]))},{id:"perl",name:"Perl",import:(()=>B(()=>import("./perl.js"),__vite__mapDeps([69,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>B(()=>import("./php.js"),__vite__mapDeps([70,1,2,3,7,8,16,9])))},{id:"plsql",name:"PL/SQL",import:(()=>B(()=>import("./plsql.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>B(()=>import("./po.js"),[]))},{id:"polar",name:"Polar",import:(()=>B(()=>import("./polar.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>B(()=>import("./postcss.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>B(()=>import("./powerquery.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>B(()=>import("./powershell.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>B(()=>import("./prisma.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>B(()=>import("./prolog.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>B(()=>import("./proto.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>B(()=>import("./pug.js"),__vite__mapDeps([71,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>B(()=>import("./puppet.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>B(()=>import("./purescript.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>B(()=>import("./python.js"),[]))},{id:"qml",name:"QML",import:(()=>B(()=>import("./qml.js"),__vite__mapDeps([72,2])))},{id:"qmldir",name:"QML Directory",import:(()=>B(()=>import("./qmldir.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>B(()=>import("./qss.js"),[]))},{id:"r",name:"R",import:(()=>B(()=>import("./r.js"),[]))},{id:"racket",name:"Racket",import:(()=>B(()=>import("./racket.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>B(()=>import("./raku.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>B(()=>import("./razor.js"),__vite__mapDeps([73,1,2,3,74])))},{id:"reg",name:"Windows Registry Script",import:(()=>B(()=>import("./reg.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>B(()=>import("./regexp.js"),[]))},{id:"rel",name:"Rel",import:(()=>B(()=>import("./rel.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>B(()=>import("./riscv.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>B(()=>import("./rst.js"),__vite__mapDeps([75,15,1,2,3,23,24,25,26,16,20,28,38,76,33,34,7,8,35,11,36,13,37])))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>B(()=>import("./ruby.js"),__vite__mapDeps([33,1,2,3,34,7,8,16,35,11,36,13,23,24,25,26,28,37,38])))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>B(()=>import("./rust.js"),[]))},{id:"sas",name:"SAS",import:(()=>B(()=>import("./sas.js"),__vite__mapDeps([77,16])))},{id:"sass",name:"Sass",import:(()=>B(()=>import("./sass.js"),[]))},{id:"scala",name:"Scala",import:(()=>B(()=>import("./scala.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>B(()=>import("./scheme.js"),[]))},{id:"scss",name:"SCSS",import:(()=>B(()=>import("./scss.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>B(()=>import("./sdbl.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>B(()=>import("./shaderlab.js"),__vite__mapDeps([78,79])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>B(()=>import("./shellscript.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>B(()=>import("./shellsession.js"),__vite__mapDeps([80,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>B(()=>import("./smalltalk.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>B(()=>import("./solidity.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>B(()=>import("./soy.js"),__vite__mapDeps([81,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>B(()=>import("./sparql.js"),__vite__mapDeps([82,83])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>B(()=>import("./splunk.js"),[]))},{id:"sql",name:"SQL",import:(()=>B(()=>import("./sql.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>B(()=>import("./ssh-config.js"),[]))},{id:"stata",name:"Stata",import:(()=>B(()=>import("./stata.js"),__vite__mapDeps([84,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>B(()=>import("./stylus.js"),[]))},{id:"svelte",name:"Svelte",import:(()=>B(()=>import("./svelte.js"),__vite__mapDeps([85,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>B(()=>import("./swift.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>B(()=>import("./system-verilog.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>B(()=>import("./systemd.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>B(()=>import("./talonscript.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>B(()=>import("./tasl.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>B(()=>import("./tcl.js"),[]))},{id:"templ",name:"Templ",import:(()=>B(()=>import("./templ.js"),__vite__mapDeps([86,87,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>B(()=>import("./terraform.js"),[]))},{id:"tex",name:"TeX",import:(()=>B(()=>import("./tex.js"),__vite__mapDeps([62,60])))},{id:"toml",name:"TOML",import:(()=>B(()=>import("./toml.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>B(()=>import("./ts-tags.js"),__vite__mapDeps([88,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>B(()=>import("./tsv.js"),[]))},{id:"tsx",name:"TSX",import:(()=>B(()=>import("./tsx.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>B(()=>import("./turtle.js"),[]))},{id:"twig",name:"Twig",import:(()=>B(()=>import("./twig.js"),__vite__mapDeps([89,3,2,5,70,1,7,8,16,9,20,33,34,35,11,36,13,23,24,25,26,28,37,38])))},{id:"typescript",name:"TypeScript",aliases:["ts"],import:(()=>B(()=>import("./typescript.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>B(()=>import("./typespec.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>B(()=>import("./typst.js"),[]))},{id:"v",name:"V",import:(()=>B(()=>import("./v.js"),[]))},{id:"vala",name:"Vala",import:(()=>B(()=>import("./vala.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>B(()=>import("./vb.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>B(()=>import("./verilog.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>B(()=>import("./vhdl.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>B(()=>import("./viml.js"),[]))},{id:"vue",name:"Vue",import:(()=>B(()=>import("./vue.js"),__vite__mapDeps([90,3,2,11,9,15,1])))},{id:"vue-html",name:"Vue HTML",import:(()=>B(()=>import("./vue-html.js"),__vite__mapDeps([91,90,3,2,11,9,15,1])))},{id:"vue-vine",name:"Vue Vine",import:(()=>B(()=>import("./vue-vine.js"),__vite__mapDeps([92,3,5,65,93,12,90,2,11,9,15,1])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>B(()=>import("./vyper.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>B(()=>import("./wasm.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>B(()=>import("./wenyan.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>B(()=>import("./wgsl.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>B(()=>import("./wikitext.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>B(()=>import("./wit.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>B(()=>import("./wolfram.js"),[]))},{id:"xml",name:"XML",import:(()=>B(()=>import("./xml.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>B(()=>import("./xsl.js"),__vite__mapDeps([94,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>B(()=>import("./yaml.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>B(()=>import("./zenscript.js"),[]))},{id:"zig",name:"Zig",import:(()=>B(()=>import("./zig.js"),[]))}],$Ee=Object.fromEntries(Aq.map(t=>[t.id,t.import])),jEe=Object.fromEntries(Aq.flatMap(t=>t.aliases?.map(e=>[e,t.import])||[])),BEe={...$Ee,...jEe},FEe=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>B(()=>import("./andromeeda.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>B(()=>import("./aurora-x.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>B(()=>import("./ayu-dark.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>B(()=>import("./catppuccin-frappe.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>B(()=>import("./catppuccin-latte.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>B(()=>import("./catppuccin-macchiato.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>B(()=>import("./catppuccin-mocha.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>B(()=>import("./dark-plus.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>B(()=>import("./dracula.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>B(()=>import("./dracula-soft.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>B(()=>import("./everforest-dark.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>B(()=>import("./everforest-light.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>B(()=>import("./github-dark.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>B(()=>import("./github-dark-default.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>B(()=>import("./github-dark-dimmed.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>B(()=>import("./github-dark-high-contrast.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>B(()=>import("./github-light.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>B(()=>import("./github-light-default.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>B(()=>import("./github-light-high-contrast.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>B(()=>import("./gruvbox-dark-hard.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>B(()=>import("./gruvbox-dark-medium.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>B(()=>import("./gruvbox-dark-soft.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>B(()=>import("./gruvbox-light-hard.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>B(()=>import("./gruvbox-light-medium.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>B(()=>import("./gruvbox-light-soft.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>B(()=>import("./houston.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>B(()=>import("./kanagawa-dragon.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>B(()=>import("./kanagawa-lotus.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>B(()=>import("./kanagawa-wave.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>B(()=>import("./laserwave.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>B(()=>import("./light-plus.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>B(()=>import("./material-theme.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>B(()=>import("./material-theme-darker.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>B(()=>import("./material-theme-lighter.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>B(()=>import("./material-theme-ocean.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>B(()=>import("./material-theme-palenight.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>B(()=>import("./min-dark.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>B(()=>import("./min-light.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>B(()=>import("./monokai.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>B(()=>import("./night-owl.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>B(()=>import("./nord.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>B(()=>import("./one-dark-pro.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>B(()=>import("./one-light.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>B(()=>import("./plastic.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>B(()=>import("./poimandres.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>B(()=>import("./red.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>B(()=>import("./rose-pine.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>B(()=>import("./rose-pine-dawn.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>B(()=>import("./rose-pine-moon.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>B(()=>import("./slack-dark.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>B(()=>import("./slack-ochin.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>B(()=>import("./snazzy-light.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>B(()=>import("./solarized-dark.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>B(()=>import("./solarized-light.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>B(()=>import("./synthwave-84.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>B(()=>import("./tokyo-night.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>B(()=>import("./vesper.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>B(()=>import("./vitesse-black.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>B(()=>import("./vitesse-dark.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>B(()=>import("./vitesse-light.js"),[]))}],zEe=Object.fromEntries(FEe.map(t=>[t.id,t.import]));class jR extends Error{constructor(e){super(e),this.name="ShikiError"}}function VEe(){return 2147483648}function UEe(){return typeof performance<"u"?performance.now():Date.now()}const HEe=(t,e)=>t+(e-t%e)%e;async function WEe(t){let e,n;const r={};function i(y){n=y,r.HEAPU8=new Uint8Array(y),r.HEAPU32=new Uint32Array(y)}function s(y,b,w){r.HEAPU8.copyWithin(y,b,b+w)}function o(y){try{return e.grow(y-n.byteLength+65535>>>16),i(e.buffer),1}catch{}}function a(y){const b=r.HEAPU8.length;y=y>>>0;const w=VEe();if(y>w)return!1;for(let S=1;S<=4;S*=2){let _=b*(1+.2/S);_=Math.min(_,y+100663296);const A=Math.min(w,HEe(Math.max(y,_),65536));if(o(A))return!0}return!1}const c=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function h(y,b,w=1024){const S=b+w;let _=b;for(;y[_]&&!(_>=S);)++_;if(_-b>16&&y.buffer&&c)return c.decode(y.subarray(b,_));let A="";for(;b<_;){let E=y[b++];if(!(E&128)){A+=String.fromCharCode(E);continue}const P=y[b++]&63;if((E&224)===192){A+=String.fromCharCode((E&31)<<6|P);continue}const O=y[b++]&63;if((E&240)===224?E=(E&15)<<12|P<<6|O:E=(E&7)<<18|P<<12|O<<6|y[b++]&63,E<65536)A+=String.fromCharCode(E);else{const M=E-65536;A+=String.fromCharCode(55296|M>>10,56320|M&1023)}}return A}function f(y,b){return y?h(r.HEAPU8,y,b):""}const d={emscripten_get_now:UEe,emscripten_memcpy_big:s,emscripten_resize_heap:a,fd_write:()=>0};async function m(){const b=await t({env:d,wasi_snapshot_preview1:d});e=b.memory,i(e.buffer),Object.assign(r,b),r.UTF8ToString=f}return await m(),r}var qEe=Object.defineProperty,GEe=(t,e,n)=>e in t?qEe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,An=(t,e,n)=>GEe(t,typeof e!="symbol"?e+"":e,n);let Nn=null;function KEe(t){throw new jR(t.UTF8ToString(t.getLastOnigError()))}class kx{constructor(e){An(this,"utf16Length"),An(this,"utf8Length"),An(this,"utf16Value"),An(this,"utf8Value"),An(this,"utf16OffsetToUtf8"),An(this,"utf8OffsetToUtf16");const n=e.length,r=kx._utf8ByteLength(e),i=r!==n,s=i?new Uint32Array(n+1):null;i&&(s[n]=r);const o=i?new Uint32Array(r+1):null;i&&(o[r]=n);const a=new Uint8Array(r);let c=0;for(let h=0;h<n;h++){const f=e.charCodeAt(h);let d=f,m=!1;if(f>=55296&&f<=56319&&h+1<n){const y=e.charCodeAt(h+1);y>=56320&&y<=57343&&(d=(f-55296<<10)+65536|y-56320,m=!0)}i&&(s[h]=c,m&&(s[h+1]=c),d<=127?o[c+0]=h:d<=2047?(o[c+0]=h,o[c+1]=h):d<=65535?(o[c+0]=h,o[c+1]=h,o[c+2]=h):(o[c+0]=h,o[c+1]=h,o[c+2]=h,o[c+3]=h)),d<=127?a[c++]=d:d<=2047?(a[c++]=192|(d&1984)>>>6,a[c++]=128|(d&63)>>>0):d<=65535?(a[c++]=224|(d&61440)>>>12,a[c++]=128|(d&4032)>>>6,a[c++]=128|(d&63)>>>0):(a[c++]=240|(d&1835008)>>>18,a[c++]=128|(d&258048)>>>12,a[c++]=128|(d&4032)>>>6,a[c++]=128|(d&63)>>>0),m&&h++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=e,this.utf8Value=a,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=o}static _utf8ByteLength(e){let n=0;for(let r=0,i=e.length;r<i;r++){const s=e.charCodeAt(r);let o=s,a=!1;if(s>=55296&&s<=56319&&r+1<i){const c=e.charCodeAt(r+1);c>=56320&&c<=57343&&(o=(s-55296<<10)+65536|c-56320,a=!0)}o<=127?n+=1:o<=2047?n+=2:o<=65535?n+=3:n+=4,a&&r++}return n}createString(e){const n=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,n),n}}const Tx=class Xs{constructor(e){if(An(this,"id",++Xs.LAST_ID),An(this,"_onigBinding"),An(this,"content"),An(this,"utf16Length"),An(this,"utf8Length"),An(this,"utf16OffsetToUtf8"),An(this,"utf8OffsetToUtf16"),An(this,"ptr"),!Nn)throw new jR("Must invoke loadWasm first.");this._onigBinding=Nn,this.content=e;const n=new kx(e);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!Xs._sharedPtrInUse?(Xs._sharedPtr||(Xs._sharedPtr=Nn.omalloc(1e4)),Xs._sharedPtrInUse=!0,Nn.HEAPU8.set(n.utf8Value,Xs._sharedPtr),this.ptr=Xs._sharedPtr):this.ptr=n.createString(Nn)}convertUtf8OffsetToUtf16(e){return this.utf8OffsetToUtf16?e<0?0:e>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[e]:e}convertUtf16OffsetToUtf8(e){return this.utf16OffsetToUtf8?e<0?0:e>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[e]:e}dispose(){this.ptr===Xs._sharedPtr?Xs._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};An(Tx,"LAST_ID",0);An(Tx,"_sharedPtr",0);An(Tx,"_sharedPtrInUse",!1);let Eq=Tx;class YEe{constructor(e){if(An(this,"_onigBinding"),An(this,"_ptr"),!Nn)throw new jR("Must invoke loadWasm first.");const n=[],r=[];for(let a=0,c=e.length;a<c;a++){const h=new kx(e[a]);n[a]=h.createString(Nn),r[a]=h.utf8Length}const i=Nn.omalloc(4*e.length);Nn.HEAPU32.set(n,i/4);const s=Nn.omalloc(4*e.length);Nn.HEAPU32.set(r,s/4);const o=Nn.createOnigScanner(i,s,e.length);for(let a=0,c=e.length;a<c;a++)Nn.ofree(n[a]);Nn.ofree(s),Nn.ofree(i),o===0&&KEe(Nn),this._onigBinding=Nn,this._ptr=o}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,n,r){let i=0;if(typeof r=="number"&&(i=r),typeof e=="string"){e=new Eq(e);const s=this._findNextMatchSync(e,n,!1,i);return e.dispose(),s}return this._findNextMatchSync(e,n,!1,i)}_findNextMatchSync(e,n,r,i){const s=this._onigBinding,o=s.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(n),i);if(o===0)return null;const a=s.HEAPU32;let c=o/4;const h=a[c++],f=a[c++],d=[];for(let m=0;m<f;m++){const y=e.convertUtf8OffsetToUtf16(a[c++]),b=e.convertUtf8OffsetToUtf16(a[c++]);d[m]={start:y,end:b,length:b-y}}return{index:h,captureIndices:d}}}function XEe(t){return typeof t.instantiator=="function"}function JEe(t){return typeof t.default=="function"}function QEe(t){return typeof t.data<"u"}function ZEe(t){return typeof Response<"u"&&t instanceof Response}function eke(t){return typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||ArrayBuffer.isView(t))||typeof Buffer<"u"&&Buffer.isBuffer?.(t)||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&t instanceof Uint32Array}let nb;function tke(t){if(nb)return nb;async function e(){Nn=await WEe(async n=>{let r=t;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),XEe(r)?r=await r.instantiator(n):JEe(r)?r=await r.default(n):(QEe(r)&&(r=r.data),ZEe(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await nke(r)(n):r=await rke(r)(n):eke(r)?r=await j2(r)(n):r instanceof WebAssembly.Module?r=await j2(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await j2(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return nb=e(),nb}function j2(t){return e=>WebAssembly.instantiate(t,e)}function nke(t){return e=>WebAssembly.instantiateStreaming(t,e)}function rke(t){return async e=>{const n=await t.arrayBuffer();return WebAssembly.instantiate(n,e)}}async function ike(t){return t&&await tke(t),{createScanner(e){return new YEe(e.map(n=>typeof n=="string"?n:n.source))},createString(e){return new Eq(e)}}}const ske=IEe({langs:BEe,themes:zEe,engine:()=>ike(B(()=>import("./wasm2.js"),[]))}),{getSingletonHighlighter:o5}=NEe(ske,{guessEmbeddedLanguages:XAe});async function oke(t,e){try{return await o5({langs:[t],themes:e})}catch(n){if(n instanceof Error&&n.message.includes("Language"))return await o5({langs:["plaintext"],themes:e});throw n}}var kq=(t,e,n,r={})=>eCe(t,e,n,oke,r),ake=nCe(kq),lke=ake;const Tq=({code:t,language:e,theme:n={dark:"kanagawa-wave",light:"kanagawa-lotus"},className:r,addDefaultStyles:i=!0,showLanguage:s=!1,...o})=>{const a="aui-shiki-base [&_pre]:overflow-x-auto [&_pre]:rounded-b-lg [&_pre]:!bg-muted/75 [&_pre]:p-4";return kq(t,e,n)?C.jsx(lke,{...o,language:e,theme:n,addDefaultStyles:i,showLanguage:s,defaultColor:"light-dark()",className:je(a,r),children:t.trim()}):C.jsx("div",{className:"px-[12px] pb-[12px] bg-[var(--chat-message-code-block-background-color)] rounded-b-[12px]",children:C.jsx("pre",{className:je("overflow-x-auto bg-[var(--chat-message-code-block-pre-background-color)] border border-[var(--chat-message-code-block-border-color)] rounded-[4px] p-[6px]",r),children:t.trim()})})};Tq.displayName="SyntaxHighlighter";const mw="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M17.5%2010.0078C18.3284%2010.0078%2019%2010.6794%2019%2011.5078V17.5039C18.9999%2018.3323%2018.3284%2019.0039%2017.5%2019.0039H11.5C10.6716%2019.0039%2010.0001%2018.3323%2010%2017.5039V11.5078C10%2010.6794%2010.6716%2010.0078%2011.5%2010.0078H17.5ZM11.5%2011.0078C11.2239%2011.0078%2011%2011.2317%2011%2011.5078V17.5039C11.0001%2017.78%2011.2239%2018.0039%2011.5%2018.0039H17.5C17.7761%2018.0039%2017.9999%2017.78%2018%2017.5039V11.5078C18%2011.2317%2017.7761%2011.0078%2017.5%2011.0078H11.5ZM12.5%205.00781C13.3284%205.00781%2014%205.67939%2014%206.50781V8.50391C13.9999%208.77999%2013.7761%209.00391%2013.5%209.00391C13.2239%209.00391%2013.0001%208.77999%2013%208.50391V6.50781C13%206.23167%2012.7761%206.00781%2012.5%206.00781H6.5C6.22386%206.00781%206%206.23167%206%206.50781V12.5039C6.00006%2012.78%206.22389%2013.0039%206.5%2013.0039H8.5C8.77614%2013.0039%209%2013.2278%209%2013.5039C8.99993%2013.78%208.7761%2014.0039%208.5%2014.0039H6.5C5.67161%2014.0039%205.00006%2013.3323%205%2012.5039V6.50781C5%205.67939%205.67157%205.00781%206.5%205.00781H12.5Z'%20fill='%23383838'/%3e%3c/svg%3e",ta=k.forwardRef(({children:t,tooltip:e,side:n="bottom",visible:r=!0,className:i,...s},o)=>C.jsxs(em,{children:[C.jsx(tm,{asChild:!0,children:C.jsx("div",{className:je("flex items-center gap-2",i),ref:o,...s,children:t})}),C.jsx(nm,{className:r?"":"hidden",side:n,children:e})]}));ta.displayName="TooltipIconButton";const cke=({copiedDuration:t=3e3}={})=>{const[e,n]=k.useState(!1);return{isCopied:e,copyToClipboard:i=>{i&&navigator.clipboard.writeText(i).then(()=>{n(!0),setTimeout(()=>n(!1),t)})}}},uke=({language:t,code:e})=>{const{isCopied:n,copyToClipboard:r}=cke(),{t:i}=vt(),s=()=>{!e||n||r(e)};return C.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4 rounded-t-lg bg-[var(--chat-message-code-block-background-color)] text-[var(--chat-message-code-block-header-color)] text-[14px] leading-[20px] px-[12px] pt-[12px] pb-[8px]",children:[C.jsx("span",{className:"lowercase",children:t}),C.jsxs(ta,{tooltip:i("CopyToClipboard"),onClick:s,visible:!n,children:[!n&&C.jsx(gt,{iconName:mw,size:16}),n&&C.jsx(gt,{iconName:Oh,size:16,isStroke:!0,disableHover:!0})]})]})},hke=I2e({SyntaxHighlighter:Tq,h1:({className:t,...e})=>C.jsx("h1",{className:je("mb-8 scroll-m-20 text-[28px] leading-[36px] font-bold last:mb-0 text-[var(--chat-message-color)]",t),...e}),h2:({className:t,...e})=>C.jsx("h2",{className:je("mb-4 mt-8 scroll-m-20 text-[24px] leading-[32px] font-bold first:mt-0 last:mb-0 text-[var(--chat-message-color)]",t),...e}),h3:({className:t,...e})=>C.jsx("h3",{className:je("mb-4 mt-6 scroll-m-20 text-[20px] leading-[28px] font-bold first:mt-0 last:mb-0 text-[var(--chat-message-color)]",t),...e}),h4:({className:t,...e})=>C.jsx("h4",{className:je("mb-4 mt-6 scroll-m-20 text-[18px] leading-[24px] font-bold first:mt-0 last:mb-0 text-[var(--chat-message-color)]",t),...e}),h5:({className:t,...e})=>C.jsx("h5",{className:je("my-4 text-[16px] leading-[22px] font-bold first:mt-0 last:mb-0 text-[var(--chat-message-color)]",t),...e}),h6:({className:t,...e})=>C.jsx("h6",{className:je("my-4 text-[14px] leading-[20px] font-bold first:mt-0 last:mb-0 text-[var(--chat-message-color)]",t),...e}),p:({className:t,...e})=>C.jsx("p",{className:je("mb-5 mt-5 text-[14px] font-normal leading-[20px] first:mt-0 last:mb-0 text-[var(--chat-message-color)]",t),...e}),a:({className:t,...e})=>C.jsx("a",{className:je("text-[var(--chat-link-color)] font-medium underline underline-offset-4",t),...e,target:"_blank"}),blockquote:({className:t,...e})=>C.jsx("blockquote",{className:je("border-l-2 pl-6 italic",t),...e}),ul:({className:t,...e})=>C.jsx("ul",{className:je("my-5 ml-6 list-disc [&>li]:mt-[4px] text-[var(--chat-message-color)]",t),...e}),ol:({className:t,...e})=>C.jsx("ol",{className:je("my-5 ml-6 list-decimal [&>li]:mt-[4px] text-[var(--chat-message-color)]",t),...e}),hr:({className:t,...e})=>C.jsx("hr",{className:je("my-5 border-b border-[var(--chat-message-divider-color)]",t),...e}),table:({className:t,...e})=>C.jsx("table",{className:je("my-5 w-full border-separate border-spacing-0 overflow-y-auto text-[var(--chat-message-color)]",t),...e}),th:({className:t,...e})=>C.jsx("th",{className:je("px-4 py-2 border-b border-[var(--chat-message-divider-color)] text-left text-[var(--chat-message-th-color)] text-[14px] leading-[20px] font-bold [&[align=center]]:text-center [&[align=right]]:text-right",t),...e}),td:({className:t,...e})=>C.jsx("td",{className:je("border-b border-[var(--chat-message-divider-color)] text-[var(--chat-message-td-color)] text-[14px] leading-[20px] px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right",t),...e}),tr:({className:t,...e})=>C.jsx("tr",{className:je("m-0 border-b border-[var(--chat-message-divider-color)]",t),...e}),sup:({className:t,...e})=>C.jsx("sup",{className:je("[&>a]:text-xs [&>a]:no-underline",t),...e}),pre:({className:t,...e})=>C.jsx("div",{className:"px-[12px] pb-[12px] bg-[var(--chat-message-code-block-background-color)] rounded-[12px]",children:C.jsx("pre",{className:je("overflow-x-auto bg-[var(--chat-message-code-block-pre-background-color)] border border-[var(--chat-message-code-block-border-color)] rounded-[4px] p-[6px]",t),...e})}),code:function({className:e,...n}){const r=qW();return C.jsx("code",{className:je(!r&&"font-bold italic",e),...n})},CodeHeader:uke}),fke=()=>C.jsx(X2e,{remarkPlugins:[tSe],className:"aui-md",components:hke}),Rq=k.memo(fke),dke=()=>{const e=ej().content.filter(n=>n.type==="file").map(n=>({type:JSON.parse(n.mimeType).type,content:n.data,path:JSON.parse(n.mimeType).path}));return C.jsx(qE,{asChild:!0,children:C.jsxs(uR.div,{className:"mx-auto grid w-full max-w-[var(--thread-max-width)] auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-1 px-[var(--thread-padding-x)] py-4 [&:where(>*)]:col-start-2",initial:{y:5,opacity:0},animate:{y:0,opacity:1},"data-role":"user",children:[e.length>0?C.jsx("div",{className:"col-span-full col-start-1 row-start-1 mb-[8px] overflow-x-auto",children:C.jsx("div",{className:"flex flex-row gap-[8px] justify-end w-max ml-auto",children:e.map(n=>C.jsx(NH,{file:n,withoutClose:!0},n.path))})}):null,C.jsx("div",{className:"bg-[var(--chat-user-message-background)] text-[var(--chat-user-message-color)] col-start-2 break-words rounded-[16px] rounded-br-[0px] px-[12px] py-[8px]",children:C.jsx(GE,{components:{Text:Rq}})})]})})},Mq="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8.5017%205.50391H6.50366C5.95138%205.50391%205.50366%205.95162%205.50366%206.50391V17.5039C5.50366%2018.0562%205.95138%2018.5039%206.50366%2018.5039H8.5017M8.5017%205.50391V7.50192C8.5017%208.0542%208.94942%208.50192%209.5017%208.50192H12.5045C13.0568%208.50192%2013.5045%208.0542%2013.5045%207.50192V5.50391M8.5017%205.50391H13.5045M13.5045%205.50391H15.0863C15.3512%205.50391%2015.6053%205.609%2015.7928%205.79613L18.2101%208.20891C18.398%208.3965%2018.5037%208.65114%2018.5037%208.91668V17.5039C18.5037%2018.0562%2018.0559%2018.5039%2017.5037%2018.5039H15.5M8.5017%2018.5039V13.5042C8.5017%2012.9519%208.94942%2012.5042%209.5017%2012.5042H14.5C15.0523%2012.5042%2015.5%2012.9519%2015.5%2013.5042V18.5039M8.5017%2018.5039H15.5'%20stroke='black'%20stroke-opacity='0.8'%20stroke-linejoin='round'/%3e%3c/svg%3e",pke="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='8'%20cy='8'%20r='7'%20fill='%234A87E7'/%3e%3cpath%20d='M11.5%205.5L7.5%2010.5L5%208'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",mke="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%208L3%2012L7%2016M17%208L21%2012L17%2016M14%204L10%2020'%20stroke='%23444444'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",CE="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%204a8%208%200%200%201%207.545%205.334A8%208%200%200%201%2020%2012a8%208%200%200%201-.455%202.667%208.003%208.003%200%200%201-15.09%200A8%208%200%200%201%204%2012c0-.934.16-1.832.455-2.666A8%208%200%200%201%2012%204M9.3%2015c.167.79.399%201.497.676%202.092C10.592%2018.409%2011.342%2019%2012%2019s1.409-.59%202.024-1.908A9.8%209.8%200%200%200%2014.7%2015zm-3.625%200a7.02%207.02%200%200%200%204.038%203.616%206.6%206.6%200%200%201-.643-1.1c-.338-.723-.607-1.577-.791-2.516zm10.046%200c-.184.94-.453%201.793-.79%202.515a6.6%206.6%200%200%201-.645%201.101A7.02%207.02%200%200%200%2018.326%2015zm-10.43-5a7%207%200%200%200-.001%204h2.829c-.08-.64-.122-1.311-.122-2s.042-1.36.122-2zm3.837%200a15%2015%200%200%200-.131%202c0%20.696.046%201.367.13%202h5.745c.084-.633.13-1.304.13-2%200-.697-.046-1.368-.13-2zm6.753%200a16.4%2016.4%200%200%201%200%204h2.829a7%207%200%200%200%200-4zM9.714%205.383A7.02%207.02%200%200%200%205.674%209H8.28c.184-.94.454-1.792.791-2.515.186-.399.402-.772.644-1.102M12%205c-.658%200-1.408.59-2.024%201.908A9.8%209.8%200%200%200%209.301%209h5.398a9.8%209.8%200%200%200-.675-2.092C13.41%205.59%2012.658%205%2012%205m2.285.382c.242.33.459.704.645%201.103.338.723.607%201.575.791%202.515h2.605a7.02%207.02%200%200%200-4.041-3.618'%20fill='%23444444'/%3e%3c/svg%3e",a5="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M10%205C10.2761%205%2010.5%205.22386%2010.5%205.5C10.5%205.77614%2010.2761%206%2010%206H6.5C6.22386%206%206%206.22386%206%206.5V17.5C6%2017.7761%206.22386%2018%206.5%2018H17.5C17.7761%2018%2018%2017.7761%2018%2017.5V14C18%2013.7239%2018.2239%2013.5%2018.5%2013.5C18.7761%2013.5%2019%2013.7239%2019%2014V17.5C19%2018.3284%2018.3284%2019%2017.5%2019H6.5C5.67157%2019%205%2018.3284%205%2017.5V6.5C5%205.67157%205.67157%205%206.5%205H10ZM18%205C18.5523%205%2019%205.44772%2019%206V10.5C19%2010.7761%2018.7761%2011%2018.5%2011C18.2239%2011%2018%2010.7761%2018%2010.5V6.70703L11.8535%2012.8535C11.6583%2013.0488%2011.3417%2013.0488%2011.1465%2012.8535C10.9512%2012.6583%2010.9512%2012.3417%2011.1465%2012.1465L17.293%206H13.5C13.2239%206%2013%205.77614%2013%205.5C13%205.22386%2013.2239%205%2013.5%205H18Z'%20fill='%23383838'/%3e%3c/svg%3e",Oq=({toolName:t,argsText:e,result:n})=>{const{t:r}=vt(),[i,s]=k.useState(!0),[o,a]=k.useState(!1),[c,h]=k.useState(!1);k.useEffect(()=>{o&&setTimeout(()=>{a(!1)},2e3)},[o]),k.useEffect(()=>{c&&setTimeout(()=>{h(!1)},2e3)},[c]);const f=Qt.getServerType(t),d=t.replace(f+"_",""),m=n===void 0,y=d==="web_search",b=d==="web_crawling";let w="",S=e;try{const E=JSON.parse(S);E.args&&(S=JSON.stringify(E.args)),w=S?y?JSON.parse(S).query:b?JSON.parse(S).urls[0]:"":""}catch{}const _=k.useCallback(E=>{E.querySelectorAll("path").forEach(M=>{M.setAttribute("fill","var(--chat-message-tool-call-name-color)")}),E.querySelectorAll("circle").forEach(M=>{M.setAttribute("fill","var(--chat-message-tool-call-name-color)")})},[]),A=k.useCallback(E=>{E.querySelectorAll("path").forEach(M=>{M.setAttribute("stroke","var(--chat-message-tool-call-name-color)")}),E.querySelectorAll("circle").forEach(M=>{M.setAttribute("stroke","var(--chat-message-tool-call-name-color)")})},[]);return C.jsxs("div",{className:"my-[16px] flex w-full flex-col gap-3",children:[C.jsxs("div",{className:"flex items-center gap-[10px] cursor-pointer",onClick:()=>{if(b){window.open(w,"_blank");return}y&&n===void 0||s(!i)},children:[m?C.jsx(Gm,{size:16}):C.jsx(dn,{src:pke}),m&&!y&&!b?C.jsx("p",{className:"text-[var(--chat-message-tool-call-header-color)] text-[14px] font-normal leading-[16px]",children:r("ToolExecuted")}):null,C.jsxs("span",{className:"flex items-center gap-[8px] rounded-[4px] ps-[4px] pe-[8px] text-[14px] leading-[20px] font-normal text-[var(--chat-message-tool-call-name-color)] bg-[var(--chat-message-tool-call-name-background-color)] min-w-0 w-fit",children:[y?C.jsx(dn,{src:CE,beforeInjection:_}):b?null:C.jsx(dn,{src:mke,beforeInjection:A}),C.jsx("span",{className:"truncate",children:y?w:b?`${d} | ${w}`:d})]}),b?C.jsx(dn,{src:a5,beforeInjection:A}):y&&n===void 0?null:C.jsx(dn,{src:i?qk:nz,beforeInjection:A})]}),i?null:C.jsxs("div",{className:"flex flex-col gap-[24px] mt-[8px] p-[12px] bg-[var(--chat-message-tool-call-body-background-color)] rounded-[12px]",children:[y?null:C.jsxs("div",{className:"",children:[C.jsxs("p",{className:"flex flex-row items-center justify-between text-[var(--chat-message-tool-call-header-color)] text-[14px] font-bold leading-[20px]",children:[r("ToolCallArguments"),C.jsx(dn,{src:o?Oh:mw,onClick:()=>a(!0),beforeInjection:o?A:_})]}),C.jsx("pre",{className:"max-h-[200px] overflow-y-auto whitespace-pre-wrap text-[var(--chat-message-tool-call-pre-color)] border border-[var(--chat-message-tool-call-pre-border-color)] bg-[var(--chat-message-tool-call-pre-background-color)] px-[8px] py-[2px] rounded-[4px]",children:S||"{}"})]}),n!==void 0&&C.jsx("div",{className:"",children:y?C.jsx("div",{children:(()=>{try{const E=typeof n=="string"?JSON.parse(n):n;if(E?.error)return C.jsx("pre",{className:"max-h-[200px] overflow-y-auto whitespace-pre-wrap text-[var(--chat-message-tool-call-pre-color)] border border-[var(--chat-message-tool-call-pre-border-color)] bg-[var(--chat-message-tool-call-pre-background-color)] px-[8px] py-[2px] rounded-[4px]",children:typeof n=="string"?n:JSON.stringify(n,null,2)});const P=E?.data||[];return P.length>0?C.jsx("div",{className:"flex flex-col gap-[10px]",children:P.map((O,M)=>C.jsxs("div",{className:"group h-[36px] px-[8px] rounded-[4px] flex flex-row items-center justify-between cursor-pointer hover:bg-[var(--drop-down-menu-item-hover-color)] transition-colors",onClick:()=>window.open(O.url,"_blank"),children:[C.jsxs("div",{className:"flex flex-row items-center gap-[8px] min-w-0 flex-1",children:[C.jsx(gt,{iconName:CE,size:24,disableHover:!0}),C.jsx("h4",{className:"text-[14px] font-normal text-[var(--chat-message-tool-call-pre-color)] truncate",children:O.title})]}),C.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity",children:C.jsx(gt,{iconName:a5,size:24,disableHover:!0})})]},M))}):C.jsx("pre",{className:"max-h-[200px] overflow-y-auto whitespace-pre-wrap text-[var(--chat-message-tool-call-pre-color)] border border-[var(--chat-message-tool-call-pre-border-color)] bg-[var(--chat-message-tool-call-pre-background-color)] px-[8px] py-[2px] rounded-[4px]",children:typeof n=="string"?n:JSON.stringify(n,null,2)})}catch{return C.jsx("pre",{className:"max-h-[200px] overflow-y-auto whitespace-pre-wrap text-[var(--chat-message-tool-call-pre-color)] border border-[var(--chat-message-tool-call-pre-border-color)] bg-[var(--chat-message-tool-call-pre-background-color)] px-[8px] py-[2px] rounded-[4px]",children:typeof n=="string"?n:JSON.stringify(n,null,2)})}})()}):C.jsxs(C.Fragment,{children:[C.jsxs("p",{className:"flex flex-row items-center justify-between text-[var(--chat-message-tool-call-header-color)] text-[14px] font-bold leading-[20px]",children:[r("ToolCallResult"),C.jsx(dn,{src:c?Oh:mw,onClick:()=>h(!0),beforeInjection:c?A:_})]}),C.jsx("pre",{className:"max-h-[200px] overflow-y-auto whitespace-pre-wrap text-[var(--chat-message-tool-call-pre-color)] border border-[var(--chat-message-tool-call-pre-border-color)] bg-[var(--chat-message-tool-call-pre-background-color)] px-[8px] py-[2px] rounded-[4px]",children:typeof n=="string"?n:JSON.stringify(n,null,2)})]})})]})]})},gke=()=>C.jsx(tB,{children:C.jsx(aB,{className:"border border-[var(--chat-message-error-border-color)] rounded-[4px] p-[6px]",children:C.jsx(lB,{className:"text-[var(--chat-message-error-color)] text-[14px] leading-[20px] font-normal"})})}),yke=()=>{const{t}=vt(),{isStreamRunning:e,messages:n}=Yh(),r=ej();if(r.status?.type==="incomplete"&&r.status?.error)return;const i=()=>{const s=n[Number(r.parentId)],o=C9([s,r]),a=Vie(o);window.AscDesktopEditor.SaveFilenameDialog(`${a}.docx`,c=>{c&&window.AscDesktopEditor.saveAndOpen(o,92,c,65,h=>{h||console.log("Conversion error")})})};return C.jsxs(lj,{hidden:e,className:"col-start-3 row-start-2 ml-3 mt-3 flex gap-[8px]",children:[C.jsx(cj,{asChild:!0,children:C.jsxs(ta,{tooltip:t("CopyToClipboard"),children:[C.jsx(X2,{copied:!0,children:C.jsx(gt,{iconName:Oh,size:24,isStroke:!0,disabled:!0})}),C.jsx(X2,{copied:!1,children:C.jsx(gt,{iconName:mw,size:24})})]})}),C.jsx("div",{children:C.jsx(ta,{tooltip:t("Save"),children:C.jsx(gt,{iconName:Mq,size:24,onClick:i,isStroke:!0})})})]})},bke=()=>C.jsx(qE,{asChild:!0,children:C.jsxs(uR.div,{className:"relative mx-auto grid w-full max-w-[var(--thread-max-width)] grid-cols-[auto_auto_1fr] grid-rows-[auto_1fr] px-[var(--thread-padding-x)] py-4",initial:{y:5,opacity:0},animate:{y:0,opacity:1},"data-role":"assistant",children:[C.jsxs("div",{className:"leading-[20px] text-[14px] col-span-2 col-start-2 row-start-1 ml-4 break-words leading-7 text-[var(--chat-message-color)]",children:[C.jsx(GE,{components:{Text:Rq,tools:{Fallback:Oq}}}),C.jsx(gke,{})]}),C.jsx(yke,{})]})}),cg=na(t=>({currentModel:null,isInitLoading:!1,initCurrentModel:()=>{try{const e=localStorage.getItem(y_);if(!e)return;const n=JSON.parse(e);t({currentModel:n})}catch(e){console.error("Failed to initialize current model:",e)}},selectModel:e=>{t({currentModel:e}),Lt.setCurrentProviderModel(e.id),localStorage.setItem(y_,JSON.stringify(e))},deleteSelectedModel:()=>{t({currentModel:null}),localStorage.removeItem(y_),Lt.setCurrentProviderModel("")}})),vke="data:image/svg+xml,%3csvg%20width='12'%20height='16'%20viewBox='0%200%2012%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%200C2.77614%201.40922e-07%203%200.223858%203%200.5V8C3%208.01656%202.99669%208.03268%202.99512%208.04883C4.13869%208.27856%205%209.28878%205%2010.5C5%2011.7112%204.13859%2012.7204%202.99512%2012.9502C2.99675%2012.9667%203%2012.9831%203%2013V15.5C3%2015.7761%202.77614%2016%202.5%2016C2.22386%2016%202%2015.7761%202%2015.5V13C2%2012.9831%202.00228%2012.9666%202.00391%2012.9502C0.860897%2012.72%20-2.86384e-08%2011.7108%200%2010.5C1.05859e-07%209.28911%200.860803%208.27892%202.00391%208.04883C2.00234%208.03271%202%208.01653%202%208V0.5C2%200.223858%202.22386%201.76916e-07%202.5%200ZM9.5%200C9.77614%202.41411e-08%2010%200.223858%2010%200.5V3C10%203.01656%209.99669%203.03268%209.99512%203.04883C11.1387%203.27856%2012%204.28878%2012%205.5C12%206.71115%2011.1386%207.72039%209.99512%207.9502C9.99675%207.96665%2010%207.98311%2010%208V15.5C10%2015.7761%209.77614%2016%209.5%2016C9.22386%2016%209%2015.7761%209%2015.5V8C9%207.98314%209.00228%207.96662%209.00391%207.9502C7.8609%207.72003%207%206.71082%207%205.5C7%204.28911%207.8608%203.27892%209.00391%203.04883C9.00234%203.03271%209%203.01653%209%203V0.5C9%200.223858%209.22386%20-5.17733e-10%209.5%200ZM2.5%209C1.67157%209%201%209.67157%201%2010.5C1%2011.3284%201.67157%2012%202.5%2012C3.32843%2012%204%2011.3284%204%2010.5C4%209.67157%203.32843%209%202.5%209ZM9.5%204C8.67157%204%208%204.67157%208%205.5C8%206.32843%208.67157%207%209.5%207C10.3284%207%2011%206.32843%2011%205.5C11%204.67157%2010.3284%204%209.5%204Z'%20fill='%23383838'/%3e%3c/svg%3e",wke=()=>{const{servers:t,changeToolStatus:e,webSearchEnabled:n,getWebSearchEnabled:r}=Rs(),[i,s]=k.useState(!1),{t:o}=vt(),a=k.useMemo(()=>C.jsx(ta,{visible:!i,tooltip:o("MCPServers"),children:C.jsx(gt,{iconName:vke,size:24,isActive:i})}),[i,o]),c=k.useMemo(()=>[{text:o("WebSearch"),onClick:()=>{},icon:C.jsx(gt,{iconName:CE,size:24,disableHover:!0}),withToggle:!0,toggleChecked:r()?n:!1,toggleDisabled:!r(),tooltipText:r()?"":o("EnableWebSearch"),onToggleChange:()=>{e("web-search",t["web-search"][0].name,!n),window.dispatchEvent(new CustomEvent("tools-changed"))}},{text:"",onClick:()=>{},isSeparator:!0},...Object.entries(t).map(([d,m])=>{if(d==="web-search")return{text:d,onClick:()=>{},subMenu:[]};const y=m.some(b=>b.enabled);return{text:d,onClick:()=>{},subMenu:[{text:"All tools",onClick:()=>{},withToggle:!0,toggleChecked:y,onToggleChange:()=>{y?m.forEach(b=>{e(d,b.name,!1)}):m.forEach(b=>{e(d,b.name,!0)})}},{text:"",onClick:()=>{},isSeparator:!0},...m.map(b=>({text:b.name,onClick:()=>{},withToggle:!0,toggleChecked:b.enabled,onToggleChange:w=>{e(d,b.name,w)}}))]}}).filter(d=>d.subMenu.length>2)],[t,e,o,n,r]),h=k.useMemo(()=>[...c],[c]);if(!t||!c.length)return null;const f=d=>{s(d)};return C.jsx(Nc,{trigger:a,items:h,onOpenChange:f})},xke="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.01953%2013.2344L12.1596%206.09434C12.5297%205.71639%2012.9711%205.41559%2013.4582%205.20932C13.9453%205.00305%2014.4684%204.89541%2014.9974%204.89263C15.5264%204.88986%2016.0506%204.99199%2016.5399%205.19314C17.0291%205.39428%2017.4736%205.69044%2017.8476%206.06448C18.2217%206.43852%2018.5178%206.88301%2018.719%207.37224C18.9201%207.86148%2019.0223%208.38574%2019.0195%208.9147C19.0167%209.44366%2018.9091%209.96683%2018.7028%2010.4539C18.4965%2010.941%2018.1957%2011.3824%2017.8178%2011.7525L11.1485%2018.4202C10.7353%2018.82%2010.1816%2019.0414%209.60671%2019.0367C9.03182%2019.0319%208.48182%2018.8014%208.07531%2018.3949C7.66879%2017.9884%207.43831%2017.4384%207.43358%2016.8635C7.42884%2016.2886%207.65022%2015.7349%208.04999%2015.3218L14.4487%208.92226'%20stroke='%23444444'%20stroke-width='1.14645'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Ske=()=>{const[t,e]=de.useState(!1),{addAttachmentFile:n}=bx(),r=f=>{e(f)},i=(f,d)=>{const m=Rb(d);window.AscDesktopEditor.convertFileExternal(f,m?260:69,(y,b)=>{if(b){console.log("Error:",b);return}const w=new Uint8Array(y.content),_=new TextDecoder("utf-8").decode(w);n({path:f,content:_,type:d})})},s=()=>{window.AscDesktopEditor.OpenFilenameDialog("",!0,f=>{Array.isArray(f)&&f.forEach((d,m)=>{if(m>5)return;const y=window.AscDesktopEditor.getOfficeFileType(d),b=Rb(y);window.AscDesktopEditor.convertFileExternal(d,b?260:69,(w,S)=>{if(S){console.log("Error:",S);return}const _=new Uint8Array(w.content),E=new TextDecoder("utf-8").decode(_);n({path:d,content:E||"",type:y})})})})},o=JSON.parse(window.AscDesktopEditor?.callToolFunction("recent_files_reader")??"{}")?.files?.filter(f=>!f.url)?.map(f=>{let d=rE;return T9(f.type)?d=PH:Rb(f.type)?d=DH:E9(f.type)?d=rE:k9(f.type)?d=IH:d=LH,{text:f.path.includes("\\")?f.path.split("\\").pop()??"":f.path.split("/").pop()??"",key:f.path,id:f.path,icon:d?C.jsx(dn,{src:d}):null,onClick:()=>i(f.path,f.type)}}).filter(Boolean),{t:a}=vt(),c=C.jsx(ta,{tooltip:a("Attachments"),visible:!t,children:C.jsx(gt,{iconName:xke,size:24,className:"cursor-pointer rounded-[4px] outline-none",isStroke:!0,isActive:t})}),h=[{text:a("AddLocalFile"),onClick:()=>s()},{text:"",onClick:()=>{},isSeparator:!0},{text:a("RecentFiles"),onClick:()=>{},subMenu:o}];return C.jsx(Nc,{trigger:c,items:h,onOpenChange:r})},_ke=()=>{const{currentModel:t,selectModel:e}=cg(),{providers:n,providersModels:r,currentProvider:i,setCurrentProvider:s}=rs(),{tools:o}=Rs(),{messages:a}=Yh(),{t:c}=vt(),h=de.useCallback((m,y)=>{if(t?.id===y&&Lt.currentProviderInfo?.name===m.name)return;const b=r.get(m.name)?.find(w=>w.id===y);b&&(Lt.currentProviderInfo?.name!==m.name&&(s(m),Lt.setCurrentProviderModel(y),Lt.setCurrentProviderTools(o),Lt.setCurrentProviderPrevMessages(a)),e(b))},[r,a,o,t,e,s]),f=n.map(m=>({text:m.name,id:m.name,onClick:()=>{},subMenu:r.get(m.name)?.map(y=>({text:y.name,id:y.id,onClick:()=>h(m,y.id),isActive:!1,checked:y.id===t?.id&&m.name===Lt.currentProviderInfo?.name}))||[]})).filter(m=>m.subMenu.length>0),d=n.some(m=>m.name===i?.name);return de.useEffect(()=>{if((!t||!i)&&n.length>0){const m=n[0],y=r.get(m.name)?.[0];if(!y)return;h(m,y.id)}},[t,i,n,r,h]),C.jsx(ex,{placeholder:c("SelectModel"),value:d&&t?.name||"",items:f,withoutBg:!0})},Cke="data:image/svg+xml,%3csvg%20width='12'%20height='14'%20viewBox='0%200%2012%2014'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.00092%2012.6467C5.00092%2013.1989%205.44863%2013.6467%206.00092%2013.6467C6.5532%2013.6467%207.00092%2013.1989%207.00092%2012.6467H6.00092H5.00092ZM9.52911%206.29494C9.91963%206.68546%2010.5528%206.68546%2010.9433%206.29494C11.3338%205.90442%2011.3338%205.27125%2010.9433%204.88073L10.2362%205.58783L9.52911%206.29494ZM1.05852%204.88073C0.667994%205.27125%200.667994%205.90442%201.05852%206.29494C1.44904%206.68546%202.08221%206.68546%202.47273%206.29494L1.76562%205.58783L1.05852%204.88073ZM6.25049%201.60211L6.95759%200.894999L6.25049%201.60211ZM5.75135%201.60211L5.04425%200.894999L5.75135%201.60211ZM6.25049%201.60211L5.54338%202.30921L9.52911%206.29494L10.2362%205.58783L10.9433%204.88073L6.95759%200.894999L6.25049%201.60211ZM5.75135%201.60211L5.04425%200.894999L1.05852%204.88073L1.76562%205.58783L2.47273%206.29494L6.45846%202.30921L5.75135%201.60211ZM6.00092%202.05842H5.00092V12.6467H6.00092H7.00092V2.05842H6.00092ZM6.25049%201.60211L6.95759%200.894999C6.42924%200.366643%205.5726%200.366643%205.04425%200.894999L5.75135%201.60211L6.45846%202.30921C6.20577%202.56191%205.79607%202.56191%205.54338%202.30921L6.25049%201.60211Z'%20fill='white'/%3e%3c/svg%3e",Ake="data:image/svg+xml,%3csvg%20width='12'%20height='12'%20viewBox='0%200%2012%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='12'%20height='12'%20rx='4'%20fill='white'/%3e%3c/svg%3e",l5="rounded-[4px] cursor-pointer disabled:cursor-not-allowed flex items-center justify-center bg-[var(--chat-composer-action-send-background-color)] hover:enabled:bg-[var(--chat-composer-action-send-background-hover-color)] active:enabled:bg-[var(--chat-composer-action-send-background-pressed-color)] disabled:opacity-[0.5]",Eke=()=>{const{isStreamRunning:t}=Yh(),{currentModel:e}=cg(),{currentProvider:n}=rs();return t?C.jsx(lee,{asChild:!0,children:C.jsx(gt,{iconName:Ake,size:24,className:l5})}):C.jsx(tv,{running:!1,children:C.jsx(HZ,{asChild:!0,disabled:!e||!n,children:C.jsx(gt,{iconName:Cke,size:24,color:"var(--chat-composer-action-send-color)",className:l5})})})},kke=()=>C.jsx("div",{className:"relative flex flex-col",children:C.jsxs("div",{className:"relative flex items-center justify-between h-[24px]",children:[C.jsxs("div",{className:"flex items-center gap-[12px] flex-row",children:[C.jsx(Ske,{}),C.jsx(wke,{})]}),C.jsxs("div",{className:"flex items-center gap-[12px] flex-row",children:[C.jsx(_ke,{}),C.jsx(Eke,{})]})]})}),c5=()=>{const{attachmentFiles:t}=bx(),{currentProvider:e}=rs(),{currentModel:n}=cg(),{t:r}=vt();return C.jsxs("div",{className:"relative mx-auto flex w-full max-w-[var(--thread-max-width)] flex-col gap-[8px] px-[var(--thread-padding-x)] pb-[16px]",children:[C.jsxs(rB,{className:"composer-root relative flex w-full flex-col gap-[16px] rounded-[16px] border px-[24px] py-[16px] box-border",children:[t.length?C.jsx("div",{className:"flex flex-row gap-[8px] overflow-x-auto",children:t.map(i=>C.jsx(NH,{file:i},i.path))}):null,C.jsx(oB,{placeholder:r("AskAI"),className:"composer-input max-h-[calc(50vh)] min-h-[16px] w-full resize-none outline-none",rows:1,autoFocus:!0,"aria-label":"Message input",disabled:!e||!n}),C.jsx(kke,{})]}),C.jsx("p",{className:"text-center font-normal text-[12px] leading-[16px] text-[var(--text-tertiary)]",children:r("CheckInfo")})]})},Tke=()=>{const{isStreamRunning:t,isRequestRunning:e}=Yh(),{t:n}=vt();return C.jsxs(cB,{className:"flex h-full flex-col",style:{"--thread-max-width":"687px","--thread-padding-x":"1rem"},children:[C.jsx(tv,{empty:!0,children:C.jsx(J2,{className:"relative flex min-w-0 flex-1 flex-col overflow-y-auto justify-center items-center",children:C.jsxs("div",{className:"flex flex-col gap-[24px] w-full",children:[C.jsx(hve,{}),C.jsx(c5,{})]})})}),C.jsxs(tv,{empty:!1,children:[C.jsxs(J2,{className:"relative flex min-w-0 flex-1 flex-col gap-6 overflow-y-auto",children:[C.jsx(mee,{components:{UserMessage:dke,AssistantMessage:bke}}),!e&&t?C.jsx("div",{className:"flex items-center justify-center",children:C.jsxs("div",{className:"flex items-center gap-[8px] w-[var(--thread-max-width)] max-w-[var(--thread-max-width)] ps-[var(--thread-padding-x)]",children:[C.jsx(Gm,{}),C.jsx("p",{className:"text-[14px] leading-[20px] font-normal text-[var(--chat-message-analyze-color)]",children:n("Analyzing")})]})}):null,C.jsx(uR.div,{className:"min-h-6 min-w-6 shrink-0"})]}),C.jsx(c5,{})]})]})},Rke="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M16.5%2015.5C16.5%2014.3954%2015.6046%2013.5%2014.5%2013.5C13.3954%2013.5%2012.5%2014.3954%2012.5%2015.5M16.5%2015.5C16.5%2016.6046%2015.6046%2017.5%2014.5%2017.5C13.3954%2017.5%2012.5%2016.6046%2012.5%2015.5M16.5%2015.5L19.5%2015.5M12.5%2015.5L4.5%2015.5M11.5%208.5C11.5%207.39543%2010.6046%206.5%209.5%206.5C8.39543%206.5%207.5%207.39543%207.5%208.5M11.5%208.5C11.5%209.60457%2010.6046%2010.5%209.5%2010.5C8.39543%2010.5%207.5%209.60457%207.5%208.5M11.5%208.5L19.5%208.5M7.5%208.5H4.5'%20stroke='%23383838'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Mke="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M11.5%205.5V11.5M11.5%2011.5V17.5M11.5%2011.5H17.5M11.5%2011.5H5.5'%20stroke='%23383838'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Oke=async(t,e)=>{const n=ns.getDB(),r={threadId:t,title:e,lastEditDate:Date.now()};return new Promise((i,s)=>{const c=n.transaction(["threads"],"readwrite").objectStore("threads").put(r);c.onerror=()=>s(c.error),c.onsuccess=()=>i()})},Pke=async()=>{const t=ns.getDB();return new Promise((e,n)=>{const s=t.transaction(["threads"],"readonly").objectStore("threads").getAll();s.onerror=()=>n(s.error),s.onsuccess=()=>{const o=s.result.sort((a,c)=>c.lastEditDate-a.lastEditDate);e(o)}})},Dke=async(t,e)=>{const n=ns.getDB();return new Promise((r,i)=>{const o=n.transaction(["threads"],"readwrite").objectStore("threads"),a=o.get(t);a.onerror=()=>i(a.error),a.onsuccess=()=>{const c=a.result;if(!c){i(new Error("Thread not found"));return}const h={...c,...e&&{title:e},lastEditDate:Date.now()},f=o.put(h);f.onerror=()=>i(f.error),f.onsuccess=()=>r()}})},Ike=async t=>{const e=ns.getDB();return new Promise((n,r)=>{const s=e.transaction(["threads"],"readwrite").objectStore("threads"),o=s.get(t);o.onerror=()=>r(o.error),o.onsuccess=()=>{const a=o.result;if(!a){r(new Error("Thread not found"));return}const c={...a,lastEditDate:Date.now()},h=s.put(c);h.onerror=()=>r(h.error),h.onsuccess=()=>n()}})},Lke=async t=>{await Fre(t);const e=ns.getDB();return new Promise((n,r)=>{const o=e.transaction(["threads"],"readwrite").objectStore("threads").delete(t);o.onerror=()=>r(o.error),o.onsuccess=()=>n()})},ug=na((t,e)=>({threadId:crypto.randomUUID(),threads:[],initThreads:async()=>{const n=await Pke();t({threads:n})},insertThread:n=>{const r=e();t({threads:[{threadId:r.threadId,title:n},...r.threads]}),Oke(r.threadId,n)},insertNewMessageToThread:()=>{const n=e();Ike(n.threadId),t({threads:n.threads.map(r=>r.threadId===n.threadId?{...r,lastEditDate:Date.now()}:r)})},onSwitchToNewThread:()=>{t({threadId:crypto.randomUUID()})},onSwitchToThread:n=>{t({threadId:n})},onDownloadThread:async n=>{const i=e().threads.find(c=>c.threadId===n),s=await c9(n),o=A9(i?.title||"Chat Export"),a=C9(s);window.AscDesktopEditor.SaveFilenameDialog(`${o}.docx`,c=>{c&&window.AscDesktopEditor.saveAndOpen(a,92,c,65,h=>{h||console.log("Conversion error")})})},onRenameThread:(n,r)=>{const i=e();t({threads:i.threads.map(s=>s.threadId===n?{...s,title:r}:s)}),Dke(n,r)},onDeleteThread:n=>{const r=e();r.threadId===n&&r.onSwitchToNewThread(),t({threads:r.threads.filter(i=>i.threadId!==n)}),Lke(n)}})),Nke=()=>{const{t}=vt(),{currentPage:e,setCurrentPage:n}=Vm(),{onSwitchToNewThread:r}=ug();return C.jsxs("nav",{className:"w-full flex justify-between items-center h-[56px] min-h-[56px] box-border border-b-[1px] border-[var(--header-border-color)] bg-[var(--header-background-color)] px-[32px]",children:[C.jsxs("div",{className:"flex items-center gap-[12px]",children:[C.jsx("h3",{className:"text-[var(--header-color)] font-bold text-[16px] leading-[24px]",children:t("AIAgent")}),C.jsx(ta,{tooltip:t("NewChat"),children:C.jsx(gt,{iconName:Mke,size:24,isStroke:!0,onClick:()=>{n("chat"),r()}})})]}),C.jsx(ta,{tooltip:t("Settings"),children:C.jsx(gt,{iconName:Rke,size:24,isStroke:!0,isActive:e==="settings",onClick:()=>n(e==="settings"?"chat":"settings")})})]})},$ke="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12.5%2019a.5.5%200%200%201%200%201h-8a.5.5%200%200%201%200-1zm3.308-11.5a4.308%204.308%200%200%201%203.378%206.979l1.668%201.668a.5.5%200%201%201-.707.707l-1.668-1.668a4.308%204.308%200%201%201-2.67-7.685m0%201a3.308%203.308%200%201%200%200%206.615%203.308%203.308%200%200%200%200-6.615M8.5%2014a.5.5%200%200%201%200%201h-4a.5.5%200%200%201%200-1zm0-5a.5.5%200%200%201%200%201h-4a.5.5%200%200%201%200-1zm11-5a.5.5%200%200%201%200%201h-15a.5.5%200%200%201%200-1z'%20fill='%23444'/%3e%3c/svg%3e",jke="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M13.57%206.42969L8%2011.9995L13.57%2017.5694'%20stroke='%23383838'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Bke="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M17.5002%2017.5002L13.881%2013.881M13.881%2013.881C14.5001%2013.2619%2014.9912%2012.527%2015.3262%2011.7181C15.6612%2010.9093%2015.8337%2010.0423%2015.8337%209.16684C15.8337%208.29134%2015.6612%207.42441%2015.3262%206.61555C14.9912%205.80669%2014.5001%205.07174%2013.881%204.45267C13.2619%203.8336%2012.527%203.34252%2011.7181%203.00748C10.9093%202.67244%2010.0423%202.5%209.16684%202.5C8.29134%202.5%207.42441%202.67244%206.61555%203.00748C5.80669%203.34252%205.07174%203.8336%204.45267%204.45267C3.2024%205.70295%202.5%207.39868%202.5%209.16684C2.5%2010.935%203.2024%2012.6307%204.45267%2013.881C5.70295%2015.1313%207.39868%2015.8337%209.16684%2015.8337C10.935%2015.8337%2012.6307%2015.1313%2013.881%2013.881Z'%20stroke='%23383838'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Fke="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M18.5%207C19.3284%207%2020%207.67157%2020%208.5V15.5C20%2016.3284%2019.3284%2017%2018.5%2017H5.5C4.67157%2017%204%2016.3284%204%2015.5V8.5C4%207.67157%204.67157%207%205.5%207H18.5ZM5.5%208C5.22386%208%205%208.22386%205%208.5V15.5C5%2015.7761%205.22386%2016%205.5%2016H18.5C18.7761%2016%2019%2015.7761%2019%2015.5V8.5C19%208.22386%2018.7761%208%2018.5%208H5.5Z'%20fill='%23383838'/%3e%3cpath%20d='M8.5%209C8.77614%209%209%209.22386%209%209.5C9%209.77614%208.77614%2010%208.5%2010H8V14H8.5C8.77614%2014%209%2014.2239%209%2014.5C9%2014.7761%208.77614%2015%208.5%2015H6.5C6.22386%2015%206%2014.7761%206%2014.5C6%2014.2239%206.22386%2014%206.5%2014H7V10H6.5C6.22386%2010%206%209.77614%206%209.5C6%209.22386%206.22386%209%206.5%209H8.5Z'%20fill='%23446ECA'/%3e%3c/svg%3e",zke=({id:t,onClose:e})=>{const{onDeleteThread:n}=ug(),{t:r}=vt(),i=de.useCallback(async()=>{await n(t),e()},[t,n,e]);return de.useEffect(()=>{const s=o=>{o.key==="Enter"&&(o.preventDefault(),i())};return document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}},[i]),C.jsx(xl,{open:!0,children:C.jsx(Sl,{header:r("Warning"),onClose:e,withWarningIcon:!0,children:C.jsxs("div",{className:"flex flex-col justify-between h-full",children:[C.jsx("p",{className:"select-none h-[40px] flex items-center text-[12px] leading-[16px] text-[var(--text-normal)]",children:r("WantDeleteChat")}),C.jsxs("div",{className:"flex flex-row justify-end items-center gap-[8px] h-[48px]",children:[C.jsx(en,{variant:"default",onClick:e,children:r("No")}),C.jsx(en,{onClick:i,children:r("Yes")})]})]})})})},Vke=t=>{const e=t.querySelector("path");e&&e.setAttribute("stroke","var(--icon-button-color)")},Uke=t=>{const e=t.querySelector("path");e&&e.setAttribute("fill","var(--icon-button-color)")},Hke=t=>{const e=t.querySelector("path");e&&e.setAttribute("fill","var(--icon-button-color)")},Wke=()=>C.jsx(dn,{src:Mq,beforeInjection:Vke}),qke=()=>C.jsx(dn,{src:Fke,beforeInjection:Uke}),Gke=()=>C.jsx(dn,{src:jk,beforeInjection:Hke}),Kke=({thread:t,isActive:e,onSwitchToThread:n,onRenameThread:r,onDownloadThread:i,setCurrentPage:s})=>{const[o,a]=de.useState(!1),[c,h]=de.useState(!1),[f,d]=de.useState(!1),[m,y]=de.useState(!1),[b,w]=de.useState(t.title),S=de.useRef(null),_=de.useRef(null),{t:A}=vt();de.useEffect(()=>{const D=$=>{f&&($.key==="Escape"?($.preventDefault(),d(!1),w(t.title)):$.key==="Enter"&&($.preventDefault(),_.current?.blur()))};return f&&document.addEventListener("keydown",D),()=>{document.removeEventListener("keydown",D)}},[f,t.title]);const E=()=>{o||f||m||(n(t.threadId),s("chat"))},P=()=>{y(!0),a(!1)},O=()=>{d(!0),a(!1)},M=()=>{i(t.threadId),a(!1)};return C.jsxs("div",{ref:S,className:`cursor-pointer rounded-[4px] h-[36px] min-h-[36px] flex items-center justify-between ${f?"":`px-[12px] ${e||o?"bg-[var(--chat-list-item-active-background-color)]":"hover:bg-[var(--chat-list-item-hover-background-color)] active:bg-[var(--chat-list-item-active-background-color)]"}`}`,onMouseEnter:()=>h(!0),onMouseLeave:()=>{o||h(!1)},onClick:E,children:[f?C.jsx(co,{ref:_,value:b,onChange:D=>w(D.target.value),onBlur:()=>{d(!1),b&&r(t.threadId,b)},autoFocus:!0,className:"w-full",maxLength:128}):C.jsxs(C.Fragment,{children:[C.jsx("p",{className:"text-[var(--chat-list-item-color)] font-normal text-[14px] leading-[20px] truncate",children:t.title}),c&&!f?C.jsx(Nc,{open:o,onOpenChange:a,trigger:C.jsx(gt,{iconName:$k,size:20,isActive:o,insideElement:!0}),items:[{icon:C.jsx(Wke,{}),text:A("Save"),onClick:M},{icon:C.jsx(qke,{}),text:A("Rename"),onClick:O},{icon:C.jsx(Gke,{}),text:A("Delete"),onClick:P}],side:"right",align:"start",sideOffset:0,containerRef:S.current}):null]}),m?C.jsx(zke,{id:t.threadId,onClose:()=>y(!1)}):null]},t.threadId)},Yke=()=>{const{threads:t,threadId:e,onSwitchToThread:n,onRenameThread:r,onDownloadThread:i}=ug(),{setCurrentPage:s}=Vm(),[o,a]=de.useState(!1),[c,h]=de.useState(""),[f,d]=de.useState(t),{t:m}=vt(),y=w=>{const S=w.target.value;h(S)};de.useEffect(()=>{const w=t.filter(S=>S.title?.toLowerCase().includes(c.toLowerCase()));d(w)},[t,c]);const b=t.length===0;return o?C.jsxs("div",{className:"w-[264px] min-w-[264px] h-full max-h-full border-r-[1px] border-[var(--chat-list-border-right)] flex flex-col overflow-y-auto",style:{maxHeight:"100%"},children:[C.jsxs("div",{className:"sticky top-0 bg-[var(--layout-background-color)] z-10 pt-[24px] px-[24px]",children:[C.jsxs("div",{className:"flex items-center justify-between px-[8px]",children:[C.jsx("h4",{className:"text-[14px] leading-[20px] font-bold text-[var(--chat-list-color)]",children:m("ChatHistory")}),C.jsx(gt,{iconName:jke,size:24,isStroke:!0,onClick:()=>a(!1)})]}),!b&&C.jsx("div",{className:"mt-[32px]",children:C.jsx(co,{className:"w-full",type:"search",placeholder:m("Search"),icon:Bke,value:c,onChange:y,onClear:()=>h("")})})]}),C.jsx("div",{className:"flex flex-col px-[24px] pb-[24px]",children:b?C.jsx("p",{className:"text-[var(--chat-list-empty-color)] font-normal text-[14px] leading-[20px] w-full text-center mt-[24px]",children:m("NoChatYet")}):C.jsx("div",{className:"flex flex-col mt-[16px]",children:f.length?f.map(w=>{const S=w.threadId===e;return C.jsx(Kke,{thread:w,isActive:S,onSwitchToThread:n,setCurrentPage:s,onRenameThread:r,onDownloadThread:i},w.threadId)}):C.jsx("p",{className:"text-[var(--chat-list-empty-color)] font-normal text-[14px] leading-[20px] w-full",children:m("NoChatYet")})})})]}):C.jsx("div",{className:"ml-[32px] mt-[24px]",children:C.jsx(ta,{tooltip:m("ChatHistory"),children:C.jsx(gt,{iconName:$ke,size:24,onClick:()=>{s("chat"),a(!0)}})})})},u5=t=>t==="dark"?"theme-night":"theme-white",h5=({children:t})=>{const{currentPage:e}=Vm(),{i18n:n}=vt(),[r,i]=de.useState(()=>window.RendererProcessVariable?window.RendererProcessVariable.theme.id==="theme-system"?u5(window.RendererProcessVariable.theme.system):window.RendererProcessVariable.theme.id:"theme-light");de.useLayoutEffect(()=>{window.RendererProcessVariable&&n.changeLanguage(window.RendererProcessVariable.lang),window.on_update_plugin_info=o=>{o.lang&&n.changeLanguage(o.lang),o.theme&&(o.theme==="theme-system"?i(u5(window.RendererProcessVariable.theme.system)):i(o.theme))}},[n]);const s=e==="settings";return C.jsx("div",{className:`h-[100vh] ${r}`,children:C.jsxs("main",{id:"app",className:"h-[100vh] bg-[var(--layout-background-color)] flex flex-col",children:[C.jsx(Nke,{}),C.jsxs("div",{className:"flex flex-row flex-1",style:{height:"calc(100vh - 56px)"},children:[s?null:C.jsx(Yke,{}),C.jsx("div",{className:"w-full",children:t})]})]})})},Xke=({checked:t=!1,onChange:e,disabled:n=!1,id:r,className:i=""})=>{const s=E=>{e&&!n&&e(E.target.checked)},o=k.useCallback(E=>{E.querySelectorAll("path").forEach(M=>{M.setAttribute("stroke","var(--checkbox-active-icon-color)")}),E.querySelectorAll("circle").forEach(M=>{M.setAttribute("stroke","var(--checkbox-active-icon-color)")})},[]),a="inline-flex items-center relative group",c="absolute opacity-0 cursor-pointer w-4 h-4 m-0",h="disabled:cursor-not-allowed",f="inline-flex items-center select-none",d=n?"cursor-not-allowed opacity-60":"cursor-pointer",m="w-4 h-4 rounded-[2px] flex items-center justify-center transition-all duration-200 box-border",y="focus-within:outline-none",b="bg-[var(--checkbox-bg-color)] border border-[var(--checkbox-color)]",w=n?"":"group-hover:!bg-[var(--checkbox-bg-hover-color)] group-active:!bg-[var(--checkbox-bg-pressed-color)]",S="bg-[var(--checkbox-active-color)]",_=n?"":"group-hover:!bg-[var(--checkbox-active-hover-color)] group-active:!bg-[var(--checkbox-active-pressed-color)]";return C.jsxs("div",{className:je(a,i),children:[C.jsx("input",{type:"checkbox",id:r,checked:t,onChange:s,disabled:n,className:je(c,h)}),C.jsx("label",{htmlFor:r,className:je(f,d),children:C.jsx("div",{className:je(m,y,t?je(S,_):je(b,w)),children:t?C.jsx(dn,{src:Oh,className:"flex items-center justify-center",beforeInjection:o}):null})})]})},Jke=({onAllow:t,onDeny:e,onClose:n})=>{const{t:r}=vt(),{manageToolData:i}=Rs(),[s,o]=k.useState(!1),a=de.useCallback(()=>{t(s),n()},[t,s,n]),c=()=>{e(),n()},h=i?.message?.content[i.idx];if(de.useEffect(()=>{const f=d=>{d.key==="Enter"&&(d.preventDefault(),a())};return window.addEventListener("keydown",f),()=>{window.removeEventListener("keydown",f)}},[a]),!(!h||typeof h!="object"||!("type"in h)||h.type!=="tool-call"))return C.jsx(xl,{open:!0,children:C.jsxs(Sl,{header:r("Confirmation"),onClose:e,isHuge:!0,children:[C.jsxs("div",{className:"flex flex-col justify-between h-full mb-[16px] text-[var(--tool-fallback-color)]",children:[C.jsx("p",{className:"mt-[8px] font-[14px] leading-[20px] font-normal text-[var(--tool-fallback-color)]",children:r("AIWouldLikeUseThisTool")}),C.jsx(Oq,{type:"tool-call",toolCallId:h.toolCallId,args:h.args??{},toolName:h.toolName,argsText:h.argsText??"{}",result:h.result,status:{type:"running"},addResult:()=>{}}),C.jsx("p",{className:"font-[14px] leading-[20px] font-normal text-[var(--tool-fallback-color)]",children:r("ReviewEachAction")}),C.jsxs("p",{onClick:()=>o(f=>!f),className:"cursor-pointer flex items-center gap-[8px] mt-[24px] font-[14px] leading-[20px] font-normal text-[var(--tool-fallback-color)]",children:[C.jsx(Xke,{checked:s,id:"allow-always-checkbox"}),r("AlwaysAllow")]})]}),C.jsxs("div",{className:"flex flex-row justify-end items-center gap-[8px] h-[64px] border-t-[1px] border-[var(--border-divider)] mx-[-32px] px-[32px]",children:[C.jsx(en,{variant:"default",onClick:c,children:r("Deny")}),C.jsx(en,{onClick:a,children:r("Allow")})]})]})})},Qke=async t=>{const e=ns.getDB();return new Promise(n=>{const s=e.transaction(["threads"],"readonly").objectStore("threads").get(t);s.onerror=()=>n(null),s.onsuccess=()=>n(s.result||null)})},Zke=({isReady:t})=>{const{messages:e,setIsStreamRunning:n,setIsRequestRunning:r,addMessage:i,updateLastMessage:s,fetchPrevMessages:o}=Yh(),{threadId:a,insertThread:c,insertNewMessageToThread:h}=ug(),{manageToolData:f,callTools:d,checkAllowAlways:m,setAllowAlways:y,setManageToolData:b}=Rs(),{attachmentFiles:w,clearAttachmentFiles:S}=bx(),{currentProvider:_}=rs(),{currentModel:A}=cg(),E=k.useRef(a);k.useEffect(()=>{t&&(E.current=a,o(a),S())},[a,t,o,S]);const P=N=>N,O=N=>{if(!f)return;const U=f?.message?.content[f.idx];if(!U||typeof U!="object"||!("type"in U)||U.type!=="tool-call")return;const q=U.toolName,K=Qt.getServerType(q),X=q.replace(K+"_","");N&&y(!0,K,X),D(f.message,f.idx,f.messageUID,!0,!1),b(void 0)},M=()=>{f&&(D(f.message,f.idx,f.messageUID,!1,!0),b(void 0))},D=async(N,U,q,K,X)=>{const ee=N.content[U];if(!ee||typeof ee!="object"||!("type"in ee)||ee.type!=="tool-call")return;const V=ee.toolName,G=Qt.getServerType(V),H=V.replace(G+"_","");if(m(G,H)||K||X){const se=X?"User deny tool call":await d(ee.toolName,ee.args),T=Array.isArray(N.content)?N.content.map((L,pe)=>pe===U?{...ee,result:se}:L):N.content,Z={...N,content:T};if(s(Z),!Lt)return;const ue=Lt.sendMessageAfterToolCall(Z);ue&&$(ue,!0,q)}else b({message:N,idx:U,messageUID:q})},$=async(N,U,q)=>{n(!0);let K=!!U;const X=U&&q?q:crypto.randomUUID();if(e)for await(const ee of N){if("isEnd"in ee){if(E.current!==a){n(!1),r(!1);return}if(ee.responseMessage.status?.type==="incomplete"){i(ee.responseMessage),n(!1),r(!1);return}const V=ee.responseMessage;if(V?.role==="assistant"&&Array.isArray(V.content)){const G=V.content.findIndex(H=>H.type==="tool-call"&&!H.result);if(G!==-1){D(V,G,X);return}}n(!1),r(!1);return}K?(Bre(X,ee),E.current===a&&s(ee)):(U||r(!0),i(ee),py(a,X,ee),K=!0)}};return{convertMessage:P,onNew:async N=>{if(!Lt||!_||!A||N.content[0].type!=="text")return;let U=[];w.length>0&&(U=w.map(V=>({type:"file",mimeType:JSON.stringify({path:V.path,type:V.type}),data:V.content})),S());const K={role:"user",content:[...U,{type:"text",text:N.content[0].text}],attachments:N.attachments};if(await Qke(a))h(),(async()=>{await py(a,crypto.randomUUID(),K)})();else{let V="";for(const G of e)G.status?.type==="incomplete"&&G.status?.error||(V+=typeof G.content=="string"?G.content:G.content[0].type==="text"?G.content[0].text:"",V+=`
`);V+=`
`+N.content[0].text,Lt.createChatName(V).then(async G=>{if(G){c(G);for(const H of e)H.status?.type==="incomplete"&&H.status?.error||await py(a,crypto.randomUUID(),H);await py(a,crypto.randomUUID(),K)}})}i(K);const ee=Lt.sendMessage([K]);ee&&$(ee)},handleStream:$,approveToolCall:O,denyToolCall:M}},eTe=({isReady:t})=>{const{initThreads:e}=ug();return k.useEffect(()=>{t&&e()},[t,e]),{}},tTe=()=>{const{initCurrentModel:t,currentModel:e}=cg();return k.useEffect(()=>{e&&Lt.setCurrentProviderModel(e.id)},[e]),k.useEffect(()=>{t()},[t]),{}},nTe=({isReady:t})=>{const{initServers:e,getTools:n,tools:r}=Rs(),{currentProvider:i}=rs();return k.useEffect(()=>{t&&(e(),n(),setInterval(()=>{n()},1e3*60*5))},[t,e,n]),k.useEffect(()=>{const s=()=>{n()};return window.addEventListener("tools-changed",s),()=>{window.removeEventListener("tools-changed",s)}},[n]),k.useEffect(()=>{!r||!i||Lt.setCurrentProviderTools(r)},[r,i]),{}},Ke=t=>typeof t=="string",Vd=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},f5=t=>t==null?"":""+t,rTe=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},iTe=/###/g,d5=t=>t&&t.indexOf("###")>-1?t.replace(iTe,"."):t,p5=t=>!t||Ke(t),zp=(t,e,n)=>{const r=Ke(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(p5(t))return{};const s=d5(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return p5(t)?{}:{obj:t,k:d5(r[i])}},m5=(t,e,n)=>{const{obj:r,k:i}=zp(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],o=e.slice(0,e.length-1),a=zp(t,o,Object);for(;a.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),a=zp(t,o,Object),a?.obj&&typeof a.obj[`${a.k}.${s}`]<"u"&&(a.obj=void 0);a.obj[`${a.k}.${s}`]=n},sTe=(t,e,n,r)=>{const{obj:i,k:s}=zp(t,e,Object);i[s]=i[s]||[],i[s].push(n)},gw=(t,e)=>{const{obj:n,k:r}=zp(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},oTe=(t,e,n)=>{const r=gw(t,n);return r!==void 0?r:gw(e,n)},Pq=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?Ke(t[r])||t[r]instanceof String||Ke(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):Pq(t[r],e[r],n):t[r]=e[r]);return t},Uu=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var aTe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const lTe=t=>Ke(t)?t.replace(/[&<>"'\/]/g,e=>aTe[e]):t;class cTe{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const uTe=[" ",",","?","!",";"],hTe=new cTe(20),fTe=(t,e,n)=>{e=e||"",n=n||"";const r=uTe.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=hTe.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!i.test(t);if(!s){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(s=!0)}return s},AE=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let s=0;s<r.length;){if(!i||typeof i!="object")return;let o,a="";for(let c=s;c<r.length;++c)if(c!==s&&(a+=n),a+=r[c],o=i[a],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&c<r.length-1)continue;s+=c-s+1;break}i=o}return i},Om=t=>t?.replace("_","-"),dTe={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class yw{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||dTe,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(Ke(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new yw(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new yw(this.logger,e)}}var ao=new yw;class Rx{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i.apply(i,[e,...n])})}}class g5 extends Rx{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,n],r&&(Array.isArray(r)?a.push(...r):Ke(r)&&s?a.push(...r.split(s)):a.push(r)));const c=gw(this.data,a);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=a[0],n=a[1],r=a.slice(2).join(".")),c||!o||!Ke(r)?c:AE(this.data?.[e]?.[n],r,s)}addResource(e,n,r,i,s={silent:!1}){const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let a=[e,n];r&&(a=a.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(a=e.split("."),i=n,n=a[1]),this.addNamespaces(n),m5(this.data,a,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const s in r)(Ke(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s,o={silent:!1,skipCopy:!1}){let a=[e,n];e.indexOf(".")>-1&&(a=e.split("."),i=r,r=n,n=a[1]),this.addNamespaces(n);let c=gw(this.data,a)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?Pq(c,r,s):c={...c,...r},m5(this.data,a,c),o.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var Dq={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{e=this.processors[s]?.process(e,n,r,i)??e}),e}};const Iq=Symbol("i18next/PATH_KEY");function pTe(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===Iq?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function EE(t,e){const{[Iq]:n}=t(pTe());return n.join(e?.keySeparator??".")}const y5={},b5=t=>!Ke(t)&&typeof t!="boolean"&&typeof t!="number";class bw extends Rx{constructor(e,n={}){super(),rTe(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=ao.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};return e==null?!1:this.resolve(e,r)?.res!==void 0}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,a=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!fTe(e,r,i);if(o&&!a){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:Ke(s)?[s]:s};const h=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(h[0])>-1)&&(s=h.shift()),e=h.join(i)}return{key:e,namespaces:Ke(s)?[s]:s}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=EE(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const s=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:a,namespaces:c}=this.extractFromKey(e[e.length-1],i),h=c[c.length-1];let f=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;f===void 0&&(f=":");const d=i.lng||this.language,m=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d?.toLowerCase()==="cimode")return m?s?{res:`${h}${f}${a}`,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:h,usedParams:this.getUsedParamsDetails(i)}:`${h}${f}${a}`:s?{res:a,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:h,usedParams:this.getUsedParamsDetails(i)}:a;const y=this.resolve(e,i);let b=y?.res;const w=y?.usedKey||a,S=y?.exactUsedKey||a,_=["[object Number]","[object Function]","[object RegExp]"],A=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,E=!this.i18nFormat||this.i18nFormat.handleAsObject,P=i.count!==void 0&&!Ke(i.count),O=bw.hasDefaultValue(i),M=P?this.pluralResolver.getSuffix(d,i.count,i):"",D=i.ordinal&&P?this.pluralResolver.getSuffix(d,i.count,{ordinal:!1}):"",$=P&&!i.ordinal&&i.count===0,F=$&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${M}`]||i[`defaultValue${D}`]||i.defaultValue;let N=b;E&&!b&&O&&(N=F);const U=b5(N),q=Object.prototype.toString.apply(N);if(E&&N&&U&&_.indexOf(q)<0&&!(Ke(A)&&Array.isArray(N))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const K=this.options.returnedObjectHandler?this.options.returnedObjectHandler(w,N,{...i,ns:c}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(y.res=K,y.usedParams=this.getUsedParamsDetails(i),y):K}if(o){const K=Array.isArray(N),X=K?[]:{},ee=K?S:w;for(const V in N)if(Object.prototype.hasOwnProperty.call(N,V)){const G=`${ee}${o}${V}`;O&&!b?X[V]=this.translate(G,{...i,defaultValue:b5(F)?F[V]:void 0,joinArrays:!1,ns:c}):X[V]=this.translate(G,{...i,joinArrays:!1,ns:c}),X[V]===G&&(X[V]=N[V])}b=X}}else if(E&&Ke(A)&&Array.isArray(b))b=b.join(A),b&&(b=this.extendTranslation(b,e,i,r));else{let K=!1,X=!1;!this.isValidLookup(b)&&O&&(K=!0,b=F),this.isValidLookup(b)||(X=!0,b=a);const V=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&X?void 0:b,G=O&&F!==b&&this.options.updateMissing;if(X||K||G){if(this.logger.log(G?"updateKey":"missingKey",d,h,a,G?F:b),o){const Z=this.resolve(a,{...i,keySeparator:!1});Z&&Z.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let H=[];const se=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&se&&se[0])for(let Z=0;Z<se.length;Z++)H.push(se[Z]);else this.options.saveMissingTo==="all"?H=this.languageUtils.toResolveHierarchy(i.lng||this.language):H.push(i.lng||this.language);const T=(Z,ue,L)=>{const pe=O&&L!==b?L:V;this.options.missingKeyHandler?this.options.missingKeyHandler(Z,h,ue,pe,G,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(Z,h,ue,pe,G,i),this.emit("missingKey",Z,h,ue,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&P?H.forEach(Z=>{const ue=this.pluralResolver.getSuffixes(Z,i);$&&i[`defaultValue${this.options.pluralSeparator}zero`]&&ue.indexOf(`${this.options.pluralSeparator}zero`)<0&&ue.push(`${this.options.pluralSeparator}zero`),ue.forEach(L=>{T([Z],a+L,i[`defaultValue${L}`]||F)})}):T(H,a,F))}b=this.extendTranslation(b,e,i,y,r),X&&b===a&&this.options.appendNamespaceToMissingKey&&(b=`${h}${f}${a}`),(X||K)&&this.options.parseMissingKeyHandler&&(b=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${h}${f}${a}`:a,K?b:void 0,i))}return s?(y.res=b,y.usedParams=this.getUsedParamsDetails(i),y):b}extendTranslation(e,n,r,i,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=Ke(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let h;if(c){const d=e.match(this.interpolator.nestingRegexp);h=d&&d.length}let f=r.replace&&!Ke(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),e=this.interpolator.interpolate(e,f,r.lng||this.language||i.usedLng,r),c){const d=e.match(this.interpolator.nestingRegexp),m=d&&d.length;h<m&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...d)=>s?.[0]===d[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${n[0]}`),null):this.translate(...d,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,a=Ke(o)?[o]:o;return e!=null&&a?.length&&r.applyPostProcessor!==!1&&(e=Dq.handle(a,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,s,o,a;return Ke(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const h=this.extractFromKey(c,n),f=h.key;i=f;let d=h.namespaces;this.options.fallbackNS&&(d=d.concat(this.options.fallbackNS));const m=n.count!==void 0&&!Ke(n.count),y=m&&!n.ordinal&&n.count===0,b=n.context!==void 0&&(Ke(n.context)||typeof n.context=="number")&&n.context!=="",w=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);d.forEach(S=>{this.isValidLookup(r)||(a=S,!y5[`${w[0]}-${S}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(y5[`${w[0]}-${S}`]=!0,this.logger.warn(`key "${i}" for languages "${w.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),w.forEach(_=>{if(this.isValidLookup(r))return;o=_;const A=[f];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(A,f,_,S,n);else{let P;m&&(P=this.pluralResolver.getSuffix(_,n.count,n));const O=`${this.options.pluralSeparator}zero`,M=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&P.indexOf(M)===0&&A.push(f+P.replace(M,this.options.pluralSeparator)),A.push(f+P),y&&A.push(f+O)),b){const D=`${f}${this.options.contextSeparator||"_"}${n.context}`;A.push(D),m&&(n.ordinal&&P.indexOf(M)===0&&A.push(D+P.replace(M,this.options.pluralSeparator)),A.push(D+P),y&&A.push(D+O))}}let E;for(;E=A.pop();)this.isValidLookup(r)||(s=E,r=this.getResource(_,S,E,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:o,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!Ke(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class v5{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ao.create("languageUtils")}getScriptPartFromCode(e){if(e=Om(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=Om(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(Ke(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(o=>{if(o===s)return o;if(!(o.indexOf("-")<0&&s.indexOf("-")<0)&&(o.indexOf("-")>0&&s.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===s||o.indexOf(s)===0&&s.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),Ke(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],s=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return Ke(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):Ke(e)&&s(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}const w5={zero:0,one:1,two:2,few:3,many:4,other:5},x5={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class mTe{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=ao.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=Om(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),x5;if(!e.match(/-|_/))return x5;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[s]=o,o}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,s)=>w5[i]-w5[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const S5=(t,e,n,r=".",i=!0)=>{let s=oTe(t,e,n);return!s&&i&&Ke(n)&&(s=AE(t,n,r),s===void 0&&(s=AE(e,n,r))),s},B2=t=>t.replace(/\$/g,"$$$$");class gTe{constructor(e={}){this.logger=ao.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:s,prefixEscaped:o,suffix:a,suffixEscaped:c,formatSeparator:h,unescapeSuffix:f,unescapePrefix:d,nestingPrefix:m,nestingPrefixEscaped:y,nestingSuffix:b,nestingSuffixEscaped:w,nestingOptionsSeparator:S,maxReplaces:_,alwaysFormat:A}=e.interpolation;this.escape=n!==void 0?n:lTe,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Uu(s):o||"{{",this.suffix=a?Uu(a):c||"}}",this.formatSeparator=h||",",this.unescapePrefix=f?"":d||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=m?Uu(m):y||Uu("$t("),this.nestingSuffix=b?Uu(b):w||Uu(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=_||1e3,this.alwaysFormat=A!==void 0?A:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let s,o,a;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},h=y=>{if(y.indexOf(this.formatSeparator)<0){const _=S5(n,c,y,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(_,void 0,r,{...i,...n,interpolationkey:y}):_}const b=y.split(this.formatSeparator),w=b.shift().trim(),S=b.join(this.formatSeparator).trim();return this.format(S5(n,c,w,this.options.keySeparator,this.options.ignoreJSONStructure),S,r,{...i,...n,interpolationkey:w})};this.resetRegExp();const f=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,d=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:y=>B2(y)},{regex:this.regexp,safeValue:y=>this.escapeValue?B2(this.escape(y)):B2(y)}].forEach(y=>{for(a=0;s=y.regex.exec(e);){const b=s[1].trim();if(o=h(b),o===void 0)if(typeof f=="function"){const S=f(e,s,i);o=Ke(S)?S:""}else if(i&&Object.prototype.hasOwnProperty.call(i,b))o="";else if(d){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${b} for interpolating ${e}`),o="";else!Ke(o)&&!this.useRawValueToEscape&&(o=f5(o));const w=y.safeValue(o);if(e=e.replace(s[0],w),d?(y.regex.lastIndex+=o.length,y.regex.lastIndex-=s[0].length):y.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,s,o;const a=(c,h)=>{const f=this.nestingOptionsSeparator;if(c.indexOf(f)<0)return c;const d=c.split(new RegExp(`${f}[ ]*{`));let m=`{${d[1]}`;c=d[0],m=this.interpolate(m,o);const y=m.match(/'/g),b=m.match(/"/g);((y?.length??0)%2===0&&!b||b.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),h&&(o={...h,...o})}catch(w){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,w),`${c}${f}${m}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];o={...r},o=o.replace&&!Ke(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const h=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(h!==-1&&(c=i[1].slice(h).split(this.formatSeparator).map(f=>f.trim()).filter(Boolean),i[1]=i[1].slice(0,h)),s=n(a.call(this,i[1].trim(),o),o),s&&i[0]===e&&!Ke(s))return s;Ke(s)||(s=f5(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),c.length&&(s=c.reduce((f,d)=>this.format(f,d,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const yTe=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(o=>{if(o){const[a,...c]=o.split(":"),h=c.join(":").trim().replace(/^'+|'+$/g,""),f=a.trim();n[f]||(n[f]=h),h==="false"&&(n[f]=!1),h==="true"&&(n[f]=!0),isNaN(h)||(n[f]=parseInt(h,10))}})}return{formatName:e,formatOptions:n}},_5=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const o=r+JSON.stringify(s);let a=e[o];return a||(a=t(Om(r),i),e[o]=a),a(n)}},bTe=t=>(e,n,r)=>t(Om(n),r)(e);class vTe{constructor(e={}){this.logger=ao.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?_5:bTe;this.formats={number:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s});return a=>o.format(a)}),currency:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s,style:"currency"});return a=>o.format(a)}),datetime:r((i,s)=>{const o=new Intl.DateTimeFormat(i,{...s});return a=>o.format(a)}),relativetime:r((i,s)=>{const o=new Intl.RelativeTimeFormat(i,{...s});return a=>o.format(a,s.range||"day")}),list:r((i,s)=>{const o=new Intl.ListFormat(i,{...s});return a=>o.format(a)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=_5(n)}format(e,n,r,i={}){const s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(a=>a.indexOf(")")>-1)){const a=s.findIndex(c=>c.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,a)].join(this.formatSeparator)}return s.reduce((a,c)=>{const{formatName:h,formatOptions:f}=yTe(c);if(this.formats[h]){let d=a;try{const m=i?.formatParams?.[i.interpolationkey]||{},y=m.locale||m.lng||i.locale||i.lng||r;d=this.formats[h](a,y,{...f,...i,...m})}catch(m){this.logger.warn(m)}return d}else this.logger.warn(`there was no format function for ${h}`);return a},e)}}const wTe=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class xTe extends Rx{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=ao.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const s={},o={},a={},c={};return e.forEach(h=>{let f=!0;n.forEach(d=>{const m=`${h}|${d}`;!r.reload&&this.store.hasResourceBundle(h,d)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,f=!1,o[m]===void 0&&(o[m]=!0),s[m]===void 0&&(s[m]=!0),c[d]===void 0&&(c[d]=!0)))}),f||(a[h]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),s=i[0],o=i[1];n&&this.emit("failedLoading",s,o,n),!n&&r&&this.store.addResourceBundle(s,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const a={};this.queue.forEach(c=>{sTe(c.loaded,[s],o),wTe(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(h=>{a[h]||(a[h]={});const f=c.loaded[h];f.length&&f.forEach(d=>{a[h][d]===void 0&&(a[h][d]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,s=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:o});return}this.readingCalls++;const a=(h,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const d=this.waitingReads.shift();this.read(d.lng,d.ns,d.fcName,d.tried,d.wait,d.callback)}if(h&&f&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,o)},s);return}o(h,f)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const h=c(e,n);h&&typeof h.then=="function"?h.then(f=>a(null,f)).catch(a):a(null,h)}catch(h){a(h)}return}return c(e,n,a)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();Ke(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Ke(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(o,a)=>{o&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,o),!o&&a&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,a),this.loaded(e,o,a)})}saveMissing(e,n,r,i,s,o={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...o,isUpdate:s},h=this.backend.create.bind(this.backend);if(h.length<6)try{let f;h.length===5?f=h(e,n,r,i,c):f=h(e,n,r,i),f&&typeof f.then=="function"?f.then(d=>a(null,d)).catch(a):a(null,f)}catch(f){a(f)}else h(e,n,r,i,a,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const C5=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),Ke(t[1])&&(e.defaultValue=t[1]),Ke(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),A5=t=>(Ke(t.ns)&&(t.ns=[t.ns]),Ke(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Ke(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),rb=()=>{},STe=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Pm extends Rx{constructor(e={},n){if(super(),this.options=A5(e),this.services={},this.logger=ao,this.modules={external:[]},STe(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(Ke(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=C5();this.options={...r,...this.options,...A5(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=h=>h?typeof h=="function"?new h:h:null;if(!this.options.isClone){this.modules.logger?ao.init(i(this.modules.logger),this.options):ao.init(null,this.options);let h;this.modules.formatter?h=this.modules.formatter:h=vTe;const f=new v5(this.options);this.store=new g5(this.options.resources,this.options);const d=this.services;d.logger=ao,d.resourceStore=this.store,d.languageUtils=f,d.pluralResolver=new mTe(f,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),h&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(d.formatter=i(h),d.formatter.init&&d.formatter.init(d,this.options),this.options.interpolation.format=d.formatter.format.bind(d.formatter)),d.interpolator=new gTe(this.options),d.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},d.backendConnector=new xTe(i(this.modules.backend),d.resourceStore,d,this.options),d.backendConnector.on("*",(y,...b)=>{this.emit(y,...b)}),this.modules.languageDetector&&(d.languageDetector=i(this.modules.languageDetector),d.languageDetector.init&&d.languageDetector.init(d,this.options.detection,this.options)),this.modules.i18nFormat&&(d.i18nFormat=i(this.modules.i18nFormat),d.i18nFormat.init&&d.i18nFormat.init(this)),this.translator=new bw(this.services,this.options),this.translator.on("*",(y,...b)=>{this.emit(y,...b)}),this.modules.external.forEach(y=>{y.init&&y.init(this)})}if(this.format=this.options.interpolation.format,n||(n=rb),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const h=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);h.length>0&&h[0]!=="dev"&&(this.options.lng=h[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(h=>{this[h]=(...f)=>this.store[h](...f)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(h=>{this[h]=(...f)=>(this.store[h](...f),this)});const a=Vd(),c=()=>{const h=(f,d)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(d),n(f,d)};if(this.languages&&!this.isInitialized)return h(null,this.t.bind(this));this.changeLanguage(this.options.lng,h)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),a}loadResources(e,n=rb){let r=n;const i=Ke(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],o=a=>{if(!a||a==="cimode")return;this.services.languageUtils.toResolveHierarchy(a).forEach(h=>{h!=="cimode"&&s.indexOf(h)<0&&s.push(h)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>o(c)),this.options.preload?.forEach?.(a=>o(a)),this.services.backendConnector.load(s,this.options.ns,a=>{!a&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(a)})}else r(null)}reloadResources(e,n,r){const i=Vd();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=rb),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Dq.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;const r=Vd();this.emit("languageChanging",e);const i=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},s=(a,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...h)=>this.t(...h)),n&&n(a,(...h)=>this.t(...h))},o=a=>{!e&&!a&&this.services.languageDetector&&(a=[]);const c=Ke(a)?a:a&&a[0],h=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Ke(a)?[a]:a);h&&(this.language||i(h),this.translator.language||this.translator.changeLanguage(h),this.services.languageDetector?.cacheUserLanguage?.(h)),this.loadResources(h,f=>{s(f,h)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),r}getFixedT(e,n,r){const i=(s,o,...a)=>{let c;typeof o!="object"?c=this.options.overloadTranslationOptionHandler([s,o].concat(a)):c={...o},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const h=this.options.keySeparator||".";let f;return c.keyPrefix&&Array.isArray(s)?f=s.map(d=>(typeof d=="function"&&(d=EE(d,{...this.options,...o})),`${c.keyPrefix}${h}${d}`)):(typeof s=="function"&&(s=EE(s,{...this.options,...o})),f=c.keyPrefix?`${c.keyPrefix}${h}${s}`:s),this.t(f,c)};return Ke(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(a,c)=>{const h=this.services.backendConnector.state[`${a}|${c}`];return h===-1||h===0||h===2};if(n.precheck){const a=n.precheck(this,o);if(a!==void 0)return a}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(s,e)))}loadNamespaces(e,n){const r=Vd();return this.options.ns?(Ke(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=Vd();Ke(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const s=i.getTextInfo();if(s&&s.direction)return s.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new v5(C5());return e.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){return new Pm(e,n)}cloneInstance(e={},n=rb){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Pm(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(a=>{s[a]=this[a]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const a=Object.keys(this.store.data).reduce((c,h)=>(c[h]={...this.store.data[h]},c[h]=Object.keys(c[h]).reduce((f,d)=>(f[d]={...c[h][d]},f),c[h]),c),{});s.store=new g5(a,i),s.services.resourceStore=s.store}return s.translator=new bw(s.services,i),s.translator.on("*",(a,...c)=>{s.emit(a,...c)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const xr=Pm.createInstance();xr.createInstance=Pm.createInstance;xr.createInstance;xr.dir;xr.init;xr.loadResources;xr.reloadResources;xr.use;xr.changeLanguage;xr.getFixedT;xr.t;xr.exists;xr.setDefaultNamespace;xr.hasLoadedNamespace;xr.loadNamespaces;xr.loadLanguages;const _Te="AI agent",CTe="AI agent Settings",ATe="Settings",ETe="Connect an AI Model to Get Started",kTe="No AI model is connected yet. Link a model to start interacting with it right here in the interface.",TTe="Connect an AI Model",RTe="Chat history",MTe="There is no chat history yet...",OTe="Choose how to connect AI",PTe="Select how you want to enable AI features in ONLYOFFICE.",DTe="You can either use the built-in Wallet for a quick start or connect your own AI model using an API key or a locally hosted model.",ITe="ONLYOFFICE Wallet",LTe="Top up your balance with a card and instantly use all AI features.",NTe="Your AI provider",$Te="Connect your own AI source — either via API key from a provider or a locally hosted model.",jTe="Register & Connect Wallet",BTe="Add provider",FTe="Connection",zTe="MCP Servers",VTe="AI Provider",UTe="Edit AI Provider",HTe="Provider",WTe="Name",qTe="URL",GTe="Enter name",KTe="Enter URL",YTe="API key",XTe="Enter API key",JTe="Cancel",QTe="Save",ZTe="Edit",eRe="Delete",tRe="Warning",nRe="Are you sure you want to delete this provider?",rRe="Are you sure you want to delete this chat?",iRe="Yes",sRe="No",oRe="How can I help?",aRe="Free Al chat, writing assistant & idea generator",lRe="Rename",cRe="Download",uRe="Search...",hRe="Add local file...",fRe="Recent files",dRe="Attachments",pRe="API key",mRe="New chat",gRe="Ask AI",yRe="Analyzing...",bRe="Al would like to use this tool:",vRe=`Review each action carefully before approving
We cannot guarantee the security or privacy practices of third-party integrations.`,wRe="Always allow this tool to perform this action without asking again",xRe="Deny",SRe="Allow",_Re="Tool call arguments",CRe="Tool call result",ARe="Tool executed",ERe="Confirmation",kRe="Select model",TRe="This section allows you to configure MCP servers for use within the AI agent. You can edit the configuration to add new MCP servers and enable tools as needed.",RRe="Edit configuration",MRe="Enter your JSON configuration:",ORe="Available tools",PRe="tools",DRe="tools enabled",IRe="Enable all tools",LRe="Disable all tools",NRe="Restart",$Re="Logs",jRe="Copy to clipboard",BRe="Close",FRe="Web Search",zRe="Connect a web search engine to enhance AI chats with real-time information from the internet.",VRe="Reset settings",URe="Web Search Engine",HRe="Select engine",WRe="All tools",qRe="Enable web search in settings",GRe="This server will be deleted from your list. Continue?",KRe="Provider not available",YRe="AI Chat can make mistakes. Check important info.",XRe="Configuration must be placed inside 'mcpServers' property",JRe={AIAgent:_Te,AIAgentSettings:CTe,Settings:ATe,ConnectAIModel:ETe,ConnectAIModelDescription:kTe,ConnectAIModelBtn:TTe,ChatHistory:RTe,NoChatYet:MTe,ChooseHowConnect:OTe,SelectHowConnect:PTe,SelectHowConnectDescription:DTe,ONLYOFFICEWallet:ITe,ONLYOFFICEWalletDescription:LTe,AIProviders:NTe,AIProvidersDescription:$Te,RegisterConnectWallet:jTe,AddProvider:BTe,Connection:FTe,MCPServers:zTe,AIProvider:VTe,EditAIProvider:UTe,Provider:HTe,Name:WTe,URL:qTe,EnterName:GTe,EnterURL:KTe,Key:YTe,EnterKey:XTe,Cancel:JTe,Save:QTe,Edit:ZTe,Delete:eRe,Warning:tRe,WantDeleteProvider:nRe,WantDeleteChat:rRe,Yes:iRe,No:sRe,WelcomeTitle:oRe,WelcomeDescription:aRe,Rename:lRe,Download:cRe,Search:uRe,AddLocalFile:hRe,RecentFiles:fRe,Attachments:dRe,APIKey:pRe,NewChat:mRe,AskAI:gRe,Analyzing:yRe,AIWouldLikeUseThisTool:bRe,ReviewEachAction:vRe,AlwaysAllow:wRe,Deny:xRe,Allow:SRe,ToolCallArguments:_Re,ToolCallResult:CRe,ToolExecuted:ARe,Confirmation:ERe,SelectModel:kRe,CustomServersDescription:TRe,EditConfiguration:RRe,EnterYourJSONConfiguration:MRe,AvailableTools:ORe,Tools:PRe,ToolsEnabled:DRe,EnableAllTools:IRe,DisableAllTools:LRe,Restart:NRe,Logs:$Re,CopyToClipboard:jRe,Close:BRe,WebSearch:FRe,WebSearchDescription:zRe,ResetSettings:VRe,WebSearchEngine:URe,SelectEngine:HRe,AllTools:WRe,EnableWebSearch:qRe,WantDeleteServer:GRe,NoModelsAvailable:KRe,CheckInfo:YRe,ConfigurationError:XRe},QRe="ИИ-агент",ZRe="Настройки ИИ-агента",eMe="Настройки",tMe="Чтобы начать, подключите ИИ-модель",nMe="Нет подключенных ИИ-моделей. Подключите модель, чтобы начать работать с ней прямо в интерфейсе.",rMe="Подключить ИИ-модель",iMe="История чатов",sMe="Здесь пока нет истории чатов...",oMe="Выберите, как вы хотите включить искусственный интеллект",aMe="Выберите, как вы хотите включить функции искусственного интеллекта в ONLYOFFICE.",lMe="Вы можете использовать встроенный кошелек для быстрого запуска или подключить собственную ИИ-модель с помощью ключа API или модели, размещенной локально.",cMe="Кошелек ONLYOFFICE",uMe="Пополните баланс с помощью карты и сразу используйте все функциональные возможности искусственного интеллекта.",hMe="Ваш ИИ-провайдер",fMe="Подключите собственный источник искусственного интеллекта с помощью ключа API провайдера или модели, размещенной локально.",dMe="Зарегистрируйтесь и подключите кошелек",pMe="Добавить провайдера",mMe="Подключение",gMe="MCP-серверы",yMe="ИИ-провайдер",bMe="Изменить ИИ-провайдера",vMe="Провайдер",wMe="Название",xMe="URL-адрес",SMe="Введите название",_Me="Введите URL-адрес",CMe="Ключ API",AMe="Введите ключ API",EMe="Отменить",kMe="Сохранить",TMe="Редактировать",RMe="Удалить",MMe="Предупреждение",OMe="Вы уверены, что хотите удалить этого провайдера?",PMe="Вы уверены, что хотите удалить этот чат?",DMe="Да",IMe="Нет",LMe="Чем я могу помочь?",NMe="Бесплатный ИИ-чат, помощник в создании документов и генератор идей",$Me="Переименовать",jMe="Загрузить",BMe="Поиск...",FMe="Добавить локальный файл...",zMe="Недавние файлы",VMe="Вложения",UMe="Ключ API",HMe="Новый чат",WMe="Спросить ИИ",qMe="Анализ...",GMe="Искусственный интеллект хочет использовать этот инструмент:",KMe=`Внимательно проверяйте каждое действие перед подтверждением
Мы не можем гарантировать соответствие правил обеспечения безопасности и конфиденциальности сторонних интеграций.`,YMe="Всегда разрешать этому инструменту выполнять данное действие без повторного запроса",XMe="Отклонить",JMe="Разрешить",QMe="Аргументы вызова инструмента",ZMe="Результат вызова инструмента",eOe="Работа с инструментом завершена",tOe="Подтверждение",nOe="Выбрать модель",rOe="В этом разделе можно настроить MCP-серверы для использования в ИИ-агенте. Вы можете редактировать конфигурацию, чтобы добавлять новые MCP-серверы и включать необходимые инструменты.",iOe="Редактировать конфигурацию",sOe="Введите конфигурацию JSON:",oOe="Доступные инструменты",aOe="инструменты",lOe="включенные инструменты",cOe="Включить все инструменты",uOe="Отключить все инструменты",hOe="Перезапустить",fOe="Журналы",dOe="Копировать в буфер обмена",pOe="Закрыть",mOe="Веб-поиск",gOe="Включите поисковую систему, чтобы дополнять ИИ-чаты информацией из Интернета в режиме реального времени.",yOe="Сбросить настройки",bOe="Поисковая система",vOe="Выберите движок",wOe="Все инструменты",xOe="Включить веб-поиск в настройках",SOe="Этот сервер будет удален из вашего списка. Продолжить?",_Oe="Поставщик недоступен",COe="ИИ-чат может ошибаться. Проверьте важную информацию.",AOe={AIAgent:QRe,AIAgentSettings:ZRe,Settings:eMe,ConnectAIModel:tMe,ConnectAIModelDescription:nMe,ConnectAIModelBtn:rMe,ChatHistory:iMe,NoChatYet:sMe,ChooseHowConnect:oMe,SelectHowConnect:aMe,SelectHowConnectDescription:lMe,ONLYOFFICEWallet:cMe,ONLYOFFICEWalletDescription:uMe,AIProviders:hMe,AIProvidersDescription:fMe,RegisterConnectWallet:dMe,AddProvider:pMe,Connection:mMe,MCPServers:gMe,AIProvider:yMe,EditAIProvider:bMe,Provider:vMe,Name:wMe,URL:xMe,EnterName:SMe,EnterURL:_Me,Key:CMe,EnterKey:AMe,Cancel:EMe,Save:kMe,Edit:TMe,Delete:RMe,Warning:MMe,WantDeleteProvider:OMe,WantDeleteChat:PMe,Yes:DMe,No:IMe,WelcomeTitle:LMe,WelcomeDescription:NMe,Rename:$Me,Download:jMe,Search:BMe,AddLocalFile:FMe,RecentFiles:zMe,Attachments:VMe,APIKey:UMe,NewChat:HMe,AskAI:WMe,Analyzing:qMe,AIWouldLikeUseThisTool:GMe,ReviewEachAction:KMe,AlwaysAllow:YMe,Deny:XMe,Allow:JMe,ToolCallArguments:QMe,ToolCallResult:ZMe,ToolExecuted:eOe,Confirmation:tOe,SelectModel:nOe,CustomServersDescription:rOe,EditConfiguration:iOe,EnterYourJSONConfiguration:sOe,AvailableTools:oOe,Tools:aOe,ToolsEnabled:lOe,EnableAllTools:cOe,DisableAllTools:uOe,Restart:hOe,Logs:fOe,CopyToClipboard:dOe,Close:pOe,WebSearch:mOe,WebSearchDescription:gOe,ResetSettings:yOe,WebSearchEngine:bOe,SelectEngine:vOe,AllTools:wOe,EnableWebSearch:xOe,WantDeleteServer:SOe,NoModelsAvailable:_Oe,CheckInfo:COe},EOe="Agent AI",kOe="Nastavení agenta AI",TOe="Nastavení",ROe="Připojte model AI a začněte",MOe="Zatím není připojen žádný model AI. Propojte model a začněte s ním komunikovat přímo zde v rozhraní.",OOe="Připojit model AI",POe="Historie chatu",DOe="Zatím neexistuje žádná historie chatu...",IOe="Vyberte způsob připojení AI",LOe="Vyberte, jak chcete povolit funkce AI v ONLYOFFICE.",NOe="Můžete buď použít vestavěnou peněženku pro rychlý start, nebo připojit svůj vlastní model AI pomocí klíče API nebo lokálně hostovaného modelu.",$Oe="Peněženka ONLYOFFICE",jOe="Doplňte svůj zůstatek kartou a okamžitě používejte všechny funkce AI.",BOe="Váš poskytovatel AI",FOe="Připojte svůj vlastní zdroj AI buď pomocí API klíče od poskytovatele, nebo lokálně hostovaného modelu.",zOe="Registrovat a připojit peněženku",VOe="Přidat poskytovatele",UOe="Připojení",HOe="Servery MCP",WOe="Poskytovatel AI",qOe="Upravit poskytovatele AI",GOe="Poskytovatel",KOe="Název",YOe="URL",XOe="Zadat název",JOe="Zadat URL",QOe="API klíč",ZOe="Zadat API klíč",ePe="Zrušit",tPe="Uložit",nPe="Upravit",rPe="Odstranit",iPe="Varování",sPe="Opravdu chcete odstranit tohoto poskytovatele?",oPe="Opravdu chcete odstranit tento chat?",aPe="Ano",lPe="Ne",cPe="Jak vám mohu pomoci?",uPe="Bezplatný Al chat, pomocník při psaní a generátor nápadů",hPe="Přejmenovat",fPe="Stáhnout",dPe="Hledat...",pPe="Přidat místní soubor...",mPe="Poslední soubory",gPe="Přílohy",yPe="API klíč",bPe="Nový chat",vPe="Zeptejte se AI",wPe="Probíhá analýza...",xPe="Al by ráda použila tento nástroj:",SPe=`Před schválením pečlivě zkontrolujte každou akci
Nemůžeme zaručit bezpečnost ani ochranu soukromí u integrací třetích stran.`,_Pe="Vždy povolit tomuto nástroji provést tuto akci bez dalšího dotazu",CPe="Odmítnout",APe="Povolit",EPe="Argumenty volání nástroje",kPe="Výsledek volání nástroje",TPe="Nástroj proveden",RPe="Potvrzení",MPe="Vybrat model",OPe="V této části můžete nakonfigurovat servery MCP pro použití v rámci AI agenta. Konfiguraci můžete upravit tak, abyste přidali nové servery MCP a podle potřeby povolili nástroje.",PPe="Upravit konfiguraci",DPe="Zadejte svou konfiguraci JSON:",IPe="Dostupné nástroje",LPe="nástroje",NPe="povolené nástroje",$Pe="Povolit všechny nástroje",jPe="Zakázat všechny nástroje",BPe="Restartovat",FPe="Protokoly",zPe="Kopírovat do schránky",VPe="Zavřít",UPe="Webové vyhledávání",HPe="Připojte webový vyhledávač a vylepšete AI chaty pomocí informací z internetu v reálném čase.",WPe="Obnovit nastavení",qPe="Webový vyhledávač",GPe="Vybrat vyhledávač",KPe="Všechny nástroje",YPe="Povolit webové vyhledávání v nastavení",XPe="Tento server bude odstraněn z vašeho seznamu. Pokračovat?",JPe="Poskytovatel není k dispozici",QPe="AI chat může dělat chyby. Zkontrolujte důležité informace.",ZPe={AIAgent:EOe,AIAgentSettings:kOe,Settings:TOe,ConnectAIModel:ROe,ConnectAIModelDescription:MOe,ConnectAIModelBtn:OOe,ChatHistory:POe,NoChatYet:DOe,ChooseHowConnect:IOe,SelectHowConnect:LOe,SelectHowConnectDescription:NOe,ONLYOFFICEWallet:$Oe,ONLYOFFICEWalletDescription:jOe,AIProviders:BOe,AIProvidersDescription:FOe,RegisterConnectWallet:zOe,AddProvider:VOe,Connection:UOe,MCPServers:HOe,AIProvider:WOe,EditAIProvider:qOe,Provider:GOe,Name:KOe,URL:YOe,EnterName:XOe,EnterURL:JOe,Key:QOe,EnterKey:ZOe,Cancel:ePe,Save:tPe,Edit:nPe,Delete:rPe,Warning:iPe,WantDeleteProvider:sPe,WantDeleteChat:oPe,Yes:aPe,No:lPe,WelcomeTitle:cPe,WelcomeDescription:uPe,Rename:hPe,Download:fPe,Search:dPe,AddLocalFile:pPe,RecentFiles:mPe,Attachments:gPe,APIKey:yPe,NewChat:bPe,AskAI:vPe,Analyzing:wPe,AIWouldLikeUseThisTool:xPe,ReviewEachAction:SPe,AlwaysAllow:_Pe,Deny:CPe,Allow:APe,ToolCallArguments:EPe,ToolCallResult:kPe,ToolExecuted:TPe,Confirmation:RPe,SelectModel:MPe,CustomServersDescription:OPe,EditConfiguration:PPe,EnterYourJSONConfiguration:DPe,AvailableTools:IPe,Tools:LPe,ToolsEnabled:NPe,EnableAllTools:$Pe,DisableAllTools:jPe,Restart:BPe,Logs:FPe,CopyToClipboard:zPe,Close:VPe,WebSearch:UPe,WebSearchDescription:HPe,ResetSettings:WPe,WebSearchEngine:qPe,SelectEngine:GPe,AllTools:KPe,EnableWebSearch:YPe,WantDeleteServer:XPe,NoModelsAvailable:JPe,CheckInfo:QPe},eDe="KI-Agent",tDe="Einstellungen des KI-Agenten",nDe="Einstellungen",rDe="Verbinden Sie ein KI-Modell, um loszulegen",iDe="Es ist noch kein KI-Modell verbunden. Verbinden Sie ein Modell, um direkt hier in der Benutzeroberfläche damit zu interagieren.",sDe="KI-Modell verbinden",oDe="Chatverlauf",aDe="Es gibt noch keinen Chatverlauf...",lDe="Wählen Sie aus, wie Sie die KI verbinden möchten",cDe="Wählen Sie aus, wie Sie die KI-Funktionen in ONLYOFFICE aktivieren möchten.",uDe="Sie können entweder die integrierte Wallet für einen schnellen Einstieg nutzen oder Ihr eigenes KI-Modell mithilfe eines API-Schlüssels oder eines lokal gehosteten Modells verbinden.",hDe="ONLYOFFICE Wallet",fDe="Laden Sie Ihr Guthaben mit einer Karte auf und nutzen Sie sofort alle KI-Funktionen.",dDe="Ihr KI-Anbieter",pDe="Verbinden Sie Ihre eigene KI-Quelle entweder über einen API-Schlüssel eines Anbieters oder über ein lokal gehostetes Modell.",mDe="Registrieren und Wallet verbinden",gDe="Anbieter hinzufügen",yDe="Verbindung",bDe="MCP-Server",vDe="KI-Anbieter",wDe="KI-Anbieter bearbeiten",xDe="Anbieter",SDe="Name",_De="URL",CDe="Name eingeben",ADe="URL eingeben",EDe="API-Schlüssel",kDe="API-Schlüssel eingeben",TDe="Abbrechen",RDe="Speichern",MDe="Bearbeiten",ODe="Löschen",PDe="Warnung",DDe="Möchten Sie diesen Anbieter wirklich löschen?",IDe="Möchten Sie diesen Chat wirklich löschen?",LDe="Ja",NDe="Nein",$De="Wie kann ich helfen?",jDe="Kostenloser KI-Chat, Schreibassistent und Ideengenerator",BDe="Umbenennen",FDe="Herunterladen",zDe="Suchen...",VDe="Lokale Datei hinzufügen...",UDe="Zuletzt verwendete Dateien",HDe="Anlagen",WDe="API-Schlüssel",qDe="Neuer Chat",GDe="KI fragen",KDe="Analyse läuft...",YDe="KI möchte dieses Tool verwenden:",XDe=`Prüfen Sie jede Aktion sorgfältig, bevor Sie sie genehmigen.
Wir können die Sicherheit und den Datenschutz bei Integrationen von Drittanbietern nicht garantieren.`,JDe="Diesem Tool immer erlauben, diese Aktion ohne erneute Nachfrage auszuführen.",QDe="Ablehnen",ZDe="Erlauben",eIe="Argumente des Toolaufrufs",tIe="Ergebnis des Toolaufrufs",nIe="Tool ausgeführt",rIe="Bestätigung",iIe="Modell auswählen",sIe=" In diesem Abschnitt können Sie MCP-Server für die Verwendung im KI-Agenten konfigurieren. Sie können die Konfiguration bearbeiten, um neue MCP-Server hinzuzufügen und bei Bedarf Tools zu aktivieren.",oIe="Konfiguration bearbeiten",aIe="Geben Sie Ihre JSON-Konfiguration ein:",lIe="Verfügbare Tools",cIe="Tools",uIe="Tools aktiviert",hIe="Alle Tools aktivieren",fIe="Alle Tools deaktivieren",dIe="Neustart",pIe="Protokolle",mIe="In die Zwischenablage kopieren",gIe="Schließen",yIe="Websuche",bIe="Verbinden Sie eine Websuchmaschine, um KI-Chats mit Echtzeitinformationen aus dem Internet zu verbessern.",vIe="Einstellungen zurücksetzen",wIe="Web-Suchmaschine",xIe="Engine auswählen",SIe="Alle Tools",_Ie="Aktivieren Sie die Websuche in den Einstellungen",CIe="Dieser Server wird aus Ihrer Liste gelöscht. Weiter?",AIe="Anbieter nicht verfügbar",EIe="KI-Chat kann Fehler machen. Überprüfen Sie wichtige Informationen.",kIe={AIAgent:eDe,AIAgentSettings:tDe,Settings:nDe,ConnectAIModel:rDe,ConnectAIModelDescription:iDe,ConnectAIModelBtn:sDe,ChatHistory:oDe,NoChatYet:aDe,ChooseHowConnect:lDe,SelectHowConnect:cDe,SelectHowConnectDescription:uDe,ONLYOFFICEWallet:hDe,ONLYOFFICEWalletDescription:fDe,AIProviders:dDe,AIProvidersDescription:pDe,RegisterConnectWallet:mDe,AddProvider:gDe,Connection:yDe,MCPServers:bDe,AIProvider:vDe,EditAIProvider:wDe,Provider:xDe,Name:SDe,URL:_De,EnterName:CDe,EnterURL:ADe,Key:EDe,EnterKey:kDe,Cancel:TDe,Save:RDe,Edit:MDe,Delete:ODe,Warning:PDe,WantDeleteProvider:DDe,WantDeleteChat:IDe,Yes:LDe,No:NDe,WelcomeTitle:$De,WelcomeDescription:jDe,Rename:BDe,Download:FDe,Search:zDe,AddLocalFile:VDe,RecentFiles:UDe,Attachments:HDe,APIKey:WDe,NewChat:qDe,AskAI:GDe,Analyzing:KDe,AIWouldLikeUseThisTool:YDe,ReviewEachAction:XDe,AlwaysAllow:JDe,Deny:QDe,Allow:ZDe,ToolCallArguments:eIe,ToolCallResult:tIe,ToolExecuted:nIe,Confirmation:rIe,SelectModel:iIe,CustomServersDescription:sIe,EditConfiguration:oIe,EnterYourJSONConfiguration:aIe,AvailableTools:lIe,Tools:cIe,ToolsEnabled:uIe,EnableAllTools:hIe,DisableAllTools:fIe,Restart:dIe,Logs:pIe,CopyToClipboard:mIe,Close:gIe,WebSearch:yIe,WebSearchDescription:bIe,ResetSettings:vIe,WebSearchEngine:wIe,SelectEngine:xIe,AllTools:SIe,EnableWebSearch:_Ie,WantDeleteServer:CIe,NoModelsAvailable:AIe,CheckInfo:EIe},TIe="Agente de IA",RIe="Configuración del agente de IA",MIe="Configuración",OIe="Conecte un modelo de IA para empezar",PIe="Aún no hay ningún modelo de IA conectado. Conecte un modelo para empezar a interactuar con él aquí mismo, en la interfaz.",DIe="Conectar un modelo de IA",IIe="Historial del chat",LIe="Todavía no hay historial de chat...",NIe="Elija cómo conectar la IA",$Ie="Seleccione cómo desea activar las funciones de IA en ONLYOFFICE.",jIe="Puedes utilizar el Monedero incorporado para empezar rápidamente o conectar tu propio modelo de IA utilizando una clave de la API o un modelo alojado localmente.",BIe="Monedero de ONLYOFFICE",FIe="Recargue su saldo con una tarjeta y utilice al instante todas las funciones de IA.",zIe="Su proveedor de IA",VIe="Conecte su propia fuente de IA, ya sea mediante una clave de la API de un proveedor o un modelo alojado localmente.",UIe="Regístrese y conecte su monedero",HIe="Añadir proveedor",WIe="Conexión",qIe="Servidores MCP",GIe="Proveedor de IA",KIe="Editar proveedor de IA",YIe="Proveedor",XIe="Nombre",JIe="URL",QIe="Introduzca el nombre",ZIe="Introduzca la URL",eLe="Clave de la API",tLe="Introduzca la clave de la API",nLe="Cancelar",rLe="Guardar",iLe="Editar",sLe="Eliminar",oLe="Advertencia",aLe="¿Está seguro de que desea eliminar este proveedor?",lLe="¿Está seguro de que desea eliminar este chat?",cLe="Sí",uLe="No",hLe="¿En qué puedo ayudarle?",fLe="Chat gratuito, asistente de escritura y generador de ideas",dLe="Renombrar",pLe="Descargar",mLe="Búsqueda...",gLe="Añadir archivo local...",yLe="Archivos recientes",bLe="Archivos adjuntos",vLe="Clave de la API",wLe="Nuevo chat",xLe="Preguntarle a la IA",SLe="Analizando...",_Le="A la IA le gustaría utilizar esta herramienta:",CLe=`Revise cada acción cuidadosamente antes de aprobarla
No podemos garantizar la seguridad o las prácticas de privacidad de las integraciones de terceros.`,ALe="Siempre permitir que esta herramienta realice esta acción sin preguntar de nuevo",ELe="Denegar",kLe="Permitir",TLe="Argumentos de la llamada a la herramienta",RLe="Resultado de la llamada a la herramienta",MLe="Herramienta ejecutada",OLe="Confirmación",PLe="Seleccionar modelo",DLe="Esta sección le permite configurar servidores MCP para su uso en el agente de IA. Puede editar la configuración para añadir nuevos servidores MCP y habilitar herramientas según sea necesario.",ILe="Editar configuración",LLe="Introduzca su configuración JSON:",NLe="Herramientas disponibles",$Le="herramientas",jLe="herramientas habilitadas",BLe="Habilitar todas las herramientas",FLe="Deshabilitar todas las herramientas",zLe="Reiniciar",VLe="Registros",ULe="Copiar al portapapeles",HLe="Cerrar",WLe="Búsqueda en la Web",qLe="Conecte un motor de búsqueda web para mejorar los chats de IA con información en tiempo real procedente de Internet.",GLe="Restablecer configuración",KLe="Motor de búsqueda web",YLe="Seleccionar motor",XLe="Todas las herramientas",JLe="Habilite la búsqueda web en la configuración",QLe="Este servidor se eliminará de su lista. ¿Continuar?",ZLe="Proveedor no disponible",eNe="El Chat de IA puede cometer errores. Compruebe la información importante.",tNe={AIAgent:TIe,AIAgentSettings:RIe,Settings:MIe,ConnectAIModel:OIe,ConnectAIModelDescription:PIe,ConnectAIModelBtn:DIe,ChatHistory:IIe,NoChatYet:LIe,ChooseHowConnect:NIe,SelectHowConnect:$Ie,SelectHowConnectDescription:jIe,ONLYOFFICEWallet:BIe,ONLYOFFICEWalletDescription:FIe,AIProviders:zIe,AIProvidersDescription:VIe,RegisterConnectWallet:UIe,AddProvider:HIe,Connection:WIe,MCPServers:qIe,AIProvider:GIe,EditAIProvider:KIe,Provider:YIe,Name:XIe,URL:JIe,EnterName:QIe,EnterURL:ZIe,Key:eLe,EnterKey:tLe,Cancel:nLe,Save:rLe,Edit:iLe,Delete:sLe,Warning:oLe,WantDeleteProvider:aLe,WantDeleteChat:lLe,Yes:cLe,No:uLe,WelcomeTitle:hLe,WelcomeDescription:fLe,Rename:dLe,Download:pLe,Search:mLe,AddLocalFile:gLe,RecentFiles:yLe,Attachments:bLe,APIKey:vLe,NewChat:wLe,AskAI:xLe,Analyzing:SLe,AIWouldLikeUseThisTool:_Le,ReviewEachAction:CLe,AlwaysAllow:ALe,Deny:ELe,Allow:kLe,ToolCallArguments:TLe,ToolCallResult:RLe,ToolExecuted:MLe,Confirmation:OLe,SelectModel:PLe,CustomServersDescription:DLe,EditConfiguration:ILe,EnterYourJSONConfiguration:LLe,AvailableTools:NLe,Tools:$Le,ToolsEnabled:jLe,EnableAllTools:BLe,DisableAllTools:FLe,Restart:zLe,Logs:VLe,CopyToClipboard:ULe,Close:HLe,WebSearch:WLe,WebSearchDescription:qLe,ResetSettings:GLe,WebSearchEngine:KLe,SelectEngine:YLe,AllTools:XLe,EnableWebSearch:JLe,WantDeleteServer:QLe,NoModelsAvailable:ZLe,CheckInfo:eNe},nNe="Agent IA",rNe="Paramètres de l'agent IA",iNe="Paramètres",sNe="Connectez un modèle d'IA pour commencer",oNe="Aucun modèle d'IA n'est encore connecté. Associez un modèle pour commencer à interagir avec lui directement dans l'interface.",aNe="Connecter un modèle d'IA",lNe="Historique de chat",cNe="Il n'y a pas encore d'historique de chat...",uNe="Choisissez comment connecter l'IA",hNe="Sélectionnez comment vous souhaitez activer les fonctionnalités IA dans ONLYOFFICE.",fNe="Vous pouvez soit utiliser le Wallet intégré pour démarrer rapidement, soit connecter votre propre modèle d'IA à l'aide d'une clé API ou d'un modèle hébergé localement.",dNe="Wallet ONLYOFFICE",pNe="Rechargez votre solde avec une carte et utilisez instantanément toutes les fonctionnalités de l'IA.",mNe="Votre fournisseur d'IA",gNe="Connectez votre propre source d'IA, soit via une clé API fournie par un fournisseur, soit via un modèle hébergé localement.",yNe="Enregistrez et connectez votre Wallet",bNe="Ajouter un fournisseur",vNe="Connexion",wNe="Serveurs MCP",xNe="Fournisseur d'IA",SNe="Modifier le fournisseur d'IA",_Ne="Fournisseur",CNe="Nom",ANe="URL",ENe="Saisissez le nom",kNe="Saisissez l'URL",TNe="Clé API",RNe="Saisissez la clé API",MNe="Annuler",ONe="Enregistrer",PNe="Modifier",DNe="Supprimer",INe="Avertissement",LNe="Souhaitez-vous vraiment supprimer ce fournisseur ?",NNe="Souhaitez-vous vraiment supprimer ce chat ?",$Ne="Oui",jNe="Non",BNe="Comment puis-je vous aider ?",FNe="Chat Al gratuit, assistant de rédaction et générateur d'idées",zNe="Renommer",VNe="Télécharger",UNe="Recherche...",HNe="Ajout d'un fichier local...",WNe="Fichiers récents",qNe="Pièces jointes",GNe="Clé API",KNe="Nouveau chat",YNe="Demander à l'IA",XNe="Analyse en cours...",JNe="lA aimerait utiliser cet outil :",QNe="Examinez attentivement chaque action avant de l'approuver. Nous ne pouvons garantir la sécurité ou les pratiques de confidentialité des intégrations tierces.",ZNe="Toujours autoriser cet outil à effectuer cette action sans demander à nouveau",e3e="Refuser",t3e="Autoriser",n3e="Arguments d'appel d'outil",r3e="Résultat de l'appel de l'outil",i3e="Outil exécuté",s3e="Confirmation",o3e="Sélectionner le modèle",a3e=" Cette section vous permet de configurer les serveurs MCP à utiliser dans l'agent IA. Vous pouvez modifier la configuration pour ajouter de nouveaux serveurs MCP et activer les outils selon vos besoins.",l3e="Modifier la configuration",c3e="Entrez votre configuration JSON :",u3e="Outils disponibles",h3e="outils",f3e="outils activés",d3e="Activer tous les outils",p3e="Désactiver tous les outils",m3e="Redémarrer",g3e="Logs",y3e="Copier dans le presse-papiers",b3e="Fermer",v3e="Recherche sur le Web",w3e="Connectez un moteur de recherche Web pour améliorer les conversations IA grâce à des informations en temps réel provenant d'Internet.",x3e="Réinitialiser les paramètres",S3e="Moteur de recherche Web",_3e="Sélectionner le moteur",C3e="Tous les outils",A3e="Activer la recherche Web dans les paramètres",E3e="Ce serveur sera supprimé de votre liste. Continuer ?",k3e="Fournisseur indisponible",T3e="Le chatbot IA peut faire des erreurs. Vérifiez les informations importantes.",R3e={AIAgent:nNe,AIAgentSettings:rNe,Settings:iNe,ConnectAIModel:sNe,ConnectAIModelDescription:oNe,ConnectAIModelBtn:aNe,ChatHistory:lNe,NoChatYet:cNe,ChooseHowConnect:uNe,SelectHowConnect:hNe,SelectHowConnectDescription:fNe,ONLYOFFICEWallet:dNe,ONLYOFFICEWalletDescription:pNe,AIProviders:mNe,AIProvidersDescription:gNe,RegisterConnectWallet:yNe,AddProvider:bNe,Connection:vNe,MCPServers:wNe,AIProvider:xNe,EditAIProvider:SNe,Provider:_Ne,Name:CNe,URL:ANe,EnterName:ENe,EnterURL:kNe,Key:TNe,EnterKey:RNe,Cancel:MNe,Save:ONe,Edit:PNe,Delete:DNe,Warning:INe,WantDeleteProvider:LNe,WantDeleteChat:NNe,Yes:$Ne,No:jNe,WelcomeTitle:BNe,WelcomeDescription:FNe,Rename:zNe,Download:VNe,Search:UNe,AddLocalFile:HNe,RecentFiles:WNe,Attachments:qNe,APIKey:GNe,NewChat:KNe,AskAI:YNe,Analyzing:XNe,AIWouldLikeUseThisTool:JNe,ReviewEachAction:QNe,AlwaysAllow:ZNe,Deny:e3e,Allow:t3e,ToolCallArguments:n3e,ToolCallResult:r3e,ToolExecuted:i3e,Confirmation:s3e,SelectModel:o3e,CustomServersDescription:a3e,EditConfiguration:l3e,EnterYourJSONConfiguration:c3e,AvailableTools:u3e,Tools:h3e,ToolsEnabled:f3e,EnableAllTools:d3e,DisableAllTools:p3e,Restart:m3e,Logs:g3e,CopyToClipboard:y3e,Close:b3e,WebSearch:v3e,WebSearchDescription:w3e,ResetSettings:x3e,WebSearchEngine:S3e,SelectEngine:_3e,AllTools:C3e,EnableWebSearch:A3e,WantDeleteServer:E3e,NoModelsAvailable:k3e,CheckInfo:T3e},M3e="Agente AI",O3e="Impostazioni agente AI",P3e="Impostazioni",D3e="Collega un modello AI per iniziare",I3e="Nessun modello AI è stato collegato. Collega un modello per iniziare a interagire direttamente da questa interfaccia.",L3e="Collega un modello AI",N3e="Cronologia chat",$3e="Non c'è ancora alcuna cronologia chat...",j3e="Scegli come collegare l'AI",B3e="Scegli come desideri abilitare le funzionalità AI in ONLYOFFICE.",F3e="Puoi usare il Wallet integrato per iniziare subito oppure collegare il tuo modello AI tramite una chiave API o un modello ospitato localmente.",z3e="Wallet ONLYOFFICE",V3e="Ricarica il saldo con una carta e usa subito tutte le funzioni AI.",U3e="Il tuo provider AI",H3e="Collega la tua fonte AI tramite chiave API di un provider o modello ospitato localmente.",W3e="Registrati e collega il Wallet",q3e="Aggiungi provider",G3e="Connessione",K3e="Server MCP",Y3e="Provider AI",X3e="Modifica provider AI",J3e="Provider",Q3e="Nome",Z3e="URL",e4e="Inserisci nome",t4e="Inserisci URL",n4e="Chiave API",r4e="Inserisci chiave API",i4e="Annulla",s4e="Salva",o4e="Modifica",a4e="Elimina",l4e="Avviso",c4e="Vuoi davvero eliminare questo provider?",u4e="Vuoi davvero eliminare questa chat?",h4e="Sì",f4e="No",d4e="Come posso aiutarti?",p4e="Chat AI gratuita, assistente di scrittura e generatore di idee",m4e="Rinomina",g4e="Scarica",y4e="Cerca...",b4e="Aggiungi file locale...",v4e="File recenti",w4e="Allegati",x4e="Chiave API",S4e="Nuova chat",_4e="Chiedi all'AI",C4e="Analisi in corso...",A4e="L'AI vorrebbe usare questo strumento:",E4e=`Controlla attentamente ogni azione prima di approvarla
Non possiamo garantire la sicurezza o le pratiche sulla privacy delle integrazioni di terze parti.`,k4e="Consenti sempre a questo strumento di eseguire questa azione senza chiedere di nuovo",T4e="Nega",R4e="Consenti",M4e="Argomenti della chiamata dello strumento",O4e="Risultato della chiamata dello strumento",P4e="Strumento eseguito",D4e="Conferma",I4e="Seleziona modello",L4e="Questa sezione consente di configurare i server MCP da usare con l'agente AI. Puoi modificare la configurazione per aggiungere nuovi server MCP e abilitare gli strumenti necessari.",N4e="Modifica configurazione",$4e="Inserisci la tua configurazione JSON:",j4e="Strumenti disponibili",B4e="strumenti",F4e="strumenti abilitati",z4e="Abilita tutti gli strumenti",V4e="Disabilita tutti gli strumenti",U4e="Riavvia",H4e="Log",W4e="Copia negli appunti",q4e="Chiudi",G4e="Ricerca web",K4e="Collega un motore di ricerca web per arricchire le chat AI con informazioni aggiornate da Internet.",Y4e="Reimposta impostazioni",X4e="Motore di ricerca web",J4e="Seleziona motore",Q4e="Tutti gli strumenti",Z4e="Abilita la ricerca web nelle impostazioni",e$e="Questo server verrà rimosso dall'elenco. Continuare?",t$e="Provider non disponibile",n$e="L'AI può commettere errori. Verifica le informazioni importanti.",r$e={AIAgent:M3e,AIAgentSettings:O3e,Settings:P3e,ConnectAIModel:D3e,ConnectAIModelDescription:I3e,ConnectAIModelBtn:L3e,ChatHistory:N3e,NoChatYet:$3e,ChooseHowConnect:j3e,SelectHowConnect:B3e,SelectHowConnectDescription:F3e,ONLYOFFICEWallet:z3e,ONLYOFFICEWalletDescription:V3e,AIProviders:U3e,AIProvidersDescription:H3e,RegisterConnectWallet:W3e,AddProvider:q3e,Connection:G3e,MCPServers:K3e,AIProvider:Y3e,EditAIProvider:X3e,Provider:J3e,Name:Q3e,URL:Z3e,EnterName:e4e,EnterURL:t4e,Key:n4e,EnterKey:r4e,Cancel:i4e,Save:s4e,Edit:o4e,Delete:a4e,Warning:l4e,WantDeleteProvider:c4e,WantDeleteChat:u4e,Yes:h4e,No:f4e,WelcomeTitle:d4e,WelcomeDescription:p4e,Rename:m4e,Download:g4e,Search:y4e,AddLocalFile:b4e,RecentFiles:v4e,Attachments:w4e,APIKey:x4e,NewChat:S4e,AskAI:_4e,Analyzing:C4e,AIWouldLikeUseThisTool:A4e,ReviewEachAction:E4e,AlwaysAllow:k4e,Deny:T4e,Allow:R4e,ToolCallArguments:M4e,ToolCallResult:O4e,ToolExecuted:P4e,Confirmation:D4e,SelectModel:I4e,CustomServersDescription:L4e,EditConfiguration:N4e,EnterYourJSONConfiguration:$4e,AvailableTools:j4e,Tools:B4e,ToolsEnabled:F4e,EnableAllTools:z4e,DisableAllTools:V4e,Restart:U4e,Logs:H4e,CopyToClipboard:W4e,Close:q4e,WebSearch:G4e,WebSearchDescription:K4e,ResetSettings:Y4e,WebSearchEngine:X4e,SelectEngine:J4e,AllTools:Q4e,EnableWebSearch:Z4e,WantDeleteServer:e$e,NoModelsAvailable:t$e,CheckInfo:n$e},i$e="Asystent AI",s$e="Ustawienia asystenta AI",o$e="Ustawienia",a$e="Podłącz model AI, aby rozpocząć",l$e="Nie podłączono jeszcze żadnego modelu AI. Podłącz model, aby rozpocząć interakcje z nim bezpośrednio w interfejsie.",c$e="Podłącz model AI",u$e="Historia czatów",h$e="Nie ma jeszcze historii czatów...",f$e="Wybierz, jak podłączyć AI",d$e="Wybierz, jak chcesz włączyć funkcje AI w ONLYOFFICE.",p$e="Użyj wbudowanego Portfela, aby szybko rozpocząć pracę bądź skonfiguruj własny model AI za pomocą klucza API lub lokalnie hostowanego modelu.",m$e="Portfel ONLYOFFICE",g$e="Zasil saldo kartą, aby uzyskać natychmiastowy dostęp do wszystkich funkcji AI.",y$e="Twój dostawca AI",b$e="Skonfiguruj własne źródło AI za pomocą klucza API od usługodawcy lub łącząc się z lokalnie hostowanym modelem.",v$e="Zarejestruj się i Podłącz Portfel",w$e="Dodaj dostawcę",x$e="Połączenie",S$e="Serwery MCP",_$e="Dostawca AI",C$e="Edytuj dostawcę AI",A$e="Dostawca",E$e="Nazwa",k$e="URL",T$e="Wpisz nazwę",R$e="Wpisz adres URL",M$e="Klucz API",O$e="Wpisz klucz API",P$e="Anuluj",D$e="Zapisz",I$e="Edytuj",L$e="Usuń",N$e="Uwaga",$$e="Czy na pewno chcesz usunąć tego dostawcę?",j$e="Czy na pewno chcesz usunąć ten czat?",B$e="Tak",F$e="Nie",z$e="Jak mogę pomóc?",V$e="Darmowy czat AI, asystent pisania i generator pomysłów",U$e="Zmień nazwę",H$e="Pobierz",W$e="Wyszukaj...",q$e="Dodaj plik lokalny...",G$e="Ostatnie pliki",K$e="Załączniki",Y$e="Klucz API",X$e="Nowy czat",J$e="Zapytaj AI",Q$e="Analizowanie...",Z$e="AI chce skorzystać z tego narzędzia:",e5e=`Sprawdź każde działanie przed zatwierdzeniem
Nie gwarantujemy bezpieczeństwa ani prywatności w integracjach z podmiotami trzecimi.`,t5e="Zawsze zezwalaj narzędziu na to działanie bez ponownego pytania",n5e="Odmów",r5e="Zezwól",i5e="Parametry wywołania narzędzia",s5e="Rezultat wywołania narzędzia",o5e="Działanie narzędzia zakończone",a5e="Potwierdzenie",l5e="Wybierz model",c5e="Dana sekcja umożliwia konfigurację serwerów MCP dla asystenta AI. Możesz edytować konfigurację, dodając nowe serwery MCP i włączając potrzebne narzędzia.",u5e="Edytuj konfigurację",h5e="Wpisz swoją konfigurację JSON:",f5e="Dostępne narzędzia",d5e="narzędzia",p5e="włączone narzędzia",m5e="Włącz wszystkie narzędzia",g5e="Wyłącz wszystkie narzędzia",y5e="Uruchom ponownie",b5e="Logi",v5e="Skopiuj do schowka",w5e="Zamknij",x5e="Wyszukiwanie w internecie",S5e="Podłącz wyszukiwarkę, aby wzbogacić czat AI o najnowsze informacje z internetu.",_5e="Resetuj ustawienia",C5e="Wyszukiwarka internetowa",A5e="Wybierz wyszukiwarkę",E5e="Wszystkie narzędzia",k5e="Włącz wyszukiwanie w internecie w ustawieniach",T5e="Serwer zostanie usunięty z Twojej listy. Kontynuować?",R5e="Dostawca jest niedostępny",M5e="Czat AI może popełniać błędy. Sprawdź ważne informacje.",O5e={AIAgent:i$e,AIAgentSettings:s$e,Settings:o$e,ConnectAIModel:a$e,ConnectAIModelDescription:l$e,ConnectAIModelBtn:c$e,ChatHistory:u$e,NoChatYet:h$e,ChooseHowConnect:f$e,SelectHowConnect:d$e,SelectHowConnectDescription:p$e,ONLYOFFICEWallet:m$e,ONLYOFFICEWalletDescription:g$e,AIProviders:y$e,AIProvidersDescription:b$e,RegisterConnectWallet:v$e,AddProvider:w$e,Connection:x$e,MCPServers:S$e,AIProvider:_$e,EditAIProvider:C$e,Provider:A$e,Name:E$e,URL:k$e,EnterName:T$e,EnterURL:R$e,Key:M$e,EnterKey:O$e,Cancel:P$e,Save:D$e,Edit:I$e,Delete:L$e,Warning:N$e,WantDeleteProvider:$$e,WantDeleteChat:j$e,Yes:B$e,No:F$e,WelcomeTitle:z$e,WelcomeDescription:V$e,Rename:U$e,Download:H$e,Search:W$e,AddLocalFile:q$e,RecentFiles:G$e,Attachments:K$e,APIKey:Y$e,NewChat:X$e,AskAI:J$e,Analyzing:Q$e,AIWouldLikeUseThisTool:Z$e,ReviewEachAction:e5e,AlwaysAllow:t5e,Deny:n5e,Allow:r5e,ToolCallArguments:i5e,ToolCallResult:s5e,ToolExecuted:o5e,Confirmation:a5e,SelectModel:l5e,CustomServersDescription:c5e,EditConfiguration:u5e,EnterYourJSONConfiguration:h5e,AvailableTools:f5e,Tools:d5e,ToolsEnabled:p5e,EnableAllTools:m5e,DisableAllTools:g5e,Restart:y5e,Logs:b5e,CopyToClipboard:v5e,Close:w5e,WebSearch:x5e,WebSearchDescription:S5e,ResetSettings:_5e,WebSearchEngine:C5e,SelectEngine:A5e,AllTools:E5e,EnableWebSearch:k5e,WantDeleteServer:T5e,NoModelsAvailable:R5e,CheckInfo:M5e},P5e="Agente de IA",D5e="Configurações do agente de IA",I5e="Configurações",L5e="Conecte um modelo de IA para começar",N5e="Nenhum modelo de IA está conectado ainda. Conecte um modelo para começar a interagir com ele aqui mesmo na interface.",$5e="Conectar um modelo de IA",j5e="Histórico do bate-papo",B5e="Ainda não há histórico de bate-papo...",F5e="Escolha como conectar a IA",z5e="Selecione como deseja ativar os recursos de IA no ONLYOFFICE.",V5e="Você pode usar a carteira integrada para começar rapidamente ou conectar seu próprio modelo de IA usando uma chave de API ou um modelo hospedado localmente.",U5e="Carteira ONLYOFFICE",H5e="Recarregue seu saldo com um cartão e use instantaneamente todos os recursos de IA.",W5e="Seu provedor de IA",q5e="Conecte sua própria fonte de IA — seja por meio de uma chave de API de um provedor ou um modelo hospedado localmente.",G5e="Registre e conecte sua carteira",K5e="Adicionar provedor",Y5e="Conexão",X5e="Servidores MCP",J5e="Provedor de IA",Q5e="Editar provedor de IA",Z5e="Fornecedor",eje="Nome",tje="URL",nje="Digite o nome",rje="Inserir URL",ije="Chave de API",sje="Cancelar",oje="Salvar",aje="Editar",lje="Excluir",cje="Aviso",uje="Tem certeza de que deseja excluir este provedor?",hje="Tem certeza de que deseja excluir este chat?",fje="Sim",dje="Não",pje="Como posso ajudar?",mje="Chat gratuito com IA, assistente de escrita e gerador de ideias",gje="Renomear",yje="Baixar",bje="Pesquisar...",vje="Adicionar arquivo local...",wje="Arquivos recentes",xje="Anexos",Sje="Chave de API",_je="Novo bate-papo",Cje="Pergunte à IA",Aje="Analisando...",Eje="Al gostaria de usar esta ferramenta:",kje="Analise cada ação cuidadosamente antes de aprová-la. Não podemos garantir a segurança ou as práticas de privacidade de integrações de terceiros.",Tje="Permitir que esta ferramenta execute esta ação sem perguntar novamente",Rje="Negar",Mje="Permitir",Oje="Argumentos da chamada da ferramenta",Pje="Resultado da chamada da ferramenta",Dje="Ferramenta executada",Ije="Confirmação",Lje="Selecionar modelo",Nje="Esta seção permite configurar servidores MCP para uso no agente de IA. Você pode editar a configuração para adicionar novos servidores MCP e habilitar ferramentas conforme necessário.",$je="Editar configuração",jje="Digite sua configuração JSON:",Bje="Ferramentas disponíveis",Fje="ferramentas",zje="ferramentas ativadas",Vje="Ativar todas as ferramentas",Uje="Desativar todas as ferramentas",Hje="Reiniciar",Wje="Registros",qje="Copiar para a área de transferência",Gje="Fechar",Kje="Busca na Web",Yje="Conecte um mecanismo de busca na web para aprimorar bate-papos com IA com informações em tempo real da internet.",Xje="Redefinir configurações",Jje="Mecanismo de busca na Web",Qje="Selecionar motor",Zje="Todas as ferramentas",eBe="Ativar pesquisa na Web nas configurações",tBe="Este servidor será removido da sua lista. Deseja continuar ?",nBe="Fornecedor não disponível",rBe="IA Bater papo Podem ocorrer erros. Verifique informações importantes.",iBe={AIAgent:P5e,AIAgentSettings:D5e,Settings:I5e,ConnectAIModel:L5e,ConnectAIModelDescription:N5e,ConnectAIModelBtn:$5e,ChatHistory:j5e,NoChatYet:B5e,ChooseHowConnect:F5e,SelectHowConnect:z5e,SelectHowConnectDescription:V5e,ONLYOFFICEWallet:U5e,ONLYOFFICEWalletDescription:H5e,AIProviders:W5e,AIProvidersDescription:q5e,RegisterConnectWallet:G5e,AddProvider:K5e,Connection:Y5e,MCPServers:X5e,AIProvider:J5e,EditAIProvider:Q5e,Provider:Z5e,Name:eje,URL:tje,EnterName:nje,EnterURL:rje,Key:ije,"EnterKey ":"Insira a chave da API",Cancel:sje,Save:oje,Edit:aje,Delete:lje,Warning:cje,WantDeleteProvider:uje,WantDeleteChat:hje,Yes:fje,No:dje,WelcomeTitle:pje,WelcomeDescription:mje,Rename:gje,Download:yje,Search:bje,AddLocalFile:vje,RecentFiles:wje,Anexos:xje,APIKey:Sje,Attachments:_je,AskAI:Cje,Analyzing:Aje,AIWouldLikeUseThisTool:Eje,ReviewEachAction:kje,AlwaysAllow:Tje,Deny:Rje,Allow:Mje,ToolCallArguments:Oje,ToolCallResult:Pje,ToolExecuted:Dje,Confirmation:Ije,SelectModel:Lje,CustomServersDescription:Nje,EditConfiguration:$je,EnterYourJSONConfiguration:jje,AvailableTools:Bje,Tools:Fje,ToolsEnabled:zje,EnableAllTools:Vje,DisableAllTools:Uje,Restart:Hje,Logs:Wje,CopyToClipboard:qje,Close:Gje,WebSearch:Kje,WebSearchDescription:Yje,ResetSettings:Xje,WebSearchEngine:Jje,SelectEngine:Qje,AllTools:Zje,EnableWebSearch:eBe,WantDeleteServer:tBe,NoModelsAvailable:nBe,CheckInfo:rBe},sBe="Agent AI",oBe="Nastavenia agenta AI",aBe="Nastavenia",lBe="Pripojte model AI, aby ste mohli začať",cBe="Zatiaľ nie je pripojený žiadny model AI. Pripojte model AI, aby ste s ním mohli komunikovať priamo v tomto rozhraní.",uBe="Pripojiť model AI",hBe="História chatu",fBe="Zatiaľ tu nie je žiadna história chatu...",dBe="Vyberte spôsob pripojenia AI",pBe="Vyberte, ako chcete povoliť funkcie AI v ONLYOFFICE.",mBe="Môžete použiť ONLYOFFICE Peňaženku pre rýchly začiatok alebo pripojiť vlastný model AI pomocou API kľúča či nainštalovať lokálny model AI.",gBe="ONLYOFFICE Peňaženka",yBe="Dobíjajte svoj kredit pomocou karty a okamžite využívajte všetky funkcie AI.",bBe="Váš provider pre AI",vBe="Pripojte svoj vlastný model AI buď prostredníctvom API kľúča od providera, alebo nainštalujte lokálny model AI",wBe="Registrovať a pripojiť Peňaženku",xBe="Pridať providera",SBe="Pripojenie",_Be="MCP Servery",CBe="AI Provider",ABe="Upraviť AI Providera",EBe="Provider",kBe="Názov",TBe="URL",RBe="Zadať názov",MBe="Zadať URL",OBe="API kľúč",PBe="Zadať API kľúč",DBe="Zrušiť",IBe="Uložiť",LBe="Upraviť",NBe="Vymazať",$Be="Upozornenie",jBe="Naozaj chcete vymazať tohto providera?",BBe="Naozaj chcete vymazať tento chat?",FBe="Áno",zBe="Nie",VBe="Ako môžem pomôcť?",UBe="Bezplatný AI chat, asistent na písanie textov a generátor nápadov.",HBe="Premenovať",WBe="Stiahnuť",qBe="Hľadať...",GBe="Pridať lokálny súbor...",KBe="Nedávne súbory",YBe="Prílohy",XBe="API kľúč",JBe="Nový chat",QBe="Opýtať sa AI",ZBe="Prebieha analýza...",e8e="Al by chcel použiť tento nástroj:",t8e=`Pred schválením starostlivo skontrolujte každú akciu
Nemôžeme zaručiť bezpečnosť ani dodržiavanie zásad ochrany osobných údajov v prípade integrovaného softvéru od tretích strán.`,n8e="Vždy povoliť tomuto nástroju vykonať túto akciu bez opýtania",r8e="Odmietnuť",i8e="Povoliť",s8e="Argumenty volania nástroja",o8e="Výsledok volania nástroja",a8e="Nástroj vykonaný",l8e="Potvrdenie",c8e="Vybrať model",u8e="V tejto sekcii môžete nakonfigurovať servery MCP, ktoré sa budú používať v AI agente. Môžete upraviť konfiguráciu, pridať nové servery MCP a zapnúť potrebné nástroje.",h8e="Upraviť konfiguráciu",f8e="Zadajte svoju konfiguráciu JSON:",d8e="Dostupné nástroje",p8e="nástroje",m8e="povolené nástroje",g8e="Povoliť všetky nástroje",y8e="Vypnúť všetky nástroje",b8e="Reštartovať",v8e="Protokoly",w8e="Kopírovať do schránky",x8e="Zatvoriť",S8e="Hľadať na webe",_8e="Pripojte webový vyhľadávač, aby mohol AI chat využívať aktuálne údaje z internetu v reálnom čase.",C8e="Obnoviť nastavenia",A8e="Webový vyhľadávač",E8e="Vybrať vyhľadávač",k8e="Všetky nástroje",T8e="Povoliť vyhľadávanie na webe v nastaveniach",R8e="Tento server bude odstránený z vášho zoznamu. Pokračovať?",M8e="Provider nie je dostupný",O8e="AI chat môže robiť chyby. Kontrolujte dôležité informácie.",P8e={AIAgent:sBe,AIAgentSettings:oBe,Settings:aBe,ConnectAIModel:lBe,ConnectAIModelDescription:cBe,ConnectAIModelBtn:uBe,ChatHistory:hBe,NoChatYet:fBe,ChooseHowConnect:dBe,SelectHowConnect:pBe,SelectHowConnectDescription:mBe,ONLYOFFICEWallet:gBe,ONLYOFFICEWalletDescription:yBe,AIProviders:bBe,AIProvidersDescription:vBe,RegisterConnectWallet:wBe,AddProvider:xBe,Connection:SBe,MCPServers:_Be,AIProvider:CBe,EditAIProvider:ABe,Provider:EBe,Name:kBe,URL:TBe,EnterName:RBe,EnterURL:MBe,Key:OBe,EnterKey:PBe,Cancel:DBe,Save:IBe,Edit:LBe,Delete:NBe,Warning:$Be,WantDeleteProvider:jBe,WantDeleteChat:BBe,Yes:FBe,No:zBe,WelcomeTitle:VBe,WelcomeDescription:UBe,Rename:HBe,Download:WBe,Search:qBe,AddLocalFile:GBe,RecentFiles:KBe,Attachments:YBe,APIKey:XBe,NewChat:JBe,AskAI:QBe,Analyzing:ZBe,AIWouldLikeUseThisTool:e8e,ReviewEachAction:t8e,AlwaysAllow:n8e,Deny:r8e,Allow:i8e,ToolCallArguments:s8e,ToolCallResult:o8e,ToolExecuted:a8e,Confirmation:l8e,SelectModel:c8e,CustomServersDescription:u8e,EditConfiguration:h8e,EnterYourJSONConfiguration:f8e,AvailableTools:d8e,Tools:p8e,ToolsEnabled:m8e,EnableAllTools:g8e,DisableAllTools:y8e,Restart:b8e,Logs:v8e,CopyToClipboard:w8e,Close:x8e,WebSearch:S8e,WebSearchDescription:_8e,ResetSettings:C8e,WebSearchEngine:A8e,SelectEngine:E8e,AllTools:k8e,EnableWebSearch:T8e,WantDeleteServer:R8e,NoModelsAvailable:M8e,CheckInfo:O8e};xr.use(nie).init({resources:{en:{translation:JRe},ru:{translation:AOe},"cs-CZ":{translation:ZPe},de:{translation:kIe},es:{translation:tNe},fr:{translation:R3e},it:{translation:r$e},pl:{translation:O5e},"pt-BR":{translation:iBe},"sl-SI":{translation:P8e}},fallbackLng:"en",interpolation:{escapeValue:!1}});const D8e=()=>{const[t,e]=k.useState(!1),[n,r]=k.useState(!1),{messages:i,stopMessage:s}=Yh(),{providers:o,fetchProvidersModels:a}=rs(),{currentPage:c}=Vm(),{manageToolData:h}=Rs();eTe({isReady:t}),tTe(),nTe({isReady:t});const{onNew:f,convertMessage:d,approveToolCall:m,denyToolCall:y}=Zke({isReady:t});k.useEffect(()=>{o.length&&a()},[o,a]),k.useEffect(()=>{h&&r(!0)},[h]),k.useEffect(()=>(jre().then(()=>e(!0)),()=>{ns.close()}),[]);const b=IY({messages:i,onNew:f,onCancel:async()=>{s()},convertMessage:d,adapters:{attachments:new SY([new bY,new wY])}});return c!=="settings"&&!o.length&&!i.length?C.jsx(h5,{children:C.jsx(rse,{})}):C.jsxs(h5,{children:[C.jsx(RX,{runtime:b,children:c==="settings"?C.jsx(Pme,{}):C.jsx(Tke,{})}),n?C.jsx(Jke,{onAllow:m,onDeny:y,onClose:()=>r(!1)}):null]})},E5=()=>{let t=document.getElementById("root");if(!t){const e=window.parent.document.querySelector('iframe[name="system_asc.{9DC93CDB-B576-4F0C-B55E-FCC9C48DD777}"]');e&&e.contentDocument&&(t=e.contentDocument.getElementById("root"))}t||(t=document.createElement("div"),t.id="root",document.body.appendChild(t)),t&&!t.hasAttribute("data-react-root")&&(t.setAttribute("data-react-root","true"),FK.createRoot(t).render(C.jsx(k.StrictMode,{children:C.jsx(D8e,{})})))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",E5):E5();