Files
2025-11-17 22:34:19 +08:00

352 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 MK(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 T0=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 RS={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 OK(){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 PK(){return sD||(sD=1,RS.exports=OK()),RS.exports}var C=PK(),MS={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 DK(){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,x={};function S(T,Z,ue){this.props=T,this.context=Z,this.refs=x,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=x,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,de,ke){return ue=ke.ref,{$$typeof:t,type:T,key:Z,ref:ue!==void 0?ue:null,props:ke}}function N(T,Z){return D(T.type,Z,void 0,void 0,void 0,T.props)}function H(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function j(T){var Z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(ue){return Z[ue]})}var V=/\/+/g;function q(T,Z){return typeof T=="object"&&T!==null&&T.key!=null?j(""+T.key):Z.toString(36)}function X(){}function Y(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(X,X):(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 te(T,Z,ue,L,de){var ke=typeof T;(ke==="undefined"||ke==="boolean")&&(T=null);var ye=!1;if(T===null)ye=!0;else switch(ke){case"bigint":case"string":case"number":ye=!0;break;case"object":switch(T.$$typeof){case t:case e:ye=!0;break;case f:return ye=T._init,te(ye(T._payload),Z,ue,L,de)}}if(ye)return de=de(T),ye=L===""?"."+q(T,0):L,P(de)?(ue="",ye!=null&&(ue=ye.replace(V,"$&/")+"/"),te(de,Z,ue,"",function(Pt){return Pt})):de!=null&&(H(de)&&(de=N(de,ue+(de.key==null||T&&T.key===de.key?"":(""+de.key).replace(V,"$&/")+"/")+ye)),Z.push(de)),1;ye=0;var Ee=L===""?".":L+":";if(P(T))for(var Ue=0;Ue<T.length;Ue++)L=T[Ue],ke=Ee+q(L,Ue),ye+=te(L,Z,ue,ke,de);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++),ye+=te(L,Z,ue,ke,de);else if(ke==="object"){if(typeof T.then=="function")return te(Y(T),Z,ue,L,de);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 ye}function z(T,Z,ue){if(T==null)return T;var L=[],de=0;return te(T,L,"","",function(ke){return Z.call(ue,ke,de++)}),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 U=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:z,forEach:function(T,Z,ue){z(T,function(){Z.apply(this,arguments)},ue)},count:function(T){var Z=0;return z(T,function(){Z++}),Z},toArray:function(T){return z(T,function(Z){return Z})||[]},only:function(T){if(!H(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),de=T.key,ke=void 0;if(Z!=null)for(ye in Z.ref!==void 0&&(ke=void 0),Z.key!==void 0&&(de=""+Z.key),Z)!M.call(Z,ye)||ye==="key"||ye==="__self"||ye==="__source"||ye==="ref"&&Z.ref===void 0||(L[ye]=Z[ye]);var ye=arguments.length-2;if(ye===1)L.children=ue;else if(1<ye){for(var Ee=Array(ye),Ue=0;Ue<ye;Ue++)Ee[Ue]=arguments[Ue+2];L.children=Ee}return D(T.type,de,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,de={},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"&&(de[L]=Z[L]);var ye=arguments.length-2;if(ye===1)de.children=ue;else if(1<ye){for(var Ee=Array(ye),Ue=0;Ue<ye;Ue++)Ee[Ue]=arguments[Ue+2];de.children=Ee}if(T&&T.defaultProps)for(L in ye=T.defaultProps,ye)de[L]===void 0&&(de[L]=ye[L]);return D(T,ke,void 0,void 0,null,de)},Je.createRef=function(){return{current:null}},Je.forwardRef=function(T){return{$$typeof:a,render:T}},Je.isValidElement=H,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(),de=O.S;de!==null&&de(ue,L),typeof L=="object"&&L!==null&&typeof L.then=="function"&&L.then(se,U)}catch(ke){U(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 EE(){return aD||(aD=1,MS.exports=DK()),MS.exports}var k=EE();const be=Pc(k),k$=MK({__proto__:null,default:be},[k]);var OS={exports:{}},pd={},PS={exports:{}},DS={};/**
* @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 IK(){return lD||(lD=1,(function(t){function e(z,G){var U=z.length;z.push(G);e:for(;0<U;){var se=U-1>>>1,T=z[se];if(0<i(T,G))z[se]=G,z[U]=T,U=se;else break e}}function n(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var G=z[0],U=z.pop();if(U!==G){z[0]=U;e:for(var se=0,T=z.length,Z=T>>>1;se<Z;){var ue=2*(se+1)-1,L=z[ue],de=ue+1,ke=z[de];if(0>i(L,U))de<T&&0>i(ke,L)?(z[se]=ke,z[de]=U,se=de):(z[se]=L,z[ue]=U,se=ue);else if(de<T&&0>i(ke,U))z[se]=ke,z[de]=U,se=de;else break e}}return G}function i(z,G){var U=z.sortIndex-G.sortIndex;return U!==0?U:z.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,x=!1,S=!1,_=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function P(z){for(var G=n(h);G!==null;){if(G.callback===null)r(h);else if(G.startTime<=z)r(h),G.sortIndex=G.expirationTime,e(c,G);else break;G=n(h)}}function O(z){if(x=!1,P(z),!b)if(n(c)!==null)b=!0,M||(M=!0,q());else{var G=n(h);G!==null&&te(O,G.startTime-z)}}var M=!1,D=-1,N=5,H=-1;function j(){return S?!0:!(t.unstable_now()-H<N)}function V(){if(S=!1,M){var z=t.unstable_now();H=z;var G=!0;try{e:{b=!1,x&&(x=!1,A(D),D=-1),y=!0;var U=m;try{t:{for(P(z),d=n(c);d!==null&&!(d.expirationTime>z&&j());){var se=d.callback;if(typeof se=="function"){d.callback=null,m=d.priorityLevel;var T=se(d.expirationTime<=z);if(z=t.unstable_now(),typeof T=="function"){d.callback=T,P(z),G=!0;break t}d===n(c)&&r(c),P(z)}else r(c);d=n(c)}if(d!==null)G=!0;else{var Z=n(h);Z!==null&&te(O,Z.startTime-z),G=!1}}break e}finally{d=null,m=U,y=!1}G=void 0}}finally{G?q():M=!1}}}var q;if(typeof E=="function")q=function(){E(V)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,Y=X.port2;X.port1.onmessage=V,q=function(){Y.postMessage(null)}}else q=function(){_(V,0)};function te(z,G){D=_(function(){z(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(z){z.callback=null},t.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):N=0<z?Math.floor(1e3/z):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_next=function(z){switch(m){case 1:case 2:case 3:var G=3;break;default:G=m}var U=m;m=G;try{return z()}finally{m=U}},t.unstable_requestPaint=function(){S=!0},t.unstable_runWithPriority=function(z,G){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var U=m;m=z;try{return G()}finally{m=U}},t.unstable_scheduleCallback=function(z,G,U){var se=t.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?se+U:se):U=se,z){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=U+T,z={id:f++,callback:G,priorityLevel:z,startTime:U,expirationTime:T,sortIndex:-1},U>se?(z.sortIndex=U,e(h,z),n(c)===null&&z===n(h)&&(x?(A(D),D=-1):x=!0,te(O,U-se))):(z.sortIndex=T,e(c,z),b||y||(b=!0,M||(M=!0,q()))),z},t.unstable_shouldYield=j,t.unstable_wrapCallback=function(z){var G=m;return function(){var U=m;m=G;try{return z.apply(this,arguments)}finally{m=U}}}})(DS)),DS}var cD;function LK(){return cD||(cD=1,PS.exports=IK()),PS.exports}var IS={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 NK(){if(uD)return cr;uD=1;var t=EE();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 T$(){if(hD)return IS.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(),IS.exports=NK(),IS.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 $K(){if(fD)return pd;fD=1;var t=LK(),e=EE(),n=T$();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 w=v.alternate;if(w===null){if(g=v.return,g!==null){p=g;continue}break}if(v.child===w.child){for(w=v.child;w;){if(w===p)return a(v),l;if(w===g)return a(v),u;w=w.sibling}throw Error(r(188))}if(p.return!==g.return)p=v,g=w;else{for(var R=!1,I=v.child;I;){if(I===p){R=!0,p=v,g=w;break}if(I===g){R=!0,g=v,p=w;break}I=I.sibling}if(!R){for(I=w.child;I;){if(I===p){R=!0,p=w,g=v;break}if(I===g){R=!0,g=w,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"),x=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"),N=Symbol.for("react.lazy"),H=Symbol.for("react.activity"),j=Symbol.for("react.memo_cache_sentinel"),V=Symbol.iterator;function q(l){return l===null||typeof l!="object"?null:(l=V&&l[V]||l["@@iterator"],typeof l=="function"?l:null)}var X=Symbol.for("react.client.reference");function Y(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===X?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case b:return"Fragment";case S:return"Profiler";case x:return"StrictMode";case O:return"Suspense";case M:return"SuspenseList";case H: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:Y(l.type)||"Memo";case N:u=l._payload,l=l._init;try{return Y(l(u))}catch{}}return null}var te=Array.isArray,z=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,U={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 de=Z(null),ke=Z(null),ye=Z(null),Ee=Z(null);function Ue(l,u){switch(L(ye,u),L(ke,l),L(de,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(de),L(de,l)}function Pt(){ue(de),ue(ke),ue(ye)}function Kt(l){l.memoizedState!==null&&L(Ee,l);var u=de.current,p=DP(u,l.type);u!==p&&(L(ke,l),L(de,p))}function Yt(l){ke.current===l&&(ue(de),ue(ke)),Ee.current===l&&(ue(Ee),ld._currentValue=U)}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,me=null;function De(l){if(typeof Mi=="function"&&aa(l),me&&typeof me.setStrictMode=="function")try{me.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,w=l.suspendedLanes,R=l.pingedLanes;l=l.warmLanes;var I=g&134217727;return I!==0?(g=I&~w,g!==0?v=_r(g):(R&=I,R!==0?v=_r(R):p||(p=I&~l,p!==0&&(v=_r(p))))):(I=g&~w,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&w)===0&&(w=v&-v,p=u&-u,w>=p||w===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 Rw(l,u,p,g,v,w){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,F=l.expirationTimes,ee=l.hiddenUpdates;for(p=R&~p;0<p;){var ae=31-$e(p),he=1<<ae;I[ae]=0,F[ae]=-1;var re=ee[ae];if(re!==null)for(ee[ae]=null,ae=0;ae<re.length;ae++){var ie=re[ae];ie!==null&&(ie.lane&=-536870913)}p&=~he}g!==0&&ug(l,g,0),w!==0&&v===0&&l.tag!==0&&(l.suspendedLanes|=w&~(R&~u))}function ug(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 hg(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 fg(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,Mw="__reactListeners$"+sr,ls="__reactHandles$"+sr,dg="__reactResources$"+sr,Ml="__reactMarker$"+sr;function df(l){delete l[Mn],delete l[or],delete l[ff],delete l[Mw],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[dg];return u||(u=l[dg]={hoistableStyles:new Map,hoistableScripts:new Map}),u}function an(l){l[Ml]=!0}var pg=new Set,mg={};function Co(l,u){ri(l,u),ri(l+"Capture",u)}function ri(l,u){for(mg[l]=u,l=0;l<u.length;l++)pg.add(u[l])}var Ow=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]*$"),gg={},yg={};function Pw(l){return er.call(yg,l)?!0:er.call(gg,l)?!1:Ow.test(l)?yg[l]=!0:(gg[l]=!0,!1)}function Vc(l,u,p){if(Pw(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,bg;function Is(l){if(fa===void 0)try{throw Error()}catch(p){var u=p.stack.trim().match(/\n( *(at )?)/);fa=u&&u[1]||"",bg=-1<p.stack.indexOf(`
at`)?" (<anonymous>)":-1<p.stack.indexOf("@")?"@unknown:0:0":""}return`
`+fa+l+bg}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 w=g.DetermineComponentFrameRoot(),R=w[0],I=w[1];if(R&&I){var F=R.split(`
`),ee=I.split(`
`);for(v=g=0;g<F.length&&!F[g].includes("DetermineComponentFrameRoot");)g++;for(;v<ee.length&&!ee[v].includes("DetermineComponentFrameRoot");)v++;if(g===F.length||v===ee.length)for(g=F.length-1,v=ee.length-1;1<=g&&0<=v&&F[g]!==ee[v];)v--;for(;1<=g&&0<=v;g--,v--)if(F[g]!==ee[v]){if(g!==1||v!==1)do if(g--,v--,0>v||F[g]!==ee[v]){var ae=`
`+F[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 Dw(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 vg(l){try{var u="";do u+=Dw(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,w=p.set;return Object.defineProperty(l,u,{configurable:!0,get:function(){return v.call(this)},set:function(R){g=""+R,w.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 wg(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 Iw=/[\n"\\]/g;function jr(l){return l.replace(Iw,function(u){return"\\"+u.charCodeAt(0).toString(16)+" "})}function yf(l,u,p,g,v,w,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&&w!=null&&(l.defaultChecked=!!w),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 Sg(l,u,p,g,v,w,R,I){if(w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(l.type=w),u!=null||p!=null){if(!(w!=="submit"&&w!=="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 _g(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(te(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 Cg=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||Cg.has(u)?u==="float"?l.cssFloat=p:l[u]=(""+p).trim():l[u]=p+"px"}function Ag(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 w in u)u.hasOwnProperty(w)&&Ls(l,w,u[w])}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 Lw=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"]]),Nw=/^[\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 Nw.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 xf(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&&wg(g)}break e;case"textarea":_g(l,p.value,p.defaultValue);break e;case"select":u=p.value,u!=null&&da(l,!!p.multiple,u,!1)}}}var wf=!1;function Yc(l,u,p){if(wf)return l(u,p);wf=!0;try{var g=l(u);return g}finally{if(wf=!1,(Br!==null||pa!==null)&&(a0(),Br&&(u=Br,l=pa,pa=Br=null,xf(u),l)))for(u=0;u<l.length;u++)xf(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,w=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[w-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 $(){return!1}function Q(l){function u(p,g,v,w,R){this._reactName=p,this._targetInst=v,this.type=g,this.nativeEvent=w,this.target=R,this.currentTarget=null;for(var I in l)l.hasOwnProperty(I)&&(p=l[I],this[I]=p?p(w):w[I]);return this.isDefaultPrevented=(w.defaultPrevented!=null?w.defaultPrevented:w.returnValue===!1)?Zc:$,this.isPropagationStopped=$,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:$w,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),Eg=f({},us,{dataTransfer:0}),kg=Q(Eg),Cf=f({},Wt,{relatedTarget:0}),va=Q(Cf),Iq=f({},le,{animationName:0,elapsedTime:0,pseudoElement:0}),Lq=Q(Iq),Nq=f({},le,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),$q=Q(Nq),jq=f({},le,{data:0}),BR=Q(jq),Bq={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Fq={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"},zq={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Vq(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=zq[l])?!!u[l]:!1}function $w(){return Vq}var Uq=f({},Wt,{key:function(l){if(l.key){var u=Bq[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"?Fq[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:$w,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}}),Hq=Q(Uq),Wq=f({},us,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),FR=Q(Wq),qq=f({},Wt,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:$w}),Gq=Q(qq),Kq=f({},le,{propertyName:0,elapsedTime:0,pseudoElement:0}),Yq=Q(Kq),Xq=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}),Jq=Q(Xq),Qq=f({},le,{newState:0,oldState:0}),Zq=Q(Qq),eG=[9,13,27,32],jw=cs&&"CompositionEvent"in window,Af=null;cs&&"documentMode"in document&&(Af=document.documentMode);var tG=cs&&"TextEvent"in window&&!Af,zR=cs&&(!jw||Af&&8<Af&&11>=Af),VR=" ",UR=!1;function HR(l,u){switch(l){case"keyup":return eG.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 nG(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 rG(l,u){if(eu)return l==="compositionend"||!jw&&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 iG={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"?!!iG[l.type]:u==="textarea"}function GR(l,u,p,g){Br?pa?pa.push(g):pa=[g]:Br=g,u=d0(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 sG(l){kP(l,0)}function Tg(l){var u=Oi(l);if(wg(u))return l}function KR(l,u){if(l==="change")return u}var YR=!1;if(cs){var Bw;if(cs){var Fw="oninput"in document;if(!Fw){var XR=document.createElement("div");XR.setAttribute("oninput","return;"),Fw=typeof XR.oninput=="function"}Bw=Fw}else Bw=!1;YR=Bw&&(!document.documentMode||9<document.documentMode)}function JR(){Ef&&(Ef.detachEvent("onpropertychange",QR),kf=Ef=null)}function QR(l){if(l.propertyName==="value"&&Tg(kf)){var u=[];GR(u,kf,l,Kc(l)),Yc(sG,u)}}function oG(l,u,p){l==="focusin"?(JR(),Ef=u,kf=p,Ef.attachEvent("onpropertychange",QR)):l==="focusout"&&JR()}function aG(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return Tg(kf)}function lG(l,u){if(l==="click")return Tg(u)}function cG(l,u){if(l==="input"||l==="change")return Tg(u)}function uG(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var oi=typeof Object.is=="function"?Object.is:uG;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 zw(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 hG=cs&&"documentMode"in document&&11>=document.documentMode,tu=null,Vw=null,Rf=null,Uw=!1;function rM(l,u,p){var g=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Uw||tu==null||tu!==Wc(g)||(g=tu,"selectionStart"in g&&zw(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=d0(Vw,"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")},Hw={},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(Hw[l])return Hw[l];if(!nu[l])return l;var u=nu[l],p;for(p in u)if(u.hasOwnProperty(p)&&p in iM)return Hw[l]=u[p];return l}var sM=Dl("animationend"),oM=Dl("animationiteration"),aM=Dl("animationstart"),fG=Dl("transitionrun"),dG=Dl("transitionstart"),pG=Dl("transitioncancel"),lM=Dl("transitionend"),cM=new Map,Ww="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(" ");Ww.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:vg(u)},uM.set(l,u),u)}return{value:l,source:u,stack:vg(u)}}var Ii=[],ru=0,qw=0;function Rg(){for(var l=ru,u=qw=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 w=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}w!==0&&hM(p,v,w)}}function Mg(l,u,p,g){Ii[ru++]=l,Ii[ru++]=u,Ii[ru++]=p,Ii[ru++]=g,qw|=g,l.lanes|=g,l=l.alternate,l!==null&&(l.lanes|=g)}function Gw(l,u,p,g){return Mg(l,u,p,g),Og(l)}function iu(l,u){return Mg(l,null,null,u),Og(l)}function hM(l,u,p){l.lanes|=p;var g=l.alternate;g!==null&&(g.lanes|=p);for(var v=!1,w=l.return;w!==null;)w.childLanes|=p,g=w.alternate,g!==null&&(g.childLanes|=p),w.tag===22&&(l=w.stateNode,l===null||l._visibility&1||(v=!0)),l=w,w=w.return;return l.tag===3?(w=l.stateNode,v&&u!==null&&(v=31-$e(p),l=w.hiddenUpdates,g=l[v],g===null?l[v]=[u]:g.push(u),u.lane=p|536870912),w):null}function Og(l){if(50<ed)throw ed=0,Z1=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 mG(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 mG(l,u,p,g)}function Kw(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 Pg(l,u,p,g,v,w){var R=0;if(g=l,typeof l=="function")Kw(l)&&(R=1);else if(typeof l=="string")R=yK(l,p,de.current)?26:l==="html"||l==="head"||l==="body"?27:5;else e:switch(l){case H:return l=ai(31,p,u,v),l.elementType=H,l.lanes=w,l;case b:return Il(p.children,v,w,u);case x:R=8,v|=24;break;case S:return l=ai(12,p,u,v|2),l.elementType=S,l.lanes=w,l;case O:return l=ai(13,p,u,v),l.elementType=O,l.lanes=w,l;case M:return l=ai(19,p,u,v),l.elementType=M,l.lanes=w,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 N: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=w,u}function Il(l,u,p,g){return l=ai(7,l,g,u),l.lanes=p,l}function Yw(l,u,p){return l=ai(6,l,null,u),l.lanes=p,l}function Xw(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,Dg=null,Ig=0,Li=[],Ni=0,Ll=null,Eo=1,ko="";function Nl(l,u){ou[au++]=Ig,ou[au++]=Dg,Dg=l,Ig=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 w=32-$e(u)+v;if(30<w){var R=v-v%5;w=(g&(1<<R)-1).toString(32),g>>=R,v-=R,Eo=1<<32-$e(u)+v|p<<v|g,ko=w+l}else Eo=1<<w|p<<v|g,ko=l}function Jw(l){l.return!==null&&(Nl(l,1),dM(l,1,0))}function Qw(l){for(;l===Dg;)Dg=ou[--au],ou[au]=null,Ig=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,Zw=Error(r(519));function jl(l){var u=Error(r(418,""));throw Pf(Di(u,l)),Zw}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),Sg(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=p0),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")||mS(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=vS,vS=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 e1=Z(null),Bl=null,To=null;function xa(l,u,p){L(e1,u._currentValue),u._currentValue=p}function Ro(l){l._currentValue=e1.current,ue(e1)}function t1(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 n1(l,u,p,g){var v=l.child;for(v!==null&&(v.return=l);v!==null;){var w=v.dependencies;if(w!==null){var R=v.child;w=w.firstContext;e:for(;w!==null;){var I=w;w=v;for(var F=0;F<u.length;F++)if(I.context===u[F]){w.lanes|=p,I=w.alternate,I!==null&&(I.lanes|=p),t1(w.return,p,l),g||(R=null);break e}w=I.next}}else if(v.tag===18){if(R=v.return,R===null)throw Error(r(341));R.lanes|=p,w=R.alternate,w!==null&&(w.lanes|=p),t1(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,w=!1;v!==null;){if(!w){if((v.flags&524288)!==0)w=!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&&n1(u,l,p,g),u.flags|=262144}function Lg(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 Ng(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 gG=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()})}},yG=t.unstable_scheduleCallback,bG=t.unstable_NormalPriority,vn={$$typeof:E,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function r1(){return{controller:new gG,data:new Map,refCount:0}}function If(l){l.refCount--,l.refCount===0&&yG(bG,function(){l.controller.abort()})}var Lf=null,i1=0,lu=0,cu=null;function vG(l,u){if(Lf===null){var p=Lf=[];i1=0,lu=oS(),cu={status:"pending",value:void 0,then:function(g){p.push(g)}}}return i1++,u.then(bM,bM),u}function bM(){if(--i1===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=z.S;z.S=function(l,u){typeof u=="object"&&u!==null&&typeof u.then=="function"&&vG(l,u),vM!==null&&vM(l,u)};var zl=Z(null);function s1(){var l=zl.current;return l!==null?l:Dt.pooledCache}function $g(l,u){u===null?L(zl,zl.current):L(zl,u.pool)}function xM(){var l=s1();return l===null?null:{parent:vn._currentValue,pool:l}}var Nf=Error(r(460)),wM=Error(r(474)),jg=Error(r(542)),o1={then:function(){}};function SM(l){return l=l.status,l==="fulfilled"||l==="rejected"}function Bg(){}function _M(l,u,p){switch(p=l[p],p===void 0?l.push(u):p!==u&&(u.then(Bg,Bg),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(Bg,Bg);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===jg)throw Error(r(483))}var wa=!1;function a1(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function l1(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,(xt&2)!==0){var v=g.pending;return v===null?u.next=u:(u.next=v.next,v.next=u),g.pending=u,u=Og(l),hM(l,null,p),u}return Mg(l,g,u,p),Og(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,hg(l,p)}}function c1(l,u){var p=l.updateQueue,g=l.alternate;if(g!==null&&(g=g.updateQueue,p===g)){var v=null,w=null;if(p=p.firstBaseUpdate,p!==null){do{var R={lane:p.lane,tag:p.tag,payload:p.payload,callback:null,next:null};w===null?v=w=R:w=w.next=R,p=p.next}while(p!==null);w===null?v=w=u:w=w.next=u}else v=w=u;p={baseState:g.baseState,firstBaseUpdate:v,lastBaseUpdate:w,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 u1=!1;function Bf(){if(u1){var l=cu;if(l!==null)throw l}}function Ff(l,u,p,g){u1=!1;var v=l.updateQueue;wa=!1;var w=v.firstBaseUpdate,R=v.lastBaseUpdate,I=v.shared.pending;if(I!==null){v.shared.pending=null;var F=I,ee=F.next;F.next=null,R===null?w=ee:R.next=ee,R=F;var ae=l.alternate;ae!==null&&(ae=ae.updateQueue,I=ae.lastBaseUpdate,I!==R&&(I===null?ae.firstBaseUpdate=ee:I.next=ee,ae.lastBaseUpdate=F))}if(w!==null){var he=v.baseState;R=0,ae=ee=F=null,I=w;do{var re=I.lane&-536870913,ie=re!==I.lane;if(ie?(ct&re)===re:(g&re)===re){re!==0&&re===lu&&(u1=!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:wa=!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?(ee=ae=ie,F=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&&(F=he),v.baseState=F,v.firstBaseUpdate=ee,v.lastBaseUpdate=ae,w===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),Fg=Z(0);function TM(l,u){l=No,L(Fg,l),L(uu,u),No=l|u.baseLanes}function h1(){L(Fg,No),L(uu,uu.current)}function f1(){No=Fg.current,ue(uu),ue(Fg)}var Ca=0,et=null,St=null,ln=null,zg=!1,hu=!1,Vl=!1,Vg=0,zf=0,fu=null,wG=0;function tn(){throw Error(r(321))}function d1(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 p1(l,u,p,g,v,w){return Ca=w,et=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,z.H=l===null||l.memoizedState===null?hO:fO,Vl=!1,w=p(g,v),Vl=!1,hu&&(w=MM(u,p,g,v)),RM(l),w}function RM(l){z.H=Kg;var u=St!==null&&St.next!==null;if(Ca=0,ln=St=et=null,zg=!1,zf=0,fu=null,u)throw Error(r(300));l===null||Pn||(l=l.dependencies,l!==null&&Lg(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 w=l.updateQueue;w.lastEffect=null,w.events=null,w.stores=null,w.memoCache!=null&&(w.memoCache.index=0)}z.H=TG,w=u(p,g)}while(hu);return w}function SG(){var l=z.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 m1(){var l=Vg!==0;return Vg=0,l}function g1(l,u,p){u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~p}function y1(l){if(zg){for(l=l.memoizedState;l!==null;){var u=l.queue;u!==null&&(u.pending=null),l=l.next}zg=!1}Ca=0,ln=St=et=null,hu=!1,zf=Vg=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 b1(){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,z.H=u===null||u.memoizedState===null?hO:fO),l}function Ug(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 v1(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=b1(),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]=j;return u.index++,p}function Mo(l,u){return typeof u=="function"?u(l):u}function Hg(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,w=g.pending;if(w!==null){if(v!==null){var R=v.next;v.next=w.next,w.next=R}u.baseQueue=v=w,g.pending=null}if(w=l.baseState,v===null)l.memoizedState=w;else{u=v.next;var I=R=null,F=null,ee=u,ae=!1;do{var he=ee.lane&-536870913;if(he!==ee.lane?(ct&he)===he:(Ca&he)===he){var re=ee.revertLane;if(re===0)F!==null&&(F=F.next={lane:0,revertLane:0,action:ee.action,hasEagerState:ee.hasEagerState,eagerState:ee.eagerState,next:null}),he===lu&&(ae=!0);else if((Ca&re)===re){ee=ee.next,re===lu&&(ae=!0);continue}else he={lane:0,revertLane:ee.revertLane,action:ee.action,hasEagerState:ee.hasEagerState,eagerState:ee.eagerState,next:null},F===null?(I=F=he,R=w):F=F.next=he,et.lanes|=re,Oa|=re;he=ee.action,Vl&&p(w,he),w=ee.hasEagerState?ee.eagerState:p(w,he)}else re={lane:he,revertLane:ee.revertLane,action:ee.action,hasEagerState:ee.hasEagerState,eagerState:ee.eagerState,next:null},F===null?(I=F=re,R=w):F=F.next=re,et.lanes|=he,Oa|=he;ee=ee.next}while(ee!==null&&ee!==u);if(F===null?R=w:F.next=I,!oi(w,l.memoizedState)&&(Pn=!0,ae&&(p=cu,p!==null)))throw p;l.memoizedState=w,l.baseState=R,l.baseQueue=F,g.lastRenderedState=w}return v===null&&(g.lanes=0),[l.memoizedState,g.dispatch]}function w1(l){var u=cn(),p=u.queue;if(p===null)throw Error(r(311));p.lastRenderedReducer=l;var g=p.dispatch,v=p.pending,w=u.memoizedState;if(v!==null){p.pending=null;var R=v=v.next;do w=l(w,R.action),R=R.next;while(R!==v);oi(w,u.memoizedState)||(Pn=!0),u.memoizedState=w,u.baseQueue===null&&(u.baseState=w),p.lastRenderedState=w}return[w,g]}function OM(l,u,p){var g=et,v=cn(),w=bt;if(w){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,Wg(),DM.bind(null,g,v,p,u),null),Dt===null)throw Error(r(349));w||(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=b1(),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 S1(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 _G(l,u,p,g,v){if(Gg(l))throw Error(r(485));if(l=u.action,l!==null){var w={payload:v,action:l,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(R){w.listeners.push(R)}};z.T!==null?p(!0):w.isTransition=!1,g(w),p=u.pending,p===null?(w.next=u.pending=w,jM(u,w)):(w.next=p.next,u.pending=p.next=w)}}function jM(l,u){var p=u.action,g=u.payload,v=l.state;if(u.isTransition){var w=z.T,R={};z.T=R;try{var I=p(v,g),F=z.S;F!==null&&F(R,I),BM(l,u,I)}catch(ee){_1(l,u,ee)}finally{z.T=w}}else try{w=p(v,g),BM(l,u,w)}catch(ee){_1(l,u,ee)}}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 _1(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 _1(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,w=$s;v.nodeType!==8;){if(!w){v=null;break t}if(v=ds(v.nextSibling),v===null){v=null;break t}}w=v.data,v=w==="F!"||w==="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=S1(!1),w=T1.bind(null,et,!1,g.queue),g=Fr(),v={state:u,dispatch:null,action:l,pending:null},g.queue=v,p=_G.bind(null,et,v,w,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=Hg(Mo)[0],typeof u=="object"&&u!==null&&typeof u.then=="function")try{var g=Vf(u)}catch(R){throw R===Nf?jg:R}else g=u;u=cn();var v=u.queue,w=v.dispatch;return p!==u.memoizedState&&(et.flags|=2048,du(9,Wg(),CG.bind(null,v,p),null)),[g,w,l]}function CG(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=b1(),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 Wg(){return{destroy:void 0,resource:void 0}}function GM(){return cn().memoizedState}function qg(l,u,p,g){var v=Fr();g=g===void 0?null:g,et.flags|=l,v.memoizedState=du(1|u,Wg(),p,g)}function Uf(l,u,p,g){var v=cn();g=g===void 0?null:g;var w=v.memoizedState.inst;St!==null&&g!==null&&d1(g,St.memoizedState.deps)?v.memoizedState=du(u,w,p,g):(et.flags|=l,v.memoizedState=du(1|u,w,p,g))}function KM(l,u){qg(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 C1(){}function eO(l,u){var p=cn();u=u===void 0?null:u;var g=p.memoizedState;return u!==null&&d1(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&&d1(u,g[1]))return g[0];if(g=l(),Vl){De(!0);try{l()}finally{De(!1)}}return p.memoizedState=[g,u],g}function A1(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=A1(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 w=G.p;G.p=w!==0&&8>w?w:8;var R=z.T,I={};z.T=I,T1(l,!1,u,p);try{var F=v(),ee=z.S;if(ee!==null&&ee(I,F),F!==null&&typeof F=="object"&&typeof F.then=="function"){var ae=xG(F,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=w,z.T=R}}function AG(){}function E1(l,u,p,g){if(l.tag!==5)throw Error(r(476));var v=iO(l).queue;rO(l,v,u,U,p===null?AG:function(){return sO(l),p(g)})}function iO(l){var u=l.memoizedState;if(u!==null)return u;u={memoizedState:U,baseState:U,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mo,lastRenderedState:U},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 k1(){return lr(ld)}function oO(){return cn().memoizedState}function aO(){return cn().memoizedState}function EG(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:r1()},l.payload=u;return}u=u.return}}function kG(l,u,p){var g=hi();p={lane:g,revertLane:0,action:p,hasEagerState:!1,eagerState:null,next:null},Gg(l)?cO(u,p):(p=Gw(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(Gg(l))cO(u,v);else{var w=l.alternate;if(l.lanes===0&&(w===null||w.lanes===0)&&(w=u.lastRenderedReducer,w!==null))try{var R=u.lastRenderedState,I=w(R,p);if(v.hasEagerState=!0,v.eagerState=I,oi(I,R))return Mg(l,u,v,0),Dt===null&&Rg(),!1}catch{}finally{}if(p=Gw(l,u,v,g),p!==null)return fi(p,l,g),uO(p,u,g),!0}return!1}function T1(l,u,p,g){if(g={lane:2,revertLane:oS(),action:g,hasEagerState:!1,eagerState:null,next:null},Gg(l)){if(u)throw Error(r(479))}else u=Gw(l,p,g,2),u!==null&&fi(u,l,2)}function Gg(l){var u=l.alternate;return l===et||u!==null&&u===et}function cO(l,u){hu=zg=!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,hg(l,p)}}var Kg={readContext:lr,use:Ug,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:Ug,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,qg(4194308,4,QM.bind(null,u,l),p)},useLayoutEffect:function(l,u){return qg(4194308,4,l,u)},useInsertionEffect:function(l,u){qg(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=kG.bind(null,et,l),[g.memoizedState,l]},useRef:function(l){var u=Fr();return l={current:l},u.memoizedState=l},useState:function(l){l=S1(l);var u=l.queue,p=lO.bind(null,et,u);return u.dispatch=p,[l.memoizedState,p]},useDebugValue:C1,useDeferredValue:function(l,u){var p=Fr();return A1(p,l,u)},useTransition:function(){var l=S1(!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 w={value:p,getSnapshot:u};return v.queue=w,KM(IM.bind(null,g,w,l),[l]),g.flags|=2048,du(9,Wg(),DM.bind(null,g,w,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=Vg++,0<p&&(u+="H"+p.toString(32)),u+="»"}else p=wG++,u="«"+u+"r"+p.toString(32)+"»";return l.memoizedState=u},useHostTransitionStatus:k1,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=T1.bind(null,et,!0,p),p.dispatch=u,[l,u]},useMemoCache:v1,useCacheRefresh:function(){return Fr().memoizedState=EG.bind(null,et)}},fO={readContext:lr,use:Ug,useCallback:eO,useContext:lr,useEffect:YM,useImperativeHandle:ZM,useInsertionEffect:XM,useLayoutEffect:JM,useMemo:tO,useReducer:Hg,useRef:GM,useState:function(){return Hg(Mo)},useDebugValue:C1,useDeferredValue:function(l,u){var p=cn();return nO(p,St.memoizedState,l,u)},useTransition:function(){var l=Hg(Mo)[0],u=cn().memoizedState;return[typeof l=="boolean"?l:Vf(l),u]},useSyncExternalStore:OM,useId:oO,useHostTransitionStatus:k1,useFormState:HM,useActionState:HM,useOptimistic:function(l,u){var p=cn();return $M(p,St,l,u)},useMemoCache:v1,useCacheRefresh:aO},TG={readContext:lr,use:Ug,useCallback:eO,useContext:lr,useEffect:YM,useImperativeHandle:ZM,useInsertionEffect:XM,useLayoutEffect:JM,useMemo:tO,useReducer:w1,useRef:GM,useState:function(){return w1(Mo)},useDebugValue:C1,useDeferredValue:function(l,u){var p=cn();return St===null?A1(p,l,u):nO(p,St.memoizedState,l,u)},useTransition:function(){var l=w1(Mo)[0],u=cn().memoizedState;return[typeof l=="boolean"?l:Vf(l),u]},useSyncExternalStore:OM,useId:oO,useHostTransitionStatus:k1,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:v1,useCacheRefresh:aO},pu=null,Wf=0;function Yg(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 Xg(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(K,W){if(l){var J=K.deletions;J===null?(K.deletions=[W],K.flags|=16):J.push(W)}}function p(K,W){if(!l)return null;for(;W!==null;)u(K,W),W=W.sibling;return null}function g(K){for(var W=new Map;K!==null;)K.key!==null?W.set(K.key,K):W.set(K.index,K),K=K.sibling;return W}function v(K,W){return K=Ao(K,W),K.index=0,K.sibling=null,K}function w(K,W,J){return K.index=J,l?(J=K.alternate,J!==null?(J=J.index,J<W?(K.flags|=67108866,W):J):(K.flags|=67108866,W)):(K.flags|=1048576,W)}function R(K){return l&&K.alternate===null&&(K.flags|=67108866),K}function I(K,W,J,ce){return W===null||W.tag!==6?(W=Yw(J,K.mode,ce),W.return=K,W):(W=v(W,J),W.return=K,W)}function F(K,W,J,ce){var Te=J.type;return Te===b?ae(K,W,J.props.children,ce,J.key):W!==null&&(W.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===N&&dO(Te)===W.type)?(W=v(W,J.props),qf(W,J),W.return=K,W):(W=Pg(J.type,J.key,J.props,null,K.mode,ce),qf(W,J),W.return=K,W)}function ee(K,W,J,ce){return W===null||W.tag!==4||W.stateNode.containerInfo!==J.containerInfo||W.stateNode.implementation!==J.implementation?(W=Xw(J,K.mode,ce),W.return=K,W):(W=v(W,J.children||[]),W.return=K,W)}function ae(K,W,J,ce,Te){return W===null||W.tag!==7?(W=Il(J,K.mode,ce,Te),W.return=K,W):(W=v(W,J),W.return=K,W)}function he(K,W,J){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return W=Yw(""+W,K.mode,J),W.return=K,W;if(typeof W=="object"&&W!==null){switch(W.$$typeof){case m:return J=Pg(W.type,W.key,W.props,null,K.mode,J),qf(J,W),J.return=K,J;case y:return W=Xw(W,K.mode,J),W.return=K,W;case N:var ce=W._init;return W=ce(W._payload),he(K,W,J)}if(te(W)||q(W))return W=Il(W,K.mode,J,null),W.return=K,W;if(typeof W.then=="function")return he(K,Yg(W),J);if(W.$$typeof===E)return he(K,Ng(K,W),J);Xg(K,W)}return null}function re(K,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(K,W,""+J,ce);if(typeof J=="object"&&J!==null){switch(J.$$typeof){case m:return J.key===Te?F(K,W,J,ce):null;case y:return J.key===Te?ee(K,W,J,ce):null;case N:return Te=J._init,J=Te(J._payload),re(K,W,J,ce)}if(te(J)||q(J))return Te!==null?null:ae(K,W,J,ce,null);if(typeof J.then=="function")return re(K,W,Yg(J),ce);if(J.$$typeof===E)return re(K,W,Ng(K,J),ce);Xg(K,J)}return null}function ie(K,W,J,ce,Te){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return K=K.get(J)||null,I(W,K,""+ce,Te);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case m:return K=K.get(ce.key===null?J:ce.key)||null,F(W,K,ce,Te);case y:return K=K.get(ce.key===null?J:ce.key)||null,ee(W,K,ce,Te);case N:var rt=ce._init;return ce=rt(ce._payload),ie(K,W,J,ce,Te)}if(te(ce)||q(ce))return K=K.get(J)||null,ae(W,K,ce,Te,null);if(typeof ce.then=="function")return ie(K,W,J,Yg(ce),Te);if(ce.$$typeof===E)return ie(K,W,J,Ng(W,ce),Te);Xg(W,ce)}return null}function We(K,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(K,Pe,J[Ve],ce);if(mt===null){Pe===null&&(Pe=In);break}l&&Pe&&mt.alternate===null&&u(K,Pe),W=w(mt,W,Ve),rt===null?Te=mt:rt.sibling=mt,rt=mt,Pe=In}if(Ve===J.length)return p(K,Pe),bt&&Nl(K,Ve),Te;if(Pe===null){for(;Ve<J.length;Ve++)Pe=he(K,J[Ve],ce),Pe!==null&&(W=w(Pe,W,Ve),rt===null?Te=Pe:rt.sibling=Pe,rt=Pe);return bt&&Nl(K,Ve),Te}for(Pe=g(Pe);Ve<J.length;Ve++)In=ie(Pe,K,Ve,J[Ve],ce),In!==null&&(l&&In.alternate!==null&&Pe.delete(In.key===null?Ve:In.key),W=w(In,W,Ve),rt===null?Te=In:rt.sibling=In,rt=In);return l&&Pe.forEach(function(Fa){return u(K,Fa)}),bt&&Nl(K,Ve),Te}function Fe(K,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(K,Pe,mt.value,ce);if(Fa===null){Pe===null&&(Pe=In);break}l&&Pe&&Fa.alternate===null&&u(K,Pe),W=w(Fa,W,Ve),rt===null?Te=Fa:rt.sibling=Fa,rt=Fa,Pe=In}if(mt.done)return p(K,Pe),bt&&Nl(K,Ve),Te;if(Pe===null){for(;!mt.done;Ve++,mt=J.next())mt=he(K,mt.value,ce),mt!==null&&(W=w(mt,W,Ve),rt===null?Te=mt:rt.sibling=mt,rt=mt);return bt&&Nl(K,Ve),Te}for(Pe=g(Pe);!mt.done;Ve++,mt=J.next())mt=ie(Pe,K,Ve,mt.value,ce),mt!==null&&(l&&mt.alternate!==null&&Pe.delete(mt.key===null?Ve:mt.key),W=w(mt,W,Ve),rt===null?Te=mt:rt.sibling=mt,rt=mt);return l&&Pe.forEach(function(RK){return u(K,RK)}),bt&&Nl(K,Ve),Te}function Ct(K,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(K,W.sibling),ce=v(W,J.props.children),ce.return=K,K=ce;break e}}else if(W.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===N&&dO(Te)===W.type){p(K,W.sibling),ce=v(W,J.props),qf(ce,J),ce.return=K,K=ce;break e}p(K,W);break}else u(K,W);W=W.sibling}J.type===b?(ce=Il(J.props.children,K.mode,ce,J.key),ce.return=K,K=ce):(ce=Pg(J.type,J.key,J.props,null,K.mode,ce),qf(ce,J),ce.return=K,K=ce)}return R(K);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(K,W.sibling),ce=v(W,J.children||[]),ce.return=K,K=ce;break e}else{p(K,W);break}else u(K,W);W=W.sibling}ce=Xw(J,K.mode,ce),ce.return=K,K=ce}return R(K);case N:return Te=J._init,J=Te(J._payload),Ct(K,W,J,ce)}if(te(J))return We(K,W,J,ce);if(q(J)){if(Te=q(J),typeof Te!="function")throw Error(r(150));return J=Te.call(J),Fe(K,W,J,ce)}if(typeof J.then=="function")return Ct(K,W,Yg(J),ce);if(J.$$typeof===E)return Ct(K,W,Ng(K,J),ce);Xg(K,J)}return typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint"?(J=""+J,W!==null&&W.tag===6?(p(K,W.sibling),ce=v(W,J),ce.return=K,K=ce):(p(K,W),ce=Yw(J,K.mode,ce),ce.return=K,K=ce),R(K)):p(K,W)}return function(K,W,J,ce){try{Wf=0;var Te=Ct(K,W,J,ce);return pu=null,Te}catch(Pe){if(Pe===Nf||Pe===jg)throw Pe;var rt=ai(29,Pe,null,K.mode);return rt.lanes=ce,rt.return=K,rt}finally{}}}var mu=pO(!0),mO=pO(!1),$i=Z(null),js=null;function Aa(l){var u=l.alternate;L(xn,xn.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(xn,xn.current),L($i,l),js===null){var u=l.alternate;u!==null&&u.memoizedState!==null&&(js=l)}}else Ea()}function Ea(){L(xn,xn.current),L($i,$i.current)}function Oo(l){ue($i),js===l&&(js=null),ue(xn)}var xn=Z(0);function Jg(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==="$?"||bS(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 R1(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 M1={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,w,R){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(g,w,R):u.prototype&&u.prototype.isPureReactComponent?!Tf(p,g)||!Tf(v,w):!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&&M1.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 Qg=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){Qg(l)}function xO(l){console.error(l)}function wO(l){Qg(l)}function Zg(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 O1(l,u,p){return p=Sa(p),p.tag=3,p.payload={element:null},p.callback=function(){Zg(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 w=g.value;l.payload=function(){return v(w)},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 RG(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?tS():p.alternate===null&&Jt===0&&(Jt=3),p.flags&=-257,p.flags|=65536,p.lanes=v,g===o1?p.flags|=16384:(u=p.updateQueue,u===null?p.updateQueue=new Set([g]):u.add(g),rS(l,g,v)),!1;case 22:return p.flags|=65536,g===o1?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)),rS(l,g,v)),!1}throw Error(r(435,p.tag))}return rS(l,g,v),tS(),!1}if(bt)return u=$i.current,u!==null?((u.flags&65536)===0&&(u.flags|=256),u.flags|=65536,u.lanes=v,g!==Zw&&(l=Error(r(422),{cause:g}),Pf(Di(l,p)))):(g!==Zw&&(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=O1(l.stateNode,g,v),c1(l,v),Jt!==4&&(Jt=2)),!1;var w=Error(r(520),{cause:g});if(w=Di(w,p),Zf===null?Zf=[w]:Zf.push(w),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=O1(p.stateNode,g,l),c1(p,l),!1;case 1:if(u=p.type,w=p.stateNode,(p.flags&128)===0&&(typeof u.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(Pa===null||!Pa.has(w))))return p.flags|=65536,v&=-v,p.lanes|=v,v=_O(v),CO(v,l,p,g),c1(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 w=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=p1(l,u,p,R,w,v),I=m1(),l!==null&&!Pn?(g1(l,u,v),Po(l,u,v)):(bt&&I&&Jw(u),u.flags|=1,Fn(l,u,g,v),u.child)}function kO(l,u,p,g,v){if(l===null){var w=p.type;return typeof w=="function"&&!Kw(w)&&w.defaultProps===void 0&&p.compare===null?(u.tag=15,u.type=w,TO(l,u,w,g,v)):(l=Pg(p.type,null,g,u,u.mode,v),l.ref=u.ref,l.return=u,u.child=l)}if(w=l.child,!B1(l,v)){var R=w.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(w,g),l.ref=u.ref,l.return=u,u.child=l}function TO(l,u,p,g,v){if(l!==null){var w=l.memoizedProps;if(Tf(w,g)&&l.ref===u.ref)if(Pn=!1,u.pendingProps=g=w,B1(l,v))(l.flags&131072)!==0&&(Pn=!0);else return u.lanes=l.lanes,Po(l,u,v)}return P1(l,u,p,g,v)}function RO(l,u,p){var g=u.pendingProps,v=g.children,w=l!==null?l.memoizedState:null;if(g.mode==="hidden"){if((u.flags&128)!==0){if(g=w!==null?w.baseLanes|p:p,l!==null){for(v=u.child=l.child,w=0;v!==null;)w=w|v.lanes|v.childLanes,v=v.sibling;u.childLanes=w&~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&&$g(u,w!==null?w.cachePool:null),w!==null?TM(u,w):h1(),gO(u);else return u.lanes=u.childLanes=536870912,MO(l,u,w!==null?w.baseLanes|p:p,p)}else w!==null?($g(u,w.cachePool),TM(u,w),Ea(),u.memoizedState=null):(l!==null&&$g(u,null),h1(),Ea());return Fn(l,u,v,p),u.child}function MO(l,u,p,g){var v=s1();return v=v===null?null:{parent:vn._currentValue,pool:v},u.memoizedState={baseLanes:p,cachePool:v},l!==null&&$g(u,null),h1(),gO(u),l!==null&&Df(l,u,g,!0),null}function e0(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 P1(l,u,p,g,v){return Fl(u),p=p1(l,u,p,g,void 0,v),g=m1(),l!==null&&!Pn?(g1(l,u,v),Po(l,u,v)):(bt&&g&&Jw(u),u.flags|=1,Fn(l,u,p,v),u.child)}function OO(l,u,p,g,v,w){return Fl(u),u.updateQueue=null,p=MM(u,g,p,v),RM(l),g=m1(),l!==null&&!Pn?(g1(l,u,w),Po(l,u,w)):(bt&&g&&Jw(u),u.flags|=1,Fn(l,u,p,w),u.child)}function PO(l,u,p,g,v){if(Fl(u),u.stateNode===null){var w=su,R=p.contextType;typeof R=="object"&&R!==null&&(w=lr(R)),w=new p(g,w),u.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,w.updater=M1,u.stateNode=w,w._reactInternals=u,w=u.stateNode,w.props=g,w.state=u.memoizedState,w.refs={},a1(u),R=p.contextType,w.context=typeof R=="object"&&R!==null?lr(R):su,w.state=u.memoizedState,R=p.getDerivedStateFromProps,typeof R=="function"&&(R1(u,p,R,g),w.state=u.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof w.getSnapshotBeforeUpdate=="function"||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(R=w.state,typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount(),R!==w.state&&M1.enqueueReplaceState(w,w.state,null),Ff(u,g,w,v),Bf(),w.state=u.memoizedState),typeof w.componentDidMount=="function"&&(u.flags|=4194308),g=!0}else if(l===null){w=u.stateNode;var I=u.memoizedProps,F=Ul(p,I);w.props=F;var ee=w.context,ae=p.contextType;R=su,typeof ae=="object"&&ae!==null&&(R=lr(ae));var he=p.getDerivedStateFromProps;ae=typeof he=="function"||typeof w.getSnapshotBeforeUpdate=="function",I=u.pendingProps!==I,ae||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(I||ee!==R)&&bO(u,w,g,R),wa=!1;var re=u.memoizedState;w.state=re,Ff(u,g,w,v),Bf(),ee=u.memoizedState,I||re!==ee||wa?(typeof he=="function"&&(R1(u,p,he,g),ee=u.memoizedState),(F=wa||yO(u,p,F,g,re,ee,R))?(ae||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount()),typeof w.componentDidMount=="function"&&(u.flags|=4194308)):(typeof w.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=g,u.memoizedState=ee),w.props=g,w.state=ee,w.context=R,g=F):(typeof w.componentDidMount=="function"&&(u.flags|=4194308),g=!1)}else{w=u.stateNode,l1(l,u),R=u.memoizedProps,ae=Ul(p,R),w.props=ae,he=u.pendingProps,re=w.context,ee=p.contextType,F=su,typeof ee=="object"&&ee!==null&&(F=lr(ee)),I=p.getDerivedStateFromProps,(ee=typeof I=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(R!==he||re!==F)&&bO(u,w,g,F),wa=!1,re=u.memoizedState,w.state=re,Ff(u,g,w,v),Bf();var ie=u.memoizedState;R!==he||re!==ie||wa||l!==null&&l.dependencies!==null&&Lg(l.dependencies)?(typeof I=="function"&&(R1(u,p,I,g),ie=u.memoizedState),(ae=wa||yO(u,p,ae,g,re,ie,F)||l!==null&&l.dependencies!==null&&Lg(l.dependencies))?(ee||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(g,ie,F),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(g,ie,F)),typeof w.componentDidUpdate=="function"&&(u.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof w.componentDidUpdate!="function"||R===l.memoizedProps&&re===l.memoizedState||(u.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||R===l.memoizedProps&&re===l.memoizedState||(u.flags|=1024),u.memoizedProps=g,u.memoizedState=ie),w.props=g,w.state=ie,w.context=F,g=ae):(typeof w.componentDidUpdate!="function"||R===l.memoizedProps&&re===l.memoizedState||(u.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||R===l.memoizedProps&&re===l.memoizedState||(u.flags|=1024),g=!1)}return w=g,e0(l,u),g=(u.flags&128)!==0,w||g?(w=u.stateNode,p=g&&typeof p.getDerivedStateFromError!="function"?null:w.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=w.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 D1={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function I1(l){return{baseLanes:l,cachePool:xM()}}function L1(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,w=(u.flags&128)!==0,R;if((R=w)||(R=l!==null&&l.memoizedState===null?!1:(xn.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,F;if(F=I){e:{for(F=I,I=$s;F.nodeType!==8;){if(!I){I=null;break e}if(F=ds(F.nextSibling),F===null){I=null;break e}}I=F}I!==null?(u.memoizedState={dehydrated:I,treeContext:Ll!==null?{id:Eo,overflow:ko}:null,retryLane:536870912,hydrationErrors:null},F=ai(18,null,null,0),F.stateNode=I,F.return=u,u.child=F,Cr=u,Xt=null,F=!0):F=!1}F||jl(u)}if(I=u.memoizedState,I!==null&&(I=I.dehydrated,I!==null))return bS(I)?u.lanes=32:u.lanes=536870912,null;Oo(u)}return I=g.children,g=g.fallback,v?(Ea(),v=u.mode,I=t0({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=I1(p),v.childLanes=L1(l,R,p),u.memoizedState=D1,g):(Aa(u),N1(u,I))}if(F=l.memoizedState,F!==null&&(I=F.dehydrated,I!==null)){if(w)u.flags&256?(Aa(u),u.flags&=-257,u=$1(l,u,p)):u.memoizedState!==null?(Ea(),u.child=l.child,u.flags|=128,u=null):(Ea(),v=g.fallback,I=u.mode,g=t0({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=I1(p),g.childLanes=L1(l,R,p),u.memoizedState=D1,u=v);else if(Aa(u),bS(I)){if(R=I.nextSibling&&I.nextSibling.dataset,R)var ee=R.dgst;R=ee,g=Error(r(419)),g.stack="",g.digest=R,Pf({value:g,source:null,stack:null}),u=$1(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!==F.retryLane))throw F.retryLane=g,iu(l,g),fi(R,l,g),AO;I.data==="$?"||tS(),u=$1(l,u,p)}else I.data==="$?"?(u.flags|=192,u.child=l.child,u=null):(l=F.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=N1(u,g.children),u.flags|=4096);return u}return v?(Ea(),v=g.fallback,I=u.mode,F=l.child,ee=F.sibling,g=Ao(F,{mode:"hidden",children:g.children}),g.subtreeFlags=F.subtreeFlags&65011712,ee!==null?v=Ao(ee,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=I1(p):(F=I.cachePool,F!==null?(ee=vn._currentValue,F=F.parent!==ee?{parent:ee,pool:ee}:F):F=xM(),I={baseLanes:I.baseLanes|p,cachePool:F}),v.memoizedState=I,v.childLanes=L1(l,R,p),u.memoizedState=D1,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 N1(l,u){return u=t0({mode:"visible",children:u},l.mode),u.return=l,l.child=u}function t0(l,u){return l=ai(22,l,null,u),l.lanes=0,l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},l}function $1(l,u,p){return mu(u,l.child,null,p),l=N1(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),t1(l.return,u,p)}function j1(l,u,p,g,v){var w=l.memoizedState;w===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:g,tail:p,tailMode:v}:(w.isBackwards=u,w.rendering=null,w.renderingStartTime=0,w.last=g,w.tail=p,w.tailMode=v)}function NO(l,u,p){var g=u.pendingProps,v=g.revealOrder,w=g.tail;if(Fn(l,u,g.children,p),g=xn.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(xn,g),v){case"forwards":for(p=u.child,v=null;p!==null;)l=p.alternate,l!==null&&Jg(l)===null&&(v=p),p=p.sibling;p=v,p===null?(v=u.child,u.child=null):(v=p.sibling,p.sibling=null),j1(u,!1,v,p,w);break;case"backwards":for(p=null,v=u.child,u.child=null;v!==null;){if(l=v.alternate,l!==null&&Jg(l)===null){u.child=v;break}l=v.sibling,v.sibling=p,p=v,v=l}j1(u,!0,p,null,w);break;case"together":j1(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 B1(l,u){return(l.lanes&u)!==0?!0:(l=l.dependencies,!!(l!==null&&Lg(l)))}function MG(l,u,p){switch(u.tag){case 3:Ue(u,u.stateNode.containerInfo),xa(u,vn,l.memoizedState.cache),Of();break;case 27:case 5:Kt(u);break;case 4:Ue(u,u.stateNode.containerInfo);break;case 10:xa(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(xn,xn.current),g)break;return null;case 22:case 23:return u.lanes=0,RO(l,u,p);case 24:xa(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(!B1(l,p)&&(u.flags&128)===0)return Pn=!1,MG(l,u,p);Pn=(l.flags&131072)!==0}else Pn=!1,bt&&(u.flags&1048576)!==0&&dM(u,Ig,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")Kw(g)?(l=Ul(g,l),u.tag=1,u=PO(null,u,g,l,p)):(u.tag=0,u=P1(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=Y(g)||g,Error(r(306,u,""))}}return u;case 0:return P1(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 w=u.memoizedState;v=w.element,l1(l,u),Ff(u,g,null,p);var R=u.memoizedState;if(g=R.cache,xa(u,vn,g),g!==w.cache&&n1(u,[vn],p,!0),Bf(),g=R.element,w.isDehydrated)if(w={element:g,isDehydrated:!1,cache:R.cache},u.updateQueue.baseState=w,u.memoizedState=w,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 e0(l,u),l===null?(p=zP(u.type,null,u.pendingProps,null))?u.memoizedState=p:bt||(p=u.type,l=u.pendingProps,g=m0(ye.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,ye.current),Cr=u,$s=!0,v=Xt,La(u.type)?(vS=v,Xt=ds(g.firstChild)):Xt=v),Fn(l,u,u.pendingProps.children,p),e0(l,u),l===null&&(u.flags|=4194304),u.child;case 5:return l===null&&bt&&((v=g=Xt)&&(g=iK(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,w=u.pendingProps,R=l!==null?l.memoizedProps:null,g=w.children,mS(v,w)?g=null:R!==null&&mS(v,R)&&(u.flags|=32),u.memoizedState!==null&&(v=p1(l,u,SG,null,null,p),ld._currentValue=v),e0(l,u),Fn(l,u,g,p),u.child;case 6:return l===null&&bt&&((l=p=Xt)&&(p=sK(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,xa(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=t0(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=s1(),v===null&&(v=Dt,w=r1(),v.pooledCache=w,w.refCount++,w!==null&&(v.pooledCacheLanes|=p),v=w),u.memoizedState={parent:g,cache:v},a1(u),xa(u,vn,v)):((l.lanes&p)!==0&&(l1(l,u),Ff(u,null,null,p),Bf()),v=l.memoizedState,w=u.memoizedState,v.parent!==g?(v={parent:g,cache:g},u.memoizedState=v,u.lanes===0&&(u.memoizedState=u.updateQueue.baseState=v),xa(u,vn,g)):(g=w.cache,xa(u,vn,g),g!==v.cache&&n1(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=o1,wM;l.flags|=8192}}function n0(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 OG(l,u,p){var g=u.pendingProps;switch(Qw(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=ye.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=de.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=de.current,Mf(u))pM(u);else{switch(v=m0(ye.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=ye.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=m0(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 w=null;g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(w=g.memoizedState.cachePool.pool),w!==v&&(g.flags|=2048)}return p!==l&&p&&(u.child.flags|=8192),n0(u,u.updateQueue),qt(u),null;case 4:return Pt(),l===null&&uS(u.stateNode.containerInfo),qt(u),null;case 10:return Ro(u.type),qt(u),null;case 19:if(ue(xn),v=u.memoizedState,v===null)return qt(u),null;if(g=(u.flags&128)!==0,w=v.rendering,w===null)if(g)Gf(v,!1);else{if(Jt!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(w=Jg(l),w!==null){for(u.flags|=128,Gf(v,!1),l=w.updateQueue,u.updateQueue=l,n0(u,l),u.subtreeFlags=0,l=p,p=u.child;p!==null;)fM(p,l),p=p.sibling;return L(xn,xn.current&1|2),u.child}l=l.sibling}v.tail!==null&&nr()>s0&&(u.flags|=128,g=!0,Gf(v,!1),u.lanes=4194304)}else{if(!g)if(l=Jg(w),l!==null){if(u.flags|=128,g=!0,l=l.updateQueue,u.updateQueue=l,n0(u,l),Gf(v,!0),v.tail===null&&v.tailMode==="hidden"&&!w.alternate&&!bt)return qt(u),null}else 2*nr()-v.renderingStartTime>s0&&p!==536870912&&(u.flags|=128,g=!0,Gf(v,!1),u.lanes=4194304);v.isBackwards?(w.sibling=u.child,u.child=w):(l=v.last,l!==null?l.sibling=w:u.child=w,v.last=w)}return v.tail!==null?(u=v.tail,v.rendering=u,v.tail=u.sibling,v.renderingStartTime=nr(),u.sibling=null,l=xn.current,L(xn,g?l&1|2:l&1),u):(qt(u),null);case 22:case 23:return Oo(u),f1(),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&&n0(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 PG(l,u){switch(Qw(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(xn),null;case 4:return Pt(),null;case 10:return Ro(u.type),null;case 22:case 23:return Oo(u),f1(),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(Qw(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(xn);break;case 10:Ro(u.type);break;case 22:case 23:Oo(u),f1(),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 w=p.create,R=p.inst;g=w(),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 w=v.next;g=w;do{if((g.tag&l)===l){var R=g.inst,I=R.destroy;if(I!==void 0){R.destroy=void 0,v=u;var F=p,ee=I;try{ee()}catch(ae){Et(v,F,ae)}}}g=g.next}while(g!==w)}}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 F1(l,u,p){try{var g=l.stateNode;ZG(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 z1(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 V1(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=p0));else if(g!==4&&(g===27&&La(l.type)&&(p=l.stateNode,u=null),l=l.child,l!==null))for(V1(l,u,p),l=l.sibling;l!==null;)V1(l,u,p),l=l.sibling}function r0(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(r0(l,u,p),l=l.sibling;l!==null;)r0(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(w){Et(l,l.return,w)}}var Io=!1,nn=!1,U1=!1,WO=typeof WeakSet=="function"?WeakSet:Set,Dn=null;function DG(l,u){if(l=l.containerInfo,dS=w0,l=nM(l),zw(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,w=g.focusNode;g=g.focusOffset;try{p.nodeType,w.nodeType}catch{p=null;break e}var R=0,I=-1,F=-1,ee=0,ae=0,he=l,re=null;t:for(;;){for(var ie;he!==p||v!==0&&he.nodeType!==3||(I=R+v),he!==w||g!==0&&he.nodeType!==3||(F=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&&++ee===v&&(I=R),re===w&&++ae===g&&(F=R),(ie=he.nextSibling)!==null)break;he=re,re=he.parentNode}he=ie}p=I===-1||F===-1?null:{start:I,end:F}}else p=null}p=p||{start:0,end:0}}else p=null;for(pS={focusedElem:l,selectionRange:p},w0=!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,w=u.alternate,l=u.flags,u.tag){case 0:break;case 11:case 15:break;case 1:if((l&1024)!==0&&w!==null){l=void 0,p=u,v=w.memoizedProps,w=w.memoizedState,g=p.stateNode;try{var We=Ul(p.type,v,p.elementType===p.type);l=g.getSnapshotBeforeUpdate(We,w),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)yS(l);else if(p===1)switch(l.nodeName){case"HEAD":case"HTML":case"BODY":yS(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=VG.bind(null,p),oK(l,p))));break;case 22:if(g=p.memoizedState!==null||Io,!g){u=u!==null&&u.memoizedState!==null||nn,v=Io;var w=nn;Io=g,(nn=u)&&!w?Ra(l,p,(p.subtreeFlags&8772)!==0):Ta(l,p),Io=v,nn=w}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(me&&typeof me.onCommitFiberUnmount=="function")try{me.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(w){Et(p,u,w)}else try{Ft.removeChild(p.stateNode)}catch(w){Et(p,u,w)}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 IG(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 H1(l,u){var p=IG(l);u.forEach(function(g){var v=UG.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],w=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(w,R,v),Ft=null,zr=!1,w=v.alternate,w!==null&&(w.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 w=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":w=v.getElementsByTagName("title")[0],(!w||w[Ml]||w[Mn]||w.namespaceURI==="http://www.w3.org/2000/svg"||w.hasAttribute("itemprop"))&&(w=v.createElement(g),v.head.insertBefore(w,v.querySelector("head > title"))),Vn(w,g,p),w[Mn]=l,an(w),g=w;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(w=R[I],w.getAttribute("href")===(p.href==null||p.href===""?null:p.href)&&w.getAttribute("rel")===(p.rel==null?null:p.rel)&&w.getAttribute("title")===(p.title==null?null:p.title)&&w.getAttribute("crossorigin")===(p.crossOrigin==null?null:p.crossOrigin)){R.splice(I,1);break t}}w=v.createElement(g),Vn(w,g,p),v.head.appendChild(w);break;case"meta":if(R=HP("meta","content",v).get(g+(p.content||""))){for(I=0;I<R.length;I++)if(w=R[I],w.getAttribute("content")===(p.content==null?null:""+p.content)&&w.getAttribute("name")===(p.name==null?null:p.name)&&w.getAttribute("property")===(p.property==null?null:p.property)&&w.getAttribute("http-equiv")===(p.httpEquiv==null?null:p.httpEquiv)&&w.getAttribute("charset")===(p.charSet==null?null:p.charSet)){R.splice(I,1);break t}}w=v.createElement(g),Vn(w,g,p),v.head.appendChild(w);break;default:throw Error(r(468,g))}w[Mn]=l,an(w),g=w}l.stateNode=g}else WP(v,l.type,l.stateNode);else l.stateNode=UP(v,g,l.memoizedProps);else w!==g?(w===null?p.stateNode!==null&&(p=p.stateNode,p.parentNode.removeChild(p)):w.count--,g===null?WP(v,l.type,l.stateNode):UP(v,g,l.memoizedProps)):g===null&&l.stateNode!==null&&F1(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&&F1(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,F1(l,v,p!==null?p.memoizedProps:v)),g&1024&&(U1=!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(b0=null,v=fs,fs=g0(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)}U1&&(U1=!1,JO(l));break;case 4:g=fs,fs=g0(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)&&(X1=nr()),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,H1(l,g)));break;case 22:v=l.memoizedState!==null;var F=p!==null&&p.memoizedState!==null,ee=Io,ae=nn;if(Io=ee||v,nn=ae||F,li(u,l),nn=ae,Io=ee,ci(l),g&8192)e:for(u=l.stateNode,u._visibility=v?u._visibility&-2:u._visibility|1,v&&(p===null||F||Io||nn||Hl(l)),p=null,u=l;;){if(u.tag===5||u.tag===26){if(p===null){F=p=u;try{if(w=F.stateNode,v)R=w.style,typeof R.setProperty=="function"?R.setProperty("display","none","important"):R.display="none";else{I=F.stateNode;var he=F.memoizedProps.style,re=he!=null&&he.hasOwnProperty("display")?he.display:null;I.style.display=re==null||typeof re=="boolean"?"":(""+re).trim()}}catch(ie){Et(F,F.return,ie)}}}else if(u.tag===6){if(p===null){F=u;try{F.stateNode.nodeValue=v?"":F.memoizedProps}catch(ie){Et(F,F.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,H1(l,p))));break;case 19:li(u,l),ci(l),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,H1(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,w=z1(l);r0(l,w,v);break;case 5:var R=p.stateNode;p.flags&32&&(ii(R,""),p.flags&=-33);var I=z1(l);r0(l,I,R);break;case 3:case 4:var F=p.stateNode.containerInfo,ee=z1(l);V1(l,ee,F);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,w=u,R=w.flags;switch(w.tag){case 0:case 11:case 15:Ra(v,w,p),Kf(4,w);break;case 1:if(Ra(v,w,p),g=w,v=g.stateNode,typeof v.componentDidMount=="function")try{v.componentDidMount()}catch(ee){Et(g,g.return,ee)}if(g=w,v=g.updateQueue,v!==null){var I=g.stateNode;try{var F=v.shared.hiddenCallbacks;if(F!==null)for(v.shared.hiddenCallbacks=null,v=0;v<F.length;v++)EM(F[v],I)}catch(ee){Et(g,g.return,ee)}}p&&R&64&&FO(w),Yf(w,w.return);break;case 27:HO(w);case 26:case 5:Ra(v,w,p),p&&g===null&&R&4&&VO(w),Yf(w,w.return);break;case 12:Ra(v,w,p);break;case 13:Ra(v,w,p),p&&R&4&&YO(v,w);break;case 22:w.memoizedState===null&&Ra(v,w,p),Yf(w,w.return);break;case 30:break;default:Ra(v,w,p)}u=u.sibling}}function W1(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 q1(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 w=u.memoizedProps,R=w.id,I=w.onPostCommit;typeof I=="function"&&I(R,u.alternate===null?"mount":"update",l.passiveEffectDuration,-0)}catch(F){Et(u,u.return,F)}}else Fs(l,u,p,g);break;case 13:Fs(l,u,p,g);break;case 23:break;case 22:w=u.stateNode,R=u.alternate,u.memoizedState!==null?w._visibility&2?Fs(l,u,p,g):Xf(l,u):w._visibility&2?Fs(l,u,p,g):(w._visibility|=2,gu(l,u,p,g,(u.subtreeFlags&10256)!==0)),v&2048&&W1(R,u);break;case 24:Fs(l,u,p,g),v&2048&&q1(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 w=l,R=u,I=p,F=g,ee=R.flags;switch(R.tag){case 0:case 11:case 15:gu(w,R,I,F,v),Kf(8,R);break;case 23:break;case 22:var ae=R.stateNode;R.memoizedState!==null?ae._visibility&2?gu(w,R,I,F,v):Xf(w,R):(ae._visibility|=2,gu(w,R,I,F,v)),v&&ee&2048&&W1(R.alternate,R);break;case 24:gu(w,R,I,F,v),v&&ee&2048&&q1(R.alternate,R);break;default:gu(w,R,I,F,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&&W1(g.alternate,g);break;case 24:Xf(p,g),v&2048&&q1(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&&vK(fs,l.memoizedState,l.memoizedProps);break;case 5:yu(l);break;case 3:case 4:var u=fs;fs=g0(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,i0(l)):Qf(l);break;default:Qf(l)}}function i0(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),i0(u);break;case 22:p=u.stateNode,p._visibility&2&&(p._visibility&=-3,i0(u));break;default:i0(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,w=g.return;if(GO(g),g===p){Dn=null;break e}if(v!==null){v.return=w,Dn=v;break e}Dn=w}}}var LG={getCacheForType:function(l){var u=lr(vn),p=u.data.get(l);return p===void 0&&(p=l(),u.data.set(l,p)),p}},NG=typeof WeakMap=="function"?WeakMap:Map,xt=0,Dt=null,ot=null,ct=0,wt=0,ui=null,Ma=!1,bu=!1,G1=!1,No=0,Jt=0,Oa=0,Wl=0,K1=0,ji=0,vu=0,Zf=null,Vr=null,Y1=!1,X1=0,s0=1/0,o0=null,Pa=null,zn=0,Da=null,xu=null,wu=0,J1=0,Q1=null,rP=null,ed=0,Z1=null;function hi(){if((xt&2)!==0&&ct!==0)return ct&-ct;if(z.T!==null){var l=lu;return l!==0?l:oS()}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&&(wt===2||wt===9)||l.cancelPendingCommit!==null)&&(Su(l,0),Ia(l,ct,ji,!1)),as(l,p),((xt&2)===0||l!==Dt)&&(l===Dt&&((xt&2)===0&&(Wl|=p),Jt===4&&Ia(l,ct,ji,!1)),zs(l))}function sP(l,u,p){if((xt&6)!==0)throw Error(r(327));var g=!p&&(u&124)===0&&(u&l.expiredLanes)===0||ir(l,u),v=g?BG(l,u):nS(l,u,!0),w=g;do{if(v===0){bu&&!g&&Ia(l,u,0,!1);break}else{if(p=l.current.alternate,w&&!$G(p)){v=nS(l,u,!1),w=!1;continue}if(v===2){if(w=u,l.errorRecoveryDisabledLanes&w)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 F=I.current.memoizedState.isDehydrated;if(F&&(Su(I,R).flags|=256),R=nS(I,R,!1),R!==2){if(G1&&!F){I.errorRecoveryDisabledLanes|=w,Wl|=w,v=4;break e}w=Vr,Vr=v,w!==null&&(Vr===null?Vr=w:Vr.push.apply(Vr,w))}v=R}if(w=!1,v!==2)continue}}if(v===1){Su(l,0),Ia(l,u,0,!0);break}e:{switch(g=l,w=v,w){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=X1+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,o0,Y1,u,ji,Wl,vu,Ma,w,2,-0,0),v);break e}oP(g,p,Vr,o0,Y1,u,ji,Wl,vu,Ma,w,0,-0,0)}}break}while(!0);zs(l)}function oP(l,u,p,g,v,w,R,I,F,ee,ae,he,re,ie){if(l.timeoutHandle=-1,he=u.subtreeFlags,(he&8192||(he&16785408)===16785408)&&(ad={stylesheets:null,count:0,unsuspend:bK},ZO(u),he=xK(),he!==null)){l.cancelPendingCommit=he(dP.bind(null,l,u,w,p,g,v,R,I,F,ae,1,re,ie)),Ia(l,w,R,!ee);return}dP(l,u,w,p,g,v,R,I,F)}function $G(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],w=v.getSnapshot;v=v.value;try{if(!oi(w(),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&=~K1,u&=~Wl,l.suspendedLanes|=u,l.pingedLanes&=~u,g&&(l.warmLanes|=u),g=l.expirationTimes;for(var v=u;0<v;){var w=31-$e(v),R=1<<w;g[w]=-1,v&=~R}p!==0&&ug(l,p,u)}function a0(){return(xt&6)===0?(td(0),!1):!0}function eS(){if(ot!==null){if(wt===0)var l=ot.return;else l=ot,To=Bl=null,y1(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,tK(p)),p=l.cancelPendingCommit,p!==null&&(l.cancelPendingCommit=null,p()),eS(),Dt=l,ot=p=Ao(l.current,null),ct=u,wt=0,ui=null,Ma=!1,bu=ir(l,u),G1=!1,vu=ji=K1=Wl=Oa=Jt=0,Vr=Zf=null,Y1=!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),w=1<<v;u|=l[v],g&=~w}return No=u,Rg(),p}function aP(l,u){et=null,z.H=Kg,u===Nf||u===jg?(u=CM(),wt=3):u===wM?(u=CM(),wt=4):wt=u===AO?8:u!==null&&typeof u=="object"&&typeof u.then=="function"?6:1,ui=u,ot===null&&(Jt=1,Zg(l,Di(u,l.current)))}function lP(){var l=z.H;return z.H=Kg,l===null?Kg:l}function cP(){var l=z.A;return z.A=LG,l}function tS(){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 nS(l,u,p){var g=xt;xt|=2;var v=lP(),w=cP();(Dt!==l||ct!==u)&&(o0=null,Su(l,u)),u=!1;var R=Jt;e:do try{if(wt!==0&&ot!==null){var I=ot,F=ui;switch(wt){case 8:eS(),R=6;break e;case 3:case 2:case 9:case 6:$i.current===null&&(u=!0);var ee=wt;if(wt=0,ui=null,_u(l,I,F,ee),p&&bu){R=0;break e}break;default:ee=wt,wt=0,ui=null,_u(l,I,F,ee)}}jG(),R=Jt;break}catch(ae){aP(l,ae)}while(!0);return u&&l.shellSuspendCounter++,To=Bl=null,xt=g,z.H=v,z.A=w,ot===null&&(Dt=null,ct=0,Rg()),R}function jG(){for(;ot!==null;)uP(ot)}function BG(l,u){var p=xt;xt|=2;var g=lP(),v=cP();Dt!==l||ct!==u?(o0=null,s0=nr()+500,Su(l,u)):bu=ir(l,u);e:do try{if(wt!==0&&ot!==null){u=ot;var w=ui;t:switch(wt){case 1:wt=0,ui=null,_u(l,u,w,1);break;case 2:case 9:if(SM(w)){wt=0,ui=null,hP(u);break}u=function(){wt!==2&&wt!==9||Dt!==l||(wt=7),zs(l)},w.then(u,u);break e;case 3:wt=7;break e;case 4:wt=5;break e;case 7:SM(w)?(wt=0,ui=null,hP(u)):(wt=0,ui=null,_u(l,u,w,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)){wt=0,ui=null;var F=I.sibling;if(F!==null)ot=F;else{var ee=I.return;ee!==null?(ot=ee,l0(ee)):ot=null}break t}}wt=0,ui=null,_u(l,u,w,5);break;case 6:wt=0,ui=null,_u(l,u,w,6);break;case 8:eS(),Jt=6;break e;default:throw Error(r(462))}}FG();break}catch(ae){aP(l,ae)}while(!0);return To=Bl=null,z.H=g,z.A=v,xt=p,ot!==null?0:(Dt=null,ct=0,Rg(),Jt)}function FG(){for(;ot!==null&&!_o();)uP(ot)}function uP(l){var u=$O(l.alternate,l,No);l.memoizedProps=l.pendingProps,u===null?l0(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:y1(u);default:BO(p,u),u=ot=fM(u,No),u=$O(p,u,No)}l.memoizedProps=l.pendingProps,u===null?l0(l):ot=u}function _u(l,u,p,g){To=Bl=null,y1(u),pu=null,Wf=0;var v=u.return;try{if(RG(l,v,u,p,ct)){Jt=1,Zg(l,Di(p,l.current)),ot=null;return}}catch(w){if(v!==null)throw ot=v,w;Jt=1,Zg(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)):l0(u)}function l0(l){var u=l;do{if((u.flags&32768)!==0){fP(u,Ma);return}l=u.return;var p=OG(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=PG(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,w,R,I,F){l.cancelPendingCommit=null;do c0();while(zn!==0);if((xt&6)!==0)throw Error(r(327));if(u!==null){if(u===l.current)throw Error(r(177));if(w=u.lanes|u.childLanes,w|=qw,Rw(l,p,w,R,I,F),l===Dt&&(ot=Dt=null,ct=0),xu=u,Da=l,wu=p,J1=w,Q1=v,rP=g,(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?(l.callbackNode=null,l.callbackPriority=0,HG(Ds,function(){return bP(),null})):(l.callbackNode=null,l.callbackPriority=0),g=(u.flags&13878)!==0,(u.subtreeFlags&13878)!==0||g){g=z.T,z.T=null,v=G.p,G.p=2,R=xt,xt|=4;try{DG(l,u,p)}finally{xt=R,G.p=v,z.T=g}}zn=1,pP(),mP(),gP()}}function pP(){if(zn===1){zn=0;var l=Da,u=xu,p=(u.flags&13878)!==0;if((u.subtreeFlags&13878)!==0||p){p=z.T,z.T=null;var g=G.p;G.p=2;var v=xt;xt|=4;try{XO(u,l);var w=pS,R=nM(l.containerInfo),I=w.focusedElem,F=w.selectionRange;if(R!==I&&I&&I.ownerDocument&&tM(I.ownerDocument.documentElement,I)){if(F!==null&&zw(I)){var ee=F.start,ae=F.end;if(ae===void 0&&(ae=ee),"selectionStart"in I)I.selectionStart=ee,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(F.start,We),Ct=F.end===void 0?Fe:Math.min(F.end,We);!ie.extend&&Fe>Ct&&(R=Ct,Ct=Fe,Fe=R);var K=eM(I,Fe),W=eM(I,Ct);if(K&&W&&(ie.rangeCount!==1||ie.anchorNode!==K.node||ie.anchorOffset!==K.offset||ie.focusNode!==W.node||ie.focusOffset!==W.offset)){var J=he.createRange();J.setStart(K.node,K.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}}w0=!!dS,pS=dS=null}finally{xt=v,G.p=g,z.T=p}}l.current=u,zn=2}}function mP(){if(zn===2){zn=0;var l=Da,u=xu,p=(u.flags&8772)!==0;if((u.subtreeFlags&8772)!==0||p){p=z.T,z.T=null;var g=G.p;G.p=2;var v=xt;xt|=4;try{qO(l,u.alternate,u)}finally{xt=v,G.p=g,z.T=p}}zn=3}}function gP(){if(zn===4||zn===3){zn=0,ss();var l=Da,u=xu,p=wu,g=rP;(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?zn=5:(zn=0,xu=Da=null,yP(l,l.pendingLanes));var v=l.pendingLanes;if(v===0&&(Pa=null),uf(p),u=u.stateNode,me&&typeof me.onCommitFiberRoot=="function")try{me.onCommitFiberRoot(oe,u,void 0,(u.current.flags&128)===128)}catch{}if(g!==null){u=z.T,v=G.p,G.p=2,z.T=null;try{for(var w=l.onRecoverableError,R=0;R<g.length;R++){var I=g[R];w(I.value,{componentStack:I.stack})}}finally{z.T=u,G.p=v}}(wu&3)!==0&&c0(),zs(l),v=l.pendingLanes,(p&4194090)!==0&&(v&42)!==0?l===Z1?ed++:(ed=0,Z1=l):ed=0,td(0)}}function yP(l,u){(l.pooledCacheLanes&=u)===0&&(u=l.pooledCache,u!=null&&(l.pooledCache=null,If(u)))}function c0(l){return pP(),mP(),gP(),bP()}function bP(){if(zn!==5)return!1;var l=Da,u=J1;J1=0;var p=uf(wu),g=z.T,v=G.p;try{G.p=32>p?32:p,z.T=null,p=Q1,Q1=null;var w=Da,R=wu;if(zn=0,xu=Da=null,wu=0,(xt&6)!==0)throw Error(r(331));var I=xt;if(xt|=4,tP(w.current),QO(w,w.current,R,p),xt=I,td(0,!1),me&&typeof me.onPostCommitFiberRoot=="function")try{me.onPostCommitFiberRoot(oe,w)}catch{}return!0}finally{G.p=v,z.T=g,yP(l,u)}}function vP(l,u,p){u=Di(p,u),u=O1(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 rS(l,u,p){var g=l.pingCache;if(g===null){g=l.pingCache=new NG;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)||(G1=!0,v.add(p),l=zG.bind(null,l,u,p),u.then(l,l))}function zG(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()-X1?(xt&2)===0&&Su(l,0):K1|=p,vu===ct&&(vu=0)),zs(l)}function xP(l,u){u===0&&(u=zc()),l=iu(l,u),l!==null&&(as(l,u),zs(l))}function VG(l){var u=l.memoizedState,p=0;u!==null&&(p=u.retryLane),xP(l,p)}function UG(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),xP(l,p)}function HG(l,u){return tr(l,u)}var u0=null,Cu=null,iS=!1,h0=!1,sS=!1,ql=0;function zs(l){l!==Cu&&l.next===null&&(Cu===null?u0=Cu=l:Cu=Cu.next=l),h0=!0,iS||(iS=!0,qG())}function td(l,u){if(!sS&&h0){sS=!0;do for(var p=!1,g=u0;g!==null;){if(l!==0){var v=g.pendingLanes;if(v===0)var w=0;else{var R=g.suspendedLanes,I=g.pingedLanes;w=(1<<31-$e(42|l)+1)-1,w&=v&~(R&~I),w=w&201326741?w&201326741|1:w?w|2:0}w!==0&&(p=!0,CP(g,w))}else w=ct,w=on(g,g===Dt?w:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(w&3)===0||ir(g,w)||(p=!0,CP(g,w));g=g.next}while(p);sS=!1}}function WG(){wP()}function wP(){h0=iS=!1;var l=0;ql!==0&&(eK()&&(l=ql),ql=0);for(var u=nr(),p=null,g=u0;g!==null;){var v=g.next,w=SP(g,u);w===0?(g.next=null,p===null?u0=v:p.next=v,v===null&&(Cu=p)):(p=g,(l!==0||(w&3)!==0)&&(h0=!0)),g=v}td(l)}function SP(l,u){for(var p=l.suspendedLanes,g=l.pingedLanes,v=l.expirationTimes,w=l.pendingLanes&-62914561;0<w;){var R=31-$e(w),I=1<<R,F=v[R];F===-1?((I&p)===0||(I&g)!==0)&&(v[R]=Bn(I,u)):F<=u&&(l.expiredLanes|=I),w&=~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&&(wt===2||wt===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(c0()&&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(c0())return null;sP(l,u,!0)}function qG(){nK(function(){(xt&6)!==0?tr(kl,WG):wP()})}function oS(){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 GG(l,u,p,g,v){if(u==="submit"&&p&&p.stateNode===v){var w=AP((v[or]||null).action),R=g.submitter;R&&(u=(u=R[or]||null)?AP(u.formAction):R.getAttribute("formAction"),u!==null&&(w=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 F=R?EP(v,R):new FormData(v);E1(p,{pending:!0,data:F,method:v.method,action:w},null,F)}}else typeof w=="function"&&(I.preventDefault(),F=R?EP(v,R):new FormData(v),E1(p,{pending:!0,data:F,method:v.method,action:w},w,F))},currentTarget:v}]})}}for(var aS=0;aS<Ww.length;aS++){var lS=Ww[aS],KG=lS.toLowerCase(),YG=lS[0].toUpperCase()+lS.slice(1);hs(KG,"on"+YG)}hs(sM,"onAnimationEnd"),hs(oM,"onAnimationIteration"),hs(aM,"onAnimationStart"),hs("dblclick","onDoubleClick"),hs("focusin","onFocus"),hs("focusout","onBlur"),hs(fG,"onTransitionRun"),hs(dG,"onTransitionStart"),hs(pG,"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(" "),XG=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 w=void 0;if(u)for(var R=g.length-1;0<=R;R--){var I=g[R],F=I.instance,ee=I.currentTarget;if(I=I.listener,F!==w&&v.isPropagationStopped())break e;w=I,v.currentTarget=ee;try{w(v)}catch(ae){Qg(ae)}v.currentTarget=null,w=F}else for(R=0;R<g.length;R++){if(I=g[R],F=I.instance,ee=I.currentTarget,I=I.listener,F!==w&&v.isPropagationStopped())break e;w=I,v.currentTarget=ee;try{w(v)}catch(ae){Qg(ae)}v.currentTarget=null,w=F}}}}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 cS(l,u,p){var g=0;u&&(g|=4),TP(p,l,g,u)}var f0="_reactListening"+Math.random().toString(36).slice(2);function uS(l){if(!l[f0]){l[f0]=!0,pg.forEach(function(p){p!=="selectionchange"&&(XG.has(p)||cS(p,!1,l),cS(p,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[f0]||(u[f0]=!0,cS("selectionchange",!1,u))}}function TP(l,u,p,g){switch(QP(u)){case 2:var v=_K;break;case 8:v=CK;break;default:v=CS}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 hS(l,u,p,g,v){var w=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 F=R.tag;if((F===3||F===4)&&R.stateNode.containerInfo===v)return;R=R.return}for(;I!==null;){if(R=ca(I),R===null)return;if(F=R.tag,F===5||F===6||F===26||F===27){g=w=R;continue e}I=I.parentNode}}g=g.return}Yc(function(){var ee=w,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=Hq;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=kg;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ie=Gq;break;case sM:case oM:case aM:ie=Lq;break;case lM:ie=Yq;break;case"scroll":case"scrollend":ie=ar;break;case"wheel":ie=Jq;break;case"copy":case"cut":case"paste":ie=$q;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=Zq}var Fe=(u&4)!==0,Ct=!Fe&&(l==="scroll"||l==="scrollend"),K=Fe?re!==null?re+"Capture":null:re;Fe=[];for(var W=ee,J;W!==null;){var ce=W;if(J=ce.stateNode,ce=ce.tag,ce!==5&&ce!==26&&ce!==27||J===null||K===null||(ce=ma(W,K),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=ee,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=ee),ie!==We)){if(Fe=_f,ce="onMouseLeave",K="onMouseEnter",W="mouse",(l==="pointerout"||l==="pointerover")&&(Fe=FR,ce="onPointerLeave",K="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)===ee&&(Fe=new Fe(K,W+"enter",We,p,ae),Fe.target=J,Fe.relatedTarget=Ct,ce=Fe),Ct=ce,ie&&We)t:{for(Fe=ie,K=We,W=0,J=Fe;J;J=Au(J))W++;for(J=0,ce=K;ce;ce=Au(ce))J++;for(;0<W-J;)Fe=Au(Fe),W--;for(;0<J-W;)K=Au(K),J--;for(;W--;){if(Fe===K||K!==null&&Fe===K.alternate)break t;Fe=Au(Fe),K=Au(K)}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=ee?Oi(ee):window,ie=re.nodeName&&re.nodeName.toLowerCase(),ie==="select"||ie==="input"&&re.type==="file")var Te=KR;else if(qR(re))if(YR)Te=cG;else{Te=aG;var rt=oG}else ie=re.nodeName,!ie||ie.toLowerCase()!=="input"||re.type!=="checkbox"&&re.type!=="radio"?ee&&bf(ee.elementType)&&(Te=KR):Te=lG;if(Te&&(Te=Te(l,ee))){GR(he,Te,p,ae);break e}rt&&rt(l,re,ee),l==="focusout"&&ee&&re.type==="number"&&ee.memoizedProps.value!=null&&qc(re,"number",re.value)}switch(rt=ee?Oi(ee):window,l){case"focusin":(qR(rt)||rt.contentEditable==="true")&&(tu=rt,Vw=ee,Rf=null);break;case"focusout":Rf=Vw=tu=null;break;case"mousedown":Uw=!0;break;case"contextmenu":case"mouseup":case"dragend":Uw=!1,rM(he,p,ae);break;case"selectionchange":if(hG)break;case"keydown":case"keyup":rM(he,p,ae)}var Pe;if(jw)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=d0(ee,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=tG?nG(l,p):rG(l,p))&&(Ve=d0(ee,"onBeforeInput"),0<Ve.length&&(rt=new BR("onBeforeInput","beforeinput",null,p,ae),he.push({event:rt,listeners:Ve}),rt.data=Pe)),GG(he,l,ee,p,ae)}kP(he,u)})}function rd(l,u,p){return{instance:l,listener:u,currentTarget:p}}function d0(l,u){for(var p=u+"Capture",g=[];l!==null;){var v=l,w=v.stateNode;if(v=v.tag,v!==5&&v!==26&&v!==27||w===null||(v=ma(l,p),v!=null&&g.unshift(rd(l,v,w)),v=ma(l,u),v!=null&&g.push(rd(l,v,w))),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 w=u._reactName,R=[];p!==null&&p!==g;){var I=p,F=I.alternate,ee=I.stateNode;if(I=I.tag,F!==null&&F===g)break;I!==5&&I!==26&&I!==27||ee===null||(F=ee,v?(ee=ma(p,w),ee!=null&&R.unshift(rd(p,ee,F))):v||(ee=ma(p,w),ee!=null&&R.push(rd(p,ee,F)))),p=p.return}R.length!==0&&l.push({event:u,listeners:R})}var JG=/\r\n?/g,QG=/\u0000|\uFFFD/g;function MP(l){return(typeof l=="string"?l:""+l).replace(JG,`
`).replace(QG,"")}function OP(l,u){return u=MP(u),MP(l)===u}function p0(){}function _t(l,u,p,g,v,w){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":Ag(l,g,w);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 w=="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=p0);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=Lw.get(p)||p,Vc(l,p,g))}}function fS(l,u,p,g,v,w){switch(p){case"style":Ag(l,g,w);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=p0);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!mg.hasOwnProperty(p))e:{if(p[0]==="o"&&p[1]==="n"&&(v=p.endsWith("Capture"),u=p.slice(2,v?p.length-7:void 0),w=l[or]||null,w=w!=null?w[p]:null,typeof w=="function"&&l.removeEventListener(u,w,v),typeof g=="function")){typeof w!="function"&&w!==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,w;for(w in p)if(p.hasOwnProperty(w)){var R=p[w];if(R!=null)switch(w){case"src":g=!0;break;case"srcSet":v=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,u));default:_t(l,u,w,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=w=R=v=null,F=null,ee=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":F=ae;break;case"defaultChecked":ee=ae;break;case"value":w=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)}}Sg(l,w,I,F,ee,R,v,!1),Hc(l);return;case"select":at("invalid",l),g=R=w=null;for(v in p)if(p.hasOwnProperty(v)&&(I=p[v],I!=null))switch(v){case"value":w=I;break;case"defaultValue":R=I;break;case"multiple":g=I;default:_t(l,u,v,I,p,null)}u=w,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),w=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":w=I;break;case"dangerouslySetInnerHTML":if(I!=null)throw Error(r(91));break;default:_t(l,u,R,I,p,null)}Ol(l,g,v,w),Hc(l);return;case"option":for(F in p)if(p.hasOwnProperty(F)&&(g=p[F],g!=null))switch(F){case"selected":l.selected=g&&typeof g!="function"&&typeof g!="symbol";break;default:_t(l,u,F,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(ee in p)if(p.hasOwnProperty(ee)&&(g=p[ee],g!=null))switch(ee){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,u));default:_t(l,u,ee,g,p,null)}return;default:if(bf(u)){for(ae in p)p.hasOwnProperty(ae)&&(g=p[ae],g!==void 0&&fS(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 ZG(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,w=null,R=null,I=null,F=null,ee=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":F=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":w=ie;break;case"name":v=ie;break;case"checked":ee=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,F,ee,ae,w,v);return;case"select":ie=R=I=re=null;for(w in p)if(F=p[w],p.hasOwnProperty(w)&&F!=null)switch(w){case"value":break;case"multiple":ie=F;default:g.hasOwnProperty(w)||_t(l,u,w,null,g,F)}for(v in g)if(w=g[v],F=p[v],g.hasOwnProperty(v)&&(w!=null||F!=null))switch(v){case"value":re=w;break;case"defaultValue":I=w;break;case"multiple":R=w;default:w!==F&&_t(l,u,v,w,g,F)}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],w=p[R],g.hasOwnProperty(R)&&(v!=null||w!=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!==w&&_t(l,u,R,v,g,w)}_g(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(F in g)if(re=g[F],ie=p[F],g.hasOwnProperty(F)&&re!==ie&&(re!=null||ie!=null))switch(F){case"selected":l.selected=re&&typeof re!="function"&&typeof re!="symbol";break;default:_t(l,u,F,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(ee in g)if(re=g[ee],ie=p[ee],g.hasOwnProperty(ee)&&re!==ie&&(re!=null||ie!=null))switch(ee){case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(r(137,u));break;default:_t(l,u,ee,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)&&fS(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||fS(l,u,ae,re,g,ie);return}}for(var K in p)re=p[K],p.hasOwnProperty(K)&&re!=null&&!g.hasOwnProperty(K)&&_t(l,u,K,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 dS=null,pS=null;function m0(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 mS(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 gS=null;function eK(){var l=window.event;return l&&l.type==="popstate"?l===gS?!1:(gS=l,!0):(gS=null,!1)}var IP=typeof setTimeout=="function"?setTimeout:void 0,tK=typeof clearTimeout=="function"?clearTimeout:void 0,LP=typeof Promise=="function"?Promise:void 0,nK=typeof queueMicrotask=="function"?queueMicrotask:typeof LP<"u"?function(l){return LP.resolve(null).then(l).catch(rK)}:IP;function rK(l){setTimeout(function(){throw l})}function La(l){return l==="head"}function NP(l,u){var p=u,g=0,v=0;do{var w=p.nextSibling;if(l.removeChild(p),w&&w.nodeType===8)if(p=w.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,F=R.nodeName;R[Ml]||F==="SCRIPT"||F==="STYLE"||F==="LINK"&&R.rel.toLowerCase()==="stylesheet"||p.removeChild(R),R=I}}if(v===0){l.removeChild(w),fd(u);return}v--}else p==="$"||p==="$?"||p==="$!"?v++:g=p.charCodeAt(0)-48;else g=0;p=w}while(p);fd(u)}function yS(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":yS(p),df(p);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(p.rel.toLowerCase()==="stylesheet")continue}l.removeChild(p)}}function iK(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(w=l.getAttribute("rel"),w==="stylesheet"&&l.hasAttribute("data-precedence"))break;if(w!==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(w=l.getAttribute("src"),(w!==(v.src==null?null:v.src)||l.getAttribute("type")!==(v.type==null?null:v.type)||l.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin))&&w&&l.hasAttribute("async")&&!l.hasAttribute("itemprop"))break;return l;default:return l}}else if(u==="input"&&l.type==="hidden"){var w=v.name==null?null:""+v.name;if(v.type==="hidden"&&l.getAttribute("name")===w)return l}else return l;if(l=ds(l.nextSibling),l===null)break}return null}function sK(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 bS(l){return l.data==="$!"||l.data==="$?"&&l.ownerDocument.readyState==="complete"}function oK(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 vS=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=m0(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 g0(l){return typeof l.getRootNode=="function"?l.getRootNode():l.nodeType===9?l:l.ownerDocument}var $o=G.d;G.d={f:aK,r:lK,D:cK,C:uK,L:hK,m:fK,X:pK,S:dK,M:mK};function aK(){var l=$o.f(),u=a0();return l||u}function lK(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 cK(l){$o.D(l),FP("dns-prefetch",l,null)}function uK(l,u){$o.C(l,u),FP("preconnect",l,u)}function hK(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 w=v;switch(u){case"style":w=ku(l);break;case"script":w=Tu(l)}Bi.has(w)||(l=f({rel:"preload",href:u==="image"&&p&&p.imageSrcSet?void 0:l,as:u},p),Bi.set(w,l),g.querySelector(v)!==null||u==="style"&&g.querySelector(sd(w))||u==="script"&&g.querySelector(od(w))||(u=g.createElement("link"),Vn(u,"link",l),an(u),g.head.appendChild(u)))}}function fK(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)+'"]',w=v;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":w=Tu(l)}if(!Bi.has(w)&&(l=f({rel:"modulepreload",href:l},u),Bi.set(w,l),p.querySelector(v)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(p.querySelector(od(w)))return}g=p.createElement("link"),Vn(g,"link",l),an(g),p.head.appendChild(g)}}}function dK(l,u,p){$o.S(l,u,p);var g=Eu;if(g&&l){var v=ha(g).hoistableStyles,w=ku(l);u=u||"default";var R=v.get(w);if(!R){var I={loading:0,preload:null};if(R=g.querySelector(sd(w)))I.loading=5;else{l=f({rel:"stylesheet",href:l,"data-precedence":u},p),(p=Bi.get(w))&&xS(l,p);var F=R=g.createElement("link");an(F),Vn(F,"link",l),F._p=new Promise(function(ee,ae){F.onload=ee,F.onerror=ae}),F.addEventListener("load",function(){I.loading|=1}),F.addEventListener("error",function(){I.loading|=2}),I.loading|=4,y0(R,u,g)}R={type:"stylesheet",instance:R,count:1,state:I},v.set(w,R)}}}function pK(l,u){$o.X(l,u);var p=Eu;if(p&&l){var g=ha(p).hoistableScripts,v=Tu(l),w=g.get(v);w||(w=p.querySelector(od(v)),w||(l=f({src:l,async:!0},u),(u=Bi.get(v))&&wS(l,u),w=p.createElement("script"),an(w),Vn(w,"link",l),p.head.appendChild(w)),w={type:"script",instance:w,count:1,state:null},g.set(v,w))}}function mK(l,u){$o.M(l,u);var p=Eu;if(p&&l){var g=ha(p).hoistableScripts,v=Tu(l),w=g.get(v);w||(w=p.querySelector(od(v)),w||(l=f({src:l,async:!0,type:"module"},u),(u=Bi.get(v))&&wS(l,u),w=p.createElement("script"),an(w),Vn(w,"link",l),p.head.appendChild(w)),w={type:"script",instance:w,count:1,state:null},g.set(v,w))}}function zP(l,u,p,g){var v=(v=ye.current)?g0(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 w=ha(v).hoistableStyles,R=w.get(l);if(R||(v=v.ownerDocument||v,R={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},w.set(l,R),(w=v.querySelector(sd(l)))&&!w._p&&(R.instance=w,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),w||gK(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 gK(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),y0(g,p.precedence,l),u.instance=g;case"stylesheet":v=ku(p.href);var w=l.querySelector(sd(v));if(w)return u.state.loading|=4,u.instance=w,an(w),w;g=VP(p),(v=Bi.get(v))&&xS(g,v),w=(l.ownerDocument||l).createElement("link"),an(w);var R=w;return R._p=new Promise(function(I,F){R.onload=I,R.onerror=F}),Vn(w,"link",g),u.state.loading|=4,y0(w,p.precedence,l),u.instance=w;case"script":return w=Tu(p.src),(v=l.querySelector(od(w)))?(u.instance=v,an(v),v):(g=p,(v=Bi.get(w))&&(g=f({},p),wS(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,y0(g,p.precedence,l));return u.instance}function y0(l,u,p){for(var g=p.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),v=g.length?g[g.length-1]:null,w=v,R=0;R<g.length;R++){var I=g[R];if(I.dataset.precedence===u)w=I;else if(w!==v)break}w?w.parentNode.insertBefore(l,w.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 wS(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.integrity==null&&(l.integrity=u.integrity)}var b0=null;function HP(l,u,p){if(b0===null){var g=new Map,v=b0=new Map;v.set(p,g)}else v=b0,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 w=p[v];if(!(w[Ml]||w[Mn]||l==="link"&&w.getAttribute("rel")==="stylesheet")&&w.namespaceURI!=="http://www.w3.org/2000/svg"){var R=w.getAttribute(u)||"";R=l+R;var I=g.get(R);I?I.push(w):g.set(R,[w])}}return g}function WP(l,u,p){l=l.ownerDocument||l,l.head.insertBefore(p,u==="title"?l.querySelector("head > title"):null)}function yK(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 bK(){}function vK(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),w=l.querySelector(sd(v));if(w){l=w._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(g.count++,g=v0.bind(g),l.then(g,g)),u.state.loading|=4,u.instance=w,an(w);return}w=l.ownerDocument||l,p=VP(p),(v=Bi.get(v))&&xS(p,v),w=w.createElement("link"),an(w);var R=w;R._p=new Promise(function(I,F){R.onload=I,R.onerror=F}),Vn(w,"link",p),u.instance=w}g.stylesheets===null&&(g.stylesheets=new Map),g.stylesheets.set(u,l),(l=u.state.preload)&&(u.state.loading&3)===0&&(g.count++,u=v0.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&&SS(l,l.stylesheets),0<l.count?function(u){var p=setTimeout(function(){if(l.stylesheets&&SS(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 v0(){if(this.count--,this.count===0){if(this.stylesheets)SS(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var x0=null;function SS(l,u){l.stylesheets=null,l.unsuspend!==null&&(l.count++,x0=new Map,u.forEach(wK,l),x0=null,v0.call(l))}function wK(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]"),w=0;w<v.length;w++){var R=v[w];(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"),w=p.get(R)||g,w===g&&p.set(null,v),p.set(R,v),this.count++,g=v0.bind(this),v.addEventListener("load",g),v.addEventListener("error",g),w?w.parentNode.insertBefore(v,w.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:U,_currentValue2:U,_threadCount:0};function SK(l,u,p,g,v,w,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=w,this.onRecoverableError=R,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=I,this.incompleteTransitions=new Map}function GP(l,u,p,g,v,w,R,I,F,ee,ae,he){return l=new SK(l,u,p,R,I,F,ee,he),u=1,w===!0&&(u|=24),w=ai(3,null,null,u),l.current=w,w.stateNode=l,u=r1(),u.refCount++,l.pooledCache=u,u.refCount++,w.memoizedState={element:g,isDehydrated:p,cache:u},a1(w),l}function KP(l){return l?(l=su,l):su}function YP(l,u,p,g,v,w){v=KP(v),g.context===null?g.context=v:g.pendingContext=v,g=Sa(u),g.payload={element:p},w=w===void 0?null:w,w!==null&&(g.callback=w),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 _S(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),_S(l,67108864)}}var w0=!0;function _K(l,u,p,g){var v=z.T;z.T=null;var w=G.p;try{G.p=2,CS(l,u,p,g)}finally{G.p=w,z.T=v}}function CK(l,u,p,g){var v=z.T;z.T=null;var w=G.p;try{G.p=8,CS(l,u,p,g)}finally{G.p=w,z.T=v}}function CS(l,u,p,g){if(w0){var v=AS(g);if(v===null)hS(l,u,g,S0,p),ZP(l,g);else if(EK(v,l,u,p,g))g.stopPropagation();else if(ZP(l,g),u&4&&-1<AK.indexOf(l)){for(;v!==null;){var w=ua(v);if(w!==null)switch(w.tag){case 3:if(w=w.stateNode,w.current.memoizedState.isDehydrated){var R=_r(w.pendingLanes);if(R!==0){var I=w;for(I.pendingLanes|=2,I.entangledLanes|=2;R;){var F=1<<31-$e(R);I.entanglements[1]|=F,R&=~F}zs(w),(xt&6)===0&&(s0=nr()+500,td(0))}}break;case 13:I=iu(w,2),I!==null&&fi(I,w,2),a0(),_S(w,2)}if(w=AS(g),w===null&&hS(l,u,g,S0,p),w===v)break;v=w}v!==null&&g.stopPropagation()}else hS(l,u,g,null,p)}}function AS(l){return l=Kc(l),ES(l)}var S0=null;function ES(l){if(S0=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 S0=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 kS=!1,Na=null,$a=null,ja=null,cd=new Map,ud=new Map,Ba=[],AK="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,w){return l===null||l.nativeEvent!==w?(l={blockedOn:u,domEventName:p,eventSystemFlags:g,nativeEvent:w,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 EK(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 w=v.pointerId;return cd.set(w,hd(cd.get(w)||null,l,u,p,g,v)),!0;case"gotpointercapture":return w=v.pointerId,ud.set(w,hd(ud.get(w)||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,fg(l.priority,function(){if(p.tag===13){var g=hi();g=cf(g);var v=iu(p,g);v!==null&&fi(v,p,g),_S(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 _0(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var p=AS(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){_0(l)&&p.delete(u)}function kK(){kS=!1,Na!==null&&_0(Na)&&(Na=null),$a!==null&&_0($a)&&($a=null),ja!==null&&_0(ja)&&(ja=null),cd.forEach(tD),ud.forEach(tD)}function C0(l,u){l.blockedOn===u&&(l.blockedOn=null,kS||(kS=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kK)))}var A0=null;function nD(l){A0!==l&&(A0=l,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){A0===l&&(A0=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(ES(g||p)===null)continue;break}var w=ua(p);w!==null&&(l.splice(u,3),u-=3,E1(w,{pending:!0,data:v,method:p.method,action:g},g,v))}}))}function fd(l){function u(F){return C0(F,l)}Na!==null&&C0(Na,l),$a!==null&&C0($a,l),ja!==null&&C0(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],w=p[g+1],R=v[or]||null;if(typeof w=="function")R||nD(p);else if(R){var I=null;if(w&&w.hasAttribute("formAction")){if(v=w,R=w[or]||null)I=R.formAction;else if(ES(v)!==null)continue}else I=R.action;typeof I=="function"?p[g+1]=I:(p.splice(g,3),g-=3),nD(p)}}}function TS(l){this._internalRoot=l}E0.prototype.render=TS.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)},E0.prototype.unmount=TS.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),a0(),u[la]=null}};function E0(l){this._internalRoot=l}E0.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 TK={bundleType:0,version:"19.1.1",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.1.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var k0=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!k0.isDisabled&&k0.supportsFiber)try{oe=k0.inject(TK),me=k0}catch{}}return pd.createRoot=function(l,u){if(!i(l))throw Error(r(299));var p=!1,g="",v=vO,w=xO,R=wO,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&&(w=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,w,R,I,null),l[la]=u.current,uS(l),new TS(u)},pd.hydrateRoot=function(l,u,p){if(!i(l))throw Error(r(299));var g=!1,v="",w=vO,R=xO,I=wO,F=null,ee=null;return p!=null&&(p.unstable_strictMode===!0&&(g=!0),p.identifierPrefix!==void 0&&(v=p.identifierPrefix),p.onUncaughtError!==void 0&&(w=p.onUncaughtError),p.onCaughtError!==void 0&&(R=p.onCaughtError),p.onRecoverableError!==void 0&&(I=p.onRecoverableError),p.unstable_transitionCallbacks!==void 0&&(F=p.unstable_transitionCallbacks),p.formState!==void 0&&(ee=p.formState)),u=GP(l,1,!0,u,p??null,g,v,w,R,I,F,ee),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,uS(l),new E0(u)},pd.version="19.1.1",pd}var dD;function jK(){if(dD)return OS.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(),OS.exports=$K(),OS.exports}var BK=jK(),FK=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},{}),R$=class{_providers=new Set;getModelContext(){return FK(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)}},M$=class{_contextProvider=new R$;registerModelContextProvider(t){return this._contextProvider.registerModelContextProvider(t)}},zK=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)}},VK=t=>t.status.type==="complete",O$=class extends zK{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=>VK(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)}}},P$=class extends O${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 UK=(t,e=21)=>(n=e)=>{let r="",i=n|0;for(;i--;)r+=t[Math.random()*t.length|0];return r};var bx=UK("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),HK="__optimistic__",WK=()=>`${HK}${bx()}`,D$=Object.freeze({type:"running"}),I$=Object.freeze({type:"complete",reason:"unknown"}),qK=Object.freeze({type:"requires-action",reason:"tool-calls"}),GK=t=>t===D$||t===I$,kE=(t,e,n)=>t&&e?D$:n?qK:I$,Gl={exports:{}},pD;function KK(){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 x=y[b];x&&typeof x=="object"&&d.push(x)}}}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 YK=KK();const mD=Pc(YK);function XK(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 LS=Symbol("aui.parse-partial-json-object.meta"),JK=t=>{if(t.length===0)return{[LS]:{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[LS]={state:"complete",partialPath:[]},e}catch{try{const[e,n]=XK(t),r=mD.parse(e);if(typeof r!="object"||r===null)throw new Error("argsText is expected to be an object");return r[LS]={state:"partial",partialPath:n},r}catch{return}}},vx=(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,...x}=m,S={...x,toolCallId:m.toolCallId??"tool-"+bx(),...b!==void 0&&{parentId:b}};return m.args?{...S,args:m.args,argsText:m.argsText??JSON.stringify(m.args)}:{...S,args:JK(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}`)}}},TE={fromArray:t=>{const e=t.map(n=>vx(n,bx(),kE(!1,!1,!1)));return{messages:e.map((n,r)=>({parentId:r>0?e[r-1].id:null,message:n}))}}},rb=t=>t.next?rb(t.next):"current"in t?t:null,QK=class{constructor(t){this.func=t}_value=null;get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},RE=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],(rb(e)===this.head||i.next===null)&&(i.next=e),e.prev=t}}}_messages=new QK(()=>{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=WK();while(this.messages.has(n));return this.addOrUpdateMessage(t,vx(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=rb(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=rb(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)}},xx=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()}}},ws=Symbol("skip-update"),ME=class extends xx{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!==ws&&(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)}},R0=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 ZK(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 xx{constructor(t){super(),this.binding=t;const e=t.getState();if(e===ws)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===ws||ZK(t,this._previousState)?!1:(this._previousState=t,!0)}_connect(){const t=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(t)}},Th=Symbol("innerMessage"),eY=t=>t[Th],Vp=t=>t.content.filter(n=>n.type==="text").map(n=>n.text).join(`
`),L$=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)}},N$=class extends L${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)}},tY=class extends N${get source(){return"thread-composer"}},nY=class extends N${get source(){return"edit-composer"}},rY=class extends L${get source(){return"message"}constructor(t){super(t)}remove(){throw new Error("Message attachments cannot be removed")}},$$=class extends xx{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?.()}}},j$=Object.freeze([]),B$=Object.freeze({}),iY=t=>Object.freeze({type:"thread",isEditing:t?.isEditing??!1,canCancel:t?.canCancel??!1,isEmpty:t?.isEmpty??!0,attachments:t?.attachments??j$,text:t?.text??"",role:t?.role??"user",runConfig:t?.runConfig??B$,attachmentAccept:t?.attachmentAccept??"",value:t?.text??""}),sY=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??j$,runConfig:t?.runConfig??B$,attachmentAccept:t?.attachmentAccept??"",value:t?.text??""}),F$=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 $$({event:t,binding:this._core}),this._eventSubscriptionSubjects.set(t,n)),n.subscribe(e)}},oY=class extends F${get path(){return this._core.path}get type(){return"thread"}_getState;constructor(t){const e=new ME({path:t.path,getState:()=>iY(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 tY(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"}:ws},subscribe:e=>this._core.subscribe(e)}),this._core)}},aY=class extends F${constructor(t,e){const n=new ME({path:t.path,getState:()=>sY(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 nY(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"}:ws},subscribe:e=>this._core.subscribe(e)}),this._core)}},gD=Symbol.for("aui.tool-response"),lY=class B2{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 B2?e:new B2({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=lY.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)}},Gb=class extends xx{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?.()}}},M0=Object.freeze({type:"complete"}),cY=(t,e,n)=>{if(t.role!=="assistant")return M0;if(n.type==="tool-call")return n.result?M0:t.status;const r=e===Math.max(0,t.content.length-1);return t.status.type==="requires-action"?M0:r?t.status:M0},bD=(t,e)=>{const n=t.content[e];if(!n)return ws;const r=cY(t,e,n);return Object.freeze({...n,[Th]:n[Th],status:r})},uY=class{constructor(t,e){this._core=t,this._threadBinding=e,this.composer=new aY(new Gb({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?ws:bD(e,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(t){return new rY(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"}:ws},subscribe:e=>this._core.subscribe(e)}))}},hY=t=>({parentId:t.parentId??null,sourceId:t.sourceId??null,runConfig:t.runConfig??{},...t.stream?{stream:t.stream}:{}}),fY=t=>({parentId:t.parentId??null,sourceId:t.sourceId??null,runConfig:t.runConfig??{}}),dY=(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},pY=(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})},z$=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:()=>pY(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 oY(new Gb({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(dY(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(fY(e))}unstable_resumeRun(t){return this._threadBinding.getState().resumeRun(hY(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 uY(new gs({path:t,getState:()=>{const{message:n,parentId:r}=e()??{},{messages:i,speech:s}=this._threadBinding.getState();if(!n||r===void 0)return ws;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 $$({event:t,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(t,n)),n.subscribe(e)}},mY=t=>({mainThreadId:t.mainThreadId,newThread:t.newThreadId,threads:t.threadIds,archivedThreads:t.archivedThreadIds,isLoading:t.isLoading,threadItems:t.threadData}),O0=(t,e)=>{if(e===void 0)return ws;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}:ws},gY=class{constructor(t,e=z$){this._core=t,this._runtimeFactory=e;const n=new ME({path:{},getState:()=>mY(t),subscribe:r=>t.subscribe(r)});this._getState=n.getState.bind(n),this._mainThreadListItemRuntime=new R0(new gs({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>O0(this._core,this._core.mainThreadId),subscribe:r=>this._core.subscribe(r)}),this._core),this.main=new e(new Gb({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 Gb({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 R0(new gs({path:{ref:`threadItems[${t}]`,threadSelector:{type:"index",index:t}},getState:()=>O0(this._core,this._core.threadIds[t]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(t){return new R0(new gs({path:{ref:`archivedThreadItems[${t}]`,threadSelector:{type:"archiveIndex",index:t}},getState:()=>O0(this._core,this._core.archivedThreadIds[t]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(t){return new R0(new gs({path:{ref:`threadItems[threadId=${t}]`,threadSelector:{type:"threadId",threadId:t}},getState:()=>O0(this._core,t),subscribe:e=>this._core.subscribe(e)}),this._core)}},yY=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 bY(t.file)}]}}async remove(){}},bY=t=>new Promise((e,n)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=i=>n(i),r.readAsDataURL(t)}),vY=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 NS(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 wY=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(NS(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(NS(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(NS({name:t.name,type:t.contentType},n.accept))return n.remove(t);throw new Error("No matching adapter found for attachment")}},SY=k.createContext(null),_Y=()=>k.useContext(SY),Kl=Object.freeze([]),lc="DEFAULT_THREAD_ID",CY=Object.freeze([lc]),V$=Object.freeze({id:lc,remoteId:void 0,externalId:void 0,status:"regular"}),AY=Promise.resolve(),vD=Object.freeze({[lc]:V$}),EY=class{constructor(t={},e){this.adapter=t,this.threadFactory=e,this._mainThread=this.threadFactory(),this.__internal_setAdapter(t,!0)}_mainThreadId=lc;_threads=CY;_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 AY}_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 V$}__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()}},xD=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})}},kY=class extends O${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()}},TY=class{constructor(t){this._contextProvider=t}_subscriptions=new Set;_isInitialized=!1;repository=new RE;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 P$(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 kY(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(TE.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)}}},RY=Object.freeze([]),MY=(t,e)=>t&&e[e.length-1]?.role!=="assistant",OY=class extends TY{_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 xD;_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??RY,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 xD;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=kE(a,e,!1);if(i&&(i.role!=="assistant"||!GK(i.status)||i.status===c))return i;const h=t.convertMessage(s,o),f=vx(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),MY(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 RE;e.import(TE.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(eY).filter(n=>n!=null)):this._store.setMessages?.(t)}},wD=t=>t.adapters?.threadList??{},PY=class extends M${threads;constructor(t){super(),this.threads=new EY(wD(t),()=>new OY(this._contextProvider,t))}setAdapter(t){this.threads.__internal_setAdapter(wD(t)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(t)}},DY=t=>{const[e]=k.useState(()=>new PY(t));k.useEffect(()=>{e.setAdapter(t)});const{modelContext:n}=_Y()??{};return k.useEffect(()=>{if(n)return e.registerModelContextProvider(n)},[n,e]),k.useMemo(()=>new tj(e),[e])},wx=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},IY=(t=>t?SD(t):SD),LY=t=>t;function NY(t,e=LY){const n=be.useSyncExternalStore(t.subscribe,be.useCallback(()=>e(t.getState()),[t,e]),be.useCallback(()=>e(t.getInitialState()),[t,e]));return be.useDebugValue(n),n}const _D=t=>{const e=IY(t),n=r=>NY(e,r);return Object.assign(n,e),n},na=(t=>t?_D(t):_D);var $Y=()=>{const t=new Set;return na(()=>({isAtBottom:!0,scrollToBottom:()=>{for(const e of t)e()},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)})}))};function jY(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 U$(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 H$=k.createContext(null),BY=jY(H$,"ThreadPrimitive.Viewport"),{useThreadViewport:FY,useThreadViewportStore:W$}=U$(BY,"useThreadViewport"),Kb=t=>t,zY=()=>{const t=W$({optional:!0}),[e]=k.useState(()=>$Y());return k.useEffect(()=>t?.getState().onScrollToBottom(()=>{e.getState().scrollToBottom()}),[t,e]),k.useEffect(()=>{if(t)return e.subscribe(n=>{t.getState().isAtBottom!==n.isAtBottom&&Kb(t).setState({isAtBottom:n.isAtBottom})})},[e,t]),e},q$=({children:t})=>{const e=zY(),[n]=k.useState(()=>({useThreadViewport:e}));return C.jsx(H$.Provider,{value:n,children:t})},Gn=t=>{const e=t.get;return e.source=t.source,e.query=t.query,e},ul=()=>()=>{},G$=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}=wx(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(G$),VY=(t,e)=>t===ul?e:e===ul?t:(...n)=>{t(...n),e(...n)},UY=(t,e)=>t===ul?e:e===ul?t:(...n)=>{const r=t(...n),i=e(...n);return()=>{r(),i()}},HY=(t,e)=>{const n=e.subscribe,r=e.flushSync;return{...t,...e,subscribe:UY(t.subscribe,n??ul),flushSync:VY(t.flushSync,r??ul)}},Sx=({api:t,children:e})=>{const n=Ti(),r=k.useMemo(()=>HY(n,t),[n,t]);return C.jsx(G$,{value:r,children:C.jsx(q$,{children:e})})};function Jn(t){return(e,n)=>({type:t,props:e,...n?.key!==void 0&&{key:n.key}})}var yp=null;function WY(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 OE(){if(!yp)throw new Error("No resource fiber available");return yp}var qY=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 GY(t){const e=OE(),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,qY(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=GY(t);return[e.value,e.set]}function KY(){const t=OE(),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=OE(),r=KY();n.renderContext.commitTasks.push({effect:t,deps:e,cellIndex:r})}function Yb(t){const[e]=Go(()=>({current:t!==void 0&&typeof t=="function"?t():t}));return e}var YY=(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=Yb(()=>({value:t(),deps:e}));return YY(n.current.deps,e)||(n.current.value=t(),n.current.deps=e),n.current.value};function XY(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 JY(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 _x(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,JY(t)}function Up(t,e){const n={commitTasks:[],props:e,state:void 0};return WY(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,XY(e,t)}function QY(t,e){const[n,r]=Go({}),i=Ht(()=>_x(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 ZY(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=_x(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 F2=[],z2=!1;function eX(){z2=!1;const t=F2;F2=[];for(const e of t)try{e()}catch(n){console.error("Error in scheduled task:",n)}}function tX(t){F2.push(t),z2||(z2=!0,queueMicrotask(eX))}var nX=class K${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,tX(()=>{this._hasScheduledTask=!1,this.flushSync()}))}flushSync(){if(this._isFlushing)return;this._isFlushing=!0;let e=0;try{for(;this._isDirty;){if(e++,e>K$.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}}},rX=({element:t,onUpdateInput:e,onFlushSync:n,onDispose:r})=>{const[i,s]=Go(t.props),o=_s({type:t.type,props:i}),a=Yb(new Set).current,c=Yb(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}),[])},iX=(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 nX(()=>{o=Up(s,r),n&&dh(s,o)}),s=_x(rX,()=>i.markDirty());let o=Up(s,r);return n&&dh(s,o),o.state},bp=Symbol("tap.Context"),sX=t=>({[bp]:t}),oX=(t,e,n)=>{const r=t[bp];t[bp]=e;try{return n()}finally{t[bp]=r}},aX=t=>t[bp],Y$=Jn(t=>{const e=Ht(()=>iX(t,!0),[t.type]);return Ss(()=>{e.updateInput(t.props)}),e}),lX=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=Yb(()=>t);Ss(()=>{n.current=t});const r=Ht(()=>new Proxy({},new lX(()=>n.current)),[]),i=e?.key,s=t.getState();return Ht(()=>({key:i,state:s,api:r}),[s,i])},cX=globalThis.__ASSISTANT_UI_DISABLE_LAYOUT_EFFECT__===!0,CD=cX?k.useEffect:k.useLayoutEffect;function X$(t){const[,e]=k.useState({}),n=k.useMemo(()=>_x(t.type,()=>e({})),[t.type]),r=Up(n,t.props);return CD(()=>()=>fh(n),[]),CD(()=>{dh(n,r)}),r.state}var uX=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})})}}},[])),hX=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)??[]}))})})}),J$=sX(null),fX=(t,e)=>oX(J$,t,e),PE=()=>{const t=aX(J$);if(!t)throw new Error("Events context is not available");return t},dX=Jn(({threads:t,registerModelContextProvider:e,__internal_runtime:n})=>{const r=_s(uX()),{threads:i,toolUIs:s}=fX(r,()=>({toolUIs:_s(hX()),threads:QY(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})}),pX=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}=wx(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}},mX=t=>{const e=X$(Y$(dX(t)));return k.useMemo(()=>pX(e),[e])},Dc=t=>{const[,e]=Go(t.getState);return Ss(()=>(e(t.getState()),t.subscribe(()=>{e(t.getState())})),[t]),t.getState()},gX=Jn(({runtime:t})=>{const e=Dc(t),n=PE();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=ZY(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}}},Q$=Jn(({runtime:t})=>{const e=Dc(t);return bo({getState:()=>e,remove:t.remove,__internal_getRuntime:()=>t},{key:e.id})}),yX=Jn(({runtime:t,index:e})=>{const n=Ht(()=>t.getAttachmentByIndex(e),[t,e]);return _s(Q$({runtime:n}))}),Z$=Jn(({threadIdRef:t,messageIdRef:e,runtime:n})=>{const r=Dc(n),i=PE();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)=>yX({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})}),bX=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})}),vX=Jn(({runtime:t,index:e})=>{const n=Ht(()=>t.getAttachmentByIndex(e),[t,e]);return _s(Q$({runtime:n}))}),xX=Jn(({runtime:t,index:e})=>{const n=Ht(()=>t.getMessagePartByIndex(e),[t,e]);return _s(bX({runtime:n}))}),wX=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(Z$({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)=>vX({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})}),SX=Jn(({runtime:t,id:e,threadIdRef:n})=>{const r=Ht(()=>t.getMessageById(e),[t,e]);return _s(wX({runtime:r,threadIdRef:n}))}),_X=Jn(({runtime:t})=>{const e=Dc(t),n=PE();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(Z$({runtime:t.composer,threadIdRef:r})),s=Hp(e.messages.map(a=>SX({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})}),CX=Jn(({runtime:t,id:e})=>{const n=Ht(()=>t.getItemById(e),[t,e]);return _s(gX({runtime:n}))}),AX=Jn(({runtime:t})=>{const e=Dc(t),n=_s(_X({runtime:t.main})),r=Hp(Object.keys(e.threadItems).map(s=>CX({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()}})}),EX=t=>t._core?.RenderComponent,kX=({children:t,runtime:e})=>{const n=mX({threads:AX({runtime:e.threads}),registerModelContextProvider:e.registerModelContextProvider,__internal_runtime:e}),r=EX(e);return C.jsxs(Sx,{api:n,children:[r&&C.jsx(r,{}),t]})},TX=k.memo(kX),RX=({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}=wx(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(Sx,{api:r,children:e})},MX=({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(Sx,{api:r,children:e})},OX=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})}),PX=({text:t,isRunning:e=!1,children:n})=>{const r=X$(Y$(OX({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(Sx,{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},DX=(t,e)=>{const n=Ti(),r=k.useRef(e);k.useEffect(()=>{r.current=e});const{scope:i,event:s}=wx(t);k.useEffect(()=>n.on({scope:i,event:s},o=>r.current(o)),[n,i,s])},IX=t=>{const e=t;e.__isBound||(e.__internal_bindMethods?.(),e.__isBound=!0)};function LX(t,e=NX){IX(t);const n=k.useSyncExternalStore(t.subscribe,()=>e(t.getState()),()=>e(t.getState()));return k.useDebugValue(n),n}var NX=t=>t;function $X(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?LX(s,i):null}return e}function jX(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=$X(jX),tj=class{constructor(t){this._core=t,this.threads=new gY(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(TE.fromArray(t??[]))}},BX=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),FX=t=>({useSmoothStatus:na(()=>t)}),zX=({children:t})=>{const e=rj({optional:!0}),n=Ti(),[r]=k.useState(()=>FX(n.part().getState().status));return e?t:C.jsx(nj.Provider,{value:r,children:t})},VX=t=>{const e=k.forwardRef((n,r)=>C.jsx(zX,{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:UX,useSmoothStatusStore:HX}=U$(rj,"useSmoothStatus"),WX=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))}},$S=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=HX({optional:!0}),c=Lr(f=>{if(o(f),a){const d=s!==f||t.status.type==="running"?$S:t.status;Kb(a).setState(d,!0)}});k.useEffect(()=>{if(a){const f=s!==n||t.status.type==="running"?$S:t.status;Kb(a).setState(f,!0)}},[a,n,s,t.status]);const[h]=k.useState(new WX(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:$S}:t,[e,s,t,n])};const qX=Object.freeze(Object.defineProperty({__proto__:null,AssistantRuntimeImpl:tj,BaseAssistantRuntimeCore:M$,CompositeContextProvider:R$,DefaultThreadComposerRuntimeCore:P$,MessageRepository:RE,ThreadRuntimeImpl:z$,fromThreadMessageLike:vx,generateId:bx,getAutoStatus:kE,splitLocalRuntimeOptions:BX,useSmooth:ij,useSmoothStatus:UX,withSmoothContextProvider:VX},Symbol.toStringTag,{value:"Module"}));function ED(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Cx(...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(Cx(...t),t)}var DE=T$();const GX=Pc(DE);function Rh(t){const e=KX(t),n=k.forwardRef((r,i)=>{const{children:s,...o}=r,a=k.Children.toArray(s),c=a.find(XX);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 KX(t){const e=k.forwardRef((n,r)=>{const{children:i,...s}=n;if(k.isValidElement(i)){const o=QX(i),a=JX(s,i.props);return i.type!==k.Fragment&&(a.ref=r?Cx(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 YX(t){const e=({children:n})=>C.jsx(C.Fragment,{children:n});return e.displayName=`${t}.Slottable`,e.__radixId=oj,e}function XX(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===oj}function JX(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 QX(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 ZX=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],st=ZX.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&&DE.flushSync(()=>t.dispatchEvent(e))}var V2=(t=>(t.Hidden="hidden",t.Floating="floating",t.Normal="normal",t))(V2||{}),eJ=({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=eJ({hideWhenRunning:t,autohide:e,autohideFloat:n});return s===V2.Hidden?null:C.jsx(st.div,{...s===V2.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 tJ=({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=tJ({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 nJ(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,x=m?.[t]?.[c]||a,S=k.useMemo(()=>b,Object.values(b));return C.jsx(x.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,rJ(i,...e)]}function rJ(...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 iJ="DismissableLayer",U2="dismissableLayer.update",sJ="dismissableLayer.pointerDownOutside",oJ="dismissableLayer.focusOutside",kD,fj=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ax=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)),x=Array.from(h.layers),[S]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),_=x.indexOf(S),A=f?x.indexOf(f):-1,E=h.layersWithOutsidePointerEventsDisabled.size>0,P=A>=_,O=cJ(D=>{const N=D.target,H=[...h.branches].some(j=>j.contains(N));!P||H||(i?.(D),o?.(D),D.defaultPrevented||a?.())},m),M=uJ(D=>{const N=D.target;[...h.branches].some(j=>j.contains(N))||(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(U2,D),()=>document.removeEventListener(U2,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)})});Ax.displayName=iJ;var aJ="DismissableLayerBranch",lJ=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})});lJ.displayName=aJ;function cJ(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(sJ,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 uJ(t,e=globalThis?.document){const n=Lr(t),r=k.useRef(!1);return k.useEffect(()=>{const i=s=>{s.target&&!r.current&&dj(oJ,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(U2);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 jS=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()),jS++,()=>{jS===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),jS--}},[])}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 BS="focusScope.autoFocusOnMount",FS="focusScope.autoFocusOnUnmount",MD={bubbles:!1,cancelable:!0},hJ="FocusScope",IE=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,x=>c(x)),y=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(r){let x=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",x),document.addEventListener("focusout",S);const A=new MutationObserver(_);return a&&A.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",S),A.disconnect()}}},[r,a,y.paused]),k.useEffect(()=>{if(a){PD.add(y);const x=document.activeElement;if(!a.contains(x)){const _=new CustomEvent(BS,MD);a.addEventListener(BS,h),a.dispatchEvent(_),_.defaultPrevented||(fJ(yJ(mj(a)),{select:!0}),document.activeElement===x&&Ka(a))}return()=>{a.removeEventListener(BS,h),setTimeout(()=>{const _=new CustomEvent(FS,MD);a.addEventListener(FS,f),a.dispatchEvent(_),_.defaultPrevented||Ka(x??document.body,{select:!0}),a.removeEventListener(FS,f),PD.remove(y)},0)}}},[a,h,f,y]);const b=k.useCallback(x=>{if(!n&&!r||y.paused)return;const S=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,_=document.activeElement;if(S&&_){const A=x.currentTarget,[E,P]=dJ(A);E&&P?!x.shiftKey&&_===P?(x.preventDefault(),n&&Ka(E,{select:!0})):x.shiftKey&&_===E&&(x.preventDefault(),n&&Ka(P,{select:!0})):_===A&&x.preventDefault()}},[n,r,y.paused]);return C.jsx(st.div,{tabIndex:-1,...o,ref:m,onKeyDown:b})});IE.displayName=hJ;function fJ(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Ka(r,{select:e}),document.activeElement!==n)return}function dJ(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(!pJ(n,{upTo:e}))return n}function pJ(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 mJ(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&&mJ(t)&&e&&t.select()}}var PD=gJ();function gJ(){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 yJ(t){return t.filter(e=>e.tagName!=="A")}var hl=globalThis?.document?k.useLayoutEffect:()=>{},bJ=k$[" useId ".trim().toString()]||(()=>{}),vJ=0;function ol(t){const[e,n]=k.useState(bJ());return hl(()=>{n(r=>r??String(vJ++))},[t]),e?`radix-${e}`:""}const xJ=["top","right","bottom","left"],fl=Math.min,Ci=Math.max,Xb=Math.round,P0=Math.floor,lo=t=>({x:t,y:t}),wJ={left:"right",right:"left",bottom:"top",top:"bottom"},SJ={start:"end",end:"start"};function H2(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 LE(t){return t==="x"?"y":"x"}function NE(t){return t==="y"?"height":"width"}const _J=new Set(["top","bottom"]);function ro(t){return _J.has(Yo(t))?"y":"x"}function $E(t){return LE(ro(t))}function CJ(t,e,n){n===void 0&&(n=!1);const r=Hh(t),i=$E(t),s=NE(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=Jb(o)),[o,Jb(o)]}function AJ(t){const e=Jb(t);return[W2(t),e,W2(e)]}function W2(t){return t.replace(/start|end/g,e=>SJ[e])}const ID=["left","right"],LD=["right","left"],EJ=["top","bottom"],kJ=["bottom","top"];function TJ(t,e,n){switch(t){case"top":case"bottom":return n?e?LD:ID:e?ID:LD;case"left":case"right":return e?EJ:kJ;default:return[]}}function RJ(t,e,n,r){const i=Hh(t);let s=TJ(Yo(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(W2)))),s}function Jb(t){return t.replace(/left|right|bottom|top/g,e=>wJ[e])}function MJ(t){return{top:0,right:0,bottom:0,left:0,...t}}function gj(t){return typeof t!="number"?MJ(t):{top:t,right:t,bottom:t,left:t}}function Qb(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=$E(e),a=NE(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 OJ=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 x=0;x<a.length;x++){const{name:S,fn:_}=a[x],{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)),x=-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],_=Qb(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=Qb(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 PJ=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=$E(i),b=NE(y),x=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 N=P/2-O/2,H=D/2-x[b]/2-1,j=fl(d[_],H),V=fl(d[A],H),q=j,X=D-x[b]-V,Y=D/2-x[b]/2+N,te=H2(q,Y,X),z=!c.arrow&&Hh(i)!=null&&Y!==te&&s.reference[b]/2-(Y<q?j:V)-x[b]/2<0,G=z?Y<q?Y-q:Y-X:0;return{[y]:m[y]+G,data:{[y]:te,centerOffset:Y-te-G,...z&&{alignmentOffset:G}},reset:z}}}),DJ=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:x=!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||!x?[Jb(a)]:AJ(a)),M=b!=="none";!m&&M&&O.push(...RJ(a,x,b,P));const D=[a,...O],N=await Wp(e,S),H=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&H.push(N[_]),d){const Y=CJ(i,o,P);H.push(N[Y[0]],N[Y[1]])}if(j=[...j,{placement:i,overflows:H}],!H.every(Y=>Y<=0)){var V,q;const Y=(((V=s.flip)==null?void 0:V.index)||0)+1,te=D[Y];if(te&&(!(d==="alignment"?A!==ro(te):!1)||j.every(U=>ro(U.placement)===A?U.overflows[0]>0:!0)))return{data:{index:Y,overflows:j},reset:{placement:te}};let z=(q=j.filter(G=>G.overflows[0]<=0).sort((G,U)=>G.overflows[1]-U.overflows[1])[0])==null?void 0:q.placement;if(!z)switch(y){case"bestFit":{var X;const G=(X=j.filter(U=>{if(M){const se=ro(U.placement);return se===A||se==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(se=>se>0).reduce((se,T)=>se+T,0)]).sort((U,se)=>U[1]-se[1])[0])==null?void 0:X[0];G&&(z=G);break}case"initialPlacement":z=a;break}if(i!==z)return{reset:{placement:z}}}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 IJ=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 LJ(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 NJ=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 LJ(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}}}}},$J=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=LE(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=H2(A,y,E)}if(o){const S=d==="y"?"top":"left",_=d==="y"?"bottom":"right",A=b+f[S],E=b-f[_];b=H2(A,b,E)}const x=a.fn({...e,[m]:y,[d]:b});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[m]:s,[d]:o}}}}}},jJ=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=LE(d);let y=f[m],b=f[d];const x=Ko(a,e),S=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};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}}}},BJ=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:x}=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=x-f.top-f.bottom,E=b-f.left-f.right,P=fl(x-f[S],A),O=fl(b-f[_],E),M=!e.middlewareData.shift;let D=P,N=O;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(N=E),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(D=A),M&&!m){const j=Ci(f.left,0),V=Ci(f.right,0),q=Ci(f.top,0),X=Ci(f.bottom,0);y?N=b-2*(j!==0||V!==0?j+V:Ci(f.left,f.right)):D=x-2*(q!==0||X!==0?q+X:Ci(f.top,f.bottom))}await c({...e,availableWidth:N,availableHeight:D});const H=await o.getDimensions(a.floating);return b!==H.width||x!==H.height?{reset:{rects:!0}}:{}}}};function Ex(){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 Ex()?t instanceof Node||t instanceof Ei(t).Node:!1}function Cs(t){return Ex()?t instanceof Element||t instanceof Ei(t).Element:!1}function mo(t){return Ex()?t instanceof HTMLElement||t instanceof Ei(t).HTMLElement:!1}function BD(t){return!Ex()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ei(t).ShadowRoot}const FJ=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)&&!FJ.has(i)}const zJ=new Set(["table","td","th"]);function VJ(t){return zJ.has(Wh(t))}const UJ=[":popover-open",":modal"];function kx(t){return UJ.some(e=>{try{return t.matches(e)}catch{return!1}})}const HJ=["transform","translate","scale","rotate","perspective"],WJ=["transform","translate","scale","rotate","perspective","filter"],qJ=["paint","layout","strict","content"];function jE(t){const e=BE(),n=Cs(t)?As(t):t;return HJ.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)||WJ.some(r=>(n.willChange||"").includes(r))||qJ.some(r=>(n.contain||"").includes(r))}function GJ(t){let e=dl(t);for(;mo(e)&&!Mh(e);){if(jE(e))return e;if(kx(e))return null;e=dl(e)}return null}function BE(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const KJ=new Set(["html","body","#document"]);function Mh(t){return KJ.has(Wh(t))}function As(t){return Ei(t).getComputedStyle(t)}function Tx(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=q2(o);return e.concat(o,o.visualViewport||[],Dm(i)?i:[],a&&n?qp(a):[])}return e.concat(i,qp(i,[],n))}function q2(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function xj(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=Xb(n)!==s||Xb(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function FE(t){return Cs(t)?t:t.contextElement}function ph(t){const e=FE(t);if(!mo(e))return lo(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=xj(e);let o=(s?Xb(n.width):n.width)/r,a=(s?Xb(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const YJ=lo(0);function wj(t){const e=Ei(t);return!BE()||!e.visualViewport?YJ:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function XJ(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ei(t)?!1:e}function wc(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=FE(t);let o=lo(1);e&&(r?Cs(r)&&(o=ph(r)):o=ph(t));const a=XJ(s,n,r)?wj(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,x=q2(b);for(;x&&r&&y!==b;){const S=ph(x),_=x.getBoundingClientRect(),A=As(x),E=_.left+(x.clientLeft+parseFloat(A.paddingLeft))*S.x,P=_.top+(x.clientTop+parseFloat(A.paddingTop))*S.y;c*=S.x,h*=S.y,f*=S.x,d*=S.y,c+=E,h+=P,b=Ei(x),x=q2(b)}}return Qb({width:f,height:d,x:c,y:h})}function Rx(t,e){const n=Tx(t).scrollLeft;return e?e.left+n:wc(vo(t)).left+n}function Sj(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Rx(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function JJ(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=vo(r),a=e?kx(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=Tx(r)),mo(r))){const y=wc(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 QJ(t){return Array.from(t.getClientRects())}function ZJ(t){const e=vo(t),n=Tx(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+Rx(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 eQ(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=BE();(!f||f&&e==="fixed")&&(a=i.offsetLeft,c=i.offsetTop)}const h=Rx(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 tQ=new Set(["absolute","fixed"]);function nQ(t,e){const n=wc(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=eQ(t,n);else if(e==="document")r=ZJ(vo(t));else if(Cs(e))r=nQ(e,n);else{const i=wj(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return Qb(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 rQ(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=jE(o);!c&&a.position==="fixed"&&(i=null),(s?!c&&!i:!c&&a.position==="static"&&!!i&&tQ.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 iQ(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?kx(e)?[]:rQ(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 sQ(t){const{width:e,height:n}=xj(t);return{width:e,height:n}}function oQ(t,e,n){const r=mo(e),i=vo(e),s=n==="fixed",o=wc(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const c=lo(0);function h(){c.x=Rx(i)}if(r||!r&&!s)if((Wh(e)!=="body"||Dm(i))&&(a=Tx(e)),r){const y=wc(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 zS(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(kx(t))return n;if(!mo(t)){let i=dl(t);for(;i&&!Mh(i);){if(Cs(i)&&!zS(i))return i;i=dl(i)}return n}let r=VD(t,e);for(;r&&VJ(r)&&zS(r);)r=VD(r,e);return r&&Mh(r)&&zS(r)&&!jE(r)?n:r||GJ(t)||n}const aQ=async function(t){const e=this.getOffsetParent||Cj,n=this.getDimensions,r=await n(t.floating);return{reference:oQ(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function lQ(t){return As(t).direction==="rtl"}const cQ={convertOffsetParentRelativeRectToViewportRelativeRect:JJ,getDocumentElement:vo,getClippingRect:iQ,getOffsetParent:Cj,getElementRects:aQ,getClientRects:QJ,getDimensions:sQ,getScale:ph,isElement:Cs,isRTL:lQ};function Aj(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function uQ(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=P0(d),x=P0(i.clientWidth-(f+m)),S=P0(i.clientHeight-(d+y)),_=P0(f),E={rootMargin:-b+"px "+-x+"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 hQ(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=FE(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?uQ(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,x=c?wc(t):null;c&&S();function S(){const _=wc(t);x&&!Aj(x,_)&&n(),x=_,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 fQ=NJ,dQ=$J,pQ=DJ,mQ=BJ,gQ=IJ,UD=PJ,yQ=jJ,bQ=(t,e,n)=>{const r=new Map,i={platform:cQ,...n},s={...i.platform,_c:r};return OJ(t,e,{...i,platform:s})};var vQ=typeof document<"u",xQ=function(){},ib=vQ?k.useLayoutEffect:xQ;function Zb(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(!Zb(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)&&!Zb(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 VS(t){const e=k.useRef(t);return ib(()=>{e.current=t}),e}function wQ(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);Zb(m,r)||y(r);const[b,x]=k.useState(null),[S,_]=k.useState(null),A=k.useCallback(U=>{U!==M.current&&(M.current=U,x(U))},[]),E=k.useCallback(U=>{U!==D.current&&(D.current=U,_(U))},[]),P=s||b,O=o||S,M=k.useRef(null),D=k.useRef(null),N=k.useRef(f),H=c!=null,j=VS(c),V=VS(i),q=VS(h),X=k.useCallback(()=>{if(!M.current||!D.current)return;const U={placement:e,strategy:n,middleware:m};V.current&&(U.platform=V.current),bQ(M.current,D.current,U).then(se=>{const T={...se,isPositioned:q.current!==!1};Y.current&&!Zb(N.current,T)&&(N.current=T,DE.flushSync(()=>{d(T)}))})},[m,e,n,V,q]);ib(()=>{h===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,d(U=>({...U,isPositioned:!1})))},[h]);const Y=k.useRef(!1);ib(()=>(Y.current=!0,()=>{Y.current=!1}),[]),ib(()=>{if(P&&(M.current=P),O&&(D.current=O),P&&O){if(j.current)return j.current(P,O,X);X()}},[P,O,X,j,H]);const te=k.useMemo(()=>({reference:M,floating:D,setReference:A,setFloating:E}),[A,E]),z=k.useMemo(()=>({reference:P,floating:O}),[P,O]),G=k.useMemo(()=>{const U={position:n,left:0,top:0};if(!z.floating)return U;const se=HD(z.floating,f.x),T=HD(z.floating,f.y);return a?{...U,transform:"translate("+se+"px, "+T+"px)",...Ej(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:se,top:T}},[n,a,z.floating,f.x,f.y]);return k.useMemo(()=>({...f,update:X,refs:te,elements:z,floatingStyles:G}),[f,X,te,z,G])}const SQ=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):{}}}},_Q=(t,e)=>({...fQ(t),options:[t,e]}),CQ=(t,e)=>({...dQ(t),options:[t,e]}),AQ=(t,e)=>({...yQ(t),options:[t,e]}),EQ=(t,e)=>({...pQ(t),options:[t,e]}),kQ=(t,e)=>({...mQ(t),options:[t,e]}),TQ=(t,e)=>({...gQ(t),options:[t,e]}),RQ=(t,e)=>({...SQ(t),options:[t,e]});var MQ="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=MQ;var OQ=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 zE="Popper",[Rj,Mx]=ra(zE),[PQ,Mj]=Rj(zE),Oj=t=>{const{__scopePopper:e,children:n}=t,[r,i]=k.useState(null);return C.jsx(PQ,{scope:e,anchor:r,onAnchorChange:i,children:n})};Oj.displayName=zE;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 VE="PopperContent",[DQ,IQ]=Rj(VE),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,...x}=t,S=Mj(VE,n),[_,A]=k.useState(null),E=Bt(e,Ee=>A(Ee)),[P,O]=k.useState(null),M=Tj(P),D=M?.width??0,N=M?.height??0,H=r+(s!=="center"?"-"+s:""),j=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},V=Array.isArray(h)?h:[h],q=V.length>0,X={padding:j,boundary:V.filter(NQ),altBoundary:q},{refs:Y,floatingStyles:te,placement:z,isPositioned:G,middlewareData:U}=wQ({strategy:"fixed",placement:H,whileElementsMounted:(...Ee)=>hQ(...Ee,{animationFrame:y==="always"}),elements:{reference:S.anchor},middleware:[_Q({mainAxis:i+N,alignmentAxis:o}),c&&CQ({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?AQ():void 0,...X}),c&&EQ({...X}),kQ({...X,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&&RQ({element:P,padding:a}),$Q({arrowWidth:D,arrowHeight:N}),m&&TQ({strategy:"referenceHidden",...X})]}),[se,T]=$j(z),Z=Lr(b);hl(()=>{G&&Z?.()},[G,Z]);const ue=U.arrow?.x,L=U.arrow?.y,de=U.arrow?.centerOffset!==0,[ke,ye]=k.useState();return hl(()=>{_&&ye(window.getComputedStyle(_).zIndex)},[_]),C.jsx("div",{ref:Y.setFloating,"data-radix-popper-content-wrapper":"",style:{...te,transform:G?te.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ke,"--radix-popper-transform-origin":[U.transformOrigin?.x,U.transformOrigin?.y].join(" "),...U.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:C.jsx(DQ,{scope:n,placedSide:se,onArrowChange:O,arrowX:ue,arrowY:L,shouldHideArrow:de,children:C.jsx(st.div,{"data-side":se,"data-align":T,...x,ref:E,style:{...x.style,animation:G?void 0:"none"}})})})});Ij.displayName=VE;var Lj="PopperArrow",LQ={top:"bottom",right:"left",bottom:"top",left:"right"},Nj=k.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=IQ(Lj,r),o=LQ[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(OQ,{...i,ref:n,style:{...i.style,display:"block"}})})});Nj.displayName=Lj;function NQ(t){return t!==null}var $Q=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="",x="";return h==="bottom"?(b=o?d:`${m}px`,x=`${-c}px`):h==="top"?(b=o?d:`${m}px`,x=`${r.floating.height+c}px`):h==="right"?(b=`${-c}px`,x=o?d:`${y}px`):h==="left"&&(b=`${r.floating.width+c}px`,x=o?d:`${y}px`),{data:{x:b,y:x}}}});function $j(t){const[e,n="center"]=t.split("-");return[e,n]}var jj=Oj,Bj=Dj,Fj=Ij,zj=Nj,jQ="Portal",Ox=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?GX.createPortal(C.jsx(st.div,{...r,ref:e}),o):null});Ox.displayName=jQ;function BQ(t,e){return k.useReducer((n,r)=>e[n][r]??n,t)}var Ts=t=>{const{present:e,children:n}=t,r=FQ(e),i=typeof n=="function"?n({present:r.isPresent}):k.Children.only(n),s=Bt(r.ref,zQ(i));return typeof n=="function"||r.isPresent?k.cloneElement(i,{ref:s}):null};Ts.displayName="Presence";function FQ(t){const[e,n]=k.useState(),r=k.useRef(null),i=k.useRef(t),s=k.useRef("none"),o=t?"mounted":"unmounted",[a,c]=BQ(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const h=D0(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=D0(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 x=D0(r.current).includes(CSS.escape(y.animationName));if(y.target===e&&x&&(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=D0(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 D0(t){return t?.animationName||"none"}function zQ(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 VQ=k$[" useInsertionEffect ".trim().toString()]||hl;function qh({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[i,s,o]=UQ({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=HQ(f)?f(t):f;d!==t&&o.current?.(d)}else s(f)},[a,t,s,o]);return[c,h]}function UQ({defaultProp:t,onChange:e}){const[n,r]=k.useState(t),i=k.useRef(n),s=k.useRef(e);return VQ(()=>{s.current=e},[e]),k.useEffect(()=>{i.current!==n&&(s.current?.(n),i.current=n)},[n,i]),[n,r,s]}function HQ(t){return typeof t=="function"}var WQ=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Ru=new WeakMap,I0=new WeakMap,L0={},US=0,Vj=function(t){return t&&(t.host||Vj(t.parentNode))},qQ=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})},GQ=function(t,e,n,r){var i=qQ(e,Array.isArray(t)?t:[t]);L0[n]||(L0[n]=new WeakMap);var s=L0[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",x=(Ru.get(m)||0)+1,S=(s.get(m)||0)+1;Ru.set(m,x),s.set(m,S),o.push(m),x===1&&b&&I0.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(),US++,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||(I0.has(d)||d.removeAttribute(r),I0.delete(d)),y||d.removeAttribute(n)}),US--,US||(Ru=new WeakMap,Ru=new WeakMap,I0=new WeakMap,L0={})}},Uj=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),i=WQ(t);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),GQ(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 sb(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 ob="right-scroll-bar-position",ab="width-before-scroll-bar",KQ="with-scroll-bars-hidden",YQ="--removed-body-scroll-bar-size";function HS(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function XQ(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 JQ=typeof window<"u"?k.useLayoutEffect:k.useEffect,WD=new WeakMap;function QQ(t,e){var n=XQ(null,function(r){return t.forEach(function(i){return HS(i,r)})});return JQ(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)||HS(a,null)}),s.forEach(function(a){i.has(a)||HS(a,o)})}WD.set(n,t)},[t]),n}function ZQ(t){return t}function eZ(t,e){e===void 0&&(e=ZQ);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 tZ(t){t===void 0&&(t={});var e=eZ(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 nZ(t,e){return t.useMedium(e),Wj}var qj=tZ(),WS=function(){},Px=k.forwardRef(function(t,e){var n=k.useRef(null),r=k.useState({onScrollCapture:WS,onWheelCapture:WS,onTouchMoveCapture:WS}),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,x=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=QQ([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:x,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))});Px.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Px.classNames={fullWidth:ab,zeroRight:ob};var rZ=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function iZ(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=rZ();return e&&t.setAttribute("nonce",e),t}function sZ(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function oZ(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var aZ=function(){var t=0,e=null;return{add:function(n){t==0&&(e=iZ())&&(sZ(e,n),oZ(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},lZ=function(){var t=aZ();return function(e,n){k.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},Gj=function(){var t=lZ(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},cZ={left:0,top:0,right:0,gap:0},qS=function(t){return parseInt(t||"",10)||0},uZ=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[qS(n),qS(r),qS(i)]},hZ=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return cZ;var e=uZ(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])}},fZ=Gj(),mh="data-scroll-locked",dZ=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(KQ,` {
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(ob,` {
right: `).concat(a,"px ").concat(r,`;
}
.`).concat(ab,` {
margin-right: `).concat(a,"px ").concat(r,`;
}
.`).concat(ob," .").concat(ob,` {
right: 0 `).concat(r,`;
}
.`).concat(ab," .").concat(ab,` {
margin-right: 0 `).concat(r,`;
}
body[`).concat(mh,`] {
`).concat(YQ,": ").concat(a,`px;
}
`)},qD=function(){var t=parseInt(document.body.getAttribute(mh)||"0",10);return isFinite(t)?t:0},pZ=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())}},[])},mZ=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,i=r===void 0?"margin":r;pZ();var s=k.useMemo(function(){return hZ(i)},[i]);return k.createElement(fZ,{styles:dZ(s,!e,i,n?"":"!important")})},G2=!1;if(typeof window<"u")try{var N0=Object.defineProperty({},"passive",{get:function(){return G2=!0,!0}});window.addEventListener("test",N0,N0),window.removeEventListener("test",N0,N0)}catch{G2=!1}var Mu=G2?{passive:!1}:!1,gZ=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&&!gZ(t)&&n[e]==="visible")},yZ=function(t){return Kj(t,"overflowY")},bZ=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},vZ=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"?yZ(e):bZ(e)},Xj=function(t,e){return t==="v"?vZ(e):xZ(e)},wZ=function(t,e){return t==="h"&&e==="rtl"?-1:1},SZ=function(t,e,n,r,i){var s=wZ(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],x=y[1],S=y[2],_=x-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},$0=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},_Z=function(t,e){return t[0]===e[0]&&t[1]===e[1]},CZ=function(t){return`
.block-interactivity-`.concat(t,` {pointer-events: none;}
.allow-interactivity-`).concat(t,` {pointer-events: all;}
`)},AZ=0,Ou=[];function EZ(t){var e=k.useRef([]),n=k.useRef([0,0]),r=k.useRef(),i=k.useState(AZ++)[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 x=sb([t.lockRef.current],(t.shards||[]).map(YD),!0).filter(Boolean);return x.forEach(function(S){return S.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),x.forEach(function(S){return S.classList.remove("allow-interactivity-".concat(i))})}}},[t.inert,t.lockRef.current,t.shards]);var a=k.useCallback(function(x,S){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!o.current.allowPinchZoom;var _=$0(x),A=n.current,E="deltaX"in x?x.deltaX:A[0]-_[0],P="deltaY"in x?x.deltaY:A[1]-_[1],O,M=x.target,D=Math.abs(E)>Math.abs(P)?"h":"v";if("touches"in x&&D==="h"&&M.type==="range")return!1;var N=GD(D,M);if(!N)return!0;if(N?O=D:(O=D==="v"?"h":"v",N=GD(D,M)),!N)return!1;if(!r.current&&"changedTouches"in x&&(E||P)&&(r.current=O),!O)return!0;var H=r.current||O;return SZ(H,S,x,H==="h"?E:P)},[]),c=k.useCallback(function(x){var S=x;if(!(!Ou.length||Ou[Ou.length-1]!==s)){var _="deltaY"in S?KD(S):$0(S),A=e.current.filter(function(O){return O.name===S.type&&(O.target===S.target||S.target===O.shadowParent)&&_Z(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(x,S,_,A){var E={name:x,delta:S,target:_,should:A,shadowParent:kZ(_)};e.current.push(E),setTimeout(function(){e.current=e.current.filter(function(P){return P!==E})},1)},[]),f=k.useCallback(function(x){n.current=$0(x),r.current=void 0},[]),d=k.useCallback(function(x){h(x.type,KD(x),x.target,a(x,t.lockRef.current))},[]),m=k.useCallback(function(x){h(x.type,$0(x),x.target,a(x,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(x){return x!==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:CZ(i)}):null,y?k.createElement(mZ,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function kZ(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const TZ=nZ(qj,EZ);var UE=k.forwardRef(function(t,e){return k.createElement(Px,Zs({},t,{ref:e,sideCar:TZ}))});UE.classNames=Px.classNames;var HE=t=>{const e=k.useRef(void 0);return k.useCallback(r=>{e.current&&e.current(),r&&(e.current=t(r))},[t])},RZ=()=>{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 HE(n)},WE=k.forwardRef((t,e)=>{const n=RZ(),r=Bt(e,n);return C.jsx(st.div,{...t,ref:r})});WE.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 MZ=()=>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}=MZ();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},OZ=(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 PZ(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):OZ(t,e):QD({entries:()=>Object.entries(t)},{entries:()=>Object.entries(e)})}function DZ(t){const e=be.useRef(void 0);return n=>{const r=t(n);return PZ(e.current,r)?e.current:e.current=r}}var IZ=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},LZ=()=>{const t=Mt(DZ(e=>e.message.parts.map(n=>n.type)));return k.useMemo(()=>t.length===0?[]:IZ(t),[t])},NZ=({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},$Z=({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(NZ,{...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}`)}},K2=k.memo(({index:t,components:e})=>C.jsx(MX,{index:t,children:C.jsx($Z,{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);K2.displayName="MessagePrimitive.PartByIndex";var jZ=({status:t,component:e})=>C.jsx(PX,{text:"",isRunning:t.type==="running",children:C.jsx(e,{type:"text",text:"",status:t})}),BZ=Object.freeze({type:"complete"}),FZ=({components:t})=>{const e=Mt(n=>n.message.status??BZ);return t?.Empty?C.jsx(t.Empty,{status:e}):C.jsx(jZ,{status:e,component:t?.Text??Xa.Text})},zZ=k.memo(FZ,(t,e)=>t.components?.Empty===e.components?.Empty&&t.components?.Text===e.components?.Text),qE=({components:t})=>{const e=Mt(({message:i})=>i.parts.length),n=LZ(),r=k.useMemo(()=>e===0?C.jsx(zZ,{components:t}):n.map(i=>{if(i.type==="single")return C.jsx(K2,{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(K2,{index:i.startIndex+a,components:t},a))},i.startIndex)}}),[n,t,e]);return C.jsx(C.Fragment,{children:r})};qE.displayName="MessagePrimitive.Parts";var VZ=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)}),Y2=({children:t,...e})=>VZ(e)?t:null;Y2.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},UZ=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 HZ=k.useLayoutEffect,WZ=function(e){var n=be.useRef(e);return HZ(function(){n.current=e}),n},ZD=function(e,n){if(typeof e=="function"){e(n);return}e.current=n},qZ=function(e,n){var r=be.useRef();return be.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"},GZ=function(e){Object.keys(eI).forEach(function(n){e.style.setProperty(n,eI[n],"important")})},tI=GZ,Ar=null,nI=function(e,n){var r=e.scrollHeight;return n.sizingStyle.boxSizing==="border-box"?r+n.borderSize:r-n.paddingSize};function KZ(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(){},YZ=function(e,n){return e.reduce(function(r,i){return r[i]=n[i],r},{})},XZ=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],JZ=!!document.documentElement.currentStyle,QZ=function(e){var n=window.getComputedStyle(e);if(n===null)return null;var r=YZ(XZ,n),i=r.boxSizing;if(i==="")return null;JZ&&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}},ZZ=QZ;function GE(t,e,n){var r=WZ(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 eee=function(e,n){GE(document.body,"reset",function(r){e.current.form===r.target&&n(r)})},tee=function(e){GE(window,"resize",e)},nee=function(e){GE(document.fonts,"loadingdone",e)},ree=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],iee=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,ree),d=f.value!==void 0,m=k.useRef(null),y=qZ(m,n),b=k.useRef(0),x=k.useRef(),S=function(){var E=m.current,P=r&&x.current?x.current:ZZ(E);if(P){x.current=P;var O=KZ(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),eee(m,function(){if(!d){var A=m.current.value;requestAnimationFrame(function(){var E=m.current;E&&A!==E.value&&S()})}}),tee(S),nee(S),k.createElement("textarea",Gp({},f,{onChange:_,ref:y}))},see=k.forwardRef(iee),sB=t=>{const e=Lr(t),n=FY(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(),x=Mt(({composer:N})=>N.isEditing?N.text:""),S=e?sj:see,_=Mt(({thread:N})=>N.isDisabled)||n,A=k.useRef(null),E=Bt(y,A);hj(N=>{if(!a)return;const H=b.composer();H.getState().canCancel&&(H.cancel(),N.preventDefault())});const P=N=>{_||!o||N.nativeEvent.isComposing||N.key==="Enter"&&N.shiftKey===!1&&(b.thread().getState().isRunning||(N.preventDefault(),A.current?.closest("form")?.requestSubmit()))},O=async N=>{if(!d)return;const H=b.thread().getState().capabilities,j=Array.from(N.clipboardData?.files||[]);if(H.attachments&&j.length>0)try{N.preventDefault(),await Promise.all(j.map(V=>b.composer().addAttachment(V)))}catch(V){console.error("Error adding attachment:",V)}},M=t&&!_,D=k.useCallback(()=>{const N=A.current;!N||!M||(N.focus({preventScroll:!0}),N.setSelectionRange(N.value.length,N.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:x,...m,ref:E,disabled:_,onChange:Le(r,N=>{b.composer().getState().isEditing&&(b.composer().setText(N.target.value),b.flushSync())}),onKeyDown:Le(i,P),onPaste:Le(s,O)})});oB.displayName="ComposerPrimitive.Input";var oee=()=>{const t=Ti(),e=Mt(({composer:r})=>!r.canCancel),n=k.useCallback(()=>{t.composer().cancel()},[t]);return e?null:n},aee=uj("ComposerPrimitive.Cancel",oee),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 lee=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)),ev=({children:t,...e})=>lee(e)?t:null;ev.displayName="ThreadPrimitive.If";var cee=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 HE(n)},uee=({autoScroll:t=!0})=>{const e=k.useRef(null),n=W$(),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&&Kb(n).setState({isAtBottom:m})),r.current=f.scrollTop},a=cee(()=>{(i.current||n.getState().isAtBottom)&&s("instant"),o()}),c=HE(f=>(f.addEventListener("scroll",o),()=>{f.removeEventListener("scroll",o)}));return sB(()=>{s("auto")}),DX("thread.run-start",()=>s("auto")),Bt(a,c,e)},hB=k.forwardRef(({autoScroll:t,children:e,...n},r)=>{const i=uee({autoScroll:t}),s=Bt(r,i);return C.jsx(st.div,{...n,ref:s,children:e})});hB.displayName="ThreadPrimitive.ViewportScrollable";var X2=k.forwardRef((t,e)=>C.jsx(q$,{children:C.jsx(hB,{...t,ref:e})}));X2.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,hee=()=>null,fee=(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??hee;default:const r=e;throw new Error(`Unknown message role: ${r}`)}},dee=({components:t})=>{const e=Mt(({message:i})=>i.role),n=Mt(({message:i})=>i.composer.isEditing),r=fee(t,e,n);return C.jsx(r,{})},dB=k.memo(({index:t,components:e})=>C.jsx(RX,{index:t,children:C.jsx(dee,{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 pee=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 pe(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 J2=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 Q2 extends nt{constructor(e,n,r,i){super(`${Q2.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 Dx({message:r,cause:J2(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 xB(e,s,r,i):e===409?new wB(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 Q2(e,s,r,i)}},ys=class extends Ri{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},Dx=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 Dx{constructor({message:e}={}){super({message:e??"Request timed out."})}},yB=class extends Ri{},bB=class extends Ri{},vB=class extends Ri{},xB=class extends Ri{},wB=class extends Ri{},SB=class extends Ri{},_B=class extends Ri{},CB=class extends Ri{};const mee=/^[a-z][a-z0-9+.-]*:/i,gee=t=>mee.test(t);let Z2=t=>(Z2=Array.isArray,Z2(t)),iI=Z2;function sI(t){return typeof t!="object"?{}:t??{}}function yee(t){if(!t)return!0;for(const e in t)return!1;return!0}function bee(t,e){return Object.prototype.hasOwnProperty.call(t,e)}const vee=(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",wee=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function See(){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 _ee=()=>{const t=See();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=Cee();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 Cee(){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 Aee=()=>lI??(lI=_ee());function Eee(){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 KE(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 kee(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 Tee=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});function Ree(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 YE(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"?YE(e):e;Ye(this,mi,Ree([pe(this,mi,"f"),n]));const r=[];let i;for(;(i=Mee(pe(this,mi,"f"),pe(this,gi,"f")))!=null;){if(i.carriage&&pe(this,gi,"f")==null){Ye(this,gi,i.index);continue}if(pe(this,gi,"f")!=null&&(i.index!==pe(this,gi,"f")+1||i.carriage)){r.push(hI(pe(this,mi,"f").subarray(0,pe(this,gi,"f")-1))),Ye(this,mi,pe(this,mi,"f").subarray(pe(this,gi,"f"))),Ye(this,gi,null);continue}const s=pe(this,gi,"f")!==null?i.preceding-1:i.preceding,o=hI(pe(this,mi,"f").subarray(0,s));r.push(o),Ye(this,mi,pe(this,mi,"f").subarray(i.index)),Ye(this,gi,null)}return r}flush(){return pe(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 Mee(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 Oee(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 tv={off:0,error:200,warn:300,info:400,debug:500},fI=(t,e,n)=>{if(t){if(bee(tv,t))return t;kr(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(tv))}`)}};function Ud(){}function j0(t,e,n){return!e||tv[t]>tv[n]?Ud:e[t].bind(e)}const Pee={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 Pee;const r=dI.get(e);if(r&&r[0]===n)return r[1];const i={error:j0("error",e,n),warn:j0("warn",e,n),info:j0("info",e,n),debug:j0("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 Dee(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=KE(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,pe(this,md,"f")),new Hd(()=>i(n),this.controller,pe(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=YE(JSON.stringify(i)+`
`);r.enqueue(o)}catch(i){r.error(i)}},async cancel(){await n.return?.()}})}};async function*Dee(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 Lee,r=new Im,i=KE(t.body);for await(const s of Iee(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*Iee(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"?YE(n):n;let i=new Uint8Array(e.length+r.length);i.set(e),i.set(r,e.length),e=i;let s;for(;(s=Oee(e))!==-1;)yield e.slice(0,s),e=e.slice(s)}e.length>0&&(yield e)}let Lee=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]=Nee(e,":");return i.startsWith(" ")&&(i=i.substring(1)),n==="event"?this.event=i:n==="data"&&this.data.push(i),null}};function Nee(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(pe(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(pe(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 B0;let $ee=class{constructor(e,n,r,i){B0.set(this,void 0),Ye(this,B0,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 pe(this,B0,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(B0=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const n of e.getPaginatedItems())yield n}},jee=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 $ee{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 lb(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",Bee=async(t,e)=>({...t,body:await zee(t.body,e)}),pI=new WeakMap;function Fee(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 zee=async(t,e)=>{if(!await Fee(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])=>eC(n,r,i))),n},Vee=t=>t instanceof Blob&&"name"in t,eC=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()],lb(n),r))}else if(DB(n))t.append(e,gh([await new Response(kB(n)).blob()],lb(n)));else if(Vee(n))t.append(e,gh([n],lb(n),{type:n.type}));else if(Array.isArray(n))await Promise.all(n.map(r=>eC(t,e+"[]",r)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([r,i])=>eC(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",Uee=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&IB(t),Hee=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function Wee(t,e,n){if(PB(),t=await t,e||(e=lb(t)),Uee(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(Hee(t)){const i=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),gh(await tC(i),e,n)}const r=await tC(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 tC(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 tC(n));else{const n=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${n?`; constructor: ${n}`:""}${qee(t)}`)}return e}function qee(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*Gee(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 Gee(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)),Kee=(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),x="^".repeat(y.length);return f=y.start+y.length,m+b+x},"");throw new nt(`Path parameters result in path with invalid segments:
${s.map(m=>m.error).join(`
`)}
${o}
${d}`)}return o},vs=Kee(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",Bee({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 Ix{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 Ix(KE(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)=>Ix.fromResponse(a.response,a.controller))}};const Yee=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},Xee=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},Jee=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(Jee(Xee(Wu(Yee(t)))));var Fi,za,gd,F0,yd,bd,z0,vd,jo,xd,V0,U0,Pu,H0,W0,GS,gI,q0,KS,YS,XS,yI;const bI="__json_buf";function vI(t){return t.type==="tool_use"||t.type==="server_tool_use"||t.type==="mcp_tool_use"}class nv{constructor(){Fi.add(this),this.messages=[],this.receivedMessages=[],za.set(this,void 0),this.controller=new AbortController,gd.set(this,void 0),F0.set(this,()=>{}),yd.set(this,()=>{}),bd.set(this,void 0),z0.set(this,()=>{}),vd.set(this,()=>{}),jo.set(this,{}),xd.set(this,!1),V0.set(this,!1),U0.set(this,!1),Pu.set(this,!1),H0.set(this,void 0),W0.set(this,void 0),q0.set(this,e=>{if(Ye(this,V0,!0),Kp(e)&&(e=new ys),e instanceof ys)return Ye(this,U0,!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,F0,e,"f"),Ye(this,yd,n,"f")})),Ye(this,bd,new Promise((e,n)=>{Ye(this,z0,e,"f"),Ye(this,vd,n,"f")})),pe(this,gd,"f").catch(()=>{}),pe(this,bd,"f").catch(()=>{})}get response(){return pe(this,H0,"f")}get request_id(){return pe(this,W0,"f")}async withResponse(){const e=await pe(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 nv;return n._run(()=>n._fromReadableStream(e)),n}static createMessage(e,n,r){const i=new nv;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")},pe(this,q0,"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{pe(this,Fi,"m",KS).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)pe(this,Fi,"m",YS).call(this,c);if(a.controller.signal?.aborted)throw new ys;pe(this,Fi,"m",XS).call(this)}finally{i&&s&&i.removeEventListener("abort",s)}}_connected(e){this.ended||(Ye(this,H0,e),Ye(this,W0,e?.headers.get("request-id")),pe(this,F0,"f").call(this,e),this._emit("connect"))}get ended(){return pe(this,xd,"f")}get errored(){return pe(this,V0,"f")}get aborted(){return pe(this,U0,"f")}abort(){this.controller.abort()}on(e,n){return(pe(this,jo,"f")[e]||(pe(this,jo,"f")[e]=[])).push({listener:n}),this}off(e,n){const r=pe(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(pe(this,jo,"f")[e]||(pe(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 pe(this,bd,"f")}get currentMessage(){return pe(this,za,"f")}async finalMessage(){return await this.done(),pe(this,Fi,"m",GS).call(this)}async finalText(){return await this.done(),pe(this,Fi,"m",gI).call(this)}_emit(e,...n){if(pe(this,xd,"f"))return;e==="end"&&(Ye(this,xd,!0),pe(this,z0,"f").call(this));const r=pe(this,jo,"f")[e];if(r&&(pe(this,jo,"f")[e]=r.filter(i=>!i.once),r.forEach(({listener:i})=>i(...n))),e==="abort"){const i=n[0];!pe(this,Pu,"f")&&!r?.length&&Promise.reject(i),pe(this,yd,"f").call(this,i),pe(this,vd,"f").call(this,i),this._emit("end");return}if(e==="error"){const i=n[0];!pe(this,Pu,"f")&&!r?.length&&Promise.reject(i),pe(this,yd,"f").call(this,i),pe(this,vd,"f").call(this,i),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",pe(this,Fi,"m",GS).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{pe(this,Fi,"m",KS).call(this),this._connected(null);const s=Yp.fromReadableStream(e,this.controller);for await(const o of s)pe(this,Fi,"m",YS).call(this,o);if(s.controller.signal?.aborted)throw new ys;pe(this,Fi,"m",XS).call(this)}finally{r&&i&&r.removeEventListener("abort",i)}}[(za=new WeakMap,gd=new WeakMap,F0=new WeakMap,yd=new WeakMap,bd=new WeakMap,z0=new WeakMap,vd=new WeakMap,jo=new WeakMap,xd=new WeakMap,V0=new WeakMap,U0=new WeakMap,Pu=new WeakMap,H0=new WeakMap,W0=new WeakMap,q0=new WeakMap,Fi=new WeakSet,GS=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(" ")},KS=function(){this.ended||Ye(this,za,void 0)},YS=function(n){if(this.ended)return;const r=pe(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}}},XS=function(){if(this.ended)throw new nt("stream has ended, this shouldn't happen");const n=pe(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=pe(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}`);pe(this,q0,"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},xI={"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 XE=class extends ia{constructor(){super(...arguments),this.batches=new BB(this._client)}create(e,n){const{betas:r,...i}=e;i.model in xI&&console.warn(`The model '${i.model}' is deprecated and will reach end-of-life on ${xI[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 nv.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])})}};XE.Batches=BB;let Nm=class extends ia{constructor(){super(...arguments),this.models=new jB(this._client),this.messages=new XE(this._client),this.files=new $B(this._client)}};Nm.Models=jB;Nm.Messages=XE;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,wd,G0,Sd,_d,K0,Cd,Bo,Ad,Y0,X0,Du,J0,Q0,JS,wI,QS,ZS,e_,t_,SI;const _I="__json_buf";function CI(t){return t.type==="tool_use"||t.type==="server_tool_use"}class rv{constructor(){zi.add(this),this.messages=[],this.receivedMessages=[],Va.set(this,void 0),this.controller=new AbortController,wd.set(this,void 0),G0.set(this,()=>{}),Sd.set(this,()=>{}),_d.set(this,void 0),K0.set(this,()=>{}),Cd.set(this,()=>{}),Bo.set(this,{}),Ad.set(this,!1),Y0.set(this,!1),X0.set(this,!1),Du.set(this,!1),J0.set(this,void 0),Q0.set(this,void 0),QS.set(this,e=>{if(Ye(this,Y0,!0),Kp(e)&&(e=new ys),e instanceof ys)return Ye(this,X0,!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,wd,new Promise((e,n)=>{Ye(this,G0,e,"f"),Ye(this,Sd,n,"f")})),Ye(this,_d,new Promise((e,n)=>{Ye(this,K0,e,"f"),Ye(this,Cd,n,"f")})),pe(this,wd,"f").catch(()=>{}),pe(this,_d,"f").catch(()=>{})}get response(){return pe(this,J0,"f")}get request_id(){return pe(this,Q0,"f")}async withResponse(){const e=await pe(this,wd,"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")},pe(this,QS,"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{pe(this,zi,"m",ZS).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)pe(this,zi,"m",e_).call(this,c);if(a.controller.signal?.aborted)throw new ys;pe(this,zi,"m",t_).call(this)}finally{i&&s&&i.removeEventListener("abort",s)}}_connected(e){this.ended||(Ye(this,J0,e),Ye(this,Q0,e?.headers.get("request-id")),pe(this,G0,"f").call(this,e),this._emit("connect"))}get ended(){return pe(this,Ad,"f")}get errored(){return pe(this,Y0,"f")}get aborted(){return pe(this,X0,"f")}abort(){this.controller.abort()}on(e,n){return(pe(this,Bo,"f")[e]||(pe(this,Bo,"f")[e]=[])).push({listener:n}),this}off(e,n){const r=pe(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(pe(this,Bo,"f")[e]||(pe(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 pe(this,_d,"f")}get currentMessage(){return pe(this,Va,"f")}async finalMessage(){return await this.done(),pe(this,zi,"m",JS).call(this)}async finalText(){return await this.done(),pe(this,zi,"m",wI).call(this)}_emit(e,...n){if(pe(this,Ad,"f"))return;e==="end"&&(Ye(this,Ad,!0),pe(this,K0,"f").call(this));const r=pe(this,Bo,"f")[e];if(r&&(pe(this,Bo,"f")[e]=r.filter(i=>!i.once),r.forEach(({listener:i})=>i(...n))),e==="abort"){const i=n[0];!pe(this,Du,"f")&&!r?.length&&Promise.reject(i),pe(this,Sd,"f").call(this,i),pe(this,Cd,"f").call(this,i),this._emit("end");return}if(e==="error"){const i=n[0];!pe(this,Du,"f")&&!r?.length&&Promise.reject(i),pe(this,Sd,"f").call(this,i),pe(this,Cd,"f").call(this,i),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",pe(this,zi,"m",JS).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{pe(this,zi,"m",ZS).call(this),this._connected(null);const s=Yp.fromReadableStream(e,this.controller);for await(const o of s)pe(this,zi,"m",e_).call(this,o);if(s.controller.signal?.aborted)throw new ys;pe(this,zi,"m",t_).call(this)}finally{r&&i&&r.removeEventListener("abort",i)}}[(Va=new WeakMap,wd=new WeakMap,G0=new WeakMap,Sd=new WeakMap,_d=new WeakMap,K0=new WeakMap,Cd=new WeakMap,Bo=new WeakMap,Ad=new WeakMap,Y0=new WeakMap,X0=new WeakMap,Du=new WeakMap,J0=new WeakMap,Q0=new WeakMap,QS=new WeakMap,zi=new WeakSet,JS=function(){if(this.receivedMessages.length===0)throw new nt("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},wI=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(" ")},ZS=function(){this.ended||Ye(this,Va,void 0)},e_=function(n){if(this.ended)return;const r=pe(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}}},t_=function(){if(this.ended)throw new nt("stream has ended, this shouldn't happen");const n=pe(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=pe(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)=>Ix.fromResponse(s.response,s.controller))}},JE=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 rv.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"};JE.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 Qee={};const Z0=t=>{if(typeof globalThis.process<"u")return Qee?.[t]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(t)?.trim()};var nC,QE,cb,WB;class bn{constructor({baseURL:e=Z0("ANTHROPIC_BASE_URL"),apiKey:n=Z0("ANTHROPIC_API_KEY")??null,authToken:r=Z0("ANTHROPIC_AUTH_TOKEN")??null,...i}={}){nC.add(this),cb.set(this,void 0);const s={apiKey:n,authToken:r,...i,baseURL:e||"https://api.anthropic.com"};if(!s.dangerouslyAllowBrowser&&wee())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??QE.DEFAULT_TIMEOUT,this.logger=s.logger??console;const o="warn";this.logLevel=o,this.logLevel=fI(s.logLevel,"ClientOptions.logLevel",this)??fI(Z0("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??o,this.fetchOptions=s.fetchOptions,this.maxRetries=s.maxRetries??2,this.fetch=s.fetch??Eee(),Ye(this,cb,Tee),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=!pe(this,nC,"m",WB).call(this)&&r||this.baseURL,s=gee(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();return yee(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(J2),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 Dx({cause:y})}const x=[...y.headers.entries()].filter(([_])=>_==="request-id").map(([_,A])=>", "+_+": "+JSON.stringify(A)).join(""),S=`[${h}${f}${x}] ${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 kee(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=>J2(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 jee(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&&vee("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))}:{},...Aee(),...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)}:pe(this,cb,"f").call(this,{body:e,headers:r})}}QE=bn,cb=new WeakMap,nC=new WeakSet,WB=function(){return this.baseURL!=="https://api.anthropic.com"};bn.Anthropic=QE;bn.HUMAN_PROMPT=`
Human:`;bn.AI_PROMPT=`
Assistant:`;bn.DEFAULT_TIMEOUT=6e5;bn.AnthropicError=nt;bn.APIError=Ri;bn.APIConnectionError=Dx;bn.APIConnectionTimeoutError=gB;bn.APIUserAbortError=ys;bn.NotFoundError=xB;bn.ConflictError=wB;bn.RateLimitError=_B;bn.BadRequestError=yB;bn.AuthenticationError=bB;bn.InternalServerError=CB;bn.PermissionDeniedError=vB;bn.UnprocessableEntityError=SB;bn.toFile=Wee;class al extends bn{constructor(){super(...arguments),this.completions=new VB(this),this.messages=new JE(this),this.models=new HB(this),this.beta=new Nm(this)}}al.Completions=VB;al.Messages=JE;al.Models=HB;al.Beta=Nm;const{HUMAN_PROMPT:i6e,AI_PROMPT:s6e}=al;var qd={exports:{}};qd.exports;var EI;function Zee(){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]",x="[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]",N="[object Float64Array]",H="[object Int8Array]",j="[object Int16Array]",V="[object Int32Array]",q="[object Uint8Array]",X="[object Uint8ClampedArray]",Y="[object Uint16Array]",te="[object Uint32Array]",z=/[\\^$.*+?()[\]{}|]/g,G=/\w*$/,U=/^\[object .+?Constructor\]$/,se=/^(?:0|[1-9]\d*)$/,T={};T[s]=T[o]=T[O]=T[M]=T[a]=T[c]=T[D]=T[N]=T[H]=T[j]=T[V]=T[m]=T[y]=T[b]=T[S]=T[_]=T[A]=T[E]=T[q]=T[X]=T[Y]=T[te]=!0,T[h]=T[f]=T[P]=!1;var Z=typeof T0=="object"&&T0&&T0.Object===Object&&T0,ue=typeof self=="object"&&self&&self.Object===Object&&self,L=Z||ue||Function("return this")(),de=e&&!e.nodeType&&e,ke=de&&!0&&t&&!t.nodeType&&t,ye=ke&&ke.exports===de;function Ee($,Q){return $.set(Q[0],Q[1]),$}function Ue($,Q){return $.add(Q),$}function Pt($,Q){for(var le=-1,Oe=$?$.length:0;++le<Oe&&Q($[le],le,$)!==!1;);return $}function Kt($,Q){for(var le=-1,Oe=Q.length,Wt=$.length;++le<Oe;)$[Wt+le]=Q[le];return $}function Yt($,Q,le,Oe){for(var Wt=-1,ar=$?$.length:0;++Wt<ar;)le=Q(le,$[Wt],Wt,$);return le}function er($,Q){for(var le=-1,Oe=Array($);++le<$;)Oe[le]=Q(le);return Oe}function tr($,Q){return $?.[Q]}function ti($){var Q=!1;if($!=null&&typeof $.toString!="function")try{Q=!!($+"")}catch{}return Q}function _o($){var Q=-1,le=Array($.size);return $.forEach(function(Oe,Wt){le[++Q]=[Wt,Oe]}),le}function ss($,Q){return function(le){return $(Q(le))}}function nr($){var Q=-1,le=Array($.size);return $.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 $=/[^.]+$/.exec(Ds&&Ds.keys&&Ds.keys.IE_PROTO||"");return $?"Symbol(src)_1."+$:""})(),Tl=kl.toString,Mi=Ps.hasOwnProperty,aa=Ps.toString,oe=RegExp("^"+Tl.call(Mi).replace(z,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),me=ye?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=me?me.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"),Rw=Br(ir),ug=Br(Bn),hg=Br(Fc),cf=Br(zc),uf=Br(Rl),hf=De?De.prototype:void 0,fg=hf?hf.valueOf:void 0;function sr($){var Q=-1,le=$?$.length:0;for(this.clear();++Q<le;){var Oe=$[Q];this.set(Oe[0],Oe[1])}}function Mn(){this.__data__=as?as(null):{}}function or($){return this.has($)&&delete this.__data__[$]}function la($){var Q=this.__data__;if(as){var le=Q[$];return le===r?void 0:le}return Mi.call(Q,$)?Q[$]:void 0}function ff($){var Q=this.__data__;return as?Q[$]!==void 0:Mi.call(Q,$)}function Mw($,Q){var le=this.__data__;return le[$]=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=Mw;function ls($){var Q=-1,le=$?$.length:0;for(this.clear();++Q<le;){var Oe=$[Q];this.set(Oe[0],Oe[1])}}function dg(){this.__data__=[]}function Ml($){var Q=this.__data__,le=fa(Q,$);if(le<0)return!1;var Oe=Q.length-1;return le==Oe?Q.pop():rr.call(Q,le,1),!0}function df($){var Q=this.__data__,le=fa(Q,$);return le<0?void 0:Q[le][1]}function ca($){return fa(this.__data__,$)>-1}function ua($,Q){var le=this.__data__,Oe=fa(le,$);return Oe<0?le.push([$,Q]):le[Oe][1]=Q,this}ls.prototype.clear=dg,ls.prototype.delete=Ml,ls.prototype.get=df,ls.prototype.has=ca,ls.prototype.set=ua;function Oi($){var Q=-1,le=$?$.length:0;for(this.clear();++Q<le;){var Oe=$[Q];this.set(Oe[0],Oe[1])}}function ha(){this.__data__={hash:new sr,map:new(Bn||ls),string:new sr}}function an($){return Ol(this,$).delete($)}function pg($){return Ol(this,$).get($)}function mg($){return Ol(this,$).has($)}function Co($,Q){return Ol(this,$).set($,Q),this}Oi.prototype.clear=ha,Oi.prototype.delete=an,Oi.prototype.get=pg,Oi.prototype.has=mg,Oi.prototype.set=Co;function ri($){this.__data__=new ls($)}function Ow(){this.__data__=new ls}function gg($){return this.__data__.delete($)}function yg($){return this.__data__.get($)}function Pw($){return this.__data__.has($)}function Vc($,Q){var le=this.__data__;if(le instanceof ls){var Oe=le.__data__;if(!Bn||Oe.length<n-1)return Oe.push([$,Q]),this;le=this.__data__=new Oi(Oe)}return le.set($,Q),this}ri.prototype.clear=Ow,ri.prototype.delete=gg,ri.prototype.get=yg,ri.prototype.has=Pw,ri.prototype.set=Vc;function Uc($,Q){var le=Yc($)||wf($)?er($.length,String):[],Oe=le.length,Wt=!!Oe;for(var ar in $)Mi.call($,ar)&&!(Wt&&(ar=="length"||Nw(ar,Oe)))&&le.push(ar);return le}function Pi($,Q,le){var Oe=$[Q];(!(Mi.call($,Q)&&xf(Oe,le))||le===void 0&&!(Q in $))&&($[Q]=le)}function fa($,Q){for(var le=$.length;le--;)if(xf($[le][0],Q))return le;return-1}function bg($,Q){return $&&qc(Q,Jc(Q),$)}function Is($,Q,le,Oe,Wt,ar,si){var On;if(Oe&&(On=ar?Oe($,Wt,ar,si):Oe($)),On!==void 0)return On;if(!ya($))return $;var ba=Yc($);if(ba){if(On=Ag($),!Q)return Sg($,On)}else{var us=Ls($),_f=us==f||us==d;if(Sf($))return xg($,Q);if(us==b||us==s||_f&&!ar){if(ti($))return ar?$:{};if(On=bf(_f?{}:$),!Q)return da($,bg(On,$))}else{if(!T[us])return ar?$:{};On=Lw($,us,Is,Q)}}si||(si=new ri);var Eg=si.get($);if(Eg)return Eg;if(si.set($,On),!ba)var kg=le?_g($):Jc($);return Pt(kg||$,function(Cf,va){kg&&(va=Cf,Cf=$[va]),Pi(On,va,Is(Cf,Q,le,Oe,va,$,si))}),On}function pf($){return ya($)?Sr($):{}}function mf($,Q,le){var Oe=Q($);return Yc($)?Oe:Kt(Oe,le($))}function Dw($){return aa.call($)}function vg($){if(!ya($)||vf($))return!1;var Q=ga($)||ti($)?oe:U;return Q.test(Br($))}function $r($){if(!Kc($))return on($);var Q=[];for(var le in Object($))Mi.call($,le)&&le!="constructor"&&Q.push(le);return Q}function xg($,Q){if(Q)return $.slice();var le=new $.constructor($.length);return $.copy(le),le}function gf($){var Q=new $.constructor($.byteLength);return new $e(Q).set(new $e($)),Q}function Hc($,Q){var le=Q?gf($.buffer):$.buffer;return new $.constructor(le,$.byteOffset,$.byteLength)}function wg($,Q,le){var Oe=Q?le(_o($),!0):_o($);return Yt(Oe,Ee,new $.constructor)}function Wc($){var Q=new $.constructor($.source,G.exec($));return Q.lastIndex=$.lastIndex,Q}function Iw($,Q,le){var Oe=Q?le(nr($),!0):nr($);return Yt(Oe,Ue,new $.constructor)}function jr($){return fg?Object(fg.call($)):{}}function yf($,Q){var le=Q?gf($.buffer):$.buffer;return new $.constructor(le,$.byteOffset,$.length)}function Sg($,Q){var le=-1,Oe=$.length;for(Q||(Q=Array(Oe));++le<Oe;)Q[le]=$[le];return Q}function qc($,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?$[si]:On)}return le}function da($,Q){return qc($,Cg($),Q)}function _g($){return mf($,Jc,Cg)}function Ol($,Q){var le=$.__data__;return Gc(Q)?le[typeof Q=="string"?"string":"hash"]:le.map}function ii($,Q){var le=tr($,Q);return vg(le)?le:void 0}var Cg=ni?ss(ni,Object):Qc,Ls=Dw;(ir&&Ls(new ir(new ArrayBuffer(1)))!=M||Bn&&Ls(new Bn)!=m||Fc&&Ls(Fc.resolve())!=x||zc&&Ls(new zc)!=_||Rl&&Ls(new Rl)!=P)&&(Ls=function($){var Q=aa.call($),le=Q==b?$.constructor:void 0,Oe=le?Br(le):void 0;if(Oe)switch(Oe){case Rw:return M;case ug:return m;case hg:return x;case cf:return _;case uf:return P}return Q});function Ag($){var Q=$.length,le=$.constructor(Q);return Q&&typeof $[0]=="string"&&Mi.call($,"index")&&(le.index=$.index,le.input=$.input),le}function bf($){return typeof $.constructor=="function"&&!Kc($)?pf(yt($)):{}}function Lw($,Q,le,Oe){var Wt=$.constructor;switch(Q){case O:return gf($);case a:case c:return new Wt(+$);case M:return Hc($,Oe);case D:case N:case H:case j:case V:case q:case X:case Y:case te:return yf($,Oe);case m:return wg($,Oe,le);case y:case A:return new Wt($);case S:return Wc($);case _:return Iw($,Oe,le);case E:return jr($)}}function Nw($,Q){return Q=Q??i,!!Q&&(typeof $=="number"||se.test($))&&$>-1&&$%1==0&&$<Q}function Gc($){var Q=typeof $;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?$!=="__proto__":$===null}function vf($){return!!Bc&&Bc in $}function Kc($){var Q=$&&$.constructor,le=typeof Q=="function"&&Q.prototype||Ps;return $===le}function Br($){if($!=null){try{return Tl.call($)}catch{}try{return $+""}catch{}}return""}function pa($){return Is($,!0,!0)}function xf($,Q){return $===Q||$!==$&&Q!==Q}function wf($){return cs($)&&Mi.call($,"callee")&&(!os.call($,"callee")||aa.call($)==s)}var Yc=Array.isArray;function ma($){return $!=null&&Ns($.length)&&!ga($)}function cs($){return Xc($)&&ma($)}var Sf=_r||Zc;function ga($){var Q=ya($)?aa.call($):"";return Q==f||Q==d}function Ns($){return typeof $=="number"&&$>-1&&$%1==0&&$<=i}function ya($){var Q=typeof $;return!!$&&(Q=="object"||Q=="function")}function Xc($){return!!$&&typeof $=="object"}function Jc($){return ma($)?Uc($):$r($)}function Qc(){return[]}function Zc(){return!1}t.exports=pa})(qd,qd.exports)),qd.exports}var ete=Zee();const Jr=Pc(ete),tte=`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`,nte=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},rte=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=nte(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},ite=t=>{const{message:e}=t;return{role:e.role,content:[]}},ste=(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},ote=(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 ate{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=rte(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=ite(a)}if(c==="content_block_start"&&(o=ste(a,o)),c==="content_block_delta"&&(o=ote(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(typeof r=="object"&&r){if("status"in r&&r.status===401)return{field:"key",message:"Invalid API key"};if("status"in r&&r.status===404)return{field:"url",message:"Invalid URL"};if(e.apiKey)return{field:"url",message:"Invalid URL"}}return{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 ate;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 lte(t){return t&&DataView.prototype.isPrototypeOf(t)}if(Rr.arrayBuffer)var cte=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],ute=ArrayBuffer.isView||function(t){return t&&cte.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 ZE(t){return typeof t!="string"&&(t=String(t)),t}function ek(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=ZE(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)]=ZE(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)}),ek(t)};Tn.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),ek(t)};Tn.prototype.entries=function(){var t=[];return this.forEach(function(e,n){t.push([n,e])}),ek(t)};Rr.iterable&&(Tn.prototype[Symbol.iterator]=Tn.prototype.entries);function n_(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 hte(t){var e=new FileReader,n=qB(e);return e.readAsArrayBuffer(t),n}function fte(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 dte(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&&lte(t)?(this._bodyArrayBuffer=TI(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Rr.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||ute(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=n_(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=n_(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(hte);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var t=n_(this);if(t)return t;if(this._bodyBlob)return fte(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(dte(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(gte)}),this.json=function(){return this.text().then(JSON.parse)},this}var pte=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function mte(t){var e=t.toUpperCase();return pte.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=mte(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 gte(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 yte(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 bte=[301,302,303,307,308];go.redirect=function(t,e){if(bte.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:yte(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,ZE(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}`,vte="0.5.18";var xte=Object.defineProperty,wte=(t,e,n)=>e in t?xte(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,r_=(t,e,n)=>(wte(t,typeof e!="symbol"?e+"":e,n),n);class tk extends Error{constructor(e,n){super(e),this.error=e,this.status_code=n,this.name="ResponseError",Error.captureStackTrace&&Error.captureStackTrace(this,tk)}}class Ste{constructor(e,n,r){r_(this,"abortController"),r_(this,"itr"),r_(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 nk=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 tk(e,t.status)};function _te(){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 Cte(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 rk=async(t,e,n={})=>{const r={"Content-Type":"application/json",Accept:"application/json","User-Agent":`ollama-js/${vte} (${_te()})`};n.headers=Cte(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 rk(t,e,{headers:n?.headers});return await nk(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 rk(t,e,{method:"POST",body:s,signal:r?.signal,headers:r?.headers});return await nk(o),o},Ate=async(t,e,n,r)=>{const i=await rk(t,e,{method:"DELETE",body:JSON.stringify(n),headers:r?.headers});return await nk(i),i},Ete=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)}},kte=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 Tte=Object.defineProperty,Rte=(t,e,n)=>e in t?Tte(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,i_=(t,e,n)=>(Rte(t,typeof e!="symbol"?e+"":e,n),n);let ub=class{constructor(e){i_(this,"config"),i_(this,"fetch"),i_(this,"ongoingStreamedRequests",[]),this.config={host:"",headers:e?.headers},e?.proxy||(this.config.host=kte(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=Ete(o.body),c=new Ste(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 Ate(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 ub;const vp="<TOOL_CALL>",iv="</TOOL_CALL>",Mte=t=>t.map(e=>({type:"string",function:{name:e.name,description:e.description,parameters:e.inputSchema}})),Ote=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}
${iv}
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}${iv}`}}).join(""):"",s=typeof n.content=="string"?n.content:i;e.push({role:"assistant",content:s}),r&&e.push({role:"user",content:r})}}),e},Pte=t=>{let e=!1,n=!1,r="";if(t.includes(vp)&&(e=!0,r=t.split(vp)[1]),!e)return{content:t};t.includes(iv)&&(n=!0,r=r.split(iv)[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 Dte{modelKey="";systemPrompt="";apiKey;url;provider;prevMessages=[];tools=[];client;messageStopped=!1;constructor(){}setProvider=e=>{this.provider=e,this.client=new ub({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=Mte(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=Ote(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}=Pte(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 ub({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 ub({host:e.url}).list()).models.map(i=>({id:i.model,name:i.name,provider:"ollama"}))}const OI=new Dte;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 rC(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}const iC=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 sC extends Ie{constructor(e,n,r,i){super(`${sC.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 Lx({message:r,cause:iC(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 sC(e,s,r,i)}},Gi=class extends Qr{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},Lx=class extends Qr{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}},ik=class extends Lx{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 Ite=/^[a-z][a-z0-9+.-]*:/i,Lte=t=>Ite.test(t);let Hr=t=>(Hr=Array.isArray,Hr(t)),PI=Hr;function l8(t){return typeof t!="object"?{}:t??{}}function Nte(t){if(!t)return!0;for(const e in t)return!1;return!0}function $te(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function s_(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}const jte=(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},Bte=t=>{try{return JSON.parse(t)}catch{return}},jm=t=>new Promise(e=>setTimeout(e,t)),qu="5.22.0",Fte=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function zte(){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 Vte=()=>{const t=zte();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=Ute();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 Ute(){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 Hte=()=>LI??(LI=Vte());function Wte(){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 qte(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 Gte=({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},Kte="RFC1738";let oC=(t,e)=>(oC=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),oC(t,e));const Vs=(()=>{const t=[];for(let e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t})(),o_=1024,Yte=(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+=o_){const c=s.length>=o_?s.slice(a,a+o_):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===Kte&&(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 Xte(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:Yte,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 Jte(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"}const a_={};function g8(t,e,n,r,i,s,o,a,c,h,f,d,m,y,b,x,S,_){let A=t,E=_,P=0,O=!1;for(;(E=E.get(a_))!==void 0&&!O;){const j=E.get(t);if(P+=1,typeof j<"u"){if(j===P)throw new RangeError("Cyclic object value");O=!0}typeof E.get(a_)>"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(j){return j instanceof Date?m?.(j):j})),A===null){if(s)return c&&!x?c(e,Cn.encoder,S,"key",y):e;A=""}if(Jte(A)||Xte(A)){if(c){const j=x?e:c(e,Cn.encoder,S,"key",y);return[b?.(j)+"="+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))x&&c&&(A=$I(A,c)),D=[{value:A.length>0?A.join(",")||null:void 0}];else if(Hr(h))D=h;else{const j=Object.keys(A);D=f?j.sort(f):j}const N=a?String(e).replace(/\./g,"%2E"):String(e),H=r&&Hr(A)&&A.length===1?N+"[]":N;if(i&&Hr(A)&&A.length===0)return H+"[]";for(let j=0;j<D.length;++j){const V=D[j],q=typeof V=="object"&&typeof V.value<"u"?V.value:A[V];if(o&&q===null)continue;const X=d&&a?V.replace(/\./g,"%2E"):V,Y=Hr(A)?typeof n=="function"?n(H,X):H:H+(d?"."+X:"["+X+"]");_.set(t,P);const te=new WeakMap;te.set(a_,_),m8(M,g8(q,Y,n,r,i,s,o,a,n==="comma"&&x&&Hr(A)?null:c,h,f,d,m,y,b,x,S,te))}return M}function Qte(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(!oC(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 Zte(t,e={}){let n=t;const r=Qte(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 ene(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 sk(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 Nx=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"?sk(e):e;Ge(this,yi,ene([ne(this,yi,"f"),n]));const r=[];let i;for(;(i=tne(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;Nx.NEWLINE_CHARS=new Set([`
`,"\r"]);Nx.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function tne(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 nne(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 sv={off:0,error:200,warn:300,info:400,debug:500},VI=(t,e,n)=>{if(t){if($te(sv,t))return t;Un(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(sv))}`)}};function Kd(){}function ey(t,e,n){return!e||sv[t]>sv[n]?Kd:e[t].bind(e)}const rne={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 rne;const r=UI.get(e);if(r&&r[0]===n)return r[1];const i={error:ey("error",e,n),warn:ey("warn",e,n),info:ey("info",e,n),debug:ey("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 ine(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(rC(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 Nx,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(rC(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=sk(JSON.stringify(i)+`
`);r.enqueue(o)}catch(i){r.error(i)}},async cancel(){await n.return?.()}})}};async function*ine(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 one,r=new Nx,i=h8(t.body);for await(const s of sne(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*sne(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"?sk(n):n;let i=new Uint8Array(e.length+r.length);i.set(e),i.set(r,e.length),e=i;let s;for(;(s=nne(e))!==-1;)yield e.slice(0,s),e=e.slice(s)}e.length>0&&(yield e)}let one=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]=ane(e,":");return i.startsWith(" ")&&(i=i.substring(1)),n==="event"?this.event=i:n==="data"&&this.data.push(i),null}};function ane(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 x8 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 x8(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 ty;class ok{constructor(e,n,r,i){ty.set(this,void 0),Ge(this,ty,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,ty,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(ty=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const n of e.getPaginatedItems())yield n}}class lne 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 $x extends ok{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 ok{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 cne extends ok{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 w8=()=>{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 xp(t,e,n){return w8(),new File(t,e??"unknown_file",n)}function hb(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 hne(t.body,e)}),HI=new WeakMap;function une(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 hne=async(t,e)=>{if(!await une(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])=>aC(n,r,i))),n},fne=t=>t instanceof Blob&&"name"in t,aC=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,xp([await n.blob()],hb(n)));else if(S8(n))t.append(e,xp([await new Response(u8(n)).blob()],hb(n)));else if(fne(n))t.append(e,n,hb(n));else if(Array.isArray(n))await Promise.all(n.map(r=>aC(t,e+"[]",r)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([r,i])=>aC(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",dne=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&_8(t),pne=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function mne(t,e,n){if(w8(),t=await t,dne(t))return t instanceof File?t:xp([await t.arrayBuffer()],t.name);if(pne(t)){const i=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),xp(await lC(i),e,n)}const r=await lC(t);if(e||(e=hb(t)),!n?.type){const i=r.find(s=>typeof s=="object"&&"type"in s&&s.type);typeof i=="string"&&(n={...n,type:i})}return xp(r,e,n)}async function lC(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 lC(n));else{const n=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${n?`; constructor: ${n}`:""}${gne(t)}`)}return e}function gne(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)),yne=(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),x="^".repeat(y.length);return f=y.start+y.length,m+b+x},"");throw new Ie(`Path parameters result in path with invalid segments:
${s.map(m=>m.error).join(`
`)}
${o}
${d}`)}return o},ve=yne(C8);let A8=class extends ze{list(e,n={},r){return this._client.getAPIList(ve`/chat/completions/${e}/messages`,gn,{query:n,...r})}};function ov(t){return t!==void 0&&"function"in t&&t.function!==void 0}function ak(t){return t?.$brand==="auto-parseable-response-format"}function Bm(t){return t?.$brand==="auto-parseable-tool"}function bne(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}}))}:lk(t,e)}function lk(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?vne(e,r.message.content):null}}});return{...t,choices:n}}function vne(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=>ov(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 wne(t,e){if(!t||!("tools"in t)||!t.tools)return!1;const n=t.tools?.find(r=>ov(r)&&r.function?.name===e.function.name);return ov(n)&&(Bm(n)||n?.function.strict||!1)}function E8(t){return ak(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 Sne(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 av=t=>t?.role==="assistant",T8=t=>t?.role==="tool";var cC,fb,db,Jd,Qd,pb,Zd,Vo,ep,lv,cv,Gu,R8;class ck{constructor(){cC.add(this),this.controller=new AbortController,fb.set(this,void 0),db.set(this,()=>{}),Jd.set(this,()=>{}),Qd.set(this,void 0),pb.set(this,()=>{}),Zd.set(this,()=>{}),Vo.set(this,{}),ep.set(this,!1),lv.set(this,!1),cv.set(this,!1),Gu.set(this,!1),Ge(this,fb,new Promise((e,n)=>{Ge(this,db,e,"f"),Ge(this,Jd,n,"f")})),Ge(this,Qd,new Promise((e,n)=>{Ge(this,pb,e,"f"),Ge(this,Zd,n,"f")})),ne(this,fb,"f").catch(()=>{}),ne(this,Qd,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},ne(this,cC,"m",R8).bind(this))},0)}_connected(){this.ended||(ne(this,db,"f").call(this),this._emit("connect"))}get ended(){return ne(this,ep,"f")}get errored(){return ne(this,lv,"f")}get aborted(){return ne(this,cv,"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,pb,"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(){}}fb=new WeakMap,db=new WeakMap,Jd=new WeakMap,Qd=new WeakMap,pb=new WeakMap,Zd=new WeakMap,Vo=new WeakMap,ep=new WeakMap,lv=new WeakMap,cv=new WeakMap,Gu=new WeakMap,cC=new WeakSet,R8=function(e){if(Ge(this,lv,!0),e instanceof Error&&e.name==="AbortError"&&(e=new Gi),e instanceof Gi)return Ge(this,cv,!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 _ne(t){return typeof t.parse=="function"}var Er,uC,uv,hC,fC,dC,M8,O8;const Cne=10;let P8=class extends ck{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(av(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",uC).call(this)}async finalMessage(){return await this.done(),ne(this,Er,"m",uv).call(this)}async finalFunctionToolCall(){return await this.done(),ne(this,Er,"m",hC).call(this)}async finalFunctionToolCallResult(){return await this.done(),ne(this,Er,"m",fC).call(this)}async totalUsage(){return await this.done(),ne(this,Er,"m",dC).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",uv).call(this);n&&this._emit("finalMessage",n);const r=ne(this,Er,"m",uC).call(this);r&&this._emit("finalContent",r);const i=ne(this,Er,"m",hC).call(this);i&&this._emit("finalFunctionToolCall",i);const s=ne(this,Er,"m",fC).call(this);s!=null&&this._emit("finalFunctionToolCallResult",s),this._chatCompletions.some(o=>o.usage)&&this._emit("totalUsage",ne(this,Er,"m",dC).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(lk(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=Cne}=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 x=(await this._createChatCompletion(e,{...a,tool_choice:s,tools:m,messages:[...this.messages]},r)).choices[0]?.message;if(!x)throw new Ie("missing message in ChatCompletion response");if(!x.tool_calls?.length)return;for(const S of x.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 N=`Invalid tool_call: ${JSON.stringify(A)}. ${JSON.stringify(c)} requested. Please try again`;this._addMessage({role:i,tool_call_id:_,content:N});continue}}else{const N=`Invalid tool_call: ${JSON.stringify(A)}. Available options are: ${Object.keys(d).map(H=>JSON.stringify(H)).join(", ")}. Please try again`;this._addMessage({role:i,tool_call_id:_,content:N});continue}let O;try{O=_ne(P)?await P.parse(E):E}catch(N){const H=N instanceof Error?N.message:String(N);this._addMessage({role:i,tool_call_id:_,content:H});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,uC=function(){return ne(this,Er,"m",uv).call(this).content??null},uv=function(){let e=this.messages.length;for(;e-- >0;){const n=this.messages[e];if(av(n))return{...n,content:n.content??null,refusal:n.refusal??null}}throw new Ie("stream ended without producing a ChatCompletionMessage with role=assistant")},hC=function(){for(let e=this.messages.length-1;e>=0;e--){const n=this.messages[e];if(av(n)&&n?.tool_calls?.length)return n.tool_calls.filter(r=>r.type==="function").at(-1)?.function}},fC=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}},dC=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 uk extends P8{static runTools(e,n,r){const i=new uk,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),av(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,Ane=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:Ane};class Ene extends Error{}class kne extends Error{}function Tne(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 Rne(t.trim(),e)}const Rne=(t,e)=>{const n=t.length;let r=0;const i=m=>{throw new Ene(`${m} at position ${r}`)},s=m=>{throw new kne(`${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=>Tne(t,Ln.ALL^Ln.NUM);var wn,Fo,Lu,Ua,l_,ny,c_,u_,h_,ry,f_,GI;let q8=class pC extends P8{constructor(e){super(),wn.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 pC(null);return n._run(()=>n._fromReadableStream(e)),n}static createChatCompletion(e,n,r){const i=new pC(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,wn,"m",l_).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,wn,"m",c_).call(this,o);if(s.controller.signal?.aborted)throw new Gi;return this._addChatCompletion(ne(this,wn,"m",ry).call(this))}async _fromReadableStream(e,n){const r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),ne(this,wn,"m",l_).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,wn,"m",ry).call(this)),ne(this,wn,"m",c_).call(this,o),s=o.id;if(i.controller.signal?.aborted)throw new Gi;return this._addChatCompletion(ne(this,wn,"m",ry).call(this))}[(Fo=new WeakMap,Lu=new WeakMap,Ua=new WeakMap,wn=new WeakSet,l_=function(){this.ended||Ge(this,Ua,void 0)},ny=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)},c_=function(n){if(this.ended)return;const r=ne(this,wn,"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,wn,"m",ny).call(this,s);s.finish_reason&&(ne(this,wn,"m",h_).call(this,s),o.current_tool_call_index!=null&&ne(this,wn,"m",u_).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,wn,"m",h_).call(this,s),o.current_tool_call_index!=null&&ne(this,wn,"m",u_).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))}}},u_=function(n,r){if(ne(this,wn,"m",ny).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=>ov(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},h_=function(n){const r=ne(this,wn,"m",ny).call(this,n);if(n.message.content&&!r.content_done){r.content_done=!0;const i=ne(this,wn,"m",f_).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}))},ry=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,[]),Mne(n,ne(this,Fo,"f"))},f_=function(){const n=ne(this,Fo,"f")?.response_format;return ak(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 x=a.choices[m];if(x||(x=a.choices[m]={finish_reason:d,index:m,message:{},logprobs:y,...b}),y)if(!x.logprobs)x.logprobs=Object.assign({},y);else{const{content:M,refusal:D,...N}=y;Object.assign(x.logprobs,N),M&&((r=x.logprobs).content??(r.content=[]),x.logprobs.content.push(...M)),D&&((i=x.logprobs).refusal??(i.refusal=[]),x.logprobs.refusal.push(...D))}if(d&&(x.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(x,b),!f)continue;const{content:S,refusal:_,function_call:A,role:E,tool_calls:P,...O}=f;if(Object.assign(x.message,O),_&&(x.message.refusal=(x.message.refusal||"")+_),E&&(x.message.role=E),A&&(x.message.function_call?(A.name&&(x.message.function_call.name=A.name),A.arguments&&((s=x.message.function_call).arguments??(s.arguments=""),x.message.function_call.arguments+=A.arguments)):x.message.function_call=A),S&&(x.message.content=(x.message.content||"")+S,!x.message.refusal&&ne(this,wn,"m",f_).call(this)&&(x.message.parsed=qI(x.message.content))),P){x.message.tool_calls||(x.message.tool_calls=[]);for(const{index:M,id:D,type:N,function:H,...j}of P){const V=(o=x.message.tool_calls)[M]??(o[M]={});Object.assign(V,j),D&&(V.id=D),N&&(V.type=N),H&&(V.function??(V.function={name:H.name??"",arguments:""})),H?.name&&(V.function.name=H.name),H?.arguments&&(V.function.arguments+=H.arguments,wne(ne(this,Fo,"f"),V)&&(V.function.parsed_arguments=qI(V.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 Mne(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:x,tool_calls:S,..._}=h,A=h.role;if(!A)throw new Ie(`missing role for choice ${d}`);if(x){const{arguments:E,name:P}=x;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,...N}=E,{arguments:H,name:j,...V}=O||{};if(D==null)throw new Ie(`missing choices[${d}].tool_calls[${P}].id
${iy(t)}`);if(M==null)throw new Ie(`missing choices[${d}].tool_calls[${P}].type
${iy(t)}`);if(j==null)throw new Ie(`missing choices[${d}].tool_calls[${P}].function.name
${iy(t)}`);if(H==null)throw new Ie(`missing choices[${d}].tool_calls[${P}].function.arguments
${iy(t)}`);return{...N,id:D,type:M,function:{...V,name:j,arguments:H}}})}}:{...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 bne(c,e)}function iy(t){return JSON.stringify(t)}class hv extends q8{static fromReadableStream(e){const n=new hv(null);return n._run(()=>n._fromReadableStream(e)),n}static runTools(e,n,r){const i=new hv(n),s={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"runTools"}};return i._run(()=>i._runTools(e,n,s)),i}}let hk=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 Sne(e.tools),this._client.chat.completions.create(e,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(r=>lk(r,e))}runTools(e,n){return e.stream?hv.runTools(this._client,e,n):uk.runTools(this._client,e,n)}stream(e,n){return q8.createChatCompletion(this._client,e,n)}};hk.Messages=A8;let fk=class extends ze{constructor(){super(...arguments),this.completions=new hk(this._client)}};fk.Completions=hk;const G8=Symbol("brand.privateNullableHeaders");function*One(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 One(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 jx=class extends ze{constructor(){super(...arguments),this.sessions=new Z8(this._client),this.transcriptionSessions=new e6(this._client)}};jx.Sessions=Z8;jx.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 Pne=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 Dne={};const Nu=t=>{if(typeof globalThis.process<"u")return Dne?.[t]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(t)?.trim()};var Wn,cc,mC,Qs,mb,ms,uc,th,sc,fv,Si,gb,yb,wp,tp,np,KI,YI,XI,JI,QI,ZI,eL;class Sp extends ck{constructor(){super(...arguments),Wn.add(this),mC.set(this,[]),Qs.set(this,{}),mb.set(this,{}),ms.set(this,void 0),uc.set(this,void 0),th.set(this,void 0),sc.set(this,void 0),fv.set(this,void 0),Si.set(this,void 0),gb.set(this,void 0),yb.set(this,void 0),wp.set(this,void 0)}[(mC=new WeakMap,Qs=new WeakMap,mb=new WeakMap,ms=new WeakMap,uc=new WeakMap,th=new WeakMap,sc=new WeakMap,fv=new WeakMap,Si=new WeakMap,gb=new WeakMap,yb=new WeakMap,wp=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,gb,"f")}currentRun(){return ne(this,yb,"f")}currentMessageSnapshot(){return ne(this,ms,"f")}currentRunStepSnapshot(){return ne(this,wp,"f")}async finalRunSteps(){return await this.done(),Object.values(ne(this,Qs,"f"))}async finalMessages(){return await this.done(),Object.values(ne(this,mb,"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(s_(s)&&s_(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(!s_(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,gb,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,mb,"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,wp,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,fv,"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,fv,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,wp,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,mC,"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,yb,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 dk=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)}};dk.Steps=n6;class Bx extends ze{constructor(){super(...arguments),this.runs=new dk(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)}}Bx.Runs=dk;Bx.Messages=t6;class zm extends ze{constructor(){super(...arguments),this.realtime=new jx(this._client),this.assistants=new Q8(this._client),this.threads=new Bx(this._client)}}zm.Realtime=jx;zm.Assistants=Q8;zm.Threads=Bx;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})}},pk=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])})}};pk.Content=i6;class mk extends ze{constructor(){super(...arguments),this.files=new pk(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])})}}mk.Files=pk;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`,cne,{query:n,...r})}delete(e,n,r){const{conversation_id:i}=n;return this._client.delete(ve`/conversations/${i}/items/${e}`,r)}}class gk 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)}}gk.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=Pne(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 yk 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)}}yk.OutputItems=a6;class bk extends ze{constructor(){super(...arguments),this.runs=new yk(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)}}bk.Runs=yk;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 ik({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 vk extends ze{constructor(){super(...arguments),this.graders=new u6(this._client)}}vk.Graders=u6;class h6 extends ze{create(e,n,r){return this._client.getAPIList(ve`/fine_tuning/checkpoints/${e}/permissions`,$x,{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 wk=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)}};wk.Checkpoints=f6;class Kh extends ze{constructor(){super(...arguments),this.methods=new c6(this._client),this.jobs=new wk(this._client),this.checkpoints=new xk(this._client),this.alpha=new vk(this._client)}}Kh.Methods=c6;Kh.Jobs=wk;Kh.Checkpoints=xk;Kh.Alpha=vk;class d6 extends ze{}class Sk extends ze{constructor(){super(...arguments),this.graderModels=new d6(this._client)}}Sk.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",$x,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 _k extends ze{constructor(){super(...arguments),this.clientSecrets=new y6(this._client)}}_k.ClientSecrets=y6;function Ine(t,e){return!e||!Nne(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:Bne(e,i)};if(i.type==="message"){const s=i.content.map(o=>o.type==="output_text"?{...o,parsed:Lne(e,o.text)}:o);return{...i,content:s}}return i}),r=Object.assign({},t,{output:n});return Object.getOwnPropertyDescriptor(t,"output_text")||gC(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 Lne(t,e){return t.text?.format?.type!=="json_schema"?null:"$parseRaw"in t.text?.format?(t.text?.format).$parseRaw(e):JSON.parse(e)}function Nne(t){return!!ak(t.text?.format)}function $ne(t){return t?.$brand==="auto-parseable-tool"}function jne(t,e){return t.find(n=>n.type==="function"&&n.name===e)}function Bne(t,e){const n=jne(t.tools??[],e.name);return{...e,...e,parsed_arguments:$ne(n)?n.$parseRaw(e.arguments):n?.strict?JSON.parse(e.arguments):null}}function gC(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,sy,Ha,oy,tL,nL,rL,iL;class Ck extends ck{constructor(e){super(),$u.add(this),sy.set(this,void 0),Ha.set(this,void 0),oy.set(this,void 0),Ge(this,sy,e)}static createResponse(e,n,r){const i=new Ck(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)}[(sy=new WeakMap,Ha=new WeakMap,oy=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=Fne(n,ne(this,sy,"f"));return Ge(this,oy,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,oy,"f");if(!e)throw new Ie("stream ended without producing a ChatCompletion");return e}}function Fne(t,e){return Ine(t,e)}class v6 extends ze{list(e,n={},r){return this._client.getAPIList(ve`/responses/${e}/input_items`,gn,{query:n,...r})}}class Ak 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"&&gC(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"&&gC(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 Ck.createResponse(this._client,e,n)}cancel(e,n){return this._client.post(ve`/responses/${e}/cancel`,n)}}Ak.InputItems=v6;class x6 extends ze{create(e,n,r){return this._client.post(ve`/uploads/${e}/parts`,_c({body:n,...r},this._client))}}class Ek extends ze{constructor(){super(...arguments),this.parts=new x6(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})}}Ek.Parts=x6;const zne=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 w6 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 zne(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`,$x,{...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};class Fx extends ze{constructor(){super(...arguments),this.files=new S6(this._client),this.fileBatches=new w6(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`,$x,{body:n,method:"post",...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}}Fx.Files=S6;Fx.FileBatches=w6;var Ku,_6,bb;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",bb).call(this,s,"webhook-signature"),a=ne(this,Ku,"m",bb).call(this,s,"webhook-timestamp"),c=ne(this,Ku,"m",bb).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(x=>x.startsWith("v1,")?x.substring(3):x),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 x of d)try{const S=Buffer.from(x,"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")},bb=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 yC,kk,vb,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(yC.add(this),vb.set(this,void 0),this.completions=new r6(this),this.chat=new fk(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 Sk(this),this.vectorStores=new Fx(this),this.webhooks=new C6(this),this.beta=new zm(this),this.batches=new J8(this),this.uploads=new Ek(this),this.responses=new Ak(this),this.realtime=new _k(this),this.conversations=new gk(this),this.evals=new bk(this),this.containers=new mk(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&&Fte())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??kk.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??Wte(),Ge(this,vb,Gte),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 Zte(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,yC,"m",A6).call(this)&&r||this.baseURL,s=Lte(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();return Nte(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(iC),b=Date.now();if(y instanceof globalThis.Error){const _=`retrying, ${n} attempts remaining`;if(i.signal?.aborted)throw new Gi;const A=rC(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 ik:new Lx({cause:y})}const x=[...y.headers.entries()].filter(([_])=>_==="x-request-id").map(([_,A])=>", "+_+": "+JSON.stringify(A)).join(""),S=`[${h}${f}${x}] ${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 qte(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=>iC(D).message),P=Bte(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 lne(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&&jte("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))}:{},...Hte(),"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,vb,"f").call(this,{body:e,headers:r})}}kk=Xe,vb=new WeakMap,yC=new WeakSet,A6=function(){return this.baseURL!=="https://api.openai.com/v1"};Xe.OpenAI=kk;Xe.DEFAULT_TIMEOUT=6e5;Xe.OpenAIError=Ie;Xe.APIError=Qr;Xe.APIConnectionError=Lx;Xe.APIConnectionTimeoutError=ik;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=mne;Xe.Completions=r6;Xe.Chat=fk;Xe.Embeddings=o6;Xe.Files=l6;Xe.Images=p6;Xe.Audio=Fm;Xe.Moderations=g6;Xe.Models=m6;Xe.FineTuning=Kh;Xe.Graders=Sk;Xe.VectorStores=Fx;Xe.Webhooks=C6;Xe.Beta=zm;Xe.Batches=J8;Xe.Uploads=Ek;Xe.Responses=Ak;Xe.Realtime=_k;Xe.Conversations=gk;Xe.Evals=bk;Xe.Containers=mk;const Vne=t=>t.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:{...e.inputSchema}}})),ay=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},Une=(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},Hne=(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 Wne{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=ay(e)};setTools=e=>{this.tools=Vne(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=ay(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,x)=>{if(b.type==="tool-call")return!0;const S=r?.content.length??0;return x>=S})}:a,y=ay([m]);this.prevMessages.push(...y);return}d.delta.content&&(a=Une(a,d,n)),d.delta.tool_calls&&typeof a.content!="string"&&(a=Hne(a,d))}}),this.stopStream){const d=ay([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(r),r.code==="invalid_api_key")return{field:"key",message:"Invalid API Key"};if(e.apiKey)return{field:"url",message:"Invalid URL"}}return{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"}))}const sL=new Wne;function Lt(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 bC(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}const vC=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 zx({message:r,cause:vC(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 zx extends yr{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}}class k6 extends zx{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 qne=/^[a-z][a-z0-9+.-]*:/i,Gne=t=>qne.test(t);let xC=t=>(xC=Array.isArray,xC(t)),oL=xC;function Kne(t){if(!t)return!0;for(const e in t)return!1;return!0}function Yne(t,e){return Object.prototype.hasOwnProperty.call(t,e)}const Xne=(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},Jne=t=>{try{return JSON.parse(t)}catch{return}},Qne=t=>new Promise(e=>setTimeout(e,t)),Yu="0.22.0";function Zne(){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 ere=()=>{const t=Zne();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=tre();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 tre(){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 nre=()=>cL??(cL=ere());function rre(){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 ire(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 sre=({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 are(t.body,e)}),uL=new WeakMap;function ore(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 are=async(t,e)=>{if(!await ore(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])=>wC(n,r,i))),n},lre=t=>t instanceof Blob&&"name"in t,wC=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(lre(n))t.append(e,n,xb(n));else if(Array.isArray(n))await Promise.all(n.map(r=>wC(t,e+"[]",r)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([r,i])=>wC(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",cre=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&V6(t),ure=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function hre(t,e,n){if(B6(),t=await t,cre(t))return t instanceof File?t:_p([await t.arrayBuffer()],t.name);if(ure(t)){const i=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),_p(await SC(i),e,n)}const r=await SC(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 SC(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 SC(n));else{const n=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${n?`; constructor: ${n}`:""}${fre(t)}`)}return e}function fre(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*dre(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 dre(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 Vx 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})}}Vx.Transcriptions=U6;Vx.Translations=H6;function q6(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const hL=Object.freeze(Object.create(null)),pre=(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),x="^".repeat(y.length);return f=y.start+y.length,m+b+x},"");throw new At(`Path parameters result in path with invalid segments:
${s.map(m=>m.error).join(`
`)}
${o}
${d}`)}return o},Ki=pre(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,wb,Sb,rp,ip,_b,sp,Uo,op,Cb,Ab,Xu,_C,dv,CC,AC,EC,kC,X6,TC;const dL=10;class mre{constructor(){hr.add(this),this.controller=new AbortController,wb.set(this,void 0),Sb.set(this,()=>{}),rp.set(this,()=>{}),ip.set(this,void 0),_b.set(this,()=>{}),sp.set(this,()=>{}),Uo.set(this,{}),this._chatCompletions=[],this.messages=[],op.set(this,!1),Cb.set(this,!1),Ab.set(this,!1),Xu.set(this,!1),kC.set(this,e=>{if(Lt(this,Cb,!0),e instanceof Error&&e.name==="AbortError"&&(e=new Cc),e instanceof Cc)return Lt(this,Ab,!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)))}),Lt(this,wb,new Promise((e,n)=>{Lt(this,Sb,e,"f"),Lt(this,rp,n,"f")})),Lt(this,ip,new Promise((e,n)=>{Lt(this,_b,e,"f"),Lt(this,sp,n,"f")})),Ae(this,wb,"f").catch(()=>{}),Ae(this,ip,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},Ae(this,kC,"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,Sb,"f").call(this),this._emit("connect"))}get ended(){return Ae(this,op,"f")}get errored(){return Ae(this,Cb,"f")}get aborted(){return Ae(this,Ab,"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)=>{Lt(this,Xu,!0),e!=="error"&&this.once("error",r),this.once(e,n)})}async done(){Lt(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",_C).call(this)}async finalMessage(){return await this.done(),Ae(this,hr,"m",dv).call(this)}async finalFunctionCall(){return await this.done(),Ae(this,hr,"m",CC).call(this)}async finalFunctionCallResult(){return await this.done(),Ae(this,hr,"m",AC).call(this)}async totalUsage(){return await this.done(),Ae(this,hr,"m",EC).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emit(e,...n){if(Ae(this,op,"f"))return;e==="end"&&(Lt(this,op,!0),Ae(this,_b,"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",dv).call(this);n&&this._emit("finalMessage",n);const r=Ae(this,hr,"m",_C).call(this);r&&this._emit("finalContent",r);const i=Ae(this,hr,"m",CC).call(this);i&&this._emit("finalFunctionCall",i);const s=Ae(this,hr,"m",AC).call(this);s!=null&&this._emit("finalFunctionCallResult",s),this._chatCompletions.some(o=>o.usage)&&this._emit("totalUsage",Ae(this,hr,"m",EC).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:x,arguments:S}=b.function_call,_=f[x];if(_){if(c&&c!==x){const O=`Invalid function_call: ${JSON.stringify(x)}. ${JSON.stringify(c)} requested. Please try again`;this._addMessage({role:i,name:x,content:O});continue}}else{const O=`Invalid function_call: ${JSON.stringify(x)}. Available options are: ${d.map(M=>JSON.stringify(M.name)).join(", ")}. Please try again`;this._addMessage({role:i,name:x,content:O});continue}let A;try{A=fL(_)?await _.parse(S):S}catch(O){this._addMessage({role:i,name:x,content:O instanceof Error?O.message:String(O)});continue}const E=await _.function(A,this),P=Ae(this,hr,"m",TC).call(this,E);if(this._addMessage({role:i,name:x,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 x of b.tool_calls){if(x.type!=="function")continue;const S=x.id,{name:_,arguments:A}=x.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(N=>JSON.stringify(N.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 N=D instanceof Error?D.message:String(D);this._addMessage({role:i,tool_call_id:S,content:N});continue}const O=await E.function(P,this),M=Ae(this,hr,"m",TC).call(this,O);if(this._addMessage({role:i,tool_call_id:S,content:M}),c)return}}}}wb=new WeakMap,Sb=new WeakMap,rp=new WeakMap,ip=new WeakMap,_b=new WeakMap,sp=new WeakMap,Uo=new WeakMap,op=new WeakMap,Cb=new WeakMap,Ab=new WeakMap,Xu=new WeakMap,kC=new WeakMap,hr=new WeakSet,_C=function(){return Ae(this,hr,"m",dv).call(this).content??null},dv=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")},CC=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}},AC=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}},EC=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.")},TC=function(e){return typeof e=="string"?e:e===void 0?"undefined":JSON.stringify(e)};function gre(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 Tk(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,xi;class Ux{constructor(){vi.set(this,void 0),xi.set(this,void 0),Lt(this,vi,new Uint8Array),Lt(this,xi,null)}decode(e){if(e==null)return[];const n=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?Tk(e):e;Lt(this,vi,gre([Ae(this,vi,"f"),n]));const r=[];let i;for(;(i=yre(Ae(this,vi,"f"),Ae(this,xi,"f")))!=null;){if(i.carriage&&Ae(this,xi,"f")==null){Lt(this,xi,i.index);continue}if(Ae(this,xi,"f")!=null&&(i.index!==Ae(this,xi,"f")+1||i.carriage)){r.push(gL(Ae(this,vi,"f").subarray(0,Ae(this,xi,"f")-1))),Lt(this,vi,Ae(this,vi,"f").subarray(Ae(this,xi,"f"))),Lt(this,xi,null);continue}const s=Ae(this,xi,"f")!==null?i.preceding-1:i.preceding,o=gL(Ae(this,vi,"f").subarray(0,s));r.push(o),Lt(this,vi,Ae(this,vi,"f").subarray(i.index)),Lt(this,xi,null)}return r}flush(){return Ae(this,vi,"f").length?this.decode(`
`):[]}}vi=new WeakMap,xi=new WeakMap;Ux.NEWLINE_CHARS=new Set([`
`,"\r"]);Ux.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function yre(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 bre(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 pv={off:0,error:200,warn:300,info:400,debug:500},yL=(t,e,n)=>{if(t){if(Yne(pv,t))return t;Tr(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(pv))}`)}};function ap(){}function ly(t,e,n){return!e||pv[t]>pv[n]?ap:e[t].bind(e)}const vre={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 vre;const r=bL.get(e);if(r&&r[0]===n)return r[1];const i={error:ly("error",e,n),warn:ly("warn",e,n),info:ly("info",e,n),debug:ly("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,Lt(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(bC(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 Ux,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(bC(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=Tk(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 Sre,r=new Ux,i=j6(t.body);for await(const s of wre(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*wre(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"?Tk(n):n;let i=new Uint8Array(e.length+r.length);i.set(e),i.set(r,e.length),e=i;let s;for(;(s=bre(e))!==-1;)yield e.slice(0,s),e=e.slice(s)}e.length>0&&(yield e)}class Sre{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]=_re(e,":");return i.startsWith(" ")&&(i=i.substring(1)),n==="event"?this.event=i:n==="data"&&this.data.push(i),null}}function _re(t,e){const n=t.indexOf(e);return n!==-1?[t.substring(0,n),e,t.substring(n+e.length)]:[t,"",""]}var Us,Wa,d_,p_,cy,vL;class mv extends mre{constructor(){super(...arguments),Us.add(this),Wa.set(this,void 0)}get currentChatCompletionSnapshot(){return Ae(this,Wa,"f")}static fromReadableStream(e){const n=new mv;return n._run(()=>n._fromReadableStream(e)),n}static createChatCompletion(e,n,r){const i=new mv;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",d_).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",p_).call(this,o);if(s.controller.signal?.aborted)throw new Cc;return this._addChatCompletion(Ae(this,Us,"m",cy).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",d_).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",cy).call(this)),Ae(this,Us,"m",p_).call(this,o),s=o.id;if(i.controller.signal?.aborted)throw new Cc;return this._addChatCompletion(Ae(this,Us,"m",cy).call(this))}[(Wa=new WeakMap,Us=new WeakSet,d_=function(){this.ended||Lt(this,Wa,void 0)},p_=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)},cy=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 Lt(this,Wa,void 0),Cre(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=Lt(this,Wa,{...f,choices:[]});for(const{delta:d,finish_reason:m,index:y,logprobs:b=null,...x}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:[]},...x}),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,x),!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:N,function:H,...j}of P){const V=(a=S.message.tool_calls)[M]??(a[M]={});Object.assign(V,j),D&&(V.id=D),N&&(V.type=N),H&&(V.function??(V.function={arguments:""})),H?.name&&(V.function.name=H.name),H?.arguments&&(V.function.arguments+=H.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 Cre(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,...x}=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:{...x,role:S,content:m,tool_calls:b.map((_,A)=>{const{function:E,type:P,id:O,...M}=_,{arguments:D,name:N,...H}=E||{};if(O==null)throw new At(`missing choices[${h}].tool_calls[${A}].id
${uy(t)}`);if(P==null)throw new At(`missing choices[${h}].tool_calls[${A}].type
${uy(t)}`);if(N==null)throw new At(`missing choices[${h}].tool_calls[${A}].function.name
${uy(t)}`);if(D==null)throw new At(`missing choices[${h}].tool_calls[${A}].function.arguments
${uy(t)}`);return{...M,id:O,type:P,function:{...H,name:N,arguments:D}}})}}:{...d,message:{...x,content:m,role:S},finish_reason:c,index:h,logprobs:f}}),created:r,model:i,object:"chat.completion",...s?{system_fingerprint:s}:{}}}function uy(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 mv.createChatCompletion(this._client.chat.completions,e,n)}};class Rk extends Qn{constructor(){super(...arguments),this.completions=new J6(this._client)}}Rk.Completions=J6;class Q6 extends Qn{list(e){return this._client.get("/tci/sessions",e)}}class Mk extends Qn{constructor(){super(...arguments),this.sessions=new Q6(this._client)}execute(e,n){return this._client.post("/tci/execute",{body:e,...n})}}Mk.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 Are(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 Ok extends Promise{constructor(e,n,r=Are){super(i=>{i(null)}),this.responsePromise=n,this.parseResponse=r,lp.set(this,void 0),Lt(this,lp,e)}_thenUnwrap(e){return new Ok(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 Ere={};const m_=t=>{if(typeof globalThis.process<"u")return Ere?.[t]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(t)?.trim()};var RC,Pk,Eb,l9;class pt{constructor({baseURL:e=m_("TOGETHER_BASE_URL"),apiKey:n=m_("TOGETHER_API_KEY"),...r}={}){if(RC.add(this),Eb.set(this,void 0),this.chat=new Rk(this),this.completions=new Z6(this),this.embeddings=new e9(this),this.files=new n9(this),this.fineTune=new r9(this),this.codeInterpreter=new Mk(this),this.images=new s9(this),this.audio=new Vx(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??Pk.DEFAULT_TIMEOUT,this.logger=i.logger??console;const s="warn";this.logLevel=s,this.logLevel=yL(i.logLevel,"ClientOptions.logLevel",this)??yL(m_("TOGETHER_LOG"),"process.env['TOGETHER_LOG']",this)??s,this.fetchOptions=i.fetchOptions,this.maxRetries=i.maxRetries??5,this.fetch=i.fetch??rre(),Lt(this,Eb,sre),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,RC,"m",l9).call(this)&&r||this.baseURL,s=Gne(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();return Kne(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 Ok(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(vC),b=Date.now();if(y instanceof Error){const S=`retrying, ${n} attempts remaining`;if(i.signal?.aborted)throw new Cc;const _=bC(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 zx({cause:y})}const x=`[${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 ire(y.body),Tr(this).info(`${x} - ${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(`${x} - ${_}`);const A=await y.text().catch(M=>vC(M).message),E=Jne(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(x),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 Qne(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&&Xne("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))}:{},...nre()},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,Eb,"f").call(this,{body:e,headers:r})}}Pk=pt,Eb=new WeakMap,RC=new WeakSet,l9=function(){return this.baseURL!=="https://api.together.xyz/v1"};pt.Together=Pk;pt.DEFAULT_TIMEOUT=6e4;pt.TogetherError=At;pt.APIError=yr;pt.APIConnectionError=zx;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=hre;pt.Chat=Rk;pt.Completions=Z6;pt.Embeddings=e9;pt.Files=n9;pt.FineTuneResource=r9;pt.CodeInterpreter=Mk;pt.Images=s9;pt.Audio=Vx;pt.Models=a9;pt.Jobs=o9;pt.Endpoints=t9;pt.Hardware=i9;pt.Batches=G6;const kre=t=>{const e=[];return t.forEach(n=>{e.push({type:"function",function:{name:n.name,description:n.description,parameters:{type:"object",...n.inputSchema}}})}),e},hy=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},Tre=(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},Rre=(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 Mre{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=hy(e)};setTools=e=>{this.tools=kre(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=hy(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,x)=>{if(b.type==="tool-call")return!0;const S=r?.content.length??0;return x>=S})}:a,y=hy([m]);this.prevMessages.push(...y);return}d.delta.content&&(a=Tre(a,d,n)),d.delta.tool_calls&&typeof a.content!="string"&&(a=Rre(a,d))}}),this.stopStream){if(typeof a.content=="string",a.content.length>0){const m=hy([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)return{field:"key",message:"Invalid API Key"};if(e.apiKey)return{field:"url",message:"Invalid URL"}}return{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 xL=new Mre,Ore=t=>t.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:{...e.inputSchema}}})),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=>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},Pre=(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},Dre=(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 Ire{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=fy(e)};setTools=e=>{this.tools=Ore(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,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,x)=>{if(b.type==="tool-call")return!0;const S=r?.content.length??0;return x>=S})}:a,y=fy([m]);this.prevMessages.push(...y);return}d.delta.content&&(a=Pre(a,d,n)),d.delta.tool_calls&&typeof a.content!="string"&&(a=Dre(a,d))}}),this.stopStream){const d=fy([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:n.status===401||!e.apiKey?{field:"key",message:"Invalid API Key"}:{field:"url",message:"Invalid URL"}}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==="x-ai/grok-4"||i.id==="google/gemini-2.5-flash"||i.id==="google/gemini-2.5-pro"||i.id==="deepseek/deepseek-chat-v3.1"||i.id==="qwen/qwen3-235b-a22b-2507").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==="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==="deepseek/deepseek-chat-v3.1"?"DeepSeek V3.1":i.id==="qwen/qwen3-235b-a22b-2507"?"Qwen 3":i.id.toUpperCase(),provider:"openrouter"}))}const wL=new Ire;let Lre=class{currentProvider;currentProviderInfo;currentProviderType;anthropicProvider;ollamaProvider;openaiProvider;togetherProvider;openrouterProvider;constructor(){this.anthropicProvider=kI,this.ollamaProvider=OI,this.openaiProvider=sL,this.togetherProvider=xL,this.openrouterProvider=wL}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=xL,this.currentProviderType="together";break;case"openrouter":this.currentProvider=wL,this.currentProviderType="openrouter";break;default:this.currentProvider=void 0,this.currentProviderType=void 0}this.currentProvider&&(this.currentProvider.setProvider(e),this.currentProvider.setSystemPrompt(tte))};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=>this.currentProvider?(await this.currentProvider.createChatName(e)).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 $t=new Lre;class Nre{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 Nre,$re=()=>ns.init(),dy=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)}})},jre=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()}})},Bre=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}),$t.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),$t.stopMessage()}})),Vm=na(t=>({currentPage:"chat",setCurrentPage:e=>t({currentPage:e}),goToChat:()=>t({currentPage:"chat"}),goToSettings:()=>t({currentPage:"settings"})})),py="providers",ju="current-provider",g_="current-model",bh=100,kb=bh+2,rs=na()((t,e)=>({providers:(()=>{const n=localStorage.getItem(py);return n?JSON.parse(n):[]})(),currentProvider:(()=>{const n=localStorage.getItem(ju);if(!n)return null;const r=JSON.parse(n);$t.setCurrentProvider(r);const i=$t.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 $t.getProvidersModels(n);t({providersModels:r})},setCurrentProvider:n=>{t({currentProvider:n}),$t.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 $t.checkNewProvider(n.type,{url:n.baseUrl,apiKey:n.key});return typeof s=="boolean"&&s?(t(o=>{const a=[...o.providers,n];return localStorage.setItem(py,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 $t.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(py,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),$t.setCurrentProvider()),localStorage.setItem(py,JSON.stringify(i)),{providers:i}})}}));class Fre{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 zre{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,x)=>{if(y(b,x),b===0)try{const S=JSON.parse(x);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 Vre=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).results;r({data:s})},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("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).results;r({data:s})},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 Ure=class{desktopEditorTool;customServers;webSearch;allowAlways;constructor(){this.desktopEditorTool=new Fre,this.customServers=new zre,this.webSearch=new Vre,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 Ure,my="disabledTools",gy="mcpServers",Rs=na((t,e)=>({servers:{},tools:[],disabledTools:{},manageToolData:void 0,webSearchEnabled:!1,initServers:()=>{const n=localStorage.getItem(gy);if(n){const r=JSON.parse(n);Qt.setCustomServers(r),Qt.startCustomServers()}},getTools:async()=>{const n=await Qt.getTools(),r=localStorage.getItem(my),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===kb: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?kb: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(my,JSON.stringify(h));return}if(s.tools.length>=(s.webSearchEnabled?kb: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(my,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(my,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(gy)||JSON.stringify({mcpServers:{}})),saveConfig:n=>{const r=n.mcpServers?n:{mcpServers:{}};localStorage.setItem(gy,JSON.stringify(r)),Qt.setCustomServers(r),Qt.startCustomServers()},deleteCustomServer:n=>{Qt.deleteCustomServer(n);const r=e().getConfig();delete r.mcpServers[n],localStorage.setItem(gy,JSON.stringify(r))},getCustomServersLogs:()=>Qt.getCustomServersLogs(),getWebSearchEnabled:()=>Qt.getWebSearchEnabled()})),Hre=(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={},MC=(t,e,n,r)=>{gc(n)&&AL[n]||(gc(n)&&(AL[n]=new Date),Hre(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)}},OC=(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 OC(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,u9(t,r))},Wre=(t,e,n={})=>!e.languages||!e.languages.length?(MC(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",qre=t=>typeof t=="object"&&t!==null,Gre=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Kre={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},Yre=t=>Kre[t],Xre=t=>t.replace(Gre,Yre);let PC={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Xre};const Jre=(t={})=>{PC={...PC,...t}},Qre=()=>PC;let h9;const Zre=t=>{h9=t},eie=()=>h9,tie={type:"3rdParty",init(t){Jre(t.options.react),Zre(t)}},nie=k.createContext();class rie{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const iie=(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),sie=(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(nie)||{},s=n||r||eie();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new rie),!s){MC(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const P=(M,D)=>gc(D)?D:qre(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&&MC(s,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...Qre(),...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=>Wre(P,s,o)),d=sie(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,x]=k.useState(m);let S=h.join();e.lng&&(S=`${e.lng}${S}`);const _=iie(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&&x(y)}):OC(s,h,()=>{A.current&&x(y)})),f&&_&&_!==S&&A.current&&x(y);const M=()=>{A.current&&x(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&&x(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()):OC(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 gv(){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=gv,oie=(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[x,S]=b;return Array.isArray(S)?S.includes({...s,...a}[x]):{...s,...a}[x]===S})?[...h,d,m]:h},[]);return TL(t,o,c,n?.class,n?.className)},Dk="-",aie=t=>{const e=cie(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const a=o.split(Dk);return a[0]===""&&a.length!==1&&a.shift(),p9(a,e)||lie(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(Dk);return e.validators.find(({validator:o})=>o(s))?.classGroupId},RL=/^\[(.+)\]$/,lie=t=>{if(RL.test(t)){const e=RL.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},cie=t=>{const{theme:e,classGroups:n}=t,r={nextPart:new Map,validators:[]};for(const i in n)DC(n[i],r,i,e);return r},DC=(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(uie(i)){DC(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{DC(o,ML(e,s),n,r)})})},ML=(t,e)=>{let n=t;return e.split(Dk).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},uie=t=>t.isThemeGetter,hie=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)}}},IC="!",LC=":",fie=LC.length,die=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 x=i[b];if(o===0&&a===0){if(x===LC){s.push(i.slice(c,b)),c=b+fie;continue}if(x==="/"){h=b;continue}}x==="["?o++:x==="]"?o--:x==="("?a++:x===")"&&a--}const f=s.length===0?i:i.substring(c),d=pie(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+LC,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},pie=t=>t.endsWith(IC)?t.substring(0,t.length-1):t.startsWith(IC)?t.substring(1):t,mie=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}},gie=t=>({cache:hie(t.cacheSize),parseClassName:die(t),sortModifiers:mie(t),...aie(t)}),yie=/\s+/,bie=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=e,o=[],a=t.trim().split(yie);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:x}=n(f);if(d){c=f+(c.length>0?" "+c:c);continue}let S=!!x,_=r(S?b.substring(0,x):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+IC: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 vie(){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=gie(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=bie(c,n);return i(c,f),f}return function(){return s(vie.apply(null,arguments))}}const Sn=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},g9=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,y9=/^\((?:(\w[\w-]*):)?(.+)\)$/i,wie=/^\d+\/\d+$/,Sie=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_ie=/\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$/,Cie=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Aie=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Eie=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Bu=t=>wie.test(t),tt=t=>!!t&&!Number.isNaN(Number(t)),qa=t=>!!t&&Number.isInteger(Number(t)),y_=t=>t.endsWith("%")&&tt(t.slice(0,-1)),zo=t=>Sie.test(t),kie=()=>!0,Tie=t=>_ie.test(t)&&!Cie.test(t),b9=()=>!1,Rie=t=>Aie.test(t),Mie=t=>Eie.test(t),Oie=t=>!Re(t)&&!Me(t),Pie=t=>Xh(t,w9,b9),Re=t=>g9.test(t),Yl=t=>Xh(t,S9,Tie),b_=t=>Xh(t,$ie,tt),OL=t=>Xh(t,v9,b9),Die=t=>Xh(t,x9,Mie),yy=t=>Xh(t,_9,Rie),Me=t=>y9.test(t),Rd=t=>Jh(t,S9),Iie=t=>Jh(t,jie),PL=t=>Jh(t,v9),Lie=t=>Jh(t,w9),Nie=t=>Jh(t,x9),by=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",x9=t=>t==="image"||t==="url",w9=t=>t==="length"||t==="size"||t==="bg-size",S9=t=>t==="length",$ie=t=>t==="number",jie=t=>t==="family-name",_9=t=>t==="shadow",Bie=()=>{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"),x=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"],N=()=>[Me,Re,c],H=()=>[Bu,"full","auto",...N()],j=()=>[qa,"none","subgrid",Me,Re],V=()=>["auto",{span:["full",qa,Me,Re]},qa,Me,Re],q=()=>[qa,"auto",Me,Re],X=()=>["auto","min","max","fr",Me,Re],Y=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],te=()=>["start","end","center","stretch","center-safe","end-safe"],z=()=>["auto",...N()],G=()=>[Bu,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...N()],U=()=>[t,Me,Re],se=()=>[...P(),PL,OL,{position:[Me,Re]}],T=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Z=()=>["auto","cover","contain",Lie,Pie,{size:[Me,Re]}],ue=()=>[y_,Rd,Yl],L=()=>["","none","full",h,Me,Re],de=()=>["",tt,Rd,Yl],ke=()=>["solid","dashed","dotted","double"],ye=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ee=()=>[tt,y_,PL,OL],Ue=()=>["","none",b,Me,Re],Pt=()=>["none",tt,Me,Re],Kt=()=>["none",tt,Me,Re],Yt=()=>[tt,Me,Re],er=()=>[Bu,"full",...N()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[zo],breakpoint:[zo],color:[kie],container:[zo],"drop-shadow":[zo],ease:["in","out","in-out"],font:[Oie],"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:H()}],"inset-x":[{"inset-x":H()}],"inset-y":[{"inset-y":H()}],start:[{start:H()}],end:[{end:H()}],top:[{top:H()}],right:[{right:H()}],bottom:[{bottom:H()}],left:[{left:H()}],visibility:["visible","invisible","collapse"],z:[{z:[qa,"auto",Me,Re]}],basis:[{basis:[Bu,"full","auto",a,...N()]}],"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":j()}],"col-start-end":[{col:V()}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":j()}],"row-start-end":[{row:V()}],"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":X()}],"auto-rows":[{"auto-rows":X()}],gap:[{gap:N()}],"gap-x":[{"gap-x":N()}],"gap-y":[{"gap-y":N()}],"justify-content":[{justify:[...Y(),"normal"]}],"justify-items":[{"justify-items":[...te(),"normal"]}],"justify-self":[{"justify-self":["auto",...te()]}],"align-content":[{content:["normal",...Y()]}],"align-items":[{items:[...te(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...te(),{baseline:["","last"]}]}],"place-content":[{"place-content":Y()}],"place-items":[{"place-items":[...te(),"baseline"]}],"place-self":[{"place-self":["auto",...te()]}],p:[{p:N()}],px:[{px:N()}],py:[{py:N()}],ps:[{ps:N()}],pe:[{pe:N()}],pt:[{pt:N()}],pr:[{pr:N()}],pb:[{pb:N()}],pl:[{pl:N()}],m:[{m:z()}],mx:[{mx:z()}],my:[{my:z()}],ms:[{ms:z()}],me:[{me:z()}],mt:[{mt:z()}],mr:[{mr:z()}],mb:[{mb:z()}],ml:[{ml:z()}],"space-x":[{"space-x":N()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":N()}],"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,b_]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",y_,Re]}],"font-family":[{font:[Iie,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,b_]}],leading:[{leading:[s,...N()]}],"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:U()}],"text-color":[{text:U()}],"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:U()}],"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:N()}],"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]},Nie,Die]}],"bg-color":[{bg:U()}],"gradient-from-pos":[{from:ue()}],"gradient-via-pos":[{via:ue()}],"gradient-to-pos":[{to:ue()}],"gradient-from":[{from:U()}],"gradient-via":[{via:U()}],"gradient-to":[{to:U()}],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:de()}],"border-w-x":[{"border-x":de()}],"border-w-y":[{"border-y":de()}],"border-w-s":[{"border-s":de()}],"border-w-e":[{"border-e":de()}],"border-w-t":[{"border-t":de()}],"border-w-r":[{"border-r":de()}],"border-w-b":[{"border-b":de()}],"border-w-l":[{"border-l":de()}],"divide-x":[{"divide-x":de()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":de()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ke(),"hidden","none"]}],"divide-style":[{divide:[...ke(),"hidden","none"]}],"border-color":[{border:U()}],"border-color-x":[{"border-x":U()}],"border-color-y":[{"border-y":U()}],"border-color-s":[{"border-s":U()}],"border-color-e":[{"border-e":U()}],"border-color-t":[{"border-t":U()}],"border-color-r":[{"border-r":U()}],"border-color-b":[{"border-b":U()}],"border-color-l":[{"border-l":U()}],"divide-color":[{divide:U()}],"outline-style":[{outline:[...ke(),"none","hidden"]}],"outline-offset":[{"outline-offset":[tt,Me,Re]}],"outline-w":[{outline:["",tt,Rd,Yl]}],"outline-color":[{outline:U()}],shadow:[{shadow:["","none",f,by,yy]}],"shadow-color":[{shadow:U()}],"inset-shadow":[{"inset-shadow":["none",d,by,yy]}],"inset-shadow-color":[{"inset-shadow":U()}],"ring-w":[{ring:de()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:U()}],"ring-offset-w":[{"ring-offset":[tt,Yl]}],"ring-offset-color":[{"ring-offset":U()}],"inset-ring-w":[{"inset-ring":de()}],"inset-ring-color":[{"inset-ring":U()}],"text-shadow":[{"text-shadow":["none",m,by,yy]}],"text-shadow-color":[{"text-shadow":U()}],opacity:[{opacity:[tt,Me,Re]}],"mix-blend":[{"mix-blend":[...ye(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ye()}],"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":U()}],"mask-image-linear-to-color":[{"mask-linear-to":U()}],"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":U()}],"mask-image-t-to-color":[{"mask-t-to":U()}],"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":U()}],"mask-image-r-to-color":[{"mask-r-to":U()}],"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":U()}],"mask-image-b-to-color":[{"mask-b-to":U()}],"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":U()}],"mask-image-l-to-color":[{"mask-l-to":U()}],"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":U()}],"mask-image-x-to-color":[{"mask-x-to":U()}],"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":U()}],"mask-image-y-to-color":[{"mask-y-to":U()}],"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":U()}],"mask-image-radial-to-color":[{"mask-radial-to":U()}],"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":U()}],"mask-image-conic-to-color":[{"mask-conic-to":U()}],"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,by,yy]}],"drop-shadow-color":[{"drop-shadow":U()}],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":N()}],"border-spacing-x":[{"border-spacing-x":N()}],"border-spacing-y":[{"border-spacing-y":N()}],"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:[x,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:U()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:U()}],"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":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"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",...U()]}],"stroke-w":[{stroke:[tt,Rd,Yl,b_]}],stroke:[{stroke:["none",...U()]}],"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"]}},Fie=xie(Bie),je=(...t)=>Fie(gv(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},zie=t=>t.split(`
`)[0].replace("## ","").substring(0,30),A9=t=>!!(t&64),E9=t=>!!(t&128),Tb=t=>!!(t&256),k9=t=>t===513||t===521,Vie="inline-flex items-center justify-center rounded-[4px] min-w-[40px]",Uie="outline-none focus:outline-none focus-visible:outline-none",Hie="bg-[var(--button-default-background-color)] border border-[var(--button-default-border-color)] text-[var(--button-default-color)]",Wie="hover:enabled:bg-[var(--button-default-hover-background-color)]",qie="active:enabled:bg-[var(--button-default-pressed-background-color)]",Gie="focus:shadow-[var(--button-default-focus-shadow)]",Kie="disabled:bg-[var(--button-default-disabled-background-color)] disabled:text-[var(--button-default-disabled-color)] disabled:opacity-40 disabled:cursor-not-allowed",Yie="bg-[var(--button-background-color)] text-[var(--button-color)]",Xie="hover:enabled:bg-[var(--button-background-hover-color)]",Jie="active:enabled:bg-[var(--button-background-pressed-color)]",Qie="focus:bg-[var(--button-background-color)] focus:border-[var(--button-border-focus-color)] focus:shadow-[var(--button-shadow-focus)]",Zie="disabled:opacity-50 disabled:cursor-not-allowed",ese="h-[32px] min-w-[40px] px-[12px] text-[14px] font-semibold leading-[16px]",tse=oie(`${Vie} ${Uie}`,{variants:{variant:{default:je(Hie,Wie,qie,Gie,Kie),primary:je(Yie,Xie,Jie,Qie,Zie)},size:{default:ese},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",tse({variant:e,size:n,className:t})),...i})},nse=()=>{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-[24px] 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 T9(t){const e=t+"CollectionProvider",[n,r]=ra(e),[i,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=x=>{const{scope:S,children:_}=x,A=be.useRef(null),E=be.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=be.forwardRef((x,S)=>{const{scope:_,children:A}=x,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=be.forwardRef((x,S)=>{const{scope:_,children:A,...E}=x,P=be.useRef(null),O=Bt(S,P),M=s(f,_);return be.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(x){const S=s(t+"CollectionConsumer",x);return be.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 rse=k.createContext(void 0);function Ik(t){const e=k.useContext(rse);return t||e||"ltr"}var v_="rovingFocusGroup.onEntryFocus",ise={bubbles:!1,cancelable:!0},Um="RovingFocusGroup",[NC,R9,sse]=T9(Um),[ose,Hx]=ra(Um,[sse]),[ase,lse]=ose(Um),M9=k.forwardRef((t,e)=>C.jsx(NC.Provider,{scope:t.__scopeRovingFocusGroup,children:C.jsx(NC.Slot,{scope:t.__scopeRovingFocusGroup,children:C.jsx(cse,{...t,ref:e})})}));M9.displayName=Um;var cse=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=Ik(s),[x,S]=qh({prop:o,defaultProp:a??null,onChange:c,caller:Um}),[_,A]=k.useState(!1),E=Lr(h),P=R9(n),O=k.useRef(!1),[M,D]=k.useState(0);return k.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(v_,E),()=>N.removeEventListener(v_,E)},[E]),C.jsx(ase,{scope:n,orientation:r,dir:b,loop:i,currentTabStopId:x,onItemFocus:k.useCallback(N=>S(N),[S]),onItemShiftTab:k.useCallback(()=>A(!0),[]),onFocusableItemAdd:k.useCallback(()=>D(N=>N+1),[]),onFocusableItemRemove:k.useCallback(()=>D(N=>N-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,N=>{const H=!O.current;if(N.target===N.currentTarget&&H&&!_){const j=new CustomEvent(v_,ise);if(N.currentTarget.dispatchEvent(j),!j.defaultPrevented){const V=P().filter(z=>z.focusable),q=V.find(z=>z.active),X=V.find(z=>z.id===x),te=[q,X,...V].filter(Boolean).map(z=>z.ref.current);D9(te,f)}}O.current=!1}),onBlur:Le(t.onBlur,()=>A(!1))})})}),O9="RovingFocusGroupItem",P9=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=lse(O9,n),d=f.currentTabStopId===h,m=R9(n),{onFocusableItemAdd:y,onFocusableItemRemove:b,currentTabStopId:x}=f;return k.useEffect(()=>{if(r)return y(),()=>b()},[r,y,b]),C.jsx(NC.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 _=fse(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?dse(E,P+1):E.slice(P+1)}setTimeout(()=>D9(E))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:x!=null}):o})})});P9.displayName=O9;var use={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function hse(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function fse(t,e,n){const r=hse(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return use[r]}function D9(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function dse(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var I9=M9,L9=P9,Wx="Tabs",[pse]=ra(Wx,[Hx]),N9=Hx(),[mse,Lk]=pse(Wx),$9=k.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:o="horizontal",dir:a,activationMode:c="automatic",...h}=t,f=Ik(a),[d,m]=qh({prop:r,onChange:i,defaultProp:s??"",caller:Wx});return C.jsx(mse,{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})})});$9.displayName=Wx;var j9="TabsList",B9=k.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...i}=t,s=Lk(j9,n),o=N9(n);return C.jsx(I9,{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})})});B9.displayName=j9;var F9="TabsTrigger",z9=k.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=t,o=Lk(F9,n),a=N9(n),c=H9(o.baseId,r),h=W9(o.baseId,r),f=r===o.value;return C.jsx(L9,{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)})})})});z9.displayName=F9;var V9="TabsContent",U9=k.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...o}=t,a=Lk(V9,n),c=H9(a.baseId,r),h=W9(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})})});U9.displayName=V9;function H9(t,e){return`${t}-trigger-${e}`}function W9(t,e){return`${t}-content-${e}`}var gse=$9,yse=B9,bse=z9,vse=U9;const xse=({items:t,defaultValue:e,value:n,onValueChange:r,className:i})=>C.jsxs(gse,{defaultValue:e||t[0]?.value,value:n,onValueChange:r,className:je("w-full",i),children:[C.jsx(yse,{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(bse,{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(vse,{value:s.value,className:"mt-[24px]",children:s.content},s.value))]}),Nk="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",$k="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",wse="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",q9="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 $C(t,e){return $C=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},$C(t,e)}function Sse(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,$C(t,e)}var vy={};/*!
* content-type
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/var DL;function _se(){if(DL)return vy;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-]+$/;vy.format=o,vy.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 x,S=Object.keys(m).sort(),_=0;_<S.length;_++){if(x=S[_],!n.test(x))throw new TypeError("invalid parameter name");b+="; "+x+"="+h(m[x])}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 x=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"))),x.parameters[S]=A}if(y!==m.length)throw new TypeError("invalid parameter format")}return x}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 vy}var Cse=_se(),Ju=new Map,G9=function(e){return e.cloneNode(!0)},IL=function(){return window.location.protocol==="file:"},K9=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=Cse.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)},Ase=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,G9(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)},Ese=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,G9(i));return}}Ju.set(e,void 0),LL(e,r),K9(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),Ase(e)})},kse=function(e,n,r){K9(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)})},Tse=0,Rse=function(){return++Tse},Hs=[],NL={},Mse="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?Ese:kse;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 x=e.getAttribute("height");x&&d.setAttribute("height",x);var S=Array.from(new Set(sb(sb(sb([],(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(U){return/^data-\w[\w-]*$/.test(U.name)});if(Array.prototype.forEach.call(A,function(U){U.name&&U.value&&d.setAttribute(U.name,U.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,N;Object.keys(E).forEach(function(U){P=U,M=E[U],O=d.querySelectorAll(P+"[id]");for(var se=function(L,de){D=O[L].id,N=D+"-"+Rse();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(#"+N+")")}});for(var ye=d.querySelectorAll("[*|href]"),Ee=[],Ue=0,Pt=ye.length;Ue<Pt;Ue++){var Kt=ye[Ue].getAttributeNS(x_,"href");Kt&&Kt.toString()==="#"+O[L].id&&Ee.push(ye[Ue])}for(var Yt=0,er=Ee.length;Yt<er;Yt++)Ee[Yt].setAttributeNS(x_,"href","#"+N);O[L].id=N},T=0,Z=O.length;T<Z;T++)se(T)})}d.removeAttribute("xmlns:a");for(var H=d.querySelectorAll("script"),j=[],V,q,X=0,Y=H.length;X<Y;X++)q=H[X].getAttribute("type"),(!q||q==="application/ecmascript"||q==="application/javascript"||q==="text/javascript")&&(V=H[X].innerText||H[X].textContent,V&&j.push(V),d.removeChild(H[X]));if(j.length>0&&(n==="always"||n==="once"&&!NL[c])){for(var te=0,z=j.length;te<z;te++)new Function(j[te])(window);NL[c]=!0}var G=d.querySelectorAll("style");if(Array.prototype.forEach.call(G,function(U){U.textContent+=""}),d.setAttribute("xmlns",Mse),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)})},Ose=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,x=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,x,h,function(O,M){a(O,M),e&&"length"in e&&e.length===++A&&s(A)});else e?$L(e,y,_,d,x,h,function(O,M){a(O,M),s(1),e=null}):s(0)},w_={exports:{}},S_,jL;function Pse(){if(jL)return S_;jL=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return S_=t,S_}var __,BL;function Dse(){if(BL)return __;BL=1;var t=Pse();function e(){}function n(){}return n.resetWarningCache=e,__=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},__}var FL;function Ise(){return FL||(FL=1,w_.exports=Dse()()),w_.exports}var _n=Ise(),Lse=function(e){var n=e?.ownerDocument||document;return n.defaultView||window},Nse=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},$se=["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}Sse(e,t);var n=e.prototype;return n.renderSVG=function(){var i=this;if(this.reactWrapper instanceof Lse(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,x=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,N){if(D){E(D);return}i._isMounted&&i.setState(function(){return{isLoading:!1}},function(){try{x(N)}catch(H){E(H)}})},O=function(D){if(D.setAttribute("role","img"),o){var N=D.querySelector(":scope > desc");N&&D.removeChild(N);var H=document.createElement("desc");H.innerHTML=o,D.prepend(H)}if(d){var j=D.querySelector(":scope > title");j&&D.removeChild(j);var V=document.createElement("title");V.innerHTML=d,D.prepend(V)}try{b(D)}catch(q){E(q)}};Ose(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;Nse(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,$se),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",x="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,x,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 jC=["Enter"," "],jse=["ArrowDown","PageUp","Home"],Y9=["ArrowUp","PageDown","End"],Bse=[...jse,...Y9],Fse={ltr:[...jC,"ArrowRight"],rtl:[...jC,"ArrowLeft"]},zse={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Hm="Menu",[Jp,Vse,Use]=T9(Hm),[Ic,X9]=ra(Hm,[Use,Mx,Hx]),qx=Mx(),J9=Hx(),[Hse,Lc]=Ic(Hm),[Wse,Wm]=Ic(Hm),Q9=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=t,a=qx(e),[c,h]=k.useState(null),f=k.useRef(!1),d=Lr(s),m=Ik(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(Hse,{scope:e,open:n,onOpenChange:d,content:c,onContentChange:h,children:C.jsx(Wse,{scope:e,onClose:k.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:f,dir:m,modal:o,children:r})})})};Q9.displayName=Hm;var qse="MenuAnchor",jk=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=qx(n);return C.jsx(Bj,{...i,...r,ref:e})});jk.displayName=qse;var Bk="MenuPortal",[Gse,Z9]=Ic(Bk,{forceMount:void 0}),eF=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:i}=t,s=Lc(Bk,e);return C.jsx(Gse,{scope:e,forceMount:n,children:C.jsx(Ts,{present:n||s.open,children:C.jsx(Ox,{asChild:!0,container:i,children:r})})})};eF.displayName=Bk;var Ji="MenuContent",[Kse,Fk]=Ic(Ji),tF=k.forwardRef((t,e)=>{const n=Z9(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(Yse,{...i,ref:e}):C.jsx(Xse,{...i,ref:e})})})})}),Yse=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(zk,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Le(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Xse=k.forwardRef((t,e)=>{const n=Lc(Ji,t.__scopeMenu);return C.jsx(zk,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Jse=Rh("MenuContent.ScrollLock"),zk=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,...x}=t,S=Lc(Ji,n),_=Wm(Ji,n),A=qx(n),E=J9(n),P=Vse(n),[O,M]=k.useState(null),D=k.useRef(null),N=Bt(e,D,S.onContentChange),H=k.useRef(0),j=k.useRef(""),V=k.useRef(0),q=k.useRef(null),X=k.useRef("right"),Y=k.useRef(0),te=b?UE:k.Fragment,z=b?{as:Jse,allowPinchZoom:!0}:void 0,G=se=>{const T=j.current+se,Z=P().filter(Ee=>!Ee.disabled),ue=document.activeElement,L=Z.find(Ee=>Ee.ref.current===ue)?.textValue,de=Z.map(Ee=>Ee.textValue),ke=coe(de,T,L),ye=Z.find(Ee=>Ee.textValue===ke)?.ref.current;(function Ee(Ue){j.current=Ue,window.clearTimeout(H.current),Ue!==""&&(H.current=window.setTimeout(()=>Ee(""),1e3))})(T),ye&&setTimeout(()=>ye.focus())};k.useEffect(()=>()=>window.clearTimeout(H.current),[]),pj();const U=k.useCallback(se=>X.current===q.current?.side&&hoe(se,q.current?.area),[]);return C.jsx(Kse,{scope:n,searchRef:j,onItemEnter:k.useCallback(se=>{U(se)&&se.preventDefault()},[U]),onItemLeave:k.useCallback(se=>{U(se)||(D.current?.focus(),M(null))},[U]),onTriggerLeave:k.useCallback(se=>{U(se)&&se.preventDefault()},[U]),pointerGraceTimerRef:V,onPointerGraceIntentChange:k.useCallback(se=>{q.current=se},[]),children:C.jsx(te,{...z,children:C.jsx(IE,{asChild:!0,trapped:i,onMountAutoFocus:Le(s,se=>{se.preventDefault(),D.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:C.jsx(Ax,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:d,onInteractOutside:m,onDismiss:y,children:C.jsx(I9,{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":yF(S.open),"data-radix-menu-content":"",dir:_.dir,...A,...x,ref:N,style:{outline:"none",...x.style},onKeyDown:Le(x.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 de=D.current;if(se.target!==de||!Bse.includes(se.key))return;se.preventDefault();const ye=P().filter(Ee=>!Ee.disabled).map(Ee=>Ee.ref.current);Y9.includes(se.key)&&ye.reverse(),aoe(ye)}),onBlur:Le(t.onBlur,se=>{se.currentTarget.contains(se.target)||(window.clearTimeout(H.current),j.current="")}),onPointerMove:Le(t.onPointerMove,Qp(se=>{const T=se.target,Z=Y.current!==se.clientX;if(se.currentTarget.contains(T)&&Z){const ue=se.clientX>Y.current?"right":"left";X.current=ue,Y.current=se.clientX}}))})})})})})})});tF.displayName=Ji;var Qse="MenuGroup",Vk=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return C.jsx(st.div,{role:"group",...r,ref:e})});Vk.displayName=Qse;var Zse="MenuLabel",nF=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return C.jsx(st.div,{...r,ref:e})});nF.displayName=Zse;var yv="MenuItem",VL="menu.itemSelect",Gx=k.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...i}=t,s=k.useRef(null),o=Wm(yv,t.__scopeMenu),a=Fk(yv,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(rF,{...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===" "||jC.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Gx.displayName=yv;var rF=k.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=t,o=Fk(yv,n),a=J9(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(L9,{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))})})})}),eoe="MenuCheckboxItem",iF=k.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...i}=t;return C.jsx(cF,{scope:t.__scopeMenu,checked:n,children:C.jsx(Gx,{role:"menuitemcheckbox","aria-checked":bv(n)?"mixed":n,...i,ref:e,"data-state":Hk(n),onSelect:Le(i.onSelect,()=>r?.(bv(n)?!0:!n),{checkForDefaultPrevented:!1})})})});iF.displayName=eoe;var sF="MenuRadioGroup",[toe,noe]=Ic(sF,{value:void 0,onValueChange:()=>{}}),oF=k.forwardRef((t,e)=>{const{value:n,onValueChange:r,...i}=t,s=Lr(r);return C.jsx(toe,{scope:t.__scopeMenu,value:n,onValueChange:s,children:C.jsx(Vk,{...i,ref:e})})});oF.displayName=sF;var aF="MenuRadioItem",lF=k.forwardRef((t,e)=>{const{value:n,...r}=t,i=noe(aF,t.__scopeMenu),s=n===i.value;return C.jsx(cF,{scope:t.__scopeMenu,checked:s,children:C.jsx(Gx,{role:"menuitemradio","aria-checked":s,...r,ref:e,"data-state":Hk(s),onSelect:Le(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});lF.displayName=aF;var Uk="MenuItemIndicator",[cF,roe]=Ic(Uk,{checked:!1}),uF=k.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...i}=t,s=roe(Uk,n);return C.jsx(Ts,{present:r||bv(s.checked)||s.checked===!0,children:C.jsx(st.span,{...i,ref:e,"data-state":Hk(s.checked)})})});uF.displayName=Uk;var ioe="MenuSeparator",hF=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return C.jsx(st.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});hF.displayName=ioe;var soe="MenuArrow",fF=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=qx(n);return C.jsx(zj,{...i,...r,ref:e})});fF.displayName=soe;var ooe="MenuSub",[G6e,dF]=Ic(ooe),cp="MenuSubTrigger",pF=k.forwardRef((t,e)=>{const n=Lc(cp,t.__scopeMenu),r=Wm(cp,t.__scopeMenu),i=dF(cp,t.__scopeMenu),s=Fk(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(jk,{asChild:!0,...h,children:C.jsx(rF,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":yF(n.open),...t,ref:Cx(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",x=b?-5:5,S=m[b?"left":"right"],_=m[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+x,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===" "||Fse[r.dir].includes(d.key)&&(n.onOpenChange(!0),n.content?.focus(),d.preventDefault())})})})});pF.displayName=cp;var mF="MenuSubContent",gF=k.forwardRef((t,e)=>{const n=Z9(Ji,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=Lc(Ji,t.__scopeMenu),o=Wm(Ji,t.__scopeMenu),a=dF(mF,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(zk,{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=zse[o.dir].includes(f.key);d&&m&&(s.onOpenChange(!1),a.trigger?.focus(),f.preventDefault())})})})})})});gF.displayName=mF;function yF(t){return t?"open":"closed"}function bv(t){return t==="indeterminate"}function Hk(t){return bv(t)?"indeterminate":t?"checked":"unchecked"}function aoe(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function loe(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function coe(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=loe(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 uoe(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 hoe(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return uoe(n,e)}function Qp(t){return e=>e.pointerType==="mouse"?t(e):void 0}var foe=Q9,doe=jk,poe=eF,moe=tF,goe=Vk,yoe=nF,boe=Gx,voe=iF,xoe=oF,woe=lF,Soe=uF,_oe=hF,Coe=fF,Aoe=pF,Eoe=gF,Kx="DropdownMenu",[koe]=ra(Kx,[X9]),Nr=X9(),[Toe,bF]=koe(Kx),vF=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:Kx});return C.jsx(Toe,{scope:e,triggerId:ol(),triggerRef:h,contentId:ol(),open:f,onOpenChange:d,onOpenToggle:k.useCallback(()=>d(m=>!m),[d]),modal:a,children:C.jsx(foe,{...c,open:f,onOpenChange:d,dir:r,modal:a,children:n})})};vF.displayName=Kx;var xF="DropdownMenuTrigger",wF=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=t,s=bF(xF,n),o=Nr(n);return C.jsx(doe,{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:Cx(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())})})})});wF.displayName=xF;var Roe="DropdownMenuPortal",SF=t=>{const{__scopeDropdownMenu:e,...n}=t,r=Nr(e);return C.jsx(poe,{...r,...n})};SF.displayName=Roe;var _F="DropdownMenuContent",CF=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=bF(_F,n),s=Nr(n),o=k.useRef(!1);return C.jsx(moe,{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)"}})});CF.displayName=_F;var Moe="DropdownMenuGroup",Ooe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(goe,{...i,...r,ref:e})});Ooe.displayName=Moe;var Poe="DropdownMenuLabel",Doe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(yoe,{...i,...r,ref:e})});Doe.displayName=Poe;var Ioe="DropdownMenuItem",AF=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(boe,{...i,...r,ref:e})});AF.displayName=Ioe;var Loe="DropdownMenuCheckboxItem",Noe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(voe,{...i,...r,ref:e})});Noe.displayName=Loe;var $oe="DropdownMenuRadioGroup",joe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(xoe,{...i,...r,ref:e})});joe.displayName=$oe;var Boe="DropdownMenuRadioItem",Foe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(woe,{...i,...r,ref:e})});Foe.displayName=Boe;var zoe="DropdownMenuItemIndicator",Voe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(Soe,{...i,...r,ref:e})});Voe.displayName=zoe;var Uoe="DropdownMenuSeparator",Hoe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(_oe,{...i,...r,ref:e})});Hoe.displayName=Uoe;var Woe="DropdownMenuArrow",qoe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(Coe,{...i,...r,ref:e})});qoe.displayName=Woe;var Goe="DropdownMenuSubTrigger",Koe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(Aoe,{...i,...r,ref:e})});Koe.displayName=Goe;var Yoe="DropdownMenuSubContent",Xoe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(Eoe,{...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)"}})});Xoe.displayName=Yoe;var Joe=vF,Qoe=wF,Zoe=SF,eae=CF,tae=AF;const Wk="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 nae=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"}),rae="VisuallyHidden",EF=k.forwardRef((t,e)=>C.jsx(st.span,{...t,ref:e,style:{...nae,...t.style}}));EF.displayName=rae;var iae=EF,[Yx]=ra("Tooltip",[Mx]),Xx=Mx(),kF="TooltipProvider",sae=700,BC="tooltip.open",[oae,qk]=Yx(kF),TF=t=>{const{__scopeTooltip:e,delayDuration:n=sae,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(oae,{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})};TF.displayName=kF;var Zp="Tooltip",[aae,qm]=Yx(Zp),RF=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=t,c=qk(Zp,t.__scopeTooltip),h=Xx(e),[f,d]=k.useState(null),m=ol(),y=k.useRef(0),b=o??c.disableHoverableContent,x=a??c.delayDuration,S=k.useRef(!1),[_,A]=qh({prop:r,defaultProp:i??!1,onChange:D=>{D?(c.onOpen(),document.dispatchEvent(new CustomEvent(BC))):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},x)},[x,A]);return k.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)},[]),C.jsx(jj,{...h,children:C.jsx(aae,{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})})};RF.displayName=Zp;var FC="TooltipTrigger",MF=k.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=qm(FC,n),s=qk(FC,n),o=Xx(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)})})});MF.displayName=FC;var Gk="TooltipPortal",[lae,cae]=Yx(Gk,{forceMount:void 0}),OF=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:i}=t,s=qm(Gk,e);return C.jsx(lae,{scope:e,forceMount:n,children:C.jsx(Ts,{present:n||s.open,children:C.jsx(Ox,{asChild:!0,container:i,children:r})})})};OF.displayName=Gk;var Ph="TooltipContent",PF=k.forwardRef((t,e)=>{const n=cae(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(DF,{side:i,...s,ref:e}):C.jsx(uae,{side:i,...s,ref:e})})}),uae=k.forwardRef((t,e)=>{const n=qm(Ph,t.__scopeTooltip),r=qk(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,x)=>{const S=b.currentTarget,_={x:b.clientX,y:b.clientY},A=mae(_,S.getBoundingClientRect()),E=gae(_,A),P=yae(x.getBoundingClientRect()),O=vae([...E,...P]);a(O),d(!0)},[d]);return k.useEffect(()=>()=>m(),[m]),k.useEffect(()=>{if(c&&f){const b=S=>y(S,f),x=S=>y(S,c);return c.addEventListener("pointerleave",b),f.addEventListener("pointerleave",x),()=>{c.removeEventListener("pointerleave",b),f.removeEventListener("pointerleave",x)}}},[c,f,y,m]),k.useEffect(()=>{if(o){const b=x=>{const S=x.target,_={x:x.clientX,y:x.clientY},A=c?.contains(S)||f?.contains(S),E=!bae(_,o);A?m():E&&(m(),h())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[c,f,o,h,m]),C.jsx(DF,{...t,ref:s})}),[hae,fae]=Yx(Zp,{isInside:!1}),dae=YX("TooltipContent"),DF=k.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=t,c=qm(Ph,n),h=Xx(n),{onClose:f}=c;return k.useEffect(()=>(document.addEventListener(BC,f),()=>document.removeEventListener(BC,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(Ax,{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(dae,{children:r}),C.jsx(hae,{scope:n,isInside:!0,children:C.jsx(iae,{id:c.contentId,role:"tooltip",children:i||r})})]})})});PF.displayName=Ph;var IF="TooltipArrow",pae=k.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Xx(n);return fae(IF,n).isInside?null:C.jsx(zj,{...i,...r,ref:e})});pae.displayName=IF;function mae(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 gae(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 yae(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 bae(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 vae(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 wae=TF,Sae=RF,_ae=MF,Cae=OF,Aae=PF;const Eae=({delayDuration:t=0,...e})=>C.jsx(wae,{"data-slot":"tooltip-provider",delayDuration:t,...e}),em=({...t})=>C.jsx(Eae,{children:C.jsx(Sae,{"data-slot":"tooltip",...t})}),tm=({...t})=>C.jsx(_ae,{"data-slot":"tooltip-trigger",...t}),nm=({className:t,sideOffset:e=0,children:n,...r})=>C.jsx(Cae,{container:document.getElementById("app"),children:C.jsx(Aae,{"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 kae(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 Jx="Switch",[Tae]=ra(Jx),[Rae,Mae]=Tae(Jx),LF=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)),x=k.useRef(!1),S=m?f||!!m.closest("form"):!0,[_,A]=qh({prop:i,defaultProp:s??!1,onChange:h,caller:Jx});return C.jsxs(Rae,{scope:n,checked:_,disabled:a,children:[C.jsx(st.button,{type:"button",role:"switch","aria-checked":_,"aria-required":o,"data-state":BF(_),"data-disabled":a?"":void 0,disabled:a,value:c,...d,ref:b,onClick:Le(t.onClick,E=>{A(P=>!P),S&&(x.current=E.isPropagationStopped(),x.current||E.stopPropagation())})}),S&&C.jsx(jF,{control:m,bubbles:!x.current,name:r,value:c,checked:_,required:o,disabled:a,form:f,style:{transform:"translateX(-100%)"}})]})});LF.displayName=Jx;var NF="SwitchThumb",$F=k.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,i=Mae(NF,n);return C.jsx(st.span,{"data-state":BF(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:e})});$F.displayName=NF;var Oae="SwitchBubbleInput",jF=k.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...i},s)=>{const o=k.useRef(null),a=Bt(o,s),c=kae(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}})});jF.displayName=Oae;function BF(t){return t?"checked":"unchecked"}var Pae=LF,Dae=$F;const FF=({checked:t,onCheckedChange:e,disabled:n=!1,id:r,className:i})=>C.jsx("div",{className:"flex items-center gap-2",children:C.jsx(Pae,{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(Dae,{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]")})})}),Iae=({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,x]=k.useState(!1),S=k.useRef(null),_=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 A=D=>{if(o){D.stopPropagation(),D.preventDefault();return}r(D)},E=D=>{D.stopPropagation(),D.preventDefault(),!h&&c?.(!a)},P=D=>{if(!S.current||!_.current)return;const N=D.clientX,H=D.clientY,j=S.current.getBoundingClientRect(),V=_.current?.getBoundingClientRect(),q=N>=j.left&&N<=j.right&&H>=j.top&&H<=j.bottom,X=V&&N>=V.left&&N<=V.right&&H>=V.top&&H<=V.bottom;!q&&!X&&(x(!1),window.removeEventListener("mousemove",P))},O=()=>{b||!f||(x(!0),window.addEventListener("mousemove",P))},M=C.jsxs(tae,{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?D=>D.preventDefault():A,onClick:o?E:void 0,onMouseEnter:O,ref:S,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:Wk,size:12,insideElement:!0,isStroke:!0}),items:f,side:"right",align:"start",sideOffset:0,open:b,contentClassName:"ms-[12px] mt-[-15px] max-w-[300px]",containerRef:S.current,dropdownRef:_}):null,d?C.jsx(gt,{iconName:Oh,size:16,disableHover:!0,isStroke:!0}):null,o&&c?C.jsx("div",{onClick:D=>D.stopPropagation(),children:C.jsx(FF,{checked:a??!1,onCheckedChange:c,disabled:h})}):null]});return m?C.jsxs(em,{children:[C.jsx(tm,{asChild:!0,children:M}),C.jsx(nm,{children:m})]}):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(Joe,{open:c,onOpenChange:d,children:[C.jsx(Qoe,{asChild:!0,children:t}),C.jsx(Zoe,{container:h??m,children:C.jsx(eae,{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(Iae,{...y},y.id||y.text||`item-${b}`))})})]})};var Qx="Dialog",[zF]=ra(Qx),[Lae,Ms]=zF(Qx),VF=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:Qx});return C.jsx(Lae,{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})};VF.displayName=Qx;var UF="DialogTrigger",Nae=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Ms(UF,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":Xk(i.open),...r,ref:s,onClick:Le(t.onClick,i.onOpenToggle)})});Nae.displayName=UF;var Kk="DialogPortal",[$ae,HF]=zF(Kk,{forceMount:void 0}),WF=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:i}=t,s=Ms(Kk,e);return C.jsx($ae,{scope:e,forceMount:n,children:k.Children.map(r,o=>C.jsx(Ts,{present:n||s.open,children:C.jsx(Ox,{asChild:!0,container:i,children:o})}))})};WF.displayName=Kk;var vv="DialogOverlay",qF=k.forwardRef((t,e)=>{const n=HF(vv,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,s=Ms(vv,t.__scopeDialog);return s.modal?C.jsx(Ts,{present:r||s.open,children:C.jsx(Bae,{...i,ref:e})}):null});qF.displayName=vv;var jae=Rh("DialogOverlay.RemoveScroll"),Bae=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Ms(vv,n);return C.jsx(UE,{as:jae,allowPinchZoom:!0,shards:[i.contentRef],children:C.jsx(st.div,{"data-state":Xk(i.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Ac="DialogContent",GF=k.forwardRef((t,e)=>{const n=HF(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(Fae,{...i,ref:e}):C.jsx(zae,{...i,ref:e})})});GF.displayName=Ac;var Fae=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(KF,{...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())})}),zae=k.forwardRef((t,e)=>{const n=Ms(Ac,t.__scopeDialog),r=k.useRef(!1),i=k.useRef(!1);return C.jsx(KF,{...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()}})}),KF=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(IE,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:C.jsx(Ax,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Xk(a.open),...o,ref:h,onDismiss:()=>a.onOpenChange(!1)})}),C.jsxs(C.Fragment,{children:[C.jsx(Uae,{titleId:a.titleId}),C.jsx(Wae,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Yk="DialogTitle",YF=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Ms(Yk,n);return C.jsx(st.h2,{id:i.titleId,...r,ref:e})});YF.displayName=Yk;var XF="DialogDescription",JF=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Ms(XF,n);return C.jsx(st.p,{id:i.descriptionId,...r,ref:e})});JF.displayName=XF;var QF="DialogClose",Vae=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Ms(QF,n);return C.jsx(st.button,{type:"button",...r,ref:e,onClick:Le(t.onClick,()=>i.onOpenChange(!1))})});Vae.displayName=QF;function Xk(t){return t?"open":"closed"}var ZF="DialogTitleWarning",[K6e,ez]=nJ(ZF,{contentName:Ac,titleName:Yk,docsSlug:"dialog"}),Uae=({titleId:t})=>{const e=ez(ZF),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},Hae="DialogDescriptionWarning",Wae=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ez(Hae).contentName}}.`;return k.useEffect(()=>{const i=t.current?.getAttribute("aria-describedby");e&&i&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},qae=VF,Gae=WF,Kae=qF,Yae=GF,Xae=YF,Jae=JF;const wl=({...t})=>C.jsx(qae,{"data-slot":"dialog",...t}),Qae="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",Zae="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",ele=({...t})=>C.jsx(Gae,{"data-slot":"dialog-portal",container:document.getElementById("app"),...t}),tle=({className:t,...e})=>C.jsx(Kae,{"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}),nle=({className:t,withWarningIcon:e,...n})=>C.jsx(Xae,{"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}),rle=()=>C.jsx(C.Fragment,{children:C.jsx(Jae,{className:"hidden",children:"Dialog content"})}),ile="w-[348px]",sle="w-[548px]",ole=" 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]",ale="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]",lle="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?sle:ile,c=s?ale:ole;return be.useEffect(()=>{const h=f=>{f.key==="Escape"&&r()};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[r]),C.jsxs(ele,{"data-slot":"dialog-portal",children:[C.jsx(tle,{}),C.jsxs(Yae,{id:"dialog-content","data-slot":"dialog-content",className:je(a,c,lle,"flex flex-col",t),onInteractOutside:h=>h.preventDefault(),...o,children:[C.jsx(rle,{}),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:Zae}):null,C.jsx(nle,{withWarningIcon:s,children:n})]}),C.jsx(gt,{iconName:Qae,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})]}),tz="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",Zx=({placeholder:t,value:e,className:n,isError:r,withoutBg:i,items:s})=>{const[o,a]=be.useState(!1),c=be.useRef(null),h=be.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:tz,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})},cle="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=be.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:cle,beforeInjection:o})})]})});co.displayName="Input";const nz="flex flex-col justify-between h-full",rz="flex flex-col gap-[12px] mb-[32px]",iz="flex flex-row justify-end items-center gap-[8px] h-[64px] border-t-[1px] border-[var(--border-divider)] mx-[-32px] px-[32px]",ule=({name:t,onClose:e})=>{const{t:n}=vt(),{providers:r,editProvider:i}=rs(),[s,o]=be.useState(()=>{const _=r.find(A=>A.name===t);return _||{name:"",type:"",icon:"",key:"",baseUrl:""}}),[a,c]=be.useState({name:s.name,url:s.baseUrl,key:s.key}),[h,f]=be.useState({key:"",url:"",name:""});be.useEffect(()=>{const _=r.find(A=>A.name===t);_&&(o(_),c({name:_.name,url:_.baseUrl,key:_.key}))},[r,t]),be.useEffect(()=>{c({name:s.name,url:s.baseUrl,key:s.key})},[s]);const d=be.useRef(null),m=_=>{c(A=>({...A,[_.target.name]:_.target.value})),f(A=>({...A,[_.target.name]:""}))},y=async()=>{const _=await i({type:s.type,name:a.name,key:a.key,baseUrl:a.url},s.name);typeof _=="boolean"&&_?e():_&&f(A=>({...A,[_.field]:_.message}))},b=a.name===s.name&&a.url===s.baseUrl,S=a.key===s.key&&b||!!h.key||!!h.url||!!h.name;return C.jsx(wl,{open:!0,children:C.jsx(Sl,{header:n("EditAIProvider"),onClose:e,ref:d,children:C.jsxs("div",{className:nz,children:[C.jsxs("div",{className:rz,children:[C.jsx(io,{header:n("Provider"),children:C.jsx(Zx,{value:s.type,items:[]})}),C.jsx(io,{header:n("Name"),error:h.name,children:C.jsx(co,{name:"name",onChange:m,value:a.name,isError:!!h.name,placeholder:n("EnterName"),className:"w-full"})}),C.jsx(io,{header:n("URL"),error:h.url,children:C.jsx(co,{name:"url",onChange:m,value:a.url,isError:!!h.url,placeholder:n("EnterURL"),className:"w-full"})}),C.jsx(io,{header:n("APIKey"),error:h.key,children:C.jsx(co,{name:"key",onChange:m,value:a.key,isError:!!h.key,placeholder:n("EnterKey"),className:"w-full",type:"password"})})]}),C.jsxs("div",{className:iz,children:[C.jsx(en,{variant:"default",onClick:e,children:n("Cancel")}),C.jsx(en,{onClick:y,disabled:S,children:n("Save")})]})]})})})},hle=({name:t,onClose:e})=>{const{providers:n,deleteProvider:r}=rs(),[i,s]=be.useState(()=>{const c=n.find(h=>h.name===t);return c||{name:"",type:"",icon:"",key:"",baseUrl:""}}),{t:o}=vt();be.useEffect(()=>{const c=n.find(h=>h.name===t);c&&s(c)},[n,t]);const a=async()=>{await r(i),e()};return C.jsx(wl,{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")})]})]})})})},fle=({provider:t})=>{const{providersModels:e}=rs(),[n,r]=be.useState(!1),[i,s]=be.useState(!1),[o,a]=be.useState(null),[c,h]=be.useState(!1),f=be.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:q9,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:Nk,size:20,isActive:c}),items:[{icon:C.jsx(gt,{iconName:wse,size:20,disableHover:!0,isStroke:!0}),text:d("Edit"),onClick:()=>r(!0)},{text:"",onClick:()=>{},isSeparator:!0},{icon:C.jsx(gt,{iconName:$k,size:20,disableHover:!0}),text:d("Delete"),onClick:()=>s(!0)}],side:"right",align:"start",sideOffset:0,containerRef:o})})]}),n?C.jsx(ule,{name:t.name,onClose:()=>r(!1)}):null,i?C.jsx(hle,{name:t.name,onClose:()=>s(!1)}):null]})},UL=$t.getProvidersInfo(),dle=({onClose:t})=>{const{addProvider:e}=rs(),{t:n}=vt(),[r,i]=be.useState(UL[0]),[s,o]=be.useState({name:"",url:r.baseUrl,key:""}),[a,c]=be.useState({key:"",url:"",name:""}),h=be.useRef(null),f=y=>{o(b=>({...b,[y.target.name]:y.target.value})),c(b=>({...b,[y.target.name]:""}))},d=async()=>{const y=await e({type:r.type,name:s.name,key:s.key,baseUrl:s.url});typeof y=="boolean"&&y?t():y&&c(b=>({...b,[y.field]:y.message}))};be.useEffect(()=>{o(y=>({...y,url:r.baseUrl}))},[r]);const m=!s.name||!s.url||!!a.key||!!a.url||!!a.name;return C.jsx(wl,{open:!0,children:C.jsx(Sl,{header:n("AIProvider"),onClose:t,ref:h,children:C.jsxs("div",{className:nz,children:[C.jsxs("div",{className:rz,children:[C.jsx(io,{header:n("Provider"),children:C.jsx(Zx,{value:r.name,items:UL.map(y=>({text:y.name,id:y.name,onClick:()=>i(y)}))})}),C.jsx(io,{header:n("Name"),error:a.name,children:C.jsx(co,{name:"name",onChange:f,value:s.name,isError:!!a.name,placeholder:n("EnterName"),className:"w-full"})}),C.jsx(io,{header:n("URL"),error:a.url,children:C.jsx(co,{name:"url",onChange:f,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:f,value:s.key,isError:!!a.key,placeholder:n("EnterKey"),className:"w-full",type:"password"})})]}),C.jsxs("div",{className:iz,children:[C.jsx(en,{variant:"default",onClick:t,children:n("Cancel")}),C.jsx(en,{onClick:d,disabled:m,children:n("AddProvider")})]})]})})})},ple=({isActive:t})=>{const[e,n]=be.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(fle,{provider:s},s.name))}),e?C.jsx(dle,{onClose:()=>n(!1)}):null]})},mle=({isActive:t})=>{const{t:e}=vt();return C.jsx(en,{className:"max-w-[fit-content]",disabled:!t,children:e("RegisterConnectWallet")})};let zC=[],sz=[];(()=>{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?sz:zC).push(n=n+t[e])})();function gle(t){if(t<768)return!1;for(let e=0,n=zC.length;;){let r=e+n>>1;if(t<zC[r])n=r;else if(t>=sz[r])e=r+1;else return!0;if(e==n)return!1}}function HL(t){return t>=127462&&t<=127487}const WL=8205;function yle(t,e,n=!0,r=!0){return(n?oz:ble)(t,e,r)}function oz(t,e,n){if(e==t.length)return e;e&&az(t.charCodeAt(e))&&lz(t.charCodeAt(e-1))&&e--;let r=C_(t,e);for(e+=qL(r);e<t.length;){let i=C_(t,e);if(r==WL||i==WL||n&&gle(i))e+=qL(i),r=i;else if(HL(i)){let s=0,o=e-2;for(;o>=0&&HL(C_(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function ble(t,e,n){for(;e>0;){let r=oz(t,e-2,n);if(r<e)return r;e--}return 0}function C_(t,e){let n=t.charCodeAt(e);if(!lz(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return az(r)?(n-55296<<10)+(r-56320)+65536:n}function az(t){return t>=56320&&t<57344}function lz(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 cz(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 uz(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=vle(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=Rb(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=Rb(this.text,Rb(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 x of y.children)d(x);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 vle(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Rb(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 Rb(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 cz{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 uz{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]=cz.prototype[Symbol.iterator]=uz.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 yle(t,e,n,r)}function wle(t){return t>=56320&&t<57344}function Sle(t){return t>=55296&&t<56320}function Wr(t,e){let n=t.charCodeAt(e);if(!Sle(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return wle(r)?(n-55296<<10)+(r-56320)+65536:n}function Jk(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 VC=/\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){UC(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:hz(this,e)}mapDesc(e,n=!1){return e.empty?this:HC(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 UC(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return HC(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:hz(this,e,!0)}map(e,n=!1){return e.empty?this:HC(this,e,n,!0)}iterChanges(e,n=!1){UC(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||VC)):y:dt.empty,x=b.length;if(d==m&&x==0)return;d<o&&c(),d>o&&fr(i,d-o,-1),fr(i,m-d,x),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 UC(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 HC(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 hz(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 fz(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Qk=0;class Ce{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=Qk++,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:Zk),!!e.static,e.enables)}of(e){return new Mb([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Mb(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Mb(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Zk(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Mb{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=Qk++}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)||WC(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 x=wv(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),x,i):i(y=r(d),x)))return d.values[o]=x,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 WC(t,e){let n=!1;for(let r of e)Ep(t,r)&1&&(n=!0);return n}function _le(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=wv(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(!WC(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=WC(c,r),d=h.config.facets[e.id],m=h.facet(e);if(d&&!f&&Zk(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 wy=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(Qk++,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(wy).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(wy),o=i.facet(wy),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,wy.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 dz(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 dz{constructor(e,n){this.inner=e,this.prec=n}}class ew{of(e){return new qC(this,e)}reconfigure(e){return ew.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class qC{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 Cle(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,x=f&&f[m]||[];if(y.every(S=>S.type==0))if(a[b.id]=c.length<<1|1,Zk(x,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=>_le(S,b,y))}}let d=h.map(m=>m(a));return new xv(e,o,d,a,c,s)}}function Cle(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 qC&&n.delete(o.compartment)}if(i.set(o,a),Array.isArray(o))for(let h of o)s(h,a);else if(o instanceof qC){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 dz)s(o.inner,o.prec);else if(o instanceof Zn)r[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof Mb)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 wv(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const pz=Ce.define(),GC=Ce.define({combine:t=>t.some(e=>e),static:!0}),mz=Ce.define({combine:t=>t.length?t[0]:void 0,static:!0}),gz=Ce.define(),yz=Ce.define(),bz=Ce.define(),vz=Ce.define({combine:t=>t.length?t[0]:!1});class sa{constructor(e,n){this.type=e,this.value=n}static define(){return new Ale}}class Ale{of(e){return new sa(this,e)}}class Ele{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 Ele(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&&fz(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 kle(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 KC(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(mz)),selection:r&&(r instanceof fe?r:fe.single(r.anchor,r.head)),effects:vh(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function wz(t,e,n){let r=KC(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,KC(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 Rle(n?Tle(i):i)}function Tle(t){let e=t.startState,n=!0;for(let i of e.facet(gz)){let s=i(t);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:kle(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(yz);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=wz(e,vh(s),!1)}return t}function Rle(t){let e=t.startState,n=e.facet(bz),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=xz(r,KC(e,s,t.changes.newLength),!0))}return r==t?t:kn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const Mle=[];function vh(t){return t==null?Mle: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 Ole=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let YC;try{YC=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Ple(t){if(YC)return YC.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||Ole.test(n)))return!0}return!1}function Dle(t){return e=>{if(!/\S/.test(e))return Vt.Space;if(Ple(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),wv(this,r)}update(...e){return wz(this,e,!0)}applyTransaction(e){let n=this.config,{base:r,compartments:i}=n;for(let a of e.effects)a.is(ew.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(GC)?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)||VC))}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),wv(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)||VC)),i=e.selection?e.selection instanceof fe?e.selection:fe.single(e.selection.anchor,e.selection.head):fe.single(0);return fz(i,r.length),n.staticFacet(GC)||(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(vz)}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(pz))for(let o of s(this,n,r))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){return Dle(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=GC;ht.tabSize=Ce.define({combine:t=>t.length?t[0]:4});ht.lineSeparator=mz;ht.readOnly=vz;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=pz;ht.changeFilter=gz;ht.transactionFilter=yz;ht.transactionExtender=bz;ew.reconfigure=Ze.define();function xo(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 XC.create(e,n,this)}}Ec.prototype.startSide=Ec.prototype.endSide=0;Ec.prototype.point=!1;Ec.prototype.mapMode=Mr.TrackDel;let XC=class Sz{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new Sz(e,n,r)}};function JC(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class eT{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 eT(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(JC)),this.isEmpty)return n.length?ft.of(n):this;let a=new _z(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(XC.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||!QC(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 XC?[e]:n?Ile(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 Ile(t){if(t.length>1)for(let e=t[0],n=1;n<t.length;n++){let r=t[n];if(JC(e,r)>0)return t.slice().sort(JC);e=r}return t}ft.empty.nextLayer=ft.empty;class Xo{finishChunk(e){this.chunks.push(new eT(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 _z{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 _z(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--)A_(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--)A_(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(),A_(this.heap,0)}}}function A_(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){Sy(this.active,e),Sy(this.activeTo,e),Sy(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++;_y(this.active,n,r),_y(this.activeTo,n,i),_y(this.activeRank,n,s),e&&_y(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&&Sy(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))&&QC(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(a,m,t.point,n.point):m>a&&!QC(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 QC(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 Sy(t,e){for(let n=e,r=t.length-1;n<r;n++)t[n]=t[n+1];t.pop()}function _y(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 ZC(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 eA="ͼ",QL=typeof Symbol>"u"?"__"+eA:Symbol.for(eA),tA=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(x=>o.map(S=>x.replace(/&/,S))).reduce((x,S)=>x.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,x=>"-"+x.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,eA+e.toString(36)}static mount(e,n,r){let i=e[tA],s=r&&r.nonce;i?s&&i.setNonce(s):i=new Lle(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let eN=new Map;class Lle{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[tA]=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[tA]=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:'"'},Nle=typeof navigator<"u"&&/Mac/.test(navigator.platform),$le=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 E_ in ml)sm.hasOwnProperty(E_)||(sm[E_]=ml[E_]);function jle(t){var e=Nle&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||$le&&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++)Cz(t,arguments[e]);return t}function Cz(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++)Cz(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 nA(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ob(t,e){if(!e.anchorNode)return!1;try{return nA(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 Sv(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 tw(t,e){let n=e?t.left:t.right;return{left:n,right:n,top:t.top,bottom:t.bottom}}function Ble(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 Az(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 Fle(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,x=1;if(y)m=Ble(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:x}=Az(f,A)),m={left:A.left,right:A.left+f.clientWidth*b,top:A.top,bottom:A.top+f.clientHeight*x}}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+=_/x,E=(f.scrollTop-P)*x}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 zle(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 Vle{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 Ez(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 xh(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 Ule(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function kz(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function Hle(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 Tz(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function Rz(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&&!Sv(n))r=kc(n),n=n.parentNode;else return null}}function Mz(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&&!Sv(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 tT=[];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=tT){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 Oz(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 Oz{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 Pz(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 Dz(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,Pz(t,h,f,a,c,r,0,i,s)}let qr=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},rA=typeof document<"u"?document:{documentElement:{style:{}}};const iA=/Edge\/(\d+)/.exec(qr.userAgent),Iz=/MSIE \d/.test(qr.userAgent),sA=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(qr.userAgent),nw=!!(Iz||sA||iA),iN=!nw&&/gecko\/(\d+)/i.test(qr.userAgent),k_=!nw&&/Chrome\/(\d+)/.exec(qr.userAgent),Wle="webkitFontSmoothing"in rA.documentElement.style,Lz=!nw&&/Apple Computer/.test(qr.vendor),sN=Lz&&(/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:nw,ie_version:Iz?rA.documentMode||6:sA?+sA[1]:iA?+iA[1]:0,gecko:iN,gecko_version:iN?+(/Firefox\/(\d+)/.exec(qr.userAgent)||[0,0])[1]:0,chrome:!!k_,chrome_version:k_?+k_[1]:0,ios:sN,android:/Android\b/.test(qr.userAgent),safari:Lz,webkit_version:Wle?+(/\bAppleWebKit\/(\d+)/.exec(qr.userAgent)||[0,0])[1]:0,tabSize:rA.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const qle=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>qle||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 Gle(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(kz(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:(Dz(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 Nz(this,e)}coordsAt(e,n){return jz(this,e,n)}}function Gle(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?tw(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 tw(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=tT;function Nz(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 $z(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)?$z(r,e.children[0],n-1):(i.push(e),e.setParent(t)),t.length+=e.length}function jz(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||Yle(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):Kle(t)}function Kle(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=am(e);return n[n.length-1]||null}function Yle(t,e){let n=t.coordsAt(0,1),r=e.coordsAt(0,1);return n&&r&&r.top<n.bottom}function oA(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 _v(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 aA(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 Xle(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 Gm(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}=Bz(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 Km(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 Gm extends He{constructor(e){let{start:n,end:r}=Bz(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 Gm&&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))&&_v(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)}}Gm.prototype.point=!1;class Km extends He{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Km&&this.spec.class==e.spec.class&&_v(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)}}Km.prototype.mapMode=Mr.TrackBefore;Km.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&&Jle(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 Bz(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 Jle(t,e){return t==e||!!(t&&e&&t.compare(e))}function Pb(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),Dz(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){_v(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,n){$z(this,e,n)}addLineDeco(e){let n=e.spec.attributes,r=e.spec.class;n&&(this.attrs=oA(n,this.attrs||{})),r&&(this.attrs=oA({class:r},this.attrs||{}))}domAtPos(e){return Nz(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,n){var r;this.dom?this.flags&4&&(kz(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&&(aA(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=jz(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&&_v(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 tT}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 lA?null:tw(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 lA 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(Cy(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(Cy(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(Cy(new Ih(1),i),s),s=i.length+Math.max(0,s-i.length)),d.append(Cy(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 Cy(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,nT=jt.RTL;function Fz(t){let e=[];for(let n=0;n<t.length;n++)e.push(1<<+t[n]);return e}const Qle=Fz("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Zle=Fz("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),cA=Object.create(null),Ws=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),n=t.charCodeAt(1);cA[e]=n,cA[n]=-e}function zz(t){return t<=247?Qle[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Zle[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const ece=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class il{get dir(){return this.level%2?nT: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 Vz(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||!Vz(r.inner,i.inner))return!1}return!0}const Tt=[];function tce(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=zz(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 x=h;x<y;x++)Tt[x]=b;h=y-1}else m==8&&d==1&&(Tt[h]=1);f=m,m&7&&(d=m)}}}function nce(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=cA[m=t.charCodeAt(d)])if(y<0){for(let x=a-3;x>=0;x-=3)if(Ws[x+1]==-y){let S=Ws[x+2],_=S&2?i:S&4?S&1?s:i:0;_&&(Tt[d]=Tt[Ws[x]]=_),a=x;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 x=b==i;c=x?0:1;for(let S=a-3;S>=0;S-=3){let _=Ws[S+2];if(_&2)break;if(x)Ws[S+2]|=2;else{if(_&4)break;Ws[S+2]|=4}}}}}function rce(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,x=i,S=x?n[x-1].to:t;b>c;)b==S&&(b=n[--x].from,S=x?n[x-1].to:t),Tt[--b]=y;c=f}else s=h,c++}}}function uA(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 x=Tt[c];x!=a&&(f=!1,d=x==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 x=s[h];if(!f)for(let S=x.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(x);else{x.from>c&&o.push(new il(c,x.from,y));let S=x.direction==Rc!=!(y%2);hA(t,S?r+1:r,i,x.inner,x.from,x.to,o),c=x.to}b=x.to}else{if(b==n||(f?Tt[b]!=a:Tt[b]==a))break;b++}m?uA(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 x=Tt[c-1];x!=a&&(f=!1,d=x==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 x=s[--h];if(!f)for(let S=x.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(x);else{x.to<c&&o.push(new il(x.to,c,y));let S=x.direction==Rc!=!(y%2);hA(t,S?r+1:r,i,x.inner,x.from,x.to,o),c=x.from}b=x.from}else{if(b==e||(f?Tt[b-1]!=a:Tt[b-1]==a))break;b--}m?uA(t,b,c,r+1,i,m,o):b<c&&o.push(new il(b,c,y)),c=b}}function hA(t,e,n,r,i,s,o){let a=e%2?2:1;tce(t,i,s,r,a),nce(t,i,s,r,a),rce(i,s,r,a),uA(t,i,s,e,n,r,o)}function ice(t,e,n){if(!t)return[new il(0,0,e==nT?1:0)];if(e==Rc&&!n.length&&!ece.test(t))return Uz(t.length);if(n.length)for(;t.length>Tt.length;)Tt[Tt.length]=256;let r=[],i=e==Rc?0:1;return hA(t,i,i,n,0,t.length,r),r}function Uz(t){return[new il(0,t,0)]}let Hz="";function sce(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),Hz=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 oce(t,e,n){for(let r=e;r<n;r++){let i=zz(t.charCodeAt(r));if(i==1)return Rc;if(i==2||i==4)return nT}return Rc}const Wz=Ce.define(),qz=Ce.define(),Gz=Ce.define(),Kz=Ce.define(),fA=Ce.define(),Yz=Ce.define(),Xz=Ce.define(),rT=Ce.define(),iT=Ce.define(),Jz=Ce.define({combine:t=>t.some(e=>e)}),Qz=Ce.define({combine:t=>t.some(e=>e)}),Zz=Ce.define();class wh{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 wh(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 wh(fe.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Ay=Ze.define({map:(t,e)=>t.map(e)}),eV=Ze.define();function Kr(t,e,n){let r=t.facet(Kz);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 ace=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(ace++,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 T_{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 tV=Ce.define(),sT=Ce.define(),lm=Ce.define(),nV=Ce.define(),rw=Ce.define(),rV=Ce.define();function aN(t,e){let n=t.state.facet(rV);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=oce(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 x={from:h,to:f,direction:y,inner:[]};d.push(x),d=x.inner}}}}),i}const iV=Ce.define();function oT(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(iV)){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 Cv{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 Cv(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:!pce(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?cce(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=fce(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 lA&&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,x;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,x=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:x}=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);Pz(this,A,E,S,_,m,y,b,x)}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(eV)&&(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)&&Ob(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&&lce(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)&&dce(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=uce(c.node,c.offset);if(m&&m!=3){let y=(m==1?Rz:Mz)(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,x=b?am(b):[];if(x.length){let S=x[x.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 Oz(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 lA(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(nV).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(Zz))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=oT(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;Fle(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 lce(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 sV(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=Rz(n.focusNode,n.focusOffset),i=Mz(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 cce(t,e,n){let r=sV(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 Gm({inclusive:!0,attributes:Xle(d),tagName:d.tagName.toLowerCase()})});else return null}}}function uce(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 hce=class{constructor(){this.changes=[]}compareRange(e,n){Pb(e,n,this.changes)}comparePoint(e,n){Pb(e,n,this.changes)}boundChange(e){Pb(e,e,this.changes)}};function fce(t,e,n){let r=new hce;return ft.compare(t,e,n,r),r.changes}function dce(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 pce(t,e){let n=!1;return e&&t.iterChangedRanges((r,i)=>{r<e.to&&i>e.from&&(n=!0)}),n}function mce(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 gce(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function yce(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function R_(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 dA(t,e,n){let r,i,s,o,a=!1,c,h,f,d;for(let b=t.firstChild;b;b=b.nextSibling){let x=am(b);for(let S=0;S<x.length;S++){let _=x[S];i&&R_(i,_)&&(_=cN(uN(_,i.bottom),i.top));let A=gce(e,_),E=yce(n,_);if(A==0&&E==0)return b.nodeType==3?hN(b,e,n):dA(b,e,n);(!r||o>E||o==E&&s>A)&&(r=b,i=_,s=A,o=E,a=A?e<_.left?S>0:S<x.length-1:!0),A==0?n>_.bottom&&(!f||f.bottom<_.bottom)?(c=b,f=_):n<_.top&&(!d||d.top>_.top)&&(h=b,d=_):f&&R_(f,_)?f=uN(f,_.bottom):d&&R_(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 dA(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 oV(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,x=t.root.elementFromPoint?t.root:b,S=x.elementFromPoint(f,d);S&&!t.contentDOM.contains(S)&&(S=null),S||(f=Math.max(o.left+1,Math.min(o.right-1,f)),S=x.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&&bce(_,A,f)||Se.chrome&&vce(_,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}=dA(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+ZC(o,s,t.state.tabSize)}function bce(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 vce(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 pA(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=pA(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=sce(i,s,o,a,n),f=Hz;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 wce(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 Sce(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,x=oV(t,{x:d,y:b},!1,s);if(b<c.top||b>c.bottom||(s<0?x<i:x>i)){let S=t.docView.coordsForChar(x),_=!S||b<S.top?-1:1;return fe.cursor(x,_,void 0,o)}}}function Db(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 aV(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=Db(t,i.from,0);o!=i.from&&(s=fe.cursor(o,-1))}else{let o=Db(t,i.from,-1),a=Db(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 M_(t,e,n){let r=Db(t.state.facet(rw).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 _ce{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:Sv(i))||Sv(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+(Cce(e,r.node,r.offset)?n:0))}}function Cce(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 Ace{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?[]:Tce(e),c=new _ce(a,e.state);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=Rce(a,this.bounds.from)}else{let a=e.observer.selectionRange,c=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!nA(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||!nA(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 lV(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=kce(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 aT(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=aV(t.state.facet(rw).map(c=>c(t)),r))),t.dispatch({selection:r,scrollIntoView:o,userEvent:a}),!0}else return!1}function aT(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&&xh(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)&&xh(t.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&xh(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,a=()=>o||(o=Ece(t,e,n));return t.state.facet(Yz).some(c=>c(t,e.from,e.to,s,a))||t.dispatch(a()),!0}function Ece(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&&sV(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 x=b.to-m,S=x-h.length;if(b.to-b.from!=y||t.state.sliceDoc(S,x)!=h||b.to>=f.from&&b.from<=f.to)return{range:b};let _=i.changes({from:S,to:x,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 kce(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 Tce(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 Rce(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 Mce{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&&qce(e.contentDOM.ownerDocument)}handleEvent(e){!jce(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=Oce(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&&uV.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=cV.find(r=>r.keyCode==e.keyCode))&&!e.ctrlKey||Pce.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,xh(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 Oce(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 cV=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Pce="dthko",uV=[16,17,18,20,91,92,224,225],Ey=6;function ky(t){return Math.max(0,t)*.7+8}function Dce(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class Ice{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=zle(e.contentDOM),this.atoms=e.state.facet(rw).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)&&Lce(e,n),this.dragging=$ce(e,n)&&dV(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&&Dce(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=oT(this.view);e.clientX-c.left<=i+Ey?n=-ky(i-e.clientX):e.clientX+c.right>=o-Ey&&(n=ky(e.clientX-o)),e.clientY-c.top<=s+Ey?r=-ky(s-e.clientY):e.clientY+c.bottom>=a-Ey&&(r=ky(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=aV(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 Lce(t,e){let n=t.state.facet(Wz);return n.length?n[0](e):Se.mac?e.metaKey:e.ctrlKey}function Nce(t,e){let n=t.state.facet(qz);return n.length?n[0](e):Se.mac?!e.altKey:!e.ctrlKey}function $ce(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 jce(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),hV=Se.ie&&Se.ie_version<15||Se.ios&&Se.webkit_version<604;function Bce(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(),fV(t,n.value)},50)}function iw(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function fV(t,e){e=iw(t.state,rT,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(mA!=null&&n.selection.ranges.every(c=>c.empty)&&mA==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(Gz))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=Vce(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new Ice(t,e,n,r)),r&&t.observer.ignore(()=>{Ez(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 mce(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 Fce(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:Fce(t,n,e.clientX,e.clientY)}}const zce=Se.ie&&Se.ie_version<=11;let vN=null,xN=0,wN=0;function dV(t){if(!zce)return t.detail;let e=vN,n=wN;return vN=t,wN=Date.now(),xN=!e||n>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(xN+1)%3:1}function Vce(t,e){let n=bN(t,e),r=dV(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=Uce(i,c.pos))?h:a?i.addRange(f):fe.create([f])}}}function Uce(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",iw(t.state,iT,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=iw(t.state,rT,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&Nce(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=hV?null:e.clipboardData;return n?(fV(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(Bce(t),!1)};function Hce(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 Wce(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:iw(t,iT,e.join(t.lineBreak)),ranges:n,linewise:r}}let mA=null;ks.copy=ks.cut=(t,e)=>{let{text:n,ranges:r,linewise:i}=Wce(t.state);if(!n&&!i)return!1;mA=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=hV?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(Hce(t,n),!1)};const pV=sa.define();function mV(t,e){let n=[];for(let r of t.facet(Xz)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:pV.of(!0)}):null}function gV(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=mV(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),gV(t)};ts.blur=t=>{t.observer.clearSelectionRange(),gV(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 aT(t,{from:c,to:h,insert:t.state.toText(s)},null),!0}}let i;if(Se.chrome&&Se.android&&(i=cV.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 qce(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 Gce{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 Kce{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 Nt=(function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t})(Nt||(Nt={}));const Ib=.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)>Ib&&(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,Nt.ByPosNoHeight,r.setDoc(n),0,0),y=m.to>=h?m:s.lineAt(h,Nt.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,Nt.ByPosNoHeight,r,0,0));f+=m.from-c,c=m.from;let b=lT.build(r.setDoc(o),e,f,d);s=Av(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 Yce(Ir.of(e.slice(0,n)),o,Ir.of(e.slice(r)))}}function Av(t,e){return t==e?t:(t.constructor!=e.constructor&&(Nh=!0),e)}Ir.prototype.size=1;class yV 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 yV{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==Nt.ByHeight)return this.blockAt(e,r,i,s);if(n==Nt.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)>=Ib&&(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)>=Ib||Math.abs(c-this.heightMetrics(e,n).perLine)>=Ib)&&(Nh=!0),Av(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 Yce 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==Nt.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==Nt.ByPosNoHeight?Nt.ByPosNoHeight:Nt.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,Nt.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=Av(this.left,e),this.right=Av(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 Xce=5;class lT{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 yV(o,i,r)):(o||s||i>=Xce)&&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 lT(r,e);return ft.spans(n,r,i,s,0),s.finish(r)}}function Jce(t,e,n){let r=new Qce;return ft.compare(t,e,n,r,0),r.changes}class Qce{constructor(){this.changes=[]}compareRange(){}comparePoint(e,n,r,i){(e<n||r&&r.heightRelevant||i&&i.heightRelevant)&&Pb(e,n,this.changes,5)}}function Zce(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 eue(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 tue(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class O_{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 nue(this.displaySize*(n?e.scaleY:e.scaleX),n)}).range(this.from,this.to)}}class nue 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(sT).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new Gce(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 Ty(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 cT(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,Jce(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(Qz)&&(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}=Az(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=Tz(e.scrollDOM);let b=(this.printing?tue:Zce)(n,this.paddingTop),x=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&&!eue(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)}x>0&&S>0?f=Math.max(x,S):x<0&&S<0&&(f=Math.min(x,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 Kce(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 Ty(i.lineAt(o-r*1e3,Nt.ByHeight,s,0,0).from,i.lineAt(a+(1-r)*1e3,Nt.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,Nt.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 Ty(i.lineAt(m-1e3/2,Nt.ByHeight,s,0,0).from,i.lineAt(m+f+1e3/2,Nt.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 Ty(this.heightMap.lineAt(r,Nt.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,Nt.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,Nt.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(n,Nt.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 O_(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,x=[b.from];b.empty||x.push(b.to);for(let _ of x)if(_>f&&_<d){c(f,_-10,m,y),c(_+10,d,m,y);return}let S=iue(e,_=>_.from>=m.from&&_.to<=m.to&&Math.abs(_.from-f)<s&&Math.abs(_.to-d)<s&&!x.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 O_(f,d,_,A)}a.push(S)},h=f=>{if(f.length<o||f.type!=Dr.Text)return;let d=rue(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 x=i/this.heightOracle.lineLength*this.heightOracle.lineHeight,S,_;if(m!=null){let A=My(d,m),E=((this.visibleBottom-this.visibleTop)/2+x)/f.height;S=A-E,_=A+E}else S=(this.visibleTop-f.top-x)/f.height,_=(this.visibleBottom-f.top+x)/f.height;y=Ry(d,S),b=Ry(d,_)}else{let x=d.total*this.heightOracle.charWidth,S=i*this.heightOracle.charWidth,_=0;if(x>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=My(d,m),D=((E-A)/2+S)/x;P=M-D,O=M+D}else P=(A-S)/x,O=(E+S)/x;y=Ry(d,P),b=Ry(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=My(i,r)-My(i,n);return this.heightOracle.lineWrapping?e.height*s:i.total*this.heightOracle.charWidth*s}updateLineGaps(e){O_.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,Nt.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),Nt.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 Ty{constructor(e,n){this.from=e,this.to=n}}function rue(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 Ry({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 My(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 iue(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 cT{constructor(e,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:a,to:c})=>{let h=n.lineAt(a,Nt.ByPos,e,0,0).top,f=n.lineAt(c,Nt.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 cT?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 Oy=Ce.define({combine:t=>t.join(" ")}),gA=Ce.define({combine:t=>t.indexOf(!0)>-1}),yA=pl.newName(),bV=pl.newName(),vV=pl.newName(),xV={"&light":"."+bV,"&dark":"."+vV};function bA(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 sue=bA("."+yA,{"&":{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),oue={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},P_=Se.ie&&Se.ie_version<=11;class aue{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Vle,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 cue(e),e.state.facet(Wo)&&(e.contentDOM.editContext=this.editContext.editContext)),P_&&(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:!Ob(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&&lue(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=Ob(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Hle(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,oue),P_&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),P_&&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&&xh(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&&Ob(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 Ace(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=lV(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 lue(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 cue{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);aT(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:eV.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||Ule(e.parent)||document,this.viewState=new kN(e.state||ht.create(e)),e.scrollTo&&e.scrollTo.is(Ay)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(nh).map(i=>new T_(i));for(let i of this.plugins)i.update(this);this.observer=new aue(this),this.inputState=new Mce(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(pV))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=mV(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=Cv.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 wh(y.empty?y:fe.cursor(y.head,y.head>y.anchor?-1:1))}for(let y of m.effects)y.is(Ay)&&(d=y.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=Ev.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(Oy)!=i.state.facet(Oy)&&(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(fA))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&&!lV(this,f)&&h.force&&xh(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 T_(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 T_(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(Tz(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=Cv.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(fA))a(n)}get themeClasses(){return yA+" "+(this.state.facet(gA)?vV:bV)+" "+this.state.facet(Oy)}updateAttrs(){let e=PN(this,tV,{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,sT,n);let r=this.observer.ignore(()=>{let i=aA(this.contentDOM,this.contentAttrs,n),s=aA(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(sue).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 M_(this,e,dN(this,e,n,r))}moveByGroup(e,n){return M_(this,e,dN(this,e,n,r=>wce(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 M_(this,e,Sce(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(),oV(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 tw(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(Jz)||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>uue)return Uz(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||Vz(s.isolates,r=aN(this,e))))return s.order;r||(r=aN(this,e));let i=ice(e.text,n,r);return this.bidiCache.push(new Ev(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(()=>{Ez(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 Ay.of(new wh(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 Ay.of(new wh(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=[Oy.of(r),up.of(bA(`.${r}`,e))];return n&&n.dark&&i.push(gA.of(!0)),i}static baseTheme(e){return $c.lowest(up.of(bA("."+yA,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=Yz;_e.clipboardInputFilter=rT;_e.clipboardOutputFilter=iT;_e.scrollHandler=Zz;_e.focusChangeEffect=Xz;_e.perLineTextDirection=Jz;_e.exceptionSink=Kz;_e.updateListener=fA;_e.editable=Wo;_e.mouseSelectionStyle=Gz;_e.dragMovesSelection=qz;_e.clickAddsSelectionRange=Wz;_e.decorations=lm;_e.outerDecorations=nV;_e.atomicRanges=rw;_e.bidiIsolatedRanges=rV;_e.scrollMargins=iV;_e.darkTheme=gA;_e.cspNonce=Ce.define({combine:t=>t.length?t[0]:""});_e.contentAttributes=sT;_e.editorAttributes=tV;_e.lineWrapping=_e.contentAttributes.of({class:"cm-lineWrapping"});_e.announce=Ze.define();const uue=4096,ON={};class Ev{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 Ev(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&&oA(o,n)}return n}const hue=Se.mac?"mac":Se.windows?"win":Se.linux?"linux":"key";function fue(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 Py(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 due=$c.default(_e.domEventHandlers({keydown(t,e){return SV(wV(e.state),t,e,"editor")}})),uT=Ce.define({enables:due}),DN=new WeakMap;function wV(t){let e=t.facet(uT),n=DN.get(e);return n||DN.set(e,n=gue(e.reduce((r,i)=>r.concat(i),[]))),n}function pue(t,e,n){return SV(wV(t.state),e,t,n)}let el=null;const mue=4e3;function gue(t,e=hue){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(_=>fue(_,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)},mue),!0}]})}let x=b.join(" ");i(x,!1);let S=y[x]||(y[x]={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,vA))}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 vA=null;function SV(t,e,n,r){vA=e;let i=jle(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+" ",uV.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,x;return y&&(m(y[a+Py(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+Py(b,e,!0)])||e.shiftKey&&(x=sm[e.keyCode])!=i&&x!=b&&m(y[a+Py(x,e,!1)]))&&(c=!0):o&&e.shiftKey&&m(y[a+Py(i,e,!0)])&&(c=!0),!c&&m(y._any)&&(c=!0)),h&&(c=!0),c&&f&&e.stopPropagation(),vA=null,c}class Ym{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=_V(e);return[new Ym(n,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}else return yue(e,n,r)}}function _V(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 yue(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=_V(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=pA(t,r,1),b=pA(t,i,-1),x=y.type==Dr.Text?y:null,S=b.type==Dr.Text?b:null;if(x&&(t.lineWrapping||y.widgetLineBreaks)&&(x=IN(t,r,1,x)),S&&(t.lineWrapping||b.widgetLineBreaks)&&(S=IN(t,i,-1,S)),x&&S&&x.from==S.from&&x.to==S.to)return A(E(n.from,n.to,x));{let O=x?E(n.from,null,x):P(y,!1),M=S?E(null,n.to,S):P(b,!0),D=[];return(x||y).to<(S||b).from-(x&&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,N){return new Ym(e,O-c.left,M-c.top,D-O,N-M)}function A({top:O,bottom:M,horizontal:D}){let N=[];for(let H=0;H<D.length;H+=2)N.push(_(D[H],O,D[H+1],M));return N}function E(O,M,D){let N=1e9,H=-1e9,j=[];function V(Y,te,z,G,U){let se=t.coordsAtPos(Y,Y==D.to?-2:2),T=t.coordsAtPos(z,z==D.from?2:-2);!se||!T||(N=Math.min(se.top,T.top,N),H=Math.max(se.bottom,T.bottom,H),U==jt.LTR?j.push(s&&te?d:se.left,s&&G?m:T.right):j.push(!s&&G?d:T.left,!s&&te?m:se.right))}let q=O??D.from,X=M??D.to;for(let Y of t.visibleRanges)if(Y.to>q&&Y.from<X)for(let te=Math.max(Y.from,q),z=Math.min(Y.to,X);;){let G=t.state.doc.lineAt(te);for(let U of t.bidiSpans(G)){let se=U.from+G.from,T=U.to+G.from;if(se>=z)break;T>te&&V(Math.max(se,te),O==null&&se<=q,Math.min(T,z),M==null&&T>=X,U.dir)}if(te=G.to+1,te>=z)break}return j.length==0&&V(q,O==null,X,M==null,t.textDirection),{top:N,bottom:H,horizontal:j}}function P(O,M){let D=a.top+(M?O.top:O.bottom);return{top:D,bottom:D,horizontal:[]}}}function bue(t,e){return t.constructor==e.constructor&&t.eq(e)}class vue{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(Lb)!=e.state.facet(Lb)&&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(Lb);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)=>!bue(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 Lb=Ce.define();function CV(t){return[yn.define(e=>new vue(e,t)),Lb.of(t)]}const cm=Ce.define({combine(t){return xo(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function xue(t={}){return[cm.of(t),wue,Sue,_ue,Qz.of(!0)]}function AV(t){return t.startState.facet(cm)!=t.state.facet(cm)}const wue=CV({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 Ym.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=AV(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 Sue=CV({above:!1,markers(t){return t.state.selection.ranges.map(e=>e.empty?[]:Ym.forRange(t,"cm-selectionBackground",e)).reduce((e,n)=>e.concat(n))},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||AV(t)},class:"cm-selectionLayer"}),_ue=$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"}}}})),EV=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(EV)?r.value:n,t)}}),Cue=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:EV.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 Aue(){return[dp,Cue]}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 Eue(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 kue{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 Eue(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=(x,S,_)=>m.push(_.range(x,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,(x,S)=>this.addMatch(S,e,x,b));n=n.update({filterFrom:f,filterTo:d,filter:(x,S)=>x<f||S>d,add:m})}}return n}}const xA=/x/.unicode!=null?"gu":"g",Tue=new RegExp(`[\0-\b
--Ÿ­؜\u2028\u2029\uFEFF-]`,xA),Rue={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 D_=null;function Mue(){var t;if(D_==null&&typeof document<"u"&&document.body){let e=document.body.style;D_=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return D_||!1}const Nb=Ce.define({combine(t){let e=xo(t,{render:null,specialChars:Tue,addSpecialChars:null});return(e.replaceTabs=!Mue())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,xA)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,xA)),e}});function Oue(t={}){return[Nb.of(t),Pue()]}let $N=null;function Pue(){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(Nb)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new kue({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 Nue((a-c%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=He.replace({widget:new Lue(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(Nb);t.startState.facet(Nb)!=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 Due="•";function Iue(t){return t>=32?Due:t==10?"␤":String.fromCharCode(9216+t)}class Lue extends _l{constructor(e,n){super(),this.options=e,this.code=n}eq(e){return e.code==this.code}toDOM(e){let n=Iue(this.code),r=e.state.phrase("Control character")+" "+(Rue[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 Nue 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 $ue(){return Bue}const jue=He.line({class:"cm-activeLine"}),Bue=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(jue.range(i.from)),e=i.from)}return He.set(n)}},{decorations:t=>t.decorations}),wA=2e3;function Fue(t,e,n){let r=Math.min(e.line,n.line),i=Math.max(e.line,n.line),s=[];if(e.off>wA||n.off>wA||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=ZC(h.text,o,t.tabSize,!0);if(f<0)s.push(fe.cursor(h.to));else{let d=ZC(h.text,a,t.tabSize);s.push(fe.range(h.from+f,h.from+d))}}}return s}function zue(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>wA?-1:i==r.length?zue(t,e.clientX):Qh(r.text,t.state.tabSize,n-r.from);return{line:r.number,col:s,off:i}}function Vue(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=Fue(t.state,n,a);return c.length?o?fe.create(c.concat(r.ranges)):fe.create(c):r}}:null}function Uue(t){let e=(n=>n.altKey&&n.button==0);return _e.mouseSelectionStyle.of((n,r)=>e(r)?Vue(n,r):null)}const Hue={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},Wue={style:"cursor: crosshair"};function que(t={}){let[e,n]=Hue[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?Wue:null})]}const Pd="-10000px";class kV{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 Gue(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const I_=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)||Gue}}}),BN=new WeakMap,hT=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(I_);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 kV(t,fT,(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(I_);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=oT(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(I_).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,x=m.right-m.left,S=(e=BN.get(h))!==null&&e!==void 0?e:m.bottom-m.top,_=h.offset||Yue,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-x)):Math.min(Math.max(r.left,d.left-x+(y?14:0)-_.x),r.right-x),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+x;if(h.overlap!==!0)for(let N of o)N.left<D&&N.right>E&&N.top<M+S&&N.bottom>M&&(M=P?N.top-S-2-b:N.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 N=d.left+(A?_.x:-_.x)-(E+14-7);y.style.left=N/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 Kue=_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"}}}),Yue={x:0,y:0},fT=Ce.define({enables:[hT,Kue]}),kv=Ce.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class sw{static create(e){return new sw(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new kV(e,kv,(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 Xue=fT.compute([kv],t=>{let e=t.facet(kv);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:sw.create,above:e[0].above,arrow:e.some(n=>n.arrow)}});class Jue{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(hT),n=e?e.manager.tooltips.findIndex(r=>r.create==sw.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&&!Que(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:!Zue(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 Dy=4;function Que(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-Dy&&e.clientX<=r+Dy&&e.clientY>=i-Dy&&e.clientY<=s+Dy}function Zue(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 ehe(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(the)&&(i=[]);return i},provide:i=>kv.from(i)});return{active:r,extension:[r,yn.define(i=>new Jue(i,t,r,n,e.hoverTime||300)),Xue]}}function TV(t,e){let n=t.plugin(hT);if(!n)return null;let r=n.manager.tooltips.indexOf(e);return r<0?null:n.manager.tooltipViews[r]}const the=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(RV),r=n?n.specs.indexOf(e):-1;return r>-1?n.panels[r]:null}const RV=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 Iy(t,!0,e.topContainer),this.bottom=new Iy(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 Iy(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Iy(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 Iy{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:RV});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 $b=Ce.define(),nhe=Ce.define(),rhe={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ft.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Rp=Ce.define();function ihe(t){return[MV(),Rp.of({...rhe,...t})]}const UN=Ce.define({combine:t=>t.some(e=>e)});function MV(t){return[she]}const she=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($b),this.view.viewport.from),r=[],i=this.gutters.map(s=>new ohe(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){SA(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){SA(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($b),t.state.facet($b),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 SA(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class ohe{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 OV(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=[];SA(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(nhe)){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 OV(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 OV{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":""),ahe(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 ahe(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 lhe=Ce.define(),che=Ce.define(),rh=Ce.define({combine(t){return xo(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 L_ extends Qo{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function N_(t,e){return t.state.facet(rh).formatNumber(e,t.state)}const uhe=Rp.compute([rh],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(lhe)},lineMarker(e,n,r){return r.some(i=>i.toDOM)?null:new L_(N_(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let i of e.state.facet(che)){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 L_(N_(e,qN(e.state.doc.lines)))},updateSpacer(e,n){let r=N_(n.view,qN(n.view.state.doc.lines));return r==e.number?e:new L_(r)},domEventHandlers:t.facet(rh).domEventHandlers,side:"before"}));function hhe(t={}){return[rh.of(t),MV(),uhe]}function qN(t){let e=9;for(;e<t;)e=e*10+9;return e}const fhe=new class extends Qo{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},dhe=$b.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(fhe.range(i)))}return ft.of(e)});function phe(){return dhe}const PV=1024;let mhe=0;class $_{constructor(e,n){this.from=e,this.to=n}}class it{constructor(e={}){this.id=mhe++,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 Tv{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 ghe=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):ghe,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 dT{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 dT(n)}}const Ly=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=Tv.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 CA(this.topNode,e)}cursorAt(e,n=0,r=0){let i=Ly.get(this)||this.topNode,s=new CA(i);return s.moveTo(e,n),Ly.set(this,s._tree),s}get topNode(){return new Zi(this,0,0,null)}resolve(e,n=0){let r=fm(Ly.get(this)||this.topNode,e,n,!1);return Ly.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 vhe(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:gT(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 pT{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 pT(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&&!(DV(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 DV(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 IV{cursor(e=0){return new CA(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 _A(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 IV{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(DV(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 yhe(o,f,e,d),null,m)}else if(s&$n.IncludeAnonymous||!f.type.isAnonymous||mT(f)){let m;if(!(s&$n.IgnoreMounts)&&(m=Tv.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=Tv.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 _A(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 yhe{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class sl extends IV{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 LV(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 bhe(i,n)}class bhe{constructor(e,n){this.heads=e,this.node=n}get next(){return LV(this.heads)}}function vhe(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=Tv.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?LV(i):r}class CA{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||mT(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 _A(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 _A(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 mT(t){return t.children.some(e=>e instanceof yl||!e.type.isAnonymous||mT(e))}function xhe(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=PV,reused:s=[],minRepeatType:o=r.types.length}=t,a=Array.isArray(n)?new pT(n,n.length):n,c=r.types,h=0,f=0;function d(O,M,D,N,H,j){let{id:V,start:q,end:X,size:Y}=a,te=f,z=h;for(;Y<0;)if(a.next(),Y==-1){let Z=s[V];D.push(Z),N.push(q-O);return}else if(Y==-3){h=V;return}else if(Y==-4){f=V;return}else throw new RangeError(`Unrecognized record size: ${Y}`);let G=c[V],U,se,T=q-O;if(X-q<=i&&(se=S(a.pos-M,H))){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);U=new yl(Z,X-se.start,r),T=se.start-O}else{let Z=a.pos-Y;a.next();let ue=[],L=[],de=V>=o?V:-1,ke=0,ye=X;for(;a.pos>Z;)de>=0&&a.id==de&&a.size>=0?(a.end<=ye-i&&(b(ue,L,q,ke,a.end,ye,de,te,z),ke=ue.length,ye=a.end),a.next()):j>2500?m(q,Z,ue,L):d(q,Z,ue,L,de,j+1);if(de>=0&&ke>0&&ke<ue.length&&b(ue,L,q,ke,q,ye,de,te,z),ue.reverse(),L.reverse(),de>-1&&ke>0){let Ee=y(G,z);U=gT(G,ue,L,0,ue.length,0,X-q,Ee,Ee)}else U=x(G,ue,L,X-q,te-X,z)}D.push(U),N.push(T)}function m(O,M,D,N){let H=[],j=0,V=-1;for(;a.pos>M;){let{id:q,start:X,end:Y,size:te}=a;if(te>4)a.next();else{if(V>-1&&X<V)break;V<0&&(V=Y-i),H.push(q,X,Y),j++,a.next()}}if(j){let q=new Uint16Array(j*4),X=H[H.length-2];for(let Y=H.length-3,te=0;Y>=0;Y-=3)q[te++]=H[Y],q[te++]=H[Y+1]-X,q[te++]=H[Y+2]-X,q[te++]=te;D.push(new yl(q,H[2]-X,r)),N.push(X-O)}}function y(O,M){return(D,N,H)=>{let j=0,V=D.length-1,q,X;if(V>=0&&(q=D[V])instanceof mn){if(!V&&q.type==O&&q.length==H)return q;(X=q.prop(it.lookAhead))&&(j=N[V]+q.length+X)}return x(O,D,N,H,j,M)}}function b(O,M,D,N,H,j,V,q,X){let Y=[],te=[];for(;O.length>N;)Y.push(O.pop()),te.push(M.pop()+D-H);O.push(x(r.types[V],Y,te,j-H,q-j,X)),M.push(H-D)}function x(O,M,D,N,H,j,V){if(j){let q=[it.contextHash,j];V=V?[q].concat(V):[q]}if(H>25){let q=[it.lookAhead,H];V=V?[q].concat(V):[q]}return new mn(O,M,D,N,V)}function S(O,M){let D=a.fork(),N=0,H=0,j=0,V=D.end-i,q={size:0,start:0,skip:0};e:for(let X=D.pos-O;D.pos>X;){let Y=D.size;if(D.id==M&&Y>=0){q.size=N,q.start=H,q.skip=j,j+=4,N+=4,D.next();continue}let te=D.pos-Y;if(Y<0||te<X||D.start<V)break;let z=D.id>=o?4:0,G=D.start;for(D.next();D.pos>te;){if(D.size<0)if(D.size==-3)z+=4;else break e;else D.id>=o&&(z+=4);D.next()}H=G,N+=Y,j+=z}return(M<0||N==O)&&(q.size=N,q.start=H,q.skip=j),q.size>4?q:void 0}function _(O,M,D){let{id:N,start:H,end:j,size:V}=a;if(a.next(),V>=0&&N<o){let q=D;if(V>4){let X=a.pos-(V-4);for(;a.pos>X;)D=_(O,M,D)}M[--D]=q,M[--D]=j-O,M[--D]=H-O,M[--D]=N}else V==-3?h=N:V==-4&&(f=N);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 jb(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+=jb(t,r)}YN.set(e,n)}return n}function gT(t,e,n,r,i,s,o,a,c){let h=0;for(let b=r;b<i;b++)h+=jb(t,e[b]);let f=Math.ceil(h*1.5/8),d=[],m=[];function y(b,x,S,_,A){for(let E=S;E<_;){let P=E,O=x[E],M=jb(t,b[E]);for(E++;E<_;E++){let D=jb(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,x[P]+A);continue}d.push(b[P])}else{let D=x[E-1]+b[E-1].length-O;d.push(gT(t,b,x,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 NV{startParse(e,n,r){return typeof e=="string"&&(e=new whe(e)),r=r?r.length?r.map(i=>new $_(i.from,i.to)):[new $_(0,0)]:[new $_(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 whe{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 She=0;class Wi{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=She++}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 Rv(e);return r=>r.modified.indexOf(n)>-1?r:Rv.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let _he=0;class Rv{constructor(e){this.name=e,this.instances=[],this.id=_he++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&Che(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=Ahe(n);for(let a of e.set)if(!a.modified.length)for(let c of o)i.push(Rv.get(a,c));return s}}function Che(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function Ahe(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 $V(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 Mv(r,o,c>0?s.slice(0,c):null);e[h]=f.sort(e[h])}}return jV.add(e)}const jV=new it;let Mv=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}};Mv.empty=new Mv([],2,null);function BV(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 Ehe(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function khe(t,e,n,r=0,i=t.length){let s=new The(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class The{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=Rhe(e)||Mv.empty,d=Ehe(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)),x=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&&x)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))}x&&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 Rhe(t){let e=t.type.prop(jV);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const we=Wi.define,Ny=we(),Ja=we(),XN=we(Ja),JN=we(Ja),Qa=we(),$y=we(Qa),j_=we(Qa),Ks=we(),Xl=we(Ks),qs=we(),Gs=we(),AA=we(),Dd=we(AA),jy=we(),xe={comment:Ny,lineComment:we(Ny),blockComment:we(Ny),docComment:we(Ny),name:Ja,variableName:we(Ja),typeName:XN,tagName:we(XN),propertyName:JN,attributeName:we(JN),className:we(Ja),labelName:we(Ja),namespace:we(Ja),macroName:we(Ja),literal:Qa,string:$y,docString:we($y),character:we($y),attributeValue:we($y),number:j_,integer:we(j_),float:we(j_),bool:we(Qa),regexp:we(Qa),escape:we(Qa),color:we(Qa),url:we(Qa),keyword:qs,self:we(qs),null:we(qs),atom:we(qs),unit:we(qs),modifier:we(qs),operatorKeyword:we(qs),controlKeyword:we(qs),definitionKeyword:we(qs),moduleKeyword:we(qs),operator:Gs,derefOperator:we(Gs),arithmeticOperator:we(Gs),logicOperator:we(Gs),bitwiseOperator:we(Gs),compareOperator:we(Gs),updateOperator:we(Gs),definitionOperator:we(Gs),typeOperator:we(Gs),controlOperator:we(Gs),punctuation:AA,separator:we(AA),bracket:Dd,angleBracket:we(Dd),squareBracket:we(Dd),paren:we(Dd),brace:we(Dd),content:Ks,heading:Xl,heading1:we(Xl),heading2:we(Xl),heading3:we(Xl),heading4:we(Xl),heading5:we(Xl),heading6:we(Xl),contentSeparator:we(Ks),list:we(Ks),quote:we(Ks),emphasis:we(Ks),strong:we(Ks),link:we(Ks),monospace:we(Ks),strikethrough:we(Ks),inserted:we(),deleted:we(),changed:we(),invalid:we(),meta:jy,documentMeta:we(jy),annotation:we(jy),processingInstruction:we(jy),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 xe){let e=xe[t];e instanceof Wi&&(e.name=t)}BV([{tag:xe.link,class:"tok-link"},{tag:xe.heading,class:"tok-heading"},{tag:xe.emphasis,class:"tok-emphasis"},{tag:xe.strong,class:"tok-strong"},{tag:xe.keyword,class:"tok-keyword"},{tag:xe.atom,class:"tok-atom"},{tag:xe.bool,class:"tok-bool"},{tag:xe.url,class:"tok-url"},{tag:xe.labelName,class:"tok-labelName"},{tag:xe.inserted,class:"tok-inserted"},{tag:xe.deleted,class:"tok-deleted"},{tag:xe.literal,class:"tok-literal"},{tag:xe.string,class:"tok-string"},{tag:xe.number,class:"tok-number"},{tag:[xe.regexp,xe.escape,xe.special(xe.string)],class:"tok-string2"},{tag:xe.variableName,class:"tok-variableName"},{tag:xe.local(xe.variableName),class:"tok-variableName tok-local"},{tag:xe.definition(xe.variableName),class:"tok-variableName tok-definition"},{tag:xe.special(xe.variableName),class:"tok-variableName2"},{tag:xe.definition(xe.propertyName),class:"tok-propertyName tok-definition"},{tag:xe.typeName,class:"tok-typeName"},{tag:xe.namespace,class:"tok-namespace"},{tag:xe.className,class:"tok-className"},{tag:xe.macroName,class:"tok-macroName"},{tag:xe.propertyName,class:"tok-propertyName"},{tag:xe.operator,class:"tok-operator"},{tag:xe.comment,class:"tok-comment"},{tag:xe.meta,class:"tok-meta"},{tag:xe.invalid,class:"tok-invalid"},{tag:xe.punctuation,class:"tok-punctuation"}]);var B_;const ih=new it;function Mhe(t){return Ce.define({combine:t?e=>e.concat(t):void 0})}const Ohe=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(Ohe);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 Ov extends bs{constructor(e,n,r){super(e,n,[],r),this.parser=n}static define(e){let n=Mhe(e.languageData);return new Ov(n,e.parser.configure({props:[ih.add(r=>r.isTop?n:void 0)]}),e.name)}configure(e,n){return new Ov(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 Phe{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 Pv{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 Pv(e,n,[],mn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Phe(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 Pv(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 NV{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=Pv.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 FV=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(FV=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const F_=typeof navigator<"u"&&(!((B_=navigator.scheduling)===null||B_===void 0)&&B_.isInputPending)?()=>navigator.scheduling.isInputPending():null,Dhe=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=FV(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&&!F_?Math.max(25,e.timeRemaining()-5):1e9),a=s.context.treeLen<i&&r.doc.length>i+1e3,c=s.context.work(()=>F_&&F_()||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,Dhe,_e.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class Ihe{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const Lhe=Ce.define(),yT=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 Dv(t){let e=t.facet(yT);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function dm(t,e){let n="",r=t.tabSize,i=t.facet(yT)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s<e;s++)n+=i;return n}function bT(t,e){t instanceof ht&&(t=new ow(t));for(let r of t.state.facet(Lhe)){let i=r(t,e);if(i!==void 0)return i}let n=br(t.state);return n.length>=e?Nhe(t,n,e):null}class ow{constructor(e,n={}){this.state=e,this.options=n,this.unit=Dv(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 zV=new it;function Nhe(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 VV(r,t,n)}function VV(t,e,n){for(let r=t;r;r=r.next){let i=jhe(r.node);if(i)return i(vT.create(e,n,r))}return 0}function $he(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function jhe(t){let e=t.type.prop(zV);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=>Vhe(o,!0,1,void 0,s&&!$he(o)?i.from:void 0)}return t.parent==null?Bhe:null}function Bhe(){return 0}class vT extends ow{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 vT(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(Fhe(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return VV(this.context.next,this.base,this.pos)}}function Fhe(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function zhe(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 Vhe(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=zhe(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 Uhe=200;function Hhe(){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+Uhe)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=bT(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 Whe=Ce.define(),UV=new it;function qhe(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 Ghe(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(UV);if(c&&(a.to<r.length-50||r.length==t.doc.length||!Khe(a))){let h=c(a,t);h&&h.from<=n&&h.from>=e&&h.to>n&&(s=h)}}return s}function Khe(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function Iv(t,e,n){for(let r of t.facet(Whe)){let i=r(t,e,n);if(i)return i}return Ghe(t,e,n)}function HV(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 aw=Ze.define({map:HV}),Xm=Ze.define({map:HV});function WV(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(aw)&&!Yhe(t,n.value.from,n.value.to)){let{preparePlaceholder:r}=e.state.facet(KV),i=r?He.replace({widget:new nfe(r(e.state,n.value))}):n3;t=t.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Xm)&&(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 Lv(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 Yhe(t,e,n){let r=!1;return t.between(e,e,(i,s)=>{i==e&&s==n&&(r=!0)}),r}function qV(t,e){return t.field(Mc,!1)?e:e.concat(Ze.appendConfig.of(YV()))}const Xhe=t=>{for(let e of WV(t)){let n=Iv(t.state,e.from,e.to);if(n)return t.dispatch({effects:qV(t.state,[aw.of(n),GV(t,n)])}),!0}return!1},Jhe=t=>{if(!t.state.field(Mc,!1))return!1;let e=[];for(let n of WV(t)){let r=Lv(t.state,n.from,n.to);r&&e.push(Xm.of(r),GV(t,r,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function GV(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 Qhe=t=>{let{state:e}=t,n=[];for(let r=0;r<e.doc.length;){let i=t.lineBlockAt(r),s=Iv(e,i.from,i.to);s&&n.push(aw.of(s)),r=(s?t.lineBlockAt(s.to):i).to+1}return n.length&&t.dispatch({effects:qV(t.state,n)}),!!n.length},Zhe=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(Xm.of({from:r,to:i}))}),t.dispatch({effects:n}),!0},efe=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Xhe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Jhe},{key:"Ctrl-Alt-[",run:Qhe},{key:"Ctrl-Alt-]",run:Zhe}],tfe={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},KV=Ce.define({combine(t){return xo(t,tfe)}});function YV(t){return[Mc,sfe]}function XV(t,e){let{state:n}=t,r=n.facet(KV),i=o=>{let a=t.lineBlockAt(t.posAtDOM(o.target)),c=Lv(t.state,a.from,a.to);c&&t.dispatch({effects:Xm.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 XV(t,null)}}});class nfe extends _l{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return XV(e,this.value)}}const rfe={openText:"⌄",closedText:"",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class z_ 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 ife(t={}){let e={...rfe,...t},n=new z_(e,!0),r=new z_(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=Lv(o.state,c.from,c.to)?r:Iv(o.state,c.from,c.to)?n:null;h&&a.add(c.from,c.from,h)}return a.finish()}}),{domEventHandlers:s}=e;return[i,ihe({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 z_(e,!1)},domEventHandlers:{...s,click:(o,a,c)=>{if(s.click&&s.click(o,a,c))return!0;let h=Lv(o.state,a.from,a.to);if(h)return o.dispatch({effects:Xm.of(h)}),!0;let f=Iv(o.state,a.from,a.to);return f?(o.dispatch({effects:aw.of(f)}),!0):!1}}}),YV()]}const sfe=_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 lw{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=BV(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 lw(e,n||{})}}const EA=Ce.define(),JV=Ce.define({combine(t){return t.length?[t[0]]:null}});function V_(t){let e=t.facet(EA);return e.length?e:t.facet(JV)}function ofe(t,e){let n=[lfe],r;return t instanceof lw&&(t.module&&n.push(_e.styleModule.of(t.module)),r=t.themeType),e?.fallback?n.push(JV.of(t)):r?n.push(EA.computeN([_e.darkTheme],i=>i.facet(_e.darkTheme)==(r=="dark")?[t]:[])):n.push(EA.of(t)),n}class afe{constructor(e){this.markCache=Object.create(null),this.tree=br(e.state),this.decorations=this.buildDeco(e,V_(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=br(e.state),r=V_(e.state),i=r!=V_(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)khe(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 lfe=$c.high(yn.fromClass(afe,{decorations:t=>t.decorations})),cfe=lw.define([{tag:xe.meta,color:"#404740"},{tag:xe.link,textDecoration:"underline"},{tag:xe.heading,textDecoration:"underline",fontWeight:"bold"},{tag:xe.emphasis,fontStyle:"italic"},{tag:xe.strong,fontWeight:"bold"},{tag:xe.strikethrough,textDecoration:"line-through"},{tag:xe.keyword,color:"#708"},{tag:[xe.atom,xe.bool,xe.url,xe.contentSeparator,xe.labelName],color:"#219"},{tag:[xe.literal,xe.inserted],color:"#164"},{tag:[xe.string,xe.deleted],color:"#a11"},{tag:[xe.regexp,xe.escape,xe.special(xe.string)],color:"#e40"},{tag:xe.definition(xe.variableName),color:"#00f"},{tag:xe.local(xe.variableName),color:"#30a"},{tag:[xe.typeName,xe.namespace],color:"#085"},{tag:xe.className,color:"#167"},{tag:[xe.special(xe.variableName),xe.macroName],color:"#256"},{tag:xe.definition(xe.propertyName),color:"#00c"},{tag:xe.comment,color:"#940"},{tag:xe.invalid,color:"#f00"}]),ufe=_e.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),QV=1e4,ZV="()[]{}",e7=Ce.define({combine(t){return xo(t,{afterCursor:!0,brackets:ZV,maxScanDistance:QV,renderMatch:dfe})}}),hfe=He.mark({class:"cm-matchingBracket"}),ffe=He.mark({class:"cm-nonmatchingBracket"});function dfe(t){let e=[],n=t.matched?hfe:ffe;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 pfe=Zn.define({create(){return He.none},update(t,e){if(!e.docChanged&&!e.selection)return t;let n=[],r=e.state.facet(e7);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)}),mfe=[pfe,ufe];function gfe(t={}){return[e7.of(t),mfe]}const yfe=new it;function kA(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 TA(t){let e=t.type.prop(yfe);return e?e(t.node):t}function so(t,e,n,r={}){let i=r.maxScanDistance||QV,s=r.brackets||ZV,o=br(t),a=o.resolveInner(e,n);for(let c=a;c;c=c.parent){let h=kA(c.type,n,s);if(h&&c.from<c.to){let f=TA(c);if(f&&(n>0?e>=f.from&&e<f.to:e>f.from&&e<=f.to))return bfe(t,e,n,c,f,h,s)}}return vfe(t,e,n,o,a.type,i,s)}function bfe(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=TA(f);return{start:c,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(kA(f.type,n,o))h++;else if(kA(f.type,-n,o)){if(h==0){let d=TA(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 vfe(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 x=n>0?0:y.length-1,S=n>0?y.length:-1;x!=S;x+=n){let _=o.indexOf(y[x]);if(!(_<0||r.resolveInner(b+x,1).type!=i))if(_%2==0==n>0)d++;else{if(d==1)return{start:h,end:{from:b+x,to:b+x+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),wfe=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"]])wfe[t]=Sfe(xfe,e);function U_(t,e){i3.indexOf(t)>-1||(i3.push(t),console.warn(e))}function Sfe(t,e){let n=[];for(let a of e.split(" ")){let c=[];for(let h of a.split(".")){let f=t[h]||xe[h];f?typeof f=="function"?c.length?c=c.map(f):U_(h,`Modifier ${h} used at start of tag`):c.length?U_(h,`Tag ${h} used as modifier`):c=Array.isArray(f)?f:[f]:U_(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:[$V({[r]:n})]});return r3.push(o),o.id}jt.RTL,jt.LTR;const _fe=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=wT(t.state,n.from);return r.line?Cfe(t):r.block?Efe(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 Cfe=xT(Rfe,0),Afe=xT(t7,0),Efe=xT((t,e)=>t7(t,e,Tfe(e)),0);function wT(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Ld=50;function kfe(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 Tfe(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 t7(t,e,n=e.selection.ranges){let r=n.map(s=>wT(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>kfe(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 Rfe(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=wT(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 RA=sa.define(),Mfe=sa.define(),Ofe=Ce.define(),n7=Ce.define({combine(t){return xo(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)})}}),r7=Zn.define({create(){return oo.empty},update(t,e){let n=e.state.facet(n7),r=e.annotation(RA);if(r){let c=Yr.fromTransaction(e,r.selection),h=r.side,f=h==0?t.undone:t.done;return c?f=Nv(f,f.length,n.minDepth,c):f=o7(f,e.startState.selection),new oo(h==0?r.rest:f,h==0?f:r.rest)}let i=e.annotation(Mfe);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 Pfe(t={}){return[r7,n7.of(t),_e.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?i7:e.inputType=="historyRedo"?MA:null;return r?(e.preventDefault(),r(n)):!1}})]}function cw(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(r7,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const i7=cw(0,!1),MA=cw(1,!1),Dfe=cw(0,!0),Ife=cw(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(Ofe)){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 Nv(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 Lfe(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 Nfe(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function s7(t,e){return t.length?e.length?t.concat(e):t:e}const Yi=[],$fe=200;function o7(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-$fe));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Nv(t,t.length-1,1e9,n.setSelAfter(r)))}else return[Yr.selection([e])]}function jfe(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 H_(t,e){if(!t.length)return t;let n=t.length,r=Yi;for(;n;){let i=Bfe(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 Bfe(t,e,n){let r=s7(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 Ffe=/^(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||Ffe.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(s,Lfe(a.changes,e.changes))||r=="input.type.compose")?o=Nv(o,o.length-1,i.minDepth,new Yr(e.changes.compose(a.changes),s7(Ze.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,Yi)):o=Nv(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)&&Nfe(s[s.length-1],e)?this:new oo(o7(this.done,e),this.undone,n,r)}addMapping(e){return new oo(H_(this.done,e),H_(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:RA.of({side:e,rest:jfe(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=H_(a,s.mapped)),n.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:RA.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 zfe=[{key:"Mod-z",run:i7,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:MA,preventDefault:!0},{linux:"Ctrl-Shift-z",run:MA,preventDefault:!0},{key:"Mod-u",run:Dfe,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Ife,preventDefault:!0}];function Zh(t,e){return fe.create(t.ranges.map(e),t.mainIndex)}function wo(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(wo(t,r)),!0)}function uw(t,e){return fe.cursor(e?t.to:t.from)}function a7(t,e){return Os(t,n=>n.empty?t.moveByChar(n,e):uw(n,e))}function vr(t){return t.textDirectionAt(t.state.selection.main.head)==jt.LTR}const l7=t=>a7(t,!vr(t)),c7=t=>a7(t,vr(t));function u7(t,e){return Os(t,n=>n.empty?t.moveByGroup(n,e):uw(n,e))}const Vfe=t=>u7(t,!vr(t)),Ufe=t=>u7(t,vr(t));function Hfe(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 hw(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;Hfe(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 Wfe=t=>Os(t,e=>hw(t.state,e,!vr(t))),qfe=t=>Os(t,e=>hw(t.state,e,vr(t)));function h7(t,e){return Os(t,n=>{if(!n.empty)return uw(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const f7=t=>h7(t,!1),d7=t=>h7(t,!0);function p7(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 m7(t,e){let n=p7(t),{state:r}=t,i=Zh(r.selection,o=>o.empty?t.moveVertically(o,e,n.height):uw(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(wo(r,i),{effects:s}),!0}const o3=t=>m7(t,!1),OA=t=>m7(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 Gfe=t=>Os(t,e=>Cl(t,e,!0)),Kfe=t=>Os(t,e=>Cl(t,e,!1)),Yfe=t=>Os(t,e=>Cl(t,e,!vr(t))),Xfe=t=>Os(t,e=>Cl(t,e,vr(t))),Jfe=t=>Os(t,e=>fe.cursor(t.lineBlockAt(e.head).from,1)),Qfe=t=>Os(t,e=>fe.cursor(t.lineBlockAt(e.head).to,-1));function Zfe(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(wo(t,i)),!0):!1}const ede=({state:t,dispatch:e})=>Zfe(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(wo(t.state,n)),!0)}function g7(t,e){return is(t,n=>t.moveByChar(n,e))}const y7=t=>g7(t,!vr(t)),b7=t=>g7(t,vr(t));function v7(t,e){return is(t,n=>t.moveByGroup(n,e))}const tde=t=>v7(t,!vr(t)),nde=t=>v7(t,vr(t)),rde=t=>is(t,e=>hw(t.state,e,!vr(t))),ide=t=>is(t,e=>hw(t.state,e,vr(t)));function x7(t,e){return is(t,n=>t.moveVertically(n,e))}const w7=t=>x7(t,!1),S7=t=>x7(t,!0);function _7(t,e){return is(t,n=>t.moveVertically(n,e,p7(t).height))}const a3=t=>_7(t,!1),l3=t=>_7(t,!0),sde=t=>is(t,e=>Cl(t,e,!0)),ode=t=>is(t,e=>Cl(t,e,!1)),ade=t=>is(t,e=>Cl(t,e,!vr(t))),lde=t=>is(t,e=>Cl(t,e,vr(t))),cde=t=>is(t,e=>fe.cursor(t.lineBlockAt(e.head).from)),ude=t=>is(t,e=>fe.cursor(t.lineBlockAt(e.head).to)),c3=({state:t,dispatch:e})=>(e(wo(t,{anchor:0})),!0),u3=({state:t,dispatch:e})=>(e(wo(t,{anchor:t.doc.length})),!0),h3=({state:t,dispatch:e})=>(e(wo(t,{anchor:t.selection.main.anchor,head:0})),!0),f3=({state:t,dispatch:e})=>(e(wo(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),hde=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),fde=({state:t,dispatch:e})=>{let n=fw(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},dde=({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(wo(t,n)),!0)},pde=({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(wo(t,r)),!0):!1};function Jm(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=By(t,c,!1)):c>o&&(n="delete.forward",c=By(t,c,!0)),o=Math.min(o,c),a=Math.max(a,c)}else o=By(t,o,!1),a=By(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 By(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 C7=(t,e,n)=>Jm(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%Dv(s)||Dv(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}),PA=t=>C7(t,!1,!0),A7=t=>C7(t,!0,!1),E7=(t,e)=>Jm(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}),k7=t=>E7(t,!1),mde=t=>E7(t,!0),gde=t=>Jm(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),yde=t=>Jm(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),bde=t=>Jm(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),vde=({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 fw(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 T7(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of fw(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 wde=({state:t,dispatch:e})=>T7(t,e,!1),Sde=({state:t,dispatch:e})=>T7(t,e,!0);function R7(t,e,n){if(t.readOnly)return!1;let r=[];for(let i of fw(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 _de=({state:t,dispatch:e})=>R7(t,e,!1),Cde=({state:t,dispatch:e})=>R7(t,e,!0),Ade=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(fw(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 Ede(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=M7(!1),kde=M7(!0);function M7(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&&Ede(e,s);t&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let h=new ow(e,{simulateBreak:s,simulateDoubleBreak:!!c}),f=bT(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 ST(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 Tde=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new ow(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=ST(t,(s,o,a)=>{let c=bT(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},Rde=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(ST(t,(n,r)=>{r.push({from:n.from,insert:t.facet(yT)})}),{userEvent:"input.indent"})),!0),Mde=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(ST(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-Dv(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),Ode=t=>(t.setTabFocusMode(),!0),Pde=[{key:"Ctrl-b",run:l7,shift:y7,preventDefault:!0},{key:"Ctrl-f",run:c7,shift:b7},{key:"Ctrl-p",run:f7,shift:w7},{key:"Ctrl-n",run:d7,shift:S7},{key:"Ctrl-a",run:Jfe,shift:cde},{key:"Ctrl-e",run:Qfe,shift:ude},{key:"Ctrl-d",run:A7},{key:"Ctrl-h",run:PA},{key:"Ctrl-k",run:gde},{key:"Ctrl-Alt-h",run:k7},{key:"Ctrl-o",run:vde},{key:"Ctrl-t",run:xde},{key:"Ctrl-v",run:OA}],Dde=[{key:"ArrowLeft",run:l7,shift:y7,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Vfe,shift:tde,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Yfe,shift:ade,preventDefault:!0},{key:"ArrowRight",run:c7,shift:b7,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Ufe,shift:nde,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Xfe,shift:lde,preventDefault:!0},{key:"ArrowUp",run:f7,shift:w7,preventDefault:!0},{mac:"Cmd-ArrowUp",run:c3,shift:h3},{mac:"Ctrl-ArrowUp",run:o3,shift:a3},{key:"ArrowDown",run:d7,shift:S7,preventDefault:!0},{mac:"Cmd-ArrowDown",run:u3,shift:f3},{mac:"Ctrl-ArrowDown",run:OA,shift:l3},{key:"PageUp",run:o3,shift:a3},{key:"PageDown",run:OA,shift:l3},{key:"Home",run:Kfe,shift:ode,preventDefault:!0},{key:"Mod-Home",run:c3,shift:h3},{key:"End",run:Gfe,shift:sde,preventDefault:!0},{key:"Mod-End",run:u3,shift:f3},{key:"Enter",run:d3,shift:d3},{key:"Mod-a",run:hde},{key:"Backspace",run:PA,shift:PA},{key:"Delete",run:A7},{key:"Mod-Backspace",mac:"Alt-Backspace",run:k7},{key:"Mod-Delete",mac:"Alt-Delete",run:mde},{mac:"Mod-Backspace",run:yde},{mac:"Mod-Delete",run:bde}].concat(Pde.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Ide=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Wfe,shift:rde},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:qfe,shift:ide},{key:"Alt-ArrowUp",run:wde},{key:"Shift-Alt-ArrowUp",run:_de},{key:"Alt-ArrowDown",run:Sde},{key:"Shift-Alt-ArrowDown",run:Cde},{key:"Escape",run:pde},{key:"Mod-Enter",run:kde},{key:"Alt-l",mac:"Ctrl-l",run:fde},{key:"Mod-i",run:dde,preventDefault:!0},{key:"Mod-[",run:Mde},{key:"Mod-]",run:Rde},{key:"Mod-Alt-\\",run:Tde},{key:"Shift-Mod-k",run:Ade},{key:"Shift-Mod-\\",run:ede},{key:"Mod-/",run:_fe},{key:"Alt-A",run:Afe},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Ode}].concat(Dde),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=Jk(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 O7={from:-1,to:-1,match:/.*/.exec("")},_T="gm"+(/x/.unicode==null?"":"u");class P7{constructor(e,n,r,i=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=O7,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new D7(e,n,r,i,s);this.re=new RegExp(n,_T+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=e.iter();let o=e.lineAt(i);this.curLineStart=o.from,this.matchPos=$v(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=$v(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 W_=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=W_.get(e);if(!i||i.from>=r||i.to<=n){let a=new Sh(n,e.sliceString(n,r));return W_.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)),W_.set(e,new Sh(o,s)),new Sh(n,s.slice(n-o,r-o))}}class D7{constructor(e,n,r,i,s){this.text=e,this.to=s,this.done=!1,this.value=O7,this.matchPos=$v(e,i),this.re=new RegExp(n,_T+(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=$v(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"&&(P7.prototype[Symbol.iterator]=D7.prototype[Symbol.iterator]=function(){return this});function Lde(t){try{return new RegExp(t,_T),!0}catch{return!1}}function $v(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 DA(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))),x=fe.cursor(b.from+Math.max(0,Math.min(m,b.length)));t.dispatch({effects:[Mp.of(!1),_e.scrollIntoView(x.from,{y:"center"})],selection:x}),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?DA:null)}),Nde=t=>{let e=um(t,DA);if(!e){let n=[Mp.of(!0)];t.state.field(m3,!1)==null&&n.push(Ze.appendConfig.of([m3,$de])),t.dispatch({effects:n}),e=um(t,DA)}return e&&e.dom.querySelector("input").select(),!0},$de=_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"}}}),jde={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Bde=Ce.define({combine(t){return xo(t,jde,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function Fde(t){return[Wde,Hde]}const zde=He.mark({class:"cm-selectionMatch"}),Vde=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 Ude(t,e,n,r){return t(e.sliceDoc(n,n+1))==Vt.Word&&t(e.sliceDoc(r-1,r))==Vt.Word}const Hde=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(Bde),{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)&&Ude(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(Vde.range(f,d)):(f>=i.to||d<=i.from)&&a.push(zde.range(f,d)),a.length>e.maxMatches))return He.none}}return He.set(a)}},{decorations:t=>t.decorations}),Wde=_e.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),qde=({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 Gde(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 Kde=({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(s=>s.from===s.to))return qde({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=Gde(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 xo(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ope(e),scrollToMatch:e=>_e.scrollIntoView(e)})}});class I7{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||Lde(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 Qde(this):new Xde(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 L7{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?Yde(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function Yde(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(jv(i,n-s))!=Vt.Word||e(Bv(i,n-s))!=Vt.Word)&&(e(Bv(i,r-s))!=Vt.Word||e(jv(i,r-s))!=Vt.Word))}class Xde extends L7{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 P7(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?Jde(e.charCategorizer(e.selection.main.head)):void 0},n,r)}function jv(t,e){return t.slice(Xn(t,e,!1),e)}function Bv(t,e){return t.slice(e,Xn(t,e))}function Jde(t){return(e,n,r)=>!r[0].length||(t(jv(r.input,r.index))!=Vt.Word||t(Bv(r.input,r.index))!=Vt.Word)&&(t(Bv(r.input,r.index+r[0].length))!=Vt.Word||t(jv(r.input,r.index+r[0].length))!=Vt.Word)}class Qde extends L7{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(),CT=Ze.define(),ll=Zn.define({create(t){return new q_(IA(t).create(),null)},update(t,e){for(let n of e.effects)n.is(pm)?t=new q_(n.value.create(),t.panel):n.is(CT)&&(t=new q_(t.query,n.value?AT:null));return t},provide:t=>hm.from(t,e=>e.panel)});class q_{constructor(e,n){this.query=e,this.panel=n}}const Zde=He.mark({class:"cm-searchMatch"}),epe=He.mark({class:"cm-searchMatch cm-searchMatch-selected"}),tpe=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?epe:Zde)})}return r.finish()}},{decorations:t=>t.decorations});function Qm(t){return e=>{let n=e.state.field(ll,!1);return n&&n.query.spec.valid?t(e,n):j7(e)}}const Fv=Qm((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:[ET(t,r),s.scrollToMatch(i.main,t)],userEvent:"select.search"}),$7(t),!0}),zv=Qm((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:[ET(t,i),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),$7(t),!0}),npe=Qm((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)}),rpe=({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=Qm((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(ET(t,o)),f.push(n.facet(ef).scrollToMatch(c.main,t))),t.dispatch({changes:d,selection:c,effects:f,userEvent:"input.replace"}),!0}),ipe=Qm((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 AT(t){return t.state.facet(ef).createPanel(t)}function IA(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 I7({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 N7(t){let e=um(t,AT);return e&&e.dom.querySelector("[main-field]")}function $7(t){let e=N7(t);e&&e==t.root.activeElement&&e.select()}const j7=t=>{let e=t.state.field(ll,!1);if(e&&e.panel){let n=N7(t);if(n&&n!=t.root.activeElement){let r=IA(t.state,e.query.spec);r.valid&&t.dispatch({effects:pm.of(r)}),n.focus(),n.select()}}else t.dispatch({effects:[CT.of(!0),e?pm.of(IA(t.state,e.query.spec)):Ze.appendConfig.of(lpe)]});return!0},B7=t=>{let e=t.state.field(ll,!1);if(!e||!e.panel)return!1;let n=um(t,AT);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:CT.of(!1)}),!0},spe=[{key:"Mod-f",run:j7,scope:"editor search-panel"},{key:"F3",run:Fv,shift:zv,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Fv,shift:zv,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:B7,scope:"editor search-panel"},{key:"Mod-Shift-l",run:rpe},{key:"Mod-Alt-g",run:Nde},{key:"Mod-d",run:Kde,preventDefault:!0}];class ope{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",()=>Fv(e),[di(e,"next")]),r("prev",()=>zv(e),[di(e,"previous")]),r("select",()=>npe(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",()=>ipe(e),[di(e,"replace all")])],kt("button",{name:"close",onclick:()=>B7(e),"aria-label":di(e,"close"),type:"button"},["×"])])}commit(){let e=new I7({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){pue(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?zv:Fv)(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 Fy=30,zy=/[\s\.,:;?!]/;function ET(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-Fy),o=Math.min(i,n+Fy),a=t.state.sliceDoc(s,o);if(s!=r.from){for(let c=0;c<Fy;c++)if(!zy.test(a[c+1])&&zy.test(a[c])){a=a.slice(c);break}}if(o!=i){for(let c=a.length-1;c>a.length-Fy;c--)if(!zy.test(a[c-1])&&zy.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 ape=_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"}}),lpe=[ll,$c.low(tpe),ape];class F7{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(z7(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 cpe(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 upe(t){let e=t.map(i=>typeof i=="string"?{label:i}:i),[n,r]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:cpe(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 z7(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 V7=sa.define();function hpe(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 x3=new WeakMap;function fpe(t){if(!Array.isArray(t))return t;let e=x3.get(t);return e||x3.set(t,e=upe(t)),e}const Vv=Ze.define(),mm=Ze.define();class dpe{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,x=-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),x=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=Jk(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+(x==e.length?0:-100),[0,x]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):y==c?this.ret(-900-e.length,[b,x]):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 ppe{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 xo(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:mpe,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=>w3(e(r),n(r)),optionClass:(e,n)=>r=>w3(e(r),n(r)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function w3(t,e){return t?e?t+" "+e:t:e}function mpe(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,x=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-x))-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>=x||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 gpe(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 G_(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 ype{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=gpe(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=G_(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=G_(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=G_(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&&vpe(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 bpe(t,e){return n=>new ype(n,t,e)}function vpe(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 ppe(d):new dpe(d);for(let b of h.result.options)if(m=y.match(b.label)){let x=b.displayLabel?f?f(b,m.matched):[]:m.matched;i(new v3(b,h.source,x,m.score+(b.boost||0)))}}}if(r){let h=Object.create(null),f=0,d=(m,y)=>{var b,x;return((b=m.rank)!==null&&b!==void 0?b:1e9)-((x=y.rank)!==null&&x!==void 0?x: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:Epe,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 Uv{constructor(e,n,r){this.active=e,this.id=n,this.open=r}static start(){return new Uv(Cpe,"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(fpe)).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(kT));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(c=>c.hasResult()&&e.changes.touchesRange(c.from,c.to))||!wpe(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(H7)&&(o=o&&o.setSelected(c.value,this.id));return s==this.active&&o==this.open?this:new Uv(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Spe:_pe}}function wpe(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 Spe={"aria-autocomplete":"list"},_pe={};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 Cpe=[];function U7(t,e){if(t.isUserEvent("input.complete")){let r=t.annotation(V7);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=U7(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(Vv))i=new Xi(i.source,1,s.value);else if(s.is(mm))i=new Xi(i.source,0);else if(s.is(kT))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 Ape(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 F7(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 Ape(t,e,n,r){if(!t)return!1;let i=e.sliceDoc(n,r);return typeof t=="function"?t(i,n,r,e):z7(t,!0).test(i)}const kT=Ze.define({map(t,e){return t.map(n=>n.map(e))}}),H7=Ze.define(),Gr=Zn.define({create(){return Uv.start()},update(t,e){return t.update(e)},provide:t=>[fT.from(t,e=>e.tooltip),_e.contentAttributes.from(t,e=>e.attrs)]});function TT(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({...hpe(t.state,n,r.from,r.to),annotations:V7.of(e.completion)}):n(t,e.completion,r.from,r.to),!0):!1}const Epe=bpe(Gr,TT);function Vy(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=TV(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:H7.of(a)}),!0}}const kpe=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:TT(t,e.open.options[e.open.selected])},K_=t=>t.state.field(Gr,!1)?(t.dispatch({effects:Vv.of(!0)}),!0):!1,Tpe=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 Rpe{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Mpe=50,Ope=1e3,Ppe=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=U7(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>Mpe&&Date.now()-o.time>Ope){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(Vv)))&&(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 F7(e,n,t.explicit,this.view),i=new Rpe(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:kT.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&&TV(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:Vv.of(!1)}),20),this.composing=0}}}),Dpe=typeof navigator=="object"&&/Win/.test(navigator.platform),Ipe=$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&&!(Dpe&&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&&TT(e,r),!1}})),Lpe=_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}}),RT=new class extends Ec{};RT.startSide=1;RT.endSide=-1;const W7=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:[RT.range(n.value,n.value+1)]}));return t}});function Npe(){return[jpe,W7]}const Y_="()[]{}<>«»»«[]{}";function q7(t){for(let e=0;e<Y_.length;e+=2)if(Y_.charCodeAt(e)==t)return Y_.charAt(e+1);return Jk(t<128?t:t+1)}function G7(t,e){return t.languageDataAt("closeBrackets",e)[0]||gm}const $pe=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),jpe=_e.inputHandler.of((t,e,n,r)=>{if(($pe?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=zpe(t.state,r);return s?(t.dispatch(s),!0):!1}),Bpe=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=G7(t,t.selection.main.head).brackets||gm.brackets,i=null,s=t.changeByRange(o=>{if(o.empty){let a=Vpe(t.doc,o.head);for(let c of r)if(c==a&&dw(t.doc,o.head)==q7(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},Fpe=[{key:"Backspace",run:Bpe}];function zpe(t,e){let n=G7(t,t.selection.main.head),r=n.brackets||gm.brackets;for(let i of r){let s=q7(Wr(i,0));if(e==i)return s==i?Wpe(t,i,r.indexOf(i+i+i)>-1,n):Upe(t,i,s,n.before||gm.before);if(e==s&&K7(t,t.selection.main.from))return Hpe(t,i,s)}return null}function K7(t,e){let n=!1;return t.field(W7).between(0,t.doc.length,r=>{r==e&&(n=!0)}),n}function dw(t,e){let n=t.sliceString(e,e+2);return n.slice(0,to(Wr(n,0)))}function Vpe(t,e){let n=t.sliceString(e-2,e);return to(Wr(n,0))==n.length?n:n.slice(1)}function Upe(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=dw(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 Hpe(t,e,n){let r=null,i=t.changeByRange(s=>s.empty&&dw(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 Wpe(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=dw(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(K7(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&&!qpe(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 qpe(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 Gpe(t={}){return[Ipe,Gr,jn.of(t),Ppe,Kpe,Lpe]}const Y7=[{key:"Ctrl-Space",run:K_},{mac:"Alt-`",run:K_},{mac:"Alt-i",run:K_},{key:"Escape",run:Tpe},{key:"ArrowDown",run:Vy(!0)},{key:"ArrowUp",run:Vy(!1)},{key:"PageDown",run:Vy(!0,"page")},{key:"PageUp",run:Vy(!1,"page")},{key:"Enter",run:kpe}],Kpe=$c.highest(uT.computeN([jn],t=>t.facet(jn).defaultKeymap?[Y7]:[]));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((x,S)=>Math.min(x,S.to),d&&d.from>m?d.from:1e8)):(m=d.from,y=d.to,a.push(d),f++);f<s.length;){let x=s[f];if(x.from==m&&(x.to>x.from||x.to==m))a.push(x),f++,y=Math.min(x.to,y);else{y=Math.min(x.from,y);break}}let b=ame(a);if(a.some(x=>x.from==x.to||x.from==x.to-1&&r.doc.lineAt(x.from).to==x.from))o.add(m,m,He.widget({widget:new rme(b),diagnostics:a.slice()}));else{let x=a.reduce((S,_)=>_.markClass?S+" "+_.markClass:S,"");o.add(m,y,He.mark({class:"cm-lintRange cm-lintRange-"+b+x,diagnostics:a.slice(),inclusiveEnd:a.some(S=>S.to>y)}))}c=y;for(let x=0;x<a.length;x++)a[x].to<=c&&a.splice(x--,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 Ype(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(X7))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function Xpe(t,e){return t.field(Ai,!1)?e:e.concat(Ze.appendConfig.of(lme))}const X7=Ze.define(),MT=Ze.define(),J7=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(X7)){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(MT)?t=new ac(t.diagnostics,n.value?bm.open:null,t.selected):n.is(J7)&&(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)]}),Jpe=He.mark({class:"cm-lintRange cm-lintRange-active"});function Qpe(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:Zpe(t,i)}}}:null}function Zpe(t,e){return kt("ul",{class:"cm-tooltip-lint"},e.map(n=>Z7(t,n,!1)))}const eme=t=>{let e=t.state.field(Ai,!1);(!e||!e.panel)&&t.dispatch({effects:Xpe(t.state,[MT.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:MT.of(!1)}),!0)},tme=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)},nme=[{key:"Mod-Shift-m",run:eme,preventDefault:!0},{key:"F8",run:tme}],ym=Ce.define({combine(t){return Object.assign({sources:t.map(e=>e.source).filter(e=>e!=null)},xo(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 Q7(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 Z7(t,e,n){var r;let i=n?Q7(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 rme 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=Z7(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=Q7(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:J7.of(r)})}static open(e){return new bm(e)}}function ime(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 Uy(t){return ime(`<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 sme=_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:Uy("#d11")},".cm-lintRange-warning":{backgroundImage:Uy("orange")},".cm-lintRange-info":{backgroundImage:Uy("#999")},".cm-lintRange-hint":{backgroundImage:Uy("#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 ome(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function ame(t){let e="hint",n=1;for(let r of t){let i=ome(r.severity);i>n&&(n=i,e=r.severity)}return e}const lme=[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([Jpe.range(e.from,e.to)])}),ehe(Qpe,{hideOn:Ype}),sme],cme=[hhe(),phe(),Oue(),Pfe(),ife(),xue(),Aue(),ht.allowMultipleSelections.of(!0),Hhe(),ofe(cfe,{fallback:!0}),gfe(),Npe(),Gpe(),Uue(),que(),$ue(),Fde(),uT.of([...Fpe,...Ide,...spe,...zfe,...efe,...Y7,...nme])];var R3={};class Hv{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 Hv(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 Hv(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 ume(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 ume{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 Wv{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 Wv(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 Wv(this.stack,this.pos,this.index)}}function Hy(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 Bb{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 Bb;class hme{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;fme(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 fme(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||dme(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),x=t[b],S=t[b+1]||65536;if(f<x)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 dme(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 X_=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 pme{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 mme{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new Bb)}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 Bb,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 Bb,{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 gme{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 hme(n,i),this.tokens=new mme(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[Hv.start(this,e.top[0],s)],this.fragments=r.length&&this.stream.end-s>e.bufferLength*4?new pme(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&&bme(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(),x=this.tokens.mainToken;if(b.apply(f,d,x?x.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:Wv.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=(X_||(X_=new WeakMap)).get(e);return n||X_.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 yme{constructor(e,n,r){this.source=e,this.flags=n,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class qv extends NV{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 dT(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=PV;let o=Hy(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=Hy(e.states,Uint32Array),this.data=Hy(e.stateData),this.goto=Hy(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 gme(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(qv.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 yme(e,r,i)}static deserialize(e){return new qv(e)}}function Ho(t,e){return t[e]|t[e+1]<<16}function bme(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 vme=$V({String:xe.string,Number:xe.number,"True False":xe.bool,PropertyName:xe.propertyName,Null:xe.null,", :":xe.separator,"[ ]":xe.squareBracket,"{ }":xe.brace}),xme=qv.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:[vme],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}),wme=Ov.define({name:"json",parser:xme.configure({props:[zV.add({Object:e3({except:/^\s*\}/}),Array:e3({except:/^\s*\]/})}),UV.add({"Object Array":qhe})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function Sme(){return new Ihe(wme)}const _me=({open:t,onClose:e})=>{const{t:n}=vt(),{saveConfig:r,getConfig:i}=Rs(),s=be.useRef(null),o=be.useRef(null),[a,c]=be.useState(""),[h,f]=be.useState(!0),d=m=>{try{return JSON.parse(m),f(!0),!0}catch{return f(!1),!1}};return be.useEffect(()=>{if(!t)return;const m=()=>{if(s.current&&!o.current){const y=JSON.stringify(i(),null,2);c(y),d(y);const b=ht.create({doc:y,extensions:[cme,Sme(),_e.updateListener.of(x=>{if(x.docChanged){const S=x.state.doc.toString();c(S),d(S)}}),_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:b,parent:s.current})}else setTimeout(m,100)};return setTimeout(m,50),()=>{o.current&&(o.current.destroy(),o.current=null)}},[t,i]),C.jsx(wl,{open:t,onOpenChange:()=>{},children:C.jsxs(Sl,{header:n("EditConfiguration"),onClose:e,className:"w-[564px] h-[400px]",children:[C.jsx("div",{className:"flex flex-col gap-[8px] h-[280px] pt-[8px] pb-[16px]",children:C.jsxs("div",{className:"flex flex-col gap-[8px] 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"})]})}),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:!h,onClick:()=>{r(JSON.parse(a)),e()},children:n("Save")})]})]})})},OT=({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"}),Cme="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",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.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",Eme=({type:t,open:e,onClose:n})=>{const{t:r}=vt(),[i,s]=be.useState([]),{getCustomServersLogs:o}=Rs();be.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(wl,{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")})]})]})})},kme=({name:t,onClose:e})=>{const{t:n}=vt(),{deleteCustomServer:r}=Rs(),i=()=>{r(t),e()};return C.jsx(wl,{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]=be.useState(!1),[c,h]=be.useState(!1),[f,d]=be.useState(!1),[m,y]=be.useState(!1),[b,x]=be.useState(!1),S=be.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);be.useEffect(()=>{n&&a(!1)},[n]),be.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:Wk,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:q9,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(OT,{}):C.jsx(Nc,{onOpenChange:h,trigger:C.jsx(gt,{iconName:Nk,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:Cme,size:20,disableHover:!0,isStroke:!0}),text:s("Restart"),onClick:()=>{Qt.restartCustomServer(t)}},{icon:C.jsx(gt,{iconName:Ame,size:20,disableHover:!0,isStroke:!0}),text:s("Logs"),onClick:P},{text:"",onClick:()=>{},isSeparator:!0},{icon:C.jsx(gt,{iconName:$k,size:20,disableHover:!0}),text:s("Delete"),onClick:()=>{x(!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(FF,{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(Eme,{type:t,open:f,onClose:()=>d(!1)}):null,b?C.jsx(kme,{name:t,onClose:()=>x(!1)}):null]})},Tme=()=>{const{t}=vt(),[e,n]=be.useState({}),{servers:r,tools:i,webSearchEnabled:s}=Rs(),[o,a]=be.useState(s?i.length-2:i.length);be.useEffect(()=>{a(s?i.length-2:i.length)},[i.length,s]),be.useEffect(()=>{n(Qt.getCustomServers());const h=setInterval(()=>{n(Qt.getCustomServers())},1e3);return()=>clearInterval(h)},[]);const c=s?i.length>=kb: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))]})]})},Rme=()=>{const{t}=vt(),[e,n]=be.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(Tme,{})]}),C.jsx(_me,{open:e,onClose:()=>n(!1)})]})},Mme=()=>{const{t}=vt(),[e,n]=be.useState(""),[r,i]=be.useState(""),[s,o]=be.useState(!1);be.useEffect(()=>{const h=Qt.getWebSearchData();h&&(n(h.provider),i(h.key),o(!0))},[]);const a=()=>{!e||!r||(Qt.setWebSearchData({provider:e,key:r}),o(!0))},c=()=>{n(""),i(""),o(!1),Qt.setWebSearchData(null)};return 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(Zx,{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")})]})]})})},Ome=()=>{const{t}=vt(),[e,n]=be.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(mle,{isActive:e===s}):C.jsx(ple,{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(Rme,{}),disabled:!r.length},{value:"web-search",label:t("WebSearch"),content:C.jsx(Mme,{}),disabled:!r.length}]})]})})})},eU=k.createContext({});function Pme(t){const e=k.useRef(null);return e.current===null&&(e.current=t()),e.current}const PT=typeof window<"u",Dme=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={},tU=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function nU(t){return typeof t=="object"&&t!==null}const rU=t=>/^0[^.\s]+$/u.test(t);function $T(t){let e;return()=>(e===void 0&&(e=t()),e)}const es=t=>t,Ime=(t,e)=>n=>e(t(n)),Zm=(...t)=>t.reduce(Ime),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 iU(t,e){return e?t*(1e3/e):0}const sU=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Lme=1e-7,Nme=12;function $me(t,e,n,r,i){let s,o,a=0;do o=e+(n-e)/2,s=sU(o,r,i)-t,s>0?n=o:e=o;while(Math.abs(s)>Lme&&++a<Nme);return o}function eg(t,e,n,r){if(t===e&&n===r)return es;const i=s=>$me(s,0,1,t,n);return s=>s===0||s===1?s:sU(i(s),e,r)}const oU=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,aU=t=>e=>1-t(1-e),lU=eg(.33,1.53,.69,.99),BT=aU(lU),cU=oU(BT),uU=t=>(t*=2)<1?.5*BT(t):.5*(2-Math.pow(2,-10*(t-1))),FT=t=>1-Math.sin(Math.acos(t)),hU=aU(FT),fU=oU(FT),jme=eg(.42,0,1,1),Bme=eg(0,0,.58,1),dU=eg(.42,0,.58,1),Fme=t=>Array.isArray(t)&&typeof t[0]!="number",pU=t=>Array.isArray(t)&&typeof t[0]=="number",zme={linear:es,easeIn:jme,easeInOut:dU,easeOut:Bme,circIn:FT,circInOut:fU,circOut:hU,backIn:BT,backInOut:cU,backOut:lU,anticipate:uU},Vme=t=>typeof t=="string",$3=t=>{if(pU(t)){NT(t.length===4);const[e,n,r,i]=t;return eg(e,n,r,i)}else if(Vme(t))return zme[t];return t},Wy=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Ume(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 Hme=40;function mU(t,e){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,o=Wy.reduce((E,P)=>(E[P]=Ume(s),E),{}),{setup:a,read:c,resolveKeyframes:h,preUpdate:f,update:d,preRender:m,render:y,postRender:b}=o,x=()=>{const E=ea.useManualTiming?i.timestamp:performance.now();n=!1,ea.useManualTiming||(i.delta=r?1e3/60:Math.max(Math.min(E-i.timestamp,Hme),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(x))},S=()=>{n=!0,r=!0,i.isProcessing||t(x)};return{schedule:Wy.reduce((E,P)=>{const O=o[P];return E[P]=(M,D=!1,N=!1)=>(n||S(),O.schedule(M,D,N)),E},{}),cancel:E=>{for(let P=0;P<Wy.length;P++)o[Wy[P]].cancel(E)},state:i,steps:o}}const{schedule:Ut,cancel:vl,state:Hn,steps:J_}=mU(typeof requestAnimationFrame<"u"?requestAnimationFrame:es,!0);let Fb;function Wme(){Fb=void 0}const Xr={now:()=>(Fb===void 0&&Xr.set(Hn.isProcessing||ea.useManualTiming?Hn.timestamp:performance.now()),Fb),set:t=>{Fb=t,queueMicrotask(Wme)}},gU=t=>e=>typeof e=="string"&&e.startsWith(t),zT=gU("--"),qme=gU("var(--"),VT=t=>qme(t)?Gme.test(t.split("/*")[0].trim()):!1,Gme=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,tf={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},xm={...tf,transform:t=>Zo(0,1,t)},qy={...tf,default:1},Op=t=>Math.round(t*1e5)/1e5,UT=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Kme(t){return t==null}const Yme=/^(?:#[\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"&&Yme.test(n)&&n.startsWith(t)||e&&!Kme(n)&&Object.prototype.hasOwnProperty.call(n,e)),yU=(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}},Xme=t=>Zo(0,255,t),Q_={...tf,transform:t=>Math.round(Xme(t))},dc={test:HT("rgb","red"),parse:yU("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+Q_.transform(t)+", "+Q_.transform(e)+", "+Q_.transform(n)+", "+Op(xm.transform(r))+")"};function Jme(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 LA={test:HT("#"),parse:Jme,transform:dc.transform},tg=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Ya=tg("deg"),po=tg("%"),qe=tg("px"),Qme=tg("vh"),Zme=tg("vw"),j3={...po,parse:t=>po.parse(t)/100,transform:t=>po.transform(t*100)},oh={test:HT("hsl","hue"),parse:yU("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(xm.transform(r))+")"},fn={test:t=>dc.test(t)||LA.test(t)||oh.test(t),parse:t=>dc.test(t)?dc.parse(t):oh.test(t)?oh.parse(t):LA.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)}},ege=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function tge(t){return isNaN(t)&&typeof t=="string"&&(t.match(UT)?.length||0)+(t.match(ege)?.length||0)>0}const bU="number",vU="color",nge="var",rge="var(",B3="${}",ige=/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 wm(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},i=[];let s=0;const a=e.replace(ige,c=>(fn.test(c)?(r.color.push(s),i.push(vU),n.push(fn.parse(c))):c.startsWith(rge)?(r.var.push(s),i.push(nge),n.push(c)):(r.number.push(s),i.push(bU),n.push(parseFloat(c))),++s,B3)).split(B3);return{values:n,split:a,indexes:r,types:i}}function xU(t){return wm(t).values}function wU(t){const{split:e,types:n}=wm(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===bU?s+=Op(i[o]):a===vU?s+=fn.transform(i[o]):s+=i[o]}return s}}const sge=t=>typeof t=="number"?0:fn.test(t)?fn.getAnimatableNone(t):t;function oge(t){const e=xU(t);return wU(t)(e.map(sge))}const xl={test:tge,parse:xU,createTransformer:wU,getAnimatableNone:oge};function Z_(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 age({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=Z_(c,a,t+1/3),s=Z_(c,a,t),o=Z_(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(o*255),alpha:r}}function Gv(t,e){return n=>n>0?e:t}const Gt=(t,e,n)=>t+(e-t)*n,e2=(t,e,n)=>{const r=t*t,i=n*(e*e-r)+r;return i<0?0:Math.sqrt(i)},lge=[LA,dc,oh],cge=t=>lge.find(e=>e.test(t));function F3(t){const e=cge(t);if(!e)return!1;let n=e.parse(t);return e===oh&&(n=age(n)),n}const z3=(t,e)=>{const n=F3(t),r=F3(e);if(!n||!r)return Gv(t,e);const i={...n};return s=>(i.red=e2(n.red,r.red,s),i.green=e2(n.green,r.green,s),i.blue=e2(n.blue,r.blue,s),i.alpha=Gt(n.alpha,r.alpha,s),dc.transform(i))},NA=new Set(["none","hidden"]);function uge(t,e){return NA.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function hge(t,e){return n=>Gt(t,e,n)}function WT(t){return typeof t=="number"?hge:typeof t=="string"?VT(t)?Gv:fn.test(t)?z3:pge:Array.isArray(t)?SU:typeof t=="object"?fn.test(t)?z3:fge:Gv}function SU(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 fge(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 dge(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 pge=(t,e)=>{const n=xl.createTransformer(e),r=wm(t),i=wm(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?NA.has(t)&&!i.values.length||NA.has(e)&&!r.values.length?uge(t,e):Zm(SU(dge(r,i),i.values),n):Gv(t,e)};function _U(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?Gt(t,e,n):WT(t)(t,e)}const mge=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()}},CU=(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)})`},Kv=2e4;function qT(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<Kv;)e+=n,r=t.next(e);return e>=Kv?1/0:e}function gge(t,e=100,n){const r=n({...t,keyframes:[0,e]}),i=Math.min(qT(r),Kv);return{type:"keyframes",ease:s=>r.next(i*s).value/e,duration:fo(i)}}const yge=5;function AU(t,e,n){const r=Math.max(e-yge,0);return iU(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},t2=.001;function bge({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=$A(h,o),b=Math.exp(-d);return t2-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),x=$A(Math.pow(h,2),o);return(-i(h)+t2>0?-1:1)*((m-y)*b)/x}):(i=h=>{const f=Math.exp(-h*t),d=(h-n)*t+1;return-t2+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 vge=12;function xge(t,e,n){let r=n;for(let i=1;i<vge;i++)r=r-t(r)/e(r);return r}function $A(t,e){return t*Math.sqrt(1-e*e)}const wge=["duration","bounce"],Sge=["stiffness","damping","mass"];function V3(t,e){return e.some(n=>t[n]!==void 0)}function _ge(t){let e={velocity:Zt.velocity,stiffness:Zt.stiffness,damping:Zt.damping,mass:Zt.mass,isResolvedFromDuration:!1,...t};if(!V3(t,Sge)&&V3(t,wge))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=bge(t);e={...e,...n,mass:Zt.mass},e.isResolvedFromDuration=!0}return e}function Yv(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}=_ge({...n,velocity:-fo(n.velocity||0)}),b=m||0,x=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(x<1){const O=$A(_,x);E=M=>{const D=Math.exp(-x*_*M);return o-D*((b+x*_*S)/O*Math.sin(O*M)+S*Math.cos(O*M))}}else if(x===1)E=O=>o-Math.exp(-_*O)*(S+(b+_*S)*O);else{const O=_*Math.sqrt(x*x-1);E=M=>{const D=Math.exp(-x*_*M),N=Math.min(O*M,300);return o-D*((b+x*_*S)*Math.sinh(N)+O*S*Math.cosh(N))/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;x<1&&(D=O===0?ho(b):AU(E,O,M));const N=Math.abs(D)<=r,H=Math.abs(o-M)<=i;a.done=N&&H}return a.value=a.done?o:M,a},toString:()=>{const O=Math.min(qT(P),Kv),M=CU(D=>P.next(O*D).value,O,30);return O+"ms "+M},toTransition:()=>{}};return P}Yv.applyToOptions=t=>{const e=gge(t,100,Yv);return t.ease=e.ease,t.duration=ho(e.duration),t.type="keyframes",t};function jA({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=N=>a!==void 0&&N<a||c!==void 0&&N>c,b=N=>a===void 0?c:c===void 0||Math.abs(a-N)<Math.abs(c-N)?a:c;let x=n*e;const S=d+x,_=o===void 0?S:o(S);_!==S&&(x=_-d);const A=N=>-x*Math.exp(-N/r),E=N=>_+A(N),P=N=>{const H=A(N),j=E(N);m.done=Math.abs(H)<=h,m.value=m.done?_:j};let O,M;const D=N=>{y(m.value)&&(O=N,M=Yv({keyframes:[m.value,b(m.value)],velocity:AU(E,N,m.value),damping:i,stiffness:s,restDelta:h,restSpeed:f}))};return D(0),{calculatedDuration:null,next:N=>{let H=!1;return!M&&O===void 0&&(H=!0,P(N),D(N)),O!==void 0&&N>=O?M.next(N-O):(!H&&P(N),m)}}}function Cge(t,e,n){const r=[],i=n||ea.mix||_U,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=Zm(c,a)}r.push(a)}return r}function Age(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=Cge(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 Ege(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 kge(t){const e=[0];return Ege(e,t.length-1),e}function Tge(t,e){return t.map(n=>n*e)}function Rge(t,e){return t.map(()=>e||dU).splice(0,t.length-1)}function Pp({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const i=Fme(r)?r.map($3):$3(r),s={done:!1,value:e[0]},o=Tge(n&&n.length===e.length?n:kge(e),t),a=Age(o,e,{ease:Array.isArray(i)?i:Rge(e,i)});return{calculatedDuration:t,next:c=>(s.value=a(c),s.done=c>=t,s)}}const Mge=t=>t!==null;function GT(t,{repeat:e,repeatType:n="loop"},r,i=1){const s=t.filter(Mge),a=i<0||e&&n!=="loop"&&e%2===1?0:s.length-1;return!a||r===void 0?s[a]:r}const Oge={decay:jA,inertia:jA,tween:Pp,keyframes:Pp,spring:Yv};function EU(t){typeof t.type=="string"&&(t.type=Oge[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 Pge=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;EU(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=Zm(Pge,_U(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:x,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 N=Math.min(this.currentTime,i)/a;let H=Math.floor(N),j=N%1;!j&&N>=1&&(j=1),j===1&&H--,H=Math.min(H,d+1),!!(H%2)&&(m==="reverse"?(j=1-j,y&&(j-=y/a)):m==="mirror"&&(P=o)),E=Zo(0,1,j)*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!==jA&&(O.value=GT(f,this.options,S,this.speed)),x&&x(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=mge,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 Dge(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const pc=t=>t*180/Math.PI,BA=t=>{const e=pc(Math.atan2(t[1],t[0]));return FA(e)},Ige={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:BA,rotateZ:BA,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},FA=t=>(t=t%360,t<0&&(t+=360),t),U3=BA,H3=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),W3=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Lge={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=>FA(pc(Math.atan2(t[6],t[5]))),rotateY:t=>FA(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 zA(t){return t.includes("scale")?1:0}function VA(t,e){if(!t||t==="none")return zA(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=Lge,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Ige,i=a}if(!i)return zA(e);const s=r[e],o=i[1].split(",").map($ge);return typeof s=="function"?s(o):o[s]}const Nge=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return VA(n,e)};function $ge(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,jge=new Set(["x","y","z"]),Bge=nf.filter(t=>!jge.has(t));function Fge(t){const e=[];return Bge.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})=>VA(e,"x"),y:(t,{transform:e})=>VA(e,"y")};vc.translateX=vc.x;vc.translateY=vc.y;const xc=new Set;let UA=!1,HA=!1,WA=!1;function kU(){if(HA){const t=Array.from(xc).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),n=new Map;e.forEach(r=>{const i=Fge(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)})}HA=!1,UA=!1,xc.forEach(t=>t.complete(WA)),xc.clear()}function TU(){xc.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(HA=!0)})}function zge(){WA=!0,TU(),kU(),WA=!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?(xc.add(this),UA||(UA=!0,Ut.read(TU),Ut.resolveKeyframes(kU))):(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])}Dge(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),xc.delete(this)}cancel(){this.state==="scheduled"&&(xc.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Vge=t=>t.startsWith("--");function Uge(t,e,n){Vge(e)?t.style.setProperty(e,n):t.style[e]=n}const Hge=$T(()=>window.ScrollTimeline!==void 0),Wge={};function qge(t,e){const n=$T(t);return()=>Wge[e]??n()}const RU=qge(()=>{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 MU(t,e){if(t)return typeof t=="function"?RU()?CU(t,e):"ease-out":pU(t)?pp(t):Array.isArray(t)?t.map(n=>MU(n,e)||G3.easeOut):G3[t]}function Gge(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=MU(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 OU(t){return typeof t=="function"&&"applyToOptions"in t}function Kge({type:t,...e}){return OU(t)&&RU()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Yge 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=Kge(e);this.animation=Gge(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):Uge(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&&Hge()?(this.animation.timeline=e,es):n(this)}}const PU={anticipate:uU,backInOut:cU,circInOut:fU};function Xge(t){return t in PU}function Jge(t){typeof t.ease=="string"&&Xge(t.ease)&&(t.ease=PU[t.ease])}const K3=10;class Qge extends Yge{constructor(e){Jge(e),EU(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"&&(xl.test(t)||t==="0")&&!t.startsWith("url("));function Zge(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 e0e(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:Zge(t)||(n==="spring"||OU(n))&&r}function qA(t){t.duration=0,t.type}const t0e=new Set(["opacity","clipPath","filter","transform"]),n0e=$T(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function r0e(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 n0e()&&n&&t0e.has(n)&&(n!=="transform"||!h)&&!c&&!r&&i!=="mirror"&&s!==0&&o!=="inertia"}const i0e=40;class s0e 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,x,S)=>this.onKeyframesResolved(b,x,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(),e0e(e,s,o,a)||((ea.instantAnimations||!c)&&f?.(GT(e,r,n)),e[0]=e[e.length-1],qA(r),r.repeat=0);const m={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>i0e?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:e},y=!h&&r0e(m)?new Qge({...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(),zge()),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 o0e=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function a0e(t){const e=o0e.exec(t);if(!e)return[,];const[,n,r,i]=e;return[`--${n??r}`,i]}function DU(t,e,n=1){const[r,i]=a0e(t);if(!r)return;const s=window.getComputedStyle(e).getPropertyValue(r);if(s){const o=s.trim();return tU(o)?parseFloat(o):o}return VT(i)?DU(i,e,n+1):i}function JT(t,e){return t?.[e]??t?.default??t}const IU=new Set(["width","height","top","left","right","bottom",...nf]),l0e={test:t=>t==="auto",parse:t=>t},LU=t=>e=>e.test(t),NU=[tf,qe,po,Ya,Zme,Qme,l0e],X3=t=>NU.find(LU(t));function c0e(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||rU(t):!0}const u0e=new Set(["brightness","contrast","saturate","opacity"]);function h0e(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=u0e.has(e)?1:0;return r!==n&&(s*=100),e+"("+s+i+")"}const f0e=/\b([a-z-]*)\(.*?\)/gu,GA={...xl,getAnimatableNone:t=>{const e=t.match(f0e);return e?e.map(h0e).join(" "):t}},J3={...tf,transform:Math.round},d0e={rotate:Ya,rotateX:Ya,rotateY:Ya,rotateZ:Ya,scale:qy,scaleX:qy,scaleY:qy,scaleZ:qy,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:xm,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,...d0e,zIndex:J3,fillOpacity:xm,strokeOpacity:xm,numOctaves:J3},p0e={...QT,color:fn,backgroundColor:fn,outlineColor:fn,fill:fn,stroke:fn,borderColor:fn,borderTopColor:fn,borderRightColor:fn,borderBottomColor:fn,borderLeftColor:fn,filter:GA,WebkitFilter:GA},$U=t=>p0e[t];function jU(t,e){let n=$U(t);return n!==GA&&(n=xl),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const m0e=new Set(["auto","none","0"]);function g0e(t,e,n){let r=0,i;for(;r<t.length&&!i;){const s=t[r];typeof s=="string"&&!m0e.has(s)&&wm(s).values.length&&(i=t[r]),r++}if(i&&n)for(const s of e)t[s]=jU(n,i)}class y0e 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=DU(h,n.current);f!==void 0&&(e[c]=f),c===e.length-1&&(this.finalKeyframe=h)}}if(this.resolveNoneKeyframes(),!IU.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||c0e(e[i]))&&r.push(i);r.length&&g0e(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 b0e(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 BU=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function v0e(t){return nU(t)&&"offsetHeight"in t}const Q3=30,x0e=t=>!isNaN(parseFloat(t));class w0e{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 iU(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 w0e(t,e)}const{schedule:ZT}=mU(queueMicrotask,!1),ps={x:!1,y:!1};function FU(){return ps.x||ps.y}function S0e(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 zU(t,e){const n=b0e(t),r=new AbortController,i={passive:!0,...e,signal:r.signal};return[n,i,()=>r.abort()]}function Z3(t){return!(t.pointerType==="touch"||FU())}function _0e(t,e,n={}){const[r,i,s]=zU(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 VU=(t,e)=>e?t===e?!0:VU(t,e.parentElement):!1,eR=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,C0e=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function A0e(t){return C0e.has(t.tagName)||t.tabIndex!==-1}const zb=new WeakSet;function e4(t){return e=>{e.key==="Enter"&&t(e)}}function n2(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const E0e=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=e4(()=>{if(zb.has(n))return;n2(n,"down");const i=e4(()=>{n2(n,"up")}),s=()=>n2(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)&&!FU()}function k0e(t,e,n={}){const[r,i,s]=zU(t,n),o=a=>{const c=a.currentTarget;if(!t4(a))return;zb.add(c);const h=e(c,a),f=(y,b)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",m),zb.has(c)&&zb.delete(c),t4(y)&&typeof h=="function"&&h(y,{success:b})},d=y=>{f(y,c===window||c===document||n.useGlobalTarget||VU(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),v0e(a)&&(a.addEventListener("focus",h=>E0e(h,i)),!A0e(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),s}function UU(t){return nU(t)&&"ownerSVGElement"in t}function T0e(t){return UU(t)&&t.tagName==="svg"}const mr=t=>!!(t&&t.getVelocity),R0e=[...NU,fn,xl],M0e=t=>R0e.find(LU(t)),HU=k.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function O0e(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 WU=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 P0e(t){for(const e in t)zh[e]={...zh[e],...t[e]}}const D0e=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 Xv(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||D0e.has(t)}let qU=t=>!Xv(t);function I0e(t){typeof t=="function"&&(qU=e=>e.startsWith("on")?!Xv(e):t(e))}try{I0e(require("@emotion/is-prop-valid").default)}catch{}function L0e(t,e,n){const r={};for(const i in t)i==="values"&&typeof t.values=="object"||(qU(i)||n===!0&&Xv(i)||!e&&!Xv(i)||t.draggable&&i.startsWith("onDrag"))&&(r[i]=t[i]);return r}const pw=k.createContext({});function mw(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 gw(t){return mw(t.animate)||nR.some(e=>Sm(t[e]))}function GU(t){return!!(gw(t)||t.variants)}function N0e(t,e){if(gw(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 $0e(t){const{initial:e,animate:n}=N0e(t,k.useContext(pw));return k.useMemo(()=>({initial:e,animate:n}),[r4(e),r4(n)])}function r4(t){return Array.isArray(t)?t.join(" "):t}const _m={};function j0e(t){for(const e in t)_m[e]=t[e],zT(e)&&(_m[e].isCSSVariable=!0)}function KU(t,{layout:e,layoutId:n}){return rf.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!_m[t]||t==="opacity")}const B0e={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},F0e=nf.length;function z0e(t,e,n){let r="",i=!0;for(let s=0;s<F0e;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=BU(a,QT[o]);if(!c){i=!1;const f=B0e[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=BU(h,QT[c]);c.startsWith("origin")?(a=!0,s[c]=f):r[c]=f}}if(e.transform||(o||n?r.transform=z0e(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 YU(t,e,n){for(const r in e)!mr(e[r])&&!KU(r,n)&&(t[r]=e[r])}function V0e({transformTemplate:t},e){return k.useMemo(()=>{const n=iR();return rR(n,e,t),Object.assign({},n.vars,n.style)},[e])}function U0e(t,e){const n=t.style||{},r={};return YU(r,n,t),Object.assign(r,V0e(t,e)),r}function H0e(t,e){const n={},r=U0e(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 W0e={offset:"stroke-dashoffset",array:"stroke-dasharray"},q0e={offset:"strokeDashoffset",array:"strokeDasharray"};function G0e(t,e,n=1,r=0,i=!0){t.pathLength=1;const s=i?W0e:q0e;t[s.offset]=qe.transform(-r);const o=qe.transform(e),a=qe.transform(n);t[s.array]=`${o} ${a}`}function XU(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&&G0e(d,i,s,o,!1)}const JU=()=>({...iR(),attrs:{}}),QU=t=>typeof t=="string"&&t.toLowerCase()==="svg";function K0e(t,e,n,r){const i=k.useMemo(()=>{const s=JU();return XU(s,e,QU(r),t.transformTemplate,t.style),{...s.attrs,style:{...s.style}}},[e]);if(t.style){const s={};YU(s,t.style,t),i.style={...s,...i.style}}return i}const Y0e=["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:!!(Y0e.indexOf(t)>-1||/[A-Z]/u.test(t))}function X0e(t,e,n,{latestValues:r},i,s=!1){const a=(sR(t)?K0e:H0e)(e,r,i,t),c=L0e(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 Vb(t){return mr(t)?t.get():t}function J0e({scrapeMotionValuesFromProps:t,createRenderState:e},n,r,i){return{latestValues:Q0e(n,r,i,t),renderState:e()}}function Q0e(t,e,n,r){const i={},s=r(t,{});for(const m in s)i[m]=Vb(s[m]);let{initial:o,animate:a}=t;const c=gw(t),h=GU(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"&&!mw(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:x,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 x)i[A]=x[A]}}}return i}const ZU=t=>(e,n)=>{const r=k.useContext(pw),i=k.useContext(DT),s=()=>J0e(t,e,r,i);return n?s():Pme(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])||KU(s,t)||n?.getValue(s)?.liveStyle!==void 0)&&(i[s]=r[s]);return i}const Z0e=ZU({scrapeMotionValuesFromProps:aR,createRenderState:iR});function eH(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 eye=ZU({scrapeMotionValuesFromProps:eH,createRenderState:JU}),tye=Symbol.for("motionComponentSymbol");function ah(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function nye(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(),rye="framerAppearId",tH="data-"+lR(rye),nH=k.createContext({});function iye(t,e,n,r,i){const{visualElement:s}=k.useContext(pw),o=k.useContext(WU),a=k.useContext(DT),c=k.useContext(HU).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(nH);f&&!f.projection&&i&&(f.type==="html"||f.type==="svg")&&sye(h.current,n,i,d);const m=k.useRef(!1);k.useInsertionEffect(()=>{f&&m.current&&f.update(n,a)});const y=n[tH],b=k.useRef(!!y&&!window.MotionHandoffIsComplete?.(y)&&window.MotionHasOptimisedAnimation?.(y));return Dme(()=>{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 sye(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:rH(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 rH(t){if(t)return t.options.allowProjection!==!1?t.projection:rH(t.parent)}function r2(t,{forwardMotionProps:e=!1}={},n,r){n&&P0e(n);const i=sR(t)?eye:Z0e;function s(a,c){let h;const f={...k.useContext(HU),...a,layoutId:oye(a)},{isStatic:d}=f,m=$0e(a),y=i(a,d);if(!d&&PT){aye();const b=lye(f);h=b.MeasureLayout,m.visualElement=iye(t,y,f,r,b.ProjectionNode)}return C.jsxs(pw.Provider,{value:m,children:[h&&m.visualElement?C.jsx(h,{visualElement:m.visualElement,...f}):null,X0e(t,a,nye(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[tye]=t,o}function oye({layoutId:t}){const e=k.useContext(eU).id;return e&&t!==void 0?e+"-"+t:t}function aye(t,e){k.useContext(WU).strict}function lye(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 cye(t,e){if(typeof Proxy>"u")return r2;const n=new Map,r=(s,o)=>r2(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,r2(o,void 0,t,e)),n.get(o))})}function iH({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function uye({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function hye(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 i2(t){return t===void 0||t===1}function KA({scale:t,scaleX:e,scaleY:n}){return!i2(t)||!i2(e)||!i2(n)}function nc(t){return KA(t)||sH(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function sH(t){return s4(t.x)||s4(t.y)}function s4(t){return t&&t!=="0%"}function Jv(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=Jv(t,i,r)),Jv(t,n,r)+e}function YA(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 oH(t,{x:e,y:n}){YA(t.x,e.translate,e.scale,e.originPoint),YA(t.y,n.translate,n.scale,n.originPoint)}const a4=.999999999999,l4=1.0000000000001;function fye(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,oH(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);YA(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 aH(t,e){return iH(hye(t.getBoundingClientRect(),e))}function dye(t,e,n){const r=aH(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()}),XA={current:null},lH={current:!1};function pye(){if(lH.current=!0,!!PT)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>XA.current=t.matches;t.addEventListener("change",e),e()}else XA.current=!1}const mye=new WeakMap;function gye(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 yye{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=gw(n),this.isVariantNode=GU(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,mye.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)),lH.current||pye(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:XA.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=gye(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"&&(tU(r)||rU(r))?r=parseFloat(r):!M0e(r)&&xl.test(n)&&(r=jU(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 cH extends yye{constructor(){super(...arguments),this.KeyframeResolver=y0e}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 uH(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 bye(t){return window.getComputedStyle(t)}class vye extends cH{constructor(){super(...arguments),this.type="html",this.renderInstance=uH}readValueFromInstance(e,n){if(rf.has(n))return this.projection?.isProjecting?zA(n):Nge(e,n);{const r=bye(e),i=(zT(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return aH(e,n)}build(e,n,r){rR(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return aR(e,n,r)}}const hH=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){uH(t,e,void 0,r);for(const i in e.attrs)t.setAttribute(hH.has(i)?i:lR(i),e.attrs[i])}class wye extends cH{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=$U(n);return r&&r.default||0}return n=hH.has(n)?n:lR(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return eH(e,n,r)}build(e,n,r){XU(e,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,n,r,i){xye(e,n,r,i)}mount(e){this.isSVGTag=QU(e.tagName),super.mount(e)}}const Sye=(t,e)=>sR(t)?new wye(e):new vye(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 JA=t=>Array.isArray(t);function _ye(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Fh(n))}function Cye(t){return JA(t)?t[t.length-1]||0:t}function Aye(t,e){const n=Ah(t,e);let{transitionEnd:r={},transition:i={},...s}=n||{};s={...s,...r};for(const o in s){const a=Cye(s[o]);_ye(t,o,a)}}function Eye(t){return!!(mr(t)&&t.add)}function QA(t,e){const n=t.getValue("willChange");if(Eye(n))return n.add(e);if(!n&&ea.WillChange){const r=new ea.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function fH(t){return t.props[tH]}const kye=t=>t!==null;function Tye(t,{repeat:e,repeatType:n="loop"},r){const i=t.filter(kye),s=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[s]}const Rye={type:"spring",stiffness:500,damping:25,restSpeed:10},Mye=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Oye={type:"keyframes",duration:.8},Pye={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Dye=(t,{keyframes:e})=>e.length>2?Oye:rf.has(t)?t.startsWith("scale")?Mye(e[1]):Rye:Pye;function Iye({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};Iye(a)||Object.assign(f,Dye(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)&&(qA(f),f.delay===0&&(d=!0)),(ea.instantAnimations||ea.skipAnimations)&&(d=!0,qA(f),f.delay=0),f.allowFlatten=!a.type&&!a.ease,d&&!s&&e.get()!==void 0){const m=Tye(f.keyframes,a);if(m!==void 0){Ut.update(()=>{f.onUpdate(m),f.onComplete()});return}}return a.isSync?new YT(f):new s0e(f)};function Lye({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function dH(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&&Lye(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 x=!1;if(window.MotionHandoffAnimation){const _=fH(t);if(_){const A=window.MotionHandoffAnimation(_,f,Ut);A!==null&&(y.startTime=A,x=!0)}}QA(t,f),d.start(cR(f,d,m,t.shouldReduceMotion&&IU.has(f)?{type:!1}:y,t,x));const S=d.animation;S&&c.push(S)}return o&&Promise.all(c).then(()=>{Ut.update(()=>{o&&Aye(t,o)})}),c}function pH(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 ZA(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(dH(t,r,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:h=0,staggerChildren:f,staggerDirection:d}=i;return Nye(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 Nye(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(ZA(c,e,{...o,delay:n+(typeof r=="function"?0:r)+pH(t.variantChildren,c,r,i,s)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function $ye(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const i=e.map(s=>ZA(t,s,n));r=Promise.all(i)}else if(typeof e=="string")r=ZA(t,e,n);else{const i=typeof e=="function"?Ah(t,e,n.custom):e;r=Promise.all(dH(t,i,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}function mH(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 jye=nR.length;function gH(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?gH(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<jye;n++){const r=nR[n],i=t.props[r];(Sm(i)||i===!1)&&(e[r]=i)}return e}const Bye=[...tR].reverse(),Fye=tR.length;function zye(t){return e=>Promise.all(e.map(({animation:n,options:r})=>$ye(t,n,r)))}function Vye(t){let e=zye(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=gH(t.parent)||{},d=[],m=new Set;let y={},b=1/0;for(let S=0;S<Fye;S++){const _=Bye[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||mw(E)||typeof E=="boolean")continue;const D=Uye(A.prevProp,E);let N=D||_===c&&A.isActive&&!M&&P||S>b&&P,H=!1;const j=Array.isArray(E)?E:[E];let V=j.reduce(i(_),{});O===!1&&(V={});const{prevResolvedValues:q={}}=A,X={...q,...V},Y=G=>{N=!0,m.has(G)&&(H=!0,m.delete(G)),A.needsAnimating[G]=!0;const U=t.getValue(G);U&&(U.liveStyle=!1)};for(const G in X){const U=V[G],se=q[G];if(y.hasOwnProperty(G))continue;let T=!1;JA(U)&&JA(se)?T=!mH(U,se):T=U!==se,T?U!=null?Y(G):m.add(G):U!==void 0&&m.has(G)?Y(G):A.protectedKeys[G]=!0}A.prevProp=E,A.prevResolvedValues=V,A.isActive&&(y={...y,...V}),r&&t.blockInitialAnimation&&(N=!1);const te=M&&D;N&&(!te||H)&&d.push(...j.map(G=>{const U={type:_};if(typeof G=="string"&&r&&!te&&t.manuallyAnimateOnMount&&t.parent){const{parent:se}=t,T=Ah(se,G);if(se.enteringChildren&&T){const{delayChildren:Z}=T.transition||{};U.delay=pH(se.enteringChildren,t,Z)}}return{animation:G,options:U}}))}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 x=!!d.length;return r&&(h.initial===!1||h.initial===h.animate)&&!t.manuallyAnimateOnMount&&(x=!1),r=!1,x?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 Uye(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!mH(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 Hye extends Al{constructor(e){super(e),e.animationState||(e.animationState=Vye(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();mw(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 Wye=0;class qye extends Al{constructor(){super(...arguments),this.id=Wye++}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 Gye={animation:{Feature:Hye},exit:{Feature:qye}};function Cm(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}function ng(t){return{point:{x:t.pageX,y:t.pageY}}}const Kye=t=>e=>eR(e)&&t(e,ng(e));function Dp(t,e,n,r){return Cm(t,e,Kye(n),r)}const yH=1e-4,Yye=1-yH,Xye=1+yH,bH=.01,Jye=0-bH,Qye=0+bH;function Pr(t){return t.max-t.min}function Zye(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>=Yye&&t.scale<=Xye||isNaN(t.scale))&&(t.scale=1),(t.translate>=Jye&&t.translate<=Qye||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 ebe(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 vH=({current:t})=>t?t.ownerDocument.defaultView:null,y4=(t,e)=>Math.abs(t-e);function tbe(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=o2(this.lastMoveEventInfo,this.history),y=this.startEvent!==null,b=tbe(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!y&&!b)return;const{point:x}=m,{timestamp:S}=Hn;this.history.push({...x,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=s2(y,this.transformPagePoint),Ut.update(this.updatePoint,!0)},this.handlePointerUp=(m,y)=>{this.end();const{onEnd:b,onSessionEnd:x,resumeAnimation:S}=this.handlers;if(this.dragSnapToOrigin&&S&&S(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const _=o2(m.type==="pointercancel"?this.lastMoveEventInfo:s2(y,this.transformPagePoint),this.history);this.startEvent&&b&&b(m,_),x&&x(m,_)},!eR(e))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=o,this.contextWindow=i||window;const a=ng(e),c=s2(a,this.transformPagePoint),{point:h}=c,{timestamp:f}=Hn;this.history=[{...h,timestamp:f}];const{onSessionStart:d}=n;d&&d(e,o2(c,this.history)),this.removeListeners=Zm(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 s2(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 o2({point:t},e){return{point:t,delta:b4(t,wH(e)),offset:b4(t,nbe(e)),velocity:rbe(e,.1)}}function nbe(t){return t[0]}function wH(t){return t[t.length-1]}function rbe(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,r=null;const i=wH(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 ibe(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 sbe(t,{top:e,left:n,bottom:r,right:i}){return{x:v4(t.x,n,i),y:v4(t.y,e,r)}}function x4(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 obe(t,e){return{x:x4(t.x,e.x),y:x4(t.y,e.y)}}function abe(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 lbe(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 eE=.35;function cbe(t=eE){return t===!1?t=0:t===!0&&(t=eE),{x:w4(t,"left","right"),y:w4(t,"top","bottom")}}function w4(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 ube=new WeakMap;class hbe{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(ng(d).point)},o=(d,m)=>{const{drag:y,dragPropagation:b,onDragStart:x}=this.getProps();if(y&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=S0e(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}),x&&Ut.postRender(()=>x(d,m)),QA(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:x,onDrag:S}=this.getProps();if(!y&&!this.openDragLock)return;const{offset:_}=m;if(b&&this.currentDirection===null){this.currentDirection=fbe(_),this.currentDirection!==null&&x&&x(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:vH(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||!Gy(e,i,this.currentDirection))return;const s=this.getAxisMotionValue(e);let o=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(o=ibe(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=sbe(r.layoutBox,e):this.constraints=!1,this.elastic=cbe(n),i!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&Hi(s=>{this.constraints!==!1&&this.getAxisMotionValue(s)&&(this.constraints[s]=lbe(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=dye(r,i.root,this.visualElement.getTransformPagePoint());let o=obe(i.layout.layoutBox,s);if(n){const a=n(uye(o));this.hasMutatedConstraints=!!a,a&&(o=iH(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(!Gy(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 QA(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(!Gy(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]=abe({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(!Gy(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;ube.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=eE,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:r,dragPropagation:i,dragConstraints:s,dragElastic:o,dragMomentum:a}}}function Gy(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function fbe(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class dbe extends Al{constructor(e){super(e),this.removeGroupControls=es,this.removeListeners=es,this.controls=new hbe(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 pbe extends Al{constructor(){super(...arguments),this.removePointerDownListener=es}onPointerDown(e){this.session=new xH(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:vH(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 Ub={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}%`}},mbe={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,i=xl.parse(t);if(i.length>5)return r;const s=xl.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 a2=!1;class gbe extends k.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r,layoutId:i}=this.props,{projection:s}=e;j0e(ybe),s&&(n.group&&n.group.add(s),r&&r.register&&i&&r.register(s),a2&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),Ub.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:r,drag:i,isPresent:s}=this.props,{projection:o}=r;return o&&(o.isPresent=s,a2=!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;a2=!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 SH(t){const[e,n]=O0e(),r=k.useContext(eU);return C.jsx(gbe,{...t,layoutGroup:r,switchLayoutGroup:k.useContext(nH),isPresent:e,safeToRemove:n})}const ybe={borderRadius:{...Nd,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Nd,borderTopRightRadius:Nd,borderBottomLeftRadius:Nd,borderBottomRightRadius:Nd,boxShadow:mbe};function bbe(t,e,n){const r=mr(t)?t:Fh(t);return r.start(cR("",r,e,n)),r.animation}const vbe=(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(vbe),this.isDirty=!1,this.children.forEach(e)}}function wbe(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 _H=["TopLeft","TopRight","BottomLeft","BottomRight"],Sbe=_H.length,A4=t=>typeof t=="string"?parseFloat(t):t,E4=t=>typeof t=="number"||qe.test(t);function _be(t,e,n,r,i,s){i?(t.opacity=Gt(0,n.opacity??1,Cbe(r)),t.opacityExit=Gt(e.opacity??1,0,Abe(r))):s&&(t.opacity=Gt(e.opacity??1,n.opacity??1,r));for(let o=0;o<Sbe;o++){const a=`border${_H[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 Cbe=CH(0,.5,hU),Abe=CH(.5,.95,es);function CH(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=Jv(t,1/n,r),i!==void 0&&(t=Jv(t,1/i,r)),t}function Ebe(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){Ebe(t,e[n],e[r],e[i],e.scale,s,o)}const kbe=["x","scaleX","originX"],Tbe=["y","scaleY","originY"];function P4(t,e,n,r){O4(t.x,e,kbe,n?n.x:void 0,r?r.x:void 0),O4(t.y,e,Tbe,n?n.y:void 0,r?r.y:void 0)}function D4(t){return t.translate===0&&t.scale===1}function AH(t){return D4(t.x)&&D4(t.y)}function I4(t,e){return t.min===e.min&&t.max===e.max}function Rbe(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 EH(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 Mbe{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 Obe(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 l2=["","X","Y","Z"],Pbe=1e3;let Dbe=0;function c2(t,e,n,r){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),r&&(r[t]=0))}function kH(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=fH(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&&kH(r)}function TH({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=Dbe++,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(Nbe),this.nodes.forEach(Fbe),this.nodes.forEach(zbe),this.nodes.forEach($be)},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=UU(o)&&!T0e(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=wbe(m,250),Ub.hasAnimatedSinceResize&&(Ub.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()||qbe,{onLayoutAnimationStart:x,onLayoutAnimationComplete:S}=h.getProps(),_=!this.targetLayout||!EH(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:x,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(Vbe),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&&kH(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(Bbe),this.nodes.forEach(Ibe),this.nodes.forEach(Lbe)):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,J_.update.process(Hn),J_.preRender.process(Hn),J_.render.process(Hn),Hn.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,ZT.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(jbe),this.sharedNodes.forEach(Ube)}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&&!AH(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)),Gbe(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(Kbe))){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;KA(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(),ebe(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Vi(this.target,this.layout.layoutBox),oH(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||KA(this.parent.latestValues)||sH(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;fye(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,x=y!==b,S=this.getStack(),_=!S||S.members.length<=1,A=!!(x&&!_&&this.options.crossfade===!0&&!this.path.some(Wbe));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),Hbe(this.relativeTarget,this.relativeTargetOrigin,m,O),E&&Rbe(this.relativeTarget,E)&&(this.isProjectionDirty=!1),E||(E=rn()),Vi(E,this.relativeTarget)),x&&(this.animationValues=f,_be(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(()=>{Ub.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Fh(0)),this.currentAnimation=bbe(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(Pbe),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&&RH(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 Mbe),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&&c2("z",o,h,this.animationValues);for(let f=0;f<l2.length;f++)c2(`rotate${l2[f]}`,o,h,this.animationValues),c2(`skew${l2[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=Vb(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=Vb(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=Obe(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:x,applyTo:S,isCSSVariable:_}=_m[b],A=d==="none"?f[b]:x(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?Vb(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 Ibe(t){t.updateLayout()}function Lbe(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}):RH(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=!AH(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),EH(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 Nbe(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 $be(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function jbe(t){t.clearSnapshot()}function j4(t){t.clearMeasurements()}function B4(t){t.isLayoutDirty=!1}function Bbe(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 Fbe(t){t.resolveTargetDelta()}function zbe(t){t.calcProjection()}function Vbe(t){t.resetSkewAndRotation()}function Ube(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 Hbe(t,e,n,r){V4(t.x,e.x,n.x,r),V4(t.y,e.y,n.y,r)}function Wbe(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const qbe={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 Gbe(t){W4(t.x),W4(t.y)}function RH(t,e,n){return t==="position"||t==="preserve-aspect"&&!Zye(N4(e),N4(n),.2)}function Kbe(t){return t!==t.root&&t.scroll?.wasRoot}const Ybe=TH({attachResizeListener:(t,e)=>Cm(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),u2={current:void 0},MH=TH({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!u2.current){const t=new Ybe({});t.mount(window),t.setOptions({layoutScroll:!0}),u2.current=t}return u2.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Xbe={pan:{Feature:pbe},drag:{Feature:dbe,ProjectionNode:MH,MeasureLayout:SH}};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,ng(e)))}class Jbe extends Al{mount(){const{current:e}=this.node;e&&(this.unmount=_0e(e,(n,r)=>(q4(this.node,r,"Start"),i=>q4(this.node,i,"End"))))}unmount(){}}class Qbe 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=Zm(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,ng(e)))}class Zbe extends Al{mount(){const{current:e}=this.node;e&&(this.unmount=k0e(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 tE=new WeakMap,h2=new WeakMap,eve=t=>{const e=tE.get(t.target);e&&e(t)},tve=t=>{t.forEach(eve)};function nve({root:t,...e}){const n=t||document;h2.has(n)||h2.set(n,{});const r=h2.get(n),i=JSON.stringify(e);return r[i]||(r[i]=new IntersectionObserver(tve,{root:t,...e})),r[i]}function rve(t,e,n){const r=nve(e);return tE.set(t,n),r.observe(t),()=>{tE.delete(t),r.unobserve(t)}}const ive={some:0,all:1};class sve 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:ive[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 rve(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(ove(e,n))&&this.startObserver()}unmount(){}}function ove({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const ave={inView:{Feature:sve},tap:{Feature:Zbe},focus:{Feature:Qbe},hover:{Feature:Jbe}},lve={layout:{ProjectionNode:MH,MeasureLayout:SH}},cve={...Gye,...ave,...Xbe,...lve},uR=cye(cve,Sye),uve=()=>{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")})]})})})},yw=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:[]})}})),hve="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",nE="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",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='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",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='%235BB514'/%3e%3cpath%20d='M9%2014V16H7V14H9ZM17%2014V16H13V14H17ZM17%208V10H13V8H17ZM9%208V10H7V8H9Z'%20fill='white'%20stroke='white'%20stroke-width='2'/%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='%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",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%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",LH=({file:t,withoutClose:e})=>{const{deleteAttachmentFile:n}=yw(),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=A9(t.type),c=k9(t.type),h=Tb(t.type),f=E9(t.type),d=c?OH:a?nE:h?PH:f?DH:IH;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:hve,size:16,onClick:r})]})};function Qv(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]/),fve=El(/[#-'*+\--9=?A-Z^-~]/);function Zv(t){return t!==null&&(t<32||t===127)}const rE=El(/\d/),dve=El(/[\dA-Fa-f]/),pve=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 bw=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 mve(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const vw=(function(t){if(t==null)return vve;if(typeof t=="function")return xw(t);if(typeof t=="object")return Array.isArray(t)?gve(t):yve(t);if(typeof t=="string")return bve(t);throw new Error("Expected function, string, or object as test")});function gve(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=vw(t[n]);return xw(r);function r(...i){let s=-1;for(;++s<e.length;)if(e[s].apply(this,i))return!0;return!1}}function yve(t){const e=t;return xw(n);function n(r){const i=r;let s;for(s in t)if(i[s]!==e[s])return!1;return!0}}function bve(t){return xw(e);function e(n){return n&&n.type===t}}function xw(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 vve(){return!0}function xve(t){return t!==null&&typeof t=="object"&&"type"in t}const NH=[],wve=!0,iE=!1,Sve="skip";function $H(t,e,n,r){let i;typeof e=="function"&&typeof n!="function"?(r=n,n=e):i=e;const s=vw(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=NH,b,x,S;if((!e||s(c,h,f[f.length-1]||void 0))&&(y=_ve(n(c,f)),y[0]===iE))return y;if("children"in c&&c.children){const _=c;if(_.children&&y[0]!==Sve)for(x=(r?_.children.length:-1)+o,S=f.concat(_);x>-1&&x<_.children.length;){const A=_.children[x];if(b=a(A,x,S)(),b[0]===iE)return b;x=typeof b[1]=="number"?b[1]:x+o}}return y}}}function _ve(t){return Array.isArray(t)?t:typeof t=="number"?[wve,t]:t==null?NH:[t]}function Cve(t,e,n){const i=vw((n||{}).ignore||[]),s=Ave(e);let o=-1;for(;++o<s.length;)$H(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 Ave(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([Eve(i[0]),kve(i[1])])}return e}function Eve(t){return typeof t=="string"?new RegExp(mve(t),"g"):t}function kve(t){return typeof t=="function"?t:function(){return t}}const f2="phrasing",d2=["autolink","link","image","label"];function Tve(){return{transforms:[Lve],enter:{literalAutolink:Mve,literalAutolinkEmail:p2,literalAutolinkHttp:p2,literalAutolinkWww:p2},exit:{literalAutolink:Ive,literalAutolinkEmail:Dve,literalAutolinkHttp:Ove,literalAutolinkWww:Pve}}}function Rve(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:f2,notInConstruct:d2},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:f2,notInConstruct:d2},{character:":",before:"[ps]",after:"\\/",inConstruct:f2,notInConstruct:d2}]}}function Mve(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function p2(t){this.config.enter.autolinkProtocol.call(this,t)}function Ove(t){this.config.exit.autolinkProtocol.call(this,t)}function Pve(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 Dve(t){this.config.exit.autolinkEmail.call(this,t)}function Ive(t){this.exit(t)}function Lve(t){Cve(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Nve],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),$ve]],{ignore:["link","linkReference"]})}function Nve(t,e,n,r,i){let s="";if(!jH(i)||(/^w/i.test(e)&&(n=e+n,e="",s="http://"),!jve(n)))return!1;const o=Bve(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 $ve(t,e,n,r){return!jH(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n}]}}function jve(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 Bve(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=Qv(t,"(");let s=Qv(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 jH(t,e){const n=t.input.charCodeAt(t.index-1);return(t.index===0||Oc(n)||bw(n))&&(!e||n!==47)}function xs(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}BH.peek=Kve;function Fve(){this.buffer()}function zve(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function Vve(){this.buffer()}function Uve(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function Hve(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=xs(this.sliceSerialize(t)).toLowerCase(),n.label=e}function Wve(t){this.exit(t)}function qve(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=xs(this.sliceSerialize(t)).toLowerCase(),n.label=e}function Gve(t){this.exit(t)}function Kve(){return"["}function BH(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 Yve(){return{enter:{gfmFootnoteCallString:Fve,gfmFootnoteCall:zve,gfmFootnoteDefinitionLabelString:Vve,gfmFootnoteDefinition:Uve},exit:{gfmFootnoteCallString:Hve,gfmFootnoteCall:Wve,gfmFootnoteDefinitionLabelString:qve,gfmFootnoteDefinition:Gve}}}function Xve(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:BH},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?FH:Jve))),h(),c}}function Jve(t,e,n){return e===0?t:FH(t,e,n)}function FH(t,e,n){return(n?"":" ")+t}const Qve=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];zH.peek=rxe;function Zve(){return{canContainEols:["delete"],enter:{strikethrough:txe},exit:{strikethrough:nxe}}}function exe(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Qve}],handlers:{delete:zH}}}function txe(t){this.enter({type:"delete",children:[]},t)}function nxe(t){this.exit(t)}function zH(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 rxe(){return"~"}function ixe(t){return t.length}function sxe(t,e){const n=e||{},r=(n.align||[]).concat(),i=n.stringLength||ixe,s=[],o=[],a=[],c=[];let h=0,f=-1;for(;++f<t.length;){const x=[],S=[];let _=-1;for(t[f].length>h&&(h=t[f].length);++_<t[f].length;){const A=oxe(t[f][_]);if(n.alignDelimiters!==!1){const E=i(A);S[_]=E,(c[_]===void 0||E>c[_])&&(c[_]=E)}x.push(A)}o[f]=x,a[f]=S}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<h;)s[d]=K4(r[d]);else{const x=K4(r);for(;++d<h;)s[d]=x}d=-1;const m=[],y=[];for(;++d<h;){const x=s[d];let S="",_="";x===99?(S=":",_=":"):x===108?S=":":x===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 x=o[f],S=a[f];d=-1;const _=[];for(;++d<h;){const A=x[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 oxe(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 axe(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 lxe(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()),cxe);return i(),o}function cxe(t,e,n){return">"+(n?"":" ")+t}function uxe(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===`
`&&uxe(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
`}function hxe(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 fxe(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 dxe(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 pxe(t,e,n,r){const i=dxe(n),s=t.value||"",o=i==="`"?"GraveAccent":"Tilde";if(fxe(t,n)){const d=n.enter("codeIndented"),m=n.indentLines(s,mxe);return d(),m}const a=n.createTracker(r),c=i.repeat(Math.max(hxe(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 mxe(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 gxe(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 yxe(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(bw(t))return 2}function ex(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}}VH.peek=bxe;function VH(t,e,n,r){const i=yxe(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=ex(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=ex(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 bxe(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),$H(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 vxe={};function dR(t,e){const n=vxe,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return UH(t,r,i)}function UH(t,e,n){if(xxe(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]=UH(t[i],e,n);return r.join("")}function xxe(t){return!!(t&&typeof t=="object")}function wxe(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,iE}),!!((!t.depth||t.depth<3)&&dR(t)&&(e.options.setext||n))}function Sxe(t,e,n,r){const i=Math.max(Math.min(6,t.depth||1),1),s=n.createTracker(r);if(wxe(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}HH.peek=_xe;function HH(t){return t.value||""}function _xe(){return"<"}WH.peek=Cxe;function WH(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 Cxe(){return"!"}qH.peek=Axe;function qH(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 Axe(){return"!"}GH.peek=Exe;function GH(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 Exe(){return"`"}function KH(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))}YH.peek=kxe;function YH(t,e,n,r){const i=hR(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,c;if(KH(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 kxe(t,e,n){return KH(t,n)?"<":"["}XH.peek=Txe;function XH(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 Txe(){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 Rxe(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 Mxe(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 JH(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 Oxe(t,e,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=t.ordered?Mxe(n):pR(n);const a=t.ordered?o==="."?")":".":Rxe(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),JH(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 Pxe(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 Dxe(t,e,n,r){const i=Pxe(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 Ixe(t,e,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(t,r);return s(),i(),o}const Lxe=vw(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Nxe(t,e,n,r){return(t.children.some(function(o){return Lxe(o)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function $xe(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}QH.peek=jxe;function QH(t,e,n,r){const i=$xe(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=ex(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=ex(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 jxe(t,e,n){return n.options.strong||"*"}function Bxe(t,e,n,r){return n.safe(t.value,r)}function Fxe(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 zxe(t,e,n){const r=(JH(n)+(n.options.ruleSpaces?" ":"")).repeat(Fxe(n));return n.options.ruleSpaces?r.slice(0,-1):r}const ZH={blockquote:lxe,break:J4,code:pxe,definition:gxe,emphasis:VH,hardBreak:J4,heading:Sxe,html:HH,image:WH,imageReference:qH,inlineCode:GH,link:YH,linkReference:XH,list:Oxe,listItem:Dxe,paragraph:Ixe,root:Nxe,strong:QH,text:Bxe,thematicBreak:zxe},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 eW(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 Vxe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Uxe(t){return t.replace(Vxe,Hxe)}function Hxe(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return eW(n.slice(s?2:1),s?16:10)}return mR(n)||t}function Wxe(){return{enter:{table:qxe,tableData:e5,tableHeader:e5,tableRow:Kxe},exit:{codeText:Yxe,table:Gxe,tableData:m2,tableHeader:m2,tableRow:m2}}}function qxe(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 Gxe(t){this.exit(t),this.data.inTable=void 0}function Kxe(t){this.enter({type:"tableRow",children:[]},t)}function m2(t){this.exit(t)}function e5(t){this.enter({type:"tableCell",children:[]},t)}function Yxe(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,Xxe));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function Xxe(t,e){return e==="|"?e:t}function Jxe(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,x,S){return h(f(y,x,S),y.align)}function a(y,b,x,S){const _=d(y,x,S),A=h([_]);return A.slice(0,A.indexOf(`
`))}function c(y,b,x,S){const _=x.enter("tableCell"),A=x.enter("phrasing"),E=x.containerPhrasing(y,{...S,before:s,after:s});return A(),_(),E}function h(y,b){return sxe(y,{align:b,alignDelimiters:r,padding:n,stringLength:i})}function f(y,b,x){const S=y.children;let _=-1;const A=[],E=b.enter("table");for(;++_<S.length;)A[_]=d(S[_],b,x);return E(),A}function d(y,b,x){const S=y.children;let _=-1;const A=[],E=b.enter("tableRow");for(;++_<S.length;)A[_]=c(S[_],y,b,x);return E(),A}function m(y,b,x){let S=ZH.inlineCode(y,b,x);return x.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function Qxe(){return{exit:{taskListCheckValueChecked:t5,taskListCheckValueUnchecked:t5,paragraph:ewe}}}function Zxe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:twe}}}function t5(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function ewe(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 twe(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=ZH.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 nwe(){return[Tve(),Yve(),Zve(),Wxe(),Qxe()]}function rwe(t){return{extensions:[Rve(),Xve(t),exe(),Jxe(t),Zxe()]}}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 n5={}.hasOwnProperty;function tW(t){const e={};let n=-1;for(;++n<t.length;)iwe(e,t[n]);return e}function iwe(t,e){let n;for(n in e){const i=(n5.call(t,n)?t[n]:void 0)||(t[n]={}),s=e[n];let o;if(s)for(o in s){n5.call(i,o)||(i[o]=[]);const a=s[o];swe(i[o],Array.isArray(a)?a:a?[a]:[])}}}function swe(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 owe={tokenize:fwe,partial:!0},nW={tokenize:dwe,partial:!0},rW={tokenize:pwe,partial:!0},iW={tokenize:mwe,partial:!0},awe={tokenize:gwe,partial:!0},sW={name:"wwwAutolink",tokenize:uwe,previous:aW},oW={name:"protocolAutolink",tokenize:hwe,previous:lW},oa={name:"emailAutolink",tokenize:cwe,previous:cW},So={};function lwe(){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,oW];So[104]=[oa,oW];So[87]=[oa,sW];So[119]=[oa,sW];function cwe(t,e,n){const r=this;let i,s;return o;function o(d){return!sE(d)||!cW.call(r,r.previous)||gR(r.events)?n(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),a(d))}function a(d){return sE(d)?(t.consume(d),a):d===64?(t.consume(d),c):n(d)}function c(d){return d===46?t.check(awe,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 uwe(t,e,n){const r=this;return i;function i(o){return o!==87&&o!==119||!aW.call(r,r.previous)||gR(r.events)?n(o):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(owe,t.attempt(nW,t.attempt(rW,s),n),n)(o))}function s(o){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(o)}}function hwe(t,e,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&lW.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||Zv(d)||Ot(d)||Oc(d)||bw(d)?n(d):t.attempt(nW,t.attempt(rW,f),n)(d)}function f(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function fwe(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 dwe(t,e,n){let r,i,s;return o;function o(h){return h===46||h===95?t.check(iW,c,a)(h):h===null||Ot(h)||Oc(h)||h!==45&&bw(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 pwe(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(iW,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 mwe(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 gwe(t,e,n){return r;function r(s){return t.consume(s),i}function i(s){return gr(s)?n(s):e(s)}}function aW(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Ot(t)}function lW(t){return!Or(t)}function cW(t){return!(t===47||sE(t))}function sE(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 ww(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 oE={name:"attention",resolveAll:ywe,tokenize:bwe};function ywe(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};r5(d,-c),r5(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,ww(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 bwe(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 r5(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const vwe={name:"autolink",tokenize:xwe};function xwe(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||Zv(y)?n(y):(t.consume(y),c)}function h(y){return y===64?(t.consume(y),f):fve(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 rg={partial:!0,tokenize:wwe};function wwe(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 uW={continuation:{tokenize:_we},exit:Cwe,name:"blockQuote",tokenize:Swe};function Swe(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 _we(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(uW,e,n)(o)}}function Cwe(t){t.exit("blockQuote")}const hW={name:"characterEscape",tokenize:Awe};function Awe(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 pve(s)?(t.enter("characterEscapeValue"),t.consume(s),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(s)}}const fW={name:"characterReference",tokenize:Ewe};function Ewe(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=dve,f):(t.enter("characterReferenceValue"),s=7,o=rE,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 i5={partial:!0,tokenize:Twe},s5={concrete:!0,name:"codeFenced",tokenize:kwe};function kwe(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(i5,x,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 x(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(i5,x,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,N){let H=0;return j;function j(te){return M.enter("lineEnding"),M.consume(te),M.exit("lineEnding"),V}function V(te){return M.enter("codeFencedFence"),lt(te)?ut(M,q,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(te):q(te)}function q(te){return te===a?(M.enter("codeFencedFenceSequence"),X(te)):N(te)}function X(te){return te===a?(H++,M.consume(te),X):H>=o?(M.exit("codeFencedFenceSequence"),lt(te)?ut(M,Y,"whitespace")(te):Y(te)):N(te)}function Y(te){return te===null||Be(te)?(M.exit("codeFencedFence"),D(te)):N(te)}}}function Twe(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 g2={name:"codeIndented",tokenize:Mwe},Rwe={partial:!0,tokenize:Owe};function Mwe(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(Rwe,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 Owe(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 Pwe={name:"codeText",previous:Iwe,resolve:Dwe,tokenize:Lwe};function Dwe(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 Iwe(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Lwe(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 Nwe{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 dW(t){const e={};let n=-1,r,i,s,o,a,c,h;const f=new Nwe(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,$we(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 $we(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,x=0;const S=[x];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&&(x=m+1,S.push(x),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 jwe={resolve:Fwe,tokenize:zwe},Bwe={partial:!0,tokenize:Vwe};function Fwe(t){return dW(t),t}function zwe(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(Bwe,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 Vwe(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 pW(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||Zv(_)?n(_):(t.enter(r),t.enter(o),t.enter(a),t.enter("chunkString",{contentType:"string"}),x(_))}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 x(_){return!f&&(_===null||_===41||Ot(_))?(t.exit("chunkString"),t.exit(a),t.exit(o),t.exit(r),e(_)):f<h&&_===40?(t.consume(_),f++,x):_===41?(t.consume(_),f--,x):_===null||_===32||_===40||Zv(_)?n(_):(t.consume(_),_===92?S:x)}function S(_){return _===40||_===41||_===92?(t.consume(_),x):x(_)}}function mW(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 gW(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 Uwe={name:"definition",tokenize:Wwe},Hwe={partial:!0,tokenize:qwe};function Wwe(t,e,n){const r=this;let i;return s;function s(y){return t.enter("definition"),o(y)}function o(y){return mW.call(r,t,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function a(y){return i=xs(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 pW(t,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function f(y){return t.attempt(Hwe,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 qwe(t,e,n){return r;function r(a){return Ot(a)?Np(t,i)(a):n(a)}function i(a){return gW(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 Gwe={name:"hardBreakEscape",tokenize:Kwe};function Kwe(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 Ywe={name:"headingAtx",resolve:Xwe,tokenize:Jwe};function Xwe(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 Jwe(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 Qwe=["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"],o5=["pre","script","style","textarea"],Zwe={concrete:!0,name:"htmlFlow",resolveTo:n1e,tokenize:r1e},e1e={partial:!0,tokenize:s1e},t1e={partial:!0,tokenize:i1e};function n1e(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 r1e(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,x):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 de="CDATA[";return L===de.charCodeAt(a++)?(t.consume(L),a===de.length?r.interrupt?e:q:b):n(L)}function x(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 de=L===47,ke=o.toLowerCase();return!de&&!s&&o5.includes(ke)?(i=1,r.interrupt?e(L):q(L)):Qwe.includes(o.toLowerCase())?(i=6,de?(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):j(L)}function E(L){return L===47?(t.consume(L),j):L===58||L===95||Or(L)?(t.consume(L),P):lt(L)?(t.consume(L),E):j(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):N(L)}function D(L){return L===c?(t.consume(L),c=null,H):L===null||Be(L)?n(L):(t.consume(L),D)}function N(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),N)}function H(L){return L===47||L===62||lt(L)?E(L):n(L)}function j(L){return L===62?(t.consume(L),V):n(L)}function V(L){return L===null||Be(L)?q(L):lt(L)?(t.consume(L),V):n(L)}function q(L){return L===45&&i===2?(t.consume(L),z):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(e1e,ue,X)(L)):L===null||Be(L)?(t.exit("htmlFlowData"),X(L)):(t.consume(L),q)}function X(L){return t.check(t1e,Y,ue)(L)}function Y(L){return t.enter("lineEnding"),t.consume(L),t.exit("lineEnding"),te}function te(L){return L===null||Be(L)?X(L):(t.enter("htmlFlowData"),q(L))}function z(L){return L===45?(t.consume(L),T):q(L)}function G(L){return L===47?(t.consume(L),o="",U):q(L)}function U(L){if(L===62){const de=o.toLowerCase();return o5.includes(de)?(t.consume(L),Z):q(L)}return Or(L)&&o.length<8?(t.consume(L),o+=String.fromCharCode(L),U):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 i1e(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 s1e(t,e,n){return r;function r(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),t.attempt(rg,e,n)}}const o1e={name:"htmlText",tokenize:a1e};function a1e(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):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?z(T):T===45?m(T):d(T)}function b(T){const Z="CDATA[";return T===Z.charCodeAt(s++)?(t.consume(T),s===Z.length?x:b):n(T)}function x(T){return T===null?n(T):T===93?(t.consume(T),S):Be(T)?(o=x,G(T)):(t.consume(T),x)}function S(T){return T===93?(t.consume(T),_):x(T)}function _(T){return T===62?z(T):T===93?(t.consume(T),_):x(T)}function A(T){return T===null||T===62?z(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?z(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):z(T)}function N(T){return T===45||gr(T)?(t.consume(T),N):T===47||T===62||Ot(T)?H(T):n(T)}function H(T){return T===47?(t.consume(T),z):T===58||T===95||Or(T)?(t.consume(T),j):Be(T)?(o=H,G(T)):lt(T)?(t.consume(T),H):z(T)}function j(T){return T===45||T===46||T===58||T===95||gr(T)?(t.consume(T),j):V(T)}function V(T){return T===61?(t.consume(T),q):Be(T)?(o=V,G(T)):lt(T)?(t.consume(T),V):H(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,X):Be(T)?(o=q,G(T)):lt(T)?(t.consume(T),q):(t.consume(T),Y)}function X(T){return T===i?(t.consume(T),i=void 0,te):T===null?n(T):Be(T)?(o=X,G(T)):(t.consume(T),X)}function Y(T){return T===null||T===34||T===39||T===60||T===61||T===96?n(T):T===47||T===62||Ot(T)?H(T):(t.consume(T),Y)}function te(T){return T===47||T===62||Ot(T)?H(T):n(T)}function z(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"),U}function U(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:h1e,resolveTo:f1e,tokenize:d1e},l1e={tokenize:p1e},c1e={tokenize:m1e},u1e={tokenize:g1e};function h1e(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 f1e(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,ww(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 d1e(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(xs(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(l1e,f,o?f:d)(m):m===91?t.attempt(c1e,f,o?h:d)(m):o?f(m):d(m)}function h(m){return t.attempt(u1e,f,d)(m)}function f(m){return e(m)}function d(m){return s._balanced=!0,n(m)}}function p1e(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):pW(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?gW(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 m1e(t,e,n){const r=this;return i;function i(a){return mW.call(r,t,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(xs(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(a):n(a)}function o(a){return n(a)}}function g1e(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 y1e={name:"labelStartImage",resolveAll:yR.resolveAll,tokenize:b1e};function b1e(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 v1e={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 y2={name:"lineEnding",tokenize:w1e};function w1e(t,e){return n;function n(r){return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),ut(t,e,"linePrefix")}}const Hb={name:"thematicBreak",tokenize:S1e};function S1e(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:E1e},exit:T1e,name:"list",tokenize:A1e},_1e={partial:!0,tokenize:R1e},C1e={partial:!0,tokenize:k1e};function A1e(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:rE(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(Hb,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 rE(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(rg,r.interrupt?n:f,t.attempt(_1e,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 E1e(t,e,n){const r=this;return r.containerState._closeFlow=void 0,t.check(rg,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(C1e,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 k1e(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 T1e(t){t.exit(this.containerState.type)}function R1e(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 a5={name:"setextUnderline",resolveTo:M1e,tokenize:O1e};function M1e(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 O1e(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 P1e={tokenize:F1e,partial:!0};function D1e(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:$1e,continuation:{tokenize:j1e},exit:B1e}},text:{91:{name:"gfmFootnoteCall",tokenize:N1e},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:I1e,resolveTo:L1e}}}}function I1e(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=xs(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 L1e(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 N1e(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(xs(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 $1e(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 x=t.exit("gfmFootnoteDefinitionLabelString");return s=xs(r.sliceSerialize(x)),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 j1e(t,e,n){return t.check(rg,e,t.attempt(P1e,e,n))}function B1e(t){t.exit("gfmFootnoteDefinition")}function F1e(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 z1e(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,ww(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 x=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&&!!x,S._close=!x||x===2&&!!_,a(b)}}}class V1e{constructor(){this.map=[]}add(e,n,r){U1e(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 U1e(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 H1e(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 W1e(){return{flow:{null:{name:"table",tokenize:q1e,resolveAll:G1e}}}}function q1e(t,e,n){const r=this;let i=0,s=0,o;return a;function a(j){let V=r.events.length-1;for(;V>-1;){const Y=r.events[V][1].type;if(Y==="lineEnding"||Y==="linePrefix")V--;else break}const q=V>-1?r.events[V][1].type:null,X=q==="tableHead"||q==="tableRow"?M:c;return X===M&&r.parser.lazy[r.now().line]?n(j):X(j)}function c(j){return t.enter("tableHead"),t.enter("tableRow"),h(j)}function h(j){return j===124||(o=!0,s+=1),f(j)}function f(j){return j===null?n(j):Be(j)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(j),t.exit("lineEnding"),y):n(j):lt(j)?ut(t,f,"whitespace")(j):(s+=1,o&&(o=!1,i+=1),j===124?(t.enter("tableCellDivider"),t.consume(j),t.exit("tableCellDivider"),o=!0,f):(t.enter("data"),d(j)))}function d(j){return j===null||j===124||Ot(j)?(t.exit("data"),f(j)):(t.consume(j),j===92?m:d)}function m(j){return j===92||j===124?(t.consume(j),d):d(j)}function y(j){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(j):(t.enter("tableDelimiterRow"),o=!1,lt(j)?ut(t,b,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):b(j))}function b(j){return j===45||j===58?S(j):j===124?(o=!0,t.enter("tableCellDivider"),t.consume(j),t.exit("tableCellDivider"),x):O(j)}function x(j){return lt(j)?ut(t,S,"whitespace")(j):S(j)}function S(j){return j===58?(s+=1,o=!0,t.enter("tableDelimiterMarker"),t.consume(j),t.exit("tableDelimiterMarker"),_):j===45?(s+=1,_(j)):j===null||Be(j)?P(j):O(j)}function _(j){return j===45?(t.enter("tableDelimiterFiller"),A(j)):O(j)}function A(j){return j===45?(t.consume(j),A):j===58?(o=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(j),t.exit("tableDelimiterMarker"),E):(t.exit("tableDelimiterFiller"),E(j))}function E(j){return lt(j)?ut(t,P,"whitespace")(j):P(j)}function P(j){return j===124?b(j):j===null||Be(j)?!o||i!==s?O(j):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(j)):O(j)}function O(j){return n(j)}function M(j){return t.enter("tableRow"),D(j)}function D(j){return j===124?(t.enter("tableCellDivider"),t.consume(j),t.exit("tableCellDivider"),D):j===null||Be(j)?(t.exit("tableRow"),e(j)):lt(j)?ut(t,D,"whitespace")(j):(t.enter("data"),N(j))}function N(j){return j===null||j===124||Ot(j)?(t.exit("data"),D(j)):(t.consume(j),j===92?H:N)}function H(j){return j===92||j===124?(t.consume(j),N):N(j)}}function G1e(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 V1e;for(;++n<t.length;){const y=t[n],b=y[1];y[0]==="enter"?b.type==="tableHead"?(a=!1,c!==0&&(l5(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=Ky(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=Ky(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=Ky(m,e,s,i,n,d)):o[1]!==0&&(d=Ky(m,e,o,i,n,d)),i=0):i&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(o[3]=n)}for(c!==0&&l5(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=H1e(e.events,n))}return t}function Ky(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,x=n[3]-n[2]-1;t.add(b,x,[])}}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 l5(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 K1e={name:"tasklistCheck",tokenize:X1e};function Y1e(){return{text:{91:K1e}}}function X1e(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:J1e},e,n)(c):n(c)}}function J1e(t,e,n){return ut(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function Q1e(t){return tW([lwe(),D1e(),z1e(t),W1e(),Y1e()])}const Z1e={};function eSe(t){const e=this,n=t||Z1e,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Q1e(n)),s.push(nwe()),o.push(rwe(n))}function yW(t,e){const n=e||{};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const tSe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nSe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rSe={};function c5(t,e){return(rSe.jsx?nSe:tSe).test(t)}const iSe=/[ \t\n\f\r]/g;function Sw(t){return typeof t=="object"?t.type==="text"?u5(t.value):!1:u5(t)}function u5(t){return t.replace(iSe,"")===""}class ig{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}}ig.prototype.normal={};ig.prototype.property={};ig.prototype.space=void 0;function bW(t,e){const n={},r={};for(const i of t)Object.assign(n,i.property),Object.assign(r,i.normal);return new ig(n,r,e)}function aE(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 sSe=0;const Qe=jc(),un=jc(),lE=jc(),ge=jc(),It=jc(),Eh=jc(),wi=jc();function jc(){return 2**++sSe}const cE=Object.freeze(Object.defineProperty({__proto__:null,boolean:Qe,booleanish:un,commaOrSpaceSeparated:wi,commaSeparated:Eh,number:ge,overloadedBoolean:lE,spaceSeparated:It},Symbol.toStringTag,{value:"Module"})),b2=Object.keys(cE);class bR extends ei{constructor(e,n,r,i){let s=-1;if(super(e,n),h5(this,"space",i),typeof r=="number")for(;++s<b2.length;){const o=b2[s];h5(this,b2[s],(r&cE[o])===cE[o])}}}bR.prototype.defined=!0;function h5(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[aE(r)]=r,n[aE(s.attribute)]=r}return new ig(e,n,t.space)}const vW=of({properties:{ariaActiveDescendant:null,ariaAtomic:un,ariaAutoComplete:null,ariaBusy:un,ariaChecked:un,ariaColCount:ge,ariaColIndex:ge,ariaColSpan:ge,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:ge,ariaLive:null,ariaModal:un,ariaMultiLine:un,ariaMultiSelectable:un,ariaOrientation:null,ariaOwns:It,ariaPlaceholder:null,ariaPosInSet:ge,ariaPressed:un,ariaReadOnly:un,ariaRelevant:null,ariaRequired:un,ariaRoleDescription:It,ariaRowCount:ge,ariaRowIndex:ge,ariaRowSpan:ge,ariaSelected:un,ariaSetSize:ge,ariaSort:null,ariaValueMax:ge,ariaValueMin:ge,ariaValueNow:ge,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 wW(t,e){return xW(t,e.toLowerCase())}const oSe=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:ge,colSpan:null,content:null,contentEditable:un,controls:Qe,controlsList:It,coords:ge|Eh,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Qe,defer:Qe,dir:null,dirName:null,disabled:Qe,download:lE,draggable:un,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Qe,formTarget:null,headers:It,height:ge,hidden:lE,high:ge,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:ge,manifest:null,max:null,maxLength:ge,media:null,method:null,min:null,minLength:ge,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:ge,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:ge,rowSpan:ge,sandbox:It,scope:null,scoped:Qe,seamless:Qe,selected:Qe,shadowRootClonable:Qe,shadowRootDelegatesFocus:Qe,shadowRootMode:null,shape:null,size:ge,sizes:null,slot:null,span:ge,spellCheck:un,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ge,step:null,style:null,tabIndex:ge,target:null,title:null,translate:null,type:null,typeMustMatch:Qe,useMap:null,value:un,width:ge,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:It,axis:null,background:null,bgColor:null,border:ge,borderColor:null,bottomMargin:ge,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:ge,leftMargin:ge,link:null,longDesc:null,lowSrc:null,marginHeight:ge,marginWidth:ge,noResize:Qe,noHref:Qe,noShade:Qe,noWrap:Qe,object:null,profile:null,prompt:null,rev:null,rightMargin:ge,rules:null,scheme:null,scrolling:un,standby:null,summary:null,text:null,topMargin:ge,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ge,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Qe,disableRemotePlayback:Qe,prefix:null,property:null,results:ge,security:null,unselectable:null},space:"html",transform:wW}),aSe=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:wi,accentHeight:ge,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ge,amplitude:ge,arabicForm:null,ascent:ge,attributeName:null,attributeType:null,azimuth:ge,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ge,by:null,calcMode:null,capHeight:ge,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:ge,diffuseConstant:ge,direction:null,display:null,dur:null,divisor:ge,dominantBaseline:null,download:Qe,dx:null,dy:null,edgeMode:null,editable:null,elevation:ge,enableBackground:null,end:null,event:null,exponent:ge,externalResourcesRequired:null,fill:null,fillOpacity:ge,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:ge,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ge,horizOriginX:ge,horizOriginY:ge,id:null,ideographic:ge,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ge,k:ge,k1:ge,k2:ge,k3:ge,k4:ge,kernelMatrix:wi,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ge,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:ge,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:ge,overlineThickness:ge,paintOrder:null,panose1:null,path:null,pathLength:ge,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:It,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ge,pointsAtY:ge,pointsAtZ:ge,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:wi,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:wi,rev:wi,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:wi,requiredFeatures:wi,requiredFonts:wi,requiredFormats:wi,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:ge,specularExponent:ge,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ge,strikethroughThickness:ge,string:null,stroke:null,strokeDashArray:wi,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ge,strokeOpacity:ge,strokeWidth:null,style:null,surfaceScale:ge,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:wi,tabIndex:ge,tableValues:null,target:null,targetX:ge,targetY:ge,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:wi,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ge,underlineThickness:ge,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ge,values:null,vAlphabetic:ge,vMathematical:ge,vectorEffect:null,vHanging:ge,vIdeographic:ge,version:null,vertAdvY:ge,vertOriginX:ge,vertOriginY:ge,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ge,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:xW}),SW=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()}}),_W=of({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:wW}),CW=of({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),lSe={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"},cSe=/[A-Z]/g,f5=/-[a-z]/g,uSe=/^data[-\w.:]+$/i;function AW(t,e){const n=aE(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"&&uSe.test(e)){if(e.charAt(4)==="-"){const s=e.slice(5).replace(f5,fSe);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=e.slice(4);if(!f5.test(s)){let o=s.replace(cSe,hSe);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}i=bR}return new i(r,e)}function hSe(t){return"-"+t.toLowerCase()}function fSe(t){return t.charAt(1).toUpperCase()}const EW=bW([vW,oSe,SW,_W,CW],"html"),sg=bW([vW,aSe,SW,_W,CW],"svg");function kW(t){return t.join(" ").trim()}var zu={},v2,d5;function dSe(){if(d5)return v2;d5=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";v2=function(x,S){if(typeof x!="string")throw new TypeError("First argument must be a string");if(!x)return[];S=S||{};var _=1,A=1;function E(X){var Y=X.match(e);Y&&(_+=Y.length);var te=X.lastIndexOf(c);A=~te?X.length-te:A+X.length}function P(){var X={line:_,column:A};return function(Y){return Y.position=new O(X),N(),Y}}function O(X){this.start=X,this.end={line:_,column:A},this.source=S.source}O.prototype.content=x;function M(X){var Y=new Error(S.source+":"+_+":"+A+": "+X);if(Y.reason=X,Y.filename=S.source,Y.line=_,Y.column=A,Y.source=x,!S.silent)throw Y}function D(X){var Y=X.exec(x);if(Y){var te=Y[0];return E(te),x=x.slice(te.length),Y}}function N(){D(n)}function H(X){var Y;for(X=X||[];Y=j();)Y!==!1&&X.push(Y);return X}function j(){var X=P();if(!(h!=x.charAt(0)||f!=x.charAt(1))){for(var Y=2;d!=x.charAt(Y)&&(f!=x.charAt(Y)||h!=x.charAt(Y+1));)++Y;if(Y+=2,d===x.charAt(Y-1))return M("End of comment missing");var te=x.slice(2,Y-2);return A+=2,E(te),x=x.slice(Y),A+=2,X({type:m,comment:te})}}function V(){var X=P(),Y=D(r);if(Y){if(j(),!D(i))return M("property missing ':'");var te=D(s),z=X({type:y,property:b(Y[0].replace(t,d)),value:te?b(te[0].replace(t,d)):d});return D(o),z}}function q(){var X=[];H(X);for(var Y;Y=V();)Y!==!1&&(X.push(Y),H(X));return X}return N(),q()};function b(x){return x?x.replace(a,d):d}return v2}var p5;function pSe(){if(p5)return zu;p5=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(dSe());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={},m5;function mSe(){if(m5)return jd;m5=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,g5;function gSe(){if(g5)return Bd;g5=1;var t=Bd&&Bd.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},e=t(pSe()),n=mSe();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 ySe=gSe();const bSe=Pc(ySe),TW=RW("end"),vR=RW("start");function RW(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 vSe(t){const e=vR(t),n=TW(t);if(e&&n)return{start:e,end:n}}function $p(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?y5(t.position):"start"in t||"end"in t?y5(t):"line"in t||"column"in t?uE(t):""}function uE(t){return b5(t&&t.line)+":"+b5(t&&t.column)}function y5(t){return uE(t&&t.start)+"-"+uE(t&&t.end)}function b5(t){return t&&typeof t=="number"?t:1}class xr 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}}xr.prototype.file="";xr.prototype.name="";xr.prototype.reason="";xr.prototype.message="";xr.prototype.stack="";xr.prototype.column=void 0;xr.prototype.line=void 0;xr.prototype.ancestors=void 0;xr.prototype.cause=void 0;xr.prototype.fatal=void 0;xr.prototype.place=void 0;xr.prototype.ruleId=void 0;xr.prototype.source=void 0;const xR={}.hasOwnProperty,xSe=new Map,wSe=/[A-Z]/g,SSe=new Set(["table","tbody","thead","tfoot","tr"]),_Se=new Set(["td","th"]),MW="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function OW(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=OSe(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=MSe(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"?sg:EW,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},s=PW(i,t,void 0);return s&&typeof s!="string"?s:i.create(t,i.Fragment,{children:s||void 0},void 0)}function PW(t,e,n){if(e.type==="element")return CSe(t,e,n);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return ASe(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return kSe(t,e,n);if(e.type==="mdxjsEsm")return ESe(t,e);if(e.type==="root")return TSe(t,e,n);if(e.type==="text")return RSe(t,e)}function CSe(t,e,n){const r=t.schema;let i=r;e.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=sg,t.schema=i),t.ancestors.push(e);const s=IW(t,e.tagName,!1),o=PSe(t,e);let a=SR(t,e);return SSe.has(e.tagName)&&(a=a.filter(function(c){return typeof c=="string"?!Sw(c):!0})),DW(t,o,s,e),wR(o,a),t.ancestors.pop(),t.schema=r,t.create(e,s,o,n)}function ASe(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 ESe(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);Em(t,e.position)}function kSe(t,e,n){const r=t.schema;let i=r;e.name==="svg"&&r.space==="html"&&(i=sg,t.schema=i),t.ancestors.push(e);const s=e.name===null?t.Fragment:IW(t,e.name,!0),o=DSe(t,e),a=SR(t,e);return DW(t,o,s,e),wR(o,a),t.ancestors.pop(),t.schema=r,t.create(e,s,o,n)}function TSe(t,e,n){const r={};return wR(r,SR(t,e)),t.create(e,t.Fragment,r,n)}function RSe(t,e){return e.value}function DW(t,e,n,r){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=r)}function wR(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function MSe(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 OSe(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 PSe(t,e){const n={};let r,i;for(i in e.properties)if(i!=="children"&&xR.call(e.properties,i)){const s=ISe(t,i,e.properties[i]);if(s){const[o,a]=s;t.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&_Se.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 DSe(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=PW(t,s,o);a!==void 0&&n.push(a)}return n}function ISe(t,e,n){const r=AW(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?yW(n):kW(n)),r.property==="style"){let i=typeof n=="object"?n:LSe(t,String(n));return t.stylePropertyNameCase==="css"&&(i=NSe(i)),["style",i]}return[t.elementAttributeNameCase==="react"&&r.space?lSe[r.property]||r.property:r.attribute,n]}}function LSe(t,e){try{return bSe(e,{reactCompat:!0})}catch(n){if(t.ignoreInvalidStyle)return{};const r=n,i=new xr("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=MW+"#cannot-parse-style-attribute",i}}function IW(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=c5(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=c5(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(r.type==="Literal"){const i=r.value;return xR.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 xr("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=MW+"#cannot-handle-mdx-estrees-without-createevaluater",n}function NSe(t){const e={};let n;for(n in t)xR.call(t,n)&&(e[$Se(n)]=t[n]);return e}function $Se(t){let e=t.replace(wSe,jSe);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function jSe(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"]},BSe={tokenize:FSe};function FSe(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 zSe={tokenize:VSe},v5={tokenize:USe};function VSe(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(v5,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(v5,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}),x(E)}function x(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),x)}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 N=D,H,j;for(;N--;)if(e.events[N][0]==="exit"&&e.events[N][1].type==="chunkFlow"){if(H){j=e.events[N][1].end;break}H=!0}for(_(r),M=D;M<e.events.length;)e.events[M][1].end={...j},M++;ki(e.events,N+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 USe(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 HSe={tokenize:WSe};function WSe(t){const e=this,n=t.attempt(rg,r,t.attempt(this.parser.constructs.flowInitial,i,ut(t,t.attempt(this.parser.constructs.flow,i,t.attempt(jwe,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 qSe={resolveAll:NW()},GSe=LW("string"),KSe=LW("text");function LW(t){return{resolveAll:NW(t==="text"?YSe: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 NW(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 YSe(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 XSe={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:uW},JSe={91:Uwe},QSe={[-2]:g2,[-1]:g2,32:g2},ZSe={35:Ywe,42:Hb,45:[a5,Hb],60:Zwe,61:a5,95:Hb,96:s5,126:s5},e_e={38:fW,92:hW},t_e={[-5]:y2,[-4]:y2,[-3]:y2,33:y1e,38:fW,42:oE,60:[vwe,o1e],91:v1e,92:[Gwe,hW],93:yR,95:oE,96:Pwe},n_e={null:[oE,qSe]},r_e={null:[42,95]},i_e={null:[]},s_e=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:r_e,contentInitial:JSe,disable:i_e,document:XSe,flow:ZSe,flowInitial:QSe,insideSpan:n_e,string:e_e,text:t_e},Symbol.toStringTag,{value:"Module"}));function o_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:x,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(V){return o=qi(o,V),S(),o[o.length-1]!==null?[]:(N(e,0),h.events=ww(s,h.events,h),h.events)}function m(V,q){return l_e(y(V),q)}function y(V){return a_e(o,V)}function b(){const{_bufferIndex:V,_index:q,line:X,column:Y,offset:te}=r;return{_bufferIndex:V,_index:q,line:X,column:Y,offset:te}}function x(V){i[V.line]=V.column,j()}function S(){let V;for(;r._index<o.length;){const q=o[r._index];if(typeof q=="string")for(V=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===V&&r._bufferIndex<q.length;)_(q.charCodeAt(r._bufferIndex));else _(q)}}function _(V){f=f(V)}function A(V){Be(V)?(r.line++,r.column=1,r.offset+=V===-3?2:1,j()):V!==-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=V}function E(V,q){const X=q||{};return X.type=V,X.start=b(),h.events.push(["enter",X,h]),a.push(X),X}function P(V){const q=a.pop();return q.end=b(),h.events.push(["exit",q,h]),q}function O(V,q){N(V,q.from)}function M(V,q){q.restore()}function D(V,q){return X;function X(Y,te,z){let G,U,se,T;return Array.isArray(Y)?ue(Y):"tokenize"in Y?ue([Y]):Z(Y);function Z(ye){return Ee;function Ee(Ue){const Pt=Ue!==null&&ye[Ue],Kt=Ue!==null&&ye.null,Yt=[...Array.isArray(Pt)?Pt:Pt?[Pt]:[],...Array.isArray(Kt)?Kt:Kt?[Kt]:[]];return ue(Yt)(Ue)}}function ue(ye){return G=ye,U=0,ye.length===0?z:L(ye[U])}function L(ye){return Ee;function Ee(Ue){return T=H(),se=ye,ye.partial||(h.currentConstruct=ye),ye.name&&h.parser.constructs.disable.null.includes(ye.name)?ke():ye.tokenize.call(q?Object.assign(Object.create(h),q):h,c,de,ke)(Ue)}}function de(ye){return V(se,T),te}function ke(ye){return T.restore(),++U<G.length?L(G[U]):z}}}function N(V,q){V.resolveAll&&!s.includes(V)&&s.push(V),V.resolve&&ki(h.events,q,h.events.length-q,V.resolve(h.events.slice(q),h)),V.resolveTo&&(h.events=V.resolveTo(h.events,h))}function H(){const V=b(),q=h.previous,X=h.currentConstruct,Y=h.events.length,te=Array.from(a);return{from:Y,restore:z};function z(){r=V,h.previous=q,h.currentConstruct=X,h.events.length=Y,a=te,j()}}function j(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function a_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 l_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 c_e(t){const r={constructs:tW([s_e,...(t||{}).extensions||[]]),content:i(BSe),defined:[],document:i(zSe),flow:i(HSe),lazy:{},string:i(GSe),text:i(KSe)};return r;function i(s){return o;function o(a){return o_e(r,s,a)}}}function u_e(t){for(;!dW(t););return t}const x5=/[\0\t\n\r]/g;function h_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(x5.lastIndex=d,h=x5.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 $W={}.hasOwnProperty;function f_e(t,e,n){return typeof e!="string"&&(n=e,e=void 0),d_e(n)(u_e(c_e(n).document().write(h_e()(t,e,!0))))}function d_e(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(kl),autolinkProtocol:H,autolinkEmail:H,atxHeading:s(_o),blockQuote:s(Kt),characterEscape:H,characterReference:H,codeFenced:s(Yt),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Yt,o),codeText:s(er,o),codeTextData:H,data:H,codeFlowValue:H,definition:s(tr),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(ti),hardBreakEscape:s(ss),hardBreakTrailing:s(ss),htmlFlow:s(nr,o),htmlFlowData:H,htmlText:s(nr,o),htmlTextData:H,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:j,characterReferenceMarkerHexadecimal:ke,characterReferenceMarkerNumeric:ke,characterReferenceValue:ye,characterReference:Ee,codeFenced:c(S),codeFencedFence:x,codeFencedFenceInfo:y,codeFencedFenceMeta:b,codeFlowValue:j,codeIndented:c(_),codeText:c(te),codeTextData:j,data:j,definition:c(),definitionDestinationString:P,definitionLabelString:A,definitionTitleString:E,emphasis:c(),hardBreakEscape:c(q),hardBreakTrailing:c(q),htmlFlow:c(X),htmlFlowData:j,htmlText:c(Y),htmlTextData:j,image:c(G),label:se,labelText:U,lineEnding:V,link:c(z),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:de,resourceDestinationString:T,resourceTitleString:Z,resource:ue,setextHeading:c(N),setextHeadingLineSequence:D,setextHeadingText:M,strong:c(),thematicBreak:c()}};jW(e,(t||{}).mdastExtensions||[]);const n={};return r;function r(oe){let me={type:"root",children:[]};const De={stack:[me],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]];$W.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]||w5).call(De,void 0,Sr[0])}for(me.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;)me=e.transforms[yt](me)||me;return me}function i(oe,me,De){let $e=me-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[me][1]._spread=Sr,De}function s(oe,me){return De;function De($e){a.call(this,oe($e),$e),me&&me.call(this,$e)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(oe,me,De){this.stack[this.stack.length-1].children.push(oe),this.stack.push(oe),this.tokenStack.push([me,De||void 0]),oe.position={start:Ga(me.start),end:void 0}}function c(oe){return me;function me(De){oe&&oe.call(this,De),h.call(this,De)}}function h(oe,me){const De=this.stack.pop(),$e=this.tokenStack.pop();if($e)$e[0].type!==oe.type&&(me?me.call(this,oe,$e[0]):($e[1]||w5).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 me=this.stack[this.stack.length-2];me.start=Number.parseInt(this.sliceSerialize(oe),10),this.data.expectingFirstListItemValue=void 0}}function y(){const oe=this.resume(),me=this.stack[this.stack.length-1];me.lang=oe}function b(){const oe=this.resume(),me=this.stack[this.stack.length-1];me.meta=oe}function x(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const oe=this.resume(),me=this.stack[this.stack.length-1];me.value=oe.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const oe=this.resume(),me=this.stack[this.stack.length-1];me.value=oe.replace(/(\r?\n|\r)$/g,"")}function A(oe){const me=this.resume(),De=this.stack[this.stack.length-1];De.label=me,De.identifier=xs(this.sliceSerialize(oe)).toLowerCase()}function E(){const oe=this.resume(),me=this.stack[this.stack.length-1];me.title=oe}function P(){const oe=this.resume(),me=this.stack[this.stack.length-1];me.url=oe}function O(oe){const me=this.stack[this.stack.length-1];if(!me.depth){const De=this.sliceSerialize(oe).length;me.depth=De}}function M(){this.data.setextHeadingSlurpLineEnding=!0}function D(oe){const me=this.stack[this.stack.length-1];me.depth=this.sliceSerialize(oe).codePointAt(0)===61?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function H(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 j(oe){const me=this.stack.pop();me.value+=this.sliceSerialize(oe),me.position.end=Ga(oe.end)}function V(oe){const me=this.stack[this.stack.length-1];if(this.data.atHardBreak){const De=me.children[me.children.length-1];De.position.end=Ga(oe.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(me.type)&&(H.call(this,oe),j.call(this,oe))}function q(){this.data.atHardBreak=!0}function X(){const oe=this.resume(),me=this.stack[this.stack.length-1];me.value=oe}function Y(){const oe=this.resume(),me=this.stack[this.stack.length-1];me.value=oe}function te(){const oe=this.resume(),me=this.stack[this.stack.length-1];me.value=oe}function z(){const oe=this.stack[this.stack.length-1];if(this.data.inReference){const me=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=me,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 me=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=me,delete oe.url,delete oe.title}else delete oe.identifier,delete oe.label;this.data.referenceType=void 0}function U(oe){const me=this.sliceSerialize(oe),De=this.stack[this.stack.length-2];De.label=Uxe(me),De.identifier=xs(me).toLowerCase()}function se(){const oe=this.stack[this.stack.length-1],me=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=me}function T(){const oe=this.resume(),me=this.stack[this.stack.length-1];me.url=oe}function Z(){const oe=this.resume(),me=this.stack[this.stack.length-1];me.title=oe}function ue(){this.data.inReference=void 0}function L(){this.data.referenceType="collapsed"}function de(oe){const me=this.resume(),De=this.stack[this.stack.length-1];De.label=me,De.identifier=xs(this.sliceSerialize(oe)).toLowerCase(),this.data.referenceType="full"}function ke(oe){this.data.characterReferenceType=oe.type}function ye(oe){const me=this.sliceSerialize(oe),De=this.data.characterReferenceType;let $e;De?($e=eW(me,De==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):$e=mR(me);const yt=this.stack[this.stack.length-1];yt.value+=$e}function Ee(oe){const me=this.stack.pop();me.position.end=Ga(oe.end)}function Ue(oe){j.call(this,oe);const me=this.stack[this.stack.length-1];me.url=this.sliceSerialize(oe)}function Pt(oe){j.call(this,oe);const me=this.stack[this.stack.length-1];me.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 jW(t,e){let n=-1;for(;++n<e.length;){const r=e[n];Array.isArray(r)?jW(t,r):p_e(t,r)}}function p_e(t,e){let n;for(n in e)if($W.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 w5(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 m_e(t){const e=this;e.parser=n;function n(r){return f_e(r,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function g_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 y_e(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:`
`}]}function b_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 v_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 w_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 S_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 __e(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}}function BW(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 C_e(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return BW(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 A_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 E_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 k_e(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return BW(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 T_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 R_e(t,e,n){const r=t.all(e),i=n?M_e(n):FW(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 M_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=FW(n[r])}return e}function FW(t){const e=t.spread;return e??t.children.length>1}function O_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 P_e(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function D_e(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)}function I_e(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function L_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=TW(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 N_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 $_e(t,e){const n={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}const S5=9,_5=32;function j_e(t){const e=String(t),n=/\r?\n|\r/g;let r=n.exec(e),i=0;const s=[];for(;r;)s.push(C5(e.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(e);return s.push(C5(e.slice(i),i>0,!1)),s.join("")}function C5(t,e,n){let r=0,i=t.length;if(e){let s=t.codePointAt(r);for(;s===S5||s===_5;)r++,s=t.codePointAt(r)}if(n){let s=t.codePointAt(i-1);for(;s===S5||s===_5;)i--,s=t.codePointAt(i-1)}return i>r?t.slice(r,i):""}function B_e(t,e){const n={type:"text",value:j_e(String(e.value))};return t.patch(e,n),t.applyData(e,n)}function F_e(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)}const z_e={blockquote:g_e,break:y_e,code:b_e,delete:v_e,emphasis:x_e,footnoteReference:w_e,heading:S_e,html:__e,imageReference:C_e,image:A_e,inlineCode:E_e,linkReference:k_e,link:T_e,listItem:R_e,list:O_e,paragraph:P_e,root:D_e,strong:I_e,table:L_e,tableCell:$_e,tableRow:N_e,text:B_e,thematicBreak:F_e,toml:Yy,yaml:Yy,definition:Yy,footnoteDefinition:Yy};function Yy(){}const zW=-1,_w=0,jp=1,tx=2,_R=3,CR=4,AR=5,ER=6,VW=7,UW=8,A5=typeof self=="object"?self:globalThis,V_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 _w:case zW:return n(o,i);case jp:{const a=n([],i);for(const c of o)a.push(r(c));return a}case tx:{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 VW:{const{name:a,message:c}=o;return n(new A5[a](c),i)}case UW: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 A5[s](o),i)};return r},E5=t=>V_e(new Map,t)(0),Vu="",{toString:U_e}={},{keys:H_e}=Object,Fd=t=>{const e=typeof t;if(e!=="object"||!t)return[_w,e];const n=U_e.call(t).slice(8,-1);switch(n){case"Array":return[jp,Vu];case"Object":return[tx,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")?[VW,n]:[tx,n]},Xy=([t,e])=>t===_w&&(e==="function"||e==="symbol"),W_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 _w:{let f=o;switch(c){case"bigint":a=UW,f=o.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+c);f=null;break;case"undefined":return i([zW],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 tx:{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 H_e(o))(t||!Xy(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||!(Xy(Fd(m))||Xy(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||!Xy(Fd(m)))&&f.push(s(m));return d}}const{message:h}=o;return i([a,{name:c,message:h}],o)};return s},k5=(t,{json:e,lossy:n}={})=>{const r=[];return W_e(!(e||n),!!e,new Map,r)(t),r},nx=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?E5(k5(t,e)):structuredClone(t):(t,e)=>E5(k5(t,e));function q_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 G_e(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function K_e(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=t.options.footnoteBackContent||q_e,r=t.options.footnoteBackLabel||G_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=[],x=t.footnoteCounts.get(d);for(;x!==void 0&&++y<=x;){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:{...nx(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 hE={}.hasOwnProperty,Y_e={};function X_e(t,e){const n=e||Y_e,r=new Map,i=new Map,s=new Map,o={...z_e,...n.handlers},a={all:h,applyData:Q_e,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:c,options:n,patch:J_e,wrap:e2e};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(hE.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:x,...S}=f,_=nx(S);return _.children=a.all(f),_}return nx(f)}return(a.options.unknownHandler||Z_e)(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=T5(b.value)),!Array.isArray(b)&&b.type==="element")){const x=b.children[0];x&&x.type==="text"&&(x.value=T5(x.value))}Array.isArray(b)?d.push(...b):d.push(b)}}}return d}}function J_e(t,e){t.position&&(e.position=vSe(t))}function Q_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,nx(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function Z_e(t,e){const n=e.data||{},r="value"in e&&!(hE.call(n,"hProperties")||hE.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 e2e(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 T5(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function R5(t,e){const n=X_e(t,e),r=n.one(t,void 0),i=K_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 t2e(t,e){return t&&"run"in t?async function(n,r){const i=R5(n,{file:r,...e});await t.run(i,r)}:function(n,r){return R5(n,{file:r,...t||e})}}function M5(t){if(t)throw t}var w2,O5;function n2e(){if(O5)return w2;O5=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 w2=function c(){var h,f,d,m,y,b,x=arguments[0],S=1,_=arguments.length,A=!1;for(typeof x=="boolean"&&(A=x,x=arguments[1]||{},S=2),(x==null||typeof x!="object"&&typeof x!="function")&&(x={});S<_;++S)if(h=arguments[S],h!=null)for(f in h)d=a(x,f),m=a(h,f),x!==m&&(A&&m&&(s(m)||(y=i(m)))?(y?(y=!1,b=d&&i(d)?d:[]):b=d&&s(d)?d:{},o(x,{name:f,newValue:c(A,b,m)})):typeof m<"u"&&o(x,{name:f,newValue:m}));return x},w2}var r2e=n2e();const S2=Pc(r2e);function fE(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 i2e(){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?s2e(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 s2e(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:o2e,dirname:a2e,extname:l2e,join:c2e,sep:"/"};function o2e(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');og(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 a2e(t){if(og(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 l2e(t){og(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 c2e(...t){let e=-1,n;for(;++e<t.length;)og(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":u2e(n)}function u2e(t){og(t);const e=t.codePointAt(0)===47;let n=h2e(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function h2e(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 og(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const f2e={cwd:d2e};function d2e(){return"/"}function dE(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function p2e(t){if(typeof t=="string")t=new URL(t);else if(!dE(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 m2e(t)}function m2e(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 _2=["history","path","basename","stem","extname","dirname"];class HW{constructor(e){let n;e?dE(e)?n={path:e}:typeof e=="string"||g2e(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":f2e.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<_2.length;){const s=_2[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)_2.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Js.basename(this.path):void 0}set basename(e){A2(e,"basename"),C2(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){P5(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(C2(e,"extname"),P5(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){dE(e)&&(e=p2e(e)),A2(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){A2(e,"stem"),C2(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 xr(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 C2(t,e){if(t&&t.includes(Js.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Js.sep+"`")}function A2(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function P5(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function g2e(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const y2e=(function(t){const r=this.constructor.prototype,i=r[t],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),b2e={}.hasOwnProperty;class kR extends y2e{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=i2e()}copy(){const e=new kR;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];e.use(...r)}return e.data(S2(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(T2("data",this.frozen),this.namespace[e]=n,this):b2e.call(this.namespace,e)&&this.namespace[e]||void 0:e?(T2("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=Jy(e),r=this.parser||this.Parser;return E2("parse",r),r(String(n),n)}process(e,n){const r=this;return this.freeze(),E2("process",this.parser||this.Parser),k2("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const a=Jy(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);w2e(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(),E2("processSync",this.parser||this.Parser),k2("processSync",this.compiler||this.Compiler),this.process(e,i),I5("processSync","process",n),r;function i(s,o){n=!0,M5(s),r=o}}run(e,n,r){D5(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=Jy(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),I5("runSync","run",r),i;function s(o,a){M5(o),i=a,r=!0}}stringify(e,n){this.freeze();const r=Jy(n),i=this.compiler||this.Compiler;return k2("stringify",i),D5(e),i(e,r)}use(e,...n){const r=this.attachers,i=this.namespace;if(T2("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=S2(!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 x=r[m][1];fE(x)&&fE(y)&&(y=S2(!0,x,y)),r[m]=[h,y,...b]}}}}const v2e=new kR().freeze();function E2(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function k2(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function T2(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 D5(t){if(!fE(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function I5(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Jy(t){return x2e(t)?t:new HW(t)}function x2e(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function w2e(t){return typeof t=="string"||S2e(t)}function S2e(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const _2e="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",L5=[],N5={allowDangerousHtml:!0},C2e=/^(https?|ircs?|mailto|xmpp)$/i,A2e=[{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 E2e(t){const e=k2e(t),n=T2e(t);return R2e(e.runSync(e.parse(n),n),t)}function k2e(t){const e=t.rehypePlugins||L5,n=t.remarkPlugins||L5,r=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...N5}:N5;return v2e().use(m_e).use(n).use(t2e,r).use(e)}function T2e(t){const e=t.children||"",n=new HW;return typeof e=="string"&&(n.value=e),n}function R2e(t,e){const n=e.allowedElements,r=e.allowElement,i=e.components,s=e.disallowedElements,o=e.skipHtml,a=e.unwrapDisallowed,c=e.urlTransform||M2e;for(const f of A2e)Object.hasOwn(e,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+_2e+f.id,void 0);return fR(t,h),OW(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],x=x2[y];(x===null||x.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 M2e(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||C2e.test(t.slice(0,e))?t:""}var O2e=(t,e)=>typeof t=="string"?t===e:JSON.stringify(t)===JSON.stringify(e),P2e=(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))&&O2e(t.children,e.children)},TR=(t,e)=>P2e(t.node,e.node),D2e=(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),WW=()=>k.useContext(RR)!==null,I2e=({children:t,...e})=>C.jsx(RR.Provider,{value:e,children:t}),L2e=k.memo(I2e,TR),N2e=({node:t,...e})=>C.jsx("pre",{...e}),$2e=({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})}),j2e=()=>null,B2e=({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})]})},R2={exports:{}};/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/var $5;function F2e(){return $5||($5=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})()})(R2)),R2.exports}var z2e=F2e();const qW=Pc(z2e);var j5=({className:t,...e})=>({className:n,...r})=>({className:qW(t,n),...e,...r}),V2e=({node:t,components:{Pre:e,Code:n,SyntaxHighlighter:r,CodeHeader:i},componentsByLanguage:s={},children:o,...a})=>{const c=k.useContext(RR),h=j5(c),f=Lr(S=>C.jsx(e,{...h(S)})),d=j5(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,x=s[y]?.CodeHeader??i;return C.jsx(B2e,{node:t,components:{Pre:f,Code:m,SyntaxHighlighter:b,CodeHeader:x},language:y||"unknown",code:o})},U2e=({node:t,components:e,componentsByLanguage:n,...r})=>WW()?C.jsx(V2e,{node:t,components:e,componentsByLanguage:n,...r}):C.jsx(e.Code,{...r}),H2e=k.memo(U2e,(t,e)=>t.components===e.components&&t.componentsByLanguage===e.componentsByLanguage&&TR(t,e)),{useSmooth:W2e,useSmoothStatus:q2e,withSmoothContextProvider:G2e}=qX,K2e=({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}=W2e(o,n),{pre:c=N2e,code:h=$2e,SyntaxHighlighter:f=MR,CodeHeader:d=j2e}=t??{},m=k.useMemo(()=>({Pre:c,Code:h,SyntaxHighlighter:f,CodeHeader:d}),[c,h,f,d]),y=Lr(x=>C.jsx(H2e,{components:m,componentsByLanguage:e,...x})),b=k.useMemo(()=>{const{pre:x,code:S,SyntaxHighlighter:_,CodeHeader:A,...E}=t??{};return{...E,pre:L2e,code:y}},[y,t]);return C.jsx(E2e,{components:b,...i,children:a})},GW=k.forwardRef(({className:t,containerProps:e,containerComponent:n="div",...r},i)=>{const s=q2e();return C.jsx(n,{"data-status":s.type,...e,className:qW(t,e?.className),ref:i,children:C.jsx(K2e,{...r})})});GW.displayName="MarkdownTextPrimitive";var Y2e=G2e(GW),B5=Object.prototype.hasOwnProperty;function F5(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=F5(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=F5(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(B5.call(t,n)&&++r&&!B5.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 M2=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])},X2e=(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)},KW=(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 J2e(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 Q2e(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 z5={light:"github-light",dark:"github-dark"},Z2e=(t,e,n,r,i={})=>{const[s,o]=k.useState(null),[a,c]=M2(e),[h,f]=M2(n),[d,m]=M2(i),{languageId:y,langsToLoad:b}=k.useMemo(()=>KW(a,d.customLanguages,d.langAlias),[a,d.customLanguages,d.langAlias]),{isMultiTheme:x,themeId:S,multiTheme:_,singleTheme:A,themesToLoad:E}=k.useMemo(()=>J2e(h),[h]),P=k.useRef({nextAllowedTime:0,timeoutId:void 0}),O=k.useMemo(()=>{const M={lang:y},{defaultColor:D,cssVariablePrefix:N,showLineNumbers:H,startingLineNumber:j,...V}=d,q=x?{themes:_||z5,defaultColor:D,cssVariablePrefix:N}:{theme:A||z5.dark},X=V.transformers||[];return H&&X.push(Q2e(j)),{...M,...q,...V,transformers:X}},[y,S,c,f,m]);return k.useEffect(()=>{let M=!0;const D=async()=>{if(!y)return;const H=d.highlighter?d.highlighter:await r(b,E),V=H.getLoadedLanguages().includes(y)?y:"plaintext",q={...O,lang:V};if(M){const X=d.outputFormat==="html"?H.codeToHtml(t,q):OW(H.codeToHast(t,q),{jsx:C.jsx,jsxs:C.jsxs,Fragment:C.Fragment});o(X)}},{delay:N}=d;return N?X2e(D,P,N):D().catch(console.error),()=>{M=!1,clearTimeout(P.current.timeoutId)}},[t,O,d.delay,d.highlighter,b,E]),s};function eCe(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))}eCe(`.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 tCe=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:x,as:S="pre",customLanguages:_,...A},E)=>{const P={delay:r,transformers:i,customLanguages:_,showLineNumbers:y,defaultColor:s,cssVariablePrefix:o,startingLineNumber:b,...A},{displayLanguageId:O}=KW(e,_),M=t(x,e,n,P),D=typeof M=="string";return C.jsxs(S,{ref:E,"data-testid":"shiki-container",className:gv("relative","not-prose",a&&"defaultStyles",f),style:c,id:"shiki-container",children:[m&&O?C.jsx("span",{className:gv("languageLabel",d),style:h,id:"language-label",children:O}):null,D?C.jsx("div",{dangerouslySetInnerHTML:{__html:M}}):M]})});const nCe="modulepreload",rCe=function(t){return"/"+t},V5={},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=rCe(f),f in V5)return;V5[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":nCe,d||(y.as="script"),y.crossOrigin="",y.href=f,c&&y.setAttribute("nonce",c),document.head.appendChild(y),d)return new Promise((b,x)=>{y.addEventListener("load",b),y.addEventListener("error",()=>x(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 iCe(t){return OR(t)}function OR(t){return Array.isArray(t)?sCe(t):t instanceof RegExp?t:typeof t=="object"?oCe(t):t}function sCe(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=OR(t[n]);return e}function oCe(t){let e={};for(let n in t)e[n]=OR(t[n]);return e}function YW(t,...e){return e.forEach(n=>{for(let r in n)t[r]=n[r]}),t}function XW(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?XW(t.substring(0,t.length-1)):t.substr(~e+1)}var O2=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Qy=class{static hasCaptures(t){return t===null?!1:(O2.lastIndex=0,O2.test(t))}static replaceCaptures(t,e,n){return t.replace(O2,(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 JW(t,e){return t<e?-1:t>e?1:0}function QW(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=JW(t[i],e[i]);if(s!==0)return s}return 0}return n-r}function U5(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 ZW(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var eq=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}},rx=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(cCe(t),e)}static createFromParsedTheme(t,e){return hCe(t,e)}_cachedMatchRoot=new eq(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=>aCe(t.parent,i.parentScopes));return r?new tq(r.fontStyle,r.foreground,r.background):null}},P2=class Wb{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const r of n)e=new Wb(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new Wb(n,e[r]);return n}push(e){return new Wb(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 aCe(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&&!lCe(t.scopeName,r);){if(i)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function lCe(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var tq=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function cCe(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"&&U5(o.settings.foreground)&&(h=o.settings.foreground);let f=null;typeof o.settings.background=="string"&&U5(o.settings.background)&&(f=o.settings.background);for(let d=0,m=a.length;d<m;d++){let b=a[d].trim().split(" "),x=b[b.length-1],S=null;b.length>1&&(S=b.slice(0,b.length-1),S.reverse()),n[r++]=new uCe(x,S,i,c,h,f)}}return n}var uCe=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 hCe(t,e){t.sort((c,h)=>{let f=JW(c.scope,h.scope);return f!==0||(f=QW(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 fCe(e),o=new tq(n,s.getId(r),s.getId(i)),a=new pCe(new pE(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 rx(s,o,a)}var fCe=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)}},dCe=Object.freeze([]),pE=class nq{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,i,s){this.scopeDepth=e,this.parentScopes=n||dCe,this.fontStyle=r,this.foreground=i,this.background=s}clone(){return new nq(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)}},pCe=class mE{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(mE._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 mE(this._mainRule.clone(),pE.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(QW(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 pE(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 ix(t,e){const n=[],r=mCe(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(H5(i)){const c=[];do c.push(i),i=r.next();while(H5(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 H5(t){return!!t&&!!t.match(/[\w\.:]+/)}function mCe(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 rq(t){typeof t.dispose=="function"&&t.dispose()}var km=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},gCe=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},yCe=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))}},bCe=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 yCe;for(const n of t)vCe(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 vCe(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?qb({baseGrammar:s,selfGrammar:i},r):gE(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 gE(t,e,n){if(e.repository&&e.repository[t]){const r=e.repository[t];sx([r],e,n)}}function qb(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&sx(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&sx(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function sx(t,e,n){for(const r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const i=r.repository?YW({},e.repository,r.repository):e.repository;Array.isArray(r.patterns)&&sx(r.patterns,{...e,repository:i},n);const s=r.include;if(!s)continue;const o=iq(s);switch(o.kind){case 0:qb({...e,selfGrammar:e.baseGrammar},n);break;case 1:qb(e,n);break;case 2:gE(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?gE(o.ruleName,c,n):qb(c,n)}else o.kind===4?n.add(new gCe(o.scopeName,o.ruleName)):n.add(new km(o.scopeName));break}}}var xCe=class{kind=0},wCe=class{kind=1},SCe=class{constructor(t){this.ruleName=t}kind=2},_Ce=class{constructor(t){this.scopeName=t}kind=3},CCe=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function iq(t){if(t==="$base")return new xCe;if(t==="$self")return new wCe;const e=t.indexOf("#");if(e===-1)return new _Ce(t);if(e===0)return new SCe(t.substring(1));{const n=t.substring(0,e),r=t.substring(e+1);return new CCe(n,r)}}var ACe=/\\(\d+)/,W5=/\\(\d+)/g,ECe=-1,sq=-2;var ag=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=Qy.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Qy.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${XW(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:Qy.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Qy.replaceCaptures(this._contentName,t,e)}},kCe=class extends ag{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!")}},TCe=class extends ag{_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}},q5=class extends ag{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}},yE=class extends ag{_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}},ox=class extends ag{_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,sq),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}},oq=class ur{static createCaptureRule(e,n,r,i,s){return e.registerRule(o=>new kCe(n,o,r,i,s))}static getCompiledRuleId(e,n,r){return e.id||n.registerRule(i=>{if(e.id=i,e.match)return new TCe(e.$vscodeTextmateLocation,e.id,e.name,e.match,ur._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){e.repository&&(r=YW({},r,e.repository));let s=e.patterns;return typeof s>"u"&&e.include&&(s=[{include:e.include}]),new q5(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,ur._compilePatterns(s,n,r))}return e.while?new ox(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 yE(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=iq(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 q5||h instanceof yE||h instanceof ox)&&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 aq{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=ACe.test(this.source):this.hasBackReferences=!1}clone(){return new aq(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 W5.lastIndex=0,this.source.replace(W5,(i,s)=>ZW(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 G5(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 G5(t,r,this._items.map(i=>i.ruleId))}},G5=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}},D2=class{constructor(t,e){this.languageId=t,this.tokenType=e}},RCe=class bE{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,n){this._defaultAttributes=new D2(e,8),this._embeddedLanguagesMatcher=new MCe(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?bE._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new D2(0,0);_getBasicScopeAttributes=new eq(e=>{const n=this._scopeToLanguage(e),r=this._toStandardTokenType(e);return new D2(n,r)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const n=e.match(bE.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/},MCe=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])=>ZW(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])}},K5=class{constructor(t,e){this.stack=t,this.stoppedEarly=e}};function lq(t,e,n,r,i,s,o,a){const c=e.content.length;let h=!1,f=-1;if(o){const y=OCe(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 K5(i,!0);m()}return new K5(i,!1);function m(){const y=PCe(t,e,n,r,i,f);if(!y){s.produce(i,c),h=!0;return}const b=y.captureIndices,x=y.matchedRuleId,S=b&&b.length>0?b[0].end>r:!1;if(x===ECe){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(x);s.produce(i,b[0].start);const A=i,E=_.getName(e.content,b),P=i.contentNameScopesList.pushAttributed(E,t);if(i=i.push(x,r,f,b[0].end===c,null,P,P),_ instanceof yE){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 ox){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 OCe(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 ox&&a.push({rule:h,stack:c})}for(let c=a.pop();c;c=a.pop()){const{ruleScanner:h,findOptions:f}=LCe(c.rule,t,c.stack.endRule,n,r===o),d=h.findNextMatchSync(e,r,f);if(d){if(d.ruleId!==sq){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 PCe(t,e,n,r,i,s){const o=DCe(t,e,n,r,i,s),a=t.getInjections();if(a.length===0)return o;const c=ICe(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 DCe(t,e,n,r,i,s){const o=i.getRule(t),{ruleScanner:a,findOptions:c}=cq(o,t,i.endRule,n,r===s),h=a.findNextMatchSync(e,r,c);return h?{captureIndices:h.captureIndices,matchedRuleId:h.ruleId}:null}function ICe(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 x=e.getRule(b.ruleId),{ruleScanner:S,findOptions:_}=cq(x,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 cq(t,e,n,r,i){return{ruleScanner:t.compileAG(e,n,r,i),findOptions:0}}function LCe(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 x=m.getName(a,o),S=r.contentNameScopesList.pushAttributed(x,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));lq(t,P,n&&y.start===0,y.start,E,i,!1,0),rq(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 NCe(S,y.end))}}for(;h.length>0;)i.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop()}var NCe=class{scopes;endPos;constructor(t,e){this.scopes=t,this.endPos=e}};function $Ce(t,e,n,r,i,s,o,a){return new BCe(t,e,n,r,i,s,o,a)}function Y5(t,e,n,r,i){const s=ix(e,ax),o=oq.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 ax(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(jCe(e[i],r))return n=i+1,!0;return!1})}function jCe(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 BCe=class{constructor(t,e,n,r,i,s,o,a){if(this._rootScopeName=t,this.balancedBracketSelectors=s,this._onigLib=a,this._basicScopeAttributesProvider=new RCe(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=X5(e,null),this._injections=null,this._tokenTypeMatchers=[],i)for(const c of Object.keys(i)){const h=ix(c,ax);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)Y5(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&&Y5(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]=X5(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=oq.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!e||e===vE.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 vE(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 zCe(n,t,this._tokenTypeMatchers,this.balancedBracketSelectors),c=lq(this,s,i,0,e,a,!0,r);return rq(s),{lineLength:o,lineTokens:a,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function X5(t,e){return t=iCe(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=P2.push(i,s.scopeNames),r=new Ys(r,i,s.encodedTokenAttributes);return r}static createRoot(e,n){return new Ys(null,new P2(null,e),n)}static createRootAndLookUpScopeName(e,n,r){const i=r.getMetadataForScope(e),s=new P2(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}},vE=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))}},FCe=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(t,e){this.balancedBracketScopes=t.flatMap(n=>n==="*"?(this.allowAny=!0,[]):ix(n,ax).map(r=>r.matcher)),this.unbalancedBracketScopes=e.flatMap(n=>ix(n,ax).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}},zCe=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}},VCe=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,$Ce(t,s,e,n,r,i,this,this._onigLib))}return this._grammars.get(t)}},UCe=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new VCe(rx.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,n){this._syncRegistry.setTheme(rx.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 FCe(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,n,r,i,s){const o=new bCe(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=vE.NULL;const HCe=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],WCe=/["&'<>`]/g,qCe=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,GCe=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,KCe=/[|\\{}()[\]^$+*?.]/g,J5=new WeakMap;function YCe(t,e){if(t=t.replace(e.subset?XCe(e.subset):WCe,r),e.subset||e.escapeOnly)return t;return t.replace(qCe,n).replace(GCe,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 XCe(t){let e=J5.get(t);return e||(e=JCe(t),J5.set(t,e)),e}function JCe(t){const e=[];let n=-1;for(;++n<t.length;)e.push(t[n].replace(KCe,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const QCe=/[\dA-Fa-f]/;function ZCe(t,e,n){const r="&#x"+t.toString(16).toUpperCase();return n&&e&&!QCe.test(String.fromCharCode(e))?r:r+";"}const eAe=/\d/;function tAe(t,e,n){const r="&#"+String(t);return n&&e&&!eAe.test(String.fromCharCode(e))?r:r+";"}const nAe=["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"],I2={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:"€"},rAe=["cent","copy","divide","gt","lt","not","para","times"],uq={}.hasOwnProperty,wE={};let Zy;for(Zy in I2)uq.call(I2,Zy)&&(wE[I2[Zy]]=Zy);const iAe=/[^\dA-Za-z]/;function sAe(t,e,n,r){const i=String.fromCharCode(t);if(uq.call(wE,i)){const s=wE[i],o="&"+s;return n&&nAe.includes(s)&&!rAe.includes(s)&&(!r||e&&e!==61&&iAe.test(String.fromCharCode(e)))?o:o+";"}return""}function oAe(t,e,n){let r=ZCe(t,e,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=sAe(t,e,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){const s=tAe(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 YCe(t,Object.assign({format:oAe},e))}const aAe=/^>|^->|<!--|-->|--!>|<!-$/g,lAe=[">"],cAe=["<",">"];function uAe(t,e,n,r){return r.settings.bogusComments?"<?"+kh(t.value,Object.assign({},r.settings.characterReferences,{subset:lAe}))+">":"<!--"+t.value.replace(aAe,i)+"-->";function i(s){return kh(s,Object.assign({},r.settings.characterReferences,{subset:cAe}))}}function hAe(t,e,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}const Rn=fq(1),hq=fq(-1),fAe=[];function fq(t){return e;function e(n,r,i){const s=n?n.children:fAe;let o=(r||0)+t,a=s[o];if(!i)for(;a&&Sw(a);)o+=t,a=s[o];return a}}const dAe={}.hasOwnProperty;function dq(t){return e;function e(n,r,i){return dAe.call(t,n.tagName)&&t[n.tagName](n,r,i)}}const PR=dq({body:mAe,caption:L2,colgroup:L2,dd:vAe,dt:bAe,head:L2,html:pAe,li:yAe,optgroup:xAe,option:wAe,p:gAe,rp:Q5,rt:Q5,tbody:_Ae,td:Z5,tfoot:CAe,th:Z5,thead:SAe,tr:AAe});function L2(t,e,n){const r=Rn(n,e,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&Sw(r.value.charAt(0)))}function pAe(t,e,n){const r=Rn(n,e);return!r||r.type!=="comment"}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==="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 yAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&r.tagName==="li"}function bAe(t,e,n){const r=Rn(n,e);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function vAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Q5(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 wAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function SAe(t,e,n){const r=Rn(n,e);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}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){return!Rn(n,e)}function AAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&r.tagName==="tr"}function Z5(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const EAe=dq({body:RAe,colgroup:MAe,head:TAe,html:kAe,tbody:OAe});function kAe(t){const e=Rn(t,-1);return!e||e.type!=="comment"}function TAe(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 RAe(t){const e=Rn(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&Sw(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function MAe(t,e,n){const r=hq(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 OAe(t,e,n){const r=hq(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 eb={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 PAe(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=sg);const h=DAe(r,t.properties),f=r.all(i.space==="html"&&t.tagName==="template"?t.content:t);return r.schema=i,f&&(o=!1),(h||!s||!EAe(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 DAe(t,e){const n=[];let r=-1,i;if(e){for(i in e)if(e[i]!==null&&e[i]!==void 0){const s=IAe(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 IAe(t,e,n){const r=AW(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:eb.name[i][s]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?yW:kW)(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:eb.unquoted[i][s]}))),a!==n&&(t.settings.quoteSmart&&Qv(n,o)>Qv(n,t.alternative)&&(o=t.alternative),a=o+kh(n,Object.assign({},t.settings.characterReferences,{subset:(o==="'"?eb.single:eb.double)[i][s],attribute:!0}))+o),c+(a&&"="+a))}const LAe=["<","&"];function pq(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:LAe}))}function NAe(t,e,n,r){return r.settings.allowDangerousHtml?t.value:pq(t,e,n,r)}function $Ae(t,e,n,r){return r.all(t)}const jAe=axe("type",{invalid:BAe,unknown:FAe,handlers:{comment:uAe,doctype:hAe,element:PAe,raw:NAe,root:$Ae,text:pq}});function BAe(t){throw new Error("Expected node, not `"+t+"`")}function FAe(t){const e=t;throw new Error("Cannot compile unknown node `"+e.type+"`")}const zAe={},VAe={},UAe=[];function HAe(t,e){const n=e||zAe,r=n.quote||'"',i=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:WAe,all:qAe,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||HCe,characterReferences:n.characterReferences||VAe,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?sg:EW,quote:r,alternative:i}.one(Array.isArray(t)?{type:"root",children:t}:t,void 0,void 0)}function WAe(t,e,n){return jAe(t,e,n,this)}function qAe(t){const e=[],n=t&&t.children||UAe;let r=-1;for(;++r<n.length;)e[r]=this.one(n[r],r,t);return e.join("")}function lx(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 GAe(t){return Array.isArray(t)?t:[t]}async function mq(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 gq(t){return t==="ansi"||DR(t)}function IR(t){return t==="none"}function yq(t){return IR(t)}function bq(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 Cw(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 KAe(t){const e=Cw(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 YAe(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()",XAe=["color","background-color"];function JAe(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 QAe(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?JAe(i,s):i})):t}function ZAe(t,e,n,r,i="css-vars"){const s={content:t.content,explanation:t.explanation,offset:t.offset},o=e.map(f=>cx(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&&XAe.includes(m))if(r===LR&&o.length>1){const b=e.findIndex(A=>A==="light"),x=e.findIndex(A=>A==="dark");if(b===-1||x===-1)throw new pn('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const S=o[b][m]||"inherit",_=o[x][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 cx(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 SE(t){return typeof t=="string"?t:Object.entries(t).map(([e,n])=>`${e}:${n}`).join(";")}const vq=new WeakMap;function Aw(t,e){vq.set(t,e)}function Mm(t){return vq.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(GAe(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 eEe(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function eEe(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 tEe(t,e){if(!(t instanceof af))throw new pn("Invalid grammar state");return t.getInternalStack(e)}function nEe(){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=KAe(n.source),s=(n.options.decorations||[]).map(o=>({...o,start:r(o.start),end:r(o.end)}));rEe(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 QAe(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 x="",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++)x+=xq(b.children[E]),S===-1&&x.length===d&&(S=E+1),_===-1&&x.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||(x=>x);return f.tagName=d.tagName||"span",f.properties={...f.properties,...y,class:f.properties.class},d.properties?.class&&bq(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 rEe(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 iEe=[nEe()];function ux(t){const e=sEe(t.transformers||[]);return[...e.pre,...e.normal,...e.post,...iEe]}function sEe(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"],N2={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function oEe(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 e$(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 aEe(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)N2[r]&&e.push({type:"setDecoration",value:N2[r]});else if(r<=29){const i=N2[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=e$(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=e$(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 lEe(){let t=null,e=null,n=new Set;return{parse(r){const i=[];let s=0;do{const o=oEe(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=aEe(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 cEe={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 uEe(t=cEe){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 hEe(t,e,n){const r=lx(t,n),i=Cw(e),s=uEe(Object.fromEntries(mc.map(a=>[a,t.colors?.[`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`]]))),o=lEe();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=fEe(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 fEe(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 Cw(e).map(c=>[{content:c[0],offset:c[1]}]);const{theme:s,colorMap:o}=t.setTheme(i);if(r==="ansi")return hEe(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 pEe(e,a,s,o,n)}function dEe(...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(hx(n,c,o,a,r).stateStack,c.name,o.name)}function pEe(t,e,n,r,i){const s=hx(t,e,n,r,i),o=new af(hx(t,e,n,r,i).stateStack,e.name,n.name);return Aw(s.tokens,o),s.tokens}function hx(t,e,n,r,i){const s=lx(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:a=500}=i,c=Cw(t);let h=i.grammarState?tEe(i.grammarState,n.name)??xE:i.grammarContextCode!=null?hx(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,x]=c[m];if(b===""){f=[],d.push([]);continue}if(o>0&&b.length>=o){f=[],d.push([{content:b,offset:x,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 N=E.tokens[2*O+1],H=cl(r[Uh.getForeground(N)],s),j=Uh.getFontStyle(N),V={content:b.substring(M,D),offset:x+M,color:H,fontStyle:j};if(i.includeExplanation){const q=[];if(i.includeExplanation!=="scopeName")for(const Y of n.settings){let te;switch(typeof Y.scope){case"string":te=Y.scope.split(/,/).map(z=>z.trim());break;case"object":te=Y.scope;break;default:continue}q.push({settings:Y,selectors:te.map(z=>z.split(/ /))})}V.explanation=[];let X=0;for(;M+X<D;){const Y=_[A],te=b.substring(Y.startIndex,Y.endIndex);X+=te.length,V.explanation.push({content:te,scopes:i.includeExplanation==="scopeName"?mEe(Y.scopes):gEe(q,Y.scopes)}),A+=1}}f.push(V)}d.push(f),f=[],h=E.ruleStack}return{tokens:d,stateStack:h}}function mEe(t){return t.map(e=>({scopeName:e}))}function gEe(t,e){const n=[];for(let r=0,i=e.length;r<i;r++){const s=e[r];n[r]={scopeName:s,themeMatches:bEe(t,s,e.slice(0,r))}}return n}function t$(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function yEe(t,e,n){if(!t$(t[t.length-1],e))return!1;let r=t.length-2,i=n.length-1;for(;r>=0&&i>=0;)t$(t[r],n[i])&&(r-=1),i-=1;return r===-1}function bEe(t,e,n){const r=[];for(const{selectors:i,settings:s}of t)for(const o of i)if(yEe(o,e,n)){r.push(s);break}return r}function wq(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=vEe(...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:x,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&&Aw(o,a),o}function vEe(...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 fx(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=wq(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)),x=m.map(_=>_.color);s=y.map(_=>_.map(A=>ZAe(A,x,f,h,d))),c&&Aw(s,c);const S=m.map(_=>lx(_.theme,n));i=n$(m,b,S,f,h,"fg",d),r=n$(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=lx(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 n$(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(x=>x.color==="light"),m=t.findIndex(x=>x.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 dx(t,e,n,r={meta:{},options:n,codeToHast:(i,s)=>dx(t,i,s),codeToTokens:(i,s)=>fx(t,i,s)}){let i=e;for(const b of ux(n))i=b.preprocess?.call(r,i,n)||i;let{tokens:s,fg:o,bg:a,themeName:c,rootStyle:h,grammarState:f}=fx(t,i,n);const{mergeWhitespaces:d=!0,mergeSameStyleTokens:m=!1}=n;d===!0?s=wEe(s):d==="never"&&(s=SEe(s)),m&&(s=_Ee(s));const y={...r,get source(){return i}};for(const b of ux(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=ux(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:bq,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,x)=>{x&&(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=SE(A.htmlStyle||cx(A));P&&(E.properties.style=P);for(const O of i)E=O?.span?.call(m,E,x+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,x+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&&Aw(y,r),y}function wEe(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 SEe(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 _Ee(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=SE(i.htmlStyle||cx(i)),o=SE(r.htmlStyle||cx(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 CEe=HAe;function AEe(t,e,n){const r={meta:{},options:n,codeToHast:(s,o)=>dx(t,s,o),codeToTokens:(s,o)=>fx(t,s,o)};let i=CEe(dx(t,e,n,r));for(const s of ux(n))i=s.postprocess?.call(r,i,n)||i;return i}const r$={light:"#333333",dark:"#bbbbbb"},i$={light:"#fffffe",dark:"#1e1e1e"},s$="__shiki_resolved";function $R(t){if(t?.[s$])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"?r$.light:r$.dark),n||(n=e.type==="light"?i$.light:i$.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,s$,{enumerable:!1,writable:!1,value:!0}),e}async function Sq(t){return Array.from(new Set((await Promise.all(t.filter(e=>!gq(e)).map(async e=>await mq(e).then(n=>Array.isArray(n)?n:[n])))).flat()))}async function _q(t){return(await Promise.all(t.map(async n=>yq(n)?null:$R(await mq(n))))).filter(n=>!!n)}let EEe=3;function kEe(t,e=3){e>EEe||console.trace(`[SHIKI DEPRECATE]: ${t}`)}let hh=class extends Error{constructor(e){super(e),this.name="ShikiError"}};class TEe extends UCe{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=rx.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 REe{_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 MEe(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 REe(t.engine,n),s=new TEe(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 Sq(A))}function b(...A){S();for(const E of A.flat(1))s.loadTheme(E)}async function x(...A){return S(),b(await _q(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:x,loadThemeSync:b,dispose:_,[Symbol.dispose]:_}}async function OEe(t){t.engine||kEe("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[e,n,r]=await Promise.all([_q(t.themes||[]),Sq(t.langs||[]),t.engine]);return MEe({...t,themes:e,langs:n,engine:r})}async function PEe(t){const e=await OEe(t);return{getLastGrammarState:(...n)=>dEe(e,...n),codeToTokensBase:(n,r)=>NR(e,n,r),codeToTokensWithThemes:(n,r)=>wq(e,n,r),codeToTokens:(n,r)=>fx(e,n,r),codeToHast:(n,r)=>dx(e,n,r),codeToHtml:(n,r)=>AEe(e,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...e,getInternalContext:()=>e}}function DEe(t){const e=t.langs,n=t.themes,r=t.engine;async function i(s){function o(d){if(typeof d=="string"){if(gq(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(yq(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 PEe({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 IEe(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 LEe(t,e){const n=IEe(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 Cq=[{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"),[]))}],NEe=Object.fromEntries(Cq.map(t=>[t.id,t.import])),$Ee=Object.fromEntries(Cq.flatMap(t=>t.aliases?.map(e=>[e,t.import])||[])),jEe={...NEe,...$Ee},BEe=[{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"),[]))}],FEe=Object.fromEntries(BEe.map(t=>[t.id,t.import]));class jR extends Error{constructor(e){super(e),this.name="ShikiError"}}function zEe(){return 2147483648}function VEe(){return typeof performance<"u"?performance.now():Date.now()}const UEe=(t,e)=>t+(e-t%e)%e;async function HEe(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,x){r.HEAPU8.copyWithin(y,b,b+x)}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 x=zEe();if(y>x)return!1;for(let S=1;S<=4;S*=2){let _=b*(1+.2/S);_=Math.min(_,y+100663296);const A=Math.min(x,UEe(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,x=1024){const S=b+x;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:VEe,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 WEe=Object.defineProperty,qEe=(t,e,n)=>e in t?WEe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,An=(t,e,n)=>qEe(t,typeof e!="symbol"?e+"":e,n);let Nn=null;function GEe(t){throw new jR(t.UTF8ToString(t.getLastOnigError()))}class Ew{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=Ew._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 kw=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 Ew(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(kw,"LAST_ID",0);An(kw,"_sharedPtr",0);An(kw,"_sharedPtrInUse",!1);let Aq=kw;class KEe{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 Ew(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&&GEe(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 Aq(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 YEe(t){return typeof t.instantiator=="function"}function XEe(t){return typeof t.default=="function"}function JEe(t){return typeof t.data<"u"}function QEe(t){return typeof Response<"u"&&t instanceof Response}function ZEe(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 tb;function eke(t){if(tb)return tb;async function e(){Nn=await HEe(async n=>{let r=t;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),YEe(r)?r=await r.instantiator(n):XEe(r)?r=await r.default(n):(JEe(r)&&(r=r.data),QEe(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await tke(r)(n):r=await nke(r)(n):ZEe(r)?r=await $2(r)(n):r instanceof WebAssembly.Module?r=await $2(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await $2(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return tb=e(),tb}function $2(t){return e=>WebAssembly.instantiate(t,e)}function tke(t){return e=>WebAssembly.instantiateStreaming(t,e)}function nke(t){return async e=>{const n=await t.arrayBuffer();return WebAssembly.instantiate(n,e)}}async function rke(t){return t&&await eke(t),{createScanner(e){return new KEe(e.map(n=>typeof n=="string"?n:n.source))},createString(e){return new Aq(e)}}}const ike=DEe({langs:jEe,themes:FEe,engine:()=>rke(B(()=>import("./wasm2.js"),[]))}),{getSingletonHighlighter:o$}=LEe(ike,{guessEmbeddedLanguages:YAe});async function ske(t,e){try{return await o$({langs:[t],themes:e})}catch(n){if(n instanceof Error&&n.message.includes("Language"))return await o$({langs:["plaintext"],themes:e});throw n}}var Eq=(t,e,n,r={})=>Z2e(t,e,n,ske,r),oke=tCe(Eq),ake=oke;const kq=({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 Eq(t,e,n)?C.jsx(ake,{...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()})})};kq.displayName="SyntaxHighlighter";const px="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 lke=({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)})}}},cke=({language:t,code:e})=>{const{isCopied:n,copyToClipboard:r}=lke(),{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:px,size:16}),n&&C.jsx(gt,{iconName:Oh,size:16,isStroke:!0,disableHover:!0})]})]})},uke=D2e({SyntaxHighlighter:kq,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=WW();return C.jsx("code",{className:je(!r&&"font-bold italic",e),...n})},CodeHeader:cke}),hke=()=>C.jsx(Y2e,{remarkPlugins:[eSe],className:"aui-md",components:uke}),Tq=k.memo(hke),fke=()=>{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(WE,{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(LH,{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(qE,{components:{Text:Tq}})})]})})},Rq="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",dke="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",pke="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",_E="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",a$="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",Mq=({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 x="",S=e;try{const E=JSON.parse(S);E.args&&(S=JSON.stringify(E.args)),x=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(x,"_blank");return}y&&n===void 0||s(!i)},children:[m?C.jsx(OT,{size:16}):C.jsx(dn,{src:dke}),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:_E,beforeInjection:_}):b?null:C.jsx(dn,{src:pke,beforeInjection:A}),C.jsx("span",{className:"truncate",children:y?x:b?`${d} | ${x}`:d})]}),b?C.jsx(dn,{src:a$,beforeInjection:A}):y&&n===void 0?null:C.jsx(dn,{src:i?Wk:tz,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:px,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:_E,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:a$,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:px,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)})]})})]})]})},mke=()=>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"})})}),gke=()=>{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=zie(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(Y2,{copied:!0,children:C.jsx(gt,{iconName:Oh,size:24,isStroke:!0,disabled:!0})}),C.jsx(Y2,{copied:!1,children:C.jsx(gt,{iconName:px,size:24})})]})}),C.jsx("div",{children:C.jsx(ta,{tooltip:t("Save"),children:C.jsx(gt,{iconName:Rq,size:24,onClick:i,isStroke:!0})})})]})},yke=()=>C.jsx(WE,{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(qE,{components:{Text:Tq,tools:{Fallback:Mq}}}),C.jsx(mke,{})]}),C.jsx(gke,{})]})}),lg=na(t=>({currentModel:null,isInitLoading:!1,initCurrentModel:()=>{try{const e=localStorage.getItem(g_);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}),$t.setCurrentProviderModel(e.id),localStorage.setItem(g_,JSON.stringify(e))},deleteSelectedModel:()=>{t({currentModel:null}),localStorage.removeItem(g_),$t.setCurrentProviderModel("")}})),bke="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",vke=()=>{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:bke,size:24,isActive:i})}),[i,o]),c=k.useMemo(()=>[{text:o("WebSearch"),onClick:()=>{},icon:C.jsx(gt,{iconName:_E,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)}},{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:x=>{e(d,b.name,x)}}))]}}).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",wke=()=>{const[t,e]=be.useState(!1),{addAttachmentFile:n}=yw(),r=f=>{e(f)},i=(f,d)=>{const m=Tb(d);window.AscDesktopEditor.convertFileExternal(f,m?260:69,(y,b)=>{if(b){console.log("Error:",b);return}const x=new Uint8Array(y.content),_=new TextDecoder("utf-8").decode(x);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=Tb(y);window.AscDesktopEditor.convertFileExternal(d,b?260:69,(x,S)=>{if(S){console.log("Error:",S);return}const _=new Uint8Array(x.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=nE;return k9(f.type)?d=OH:Tb(f.type)?d=PH:A9(f.type)?d=nE:E9(f.type)?d=DH:d=IH,{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})},Ske=()=>{const{currentModel:t,selectModel:e}=lg(),{providers:n,providersModels:r,currentProvider:i,setCurrentProvider:s}=rs(),{tools:o}=Rs(),{messages:a}=Yh(),{t:c}=vt(),h=be.useCallback((m,y)=>{if(t?.id===y&&$t.currentProviderInfo?.name===m.name)return;const b=r.get(m.name)?.find(x=>x.id===y);b&&($t.currentProviderInfo?.name!==m.name&&(s(m),$t.setCurrentProviderModel(y),$t.setCurrentProviderTools(o),$t.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===$t.currentProviderInfo?.name}))||[]})).filter(m=>m.subMenu.length>0),d=n.some(m=>m.name===i?.name);return be.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(Zx,{placeholder:c("SelectModel"),value:d&&t?.name||"",items:f,withoutBg:!0})},_ke="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",Cke="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",l$="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]",Ake=()=>{const{isStreamRunning:t}=Yh(),{currentModel:e}=lg(),{currentProvider:n}=rs();return t?C.jsx(aee,{asChild:!0,children:C.jsx(gt,{iconName:Cke,size:24,className:l$})}):C.jsx(ev,{running:!1,children:C.jsx(UZ,{asChild:!0,disabled:!e||!n,children:C.jsx(gt,{iconName:_ke,size:24,color:"var(--chat-composer-action-send-color)",className:l$})})})},Eke=()=>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(wke,{}),C.jsx(vke,{})]}),C.jsxs("div",{className:"flex items-center gap-[12px] flex-row",children:[C.jsx(Ske,{}),C.jsx(Ake,{})]})]})}),c$=()=>{const{attachmentFiles:t}=yw(),{currentProvider:e}=rs(),{currentModel:n}=lg(),{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(LH,{file:i},i.path))}):null,C.jsx(oB,{placeholder:r("AskAI"),className:"composer-input max-h-[calc(50dvh)] min-h-[16px] w-full resize-none outline-none",rows:1,autoFocus:!0,"aria-label":"Message input",disabled:!e||!n}),C.jsx(Eke,{})]}),C.jsx("p",{className:"text-center font-normal text-[12px] leading-[16px] text-[var(--text-tertiary)]",children:r("CheckInfo")})]})},kke=()=>{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(ev,{empty:!0,children:C.jsx(X2,{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(uve,{}),C.jsx(c$,{})]})})}),C.jsxs(ev,{empty:!1,children:[C.jsxs(X2,{className:"relative flex min-w-0 flex-1 flex-col gap-6 overflow-y-auto",children:[C.jsx(pee,{components:{UserMessage:fke,AssistantMessage:yke}}),!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(OT,{}),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(c$,{})]})]})},Tke="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",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='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",Mke=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()})},Oke=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)}})},Pke=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()}})},Dke=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()}})},Ike=async t=>{await Bre(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()})},cg=na((t,e)=>({threadId:crypto.randomUUID(),threads:[],initThreads:async()=>{const n=await Oke();t({threads:n})},insertThread:n=>{const r=e();t({threads:[{threadId:r.threadId,title:n},...r.threads]}),Mke(r.threadId,n)},insertNewMessageToThread:()=>{const n=e();Dke(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=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)}),Pke(n,r)},onDeleteThread:n=>{const r=e();r.threadId===n&&r.onSwitchToNewThread(),t({threads:r.threads.filter(i=>i.threadId!==n)}),Ike(n)}})),Lke=()=>{const{t}=vt(),{currentPage:e,setCurrentPage:n}=Vm(),{onSwitchToNewThread:r}=cg();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:Rke,size:24,isStroke:!0,onClick:()=>{n("chat"),r()}})})]}),C.jsx(ta,{tooltip:t("Settings"),children:C.jsx(gt,{iconName:Tke,size:24,isStroke:!0,isActive:e==="settings",onClick:()=>n(e==="settings"?"chat":"settings")})})]})},Nke="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",$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='M13.57%206.42969L8%2011.9995L13.57%2017.5694'%20stroke='%23383838'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",jke="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",Bke="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",Fke=({id:t,onClose:e})=>{const{onDeleteThread:n}=cg(),{t:r}=vt(),i=be.useCallback(async()=>{await n(t),e()},[t,n,e]);return be.useEffect(()=>{const s=o=>{o.key==="Enter"&&(o.preventDefault(),i())};return document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}},[i]),C.jsx(wl,{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")})]})]})})})},zke=t=>{const e=t.querySelector("path");e&&e.setAttribute("stroke","var(--icon-button-color)")},Vke=t=>{const e=t.querySelector("path");e&&e.setAttribute("fill","var(--icon-button-color)")},Uke=t=>{const e=t.querySelector("path");e&&e.setAttribute("fill","var(--icon-button-color)")},Hke=()=>C.jsx(dn,{src:Rq,beforeInjection:zke}),Wke=()=>C.jsx(dn,{src:Bke,beforeInjection:Vke}),qke=()=>C.jsx(dn,{src:$k,beforeInjection:Uke}),Gke=({thread:t,isActive:e,onSwitchToThread:n,onRenameThread:r,onDownloadThread:i,setCurrentPage:s})=>{const[o,a]=be.useState(!1),[c,h]=be.useState(!1),[f,d]=be.useState(!1),[m,y]=be.useState(!1),[b,x]=be.useState(t.title),S=be.useRef(null),_=be.useRef(null),{t:A}=vt();be.useEffect(()=>{const D=N=>{f&&(N.key==="Escape"?(N.preventDefault(),d(!1),x(t.title)):N.key==="Enter"&&(N.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=>x(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:Nk,size:20,isActive:o,insideElement:!0}),items:[{icon:C.jsx(Hke,{}),text:A("Save"),onClick:M},{icon:C.jsx(Wke,{}),text:A("Rename"),onClick:O},{icon:C.jsx(qke,{}),text:A("Delete"),onClick:P}],side:"right",align:"start",sideOffset:0,containerRef:S.current}):null]}),m?C.jsx(Fke,{id:t.threadId,onClose:()=>y(!1)}):null]},t.threadId)},Kke=()=>{const{threads:t,threadId:e,onSwitchToThread:n,onRenameThread:r,onDownloadThread:i}=cg(),{setCurrentPage:s}=Vm(),[o,a]=be.useState(!1),[c,h]=be.useState(""),[f,d]=be.useState(t),{t:m}=vt(),y=x=>{const S=x.target.value;h(S)};be.useEffect(()=>{const x=t.filter(S=>S.title?.toLowerCase().includes(c.toLowerCase()));d(x)},[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:$ke,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:jke,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(x=>{const S=x.threadId===e;return C.jsx(Gke,{thread:x,isActive:S,onSwitchToThread:n,setCurrentPage:s,onRenameThread:r,onDownloadThread:i},x.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:Nke,size:24,onClick:()=>{s("chat"),a(!0)}})})})},u$=t=>t==="dark"?"theme-night":"theme-white",h$=({children:t})=>{const{currentPage:e}=Vm(),{i18n:n}=vt(),[r,i]=be.useState(()=>window.RendererProcessVariable?window.RendererProcessVariable.theme.id==="theme-system"?u$(window.RendererProcessVariable.theme.system):window.RendererProcessVariable.theme.id:"theme-light");be.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(u$(window.RendererProcessVariable.theme.system)):i(o.theme))}},[n]);const s=e==="settings";return C.jsx("div",{className:`h-dvh ${r}`,children:C.jsxs("main",{id:"app",className:"h-dvh bg-[var(--layout-background-color)] flex flex-col",children:[C.jsx(Lke,{}),C.jsxs("div",{className:"flex flex-row flex-1",style:{height:"calc(100dvh - 56px)"},children:[s?null:C.jsx(Kke,{}),C.jsx("div",{className:"w-full",children:t})]})]})})},Yke=({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)]",x=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,x)),children:t?C.jsx(dn,{src:Oh,className:"flex items-center justify-center",beforeInjection:o}):null})})]})},Xke=({onAllow:t,onDeny:e,onClose:n})=>{const{t:r}=vt(),{manageToolData:i}=Rs(),[s,o]=k.useState(!1),a=()=>{t(s),n()},c=()=>{e(),n()},h=i?.message?.content[i.idx];if(!(!h||typeof h!="object"||!("type"in h)||h.type!=="tool-call"))return C.jsx(wl,{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(Mq,{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(Yke,{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")})]})]})})},Jke=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)})},Qke=({isReady:t})=>{const{messages:e,setIsStreamRunning:n,setIsRequestRunning:r,addMessage:i,updateLastMessage:s,fetchPrevMessages:o}=Yh(),{threadId:a,insertThread:c,insertNewMessageToThread:h}=cg(),{manageToolData:f,callTools:d,checkAllowAlways:m,setAllowAlways:y,setManageToolData:b}=Rs(),{attachmentFiles:x,clearAttachmentFiles:S}=yw(),{currentProvider:_}=rs(),{currentModel:A}=lg(),E=k.useRef(a);k.useEffect(()=>{t&&(E.current=a,o(a),S())},[a,t,o,S]);const P=j=>j,O=j=>{if(!f)return;const V=f?.message?.content[f.idx];if(!V||typeof V!="object"||!("type"in V)||V.type!=="tool-call")return;const q=V.toolName,X=Qt.getServerType(q),Y=q.replace(X+"_","");j&&y(!0,X,Y),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(j,V,q,X,Y)=>{const te=j.content[V];if(!te||typeof te!="object"||!("type"in te)||te.type!=="tool-call")return;const z=te.toolName,G=Qt.getServerType(z),U=z.replace(G+"_","");if(m(G,U)||X||Y){const se=Y?"User deny tool call":await d(te.toolName,te.args),T=Array.isArray(j.content)?j.content.map((L,de)=>de===V?{...te,result:se}:L):j.content,Z={...j,content:T};if(s(Z),!$t)return;const ue=$t.sendMessageAfterToolCall(Z);ue&&N(ue,!0,q)}else b({message:j,idx:V,messageUID:q})},N=async(j,V,q)=>{n(!0);let X=!!V;const Y=V&&q?q:crypto.randomUUID();if(e)for await(const te of j){if("isEnd"in te){if(E.current!==a){n(!1),r(!1);return}if(te.responseMessage.status?.type==="incomplete"){i(te.responseMessage),n(!1),r(!1);return}const z=te.responseMessage;if(z?.role==="assistant"&&Array.isArray(z.content)){const G=z.content.findIndex(U=>U.type==="tool-call"&&!U.result);if(G!==-1){D(z,G,Y);return}}n(!1),r(!1);return}X?(jre(Y,te),E.current===a&&s(te)):(V||r(!0),i(te),dy(a,Y,te),X=!0)}};return{convertMessage:P,onNew:async j=>{if(!$t||!_||!A||j.content[0].type!=="text")return;let V=[];x.length>0&&(V=x.map(z=>({type:"file",mimeType:JSON.stringify({path:z.path,type:z.type}),data:z.content})),S());const X={role:"user",content:[...V,{type:"text",text:j.content[0].text}],attachments:j.attachments};if(await Jke(a))h(),(async()=>{await dy(a,crypto.randomUUID(),X)})();else{let z="";for(const G of e)G.status?.type==="incomplete"&&G.status?.error||(z+=typeof G.content=="string"?G.content:G.content[0].type==="text"?G.content[0].text:"",z+=`
`);z+=`
`+j.content[0].text,$t.createChatName(z).then(async G=>{if(G){c(G);for(const U of e)U.status?.type==="incomplete"&&U.status?.error||await dy(a,crypto.randomUUID(),U);await dy(a,crypto.randomUUID(),X)}})}i(X);const te=$t.sendMessage([X]);te&&N(te)},handleStream:N,approveToolCall:O,denyToolCall:M}},Zke=({isReady:t})=>{const{initThreads:e}=cg();return k.useEffect(()=>{t&&e()},[t,e]),{}},eTe=()=>{const{initCurrentModel:t,currentModel:e}=lg();return k.useEffect(()=>{e&&$t.setCurrentProviderModel(e.id)},[e]),k.useEffect(()=>{t()},[t]),{}},tTe=({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||$t.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},f$=t=>t==null?"":""+t,nTe=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},rTe=/###/g,d$=t=>t&&t.indexOf("###")>-1?t.replace(rTe,"."):t,p$=t=>!t||Ke(t),zp=(t,e,n)=>{const r=Ke(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(p$(t))return{};const s=d$(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return p$(t)?{}:{obj:t,k:d$(r[i])}},m$=(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},iTe=(t,e,n,r)=>{const{obj:i,k:s}=zp(t,e,Object);i[s]=i[s]||[],i[s].push(n)},mx=(t,e)=>{const{obj:n,k:r}=zp(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},sTe=(t,e,n)=>{const r=mx(t,n);return r!==void 0?r:mx(e,n)},Oq=(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]):Oq(t[r],e[r],n):t[r]=e[r]);return t},Uu=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var oTe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const aTe=t=>Ke(t)?t.replace(/[&<>"'\/]/g,e=>oTe[e]):t;class lTe{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 cTe=[" ",",","?","!",";"],uTe=new lTe(20),hTe=(t,e,n)=>{e=e||"",n=n||"";const r=cTe.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=uTe.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},CE=(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("_","-"),fTe={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 gx{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||fTe,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 gx(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new gx(this.logger,e)}}var ao=new gx;class Tw{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 g$ extends Tw{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=mx(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:CE(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),m$(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=mx(this.data,a)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?Oq(c,r,s):c={...c,...r},m$(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 Pq={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 Dq=Symbol("i18next/PATH_KEY");function dTe(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===Dq?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function AE(t,e){const{[Dq]:n}=t(dTe());return n.join(e?.keySeparator??".")}const y$={},b$=t=>!Ke(t)&&typeof t!="boolean"&&typeof t!="number";class yx extends Tw{constructor(e,n={}){super(),nTe(["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&&!hTe(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=AE(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 x=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=yx.hasDefaultValue(i),M=P?this.pluralResolver.getSuffix(d,i.count,i):"",D=i.ordinal&&P?this.pluralResolver.getSuffix(d,i.count,{ordinal:!1}):"",N=P&&!i.ordinal&&i.count===0,H=N&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${M}`]||i[`defaultValue${D}`]||i.defaultValue;let j=b;E&&!b&&O&&(j=H);const V=b$(j),q=Object.prototype.toString.apply(j);if(E&&j&&V&&_.indexOf(q)<0&&!(Ke(A)&&Array.isArray(j))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const X=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,j,{...i,ns:c}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(y.res=X,y.usedParams=this.getUsedParamsDetails(i),y):X}if(o){const X=Array.isArray(j),Y=X?[]:{},te=X?S:x;for(const z in j)if(Object.prototype.hasOwnProperty.call(j,z)){const G=`${te}${o}${z}`;O&&!b?Y[z]=this.translate(G,{...i,defaultValue:b$(H)?H[z]:void 0,joinArrays:!1,ns:c}):Y[z]=this.translate(G,{...i,joinArrays:!1,ns:c}),Y[z]===G&&(Y[z]=j[z])}b=Y}}else if(E&&Ke(A)&&Array.isArray(b))b=b.join(A),b&&(b=this.extendTranslation(b,e,i,r));else{let X=!1,Y=!1;!this.isValidLookup(b)&&O&&(X=!0,b=H),this.isValidLookup(b)||(Y=!0,b=a);const z=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&Y?void 0:b,G=O&&H!==b&&this.options.updateMissing;if(Y||X||G){if(this.logger.log(G?"updateKey":"missingKey",d,h,a,G?H: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 U=[];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++)U.push(se[Z]);else this.options.saveMissingTo==="all"?U=this.languageUtils.toResolveHierarchy(i.lng||this.language):U.push(i.lng||this.language);const T=(Z,ue,L)=>{const de=O&&L!==b?L:z;this.options.missingKeyHandler?this.options.missingKeyHandler(Z,h,ue,de,G,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(Z,h,ue,de,G,i),this.emit("missingKey",Z,h,ue,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&P?U.forEach(Z=>{const ue=this.pluralResolver.getSuffixes(Z,i);N&&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}`]||H)})}):T(U,a,H))}b=this.extendTranslation(b,e,i,y,r),Y&&b===a&&this.options.appendNamespaceToMissingKey&&(b=`${h}${f}${a}`),(Y||X)&&this.options.parseMissingKeyHandler&&(b=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${h}${f}${a}`:a,X?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=Pq.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!=="",x=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);d.forEach(S=>{this.isValidLookup(r)||(a=S,!y$[`${x[0]}-${S}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(y$[`${x[0]}-${S}`]=!0,this.logger.warn(`key "${i}" for languages "${x.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!!!")),x.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 v${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 x$={zero:0,one:1,two:2,few:3,many:4,other:5},w$={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class pTe{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!"),w$;if(!e.match(/-|_/))return w$;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)=>x$[i]-x$[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 S$=(t,e,n,r=".",i=!0)=>{let s=sTe(t,e,n);return!s&&i&&Ke(n)&&(s=CE(t,n,r),s===void 0&&(s=CE(e,n,r))),s},j2=t=>t.replace(/\$/g,"$$$$");class mTe{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:x,nestingOptionsSeparator:S,maxReplaces:_,alwaysFormat:A}=e.interpolation;this.escape=n!==void 0?n:aTe,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):x||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 _=S$(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),x=b.shift().trim(),S=b.join(this.formatSeparator).trim();return this.format(S$(n,c,x,this.options.keySeparator,this.options.ignoreJSONStructure),S,r,{...i,...n,interpolationkey:x})};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=>j2(y)},{regex:this.regexp,safeValue:y=>this.escapeValue?j2(this.escape(y)):j2(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=f$(o));const x=y.safeValue(o);if(e=e.replace(s[0],x),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(x){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,x),`${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=f$(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 gTe=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}},_$=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)}},yTe=t=>(e,n,r)=>t(Om(n),r)(e);class bTe{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?_$:yTe;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()]=_$(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}=gTe(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 vTe=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class xTe extends Tw{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=>{iTe(c.loaded,[s],o),vTe(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 C$=()=>({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}),A$=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),nb=()=>{},wTe=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Pm extends Tw{constructor(e={},n){if(super(),this.options=A$(e),this.services={},this.logger=ao,this.modules={external:[]},wTe(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=C$();this.options={...r,...this.options,...A$(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=bTe;const f=new v$(this.options);this.store=new g$(this.options.resources,this.options);const d=this.services;d.logger=ao,d.resourceStore=this.store,d.languageUtils=f,d.pluralResolver=new pTe(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 mTe(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 yx(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=nb),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=nb){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=nb),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"&&Pq.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=AE(d,{...this.options,...o})),`${c.keyPrefix}${h}${d}`)):(typeof s=="function"&&(s=AE(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 v$(C$());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=nb){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 g$(a,i),s.services.resourceStore=s.store}return s.translator=new yx(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 wr=Pm.createInstance();wr.createInstance=Pm.createInstance;wr.createInstance;wr.dir;wr.init;wr.loadResources;wr.reloadResources;wr.use;wr.changeLanguage;wr.getFixedT;wr.t;wr.exists;wr.setDefaultNamespace;wr.hasLoadedNamespace;wr.loadNamespaces;wr.loadLanguages;const STe="AI agent",_Te="AI agent Settings",CTe="Settings",ATe="Connect an AI Model to Get Started",ETe="No AI model is connected yet. Link a model to start interacting with it right here in the interface.",kTe="Connect an AI Model",TTe="Chat history",RTe="There is no chat history yet...",MTe="Choose how to connect AI",OTe="Select how you want to enable AI features in ONLYOFFICE.",PTe="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.",DTe="ONLYOFFICE Wallet",ITe="Top up your balance with a card and instantly use all AI features.",LTe="Your AI provider",NTe="Connect your own AI source — either via API key from a provider or a locally hosted model.",$Te="Register & Connect Wallet",jTe="Add provider",BTe="Connection",FTe="MCP Servers",zTe="AI Provider",VTe="Edit AI Provider",UTe="Provider",HTe="Name",WTe="URL",qTe="Enter name",GTe="Enter URL",KTe="API key",YTe="Enter API key",XTe="Cancel",JTe="Save",QTe="Edit",ZTe="Delete",eRe="Warning",tRe="Are you sure you want to delete this provider?",nRe="Are you sure you want to delete this chat?",rRe="Yes",iRe="No",sRe="How can I help?",oRe="Free Al chat, writing assistant & idea generator",aRe="Rename",lRe="Download",cRe="Search...",uRe="Add local file...",hRe="Recent files",fRe="Attachments",dRe="API key",pRe="New chat",mRe="Ask AI",gRe="Analyzing...",yRe="Al would like to use this tool:",bRe=`Review each action carefully before approving
We cannot guarantee the security or privacy practices of third-party integrations.`,vRe="Always allow this tool to perform this action without asking again",xRe="Deny",wRe="Allow",SRe="Tool call arguments",_Re="Tool call result",CRe="Tool executed",ARe="Confirmation",ERe="Select model",kRe="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.",TRe="Edit configuration",RRe="Enter your JSON configuration:",MRe="Available tools",ORe="tools",PRe="tools enabled",DRe="Enable all tools",IRe="Disable all tools",LRe="Restart",NRe="Logs",$Re="Copy to clipboard",jRe="Close",BRe="Web Search",FRe="Connect a web search engine to enhance AI chats with real-time information from the internet.",zRe="Reset settings",VRe="Web Search Engine",URe="Select engine",HRe="All tools",WRe="Enable web search in settings",qRe="This server will be deleted from your list. Continue?",GRe="Provider not available",KRe="AI Chat can make mistakes. Check important info.",YRe={AIAgent:STe,AIAgentSettings:_Te,Settings:CTe,ConnectAIModel:ATe,ConnectAIModelDescription:ETe,ConnectAIModelBtn:kTe,ChatHistory:TTe,NoChatYet:RTe,ChooseHowConnect:MTe,SelectHowConnect:OTe,SelectHowConnectDescription:PTe,ONLYOFFICEWallet:DTe,ONLYOFFICEWalletDescription:ITe,AIProviders:LTe,AIProvidersDescription:NTe,RegisterConnectWallet:$Te,AddProvider:jTe,Connection:BTe,MCPServers:FTe,AIProvider:zTe,EditAIProvider:VTe,Provider:UTe,Name:HTe,URL:WTe,EnterName:qTe,EnterURL:GTe,Key:KTe,EnterKey:YTe,Cancel:XTe,Save:JTe,Edit:QTe,Delete:ZTe,Warning:eRe,WantDeleteProvider:tRe,WantDeleteChat:nRe,Yes:rRe,No:iRe,WelcomeTitle:sRe,WelcomeDescription:oRe,Rename:aRe,Download:lRe,Search:cRe,AddLocalFile:uRe,RecentFiles:hRe,Attachments:fRe,APIKey:dRe,NewChat:pRe,AskAI:mRe,Analyzing:gRe,AIWouldLikeUseThisTool:yRe,ReviewEachAction:bRe,AlwaysAllow:vRe,Deny:xRe,Allow:wRe,ToolCallArguments:SRe,ToolCallResult:_Re,ToolExecuted:CRe,Confirmation:ARe,SelectModel:ERe,CustomServersDescription:kRe,EditConfiguration:TRe,EnterYourJSONConfiguration:RRe,AvailableTools:MRe,Tools:ORe,ToolsEnabled:PRe,EnableAllTools:DRe,DisableAllTools:IRe,Restart:LRe,Logs:NRe,CopyToClipboard:$Re,Close:jRe,WebSearch:BRe,WebSearchDescription:FRe,ResetSettings:zRe,WebSearchEngine:VRe,SelectEngine:URe,AllTools:HRe,EnableWebSearch:WRe,WantDeleteServer:qRe,NoModelsAvailable:GRe,CheckInfo:KRe},XRe="ИИ-агент",JRe="Настройки ИИ-агента",QRe="Настройки",ZRe="Чтобы начать, подключите ИИ-модель",eMe="Нет подключенных ИИ-моделей. Подключите модель, чтобы начать работать с ней прямо в интерфейсе.",tMe="Подключить ИИ-модель",nMe="История чатов",rMe="Здесь пока нет истории чатов...",iMe="Выберите, как вы хотите включить искусственный интеллект",sMe="Выберите, как вы хотите включить функции искусственного интеллекта в ONLYOFFICE.",oMe="Вы можете использовать встроенный кошелек для быстрого запуска или подключить собственную ИИ-модель с помощью ключа API или модели, размещенной локально.",aMe="Кошелек ONLYOFFICE",lMe="Пополните баланс с помощью карты и сразу используйте все функциональные возможности искусственного интеллекта.",cMe="Ваш ИИ-провайдер",uMe="Подключите собственный источник искусственного интеллекта с помощью ключа API провайдера или модели, размещенной локально.",hMe="Зарегистрируйтесь и подключите кошелек",fMe="Добавить провайдера",dMe="Подключение",pMe="MCP-серверы",mMe="ИИ-провайдер",gMe="Изменить ИИ-провайдера",yMe="Провайдер",bMe="Название",vMe="URL-адрес",xMe="Введите название",wMe="Введите URL-адрес",SMe="Ключ API",_Me="Введите ключ API",CMe="Отменить",AMe="Сохранить",EMe="Редактировать",kMe="Удалить",TMe="Предупреждение",RMe="Вы уверены, что хотите удалить этого провайдера?",MMe="Вы уверены, что хотите удалить этот чат?",OMe="Да",PMe="Нет",DMe="Чем я могу помочь?",IMe="Бесплатный ИИ-чат, помощник в создании документов и генератор идей",LMe="Переименовать",NMe="Загрузить",$Me="Поиск...",jMe="Добавить локальный файл...",BMe="Недавние файлы",FMe="Вложения",zMe="Ключ API",VMe="Новый чат",UMe="Спросить ИИ",HMe="Анализ...",WMe="Искусственный интеллект хочет использовать этот инструмент:",qMe=`Внимательно проверяйте каждое действие перед подтверждением
Мы не можем гарантировать соответствие правил обеспечения безопасности и конфиденциальности сторонних интеграций.`,GMe="Всегда разрешать этому инструменту выполнять данное действие без повторного запроса",KMe="Отклонить",YMe="Разрешить",XMe="Аргументы вызова инструмента",JMe="Результат вызова инструмента",QMe="Работа с инструментом завершена",ZMe="Подтверждение",eOe="Выбрать модель",tOe="В этом разделе можно настроить MCP-серверы для использования в ИИ-агенте. Вы можете редактировать конфигурацию, чтобы добавлять новые MCP-серверы и включать необходимые инструменты.",nOe="Редактировать конфигурацию",rOe="Введите конфигурацию JSON:",iOe="Доступные инструменты",sOe="инструменты",oOe="включенные инструменты",aOe="Включить все инструменты",lOe="Отключить все инструменты",cOe="Перезапустить",uOe="Журналы",hOe="Копировать в буфер обмена",fOe="Закрыть",dOe="Веб-поиск",pOe="Включите поисковую систему, чтобы дополнять ИИ-чаты информацией из Интернета в режиме реального времени.",mOe="Сбросить настройки",gOe="Поисковая система",yOe="Выберите движок",bOe="Все инструменты",vOe="Включить веб-поиск в настройках",xOe="Этот сервер будет удален из вашего списка. Продолжить?",wOe="Поставщик недоступен",SOe="ИИ-чат может ошибаться. Проверьте важную информацию.",_Oe={AIAgent:XRe,AIAgentSettings:JRe,Settings:QRe,ConnectAIModel:ZRe,ConnectAIModelDescription:eMe,ConnectAIModelBtn:tMe,ChatHistory:nMe,NoChatYet:rMe,ChooseHowConnect:iMe,SelectHowConnect:sMe,SelectHowConnectDescription:oMe,ONLYOFFICEWallet:aMe,ONLYOFFICEWalletDescription:lMe,AIProviders:cMe,AIProvidersDescription:uMe,RegisterConnectWallet:hMe,AddProvider:fMe,Connection:dMe,MCPServers:pMe,AIProvider:mMe,EditAIProvider:gMe,Provider:yMe,Name:bMe,URL:vMe,EnterName:xMe,EnterURL:wMe,Key:SMe,EnterKey:_Me,Cancel:CMe,Save:AMe,Edit:EMe,Delete:kMe,Warning:TMe,WantDeleteProvider:RMe,WantDeleteChat:MMe,Yes:OMe,No:PMe,WelcomeTitle:DMe,WelcomeDescription:IMe,Rename:LMe,Download:NMe,Search:$Me,AddLocalFile:jMe,RecentFiles:BMe,Attachments:FMe,APIKey:zMe,NewChat:VMe,AskAI:UMe,Analyzing:HMe,AIWouldLikeUseThisTool:WMe,ReviewEachAction:qMe,AlwaysAllow:GMe,Deny:KMe,Allow:YMe,ToolCallArguments:XMe,ToolCallResult:JMe,ToolExecuted:QMe,Confirmation:ZMe,SelectModel:eOe,CustomServersDescription:tOe,EditConfiguration:nOe,EnterYourJSONConfiguration:rOe,AvailableTools:iOe,Tools:sOe,ToolsEnabled:oOe,EnableAllTools:aOe,DisableAllTools:lOe,Restart:cOe,Logs:uOe,CopyToClipboard:hOe,Close:fOe,WebSearch:dOe,WebSearchDescription:pOe,ResetSettings:mOe,WebSearchEngine:gOe,SelectEngine:yOe,AllTools:bOe,EnableWebSearch:vOe,WantDeleteServer:xOe,NoModelsAvailable:wOe,CheckInfo:SOe},COe="Agent AI",AOe="Nastavení agenta AI",EOe="Nastavení",kOe="Připojte model AI a začněte",TOe="Zatím není připojen žádný model AI. Propojte model a začněte s ním komunikovat přímo zde v rozhraní.",ROe="Připojit model AI",MOe="Historie chatu",OOe="Zatím neexistuje žádná historie chatu...",POe="Vyberte způsob připojení AI",DOe="Vyberte, jak chcete povolit funkce AI v ONLYOFFICE.",IOe="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.",LOe="Peněženka ONLYOFFICE",NOe="Doplňte svůj zůstatek kartou a okamžitě používejte všechny funkce AI.",$Oe="Váš poskytovatel AI",jOe="Připojte svůj vlastní zdroj AI buď pomocí API klíče od poskytovatele, nebo lokálně hostovaného modelu.",BOe="Registrovat a připojit peněženku",FOe="Přidat poskytovatele",zOe="Připojení",VOe="Servery MCP",UOe="Poskytovatel AI",HOe="Upravit poskytovatele AI",WOe="Poskytovatel",qOe="Název",GOe="URL",KOe="Zadat název",YOe="Zadat URL",XOe="API klíč",JOe="Zadat API klíč",QOe="Zrušit",ZOe="Uložit",ePe="Upravit",tPe="Odstranit",nPe="Varování",rPe="Opravdu chcete odstranit tohoto poskytovatele?",iPe="Opravdu chcete odstranit tento chat?",sPe="Ano",oPe="Ne",aPe="Jak vám mohu pomoci?",lPe="Bezplatný Al chat, pomocník při psaní a generátor nápadů",cPe="Přejmenovat",uPe="Stáhnout",hPe="Hledat...",fPe="Přidat místní soubor...",dPe="Poslední soubory",pPe="Přílohy",mPe="API klíč",gPe="Nový chat",yPe="Zeptejte se AI",bPe="Probíhá analýza...",vPe="Al by ráda použila tento nástroj:",xPe=`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.`,wPe="Vždy povolit tomuto nástroji provést tuto akci bez dalšího dotazu",SPe="Odmítnout",_Pe="Povolit",CPe="Argumenty volání nástroje",APe="Výsledek volání nástroje",EPe="Nástroj proveden",kPe="Potvrzení",TPe="Vybrat model",RPe="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.",MPe="Upravit konfiguraci",OPe="Zadejte svou konfiguraci JSON:",PPe="Dostupné nástroje",DPe="nástroje",IPe="povolené nástroje",LPe="Povolit všechny nástroje",NPe="Zakázat všechny nástroje",$Pe="Restartovat",jPe="Protokoly",BPe="Kopírovat do schránky",FPe="Zavřít",zPe="Webové vyhledávání",VPe="Připojte webový vyhledávač a vylepšete AI chaty pomocí informací z internetu v reálném čase.",UPe="Obnovit nastavení",HPe="Webový vyhledávač",WPe="Vybrat vyhledávač",qPe="Všechny nástroje",GPe="Povolit webové vyhledávání v nastavení",KPe="Tento server bude odstraněn z vašeho seznamu. Pokračovat?",YPe="Poskytovatel není k dispozici",XPe="AI chat může dělat chyby. Zkontrolujte důležité informace.",JPe={AIAgent:COe,AIAgentSettings:AOe,Settings:EOe,ConnectAIModel:kOe,ConnectAIModelDescription:TOe,ConnectAIModelBtn:ROe,ChatHistory:MOe,NoChatYet:OOe,ChooseHowConnect:POe,SelectHowConnect:DOe,SelectHowConnectDescription:IOe,ONLYOFFICEWallet:LOe,ONLYOFFICEWalletDescription:NOe,AIProviders:$Oe,AIProvidersDescription:jOe,RegisterConnectWallet:BOe,AddProvider:FOe,Connection:zOe,MCPServers:VOe,AIProvider:UOe,EditAIProvider:HOe,Provider:WOe,Name:qOe,URL:GOe,EnterName:KOe,EnterURL:YOe,Key:XOe,EnterKey:JOe,Cancel:QOe,Save:ZOe,Edit:ePe,Delete:tPe,Warning:nPe,WantDeleteProvider:rPe,WantDeleteChat:iPe,Yes:sPe,No:oPe,WelcomeTitle:aPe,WelcomeDescription:lPe,Rename:cPe,Download:uPe,Search:hPe,AddLocalFile:fPe,RecentFiles:dPe,Attachments:pPe,APIKey:mPe,NewChat:gPe,AskAI:yPe,Analyzing:bPe,AIWouldLikeUseThisTool:vPe,ReviewEachAction:xPe,AlwaysAllow:wPe,Deny:SPe,Allow:_Pe,ToolCallArguments:CPe,ToolCallResult:APe,ToolExecuted:EPe,Confirmation:kPe,SelectModel:TPe,CustomServersDescription:RPe,EditConfiguration:MPe,EnterYourJSONConfiguration:OPe,AvailableTools:PPe,Tools:DPe,ToolsEnabled:IPe,EnableAllTools:LPe,DisableAllTools:NPe,Restart:$Pe,Logs:jPe,CopyToClipboard:BPe,Close:FPe,WebSearch:zPe,WebSearchDescription:VPe,ResetSettings:UPe,WebSearchEngine:HPe,SelectEngine:WPe,AllTools:qPe,EnableWebSearch:GPe,WantDeleteServer:KPe,NoModelsAvailable:YPe,CheckInfo:XPe},QPe="KI-Agent",ZPe="Einstellungen des KI-Agenten",eDe="Einstellungen",tDe="Verbinden Sie ein KI-Modell, um loszulegen",nDe="Es ist noch kein KI-Modell verbunden. Verbinden Sie ein Modell, um direkt hier in der Benutzeroberfläche damit zu interagieren.",rDe="KI-Modell verbinden",iDe="Chatverlauf",sDe="Es gibt noch keinen Chatverlauf...",oDe="Wählen Sie aus, wie Sie die KI verbinden möchten",aDe="Wählen Sie aus, wie Sie die KI-Funktionen in ONLYOFFICE aktivieren möchten.",lDe="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.",cDe="ONLYOFFICE Wallet",uDe="Laden Sie Ihr Guthaben mit einer Karte auf und nutzen Sie sofort alle KI-Funktionen.",hDe="Ihr KI-Anbieter",fDe="Verbinden Sie Ihre eigene KI-Quelle entweder über einen API-Schlüssel eines Anbieters oder über ein lokal gehostetes Modell.",dDe="Registrieren und Wallet verbinden",pDe="Anbieter hinzufügen",mDe="Verbindung",gDe="MCP-Server",yDe="KI-Anbieter",bDe="KI-Anbieter bearbeiten",vDe="Anbieter",xDe="Name",wDe="URL",SDe="Name eingeben",_De="URL eingeben",CDe="API-Schlüssel",ADe="API-Schlüssel eingeben",EDe="Abbrechen",kDe="Speichern",TDe="Bearbeiten",RDe="Löschen",MDe="Warnung",ODe="Möchten Sie diesen Anbieter wirklich löschen?",PDe="Möchten Sie diesen Chat wirklich löschen?",DDe="Ja",IDe="Nein",LDe="Wie kann ich helfen?",NDe="Kostenloser KI-Chat, Schreibassistent und Ideengenerator",$De="Umbenennen",jDe="Herunterladen",BDe="Suchen...",FDe="Lokale Datei hinzufügen...",zDe="Zuletzt verwendete Dateien",VDe="Anlagen",UDe="API-Schlüssel",HDe="Neuer Chat",WDe="KI fragen",qDe="Analyse läuft...",GDe="KI möchte dieses Tool verwenden:",KDe=`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.`,YDe="Diesem Tool immer erlauben, diese Aktion ohne erneute Nachfrage auszuführen.",XDe="Ablehnen",JDe="Erlauben",QDe="Argumente des Toolaufrufs",ZDe="Ergebnis des Toolaufrufs",eIe="Tool ausgeführt",tIe="Bestätigung",nIe="Modell auswählen",rIe=" 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.",iIe="Konfiguration bearbeiten",sIe="Geben Sie Ihre JSON-Konfiguration ein:",oIe="Verfügbare Tools",aIe="Tools",lIe="Tools aktiviert",cIe="Alle Tools aktivieren",uIe="Alle Tools deaktivieren",hIe="Neustart",fIe="Protokolle",dIe="In die Zwischenablage kopieren",pIe="Schließen",mIe="Websuche",gIe="Verbinden Sie eine Websuchmaschine, um KI-Chats mit Echtzeitinformationen aus dem Internet zu verbessern.",yIe="Einstellungen zurücksetzen",bIe="Web-Suchmaschine",vIe="Engine auswählen",xIe="Alle Tools",wIe="Aktivieren Sie die Websuche in den Einstellungen",SIe="Dieser Server wird aus Ihrer Liste gelöscht. Weiter?",_Ie="Anbieter nicht verfügbar",CIe="KI-Chat kann Fehler machen. Überprüfen Sie wichtige Informationen.",AIe={AIAgent:QPe,AIAgentSettings:ZPe,Settings:eDe,ConnectAIModel:tDe,ConnectAIModelDescription:nDe,ConnectAIModelBtn:rDe,ChatHistory:iDe,NoChatYet:sDe,ChooseHowConnect:oDe,SelectHowConnect:aDe,SelectHowConnectDescription:lDe,ONLYOFFICEWallet:cDe,ONLYOFFICEWalletDescription:uDe,AIProviders:hDe,AIProvidersDescription:fDe,RegisterConnectWallet:dDe,AddProvider:pDe,Connection:mDe,MCPServers:gDe,AIProvider:yDe,EditAIProvider:bDe,Provider:vDe,Name:xDe,URL:wDe,EnterName:SDe,EnterURL:_De,Key:CDe,EnterKey:ADe,Cancel:EDe,Save:kDe,Edit:TDe,Delete:RDe,Warning:MDe,WantDeleteProvider:ODe,WantDeleteChat:PDe,Yes:DDe,No:IDe,WelcomeTitle:LDe,WelcomeDescription:NDe,Rename:$De,Download:jDe,Search:BDe,AddLocalFile:FDe,RecentFiles:zDe,Attachments:VDe,APIKey:UDe,NewChat:HDe,AskAI:WDe,Analyzing:qDe,AIWouldLikeUseThisTool:GDe,ReviewEachAction:KDe,AlwaysAllow:YDe,Deny:XDe,Allow:JDe,ToolCallArguments:QDe,ToolCallResult:ZDe,ToolExecuted:eIe,Confirmation:tIe,SelectModel:nIe,CustomServersDescription:rIe,EditConfiguration:iIe,EnterYourJSONConfiguration:sIe,AvailableTools:oIe,Tools:aIe,ToolsEnabled:lIe,EnableAllTools:cIe,DisableAllTools:uIe,Restart:hIe,Logs:fIe,CopyToClipboard:dIe,Close:pIe,WebSearch:mIe,WebSearchDescription:gIe,ResetSettings:yIe,WebSearchEngine:bIe,SelectEngine:vIe,AllTools:xIe,EnableWebSearch:wIe,WantDeleteServer:SIe,NoModelsAvailable:_Ie,CheckInfo:CIe},EIe="Agente de IA",kIe="Configuración del agente de IA",TIe="Configuración",RIe="Conecte un modelo de IA para empezar",MIe="Aún no hay ningún modelo de IA conectado. Conecte un modelo para empezar a interactuar con él aquí mismo, en la interfaz.",OIe="Conectar un modelo de IA",PIe="Historial del chat",DIe="Todavía no hay historial de chat...",IIe="Elija cómo conectar la IA",LIe="Seleccione cómo desea activar las funciones de IA en ONLYOFFICE.",NIe="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.",$Ie="Monedero de ONLYOFFICE",jIe="Recargue su saldo con una tarjeta y utilice al instante todas las funciones de IA.",BIe="Su proveedor de IA",FIe="Conecte su propia fuente de IA, ya sea mediante una clave de la API de un proveedor o un modelo alojado localmente.",zIe="Regístrese y conecte su monedero",VIe="Añadir proveedor",UIe="Conexión",HIe="Servidores MCP",WIe="Proveedor de IA",qIe="Editar proveedor de IA",GIe="Proveedor",KIe="Nombre",YIe="URL",XIe="Introduzca el nombre",JIe="Introduzca la URL",QIe="Clave de la API",ZIe="Introduzca la clave de la API",eLe="Cancelar",tLe="Guardar",nLe="Editar",rLe="Eliminar",iLe="Advertencia",sLe="¿Está seguro de que desea eliminar este proveedor?",oLe="¿Está seguro de que desea eliminar este chat?",aLe="Sí",lLe="No",cLe="¿En qué puedo ayudarle?",uLe="Chat gratuito, asistente de escritura y generador de ideas",hLe="Renombrar",fLe="Descargar",dLe="Búsqueda...",pLe="Añadir archivo local...",mLe="Archivos recientes",gLe="Archivos adjuntos",yLe="Clave de la API",bLe="Nuevo chat",vLe="Preguntarle a la IA",xLe="Analizando...",wLe="A la IA le gustaría utilizar esta herramienta:",SLe=`Revise cada acción cuidadosamente antes de aprobarla
No podemos garantizar la seguridad o las prácticas de privacidad de las integraciones de terceros.`,_Le="Siempre permitir que esta herramienta realice esta acción sin preguntar de nuevo",CLe="Denegar",ALe="Permitir",ELe="Argumentos de la llamada a la herramienta",kLe="Resultado de la llamada a la herramienta",TLe="Herramienta ejecutada",RLe="Confirmación",MLe="Seleccionar modelo",OLe="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.",PLe="Editar configuración",DLe="Introduzca su configuración JSON:",ILe="Herramientas disponibles",LLe="herramientas",NLe="herramientas habilitadas",$Le="Habilitar todas las herramientas",jLe="Deshabilitar todas las herramientas",BLe="Reiniciar",FLe="Registros",zLe="Copiar al portapapeles",VLe="Cerrar",ULe="Búsqueda en la Web",HLe="Conecte un motor de búsqueda web para mejorar los chats de IA con información en tiempo real procedente de Internet.",WLe="Restablecer configuración",qLe="Motor de búsqueda web",GLe="Seleccionar motor",KLe="Todas las herramientas",YLe="Habilite la búsqueda web en la configuración",XLe="Este servidor se eliminará de su lista. ¿Continuar?",JLe="Proveedor no disponible",QLe="El Chat de IA puede cometer errores. Compruebe la información importante.",ZLe={AIAgent:EIe,AIAgentSettings:kIe,Settings:TIe,ConnectAIModel:RIe,ConnectAIModelDescription:MIe,ConnectAIModelBtn:OIe,ChatHistory:PIe,NoChatYet:DIe,ChooseHowConnect:IIe,SelectHowConnect:LIe,SelectHowConnectDescription:NIe,ONLYOFFICEWallet:$Ie,ONLYOFFICEWalletDescription:jIe,AIProviders:BIe,AIProvidersDescription:FIe,RegisterConnectWallet:zIe,AddProvider:VIe,Connection:UIe,MCPServers:HIe,AIProvider:WIe,EditAIProvider:qIe,Provider:GIe,Name:KIe,URL:YIe,EnterName:XIe,EnterURL:JIe,Key:QIe,EnterKey:ZIe,Cancel:eLe,Save:tLe,Edit:nLe,Delete:rLe,Warning:iLe,WantDeleteProvider:sLe,WantDeleteChat:oLe,Yes:aLe,No:lLe,WelcomeTitle:cLe,WelcomeDescription:uLe,Rename:hLe,Download:fLe,Search:dLe,AddLocalFile:pLe,RecentFiles:mLe,Attachments:gLe,APIKey:yLe,NewChat:bLe,AskAI:vLe,Analyzing:xLe,AIWouldLikeUseThisTool:wLe,ReviewEachAction:SLe,AlwaysAllow:_Le,Deny:CLe,Allow:ALe,ToolCallArguments:ELe,ToolCallResult:kLe,ToolExecuted:TLe,Confirmation:RLe,SelectModel:MLe,CustomServersDescription:OLe,EditConfiguration:PLe,EnterYourJSONConfiguration:DLe,AvailableTools:ILe,Tools:LLe,ToolsEnabled:NLe,EnableAllTools:$Le,DisableAllTools:jLe,Restart:BLe,Logs:FLe,CopyToClipboard:zLe,Close:VLe,WebSearch:ULe,WebSearchDescription:HLe,ResetSettings:WLe,WebSearchEngine:qLe,SelectEngine:GLe,AllTools:KLe,EnableWebSearch:YLe,WantDeleteServer:XLe,NoModelsAvailable:JLe,CheckInfo:QLe},eNe="Agent IA",tNe="Paramètres de l'agent IA",nNe="Paramètres",rNe="Connectez un modèle d'IA pour commencer",iNe="Aucun modèle d'IA n'est encore connecté. Associez un modèle pour commencer à interagir avec lui directement dans l'interface.",sNe="Connecter un modèle d'IA",oNe="Historique de chat",aNe="Il n'y a pas encore d'historique de chat...",lNe="Choisissez comment connecter l'IA",cNe="Sélectionnez comment vous souhaitez activer les fonctionnalités IA dans ONLYOFFICE.",uNe="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.",hNe="Wallet ONLYOFFICE",fNe="Rechargez votre solde avec une carte et utilisez instantanément toutes les fonctionnalités de l'IA.",dNe="Votre fournisseur d'IA",pNe="Connectez votre propre source d'IA, soit via une clé API fournie par un fournisseur, soit via un modèle hébergé localement.",mNe="Enregistrez et connectez votre Wallet",gNe="Ajouter un fournisseur",yNe="Connexion",bNe="Serveurs MCP",vNe="Fournisseur d'IA",xNe="Modifier le fournisseur d'IA",wNe="Fournisseur",SNe="Nom",_Ne="URL",CNe="Saisissez le nom",ANe="Saisissez l'URL",ENe="Clé API",kNe="Saisissez la clé API",TNe="Annuler",RNe="Enregistrer",MNe="Modifier",ONe="Supprimer",PNe="Avertissement",DNe="Souhaitez-vous vraiment supprimer ce fournisseur ?",INe="Souhaitez-vous vraiment supprimer ce chat ?",LNe="Oui",NNe="Non",$Ne="Comment puis-je vous aider ?",jNe="Chat Al gratuit, assistant de rédaction et générateur d'idées",BNe="Renommer",FNe="Télécharger",zNe="Recherche...",VNe="Ajout d'un fichier local...",UNe="Fichiers récents",HNe="Pièces jointes",WNe="Clé API",qNe="Nouveau chat",GNe="Demander à l'IA",KNe="Analyse en cours...",YNe="lA aimerait utiliser cet outil :",XNe="Examinez attentivement chaque action avant de l'approuver. Nous ne pouvons garantir la sécurité ou les pratiques de confidentialité des intégrations tierces.",JNe="Toujours autoriser cet outil à effectuer cette action sans demander à nouveau",QNe="Refuser",ZNe="Autoriser",e3e="Arguments d'appel d'outil",t3e="Résultat de l'appel de l'outil",n3e="Outil exécuté",r3e="Confirmation",i3e="Sélectionner le modèle",s3e=" 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.",o3e="Modifier la configuration",a3e="Entrez votre configuration JSON :",l3e="Outils disponibles",c3e="outils",u3e="outils activés",h3e="Activer tous les outils",f3e="Désactiver tous les outils",d3e="Redémarrer",p3e="Logs",m3e="Copier dans le presse-papiers",g3e="Fermer",y3e="Recherche sur le Web",b3e="Connectez un moteur de recherche Web pour améliorer les conversations IA grâce à des informations en temps réel provenant d'Internet.",v3e="Réinitialiser les paramètres",x3e="Moteur de recherche Web",w3e="Sélectionner le moteur",S3e="Tous les outils",_3e="Activer la recherche Web dans les paramètres",C3e="Ce serveur sera supprimé de votre liste. Continuer ?",A3e="Fournisseur indisponible",E3e="Le chatbot IA peut faire des erreurs. Vérifiez les informations importantes.",k3e={AIAgent:eNe,AIAgentSettings:tNe,Settings:nNe,ConnectAIModel:rNe,ConnectAIModelDescription:iNe,ConnectAIModelBtn:sNe,ChatHistory:oNe,NoChatYet:aNe,ChooseHowConnect:lNe,SelectHowConnect:cNe,SelectHowConnectDescription:uNe,ONLYOFFICEWallet:hNe,ONLYOFFICEWalletDescription:fNe,AIProviders:dNe,AIProvidersDescription:pNe,RegisterConnectWallet:mNe,AddProvider:gNe,Connection:yNe,MCPServers:bNe,AIProvider:vNe,EditAIProvider:xNe,Provider:wNe,Name:SNe,URL:_Ne,EnterName:CNe,EnterURL:ANe,Key:ENe,EnterKey:kNe,Cancel:TNe,Save:RNe,Edit:MNe,Delete:ONe,Warning:PNe,WantDeleteProvider:DNe,WantDeleteChat:INe,Yes:LNe,No:NNe,WelcomeTitle:$Ne,WelcomeDescription:jNe,Rename:BNe,Download:FNe,Search:zNe,AddLocalFile:VNe,RecentFiles:UNe,Attachments:HNe,APIKey:WNe,NewChat:qNe,AskAI:GNe,Analyzing:KNe,AIWouldLikeUseThisTool:YNe,ReviewEachAction:XNe,AlwaysAllow:JNe,Deny:QNe,Allow:ZNe,ToolCallArguments:e3e,ToolCallResult:t3e,ToolExecuted:n3e,Confirmation:r3e,SelectModel:i3e,CustomServersDescription:s3e,EditConfiguration:o3e,EnterYourJSONConfiguration:a3e,AvailableTools:l3e,Tools:c3e,ToolsEnabled:u3e,EnableAllTools:h3e,DisableAllTools:f3e,Restart:d3e,Logs:p3e,CopyToClipboard:m3e,Close:g3e,WebSearch:y3e,WebSearchDescription:b3e,ResetSettings:v3e,WebSearchEngine:x3e,SelectEngine:w3e,AllTools:S3e,EnableWebSearch:_3e,WantDeleteServer:C3e,NoModelsAvailable:A3e,CheckInfo:E3e},T3e="Agente AI",R3e="Impostazioni agente AI",M3e="Impostazioni",O3e="Collega un modello AI per iniziare",P3e="Nessun modello AI è stato collegato. Collega un modello per iniziare a interagire direttamente da questa interfaccia.",D3e="Collega un modello AI",I3e="Cronologia chat",L3e="Non c'è ancora alcuna cronologia chat...",N3e="Scegli come collegare l'AI",$3e="Scegli come desideri abilitare le funzionalità AI in ONLYOFFICE.",j3e="Puoi usare il Wallet integrato per iniziare subito oppure collegare il tuo modello AI tramite una chiave API o un modello ospitato localmente.",B3e="Wallet ONLYOFFICE",F3e="Ricarica il saldo con una carta e usa subito tutte le funzioni AI.",z3e="Il tuo provider AI",V3e="Collega la tua fonte AI tramite chiave API di un provider o modello ospitato localmente.",U3e="Registrati e collega il Wallet",H3e="Aggiungi provider",W3e="Connessione",q3e="Server MCP",G3e="Provider AI",K3e="Modifica provider AI",Y3e="Provider",X3e="Nome",J3e="URL",Q3e="Inserisci nome",Z3e="Inserisci URL",e4e="Chiave API",t4e="Inserisci chiave API",n4e="Annulla",r4e="Salva",i4e="Modifica",s4e="Elimina",o4e="Avviso",a4e="Vuoi davvero eliminare questo provider?",l4e="Vuoi davvero eliminare questa chat?",c4e="Sì",u4e="No",h4e="Come posso aiutarti?",f4e="Chat AI gratuita, assistente di scrittura e generatore di idee",d4e="Rinomina",p4e="Scarica",m4e="Cerca...",g4e="Aggiungi file locale...",y4e="File recenti",b4e="Allegati",v4e="Chiave API",x4e="Nuova chat",w4e="Chiedi all'AI",S4e="Analisi in corso...",_4e="L'AI vorrebbe usare questo strumento:",C4e=`Controlla attentamente ogni azione prima di approvarla
Non possiamo garantire la sicurezza o le pratiche sulla privacy delle integrazioni di terze parti.`,A4e="Consenti sempre a questo strumento di eseguire questa azione senza chiedere di nuovo",E4e="Nega",k4e="Consenti",T4e="Argomenti della chiamata dello strumento",R4e="Risultato della chiamata dello strumento",M4e="Strumento eseguito",O4e="Conferma",P4e="Seleziona modello",D4e="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.",I4e="Modifica configurazione",L4e="Inserisci la tua configurazione JSON:",N4e="Strumenti disponibili",$4e="strumenti",j4e="strumenti abilitati",B4e="Abilita tutti gli strumenti",F4e="Disabilita tutti gli strumenti",z4e="Riavvia",V4e="Log",U4e="Copia negli appunti",H4e="Chiudi",W4e="Ricerca web",q4e="Collega un motore di ricerca web per arricchire le chat AI con informazioni aggiornate da Internet.",G4e="Reimposta impostazioni",K4e="Motore di ricerca web",Y4e="Seleziona motore",X4e="Tutti gli strumenti",J4e="Abilita la ricerca web nelle impostazioni",Q4e="Questo server verrà rimosso dall'elenco. Continuare?",Z4e="Provider non disponibile",e5e="L'AI può commettere errori. Verifica le informazioni importanti.",t5e={AIAgent:T3e,AIAgentSettings:R3e,Settings:M3e,ConnectAIModel:O3e,ConnectAIModelDescription:P3e,ConnectAIModelBtn:D3e,ChatHistory:I3e,NoChatYet:L3e,ChooseHowConnect:N3e,SelectHowConnect:$3e,SelectHowConnectDescription:j3e,ONLYOFFICEWallet:B3e,ONLYOFFICEWalletDescription:F3e,AIProviders:z3e,AIProvidersDescription:V3e,RegisterConnectWallet:U3e,AddProvider:H3e,Connection:W3e,MCPServers:q3e,AIProvider:G3e,EditAIProvider:K3e,Provider:Y3e,Name:X3e,URL:J3e,EnterName:Q3e,EnterURL:Z3e,Key:e4e,EnterKey:t4e,Cancel:n4e,Save:r4e,Edit:i4e,Delete:s4e,Warning:o4e,WantDeleteProvider:a4e,WantDeleteChat:l4e,Yes:c4e,No:u4e,WelcomeTitle:h4e,WelcomeDescription:f4e,Rename:d4e,Download:p4e,Search:m4e,AddLocalFile:g4e,RecentFiles:y4e,Attachments:b4e,APIKey:v4e,NewChat:x4e,AskAI:w4e,Analyzing:S4e,AIWouldLikeUseThisTool:_4e,ReviewEachAction:C4e,AlwaysAllow:A4e,Deny:E4e,Allow:k4e,ToolCallArguments:T4e,ToolCallResult:R4e,ToolExecuted:M4e,Confirmation:O4e,SelectModel:P4e,CustomServersDescription:D4e,EditConfiguration:I4e,EnterYourJSONConfiguration:L4e,AvailableTools:N4e,Tools:$4e,ToolsEnabled:j4e,EnableAllTools:B4e,DisableAllTools:F4e,Restart:z4e,Logs:V4e,CopyToClipboard:U4e,Close:H4e,WebSearch:W4e,WebSearchDescription:q4e,ResetSettings:G4e,WebSearchEngine:K4e,SelectEngine:Y4e,AllTools:X4e,EnableWebSearch:J4e,WantDeleteServer:Q4e,NoModelsAvailable:Z4e,CheckInfo:e5e},n5e="Asystent AI",r5e="Ustawienia asystenta AI",i5e="Ustawienia",s5e="Podłącz model AI, aby rozpocząć",o5e="Nie podłączono jeszcze żadnego modelu AI. Podłącz model, aby rozpocząć interakcje z nim bezpośrednio w interfejsie.",a5e="Podłącz model AI",l5e="Historia czatów",c5e="Nie ma jeszcze historii czatów...",u5e="Wybierz, jak podłączyć AI",h5e="Wybierz, jak chcesz włączyć funkcje AI w ONLYOFFICE.",f5e="Użyj wbudowanego Portfela, aby szybko rozpocząć pracę bądź skonfiguruj własny model AI za pomocą klucza API lub lokalnie hostowanego modelu.",d5e="Portfel ONLYOFFICE",p5e="Zasil saldo kartą, aby uzyskać natychmiastowy dostęp do wszystkich funkcji AI.",m5e="Twój dostawca AI",g5e="Skonfiguruj własne źródło AI za pomocą klucza API od usługodawcy lub łącząc się z lokalnie hostowanym modelem.",y5e="Zarejestruj się i Podłącz Portfel",b5e="Dodaj dostawcę",v5e="Połączenie",x5e="Serwery MCP",w5e="Dostawca AI",S5e="Edytuj dostawcę AI",_5e="Dostawca",C5e="Nazwa",A5e="URL",E5e="Wpisz nazwę",k5e="Wpisz adres URL",T5e="Klucz API",R5e="Wpisz klucz API",M5e="Anuluj",O5e="Zapisz",P5e="Edytuj",D5e="Usuń",I5e="Uwaga",L5e="Czy na pewno chcesz usunąć tego dostawcę?",N5e="Czy na pewno chcesz usunąć ten czat?",$5e="Tak",j5e="Nie",B5e="Jak mogę pomóc?",F5e="Darmowy czat AI, asystent pisania i generator pomysłów",z5e="Zmień nazwę",V5e="Pobierz",U5e="Wyszukaj...",H5e="Dodaj plik lokalny...",W5e="Ostatnie pliki",q5e="Załączniki",G5e="Klucz API",K5e="Nowy czat",Y5e="Zapytaj AI",X5e="Analizowanie...",J5e="AI chce skorzystać z tego narzędzia:",Q5e=`Sprawdź każde działanie przed zatwierdzeniem
Nie gwarantujemy bezpieczeństwa ani prywatności w integracjach z podmiotami trzecimi.`,Z5e="Zawsze zezwalaj narzędziu na to działanie bez ponownego pytania",e$e="Odmów",t$e="Zezwól",n$e="Parametry wywołania narzędzia",r$e="Rezultat wywołania narzędzia",i$e="Działanie narzędzia zakończone",s$e="Potwierdzenie",o$e="Wybierz model",a$e="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.",l$e="Edytuj konfigurację",c$e="Wpisz swoją konfigurację JSON:",u$e="Dostępne narzędzia",h$e="narzędzia",f$e="włączone narzędzia",d$e="Włącz wszystkie narzędzia",p$e="Wyłącz wszystkie narzędzia",m$e="Uruchom ponownie",g$e="Logi",y$e="Skopiuj do schowka",b$e="Zamknij",v$e="Wyszukiwanie w internecie",x$e="Podłącz wyszukiwarkę, aby wzbogacić czat AI o najnowsze informacje z internetu.",w$e="Resetuj ustawienia",S$e="Wyszukiwarka internetowa",_$e="Wybierz wyszukiwarkę",C$e="Wszystkie narzędzia",A$e="Włącz wyszukiwanie w internecie w ustawieniach",E$e="Serwer zostanie usunięty z Twojej listy. Kontynuować?",k$e="Dostawca jest niedostępny",T$e="Czat AI może popełniać błędy. Sprawdź ważne informacje.",R$e={AIAgent:n5e,AIAgentSettings:r5e,Settings:i5e,ConnectAIModel:s5e,ConnectAIModelDescription:o5e,ConnectAIModelBtn:a5e,ChatHistory:l5e,NoChatYet:c5e,ChooseHowConnect:u5e,SelectHowConnect:h5e,SelectHowConnectDescription:f5e,ONLYOFFICEWallet:d5e,ONLYOFFICEWalletDescription:p5e,AIProviders:m5e,AIProvidersDescription:g5e,RegisterConnectWallet:y5e,AddProvider:b5e,Connection:v5e,MCPServers:x5e,AIProvider:w5e,EditAIProvider:S5e,Provider:_5e,Name:C5e,URL:A5e,EnterName:E5e,EnterURL:k5e,Key:T5e,EnterKey:R5e,Cancel:M5e,Save:O5e,Edit:P5e,Delete:D5e,Warning:I5e,WantDeleteProvider:L5e,WantDeleteChat:N5e,Yes:$5e,No:j5e,WelcomeTitle:B5e,WelcomeDescription:F5e,Rename:z5e,Download:V5e,Search:U5e,AddLocalFile:H5e,RecentFiles:W5e,Attachments:q5e,APIKey:G5e,NewChat:K5e,AskAI:Y5e,Analyzing:X5e,AIWouldLikeUseThisTool:J5e,ReviewEachAction:Q5e,AlwaysAllow:Z5e,Deny:e$e,Allow:t$e,ToolCallArguments:n$e,ToolCallResult:r$e,ToolExecuted:i$e,Confirmation:s$e,SelectModel:o$e,CustomServersDescription:a$e,EditConfiguration:l$e,EnterYourJSONConfiguration:c$e,AvailableTools:u$e,Tools:h$e,ToolsEnabled:f$e,EnableAllTools:d$e,DisableAllTools:p$e,Restart:m$e,Logs:g$e,CopyToClipboard:y$e,Close:b$e,WebSearch:v$e,WebSearchDescription:x$e,ResetSettings:w$e,WebSearchEngine:S$e,SelectEngine:_$e,AllTools:C$e,EnableWebSearch:A$e,WantDeleteServer:E$e,NoModelsAvailable:k$e,CheckInfo:T$e},M$e="Agente de IA",O$e="Configurações do agente de IA",P$e="Configurações",D$e="Conecte um modelo de IA para começar",I$e="Nenhum modelo de IA está conectado ainda. Conecte um modelo para começar a interagir com ele aqui mesmo na interface.",L$e="Conectar um modelo de IA",N$e="Histórico do bate-papo",$$e="Ainda não há histórico de bate-papo...",j$e="Escolha como conectar a IA",B$e="Selecione como deseja ativar os recursos de IA no ONLYOFFICE.",F$e="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.",z$e="Carteira ONLYOFFICE",V$e="Recarregue seu saldo com um cartão e use instantaneamente todos os recursos de IA.",U$e="Seu provedor de IA",H$e="Conecte sua própria fonte de IA — seja por meio de uma chave de API de um provedor ou um modelo hospedado localmente.",W$e="Registre e conecte sua carteira",q$e="Adicionar provedor",G$e="Conexão",K$e="Servidores MCP",Y$e="Provedor de IA",X$e="Editar provedor de IA",J$e="Fornecedor",Q$e="Nome",Z$e="URL",eje="Digite o nome",tje="Inserir URL",nje="Chave de API",rje="Cancelar",ije="Salvar",sje="Editar",oje="Excluir",aje="Aviso",lje="Tem certeza de que deseja excluir este provedor?",cje="Tem certeza de que deseja excluir este chat?",uje="Sim",hje="Não",fje="Como posso ajudar?",dje="Chat gratuito com IA, assistente de escrita e gerador de ideias",pje="Renomear",mje="Baixar",gje="Pesquisar...",yje="Adicionar arquivo local...",bje="Arquivos recentes",vje="Anexos",xje="Chave de API",wje="Novo bate-papo",Sje="Pergunte à IA",_je="Analisando...",Cje="Al gostaria de usar esta ferramenta:",Aje="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.",Eje="Permitir que esta ferramenta execute esta ação sem perguntar novamente",kje="Negar",Tje="Permitir",Rje="Argumentos da chamada da ferramenta",Mje="Resultado da chamada da ferramenta",Oje="Ferramenta executada",Pje="Confirmação",Dje="Selecionar modelo",Ije="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.",Lje="Editar configuração",Nje="Digite sua configuração JSON:",$je="Ferramentas disponíveis",jje="ferramentas",Bje="ferramentas ativadas",Fje="Ativar todas as ferramentas",zje="Desativar todas as ferramentas",Vje="Reiniciar",Uje="Registros",Hje="Copiar para a área de transferência",Wje="Fechar",qje="Busca na Web",Gje="Conecte um mecanismo de busca na web para aprimorar bate-papos com IA com informações em tempo real da internet.",Kje="Redefinir configurações",Yje="Mecanismo de busca na Web",Xje="Selecionar motor",Jje="Todas as ferramentas",Qje="Ativar pesquisa na Web nas configurações",Zje="Este servidor será removido da sua lista. Deseja continuar ?",eBe="Fornecedor não disponível",tBe="IA Bater papo Podem ocorrer erros. Verifique informações importantes.",nBe={AIAgent:M$e,AIAgentSettings:O$e,Settings:P$e,ConnectAIModel:D$e,ConnectAIModelDescription:I$e,ConnectAIModelBtn:L$e,ChatHistory:N$e,NoChatYet:$$e,ChooseHowConnect:j$e,SelectHowConnect:B$e,SelectHowConnectDescription:F$e,ONLYOFFICEWallet:z$e,ONLYOFFICEWalletDescription:V$e,AIProviders:U$e,AIProvidersDescription:H$e,RegisterConnectWallet:W$e,AddProvider:q$e,Connection:G$e,MCPServers:K$e,AIProvider:Y$e,EditAIProvider:X$e,Provider:J$e,Name:Q$e,URL:Z$e,EnterName:eje,EnterURL:tje,Key:nje,"EnterKey ":"Insira a chave da API",Cancel:rje,Save:ije,Edit:sje,Delete:oje,Warning:aje,WantDeleteProvider:lje,WantDeleteChat:cje,Yes:uje,No:hje,WelcomeTitle:fje,WelcomeDescription:dje,Rename:pje,Download:mje,Search:gje,AddLocalFile:yje,RecentFiles:bje,Anexos:vje,APIKey:xje,Attachments:wje,AskAI:Sje,Analyzing:_je,AIWouldLikeUseThisTool:Cje,ReviewEachAction:Aje,AlwaysAllow:Eje,Deny:kje,Allow:Tje,ToolCallArguments:Rje,ToolCallResult:Mje,ToolExecuted:Oje,Confirmation:Pje,SelectModel:Dje,CustomServersDescription:Ije,EditConfiguration:Lje,EnterYourJSONConfiguration:Nje,AvailableTools:$je,Tools:jje,ToolsEnabled:Bje,EnableAllTools:Fje,DisableAllTools:zje,Restart:Vje,Logs:Uje,CopyToClipboard:Hje,Close:Wje,WebSearch:qje,WebSearchDescription:Gje,ResetSettings:Kje,WebSearchEngine:Yje,SelectEngine:Xje,AllTools:Jje,EnableWebSearch:Qje,WantDeleteServer:Zje,NoModelsAvailable:eBe,CheckInfo:tBe},rBe="Agent AI",iBe="Nastavenia agenta AI",sBe="Nastavenia",oBe="Pripojte model AI, aby ste mohli začať",aBe="Zatiaľ nie je pripojený žiadny model AI. Pripojte model AI, aby ste s ním mohli komunikovať priamo v tomto rozhraní.",lBe="Pripojiť model AI",cBe="História chatu",uBe="Zatiaľ tu nie je žiadna história chatu...",hBe="Vyberte spôsob pripojenia AI",fBe="Vyberte, ako chcete povoliť funkcie AI v ONLYOFFICE.",dBe="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.",pBe="ONLYOFFICE Peňaženka",mBe="Dobíjajte svoj kredit pomocou karty a okamžite využívajte všetky funkcie AI.",gBe="Váš provider pre AI",yBe="Pripojte svoj vlastný model AI buď prostredníctvom API kľúča od providera, alebo nainštalujte lokálny model AI",bBe="Registrovať a pripojiť Peňaženku",vBe="Pridať providera",xBe="Pripojenie",wBe="MCP Servery",SBe="AI Provider",_Be="Upraviť AI Providera",CBe="Provider",ABe="Názov",EBe="URL",kBe="Zadať názov",TBe="Zadať URL",RBe="API kľúč",MBe="Zadať API kľúč",OBe="Zrušiť",PBe="Uložiť",DBe="Upraviť",IBe="Vymazať",LBe="Upozornenie",NBe="Naozaj chcete vymazať tohto providera?",$Be="Naozaj chcete vymazať tento chat?",jBe="Áno",BBe="Nie",FBe="Ako môžem pomôcť?",zBe="Bezplatný AI chat, asistent na písanie textov a generátor nápadov.",VBe="Premenovať",UBe="Stiahnuť",HBe="Hľadať...",WBe="Pridať lokálny súbor...",qBe="Nedávne súbory",GBe="Prílohy",KBe="API kľúč",YBe="Nový chat",XBe="Opýtať sa AI",JBe="Prebieha analýza...",QBe="Al by chcel použiť tento nástroj:",ZBe=`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.`,e8e="Vždy povoliť tomuto nástroju vykonať túto akciu bez opýtania",t8e="Odmietnuť",n8e="Povoliť",r8e="Argumenty volania nástroja",i8e="Výsledok volania nástroja",s8e="Nástroj vykonaný",o8e="Potvrdenie",a8e="Vybrať model",l8e="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.",c8e="Upraviť konfiguráciu",u8e="Zadajte svoju konfiguráciu JSON:",h8e="Dostupné nástroje",f8e="nástroje",d8e="povolené nástroje",p8e="Povoliť všetky nástroje",m8e="Vypnúť všetky nástroje",g8e="Reštartovať",y8e="Protokoly",b8e="Kopírovať do schránky",v8e="Zatvoriť",x8e="Hľadať na webe",w8e="Pripojte webový vyhľadávač, aby mohol AI chat využívať aktuálne údaje z internetu v reálnom čase.",S8e="Obnoviť nastavenia",_8e="Webový vyhľadávač",C8e="Vybrať vyhľadávač",A8e="Všetky nástroje",E8e="Povoliť vyhľadávanie na webe v nastaveniach",k8e="Tento server bude odstránený z vášho zoznamu. Pokračovať?",T8e="Provider nie je dostupný",R8e="AI chat môže robiť chyby. Kontrolujte dôležité informácie.",M8e={AIAgent:rBe,AIAgentSettings:iBe,Settings:sBe,ConnectAIModel:oBe,ConnectAIModelDescription:aBe,ConnectAIModelBtn:lBe,ChatHistory:cBe,NoChatYet:uBe,ChooseHowConnect:hBe,SelectHowConnect:fBe,SelectHowConnectDescription:dBe,ONLYOFFICEWallet:pBe,ONLYOFFICEWalletDescription:mBe,AIProviders:gBe,AIProvidersDescription:yBe,RegisterConnectWallet:bBe,AddProvider:vBe,Connection:xBe,MCPServers:wBe,AIProvider:SBe,EditAIProvider:_Be,Provider:CBe,Name:ABe,URL:EBe,EnterName:kBe,EnterURL:TBe,Key:RBe,EnterKey:MBe,Cancel:OBe,Save:PBe,Edit:DBe,Delete:IBe,Warning:LBe,WantDeleteProvider:NBe,WantDeleteChat:$Be,Yes:jBe,No:BBe,WelcomeTitle:FBe,WelcomeDescription:zBe,Rename:VBe,Download:UBe,Search:HBe,AddLocalFile:WBe,RecentFiles:qBe,Attachments:GBe,APIKey:KBe,NewChat:YBe,AskAI:XBe,Analyzing:JBe,AIWouldLikeUseThisTool:QBe,ReviewEachAction:ZBe,AlwaysAllow:e8e,Deny:t8e,Allow:n8e,ToolCallArguments:r8e,ToolCallResult:i8e,ToolExecuted:s8e,Confirmation:o8e,SelectModel:a8e,CustomServersDescription:l8e,EditConfiguration:c8e,EnterYourJSONConfiguration:u8e,AvailableTools:h8e,Tools:f8e,ToolsEnabled:d8e,EnableAllTools:p8e,DisableAllTools:m8e,Restart:g8e,Logs:y8e,CopyToClipboard:b8e,Close:v8e,WebSearch:x8e,WebSearchDescription:w8e,ResetSettings:S8e,WebSearchEngine:_8e,SelectEngine:C8e,AllTools:A8e,EnableWebSearch:E8e,WantDeleteServer:k8e,NoModelsAvailable:T8e,CheckInfo:R8e};wr.use(tie).init({resources:{en:{translation:YRe},ru:{translation:_Oe},"cs-CZ":{translation:JPe},de:{translation:AIe},es:{translation:ZLe},fr:{translation:k3e},it:{translation:t5e},pl:{translation:R$e},"pt-BR":{translation:nBe},"sl-SI":{translation:M8e}},fallbackLng:"en",interpolation:{escapeValue:!1}});const O8e=()=>{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();Zke({isReady:t}),eTe(),tTe({isReady:t});const{onNew:f,convertMessage:d,approveToolCall:m,denyToolCall:y}=Qke({isReady:t});k.useEffect(()=>{o.length&&a()},[o,a]),k.useEffect(()=>{h&&r(!0)},[h]),k.useEffect(()=>($re().then(()=>e(!0)),()=>{ns.close()}),[]);const b=DY({messages:i,onNew:f,onCancel:async()=>{s()},convertMessage:d,adapters:{attachments:new wY([new yY,new vY])}});return c!=="settings"&&!o.length&&!i.length?C.jsx(h$,{children:C.jsx(nse,{})}):C.jsxs(h$,{children:[C.jsx(TX,{runtime:b,children:c==="settings"?C.jsx(Ome,{}):C.jsx(kke,{})}),n?C.jsx(Xke,{onAllow:m,onDeny:y,onClose:()=>r(!1)}):null]})},E$=()=>{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"),BK.createRoot(t).render(C.jsx(k.StrictMode,{children:C.jsx(O8e,{})})))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",E$):E$();