mirror of
https://github.com/ONLYOFFICE/desktop-sdk.git
synced 2026-02-10 18:15:05 +08:00
352 lines
1.6 MiB
352 lines
1.6 MiB
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 TK(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 k0=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 TS={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 rD;function RK(){if(rD)return dd;rD=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 iD;function MK(){return iD||(iD=1,TS.exports=RK()),TS.exports}var C=MK(),RS={exports:{}},Xe={};/**
|
||
* @license React
|
||
* react.production.js
|
||
*
|
||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var sD;function OK(){if(sD)return Xe;sD=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 Xe.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}},Xe.Component=S,Xe.Fragment=n,Xe.Profiler=i,Xe.PureComponent=A,Xe.StrictMode=r,Xe.Suspense=c,Xe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,Xe.__COMPILER_RUNTIME={__proto__:null,c:function(T){return O.H.useMemoCache(T)}},Xe.cache=function(T){return function(){return T.apply(null,arguments)}},Xe.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)},Xe.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},Xe.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)},Xe.createRef=function(){return{current:null}},Xe.forwardRef=function(T){return{$$typeof:a,render:T}},Xe.isValidElement=H,Xe.lazy=function(T){return{$$typeof:f,_payload:{_status:-1,_result:T},_init:G}},Xe.memo=function(T,Z){return{$$typeof:h,type:T,compare:Z===void 0?null:Z}},Xe.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}},Xe.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},Xe.use=function(T){return O.H.use(T)},Xe.useActionState=function(T,Z,ue){return O.H.useActionState(T,Z,ue)},Xe.useCallback=function(T,Z){return O.H.useCallback(T,Z)},Xe.useContext=function(T){return O.H.useContext(T)},Xe.useDebugValue=function(){},Xe.useDeferredValue=function(T,Z){return O.H.useDeferredValue(T,Z)},Xe.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)},Xe.useId=function(){return O.H.useId()},Xe.useImperativeHandle=function(T,Z,ue){return O.H.useImperativeHandle(T,Z,ue)},Xe.useInsertionEffect=function(T,Z){return O.H.useInsertionEffect(T,Z)},Xe.useLayoutEffect=function(T,Z){return O.H.useLayoutEffect(T,Z)},Xe.useMemo=function(T,Z){return O.H.useMemo(T,Z)},Xe.useOptimistic=function(T,Z){return O.H.useOptimistic(T,Z)},Xe.useReducer=function(T,Z,ue){return O.H.useReducer(T,Z,ue)},Xe.useRef=function(T){return O.H.useRef(T)},Xe.useState=function(T){return O.H.useState(T)},Xe.useSyncExternalStore=function(T,Z,ue){return O.H.useSyncExternalStore(T,Z,ue)},Xe.useTransition=function(){return O.H.useTransition()},Xe.version="19.1.1",Xe}var oD;function AE(){return oD||(oD=1,RS.exports=OK()),RS.exports}var k=AE();const be=Pc(k),A5=TK({__proto__:null,default:be},[k]);var MS={exports:{}},pd={},OS={exports:{}},PS={};/**
|
||
* @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 aD;function PK(){return aD||(aD=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}}}})(PS)),PS}var lD;function DK(){return lD||(lD=1,OS.exports=PK()),OS.exports}var DS={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 cD;function IK(){if(cD)return cr;cD=1;var t=AE();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 uD;function E5(){if(uD)return DS.exports;uD=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(),DS.exports=IK(),DS.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 hD;function LK(){if(hD)return pd;hD=1;var t=DK(),e=AE(),n=E5();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)?OP(l):0;break;default:if(l=u.tagName,u=u.namespaceURI)u=OP(u),l=PP(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 Yt(l){l.memoizedState!==null&&L(Ee,l);var u=de.current,p=PP(u,l.type);u!==p&&(L(ke,l),L(de,p))}function Xt(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,ei=t.unstable_cancelCallback,_o=t.unstable_shouldYield,is=t.unstable_requestPaint,nr=t.unstable_now,lf=t.unstable_getCurrentPriorityLevel,kl=t.unstable_ImmediatePriority,Os=t.unstable_UserBlockingPriority,Ps=t.unstable_NormalPriority,Bc=t.unstable_LowPriority,Tl=t.unstable_IdlePriority,Ri=t.log,aa=t.unstable_setDisableYieldValue,oe=null,me=null;function De(l){if(typeof Ri=="function"&&aa(l),me&&typeof me.setStrictMode=="function")try{me.setStrictMode(oe,l)}catch{}}var $e=Math.clz32?Math.clz32:ss,gt=Math.log,Sr=Math.LN2;function ss(l){return l>>>=0,l===0?32:31-(gt(l)/Sr|0)|0}var rr=256,ti=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 an(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=ti;return ti<<=1,(ti&62914560)===0&&(ti=4194304),l}function Rl(l){for(var u=[],p=0;31>p;p++)u.push(l);return u}function os(l,u){l.pendingLanes|=u,u!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function Tw(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&&cg(l,g,0),w!==0&&v===0&&l.tag!==0&&(l.suspendedLanes|=w&~(R&~u))}function cg(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 ug(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:JP(l.type))}function hg(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,Rw="__reactListeners$"+sr,as="__reactHandles$"+sr,fg="__reactResources$"+sr,Ml="__reactMarker$"+sr;function df(l){delete l[Mn],delete l[or],delete l[ff],delete l[Rw],delete l[as]}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=NP(l);l!==null;){if(p=l[Mn])return p;l=NP(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 Mi(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[fg];return u||(u=l[fg]={hoistableStyles:new Map,hoistableScripts:new Map}),u}function ln(l){l[Ml]=!0}var dg=new Set,pg={};function Co(l,u){ni(l,u),ni(l+"Capture",u)}function ni(l,u){for(pg[l]=u,l=0;l<u.length;l++)dg.add(u[l])}var Mw=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]*$"),mg={},gg={};function Ow(l){return er.call(gg,l)?!0:er.call(mg,l)?!1:Mw.test(l)?gg[l]=!0:(mg[l]=!0,!1)}function Vc(l,u,p){if(Ow(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 Oi(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,yg;function Ds(l){if(fa===void 0)try{throw Error()}catch(p){var u=p.stack.trim().match(/\n( *(at )?)/);fa=u&&u[1]||"",yg=-1<p.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<p.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+fa+l+yg}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:"")?Ds(p):""}function Pw(l){switch(l.tag){case 26:case 27:case 5:return Ds(l.type);case 16:return Ds("Lazy");case 13:return Ds("Suspense");case 19:return Ds("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 Ds("Activity");default:return""}}function bg(l){try{var u="";do u+=Pw(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 vg(l){var u=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function gf(l){var u=vg(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 xg(l){if(!l)return!1;var u=l._valueTracker;if(!u)return!0;var p=u.getValue(),g="";return l&&(g=vg(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 Dw=/[\n"\\]/g;function jr(l){return l.replace(Dw,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 wg(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 Sg(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 ri(l,u){if(u){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=u;return}}l.textContent=u}var _g=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 Is(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||_g.has(u)?u==="float"?l.cssFloat=p:l[u]=(""+p).trim():l[u]=p+"px"}function Cg(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&&Is(l,v,g)}else for(var w in u)u.hasOwnProperty(w)&&Is(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 Iw=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"]]),Lw=/^[\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 Lw.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&&xg(g)}break e;case"textarea":Sg(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)&&(o0(),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 ls=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Sf=!1;if(ls)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 Ls=null,ya=null,Xc=null;function Jc(){if(Xc)return Xc;var l,u=ya,p=u.length,g,v="value"in Ls?Ls.value:Ls.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),ii,On,ba,cs=f({},Wt,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Nw,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"?(ii=l.screenX-ba.screenX,On=l.screenY-ba.screenY):On=ii=0,ba=l),ii)},movementY:function(l){return"movementY"in l?l.movementY:On}}),_f=Q(cs),Ag=f({},cs,{dataTransfer:0}),Eg=Q(Ag),Cf=f({},Wt,{relatedTarget:0}),va=Q(Cf),Pq=f({},le,{animationName:0,elapsedTime:0,pseudoElement:0}),Dq=Q(Pq),Iq=f({},le,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),Lq=Q(Iq),Nq=f({},le,{data:0}),jR=Q(Nq),$q={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},jq={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"},Bq={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Fq(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=Bq[l])?!!u[l]:!1}function Nw(){return Fq}var zq=f({},Wt,{key:function(l){if(l.key){var u=$q[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"?jq[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Nw,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}}),Vq=Q(zq),Uq=f({},cs,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),BR=Q(Uq),Hq=f({},Wt,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Nw}),Wq=Q(Hq),qq=f({},le,{propertyName:0,elapsedTime:0,pseudoElement:0}),Gq=Q(qq),Kq=f({},cs,{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}),Yq=Q(Kq),Xq=f({},le,{newState:0,oldState:0}),Jq=Q(Xq),Qq=[9,13,27,32],$w=ls&&"CompositionEvent"in window,Af=null;ls&&"documentMode"in document&&(Af=document.documentMode);var Zq=ls&&"TextEvent"in window&&!Af,FR=ls&&(!$w||Af&&8<Af&&11>=Af),zR=" ",VR=!1;function UR(l,u){switch(l){case"keyup":return Qq.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function HR(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var eu=!1;function eG(l,u){switch(l){case"compositionend":return HR(u);case"keypress":return u.which!==32?null:(VR=!0,zR);case"textInput":return l=u.data,l===zR&&VR?null:l;default:return null}}function tG(l,u){if(eu)return l==="compositionend"||!$w&&UR(l,u)?(l=Jc(),Xc=ya=Ls=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 FR&&u.locale!=="ko"?null:u.data;default:return null}}var nG={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 WR(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u==="input"?!!nG[l.type]:u==="textarea"}function qR(l,u,p,g){Br?pa?pa.push(g):pa=[g]:Br=g,u=f0(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 rG(l){EP(l,0)}function kg(l){var u=Mi(l);if(xg(u))return l}function GR(l,u){if(l==="change")return u}var KR=!1;if(ls){var jw;if(ls){var Bw="oninput"in document;if(!Bw){var YR=document.createElement("div");YR.setAttribute("oninput","return;"),Bw=typeof YR.oninput=="function"}jw=Bw}else jw=!1;KR=jw&&(!document.documentMode||9<document.documentMode)}function XR(){Ef&&(Ef.detachEvent("onpropertychange",JR),kf=Ef=null)}function JR(l){if(l.propertyName==="value"&&kg(kf)){var u=[];qR(u,kf,l,Kc(l)),Yc(rG,u)}}function iG(l,u,p){l==="focusin"?(XR(),Ef=u,kf=p,Ef.attachEvent("onpropertychange",JR)):l==="focusout"&&XR()}function sG(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return kg(kf)}function oG(l,u){if(l==="click")return kg(u)}function aG(l,u){if(l==="input"||l==="change")return kg(u)}function lG(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var si=typeof Object.is=="function"?Object.is:lG;function Tf(l,u){if(si(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)||!si(l[v],u[v]))return!1}return!0}function QR(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function ZR(l,u){var p=QR(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=QR(p)}}function eM(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?eM(l,u.parentNode):"contains"in l?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function tM(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 Fw(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 cG=ls&&"documentMode"in document&&11>=document.documentMode,tu=null,zw=null,Rf=null,Vw=!1;function nM(l,u,p){var g=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Vw||tu==null||tu!==Wc(g)||(g=tu,"selectionStart"in g&&Fw(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=f0(zw,"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")},Uw={},rM={};ls&&(rM=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(Uw[l])return Uw[l];if(!nu[l])return l;var u=nu[l],p;for(p in u)if(u.hasOwnProperty(p)&&p in rM)return Uw[l]=u[p];return l}var iM=Dl("animationend"),sM=Dl("animationiteration"),oM=Dl("animationstart"),uG=Dl("transitionrun"),hG=Dl("transitionstart"),fG=Dl("transitioncancel"),aM=Dl("transitionend"),lM=new Map,Hw="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(" ");Hw.push("scrollEnd");function us(l,u){lM.set(l,u),Co(u,[l])}var cM=new WeakMap;function Pi(l,u){if(typeof l=="object"&&l!==null){var p=cM.get(l);return p!==void 0?p:(u={value:l,source:u,stack:bg(u)},cM.set(l,u),u)}return{value:l,source:u,stack:bg(u)}}var Di=[],ru=0,Ww=0;function Tg(){for(var l=ru,u=Ww=ru=0;u<l;){var p=Di[u];Di[u++]=null;var g=Di[u];Di[u++]=null;var v=Di[u];Di[u++]=null;var w=Di[u];if(Di[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&&uM(p,v,w)}}function Rg(l,u,p,g){Di[ru++]=l,Di[ru++]=u,Di[ru++]=p,Di[ru++]=g,Ww|=g,l.lanes|=g,l=l.alternate,l!==null&&(l.lanes|=g)}function qw(l,u,p,g){return Rg(l,u,p,g),Mg(l)}function iu(l,u){return Rg(l,null,null,u),Mg(l)}function uM(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 Mg(l){if(50<ed)throw ed=0,Q1=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 dG(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 oi(l,u,p,g){return new dG(l,u,p,g)}function Gw(l){return l=l.prototype,!(!l||!l.isReactComponent)}function Ao(l,u){var p=l.alternate;return p===null?(p=oi(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 hM(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 Og(l,u,p,g,v,w){var R=0;if(g=l,typeof l=="function")Gw(l)&&(R=1);else if(typeof l=="string")R=mK(l,p,de.current)?26:l==="html"||l==="head"||l==="body"?27:5;else e:switch(l){case H:return l=oi(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=oi(12,p,u,v|2),l.elementType=S,l.lanes=w,l;case O:return l=oi(13,p,u,v),l.elementType=O,l.lanes=w,l;case M:return l=oi(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=oi(R,p,u,v),u.elementType=l,u.type=g,u.lanes=w,u}function Il(l,u,p,g){return l=oi(7,l,g,u),l.lanes=p,l}function Kw(l,u,p){return l=oi(6,l,null,u),l.lanes=p,l}function Yw(l,u,p){return u=oi(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,Pg=null,Dg=0,Ii=[],Li=0,Ll=null,Eo=1,ko="";function Nl(l,u){ou[au++]=Dg,ou[au++]=Pg,Pg=l,Dg=u}function fM(l,u,p){Ii[Li++]=Eo,Ii[Li++]=ko,Ii[Li++]=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 Xw(l){l.return!==null&&(Nl(l,1),fM(l,1,0))}function Jw(l){for(;l===Pg;)Pg=ou[--au],ou[au]=null,Dg=ou[--au],ou[au]=null;for(;l===Ll;)Ll=Ii[--Li],Ii[Li]=null,ko=Ii[--Li],Ii[Li]=null,Eo=Ii[--Li],Ii[Li]=null}var Cr=null,Jt=null,yt=!1,$l=null,Ns=!1,Qw=Error(r(519));function jl(l){var u=Error(r(418,""));throw Pf(Pi(u,l)),Qw}function dM(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),wg(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||MP(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=d0),u=!0):u=!1,u||jl(l)}function pM(l){for(Cr=l.return;Cr;)switch(Cr.tag){case 5:case 13:Ns=!1;return;case 27:case 3:Ns=!0;return;default:Cr=Cr.return}}function Mf(l){if(l!==Cr)return!1;if(!yt)return pM(l),yt=!0,!1;var u=l.tag,p;if((p=u!==3&&u!==27)&&((p=u===5)&&(p=l.type,p=!(p!=="form"&&p!=="button")||pS(l.type,l.memoizedProps)),p=!p),p&&Jt&&jl(l),pM(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){Jt=fs(l.nextSibling);break e}u--}else p!=="$"&&p!=="$!"&&p!=="$?"||u++;l=l.nextSibling}Jt=null}}else u===27?(u=Jt,La(l.type)?(l=bS,bS=null,Jt=l):Jt=u):Jt=Cr?fs(l.stateNode.nextSibling):null;return!0}function Of(){Jt=Cr=null,yt=!1}function mM(){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 Zw=Z(null),Bl=null,To=null;function xa(l,u,p){L(Zw,u._currentValue),u._currentValue=p}function Ro(l){l._currentValue=Zw.current,ue(Zw)}function e1(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 t1(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),e1(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),e1(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;si(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&&t1(u,l,p,g),u.flags|=262144}function Ig(l){for(l=l.firstContext;l!==null;){if(!si(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 gM(Bl,l)}function Lg(l,u){return Bl===null&&Fl(l),gM(l,u)}function gM(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 pG=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()})}},mG=t.unstable_scheduleCallback,gG=t.unstable_NormalPriority,vn={$$typeof:E,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function n1(){return{controller:new pG,data:new Map,refCount:0}}function If(l){l.refCount--,l.refCount===0&&mG(gG,function(){l.controller.abort()})}var Lf=null,r1=0,lu=0,cu=null;function yG(l,u){if(Lf===null){var p=Lf=[];r1=0,lu=sS(),cu={status:"pending",value:void 0,then:function(g){p.push(g)}}}return r1++,u.then(yM,yM),u}function yM(){if(--r1===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 bG(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 bM=z.S;z.S=function(l,u){typeof u=="object"&&u!==null&&typeof u.then=="function"&&yG(l,u),bM!==null&&bM(l,u)};var zl=Z(null);function i1(){var l=zl.current;return l!==null?l:Dt.pooledCache}function Ng(l,u){u===null?L(zl,zl.current):L(zl,u.pool)}function vM(){var l=i1();return l===null?null:{parent:vn._currentValue,pool:l}}var Nf=Error(r(460)),xM=Error(r(474)),$g=Error(r(542)),s1={then:function(){}};function wM(l){return l=l.status,l==="fulfilled"||l==="rejected"}function jg(){}function SM(l,u,p){switch(p=l[p],p===void 0?l.push(u):p!==u&&(u.then(jg,jg),u=p),u.status){case"fulfilled":return u.value;case"rejected":throw l=u.reason,CM(l),l;default:if(typeof u.status=="string")u.then(jg,jg);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,CM(l),l}throw $f=u,Nf}}var $f=null;function _M(){if($f===null)throw Error(r(459));var l=$f;return $f=null,l}function CM(l){if(l===Nf||l===$g)throw Error(r(483))}var wa=!1;function o1(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function a1(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,(bt&2)!==0){var v=g.pending;return v===null?u.next=u:(u.next=v.next,v.next=u),g.pending=u,u=Mg(l),uM(l,null,p),u}return Rg(l,g,u,p),Mg(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,ug(l,p)}}function l1(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 c1=!1;function Bf(){if(c1){var l=cu;if(l!==null)throw l}}function Ff(l,u,p,g){c1=!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&&(c1=!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 AM(l,u){if(typeof l!="function")throw Error(r(191,l));l.call(u)}function EM(l,u){var p=l.callbacks;if(p!==null)for(l.callbacks=null,l=0;l<p.length;l++)AM(p[l],u)}var uu=Z(null),Bg=Z(0);function kM(l,u){l=No,L(Bg,l),L(uu,u),No=l|u.baseLanes}function u1(){L(Bg,No),L(uu,uu.current)}function h1(){No=Bg.current,ue(uu),ue(Bg)}var Ca=0,et=null,St=null,cn=null,Fg=!1,hu=!1,Vl=!1,zg=0,zf=0,fu=null,vG=0;function nn(){throw Error(r(321))}function f1(l,u){if(u===null)return!1;for(var p=0;p<u.length&&p<l.length;p++)if(!si(l[p],u[p]))return!1;return!0}function d1(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?uO:hO,Vl=!1,w=p(g,v),Vl=!1,hu&&(w=RM(u,p,g,v)),TM(l),w}function TM(l){z.H=Gg;var u=St!==null&&St.next!==null;if(Ca=0,cn=St=et=null,Fg=!1,zf=0,fu=null,u)throw Error(r(300));l===null||Pn||(l=l.dependencies,l!==null&&Ig(l)&&(Pn=!0))}function RM(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,cn=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=EG,w=u(p,g)}while(hu);return w}function xG(){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 p1(){var l=zg!==0;return zg=0,l}function m1(l,u,p){u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~p}function g1(l){if(Fg){for(l=l.memoizedState;l!==null;){var u=l.queue;u!==null&&(u.pending=null),l=l.next}Fg=!1}Ca=0,cn=St=et=null,hu=!1,zf=zg=0,fu=null}function Fr(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return cn===null?et.memoizedState=cn=l:cn=cn.next=l,cn}function un(){if(St===null){var l=et.alternate;l=l!==null?l.memoizedState:null}else l=St.next;var u=cn===null?et.memoizedState:cn.next;if(u!==null)cn=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},cn===null?et.memoizedState=cn=l:cn=cn.next=l}return cn}function y1(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Vf(l){var u=zf;return zf+=1,fu===null&&(fu=[]),l=SM(fu,l,u),u=et,(cn===null?u.memoizedState:cn.next)===null&&(u=u.alternate,z.H=u===null||u.memoizedState===null?uO:hO),l}function Vg(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 b1(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=y1(),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 Ug(l){var u=un();return v1(u,St,l)}function v1(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,!si(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 x1(l){var u=un(),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);si(w,u.memoizedState)||(Pn=!0),u.memoizedState=w,u.baseQueue===null&&(u.baseState=w),p.lastRenderedState=w}return[w,g]}function MM(l,u,p){var g=et,v=un(),w=yt;if(w){if(p===void 0)throw Error(r(407));p=p()}else p=u();var R=!si((St||v).memoizedState,p);R&&(v.memoizedState=p,Pn=!0),v=v.queue;var I=DM.bind(null,g,v,l);if(Uf(2048,8,I,[l]),v.getSnapshot!==u||R||cn!==null&&cn.memoizedState.tag&1){if(g.flags|=2048,du(9,Hg(),PM.bind(null,g,v,p,u),null),Dt===null)throw Error(r(349));w||(Ca&124)!==0||OM(g,u,p)}return p}function OM(l,u,p){l.flags|=16384,l={getSnapshot:u,value:p},u=et.updateQueue,u===null?(u=y1(),et.updateQueue=u,u.stores=[l]):(p=u.stores,p===null?u.stores=[l]:p.push(l))}function PM(l,u,p,g){u.value=p,u.getSnapshot=g,IM(u)&&LM(l)}function DM(l,u,p){return p(function(){IM(u)&&LM(l)})}function IM(l){var u=l.getSnapshot;l=l.value;try{var p=u();return!si(l,p)}catch{return!0}}function LM(l){var u=iu(l,2);u!==null&&hi(u,l,2)}function w1(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 NM(l,u,p,g){return l.baseState=p,v1(l,St,typeof g=="function"?g:Mo)}function wG(l,u,p,g,v){if(qg(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,$M(u,w)):(w.next=p.next,u.pending=p.next=w)}}function $M(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),jM(l,u,I)}catch(ee){S1(l,u,ee)}finally{z.T=w}}else try{w=p(v,g),jM(l,u,w)}catch(ee){S1(l,u,ee)}}function jM(l,u,p){p!==null&&typeof p=="object"&&typeof p.then=="function"?p.then(function(g){BM(l,u,g)},function(g){return S1(l,u,g)}):BM(l,u,p)}function BM(l,u,p){u.status="fulfilled",u.value=p,FM(u),l.state=p,u=l.pending,u!==null&&(p=u.next,p===u?l.pending=null:(p=p.next,u.next=p,$M(l,p)))}function S1(l,u,p){var g=l.pending;if(l.pending=null,g!==null){g=g.next;do u.status="rejected",u.reason=p,FM(u),u=u.next;while(u!==g)}l.action=null}function FM(l){l=l.listeners;for(var u=0;u<l.length;u++)(0,l[u])()}function zM(l,u){return u}function VM(l,u){if(yt){var p=Dt.formState;if(p!==null){e:{var g=et;if(yt){if(Jt){t:{for(var v=Jt,w=Ns;v.nodeType!==8;){if(!w){v=null;break t}if(v=fs(v.nextSibling),v===null){v=null;break t}}w=v.data,v=w==="F!"||w==="F"?v:null}if(v){Jt=fs(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:zM,lastRenderedState:u},p.queue=g,p=aO.bind(null,et,g),g.dispatch=p,g=w1(!1),w=k1.bind(null,et,!1,g.queue),g=Fr(),v={state:u,dispatch:null,action:l,pending:null},g.queue=v,p=wG.bind(null,et,v,w,p),v.dispatch=p,g.memoizedState=l,[u,p,!1]}function UM(l){var u=un();return HM(u,St,l)}function HM(l,u,p){if(u=v1(l,u,zM)[0],l=Ug(Mo)[0],typeof u=="object"&&u!==null&&typeof u.then=="function")try{var g=Vf(u)}catch(R){throw R===Nf?$g:R}else g=u;u=un();var v=u.queue,w=v.dispatch;return p!==u.memoizedState&&(et.flags|=2048,du(9,Hg(),SG.bind(null,v,p),null)),[g,w,l]}function SG(l,u){l.action=u}function WM(l){var u=un(),p=St;if(p!==null)return HM(u,p,l);un(),u=u.memoizedState,p=un();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=y1(),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 Hg(){return{destroy:void 0,resource:void 0}}function qM(){return un().memoizedState}function Wg(l,u,p,g){var v=Fr();g=g===void 0?null:g,et.flags|=l,v.memoizedState=du(1|u,Hg(),p,g)}function Uf(l,u,p,g){var v=un();g=g===void 0?null:g;var w=v.memoizedState.inst;St!==null&&g!==null&&f1(g,St.memoizedState.deps)?v.memoizedState=du(u,w,p,g):(et.flags|=l,v.memoizedState=du(1|u,w,p,g))}function GM(l,u){Wg(8390656,8,l,u)}function KM(l,u){Uf(2048,8,l,u)}function YM(l,u){return Uf(4,2,l,u)}function XM(l,u){return Uf(4,4,l,u)}function JM(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 QM(l,u,p){p=p!=null?p.concat([l]):null,Uf(4,4,JM.bind(null,u,l),p)}function _1(){}function ZM(l,u){var p=un();u=u===void 0?null:u;var g=p.memoizedState;return u!==null&&f1(u,g[1])?g[0]:(p.memoizedState=[l,u],l)}function eO(l,u){var p=un();u=u===void 0?null:u;var g=p.memoizedState;if(u!==null&&f1(u,g[1]))return g[0];if(g=l(),Vl){De(!0);try{l()}finally{De(!1)}}return p.memoizedState=[g,u],g}function C1(l,u,p){return p===void 0||(Ca&1073741824)!==0?l.memoizedState=u:(l.memoizedState=p,l=rP(),et.lanes|=l,Oa|=l,p)}function tO(l,u,p,g){return si(p,u)?p:uu.current!==null?(l=C1(l,p,g),si(l,u)||(Pn=!0),l):(Ca&42)===0?(Pn=!0,l.memoizedState=p):(l=rP(),et.lanes|=l,Oa|=l,u)}function nO(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,k1(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=bG(F,g);Hf(l,u,ae,ui(l))}else Hf(l,u,g,ui(l))}catch(he){Hf(l,u,{then:function(){},status:"rejected",reason:he},ui())}finally{G.p=w,z.T=R}}function _G(){}function A1(l,u,p,g){if(l.tag!==5)throw Error(r(476));var v=rO(l).queue;nO(l,v,u,U,p===null?_G:function(){return iO(l),p(g)})}function rO(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 iO(l){var u=rO(l).next.queue;Hf(l,u,{},ui())}function E1(){return lr(ld)}function sO(){return un().memoizedState}function oO(){return un().memoizedState}function CG(l){for(var u=l.return;u!==null;){switch(u.tag){case 24:case 3:var p=ui();l=Sa(p);var g=_a(u,l,p);g!==null&&(hi(g,u,p),jf(g,u,p)),u={cache:n1()},l.payload=u;return}u=u.return}}function AG(l,u,p){var g=ui();p={lane:g,revertLane:0,action:p,hasEagerState:!1,eagerState:null,next:null},qg(l)?lO(u,p):(p=qw(l,u,p,g),p!==null&&(hi(p,l,g),cO(p,u,g)))}function aO(l,u,p){var g=ui();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(qg(l))lO(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,si(I,R))return Rg(l,u,v,0),Dt===null&&Tg(),!1}catch{}finally{}if(p=qw(l,u,v,g),p!==null)return hi(p,l,g),cO(p,u,g),!0}return!1}function k1(l,u,p,g){if(g={lane:2,revertLane:sS(),action:g,hasEagerState:!1,eagerState:null,next:null},qg(l)){if(u)throw Error(r(479))}else u=qw(l,p,g,2),u!==null&&hi(u,l,2)}function qg(l){var u=l.alternate;return l===et||u!==null&&u===et}function lO(l,u){hu=Fg=!0;var p=l.pending;p===null?u.next=u:(u.next=p.next,p.next=u),l.pending=u}function cO(l,u,p){if((p&4194048)!==0){var g=u.lanes;g&=l.pendingLanes,p|=g,u.lanes=p,ug(l,p)}}var Gg={readContext:lr,use:Vg,useCallback:nn,useContext:nn,useEffect:nn,useImperativeHandle:nn,useLayoutEffect:nn,useInsertionEffect:nn,useMemo:nn,useReducer:nn,useRef:nn,useState:nn,useDebugValue:nn,useDeferredValue:nn,useTransition:nn,useSyncExternalStore:nn,useId:nn,useHostTransitionStatus:nn,useFormState:nn,useActionState:nn,useOptimistic:nn,useMemoCache:nn,useCacheRefresh:nn},uO={readContext:lr,use:Vg,useCallback:function(l,u){return Fr().memoizedState=[l,u===void 0?null:u],l},useContext:lr,useEffect:GM,useImperativeHandle:function(l,u,p){p=p!=null?p.concat([l]):null,Wg(4194308,4,JM.bind(null,u,l),p)},useLayoutEffect:function(l,u){return Wg(4194308,4,l,u)},useInsertionEffect:function(l,u){Wg(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=AG.bind(null,et,l),[g.memoizedState,l]},useRef:function(l){var u=Fr();return l={current:l},u.memoizedState=l},useState:function(l){l=w1(l);var u=l.queue,p=aO.bind(null,et,u);return u.dispatch=p,[l.memoizedState,p]},useDebugValue:_1,useDeferredValue:function(l,u){var p=Fr();return C1(p,l,u)},useTransition:function(){var l=w1(!1);return l=nO.bind(null,et,l.queue,!0,!1),Fr().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,u,p){var g=et,v=Fr();if(yt){if(p===void 0)throw Error(r(407));p=p()}else{if(p=u(),Dt===null)throw Error(r(349));(ct&124)!==0||OM(g,u,p)}v.memoizedState=p;var w={value:p,getSnapshot:u};return v.queue=w,GM(DM.bind(null,g,w,l),[l]),g.flags|=2048,du(9,Hg(),PM.bind(null,g,w,p,u),null),p},useId:function(){var l=Fr(),u=Dt.identifierPrefix;if(yt){var p=ko,g=Eo;p=(g&~(1<<32-$e(g)-1)).toString(32)+p,u="«"+u+"R"+p,p=zg++,0<p&&(u+="H"+p.toString(32)),u+="»"}else p=vG++,u="«"+u+"r"+p.toString(32)+"»";return l.memoizedState=u},useHostTransitionStatus:E1,useFormState:VM,useActionState:VM,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=k1.bind(null,et,!0,p),p.dispatch=u,[l,u]},useMemoCache:b1,useCacheRefresh:function(){return Fr().memoizedState=CG.bind(null,et)}},hO={readContext:lr,use:Vg,useCallback:ZM,useContext:lr,useEffect:KM,useImperativeHandle:QM,useInsertionEffect:YM,useLayoutEffect:XM,useMemo:eO,useReducer:Ug,useRef:qM,useState:function(){return Ug(Mo)},useDebugValue:_1,useDeferredValue:function(l,u){var p=un();return tO(p,St.memoizedState,l,u)},useTransition:function(){var l=Ug(Mo)[0],u=un().memoizedState;return[typeof l=="boolean"?l:Vf(l),u]},useSyncExternalStore:MM,useId:sO,useHostTransitionStatus:E1,useFormState:UM,useActionState:UM,useOptimistic:function(l,u){var p=un();return NM(p,St,l,u)},useMemoCache:b1,useCacheRefresh:oO},EG={readContext:lr,use:Vg,useCallback:ZM,useContext:lr,useEffect:KM,useImperativeHandle:QM,useInsertionEffect:YM,useLayoutEffect:XM,useMemo:eO,useReducer:x1,useRef:qM,useState:function(){return x1(Mo)},useDebugValue:_1,useDeferredValue:function(l,u){var p=un();return St===null?C1(p,l,u):tO(p,St.memoizedState,l,u)},useTransition:function(){var l=x1(Mo)[0],u=un().memoizedState;return[typeof l=="boolean"?l:Vf(l),u]},useSyncExternalStore:MM,useId:sO,useHostTransitionStatus:E1,useFormState:WM,useActionState:WM,useOptimistic:function(l,u){var p=un();return St!==null?NM(p,St,l,u):(p.baseState=l,[l,p.queue.dispatch])},useMemoCache:b1,useCacheRefresh:oO},pu=null,Wf=0;function Kg(l){var u=Wf;return Wf+=1,pu===null&&(pu=[]),SM(pu,l,u)}function qf(l,u){u=u.props.ref,l.ref=u!==void 0?u:null}function Yg(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 fO(l){var u=l._init;return u(l._payload)}function dO(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=Kw(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&&fO(Te)===W.type)?(W=v(W,J.props),qf(W,J),W.return=K,W):(W=Og(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=Yw(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=Kw(""+W,K.mode,J),W.return=K,W;if(typeof W=="object"&&W!==null){switch(W.$$typeof){case m:return J=Og(W.type,W.key,W.props,null,K.mode,J),qf(J,W),J.return=K,J;case y:return W=Yw(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,Kg(W),J);if(W.$$typeof===E)return he(K,Lg(K,W),J);Yg(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,Kg(J),ce);if(J.$$typeof===E)return re(K,W,Lg(K,J),ce);Yg(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,Kg(ce),Te);if(ce.$$typeof===E)return ie(K,W,J,Lg(W,ce),Te);Yg(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),yt&&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 yt&&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)}),yt&&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),yt&&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 yt&&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(kK){return u(K,kK)}),yt&&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&&fO(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=Og(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=Yw(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,Kg(J),ce);if(J.$$typeof===E)return Ct(K,W,Lg(K,J),ce);Yg(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=Kw(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===$g)throw Pe;var rt=oi(29,Pe,null,K.mode);return rt.lanes=ce,rt.return=K,rt}finally{}}}var mu=dO(!0),pO=dO(!1),Ni=Z(null),$s=null;function Aa(l){var u=l.alternate;L(xn,xn.current&1),L(Ni,l),$s===null&&(u===null||uu.current!==null||u.memoizedState!==null)&&($s=l)}function mO(l){if(l.tag===22){if(L(xn,xn.current),L(Ni,l),$s===null){var u=l.alternate;u!==null&&u.memoizedState!==null&&($s=l)}}else Ea()}function Ea(){L(xn,xn.current),L(Ni,Ni.current)}function Oo(l){ue(Ni),$s===l&&($s=null),ue(xn)}var xn=Z(0);function Xg(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==="$?"||yS(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 T1(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 R1={enqueueSetState:function(l,u,p){l=l._reactInternals;var g=ui(),v=Sa(g);v.payload=u,p!=null&&(v.callback=p),u=_a(l,v,g),u!==null&&(hi(u,l,g),jf(u,l,g))},enqueueReplaceState:function(l,u,p){l=l._reactInternals;var g=ui(),v=Sa(g);v.tag=1,v.payload=u,p!=null&&(v.callback=p),u=_a(l,v,g),u!==null&&(hi(u,l,g),jf(u,l,g))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var p=ui(),g=Sa(p);g.tag=2,u!=null&&(g.callback=u),u=_a(l,g,p),u!==null&&(hi(u,l,p),jf(u,l,p))}};function gO(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 yO(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&&R1.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 Jg=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 bO(l){Jg(l)}function vO(l){console.error(l)}function xO(l){Jg(l)}function Qg(l,u){try{var p=l.onUncaughtError;p(u.value,{componentStack:u.stack})}catch(g){setTimeout(function(){throw g})}}function wO(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 M1(l,u,p){return p=Sa(p),p.tag=3,p.payload={element:null},p.callback=function(){Qg(l,u)},p}function SO(l){return l=Sa(l),l.tag=3,l}function _O(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(){wO(u,p,g)}}var R=p.stateNode;R!==null&&typeof R.componentDidCatch=="function"&&(l.callback=function(){wO(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 kG(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=Ni.current,p!==null){switch(p.tag){case 13:return $s===null?eS():p.alternate===null&&Qt===0&&(Qt=3),p.flags&=-257,p.flags|=65536,p.lanes=v,g===s1?p.flags|=16384:(u=p.updateQueue,u===null?p.updateQueue=new Set([g]):u.add(g),nS(l,g,v)),!1;case 22:return p.flags|=65536,g===s1?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)),nS(l,g,v)),!1}throw Error(r(435,p.tag))}return nS(l,g,v),eS(),!1}if(yt)return u=Ni.current,u!==null?((u.flags&65536)===0&&(u.flags|=256),u.flags|=65536,u.lanes=v,g!==Qw&&(l=Error(r(422),{cause:g}),Pf(Pi(l,p)))):(g!==Qw&&(u=Error(r(423),{cause:g}),Pf(Pi(u,p))),l=l.current.alternate,l.flags|=65536,v&=-v,l.lanes|=v,g=Pi(g,p),v=M1(l.stateNode,g,v),l1(l,v),Qt!==4&&(Qt=2)),!1;var w=Error(r(520),{cause:g});if(w=Pi(w,p),Zf===null?Zf=[w]:Zf.push(w),Qt!==4&&(Qt=2),u===null)return!0;g=Pi(g,p),p=u;do{switch(p.tag){case 3:return p.flags|=65536,l=v&-v,p.lanes|=l,l=M1(p.stateNode,g,l),l1(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=SO(v),_O(v,l,p,g),l1(p,v),!1}p=p.return}while(p!==null);return!1}var CO=Error(r(461)),Pn=!1;function Fn(l,u,p,g){u.child=l===null?pO(u,null,p,g):mu(u,l.child,p,g)}function AO(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=d1(l,u,p,R,w,v),I=p1(),l!==null&&!Pn?(m1(l,u,v),Po(l,u,v)):(yt&&I&&Xw(u),u.flags|=1,Fn(l,u,g,v),u.child)}function EO(l,u,p,g,v){if(l===null){var w=p.type;return typeof w=="function"&&!Gw(w)&&w.defaultProps===void 0&&p.compare===null?(u.tag=15,u.type=w,kO(l,u,w,g,v)):(l=Og(p.type,null,g,u,u.mode,v),l.ref=u.ref,l.return=u,u.child=l)}if(w=l.child,!j1(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 kO(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,j1(l,v))(l.flags&131072)!==0&&(Pn=!0);else return u.lanes=l.lanes,Po(l,u,v)}return O1(l,u,p,g,v)}function TO(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 RO(l,u,g,p)}if((p&536870912)!==0)u.memoizedState={baseLanes:0,cachePool:null},l!==null&&Ng(u,w!==null?w.cachePool:null),w!==null?kM(u,w):u1(),mO(u);else return u.lanes=u.childLanes=536870912,RO(l,u,w!==null?w.baseLanes|p:p,p)}else w!==null?(Ng(u,w.cachePool),kM(u,w),Ea(),u.memoizedState=null):(l!==null&&Ng(u,null),u1(),Ea());return Fn(l,u,v,p),u.child}function RO(l,u,p,g){var v=i1();return v=v===null?null:{parent:vn._currentValue,pool:v},u.memoizedState={baseLanes:p,cachePool:v},l!==null&&Ng(u,null),u1(),mO(u),l!==null&&Df(l,u,g,!0),null}function Zg(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 O1(l,u,p,g,v){return Fl(u),p=d1(l,u,p,g,void 0,v),g=p1(),l!==null&&!Pn?(m1(l,u,v),Po(l,u,v)):(yt&&g&&Xw(u),u.flags|=1,Fn(l,u,p,v),u.child)}function MO(l,u,p,g,v,w){return Fl(u),u.updateQueue=null,p=RM(u,g,p,v),TM(l),g=p1(),l!==null&&!Pn?(m1(l,u,w),Po(l,u,w)):(yt&&g&&Xw(u),u.flags|=1,Fn(l,u,p,w),u.child)}function OO(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=R1,u.stateNode=w,w._reactInternals=u,w=u.stateNode,w.props=g,w.state=u.memoizedState,w.refs={},o1(u),R=p.contextType,w.context=typeof R=="object"&&R!==null?lr(R):su,w.state=u.memoizedState,R=p.getDerivedStateFromProps,typeof R=="function"&&(T1(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&&R1.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)&&yO(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"&&(T1(u,p,he,g),ee=u.memoizedState),(F=wa||gO(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,a1(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)&&yO(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&&Ig(l.dependencies)?(typeof I=="function"&&(T1(u,p,I,g),ie=u.memoizedState),(ae=wa||gO(u,p,ae,g,re,ie,F)||l!==null&&l.dependencies!==null&&Ig(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,Zg(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 PO(l,u,p,g){return Of(),u.flags|=256,Fn(l,u,p,g),u.child}var P1={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function D1(l){return{baseLanes:l,cachePool:vM()}}function I1(l,u,p){return l=l!==null?l.childLanes&~p:0,u&&(l|=$i),l}function DO(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(yt){if(v?Aa(u):Ea(),yt){var I=Jt,F;if(F=I){e:{for(F=I,I=Ns;F.nodeType!==8;){if(!I){I=null;break e}if(F=fs(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=oi(18,null,null,0),F.stateNode=I,F.return=u,u.child=F,Cr=u,Jt=null,F=!0):F=!1}F||jl(u)}if(I=u.memoizedState,I!==null&&(I=I.dehydrated,I!==null))return yS(I)?u.lanes=32:u.lanes=536870912,null;Oo(u)}return I=g.children,g=g.fallback,v?(Ea(),v=u.mode,I=e0({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=D1(p),v.childLanes=I1(l,R,p),u.memoizedState=P1,g):(Aa(u),L1(u,I))}if(F=l.memoizedState,F!==null&&(I=F.dehydrated,I!==null)){if(w)u.flags&256?(Aa(u),u.flags&=-257,u=N1(l,u,p)):u.memoizedState!==null?(Ea(),u.child=l.child,u.flags|=128,u=null):(Ea(),v=g.fallback,I=u.mode,g=e0({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=D1(p),g.childLanes=I1(l,R,p),u.memoizedState=P1,u=v);else if(Aa(u),yS(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=N1(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),hi(R,l,g),CO;I.data==="$?"||eS(),u=N1(l,u,p)}else I.data==="$?"?(u.flags|=192,u.child=l.child,u=null):(l=F.treeContext,Jt=fs(I.nextSibling),Cr=u,yt=!0,$l=null,Ns=!1,l!==null&&(Ii[Li++]=Eo,Ii[Li++]=ko,Ii[Li++]=Ll,Eo=l.id,ko=l.overflow,Ll=u),u=L1(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=D1(p):(F=I.cachePool,F!==null?(ee=vn._currentValue,F=F.parent!==ee?{parent:ee,pool:ee}:F):F=vM(),I={baseLanes:I.baseLanes|p,cachePool:F}),v.memoizedState=I,v.childLanes=I1(l,R,p),u.memoizedState=P1,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 L1(l,u){return u=e0({mode:"visible",children:u},l.mode),u.return=l,l.child=u}function e0(l,u){return l=oi(22,l,null,u),l.lanes=0,l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},l}function N1(l,u,p){return mu(u,l.child,null,p),l=L1(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function IO(l,u,p){l.lanes|=u;var g=l.alternate;g!==null&&(g.lanes|=u),e1(l.return,u,p)}function $1(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 LO(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&&IO(l,p,u);else if(l.tag===19)IO(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&&Xg(l)===null&&(v=p),p=p.sibling;p=v,p===null?(v=u.child,u.child=null):(v=p.sibling,p.sibling=null),$1(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&&Xg(l)===null){u.child=v;break}l=v.sibling,v.sibling=p,p=v,v=l}$1(u,!0,p,null,w);break;case"together":$1(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 j1(l,u){return(l.lanes&u)!==0?!0:(l=l.dependencies,!!(l!==null&&Ig(l)))}function TG(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:Yt(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?DO(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 LO(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,TO(l,u,p);case 24:xa(u,vn,l.memoizedState.cache)}return Po(l,u,p)}function NO(l,u,p){if(l!==null)if(l.memoizedProps!==u.pendingProps)Pn=!0;else{if(!j1(l,p)&&(u.flags&128)===0)return Pn=!1,TG(l,u,p);Pn=(l.flags&131072)!==0}else Pn=!1,yt&&(u.flags&1048576)!==0&&fM(u,Dg,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")Gw(g)?(l=Ul(g,l),u.tag=1,u=OO(null,u,g,l,p)):(u.tag=0,u=O1(null,u,g,l,p));else{if(g!=null){if(v=g.$$typeof,v===P){u.tag=11,u=AO(null,u,g,l,p);break e}else if(v===D){u.tag=14,u=EO(null,u,g,l,p);break e}}throw u=Y(g)||g,Error(r(306,u,""))}}return u;case 0:return O1(l,u,u.type,u.pendingProps,p);case 1:return g=u.type,v=Ul(g,u.pendingProps),OO(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,a1(l,u),Ff(u,g,null,p);var R=u.memoizedState;if(g=R.cache,xa(u,vn,g),g!==w.cache&&t1(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=PO(l,u,g,p);break e}else if(g!==v){v=Pi(Error(r(424)),u),Pf(v),u=PO(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(Jt=fs(l.firstChild),Cr=u,yt=!0,$l=null,Ns=!0,p=pO(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 Zg(l,u),l===null?(p=FP(u.type,null,u.pendingProps,null))?u.memoizedState=p:yt||(p=u.type,l=u.pendingProps,g=p0(ye.current).createElement(p),g[Mn]=u,g[or]=l,Vn(g,p,l),ln(g),u.stateNode=g):u.memoizedState=FP(u.type,l.memoizedProps,u.pendingProps,l.memoizedState),null;case 27:return Yt(u),l===null&&yt&&(g=u.stateNode=$P(u.type,u.pendingProps,ye.current),Cr=u,Ns=!0,v=Jt,La(u.type)?(bS=v,Jt=fs(g.firstChild)):Jt=v),Fn(l,u,u.pendingProps.children,p),Zg(l,u),l===null&&(u.flags|=4194304),u.child;case 5:return l===null&&yt&&((v=g=Jt)&&(g=nK(g,u.type,u.pendingProps,Ns),g!==null?(u.stateNode=g,Cr=u,Jt=fs(g.firstChild),Ns=!1,v=!0):v=!1),v||jl(u)),Yt(u),v=u.type,w=u.pendingProps,R=l!==null?l.memoizedProps:null,g=w.children,pS(v,w)?g=null:R!==null&&pS(v,R)&&(u.flags|=32),u.memoizedState!==null&&(v=d1(l,u,xG,null,null,p),ld._currentValue=v),Zg(l,u),Fn(l,u,g,p),u.child;case 6:return l===null&&yt&&((l=p=Jt)&&(p=rK(p,u.pendingProps,Ns),p!==null?(u.stateNode=p,Cr=u,Jt=null,l=!0):l=!1),l||jl(u)),null;case 13:return DO(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 AO(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 EO(l,u,u.type,u.pendingProps,p);case 15:return kO(l,u,u.type,u.pendingProps,p);case 19:return LO(l,u,p);case 31:return g=u.pendingProps,p=u.mode,g={mode:g.mode,children:g.children},l===null?(p=e0(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 TO(l,u,p);case 24:return Fl(u),g=lr(vn),l===null?(v=i1(),v===null&&(v=Dt,w=n1(),v.pooledCache=w,w.refCount++,w!==null&&(v.pooledCacheLanes|=p),v=w),u.memoizedState={parent:g,cache:v},o1(u),xa(u,vn,v)):((l.lanes&p)!==0&&(a1(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&&t1(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 $O(l,u){if(u.type!=="stylesheet"||(u.state.loading&4)!==0)l.flags&=-16777217;else if(l.flags|=16777216,!WP(u)){if(u=Ni.current,u!==null&&((ct&4194048)===ct?$s!==null:(ct&62914560)!==ct&&(ct&536870912)===0||u!==$s))throw $f=s1,xM;l.flags|=8192}}function t0(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(!yt)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 RG(l,u,p){var g=u.pendingProps;switch(Jw(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,mM())),qt(u),null;case 26:return p=u.memoizedState,l===null?(Do(u),p!==null?(qt(u),$O(u,p)):(qt(u),u.flags&=-16777217)):p?p!==l.memoizedState?(Do(u),qt(u),$O(u,p)):(qt(u),u.flags&=-16777217):(l.memoizedProps!==g&&Do(u),qt(u),u.flags&=-16777217),null;case 27:Xt(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)?dM(u):(l=$P(v,g,p),u.stateNode=l,Do(u))}return qt(u),null;case 5:if(Xt(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))dM(u);else{switch(v=p0(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||MP(l.nodeValue,p)),l||jl(u)}else l=p0(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=mM(),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),t0(u,u.updateQueue),qt(u),null;case 4:return Pt(),l===null&&cS(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(Qt!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(w=Xg(l),w!==null){for(u.flags|=128,Gf(v,!1),l=w.updateQueue,u.updateQueue=l,t0(u,l),u.subtreeFlags=0,l=p,p=u.child;p!==null;)hM(p,l),p=p.sibling;return L(xn,xn.current&1|2),u.child}l=l.sibling}v.tail!==null&&nr()>i0&&(u.flags|=128,g=!0,Gf(v,!1),u.lanes=4194304)}else{if(!g)if(l=Xg(w),l!==null){if(u.flags|=128,g=!0,l=l.updateQueue,u.updateQueue=l,t0(u,l),Gf(v,!0),v.tail===null&&v.tailMode==="hidden"&&!w.alternate&&!yt)return qt(u),null}else 2*nr()-v.renderingStartTime>i0&&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),h1(),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&&t0(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 MG(l,u){switch(Jw(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 Xt(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),h1(),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 jO(l,u){switch(Jw(u),u.tag){case 3:Ro(vn),Pt();break;case 26:case 27:case 5:Xt(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),h1(),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 BO(l){var u=l.updateQueue;if(u!==null){var p=l.stateNode;try{EM(u,p)}catch(g){Et(l,l.return,g)}}}function FO(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 js(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 zO(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 B1(l,u,p){try{var g=l.stateNode;JG(g,l.type,p,u),g[or]=u}catch(v){Et(l,l.return,v)}}function VO(l){return l.tag===5||l.tag===3||l.tag===26||l.tag===27&&La(l.type)||l.tag===4}function F1(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||VO(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 z1(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=d0));else if(g!==4&&(g===27&&La(l.type)&&(p=l.stateNode,u=null),l=l.child,l!==null))for(z1(l,u,p),l=l.sibling;l!==null;)z1(l,u,p),l=l.sibling}function n0(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(n0(l,u,p),l=l.sibling;l!==null;)n0(l,u,p),l=l.sibling}function UO(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,rn=!1,V1=!1,HO=typeof WeakSet=="function"?WeakSet:Set,Dn=null;function OG(l,u){if(l=l.containerInfo,fS=x0,l=tM(l),Fw(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(dS={focusedElem:l,selectionRange:p},x0=!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)gS(l);else if(p===1)switch(l.nodeName){case"HEAD":case"HTML":case"BODY":gS(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 WO(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&&BO(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{EM(l,u)}catch(R){Et(p,p.return,R)}}break;case 27:u===null&&g&4&&UO(p);case 26:case 5:Ta(l,p),u===null&&g&4&&zO(p),g&512&&Yf(p,p.return);break;case 12:Ta(l,p);break;case 13:Ta(l,p),g&4&&KO(l,p),g&64&&(l=p.memoizedState,l!==null&&(l=l.dehydrated,l!==null&&(p=FG.bind(null,p),iK(l,p))));break;case 22:if(g=p.memoizedState!==null||Io,!g){u=u!==null&&u.memoizedState!==null||rn,v=Io;var w=rn;Io=g,(rn=u)&&!w?Ra(l,p,(p.subtreeFlags&8772)!==0):Ta(l,p),Io=v,rn=w}break;case 30:break;default:Ta(l,p)}}function qO(l){var u=l.alternate;u!==null&&(l.alternate=null,qO(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;)GO(l,u,p),p=p.sibling}function GO(l,u,p){if(me&&typeof me.onCommitFiberUnmount=="function")try{me.onCommitFiberUnmount(oe,p)}catch{}switch(p.tag){case 26:rn||js(p,u),Lo(l,u,p),p.memoizedState?p.memoizedState.count--:p.stateNode&&(p=p.stateNode,p.parentNode.removeChild(p));break;case 27:rn||js(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:rn||js(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,LP(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,p.stateNode),fd(l)):LP(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:rn||ka(2,p,u),rn||ka(4,p,u),Lo(l,u,p);break;case 1:rn||(js(p,u),g=p.stateNode,typeof g.componentWillUnmount=="function"&&FO(p,u,g)),Lo(l,u,p);break;case 21:Lo(l,u,p);break;case 22:rn=(g=rn)||p.memoizedState!==null,Lo(l,u,p),rn=g;break;default:Lo(l,u,p)}}function KO(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 PG(l){switch(l.tag){case 13:case 19:var u=l.stateNode;return u===null&&(u=l.stateNode=new HO),u;case 22:return l=l.stateNode,u=l._retryCache,u===null&&(u=l._retryCache=new HO),u;default:throw Error(r(435,l.tag))}}function U1(l,u){var p=PG(l);u.forEach(function(g){var v=zG.bind(null,l,g);p.has(g)||(p.add(g),g.then(v,v))})}function ai(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));GO(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;)YO(u,l),u=u.sibling}var hs=null;function YO(l,u){var p=l.alternate,g=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:ai(u,l),li(l),g&4&&(ka(3,l,l.return),Kf(3,l),ka(5,l,l.return));break;case 1:ai(u,l),li(l),g&512&&(rn||p===null||js(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=hs;if(ai(u,l),li(l),g&512&&(rn||p===null||js(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,ln(w),g=w;break e;case"link":var R=UP("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=UP("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,ln(w),g=w}l.stateNode=g}else HP(v,l.type,l.stateNode);else l.stateNode=VP(v,g,l.memoizedProps);else w!==g?(w===null?p.stateNode!==null&&(p=p.stateNode,p.parentNode.removeChild(p)):w.count--,g===null?HP(v,l.type,l.stateNode):VP(v,g,l.memoizedProps)):g===null&&l.stateNode!==null&&B1(l,l.memoizedProps,p.memoizedProps)}break;case 27:ai(u,l),li(l),g&512&&(rn||p===null||js(p,p.return)),p!==null&&g&4&&B1(l,l.memoizedProps,p.memoizedProps);break;case 5:if(ai(u,l),li(l),g&512&&(rn||p===null||js(p,p.return)),l.flags&32){v=l.stateNode;try{ri(v,"")}catch(ie){Et(l,l.return,ie)}}g&4&&l.stateNode!=null&&(v=l.memoizedProps,B1(l,v,p!==null?p.memoizedProps:v)),g&1024&&(V1=!0);break;case 6:if(ai(u,l),li(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(y0=null,v=hs,hs=m0(u.containerInfo),ai(u,l),hs=v,li(l),g&4&&p!==null&&p.memoizedState.isDehydrated)try{fd(u.containerInfo)}catch(ie){Et(l,l.return,ie)}V1&&(V1=!1,XO(l));break;case 4:g=hs,hs=m0(l.stateNode.containerInfo),ai(u,l),li(l),hs=g;break;case 12:ai(u,l),li(l);break;case 13:ai(u,l),li(l),l.child.flags&8192&&l.memoizedState!==null!=(p!==null&&p.memoizedState!==null)&&(Y1=nr()),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,U1(l,g)));break;case 22:v=l.memoizedState!==null;var F=p!==null&&p.memoizedState!==null,ee=Io,ae=rn;if(Io=ee||v,rn=ae||F,ai(u,l),rn=ae,Io=ee,li(l),g&8192)e:for(u=l.stateNode,u._visibility=v?u._visibility&-2:u._visibility|1,v&&(p===null||F||Io||rn||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,U1(l,p))));break;case 19:ai(u,l),li(l),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,U1(l,g)));break;case 30:break;case 21:break;default:ai(u,l),li(l)}}function li(l){var u=l.flags;if(u&2){try{for(var p,g=l.return;g!==null;){if(VO(g)){p=g;break}g=g.return}if(p==null)throw Error(r(160));switch(p.tag){case 27:var v=p.stateNode,w=F1(l);n0(l,w,v);break;case 5:var R=p.stateNode;p.flags&32&&(ri(R,""),p.flags&=-33);var I=F1(l);n0(l,I,R);break;case 3:case 4:var F=p.stateNode.containerInfo,ee=F1(l);z1(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 XO(l){if(l.subtreeFlags&1024)for(l=l.child;l!==null;){var u=l;XO(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;)WO(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:js(u,u.return);var p=u.stateNode;typeof p.componentWillUnmount=="function"&&FO(u,u.return,p),Hl(u);break;case 27:id(u.stateNode);case 26:case 5:js(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++)AM(F[v],I)}catch(ee){Et(g,g.return,ee)}}p&&R&64&&BO(w),Yf(w,w.return);break;case 27:UO(w);case 26:case 5:Ra(v,w,p),p&&g===null&&R&4&&zO(w),Yf(w,w.return);break;case 12:Ra(v,w,p);break;case 13:Ra(v,w,p),p&&R&4&&KO(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 H1(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 W1(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 Bs(l,u,p,g){if(u.subtreeFlags&10256)for(u=u.child;u!==null;)JO(l,u,p,g),u=u.sibling}function JO(l,u,p,g){var v=u.flags;switch(u.tag){case 0:case 11:case 15:Bs(l,u,p,g),v&2048&&Kf(9,u);break;case 1:Bs(l,u,p,g);break;case 3:Bs(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){Bs(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 Bs(l,u,p,g);break;case 13:Bs(l,u,p,g);break;case 23:break;case 22:w=u.stateNode,R=u.alternate,u.memoizedState!==null?w._visibility&2?Bs(l,u,p,g):Xf(l,u):w._visibility&2?Bs(l,u,p,g):(w._visibility|=2,gu(l,u,p,g,(u.subtreeFlags&10256)!==0)),v&2048&&H1(R,u);break;case 24:Bs(l,u,p,g),v&2048&&W1(u.alternate,u);break;default:Bs(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&&H1(R.alternate,R);break;case 24:gu(w,R,I,F,v),v&&ee&2048&&W1(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&&H1(g.alternate,g);break;case 24:Xf(p,g),v&2048&&W1(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;)QO(l),l=l.sibling}function QO(l){switch(l.tag){case 26:yu(l),l.flags&Jf&&l.memoizedState!==null&&yK(hs,l.memoizedState,l.memoizedProps);break;case 5:yu(l);break;case 3:case 4:var u=hs;hs=m0(l.stateNode.containerInfo),yu(l),hs=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 ZO(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,tP(g,l)}ZO(l)}if(l.subtreeFlags&10256)for(l=l.child;l!==null;)eP(l),l=l.sibling}function eP(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,r0(l)):Qf(l);break;default:Qf(l)}}function r0(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,tP(g,l)}ZO(l)}for(l=l.child;l!==null;){switch(u=l,u.tag){case 0:case 11:case 15:ka(8,u,u.return),r0(u);break;case 22:p=u.stateNode,p._visibility&2&&(p._visibility&=-3,r0(u));break;default:r0(u)}l=l.sibling}}function tP(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(qO(g),g===p){Dn=null;break e}if(v!==null){v.return=w,Dn=v;break e}Dn=w}}}var DG={getCacheForType:function(l){var u=lr(vn),p=u.data.get(l);return p===void 0&&(p=l(),u.data.set(l,p)),p}},IG=typeof WeakMap=="function"?WeakMap:Map,bt=0,Dt=null,ot=null,ct=0,vt=0,ci=null,Ma=!1,bu=!1,q1=!1,No=0,Qt=0,Oa=0,Wl=0,G1=0,$i=0,vu=0,Zf=null,Vr=null,K1=!1,Y1=0,i0=1/0,s0=null,Pa=null,zn=0,Da=null,xu=null,wu=0,X1=0,J1=null,nP=null,ed=0,Q1=null;function ui(){if((bt&2)!==0&&ct!==0)return ct&-ct;if(z.T!==null){var l=lu;return l!==0?l:sS()}return hf()}function rP(){$i===0&&($i=(ct&536870912)===0||yt?Fc():536870912);var l=Ni.current;return l!==null&&(l.flags|=32),$i}function hi(l,u,p){(l===Dt&&(vt===2||vt===9)||l.cancelPendingCommit!==null)&&(Su(l,0),Ia(l,ct,$i,!1)),os(l,p),((bt&2)===0||l!==Dt)&&(l===Dt&&((bt&2)===0&&(Wl|=p),Qt===4&&Ia(l,ct,$i,!1)),Fs(l))}function iP(l,u,p){if((bt&6)!==0)throw Error(r(327));var g=!p&&(u&124)===0&&(u&l.expiredLanes)===0||ir(l,u),v=g?$G(l,u):tS(l,u,!0),w=g;do{if(v===0){bu&&!g&&Ia(l,u,0,!1);break}else{if(p=l.current.alternate,w&&!LG(p)){v=tS(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=tS(I,R,!1),R!==2){if(q1&&!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,$i,!Ma);break e;case 2:Vr=null;break;case 3:case 5:break;default:throw Error(r(329))}if((u&62914560)===u&&(v=Y1+300-nr(),10<v)){if(Ia(g,u,$i,!Ma),an(g,0,!0)!==0)break e;g.timeoutHandle=DP(sP.bind(null,g,p,Vr,s0,K1,u,$i,Wl,vu,Ma,w,2,-0,0),v);break e}sP(g,p,Vr,s0,K1,u,$i,Wl,vu,Ma,w,0,-0,0)}}break}while(!0);Fs(l)}function sP(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:gK},QO(u),he=bK(),he!==null)){l.cancelPendingCommit=he(fP.bind(null,l,u,w,p,g,v,R,I,F,ae,1,re,ie)),Ia(l,w,R,!ee);return}fP(l,u,w,p,g,v,R,I,F)}function LG(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(!si(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&=~G1,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&&cg(l,p,u)}function o0(){return(bt&6)===0?(td(0),!1):!0}function Z1(){if(ot!==null){if(vt===0)var l=ot.return;else l=ot,To=Bl=null,g1(l),pu=null,Wf=0,l=ot;for(;l!==null;)jO(l.alternate,l),l=l.return;ot=null}}function Su(l,u){var p=l.timeoutHandle;p!==-1&&(l.timeoutHandle=-1,ZG(p)),p=l.cancelPendingCommit,p!==null&&(l.cancelPendingCommit=null,p()),Z1(),Dt=l,ot=p=Ao(l.current,null),ct=u,vt=0,ci=null,Ma=!1,bu=ir(l,u),q1=!1,vu=$i=G1=Wl=Oa=Qt=0,Vr=Zf=null,K1=!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,Tg(),p}function oP(l,u){et=null,z.H=Gg,u===Nf||u===$g?(u=_M(),vt=3):u===xM?(u=_M(),vt=4):vt=u===CO?8:u!==null&&typeof u=="object"&&typeof u.then=="function"?6:1,ci=u,ot===null&&(Qt=1,Qg(l,Pi(u,l.current)))}function aP(){var l=z.H;return z.H=Gg,l===null?Gg:l}function lP(){var l=z.A;return z.A=DG,l}function eS(){Qt=4,Ma||(ct&4194048)!==ct&&Ni.current!==null||(bu=!0),(Oa&134217727)===0&&(Wl&134217727)===0||Dt===null||Ia(Dt,ct,$i,!1)}function tS(l,u,p){var g=bt;bt|=2;var v=aP(),w=lP();(Dt!==l||ct!==u)&&(s0=null,Su(l,u)),u=!1;var R=Qt;e:do try{if(vt!==0&&ot!==null){var I=ot,F=ci;switch(vt){case 8:Z1(),R=6;break e;case 3:case 2:case 9:case 6:Ni.current===null&&(u=!0);var ee=vt;if(vt=0,ci=null,_u(l,I,F,ee),p&&bu){R=0;break e}break;default:ee=vt,vt=0,ci=null,_u(l,I,F,ee)}}NG(),R=Qt;break}catch(ae){oP(l,ae)}while(!0);return u&&l.shellSuspendCounter++,To=Bl=null,bt=g,z.H=v,z.A=w,ot===null&&(Dt=null,ct=0,Tg()),R}function NG(){for(;ot!==null;)cP(ot)}function $G(l,u){var p=bt;bt|=2;var g=aP(),v=lP();Dt!==l||ct!==u?(s0=null,i0=nr()+500,Su(l,u)):bu=ir(l,u);e:do try{if(vt!==0&&ot!==null){u=ot;var w=ci;t:switch(vt){case 1:vt=0,ci=null,_u(l,u,w,1);break;case 2:case 9:if(wM(w)){vt=0,ci=null,uP(u);break}u=function(){vt!==2&&vt!==9||Dt!==l||(vt=7),Fs(l)},w.then(u,u);break e;case 3:vt=7;break e;case 4:vt=5;break e;case 7:wM(w)?(vt=0,ci=null,uP(u)):(vt=0,ci=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||WP(R)){vt=0,ci=null;var F=I.sibling;if(F!==null)ot=F;else{var ee=I.return;ee!==null?(ot=ee,a0(ee)):ot=null}break t}}vt=0,ci=null,_u(l,u,w,5);break;case 6:vt=0,ci=null,_u(l,u,w,6);break;case 8:Z1(),Qt=6;break e;default:throw Error(r(462))}}jG();break}catch(ae){oP(l,ae)}while(!0);return To=Bl=null,z.H=g,z.A=v,bt=p,ot!==null?0:(Dt=null,ct=0,Tg(),Qt)}function jG(){for(;ot!==null&&!_o();)cP(ot)}function cP(l){var u=NO(l.alternate,l,No);l.memoizedProps=l.pendingProps,u===null?a0(l):ot=u}function uP(l){var u=l,p=u.alternate;switch(u.tag){case 15:case 0:u=MO(p,u,u.pendingProps,u.type,void 0,ct);break;case 11:u=MO(p,u,u.pendingProps,u.type.render,u.ref,ct);break;case 5:g1(u);default:jO(p,u),u=ot=hM(u,No),u=NO(p,u,No)}l.memoizedProps=l.pendingProps,u===null?a0(l):ot=u}function _u(l,u,p,g){To=Bl=null,g1(u),pu=null,Wf=0;var v=u.return;try{if(kG(l,v,u,p,ct)){Qt=1,Qg(l,Pi(p,l.current)),ot=null;return}}catch(w){if(v!==null)throw ot=v,w;Qt=1,Qg(l,Pi(p,l.current)),ot=null;return}u.flags&32768?(yt||g===1?l=!0:bu||(ct&536870912)!==0?l=!1:(Ma=l=!0,(g===2||g===9||g===3||g===6)&&(g=Ni.current,g!==null&&g.tag===13&&(g.flags|=16384))),hP(u,l)):a0(u)}function a0(l){var u=l;do{if((u.flags&32768)!==0){hP(u,Ma);return}l=u.return;var p=RG(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);Qt===0&&(Qt=5)}function hP(l,u){do{var p=MG(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);Qt=6,ot=null}function fP(l,u,p,g,v,w,R,I,F){l.cancelPendingCommit=null;do l0();while(zn!==0);if((bt&6)!==0)throw Error(r(327));if(u!==null){if(u===l.current)throw Error(r(177));if(w=u.lanes|u.childLanes,w|=Ww,Tw(l,p,w,R,I,F),l===Dt&&(ot=Dt=null,ct=0),xu=u,Da=l,wu=p,X1=w,J1=v,nP=g,(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?(l.callbackNode=null,l.callbackPriority=0,VG(Ps,function(){return yP(),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=bt,bt|=4;try{OG(l,u,p)}finally{bt=R,G.p=v,z.T=g}}zn=1,dP(),pP(),mP()}}function dP(){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=bt;bt|=4;try{YO(u,l);var w=dS,R=tM(l.containerInfo),I=w.focusedElem,F=w.selectionRange;if(R!==I&&I&&I.ownerDocument&&eM(I.ownerDocument.documentElement,I)){if(F!==null&&Fw(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=ZR(I,Fe),W=ZR(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}}x0=!!fS,dS=fS=null}finally{bt=v,G.p=g,z.T=p}}l.current=u,zn=2}}function pP(){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=bt;bt|=4;try{WO(l,u.alternate,u)}finally{bt=v,G.p=g,z.T=p}}zn=3}}function mP(){if(zn===4||zn===3){zn=0,is();var l=Da,u=xu,p=wu,g=nP;(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?zn=5:(zn=0,xu=Da=null,gP(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&&l0(),Fs(l),v=l.pendingLanes,(p&4194090)!==0&&(v&42)!==0?l===Q1?ed++:(ed=0,Q1=l):ed=0,td(0)}}function gP(l,u){(l.pooledCacheLanes&=u)===0&&(u=l.pooledCache,u!=null&&(l.pooledCache=null,If(u)))}function l0(l){return dP(),pP(),mP(),yP()}function yP(){if(zn!==5)return!1;var l=Da,u=X1;X1=0;var p=uf(wu),g=z.T,v=G.p;try{G.p=32>p?32:p,z.T=null,p=J1,J1=null;var w=Da,R=wu;if(zn=0,xu=Da=null,wu=0,(bt&6)!==0)throw Error(r(331));var I=bt;if(bt|=4,eP(w.current),JO(w,w.current,R,p),bt=I,td(0,!1),me&&typeof me.onPostCommitFiberRoot=="function")try{me.onPostCommitFiberRoot(oe,w)}catch{}return!0}finally{G.p=v,z.T=g,gP(l,u)}}function bP(l,u,p){u=Pi(p,u),u=M1(l.stateNode,u,2),l=_a(l,u,2),l!==null&&(os(l,2),Fs(l))}function Et(l,u,p){if(l.tag===3)bP(l,l,p);else for(;u!==null;){if(u.tag===3){bP(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=Pi(p,l),p=SO(2),g=_a(u,p,2),g!==null&&(_O(p,g,u,l),os(g,2),Fs(g));break}}u=u.return}}function nS(l,u,p){var g=l.pingCache;if(g===null){g=l.pingCache=new IG;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)||(q1=!0,v.add(p),l=BG.bind(null,l,u,p),u.then(l,l))}function BG(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&&(Qt===4||Qt===3&&(ct&62914560)===ct&&300>nr()-Y1?(bt&2)===0&&Su(l,0):G1|=p,vu===ct&&(vu=0)),Fs(l)}function vP(l,u){u===0&&(u=zc()),l=iu(l,u),l!==null&&(os(l,u),Fs(l))}function FG(l){var u=l.memoizedState,p=0;u!==null&&(p=u.retryLane),vP(l,p)}function zG(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),vP(l,p)}function VG(l,u){return tr(l,u)}var c0=null,Cu=null,rS=!1,u0=!1,iS=!1,ql=0;function Fs(l){l!==Cu&&l.next===null&&(Cu===null?c0=Cu=l:Cu=Cu.next=l),u0=!0,rS||(rS=!0,HG())}function td(l,u){if(!iS&&u0){iS=!0;do for(var p=!1,g=c0;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,_P(g,w))}else w=ct,w=an(g,g===Dt?w:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(w&3)===0||ir(g,w)||(p=!0,_P(g,w));g=g.next}while(p);iS=!1}}function UG(){xP()}function xP(){u0=rS=!1;var l=0;ql!==0&&(QG()&&(l=ql),ql=0);for(var u=nr(),p=null,g=c0;g!==null;){var v=g.next,w=wP(g,u);w===0?(g.next=null,p===null?c0=v:p.next=v,v===null&&(Cu=p)):(p=g,(l!==0||(w&3)!==0)&&(u0=!0)),g=v}td(l)}function wP(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=an(l,l===u?p:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),g=l.callbackNode,p===0||l===u&&(vt===2||vt===9)||l.cancelPendingCommit!==null)return g!==null&&g!==null&&ei(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&&ei(g),uf(p)){case 2:case 8:p=Os;break;case 32:p=Ps;break;case 268435456:p=Tl;break;default:p=Ps}return g=SP.bind(null,l),p=tr(p,g),l.callbackPriority=u,l.callbackNode=p,u}return g!==null&&g!==null&&ei(g),l.callbackPriority=2,l.callbackNode=null,2}function SP(l,u){if(zn!==0&&zn!==5)return l.callbackNode=null,l.callbackPriority=0,null;var p=l.callbackNode;if(l0()&&l.callbackNode!==p)return null;var g=ct;return g=an(l,l===Dt?g:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),g===0?null:(iP(l,g,u),wP(l,nr()),l.callbackNode!=null&&l.callbackNode===p?SP.bind(null,l):null)}function _P(l,u){if(l0())return null;iP(l,u,!0)}function HG(){eK(function(){(bt&6)!==0?tr(kl,UG):xP()})}function sS(){return ql===0&&(ql=Fc()),ql}function CP(l){return l==null||typeof l=="symbol"||typeof l=="boolean"?null:typeof l=="function"?l:Gc(""+l)}function AP(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 WG(l,u,p,g,v){if(u==="submit"&&p&&p.stateNode===v){var w=CP((v[or]||null).action),R=g.submitter;R&&(u=(u=R[or]||null)?CP(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?AP(v,R):new FormData(v);A1(p,{pending:!0,data:F,method:v.method,action:w},null,F)}}else typeof w=="function"&&(I.preventDefault(),F=R?AP(v,R):new FormData(v),A1(p,{pending:!0,data:F,method:v.method,action:w},w,F))},currentTarget:v}]})}}for(var oS=0;oS<Hw.length;oS++){var aS=Hw[oS],qG=aS.toLowerCase(),GG=aS[0].toUpperCase()+aS.slice(1);us(qG,"on"+GG)}us(iM,"onAnimationEnd"),us(sM,"onAnimationIteration"),us(oM,"onAnimationStart"),us("dblclick","onDoubleClick"),us("focusin","onFocus"),us("focusout","onBlur"),us(uG,"onTransitionRun"),us(hG,"onTransitionStart"),us(fG,"onTransitionCancel"),us(aM,"onTransitionEnd"),ni("onMouseEnter",["mouseout","mouseover"]),ni("onMouseLeave",["mouseout","mouseover"]),ni("onPointerEnter",["pointerout","pointerover"]),ni("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(" "),KG=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(nd));function EP(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){Jg(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){Jg(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)||(kP(u,l,2,!1),p.add(g))}function lS(l,u,p){var g=0;u&&(g|=4),kP(p,l,g,u)}var h0="_reactListening"+Math.random().toString(36).slice(2);function cS(l){if(!l[h0]){l[h0]=!0,dg.forEach(function(p){p!=="selectionchange"&&(KG.has(p)||lS(p,!1,l),lS(p,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[h0]||(u[h0]=!0,lS("selectionchange",!1,u))}}function kP(l,u,p,g){switch(JP(u)){case 2:var v=wK;break;case 8:v=SK;break;default:v=_S}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 uS(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=lM.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=Vq;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=Eg;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ie=Wq;break;case iM:case sM:case oM:ie=Dq;break;case aM:ie=Gq;break;case"scroll":case"scrollend":ie=ar;break;case"wheel":ie=Yq;break;case"copy":case"cut":case"paste":ie=Lq;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ie=BR;break;case"toggle":case"beforetoggle":ie=Jq}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=BR,ce="onPointerLeave",K="onPointerEnter",W="pointer"),Ct=ie==null?re:Mi(ie),J=We==null?re:Mi(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&&TP(he,re,ie,Fe,!1),We!==null&&Ct!==null&&TP(he,Ct,We,Fe,!0)}}e:{if(re=ee?Mi(ee):window,ie=re.nodeName&&re.nodeName.toLowerCase(),ie==="select"||ie==="input"&&re.type==="file")var Te=GR;else if(WR(re))if(KR)Te=aG;else{Te=sG;var rt=iG}else ie=re.nodeName,!ie||ie.toLowerCase()!=="input"||re.type!=="checkbox"&&re.type!=="radio"?ee&&bf(ee.elementType)&&(Te=GR):Te=oG;if(Te&&(Te=Te(l,ee))){qR(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?Mi(ee):window,l){case"focusin":(WR(rt)||rt.contentEditable==="true")&&(tu=rt,zw=ee,Rf=null);break;case"focusout":Rf=zw=tu=null;break;case"mousedown":Vw=!0;break;case"contextmenu":case"mouseup":case"dragend":Vw=!1,nM(he,p,ae);break;case"selectionchange":if(cG)break;case"keydown":case"keyup":nM(he,p,ae)}var Pe;if($w)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?UR(l,p)&&(Ve="onCompositionEnd"):l==="keydown"&&p.keyCode===229&&(Ve="onCompositionStart");Ve&&(FR&&p.locale!=="ko"&&(eu||Ve!=="onCompositionStart"?Ve==="onCompositionEnd"&&eu&&(Pe=Jc()):(Ls=ae,ya="value"in Ls?Ls.value:Ls.textContent,eu=!0)),rt=f0(ee,Ve),0<rt.length&&(Ve=new jR(Ve,l,null,p,ae),he.push({event:Ve,listeners:rt}),Pe?Ve.data=Pe:(Pe=HR(p),Pe!==null&&(Ve.data=Pe)))),(Pe=Zq?eG(l,p):tG(l,p))&&(Ve=f0(ee,"onBeforeInput"),0<Ve.length&&(rt=new jR("onBeforeInput","beforeinput",null,p,ae),he.push({event:rt,listeners:Ve}),rt.data=Pe)),WG(he,l,ee,p,ae)}EP(he,u)})}function rd(l,u,p){return{instance:l,listener:u,currentTarget:p}}function f0(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 TP(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 YG=/\r\n?/g,XG=/\u0000|\uFFFD/g;function RP(l){return(typeof l=="string"?l:""+l).replace(YG,`
|
||
`).replace(XG,"")}function MP(l,u){return u=RP(u),RP(l)===u}function d0(){}function _t(l,u,p,g,v,w){switch(p){case"children":typeof g=="string"?u==="body"||u==="textarea"&&g===""||ri(l,g):(typeof g=="number"||typeof g=="bigint")&&u!=="body"&&ri(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":Cg(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=d0);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":Oi(l,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":Oi(l,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":Oi(l,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":Oi(l,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":Oi(l,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":Oi(l,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":Oi(l,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":Oi(l,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":Oi(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=Iw.get(p)||p,Vc(l,p,g))}}function hS(l,u,p,g,v,w){switch(p){case"style":Cg(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"?ri(l,g):(typeof g=="number"||typeof g=="bigint")&&ri(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=d0);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!pg.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)}}wg(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&&hS(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 JG(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)}Sg(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)&&hS(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||hS(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 fS=null,dS=null;function p0(l){return l.nodeType===9?l:l.ownerDocument}function OP(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 PP(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 pS(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 mS=null;function QG(){var l=window.event;return l&&l.type==="popstate"?l===mS?!1:(mS=l,!0):(mS=null,!1)}var DP=typeof setTimeout=="function"?setTimeout:void 0,ZG=typeof clearTimeout=="function"?clearTimeout:void 0,IP=typeof Promise=="function"?Promise:void 0,eK=typeof queueMicrotask=="function"?queueMicrotask:typeof IP<"u"?function(l){return IP.resolve(null).then(l).catch(tK)}:DP;function tK(l){setTimeout(function(){throw l})}function La(l){return l==="head"}function LP(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 gS(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":gS(p),df(p);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(p.rel.toLowerCase()==="stylesheet")continue}l.removeChild(p)}}function nK(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=fs(l.nextSibling),l===null)break}return null}function rK(l,u,p){if(u==="")return null;for(;l.nodeType!==3;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!p||(l=fs(l.nextSibling),l===null))return null;return l}function yS(l){return l.data==="$!"||l.data==="$?"&&l.ownerDocument.readyState==="complete"}function iK(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 fs(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 bS=null;function NP(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 $P(l,u,p){switch(u=p0(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 ji=new Map,jP=new Set;function m0(l){return typeof l.getRootNode=="function"?l.getRootNode():l.nodeType===9?l:l.ownerDocument}var $o=G.d;G.d={f:sK,r:oK,D:aK,C:lK,L:cK,m:uK,X:fK,S:hK,M:dK};function sK(){var l=$o.f(),u=o0();return l||u}function oK(l){var u=ua(l);u!==null&&u.tag===5&&u.type==="form"?iO(u):$o.r(l)}var Eu=typeof document>"u"?null:document;function BP(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+'"]'),jP.has(v)||(jP.add(v),l={rel:l,crossOrigin:p,href:u},g.querySelector(v)===null&&(u=g.createElement("link"),Vn(u,"link",l),ln(u),g.head.appendChild(u)))}}function aK(l){$o.D(l),BP("dns-prefetch",l,null)}function lK(l,u){$o.C(l,u),BP("preconnect",l,u)}function cK(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)}ji.has(w)||(l=f({rel:"preload",href:u==="image"&&p&&p.imageSrcSet?void 0:l,as:u},p),ji.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),ln(u),g.head.appendChild(u)))}}function uK(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(!ji.has(w)&&(l=f({rel:"modulepreload",href:l},u),ji.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),ln(g),p.head.appendChild(g)}}}function hK(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=ji.get(w))&&vS(l,p);var F=R=g.createElement("link");ln(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,g0(R,u,g)}R={type:"stylesheet",instance:R,count:1,state:I},v.set(w,R)}}}function fK(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=ji.get(v))&&xS(l,u),w=p.createElement("script"),ln(w),Vn(w,"link",l),p.head.appendChild(w)),w={type:"script",instance:w,count:1,state:null},g.set(v,w))}}function dK(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=ji.get(v))&&xS(l,u),w=p.createElement("script"),ln(w),Vn(w,"link",l),p.head.appendChild(w)),w={type:"script",instance:w,count:1,state:null},g.set(v,w))}}function FP(l,u,p,g){var v=(v=ye.current)?m0(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),ji.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},ji.set(l,p),w||pK(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 zP(l){return f({},l,{"data-precedence":l.precedence,precedence:null})}function pK(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),ln(u),l.head.appendChild(u))}function Tu(l){return'[src="'+jr(l)+'"]'}function od(l){return"script[async]"+l}function VP(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,ln(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"),ln(g),Vn(g,"style",v),g0(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,ln(w),w;g=zP(p),(v=ji.get(v))&&vS(g,v),w=(l.ownerDocument||l).createElement("link"),ln(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,g0(w,p.precedence,l),u.instance=w;case"script":return w=Tu(p.src),(v=l.querySelector(od(w)))?(u.instance=v,ln(v),v):(g=p,(v=ji.get(w))&&(g=f({},p),xS(g,v)),l=l.ownerDocument||l,v=l.createElement("script"),ln(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,g0(g,p.precedence,l));return u.instance}function g0(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 vS(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.title==null&&(l.title=u.title)}function xS(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.integrity==null&&(l.integrity=u.integrity)}var y0=null;function UP(l,u,p){if(y0===null){var g=new Map,v=y0=new Map;v.set(p,g)}else v=y0,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 HP(l,u,p){l=l.ownerDocument||l,l.head.insertBefore(p,u==="title"?l.querySelector("head > title"):null)}function mK(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 WP(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}var ad=null;function gK(){}function yK(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=b0.bind(g),l.then(g,g)),u.state.loading|=4,u.instance=w,ln(w);return}w=l.ownerDocument||l,p=zP(p),(v=ji.get(v))&&vS(p,v),w=w.createElement("link"),ln(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=b0.bind(g),l.addEventListener("load",u),l.addEventListener("error",u))}}function bK(){if(ad===null)throw Error(r(475));var l=ad;return l.stylesheets&&l.count===0&&wS(l,l.stylesheets),0<l.count?function(u){var p=setTimeout(function(){if(l.stylesheets&&wS(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 b0(){if(this.count--,this.count===0){if(this.stylesheets)wS(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var v0=null;function wS(l,u){l.stylesheets=null,l.unsuspend!==null&&(l.count++,v0=new Map,u.forEach(vK,l),v0=null,b0.call(l))}function vK(l,u){if(!(u.state.loading&4)){var p=v0.get(l);if(p)var g=p.get(null);else{p=new Map,v0.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=b0.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 xK(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 qP(l,u,p,g,v,w,R,I,F,ee,ae,he){return l=new xK(l,u,p,R,I,F,ee,he),u=1,w===!0&&(u|=24),w=oi(3,null,null,u),l.current=w,w.stateNode=l,u=n1(),u.refCount++,l.pooledCache=u,u.refCount++,w.memoizedState={element:g,isDehydrated:p,cache:u},o1(w),l}function GP(l){return l?(l=su,l):su}function KP(l,u,p,g,v,w){v=GP(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&&(hi(p,l,u),jf(p,l,u))}function YP(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var p=l.retryLane;l.retryLane=p!==0&&p<u?p:u}}function SS(l,u){YP(l,u),(l=l.alternate)&&YP(l,u)}function XP(l){if(l.tag===13){var u=iu(l,67108864);u!==null&&hi(u,l,67108864),SS(l,67108864)}}var x0=!0;function wK(l,u,p,g){var v=z.T;z.T=null;var w=G.p;try{G.p=2,_S(l,u,p,g)}finally{G.p=w,z.T=v}}function SK(l,u,p,g){var v=z.T;z.T=null;var w=G.p;try{G.p=8,_S(l,u,p,g)}finally{G.p=w,z.T=v}}function _S(l,u,p,g){if(x0){var v=CS(g);if(v===null)uS(l,u,g,w0,p),QP(l,g);else if(CK(v,l,u,p,g))g.stopPropagation();else if(QP(l,g),u&4&&-1<_K.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}Fs(w),(bt&6)===0&&(i0=nr()+500,td(0))}}break;case 13:I=iu(w,2),I!==null&&hi(I,w,2),o0(),SS(w,2)}if(w=CS(g),w===null&&uS(l,u,g,w0,p),w===v)break;v=w}v!==null&&g.stopPropagation()}else uS(l,u,g,null,p)}}function CS(l){return l=Kc(l),AS(l)}var w0=null;function AS(l){if(w0=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 w0=l,null}function JP(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 Os:return 8;case Ps:case Bc:return 32;case Tl:return 268435456;default:return 32}default:return 32}}var ES=!1,Na=null,$a=null,ja=null,cd=new Map,ud=new Map,Ba=[],_K="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 QP(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&&XP(u)),l):(l.eventSystemFlags|=g,u=l.targetContainers,v!==null&&u.indexOf(v)===-1&&u.push(v),l)}function CK(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 ZP(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,hg(l.priority,function(){if(p.tag===13){var g=ui();g=cf(g);var v=iu(p,g);v!==null&&hi(v,p,g),SS(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 S0(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var p=CS(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&&XP(u),l.blockedOn=p,!1;u.shift()}return!0}function eD(l,u,p){S0(l)&&p.delete(u)}function AK(){ES=!1,Na!==null&&S0(Na)&&(Na=null),$a!==null&&S0($a)&&($a=null),ja!==null&&S0(ja)&&(ja=null),cd.forEach(eD),ud.forEach(eD)}function _0(l,u){l.blockedOn===u&&(l.blockedOn=null,ES||(ES=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,AK)))}var C0=null;function tD(l){C0!==l&&(C0=l,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){C0===l&&(C0=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(AS(g||p)===null)continue;break}var w=ua(p);w!==null&&(l.splice(u,3),u-=3,A1(w,{pending:!0,data:v,method:p.method,action:g},g,v))}}))}function fd(l){function u(F){return _0(F,l)}Na!==null&&_0(Na,l),$a!==null&&_0($a,l),ja!==null&&_0(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);)ZP(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||tD(p);else if(R){var I=null;if(w&&w.hasAttribute("formAction")){if(v=w,R=w[or]||null)I=R.formAction;else if(AS(v)!==null)continue}else I=R.action;typeof I=="function"?p[g+1]=I:(p.splice(g,3),g-=3),tD(p)}}}function kS(l){this._internalRoot=l}A0.prototype.render=kS.prototype.render=function(l){var u=this._internalRoot;if(u===null)throw Error(r(409));var p=u.current,g=ui();KP(p,g,l,u,null,null)},A0.prototype.unmount=kS.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var u=l.containerInfo;KP(l.current,2,null,l,null,null),o0(),u[la]=null}};function A0(l){this._internalRoot=l}A0.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&&ZP(l)}};var nD=e.version;if(nD!=="19.1.1")throw Error(r(527,nD,"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 EK={bundleType:0,version:"19.1.1",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.1.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var E0=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!E0.isDisabled&&E0.supportsFiber)try{oe=E0.inject(EK),me=E0}catch{}}return pd.createRoot=function(l,u){if(!i(l))throw Error(r(299));var p=!1,g="",v=bO,w=vO,R=xO,I=null;return u!=null&&(u.unstable_strictMode===!0&&(p=!0),u.identifierPrefix!==void 0&&(g=u.identifierPrefix),u.onUncaughtError!==void 0&&(v=u.onUncaughtError),u.onCaughtError!==void 0&&(w=u.onCaughtError),u.onRecoverableError!==void 0&&(R=u.onRecoverableError),u.unstable_transitionCallbacks!==void 0&&(I=u.unstable_transitionCallbacks)),u=qP(l,1,!1,null,null,p,g,v,w,R,I,null),l[la]=u.current,cS(l),new kS(u)},pd.hydrateRoot=function(l,u,p){if(!i(l))throw Error(r(299));var g=!1,v="",w=bO,R=vO,I=xO,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=qP(l,1,!0,u,p??null,g,v,w,R,I,F,ee),u.context=GP(null),p=u.current,g=ui(),g=cf(g),v=Sa(g),v.callback=null,_a(p,v,g),p=g,u.current.lanes=p,os(u,p),Fs(u),l[la]=u.current,cS(l),new A0(u)},pd.version="19.1.1",pd}var fD;function NK(){if(fD)return MS.exports;fD=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(),MS.exports=LK(),MS.exports}var $K=NK(),jK=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},{}),k5=class{_providers=new Set;getModelContext(){return jK(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)}},T5=class{_contextProvider=new k5;registerModelContextProvider(t){return this._contextProvider.registerModelContextProvider(t)}},BK=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)}},FK=t=>t.status.type==="complete",R5=class extends BK{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=>FK(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)}}},M5=class extends R5{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 zK=(t,e=21)=>(n=e)=>{let r="",i=n|0;for(;i--;)r+=t[Math.random()*t.length|0];return r};var gx=zK("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),VK="__optimistic__",UK=()=>`${VK}${gx()}`,O5=Object.freeze({type:"running"}),P5=Object.freeze({type:"complete",reason:"unknown"}),HK=Object.freeze({type:"requires-action",reason:"tool-calls"}),WK=t=>t===O5||t===P5,EE=(t,e,n)=>t&&e?O5:n?HK:P5,Gl={exports:{}},dD;function qK(){if(dD)return Gl.exports;dD=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 GK=qK();const pD=Pc(GK);function KK(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 IS=Symbol("aui.parse-partial-json-object.meta"),YK=t=>{if(t.length===0)return{[IS]:{state:"partial",partialPath:[]}};try{const e=pD.parse(t);if(typeof e!="object"||e===null)throw new Error("argsText is expected to be an object");return e[IS]={state:"complete",partialPath:[]},e}catch{try{const[e,n]=KK(t),r=pD.parse(e);if(typeof r!="object"||r===null)throw new Error("argsText is expected to be an object");return r[IS]={state:"partial",partialPath:n},r}catch{return}}},yx=(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-"+gx(),...b!==void 0&&{parentId:b}};return m.args?{...S,args:m.args,argsText:m.argsText??JSON.stringify(m.args)}:{...S,args:YK(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}`)}}},kE={fromArray:t=>{const e=t.map(n=>yx(n,gx(),EE(!1,!1,!1)));return{messages:e.map((n,r)=>({parentId:r>0?e[r-1].id:null,message:n}))}}},tb=t=>t.next?tb(t.next):"current"in t?t:null,XK=class{constructor(t){this.func=t}_value=null;get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},TE=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],(tb(e)===this.head||i.next===null)&&(i.next=e),e.prev=t}}}_messages=new XK(()=>{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=UK();while(this.messages.has(n));return this.addOrUpdateMessage(t,yx(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=tb(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=tb(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)}},bx=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(){for(const t of this._subscriptions)t()}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else this._connection?.(),this._connection=void 0}subscribe(t){return this._subscriptions.add(t),this._updateConnection(),()=>{this._subscriptions.delete(t),this._updateConnection()}}},xs=Symbol("skip-update"),RE=class extends bx{constructor(t){super(),this.binding=t}get path(){return this.binding.path}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){const t=this.binding.getState();t!==xs&&(this._previousState=t),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState};_connect(){const t=()=>{this._previousStateDirty=!0,this.notifySubscribers()};return this.binding.subscribe(t)}},T0=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 JK(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 ms=class extends bx{constructor(t){super(),this.binding=t;const e=t.getState();if(e===xs)throw new Error("Entry not available in the store");this._previousState=e}get path(){return this.binding.path}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){const t=this.binding.getState();return t===xs||JK(t,this._previousState)?!1:(this._previousState=t,!0)}_connect(){const t=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(t)}},Th=Symbol("innerMessage"),QK=t=>t[Th],Vp=t=>t.content.filter(n=>n.type==="text").map(n=>n.text).join(`
|
||
|
||
`),D5=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)}},I5=class extends D5{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)}},ZK=class extends I5{get source(){return"thread-composer"}},eY=class extends I5{get source(){return"edit-composer"}},tY=class extends D5{get source(){return"message"}constructor(t){super(t)}remove(){throw new Error("Message attachments cannot be removed")}},L5=class extends bx{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?.()}}},N5=Object.freeze([]),$5=Object.freeze({}),nY=t=>Object.freeze({type:"thread",isEditing:t?.isEditing??!1,canCancel:t?.canCancel??!1,isEmpty:t?.isEmpty??!0,attachments:t?.attachments??N5,text:t?.text??"",role:t?.role??"user",runConfig:t?.runConfig??$5,attachmentAccept:t?.attachmentAccept??"",value:t?.text??""}),rY=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??N5,runConfig:t?.runConfig??$5,attachmentAccept:t?.attachmentAccept??"",value:t?.text??""}),j5=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 L5({event:t,binding:this._core}),this._eventSubscriptionSubjects.set(t,n)),n.subscribe(e)}},iY=class extends j5{get path(){return this._core.path}get type(){return"thread"}_getState;constructor(t){const e=new RE({path:t.path,getState:()=>nY(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 ZK(new ms({path:{...this.path,attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:t},ref:this.path.ref+`${this.path.ref}.attachments[${t}]`},getState:()=>{const n=this.getState().attachments[t];return n?{...n,source:"thread-composer"}:xs},subscribe:e=>this._core.subscribe(e)}),this._core)}},sY=class extends j5{constructor(t,e){const n=new RE({path:t.path,getState:()=>rY(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 eY(new ms({path:{...this.path,attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:t},ref:this.path.ref+`${this.path.ref}.attachments[${t}]`},getState:()=>{const n=this.getState().attachments[t];return n?{...n,source:"edit-composer"}:xs},subscribe:e=>this._core.subscribe(e)}),this._core)}},mD=Symbol.for("aui.tool-response"),oY=class j2{get[mD](){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&&mD in e}static toResponse(e){return e instanceof j2?e:new j2({result:e===void 0?"<no result>":e})}},gD=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=oY.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)}},Wb=class extends bx{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?.()}}},R0=Object.freeze({type:"complete"}),aY=(t,e,n)=>{if(t.role!=="assistant")return R0;if(n.type==="tool-call")return n.result?R0:t.status;const r=e===Math.max(0,t.content.length-1);return t.status.type==="requires-action"?R0:r?t.status:R0},yD=(t,e)=>{const n=t.content[e];if(!n)return xs;const r=aY(t,e,n);return Object.freeze({...n,[Th]:n[Th],status:r})},lY=class{constructor(t,e){this._core=t,this._threadBinding=e,this.composer=new sY(new Wb({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 gD(new ms({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[${t}]`,messagePartSelector:{type:"index",index:t}},getState:()=>yD(this.getState(),t),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(t){return new gD(new ms({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(t)}]`,messagePartSelector:{type:"toolCallId",toolCallId:t}},getState:()=>{const e=this._core.getState(),n=e.content.findIndex(r=>r.type==="tool-call"&&r.toolCallId===t);return n===-1?xs:yD(e,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(t){return new tY(new ms({path:{...this.path,ref:this.path.ref+`${this.path.ref}.attachments[${t}]`,attachmentSource:"message",attachmentSelector:{type:"index",index:t}},getState:()=>{const n=this.getState().attachments?.[t];return n?{...n,source:"message"}:xs},subscribe:e=>this._core.subscribe(e)}))}},cY=t=>({parentId:t.parentId??null,sourceId:t.sourceId??null,runConfig:t.runConfig??{},...t.stream?{stream:t.stream}:{}}),uY=t=>({parentId:t.parentId??null,sourceId:t.sourceId??null,runConfig:t.runConfig??{}}),hY=(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},fY=(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})},B5=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;constructor(t,e){const n=new ms({path:t.path,getState:()=>fY(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 iY(new Wb({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(hY(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(uY(e))}unstable_resumeRun(t){return this._threadBinding.getState().resumeRun(cY(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 lY(new ms({path:t,getState:()=>{const{message:n,parentId:r}=e()??{},{messages:i,speech:s}=this._threadBinding.getState();if(!n||r===void 0)return xs;const o=this._threadBinding.getState(),a=o.getBranches(n.id),c=o.getSubmittedFeedback(n.id);return{...n,[Th]:n[Th],isLast:i.at(-1)?.id===n.id,parentId:r,branchNumber:a.indexOf(n.id)+1,branchCount:a.length,speech:s?.messageId===n.id?s:void 0,submittedFeedback:c}},subscribe:n=>this._threadBinding.subscribe(n)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(t,e){let n=this._eventSubscriptionSubjects.get(t);return n||(n=new L5({event:t,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(t,n)),n.subscribe(e)}},dY=t=>({mainThreadId:t.mainThreadId,newThread:t.newThreadId,threads:t.threadIds,archivedThreads:t.archivedThreadIds,isLoading:t.isLoading,threadItems:t.threadData}),M0=(t,e)=>{if(e===void 0)return xs;const n=t.getItemById(e);return n?{id:n.id,threadId:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,isMain:n.id===t.mainThreadId}:xs},pY=class{constructor(t,e=B5){this._core=t,this._runtimeFactory=e;const n=new RE({path:{},getState:()=>dY(t),subscribe:r=>t.subscribe(r)});this._getState=n.getState.bind(n),this._mainThreadListItemRuntime=new T0(new ms({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>M0(this._core,this._core.mainThreadId),subscribe:r=>this._core.subscribe(r)}),this._core),this.main=new e(new Wb({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 Wb({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 T0(new ms({path:{ref:`threadItems[${t}]`,threadSelector:{type:"index",index:t}},getState:()=>M0(this._core,this._core.threadIds[t]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(t){return new T0(new ms({path:{ref:`archivedThreadItems[${t}]`,threadSelector:{type:"archiveIndex",index:t}},getState:()=>M0(this._core,this._core.archivedThreadIds[t]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(t){return new T0(new ms({path:{ref:`threadItems[threadId=${t}]`,threadSelector:{type:"threadId",threadId:t}},getState:()=>M0(this._core,t),subscribe:e=>this._core.subscribe(e)}),this._core)}},mY=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 gY(t.file)}]}}async remove(){}},gY=t=>new Promise((e,n)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=i=>n(i),r.readAsDataURL(t)}),yY=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 bY(t.file)}
|
||
</attachment>`}]}}async remove(){}},bY=t=>new Promise((e,n)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=i=>n(i),r.readAsText(t)});function LS(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 vY=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(LS(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(LS(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(LS({name:t.name,type:t.contentType},n.accept))return n.remove(t);throw new Error("No matching adapter found for attachment")}},xY=k.createContext(null),wY=()=>k.useContext(xY),Kl=Object.freeze([]),lc="DEFAULT_THREAD_ID",SY=Object.freeze([lc]),F5=Object.freeze({id:lc,remoteId:void 0,externalId:void 0,status:"regular"}),_Y=Promise.resolve(),bD=Object.freeze({[lc]:F5}),CY=class{constructor(t={},e){this.adapter=t,this.threadFactory=e,this._mainThread=this.threadFactory(),this.__internal_setAdapter(t,!0)}_mainThreadId=lc;_threads=SY;_archivedThreads=Kl;_threadData=bD;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 _Y}_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 F5}__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={...bD,...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()}},vD=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})}},AY=class extends R5{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()}},EY=class{constructor(t){this._contextProvider=t}_subscriptions=new Set;_isInitialized=!1;repository=new TE;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 M5(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 AY(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(kE.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)}}},kY=Object.freeze([]),TY=(t,e)=>t&&e[e.length-1]?.role!=="assistant",RY=class extends EY{_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 vD;_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??kY,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 vD;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=EE(a,e,!1);if(i&&(i.role!=="assistant"||!WK(i.status)||i.status===c))return i;const h=t.convertMessage(s,o),f=yx(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),TY(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 TE;e.import(kE.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(QK).filter(n=>n!=null)):this._store.setMessages?.(t)}},xD=t=>t.adapters?.threadList??{},MY=class extends T5{threads;constructor(t){super(),this.threads=new CY(xD(t),()=>new RY(this._contextProvider,t))}setAdapter(t){this.threads.__internal_setAdapter(xD(t)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(t)}},OY=t=>{const[e]=k.useState(()=>new MY(t));k.useEffect(()=>{e.setAdapter(t)});const{modelContext:n}=wY()??{};return k.useEffect(()=>{if(n)return e.registerModelContextProvider(n)},[n,e]),k.useMemo(()=>new Z5(e),[e])},vx=t=>typeof t=="string"?{scope:t.split(".")[0],event:t}:{scope:t.scope,event:t.event},gp=(t,e,n)=>e===t;const wD=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},PY=(t=>t?wD(t):wD),DY=t=>t;function IY(t,e=DY){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 SD=t=>{const e=PY(t),n=r=>IY(e,r);return Object.assign(n,e),n},na=(t=>t?SD(t):SD);var LY=()=>{const t=new Set;return na(()=>({isAtBottom:!0,scrollToBottom:()=>{for(const e of t)e()},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)})}))};function NY(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 z5(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 V5=k.createContext(null),$Y=NY(V5,"ThreadPrimitive.Viewport"),{useThreadViewport:jY,useThreadViewportStore:U5}=z5($Y,"useThreadViewport"),qb=t=>t,BY=()=>{const t=U5({optional:!0}),[e]=k.useState(()=>LY());return k.useEffect(()=>t?.getState().onScrollToBottom(()=>{e.getState().scrollToBottom()}),[t,e]),k.useEffect(()=>{if(t)return e.subscribe(n=>{t.getState().isAtBottom!==n.isAtBottom&&qb(t).setState({isAtBottom:n.isAtBottom})})},[e,t]),e},H5=({children:t})=>{const e=BY(),[n]=k.useState(()=>({useThreadViewport:e}));return C.jsx(V5.Provider,{value:n,children:t})},Gn=t=>{const e=t.get;return e.source=t.source,e.query=t.query,e},ul=()=>()=>{},W5=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}=vx(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}),ki=()=>k.useContext(W5),FY=(t,e)=>t===ul?e:e===ul?t:(...n)=>{t(...n),e(...n)},zY=(t,e)=>t===ul?e:e===ul?t:(...n)=>{const r=t(...n),i=e(...n);return()=>{r(),i()}},VY=(t,e)=>{const n=e.subscribe,r=e.flushSync;return{...t,...e,subscribe:zY(t.subscribe,n??ul),flushSync:FY(t.flushSync,r??ul)}},xx=({api:t,children:e})=>{const n=ki(),r=k.useMemo(()=>VY(n,t),[n,t]);return C.jsx(W5,{value:r,children:C.jsx(H5,{children:e})})};function Jn(t){return(e,n)=>({type:t,props:e,...n?.key!==void 0&&{key:n.key}})}var yp=null;function UY(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 ME(){if(!yp)throw new Error("No resource fiber available");return yp}var HY=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 WY(t){const e=ME(),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,HY(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=WY(t);return[e.value,e.set]}function qY(){const t=ME(),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 ws(t,e){const n=ME(),r=qY();n.renderContext.commitTasks.push({effect:t,deps:e,cellIndex:r})}function Gb(t){const[e]=Go(()=>({current:t!==void 0&&typeof t=="function"?t():t}));return e}var GY=(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=Gb(()=>({value:t(),deps:e}));return GY(n.current.deps,e)||(n.current.value=t(),n.current.deps=e),n.current.value};function KY(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 YY(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 wx(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,YY(t)}function Up(t,e){const n={commitTasks:[],props:e,state:void 0};return UY(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,KY(e,t)}function XY(t,e){const[n,r]=Go({}),i=Ht(()=>wx(t.type,()=>r({})),[t.type]),s=e?Ht(()=>t.props,e):t.props,o=Ht(()=>Up(i,s),[i,s,n]);return ws(()=>()=>fh(i),[i]),ws(()=>{dh(i,o)},[i,o]),o.state}function Ss(t){return t.type(t.props)}function JY(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=wx(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 ws(()=>{o.forEach((a,c)=>{const h=s.get(c);h&&dh(h,a)})},[o,s]),ws(()=>()=>{s.forEach(a=>{fh(a)}),s.clear()},[s]),Ht(()=>t.map(a=>o.get(a.key)?.state),[t,o])}var B2=[],F2=!1;function QY(){F2=!1;const t=B2;B2=[];for(const e of t)try{e()}catch(n){console.error("Error in scheduled task:",n)}}function ZY(t){B2.push(t),F2||(F2=!0,queueMicrotask(QY))}var eX=class q5{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,ZY(()=>{this._hasScheduledTask=!1,this.flushSync()}))}flushSync(){if(this._isFlushing)return;this._isFlushing=!0;let e=0;try{for(;this._isDirty;){if(e++,e>q5.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}}},tX=({element:t,onUpdateInput:e,onFlushSync:n,onDispose:r})=>{const[i,s]=Go(t.props),o=Ss({type:t.type,props:i}),a=Gb(new Set).current,c=Gb(o);return ws(()=>{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}),[])},nX=(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 eX(()=>{o=Up(s,r),n&&dh(s,o)}),s=wx(tX,()=>i.markDirty());let o=Up(s,r);return n&&dh(s,o),o.state},bp=Symbol("tap.Context"),rX=t=>({[bp]:t}),iX=(t,e,n)=>{const r=t[bp];t[bp]=e;try{return n()}finally{t[bp]=r}},sX=t=>t[bp],G5=Jn(t=>{const e=Ht(()=>nX(t,!0),[t.type]);return ws(()=>{e.updateInput(t.props)}),e}),oX=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=Gb(()=>t);ws(()=>{n.current=t});const r=Ht(()=>new Proxy({},new oX(()=>n.current)),[]),i=e?.key,s=t.getState();return Ht(()=>({key:i,state:s,api:r}),[s,i])},aX=globalThis.__ASSISTANT_UI_DISABLE_LAYOUT_EFFECT__===!0,_D=aX?k.useEffect:k.useLayoutEffect;function K5(t){const[,e]=k.useState({}),n=k.useMemo(()=>wx(t.type,()=>e({})),[t.type]),r=Up(n,t.props);return _D(()=>()=>fh(n),[]),_D(()=>{dh(n,r)}),r.state}var lX=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})})}}},[])),cX=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)??[]}))})})}),Y5=rX(null),uX=(t,e)=>iX(Y5,t,e),OE=()=>{const t=sX(Y5);if(!t)throw new Error("Events context is not available");return t},hX=Jn(({threads:t,registerModelContextProvider:e,__internal_runtime:n})=>{const r=Ss(lX()),{threads:i,toolUIs:s}=uX(r,()=>({toolUIs:Ss(cX()),threads:XY(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})}),fX=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}=vx(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}},dX=t=>{const e=K5(G5(hX(t)));return k.useMemo(()=>fX(e),[e])},Dc=t=>{const[,e]=Go(t.getState);return ws(()=>(e(t.getState()),t.subscribe(()=>{e(t.getState())})),[t]),t.getState()},pX=Jn(({runtime:t})=>{const e=Dc(t),n=OE();return ws(()=>{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=JY(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}}},X5=Jn(({runtime:t})=>{const e=Dc(t);return bo({getState:()=>e,remove:t.remove,__internal_getRuntime:()=>t},{key:e.id})}),mX=Jn(({runtime:t,index:e})=>{const n=Ht(()=>t.getAttachmentByIndex(e),[t,e]);return Ss(X5({runtime:n}))}),J5=Jn(({threadIdRef:t,messageIdRef:e,runtime:n})=>{const r=Dc(n),i=OE();ws(()=>{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)=>mX({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})}),gX=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})}),yX=Jn(({runtime:t,index:e})=>{const n=Ht(()=>t.getAttachmentByIndex(e),[t,e]);return Ss(X5({runtime:n}))}),bX=Jn(({runtime:t,index:e})=>{const n=Ht(()=>t.getMessagePartByIndex(e),[t,e]);return Ss(gX({runtime:n}))}),vX=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=Ss(J5({runtime:t.composer,threadIdRef:e,messageIdRef:a})),h=Hp(n.content.map((m,y)=>bX({runtime:t,index:y},{key:y}))),f=Hp(n.attachments?.map((m,y)=>yX({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})}),xX=Jn(({runtime:t,id:e,threadIdRef:n})=>{const r=Ht(()=>t.getMessageById(e),[t,e]);return Ss(vX({runtime:r,threadIdRef:n}))}),wX=Jn(({runtime:t})=>{const e=Dc(t),n=OE();ws(()=>{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=Ss(J5({runtime:t.composer,threadIdRef:r})),s=Hp(e.messages.map(a=>xX({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})}),SX=Jn(({runtime:t,id:e})=>{const n=Ht(()=>t.getItemById(e),[t,e]);return Ss(pX({runtime:n}))}),_X=Jn(({runtime:t})=>{const e=Dc(t),n=Ss(wX({runtime:t.main})),r=Hp(Object.keys(e.threadItems).map(s=>SX({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()}})}),CX=t=>t._core?.RenderComponent,AX=({children:t,runtime:e})=>{const n=dX({threads:_X({runtime:e.threads}),registerModelContextProvider:e.registerModelContextProvider,__internal_runtime:e}),r=CX(e);return C.jsxs(xx,{api:n,children:[r&&C.jsx(r,{}),t]})},EX=k.memo(AX),kX=({index:t,children:e})=>{const n=ki(),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}=vx(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(xx,{api:r,children:e})},TX=({index:t,children:e})=>{const n=ki(),r=k.useMemo(()=>({part:Gn({source:"message",query:{type:"index",index:t},get:()=>n.message().part({index:t})})}),[n,t]);return C.jsx(xx,{api:r,children:e})},RX=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})}),MX=({text:t,isRunning:e=!1,children:n})=>{const r=K5(G5(RX({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(xx,{api:i,children:n})},CD=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=ki(),n=k.useMemo(()=>new CD(e),[e]),r=k.useSyncExternalStore(e.subscribe,()=>t(n),()=>t(n));if(k.useDebugValue(r),r instanceof CD)throw new Error("You tried to return the entire AssistantState. This is not supported due to technical limitations.");return r},OX=(t,e)=>{const n=ki(),r=k.useRef(e);k.useEffect(()=>{r.current=e});const{scope:i,event:s}=vx(t);k.useEffect(()=>n.on({scope:i,event:s},o=>r.current(o)),[n,i,s])},PX=t=>{const e=t;e.__isBound||(e.__internal_bindMethods?.(),e.__isBound=!0)};function DX(t,e=IX){PX(t);const n=k.useSyncExternalStore(t.subscribe,()=>e(t.getState()),()=>e(t.getState()));return k.useDebugValue(n),n}var IX=t=>t;function LX(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?DX(s,i):null}return e}function NX(t){const e=ki(),n=e.message.source?e.message().__internal_getRuntime():null;if(!n&&!t?.optional)throw new Error("MessageRuntime is not available");return n}var Q5=LX(NX),Z5=class{constructor(t){this._core=t,this.threads=new pY(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(kE.fromArray(t??[]))}},$X=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 ej=k.createContext(null),jX=t=>({useSmoothStatus:na(()=>t)}),BX=({children:t})=>{const e=tj({optional:!0}),n=ki(),[r]=k.useState(()=>jX(n.part().getState().status));return e?t:C.jsx(ej.Provider,{value:r,children:t})},FX=t=>{const e=k.forwardRef((n,r)=>C.jsx(BX,{children:C.jsx(t,{...n,ref:r})}));return e.displayName=t.displayName,e};function tj(t){const e=k.useContext(ej);if(!t?.optional&&!e)throw new Error("This component must be used within a SmoothContextProvider.");return e}var{useSmoothStatus:zX,useSmoothStatusStore:VX}=z5(tj,"useSmoothStatus"),UX=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))}},NS=Object.freeze({type:"running"}),nj=(t,e=!1)=>{const{text:n}=t,r=Mt(({message:f})=>f.id),i=k.useRef(r),[s,o]=k.useState(n),a=VX({optional:!0}),c=Lr(f=>{if(o(f),a){const d=s!==f||t.status.type==="running"?NS:t.status;qb(a).setState(d,!0)}});k.useEffect(()=>{if(a){const f=s!==n||t.status.type==="running"?NS:t.status;qb(a).setState(f,!0)}},[a,n,s,t.status]);const[h]=k.useState(new UX(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:NS}:t,[e,s,t,n])};const HX=Object.freeze(Object.defineProperty({__proto__:null,AssistantRuntimeImpl:Z5,BaseAssistantRuntimeCore:T5,CompositeContextProvider:k5,DefaultThreadComposerRuntimeCore:M5,MessageRepository:TE,ThreadRuntimeImpl:B5,fromThreadMessageLike:yx,generateId:gx,getAutoStatus:EE,splitLocalRuntimeOptions:$X,useSmooth:nj,useSmoothStatus:zX,withSmoothContextProvider:FX},Symbol.toStringTag,{value:"Module"}));function AD(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Sx(...t){return e=>{let n=!1;const r=t.map(i=>{const s=AD(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():AD(t[i],null)}}}}function Bt(...t){return k.useCallback(Sx(...t),t)}var PE=E5();const WX=Pc(PE);function Rh(t){const e=qX(t),n=k.forwardRef((r,i)=>{const{children:s,...o}=r,a=k.Children.toArray(s),c=a.find(KX);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 rj=Rh("Slot");function qX(t){const e=k.forwardRef((n,r)=>{const{children:i,...s}=n;if(k.isValidElement(i)){const o=XX(i),a=YX(s,i.props);return i.type!==k.Fragment&&(a.ref=r?Sx(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 ij=Symbol("radix.slottable");function GX(t){const e=({children:n})=>C.jsx(C.Fragment,{children:n});return e.displayName=`${t}.Slottable`,e.__radixId=ij,e}function KX(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===ij}function YX(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 XX(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 JX=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],st=JX.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 sj(t,e){t&&PE.flushSync(()=>t.dispatchEvent(e))}var z2=(t=>(t.Hidden="hidden",t.Floating="floating",t.Normal="normal",t))(z2||{}),QX=({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"),oj=k.forwardRef(({hideWhenRunning:t,autohide:e,autohideFloat:n,...r},i)=>{const s=QX({hideWhenRunning:t,autohide:e,autohideFloat:n});return s===z2.Hidden?null:C.jsx(st.div,{...s===z2.Floating?{"data-floating":"true"}:null,...r,ref:i})});oj.displayName="ActionBarPrimitive.Root";function Le(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t?.(i),n===!1||!i.defaultPrevented)return e?.(i)}}var ZX=({copiedDuration:t=3e3}={})=>{const e=ki(),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},aj=k.forwardRef(({copiedDuration:t,onClick:e,disabled:n,...r},i)=>{const s=Mt(({message:a})=>a.isCopied),o=ZX({copiedDuration:t});return C.jsx(st.button,{type:"button",...s?{"data-copied":"true"}:{},...r,ref:i,disabled:n||!o,onClick:Le(e,()=>{o?.()})})});aj.displayName="ActionBarPrimitive.Copy";var lj=(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 cj(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 eJ(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,tJ(i,...e)]}function tJ(...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 nJ="DismissableLayer",V2="dismissableLayer.update",rJ="dismissableLayer.pointerDownOutside",iJ="dismissableLayer.focusOutside",ED,uj=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_x=k.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...c}=t,h=k.useContext(uj),[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=aJ(D=>{const N=D.target,H=[...h.branches].some(j=>j.contains(N));!P||H||(i?.(D),o?.(D),D.defaultPrevented||a?.())},m),M=lJ(D=>{const N=D.target;[...h.branches].some(j=>j.contains(N))||(s?.(D),o?.(D),D.defaultPrevented||a?.())},m);return cj(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&&(ED=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),kD(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=ED)}},[f,m,n,h]),k.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),kD())},[f,h]),k.useEffect(()=>{const D=()=>y({});return document.addEventListener(V2,D),()=>document.removeEventListener(V2,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)})});_x.displayName=nJ;var sJ="DismissableLayerBranch",oJ=k.forwardRef((t,e)=>{const n=k.useContext(uj),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})});oJ.displayName=sJ;function aJ(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(){hj(rJ,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 lJ(t,e=globalThis?.document){const n=Lr(t),r=k.useRef(!1);return k.useEffect(()=>{const i=s=>{s.target&&!r.current&&hj(iJ,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 kD(){const t=new CustomEvent(V2);document.dispatchEvent(t)}function hj(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?sj(i,s):i.dispatchEvent(s)}var $S=0;function fj(){k.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??TD()),document.body.insertAdjacentElement("beforeend",t[1]??TD()),$S++,()=>{$S===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),$S--}},[])}function TD(){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 jS="focusScope.autoFocusOnMount",BS="focusScope.autoFocusOnUnmount",RD={bubbles:!1,cancelable:!0},cJ="FocusScope",DE=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){OD.add(y);const x=document.activeElement;if(!a.contains(x)){const _=new CustomEvent(jS,RD);a.addEventListener(jS,h),a.dispatchEvent(_),_.defaultPrevented||(uJ(mJ(dj(a)),{select:!0}),document.activeElement===x&&Ka(a))}return()=>{a.removeEventListener(jS,h),setTimeout(()=>{const _=new CustomEvent(BS,RD);a.addEventListener(BS,f),a.dispatchEvent(_),_.defaultPrevented||Ka(x??document.body,{select:!0}),a.removeEventListener(BS,f),OD.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]=hJ(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})});DE.displayName=cJ;function uJ(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Ka(r,{select:e}),document.activeElement!==n)return}function hJ(t){const e=dj(t),n=MD(e,t),r=MD(e.reverse(),t);return[n,r]}function dj(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 MD(t,e){for(const n of t)if(!fJ(n,{upTo:e}))return n}function fJ(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 dJ(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&&dJ(t)&&e&&t.select()}}var OD=pJ();function pJ(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=PD(t,e),t.unshift(e)},remove(e){t=PD(t,e),t[0]?.resume()}}}function PD(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function mJ(t){return t.filter(e=>e.tagName!=="A")}var hl=globalThis?.document?k.useLayoutEffect:()=>{},gJ=A5[" useId ".trim().toString()]||(()=>{}),yJ=0;function ol(t){const[e,n]=k.useState(gJ());return hl(()=>{n(r=>r??String(yJ++))},[t]),e?`radix-${e}`:""}const bJ=["top","right","bottom","left"],fl=Math.min,_i=Math.max,Kb=Math.round,O0=Math.floor,ao=t=>({x:t,y:t}),vJ={left:"right",right:"left",bottom:"top",top:"bottom"},xJ={start:"end",end:"start"};function U2(t,e,n){return _i(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 IE(t){return t==="x"?"y":"x"}function LE(t){return t==="y"?"height":"width"}const wJ=new Set(["top","bottom"]);function no(t){return wJ.has(Yo(t))?"y":"x"}function NE(t){return IE(no(t))}function SJ(t,e,n){n===void 0&&(n=!1);const r=Hh(t),i=NE(t),s=LE(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=Yb(o)),[o,Yb(o)]}function _J(t){const e=Yb(t);return[H2(t),e,H2(e)]}function H2(t){return t.replace(/start|end/g,e=>xJ[e])}const DD=["left","right"],ID=["right","left"],CJ=["top","bottom"],AJ=["bottom","top"];function EJ(t,e,n){switch(t){case"top":case"bottom":return n?e?ID:DD:e?DD:ID;case"left":case"right":return e?CJ:AJ;default:return[]}}function kJ(t,e,n,r){const i=Hh(t);let s=EJ(Yo(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(H2)))),s}function Yb(t){return t.replace(/left|right|bottom|top/g,e=>vJ[e])}function TJ(t){return{top:0,right:0,bottom:0,left:0,...t}}function pj(t){return typeof t!="number"?TJ(t):{top:t,right:t,bottom:t,left:t}}function Xb(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 LD(t,e,n){let{reference:r,floating:i}=t;const s=no(e),o=NE(e),a=LE(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 RJ=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}=LD(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}=LD(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=pj(y),S=a[m?d==="floating"?"reference":"floating":d],_=Xb(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=Xb(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 MJ=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=pj(f),m={x:n,y:r},y=NE(i),b=LE(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=U2(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}}}),OJ=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=no(a),E=Yo(a)===a,P=await(c.isRTL==null?void 0:c.isRTL(h.floating)),O=m||(E||!x?[Yb(a)]:_J(a)),M=b!=="none";!m&&M&&O.push(...kJ(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=SJ(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!==no(te):!1)||j.every(U=>no(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=no(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 ND(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function $D(t){return bJ.some(e=>t[e]>=0)}const PJ=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=ND(s,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:$D(o)}}}case"escaped":{const s=await Wp(e,{...i,altBoundary:!0}),o=ND(s,n.floating);return{data:{escapedOffsets:o,escaped:$D(o)}}}default:return{}}}}},mj=new Set(["left","top"]);async function DJ(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=no(n)==="y",h=mj.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 IJ=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 DJ(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}}}}},LJ=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=no(Yo(i)),m=IE(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=U2(A,y,E)}if(o){const S=d==="y"?"top":"left",_=d==="y"?"bottom":"right",A=b+f[S],E=b-f[_];b=U2(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}}}}}},NJ=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=no(i),m=IE(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=mj.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}}}},$J=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=no(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=_i(f.left,0),V=_i(f.right,0),q=_i(f.top,0),X=_i(f.bottom,0);y?N=b-2*(j!==0||V!==0?j+V:_i(f.left,f.right)):D=x-2*(q!==0||X!==0?q+X:_i(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 Cx(){return typeof window<"u"}function Wh(t){return gj(t)?(t.nodeName||"").toLowerCase():"#document"}function Ai(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function vo(t){var e;return(e=(gj(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function gj(t){return Cx()?t instanceof Node||t instanceof Ai(t).Node:!1}function _s(t){return Cx()?t instanceof Element||t instanceof Ai(t).Element:!1}function po(t){return Cx()?t instanceof HTMLElement||t instanceof Ai(t).HTMLElement:!1}function jD(t){return!Cx()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ai(t).ShadowRoot}const jJ=new Set(["inline","contents"]);function Dm(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=Cs(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!jJ.has(i)}const BJ=new Set(["table","td","th"]);function FJ(t){return BJ.has(Wh(t))}const zJ=[":popover-open",":modal"];function Ax(t){return zJ.some(e=>{try{return t.matches(e)}catch{return!1}})}const VJ=["transform","translate","scale","rotate","perspective"],UJ=["transform","translate","scale","rotate","perspective","filter"],HJ=["paint","layout","strict","content"];function $E(t){const e=jE(),n=_s(t)?Cs(t):t;return VJ.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)||UJ.some(r=>(n.willChange||"").includes(r))||HJ.some(r=>(n.contain||"").includes(r))}function WJ(t){let e=dl(t);for(;po(e)&&!Mh(e);){if($E(e))return e;if(Ax(e))return null;e=dl(e)}return null}function jE(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const qJ=new Set(["html","body","#document"]);function Mh(t){return qJ.has(Wh(t))}function Cs(t){return Ai(t).getComputedStyle(t)}function Ex(t){return _s(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||jD(t)&&t.host||vo(t);return jD(e)?e.host:e}function yj(t){const e=dl(t);return Mh(e)?t.ownerDocument?t.ownerDocument.body:t.body:po(e)&&Dm(e)?e:yj(e)}function qp(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=yj(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=Ai(i);if(s){const a=W2(o);return e.concat(o,o.visualViewport||[],Dm(i)?i:[],a&&n?qp(a):[])}return e.concat(i,qp(i,[],n))}function W2(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function bj(t){const e=Cs(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=po(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,a=Kb(n)!==s||Kb(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function BE(t){return _s(t)?t:t.contextElement}function ph(t){const e=BE(t);if(!po(e))return ao(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=bj(e);let o=(s?Kb(n.width):n.width)/r,a=(s?Kb(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const GJ=ao(0);function vj(t){const e=Ai(t);return!jE()||!e.visualViewport?GJ:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function KJ(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ai(t)?!1:e}function wc(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=BE(t);let o=ao(1);e&&(r?_s(r)&&(o=ph(r)):o=ph(t));const a=KJ(s,n,r)?vj(s):ao(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=Ai(s),y=r&&_s(r)?Ai(r):r;let b=m,x=W2(b);for(;x&&r&&y!==b;){const S=ph(x),_=x.getBoundingClientRect(),A=Cs(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=Ai(x),x=W2(b)}}return Xb({width:f,height:d,x:c,y:h})}function kx(t,e){const n=Ex(t).scrollLeft;return e?e.left+n:wc(vo(t)).left+n}function xj(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-kx(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function YJ(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=vo(r),a=e?Ax(e.floating):!1;if(r===o||a&&s)return n;let c={scrollLeft:0,scrollTop:0},h=ao(1);const f=ao(0),d=po(r);if((d||!d&&!s)&&((Wh(r)!=="body"||Dm(o))&&(c=Ex(r)),po(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?xj(o,c):ao(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 XJ(t){return Array.from(t.getClientRects())}function JJ(t){const e=vo(t),n=Ex(t),r=t.ownerDocument.body,i=_i(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=_i(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+kx(t);const a=-n.scrollTop;return Cs(r).direction==="rtl"&&(o+=_i(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}const BD=25;function QJ(t,e){const n=Ai(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=jE();(!f||f&&e==="fixed")&&(a=i.offsetLeft,c=i.offsetTop)}const h=kx(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<=BD&&(s-=b)}else h<=BD&&(s+=h);return{width:s,height:o,x:a,y:c}}const ZJ=new Set(["absolute","fixed"]);function eQ(t,e){const n=wc(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=po(t)?ph(t):ao(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 FD(t,e,n){let r;if(e==="viewport")r=QJ(t,n);else if(e==="document")r=JJ(vo(t));else if(_s(e))r=eQ(e,n);else{const i=vj(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return Xb(r)}function wj(t,e){const n=dl(t);return n===e||!_s(n)||Mh(n)?!1:Cs(n).position==="fixed"||wj(n,e)}function tQ(t,e){const n=e.get(t);if(n)return n;let r=qp(t,[],!1).filter(a=>_s(a)&&Wh(a)!=="body"),i=null;const s=Cs(t).position==="fixed";let o=s?dl(t):t;for(;_s(o)&&!Mh(o);){const a=Cs(o),c=$E(o);!c&&a.position==="fixed"&&(i=null),(s?!c&&!i:!c&&a.position==="static"&&!!i&&ZJ.has(i.position)||Dm(o)&&!c&&wj(t,o))?r=r.filter(f=>f!==o):i=a,o=dl(o)}return e.set(t,r),r}function nQ(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?Ax(e)?[]:tQ(e,this._c):[].concat(n),r],a=o[0],c=o.reduce((h,f)=>{const d=FD(e,f,i);return h.top=_i(d.top,h.top),h.right=fl(d.right,h.right),h.bottom=fl(d.bottom,h.bottom),h.left=_i(d.left,h.left),h},FD(e,a,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function rQ(t){const{width:e,height:n}=bj(t);return{width:e,height:n}}function iQ(t,e,n){const r=po(e),i=vo(e),s=n==="fixed",o=wc(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const c=ao(0);function h(){c.x=kx(i)}if(r||!r&&!s)if((Wh(e)!=="body"||Dm(i))&&(a=Ex(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?xj(i,a):ao(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 FS(t){return Cs(t).position==="static"}function zD(t,e){if(!po(t)||Cs(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return vo(t)===n&&(n=n.ownerDocument.body),n}function Sj(t,e){const n=Ai(t);if(Ax(t))return n;if(!po(t)){let i=dl(t);for(;i&&!Mh(i);){if(_s(i)&&!FS(i))return i;i=dl(i)}return n}let r=zD(t,e);for(;r&&FJ(r)&&FS(r);)r=zD(r,e);return r&&Mh(r)&&FS(r)&&!$E(r)?n:r||WJ(t)||n}const sQ=async function(t){const e=this.getOffsetParent||Sj,n=this.getDimensions,r=await n(t.floating);return{reference:iQ(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function oQ(t){return Cs(t).direction==="rtl"}const aQ={convertOffsetParentRelativeRectToViewportRelativeRect:YJ,getDocumentElement:vo,getClippingRect:nQ,getOffsetParent:Sj,getElementRects:sQ,getClientRects:XJ,getDimensions:rQ,getScale:ph,isElement:_s,isRTL:oQ};function _j(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function lQ(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=O0(d),x=O0(i.clientWidth-(f+m)),S=O0(i.clientHeight-(d+y)),_=O0(f),E={rootMargin:-b+"px "+-x+"px "+-S+"px "+-_+"px",threshold:_i(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&&!_j(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 cQ(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=BE(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?lQ(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&&!_j(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 uQ=IJ,hQ=LJ,fQ=OJ,dQ=$J,pQ=PJ,VD=MJ,mQ=NJ,gQ=(t,e,n)=>{const r=new Map,i={platform:aQ,...n},s={...i.platform,_c:r};return RJ(t,e,{...i,platform:s})};var yQ=typeof document<"u",bQ=function(){},nb=yQ?k.useLayoutEffect:bQ;function Jb(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(!Jb(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)&&!Jb(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function Cj(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function UD(t,e){const n=Cj(t);return Math.round(e*n)/n}function zS(t){const e=k.useRef(t);return nb(()=>{e.current=t}),e}function vQ(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);Jb(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=zS(c),V=zS(i),q=zS(h),X=k.useCallback(()=>{if(!M.current||!D.current)return;const U={placement:e,strategy:n,middleware:m};V.current&&(U.platform=V.current),gQ(M.current,D.current,U).then(se=>{const T={...se,isPositioned:q.current!==!1};Y.current&&!Jb(N.current,T)&&(N.current=T,PE.flushSync(()=>{d(T)}))})},[m,e,n,V,q]);nb(()=>{h===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,d(U=>({...U,isPositioned:!1})))},[h]);const Y=k.useRef(!1);nb(()=>(Y.current=!0,()=>{Y.current=!1}),[]),nb(()=>{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=UD(z.floating,f.x),T=UD(z.floating,f.y);return a?{...U,transform:"translate("+se+"px, "+T+"px)",...Cj(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 xQ=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?VD({element:r.current,padding:i}).fn(n):{}:r?VD({element:r,padding:i}).fn(n):{}}}},wQ=(t,e)=>({...uQ(t),options:[t,e]}),SQ=(t,e)=>({...hQ(t),options:[t,e]}),_Q=(t,e)=>({...mQ(t),options:[t,e]}),CQ=(t,e)=>({...fQ(t),options:[t,e]}),AQ=(t,e)=>({...dQ(t),options:[t,e]}),EQ=(t,e)=>({...pQ(t),options:[t,e]}),kQ=(t,e)=>({...xQ(t),options:[t,e]});var TQ="Arrow",Aj=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"})})});Aj.displayName=TQ;var RQ=Aj;function Ej(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 FE="Popper",[kj,Tx]=ra(FE),[MQ,Tj]=kj(FE),Rj=t=>{const{__scopePopper:e,children:n}=t,[r,i]=k.useState(null);return C.jsx(MQ,{scope:e,anchor:r,onAnchorChange:i,children:n})};Rj.displayName=FE;var Mj="PopperAnchor",Oj=k.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,s=Tj(Mj,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})});Oj.displayName=Mj;var zE="PopperContent",[OQ,PQ]=kj(zE),Pj=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=Tj(zE,n),[_,A]=k.useState(null),E=Bt(e,Ee=>A(Ee)),[P,O]=k.useState(null),M=Ej(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(IQ),altBoundary:q},{refs:Y,floatingStyles:te,placement:z,isPositioned:G,middlewareData:U}=vQ({strategy:"fixed",placement:H,whileElementsMounted:(...Ee)=>cQ(...Ee,{animationFrame:y==="always"}),elements:{reference:S.anchor},middleware:[wQ({mainAxis:i+N,alignmentAxis:o}),c&&SQ({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?_Q():void 0,...X}),c&&CQ({...X}),AQ({...X,apply:({elements:Ee,rects:Ue,availableWidth:Pt,availableHeight:Yt})=>{const{width:Xt,height:er}=Ue.reference,tr=Ee.floating.style;tr.setProperty("--radix-popper-available-width",`${Pt}px`),tr.setProperty("--radix-popper-available-height",`${Yt}px`),tr.setProperty("--radix-popper-anchor-width",`${Xt}px`),tr.setProperty("--radix-popper-anchor-height",`${er}px`)}}),P&&kQ({element:P,padding:a}),LQ({arrowWidth:D,arrowHeight:N}),m&&EQ({strategy:"referenceHidden",...X})]}),[se,T]=Lj(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(OQ,{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"}})})})});Pj.displayName=zE;var Dj="PopperArrow",DQ={top:"bottom",right:"left",bottom:"top",left:"right"},Ij=k.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=PQ(Dj,r),o=DQ[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(RQ,{...i,ref:n,style:{...i.style,display:"block"}})})});Ij.displayName=Dj;function IQ(t){return t!==null}var LQ=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]=Lj(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 Lj(t){const[e,n="center"]=t.split("-");return[e,n]}var Nj=Rj,$j=Oj,jj=Pj,Bj=Ij,NQ="Portal",Rx=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?WX.createPortal(C.jsx(st.div,{...r,ref:e}),o):null});Rx.displayName=NQ;function $Q(t,e){return k.useReducer((n,r)=>e[n][r]??n,t)}var ks=t=>{const{present:e,children:n}=t,r=jQ(e),i=typeof n=="function"?n({present:r.isPresent}):k.Children.only(n),s=Bt(r.ref,BQ(i));return typeof n=="function"||r.isPresent?k.cloneElement(i,{ref:s}):null};ks.displayName="Presence";function jQ(t){const[e,n]=k.useState(),r=k.useRef(null),i=k.useRef(t),s=k.useRef("none"),o=t?"mounted":"unmounted",[a,c]=$Q(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const h=P0(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=P0(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=P0(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=P0(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 P0(t){return t?.animationName||"none"}function BQ(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 FQ=A5[" useInsertionEffect ".trim().toString()]||hl;function qh({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[i,s,o]=zQ({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=VQ(f)?f(t):f;d!==t&&o.current?.(d)}else s(f)},[a,t,s,o]);return[c,h]}function zQ({defaultProp:t,onChange:e}){const[n,r]=k.useState(t),i=k.useRef(n),s=k.useRef(e);return FQ(()=>{s.current=e},[e]),k.useEffect(()=>{i.current!==n&&(s.current?.(n),i.current=n)},[n,i]),[n,r,s]}function VQ(t){return typeof t=="function"}var UQ=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Ru=new WeakMap,D0=new WeakMap,I0={},VS=0,Fj=function(t){return t&&(t.host||Fj(t.parentNode))},HQ=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=Fj(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})},WQ=function(t,e,n,r){var i=HQ(e,Array.isArray(t)?t:[t]);I0[n]||(I0[n]=new WeakMap);var s=I0[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&&D0.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(),VS++,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||(D0.has(d)||d.removeAttribute(r),D0.delete(d)),y||d.removeAttribute(n)}),VS--,VS||(Ru=new WeakMap,Ru=new WeakMap,D0=new WeakMap,I0={})}},zj=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),i=UQ(t);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),WQ(r,i,n,"aria-hidden")):function(){return null}},Qs=function(){return Qs=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},Qs.apply(this,arguments)};function Vj(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 rb(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 ib="right-scroll-bar-position",sb="width-before-scroll-bar",qQ="with-scroll-bars-hidden",GQ="--removed-body-scroll-bar-size";function US(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function KQ(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 YQ=typeof window<"u"?k.useLayoutEffect:k.useEffect,HD=new WeakMap;function XQ(t,e){var n=KQ(null,function(r){return t.forEach(function(i){return US(i,r)})});return YQ(function(){var r=HD.get(n);if(r){var i=new Set(r),s=new Set(t),o=n.current;i.forEach(function(a){s.has(a)||US(a,null)}),s.forEach(function(a){i.has(a)||US(a,o)})}HD.set(n,t)},[t]),n}function JQ(t){return t}function QQ(t,e){e===void 0&&(e=JQ);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 ZQ(t){t===void 0&&(t={});var e=QQ(null);return e.options=Qs({async:!0,ssr:!1},t),e}var Uj=function(t){var e=t.sideCar,n=Vj(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,Qs({},n))};Uj.isSideCarExport=!0;function eZ(t,e){return t.useMedium(e),Uj}var Hj=ZQ(),HS=function(){},Mx=k.forwardRef(function(t,e){var n=k.useRef(null),r=k.useState({onScrollCapture:HS,onWheelCapture:HS,onTouchMoveCapture:HS}),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=Vj(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),O=m,M=XQ([n,e]),D=Qs(Qs({},P),i);return k.createElement(k.Fragment,null,f&&k.createElement(O,{sideCar:Hj,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),Qs(Qs({},D),{ref:M})):k.createElement(A,Qs({},D,{className:c,ref:M}),a))});Mx.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Mx.classNames={fullWidth:sb,zeroRight:ib};var tZ=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function nZ(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=tZ();return e&&t.setAttribute("nonce",e),t}function rZ(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function iZ(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var sZ=function(){var t=0,e=null;return{add:function(n){t==0&&(e=nZ())&&(rZ(e,n),iZ(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},oZ=function(){var t=sZ();return function(e,n){k.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},Wj=function(){var t=oZ(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},aZ={left:0,top:0,right:0,gap:0},WS=function(t){return parseInt(t||"",10)||0},lZ=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[WS(n),WS(r),WS(i)]},cZ=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return aZ;var e=lZ(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])}},uZ=Wj(),mh="data-scroll-locked",hZ=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(qQ,` {
|
||
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(ib,` {
|
||
right: `).concat(a,"px ").concat(r,`;
|
||
}
|
||
|
||
.`).concat(sb,` {
|
||
margin-right: `).concat(a,"px ").concat(r,`;
|
||
}
|
||
|
||
.`).concat(ib," .").concat(ib,` {
|
||
right: 0 `).concat(r,`;
|
||
}
|
||
|
||
.`).concat(sb," .").concat(sb,` {
|
||
margin-right: 0 `).concat(r,`;
|
||
}
|
||
|
||
body[`).concat(mh,`] {
|
||
`).concat(GQ,": ").concat(a,`px;
|
||
}
|
||
`)},WD=function(){var t=parseInt(document.body.getAttribute(mh)||"0",10);return isFinite(t)?t:0},fZ=function(){k.useEffect(function(){return document.body.setAttribute(mh,(WD()+1).toString()),function(){var t=WD()-1;t<=0?document.body.removeAttribute(mh):document.body.setAttribute(mh,t.toString())}},[])},dZ=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,i=r===void 0?"margin":r;fZ();var s=k.useMemo(function(){return cZ(i)},[i]);return k.createElement(uZ,{styles:hZ(s,!e,i,n?"":"!important")})},q2=!1;if(typeof window<"u")try{var L0=Object.defineProperty({},"passive",{get:function(){return q2=!0,!0}});window.addEventListener("test",L0,L0),window.removeEventListener("test",L0,L0)}catch{q2=!1}var Mu=q2?{passive:!1}:!1,pZ=function(t){return t.tagName==="TEXTAREA"},qj=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!pZ(t)&&n[e]==="visible")},mZ=function(t){return qj(t,"overflowY")},gZ=function(t){return qj(t,"overflowX")},qD=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=Gj(t,r);if(i){var s=Kj(t,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},yZ=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},bZ=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},Gj=function(t,e){return t==="v"?mZ(e):gZ(e)},Kj=function(t,e){return t==="v"?yZ(e):bZ(e)},vZ=function(t,e){return t==="h"&&e==="rtl"?-1:1},xZ=function(t,e,n,r,i){var s=vZ(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=Kj(t,a),b=y[0],x=y[1],S=y[2],_=x-S-s*b;(b||_)&&Gj(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},N0=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},GD=function(t){return[t.deltaX,t.deltaY]},KD=function(t){return t&&"current"in t?t.current:t},wZ=function(t,e){return t[0]===e[0]&&t[1]===e[1]},SZ=function(t){return`
|
||
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
||
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
||
`)},_Z=0,Ou=[];function CZ(t){var e=k.useRef([]),n=k.useRef([0,0]),r=k.useRef(),i=k.useState(_Z++)[0],s=k.useState(Wj)[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=rb([t.lockRef.current],(t.shards||[]).map(KD),!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 _=N0(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=qD(D,M);if(!N)return!0;if(N?O=D:(O=D==="v"?"h":"v",N=qD(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 xZ(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?GD(S):N0(S),A=e.current.filter(function(O){return O.name===S.type&&(O.target===S.target||S.target===O.shadowParent)&&wZ(O.delta,_)})[0];if(A&&A.should){S.cancelable&&S.preventDefault();return}if(!A){var E=(o.current.shards||[]).map(KD).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:AZ(_)};e.current.push(E),setTimeout(function(){e.current=e.current.filter(function(P){return P!==E})},1)},[]),f=k.useCallback(function(x){n.current=N0(x),r.current=void 0},[]),d=k.useCallback(function(x){h(x.type,GD(x),x.target,a(x,t.lockRef.current))},[]),m=k.useCallback(function(x){h(x.type,N0(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:SZ(i)}):null,y?k.createElement(dZ,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function AZ(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const EZ=eZ(Hj,CZ);var VE=k.forwardRef(function(t,e){return k.createElement(Mx,Qs({},t,{ref:e,sideCar:EZ}))});VE.classNames=Mx.classNames;var UE=t=>{const e=k.useRef(void 0);return k.useCallback(r=>{e.current&&e.current(),r&&(e.current=t(r))},[t])},kZ=()=>{const t=ki(),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 UE(n)},HE=k.forwardRef((t,e)=>{const n=kZ(),r=Bt(e,n);return C.jsx(st.div,{...t,ref:r})});HE.displayName="MessagePrimitive.Root";var Yj=()=>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}),Xj=k.forwardRef(({smooth:t=!0,component:e="span",...n},r)=>{const{text:i,status:s}=nj(Yj(),t);return C.jsx(e,{"data-status":s.type,...n,ref:r,children:i})});Xj.displayName="MessagePartPrimitive.Text";var TZ=()=>Mt(({part:e})=>{if(e.type!=="image")throw new Error("MessagePartImage can only be used inside image message parts.");return e}),Jj=k.forwardRef((t,e)=>{const{image:n}=TZ();return C.jsx(st.img,{src:n,...t,ref:e})});Jj.displayName="MessagePartPrimitive.Image";var Qj=({children:t})=>Mt(({part:n})=>n.status.type==="running")?t:null;Qj.displayName="MessagePartPrimitive.InProgress";const YD=t=>Symbol.iterator in t,XD=t=>"entries"in t,JD=(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},RZ=(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 MZ(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:YD(t)&&YD(e)?XD(t)&&XD(e)?JD(t,e):RZ(t,e):JD({entries:()=>Object.entries(t)},{entries:()=>Object.entries(e)})}function OZ(t){const e=be.useRef(void 0);return n=>{const r=t(n);return MZ(e.current,r)?e.current:e.current=r}}var PZ=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},DZ=()=>{const t=Mt(OZ(e=>e.message.parts.map(n=>n.type)));return k.useMemo(()=>t.length===0?[]:PZ(t),[t])},IZ=({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(Xj,{}),C.jsx(Qj,{children:C.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>C.jsx(Jj,{}),File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:t})=>t},LZ=({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=ki(),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(IZ,{...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}`)}},G2=k.memo(({index:t,components:e})=>C.jsx(TX,{index:t,children:C.jsx(LZ,{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);G2.displayName="MessagePrimitive.PartByIndex";var NZ=({status:t,component:e})=>C.jsx(MX,{text:"",isRunning:t.type==="running",children:C.jsx(e,{type:"text",text:"",status:t})}),$Z=Object.freeze({type:"complete"}),jZ=({components:t})=>{const e=Mt(n=>n.message.status??$Z);return t?.Empty?C.jsx(t.Empty,{status:e}):C.jsx(NZ,{status:e,component:t?.Text??Xa.Text})},BZ=k.memo(jZ,(t,e)=>t.components?.Empty===e.components?.Empty&&t.components?.Text===e.components?.Text),WE=({components:t})=>{const e=Mt(({message:i})=>i.parts.length),n=DZ(),r=k.useMemo(()=>e===0?C.jsx(BZ,{components:t}):n.map(i=>{if(i.type==="single")return C.jsx(G2,{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(G2,{index:i.startIndex+a,components:t},a))},i.startIndex)}}),[n,t,e]);return C.jsx(C.Fragment,{children:r})};WE.displayName="MessagePrimitive.Parts";var FZ=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)}),K2=({children:t,...e})=>FZ(e)?t:null;K2.displayName="MessagePrimitive.If";var Zj=({children:t})=>Mt(({message:n})=>n.status?.type==="incomplete"&&n.status.reason==="error")?C.jsx(C.Fragment,{children:t}):null;Zj.displayName="MessagePrimitive.Error";var eB=()=>{const t=ki(),e=Mt(r=>r.thread.isRunning||!r.composer.isEditing||r.composer.isEmpty),n=k.useCallback(()=>{t.composer().send()},[t]);return e?null:n},zZ=lj("ComposerPrimitive.Send",eB),tB=k.forwardRef(({onSubmit:t,...e},n)=>{const r=eB(),i=s=>{s.preventDefault(),r&&r()};return C.jsx(st.form,{...e,ref:n,onSubmit:Le(t,i)})});tB.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 nB(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 VZ=k.useLayoutEffect,UZ=function(e){var n=be.useRef(e);return VZ(function(){n.current=e}),n},QD=function(e,n){if(typeof e=="function"){e(n);return}e.current=n},HZ=function(e,n){var r=be.useRef();return be.useCallback(function(i){e.current=i,r.current&&QD(r.current,null),r.current=n,n&&QD(n,i)},[n])},ZD={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},WZ=function(e){Object.keys(ZD).forEach(function(n){e.style.setProperty(n,ZD[n],"important")})},eI=WZ,Ar=null,tI=function(e,n){var r=e.scrollHeight;return n.sizingStyle.boxSizing==="border-box"?r+n.borderSize:r-n.paddingSize};function qZ(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"),eI(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]}),eI(Ar),Ar.value=e;var c=tI(Ar,t);Ar.value=e,c=tI(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 nI=function(){},GZ=function(e,n){return e.reduce(function(r,i){return r[i]=n[i],r},{})},KZ=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],YZ=!!document.documentElement.currentStyle,XZ=function(e){var n=window.getComputedStyle(e);if(n===null)return null;var r=GZ(KZ,n),i=r.boxSizing;if(i==="")return null;YZ&&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}},JZ=XZ;function qE(t,e,n){var r=UZ(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 QZ=function(e,n){qE(document.body,"reset",function(r){e.current.form===r.target&&n(r)})},ZZ=function(e){qE(window,"resize",e)},eee=function(e){qE(document.fonts,"loadingdone",e)},tee=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],nee=function(e,n){var r=e.cacheMeasurements,i=e.maxRows,s=e.minRows,o=e.onChange,a=o===void 0?nI:o,c=e.onHeightChange,h=c===void 0?nI:c,f=nB(e,tee),d=f.value!==void 0,m=k.useRef(null),y=HZ(m,n),b=k.useRef(0),x=k.useRef(),S=function(){var E=m.current,P=r&&x.current?x.current:JZ(E);if(P){x.current=P;var O=qZ(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),QZ(m,function(){if(!d){var A=m.current.value;requestAnimationFrame(function(){var E=m.current;E&&A!==E.value&&S()})}}),ZZ(S),eee(S),k.createElement("textarea",Gp({},f,{onChange:_,ref:y}))},ree=k.forwardRef(nee),rB=t=>{const e=Lr(t),n=jY(r=>r.onScrollToBottom);k.useEffect(()=>n(e),[n,e])},iB=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=ki(),x=Mt(({composer:N})=>N.isEditing?N.text:""),S=e?rj:ree,_=Mt(({thread:N})=>N.isDisabled)||n,A=k.useRef(null),E=Bt(y,A);cj(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]),rB(()=>{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)})});iB.displayName="ComposerPrimitive.Input";var iee=()=>{const t=ki(),e=Mt(({composer:r})=>!r.canCancel),n=k.useCallback(()=>{t.composer().cancel()},[t]);return e?null:n},see=lj("ComposerPrimitive.Cancel",iee),sB=k.forwardRef((t,e)=>C.jsx(st.div,{role:"alert",...t,ref:e}));sB.displayName="ErrorPrimitive.Root";var oB=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)})});oB.displayName="ErrorPrimitive.Message";var aB=k.forwardRef((t,e)=>C.jsx(st.div,{...t,ref:e}));aB.displayName="ThreadPrimitive.Root";var lB=({children:t})=>Mt(({thread:n})=>n.messages.length===0)?t:null;lB.displayName="ThreadPrimitive.Empty";var oee=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)),Qb=({children:t,...e})=>oee(e)?t:null;Qb.displayName="ThreadPrimitive.If";var aee=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 UE(n)},lee=({autoScroll:t=!0})=>{const e=k.useRef(null),n=U5(),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&&qb(n).setState({isAtBottom:m})),r.current=f.scrollTop},a=aee(()=>{(i.current||n.getState().isAtBottom)&&s("instant"),o()}),c=UE(f=>(f.addEventListener("scroll",o),()=>{f.removeEventListener("scroll",o)}));return rB(()=>{s("auto")}),OX("thread.run-start",()=>s("auto")),Bt(a,c,e)},cB=k.forwardRef(({autoScroll:t,children:e,...n},r)=>{const i=lee({autoScroll:t}),s=Bt(r,i);return C.jsx(st.div,{...n,ref:s,children:e})});cB.displayName="ThreadPrimitive.ViewportScrollable";var Y2=k.forwardRef((t,e)=>C.jsx(H5,{children:C.jsx(cB,{...t,ref:e})}));Y2.displayName="ThreadPrimitive.Viewport";var uB=(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,cee=()=>null,uee=(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??cee;default:const r=e;throw new Error(`Unknown message role: ${r}`)}},hee=({components:t})=>{const e=Mt(({message:i})=>i.role),n=Mt(({message:i})=>i.composer.isEditing),r=uee(t,e,n);return C.jsx(r,{})},hB=k.memo(({index:t,components:e})=>C.jsx(kX,{index:t,children:C.jsx(hee,{components:e})}),(t,e)=>t.index===e.index&&uB(t.components,e.components));hB.displayName="ThreadPrimitive.MessageByIndex";var fB=({components:t})=>{const e=Mt(({thread:r})=>r.messages.length);return k.useMemo(()=>e===0?null:Array.from({length:e},(r,i)=>C.jsx(hB,{index:i,components:t},i)),[e,t])};fB.displayName="ThreadPrimitive.Messages";var fee=k.memo(fB,(t,e)=>uB(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 dB=function(){const{crypto:t}=globalThis;if(t?.randomUUID)return dB=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 X2=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 Ti=class J2 extends nt{constructor(e,n,r,i){super(`${J2.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 Ox({message:r,cause:X2(n)});const s=n;return e===400?new mB(e,s,r,i):e===401?new gB(e,s,r,i):e===403?new yB(e,s,r,i):e===404?new bB(e,s,r,i):e===409?new vB(e,s,r,i):e===422?new xB(e,s,r,i):e===429?new wB(e,s,r,i):e>=500?new SB(e,s,r,i):new J2(e,s,r,i)}},gs=class extends Ti{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},Ox=class extends Ti{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}},pB=class extends Ox{constructor({message:e}={}){super({message:e??"Request timed out."})}},mB=class extends Ti{},gB=class extends Ti{},yB=class extends Ti{},bB=class extends Ti{},vB=class extends Ti{},xB=class extends Ti{},wB=class extends Ti{},SB=class extends Ti{};const dee=/^[a-z][a-z0-9+.-]*:/i,pee=t=>dee.test(t);let Q2=t=>(Q2=Array.isArray,Q2(t)),rI=Q2;function iI(t){return typeof t!="object"?{}:t??{}}function mee(t){if(!t)return!0;for(const e in t)return!1;return!0}function gee(t,e){return Object.prototype.hasOwnProperty.call(t,e)}const yee=(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},_B=t=>{try{return JSON.parse(t)}catch{return}},bee=t=>new Promise(e=>setTimeout(e,t)),Hu="0.60.0",vee=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function xee(){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 wee=()=>{const t=xee();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Hu,"X-Stainless-OS":oI(Deno.build.os),"X-Stainless-Arch":sI(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":oI(globalThis.process.platform??"unknown"),"X-Stainless-Arch":sI(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const e=See();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 See(){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 sI=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",oI=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 aI;const _ee=()=>aI??(aI=wee());function Cee(){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 CB(...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 AB(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return CB({start(){},async pull(n){const{done:r,value:i}=await e.next();r?n.close():n.enqueue(i)},async cancel(){await e.return?.()}})}function GE(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 Aee(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 Eee=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});function kee(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 lI;function KE(t){let e;return(lI??(e=new globalThis.TextEncoder,lI=e.encode.bind(e)))(t)}let cI;function uI(t){let e;return(cI??(e=new globalThis.TextDecoder,cI=e.decode.bind(e)))(t)}var pi,mi;let Im=class{constructor(){pi.set(this,void 0),mi.set(this,void 0),Ye(this,pi,new Uint8Array),Ye(this,mi,null)}decode(e){if(e==null)return[];const n=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?KE(e):e;Ye(this,pi,kee([pe(this,pi,"f"),n]));const r=[];let i;for(;(i=Tee(pe(this,pi,"f"),pe(this,mi,"f")))!=null;){if(i.carriage&&pe(this,mi,"f")==null){Ye(this,mi,i.index);continue}if(pe(this,mi,"f")!=null&&(i.index!==pe(this,mi,"f")+1||i.carriage)){r.push(uI(pe(this,pi,"f").subarray(0,pe(this,mi,"f")-1))),Ye(this,pi,pe(this,pi,"f").subarray(pe(this,mi,"f"))),Ye(this,mi,null);continue}const s=pe(this,mi,"f")!==null?i.preceding-1:i.preceding,o=uI(pe(this,pi,"f").subarray(0,s));r.push(o),Ye(this,pi,pe(this,pi,"f").subarray(i.index)),Ye(this,mi,null)}return r}flush(){return pe(this,pi,"f").length?this.decode(`
|
||
`):[]}};pi=new WeakMap,mi=new WeakMap;Im.NEWLINE_CHARS=new Set([`
|
||
`,"\r"]);Im.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Tee(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 Ree(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 Zb={off:0,error:200,warn:300,info:400,debug:500},hI=(t,e,n)=>{if(t){if(gee(Zb,t))return t;kr(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(Zb))}`)}};function Ud(){}function $0(t,e,n){return!e||Zb[t]>Zb[n]?Ud:e[t].bind(e)}const Mee={error:Ud,warn:Ud,info:Ud,debug:Ud};let fI=new WeakMap;function kr(t){const e=t.logger,n=t.logLevel??"off";if(!e)return Mee;const r=fI.get(e);if(r&&r[0]===n)return r[1];const i={error:$0("error",e,n),warn:$0("warn",e,n),info:$0("info",e,n),debug:$0("debug",e,n)};return fI.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 Oee(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 Ti(void 0,_B(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=GE(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 CB({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=KE(JSON.stringify(i)+`
|
||
`);r.enqueue(o)}catch(i){r.error(i)}},async cancel(){await n.return?.()}})}};async function*Oee(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 Dee,r=new Im,i=GE(t.body);for await(const s of Pee(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*Pee(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"?KE(n):n;let i=new Uint8Array(e.length+r.length);i.set(e),i.set(r,e.length),e=i;let s;for(;(s=Ree(e))!==-1;)yield e.slice(0,s),e=e.slice(s)}e.length>0&&(yield e)}let Dee=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]=Iee(e,":");return i.startsWith(" ")&&(i=i.substring(1)),n==="event"?this.event=i:n==="data"&&this.data.push(i),null}};function Iee(t,e){const n=t.indexOf(e);return n!==-1?[t.substring(0,n),e,t.substring(n+e.length)]:[t,"",""]}async function EB(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 kB(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 kB(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 TB=class RB extends Promise{constructor(e,n,r=EB){super(i=>{i(null)}),this.responsePromise=n,this.parseResponse=r,Wd.set(this,void 0),Ye(this,Wd,e)}_thenUnwrap(e){return new RB(pe(this,Wd,"f"),this.responsePromise,async(n,r)=>kB(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 j0;let Lee=class{constructor(e,n,r,i){j0.set(this,void 0),Ye(this,j0,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,j0,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(j0=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const n of e.getPaginatedItems())yield n}},Nee=class extends TB{constructor(e,n,r){super(e,n,async(i,s)=>new r(i,s.response,await EB(i,s),s.options))}async*[Symbol.asyncIterator](){const e=await this;for await(const n of e)yield n}},Lm=class extends Lee{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:{...iI(this.options.query),before_id:n}}:null}const e=this.last_id;return e?{...this.options,query:{...iI(this.options.query),after_id:e}}:null}};const MB=()=>{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 MB(),new File(t,e??"unknown_file",n)}function ob(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 OB=t=>t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function",$ee=async(t,e)=>({...t,body:await Bee(t.body,e)}),dI=new WeakMap;function jee(t){const e=typeof t=="function"?t:t.fetch,n=dI.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 dI.set(e,r),r}const Bee=async(t,e)=>{if(!await jee(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])=>Z2(n,r,i))),n},Fee=t=>t instanceof Blob&&"name"in t,Z2=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()],ob(n),r))}else if(OB(n))t.append(e,gh([await new Response(AB(n)).blob()],ob(n)));else if(Fee(n))t.append(e,gh([n],ob(n),{type:n.type}));else if(Array.isArray(n))await Promise.all(n.map(r=>Z2(t,e+"[]",r)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([r,i])=>Z2(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`)}},PB=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",zee=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&PB(t),Vee=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function Uee(t,e,n){if(MB(),t=await t,e||(e=ob(t)),zee(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(Vee(t)){const i=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),gh(await eC(i),e,n)}const r=await eC(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 eC(t){let e=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)e.push(t);else if(PB(t))e.push(t instanceof Blob?t:await t.arrayBuffer());else if(OB(t))for await(const n of t)e.push(...await eC(n));else{const n=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${n?`; constructor: ${n}`:""}${Hee(t)}`)}return e}function Hee(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(n=>`"${n}"`).join(", ")}]`}let ia=class{constructor(e){this._client=e}};const DB=Symbol.for("brand.privateNullableHeaders");function*Wee(t){if(!t)return;if(DB 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():rI(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=rI(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 Wee(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{[DB]:!0,values:e,nulls:n}};function IB(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const pI=Object.freeze(Object.create(null)),qee=(t=IB)=>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??pI)??pI)?.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},bs=qee(IB);let LB=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(bs`/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(bs`/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(bs`/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",$ee({body:i,...n,headers:zt([{"anthropic-beta":[...r??[],"files-api-2025-04-14"].toString()},n?.headers])},this._client))}},NB=class extends ia{retrieve(e,n={},r){const{betas:i}=n??{};return this._client.get(bs`/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 Px{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 Px(GE(e.body),n)}}let $B=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(bs`/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(bs`/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(bs`/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)=>Px.fromResponse(a.response,a.controller))}};const Gee=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},Kee=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},Yee=t=>{let e="";return t.map(n=>{switch(n.type){case"string":e+='"'+n.value+'"';break;default:e+=n.value;break}}),e},jB=t=>JSON.parse(Yee(Kee(Wu(Gee(t)))));var Bi,za,gd,B0,yd,bd,F0,vd,jo,xd,z0,V0,Pu,U0,H0,qS,mI,W0,GS,KS,YS,gI;const yI="__json_buf";function bI(t){return t.type==="tool_use"||t.type==="server_tool_use"||t.type==="mcp_tool_use"}class ev{constructor(){Bi.add(this),this.messages=[],this.receivedMessages=[],za.set(this,void 0),this.controller=new AbortController,gd.set(this,void 0),B0.set(this,()=>{}),yd.set(this,()=>{}),bd.set(this,void 0),F0.set(this,()=>{}),vd.set(this,()=>{}),jo.set(this,{}),xd.set(this,!1),z0.set(this,!1),V0.set(this,!1),Pu.set(this,!1),U0.set(this,void 0),H0.set(this,void 0),W0.set(this,e=>{if(Ye(this,z0,!0),Kp(e)&&(e=new gs),e instanceof gs)return Ye(this,V0,!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,B0,e,"f"),Ye(this,yd,n,"f")})),Ye(this,bd,new Promise((e,n)=>{Ye(this,F0,e,"f"),Ye(this,vd,n,"f")})),pe(this,gd,"f").catch(()=>{}),pe(this,bd,"f").catch(()=>{})}get response(){return pe(this,U0,"f")}get request_id(){return pe(this,H0,"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 ev;return n._run(()=>n._fromReadableStream(e)),n}static createMessage(e,n,r){const i=new ev;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,W0,"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,Bi,"m",GS).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,Bi,"m",KS).call(this,c);if(a.controller.signal?.aborted)throw new gs;pe(this,Bi,"m",YS).call(this)}finally{i&&s&&i.removeEventListener("abort",s)}}_connected(e){this.ended||(Ye(this,U0,e),Ye(this,H0,e?.headers.get("request-id")),pe(this,B0,"f").call(this,e),this._emit("connect"))}get ended(){return pe(this,xd,"f")}get errored(){return pe(this,z0,"f")}get aborted(){return pe(this,V0,"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,Bi,"m",qS).call(this)}async finalText(){return await this.done(),pe(this,Bi,"m",mI).call(this)}_emit(e,...n){if(pe(this,xd,"f"))return;e==="end"&&(Ye(this,xd,!0),pe(this,F0,"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,Bi,"m",qS).call(this))}async _fromReadableStream(e,n){const r=n?.signal;let i;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener("abort",i));try{pe(this,Bi,"m",GS).call(this),this._connected(null);const s=Yp.fromReadableStream(e,this.controller);for await(const o of s)pe(this,Bi,"m",KS).call(this,o);if(s.controller.signal?.aborted)throw new gs;pe(this,Bi,"m",YS).call(this)}finally{r&&i&&r.removeEventListener("abort",i)}}[(za=new WeakMap,gd=new WeakMap,B0=new WeakMap,yd=new WeakMap,bd=new WeakMap,F0=new WeakMap,vd=new WeakMap,jo=new WeakMap,xd=new WeakMap,z0=new WeakMap,V0=new WeakMap,Pu=new WeakMap,U0=new WeakMap,H0=new WeakMap,W0=new WeakMap,Bi=new WeakSet,qS=function(){if(this.receivedMessages.length===0)throw new nt("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},mI=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(" ")},GS=function(){this.ended||Ye(this,za,void 0)},KS=function(n){if(this.ended)return;const r=pe(this,Bi,"m",gI).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":{bI(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}}},YS=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},gI=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&&bI(i)){let s=i[yI]||"";s+=n.delta.partial_json;const o={...i};if(Object.defineProperty(o,yI,{value:s,enumerable:!1,writable:!0}),s)try{o.input=jB(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,W0,"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 BB={"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},vI={"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 YE=class extends ia{constructor(){super(...arguments),this.batches=new $B(this._client)}create(e,n){const{betas:r,...i}=e;i.model in vI&&console.warn(`The model '${i.model}' is deprecated and will reach end-of-life on ${vI[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=BB[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 ev.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])})}};YE.Batches=$B;let Nm=class extends ia{constructor(){super(...arguments),this.models=new NB(this._client),this.messages=new YE(this._client),this.files=new LB(this._client)}};Nm.Models=NB;Nm.Messages=YE;Nm.Files=LB;let FB=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 Fi,Va,wd,q0,Sd,_d,G0,Cd,Bo,Ad,K0,Y0,Du,X0,J0,XS,xI,JS,QS,ZS,e_,wI;const SI="__json_buf";function _I(t){return t.type==="tool_use"||t.type==="server_tool_use"}class tv{constructor(){Fi.add(this),this.messages=[],this.receivedMessages=[],Va.set(this,void 0),this.controller=new AbortController,wd.set(this,void 0),q0.set(this,()=>{}),Sd.set(this,()=>{}),_d.set(this,void 0),G0.set(this,()=>{}),Cd.set(this,()=>{}),Bo.set(this,{}),Ad.set(this,!1),K0.set(this,!1),Y0.set(this,!1),Du.set(this,!1),X0.set(this,void 0),J0.set(this,void 0),JS.set(this,e=>{if(Ye(this,K0,!0),Kp(e)&&(e=new gs),e instanceof gs)return Ye(this,Y0,!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,q0,e,"f"),Ye(this,Sd,n,"f")})),Ye(this,_d,new Promise((e,n)=>{Ye(this,G0,e,"f"),Ye(this,Cd,n,"f")})),pe(this,wd,"f").catch(()=>{}),pe(this,_d,"f").catch(()=>{})}get response(){return pe(this,X0,"f")}get request_id(){return pe(this,J0,"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 tv;return n._run(()=>n._fromReadableStream(e)),n}static createMessage(e,n,r){const i=new tv;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,JS,"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",QS).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",ZS).call(this,c);if(a.controller.signal?.aborted)throw new gs;pe(this,Fi,"m",e_).call(this)}finally{i&&s&&i.removeEventListener("abort",s)}}_connected(e){this.ended||(Ye(this,X0,e),Ye(this,J0,e?.headers.get("request-id")),pe(this,q0,"f").call(this,e),this._emit("connect"))}get ended(){return pe(this,Ad,"f")}get errored(){return pe(this,K0,"f")}get aborted(){return pe(this,Y0,"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,Fi,"m",XS).call(this)}async finalText(){return await this.done(),pe(this,Fi,"m",xI).call(this)}_emit(e,...n){if(pe(this,Ad,"f"))return;e==="end"&&(Ye(this,Ad,!0),pe(this,G0,"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,Fi,"m",XS).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",QS).call(this),this._connected(null);const s=Yp.fromReadableStream(e,this.controller);for await(const o of s)pe(this,Fi,"m",ZS).call(this,o);if(s.controller.signal?.aborted)throw new gs;pe(this,Fi,"m",e_).call(this)}finally{r&&i&&r.removeEventListener("abort",i)}}[(Va=new WeakMap,wd=new WeakMap,q0=new WeakMap,Sd=new WeakMap,_d=new WeakMap,G0=new WeakMap,Cd=new WeakMap,Bo=new WeakMap,Ad=new WeakMap,K0=new WeakMap,Y0=new WeakMap,Du=new WeakMap,X0=new WeakMap,J0=new WeakMap,JS=new WeakMap,Fi=new WeakSet,XS=function(){if(this.receivedMessages.length===0)throw new nt("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},xI=function(){if(this.receivedMessages.length===0)throw new nt("stream ended without producing a Message with role=assistant");const n=this.receivedMessages.at(-1).content.filter(r=>r.type==="text").map(r=>r.text);if(n.length===0)throw new nt("stream ended without producing a content block with type=text");return n.join(" ")},QS=function(){this.ended||Ye(this,Va,void 0)},ZS=function(n){if(this.ended)return;const r=pe(this,Fi,"m",wI).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":{_I(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}}},e_=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},wI=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&&_I(i)){let s=i[SI]||"";s+=n.delta.partial_json;const o={...i};Object.defineProperty(o,SI,{value:s,enumerable:!1,writable:!0}),s&&(o.input=jB(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 zB=class extends ia{create(e,n){return this._client.post("/v1/messages/batches",{body:e,...n})}retrieve(e,n){return this._client.get(bs`/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(bs`/v1/messages/batches/${e}`,n)}cancel(e,n){return this._client.post(bs`/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)=>Px.fromResponse(s.response,s.controller))}},XE=class extends ia{constructor(){super(...arguments),this.batches=new zB(this._client)}create(e,n){e.model in CI&&console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${CI[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=BB[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 tv.createMessage(this,e,n)}countTokens(e,n){return this._client.post("/v1/messages/count_tokens",{body:e,...n})}};const CI={"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"};XE.Batches=zB;let VB=class extends ia{retrieve(e,n={},r){const{betas:i}=n??{};return this._client.get(bs`/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 Xee={};const Q0=t=>{if(typeof globalThis.process<"u")return Xee?.[t]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(t)?.trim()};var tC,JE,ab,UB;class bn{constructor({baseURL:e=Q0("ANTHROPIC_BASE_URL"),apiKey:n=Q0("ANTHROPIC_API_KEY")??null,authToken:r=Q0("ANTHROPIC_AUTH_TOKEN")??null,...i}={}){tC.add(this),ab.set(this,void 0);const s={apiKey:n,authToken:r,...i,baseURL:e||"https://api.anthropic.com"};if(!s.dangerouslyAllowBrowser&&vee())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??JE.DEFAULT_TIMEOUT,this.logger=s.logger??console;const o="warn";this.logLevel=o,this.logLevel=hI(s.logLevel,"ClientOptions.logLevel",this)??hI(Q0("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??o,this.fetchOptions=s.fetchOptions,this.maxRetries=s.maxRetries??2,this.fetch=s.fetch??Cee(),Ye(this,ab,Eee),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-${dB()}`}makeStatusError(e,n,r,i){return Ti.generate(e,n,r,i)}buildURL(e,n,r){const i=!pe(this,tC,"m",UB).call(this)&&r||this.baseURL,s=pee(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();return mee(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 TB(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 gs;const m=new AbortController,y=await this.fetchWithTimeout(a,o,c,m).catch(X2),b=Date.now();if(y instanceof Error){const _=`retrying, ${n} attempts remaining`;if(i.signal?.aborted)throw new gs;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 pB:new Ox({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 Aee(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=>X2(D).message),P=_B(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 Nee(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 bee(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&&yee("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))}:{},..._ee(),...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:AB(e)}:pe(this,ab,"f").call(this,{body:e,headers:r})}}JE=bn,ab=new WeakMap,tC=new WeakSet,UB=function(){return this.baseURL!=="https://api.anthropic.com"};bn.Anthropic=JE;bn.HUMAN_PROMPT=`
|
||
|
||
Human:`;bn.AI_PROMPT=`
|
||
|
||
Assistant:`;bn.DEFAULT_TIMEOUT=6e5;bn.AnthropicError=nt;bn.APIError=Ti;bn.APIConnectionError=Ox;bn.APIConnectionTimeoutError=pB;bn.APIUserAbortError=gs;bn.NotFoundError=bB;bn.ConflictError=vB;bn.RateLimitError=wB;bn.BadRequestError=mB;bn.AuthenticationError=gB;bn.InternalServerError=SB;bn.PermissionDeniedError=yB;bn.UnprocessableEntityError=xB;bn.toFile=Uee;class al extends bn{constructor(){super(...arguments),this.completions=new FB(this),this.messages=new XE(this),this.models=new VB(this),this.beta=new Nm(this)}}al.Completions=FB;al.Messages=XE;al.Models=VB;al.Beta=Nm;const{HUMAN_PROMPT:Q8e,AI_PROMPT:Z8e}=al;var qd={exports:{}};qd.exports;var AI;function Jee(){return AI||(AI=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 k0=="object"&&k0&&k0.Object===Object&&k0,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 Yt($,Q){for(var le=-1,Oe=Q.length,Wt=$.length;++le<Oe;)$[Wt+le]=Q[le];return $}function Xt($,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 ei($){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 is($,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,Os=Object.prototype,Ps=L["__core-js_shared__"],Bc=(function(){var $=/[^.]+$/.exec(Ps&&Ps.keys&&Ps.keys.IE_PROTO||"");return $?"Symbol(src)_1."+$:""})(),Tl=kl.toString,Ri=Os.hasOwnProperty,aa=Os.toString,oe=RegExp("^"+Tl.call(Ri).replace(z,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),me=ye?L.Buffer:void 0,De=L.Symbol,$e=L.Uint8Array,gt=is(Object.getPrototypeOf,Object),Sr=Object.create,ss=Os.propertyIsEnumerable,rr=lf.splice,ti=Object.getOwnPropertySymbols,_r=me?me.isBuffer:void 0,an=is(Object.keys,Object),ir=ri(L,"DataView"),Bn=ri(L,"Map"),Fc=ri(L,"Promise"),zc=ri(L,"Set"),Rl=ri(L,"WeakMap"),os=ri(Object,"create"),Tw=Br(ir),cg=Br(Bn),ug=Br(Fc),cf=Br(zc),uf=Br(Rl),hf=De?De.prototype:void 0,hg=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__=os?os(null):{}}function or($){return this.has($)&&delete this.__data__[$]}function la($){var Q=this.__data__;if(os){var le=Q[$];return le===r?void 0:le}return Ri.call(Q,$)?Q[$]:void 0}function ff($){var Q=this.__data__;return os?Q[$]!==void 0:Ri.call(Q,$)}function Rw($,Q){var le=this.__data__;return le[$]=os&&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=Rw;function as($){var Q=-1,le=$?$.length:0;for(this.clear();++Q<le;){var Oe=$[Q];this.set(Oe[0],Oe[1])}}function fg(){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}as.prototype.clear=fg,as.prototype.delete=Ml,as.prototype.get=df,as.prototype.has=ca,as.prototype.set=ua;function Mi($){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||as),string:new sr}}function ln($){return Ol(this,$).delete($)}function dg($){return Ol(this,$).get($)}function pg($){return Ol(this,$).has($)}function Co($,Q){return Ol(this,$).set($,Q),this}Mi.prototype.clear=ha,Mi.prototype.delete=ln,Mi.prototype.get=dg,Mi.prototype.has=pg,Mi.prototype.set=Co;function ni($){this.__data__=new as($)}function Mw(){this.__data__=new as}function mg($){return this.__data__.delete($)}function gg($){return this.__data__.get($)}function Ow($){return this.__data__.has($)}function Vc($,Q){var le=this.__data__;if(le instanceof as){var Oe=le.__data__;if(!Bn||Oe.length<n-1)return Oe.push([$,Q]),this;le=this.__data__=new Mi(Oe)}return le.set($,Q),this}ni.prototype.clear=Mw,ni.prototype.delete=mg,ni.prototype.get=gg,ni.prototype.has=Ow,ni.prototype.set=Vc;function Uc($,Q){var le=Yc($)||wf($)?er($.length,String):[],Oe=le.length,Wt=!!Oe;for(var ar in $)Ri.call($,ar)&&!(Wt&&(ar=="length"||Lw(ar,Oe)))&&le.push(ar);return le}function Oi($,Q,le){var Oe=$[Q];(!(Ri.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 yg($,Q){return $&&qc(Q,Jc(Q),$)}function Ds($,Q,le,Oe,Wt,ar,ii){var On;if(Oe&&(On=ar?Oe($,Wt,ar,ii):Oe($)),On!==void 0)return On;if(!ya($))return $;var ba=Yc($);if(ba){if(On=Cg($),!Q)return wg($,On)}else{var cs=Is($),_f=cs==f||cs==d;if(Sf($))return vg($,Q);if(cs==b||cs==s||_f&&!ar){if(ei($))return ar?$:{};if(On=bf(_f?{}:$),!Q)return da($,yg(On,$))}else{if(!T[cs])return ar?$:{};On=Iw($,cs,Ds,Q)}}ii||(ii=new ni);var Ag=ii.get($);if(Ag)return Ag;if(ii.set($,On),!ba)var Eg=le?Sg($):Jc($);return Pt(Eg||$,function(Cf,va){Eg&&(va=Cf,Cf=$[va]),Oi(On,va,Ds(Cf,Q,le,Oe,va,$,ii))}),On}function pf($){return ya($)?Sr($):{}}function mf($,Q,le){var Oe=Q($);return Yc($)?Oe:Yt(Oe,le($))}function Pw($){return aa.call($)}function bg($){if(!ya($)||vf($))return!1;var Q=ga($)||ei($)?oe:U;return Q.test(Br($))}function $r($){if(!Kc($))return an($);var Q=[];for(var le in Object($))Ri.call($,le)&&le!="constructor"&&Q.push(le);return Q}function vg($,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 xg($,Q,le){var Oe=Q?le(_o($),!0):_o($);return Xt(Oe,Ee,new $.constructor)}function Wc($){var Q=new $.constructor($.source,G.exec($));return Q.lastIndex=$.lastIndex,Q}function Dw($,Q,le){var Oe=Q?le(nr($),!0):nr($);return Xt(Oe,Ue,new $.constructor)}function jr($){return hg?Object(hg.call($)):{}}function yf($,Q){var le=Q?gf($.buffer):$.buffer;return new $.constructor(le,$.byteOffset,$.length)}function wg($,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 ii=Q[Wt],On=void 0;Oi(le,ii,On===void 0?$[ii]:On)}return le}function da($,Q){return qc($,_g($),Q)}function Sg($){return mf($,Jc,_g)}function Ol($,Q){var le=$.__data__;return Gc(Q)?le[typeof Q=="string"?"string":"hash"]:le.map}function ri($,Q){var le=tr($,Q);return bg(le)?le:void 0}var _g=ti?is(ti,Object):Qc,Is=Pw;(ir&&Is(new ir(new ArrayBuffer(1)))!=M||Bn&&Is(new Bn)!=m||Fc&&Is(Fc.resolve())!=x||zc&&Is(new zc)!=_||Rl&&Is(new Rl)!=P)&&(Is=function($){var Q=aa.call($),le=Q==b?$.constructor:void 0,Oe=le?Br(le):void 0;if(Oe)switch(Oe){case Tw:return M;case cg:return m;case ug:return x;case cf:return _;case uf:return P}return Q});function Cg($){var Q=$.length,le=$.constructor(Q);return Q&&typeof $[0]=="string"&&Ri.call($,"index")&&(le.index=$.index,le.input=$.input),le}function bf($){return typeof $.constructor=="function"&&!Kc($)?pf(gt($)):{}}function Iw($,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 xg($,Oe,le);case y:case A:return new Wt($);case S:return Wc($);case _:return Dw($,Oe,le);case E:return jr($)}}function Lw($,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||Os;return $===le}function Br($){if($!=null){try{return Tl.call($)}catch{}try{return $+""}catch{}}return""}function pa($){return Ds($,!0,!0)}function xf($,Q){return $===Q||$!==$&&Q!==Q}function wf($){return ls($)&&Ri.call($,"callee")&&(!ss.call($,"callee")||aa.call($)==s)}var Yc=Array.isArray;function ma($){return $!=null&&Ls($.length)&&!ga($)}function ls($){return Xc($)&&ma($)}var Sf=_r||Zc;function ga($){var Q=ya($)?aa.call($):"";return Q==f||Q==d}function Ls($){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 Qee=Jee();const mo=Pc(Qee),Zee=`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 user’s request clearly indicates the need for it (e.g., "search", "open URL", "analyze file", "plot data", etc.).
|
||
If the user’s 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 you’re doing if appropriate.
|
||
Otherwise, behave as if you are a standalone LLM chat without tools`,Dx=`You are an assistant that generates short, clear chat titles.
|
||
|
||
Instructions:
|
||
|
||
Read the user’s message.
|
||
|
||
Create a concise chat title summarizing the topic.
|
||
|
||
Limit the title to 3–7 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`,ete=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},tte=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=ete(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},nte=t=>{const{message:e}=t;return{role:e.role,content:[]}},rte=(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},ite=(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 ste{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=tte(e)};async createChatName(e){try{return this.client?(await this.client.messages.create({messages:[{role:"user",content:e}],model:this.modelKey,system:Dx,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:2048,tool_choice:{disable_parallel_tool_use:!0,type:"auto"}});this.prevMessages.push(...i);let o=n&&r?mo(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=nte(a)}if(c==="content_block_start"&&(o=rte(a,o)),c==="content_block_delta"&&(o=ite(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 EI=new ste;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 ote(t){return t&&DataView.prototype.isPrototypeOf(t)}if(Rr.arrayBuffer)var ate=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],lte=ArrayBuffer.isView||function(t){return t&&ate.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 QE(t){return typeof t!="string"&&(t=String(t)),t}function ZE(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=QE(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)]=QE(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)}),ZE(t)};Tn.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),ZE(t)};Tn.prototype.entries=function(){var t=[];return this.forEach(function(e,n){t.push([n,e])}),ZE(t)};Rr.iterable&&(Tn.prototype[Symbol.iterator]=Tn.prototype.entries);function t_(t){if(!t._noBody){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}}function HB(t){return new Promise(function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}})}function cte(t){var e=new FileReader,n=HB(e);return e.readAsArrayBuffer(t),n}function ute(t){var e=new FileReader,n=HB(e),r=/charset=([A-Za-z0-9_-]+)/.exec(t.type),i=r?r[1]:"utf-8";return e.readAsText(t,i),n}function hte(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 kI(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function WB(){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&&ote(t)?(this._bodyArrayBuffer=kI(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Rr.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||lte(t))?this._bodyArrayBuffer=kI(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=t_(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=t_(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(cte);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var t=t_(this);if(t)return t;if(this._bodyBlob)return ute(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(hte(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(pte)}),this.json=function(){return this.text().then(JSON.parse)},this}var fte=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function dte(t){var e=t.toUpperCase();return fte.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=dte(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 pte(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 mte(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}WB.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)}WB.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 gte=[301,302,303,307,308];go.redirect=function(t,e){if(gte.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 qB(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:mte(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,QE(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)})}qB.polyfill=!0;Kn.fetch||(Kn.fetch=qB,Kn.Headers=Tn,Kn.Request=Sc,Kn.Response=go);const GB="11434",KB=`http://127.0.0.1:${GB}`,yte="0.5.18";var bte=Object.defineProperty,vte=(t,e,n)=>e in t?bte(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,n_=(t,e,n)=>(vte(t,typeof e!="symbol"?e+"":e,n),n);class ek extends Error{constructor(e,n){super(e),this.error=e,this.status_code=n,this.name="ResponseError",Error.captureStackTrace&&Error.captureStackTrace(this,ek)}}class xte{constructor(e,n,r){n_(this,"abortController"),n_(this,"itr"),n_(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 tk=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 ek(e,t.status)};function wte(){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 Ste(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 nk=async(t,e,n={})=>{const r={"Content-Type":"application/json",Accept:"application/json","User-Agent":`ollama-js/${yte} (${wte()})`};n.headers=Ste(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)},TI=async(t,e,n)=>{const r=await nk(t,e,{headers:n?.headers});return await tk(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 nk(t,e,{method:"POST",body:s,signal:r?.signal,headers:r?.headers});return await tk(o),o},_te=async(t,e,n,r)=>{const i=await nk(t,e,{method:"DELETE",body:JSON.stringify(n),headers:r?.headers});return await tk(i),i},Cte=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)}},Ate=t=>{if(!t)return KB;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=GB);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 Ete=Object.defineProperty,kte=(t,e,n)=>e in t?Ete(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,r_=(t,e,n)=>(kte(t,typeof e!="symbol"?e+"":e,n),n);let lb=class{constructor(e){r_(this,"config"),r_(this,"fetch"),r_(this,"ongoingStreamedRequests",[]),this.config={host:"",headers:e?.headers},e?.proxy||(this.config.host=Ate(e?.host??KB)),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=Cte(o.body),c=new xte(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 _te(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 TI(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 TI(this.fetch,`${this.config.host}/api/ps`,{headers:this.config.headers})).json()}};new lb;const vp="<TOOL_CALL>",nv="</TOOL_CALL>",Tte=t=>t.map(e=>({type:"string",function:{name:e.name,description:e.description,parameters:e.inputSchema}})),Rte=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}
|
||
${nv}
|
||
|
||
Do not add explanations, markdown, or extra text outside the tags.`,e},RI=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}${nv}`}}).join(""):"",s=typeof n.content=="string"?n.content:i;e.push({role:"assistant",content:s}),r&&e.push({role:"user",content:r})}}),e},Mte=t=>{let e=!1,n=!1,r="";if(t.includes(vp)&&(e=!0,r=t.split(vp)[1]),!e)return{content:t};t.includes(nv)&&(n=!0,r=r.split(nv)[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 Ote{modelKey="";systemPrompt="";apiKey;url;provider;prevMessages=[];tools=[];client;messageStopped=!1;constructor(){}setProvider=e=>{this.provider=e,this.client=new lb({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=RI(e)};setTools=e=>{this.tools=Tte(e)};async createChatName(e){try{if(!this.client)return"";const n={role:"system",content:Dx};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=RI(e),s=Rte(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?mo(r):{role:"assistant",content:[]};let h="";for await(const f of a){h+=f.message.content;const{toolContent:d,content:m}=Mte(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 lb({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 lb({host:e.url}).list()).models.map(i=>({id:i.model,name:i.name,provider:"ollama"}))}const MI=new Ote;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 YB=function(){const{crypto:t}=globalThis;if(t?.randomUUID)return YB=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 nC(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}const rC=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 Jr=class iC extends Ie{constructor(e,n,r,i){super(`${iC.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 Ix({message:r,cause:rC(n)});const s=n?.error;return e===400?new XB(e,s,r,i):e===401?new JB(e,s,r,i):e===403?new QB(e,s,r,i):e===404?new ZB(e,s,r,i):e===409?new e8(e,s,r,i):e===422?new t8(e,s,r,i):e===429?new n8(e,s,r,i):e>=500?new r8(e,s,r,i):new iC(e,s,r,i)}},qi=class extends Jr{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},Ix=class extends Jr{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}},rk=class extends Ix{constructor({message:e}={}){super({message:e??"Request timed out."})}},XB=class extends Jr{},JB=class extends Jr{},QB=class extends Jr{},ZB=class extends Jr{},e8=class extends Jr{},t8=class extends Jr{},n8=class extends Jr{},r8=class extends Jr{};class i8 extends Ie{constructor(){super("Could not parse response content as the length limit was reached")}}class s8 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 Pte=/^[a-z][a-z0-9+.-]*:/i,Dte=t=>Pte.test(t);let Hr=t=>(Hr=Array.isArray,Hr(t)),OI=Hr;function o8(t){return typeof t!="object"?{}:t??{}}function Ite(t){if(!t)return!0;for(const e in t)return!1;return!0}function Lte(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function i_(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}const Nte=(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},$te=t=>{try{return JSON.parse(t)}catch{return}},$m=t=>new Promise(e=>setTimeout(e,t)),qu="5.22.0",jte=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Bte(){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 Fte=()=>{const t=Bte();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":qu,"X-Stainless-OS":DI(Deno.build.os),"X-Stainless-Arch":PI(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":DI(globalThis.process.platform??"unknown"),"X-Stainless-Arch":PI(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const e=zte();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 zte(){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 PI=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",DI=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 II;const Vte=()=>II??(II=Fte());function Ute(){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 a8(...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 l8(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return a8({start(){},async pull(n){const{done:r,value:i}=await e.next();r?n.close():n.enqueue(i)},async cancel(){await e.return?.()}})}function c8(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 Hte(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 Wte=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)}),u8="RFC3986",h8=t=>String(t),LI={RFC1738:t=>String(t).replace(/%20/g,"+"),RFC3986:h8},qte="RFC1738";let sC=(t,e)=>(sC=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),sC(t,e));const zs=(()=>{const t=[];for(let e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t})(),s_=1024,Gte=(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+=s_){const c=s.length>=s_?s.slice(a,a+s_):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===qte&&(d===40||d===41)){h[h.length]=c.charAt(f);continue}if(d<128){h[h.length]=zs[d];continue}if(d<2048){h[h.length]=zs[192|d>>6]+zs[128|d&63];continue}if(d<55296||d>=57344){h[h.length]=zs[224|d>>12]+zs[128|d>>6&63]+zs[128|d&63];continue}f+=1,d=65536+((d&1023)<<10|c.charCodeAt(f)&1023),h[h.length]=zs[240|d>>18]+zs[128|d>>12&63]+zs[128|d>>6&63]+zs[128|d&63]}o+=h.join("")}return o};function Kte(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}function NI(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 f8={brackets(t){return String(t)+"[]"},comma:"comma",indices(t,e){return String(t)+"["+e+"]"},repeat(t){return String(t)}},d8=function(t,e){Array.prototype.push.apply(t,Hr(e)?e:[e])};let $I;const Cn={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Gte,encodeValuesOnly:!1,format:u8,formatter:h8,indices:!1,serializeDate(t){return($I??($I=Function.prototype.call.bind(Date.prototype.toISOString)))(t)},skipNulls:!1,strictNullHandling:!1};function Yte(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"}const o_={};function p8(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(o_))!==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(o_)>"u"&&(P=0)}if(typeof h=="function"?A=h(e,A):A instanceof Date?A=m?.(A):n==="comma"&&Hr(A)&&(A=NI(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(Yte(A)||Kte(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=NI(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(o_,_),d8(M,p8(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 Xte(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=u8;if(typeof t.format<"u"){if(!sC(LI,t.format))throw new TypeError("Unknown format option provided.");n=t.format}const r=LI[n];let i=Cn.filter;(typeof t.filter=="function"||Hr(t.filter))&&(i=t.filter);let s;if(t.arrayFormat&&t.arrayFormat in f8?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 Jte(t,e={}){let n=t;const r=Xte(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=f8[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||d8(o,p8(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 Qte(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 jI;function ik(t){let e;return(jI??(e=new globalThis.TextEncoder,jI=e.encode.bind(e)))(t)}let BI;function FI(t){let e;return(BI??(e=new globalThis.TextDecoder,BI=e.decode.bind(e)))(t)}var gi,yi;let Lx=class{constructor(){gi.set(this,void 0),yi.set(this,void 0),Ge(this,gi,new Uint8Array),Ge(this,yi,null)}decode(e){if(e==null)return[];const n=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?ik(e):e;Ge(this,gi,Qte([ne(this,gi,"f"),n]));const r=[];let i;for(;(i=Zte(ne(this,gi,"f"),ne(this,yi,"f")))!=null;){if(i.carriage&&ne(this,yi,"f")==null){Ge(this,yi,i.index);continue}if(ne(this,yi,"f")!=null&&(i.index!==ne(this,yi,"f")+1||i.carriage)){r.push(FI(ne(this,gi,"f").subarray(0,ne(this,yi,"f")-1))),Ge(this,gi,ne(this,gi,"f").subarray(ne(this,yi,"f"))),Ge(this,yi,null);continue}const s=ne(this,yi,"f")!==null?i.preceding-1:i.preceding,o=FI(ne(this,gi,"f").subarray(0,s));r.push(o),Ge(this,gi,ne(this,gi,"f").subarray(i.index)),Ge(this,yi,null)}return r}flush(){return ne(this,gi,"f").length?this.decode(`
|
||
`):[]}};gi=new WeakMap,yi=new WeakMap;Lx.NEWLINE_CHARS=new Set([`
|
||
`,"\r"]);Lx.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Zte(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 ene(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 rv={off:0,error:200,warn:300,info:400,debug:500},zI=(t,e,n)=>{if(t){if(Lte(rv,t))return t;Un(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(rv))}`)}};function Kd(){}function Z0(t,e,n){return!e||rv[t]>rv[n]?Kd:e[t].bind(e)}const tne={error:Kd,warn:Kd,info:Kd,debug:Kd};let VI=new WeakMap;function Un(t){const e=t.logger,n=t.logLevel??"off";if(!e)return tne;const r=VI.get(e);if(r&&r[0]===n)return r[1];const i={error:Z0("error",e,n),warn:Z0("warn",e,n),info:Z0("info",e,n),debug:Z0("debug",e,n)};return VI.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 nne(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 Jr(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 Jr(void 0,h.error,h.message,void 0);yield{event:c.event,data:h}}}a=!0}catch(c){if(nC(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 Lx,c=c8(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(nC(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 a8({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=ik(JSON.stringify(i)+`
|
||
`);r.enqueue(o)}catch(i){r.error(i)}},async cancel(){await n.return?.()}})}};async function*nne(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 ine,r=new Lx,i=c8(t.body);for await(const s of rne(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*rne(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"?ik(n):n;let i=new Uint8Array(e.length+r.length);i.set(e),i.set(r,e.length),e=i;let s;for(;(s=ene(e))!==-1;)yield e.slice(0,s),e=e.slice(s)}e.length>0&&(yield e)}let ine=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]=sne(e,":");return i.startsWith(" ")&&(i=i.substring(1)),n==="event"?this.event=i:n==="data"&&this.data.push(i),null}};function sne(t,e){const n=t.indexOf(e);return n!==-1?[t.substring(0,n),e,t.substring(n+e.length)]:[t,"",""]}async function m8(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 g8(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 g8(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 y8=class b8 extends Promise{constructor(e,n,r=m8){super(i=>{i(null)}),this.responsePromise=n,this.parseResponse=r,Xd.set(this,void 0),Ge(this,Xd,e)}_thenUnwrap(e){return new b8(ne(this,Xd,"f"),this.responsePromise,async(n,r)=>g8(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 ey;class sk{constructor(e,n,r,i){ey.set(this,void 0),Ge(this,ey,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,ey,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(ey=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const n of e.getPaginatedItems())yield n}}class one extends y8{constructor(e,n,r){super(e,n,async(i,s)=>new r(i,s.response,await m8(i,s),s.options))}async*[Symbol.asyncIterator](){const e=await this;for await(const n of e)yield n}}class Nx extends sk{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 sk{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:{...o8(this.options.query),after:n}}:null}}class ane extends sk{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:{...o8(this.options.query),after:e}}:null}}const v8=()=>{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 v8(),new File(t,e??"unknown_file",n)}function cb(t){return(typeof t=="object"&&t!==null&&("name"in t&&t.name&&String(t.name)||"url"in t&&t.url&&String(t.url)||"filename"in t&&t.filename&&String(t.filename)||"path"in t&&t.path&&String(t.path))||"").split(/[\\/]/).pop()||void 0}const x8=t=>t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function",_c=async(t,e)=>({...t,body:await cne(t.body,e)}),UI=new WeakMap;function lne(t){const e=typeof t=="function"?t:t.fetch,n=UI.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 UI.set(e,r),r}const cne=async(t,e)=>{if(!await lne(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])=>oC(n,r,i))),n},une=t=>t instanceof Blob&&"name"in t,oC=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()],cb(n)));else if(x8(n))t.append(e,xp([await new Response(l8(n)).blob()],cb(n)));else if(une(n))t.append(e,n,cb(n));else if(Array.isArray(n))await Promise.all(n.map(r=>oC(t,e+"[]",r)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([r,i])=>oC(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`)}},w8=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",hne=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&w8(t),fne=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function dne(t,e,n){if(v8(),t=await t,hne(t))return t instanceof File?t:xp([await t.arrayBuffer()],t.name);if(fne(t)){const i=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),xp(await aC(i),e,n)}const r=await aC(t);if(e||(e=cb(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 aC(t){let e=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)e.push(t);else if(w8(t))e.push(t instanceof Blob?t:await t.arrayBuffer());else if(x8(t))for await(const n of t)e.push(...await aC(n));else{const n=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${n?`; constructor: ${n}`:""}${pne(t)}`)}return e}function pne(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(n=>`"${n}"`).join(", ")}]`}let ze=class{constructor(e){this._client=e}};function S8(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const HI=Object.freeze(Object.create(null)),mne=(t=S8)=>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??HI)??HI)?.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=mne(S8);let _8=class extends ze{list(e,n={},r){return this._client.getAPIList(ve`/chat/completions/${e}/messages`,gn,{query:n,...r})}};function iv(t){return t!==void 0&&"function"in t&&t.function!==void 0}function ok(t){return t?.$brand==="auto-parseable-response-format"}function jm(t){return t?.$brand==="auto-parseable-tool"}function gne(t,e){return!e||!C8(e)?{...t,choices:t.choices.map(n=>(A8(n.message.tool_calls),{...n,message:{...n.message,parsed:null,...n.message.tool_calls?{tool_calls:n.message.tool_calls}:void 0}}))}:ak(t,e)}function ak(t,e){const n=t.choices.map(r=>{if(r.finish_reason==="length")throw new i8;if(r.finish_reason==="content_filter")throw new s8;return A8(r.message.tool_calls),{...r,message:{...r.message,...r.message.tool_calls?{tool_calls:r.message.tool_calls?.map(i=>bne(e,i))??void 0}:void 0,parsed:r.message.content&&!r.message.refusal?yne(e,r.message.content):null}}});return{...t,choices:n}}function yne(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 bne(t,e){const n=t.tools?.find(r=>iv(r)&&r.function?.name===e.function.name);return{...e,function:{...e.function,parsed_arguments:jm(n)?n.$parseRaw(e.function.arguments):n?.function.strict?JSON.parse(e.function.arguments):null}}}function vne(t,e){if(!t||!("tools"in t)||!t.tools)return!1;const n=t.tools?.find(r=>iv(r)&&r.function?.name===e.function.name);return iv(n)&&(jm(n)||n?.function.strict||!1)}function C8(t){return ok(t.response_format)?!0:t.tools?.some(e=>jm(e)||e.type==="function"&&e.function.strict===!0)??!1}function A8(t){for(const e of t||[])if(e.type!=="function")throw new Ie(`Currently only \`function\` tool calls are supported; Received \`${e.type}\``)}function xne(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 sv=t=>t?.role==="assistant",E8=t=>t?.role==="tool";var lC,ub,hb,Jd,Qd,fb,Zd,Vo,ep,ov,av,Gu,k8;class lk{constructor(){lC.add(this),this.controller=new AbortController,ub.set(this,void 0),hb.set(this,()=>{}),Jd.set(this,()=>{}),Qd.set(this,void 0),fb.set(this,()=>{}),Zd.set(this,()=>{}),Vo.set(this,{}),ep.set(this,!1),ov.set(this,!1),av.set(this,!1),Gu.set(this,!1),Ge(this,ub,new Promise((e,n)=>{Ge(this,hb,e,"f"),Ge(this,Jd,n,"f")})),Ge(this,Qd,new Promise((e,n)=>{Ge(this,fb,e,"f"),Ge(this,Zd,n,"f")})),ne(this,ub,"f").catch(()=>{}),ne(this,Qd,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},ne(this,lC,"m",k8).bind(this))},0)}_connected(){this.ended||(ne(this,hb,"f").call(this),this._emit("connect"))}get ended(){return ne(this,ep,"f")}get errored(){return ne(this,ov,"f")}get aborted(){return ne(this,av,"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,fb,"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(){}}ub=new WeakMap,hb=new WeakMap,Jd=new WeakMap,Qd=new WeakMap,fb=new WeakMap,Zd=new WeakMap,Vo=new WeakMap,ep=new WeakMap,ov=new WeakMap,av=new WeakMap,Gu=new WeakMap,lC=new WeakSet,k8=function(e){if(Ge(this,ov,!0),e instanceof Error&&e.name==="AbortError"&&(e=new qi),e instanceof qi)return Ge(this,av,!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 wne(t){return typeof t.parse=="function"}var Er,cC,lv,uC,hC,fC,T8,R8;const Sne=10;let M8=class extends lk{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),E8(e)&&e.content)this._emit("functionToolCallResult",e.content);else if(sv(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",cC).call(this)}async finalMessage(){return await this.done(),ne(this,Er,"m",lv).call(this)}async finalFunctionToolCall(){return await this.done(),ne(this,Er,"m",uC).call(this)}async finalFunctionToolCallResult(){return await this.done(),ne(this,Er,"m",hC).call(this)}async totalUsage(){return await this.done(),ne(this,Er,"m",fC).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",lv).call(this);n&&this._emit("finalMessage",n);const r=ne(this,Er,"m",cC).call(this);r&&this._emit("finalContent",r);const i=ne(this,Er,"m",uC).call(this);i&&this._emit("finalFunctionToolCall",i);const s=ne(this,Er,"m",hC).call(this);s!=null&&this._emit("finalFunctionToolCallResult",s),this._chatCompletions.some(o=>o.usage)&&this._emit("totalUsage",ne(this,Er,"m",fC).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",T8).call(this,n);const s=await e.chat.completions.create({...n,stream:!1},{...r,signal:this.controller.signal});return this._connected(),this._addChatCompletion(ak(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=Sne}=r||{},f=n.tools.map(y=>{if(jm(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=wne(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",R8).call(this,M);if(this._addMessage({role:i,tool_call_id:_,content:D}),c)return}}}};Er=new WeakSet,cC=function(){return ne(this,Er,"m",lv).call(this).content??null},lv=function(){let e=this.messages.length;for(;e-- >0;){const n=this.messages[e];if(sv(n))return{...n,content:n.content??null,refusal:n.refusal??null}}throw new Ie("stream ended without producing a ChatCompletionMessage with role=assistant")},uC=function(){for(let e=this.messages.length-1;e>=0;e--){const n=this.messages[e];if(sv(n)&&n?.tool_calls?.length)return n.tool_calls.filter(r=>r.type==="function").at(-1)?.function}},hC=function(){for(let e=this.messages.length-1;e>=0;e--){const n=this.messages[e];if(E8(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}},fC=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},T8=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.")},R8=function(e){return typeof e=="string"?e:e===void 0?"undefined":JSON.stringify(e)};class ck extends M8{static runTools(e,n,r){const i=new ck,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),sv(e)&&e.content&&this._emit("content",e.content)}}const O8=1,P8=2,D8=4,I8=8,L8=16,N8=32,$8=64,j8=128,B8=256,F8=j8|B8,z8=L8|N8|F8|$8,V8=O8|P8|z8,U8=D8|I8,_ne=V8|U8,Ln={STR:O8,NUM:P8,ARR:D8,OBJ:I8,NULL:L8,BOOL:N8,NAN:$8,INFINITY:j8,MINUS_INFINITY:B8,INF:F8,SPECIAL:z8,ATOM:V8,COLLECTION:U8,ALL:_ne};class Cne extends Error{}class Ane extends Error{}function Ene(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 kne(t.trim(),e)}const kne=(t,e)=>{const n=t.length;let r=0;const i=m=>{throw new Cne(`${m} at position ${r}`)},s=m=>{throw new Ane(`${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()},WI=t=>Ene(t,Ln.ALL^Ln.NUM);var wn,Fo,Lu,Ua,a_,ty,l_,c_,u_,ny,h_,qI;let H8=class dC extends M8{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 dC(null);return n._run(()=>n._fromReadableStream(e)),n}static createChatCompletion(e,n,r){const i=new dC(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",a_).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",l_).call(this,o);if(s.controller.signal?.aborted)throw new qi;return this._addChatCompletion(ne(this,wn,"m",ny).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",a_).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",ny).call(this)),ne(this,wn,"m",l_).call(this,o),s=o.id;if(i.controller.signal?.aborted)throw new qi;return this._addChatCompletion(ne(this,wn,"m",ny).call(this))}[(Fo=new WeakMap,Lu=new WeakMap,Ua=new WeakMap,wn=new WeakSet,a_=function(){this.ended||Ge(this,Ua,void 0)},ty=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)},l_=function(n){if(this.ended)return;const r=ne(this,wn,"m",qI).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",ty).call(this,s);s.finish_reason&&(ne(this,wn,"m",u_).call(this,s),o.current_tool_call_index!=null&&ne(this,wn,"m",c_).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",u_).call(this,s),o.current_tool_call_index!=null&&ne(this,wn,"m",c_).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))}}},c_=function(n,r){if(ne(this,wn,"m",ty).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=>iv(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:jm(o)?o.$parseRaw(s.function.arguments):o?.function.strict?JSON.parse(s.function.arguments):null})}else s.type},u_=function(n){const r=ne(this,wn,"m",ty).call(this,n);if(n.message.content&&!r.content_done){r.content_done=!0;const i=ne(this,wn,"m",h_).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}))},ny=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,[]),Tne(n,ne(this,Fo,"f"))},h_=function(){const n=ne(this,Fo,"f")?.response_format;return ok(n)?n:null},qI=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")&&C8(ne(this,Fo,"f")))){if(d==="length")throw new i8;if(d==="content_filter")throw new s8}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",h_).call(this)&&(x.message.parsed=WI(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,vne(ne(this,Fo,"f"),V)&&(V.function.parsed_arguments=WI(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 Tne(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
|
||
${ry(t)}`);if(M==null)throw new Ie(`missing choices[${d}].tool_calls[${P}].type
|
||
${ry(t)}`);if(j==null)throw new Ie(`missing choices[${d}].tool_calls[${P}].function.name
|
||
${ry(t)}`);if(H==null)throw new Ie(`missing choices[${d}].tool_calls[${P}].function.arguments
|
||
${ry(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 gne(c,e)}function ry(t){return JSON.stringify(t)}class cv extends H8{static fromReadableStream(e){const n=new cv(null);return n._run(()=>n._fromReadableStream(e)),n}static runTools(e,n,r){const i=new cv(n),s={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"runTools"}};return i._run(()=>i._runTools(e,n,s)),i}}let uk=class extends ze{constructor(){super(...arguments),this.messages=new _8(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 xne(e.tools),this._client.chat.completions.create(e,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(r=>ak(r,e))}runTools(e,n){return e.stream?cv.runTools(this._client,e,n):ck.runTools(this._client,e,n)}stream(e,n){return H8.createChatCompletion(this._client,e,n)}};uk.Messages=_8;let hk=class extends ze{constructor(){super(...arguments),this.completions=new uk(this._client)}};hk.Completions=uk;const W8=Symbol("brand.privateNullableHeaders");function*Rne(t){if(!t)return;if(W8 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():OI(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=OI(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 Rne(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{[W8]:!0,values:e,nulls:n}};class q8 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 G8=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))}},K8=class extends ze{create(e,n){return this._client.post("/audio/translations",_c({body:e,...n,__metadata:{model:e.model}},this._client))}},Bm=class extends ze{constructor(){super(...arguments),this.transcriptions=new G8(this._client),this.translations=new K8(this._client),this.speech=new q8(this._client)}};Bm.Transcriptions=G8;Bm.Translations=K8;Bm.Speech=q8;let Y8=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 X8 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 J8=class extends ze{create(e,n){return this._client.post("/realtime/sessions",{body:e,...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};class Q8 extends ze{create(e,n){return this._client.post("/realtime/transcription_sessions",{body:e,...n,headers:Ne([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}let $x=class extends ze{constructor(){super(...arguments),this.sessions=new J8(this._client),this.transcriptionSessions=new Q8(this._client)}};$x.Sessions=J8;$x.TranscriptionSessions=Q8;class Z8 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 e6 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 Mne=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 One={};const Nu=t=>{if(typeof globalThis.process<"u")return One?.[t]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(t)?.trim()};var Wn,cc,pC,Js,db,ps,uc,th,sc,uv,wi,pb,mb,wp,tp,np,GI,KI,YI,XI,JI,QI,ZI;class Sp extends lk{constructor(){super(...arguments),Wn.add(this),pC.set(this,[]),Js.set(this,{}),db.set(this,{}),ps.set(this,void 0),uc.set(this,void 0),th.set(this,void 0),sc.set(this,void 0),uv.set(this,void 0),wi.set(this,void 0),pb.set(this,void 0),mb.set(this,void 0),wp.set(this,void 0)}[(pC=new WeakMap,Js=new WeakMap,db=new WeakMap,ps=new WeakMap,uc=new WeakMap,th=new WeakMap,sc=new WeakMap,uv=new WeakMap,wi=new WeakMap,pb=new WeakMap,mb=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 qi;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 qi;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,pb,"f")}currentRun(){return ne(this,mb,"f")}currentMessageSnapshot(){return ne(this,ps,"f")}currentRunStepSnapshot(){return ne(this,wp,"f")}async finalRunSteps(){return await this.done(),Object.values(ne(this,Js,"f"))}async finalMessages(){return await this.done(),Object.values(ne(this,db,"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 qi;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 qi;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(i_(s)&&i_(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(!i_(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,pb,e),ne(this,Wn,"m",YI).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",ZI).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",KI).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",GI).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")},GI=function(e){const[n,r]=ne(this,Wn,"m",JI).call(this,e,ne(this,ps,"f"));Ge(this,ps,n),ne(this,db,"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,ps,"f"));break;case"image_file":this._emit("imageFileDone",ne(this,sc,"f").image_file,ne(this,ps,"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,ps,"f"));break;case"text":this._emit("textDone",i.text,ne(this,ps,"f"));break}}ne(this,ps,"f")&&this._emit("messageDone",e.data),Ge(this,ps,void 0)}},KI=function(e){const n=ne(this,Wn,"m",XI).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,uv,"f")?this._emit("toolCallDelta",s,n.step_details.tool_calls[s.index]):(ne(this,wi,"f")&&this._emit("toolCallDone",ne(this,wi,"f")),Ge(this,uv,s.index),Ge(this,wi,n.step_details.tool_calls[s.index]),ne(this,wi,"f")&&this._emit("toolCallCreated",ne(this,wi,"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,wi,"f")&&(this._emit("toolCallDone",ne(this,wi,"f")),Ge(this,wi,void 0)),this._emit("runStepDone",e.data,n);break}},YI=function(e){ne(this,pC,"f").push(e),this._emit("event",e)},XI=function(e){switch(e.event){case"thread.run.step.created":return ne(this,Js,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let n=ne(this,Js,"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,Js,"f")[e.data.id]=i}return ne(this,Js,"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,Js,"f")[e.data.id]=e.data;break}if(ne(this,Js,"f")[e.data.id])return ne(this,Js,"f")[e.data.id];throw new Error("No snapshot available")},JI=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",QI).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")},QI=function(e,n){return cc.accumulateDelta(n,e)},ZI=function(e){switch(Ge(this,mb,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,wi,"f")&&(this._emit("toolCallDone",ne(this,wi,"f")),Ge(this,wi,void 0));break}};let fk=class extends ze{constructor(){super(...arguments),this.steps=new e6(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 $m(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)}};fk.Steps=e6;class jx extends ze{constructor(){super(...arguments),this.runs=new fk(this._client),this.messages=new Z8(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)}}jx.Runs=fk;jx.Messages=Z8;class Fm extends ze{constructor(){super(...arguments),this.realtime=new $x(this._client),this.assistants=new X8(this._client),this.threads=new jx(this._client)}}Fm.Realtime=$x;Fm.Assistants=X8;Fm.Threads=jx;let t6=class extends ze{create(e,n){return this._client.post("/completions",{body:e,...n,stream:e.stream??!1})}},n6=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})}},dk=class extends ze{constructor(){super(...arguments),this.content=new n6(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])})}};dk.Content=n6;class pk extends ze{constructor(){super(...arguments),this.files=new dk(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])})}}pk.Files=dk;class r6 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`,ane,{query:n,...r})}delete(e,n,r){const{conversation_id:i}=n;return this._client.delete(ve`/conversations/${i}/items/${e}`,r)}}class mk extends ze{constructor(){super(...arguments),this.items=new r6(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)}}mk.Items=r6;let i6=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=Mne(c)}),o)))}};class s6 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 gk extends ze{constructor(){super(...arguments),this.outputItems=new s6(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)}}gk.OutputItems=s6;class yk extends ze{constructor(){super(...arguments),this.runs=new gk(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)}}yk.Runs=gk;let o6=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 $m(n),o=await this.retrieve(e),Date.now()-s>r)throw new rk({message:`Giving up on waiting for file ${e} to finish processing after ${r} milliseconds.`});return o}};class a6 extends ze{}let l6=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 bk extends ze{constructor(){super(...arguments),this.graders=new l6(this._client)}}bk.Graders=l6;class c6 extends ze{create(e,n,r){return this._client.getAPIList(ve`/fine_tuning/checkpoints/${e}/permissions`,Nx,{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 vk=class extends ze{constructor(){super(...arguments),this.permissions=new c6(this._client)}};vk.Permissions=c6;class u6 extends ze{list(e,n={},r){return this._client.getAPIList(ve`/fine_tuning/jobs/${e}/checkpoints`,gn,{query:n,...r})}}let xk=class extends ze{constructor(){super(...arguments),this.checkpoints=new u6(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)}};xk.Checkpoints=u6;class Kh extends ze{constructor(){super(...arguments),this.methods=new a6(this._client),this.jobs=new xk(this._client),this.checkpoints=new vk(this._client),this.alpha=new bk(this._client)}}Kh.Methods=a6;Kh.Jobs=xk;Kh.Checkpoints=vk;Kh.Alpha=bk;class h6 extends ze{}class wk extends ze{constructor(){super(...arguments),this.graderModels=new h6(this._client)}}wk.GraderModels=h6;let f6=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})}},d6=class extends ze{retrieve(e,n){return this._client.get(ve`/models/${e}`,n)}list(e){return this._client.getAPIList("/models",Nx,e)}delete(e,n){return this._client.delete(ve`/models/${e}`,n)}};class p6 extends ze{create(e,n){return this._client.post("/moderations",{body:e,...n})}}class m6 extends ze{create(e,n){return this._client.post("/realtime/client_secrets",{body:e,...n})}}class Sk extends ze{constructor(){super(...arguments),this.clientSecrets=new m6(this._client)}}Sk.ClientSecrets=m6;function Pne(t,e){return!e||!Ine(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)}:g6(t,e)}function g6(t,e){const n=t.output.map(i=>{if(i.type==="function_call")return{...i,parsed_arguments:$ne(e,i)};if(i.type==="message"){const s=i.content.map(o=>o.type==="output_text"?{...o,parsed:Dne(e,o.text)}:o);return{...i,content:s}}return i}),r=Object.assign({},t,{output:n});return Object.getOwnPropertyDescriptor(t,"output_text")||mC(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 Dne(t,e){return t.text?.format?.type!=="json_schema"?null:"$parseRaw"in t.text?.format?(t.text?.format).$parseRaw(e):JSON.parse(e)}function Ine(t){return!!ok(t.text?.format)}function Lne(t){return t?.$brand==="auto-parseable-tool"}function Nne(t,e){return t.find(n=>n.type==="function"&&n.name===e)}function $ne(t,e){const n=Nne(t.tools??[],e.name);return{...e,...e,parsed_arguments:Lne(n)?n.$parseRaw(e.arguments):n?.strict?JSON.parse(e.arguments):null}}function mC(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,iy,Ha,sy,eL,tL,nL,rL;class _k extends lk{constructor(e){super(),$u.add(this),iy.set(this,void 0),Ha.set(this,void 0),sy.set(this,void 0),Ge(this,iy,e)}static createResponse(e,n,r){const i=new _k(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",eL).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",tL).call(this,a,o);if(s.controller.signal?.aborted)throw new qi;return ne(this,$u,"m",nL).call(this)}[(iy=new WeakMap,Ha=new WeakMap,sy=new WeakMap,$u=new WeakSet,eL=function(){this.ended||Ge(this,Ha,void 0)},tL=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",rL).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}},nL=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=jne(n,ne(this,iy,"f"));return Ge(this,sy,r),r},rL=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,sy,"f");if(!e)throw new Ie("stream ended without producing a ChatCompletion");return e}}function jne(t,e){return Pne(t,e)}class y6 extends ze{list(e,n={},r){return this._client.getAPIList(ve`/responses/${e}/input_items`,gn,{query:n,...r})}}class Ck extends ze{constructor(){super(...arguments),this.inputItems=new y6(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"&&mC(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"&&mC(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=>g6(r,e))}stream(e,n){return _k.createResponse(this._client,e,n)}cancel(e,n){return this._client.post(ve`/responses/${e}/cancel`,n)}}Ck.InputItems=y6;class b6 extends ze{create(e,n,r){return this._client.post(ve`/uploads/${e}/parts`,_c({body:n,...r},this._client))}}class Ak extends ze{constructor(){super(...arguments),this.parts=new b6(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})}}Ak.Parts=b6;const Bne=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 v6 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 $m(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 Bne(d),await this.createAndPoll(e,{file_ids:h})}}let x6=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 $m(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`,Nx,{...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};class Bx extends ze{constructor(){super(...arguments),this.files=new x6(this._client),this.fileBatches=new v6(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`,Nx,{body:n,method:"post",...r,headers:Ne([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}}Bx.Files=x6;Bx.FileBatches=v6;var Ku,w6,gb;class S6 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",w6).call(this,r);const s=Ne([n]).values,o=ne(this,Ku,"m",gb).call(this,s,"webhook-signature"),a=ne(this,Ku,"m",gb).call(this,s,"webhook-timestamp"),c=ne(this,Ku,"m",gb).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,w6=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")},gb=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 gC,Ek,yb,_6;class Ze{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(gC.add(this),yb.set(this,void 0),this.completions=new t6(this),this.chat=new hk(this),this.embeddings=new i6(this),this.files=new o6(this),this.images=new f6(this),this.audio=new Bm(this),this.moderations=new p6(this),this.models=new d6(this),this.fineTuning=new Kh(this),this.graders=new wk(this),this.vectorStores=new Bx(this),this.webhooks=new S6(this),this.beta=new Fm(this),this.batches=new Y8(this),this.uploads=new Ak(this),this.responses=new Ck(this),this.realtime=new Sk(this),this.conversations=new mk(this),this.evals=new yk(this),this.containers=new pk(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&&jte())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??Ek.DEFAULT_TIMEOUT,this.logger=a.logger??console;const c="warn";this.logLevel=c,this.logLevel=zI(a.logLevel,"ClientOptions.logLevel",this)??zI(Nu("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??c,this.fetchOptions=a.fetchOptions,this.maxRetries=a.maxRetries??2,this.fetch=a.fetch??Ute(),Ge(this,yb,Wte),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 Jte(e,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${qu}`}defaultIdempotencyKey(){return`stainless-node-retry-${YB()}`}makeStatusError(e,n,r,i){return Jr.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,gC,"m",_6).call(this)&&r||this.baseURL,s=Dte(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();return Ite(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 y8(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 qi;const m=new AbortController,y=await this.fetchWithTimeout(a,o,c,m).catch(rC),b=Date.now();if(y instanceof globalThis.Error){const _=`retrying, ${n} attempts remaining`;if(i.signal?.aborted)throw new qi;const A=nC(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 rk:new Ix({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 Hte(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=>rC(D).message),P=$te(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 one(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 $m(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&&Nte("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))}:{},...Vte(),"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:l8(e)}:ne(this,yb,"f").call(this,{body:e,headers:r})}}Ek=Ze,yb=new WeakMap,gC=new WeakSet,_6=function(){return this.baseURL!=="https://api.openai.com/v1"};Ze.OpenAI=Ek;Ze.DEFAULT_TIMEOUT=6e5;Ze.OpenAIError=Ie;Ze.APIError=Jr;Ze.APIConnectionError=Ix;Ze.APIConnectionTimeoutError=rk;Ze.APIUserAbortError=qi;Ze.NotFoundError=ZB;Ze.ConflictError=e8;Ze.RateLimitError=n8;Ze.BadRequestError=XB;Ze.AuthenticationError=JB;Ze.InternalServerError=r8;Ze.PermissionDeniedError=QB;Ze.UnprocessableEntityError=t8;Ze.InvalidWebhookSignatureError=Gd;Ze.toFile=dne;Ze.Completions=t6;Ze.Chat=hk;Ze.Embeddings=i6;Ze.Files=o6;Ze.Images=f6;Ze.Audio=Bm;Ze.Moderations=p6;Ze.Models=d6;Ze.FineTuning=Kh;Ze.Graders=wk;Ze.VectorStores=Bx;Ze.Webhooks=S6;Ze.Beta=Fm;Ze.Batches=Y8;Ze.Uploads=Ak;Ze.Responses=Ck;Ze.Realtime=Sk;Ze.Conversations=mk;Ze.Evals=yk;Ze.Containers=pk;const Fne=t=>t.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:{...e.inputSchema}}})),oy=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},zne=(t,e,n)=>{if(!e.delta.content)return t;let r=mo(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=mo({...s,text:o});r={...r,content:[...i.slice(0,-1),a]}}return r},Vne=(t,e)=>{let n=mo(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 Une{modelKey="";systemPrompt="";apiKey;url;provider;prevMessages=[];tools=[];client;stopStream=!1;constructor(){}setProvider=e=>{this.provider=e,this.client=new Ze({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=oy(e)};setTools=e=>{this.tools=Fne(e)};async createChatName(e){try{if(!this.client)return"";const n={role:"system",content:Dx};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=oy(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,max_completion_tokens:2048});this.prevMessages.push(...i);let a=n&&r?mo(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=oy([m]);this.prevMessages.push(...y);return}d.delta.content&&(a=zne(a,d,n)),d.delta.tool_calls&&typeof a.content!="string"&&(a=Vne(a,d))}}),this.stopStream){const d=oy([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 Ze({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 Ze({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 iL=new Une;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 C6=function(){const{crypto:t}=globalThis;if(t?.randomUUID)return C6=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 yC(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}const bC=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 Fx({message:r,cause:bC(n)});const s=n;return e===400?new E6(e,s,r,i):e===401?new k6(e,s,r,i):e===403?new T6(e,s,r,i):e===404?new R6(e,s,r,i):e===409?new M6(e,s,r,i):e===422?new O6(e,s,r,i):e===429?new P6(e,s,r,i):e>=500?new D6(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 Fx extends yr{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}}class A6 extends Fx{constructor({message:e}={}){super({message:e??"Request timed out."})}}class E6 extends yr{}class k6 extends yr{}class T6 extends yr{}class R6 extends yr{}class M6 extends yr{}class O6 extends yr{}class P6 extends yr{}class D6 extends yr{}const Hne=/^[a-z][a-z0-9+.-]*:/i,Wne=t=>Hne.test(t);let vC=t=>(vC=Array.isArray,vC(t)),sL=vC;function qne(t){if(!t)return!0;for(const e in t)return!1;return!0}function Gne(t,e){return Object.prototype.hasOwnProperty.call(t,e)}const Kne=(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},Yne=t=>{try{return JSON.parse(t)}catch{return}},Xne=t=>new Promise(e=>setTimeout(e,t)),Yu="0.22.0";function Jne(){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 Qne=()=>{const t=Jne();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Yu,"X-Stainless-OS":aL(Deno.build.os),"X-Stainless-Arch":oL(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":aL(globalThis.process.platform??"unknown"),"X-Stainless-Arch":oL(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const e=Zne();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 Zne(){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 oL=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",aL=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 lL;const ere=()=>lL??(lL=Qne());function tre(){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 I6(...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 L6(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return I6({start(){},async pull(n){const{done:r,value:i}=await e.next();r?n.close():n.enqueue(i)},async cancel(){await e.return?.()}})}function N6(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 nre(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 rre=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)}),$6=()=>{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 $6(),new File(t,e??"unknown_file",n)}function bb(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 j6=t=>t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function",B6=async(t,e)=>({...t,body:await sre(t.body,e)}),cL=new WeakMap;function ire(t){const e=typeof t=="function"?t:t.fetch,n=cL.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 cL.set(e,r),r}const sre=async(t,e)=>{if(!await ire(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])=>xC(n,r,i))),n},ore=t=>t instanceof Blob&&"name"in t,xC=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()],bb(n)));else if(j6(n))t.append(e,_p([await new Response(L6(n)).blob()],bb(n)));else if(ore(n))t.append(e,n,bb(n));else if(Array.isArray(n))await Promise.all(n.map(r=>xC(t,e+"[]",r)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([r,i])=>xC(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`)}},F6=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",are=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&F6(t),lre=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function cre(t,e,n){if($6(),t=await t,are(t))return t instanceof File?t:_p([await t.arrayBuffer()],t.name);if(lre(t)){const i=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),_p(await wC(i),e,n)}const r=await wC(t);if(e||(e=bb(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 wC(t){let e=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)e.push(t);else if(F6(t))e.push(t instanceof Blob?t:await t.arrayBuffer());else if(j6(t))for await(const n of t)e.push(...await wC(n));else{const n=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${n?`; constructor: ${n}`:""}${ure(t)}`)}return e}function ure(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(n=>`"${n}"`).join(", ")}]`}class Qn{constructor(e){this._client=e}}class z6 extends Qn{create(e,n){return this._client.post("/audio/transcriptions",B6({body:e,...n},this._client))}}class V6 extends Qn{create(e,n){return this._client.post("/audio/translations",B6({body:e,...n},this._client))}}const U6=Symbol("brand.privateNullableHeaders");function*hre(t){if(!t)return;if(U6 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():sL(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=sL(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 hre(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{[U6]:!0,values:e,nulls:n}};class zx extends Qn{constructor(){super(...arguments),this.transcriptions=new z6(this._client),this.translations=new V6(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})}}zx.Transcriptions=z6;zx.Translations=V6;function H6(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const uL=Object.freeze(Object.create(null)),fre=(t=H6)=>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??uL)??uL)?.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},Gi=fre(H6);class W6 extends Qn{create(e,n){return this._client.post("/batches",{body:e,...n})}retrieve(e,n){return this._client.get(Gi`/batches/${e}`,n)}list(e){return this._client.get("/batches",e)}}function hL(t){return typeof t.parse=="function"}const Cp=t=>t?.role==="assistant",q6=t=>t?.role==="function",G6=t=>t?.role==="tool";var hr,vb,xb,rp,ip,wb,sp,Uo,op,Sb,_b,Xu,SC,hv,_C,CC,AC,EC,K6,kC;const fL=10;class dre{constructor(){hr.add(this),this.controller=new AbortController,vb.set(this,void 0),xb.set(this,()=>{}),rp.set(this,()=>{}),ip.set(this,void 0),wb.set(this,()=>{}),sp.set(this,()=>{}),Uo.set(this,{}),this._chatCompletions=[],this.messages=[],op.set(this,!1),Sb.set(this,!1),_b.set(this,!1),Xu.set(this,!1),EC.set(this,e=>{if(Lt(this,Sb,!0),e instanceof Error&&e.name==="AbortError"&&(e=new Cc),e instanceof Cc)return Lt(this,_b,!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,vb,new Promise((e,n)=>{Lt(this,xb,e,"f"),Lt(this,rp,n,"f")})),Lt(this,ip,new Promise((e,n)=>{Lt(this,wb,e,"f"),Lt(this,sp,n,"f")})),Ae(this,vb,"f").catch(()=>{}),Ae(this,ip,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},Ae(this,EC,"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),(q6(e)||G6(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,xb,"f").call(this),this._emit("connect"))}get ended(){return Ae(this,op,"f")}get errored(){return Ae(this,Sb,"f")}get aborted(){return Ae(this,_b,"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",SC).call(this)}async finalMessage(){return await this.done(),Ae(this,hr,"m",hv).call(this)}async finalFunctionCall(){return await this.done(),Ae(this,hr,"m",_C).call(this)}async finalFunctionCallResult(){return await this.done(),Ae(this,hr,"m",CC).call(this)}async totalUsage(){return await this.done(),Ae(this,hr,"m",AC).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emit(e,...n){if(Ae(this,op,"f"))return;e==="end"&&(Lt(this,op,!0),Ae(this,wb,"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",hv).call(this);n&&this._emit("finalMessage",n);const r=Ae(this,hr,"m",SC).call(this);r&&this._emit("finalContent",r);const i=Ae(this,hr,"m",_C).call(this);i&&this._emit("finalFunctionCall",i);const s=Ae(this,hr,"m",CC).call(this);s!=null&&this._emit("finalFunctionCallResult",s),this._chatCompletions.some(o=>o.usage)&&this._emit("totalUsage",Ae(this,hr,"m",AC).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",K6).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=fL}=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=hL(_)?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",kC).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=fL}=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=hL(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",kC).call(this,O);if(this._addMessage({role:i,tool_call_id:S,content:M}),c)return}}}}vb=new WeakMap,xb=new WeakMap,rp=new WeakMap,ip=new WeakMap,wb=new WeakMap,sp=new WeakMap,Uo=new WeakMap,op=new WeakMap,Sb=new WeakMap,_b=new WeakMap,Xu=new WeakMap,EC=new WeakMap,hr=new WeakSet,SC=function(){return Ae(this,hr,"m",hv).call(this).content??null},hv=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")},_C=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}},CC=function(){for(let e=this.messages.length-1;e>=0;e--){const n=this.messages[e];if(q6(n)&&n.content!=null||G6(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}},AC=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},K6=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.")},kC=function(e){return typeof e=="string"?e:e===void 0?"undefined":JSON.stringify(e)};function pre(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 dL;function kk(t){let e;return(dL??(e=new globalThis.TextEncoder,dL=e.encode.bind(e)))(t)}let pL;function mL(t){let e;return(pL??(e=new globalThis.TextDecoder,pL=e.decode.bind(e)))(t)}var bi,vi;class Vx{constructor(){bi.set(this,void 0),vi.set(this,void 0),Lt(this,bi,new Uint8Array),Lt(this,vi,null)}decode(e){if(e==null)return[];const n=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?kk(e):e;Lt(this,bi,pre([Ae(this,bi,"f"),n]));const r=[];let i;for(;(i=mre(Ae(this,bi,"f"),Ae(this,vi,"f")))!=null;){if(i.carriage&&Ae(this,vi,"f")==null){Lt(this,vi,i.index);continue}if(Ae(this,vi,"f")!=null&&(i.index!==Ae(this,vi,"f")+1||i.carriage)){r.push(mL(Ae(this,bi,"f").subarray(0,Ae(this,vi,"f")-1))),Lt(this,bi,Ae(this,bi,"f").subarray(Ae(this,vi,"f"))),Lt(this,vi,null);continue}const s=Ae(this,vi,"f")!==null?i.preceding-1:i.preceding,o=mL(Ae(this,bi,"f").subarray(0,s));r.push(o),Lt(this,bi,Ae(this,bi,"f").subarray(i.index)),Lt(this,vi,null)}return r}flush(){return Ae(this,bi,"f").length?this.decode(`
|
||
`):[]}}bi=new WeakMap,vi=new WeakMap;Vx.NEWLINE_CHARS=new Set([`
|
||
`,"\r"]);Vx.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function mre(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 gre(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 fv={off:0,error:200,warn:300,info:400,debug:500},gL=(t,e,n)=>{if(t){if(Gne(fv,t))return t;Tr(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(fv))}`)}};function ap(){}function ay(t,e,n){return!e||fv[t]>fv[n]?ap:e[t].bind(e)}const yre={error:ap,warn:ap,info:ap,debug:ap};let yL=new WeakMap;function Tr(t){const e=t.logger,n=t.logLevel??"off";if(!e)return yre;const r=yL.get(e);if(r&&r[0]===n)return r[1];const i={error:ay("error",e,n),warn:ay("warn",e,n),info:ay("info",e,n),debug:ay("debug",e,n)};return yL.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 bre(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(yC(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 Vx,c=N6(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(yC(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 I6({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=kk(JSON.stringify(i)+`
|
||
`);r.enqueue(o)}catch(i){r.error(i)}},async cancel(){await n.return?.()}})}}async function*bre(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 xre,r=new Vx,i=N6(t.body);for await(const s of vre(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*vre(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"?kk(n):n;let i=new Uint8Array(e.length+r.length);i.set(e),i.set(r,e.length),e=i;let s;for(;(s=gre(e))!==-1;)yield e.slice(0,s),e=e.slice(s)}e.length>0&&(yield e)}class xre{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]=wre(e,":");return i.startsWith(" ")&&(i=i.substring(1)),n==="event"?this.event=i:n==="data"&&this.data.push(i),null}}function wre(t,e){const n=t.indexOf(e);return n!==-1?[t.substring(0,n),e,t.substring(n+e.length)]:[t,"",""]}var Vs,Wa,f_,d_,ly,bL;class dv extends dre{constructor(){super(...arguments),Vs.add(this),Wa.set(this,void 0)}get currentChatCompletionSnapshot(){return Ae(this,Wa,"f")}static fromReadableStream(e){const n=new dv;return n._run(()=>n._fromReadableStream(e)),n}static createChatCompletion(e,n,r){const i=new dv;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,Vs,"m",f_).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,Vs,"m",d_).call(this,o);if(s.controller.signal?.aborted)throw new Cc;return this._addChatCompletion(Ae(this,Vs,"m",ly).call(this))}async _fromReadableStream(e,n){const r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),Ae(this,Vs,"m",f_).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,Vs,"m",ly).call(this)),Ae(this,Vs,"m",d_).call(this,o),s=o.id;if(i.controller.signal?.aborted)throw new Cc;return this._addChatCompletion(Ae(this,Vs,"m",ly).call(this))}[(Wa=new WeakMap,Vs=new WeakSet,f_=function(){this.ended||Lt(this,Wa,void 0)},d_=function(n){if(this.ended)return;const r=Ae(this,Vs,"m",bL).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)},ly=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),Sre(n)},bL=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 Sre(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
|
||
${cy(t)}`);if(P==null)throw new At(`missing choices[${h}].tool_calls[${A}].type
|
||
${cy(t)}`);if(N==null)throw new At(`missing choices[${h}].tool_calls[${A}].function.name
|
||
${cy(t)}`);if(D==null)throw new At(`missing choices[${h}].tool_calls[${A}].function.arguments
|
||
${cy(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 cy(t){return JSON.stringify(t)}let Y6=class extends Qn{create(e,n){return this._client.post("/chat/completions",{body:e,...n,stream:e.stream??!1})}stream(e,n){return dv.createChatCompletion(this._client.chat.completions,e,n)}};class Tk extends Qn{constructor(){super(...arguments),this.completions=new Y6(this._client)}}Tk.Completions=Y6;class X6 extends Qn{list(e){return this._client.get("/tci/sessions",e)}}class Rk extends Qn{constructor(){super(...arguments),this.sessions=new X6(this._client)}execute(e,n){return this._client.post("/tci/execute",{body:e,...n})}}Rk.Sessions=X6;class J6 extends Qn{create(e,n){return this._client.post("/completions",{body:e,...n,stream:e.stream??!1})}}class Q6 extends Qn{create(e,n){return this._client.post("/embeddings",{body:e,...n})}}class Z6 extends Qn{create(e,n){return this._client.post("/endpoints",{body:e,...n})}retrieve(e,n){return this._client.get(Gi`/endpoints/${e}`,n)}update(e,n,r){return this._client.patch(Gi`/endpoints/${e}`,{body:n,...r})}list(e={},n){return this._client.get("/endpoints",{query:e,...n})}delete(e,n){return this._client.delete(Gi`/endpoints/${e}`,{...n,headers:yh([{Accept:"*/*"},n?.headers])})}}class e9 extends Qn{retrieve(e,n){return this._client.get(Gi`/files/${e}`,n)}list(e){return this._client.get("/files",e)}delete(e,n){return this._client.delete(Gi`/files/${e}`,n)}content(e,n){return this._client.get(Gi`/files/${e}/content`,{...n,headers:yh([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}upload(e){throw"please use together-ai/lib/upload"}}class t9 extends Qn{create(e,n){return this._client.post("/fine-tunes",{body:e,...n})}retrieve(e,n){return this._client.get(Gi`/fine-tunes/${e}`,n)}list(e){return this._client.get("/fine-tunes",e)}cancel(e,n){return this._client.post(Gi`/fine-tunes/${e}/cancel`,n)}download(e,n){return this._client.get("/finetune/download",{query:e,...n})}listEvents(e,n){return this._client.get(Gi`/fine-tunes/${e}/events`,n)}retrieveCheckpoints(e,n){return this._client.get(Gi`/fine-tunes/${e}/checkpoints`,n)}}class n9 extends Qn{list(e={},n){return this._client.get("/hardware",{query:e,...n})}}class r9 extends Qn{create(e,n){return this._client.post("/images/generations",{body:e,...n})}}class i9 extends Qn{retrieve(e,n){return this._client.get(Gi`/jobs/${e}`,n)}list(e){return this._client.get("/jobs",e)}}class s9 extends Qn{list(e){return this._client.get("/models",e)}upload(e,n){return this._client.post("/models",{body:e,...n})}}async function _re(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 Mk extends Promise{constructor(e,n,r=_re){super(i=>{i(null)}),this.responsePromise=n,this.parseResponse=r,lp.set(this,void 0),Lt(this,lp,e)}_thenUnwrap(e){return new Mk(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 Cre={};const p_=t=>{if(typeof globalThis.process<"u")return Cre?.[t]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(t)?.trim()};var TC,Ok,Cb,o9;class pt{constructor({baseURL:e=p_("TOGETHER_BASE_URL"),apiKey:n=p_("TOGETHER_API_KEY"),...r}={}){if(TC.add(this),Cb.set(this,void 0),this.chat=new Tk(this),this.completions=new J6(this),this.embeddings=new Q6(this),this.files=new e9(this),this.fineTune=new t9(this),this.codeInterpreter=new Rk(this),this.images=new r9(this),this.audio=new zx(this),this.models=new s9(this),this.jobs=new i9(this),this.endpoints=new Z6(this),this.hardware=new n9(this),this.batches=new W6(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??Ok.DEFAULT_TIMEOUT,this.logger=i.logger??console;const s="warn";this.logLevel=s,this.logLevel=gL(i.logLevel,"ClientOptions.logLevel",this)??gL(p_("TOGETHER_LOG"),"process.env['TOGETHER_LOG']",this)??s,this.fetchOptions=i.fetchOptions,this.maxRetries=i.maxRetries??5,this.fetch=i.fetch??tre(),Lt(this,Cb,rre),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-${C6()}`}makeStatusError(e,n,r,i){return yr.generate(e,n,r,i)}buildURL(e,n,r){const i=!Ae(this,TC,"m",o9).call(this)&&r||this.baseURL,s=Wne(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();return qne(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 Mk(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(bC),b=Date.now();if(y instanceof Error){const S=`retrying, ${n} attempts remaining`;if(i.signal?.aborted)throw new Cc;const _=yC(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 A6:new Fx({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 nre(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=>bC(M).message),E=Yne(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 Xne(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&&Kne("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))}:{},...ere()},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:L6(e)}:Ae(this,Cb,"f").call(this,{body:e,headers:r})}}Ok=pt,Cb=new WeakMap,TC=new WeakSet,o9=function(){return this.baseURL!=="https://api.together.xyz/v1"};pt.Together=Ok;pt.DEFAULT_TIMEOUT=6e4;pt.TogetherError=At;pt.APIError=yr;pt.APIConnectionError=Fx;pt.APIConnectionTimeoutError=A6;pt.APIUserAbortError=Cc;pt.NotFoundError=R6;pt.ConflictError=M6;pt.RateLimitError=P6;pt.BadRequestError=E6;pt.AuthenticationError=k6;pt.InternalServerError=D6;pt.PermissionDeniedError=T6;pt.UnprocessableEntityError=O6;pt.toFile=cre;pt.Chat=Tk;pt.Completions=J6;pt.Embeddings=Q6;pt.Files=e9;pt.FineTuneResource=t9;pt.CodeInterpreter=Rk;pt.Images=r9;pt.Audio=zx;pt.Models=s9;pt.Jobs=i9;pt.Endpoints=Z6;pt.Hardware=n9;pt.Batches=W6;const Are=t=>{const e=[];return t.forEach(n=>{e.push({type:"function",function:{name:n.name,description:n.description,parameters:{type:"object",...n.inputSchema}}})}),e},uy=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},Ere=(t,e,n)=>{if(!e.delta.content)return t;let r=mo(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=mo({...s,text:o});r={...r,content:[...i.slice(0,-1),a]}}return r},kre=(t,e)=>{let n=mo(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 Tre{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=uy(e)};setTools=e=>{this.tools=Are(e)};async createChatName(e){try{if(!this.client)return"";const n={role:"system",content:Dx};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=uy(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,max_tokens:2048});this.prevMessages.push(...i);let a=n&&r?mo(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=uy([m]);this.prevMessages.push(...y);return}d.delta.content&&(a=Ere(a,d,n)),d.delta.tool_calls&&typeof a.content!="string"&&(a=kre(a,d))}}),this.stopStream){if(typeof a.content=="string",a.content.length>0){const m=uy([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:"openai"}))}const vL=new Tre;let Rre=class{currentProvider;currentProviderInfo;currentProviderType;anthropicProvider;ollamaProvider;openaiProvider;togetherProvider;constructor(){this.anthropicProvider=EI,this.ollamaProvider=MI,this.openaiProvider=iL,this.togetherProvider=vL}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=EI,this.currentProviderType="anthropic";break;case"ollama":this.currentProvider=MI,this.currentProviderType="ollama";break;case"openai":this.currentProvider=iL,this.currentProviderType="openai";break;case"together":this.currentProvider=vL,this.currentProviderType="together";break;default:this.currentProvider=void 0,this.currentProviderType=void 0}this.currentProvider&&(this.currentProvider.setProvider(e),this.currentProvider.setSystemPrompt(Zee))};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?this.currentProvider.createChatName(e):"";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()};return[e,n,r,i]};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()}:{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):!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}):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"){const a=i[s];a.status==="fulfilled"&&a.value&&a.value.length>0&&n.set(o.name,a.value),s++}}),n}};const $t=new Rre;class Mre{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 ts=new Mre,Ore=()=>ts.init(),hy=async(t,e,n)=>{const r=ts.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()})},a9=async(t,e)=>{const n=ts.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)}})},Pre=async(t,e)=>{const n=ts.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()}})},Dre=async t=>{const e=ts.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 a9(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()}})),zm=na(t=>({currentPage:"chat",setCurrentPage:e=>t({currentPage:e}),goToChat:()=>t({currentPage:"chat"}),goToSettings:()=>t({currentPage:"settings"})})),fy="providers",ju="current-provider",m_="current-model",bh=100,Ab=bh+2,ns=na()((t,e)=>({providers:(()=>{const n=localStorage.getItem(fy);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(fy,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(fy,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(fy,JSON.stringify(i)),{providers:i}})}}));class Ire{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 xL=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 Lre{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}=xL(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}=xL(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 wL="webSearchProviderData";let Nre=class{tools;webSearchData=null;constructor(){this.tools=[];const e=localStorage.getItem(wL);e?this.webSearchData=JSON.parse(e):this.webSearchData=null,this.initTools()}setWebSearchData=e=>{this.webSearchData=e,localStorage.setItem(wL,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 SL="allowAlwaysTools";let $re=class{desktopEditorTool;customServers;webSearch;allowAlways;constructor(){this.desktopEditorTool=new Ire,this.customServers=new Lre,this.webSearch=new Nre,this.allowAlways=localStorage.getItem(SL)?.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(SL,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 Zt=new $re,dy="disabledTools",py="mcpServers",Ts=na((t,e)=>({servers:{},tools:[],disabledTools:{},manageToolData:void 0,webSearchEnabled:!1,initServers:()=>{const n=localStorage.getItem(py);if(n){const r=JSON.parse(n);Zt.setCustomServers(r),Zt.startCustomServers()}},getTools:async()=>{const n=await Zt.getTools(),r=localStorage.getItem(dy),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===Ab: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?Ab: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(dy,JSON.stringify(h));return}if(s.tools.length>=(s.webSearchEnabled?Ab: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(dy,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(dy,JSON.stringify(h))}t({servers:{...o,[n]:o[n].map(c=>c.name===r?{...c,enabled:i}:c)}})}},checkAllowAlways:(n,r)=>Zt.checkAllowAlways(n,r),setAllowAlways:(n,r,i)=>{Zt.setAllowAlways(n,r,i)},callTools:async(n,r)=>{const i=e(),s=Zt.getServerType(n),o=n.replace(s+"_","");if(!i.disabledTools[s].find(c=>c===o))return await Zt.callTools(s,o,r)},setManageToolData:n=>{t({manageToolData:n})},getConfig:()=>JSON.parse(localStorage.getItem(py)||JSON.stringify({mcpServers:{}})),saveConfig:n=>{const r=n.mcpServers?n:{mcpServers:{}};localStorage.setItem(py,JSON.stringify(r)),Zt.setCustomServers(r),Zt.startCustomServers()},deleteCustomServer:n=>{Zt.deleteCustomServer(n);const r=e().getConfig();delete r.mcpServers[n],localStorage.setItem(py,JSON.stringify(r))},getCustomServersLogs:()=>Zt.getCustomServersLogs(),getWebSearchEnabled:()=>Zt.getWebSearchEnabled()})),jre=(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)},_L={},RC=(t,e,n,r)=>{gc(n)&&_L[n]||(gc(n)&&(_L[n]=new Date),jre(t,e,n,r))},l9=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},MC=(t,e,n)=>{t.loadNamespaces(e,l9(t,n))},CL=(t,e,n,r)=>{if(gc(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return MC(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,l9(t,r))},Bre=(t,e,n={})=>!e.languages||!e.languages.length?(RC(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",Fre=t=>typeof t=="object"&&t!==null,zre=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Vre={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},Ure=t=>Vre[t],Hre=t=>t.replace(zre,Ure);let OC={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Hre};const Wre=(t={})=>{OC={...OC,...t}},qre=()=>OC;let c9;const Gre=t=>{c9=t},Kre=()=>c9,Yre={type:"3rdParty",init(t){Wre(t.options.react),Gre(t)}},Xre=k.createContext();class Jre{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const Qre=(t,e)=>{const n=k.useRef();return k.useEffect(()=>{n.current=t},[t,e]),n.current},u9=(t,e,n,r)=>t.getFixedT(e,n,r),Zre=(t,e,n,r)=>k.useCallback(u9(t,e,n,r),[t,e,n,r]),wt=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=k.useContext(Xre)||{},s=n||r||Kre();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new Jre),!s){RC(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const P=(M,D)=>gc(D)?D:Fre(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&&RC(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=>Bre(P,s,o)),d=Zre(s,e.lng||null,o.nsMode==="fallback"?h:h[0],c),m=()=>d,y=()=>u9(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 _=Qre(S),A=k.useRef(!0);k.useEffect(()=>{const{bindI18n:P,bindI18nStore:O}=o;A.current=!0,!f&&!a&&(e.lng?CL(s,e.lng,h,()=>{A.current&&x(y)}):MC(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?CL(s,e.lng,h,()=>P()):MC(s,h,()=>P())})};function h9(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=h9(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function pv(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=h9(t))&&(r&&(r+=" "),r+=e);return r}const AL=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,EL=pv,eie=(t,e)=>n=>{var r;if(e?.variants==null)return EL(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=AL(f)||AL(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 EL(t,o,c,n?.class,n?.className)},Pk="-",tie=t=>{const e=rie(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const a=o.split(Pk);return a[0]===""&&a.length!==1&&a.shift(),f9(a,e)||nie(o)},getConflictingClassGroupIds:(o,a)=>{const c=n[o]||[];return a&&r[o]?[...c,...r[o]]:c}}},f9=(t,e)=>{if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?f9(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(Pk);return e.validators.find(({validator:o})=>o(s))?.classGroupId},kL=/^\[(.+)\]$/,nie=t=>{if(kL.test(t)){const e=kL.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},rie=t=>{const{theme:e,classGroups:n}=t,r={nextPart:new Map,validators:[]};for(const i in n)PC(n[i],r,i,e);return r},PC=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:TL(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(iie(i)){PC(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{PC(o,TL(e,s),n,r)})})},TL=(t,e)=>{let n=t;return e.split(Pk).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},iie=t=>t.isThemeGetter,sie=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)}}},DC="!",IC=":",oie=IC.length,aie=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===IC){s.push(i.slice(c,b)),c=b+oie;continue}if(x==="/"){h=b;continue}}x==="["?o++:x==="]"?o--:x==="("?a++:x===")"&&a--}const f=s.length===0?i:i.substring(c),d=lie(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+IC,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},lie=t=>t.endsWith(DC)?t.substring(0,t.length-1):t.startsWith(DC)?t.substring(1):t,cie=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}},uie=t=>({cache:sie(t.cacheSize),parseClassName:aie(t),sortModifiers:cie(t),...tie(t)}),hie=/\s+/,fie=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=e,o=[],a=t.trim().split(hie);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+DC: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 die(){let t=0,e,n,r="";for(;t<arguments.length;)(e=arguments[t++])&&(n=d9(e))&&(r&&(r+=" "),r+=n);return r}const d9=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=d9(t[r]))&&(n&&(n+=" "),n+=e);return n};function pie(t,...e){let n,r,i,s=o;function o(c){const h=e.reduce((f,d)=>d(f),t());return n=uie(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=fie(c,n);return i(c,f),f}return function(){return s(die.apply(null,arguments))}}const Sn=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},p9=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,m9=/^\((?:(\w[\w-]*):)?(.+)\)$/i,mie=/^\d+\/\d+$/,gie=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,yie=/\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$/,bie=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,vie=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,xie=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Bu=t=>mie.test(t),tt=t=>!!t&&!Number.isNaN(Number(t)),qa=t=>!!t&&Number.isInteger(Number(t)),g_=t=>t.endsWith("%")&&tt(t.slice(0,-1)),zo=t=>gie.test(t),wie=()=>!0,Sie=t=>yie.test(t)&&!bie.test(t),g9=()=>!1,_ie=t=>vie.test(t),Cie=t=>xie.test(t),Aie=t=>!Re(t)&&!Me(t),Eie=t=>Xh(t,v9,g9),Re=t=>p9.test(t),Yl=t=>Xh(t,x9,Sie),y_=t=>Xh(t,Oie,tt),RL=t=>Xh(t,y9,g9),kie=t=>Xh(t,b9,Cie),my=t=>Xh(t,w9,_ie),Me=t=>m9.test(t),Rd=t=>Jh(t,x9),Tie=t=>Jh(t,Pie),ML=t=>Jh(t,y9),Rie=t=>Jh(t,v9),Mie=t=>Jh(t,b9),gy=t=>Jh(t,w9,!0),Xh=(t,e,n)=>{const r=p9.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},Jh=(t,e,n=!1)=>{const r=m9.exec(t);return r?r[1]?e(r[1]):n:!1},y9=t=>t==="position"||t==="percentage",b9=t=>t==="image"||t==="url",v9=t=>t==="length"||t==="size"||t==="bg-size",x9=t=>t==="length",Oie=t=>t==="number",Pie=t=>t==="family-name",w9=t=>t==="shadow",Die=()=>{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(),ML,RL,{position:[Me,Re]}],T=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Z=()=>["auto","cover","contain",Rie,Eie,{size:[Me,Re]}],ue=()=>[g_,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,g_,ML,RL],Ue=()=>["","none",b,Me,Re],Pt=()=>["none",tt,Me,Re],Yt=()=>["none",tt,Me,Re],Xt=()=>[tt,Me,Re],er=()=>[Bu,"full",...N()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[zo],breakpoint:[zo],color:[wie],container:[zo],"drop-shadow":[zo],ease:["in","out","in-out"],font:[Aie],"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,y_]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",g_,Re]}],"font-family":[{font:[Tie,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,y_]}],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]},Mie,kie]}],"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,gy,my]}],"shadow-color":[{shadow:U()}],"inset-shadow":[{"inset-shadow":["none",d,gy,my]}],"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,gy,my]}],"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,gy,my]}],"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:Yt()}],"scale-x":[{"scale-x":Yt()}],"scale-y":[{"scale-y":Yt()}],"scale-z":[{"scale-z":Yt()}],"scale-3d":["scale-3d"],skew:[{skew:Xt()}],"skew-x":[{"skew-x":Xt()}],"skew-y":[{"skew-y":Xt()}],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,y_]}],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"]}},Iie=pie(Die),je=(...t)=>Iie(pv(t)),S9=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},Lie=t=>t.split(`
|
||
`)[0].replace("## ","").substring(0,30),_9=t=>!!(t&64),C9=t=>!!(t&128),Eb=t=>!!(t&256),A9=t=>t===513||t===521,Nie="inline-flex items-center justify-center rounded-[4px] min-w-[40px]",$ie="outline-none focus:outline-none focus-visible:outline-none",jie="bg-[var(--button-default-background-color)] border border-[var(--button-default-border-color)] text-[var(--button-default-color)]",Bie="hover:enabled:bg-[var(--button-default-hover-background-color)]",Fie="active:enabled:bg-[var(--button-default-pressed-background-color)]",zie="focus:shadow-[var(--button-default-focus-shadow)]",Vie="disabled:bg-[var(--button-default-disabled-background-color)] disabled:text-[var(--button-default-disabled-color)] disabled:opacity-40 disabled:cursor-not-allowed",Uie="bg-[var(--button-background-color)] text-[var(--button-color)]",Hie="hover:enabled:bg-[var(--button-background-hover-color)]",Wie="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)]",Gie="disabled:opacity-50 disabled:cursor-not-allowed",Kie="h-[32px] min-w-[40px] px-[12px] text-[14px] font-semibold leading-[16px]",Yie=eie(`${Nie} ${$ie}`,{variants:{variant:{default:je(jie,Bie,Fie,zie,Vie),primary:je(Uie,Hie,Wie,qie,Gie)},size:{default:Kie},scale:{default:"w-fit",scale:"w-full"}},defaultVariants:{variant:"primary",size:"default",scale:"default"}}),tn=({className:t,variant:e,size:n,asChild:r=!1,...i})=>{const s=r?rj:"button";return C.jsx(s,{"data-slot":"button",className:je("cursor-pointer",Yie({variant:e,size:n,className:t})),...i})},Xie=()=>{const{t}=wt(),{setCurrentPage:e}=zm();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(tn,{onClick:()=>e("settings"),children:t("ConnectAIModelBtn")})]})})};function E9(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 Jie=k.createContext(void 0);function Dk(t){const e=k.useContext(Jie);return t||e||"ltr"}var b_="rovingFocusGroup.onEntryFocus",Qie={bubbles:!1,cancelable:!0},Vm="RovingFocusGroup",[LC,k9,Zie]=E9(Vm),[ese,Ux]=ra(Vm,[Zie]),[tse,nse]=ese(Vm),T9=k.forwardRef((t,e)=>C.jsx(LC.Provider,{scope:t.__scopeRovingFocusGroup,children:C.jsx(LC.Slot,{scope:t.__scopeRovingFocusGroup,children:C.jsx(rse,{...t,ref:e})})}));T9.displayName=Vm;var rse=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=Dk(s),[x,S]=qh({prop:o,defaultProp:a??null,onChange:c,caller:Vm}),[_,A]=k.useState(!1),E=Lr(h),P=k9(n),O=k.useRef(!1),[M,D]=k.useState(0);return k.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(b_,E),()=>N.removeEventListener(b_,E)},[E]),C.jsx(tse,{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(b_,Qie);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);O9(te,f)}}O.current=!1}),onBlur:Le(t.onBlur,()=>A(!1))})})}),R9="RovingFocusGroupItem",M9=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=nse(R9,n),d=f.currentTabStopId===h,m=k9(n),{onFocusableItemAdd:y,onFocusableItemRemove:b,currentTabStopId:x}=f;return k.useEffect(()=>{if(r)return y(),()=>b()},[r,y,b]),C.jsx(LC.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 _=ose(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?ase(E,P+1):E.slice(P+1)}setTimeout(()=>O9(E))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:x!=null}):o})})});M9.displayName=R9;var ise={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function sse(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function ose(t,e,n){const r=sse(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return ise[r]}function O9(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function ase(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var P9=T9,D9=M9,Hx="Tabs",[lse]=ra(Hx,[Ux]),I9=Ux(),[cse,Ik]=lse(Hx),L9=k.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:o="horizontal",dir:a,activationMode:c="automatic",...h}=t,f=Dk(a),[d,m]=qh({prop:r,onChange:i,defaultProp:s??"",caller:Hx});return C.jsx(cse,{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})})});L9.displayName=Hx;var N9="TabsList",$9=k.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...i}=t,s=Ik(N9,n),o=I9(n);return C.jsx(P9,{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})})});$9.displayName=N9;var j9="TabsTrigger",B9=k.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=t,o=Ik(j9,n),a=I9(n),c=V9(o.baseId,r),h=U9(o.baseId,r),f=r===o.value;return C.jsx(D9,{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)})})})});B9.displayName=j9;var F9="TabsContent",z9=k.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...o}=t,a=Ik(F9,n),c=V9(a.baseId,r),h=U9(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(ks,{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})})});z9.displayName=F9;function V9(t,e){return`${t}-trigger-${e}`}function U9(t,e){return`${t}-content-${e}`}var use=L9,hse=$9,fse=B9,dse=z9;const pse=({items:t,defaultValue:e,value:n,onValueChange:r,className:i})=>C.jsxs(use,{defaultValue:e||t[0]?.value,value:n,onValueChange:r,className:je("w-full",i),children:[C.jsx(hse,{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(fse,{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(dse,{value:s.value,className:"mt-[24px]",children:s.content},s.value))]}),Lk="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",Nk="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",mse="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",H9="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 NC(t,e){return NC=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},NC(t,e)}function gse(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,NC(t,e)}var yy={};/*!
|
||
* content-type
|
||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||
* MIT Licensed
|
||
*/var OL;function yse(){if(OL)return yy;OL=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-]+$/;yy.format=o,yy.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 yy}var bse=yse(),Ju=new Map,W9=function(e){return e.cloneNode(!0)},PL=function(){return window.location.protocol==="file:"},q9=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=bse.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(PL()?"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||PL()&&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={},DL=function(e,n){Za[e]=Za[e]||[],Za[e].push(n)},vse=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,W9(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)},xse=function(e,n,r){if(Ju.has(e)){var i=Ju.get(e);if(i===void 0){DL(e,r);return}if(i instanceof SVGSVGElement){r(null,W9(i));return}}Ju.set(e,void 0),DL(e,r),q9(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),vse(e)})},wse=function(e,n,r){q9(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)})},Sse=0,_se=function(){return++Sse},Us=[],IL={},Cse="http://www.w3.org/2000/svg",v_="http://www.w3.org/1999/xlink",LL=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(Us.indexOf(e)!==-1){Us.splice(Us.indexOf(e),1),e=null;return}Us.push(e),e.setAttribute("src","");var h=i?xse:wse;h(c,s,function(f,d){if(!d){Us.splice(Us.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(rb(rb(rb([],(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+"-"+_se();var ke;Array.prototype.forEach.call(M,function(tr){ke=d.querySelectorAll("["+tr+'*="'+D+'"]');for(var ei=0,_o=ke.length;ei<_o;ei++){var is=ke[ei].getAttribute(tr);is&&!is.match(new RegExp('url\\("?#'+D+'"?\\)'))||ke[ei].setAttribute(tr,"url(#"+N+")")}});for(var ye=d.querySelectorAll("[*|href]"),Ee=[],Ue=0,Pt=ye.length;Ue<Pt;Ue++){var Yt=ye[Ue].getAttributeNS(v_,"href");Yt&&Yt.toString()==="#"+O[L].id&&Ee.push(ye[Ue])}for(var Xt=0,er=Ee.length;Xt<er;Xt++)Ee[Xt].setAttributeNS(v_,"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"&&!IL[c])){for(var te=0,z=j.length;te<z;te++)new Function(j[te])(window);IL[c]=!0}var G=d.querySelectorAll("style");if(Array.prototype.forEach.call(G,function(U){U.textContent+=""}),d.setAttribute("xmlns",Cse),d.setAttribute("xmlns:xlink",v_),o(d),!e.parentNode){Us.splice(Us.indexOf(e),1),e=null,a(new Error("Parent node is null"));return}e.parentNode.replaceChild(d,e),Us.splice(Us.indexOf(e),1),e=null,a(null,d)})},Ase=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++)LL(e[E],y,_,d,x,h,function(O,M){a(O,M),e&&"length"in e&&e.length===++A&&s(A)});else e?LL(e,y,_,d,x,h,function(O,M){a(O,M),s(1),e=null}):s(0)},x_={exports:{}},w_,NL;function Ese(){if(NL)return w_;NL=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return w_=t,w_}var S_,$L;function kse(){if($L)return S_;$L=1;var t=Ese();function e(){}function n(){}return n.resetWarningCache=e,S_=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},S_}var jL;function Tse(){return jL||(jL=1,x_.exports=kse()()),x_.exports}var _n=Tse(),Rse=function(e){var n=e?.ownerDocument||document;return n.defaultView||window},Mse=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},Ose=["afterInjection","beforeInjection","desc","evalScripts","fallback","httpRequestWithCredentials","loading","renumerateIRIElements","src","title","useRequestCache","wrapper"],by="http://www.w3.org/2000/svg",BL="http://www.w3.org/1999/xlink",Gt=(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}gse(e,t);var n=e.prototype;return n.renderSVG=function(){var i=this;if(this.reactWrapper instanceof Rse(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(by,S),_.setAttribute("xmlns",by),_.setAttribute("xmlns:xlink",BL),A=document.createElementNS(by,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)}};Ase(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;Mse(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=nB(i,Ose),h=a;return k.createElement(h,Gp({},c,{ref:this.refCallback},a==="svg"?{xmlns:by,xmlnsXlink:BL}:{}),this.state.isLoading&&o&&k.createElement(o,null),this.state.hasError&&s&&k.createElement(s,null))},e})(k.Component);Gt.defaultProps={afterInjection:function(){},beforeInjection:function(){},desc:"",evalScripts:"never",fallback:null,httpRequestWithCredentials:!1,loading:null,onError:function(){},renumerateIRIElements:!0,title:"",useRequestCache:!0,wrapper:"div"};Gt.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 xt=({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(Gt,{src:t,className:`flex items-center justify-center ${r?"rotate-90":""}`,beforeInjection:_})})};var $C=["Enter"," "],Pse=["ArrowDown","PageUp","Home"],G9=["ArrowUp","PageDown","End"],Dse=[...Pse,...G9],Ise={ltr:[...$C,"ArrowRight"],rtl:[...$C,"ArrowLeft"]},Lse={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Um="Menu",[Jp,Nse,$se]=E9(Um),[Ic,K9]=ra(Um,[$se,Tx,Ux]),Wx=Tx(),Y9=Ux(),[jse,Lc]=Ic(Um),[Bse,Hm]=Ic(Um),X9=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=t,a=Wx(e),[c,h]=k.useState(null),f=k.useRef(!1),d=Lr(s),m=Dk(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(Nj,{...a,children:C.jsx(jse,{scope:e,open:n,onOpenChange:d,content:c,onContentChange:h,children:C.jsx(Bse,{scope:e,onClose:k.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:f,dir:m,modal:o,children:r})})})};X9.displayName=Um;var Fse="MenuAnchor",$k=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=Wx(n);return C.jsx($j,{...i,...r,ref:e})});$k.displayName=Fse;var jk="MenuPortal",[zse,J9]=Ic(jk,{forceMount:void 0}),Q9=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:i}=t,s=Lc(jk,e);return C.jsx(zse,{scope:e,forceMount:n,children:C.jsx(ks,{present:n||s.open,children:C.jsx(Rx,{asChild:!0,container:i,children:r})})})};Q9.displayName=jk;var Xi="MenuContent",[Vse,Bk]=Ic(Xi),Z9=k.forwardRef((t,e)=>{const n=J9(Xi,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=Lc(Xi,t.__scopeMenu),o=Hm(Xi,t.__scopeMenu);return C.jsx(Jp.Provider,{scope:t.__scopeMenu,children:C.jsx(ks,{present:r||s.open,children:C.jsx(Jp.Slot,{scope:t.__scopeMenu,children:o.modal?C.jsx(Use,{...i,ref:e}):C.jsx(Hse,{...i,ref:e})})})})}),Use=k.forwardRef((t,e)=>{const n=Lc(Xi,t.__scopeMenu),r=k.useRef(null),i=Bt(e,r);return k.useEffect(()=>{const s=r.current;if(s)return zj(s)},[]),C.jsx(Fk,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Le(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Hse=k.forwardRef((t,e)=>{const n=Lc(Xi,t.__scopeMenu);return C.jsx(Fk,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Wse=Rh("MenuContent.ScrollLock"),Fk=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(Xi,n),_=Hm(Xi,n),A=Wx(n),E=Y9(n),P=Nse(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?VE:k.Fragment,z=b?{as:Wse,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=roe(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),[]),fj();const U=k.useCallback(se=>X.current===q.current?.side&&soe(se,q.current?.area),[]);return C.jsx(Vse,{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(DE,{asChild:!0,trapped:i,onMountAutoFocus:Le(s,se=>{se.preventDefault(),D.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:C.jsx(_x,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:d,onInteractOutside:m,onDismiss:y,children:C.jsx(P9,{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(jj,{role:"menu","aria-orientation":"vertical","data-state":mF(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||!Dse.includes(se.key))return;se.preventDefault();const ye=P().filter(Ee=>!Ee.disabled).map(Ee=>Ee.ref.current);G9.includes(se.key)&&ye.reverse(),toe(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}}))})})})})})})});Z9.displayName=Xi;var qse="MenuGroup",zk=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return C.jsx(st.div,{role:"group",...r,ref:e})});zk.displayName=qse;var Gse="MenuLabel",eF=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return C.jsx(st.div,{...r,ref:e})});eF.displayName=Gse;var mv="MenuItem",FL="menu.itemSelect",qx=k.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...i}=t,s=k.useRef(null),o=Hm(mv,t.__scopeMenu),a=Bk(mv,t.__scopeMenu),c=Bt(e,s),h=k.useRef(!1),f=()=>{const d=s.current;if(!n&&d){const m=new CustomEvent(FL,{bubbles:!0,cancelable:!0});d.addEventListener(FL,y=>r?.(y),{once:!0}),sj(d,m),m.defaultPrevented?h.current=!1:o.onClose()}};return C.jsx(tF,{...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===" "||$C.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});qx.displayName=mv;var tF=k.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=t,o=Bk(mv,n),a=Y9(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(D9,{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))})})})}),Kse="MenuCheckboxItem",nF=k.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...i}=t;return C.jsx(aF,{scope:t.__scopeMenu,checked:n,children:C.jsx(qx,{role:"menuitemcheckbox","aria-checked":gv(n)?"mixed":n,...i,ref:e,"data-state":Uk(n),onSelect:Le(i.onSelect,()=>r?.(gv(n)?!0:!n),{checkForDefaultPrevented:!1})})})});nF.displayName=Kse;var rF="MenuRadioGroup",[Yse,Xse]=Ic(rF,{value:void 0,onValueChange:()=>{}}),iF=k.forwardRef((t,e)=>{const{value:n,onValueChange:r,...i}=t,s=Lr(r);return C.jsx(Yse,{scope:t.__scopeMenu,value:n,onValueChange:s,children:C.jsx(zk,{...i,ref:e})})});iF.displayName=rF;var sF="MenuRadioItem",oF=k.forwardRef((t,e)=>{const{value:n,...r}=t,i=Xse(sF,t.__scopeMenu),s=n===i.value;return C.jsx(aF,{scope:t.__scopeMenu,checked:s,children:C.jsx(qx,{role:"menuitemradio","aria-checked":s,...r,ref:e,"data-state":Uk(s),onSelect:Le(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});oF.displayName=sF;var Vk="MenuItemIndicator",[aF,Jse]=Ic(Vk,{checked:!1}),lF=k.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...i}=t,s=Jse(Vk,n);return C.jsx(ks,{present:r||gv(s.checked)||s.checked===!0,children:C.jsx(st.span,{...i,ref:e,"data-state":Uk(s.checked)})})});lF.displayName=Vk;var Qse="MenuSeparator",cF=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return C.jsx(st.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});cF.displayName=Qse;var Zse="MenuArrow",uF=k.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=Wx(n);return C.jsx(Bj,{...i,...r,ref:e})});uF.displayName=Zse;var eoe="MenuSub",[z6e,hF]=Ic(eoe),cp="MenuSubTrigger",fF=k.forwardRef((t,e)=>{const n=Lc(cp,t.__scopeMenu),r=Hm(cp,t.__scopeMenu),i=hF(cp,t.__scopeMenu),s=Bk(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($k,{asChild:!0,...h,children:C.jsx(tF,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":mF(n.open),...t,ref:Sx(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===" "||Ise[r.dir].includes(d.key)&&(n.onOpenChange(!0),n.content?.focus(),d.preventDefault())})})})});fF.displayName=cp;var dF="MenuSubContent",pF=k.forwardRef((t,e)=>{const n=J9(Xi,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=Lc(Xi,t.__scopeMenu),o=Hm(Xi,t.__scopeMenu),a=hF(dF,t.__scopeMenu),c=k.useRef(null),h=Bt(e,c);return C.jsx(Jp.Provider,{scope:t.__scopeMenu,children:C.jsx(ks,{present:r||s.open,children:C.jsx(Jp.Slot,{scope:t.__scopeMenu,children:C.jsx(Fk,{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=Lse[o.dir].includes(f.key);d&&m&&(s.onOpenChange(!1),a.trigger?.focus(),f.preventDefault())})})})})})});pF.displayName=dF;function mF(t){return t?"open":"closed"}function gv(t){return t==="indeterminate"}function Uk(t){return gv(t)?"indeterminate":t?"checked":"unchecked"}function toe(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function noe(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function roe(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=noe(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 ioe(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 soe(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return ioe(n,e)}function Qp(t){return e=>e.pointerType==="mouse"?t(e):void 0}var ooe=X9,aoe=$k,loe=Q9,coe=Z9,uoe=zk,hoe=eF,foe=qx,doe=nF,poe=iF,moe=oF,goe=lF,yoe=cF,boe=uF,voe=fF,xoe=pF,Gx="DropdownMenu",[woe]=ra(Gx,[K9]),Nr=K9(),[Soe,gF]=woe(Gx),yF=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:Gx});return C.jsx(Soe,{scope:e,triggerId:ol(),triggerRef:h,contentId:ol(),open:f,onOpenChange:d,onOpenToggle:k.useCallback(()=>d(m=>!m),[d]),modal:a,children:C.jsx(ooe,{...c,open:f,onOpenChange:d,dir:r,modal:a,children:n})})};yF.displayName=Gx;var bF="DropdownMenuTrigger",vF=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=t,s=gF(bF,n),o=Nr(n);return C.jsx(aoe,{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:Sx(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())})})})});vF.displayName=bF;var _oe="DropdownMenuPortal",xF=t=>{const{__scopeDropdownMenu:e,...n}=t,r=Nr(e);return C.jsx(loe,{...r,...n})};xF.displayName=_oe;var wF="DropdownMenuContent",SF=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=gF(wF,n),s=Nr(n),o=k.useRef(!1);return C.jsx(coe,{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)"}})});SF.displayName=wF;var Coe="DropdownMenuGroup",Aoe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(uoe,{...i,...r,ref:e})});Aoe.displayName=Coe;var Eoe="DropdownMenuLabel",koe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(hoe,{...i,...r,ref:e})});koe.displayName=Eoe;var Toe="DropdownMenuItem",_F=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(foe,{...i,...r,ref:e})});_F.displayName=Toe;var Roe="DropdownMenuCheckboxItem",Moe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(doe,{...i,...r,ref:e})});Moe.displayName=Roe;var Ooe="DropdownMenuRadioGroup",Poe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(poe,{...i,...r,ref:e})});Poe.displayName=Ooe;var Doe="DropdownMenuRadioItem",Ioe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(moe,{...i,...r,ref:e})});Ioe.displayName=Doe;var Loe="DropdownMenuItemIndicator",Noe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(goe,{...i,...r,ref:e})});Noe.displayName=Loe;var $oe="DropdownMenuSeparator",joe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(yoe,{...i,...r,ref:e})});joe.displayName=$oe;var Boe="DropdownMenuArrow",Foe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(boe,{...i,...r,ref:e})});Foe.displayName=Boe;var zoe="DropdownMenuSubTrigger",Voe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(voe,{...i,...r,ref:e})});Voe.displayName=zoe;var Uoe="DropdownMenuSubContent",Hoe=k.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Nr(n);return C.jsx(xoe,{...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)"}})});Hoe.displayName=Uoe;var Woe=yF,qoe=vF,Goe=xF,Koe=SF,Yoe=_F;const Hk="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 Xoe=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"}),Joe="VisuallyHidden",CF=k.forwardRef((t,e)=>C.jsx(st.span,{...t,ref:e,style:{...Xoe,...t.style}}));CF.displayName=Joe;var Qoe=CF,[Kx]=ra("Tooltip",[Tx]),Yx=Tx(),AF="TooltipProvider",Zoe=700,jC="tooltip.open",[eae,Wk]=Kx(AF),EF=t=>{const{__scopeTooltip:e,delayDuration:n=Zoe,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(eae,{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})};EF.displayName=AF;var Zp="Tooltip",[tae,Wm]=Kx(Zp),kF=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=t,c=Wk(Zp,t.__scopeTooltip),h=Yx(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(jC))):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(Nj,{...h,children:C.jsx(tae,{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})})};kF.displayName=Zp;var BC="TooltipTrigger",TF=k.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Wm(BC,n),s=Wk(BC,n),o=Yx(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($j,{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)})})});TF.displayName=BC;var qk="TooltipPortal",[nae,rae]=Kx(qk,{forceMount:void 0}),RF=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:i}=t,s=Wm(qk,e);return C.jsx(nae,{scope:e,forceMount:n,children:C.jsx(ks,{present:n||s.open,children:C.jsx(Rx,{asChild:!0,container:i,children:r})})})};RF.displayName=qk;var Ph="TooltipContent",MF=k.forwardRef((t,e)=>{const n=rae(Ph,t.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=t,o=Wm(Ph,t.__scopeTooltip);return C.jsx(ks,{present:r||o.open,children:o.disableHoverableContent?C.jsx(OF,{side:i,...s,ref:e}):C.jsx(iae,{side:i,...s,ref:e})})}),iae=k.forwardRef((t,e)=>{const n=Wm(Ph,t.__scopeTooltip),r=Wk(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=cae(_,S.getBoundingClientRect()),E=uae(_,A),P=hae(x.getBoundingClientRect()),O=dae([...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=!fae(_,o);A?m():E&&(m(),h())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[c,f,o,h,m]),C.jsx(OF,{...t,ref:s})}),[sae,oae]=Kx(Zp,{isInside:!1}),aae=GX("TooltipContent"),OF=k.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=t,c=Wm(Ph,n),h=Yx(n),{onClose:f}=c;return k.useEffect(()=>(document.addEventListener(jC,f),()=>document.removeEventListener(jC,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(_x,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:f,children:C.jsxs(jj,{"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(aae,{children:r}),C.jsx(sae,{scope:n,isInside:!0,children:C.jsx(Qoe,{id:c.contentId,role:"tooltip",children:i||r})})]})})});MF.displayName=Ph;var PF="TooltipArrow",lae=k.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Yx(n);return oae(PF,n).isInside?null:C.jsx(Bj,{...i,...r,ref:e})});lae.displayName=PF;function cae(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 uae(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 hae(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 fae(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 dae(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),pae(e)}function pae(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 mae=EF,gae=kF,yae=TF,bae=RF,vae=MF;const xae=({delayDuration:t=0,...e})=>C.jsx(mae,{"data-slot":"tooltip-provider",delayDuration:t,...e}),em=({...t})=>C.jsx(xae,{children:C.jsx(gae,{"data-slot":"tooltip",...t})}),tm=({...t})=>C.jsx(yae,{"data-slot":"tooltip-trigger",...t}),nm=({className:t,sideOffset:e=0,children:n,...r})=>C.jsx(bae,{container:document.getElementById("app"),children:C.jsx(vae,{"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 wae(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 Xx="Switch",[Sae]=ra(Xx),[_ae,Cae]=Sae(Xx),DF=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:Xx});return C.jsxs(_ae,{scope:n,checked:_,disabled:a,children:[C.jsx(st.button,{type:"button",role:"switch","aria-checked":_,"aria-required":o,"data-state":$F(_),"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(NF,{control:m,bubbles:!x.current,name:r,value:c,checked:_,required:o,disabled:a,form:f,style:{transform:"translateX(-100%)"}})]})});DF.displayName=Xx;var IF="SwitchThumb",LF=k.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,i=Cae(IF,n);return C.jsx(st.span,{"data-state":$F(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:e})});LF.displayName=IF;var Aae="SwitchBubbleInput",NF=k.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...i},s)=>{const o=k.useRef(null),a=Bt(o,s),c=wae(n),h=Ej(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}})});NF.displayName=Aae;function $F(t){return t?"checked":"unchecked"}var Eae=DF,kae=LF;const jF=({checked:t,onCheckedChange:e,disabled:n=!1,id:r,className:i})=>C.jsx("div",{className:"flex items-center gap-2",children:C.jsx(Eae,{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(kae,{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]")})})}),Tae=({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(Yoe,{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(xt,{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(xt,{iconName:Hk,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,{src:Oh}):null,o&&c?C.jsx("div",{onClick:D=>D.stopPropagation(),children:C.jsx(jF,{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(Woe,{open:c,onOpenChange:d,children:[C.jsx(qoe,{asChild:!0,children:t}),C.jsx(Goe,{container:h??m,children:C.jsx(Koe,{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?"w-[var(--radix-dropdown-menu-trigger-width)]":"w-fit",s),style:o?{maxWidth:o}:void 0,children:e.map((y,b)=>C.jsx(Tae,{...y},y.id||y.text||`item-${b}`))})})]})};var Jx="Dialog",[BF]=ra(Jx),[Rae,Rs]=BF(Jx),FF=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:Jx});return C.jsx(Rae,{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})};FF.displayName=Jx;var zF="DialogTrigger",Mae=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Rs(zF,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":Yk(i.open),...r,ref:s,onClick:Le(t.onClick,i.onOpenToggle)})});Mae.displayName=zF;var Gk="DialogPortal",[Oae,VF]=BF(Gk,{forceMount:void 0}),UF=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:i}=t,s=Rs(Gk,e);return C.jsx(Oae,{scope:e,forceMount:n,children:k.Children.map(r,o=>C.jsx(ks,{present:n||s.open,children:C.jsx(Rx,{asChild:!0,container:i,children:o})}))})};UF.displayName=Gk;var yv="DialogOverlay",HF=k.forwardRef((t,e)=>{const n=VF(yv,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,s=Rs(yv,t.__scopeDialog);return s.modal?C.jsx(ks,{present:r||s.open,children:C.jsx(Dae,{...i,ref:e})}):null});HF.displayName=yv;var Pae=Rh("DialogOverlay.RemoveScroll"),Dae=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Rs(yv,n);return C.jsx(VE,{as:Pae,allowPinchZoom:!0,shards:[i.contentRef],children:C.jsx(st.div,{"data-state":Yk(i.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Ac="DialogContent",WF=k.forwardRef((t,e)=>{const n=VF(Ac,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,s=Rs(Ac,t.__scopeDialog);return C.jsx(ks,{present:r||s.open,children:s.modal?C.jsx(Iae,{...i,ref:e}):C.jsx(Lae,{...i,ref:e})})});WF.displayName=Ac;var Iae=k.forwardRef((t,e)=>{const n=Rs(Ac,t.__scopeDialog),r=k.useRef(null),i=Bt(e,n.contentRef,r);return k.useEffect(()=>{const s=r.current;if(s)return zj(s)},[]),C.jsx(qF,{...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())})}),Lae=k.forwardRef((t,e)=>{const n=Rs(Ac,t.__scopeDialog),r=k.useRef(!1),i=k.useRef(!1);return C.jsx(qF,{...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()}})}),qF=k.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=t,a=Rs(Ac,n),c=k.useRef(null),h=Bt(e,c);return fj(),C.jsxs(C.Fragment,{children:[C.jsx(DE,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:C.jsx(_x,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Yk(a.open),...o,ref:h,onDismiss:()=>a.onOpenChange(!1)})}),C.jsxs(C.Fragment,{children:[C.jsx($ae,{titleId:a.titleId}),C.jsx(Bae,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Kk="DialogTitle",GF=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Rs(Kk,n);return C.jsx(st.h2,{id:i.titleId,...r,ref:e})});GF.displayName=Kk;var KF="DialogDescription",YF=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Rs(KF,n);return C.jsx(st.p,{id:i.descriptionId,...r,ref:e})});YF.displayName=KF;var XF="DialogClose",Nae=k.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=Rs(XF,n);return C.jsx(st.button,{type:"button",...r,ref:e,onClick:Le(t.onClick,()=>i.onOpenChange(!1))})});Nae.displayName=XF;function Yk(t){return t?"open":"closed"}var JF="DialogTitleWarning",[V6e,QF]=eJ(JF,{contentName:Ac,titleName:Kk,docsSlug:"dialog"}),$ae=({titleId:t})=>{const e=QF(JF),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},jae="DialogDescriptionWarning",Bae=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${QF(jae).contentName}}.`;return k.useEffect(()=>{const i=t.current?.getAttribute("aria-describedby");e&&i&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},Fae=FF,zae=UF,Vae=HF,Uae=WF,Hae=GF,Wae=YF;const wl=({...t})=>C.jsx(Fae,{"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",Gae="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",Kae=({...t})=>C.jsx(zae,{"data-slot":"dialog-portal",container:document.getElementById("app"),...t}),Yae=({className:t,...e})=>C.jsx(Vae,{"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}),Xae=({className:t,withWarningIcon:e,...n})=>C.jsx(Hae,{"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}),Jae=()=>C.jsx(C.Fragment,{children:C.jsx(Wae,{className:"hidden",children:"Dialog content"})}),Qae="w-[348px]",Zae="w-[548px]",ele=" 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]",tle="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]",nle="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?Zae:Qae,c=s?tle:ele;return be.useEffect(()=>{const h=f=>{f.key==="Escape"&&r()};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[r]),C.jsxs(Kae,{"data-slot":"dialog-portal",children:[C.jsx(Yae,{}),C.jsxs(Uae,{id:"dialog-content","data-slot":"dialog-content",className:je(a,c,nle,"flex flex-col",t),onInteractOutside:h=>h.preventDefault(),...o,children:[C.jsx(Jae,{}),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(Gt,{src:Gae}):null,C.jsx(Xae,{withWarningIcon:s,children:n})]}),C.jsx(xt,{iconName:qae,size:24,onClick:r})]}),C.jsx("div",{className:je("flex-1 min-h-0",s?"px-[16px]":"px-[32px]"),children:e})]})]})},ro=({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})]}),ZF="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",Qx=({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(Gt,{src:ZF,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})},rle="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",lo=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(Gt,{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(Gt,{src:rle,beforeInjection:o})})]})});lo.displayName="Input";const ez="flex flex-col justify-between h-full",tz="flex flex-col gap-[12px] mb-[32px]",nz="flex flex-row justify-end items-center gap-[8px] h-[64px] border-t-[1px] border-[var(--border-divider)] mx-[-32px] px-[32px]",ile=({name:t,onClose:e})=>{const{t:n}=wt(),{providers:r,editProvider:i}=ns(),[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:ez,children:[C.jsxs("div",{className:tz,children:[C.jsx(ro,{header:n("Provider"),children:C.jsx(Qx,{value:s.type,items:[]})}),C.jsx(ro,{header:n("Name"),error:h.name,children:C.jsx(lo,{name:"name",onChange:m,value:a.name,isError:!!h.name,placeholder:n("EnterName"),className:"w-full"})}),C.jsx(ro,{header:n("URL"),error:h.url,children:C.jsx(lo,{name:"url",onChange:m,value:a.url,isError:!!h.url,placeholder:n("EnterURL"),className:"w-full"})}),C.jsx(ro,{header:n("APIKey"),error:h.key,children:C.jsx(lo,{name:"key",onChange:m,value:a.key,isError:!!h.key,placeholder:n("EnterKey"),className:"w-full",type:"password"})})]}),C.jsxs("div",{className:nz,children:[C.jsx(tn,{variant:"default",onClick:e,children:n("Cancel")}),C.jsx(tn,{onClick:y,disabled:S,children:n("Save")})]})]})})})},sle=({name:t,onClose:e})=>{const{providers:n,deleteProvider:r}=ns(),[i,s]=be.useState(()=>{const c=n.find(h=>h.name===t);return c||{name:"",type:"",icon:"",key:"",baseUrl:""}}),{t:o}=wt();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(tn,{variant:"default",onClick:e,children:o("No")}),C.jsx(tn,{onClick:a,children:o("Yes")})]})]})})})},ole=({provider:t})=>{const{providersModels:e}=ns(),[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}=wt(),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(xt,{iconName:H9,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(xt,{iconName:Lk,size:20,isActive:c}),items:[{icon:C.jsx(xt,{iconName:mse,size:20,disableHover:!0,isStroke:!0}),text:d("Edit"),onClick:()=>r(!0)},{text:"",onClick:()=>{},isSeparator:!0},{icon:C.jsx(xt,{iconName:Nk,size:20,disableHover:!0}),text:d("Delete"),onClick:()=>s(!0)}],side:"right",align:"start",sideOffset:0,containerRef:o})})]}),n?C.jsx(ile,{name:t.name,onClose:()=>r(!1)}):null,i?C.jsx(sle,{name:t.name,onClose:()=>s(!1)}):null]})},zL=$t.getProvidersInfo(),ale=({onClose:t})=>{const{addProvider:e}=ns(),{t:n}=wt(),[r,i]=be.useState(zL[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:ez,children:[C.jsxs("div",{className:tz,children:[C.jsx(ro,{header:n("Provider"),children:C.jsx(Qx,{value:r.name,items:zL.map(y=>({text:y.name,id:y.name,onClick:()=>i(y)}))})}),C.jsx(ro,{header:n("Name"),error:a.name,children:C.jsx(lo,{name:"name",onChange:f,value:s.name,isError:!!a.name,placeholder:n("EnterName"),className:"w-full"})}),C.jsx(ro,{header:n("URL"),error:a.url,children:C.jsx(lo,{name:"url",onChange:f,value:s.url,isError:!!a.url,placeholder:n("EnterURL"),className:"w-full"})}),C.jsx(ro,{header:n("APIKey"),error:a.key,children:C.jsx(lo,{name:"key",onChange:f,value:s.key,isError:!!a.key,placeholder:n("EnterKey"),className:"w-full",type:"password"})})]}),C.jsxs("div",{className:nz,children:[C.jsx(tn,{variant:"default",onClick:t,children:n("Cancel")}),C.jsx(tn,{onClick:d,disabled:m,children:n("AddProvider")})]})]})})})},lle=({isActive:t})=>{const[e,n]=be.useState(!1),{providers:r}=ns(),{t:i}=wt();return C.jsxs(C.Fragment,{children:[C.jsx(tn,{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(ole,{provider:s},s.name))}),e?C.jsx(ale,{onClose:()=>n(!1)}):null]})},cle=({isActive:t})=>{const{t:e}=wt();return C.jsx(tn,{className:"max-w-[fit-content]",disabled:!t,children:e("RegisterConnectWallet")})};let FC=[],rz=[];(()=>{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?rz:FC).push(n=n+t[e])})();function ule(t){if(t<768)return!1;for(let e=0,n=FC.length;;){let r=e+n>>1;if(t<FC[r])n=r;else if(t>=rz[r])e=r+1;else return!0;if(e==n)return!1}}function VL(t){return t>=127462&&t<=127487}const UL=8205;function hle(t,e,n=!0,r=!0){return(n?iz:fle)(t,e,r)}function iz(t,e,n){if(e==t.length)return e;e&&sz(t.charCodeAt(e))&&oz(t.charCodeAt(e-1))&&e--;let r=__(t,e);for(e+=HL(r);e<t.length;){let i=__(t,e);if(r==UL||i==UL||n&&ule(i))e+=HL(i),r=i;else if(VL(i)){let s=0,o=e-2;for(;o>=0&&VL(__(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function fle(t,e,n){for(;e>0;){let r=iz(t,e-2,n);if(r<e)return r;e--}return 0}function __(t,e){let n=t.charCodeAt(e);if(!oz(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return sz(r)?(n-55296<<10)+(r-56320)+65536:n}function sz(t){return t>=56320&&t<57344}function oz(t){return t>=55296&&t<56320}function HL(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),Zs.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),Zs.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 az(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 lz(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 on(e):Zs.from(on.split(e,[]))}}class on extends dt{constructor(e,n=dle(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 ple(i,a,r,o);i=a+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new on(WL(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),a=kb(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new on(a,o.length+s.length));else{let c=a.length>>1;r.push(new on(a.slice(0,c)),new on(a.slice(c)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof on))return super.replace(e,n,r);[e,n]=Dh(this,e,n);let i=kb(this.text,kb(r.text,WL(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new on(i,s):Zs.from(on.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 on(r,i)),r=[],i=-1);return i>-1&&n.push(new on(r,i)),n}}class Zs 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 Zs(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 Zs))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 on(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 Zs)for(let x of y.children)d(x);else y.lines>o&&(c>o||!c)?(m(),a.push(y)):y instanceof on&&c&&(b=f[f.length-1])instanceof on&&y.lines+b.lines<=32?(c+=y.lines,h+=y.length+1,f[f.length-1]=new on(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]:Zs.from(f,h)),h=-1,c=f.length=0)}for(let y of e)d(y);return m(),a.length==1?a[0]:new Zs(a,n)}}dt.empty=new on([""],0);function dle(t){let e=-1;for(let n of t)e+=n.length+1;return e}function kb(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 WL(t,e,n){return kb(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 on?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 on?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 on){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 on?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 az{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 lz{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]=az.prototype[Symbol.iterator]=lz.prototype[Symbol.iterator]=function(){return this});class ple{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 hle(t,e,n,r)}function mle(t){return t>=56320&&t<57344}function gle(t){return t>=55296&&t<56320}function Wr(t,e){let n=t.charCodeAt(e);if(!gle(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return mle(r)?(n-55296<<10)+(r-56320)+65536:n}function Xk(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function eo(t){return t<65536?1:2}const zC=/\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 co{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){VC(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 co(e)}composeDesc(e){return this.empty?e:e.empty?this:cz(this,e)}mapDesc(e,n=!1){return e.empty?this:UC(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 co(e)}static create(e){return new co(e)}}class En extends co{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 VC(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return UC(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:cz(this,e,!0)}map(e,n=!1){return e.empty?this:UC(this,e,n,!0)}iterChanges(e,n=!1){VC(this,e,n)}get desc(){return co.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:co.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||zC)):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 VC(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 UC(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):co.create(i);throw new Error("Mismatched change set lengths")}}}function cz(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):co.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 uz(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Jk=0;class Ce{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=Jk++,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:Qk),!!e.static,e.enables)}of(e){return new Tb([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Tb(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Tb(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Qk(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Tb{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=Jk++}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)||HC(d,f)){let y=r(d);if(a?!qL(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=vv(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?qL(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 qL(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 HC(t,e){let n=!1;for(let r of e)Ep(t,r)&1&&(n=!0);return n}function yle(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=vv(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(!HC(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=HC(c,r),d=h.config.facets[e.id],m=h.facet(e);if(d&&!f&&Qk(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 vy=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(Jk++,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(vy).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(vy),o=i.facet(vy),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,vy.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 hz(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 hz{constructor(e,n){this.inner=e,this.prec=n}}class Zx{of(e){return new WC(this,e)}reconfigure(e){return Zx.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class WC{constructor(e,n){this.compartment=e,this.inner=n}}class bv{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 ble(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,Qk(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=>yle(S,b,y))}}let d=h.map(m=>m(a));return new bv(e,o,d,a,c,s)}}function ble(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 WC&&n.delete(o.compartment)}if(i.set(o,a),Array.isArray(o))for(let h of o)s(h,a);else if(o instanceof WC){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 hz)s(o.inner,o.prec);else if(o instanceof Zn)r[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof Tb)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 vv(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const fz=Ce.define(),qC=Ce.define({combine:t=>t.some(e=>e),static:!0}),dz=Ce.define({combine:t=>t.length?t[0]:void 0,static:!0}),pz=Ce.define(),mz=Ce.define(),gz=Ce.define(),yz=Ce.define({combine:t=>t.length?t[0]:!1});class sa{constructor(e,n){this.type=e,this.value=n}static define(){return new vle}}class vle{of(e){return new sa(this,e)}}class xle{constructor(e){this.map=e}of(e){return new Qe(this,e)}}class Qe{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 Qe(this.type,n)}is(e){return this.type==e}static define(e={}){return new xle(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}}Qe.reconfigure=Qe.define();Qe.appendConfig=Qe.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&&uz(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 wle(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 bz(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:Qe.mapEffects(t.effects,i).concat(Qe.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function GC(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(dz)),selection:r&&(r instanceof fe?r:fe.single(r.anchor,r.head)),effects:vh(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function vz(t,e,n){let r=GC(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=bz(r,GC(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 _le(n?Sle(i):i)}function Sle(t){let e=t.startState,n=!0;for(let i of e.facet(pz)){let s=i(t);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:wle(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),Qe.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let r=e.facet(mz);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=vz(e,vh(s),!1)}return t}function _le(t){let e=t.startState,n=e.facet(gz),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=bz(r,GC(e,s,t.changes.newLength),!0))}return r==t?t:kn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const Cle=[];function vh(t){return t==null?Cle: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 Ale=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let KC;try{KC=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Ele(t){if(KC)return KC.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||Ale.test(n)))return!0}return!1}function kle(t){return e=>{if(!/\S/.test(e))return Vt.Space;if(Ele(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),vv(this,r)}update(...e){return vz(this,e,!0)}applyTransaction(e){let n=this.config,{base:r,compartments:i}=n;for(let a of e.effects)a.is(Zx.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(Qe.reconfigure)?(n=null,r=a.value):a.is(Qe.appendConfig)&&(n=null,r=vh(r).concat(a.value));let s;n?s=e.startState.values.slice():(n=bv.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(qC)?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=Qe.mapEffects(o,f).concat(Qe.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)||zC))}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),vv(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=bv.resolve(e.extensions||[],new Map),r=e.doc instanceof dt?e.doc:dt.of((e.doc||"").split(n.staticFacet(ht.lineSeparator)||zC)),i=e.selection?e.selection instanceof fe?e.selection:fe.single(e.selection.anchor,e.selection.head):fe.single(0);return uz(i,r.length),n.staticFacet(qC)||(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(yz)}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(fz))for(let o of s(this,n,r))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){return kle(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=qC;ht.tabSize=Ce.define({combine:t=>t.length?t[0]:4});ht.lineSeparator=dz;ht.readOnly=yz;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=fz;ht.changeFilter=pz;ht.transactionFilter=mz;ht.transactionExtender=gz;Zx.reconfigure=Qe.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 YC.create(e,n,this)}}Ec.prototype.startSide=Ec.prototype.endSide=0;Ec.prototype.point=!1;Ec.prototype.mapMode=Mr.TrackDel;let YC=class xz{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new xz(e,n,r)}};function XC(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Zk{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 Zk(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(XC)),this.isEmpty)return n.length?ft.of(n):this;let a=new wz(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(YC.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=GL(o,a,r),h=new Od(o,c,s),f=new Od(a,c,s);r.iterGaps((d,m,y)=>KL(h,d,f,m,y,i)),r.empty&&r.length==0&&KL(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=GL(s,o),c=new Od(s,a,0).goto(r),h=new Od(o,a,0).goto(r);for(;;){if(c.to!=h.to||!JC(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 YC?[e]:n?Tle(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 Tle(t){if(t.length>1)for(let e=t[0],n=1;n<t.length;n++){let r=t[n];if(XC(e,r)>0)return t.slice().sort(XC);e=r}return t}ft.empty.nextLayer=ft.empty;class Xo{finishChunk(e){this.chunks.push(new Zk(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 GL(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 wz{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 wz(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--)C_(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--)C_(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(),C_(this.heap,0)}}}function C_(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){xy(this.active,e),xy(this.activeTo,e),xy(this.activeRank,e),this.minActive=YL(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++;wy(this.active,n,r),wy(this.activeTo,n,i),wy(this.activeRank,n,s),e&&wy(e,n,this.cursor.from),this.minActive=YL(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&&xy(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 KL(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))&&JC(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(a,m,t.point,n.point):m>a&&!JC(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 JC(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 xy(t,e){for(let n=e,r=t.length-1;n<r;n++)t[n]=t[n+1];t.pop()}function wy(t,e,n){for(let r=t.length-1;r>=e;r--)t[r+1]=t[r];t[e]=n}function YL(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 QC(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 ZC="ͼ",XL=typeof Symbol>"u"?"__"+ZC:Symbol.for(ZC),eA=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),JL=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=JL[XL]||1;return JL[XL]=e+1,ZC+e.toString(36)}static mount(e,n,r){let i=e[eA],s=r&&r.nonce;i?s&&i.setNonce(s):i=new Rle(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let QL=new Map;class Rle{constructor(e,n){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=QL.get(r);if(s)return e[eA]=s;this.sheet=new i.CSSStyleSheet,QL.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[eA]=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:'"'},Mle=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ole=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 A_ in ml)sm.hasOwnProperty(A_)||(sm[A_]=ml[A_]);function Ple(t){var e=Mle&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Ole&&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++)Sz(t,arguments[e]);return t}function Sz(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++)Sz(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 tA(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Rb(t,e){if(!e.anchorNode)return!1;try{return tA(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?ZL(t,e,n,r,-1)||ZL(t,e,n,r,1):!1}function kc(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function xv(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ZL(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 ew(t,e){let n=e?t.left:t.right;return{left:n,right:n,top:t.top,bottom:t.bottom}}function Dle(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 _z(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 Ile(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=Dle(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}=_z(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 Lle(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 Nle{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 Cz(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 eN;function Tc(t,e,n=e){let r=eN||(eN=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 $le(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function Az(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function jle(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 Ez(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function kz(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&&!xv(n))r=kc(n),n=n.parentNode;else return null}}function Tz(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&&!xv(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 eT=[];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=tN(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=tN(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=eT){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 Rz(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 tN(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Rz{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 Mz(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 Oz(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,Mz(t,h,f,a,c,r,0,i,s)}let qr=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},nA=typeof document<"u"?document:{documentElement:{style:{}}};const rA=/Edge\/(\d+)/.exec(qr.userAgent),Pz=/MSIE \d/.test(qr.userAgent),iA=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(qr.userAgent),tw=!!(Pz||iA||rA),nN=!tw&&/gecko\/(\d+)/i.test(qr.userAgent),E_=!tw&&/Chrome\/(\d+)/.exec(qr.userAgent),Ble="webkitFontSmoothing"in nA.documentElement.style,Dz=!tw&&/Apple Computer/.test(qr.vendor),rN=Dz&&(/Mobile\/\w+/.test(qr.userAgent)||qr.maxTouchPoints>2);var Se={mac:rN||/Mac/.test(qr.platform),windows:/Win/.test(qr.platform),linux:/Linux|X11/.test(qr.platform),ie:tw,ie_version:Pz?nA.documentMode||6:iA?+iA[1]:rA?+rA[1]:0,gecko:nN,gecko_version:nN?+(/Firefox\/(\d+)/.exec(qr.userAgent)||[0,0])[1]:0,chrome:!!E_,chrome_version:E_?+E_[1]:0,ios:rN,android:/Android\b/.test(qr.userAgent),safari:Dz,webkit_version:Ble?+(/\bAppleWebKit\/(\d+)/.exec(qr.userAgent)||[0,0])[1]:0,tabSize:nA.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const Fle=256;class As 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 As)||this.length-(n-e)+r.length>Fle||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 As(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 zle(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(Az(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:(Oz(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 Iz(this,e)}coordsAt(e,n){return Nz(this,e,n)}}function zle(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?ew(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 ew(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}}As.prototype.children=rl.prototype.children=Ih.prototype.children=eT;function Iz(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 Lz(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)?Lz(r,e.children[0],n-1):(i.push(e),e.setParent(t)),t.length+=e.length}function Nz(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||Ule(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):Vle(t)}function Vle(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=am(e);return n[n.length-1]||null}function Ule(t,e){let n=t.coordsAt(0,1),r=e.coordsAt(0,1);return n&&r&&r.top<n.bottom}function sA(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 iN=Object.create(null);function wv(t,e,n){if(t==e)return!0;t||(t=iN),e||(e=iN);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 oA(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 Hle(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 qm(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}=$z(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 Gm(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 qm extends He{constructor(e){let{start:n,end:r}=$z(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 qm&&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))&&wv(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)}}qm.prototype.point=!1;class Gm extends He{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Gm&&this.spec.class==e.spec.class&&wv(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)}}Gm.prototype.mapMode=Mr.TrackBefore;Gm.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&&Wle(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 $z(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 Wle(t,e){return t==e||!!(t&&e&&t.compare(e))}function Mb(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 fn 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 fn))return!1;this.dom||r.transferDOM(this)}return i&&this.setDeco(r?r.attrs:null),Oz(this,e,n,r?r.children.slice():[],s,o),!0}split(e){let n=new fn;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){wv(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,n){Lz(this,e,n)}addLineDeco(e){let n=e.spec.attributes,r=e.spec.class;n&&(this.attrs=sA(n,this.attrs||{})),r&&(this.attrs=sA({class:r},this.attrs||{}))}domAtPos(e){return Iz(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,n){var r;this.dom?this.flags&4&&(Az(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&&(oA(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 As))){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 As)||/[^ -~]/.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=Nz(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 fn&&this.children.length==0&&e.children.length==0&&wv(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 fn)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 eT}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 aA?null:ew(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 aA 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 fn),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Sy(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(Sy(new As(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(Sy(new Ih(1),i),s),s=i.length+Math.max(0,s-i.length)),d.append(Sy(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 Sy(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,tT=jt.RTL;function jz(t){let e=[];for(let n=0;n<t.length;n++)e.push(1<<+t[n]);return e}const qle=jz("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Gle=jz("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),lA=Object.create(null),Hs=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),n=t.charCodeAt(1);lA[e]=n,lA[n]=-e}function Bz(t){return t<=247?qle[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Gle[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Kle=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class il{get dir(){return this.level%2?tT: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 Fz(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||!Fz(r.inner,i.inner))return!1}return!0}const Tt=[];function Yle(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=Bz(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 Xle(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=lA[m=t.charCodeAt(d)])if(y<0){for(let x=a-3;x>=0;x-=3)if(Hs[x+1]==-y){let S=Hs[x+2],_=S&2?i:S&4?S&1?s:i:0;_&&(Tt[d]=Tt[Hs[x]]=_),a=x;break}}else{if(Hs.length==189)break;Hs[a++]=d,Hs[a++]=m,Hs[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 _=Hs[S+2];if(_&2)break;if(x)Hs[S+2]|=2;else{if(_&4)break;Hs[S+2]|=4}}}}}function Jle(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 cA(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);uA(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?cA(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);uA(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?cA(t,b,c,r+1,i,m,o):b<c&&o.push(new il(b,c,y)),c=b}}function uA(t,e,n,r,i,s,o){let a=e%2?2:1;Yle(t,i,s,r,a),Xle(t,i,s,r,a),Jle(i,s,r,a),cA(t,i,s,e,n,r,o)}function Qle(t,e,n){if(!t)return[new il(0,0,e==tT?1:0)];if(e==Rc&&!n.length&&!Kle.test(t))return zz(t.length);if(n.length)for(;t.length>Tt.length;)Tt[Tt.length]=256;let r=[],i=e==Rc?0:1;return uA(t,i,i,n,0,t.length,r),r}function zz(t){return[new il(0,t,0)]}let Vz="";function Zle(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),Vz=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 ece(t,e,n){for(let r=e;r<n;r++){let i=Bz(t.charCodeAt(r));if(i==1)return Rc;if(i==2||i==4)return tT}return Rc}const Uz=Ce.define(),Hz=Ce.define(),Wz=Ce.define(),qz=Ce.define(),hA=Ce.define(),Gz=Ce.define(),Kz=Ce.define(),nT=Ce.define(),rT=Ce.define(),Yz=Ce.define({combine:t=>t.some(e=>e)}),Xz=Ce.define({combine:t=>t.some(e=>e)}),Jz=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 _y=Qe.define({map:(t,e)=>t.map(e)}),Qz=Qe.define();function Kr(t,e,n){let r=t.facet(qz);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 tce=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(tce++,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 k_{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 Zz=Ce.define(),iT=Ce.define(),lm=Ce.define(),eV=Ce.define(),nw=Ce.define(),tV=Ce.define();function sN(t,e){let n=t.state.facet(tV);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=ece(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 nV=Ce.define();function sT(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(nV)){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 Ji{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}join(e){return new Ji(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 Ji(y+h,b+h,y,b).addToSet(r),m>f)break;s+=2}if(!c)return r;new Ji(c.fromA,c.toA,c.fromB,c.toB).addToSet(r),o=c.toA,a=c.toB}}}class Sv{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 Ji(s,o,a,c))),this.changedRanges=i}static create(e,n,r){return new Sv(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 oN 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 fn],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Ji(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:!lce(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?rce(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:f}=this.hasComposition;r=new Ji(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=oce(o,a,e.changes);return r=Ji.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 aA&&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);Mz(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(Qz)&&(this.editContextFormatting=r.value)}compositionView(e){let n=new As(e.text.nodeValue);n.flags|=8;for(let{deco:i}of e.marks)n=new Jo(i,[n],n.length);let r=new fn;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)&&Rb(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&&nce(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)&&ace(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=ice(c.node,c.offset);if(m&&m!=3){let y=(m==1?kz:Tz)(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=fn.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 fn&&(r=s.domAtPos(0))}for(let i=e.offset-1;!r&&i>=0;i--){let s=Rt.get(n.childNodes[i]);s instanceof fn&&(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 fn)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 fn&&!(r instanceof fn&&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 fn))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 As))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 fn){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 Rz(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 aA(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(eV).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(Jz))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=sT(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;Ile(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 nce(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 rV(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=kz(n.focusNode,n.focusOffset),i=Tz(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let a=Rt.get(i.node);if(!a||a instanceof As&&a.text!=i.node.nodeValue)s=i;else if(t.docView.lastCompositionAfterCursor){let c=Rt.get(r.node);!c||c instanceof As&&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 rce(t,e,n){let r=rV(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 Ji(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 fn||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 qm({inclusive:!0,attributes:Hle(d),tagName:d.tagName.toLowerCase()})});else return null}}}function ice(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 sce=class{constructor(){this.changes=[]}compareRange(e,n){Mb(e,n,this.changes)}comparePoint(e,n){Mb(e,n,this.changes)}boundChange(e){Mb(e,e,this.changes)}};function oce(t,e,n){let r=new sce;return ft.compare(t,e,n,r),r.changes}function ace(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 lce(t,e){let n=!1;return e&&t.iterChangedRanges((r,i)=>{r<e.to&&i>e.from&&(n=!0)}),n}function cce(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 uce(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function hce(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function T_(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function aN(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function lN(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function fA(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&&T_(i,_)&&(_=aN(lN(_,i.bottom),i.top));let A=uce(e,_),E=hce(n,_);if(A==0&&E==0)return b.nodeType==3?cN(b,e,n):fA(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&&T_(f,_)?f=lN(f,_.bottom):d&&T_(d,_)&&(d=aN(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 cN(r,m,n);if(a&&r.contentEditable!="false")return fA(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 cN(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 iV(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:uN(t,o,c,f,d);if(y>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:n?null:uN(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&&fce(_,A,f)||Se.chrome&&dce(_,A,f))&&(_=void 0))}_&&(A=Math.min(yo(_),A))}if(!_||!t.docView.dom.contains(_)){let P=fn.find(t.docView,y);if(!P)return m>c.top+c.height/2?c.to:c.from;({node:_,offset:A}=fA(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 uN(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+QC(o,s,t.state.tabSize)}function fce(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 dce(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 dA(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 pce(t,e,n,r){let i=dA(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 hN(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=Zle(i,s,o,a,n),f=Vz;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 mce(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 gce(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=iV(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 Ob(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 sV(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=Ob(t,i.from,0);o!=i.from&&(s=fe.cursor(o,-1))}else{let o=Ob(t,i.from,-1),a=Ob(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 R_(t,e,n){let r=Ob(t.state.facet(nw).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 yce{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:xv(i))||xv(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+(bce(e,r.node,r.offset)?n:0))}}function bce(t,e,n){for(;;){if(!e||n<yo(e))return!1;if(e==t)return!0;n=kc(e)+1,e=e.parentNode}}class fN{constructor(e,n){this.node=e,this.offset=n,this.pos=-1}}class vce{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?[]:Sce(e),c=new yce(a,e.state);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=_ce(a,this.bounds.from)}else{let a=e.observer.selectionRange,c=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!tA(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||!tA(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 oV(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=wce(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 oT(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=sV(t.state.facet(nw).map(c=>c(t)),r))),t.dispatch({selection:r,scrollIntoView:o,userEvent:a}),!0}else return!1}function oT(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=xce(t,e,n));return t.state.facet(Gz).some(c=>c(t,e.from,e.to,s,a))||t.dispatch(a()),!0}function xce(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&&rV(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 wce(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 Sce(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 fN(n,r)),(i!=n||s!=r)&&e.push(new fN(i,s))),e}function _ce(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 Cce{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&&Fce(e.contentDOM.ownerDocument)}handleEvent(e){!Pce(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=Ace(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&&lV.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=aV.find(r=>r.keyCode==e.keyCode))&&!e.ctrlKey||Ece.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 dN(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){Kr(n.state,i)}}}function Ace(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(dN(r.value,c))}if(o)for(let a in o){let c=o[a];c&&n(a).observers.push(dN(r.value,c))}}for(let r in Es)n(r).handlers.push(Es[r]);for(let r in es)n(r).observers.push(es[r]);return e}const aV=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Ece="dthko",lV=[16,17,18,20,91,92,224,225],Cy=6;function Ay(t){return Math.max(0,t)*.7+8}function kce(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class Tce{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=Lle(e.contentDOM),this.atoms=e.state.facet(nw).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)&&Rce(e,n),this.dragging=Oce(e,n)&&hV(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&&kce(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=sT(this.view);e.clientX-c.left<=i+Cy?n=-Ay(i-e.clientX):e.clientX+c.right>=o-Cy&&(n=Ay(e.clientX-o)),e.clientY-c.top<=s+Cy?r=-Ay(s-e.clientY):e.clientY+c.bottom>=a-Cy&&(r=Ay(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=sV(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 Rce(t,e){let n=t.state.facet(Uz);return n.length?n[0](e):Se.mac?e.metaKey:e.ctrlKey}function Mce(t,e){let n=t.state.facet(Hz);return n.length?n[0](e):Se.mac?!e.altKey:!e.ctrlKey}function Oce(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 Pce(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 Es=Object.create(null),es=Object.create(null),cV=Se.ie&&Se.ie_version<15||Se.ios&&Se.webkit_version<604;function Dce(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(),uV(t,n.value)},50)}function rw(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function uV(t,e){e=rw(t.state,nT,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(pA!=null&&n.selection.ranges.every(c=>c.empty)&&pA==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})}es.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft};Es.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);es.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")};es.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};Es.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(Wz))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=Nce(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new Tce(t,e,n,r)),r&&t.observer.ignore(()=>{Cz(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 pN(t,e,n,r){if(r==1)return fe.cursor(e,n);if(r==2)return cce(t.state,e,n);{let i=fn.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 mN=(t,e,n)=>e>=n.top&&e<=n.bottom&&t>=n.left&&t<=n.right;function Ice(t,e,n,r){let i=fn.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&&mN(n,r,o))return-1;let a=i.coordsAt(s,1);return a&&mN(n,r,a)?1:o&&o.bottom>=r?-1:1}function gN(t,e){let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:n,bias:Ice(t,n,e.clientX,e.clientY)}}const Lce=Se.ie&&Se.ie_version<=11;let yN=null,bN=0,vN=0;function hV(t){if(!Lce)return t.detail;let e=yN,n=vN;return yN=t,vN=Date.now(),bN=!e||n>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(bN+1)%3:1}function Nce(t,e){let n=gN(t,e),r=hV(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=gN(t,s),h,f=pN(t,c.pos,c.bias,r);if(n.pos!=c.pos&&!o){let d=pN(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=$ce(i,c.pos))?h:a?i.addRange(f):fe.create([f])}}}function $ce(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}Es.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",rw(t.state,rT,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Es.dragend=t=>(t.inputState.draggedContent=null,!1);function xN(t,e,n,r){if(n=rw(t.state,nT,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&Mce(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}Es.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&&xN(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 xN(t,e,r,!0),!0}return!1};Es.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=cV?null:e.clipboardData;return n?(uV(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(Dce(t),!1)};function jce(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 Bce(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:rw(t,rT,e.join(t.lineBreak)),ranges:n,linewise:r}}let pA=null;Es.copy=Es.cut=(t,e)=>{let{text:n,ranges:r,linewise:i}=Bce(t.state);if(!n&&!i)return!1;pA=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=cV?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(jce(t,n),!1)};const fV=sa.define();function dV(t,e){let n=[];for(let r of t.facet(Kz)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:fV.of(!0)}):null}function pV(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=dV(t.state,e);n?t.dispatch(n):t.update([])}},10)}es.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),pV(t)};es.blur=t=>{t.observer.clearSelectionRange(),pV(t)};es.compositionstart=es.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};es.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))};es.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Es.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 oT(t,{from:c,to:h,insert:t.state.toText(s)},null),!0}}let i;if(Se.chrome&&Se.android&&(i=aV.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(()=>es.compositionend(t,e),20),!1};const wN=new Set;function Fce(t){wN.has(t)||(wN.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const SN=["pre-wrap","normal","pre-line","break-spaces"];let Nh=!1;function _N(){Nh=!1}class zce{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 SN.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=SN.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 Vce{constructor(e,n){this.from=e,this.heights=n,this.index=0}get more(){return this.index<this.heights.length}}class to{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 to(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 Pb=.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)>Pb&&(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=aT.build(r.setDoc(o),e,f,d);s=_v(s,s.replace(c,h,b))}return s.updateHeight(r,0)}static empty(){return new Si(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 Uce(Ir.of(e.slice(0,n)),o,Ir.of(e.slice(r)))}}function _v(t,e){return t==e?t:(t.constructor!=e.constructor&&(Nh=!0),e)}Ir.prototype.size=1;class mV extends Ir{constructor(e,n,r){super(e,n),this.deco=r}blockAt(e,n,r,i){return new to(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 Si extends mV{constructor(e,n){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,n,r,i){return new to(i,this.length,r,this.height,this.breaks)}replace(e,n,r){let i=r[0];return r.length==1&&(i instanceof Si||i instanceof qn&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof qn?i=new Si(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 to(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 to(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 to(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 to(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 to(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)>=Pb&&(c=-2);let m=new Si(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)>=Pb||Math.abs(c-this.heightMetrics(e,n).perLine)>=Pb)&&(Nh=!0),_v(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 Uce 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&&CN(s,o-1),n<this.length){let a=s.length;this.decomposeRight(n,s),CN(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=_v(this.left,e),this.right=_v(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 CN(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 Hce=5;class aT{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 Si?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Si(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 mV(o,i,r)):(o||s||i>=Hce)&&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 Si(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 Si)return e;let n=new Si(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 Si)&&!this.isCovered?this.nodes.push(new Si(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 Si&&i.updateHeight(this.oracle,r),r+=i?i.length:1;return this.nodes}static build(e,n,r,i){let s=new aT(r,e);return ft.spans(n,r,i,s,0),s.finish(r)}}function Wce(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)&&Mb(e,n,this.changes,5)}}function Gce(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 Kce(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 Yce(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class M_{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 Xce(this.displaySize*(n?e.scaleY:e.scaleX),n)}).range(this.from,this.to)}}class Xce 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 AN{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=EN,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=jt.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=e.facet(iT).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new zce(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 Ji(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 Ey(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?EN:new lT(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=Ji.extendWithRanges(i,Wce(r,this.stateDeco,e?e.changes:En.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);_N(),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(Xz)&&(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}=_z(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=Ez(e.scrollDOM);let b=(this.printing?Yce:Gce)(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&&!Kce(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)),_N();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 Ji(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new Vce(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 Ey(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 Ey(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 Ey(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 M_(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=Qce(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 M_(f,d,_,A)}a.push(S)},h=f=>{if(f.length<o||f.type!=Dr.Text)return;let d=Jce(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=Ty(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=ky(d,S),b=ky(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=Ty(d,m),D=((E-A)/2+S)/x;P=M-D,O=M+D}else P=(A-S)/x,O=(E+S)/x;y=ky(d,P),b=ky(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=Ty(i,r)-Ty(i,n);return this.heightOracle.lineWrapping?e.height*s:i.total*this.heightOracle.charWidth*s}updateLineGaps(e){M_.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 Ey{constructor(e,n){this.from=e,this.to=n}}function Jce(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 ky({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 Ty(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 Qce(t,e){for(let n of t)if(e(n))return n}const EN={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};class lT{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 lT?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 to(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>fp(i,e)):t._content)}const Ry=Ce.define({combine:t=>t.join(" ")}),mA=Ce.define({combine:t=>t.indexOf(!0)>-1}),gA=pl.newName(),gV=pl.newName(),yV=pl.newName(),bV={"&light":"."+gV,"&dark":"."+yV};function yA(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 Zce=yA("."+gA,{"&":{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"}},bV),eue={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},O_=Se.ie&&Se.ie_version<=11;class tue{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Nle,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 rue(e),e.state.facet(Wo)&&(e.contentDOM.editContext=this.editContext.editContext)),O_&&(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:!Rb(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&&nue(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=Rb(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&jle(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,eue),O_&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),O_&&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&&Rb(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 vce(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=oV(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=kN(n,e.previousSibling||e.target.previousSibling,-1),i=kN(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 kN(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 TN(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 nue(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return TN(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?TN(t,n):null}class rue{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);oT(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:Qz.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||$le(e.parent)||document,this.viewState=new AN(e.state||ht.create(e)),e.scrollTo&&e.scrollTo.is(_y)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(nh).map(i=>new k_(i));for(let i of this.plugins)i.update(this);this.observer=new tue(this),this.inputState=new Cce(this),this.inputState.ensureHandlers(this.plugins),this.docView=new oN(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(fV))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=dV(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=Sv.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(_y)&&(d=y.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=Cv.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(Ry)!=i.state.facet(Ry)&&(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(hA))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&&!oV(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 AN(e),this.plugins=e.facet(nh).map(r=>new k_(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new oN(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 k_(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(Ez(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),RN}}),d=Sv.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]!=RN)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(hA))a(n)}get themeClasses(){return gA+" "+(this.state.facet(mA)?yV:gV)+" "+this.state.facet(Ry)}updateAttrs(){let e=MN(this,Zz,{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"),MN(this,iT,n);let r=this.observer.ignore(()=>{let i=oA(this.contentDOM,this.contentAttrs,n),s=oA(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(Zce).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 R_(this,e,hN(this,e,n,r))}moveByGroup(e,n){return R_(this,e,hN(this,e,n,r=>mce(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 pce(this,e,n,r)}moveVertically(e,n,r){return R_(this,e,gce(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(),iV(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 ew(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(Yz)||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>iue)return zz(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||Fz(s.isolates,r=sN(this,e))))return s.order;r||(r=sN(this,e));let i=Qle(e.text,n,r);return this.bidiCache.push(new Cv(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(()=>{Cz(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 _y.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 _y.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=[Ry.of(r),up.of(yA(`.${r}`,e))];return n&&n.dark&&i.push(mA.of(!0)),i}static baseTheme(e){return $c.lowest(up.of(yA("."+gA,e,bV)))}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=Gz;_e.clipboardInputFilter=nT;_e.clipboardOutputFilter=rT;_e.scrollHandler=Jz;_e.focusChangeEffect=Kz;_e.perLineTextDirection=Yz;_e.exceptionSink=qz;_e.updateListener=hA;_e.editable=Wo;_e.mouseSelectionStyle=Wz;_e.dragMovesSelection=Hz;_e.clickAddsSelectionRange=Uz;_e.decorations=lm;_e.outerDecorations=eV;_e.atomicRanges=nw;_e.bidiIsolatedRanges=tV;_e.scrollMargins=nV;_e.darkTheme=mA;_e.cspNonce=Ce.define({combine:t=>t.length?t[0]:""});_e.contentAttributes=iT;_e.editorAttributes=Zz;_e.lineWrapping=_e.contentAttributes.of({class:"cm-lineWrapping"});_e.announce=Qe.define();const iue=4096,RN={};class Cv{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 Cv(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function MN(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&&sA(o,n)}return n}const sue=Se.mac?"mac":Se.windows?"win":Se.linux?"linux":"key";function oue(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 My(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 aue=$c.default(_e.domEventHandlers({keydown(t,e){return xV(vV(e.state),t,e,"editor")}})),cT=Ce.define({enables:aue}),ON=new WeakMap;function vV(t){let e=t.facet(cT),n=ON.get(e);return n||ON.set(e,n=uue(e.reduce((r,i)=>r.concat(i),[]))),n}function lue(t,e,n){return xV(vV(t.state),e,t,n)}let el=null;const cue=4e3;function uue(t,e=sue){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(_=>oue(_,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)},cue),!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,bA))}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 bA=null;function xV(t,e,n,r){bA=e;let i=Ple(e),s=Wr(i,0),o=eo(s)==i.length&&i!=" ",a="",c=!1,h=!1,f=!1;el&&el.view==n&&el.scope==r&&(a=el.prefix+" ",lV.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+My(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+My(b,e,!0)])||e.shiftKey&&(x=sm[e.keyCode])!=i&&x!=b&&m(y[a+My(x,e,!1)]))&&(c=!0):o&&e.shiftKey&&m(y[a+My(i,e,!0)])&&(c=!0),!c&&m(y._any)&&(c=!0)),h&&(c=!0),c&&f&&e.stopPropagation(),bA=null,c}class Km{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=wV(e);return[new Km(n,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}else return hue(e,n,r)}}function wV(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 PN(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 hue(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=wV(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=dA(t,r,1),b=dA(t,i,-1),x=y.type==Dr.Text?y:null,S=b.type==Dr.Text?b:null;if(x&&(t.lineWrapping||y.widgetLineBreaks)&&(x=PN(t,r,1,x)),S&&(t.lineWrapping||b.widgetLineBreaks)&&(S=PN(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 Km(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 fue(t,e){return t.constructor==e.constructor&&t.eq(e)}class due{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(Db)!=e.state.facet(Db)&&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(Db);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)=>!fue(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 Db=Ce.define();function SV(t){return[yn.define(e=>new due(e,t)),Db.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 pue(t={}){return[cm.of(t),mue,gue,yue,Xz.of(!0)]}function _V(t){return t.startState.facet(cm)!=t.state.facet(cm)}const mue=SV({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 Km.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=_V(t);return n&&DN(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){DN(e.state,t)},class:"cm-cursorLayer"});function DN(t,e){e.style.animationDuration=t.facet(cm).cursorBlinkRate+"ms"}const gue=SV({above:!1,markers(t){return t.state.selection.ranges.map(e=>e.empty?[]:Km.forRange(t,"cm-selectionBackground",e)).reduce((e,n)=>e.concat(n))},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||_V(t)},class:"cm-selectionLayer"}),yue=$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"}}}})),CV=Qe.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(CV)?r.value:n,t)}}),bue=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:CV.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 vue(){return[dp,bue]}function IN(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 xue(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 wue{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 xue(e,this.maxLength))IN(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 IN(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 vA=/x/.unicode!=null?"gu":"g",Sue=new RegExp(`[\0-\b
|
||
--\u2028\u2029\uFEFF-]`,vA),_ue={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 P_=null;function Cue(){var t;if(P_==null&&typeof document<"u"&&document.body){let e=document.body.style;P_=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return P_||!1}const Ib=Ce.define({combine(t){let e=xo(t,{render:null,specialChars:Sue,addSpecialChars:null});return(e.replaceTabs=!Cue())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,vA)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,vA)),e}});function Aue(t={}){return[Ib.of(t),Eue()]}let LN=null;function Eue(){return LN||(LN=yn.fromClass(class{constructor(t){this.view=t,this.decorations=He.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(Ib)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new wue({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 Mue((a-c%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=He.replace({widget:new Rue(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(Ib);t.startState.facet(Ib)!=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 kue="•";function Tue(t){return t>=32?kue:t==10?"":String.fromCharCode(9216+t)}class Rue extends _l{constructor(e,n){super(),this.options=e,this.code=n}eq(e){return e.code==this.code}toDOM(e){let n=Tue(this.code),r=e.state.phrase("Control character")+" "+(_ue[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 Mue 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 Oue(){return Due}const Pue=He.line({class:"cm-activeLine"}),Due=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(Pue.range(i.from)),e=i.from)}return He.set(n)}},{decorations:t=>t.decorations}),xA=2e3;function Iue(t,e,n){let r=Math.min(e.line,n.line),i=Math.max(e.line,n.line),s=[];if(e.off>xA||n.off>xA||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=QC(h.text,o,t.tabSize,!0);if(f<0)s.push(fe.cursor(h.to));else{let d=QC(h.text,a,t.tabSize);s.push(fe.range(h.from+f,h.from+d))}}}return s}function Lue(t,e){let n=t.coordsAtPos(t.viewport.from);return n?Math.round(Math.abs((n.left-e)/t.defaultCharacterWidth)):-1}function NN(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>xA?-1:i==r.length?Lue(t,e.clientX):Qh(r.text,t.state.tabSize,n-r.from);return{line:r.number,col:s,off:i}}function Nue(t,e){let n=NN(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=NN(t,i);if(!a)return r;let c=Iue(t.state,n,a);return c.length?o?fe.create(c.concat(r.ranges)):fe.create(c):r}}:null}function $ue(t){let e=(n=>n.altKey&&n.button==0);return _e.mouseSelectionStyle.of((n,r)=>e(r)?Nue(n,r):null)}const jue={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},Bue={style:"cursor: crosshair"};function Fue(t={}){let[e,n]=jue[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?Bue:null})]}const Pd="-10000px";class AV{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 zue(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const D_=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)||zue}}}),$N=new WeakMap,uT=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(D_);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 AV(t,hT,(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(D_);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=sT(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(D_).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=$N.get(h))!==null&&e!==void 0?e:m.bottom-m.top,_=h.offset||Uue,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}$N.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",jN(f,(E-t.parent.left)/i)):(f.style.top=M/s+"px",jN(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 jN(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const Vue=_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"}}}),Uue={x:0,y:0},hT=Ce.define({enables:[uT,Vue]}),Av=Ce.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class iw{static create(e){return new iw(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new AV(e,Av,(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 Hue=hT.compute([Av],t=>{let e=t.facet(Av);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:iw.create,above:e[0].above,arrow:e.some(n=>n.arrow)}});class Wue{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(uT),n=e?e.manager.tooltips.findIndex(r=>r.create==iw.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:!Gue(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 Oy=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-Oy&&e.clientX<=r+Oy&&e.clientY>=i-Oy&&e.clientY<=s+Oy}function Gue(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 Kue(t,e={}){let n=Qe.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(Yue)&&(i=[]);return i},provide:i=>Av.from(i)});return{active:r,extension:[r,yn.define(i=>new Wue(i,t,r,n,e.hoverTime||300)),Hue]}}function EV(t,e){let n=t.plugin(uT);if(!n)return null;let r=n.manager.tooltips.indexOf(e);return r<0?null:n.manager.tooltipViews[r]}const Yue=Qe.define(),BN=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(kV),r=n?n.specs.indexOf(e):-1;return r>-1?n.panels[r]:null}const kV=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(BN);this.top=new Py(t,!0,e.topContainer),this.bottom=new Py(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(BN);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Py(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Py(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 Py{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=FN(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=FN(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 FN(t){let e=t.nextSibling;return t.remove(),e}const hm=Ce.define({enables:kV});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 Lb=Ce.define(),Xue=Ce.define(),Jue={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ft.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Rp=Ce.define();function Que(t){return[TV(),Rp.of({...Jue,...t})]}const zN=Ce.define({combine:t=>t.some(e=>e)});function TV(t){return[Zue]}const Zue=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 UN(t,e)),this.fixed=!t.state.facet(zN);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(zN)!=!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(Lb),this.view.viewport.from),r=[],i=this.gutters.map(s=>new ehe(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){wA(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){wA(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(Lb),t.state.facet(Lb),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 UN(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 VN(t){return Array.isArray(t)?t:[t]}function wA(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class ehe{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 RV(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=[];wA(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(Xue)){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 UN{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=VN(n.markers(e)),n.initialSpacer&&(this.spacer=new RV(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=VN(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 RV{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":""),the(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 the(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 nhe=Ce.define(),rhe=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 I_ extends Qo{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function L_(t,e){return t.state.facet(rh).formatNumber(e,t.state)}const ihe=Rp.compute([rh],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(nhe)},lineMarker(e,n,r){return r.some(i=>i.toDOM)?null:new I_(L_(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let i of e.state.facet(rhe)){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 I_(L_(e,HN(e.state.doc.lines)))},updateSpacer(e,n){let r=L_(n.view,HN(n.view.state.doc.lines));return r==e.number?e:new I_(r)},domEventHandlers:t.facet(rh).domEventHandlers,side:"before"}));function she(t={}){return[rh.of(t),TV(),ihe]}function HN(t){let e=9;for(;e<t;)e=e*10+9;return e}const ohe=new class extends Qo{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},ahe=Lb.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(ohe.range(i)))}return ft.of(e)});function lhe(){return ahe}const MV=1024;let che=0;class N_{constructor(e,n){this.from=e,this.to=n}}class it{constructor(e={}){this.id=che++,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=Qr.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 Ev{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 uhe=Object.create(null);class Qr{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):uhe,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Qr(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}}}}Qr.none=new Qr("",Object.create(null),0,8);class fT{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 Qr(r.name,i,r.id,r.flags):r)}return new fT(n)}}const Dy=new WeakMap,WN=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=Ev.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 _A(this.topNode,e)}cursorAt(e,n=0,r=0){let i=Dy.get(this)||this.topNode,s=new _A(i);return s.moveTo(e,n),Dy.set(this,s._tree),s}get topNode(){return new Qi(this,0,0,null)}resolve(e,n=0){let r=fm(Dy.get(this)||this.topNode,e,n,!1);return Dy.set(this,r),r}resolveInner(e,n=0){let r=fm(WN.get(this)||this.topNode,e,n,!0);return WN.set(this,r),r}resolveStack(e,n=0){return dhe(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:mT(Qr.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(Qr.none,n,r,i)))}static build(e){return phe(e)}}mn.empty=new mn(Qr.none,[],[],0);class dT{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 dT(this.buffer,this.index)}}class yl{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Qr.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&&!(OV(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 OV(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 Qi&&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 Qi&&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 PV{cursor(e=0){return new _A(this,e)}getChild(e,n=null,r=null){let i=qN(this,e,n,r);return i.length?i[0]:null}getChildren(e,n=null,r=null){return qN(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 SA(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 Qi extends PV{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(OV(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 hhe(o,f,e,d),null,m)}else if(s&$n.IncludeAnonymous||!f.type.isAnonymous||pT(f)){let m;if(!(s&$n.IgnoreMounts)&&(m=Ev.get(f))&&!m.overlay)return new Qi(m.tree,d,e,o);let y=new Qi(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=Ev.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 Qi(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 qN(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 SA(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 hhe{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class sl extends PV{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 DV(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 Qi&&n.index<0?null:n.parent,i=t.slice();return r?i[e]=r:i.splice(e,1),new fhe(i,n)}class fhe{constructor(e,n){this.heads=e,this.node=n}get next(){return DV(this.heads)}}function dhe(t,e,n){let r=t.resolveInner(e,n),i=null;for(let s=r instanceof Qi?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=Ev.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new Qi(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(fm(a,e,n,!1))}}return i?DV(i):r}class _A{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 Qi)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 Qi?(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||pT(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 SA(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 SA(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 pT(t){return t.children.some(e=>e instanceof yl||!e.type.isAnonymous||pT(e))}function phe(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=MV,reused:s=[],minRepeatType:o=r.types.length}=t,a=Array.isArray(n)?new dT(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=mT(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 GN=new WeakMap;function Nb(t,e){if(!t.isAnonymous||e instanceof yl||e.type!=t)return 1;let n=GN.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof mn)){n=1;break}n+=Nb(t,r)}GN.set(e,n)}return n}function mT(t,e,n,r,i,s,o,a,c){let h=0;for(let b=r;b<i;b++)h+=Nb(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=Nb(t,b[E]);for(E++;E<_;E++){let D=Nb(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(mT(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 IV{startParse(e,n,r){return typeof e=="string"&&(e=new mhe(e)),r=r?r.length?r.map(i=>new N_(i.from,i.to)):[new N_(0,0)]:[new N_(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 mhe{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 ghe=0;class Hi{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=ghe++}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 Hi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let i=new Hi(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 kv(e);return r=>r.modified.indexOf(n)>-1?r:kv.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let yhe=0;class kv{constructor(e){this.name=e,this.instances=[],this.id=yhe++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&bhe(n,a.modified));if(r)return r;let i=[],s=new Hi(e.name,i,e,n);for(let a of n)a.instances.push(s);let o=vhe(n);for(let a of e.set)if(!a.modified.length)for(let c of o)i.push(kv.get(a,c));return s}}function bhe(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function vhe(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 LV(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 Tv(r,o,c>0?s.slice(0,c):null);e[h]=f.sort(e[h])}}return NV.add(e)}const NV=new it;let Tv=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}};Tv.empty=new Tv([],2,null);function $V(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 xhe(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function whe(t,e,n,r=0,i=t.length){let s=new She(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class She{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=_he(e)||Tv.empty,d=xhe(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 _he(t){let e=t.type.prop(NV);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const we=Hi.define,Iy=we(),Ja=we(),KN=we(Ja),YN=we(Ja),Qa=we(),Ly=we(Qa),$_=we(Qa),Gs=we(),Xl=we(Gs),Ws=we(),qs=we(),CA=we(),Dd=we(CA),Ny=we(),xe={comment:Iy,lineComment:we(Iy),blockComment:we(Iy),docComment:we(Iy),name:Ja,variableName:we(Ja),typeName:KN,tagName:we(KN),propertyName:YN,attributeName:we(YN),className:we(Ja),labelName:we(Ja),namespace:we(Ja),macroName:we(Ja),literal:Qa,string:Ly,docString:we(Ly),character:we(Ly),attributeValue:we(Ly),number:$_,integer:we($_),float:we($_),bool:we(Qa),regexp:we(Qa),escape:we(Qa),color:we(Qa),url:we(Qa),keyword:Ws,self:we(Ws),null:we(Ws),atom:we(Ws),unit:we(Ws),modifier:we(Ws),operatorKeyword:we(Ws),controlKeyword:we(Ws),definitionKeyword:we(Ws),moduleKeyword:we(Ws),operator:qs,derefOperator:we(qs),arithmeticOperator:we(qs),logicOperator:we(qs),bitwiseOperator:we(qs),compareOperator:we(qs),updateOperator:we(qs),definitionOperator:we(qs),typeOperator:we(qs),controlOperator:we(qs),punctuation:CA,separator:we(CA),bracket:Dd,angleBracket:we(Dd),squareBracket:we(Dd),paren:we(Dd),brace:we(Dd),content:Gs,heading:Xl,heading1:we(Xl),heading2:we(Xl),heading3:we(Xl),heading4:we(Xl),heading5:we(Xl),heading6:we(Xl),contentSeparator:we(Gs),list:we(Gs),quote:we(Gs),emphasis:we(Gs),strong:we(Gs),link:we(Gs),monospace:we(Gs),strikethrough:we(Gs),inserted:we(),deleted:we(),changed:we(),invalid:we(),meta:Ny,documentMeta:we(Ny),annotation:we(Ny),processingInstruction:we(Ny),definition:Hi.defineModifier("definition"),constant:Hi.defineModifier("constant"),function:Hi.defineModifier("function"),standard:Hi.defineModifier("standard"),local:Hi.defineModifier("local"),special:Hi.defineModifier("special")};for(let t in xe){let e=xe[t];e instanceof Hi&&(e.name=t)}$V([{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 j_;const ih=new it;function Che(t){return Ce.define({combine:t?e=>e.concat(t):void 0})}const Ahe=new it;class ys{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=XN(s,o,a),h=c.type.prop(ih);if(!h)return[];let f=s.facet(h),d=c.type.prop(Ahe);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 XN(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}}ys.setState=Qe.define();function XN(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 Rv extends ys{constructor(e,n,r){super(e,n,[],r),this.parser=n}static define(e){let n=Che(e.languageData);return new Rv(n,e.parser.configure({props:[ih.add(r=>r.isTop?n:void 0)]}),e.name)}configure(e,n){return new Rv(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function br(t){let e=t.field(ys.state,!1);return e?e.tree:mn.empty}class Ehe{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 Mv{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 Mv(e,n,[],mn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Ehe(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=JN(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 Mv(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=JN(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 IV{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(Qr.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 JN(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=Mv.create(e.facet(bl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new $h(r)}}ys.state=Zn.define({create:$h.init,update(t,e){for(let n of e.effects)if(n.is(ys.setState))return n.value;return e.startState.facet(bl)!=e.state.facet(bl)?$h.init(e.state):t.apply(e)}});let jV=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(jV=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const B_=typeof navigator<"u"&&(!((j_=navigator.scheduling)===null||j_===void 0)&&j_.isInputPending)?()=>navigator.scheduling.isInputPending():null,khe=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(ys.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(ys.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=jV(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(ys.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!B_?Math.max(25,e.timeRemaining()-5):1e9),a=s.context.treeLen<i&&r.doc.length>i+1e3,c=s.context.work(()=>B_&&B_()||Date.now()>o,i+(a?0:1e5));this.chunkBudget-=Date.now()-n,(c||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:ys.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=>[ys.state,khe,_e.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class The{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const Rhe=Ce.define(),gT=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 Ov(t){let e=t.facet(gT);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function dm(t,e){let n="",r=t.tabSize,i=t.facet(gT)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s<e;s++)n+=i;return n}function yT(t,e){t instanceof ht&&(t=new sw(t));for(let r of t.state.facet(Rhe)){let i=r(t,e);if(i!==void 0)return i}let n=br(t.state);return n.length>=e?Mhe(t,n,e):null}class sw{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ov(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 BV=new it;function Mhe(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 FV(r,t,n)}function FV(t,e,n){for(let r=t;r;r=r.next){let i=Phe(r.node);if(i)return i(bT.create(e,n,r))}return 0}function Ohe(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function Phe(t){let e=t.type.prop(BV);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=>Nhe(o,!0,1,void 0,s&&!Ohe(o)?i.from:void 0)}return t.parent==null?Dhe:null}function Dhe(){return 0}class bT extends sw{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 bT(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(Ihe(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return FV(this.context.next,this.base,this.pos)}}function Ihe(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function Lhe(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 Nhe(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=Lhe(t);return c?a?t.column(c.from):t.column(c.to):t.baseIndent+(a?0:t.unit*n)}function QN({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const $he=200;function jhe(){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+$he)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=yT(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 Bhe=Ce.define(),zV=new it;function Fhe(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 zhe(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(zV);if(c&&(a.to<r.length-50||r.length==t.doc.length||!Vhe(a))){let h=c(a,t);h&&h.from<=n&&h.from>=e&&h.to>n&&(s=h)}}return s}function Vhe(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function Pv(t,e,n){for(let r of t.facet(Bhe)){let i=r(t,e,n);if(i)return i}return zhe(t,e,n)}function VV(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 ow=Qe.define({map:VV}),Ym=Qe.define({map:VV});function UV(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=ZN(t,n,r)),t=t.map(e.changes);for(let n of e.effects)if(n.is(ow)&&!Uhe(t,n.value.from,n.value.to)){let{preparePlaceholder:r}=e.state.facet(qV),i=r?He.replace({widget:new Xhe(r(e.state,n.value))}):e3;t=t.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Ym)&&(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=ZN(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(e3.range(r,i))}return He.set(e,!0)}});function ZN(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 Dv(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 Uhe(t,e,n){let r=!1;return t.between(e,e,(i,s)=>{i==e&&s==n&&(r=!0)}),r}function HV(t,e){return t.field(Mc,!1)?e:e.concat(Qe.appendConfig.of(GV()))}const Hhe=t=>{for(let e of UV(t)){let n=Pv(t.state,e.from,e.to);if(n)return t.dispatch({effects:HV(t.state,[ow.of(n),WV(t,n)])}),!0}return!1},Whe=t=>{if(!t.state.field(Mc,!1))return!1;let e=[];for(let n of UV(t)){let r=Dv(t.state,n.from,n.to);r&&e.push(Ym.of(r),WV(t,r,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function WV(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=Pv(e,i.from,i.to);s&&n.push(ow.of(s)),r=(s?t.lineBlockAt(s.to):i).to+1}return n.length&&t.dispatch({effects:HV(t.state,n)}),!!n.length},Ghe=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(Ym.of({from:r,to:i}))}),t.dispatch({effects:n}),!0},Khe=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Hhe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Whe},{key:"Ctrl-Alt-[",run:qhe},{key:"Ctrl-Alt-]",run:Ghe}],Yhe={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},qV=Ce.define({combine(t){return xo(t,Yhe)}});function GV(t){return[Mc,Zhe]}function KV(t,e){let{state:n}=t,r=n.facet(qV),i=o=>{let a=t.lineBlockAt(t.posAtDOM(o.target)),c=Dv(t.state,a.from,a.to);c&&t.dispatch({effects:Ym.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 e3=He.replace({widget:new class extends _l{toDOM(t){return KV(t,null)}}});class Xhe extends _l{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return KV(e,this.value)}}const Jhe={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class F_ 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 Qhe(t={}){let e={...Jhe,...t},n=new F_(e,!0),r=new F_(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=Dv(o.state,c.from,c.to)?r:Pv(o.state,c.from,c.to)?n:null;h&&a.add(c.from,c.from,h)}return a.finish()}}),{domEventHandlers:s}=e;return[i,Que({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 F_(e,!1)},domEventHandlers:{...s,click:(o,a,c)=>{if(s.click&&s.click(o,a,c))return!0;let h=Dv(o.state,a.from,a.to);if(h)return o.dispatch({effects:Ym.of(h)}),!0;let f=Pv(o.state,a.from,a.to);return f?(o.dispatch({effects:ow.of(f)}),!0):!1}}}),GV()]}const Zhe=_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 aw{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 ys?a=>a.prop(ih)==o.data:o?a=>a==o:void 0,this.style=$V(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 aw(e,n||{})}}const AA=Ce.define(),YV=Ce.define({combine(t){return t.length?[t[0]]:null}});function z_(t){let e=t.facet(AA);return e.length?e:t.facet(YV)}function efe(t,e){let n=[nfe],r;return t instanceof aw&&(t.module&&n.push(_e.styleModule.of(t.module)),r=t.themeType),e?.fallback?n.push(YV.of(t)):r?n.push(AA.computeN([_e.darkTheme],i=>i.facet(_e.darkTheme)==(r=="dark")?[t]:[])):n.push(AA.of(t)),n}class tfe{constructor(e){this.markCache=Object.create(null),this.tree=br(e.state),this.decorations=this.buildDeco(e,z_(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=br(e.state),r=z_(e.state),i=r!=z_(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)whe(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 nfe=$c.high(yn.fromClass(tfe,{decorations:t=>t.decorations})),rfe=aw.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"}]),ife=_e.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),XV=1e4,JV="()[]{}",QV=Ce.define({combine(t){return xo(t,{afterCursor:!0,brackets:JV,maxScanDistance:XV,renderMatch:afe})}}),sfe=He.mark({class:"cm-matchingBracket"}),ofe=He.mark({class:"cm-nonmatchingBracket"});function afe(t){let e=[],n=t.matched?sfe:ofe;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 lfe=Zn.define({create(){return He.none},update(t,e){if(!e.docChanged&&!e.selection)return t;let n=[],r=e.state.facet(QV);for(let i of e.state.selection.ranges){if(!i.empty)continue;let s=io(e.state,i.head,-1,r)||i.head>0&&io(e.state,i.head-1,1,r)||r.afterCursor&&(io(e.state,i.head,1,r)||i.head<e.state.doc.length&&io(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)}),cfe=[lfe,ife];function ufe(t={}){return[QV.of(t),cfe]}const hfe=new it;function EA(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 kA(t){let e=t.type.prop(hfe);return e?e(t.node):t}function io(t,e,n,r={}){let i=r.maxScanDistance||XV,s=r.brackets||JV,o=br(t),a=o.resolveInner(e,n);for(let c=a;c;c=c.parent){let h=EA(c.type,n,s);if(h&&c.from<c.to){let f=kA(c);if(f&&(n>0?e>=f.from&&e<f.to:e>f.from&&e<=f.to))return ffe(t,e,n,c,f,h,s)}}return dfe(t,e,n,o,a.type,i,s)}function ffe(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=kA(f);return{start:c,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(EA(f.type,n,o))h++;else if(EA(f.type,-n,o)){if(h==0){let d=kA(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 dfe(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 pfe=Object.create(null),t3=[Qr.none],n3=[],r3=Object.create(null),mfe=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"]])mfe[t]=gfe(pfe,e);function V_(t,e){n3.indexOf(t)>-1||(n3.push(t),console.warn(e))}function gfe(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):V_(h,`Modifier ${h} used at start of tag`):c.length?V_(h,`Tag ${h} used as modifier`):c=Array.isArray(f)?f:[f]:V_(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=r3[i];if(s)return s.id;let o=r3[i]=Qr.define({id:t3.length,name:r,props:[LV({[r]:n})]});return t3.push(o),o.id}jt.RTL,jt.LTR;const yfe=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=xT(t.state,n.from);return r.line?bfe(t):r.block?xfe(t):!1};function vT(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 bfe=vT(_fe,0),vfe=vT(ZV,0),xfe=vT((t,e)=>ZV(t,e,Sfe(e)),0);function xT(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Ld=50;function wfe(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 Sfe(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 ZV(t,e,n=e.selection.ranges){let r=n.map(s=>xT(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>wfe(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 _fe(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=xT(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 TA=sa.define(),Cfe=sa.define(),Afe=Ce.define(),e7=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)})}}),t7=Zn.define({create(){return so.empty},update(t,e){let n=e.state.facet(e7),r=e.annotation(TA);if(r){let c=Yr.fromTransaction(e,r.selection),h=r.side,f=h==0?t.undone:t.done;return c?f=Iv(f,f.length,n.minDepth,c):f=i7(f,e.startState.selection),new so(h==0?r.rest:f,h==0?f:r.rest)}let i=e.annotation(Cfe);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 so(t.done.map(Yr.fromJSON),t.undone.map(Yr.fromJSON))}});function Efe(t={}){return[t7,e7.of(t),_e.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?n7:e.inputType=="historyRedo"?RA:null;return r?(e.preventDefault(),r(n)):!1}})]}function lw(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(t7,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const n7=lw(0,!1),RA=lw(1,!1),kfe=lw(0,!0),Tfe=lw(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&&co.fromJSON(e.mapped),e.startSelection&&fe.fromJSON(e.startSelection),e.selectionsAfter.map(fe.fromJSON))}static fromTransaction(e,n){let r=Ki;for(let i of e.startState.facet(Afe)){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,Ki)}static selection(e){return new Yr(void 0,Ki,void 0,void 0,e)}}function Iv(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 Rfe(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 Mfe(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function r7(t,e){return t.length?e.length?t.concat(e):t:e}const Ki=[],Ofe=200;function i7(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Ofe));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Iv(t,t.length-1,1e9,n.setSelAfter(r)))}else return[Yr.selection([e])]}function Pfe(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 U_(t,e){if(!t.length)return t;let n=t.length,r=Ki;for(;n;){let i=Dfe(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)]:Ki}function Dfe(t,e,n){let r=r7(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):Ki,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,Qe.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const Ife=/^(input\.type|delete)($|\.)/;class so{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 so(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||Ife.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(s,Rfe(a.changes,e.changes))||r=="input.type.compose")?o=Iv(o,o.length-1,i.minDepth,new Yr(e.changes.compose(a.changes),r7(Qe.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,Ki)):o=Iv(o,o.length,i.minDepth,e),new so(o,Ki,n,r)}addSelection(e,n,r,i){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Ki;return s.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Mfe(s[s.length-1],e)?this:new so(i7(this.done,e),this.undone,n,r)}addMapping(e){return new so(U_(this.done,e),U_(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:TA.of({side:e,rest:Pfe(i),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let a=i.length==1?Ki:i.slice(0,i.length-1);return s.mapped&&(a=U_(a,s.mapped)),n.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:TA.of({side:e,rest:a,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}so.empty=new so(Ki,Ki);const Lfe=[{key:"Mod-z",run:n7,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:RA,preventDefault:!0},{linux:"Ctrl-Shift-z",run:RA,preventDefault:!0},{key:"Mod-u",run:kfe,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Tfe,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 Ms({state:t,dispatch:e},n){let r=Zh(t.selection,n);return r.eq(t.selection,!0)?!1:(e(wo(t,r)),!0)}function cw(t,e){return fe.cursor(e?t.to:t.from)}function s7(t,e){return Ms(t,n=>n.empty?t.moveByChar(n,e):cw(n,e))}function vr(t){return t.textDirectionAt(t.state.selection.main.head)==jt.LTR}const o7=t=>s7(t,!vr(t)),a7=t=>s7(t,vr(t));function l7(t,e){return Ms(t,n=>n.empty?t.moveByGroup(n,e):cw(n,e))}const Nfe=t=>l7(t,!vr(t)),$fe=t=>l7(t,vr(t));function jfe(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 uw(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;jfe(t,h,i)?r=h:c=n?h.to:h.from}let s=r.type.prop(i),o,a;return s&&(o=n?io(t,r.from,1):io(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 Bfe=t=>Ms(t,e=>uw(t.state,e,!vr(t))),Ffe=t=>Ms(t,e=>uw(t.state,e,vr(t)));function c7(t,e){return Ms(t,n=>{if(!n.empty)return cw(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const u7=t=>c7(t,!1),h7=t=>c7(t,!0);function f7(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 d7(t,e){let n=f7(t),{state:r}=t,i=Zh(r.selection,o=>o.empty?t.moveVertically(o,e,n.height):cw(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 i3=t=>d7(t,!1),MA=t=>d7(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 zfe=t=>Ms(t,e=>Cl(t,e,!0)),Vfe=t=>Ms(t,e=>Cl(t,e,!1)),Ufe=t=>Ms(t,e=>Cl(t,e,!vr(t))),Hfe=t=>Ms(t,e=>Cl(t,e,vr(t))),Wfe=t=>Ms(t,e=>fe.cursor(t.lineBlockAt(e.head).from,1)),qfe=t=>Ms(t,e=>fe.cursor(t.lineBlockAt(e.head).to,-1));function Gfe(t,e,n){let r=!1,i=Zh(t.selection,s=>{let o=io(t,s.head,-1)||io(t,s.head,1)||s.head>0&&io(t,s.head-1,1)||s.head<t.doc.length&&io(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 Kfe=({state:t,dispatch:e})=>Gfe(t,e);function rs(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 p7(t,e){return rs(t,n=>t.moveByChar(n,e))}const m7=t=>p7(t,!vr(t)),g7=t=>p7(t,vr(t));function y7(t,e){return rs(t,n=>t.moveByGroup(n,e))}const Yfe=t=>y7(t,!vr(t)),Xfe=t=>y7(t,vr(t)),Jfe=t=>rs(t,e=>uw(t.state,e,!vr(t))),Qfe=t=>rs(t,e=>uw(t.state,e,vr(t)));function b7(t,e){return rs(t,n=>t.moveVertically(n,e))}const v7=t=>b7(t,!1),x7=t=>b7(t,!0);function w7(t,e){return rs(t,n=>t.moveVertically(n,e,f7(t).height))}const s3=t=>w7(t,!1),o3=t=>w7(t,!0),Zfe=t=>rs(t,e=>Cl(t,e,!0)),ede=t=>rs(t,e=>Cl(t,e,!1)),tde=t=>rs(t,e=>Cl(t,e,!vr(t))),nde=t=>rs(t,e=>Cl(t,e,vr(t))),rde=t=>rs(t,e=>fe.cursor(t.lineBlockAt(e.head).from)),ide=t=>rs(t,e=>fe.cursor(t.lineBlockAt(e.head).to)),a3=({state:t,dispatch:e})=>(e(wo(t,{anchor:0})),!0),l3=({state:t,dispatch:e})=>(e(wo(t,{anchor:t.doc.length})),!0),c3=({state:t,dispatch:e})=>(e(wo(t,{anchor:t.selection.main.anchor,head:0})),!0),u3=({state:t,dispatch:e})=>(e(wo(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),sde=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),ode=({state:t,dispatch:e})=>{let n=hw(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},ade=({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)},lde=({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 Xm(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=$y(t,c,!1)):c>o&&(n="delete.forward",c=$y(t,c,!0)),o=Math.min(o,c),a=Math.max(a,c)}else o=$y(t,o,!1),a=$y(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 $y(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 S7=(t,e,n)=>Xm(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%Ov(s)||Ov(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}),OA=t=>S7(t,!1,!0),_7=t=>S7(t,!0,!1),C7=(t,e)=>Xm(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}),A7=t=>C7(t,!1),cde=t=>C7(t,!0),ude=t=>Xm(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),hde=t=>Xm(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),fde=t=>Xm(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),dde=({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},pde=({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 hw(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 E7(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of hw(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 mde=({state:t,dispatch:e})=>E7(t,e,!1),gde=({state:t,dispatch:e})=>E7(t,e,!0);function k7(t,e,n){if(t.readOnly)return!1;let r=[];for(let i of hw(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 yde=({state:t,dispatch:e})=>k7(t,e,!1),bde=({state:t,dispatch:e})=>k7(t,e,!0),vde=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(hw(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 xde(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 h3=T7(!1),wde=T7(!0);function T7(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&&xde(e,s);t&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let h=new sw(e,{simulateBreak:s,simulateDoubleBreak:!!c}),f=yT(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 wT(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 Sde=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new sw(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=wT(t,(s,o,a)=>{let c=yT(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},_de=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(wT(t,(n,r)=>{r.push({from:n.from,insert:t.facet(gT)})}),{userEvent:"input.indent"})),!0),Cde=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(wT(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-Ov(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),Ade=t=>(t.setTabFocusMode(),!0),Ede=[{key:"Ctrl-b",run:o7,shift:m7,preventDefault:!0},{key:"Ctrl-f",run:a7,shift:g7},{key:"Ctrl-p",run:u7,shift:v7},{key:"Ctrl-n",run:h7,shift:x7},{key:"Ctrl-a",run:Wfe,shift:rde},{key:"Ctrl-e",run:qfe,shift:ide},{key:"Ctrl-d",run:_7},{key:"Ctrl-h",run:OA},{key:"Ctrl-k",run:ude},{key:"Ctrl-Alt-h",run:A7},{key:"Ctrl-o",run:dde},{key:"Ctrl-t",run:pde},{key:"Ctrl-v",run:MA}],kde=[{key:"ArrowLeft",run:o7,shift:m7,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Nfe,shift:Yfe,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Ufe,shift:tde,preventDefault:!0},{key:"ArrowRight",run:a7,shift:g7,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:$fe,shift:Xfe,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Hfe,shift:nde,preventDefault:!0},{key:"ArrowUp",run:u7,shift:v7,preventDefault:!0},{mac:"Cmd-ArrowUp",run:a3,shift:c3},{mac:"Ctrl-ArrowUp",run:i3,shift:s3},{key:"ArrowDown",run:h7,shift:x7,preventDefault:!0},{mac:"Cmd-ArrowDown",run:l3,shift:u3},{mac:"Ctrl-ArrowDown",run:MA,shift:o3},{key:"PageUp",run:i3,shift:s3},{key:"PageDown",run:MA,shift:o3},{key:"Home",run:Vfe,shift:ede,preventDefault:!0},{key:"Mod-Home",run:a3,shift:c3},{key:"End",run:zfe,shift:Zfe,preventDefault:!0},{key:"Mod-End",run:l3,shift:u3},{key:"Enter",run:h3,shift:h3},{key:"Mod-a",run:sde},{key:"Backspace",run:OA,shift:OA},{key:"Delete",run:_7},{key:"Mod-Backspace",mac:"Alt-Backspace",run:A7},{key:"Mod-Delete",mac:"Alt-Delete",run:cde},{mac:"Mod-Backspace",run:hde},{mac:"Mod-Delete",run:fde}].concat(Ede.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Tde=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Bfe,shift:Jfe},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Ffe,shift:Qfe},{key:"Alt-ArrowUp",run:mde},{key:"Shift-Alt-ArrowUp",run:yde},{key:"Alt-ArrowDown",run:gde},{key:"Shift-Alt-ArrowDown",run:bde},{key:"Escape",run:lde},{key:"Mod-Enter",run:wde},{key:"Alt-l",mac:"Ctrl-l",run:ode},{key:"Mod-i",run:ade,preventDefault:!0},{key:"Mod-[",run:Cde},{key:"Mod-]",run:_de},{key:"Mod-Alt-\\",run:Sde},{key:"Shift-Mod-k",run:vde},{key:"Shift-Mod-\\",run:Kfe},{key:"Mod-/",run:yfe},{key:"Alt-A",run:vfe},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Ade}].concat(kde),f3=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(f3(a)):f3,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=Xk(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=eo(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 R7={from:-1,to:-1,match:/.*/.exec("")},ST="gm"+(/x/.unicode==null?"":"u");class M7{constructor(e,n,r,i=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=R7,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new O7(e,n,r,i,s);this.re=new RegExp(n,ST+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=e.iter();let o=e.lineAt(i);this.curLineStart=o.from,this.matchPos=Lv(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=Lv(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 H_=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=H_.get(e);if(!i||i.from>=r||i.to<=n){let a=new Sh(n,e.sliceString(n,r));return H_.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)),H_.set(e,new Sh(o,s)),new Sh(n,s.slice(n-o,r-o))}}class O7{constructor(e,n,r,i,s){this.text=e,this.to=s,this.done=!1,this.value=R7,this.matchPos=Lv(e,i),this.re=new RegExp(n,ST+(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=Lv(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"&&(M7.prototype[Symbol.iterator]=O7.prototype[Symbol.iterator]=function(){return this});function Rde(t){try{return new RegExp(t,ST),!0}catch{return!1}}function Lv(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 PA(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=Qe.define(),d3=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?PA:null)}),Mde=t=>{let e=um(t,PA);if(!e){let n=[Mp.of(!0)];t.state.field(d3,!1)==null&&n.push(Qe.appendConfig.of([d3,Ode])),t.dispatch({effects:n}),e=um(t,PA)}return e&&e.dom.querySelector("input").select(),!0},Ode=_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"}}}),Pde={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Dde=Ce.define({combine(t){return xo(t,Pde,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function Ide(t){return[Bde,jde]}const Lde=He.mark({class:"cm-selectionMatch"}),Nde=He.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function p3(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 $de(t,e,n,r){return t(e.sliceDoc(n,n+1))==Vt.Word&&t(e.sliceDoc(r-1,r))==Vt.Word}const jde=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(Dde),{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),!(p3(o,n,i.from,i.to)&&$de(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||p3(o,n,f,d))&&(i.empty&&f<=i.from&&d>=i.to?a.push(Nde.range(f,d)):(f>=i.to||d<=i.from)&&a.push(Lde.range(f,d)),a.length>e.maxMatches))return He.none}}return He.set(a)}},{decorations:t=>t.decorations}),Bde=_e.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Fde=({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 zde(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 Vde=({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(s=>s.from===s.to))return Fde({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=zde(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 epe(e),scrollToMatch:e=>_e.scrollIntoView(e)})}});class P7{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||Rde(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 Hde(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 D7{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?Ude(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function Ude(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(Nv(i,n-s))!=Vt.Word||e($v(i,n-s))!=Vt.Word)&&(e($v(i,r-s))!=Vt.Word||e(Nv(i,r-s))!=Vt.Word))}class Hde extends D7{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 M7(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?Wde(e.charCategorizer(e.selection.main.head)):void 0},n,r)}function Nv(t,e){return t.slice(Xn(t,e,!1),e)}function $v(t,e){return t.slice(e,Xn(t,e))}function Wde(t){return(e,n,r)=>!r[0].length||(t(Nv(r.input,r.index))!=Vt.Word||t($v(r.input,r.index))!=Vt.Word)&&(t($v(r.input,r.index+r[0].length))!=Vt.Word||t(Nv(r.input,r.index+r[0].length))!=Vt.Word)}class qde extends D7{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=Qe.define(),_T=Qe.define(),ll=Zn.define({create(t){return new W_(DA(t).create(),null)},update(t,e){for(let n of e.effects)n.is(pm)?t=new W_(n.value.create(),t.panel):n.is(_T)&&(t=new W_(t.query,n.value?CT:null));return t},provide:t=>hm.from(t,e=>e.panel)});class W_{constructor(e,n){this.query=e,this.panel=n}}const Gde=He.mark({class:"cm-searchMatch"}),Kde=He.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Yde=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?Kde:Gde)})}return r.finish()}},{decorations:t=>t.decorations});function Jm(t){return e=>{let n=e.state.field(ll,!1);return n&&n.query.spec.valid?t(e,n):N7(e)}}const jv=Jm((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:[AT(t,r),s.scrollToMatch(i.main,t)],userEvent:"select.search"}),L7(t),!0}),Bv=Jm((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:[AT(t,i),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),L7(t),!0}),Xde=Jm((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)}),Jde=({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},m3=Jm((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(AT(t,o)),f.push(n.facet(ef).scrollToMatch(c.main,t))),t.dispatch({changes:d,selection:c,effects:f,userEvent:"input.replace"}),!0}),Qde=Jm((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 CT(t){return t.state.facet(ef).createPanel(t)}function DA(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 P7({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 I7(t){let e=um(t,CT);return e&&e.dom.querySelector("[main-field]")}function L7(t){let e=I7(t);e&&e==t.root.activeElement&&e.select()}const N7=t=>{let e=t.state.field(ll,!1);if(e&&e.panel){let n=I7(t);if(n&&n!=t.root.activeElement){let r=DA(t.state,e.query.spec);r.valid&&t.dispatch({effects:pm.of(r)}),n.focus(),n.select()}}else t.dispatch({effects:[_T.of(!0),e?pm.of(DA(t.state,e.query.spec)):Qe.appendConfig.of(npe)]});return!0},$7=t=>{let e=t.state.field(ll,!1);if(!e||!e.panel)return!1;let n=um(t,CT);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:_T.of(!1)}),!0},Zde=[{key:"Mod-f",run:N7,scope:"editor search-panel"},{key:"F3",run:jv,shift:Bv,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:jv,shift:Bv,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:$7,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Jde},{key:"Mod-Alt-g",run:Mde},{key:"Mod-d",run:Vde,preventDefault:!0}];class epe{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:fi(e,"Find"),"aria-label":fi(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:fi(e,"Replace"),"aria-label":fi(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",()=>jv(e),[fi(e,"next")]),r("prev",()=>Bv(e),[fi(e,"previous")]),r("select",()=>Xde(e),[fi(e,"all")]),kt("label",null,[this.caseField,fi(e,"match case")]),kt("label",null,[this.reField,fi(e,"regexp")]),kt("label",null,[this.wordField,fi(e,"by word")]),...e.state.readOnly?[]:[kt("br"),this.replaceField,r("replace",()=>m3(e),[fi(e,"replace")]),r("replaceAll",()=>Qde(e),[fi(e,"replace all")])],kt("button",{name:"close",onclick:()=>$7(e),"aria-label":fi(e,"close"),type:"button"},["×"])])}commit(){let e=new P7({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){lue(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Bv:jv)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),m3(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 fi(t,e){return t.state.phrase(e)}const jy=30,By=/[\s\.,:;?!]/;function AT(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-jy),o=Math.min(i,n+jy),a=t.state.sliceDoc(s,o);if(s!=r.from){for(let c=0;c<jy;c++)if(!By.test(a[c+1])&&By.test(a[c])){a=a.slice(c);break}}if(o!=i){for(let c=a.length-1;c>a.length-jy;c--)if(!By.test(a[c-1])&&By.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 tpe=_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"}}),npe=[ll,$c.low(Yde),tpe];class j7{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(B7(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 g3(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 rpe(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=g3(e)+g3(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function ipe(t){let e=t.map(i=>typeof i=="string"?{label:i}:i),[n,r]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:rpe(e);return i=>{let s=i.matchBefore(r);return s||i.explicit?{from:s?s.from:i.pos,options:e,validFor:n}:null}}class y3{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 B7(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 F7=sa.define();function spe(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 b3=new WeakMap;function ope(t){if(!Array.isArray(t))return t;let e=b3.get(t);return e||b3.set(t,e=ipe(t)),e}const Fv=Qe.define(),mm=Qe.define();class ape{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=eo(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=eo(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+=eo(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=Xk(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+=eo(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?eo(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 lpe{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:cpe,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=>v3(e(r),n(r)),optionClass:(e,n)=>r=>v3(e(r),n(r)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function v3(t,e){return t?e?t+" "+e:t:e}function cpe(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 upe(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 q_(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 hpe{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=upe(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=q_(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=q_(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=q_(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&&dpe(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 fpe(t,e){return n=>new hpe(n,t,e)}function dpe(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 x3(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function ppe(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 y3(d,h.source,f?f(d):[],1e9-n.length));else{let d=e.sliceDoc(h.from,h.to),m,y=s.filterStrict?new lpe(d):new ape(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 y3(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):x3(h.completion)>x3(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,w3(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=ppe(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,w3(r,c),{pos:e.reduce((h,f)=>f.hasResult()?Math.min(h,f.from):h,1e8),create:xpe,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 zv{constructor(e,n,r){this.active=e,this.id=n,this.open=r}static start(){return new zv(bpe,"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(ope)).map(c=>(this.active.find(f=>f.source==c)||new Yi(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(ET));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(c=>c.hasResult()&&e.changes.touchesRange(c.from,c.to))||!mpe(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 Yi(c.source,0):c));for(let c of e.effects)c.is(V7)&&(o=o&&o.setSelected(c.value,this.id));return s==this.active&&o==this.open?this:new zv(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?gpe:ype}}function mpe(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 gpe={"aria-autocomplete":"list"},ype={};function w3(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const bpe=[];function z7(t,e){if(t.isUserEvent("input.complete")){let r=t.annotation(F7);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 Yi{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=z7(e,n),i=this;(r&8||r&16&&this.touches(e))&&(i=new Yi(i.source,0)),r&4&&i.state==0&&(i=new Yi(this.source,1)),i=i.updateFor(e,r);for(let s of e.effects)if(s.is(Fv))i=new Yi(i.source,1,s.value);else if(s.is(mm))i=new Yi(i.source,0);else if(s.is(ET))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 Yi{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 Yi(this.source,n&4?1:0);let c=e.changes.mapPos(this.limit);return vpe(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 j7(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 Yi(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 Yi(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function vpe(t,e,n,r){if(!t)return!1;let i=e.sliceDoc(n,r);return typeof t=="function"?t(i,n,r,e):B7(t,!0).test(i)}const ET=Qe.define({map(t,e){return t.map(n=>n.map(e))}}),V7=Qe.define(),Gr=Zn.define({create(){return zv.start()},update(t,e){return t.update(e)},provide:t=>[hT.from(t,e=>e.tooltip),_e.contentAttributes.from(t,e=>e.attrs)]});function kT(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({...spe(t.state,n,r.from,r.to),annotations:F7.of(e.completion)}):n(t,e.completion,r.from,r.to),!0):!1}const xpe=fpe(Gr,kT);function Fy(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=EV(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:V7.of(a)}),!0}}const wpe=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:kT(t,e.open.options[e.open.selected])},G_=t=>t.state.field(Gr,!1)?(t.dispatch({effects:Fv.of(!0)}),!0):!1,Spe=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 _pe{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Cpe=50,Ape=1e3,Epe=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=z7(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>Cpe&&Date.now()-o.time>Ape){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(Fv)))&&(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 j7(e,n,t.explicit,this.view),i=new _pe(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 Yi(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:ET.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&&EV(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:Fv.of(!1)}),20),this.composing=0}}}),kpe=typeof navigator=="object"&&/Win/.test(navigator.platform),Tpe=$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&&!(kpe&&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&&kT(e,r),!1}})),Rpe=_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=Qe.define({map(t,e){let n=e.mapPos(t,-1,Mr.TrackAfter);return n??void 0}}),TT=new class extends Ec{};TT.startSide=1;TT.endSide=-1;const U7=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:[TT.range(n.value,n.value+1)]}));return t}});function Mpe(){return[Ppe,U7]}const K_="()[]{}<>«»»«[]{}";function H7(t){for(let e=0;e<K_.length;e+=2)if(K_.charCodeAt(e)==t)return K_.charAt(e+1);return Xk(t<128?t:t+1)}function W7(t,e){return t.languageDataAt("closeBrackets",e)[0]||gm}const Ope=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Ppe=_e.inputHandler.of((t,e,n,r)=>{if((Ope?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let i=t.state.selection.main;if(r.length>2||r.length==2&&eo(Wr(r,0))==1||e!=i.from||n!=i.to)return!1;let s=Lpe(t.state,r);return s?(t.dispatch(s),!0):!1}),Dpe=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=W7(t,t.selection.main.head).brackets||gm.brackets,i=null,s=t.changeByRange(o=>{if(o.empty){let a=Npe(t.doc,o.head);for(let c of r)if(c==a&&fw(t.doc,o.head)==H7(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},Ipe=[{key:"Backspace",run:Dpe}];function Lpe(t,e){let n=W7(t,t.selection.main.head),r=n.brackets||gm.brackets;for(let i of r){let s=H7(Wr(i,0));if(e==i)return s==i?Bpe(t,i,r.indexOf(i+i+i)>-1,n):$pe(t,i,s,n.before||gm.before);if(e==s&&q7(t,t.selection.main.from))return jpe(t,i,s)}return null}function q7(t,e){let n=!1;return t.field(U7).between(0,t.doc.length,r=>{r==e&&(n=!0)}),n}function fw(t,e){let n=t.sliceString(e,e+2);return n.slice(0,eo(Wr(n,0)))}function Npe(t,e){let n=t.sliceString(e-2,e);return eo(Wr(n,0))==n.length?n:n.slice(1)}function $pe(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=fw(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 jpe(t,e,n){let r=null,i=t.changeByRange(s=>s.empty&&fw(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 Bpe(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=fw(t.doc,c),f;if(h==e){if(S3(t,c))return{changes:{insert:e+e,from:c},effects:fc.of(c+e.length),range:fe.cursor(c+e.length)};if(q7(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=_3(t,c-2*e.length,i))>-1&&S3(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&&_3(t,c,i)>-1&&!Fpe(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 S3(t,e){let n=br(t).resolveInner(e+1);return n.parent&&n.from==e}function Fpe(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 _3(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 zpe(t={}){return[Tpe,Gr,jn.of(t),Epe,Vpe,Rpe]}const G7=[{key:"Ctrl-Space",run:G_},{mac:"Alt-`",run:G_},{mac:"Alt-i",run:G_},{key:"Escape",run:Spe},{key:"ArrowDown",run:Fy(!0)},{key:"ArrowUp",run:Fy(!1)},{key:"PageDown",run:Fy(!0,"page")},{key:"PageUp",run:Fy(!1,"page")},{key:"Enter",run:wpe}],Vpe=$c.highest(cT.computeN([jn],t=>t.facet(jn).defaultKeymap?[G7]:[]));class C3{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=tme(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 Jpe(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 C3(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new C3(r.from,s,r.diagnostic)}}),r}function Upe(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(K7))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function Hpe(t,e){return t.field(Ci,!1)?e:e.concat(Qe.appendConfig.of(nme))}const K7=Qe.define(),RT=Qe.define(),Y7=Qe.define(),Ci=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(K7)){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(RT)?t=new ac(t.diagnostics,n.value?bm.open:null,t.selected):n.is(Y7)&&(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)]}),Wpe=He.mark({class:"cm-lintRange cm-lintRange-active"});function qpe(t,e,n){let{diagnostics:r}=t.state.field(Ci),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:Gpe(t,i)}}}:null}function Gpe(t,e){return kt("ul",{class:"cm-tooltip-lint"},e.map(n=>J7(t,n,!1)))}const Kpe=t=>{let e=t.state.field(Ci,!1);(!e||!e.panel)&&t.dispatch({effects:Hpe(t.state,[RT.of(!0)])});let n=um(t,bm.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},A3=t=>{let e=t.state.field(Ci,!1);return!e||!e.panel?!1:(t.dispatch({effects:RT.of(!1)}),!0)},Ype=t=>{let e=t.state.field(Ci,!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)},Xpe=[{key:"Mod-Shift-m",run:Kpe,preventDefault:!0},{key:"F8",run:Ype}],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 X7(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 J7(t,e,n){var r;let i=n?X7(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(Ci).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 Jpe 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 E3{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=J7(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)A3(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=X7(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(Ci).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:()=>A3(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Ci).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(Ci),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 E3(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 E3(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(Ci),r=Bh(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:Y7.of(r)})}static open(e){return new bm(e)}}function Qpe(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 zy(t){return Qpe(`<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 Zpe=_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:zy("#d11")},".cm-lintRange-warning":{backgroundImage:zy("orange")},".cm-lintRange-info":{backgroundImage:zy("#999")},".cm-lintRange-hint":{backgroundImage:zy("#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 eme(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function tme(t){let e="hint",n=1;for(let r of t){let i=eme(r.severity);i>n&&(n=i,e=r.severity)}return e}const nme=[Ci,_e.decorations.compute([Ci],t=>{let{selected:e,panel:n}=t.field(Ci);return!e||!n||e.from==e.to?He.none:He.set([Wpe.range(e.from,e.to)])}),Kue(qpe,{hideOn:Upe}),Zpe],rme=[she(),lhe(),Aue(),Efe(),Qhe(),pue(),vue(),ht.allowMultipleSelections.of(!0),jhe(),efe(rfe,{fallback:!0}),ufe(),Mpe(),zpe(),$ue(),Fue(),Oue(),Ide(),cT.of([...Ipe,...Tde,...Zde,...Lfe,...Khe,...G7,...Xpe])];var k3={};class Vv{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 Vv(e,[],n,r,r,0,[],0,i?new T3(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 Vv(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 ime(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 T3(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 T3{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class ime{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 Uv{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 Uv(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 Uv(this.stack,this.pos,this.index)}}function Vy(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 $b{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const R3=new $b;class sme{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=R3,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=R3,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;ome(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 ome(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||ame(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 M3(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function ame(t,e,n,r){let i=M3(n,r,e);return i<0||M3(n,r,t)<i}const di=typeof process<"u"&&k3&&/\bparse\b/.test(k3.LOG);let Y_=null;function O3(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 lme{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?O3(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?O3(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 cme{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new $b)}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 $b,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 $b,{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 ume{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 sme(n,i),this.tokens=new cme(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[Vv.start(this,e.top[0],s)],this.fragments=r.length&&this.stream.end-s>e.bufferLength*4?new lme(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&&fme(i);if(o)return di&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw di&&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 di&&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=di?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),di&&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),di&&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),di&&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 P3(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=di?this.stackID(a)+" -> ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),di&&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&&(di&&console.log(m+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,r));y++)di&&(m=this.stackID(d)+" -> ");for(let y of a.recoverByInsert(c))di&&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),di&&console.log(f+this.stackID(a)+` (via recover-delete ${this.parser.getName(c)})`),P3(a,r)):(!i||i.score<a.score)&&(i=a)}return i}stackToTree(e){return e.close(),mn.build({buffer:Uv.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=(Y_||(Y_=new WeakMap)).get(e);return n||Y_.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function P3(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 hme{constructor(e,n,r){this.source=e,this.flags=n,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class Hv extends IV{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 fT(n.map((a,c)=>Qr.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=MV;let o=Vy(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(D3),this.states=Vy(e.states,Uint32Array),this.data=Vy(e.stateData),this.goto=Vy(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 ume(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(Hv.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]=D3(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 hme(e,r,i)}static deserialize(e){return new Hv(e)}}function Ho(t,e){return t[e]|t[e+1]<<16}function fme(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 D3(t){if(t.external){let e=t.extend?1:0;return(n,r)=>t.external(n,r)<<1|e}return t.get}const dme=LV({String:xe.string,Number:xe.number,"True False":xe.bool,PropertyName:xe.propertyName,Null:xe.null,", :":xe.separator,"[ ]":xe.squareBracket,"{ }":xe.brace}),pme=Hv.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:[dme],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}),mme=Rv.define({name:"json",parser:pme.configure({props:[BV.add({Object:QN({except:/^\s*\}/}),Array:QN({except:/^\s*\]/})}),zV.add({"Object Array":Fhe})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function gme(){return new The(mme)}const yme=({open:t,onClose:e})=>{const{t:n}=wt(),{saveConfig:r,getConfig:i}=Ts(),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:[rme,gme(),_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(tn,{onClick:e,variant:"default",children:n("Cancel")}),C.jsx(tn,{disabled:!h,onClick:()=>{r(JSON.parse(a)),e()},children:n("Save")})]})]})})},MT=({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"}),bme="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",vme="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",xme=({type:t,open:e,onClose:n})=>{const{t:r}=wt(),[i,s]=be.useState([]),{getCustomServersLogs:o}=Ts();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(tn,{onClick:a,variant:"default",children:r("CopyToClipboard")}),C.jsx(tn,{onClick:n,children:r("Close")})]})]})})},wme=({name:t,onClose:e})=>{const{t:n}=wt(),{deleteCustomServer:r}=Ts(),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(tn,{variant:"default",onClick:e,children:n("No")}),C.jsx(tn,{onClick:i,children:n("Yes")})]})]})})})},I3=({name:t,mcpItems:e,isLoading:n,isSystem:r,disableEnable:i})=>{const{t:s}=wt(),[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:_}=Ts(),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(Zt.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(xt,{iconName:Hk,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(xt,{iconName:H9,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(MT,{}):C.jsx(Nc,{onOpenChange:h,trigger:C.jsx(xt,{iconName:Lk,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(xt,{iconName:bme,size:20,disableHover:!0,isStroke:!0}),text:s("Restart"),onClick:()=>{Zt.restartCustomServer(t)}},{icon:C.jsx(xt,{iconName:vme,size:20,disableHover:!0,isStroke:!0}),text:s("Logs"),onClick:P},{text:"",onClick:()=>{},isSeparator:!0},{icon:C.jsx(xt,{iconName:Nk,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(jF,{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(xme,{type:t,open:f,onClose:()=>d(!1)}):null,b?C.jsx(wme,{name:t,onClose:()=>x(!1)}):null]})},Sme=()=>{const{t}=wt(),[e,n]=be.useState({}),{servers:r,tools:i,webSearchEnabled:s}=Ts(),[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(Zt.getCustomServers());const h=setInterval(()=>{n(Zt.getCustomServers())},1e3);return()=>clearInterval(h)},[]);const c=s?i.length>=Ab: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(I3,{name:"desktop-editor",mcpItems:r["desktop-editor"]??[],isLoading:!1,isSystem:!0,disableEnable:c}),Object.keys(e).map(h=>C.jsx(I3,{name:h,mcpItems:r[h]??[],isLoading:!r[h]?.length,isSystem:!1,disableEnable:c},h))]})]})},_me=()=>{const{t}=wt(),[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(tn,{className:"w-fit",onClick:()=>n(!0),children:t("EditConfiguration")}),C.jsx(Sme,{})]}),C.jsx(yme,{open:e,onClose:()=>n(!1)})]})},Cme=()=>{const{t}=wt(),[e,n]=be.useState(""),[r,i]=be.useState(""),[s,o]=be.useState(!1);be.useEffect(()=>{const h=Zt.getWebSearchData();h&&(n(h.provider),i(h.key),o(!0))},[]);const a=()=>{!e||!r||(Zt.setWebSearchData({provider:e,key:r}),o(!0))},c=()=>{n(""),i(""),o(!1),Zt.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(ro,{header:t("WebSearchEngine"),children:C.jsx(Qx,{className:"w-[260px]",value:e||t("SelectEngine"),items:s?[]:[{text:"Exa",id:"Exa",onClick:()=>n("Exa")}]})}),C.jsx(ro,{header:t("APIKey"),children:C.jsx(lo,{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(tn,{className:"w-fit",onClick:a,disabled:!e||!r||s,children:t("Save")}),C.jsx(tn,{className:"w-fit",disabled:!s,onClick:c,variant:"default",children:t("ResetSettings")})]})]})})},Ame=()=>{const{t}=wt(),[e,n]=be.useState("providers"),{providers:r}=ns(),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(cle,{isActive:e===s}):C.jsx(lle,{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(pse,{items:[{value:"ai-settings",label:t("Connection"),content:i},{value:"mcp-servers",label:t("MCPServers"),content:C.jsx(_me,{}),disabled:!r.length},{value:"web-search",label:t("WebSearch"),content:C.jsx(Cme,{}),disabled:!r.length}]})]})})})},Q7=k.createContext({});function Eme(t){const e=k.useRef(null);return e.current===null&&(e.current=t()),e.current}const OT=typeof window<"u",kme=OT?k.useLayoutEffect:k.useEffect,PT=k.createContext(null);function DT(t,e){t.indexOf(e)===-1&&t.push(e)}function IT(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 LT=()=>{};const ea={},Z7=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function eU(t){return typeof t=="object"&&t!==null}const tU=t=>/^0[^.\s]+$/u.test(t);function NT(t){let e;return()=>(e===void 0&&(e=t()),e)}const Zi=t=>t,Tme=(t,e)=>n=>e(t(n)),Qm=(...t)=>t.reduce(Tme),vm=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r};class $T{constructor(){this.subscriptions=[]}add(e){return DT(this.subscriptions,e),()=>IT(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 uo=t=>t*1e3,ho=t=>t/1e3;function nU(t,e){return e?t*(1e3/e):0}const rU=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Rme=1e-7,Mme=12;function Ome(t,e,n,r,i){let s,o,a=0;do o=e+(n-e)/2,s=rU(o,r,i)-t,s>0?n=o:e=o;while(Math.abs(s)>Rme&&++a<Mme);return o}function Zm(t,e,n,r){if(t===e&&n===r)return Zi;const i=s=>Ome(s,0,1,t,n);return s=>s===0||s===1?s:rU(i(s),e,r)}const iU=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,sU=t=>e=>1-t(1-e),oU=Zm(.33,1.53,.69,.99),jT=sU(oU),aU=iU(jT),lU=t=>(t*=2)<1?.5*jT(t):.5*(2-Math.pow(2,-10*(t-1))),BT=t=>1-Math.sin(Math.acos(t)),cU=sU(BT),uU=iU(BT),Pme=Zm(.42,0,1,1),Dme=Zm(0,0,.58,1),hU=Zm(.42,0,.58,1),Ime=t=>Array.isArray(t)&&typeof t[0]!="number",fU=t=>Array.isArray(t)&&typeof t[0]=="number",Lme={linear:Zi,easeIn:Pme,easeInOut:hU,easeOut:Dme,circIn:BT,circInOut:uU,circOut:cU,backIn:jT,backInOut:aU,backOut:oU,anticipate:lU},Nme=t=>typeof t=="string",L3=t=>{if(fU(t)){LT(t.length===4);const[e,n,r,i]=t;return Zm(e,n,r,i)}else if(Nme(t))return Lme[t];return t},Uy=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function $me(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 jme=40;function dU(t,e){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,o=Uy.reduce((E,P)=>(E[P]=$me(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,jme),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:Uy.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<Uy.length;P++)o[Uy[P]].cancel(E)},state:i,steps:o}}const{schedule:Ut,cancel:vl,state:Hn,steps:X_}=dU(typeof requestAnimationFrame<"u"?requestAnimationFrame:Zi,!0);let jb;function Bme(){jb=void 0}const Xr={now:()=>(jb===void 0&&Xr.set(Hn.isProcessing||ea.useManualTiming?Hn.timestamp:performance.now()),jb),set:t=>{jb=t,queueMicrotask(Bme)}},pU=t=>e=>typeof e=="string"&&e.startsWith(t),FT=pU("--"),Fme=pU("var(--"),zT=t=>Fme(t)?zme.test(t.split("/*")[0].trim()):!1,zme=/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)},Hy={...tf,default:1},Op=t=>Math.round(t*1e5)/1e5,VT=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Vme(t){return t==null}const Ume=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,UT=(t,e)=>n=>!!(typeof n=="string"&&Ume.test(n)&&n.startsWith(t)||e&&!Vme(n)&&Object.prototype.hasOwnProperty.call(n,e)),mU=(t,e,n)=>r=>{if(typeof r!="string")return r;const[i,s,o,a]=r.match(VT);return{[t]:parseFloat(i),[e]:parseFloat(s),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Hme=t=>Zo(0,255,t),J_={...tf,transform:t=>Math.round(Hme(t))},dc={test:UT("rgb","red"),parse:mU("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+J_.transform(t)+", "+J_.transform(e)+", "+J_.transform(n)+", "+Op(xm.transform(r))+")"};function Wme(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 IA={test:UT("#"),parse:Wme,transform:dc.transform},eg=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Ya=eg("deg"),fo=eg("%"),qe=eg("px"),qme=eg("vh"),Gme=eg("vw"),N3={...fo,parse:t=>fo.parse(t)/100,transform:t=>fo.transform(t*100)},oh={test:UT("hsl","hue"),parse:mU("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+fo.transform(Op(e))+", "+fo.transform(Op(n))+", "+Op(xm.transform(r))+")"},dn={test:t=>dc.test(t)||IA.test(t)||oh.test(t),parse:t=>dc.test(t)?dc.parse(t):oh.test(t)?oh.parse(t):IA.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?dc.transform(t):oh.transform(t),getAnimatableNone:t=>{const e=dn.parse(t);return e.alpha=0,dn.transform(e)}},Kme=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Yme(t){return isNaN(t)&&typeof t=="string"&&(t.match(VT)?.length||0)+(t.match(Kme)?.length||0)>0}const gU="number",yU="color",Xme="var",Jme="var(",$3="${}",Qme=/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(Qme,c=>(dn.test(c)?(r.color.push(s),i.push(yU),n.push(dn.parse(c))):c.startsWith(Jme)?(r.var.push(s),i.push(Xme),n.push(c)):(r.number.push(s),i.push(gU),n.push(parseFloat(c))),++s,$3)).split($3);return{values:n,split:a,indexes:r,types:i}}function bU(t){return wm(t).values}function vU(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===gU?s+=Op(i[o]):a===yU?s+=dn.transform(i[o]):s+=i[o]}return s}}const Zme=t=>typeof t=="number"?0:dn.test(t)?dn.getAnimatableNone(t):t;function ege(t){const e=bU(t);return vU(t)(e.map(Zme))}const xl={test:Yme,parse:bU,createTransformer:vU,getAnimatableNone:ege};function Q_(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 tge({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=Q_(c,a,t+1/3),s=Q_(c,a,t),o=Q_(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(o*255),alpha:r}}function Wv(t,e){return n=>n>0?e:t}const Kt=(t,e,n)=>t+(e-t)*n,Z_=(t,e,n)=>{const r=t*t,i=n*(e*e-r)+r;return i<0?0:Math.sqrt(i)},nge=[IA,dc,oh],rge=t=>nge.find(e=>e.test(t));function j3(t){const e=rge(t);if(!e)return!1;let n=e.parse(t);return e===oh&&(n=tge(n)),n}const B3=(t,e)=>{const n=j3(t),r=j3(e);if(!n||!r)return Wv(t,e);const i={...n};return s=>(i.red=Z_(n.red,r.red,s),i.green=Z_(n.green,r.green,s),i.blue=Z_(n.blue,r.blue,s),i.alpha=Kt(n.alpha,r.alpha,s),dc.transform(i))},LA=new Set(["none","hidden"]);function ige(t,e){return LA.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function sge(t,e){return n=>Kt(t,e,n)}function HT(t){return typeof t=="number"?sge:typeof t=="string"?zT(t)?Wv:dn.test(t)?B3:lge:Array.isArray(t)?xU:typeof t=="object"?dn.test(t)?B3:oge:Wv}function xU(t,e){const n=[...t],r=n.length,i=t.map((s,o)=>HT(s)(s,e[o]));return s=>{for(let o=0;o<r;o++)n[o]=i[o](s);return n}}function oge(t,e){const n={...t,...e},r={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(r[i]=HT(t[i])(t[i],e[i]));return i=>{for(const s in r)n[s]=r[s](i);return n}}function age(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 lge=(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?LA.has(t)&&!i.values.length||LA.has(e)&&!r.values.length?ige(t,e):Qm(xU(age(r,i),i.values),n):Wv(t,e)};function wU(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?Kt(t,e,n):HT(t)(t,e)}const cge=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()}},SU=(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)})`},qv=2e4;function WT(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<qv;)e+=n,r=t.next(e);return e>=qv?1/0:e}function uge(t,e=100,n){const r=n({...t,keyframes:[0,e]}),i=Math.min(WT(r),qv);return{type:"keyframes",ease:s=>r.next(i*s).value/e,duration:ho(i)}}const hge=5;function _U(t,e,n){const r=Math.max(e-hge,0);return nU(n-t(r),e-r)}const en={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},e2=.001;function fge({duration:t=en.duration,bounce:e=en.bounce,velocity:n=en.velocity,mass:r=en.mass}){let i,s,o=1-e;o=Zo(en.minDamping,en.maxDamping,o),t=Zo(en.minDuration,en.maxDuration,ho(t)),o<1?(i=h=>{const f=h*o,d=f*t,m=f-n,y=NA(h,o),b=Math.exp(-d);return e2-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=NA(Math.pow(h,2),o);return(-i(h)+e2>0?-1:1)*((m-y)*b)/x}):(i=h=>{const f=Math.exp(-h*t),d=(h-n)*t+1;return-e2+f*d},s=h=>{const f=Math.exp(-h*t),d=(n-h)*(t*t);return f*d});const a=5/t,c=pge(i,s,a);if(t=uo(t),isNaN(c))return{stiffness:en.stiffness,damping:en.damping,duration:t};{const h=Math.pow(c,2)*r;return{stiffness:h,damping:o*2*Math.sqrt(r*h),duration:t}}}const dge=12;function pge(t,e,n){let r=n;for(let i=1;i<dge;i++)r=r-t(r)/e(r);return r}function NA(t,e){return t*Math.sqrt(1-e*e)}const mge=["duration","bounce"],gge=["stiffness","damping","mass"];function F3(t,e){return e.some(n=>t[n]!==void 0)}function yge(t){let e={velocity:en.velocity,stiffness:en.stiffness,damping:en.damping,mass:en.mass,isResolvedFromDuration:!1,...t};if(!F3(t,gge)&&F3(t,mge))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:en.mass,stiffness:i,damping:s}}else{const n=fge(t);e={...e,...n,mass:en.mass},e.isResolvedFromDuration=!0}return e}function Gv(t=en.visualDuration,e=en.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}=yge({...n,velocity:-ho(n.velocity||0)}),b=m||0,x=h/(2*Math.sqrt(c*f)),S=o-s,_=ho(Math.sqrt(c/f)),A=Math.abs(S)<5;r||(r=A?en.restSpeed.granular:en.restSpeed.default),i||(i=A?en.restDelta.granular:en.restDelta.default);let E;if(x<1){const O=NA(_,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?uo(b):_U(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(WT(P),qv),M=SU(D=>P.next(O*D).value,O,30);return O+"ms "+M},toTransition:()=>{}};return P}Gv.applyToOptions=t=>{const e=uge(t,100,Gv);return t.ease=e.ease,t.duration=uo(e.duration),t.type="keyframes",t};function $A({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=Gv({keyframes:[m.value,b(m.value)],velocity:_U(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 bge(t,e,n){const r=[],i=n||ea.mix||wU,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]||Zi:e;a=Qm(c,a)}r.push(a)}return r}function vge(t,e,{clamp:n=!0,ease:r,mixer:i}={}){const s=t.length;if(LT(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=bge(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 xge(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const i=vm(0,e,r);t.push(Kt(n,1,i))}}function wge(t){const e=[0];return xge(e,t.length-1),e}function Sge(t,e){return t.map(n=>n*e)}function _ge(t,e){return t.map(()=>e||hU).splice(0,t.length-1)}function Pp({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const i=Ime(r)?r.map(L3):L3(r),s={done:!1,value:e[0]},o=Sge(n&&n.length===e.length?n:wge(e),t),a=vge(o,e,{ease:Array.isArray(i)?i:_ge(e,i)});return{calculatedDuration:t,next:c=>(s.value=a(c),s.done=c>=t,s)}}const Cge=t=>t!==null;function qT(t,{repeat:e,repeatType:n="loop"},r,i=1){const s=t.filter(Cge),a=i<0||e&&n!=="loop"&&e%2===1?0:s.length-1;return!a||r===void 0?s[a]:r}const Age={decay:$A,inertia:$A,tween:Pp,keyframes:Pp,spring:Gv};function CU(t){typeof t.type=="string"&&(t.type=Age[t.type])}class GT{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 Ege=t=>t/100;class KT extends GT{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;CU(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=Qm(Ege,wU(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=WT(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!==$A&&(O.value=qT(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 ho(this.calculatedDuration)}get time(){return ho(this.currentTime)}set time(e){e=uo(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=ho(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=cge,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 kge(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const pc=t=>t*180/Math.PI,jA=t=>{const e=pc(Math.atan2(t[1],t[0]));return BA(e)},Tge={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:jA,rotateZ:jA,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},BA=t=>(t=t%360,t<0&&(t+=360),t),z3=jA,V3=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),U3=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Rge={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:V3,scaleY:U3,scale:t=>(V3(t)+U3(t))/2,rotateX:t=>BA(pc(Math.atan2(t[6],t[5]))),rotateY:t=>BA(pc(Math.atan2(-t[2],t[0]))),rotateZ:z3,rotate:z3,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 FA(t){return t.includes("scale")?1:0}function zA(t,e){if(!t||t==="none")return FA(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=Rge,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Tge,i=a}if(!i)return FA(e);const s=r[e],o=i[1].split(",").map(Oge);return typeof s=="function"?s(o):o[s]}const Mge=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return zA(n,e)};function Oge(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),H3=t=>t===tf||t===qe,Pge=new Set(["x","y","z"]),Dge=nf.filter(t=>!Pge.has(t));function Ige(t){const e=[];return Dge.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})=>zA(e,"x"),y:(t,{transform:e})=>zA(e,"y")};vc.translateX=vc.x;vc.translateY=vc.y;const xc=new Set;let VA=!1,UA=!1,HA=!1;function AU(){if(UA){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=Ige(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)})}UA=!1,VA=!1,xc.forEach(t=>t.complete(HA)),xc.clear()}function EU(){xc.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(UA=!0)})}function Lge(){HA=!0,EU(),AU(),HA=!1}class YT{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),VA||(VA=!0,Ut.read(EU),Ut.resolveKeyframes(AU))):(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])}kge(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 Nge=t=>t.startsWith("--");function $ge(t,e,n){Nge(e)?t.style.setProperty(e,n):t.style[e]=n}const jge=NT(()=>window.ScrollTimeline!==void 0),Bge={};function Fge(t,e){const n=NT(t);return()=>Bge[e]??n()}const kU=Fge(()=>{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})`,W3={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 TU(t,e){if(t)return typeof t=="function"?kU()?SU(t,e):"ease-out":fU(t)?pp(t):Array.isArray(t)?t.map(n=>TU(n,e)||W3.easeOut):W3[t]}function zge(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=TU(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 RU(t){return typeof t=="function"&&"applyToOptions"in t}function Vge({type:t,...e}){return RU(t)&&kU()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Uge extends GT{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,LT(typeof e.type!="string");const h=Vge(e);this.animation=zge(n,r,i,h,s),h.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!s){const f=qT(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(f):$ge(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 ho(Number(e))}get time(){return ho(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=uo(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&&jge()?(this.animation.timeline=e,Zi):n(this)}}const MU={anticipate:lU,backInOut:aU,circInOut:uU};function Hge(t){return t in MU}function Wge(t){typeof t.ease=="string"&&Hge(t.ease)&&(t.ease=MU[t.ease])}const q3=10;class qge extends Uge{constructor(e){Wge(e),CU(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 KT({...o,autoplay:!1}),c=uo(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-q3).value,a.sample(c).value,q3),a.stop()}}const G3=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(xl.test(t)||t==="0")&&!t.startsWith("url("));function Gge(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 Kge(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=G3(i,e),a=G3(s,e);return!o||!a?!1:Gge(t)||(n==="spring"||RU(n))&&r}function WA(t){t.duration=0,t.type}const Yge=new Set(["opacity","clipPath","filter","transform"]),Xge=NT(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Jge(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 Xge()&&n&&Yge.has(n)&&(n!=="transform"||!h)&&!c&&!r&&i!=="mirror"&&s!==0&&o!=="inertia"}const Qge=40;class Zge extends GT{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||YT;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(),Kge(e,s,o,a)||((ea.instantAnimations||!c)&&f?.(qT(e,r,n)),e[0]=e[e.length-1],WA(r),r.repeat=0);const m={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>Qge?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:e},y=!h&&Jge(m)?new qge({...m,element:m.motionValue.owner.current}):new KT(m);y.finished.then(()=>this.notifyFinished()).catch(Zi),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(),Lge()),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 e0e=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function t0e(t){const e=e0e.exec(t);if(!e)return[,];const[,n,r,i]=e;return[`--${n??r}`,i]}function OU(t,e,n=1){const[r,i]=t0e(t);if(!r)return;const s=window.getComputedStyle(e).getPropertyValue(r);if(s){const o=s.trim();return Z7(o)?parseFloat(o):o}return zT(i)?OU(i,e,n+1):i}function XT(t,e){return t?.[e]??t?.default??t}const PU=new Set(["width","height","top","left","right","bottom",...nf]),n0e={test:t=>t==="auto",parse:t=>t},DU=t=>e=>e.test(t),IU=[tf,qe,fo,Ya,Gme,qme,n0e],K3=t=>IU.find(DU(t));function r0e(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||tU(t):!0}const i0e=new Set(["brightness","contrast","saturate","opacity"]);function s0e(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=n.match(VT)||[];if(!r)return t;const i=n.replace(r,"");let s=i0e.has(e)?1:0;return r!==n&&(s*=100),e+"("+s+i+")"}const o0e=/\b([a-z-]*)\(.*?\)/gu,qA={...xl,getAnimatableNone:t=>{const e=t.match(o0e);return e?e.map(s0e).join(" "):t}},Y3={...tf,transform:Math.round},a0e={rotate:Ya,rotateX:Ya,rotateY:Ya,rotateZ:Ya,scale:Hy,scaleX:Hy,scaleY:Hy,scaleZ:Hy,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:N3,originY:N3,originZ:qe},JT={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,...a0e,zIndex:Y3,fillOpacity:xm,strokeOpacity:xm,numOctaves:Y3},l0e={...JT,color:dn,backgroundColor:dn,outlineColor:dn,fill:dn,stroke:dn,borderColor:dn,borderTopColor:dn,borderRightColor:dn,borderBottomColor:dn,borderLeftColor:dn,filter:qA,WebkitFilter:qA},LU=t=>l0e[t];function NU(t,e){let n=LU(t);return n!==qA&&(n=xl),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const c0e=new Set(["auto","none","0"]);function u0e(t,e,n){let r=0,i;for(;r<t.length&&!i;){const s=t[r];typeof s=="string"&&!c0e.has(s)&&wm(s).values.length&&(i=t[r]),r++}if(i&&n)for(const s of e)t[s]=NU(n,i)}class h0e extends YT{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(),zT(h))){const f=OU(h,n.current);f!==void 0&&(e[c]=f),c===e.length-1&&(this.finalKeyframe=h)}}if(this.resolveNoneKeyframes(),!PU.has(r)||e.length!==2)return;const[i,s]=e,o=K3(i),a=K3(s);if(o!==a)if(H3(o)&&H3(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||r0e(e[i]))&&r.push(i);r.length&&u0e(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 f0e(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 $U=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function d0e(t){return eU(t)&&"offsetHeight"in t}const X3=30,p0e=t=>!isNaN(parseFloat(t));class m0e{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=p0e(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 $T);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>X3)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,X3);return nU(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 m0e(t,e)}const{schedule:QT}=dU(queueMicrotask,!1),ds={x:!1,y:!1};function jU(){return ds.x||ds.y}function g0e(t){return t==="x"||t==="y"?ds[t]?null:(ds[t]=!0,()=>{ds[t]=!1}):ds.x||ds.y?null:(ds.x=ds.y=!0,()=>{ds.x=ds.y=!1})}function BU(t,e){const n=f0e(t),r=new AbortController,i={passive:!0,...e,signal:r.signal};return[n,i,()=>r.abort()]}function J3(t){return!(t.pointerType==="touch"||jU())}function y0e(t,e,n={}){const[r,i,s]=BU(t,n),o=a=>{if(!J3(a))return;const{target:c}=a,h=e(c,a);if(typeof h!="function"||!c)return;const f=d=>{J3(d)&&(h(d),c.removeEventListener("pointerleave",f))};c.addEventListener("pointerleave",f,i)};return r.forEach(a=>{a.addEventListener("pointerenter",o,i)}),s}const FU=(t,e)=>e?t===e?!0:FU(t,e.parentElement):!1,ZT=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,b0e=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function v0e(t){return b0e.has(t.tagName)||t.tabIndex!==-1}const Bb=new WeakSet;function Q3(t){return e=>{e.key==="Enter"&&t(e)}}function t2(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const x0e=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=Q3(()=>{if(Bb.has(n))return;t2(n,"down");const i=Q3(()=>{t2(n,"up")}),s=()=>t2(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 Z3(t){return ZT(t)&&!jU()}function w0e(t,e,n={}){const[r,i,s]=BU(t,n),o=a=>{const c=a.currentTarget;if(!Z3(a))return;Bb.add(c);const h=e(c,a),f=(y,b)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",m),Bb.has(c)&&Bb.delete(c),Z3(y)&&typeof h=="function"&&h(y,{success:b})},d=y=>{f(y,c===window||c===document||n.useGlobalTarget||FU(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),d0e(a)&&(a.addEventListener("focus",h=>x0e(h,i)),!v0e(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),s}function zU(t){return eU(t)&&"ownerSVGElement"in t}function S0e(t){return zU(t)&&t.tagName==="svg"}const mr=t=>!!(t&&t.getVelocity),_0e=[...IU,dn,xl],C0e=t=>_0e.find(DU(t)),VU=k.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function A0e(t=!0){const e=k.useContext(PT);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 UU=k.createContext({strict:!1}),e4={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 e4)zh[t]={isEnabled:e=>e4[t].some(n=>!!e[n])};function E0e(t){for(const e in t)zh[e]={...zh[e],...t[e]}}const k0e=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 Kv(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||k0e.has(t)}let HU=t=>!Kv(t);function T0e(t){typeof t=="function"&&(HU=e=>e.startsWith("on")?!Kv(e):t(e))}try{T0e(require("@emotion/is-prop-valid").default)}catch{}function R0e(t,e,n){const r={};for(const i in t)i==="values"&&typeof t.values=="object"||(HU(i)||n===!0&&Kv(i)||!e&&!Kv(i)||t.draggable&&i.startsWith("onDrag"))&&(r[i]=t[i]);return r}const dw=k.createContext({});function pw(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Sm(t){return typeof t=="string"||Array.isArray(t)}const eR=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],tR=["initial",...eR];function mw(t){return pw(t.animate)||tR.some(e=>Sm(t[e]))}function WU(t){return!!(mw(t)||t.variants)}function M0e(t,e){if(mw(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 O0e(t){const{initial:e,animate:n}=M0e(t,k.useContext(dw));return k.useMemo(()=>({initial:e,animate:n}),[t4(e),t4(n)])}function t4(t){return Array.isArray(t)?t.join(" "):t}const _m={};function P0e(t){for(const e in t)_m[e]=t[e],FT(e)&&(_m[e].isCSSVariable=!0)}function qU(t,{layout:e,layoutId:n}){return rf.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!_m[t]||t==="opacity")}const D0e={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},I0e=nf.length;function L0e(t,e,n){let r="",i=!0;for(let s=0;s<I0e;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=$U(a,JT[o]);if(!c){i=!1;const f=D0e[o]||o;r+=`${f}(${h}) `}n&&(e[o]=h)}}return r=r.trim(),n?r=n(e,i?"":r):i&&(r="none"),r}function nR(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(FT(c)){i[c]=h;continue}else{const f=$U(h,JT[c]);c.startsWith("origin")?(a=!0,s[c]=f):r[c]=f}}if(e.transform||(o||n?r.transform=L0e(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 rR=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function GU(t,e,n){for(const r in e)!mr(e[r])&&!qU(r,n)&&(t[r]=e[r])}function N0e({transformTemplate:t},e){return k.useMemo(()=>{const n=rR();return nR(n,e,t),Object.assign({},n.vars,n.style)},[e])}function $0e(t,e){const n=t.style||{},r={};return GU(r,n,t),Object.assign(r,N0e(t,e)),r}function j0e(t,e){const n={},r=$0e(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 B0e={offset:"stroke-dashoffset",array:"stroke-dasharray"},F0e={offset:"strokeDashoffset",array:"strokeDasharray"};function z0e(t,e,n=1,r=0,i=!0){t.pathLength=1;const s=i?B0e:F0e;t[s.offset]=qe.transform(-r);const o=qe.transform(e),a=qe.transform(n);t[s.array]=`${o} ${a}`}function KU(t,{attrX:e,attrY:n,attrScale:r,pathLength:i,pathSpacing:s=1,pathOffset:o=0,...a},c,h,f){if(nR(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&&z0e(d,i,s,o,!1)}const YU=()=>({...rR(),attrs:{}}),XU=t=>typeof t=="string"&&t.toLowerCase()==="svg";function V0e(t,e,n,r){const i=k.useMemo(()=>{const s=YU();return KU(s,e,XU(r),t.transformTemplate,t.style),{...s.attrs,style:{...s.style}}},[e]);if(t.style){const s={};GU(s,t.style,t),i.style={...s,...i.style}}return i}const U0e=["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 iR(t){return typeof t!="string"||t.includes("-")?!1:!!(U0e.indexOf(t)>-1||/[A-Z]/u.test(t))}function H0e(t,e,n,{latestValues:r},i,s=!1){const a=(iR(t)?V0e:j0e)(e,r,i,t),c=R0e(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 n4(t){const e=[{},{}];return t?.values.forEach((n,r)=>{e[0][r]=n.get(),e[1][r]=n.getVelocity()}),e}function sR(t,e,n,r){if(typeof e=="function"){const[i,s]=n4(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]=n4(r);e=e(n!==void 0?n:t.custom,i,s)}return e}function Fb(t){return mr(t)?t.get():t}function W0e({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]=Fb(s[m]);let{initial:o,animate:a}=t;const c=mw(t),h=WU(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"&&!pw(d)){const m=Array.isArray(d)?d:[d];for(let y=0;y<m.length;y++){const b=sR(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 JU=t=>(e,n)=>{const r=k.useContext(dw),i=k.useContext(PT),s=()=>W0e(t,e,r,i);return n?s():Eme(s)};function oR(t,e,n){const{style:r}=t,i={};for(const s in r)(mr(r[s])||e.style&&mr(e.style[s])||qU(s,t)||n?.getValue(s)?.liveStyle!==void 0)&&(i[s]=r[s]);return i}const G0e=JU({scrapeMotionValuesFromProps:oR,createRenderState:rR});function QU(t,e,n){const r=oR(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 K0e=JU({scrapeMotionValuesFromProps:QU,createRenderState:YU}),Y0e=Symbol.for("motionComponentSymbol");function ah(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function X0e(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 aR=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),J0e="framerAppearId",ZU="data-"+aR(J0e),eH=k.createContext({});function Q0e(t,e,n,r,i){const{visualElement:s}=k.useContext(dw),o=k.useContext(UU),a=k.useContext(PT),c=k.useContext(VU).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(eH);f&&!f.projection&&i&&(f.type==="html"||f.type==="svg")&&Z0e(h.current,n,i,d);const m=k.useRef(!1);k.useInsertionEffect(()=>{f&&m.current&&f.update(n,a)});const y=n[ZU],b=k.useRef(!!y&&!window.MotionHandoffIsComplete?.(y)&&window.MotionHasOptimisedAnimation?.(y));return kme(()=>{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 Z0e(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:tH(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 tH(t){if(t)return t.options.allowProjection!==!1?t.projection:tH(t.parent)}function n2(t,{forwardMotionProps:e=!1}={},n,r){n&&E0e(n);const i=iR(t)?K0e:G0e;function s(a,c){let h;const f={...k.useContext(VU),...a,layoutId:eye(a)},{isStatic:d}=f,m=O0e(a),y=i(a,d);if(!d&&OT){tye();const b=nye(f);h=b.MeasureLayout,m.visualElement=Q0e(t,y,f,r,b.ProjectionNode)}return C.jsxs(dw.Provider,{value:m,children:[h&&m.visualElement?C.jsx(h,{visualElement:m.visualElement,...f}):null,H0e(t,a,X0e(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[Y0e]=t,o}function eye({layoutId:t}){const e=k.useContext(Q7).id;return e&&t!==void 0?e+"-"+t:t}function tye(t,e){k.useContext(UU).strict}function nye(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 rye(t,e){if(typeof Proxy>"u")return n2;const n=new Map,r=(s,o)=>n2(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,n2(o,void 0,t,e)),n.get(o))})}function nH({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function iye({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function sye(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 r2(t){return t===void 0||t===1}function GA({scale:t,scaleX:e,scaleY:n}){return!r2(t)||!r2(e)||!r2(n)}function nc(t){return GA(t)||rH(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function rH(t){return r4(t.x)||r4(t.y)}function r4(t){return t&&t!=="0%"}function Yv(t,e,n){const r=t-n,i=e*r;return n+i}function i4(t,e,n,r,i){return i!==void 0&&(t=Yv(t,i,r)),Yv(t,n,r)+e}function KA(t,e=0,n=1,r,i){t.min=i4(t.min,e,n,r,i),t.max=i4(t.max,e,n,r,i)}function iH(t,{x:e,y:n}){KA(t.x,e.translate,e.scale,e.originPoint),KA(t.y,n.translate,n.scale,n.originPoint)}const s4=.999999999999,o4=1.0000000000001;function oye(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,iH(t,o)),r&&nc(s.latestValues)&&ch(t,s.latestValues))}e.x<o4&&e.x>s4&&(e.x=1),e.y<o4&&e.y>s4&&(e.y=1)}function lh(t,e){t.min=t.min+e,t.max=t.max+e}function a4(t,e,n,r,i=.5){const s=Kt(t.min,t.max,i);KA(t,e,n,s,r)}function ch(t,e){a4(t.x,e.x,e.scaleX,e.scale,e.originX),a4(t.y,e.y,e.scaleY,e.scale,e.originY)}function sH(t,e){return nH(sye(t.getBoundingClientRect(),e))}function aye(t,e,n){const r=sH(t,n),{scroll:i}=e;return i&&(lh(r.x,i.offset.x),lh(r.y,i.offset.y)),r}const l4=()=>({translate:0,scale:1,origin:0,originPoint:0}),uh=()=>({x:l4(),y:l4()}),c4=()=>({min:0,max:0}),sn=()=>({x:c4(),y:c4()}),YA={current:null},oH={current:!1};function lye(){if(oH.current=!0,!!OT)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>YA.current=t.matches;t.addEventListener("change",e),e()}else YA.current=!1}const cye=new WeakMap;function uye(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 u4=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class hye{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=YT,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=mw(n),this.isVariantNode=WU(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,cye.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)),oH.current||lye(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:YA.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):sn()}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<u4.length;r++){const i=u4[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=uye(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"&&(Z7(r)||tU(r))?r=parseFloat(r):!C0e(r)&&xl.test(n)&&(r=NU(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=sR(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 $T),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){QT.render(this.render)}}class aH extends hye{constructor(){super(...arguments),this.KeyframeResolver=h0e}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 lH(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 fye(t){return window.getComputedStyle(t)}class dye extends aH{constructor(){super(...arguments),this.type="html",this.renderInstance=lH}readValueFromInstance(e,n){if(rf.has(n))return this.projection?.isProjecting?FA(n):Mge(e,n);{const r=fye(e),i=(FT(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return sH(e,n)}build(e,n,r){nR(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return oR(e,n,r)}}const cH=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 pye(t,e,n,r){lH(t,e,void 0,r);for(const i in e.attrs)t.setAttribute(cH.has(i)?i:aR(i),e.attrs[i])}class mye extends aH{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=sn}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(rf.has(n)){const r=LU(n);return r&&r.default||0}return n=cH.has(n)?n:aR(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return QU(e,n,r)}build(e,n,r){KU(e,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,n,r,i){pye(e,n,r,i)}mount(e){this.isSVGTag=XU(e.tagName),super.mount(e)}}const gye=(t,e)=>iR(t)?new mye(e):new dye(e,{allowProjection:t!==k.Fragment});function Ah(t,e,n){const r=t.getProps();return sR(r,e,n!==void 0?n:r.custom,t)}const XA=t=>Array.isArray(t);function yye(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Fh(n))}function bye(t){return XA(t)?t[t.length-1]||0:t}function vye(t,e){const n=Ah(t,e);let{transitionEnd:r={},transition:i={},...s}=n||{};s={...s,...r};for(const o in s){const a=bye(s[o]);yye(t,o,a)}}function xye(t){return!!(mr(t)&&t.add)}function JA(t,e){const n=t.getValue("willChange");if(xye(n))return n.add(e);if(!n&&ea.WillChange){const r=new ea.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function uH(t){return t.props[ZU]}const wye=t=>t!==null;function Sye(t,{repeat:e,repeatType:n="loop"},r){const i=t.filter(wye),s=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[s]}const _ye={type:"spring",stiffness:500,damping:25,restSpeed:10},Cye=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Aye={type:"keyframes",duration:.8},Eye={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},kye=(t,{keyframes:e})=>e.length>2?Aye:rf.has(t)?t.startsWith("scale")?Cye(e[1]):_ye:Eye;function Tye({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 lR=(t,e,n,r={},i,s)=>o=>{const a=XT(r,t)||{},c=a.delay||r.delay||0;let{elapsed:h=0}=r;h=h-uo(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};Tye(a)||Object.assign(f,kye(t,f)),f.duration&&(f.duration=uo(f.duration)),f.repeatDelay&&(f.repeatDelay=uo(f.repeatDelay)),f.from!==void 0&&(f.keyframes[0]=f.from);let d=!1;if((f.type===!1||f.duration===0&&!f.repeatDelay)&&(WA(f),f.delay===0&&(d=!0)),(ea.instantAnimations||ea.skipAnimations)&&(d=!0,WA(f),f.delay=0),f.allowFlatten=!a.type&&!a.ease,d&&!s&&e.get()!==void 0){const m=Sye(f.keyframes,a);if(m!==void 0){Ut.update(()=>{f.onUpdate(m),f.onComplete()});return}}return a.isSync?new KT(f):new Zge(f)};function Rye({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function hH(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&&Rye(h,f))continue;const y={delay:n,...XT(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 _=uH(t);if(_){const A=window.MotionHandoffAnimation(_,f,Ut);A!==null&&(y.startTime=A,x=!0)}}JA(t,f),d.start(lR(f,d,m,t.shouldReduceMotion&&PU.has(f)?{type:!1}:y,t,x));const S=d.animation;S&&c.push(S)}return o&&Promise.all(c).then(()=>{Ut.update(()=>{o&&vye(t,o)})}),c}function fH(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 QA(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(hH(t,r,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:h=0,staggerChildren:f,staggerDirection:d}=i;return Mye(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 Mye(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(QA(c,e,{...o,delay:n+(typeof r=="function"?0:r)+fH(t.variantChildren,c,r,i,s)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function Oye(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const i=e.map(s=>QA(t,s,n));r=Promise.all(i)}else if(typeof e=="string")r=QA(t,e,n);else{const i=typeof e=="function"?Ah(t,e,n.custom):e;r=Promise.all(hH(t,i,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}function dH(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 Pye=tR.length;function pH(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?pH(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<Pye;n++){const r=tR[n],i=t.props[r];(Sm(i)||i===!1)&&(e[r]=i)}return e}const Dye=[...eR].reverse(),Iye=eR.length;function Lye(t){return e=>Promise.all(e.map(({animation:n,options:r})=>Oye(t,n,r)))}function Nye(t){let e=Lye(t),n=h4(),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=pH(t.parent)||{},d=[],m=new Set;let y={},b=1/0;for(let S=0;S<Iye;S++){const _=Dye[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||pw(E)||typeof E=="boolean")continue;const D=$ye(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;XA(U)&&XA(se)?T=!dH(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=fH(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=h4(),r=!0}}}function $ye(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!dH(e,t):!1}function Jl(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function h4(){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 jye extends Al{constructor(e){super(e),e.animationState||(e.animationState=Nye(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();pw(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 Bye=0;class Fye extends Al{constructor(){super(...arguments),this.id=Bye++}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 zye={animation:{Feature:jye},exit:{Feature:Fye}};function Cm(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}function tg(t){return{point:{x:t.pageX,y:t.pageY}}}const Vye=t=>e=>ZT(e)&&t(e,tg(e));function Dp(t,e,n,r){return Cm(t,e,Vye(n),r)}const mH=1e-4,Uye=1-mH,Hye=1+mH,gH=.01,Wye=0-gH,qye=0+gH;function Pr(t){return t.max-t.min}function Gye(t,e,n){return Math.abs(t-e)<=n}function f4(t,e,n,r=.5){t.origin=r,t.originPoint=Kt(e.min,e.max,t.origin),t.scale=Pr(n)/Pr(e),t.translate=Kt(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Uye&&t.scale<=Hye||isNaN(t.scale))&&(t.scale=1),(t.translate>=Wye&&t.translate<=qye||isNaN(t.translate))&&(t.translate=0)}function Ip(t,e,n,r){f4(t.x,e.x,n.x,r?r.originX:void 0),f4(t.y,e.y,n.y,r?r.originY:void 0)}function d4(t,e,n){t.min=n.min+e.min,t.max=t.min+Pr(e)}function Kye(t,e,n){d4(t.x,e.x,n.x),d4(t.y,e.y,n.y)}function p4(t,e,n){t.min=e.min-n.min,t.max=t.min+Pr(e)}function Lp(t,e,n){p4(t.x,e.x,n.x),p4(t.y,e.y,n.y)}function Ui(t){return[t("x"),t("y")]}const yH=({current:t})=>t?t.ownerDocument.defaultView:null,m4=(t,e)=>Math.abs(t-e);function Yye(t,e){const n=m4(t.x,e.x),r=m4(t.y,e.y);return Math.sqrt(n**2+r**2)}class bH{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=s2(this.lastMoveEventInfo,this.history),y=this.startEvent!==null,b=Yye(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=i2(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 _=s2(m.type==="pointercancel"?this.lastMoveEventInfo:i2(y,this.transformPagePoint),this.history);this.startEvent&&b&&b(m,_),x&&x(m,_)},!ZT(e))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=o,this.contextWindow=i||window;const a=tg(e),c=i2(a,this.transformPagePoint),{point:h}=c,{timestamp:f}=Hn;this.history=[{...h,timestamp:f}];const{onSessionStart:d}=n;d&&d(e,s2(c,this.history)),this.removeListeners=Qm(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 i2(t,e){return e?{point:e(t.point)}:t}function g4(t,e){return{x:t.x-e.x,y:t.y-e.y}}function s2({point:t},e){return{point:t,delta:g4(t,vH(e)),offset:g4(t,Xye(e)),velocity:Jye(e,.1)}}function Xye(t){return t[0]}function vH(t){return t[t.length-1]}function Jye(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,r=null;const i=vH(t);for(;n>=0&&(r=t[n],!(i.timestamp-r.timestamp>uo(e)));)n--;if(!r)return{x:0,y:0};const s=ho(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 Qye(t,{min:e,max:n},r){return e!==void 0&&t<e?t=r?Kt(e,t,r.min):Math.max(t,e):n!==void 0&&t>n&&(t=r?Kt(n,t,r.max):Math.min(t,n)),t}function y4(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 Zye(t,{top:e,left:n,bottom:r,right:i}){return{x:y4(t.x,n,i),y:y4(t.y,e,r)}}function b4(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 ebe(t,e){return{x:b4(t.x,e.x),y:b4(t.y,e.y)}}function tbe(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 nbe(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 ZA=.35;function rbe(t=ZA){return t===!1?t=0:t===!0&&(t=ZA),{x:v4(t,"left","right"),y:v4(t,"top","bottom")}}function v4(t,e,n){return{min:x4(t,e),max:x4(t,n)}}function x4(t,e){return typeof t=="number"?t:t[e]||0}const ibe=new WeakMap;class sbe{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=sn(),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(tg(d).point)},o=(d,m)=>{const{drag:y,dragPropagation:b,onDragStart:x}=this.getProps();if(y&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=g0e(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),Ui(_=>{let A=this.getAxisMotionValue(_).get()||0;if(fo.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)),JA(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=obe(_),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=()=>Ui(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:f}=this.getProps();this.panSession=new bH(e,{onSessionStart:s,onStart:o,onMove:a,onSessionEnd:c,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:f,distanceThreshold:r,contextWindow:yH(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||!Wy(e,i,this.currentDirection))return;const s=this.getAxisMotionValue(e);let o=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(o=Qye(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=Zye(r.layoutBox,e):this.constraints=!1,this.elastic=rbe(n),i!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&Ui(s=>{this.constraints!==!1&&this.getAxisMotionValue(s)&&(this.constraints[s]=nbe(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=aye(r,i.root,this.visualElement.getTransformPagePoint());let o=ebe(i.layout.layoutBox,s);if(n){const a=n(iye(o));this.hasMutatedConstraints=!!a,a&&(o=nH(a))}return o}startAnimation(e){const{drag:n,dragMomentum:r,dragElastic:i,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},h=Ui(f=>{if(!Wy(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 JA(this.visualElement,e),r.start(lR(e,r,0,n,this.visualElement,!1))}stopAnimation(){Ui(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){Ui(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){Ui(n=>{const{drag:r}=this.getProps();if(!Wy(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]-Kt(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};Ui(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const c=a.get();i[o]=tbe({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(),Ui(o=>{if(!Wy(o,e,null))return;const a=this.getAxisMotionValue(o),{min:c,max:h}=this.constraints[o];a.set(Kt(c,h,i[o]))})}addListeners(){if(!this.visualElement.current)return;ibe.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&&(Ui(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=ZA,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:r,dragPropagation:i,dragConstraints:s,dragElastic:o,dragMomentum:a}}}function Wy(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function obe(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class abe extends Al{constructor(e){super(e),this.removeGroupControls=Zi,this.removeListeners=Zi,this.controls=new sbe(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Zi}unmount(){this.removeGroupControls(),this.removeListeners()}}const w4=t=>(e,n)=>{t&&Ut.postRender(()=>t(e,n))};class lbe extends Al{constructor(){super(...arguments),this.removePointerDownListener=Zi}onPointerDown(e){this.session=new bH(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:yH(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:r,onPanEnd:i}=this.node.getProps();return{onSessionStart:w4(e),onStart:w4(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 zb={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function S4(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=S4(t,e.target.x),r=S4(t,e.target.y);return`${n}% ${r}%`}},cbe={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=Kt(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 o2=!1;class ube extends k.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r,layoutId:i}=this.props,{projection:s}=e;P0e(hbe),s&&(n.group&&n.group.add(s),r&&r.register&&i&&r.register(s),o2&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),zb.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:r,drag:i,isPresent:s}=this.props,{projection:o}=r;return o&&(o.isPresent=s,o2=!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(),QT.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:i}=e;o2=!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 xH(t){const[e,n]=A0e(),r=k.useContext(Q7);return C.jsx(ube,{...t,layoutGroup:r,switchLayoutGroup:k.useContext(eH),isPresent:e,safeToRemove:n})}const hbe={borderRadius:{...Nd,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Nd,borderTopRightRadius:Nd,borderBottomLeftRadius:Nd,borderBottomRightRadius:Nd,boxShadow:cbe};function fbe(t,e,n){const r=mr(t)?t:Fh(t);return r.start(lR("",r,e,n)),r.animation}const dbe=(t,e)=>t.depth-e.depth;class pbe{constructor(){this.children=[],this.isDirty=!1}add(e){DT(this.children,e),this.isDirty=!0}remove(e){IT(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(dbe),this.isDirty=!1,this.children.forEach(e)}}function mbe(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 wH=["TopLeft","TopRight","BottomLeft","BottomRight"],gbe=wH.length,_4=t=>typeof t=="string"?parseFloat(t):t,C4=t=>typeof t=="number"||qe.test(t);function ybe(t,e,n,r,i,s){i?(t.opacity=Kt(0,n.opacity??1,bbe(r)),t.opacityExit=Kt(e.opacity??1,0,vbe(r))):s&&(t.opacity=Kt(e.opacity??1,n.opacity??1,r));for(let o=0;o<gbe;o++){const a=`border${wH[o]}Radius`;let c=A4(e,a),h=A4(n,a);if(c===void 0&&h===void 0)continue;c||(c=0),h||(h=0),c===0||h===0||C4(c)===C4(h)?(t[a]=Math.max(Kt(_4(c),_4(h),r),0),(fo.test(h)||fo.test(c))&&(t[a]+="%")):t[a]=h}(e.rotate||n.rotate)&&(t.rotate=Kt(e.rotate||0,n.rotate||0,r))}function A4(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const bbe=SH(0,.5,cU),vbe=SH(.5,.95,Zi);function SH(t,e,n){return r=>r<t?0:r>e?1:n(vm(t,e,r))}function E4(t,e){t.min=e.min,t.max=e.max}function zi(t,e){E4(t.x,e.x),E4(t.y,e.y)}function k4(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function T4(t,e,n,r,i){return t-=e,t=Yv(t,1/n,r),i!==void 0&&(t=Yv(t,1/i,r)),t}function xbe(t,e=0,n=1,r=.5,i,s=t,o=t){if(fo.test(e)&&(e=parseFloat(e),e=Kt(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=Kt(s.min,s.max,r);t===s&&(a-=e),t.min=T4(t.min,e,n,a,i),t.max=T4(t.max,e,n,a,i)}function R4(t,e,[n,r,i],s,o){xbe(t,e[n],e[r],e[i],e.scale,s,o)}const wbe=["x","scaleX","originX"],Sbe=["y","scaleY","originY"];function M4(t,e,n,r){R4(t.x,e,wbe,n?n.x:void 0,r?r.x:void 0),R4(t.y,e,Sbe,n?n.y:void 0,r?r.y:void 0)}function O4(t){return t.translate===0&&t.scale===1}function _H(t){return O4(t.x)&&O4(t.y)}function P4(t,e){return t.min===e.min&&t.max===e.max}function _be(t,e){return P4(t.x,e.x)&&P4(t.y,e.y)}function D4(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function CH(t,e){return D4(t.x,e.x)&&D4(t.y,e.y)}function I4(t){return Pr(t.x)/Pr(t.y)}function L4(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class Cbe{constructor(){this.members=[]}add(e){DT(this.members,e),e.scheduleRender()}remove(e){if(IT(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 Abe(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 a2=["","X","Y","Z"],Ebe=1e3;let kbe=0;function l2(t,e,n,r){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),r&&(r[t]=0))}function AH(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=uH(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&&AH(r)}function EH({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=kbe++,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(Mbe),this.nodes.forEach(Ibe),this.nodes.forEach(Lbe),this.nodes.forEach(Obe)},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 pbe)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new $T),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=zU(o)&&!S0e(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=mbe(m,250),zb.hasAnimatedSinceResize&&(zb.hasAnimatedSinceResize=!1,this.nodes.forEach(j4)))})}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()||Fbe,{onLayoutAnimationStart:x,onLayoutAnimationComplete:S}=h.getProps(),_=!this.targetLayout||!CH(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={...XT(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||j4(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(Nbe),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&&AH(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(N4);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach($4);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Dbe),this.nodes.forEach(Tbe),this.nodes.forEach(Rbe)):this.nodes.forEach($4),this.clearAllSnapshots();const a=Xr.now();Hn.delta=Zo(0,1e3/60,a-Hn.timestamp),Hn.timestamp=a,Hn.isProcessing=!0,X_.update.process(Hn),X_.preRender.process(Hn),X_.render.process(Hn),Hn.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,QT.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Pbe),this.sharedNodes.forEach($be)}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=sn(),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&&!_H(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)),zbe(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return sn();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Vbe))){const{scroll:h}=this.root;h&&(lh(a.x,h.offset.x),lh(a.y,h.offset.y))}return a}removeElementScroll(o){const a=sn();if(zi(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&&zi(a,o),lh(a.x,f.offset.x),lh(a.y,f.offset.y))}return a}applyTransform(o,a=!1){const c=sn();zi(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=sn();zi(a,o);for(let c=0;c<this.path.length;c++){const h=this.path[c];if(!h.instance||!nc(h.latestValues))continue;GA(h.latestValues)&&h.updateSnapshot();const f=sn(),d=h.measurePageBox();zi(f,d),M4(a,h.latestValues,h.snapshot?h.snapshot.layoutBox:void 0,f)}return nc(this.latestValues)&&M4(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=sn(),this.relativeTargetOrigin=sn(),Lp(this.relativeTargetOrigin,this.layout.layoutBox,m.layout.layoutBox),zi(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=sn(),this.targetWithTransforms=sn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Kye(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):zi(this.target,this.layout.layoutBox),iH(this.target,this.targetDelta)):zi(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=sn(),this.relativeTargetOrigin=sn(),Lp(this.relativeTargetOrigin,this.target,m.target),zi(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||GA(this.parent.latestValues)||rH(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;zi(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,m=this.treeScale.y;oye(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=sn());const{target:y}=o;if(!y){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(k4(this.prevProjectionDelta.x,this.projectionDelta.x),k4(this.prevProjectionDelta.y,this.projectionDelta.y)),Ip(this.projectionDelta,this.layoutCorrected,y,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==m||!L4(this.projectionDelta.x,this.prevProjectionDelta.x)||!L4(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=sn(),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(Bbe));this.animationProgress=0;let E;this.mixTargetDelta=P=>{const O=P/1e3;B4(d.x,o.x,O),B4(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),jbe(this.relativeTarget,this.relativeTargetOrigin,m,O),E&&_be(this.relativeTarget,E)&&(this.isProjectionDirty=!1),E||(E=sn()),zi(E,this.relativeTarget)),x&&(this.animationValues=f,ybe(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(()=>{zb.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Fh(0)),this.currentAnimation=fbe(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(Ebe),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&&kH(this.options.animationType,this.layout.layoutBox,h.layoutBox)){c=this.target||sn();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}zi(a,c),ch(a,f),Ip(this.projectionDeltaWithTransform,this.layoutCorrected,a,f)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Cbe),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&&l2("z",o,h,this.animationValues);for(let f=0;f<a2.length;f++)l2(`rotate${a2[f]}`,o,h,this.animationValues),l2(`skew${a2[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=Fb(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=Fb(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=Abe(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?Fb(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(N4),this.root.sharedNodes.clear()}}}function Tbe(t){t.updateLayout()}function Rbe(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"?Ui(f=>{const d=s?e.measuredBox[f]:e.layoutBox[f],m=Pr(d);d.min=n[f].min,d.max=d.min+m}):kH(i,e.layoutBox,n)&&Ui(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=!_H(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=sn();Lp(y,e.layoutBox,d.layoutBox);const b=sn();Lp(b,n,m.layoutBox),CH(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 Mbe(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 Obe(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Pbe(t){t.clearSnapshot()}function N4(t){t.clearMeasurements()}function $4(t){t.isLayoutDirty=!1}function Dbe(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function j4(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Ibe(t){t.resolveTargetDelta()}function Lbe(t){t.calcProjection()}function Nbe(t){t.resetSkewAndRotation()}function $be(t){t.removeLeadSnapshot()}function B4(t,e,n){t.translate=Kt(e.translate,0,n),t.scale=Kt(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function F4(t,e,n,r){t.min=Kt(e.min,n.min,r),t.max=Kt(e.max,n.max,r)}function jbe(t,e,n,r){F4(t.x,e.x,n.x,r),F4(t.y,e.y,n.y,r)}function Bbe(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Fbe={duration:.45,ease:[.4,0,.1,1]},z4=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),V4=z4("applewebkit/")&&!z4("chrome/")?Math.round:Zi;function U4(t){t.min=V4(t.min),t.max=V4(t.max)}function zbe(t){U4(t.x),U4(t.y)}function kH(t,e,n){return t==="position"||t==="preserve-aspect"&&!Gye(I4(e),I4(n),.2)}function Vbe(t){return t!==t.root&&t.scroll?.wasRoot}const Ube=EH({attachResizeListener:(t,e)=>Cm(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),c2={current:void 0},TH=EH({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!c2.current){const t=new Ube({});t.mount(window),t.setOptions({layoutScroll:!0}),c2.current=t}return c2.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Hbe={pan:{Feature:lbe},drag:{Feature:abe,ProjectionNode:TH,MeasureLayout:xH}};function H4(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,tg(e)))}class Wbe extends Al{mount(){const{current:e}=this.node;e&&(this.unmount=y0e(e,(n,r)=>(H4(this.node,r,"Start"),i=>H4(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=Qm(Cm(this.node.current,"focus",()=>this.onFocus()),Cm(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function W4(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,tg(e)))}class Gbe extends Al{mount(){const{current:e}=this.node;e&&(this.unmount=w0e(e,(n,r)=>(W4(this.node,r,"Start"),(i,{success:s})=>W4(this.node,i,s?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const eE=new WeakMap,u2=new WeakMap,Kbe=t=>{const e=eE.get(t.target);e&&e(t)},Ybe=t=>{t.forEach(Kbe)};function Xbe({root:t,...e}){const n=t||document;u2.has(n)||u2.set(n,{});const r=u2.get(n),i=JSON.stringify(e);return r[i]||(r[i]=new IntersectionObserver(Ybe,{root:t,...e})),r[i]}function Jbe(t,e,n){const r=Xbe(e);return eE.set(t,n),r.observe(t),()=>{eE.delete(t),r.unobserve(t)}}const Qbe={some:0,all:1};class Zbe 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:Qbe[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 Jbe(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(eve(e,n))&&this.startObserver()}unmount(){}}function eve({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const tve={inView:{Feature:Zbe},tap:{Feature:Gbe},focus:{Feature:qbe},hover:{Feature:Wbe}},nve={layout:{ProjectionNode:TH,MeasureLayout:xH}},rve={...zye,...tve,...Hbe,...nve},cR=rye(rve,gye),ive=()=>{const{t}=wt();return C.jsx(lB,{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")})]})})})},gw=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:[]})}})),sve="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",tE="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",RH="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",MH="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",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='%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",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%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",DH=({file:t,withoutClose:e})=>{const{deleteAttachmentFile:n}=gw(),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=_9(t.type),c=A9(t.type),h=Eb(t.type),f=C9(t.type),d=c?RH:a?tE:h?MH:f?OH:PH;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(Gt,{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(xt,{iconName:sve,size:16,onClick:r})]})};function Xv(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]/),ove=El(/[#-'*+\--9=?A-Z^-~]/);function Jv(t){return t!==null&&(t<32||t===127)}const nE=El(/\d/),ave=El(/[\dA-Fa-f]/),lve=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 yw=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 cve(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const bw=(function(t){if(t==null)return dve;if(typeof t=="function")return vw(t);if(typeof t=="object")return Array.isArray(t)?uve(t):hve(t);if(typeof t=="string")return fve(t);throw new Error("Expected function, string, or object as test")});function uve(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=bw(t[n]);return vw(r);function r(...i){let s=-1;for(;++s<e.length;)if(e[s].apply(this,i))return!0;return!1}}function hve(t){const e=t;return vw(n);function n(r){const i=r;let s;for(s in t)if(i[s]!==e[s])return!1;return!0}}function fve(t){return vw(e);function e(n){return n&&n.type===t}}function vw(t){return e;function e(n,r,i){return!!(pve(n)&&t.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function dve(){return!0}function pve(t){return t!==null&&typeof t=="object"&&"type"in t}const IH=[],mve=!0,rE=!1,gve="skip";function LH(t,e,n,r){let i;typeof e=="function"&&typeof n!="function"?(r=n,n=e):i=e;const s=bw(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=IH,b,x,S;if((!e||s(c,h,f[f.length-1]||void 0))&&(y=yve(n(c,f)),y[0]===rE))return y;if("children"in c&&c.children){const _=c;if(_.children&&y[0]!==gve)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]===rE)return b;x=typeof b[1]=="number"?b[1]:x+o}}return y}}}function yve(t){return Array.isArray(t)?t:typeof t=="number"?[mve,t]:t==null?IH:[t]}function bve(t,e,n){const i=bw((n||{}).ignore||[]),s=vve(e);let o=-1;for(;++o<s.length;)LH(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 vve(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([xve(i[0]),wve(i[1])])}return e}function xve(t){return typeof t=="string"?new RegExp(cve(t),"g"):t}function wve(t){return typeof t=="function"?t:function(){return t}}const h2="phrasing",f2=["autolink","link","image","label"];function Sve(){return{transforms:[Rve],enter:{literalAutolink:Cve,literalAutolinkEmail:d2,literalAutolinkHttp:d2,literalAutolinkWww:d2},exit:{literalAutolink:Tve,literalAutolinkEmail:kve,literalAutolinkHttp:Ave,literalAutolinkWww:Eve}}}function _ve(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:h2,notInConstruct:f2},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:h2,notInConstruct:f2},{character:":",before:"[ps]",after:"\\/",inConstruct:h2,notInConstruct:f2}]}}function Cve(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function d2(t){this.config.enter.autolinkProtocol.call(this,t)}function Ave(t){this.config.exit.autolinkProtocol.call(this,t)}function Eve(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 kve(t){this.config.exit.autolinkEmail.call(this,t)}function Tve(t){this.exit(t)}function Rve(t){bve(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Mve],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Ove]],{ignore:["link","linkReference"]})}function Mve(t,e,n,r,i){let s="";if(!NH(i)||(/^w/i.test(e)&&(n=e+n,e="",s="http://"),!Pve(n)))return!1;const o=Dve(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 Ove(t,e,n,r){return!NH(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n}]}}function Pve(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 Dve(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=Xv(t,"(");let s=Xv(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 NH(t,e){const n=t.input.charCodeAt(t.index-1);return(t.index===0||Oc(n)||yw(n))&&(!e||n!==47)}function vs(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}$H.peek=Vve;function Ive(){this.buffer()}function Lve(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function Nve(){this.buffer()}function $ve(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function jve(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=vs(this.sliceSerialize(t)).toLowerCase(),n.label=e}function Bve(t){this.exit(t)}function Fve(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=vs(this.sliceSerialize(t)).toLowerCase(),n.label=e}function zve(t){this.exit(t)}function Vve(){return"["}function $H(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 Uve(){return{enter:{gfmFootnoteCallString:Ive,gfmFootnoteCall:Lve,gfmFootnoteDefinitionLabelString:Nve,gfmFootnoteDefinition:$ve},exit:{gfmFootnoteCallString:jve,gfmFootnoteCall:Bve,gfmFootnoteDefinitionLabelString:Fve,gfmFootnoteDefinition:zve}}}function Hve(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:$H},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?jH:Wve))),h(),c}}function Wve(t,e,n){return e===0?t:jH(t,e,n)}function jH(t,e,n){return(n?"":" ")+t}const qve=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];BH.peek=Jve;function Gve(){return{canContainEols:["delete"],enter:{strikethrough:Yve},exit:{strikethrough:Xve}}}function Kve(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:qve}],handlers:{delete:BH}}}function Yve(t){this.enter({type:"delete",children:[]},t)}function Xve(t){this.exit(t)}function BH(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 Jve(){return"~"}function Qve(t){return t.length}function Zve(t,e){const n=e||{},r=(n.align||[]).concat(),i=n.stringLength||Qve,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=exe(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]=q4(r[d]);else{const x=q4(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 exe(t){return t==null?"":String(t)}function q4(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 G4={}.hasOwnProperty;function txe(t,e){const n=e||{};function r(i,...s){let o=r.invalid;const a=r.handlers;if(i&&G4.call(i,t)){const c=String(i[t]);o=G4.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 nxe(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()),rxe);return i(),o}function rxe(t,e,n){return">"+(n?"":" ")+t}function ixe(t,e){return K4(t,e.inConstruct,!0)&&!K4(t,e.notInConstruct,!1)}function K4(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 Y4(t,e,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
||
`&&ixe(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
||
`}function sxe(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 oxe(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 axe(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 lxe(t,e,n,r){const i=axe(n),s=t.value||"",o=i==="`"?"GraveAccent":"Tilde";if(oxe(t,n)){const d=n.enter("codeIndented"),m=n.indentLines(s,cxe);return d(),m}const a=n.createTracker(r),c=i.repeat(Math.max(sxe(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 cxe(t,e,n){return(n?"":" ")+t}function uR(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 uxe(t,e,n,r){const i=uR(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 hxe(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(yw(t))return 2}function Qv(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}}FH.peek=fxe;function FH(t,e,n,r){const i=hxe(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=Qv(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=Qv(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 fxe(t,e,n){return n.options.emphasis||"*"}function hR(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),LH(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 dxe={};function fR(t,e){const n=dxe,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return zH(t,r,i)}function zH(t,e,n){if(pxe(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 X4(t.children,e,n)}return Array.isArray(t)?X4(t,e,n):""}function X4(t,e,n){const r=[];let i=-1;for(;++i<t.length;)r[i]=zH(t[i],e,n);return r.join("")}function pxe(t){return!!(t&&typeof t=="object")}function mxe(t,e){let n=!1;return hR(t,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,rE}),!!((!t.depth||t.depth<3)&&fR(t)&&(e.options.setext||n))}function gxe(t,e,n,r){const i=Math.max(Math.min(6,t.depth||1),1),s=n.createTracker(r);if(mxe(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}VH.peek=yxe;function VH(t){return t.value||""}function yxe(){return"<"}UH.peek=bxe;function UH(t,e,n,r){const i=uR(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 bxe(){return"!"}HH.peek=vxe;function HH(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 vxe(){return"!"}WH.peek=xxe;function WH(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 xxe(){return"`"}function qH(t,e){const n=fR(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))}GH.peek=wxe;function GH(t,e,n,r){const i=uR(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,c;if(qH(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 wxe(t,e,n){return qH(t,n)?"<":"["}KH.peek=Sxe;function KH(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 Sxe(){return"["}function dR(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 _xe(t){const e=dR(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 Cxe(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 YH(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 Axe(t,e,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=t.ordered?Cxe(n):dR(n);const a=t.ordered?o==="."?")":".":_xe(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),YH(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 Exe(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 kxe(t,e,n,r){const i=Exe(n);let s=n.bulletCurrent||dR(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 Txe(t,e,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(t,r);return s(),i(),o}const Rxe=bw(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Mxe(t,e,n,r){return(t.children.some(function(o){return Rxe(o)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function Oxe(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}XH.peek=Pxe;function XH(t,e,n,r){const i=Oxe(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=Qv(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=Qv(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 Pxe(t,e,n){return n.options.strong||"*"}function Dxe(t,e,n,r){return n.safe(t.value,r)}function Ixe(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 Lxe(t,e,n){const r=(YH(n)+(n.options.ruleSpaces?" ":"")).repeat(Ixe(n));return n.options.ruleSpaces?r.slice(0,-1):r}const JH={blockquote:nxe,break:Y4,code:lxe,definition:uxe,emphasis:FH,hardBreak:Y4,heading:gxe,html:VH,image:UH,imageReference:HH,inlineCode:WH,link:GH,linkReference:KH,list:Axe,listItem:kxe,paragraph:Txe,root:Mxe,strong:XH,text:Dxe,thematicBreak:Lxe},J4=document.createElement("i");function pR(t){const e="&"+t+";";J4.innerHTML=e;const n=J4.textContent;return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function QH(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 Nxe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function $xe(t){return t.replace(Nxe,jxe)}function jxe(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return QH(n.slice(s?2:1),s?16:10)}return pR(n)||t}function Bxe(){return{enter:{table:Fxe,tableData:Q4,tableHeader:Q4,tableRow:Vxe},exit:{codeText:Uxe,table:zxe,tableData:p2,tableHeader:p2,tableRow:p2}}}function Fxe(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 zxe(t){this.exit(t),this.data.inTable=void 0}function Vxe(t){this.enter({type:"tableRow",children:[]},t)}function p2(t){this.exit(t)}function Q4(t){this.enter({type:"tableCell",children:[]},t)}function Uxe(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,Hxe));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function Hxe(t,e){return e==="|"?e:t}function Wxe(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 Zve(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=JH.inlineCode(y,b,x);return x.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function qxe(){return{exit:{taskListCheckValueChecked:Z4,taskListCheckValueUnchecked:Z4,paragraph:Kxe}}}function Gxe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Yxe}}}function Z4(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function Kxe(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 Yxe(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=JH.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 Xxe(){return[Sve(),Uve(),Gve(),Bxe(),qxe()]}function Jxe(t){return{extensions:[_ve(),Hve(t),Kve(),Wxe(t),Gxe()]}}function Ei(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 Wi(t,e){return t.length>0?(Ei(t,t.length,0,e),t):e}const e$={}.hasOwnProperty;function ZH(t){const e={};let n=-1;for(;++n<t.length;)Qxe(e,t[n]);return e}function Qxe(t,e){let n;for(n in e){const i=(e$.call(t,n)?t[n]:void 0)||(t[n]={}),s=e[n];let o;if(s)for(o in s){e$.call(i,o)||(i[o]=[]);const a=s[o];Zxe(i[o],Array.isArray(a)?a:a?[a]:[])}}}function Zxe(t,e){let n=-1;const r=[];for(;++n<e.length;)(e[n].add==="after"?t:r).push(e[n]);Ei(t,0,0,r)}const ewe={tokenize:owe,partial:!0},eW={tokenize:awe,partial:!0},tW={tokenize:lwe,partial:!0},nW={tokenize:cwe,partial:!0},twe={tokenize:uwe,partial:!0},rW={name:"wwwAutolink",tokenize:iwe,previous:sW},iW={name:"protocolAutolink",tokenize:swe,previous:oW},oa={name:"emailAutolink",tokenize:rwe,previous:aW},So={};function nwe(){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,iW];So[104]=[oa,iW];So[87]=[oa,rW];So[119]=[oa,rW];function rwe(t,e,n){const r=this;let i,s;return o;function o(d){return!iE(d)||!aW.call(r,r.previous)||mR(r.events)?n(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),a(d))}function a(d){return iE(d)?(t.consume(d),a):d===64?(t.consume(d),c):n(d)}function c(d){return d===46?t.check(twe,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 iwe(t,e,n){const r=this;return i;function i(o){return o!==87&&o!==119||!sW.call(r,r.previous)||mR(r.events)?n(o):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(ewe,t.attempt(eW,t.attempt(tW,s),n),n)(o))}function s(o){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(o)}}function swe(t,e,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&oW.call(r,r.previous)&&!mR(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||Jv(d)||Ot(d)||Oc(d)||yw(d)?n(d):t.attempt(eW,t.attempt(tW,f),n)(d)}function f(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function owe(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 awe(t,e,n){let r,i,s;return o;function o(h){return h===46||h===95?t.check(nW,c,a)(h):h===null||Ot(h)||Oc(h)||h!==45&&yw(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 lwe(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(nW,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 cwe(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 uwe(t,e,n){return r;function r(s){return t.consume(s),i}function i(s){return gr(s)?n(s):e(s)}}function sW(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Ot(t)}function oW(t){return!Or(t)}function aW(t){return!(t===47||iE(t))}function iE(t){return t===43||t===45||t===46||t===95||gr(t)}function mR(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 xw(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 sE={name:"attention",resolveAll:hwe,tokenize:fwe};function hwe(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};t$(d,-c),t$(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=Wi(h,[["enter",t[r][1],e],["exit",t[r][1],e]])),h=Wi(h,[["enter",i,e],["enter",o,e],["exit",o,e],["enter",s,e]]),h=Wi(h,xw(e.parser.constructs.insideSpan.null,t.slice(r+1,n),e)),h=Wi(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=Wi(h,[["enter",t[n][1],e],["exit",t[n][1],e]])):f=0,Ei(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 fwe(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 t$(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const dwe={name:"autolink",tokenize:pwe};function pwe(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||Jv(y)?n(y):(t.consume(y),c)}function h(y){return y===64?(t.consume(y),f):ove(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 ng={partial:!0,tokenize:mwe};function mwe(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 lW={continuation:{tokenize:ywe},exit:bwe,name:"blockQuote",tokenize:gwe};function gwe(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 ywe(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(lW,e,n)(o)}}function bwe(t){t.exit("blockQuote")}const cW={name:"characterEscape",tokenize:vwe};function vwe(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 lve(s)?(t.enter("characterEscapeValue"),t.consume(s),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(s)}}const uW={name:"characterReference",tokenize:xwe};function xwe(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=ave,f):(t.enter("characterReferenceValue"),s=7,o=nE,f(d))}function f(d){if(d===59&&i){const m=t.exit("characterReferenceValue");return o===gr&&!pR(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 n$={partial:!0,tokenize:Swe},r$={concrete:!0,name:"codeFenced",tokenize:wwe};function wwe(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(n$,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&<(M)?ut(t,A,"linePrefix",s+1)(M):A(M)}function A(M){return M===null||Be(M)?t.check(n$,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 Swe(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 m2={name:"codeIndented",tokenize:Cwe},_we={partial:!0,tokenize:Awe};function Cwe(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(_we,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 Awe(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 Ewe={name:"codeText",previous:Twe,resolve:kwe,tokenize:Rwe};function kwe(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 Twe(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Rwe(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 Mwe{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 hW(t){const e={};let n=-1,r,i,s,o,a,c,h;const f=new Mwe(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,Owe(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 Ei(t,0,Number.POSITIVE_INFINITY,f.slice(0)),!h}function Owe(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 Pwe={resolve:Iwe,tokenize:Lwe},Dwe={partial:!0,tokenize:Nwe};function Iwe(t){return hW(t),t}function Lwe(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(Dwe,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 Nwe(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 fW(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||Jv(_)?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||Jv(_)?n(_):(t.consume(_),_===92?S:x)}function S(_){return _===40||_===41||_===92?(t.consume(_),x):x(_)}}function dW(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 pW(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 $we={name:"definition",tokenize:Bwe},jwe={partial:!0,tokenize:Fwe};function Bwe(t,e,n){const r=this;let i;return s;function s(y){return t.enter("definition"),o(y)}function o(y){return dW.call(r,t,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function a(y){return i=vs(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 fW(t,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function f(y){return t.attempt(jwe,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 Fwe(t,e,n){return r;function r(a){return Ot(a)?Np(t,i)(a):n(a)}function i(a){return pW(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 zwe={name:"hardBreakEscape",tokenize:Vwe};function Vwe(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 Uwe={name:"headingAtx",resolve:Hwe,tokenize:Wwe};function Hwe(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"},Ei(t,r,n-r+1,[["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e]])),t}function Wwe(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"],i$=["pre","script","style","textarea"],Gwe={concrete:!0,name:"htmlFlow",resolveTo:Xwe,tokenize:Jwe},Kwe={partial:!0,tokenize:Zwe},Ywe={partial:!0,tokenize:Qwe};function Xwe(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 Jwe(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&&i$.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(Kwe,ue,X)(L)):L===null||Be(L)?(t.exit("htmlFlowData"),X(L)):(t.consume(L),q)}function X(L){return t.check(Ywe,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 i$.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 Qwe(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 Zwe(t,e,n){return r;function r(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),t.attempt(ng,e,n)}}const e1e={name:"htmlText",tokenize:t1e};function t1e(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 gR={name:"labelEnd",resolveAll:s1e,resolveTo:o1e,tokenize:a1e},n1e={tokenize:l1e},r1e={tokenize:c1e},i1e={tokenize:u1e};function s1e(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&&Ei(t,0,t.length,n),t}function o1e(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=Wi(a,t.slice(s+1,s+r+3)),a=Wi(a,[["enter",f,e]]),a=Wi(a,xw(e.parser.constructs.insideSpan.null,t.slice(s+r+4,o-3),e)),a=Wi(a,[["exit",f,e],t[o-2],t[o-1],["exit",h,e]]),a=Wi(a,t.slice(o+1)),a=Wi(a,[["exit",c,e]]),Ei(t,s,t.length,a),t}function a1e(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(vs(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(n1e,f,o?f:d)(m):m===91?t.attempt(r1e,f,o?h:d)(m):o?f(m):d(m)}function h(m){return t.attempt(i1e,f,d)(m)}function f(m){return e(m)}function d(m){return s._balanced=!0,n(m)}}function l1e(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):fW(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?pW(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 c1e(t,e,n){const r=this;return i;function i(a){return dW.call(r,t,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(vs(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(a):n(a)}function o(a){return n(a)}}function u1e(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 h1e={name:"labelStartImage",resolveAll:gR.resolveAll,tokenize:f1e};function f1e(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 d1e={name:"labelStartLink",resolveAll:gR.resolveAll,tokenize:p1e};function p1e(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 g2={name:"lineEnding",tokenize:m1e};function m1e(t,e){return n;function n(r){return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),ut(t,e,"linePrefix")}}const Vb={name:"thematicBreak",tokenize:g1e};function g1e(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:x1e},exit:S1e,name:"list",tokenize:v1e},y1e={partial:!0,tokenize:_1e},b1e={partial:!0,tokenize:w1e};function v1e(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:nE(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(Vb,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 nE(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(ng,r.interrupt?n:f,t.attempt(y1e,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 x1e(t,e,n){const r=this;return r.containerState._closeFlow=void 0,t.check(ng,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(b1e,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 w1e(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 S1e(t){t.exit(this.containerState.type)}function _1e(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 s$={name:"setextUnderline",resolveTo:C1e,tokenize:A1e};function C1e(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 A1e(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 E1e={tokenize:I1e,partial:!0};function k1e(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:O1e,continuation:{tokenize:P1e},exit:D1e}},text:{91:{name:"gfmFootnoteCall",tokenize:M1e},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:T1e,resolveTo:R1e}}}}function T1e(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=vs(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 R1e(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 M1e(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(vs(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 O1e(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=vs(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 P1e(t,e,n){return t.check(ng,e,t.attempt(E1e,e,n))}function D1e(t){t.exit("gfmFootnoteDefinition")}function I1e(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 L1e(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&&Ei(m,m.length,0,xw(y,o.slice(h+1,c),a)),Ei(m,m.length,0,[["exit",d,a],["enter",o[c][1],a],["exit",o[c][1],a],["exit",f,a]]),Ei(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 N1e{constructor(){this.map=[]}add(e,n,r){$1e(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 $1e(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 j1e(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 B1e(){return{flow:{null:{name:"table",tokenize:F1e,resolveAll:z1e}}}}function F1e(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 z1e(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 N1e;for(;++n<t.length;){const y=t[n],b=y[1];y[0]==="enter"?b.type==="tableHead"?(a=!1,c!==0&&(o$(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=qy(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=qy(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=qy(m,e,s,i,n,d)):o[1]!==0&&(d=qy(m,e,o,i,n,d)),i=0):i&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(o[3]=n)}for(c!==0&&o$(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=j1e(e.events,n))}return t}function qy(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 o$(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 V1e={name:"tasklistCheck",tokenize:H1e};function U1e(){return{text:{91:V1e}}}function H1e(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:W1e},e,n)(c):n(c)}}function W1e(t,e,n){return ut(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function q1e(t){return ZH([nwe(),k1e(),L1e(t),B1e(),U1e()])}const G1e={};function K1e(t){const e=this,n=t||G1e,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(q1e(n)),s.push(Xxe()),o.push(Jxe(n))}function mW(t,e){const n=e||{};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Y1e=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,X1e=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,J1e={};function a$(t,e){return(J1e.jsx?X1e:Y1e).test(t)}const Q1e=/[ \t\n\f\r]/g;function ww(t){return typeof t=="object"?t.type==="text"?l$(t.value):!1:l$(t)}function l$(t){return t.replace(Q1e,"")===""}class rg{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}}rg.prototype.normal={};rg.prototype.property={};rg.prototype.space=void 0;function gW(t,e){const n={},r={};for(const i of t)Object.assign(n,i.property),Object.assign(r,i.normal);return new rg(n,r,e)}function oE(t){return t.toLowerCase()}class Zr{constructor(e,n){this.attribute=n,this.property=e}}Zr.prototype.attribute="";Zr.prototype.booleanish=!1;Zr.prototype.boolean=!1;Zr.prototype.commaOrSpaceSeparated=!1;Zr.prototype.commaSeparated=!1;Zr.prototype.defined=!1;Zr.prototype.mustUseProperty=!1;Zr.prototype.number=!1;Zr.prototype.overloadedBoolean=!1;Zr.prototype.property="";Zr.prototype.spaceSeparated=!1;Zr.prototype.space=void 0;let Z1e=0;const Je=jc(),hn=jc(),aE=jc(),ge=jc(),It=jc(),Eh=jc(),xi=jc();function jc(){return 2**++Z1e}const lE=Object.freeze(Object.defineProperty({__proto__:null,boolean:Je,booleanish:hn,commaOrSpaceSeparated:xi,commaSeparated:Eh,number:ge,overloadedBoolean:aE,spaceSeparated:It},Symbol.toStringTag,{value:"Module"})),y2=Object.keys(lE);class yR extends Zr{constructor(e,n,r,i){let s=-1;if(super(e,n),c$(this,"space",i),typeof r=="number")for(;++s<y2.length;){const o=y2[s];c$(this,y2[s],(r&lE[o])===lE[o])}}}yR.prototype.defined=!0;function c$(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 yR(r,t.transform(t.attributes||{},r),i,t.space);t.mustUseProperty&&t.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),e[r]=s,n[oE(r)]=r,n[oE(s.attribute)]=r}return new rg(e,n,t.space)}const yW=of({properties:{ariaActiveDescendant:null,ariaAtomic:hn,ariaAutoComplete:null,ariaBusy:hn,ariaChecked:hn,ariaColCount:ge,ariaColIndex:ge,ariaColSpan:ge,ariaControls:It,ariaCurrent:null,ariaDescribedBy:It,ariaDetails:null,ariaDisabled:hn,ariaDropEffect:It,ariaErrorMessage:null,ariaExpanded:hn,ariaFlowTo:It,ariaGrabbed:hn,ariaHasPopup:null,ariaHidden:hn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:It,ariaLevel:ge,ariaLive:null,ariaModal:hn,ariaMultiLine:hn,ariaMultiSelectable:hn,ariaOrientation:null,ariaOwns:It,ariaPlaceholder:null,ariaPosInSet:ge,ariaPressed:hn,ariaReadOnly:hn,ariaRelevant:null,ariaRequired:hn,ariaRoleDescription:It,ariaRowCount:ge,ariaRowIndex:ge,ariaRowSpan:ge,ariaSelected:hn,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 bW(t,e){return e in t?t[e]:e}function vW(t,e){return bW(t,e.toLowerCase())}const eSe=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:Je,allowPaymentRequest:Je,allowUserMedia:Je,alt:null,as:null,async:Je,autoCapitalize:null,autoComplete:It,autoFocus:Je,autoPlay:Je,blocking:It,capture:null,charSet:null,checked:Je,cite:null,className:It,cols:ge,colSpan:null,content:null,contentEditable:hn,controls:Je,controlsList:It,coords:ge|Eh,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Je,defer:Je,dir:null,dirName:null,disabled:Je,download:aE,draggable:hn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Je,formTarget:null,headers:It,height:ge,hidden:aE,high:ge,href:null,hrefLang:null,htmlFor:It,httpEquiv:It,id:null,imageSizes:null,imageSrcSet:null,inert:Je,inputMode:null,integrity:null,is:null,isMap:Je,itemId:null,itemProp:It,itemRef:It,itemScope:Je,itemType:It,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Je,low:ge,manifest:null,max:null,maxLength:ge,media:null,method:null,min:null,minLength:ge,multiple:Je,muted:Je,name:null,nonce:null,noModule:Je,noValidate:Je,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:Je,optimum:ge,pattern:null,ping:It,placeholder:null,playsInline:Je,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Je,referrerPolicy:null,rel:It,required:Je,reversed:Je,rows:ge,rowSpan:ge,sandbox:It,scope:null,scoped:Je,seamless:Je,selected:Je,shadowRootClonable:Je,shadowRootDelegatesFocus:Je,shadowRootMode:null,shape:null,size:ge,sizes:null,slot:null,span:ge,spellCheck:hn,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:Je,useMap:null,value:hn,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:Je,declare:Je,event:null,face:null,frame:null,frameBorder:null,hSpace:ge,leftMargin:ge,link:null,longDesc:null,lowSrc:null,marginHeight:ge,marginWidth:ge,noResize:Je,noHref:Je,noShade:Je,noWrap:Je,object:null,profile:null,prompt:null,rev:null,rightMargin:ge,rules:null,scheme:null,scrolling:hn,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:Je,disableRemotePlayback:Je,prefix:null,property:null,results:ge,security:null,unselectable:null},space:"html",transform:vW}),tSe=of({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:xi,accentHeight: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:Je,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:xi,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:xi,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:xi,rev:xi,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:xi,requiredFeatures:xi,requiredFonts:xi,requiredFormats:xi,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant: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:xi,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:xi,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:xi,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:bW}),xW=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()}}),wW=of({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:vW}),SW=of({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),nSe={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"},rSe=/[A-Z]/g,u$=/-[a-z]/g,iSe=/^data[-\w.:]+$/i;function _W(t,e){const n=oE(e);let r=e,i=Zr;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&iSe.test(e)){if(e.charAt(4)==="-"){const s=e.slice(5).replace(u$,oSe);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=e.slice(4);if(!u$.test(s)){let o=s.replace(rSe,sSe);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}i=yR}return new i(r,e)}function sSe(t){return"-"+t.toLowerCase()}function oSe(t){return t.charAt(1).toUpperCase()}const CW=gW([yW,eSe,xW,wW,SW],"html"),ig=gW([yW,tSe,xW,wW,SW],"svg");function AW(t){return t.join(" ").trim()}var zu={},b2,h$;function aSe(){if(h$)return b2;h$=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";b2=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 b2}var f$;function lSe(){if(f$)return zu;f$=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(aSe());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={},d$;function cSe(){if(d$)return jd;d$=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,p$;function uSe(){if(p$)return Bd;p$=1;var t=Bd&&Bd.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},e=t(lSe()),n=cSe();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 hSe=uSe();const fSe=Pc(hSe),EW=kW("end"),bR=kW("start");function kW(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 dSe(t){const e=bR(t),n=EW(t);if(e&&n)return{start:e,end:n}}function $p(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?m$(t.position):"start"in t||"end"in t?m$(t):"line"in t||"column"in t?cE(t):""}function cE(t){return g$(t&&t.line)+":"+g$(t&&t.column)}function m$(t){return cE(t&&t.start)+"-"+cE(t&&t.end)}function g$(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 vR={}.hasOwnProperty,pSe=new Map,mSe=/[A-Z]/g,gSe=new Set(["table","tbody","thead","tfoot","tr"]),ySe=new Set(["td","th"]),TW="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function RW(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=ASe(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=CSe(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"?ig:CW,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},s=MW(i,t,void 0);return s&&typeof s!="string"?s:i.create(t,i.Fragment,{children:s||void 0},void 0)}function MW(t,e,n){if(e.type==="element")return bSe(t,e,n);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return vSe(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return wSe(t,e,n);if(e.type==="mdxjsEsm")return xSe(t,e);if(e.type==="root")return SSe(t,e,n);if(e.type==="text")return _Se(t,e)}function bSe(t,e,n){const r=t.schema;let i=r;e.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=ig,t.schema=i),t.ancestors.push(e);const s=PW(t,e.tagName,!1),o=ESe(t,e);let a=wR(t,e);return gSe.has(e.tagName)&&(a=a.filter(function(c){return typeof c=="string"?!ww(c):!0})),OW(t,o,s,e),xR(o,a),t.ancestors.pop(),t.schema=r,t.create(e,s,o,n)}function vSe(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 xSe(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);Em(t,e.position)}function wSe(t,e,n){const r=t.schema;let i=r;e.name==="svg"&&r.space==="html"&&(i=ig,t.schema=i),t.ancestors.push(e);const s=e.name===null?t.Fragment:PW(t,e.name,!0),o=kSe(t,e),a=wR(t,e);return OW(t,o,s,e),xR(o,a),t.ancestors.pop(),t.schema=r,t.create(e,s,o,n)}function SSe(t,e,n){const r={};return xR(r,wR(t,e)),t.create(e,t.Fragment,r,n)}function _Se(t,e){return e.value}function OW(t,e,n,r){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=r)}function xR(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function CSe(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 ASe(t,e){return n;function n(r,i,s,o){const a=Array.isArray(s.children),c=bR(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 ESe(t,e){const n={};let r,i;for(i in e.properties)if(i!=="children"&&vR.call(e.properties,i)){const s=TSe(t,i,e.properties[i]);if(s){const[o,a]=s;t.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&ySe.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 kSe(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 wR(t,e){const n=[];let r=-1;const i=t.passKeys?new Map:pSe;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=MW(t,s,o);a!==void 0&&n.push(a)}return n}function TSe(t,e,n){const r=_W(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?mW(n):AW(n)),r.property==="style"){let i=typeof n=="object"?n:RSe(t,String(n));return t.stylePropertyNameCase==="css"&&(i=MSe(i)),["style",i]}return[t.elementAttributeNameCase==="react"&&r.space?nSe[r.property]||r.property:r.attribute,n]}}function RSe(t,e){try{return fSe(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=TW+"#cannot-parse-style-attribute",i}}function PW(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=a$(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=a$(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(r.type==="Literal"){const i=r.value;return vR.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=TW+"#cannot-handle-mdx-estrees-without-createevaluater",n}function MSe(t){const e={};let n;for(n in t)vR.call(t,n)&&(e[OSe(n)]=t[n]);return e}function OSe(t){let e=t.replace(mSe,PSe);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function PSe(t){return"-"+t.toLowerCase()}const v2={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"]},DSe={tokenize:ISe};function ISe(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 LSe={tokenize:NSe},y$={tokenize:$Se};function NSe(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 Ei(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(y$,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(y$,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++;Ei(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 $Se(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 jSe={tokenize:BSe};function BSe(t){const e=this,n=t.attempt(ng,r,t.attempt(this.parser.constructs.flowInitial,i,ut(t,t.attempt(this.parser.constructs.flow,i,t.attempt(Pwe,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 FSe={resolveAll:IW()},zSe=DW("string"),VSe=DW("text");function DW(t){return{resolveAll:IW(t==="text"?USe: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 IW(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 USe(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 HSe={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:lW},WSe={91:$we},qSe={[-2]:m2,[-1]:m2,32:m2},GSe={35:Uwe,42:Vb,45:[s$,Vb],60:Gwe,61:s$,95:Vb,96:r$,126:r$},KSe={38:uW,92:cW},YSe={[-5]:g2,[-4]:g2,[-3]:g2,33:h1e,38:uW,42:sE,60:[dwe,e1e],91:d1e,92:[zwe,cW],93:gR,95:sE,96:Ewe},XSe={null:[sE,FSe]},JSe={null:[42,95]},QSe={null:[]},ZSe=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:JSe,contentInitial:WSe,disable:QSe,document:HSe,flow:GSe,flowInitial:qSe,insideSpan:XSe,string:KSe,text:YSe},Symbol.toStringTag,{value:"Module"}));function e_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=Wi(o,V),S(),o[o.length-1]!==null?[]:(N(e,0),h.events=xw(s,h.events,h),h.events)}function m(V,q){return n_e(y(V),q)}function y(V){return t_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],Yt=Ue!==null&&ye.null,Xt=[...Array.isArray(Pt)?Pt:Pt?[Pt]:[],...Array.isArray(Yt)?Yt:Yt?[Yt]:[]];return ue(Xt)(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&&Ei(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 t_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 n_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 r_e(t){const r={constructs:ZH([ZSe,...(t||{}).extensions||[]]),content:i(DSe),defined:[],document:i(LSe),flow:i(jSe),lazy:{},string:i(zSe),text:i(VSe)};return r;function i(s){return o;function o(a){return e_e(r,s,a)}}}function i_e(t){for(;!hW(t););return t}const b$=/[\0\t\n\r]/g;function s_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(b$.lastIndex=d,h=b$.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 LW={}.hasOwnProperty;function o_e(t,e,n){return typeof e!="string"&&(n=e,e=void 0),a_e(n)(i_e(r_e(n).document().write(s_e()(t,e,!0))))}function a_e(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(kl),autolinkProtocol:H,autolinkEmail:H,atxHeading:s(_o),blockQuote:s(Yt),characterEscape:H,characterReference:H,codeFenced:s(Xt),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Xt,o),codeText:s(er,o),codeTextData:H,data:H,codeFlowValue:H,definition:s(tr),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(ei),hardBreakEscape:s(is),hardBreakTrailing:s(is),htmlFlow:s(nr,o),htmlFlowData:H,htmlText:s(nr,o),htmlTextData:H,image:s(lf),label:o,link:s(kl),listItem:s(Ps),listItemValue:m,listOrdered:s(Os,d),listUnordered:s(Os),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()}};NW(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 gt=-1;for(;++gt<oe.length;)if(oe[gt][1].type==="listOrdered"||oe[gt][1].type==="listUnordered")if(oe[gt][0]==="enter")$e.push(gt);else{const Sr=$e.pop();gt=i(oe,Sr,gt)}for(gt=-1;++gt<oe.length;){const Sr=e[oe[gt][0]];LW.call(Sr,oe[gt][1].type)&&Sr[oe[gt][1].type].call(Object.assign({sliceSerialize:oe[gt][2].sliceSerialize},De),oe[gt][1])}if(De.tokenStack.length>0){const Sr=De.tokenStack[De.tokenStack.length-1];(Sr[1]||v$).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})},gt=-1;++gt<e.transforms.length;)me=e.transforms[gt](me)||me;return me}function i(oe,me,De){let $e=me-1,gt=-1,Sr=!1,ss,rr,ti,_r;for(;++$e<=De;){const an=oe[$e];switch(an[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{an[0]==="enter"?gt++:gt--,_r=void 0;break}case"lineEndingBlank":{an[0]==="enter"&&(ss&&!_r&&!gt&&!ti&&(ti=$e),_r=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:_r=void 0}if(!gt&&an[0]==="enter"&&an[1].type==="listItemPrefix"||gt===-1&&an[0]==="exit"&&(an[1].type==="listUnordered"||an[1].type==="listOrdered")){if(ss){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}ti&&(!rr||ti<rr)&&(ss._spread=!0),ss.end=Object.assign({},rr?oe[rr][1].start:an[1].end),oe.splice(rr||$e,0,["exit",ss,an[2]]),$e++,De++}if(an[1].type==="listItemPrefix"){const ir={type:"listItem",_spread:!1,start:Object.assign({},an[1].start),end:void 0};ss=ir,oe.splice($e,0,["enter",ir,an[2]]),$e++,De++,ti=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]||v$).call(this,oe,$e[0]));else throw new Error("Cannot close `"+oe.type+"` ("+$p({start:oe.start,end:oe.end})+"): it’s not open");De.position.end=Ga(oe.end)}function f(){return fR(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=vs(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=Ri(),$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=$xe(me),De.identifier=vs(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=vs(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=QH(me,De==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):$e=pR(me);const gt=this.stack[this.stack.length-1];gt.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 Yt(){return{type:"blockquote",children:[]}}function Xt(){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 ei(){return{type:"emphasis",children:[]}}function _o(){return{type:"heading",depth:0,children:[]}}function is(){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 Os(oe){return{type:"list",ordered:oe.type==="listOrdered",start:null,spread:oe._spread,children:[]}}function Ps(oe){return{type:"listItem",spread:oe._spread,checked:null,children:[]}}function Bc(){return{type:"paragraph",children:[]}}function Tl(){return{type:"strong",children:[]}}function Ri(){return{type:"text",value:""}}function aa(){return{type:"thematicBreak"}}}function Ga(t){return{line:t.line,column:t.column,offset:t.offset}}function NW(t,e){let n=-1;for(;++n<e.length;){const r=e[n];Array.isArray(r)?NW(t,r):l_e(t,r)}}function l_e(t,e){let n;for(n in e)if(LW.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 v$(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 c_e(t){const e=this;e.parser=n;function n(r){return o_e(r,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function u_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 h_e(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:`
|
||
`}]}function f_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 d_e(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function p_e(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function m_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 g_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 y_e(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}}function $W(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 b_e(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return $W(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 v_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 x_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 w_e(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return $W(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 S_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 __e(t,e,n){const r=t.all(e),i=n?C_e(n):jW(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 C_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=jW(n[r])}return e}function jW(t){const e=t.spread;return e??t.children.length>1}function A_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 E_e(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function k_e(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)}function T_e(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function R_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=bR(e.children[1]),c=EW(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 M_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 O_e(t,e){const n={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}const x$=9,w$=32;function P_e(t){const e=String(t),n=/\r?\n|\r/g;let r=n.exec(e),i=0;const s=[];for(;r;)s.push(S$(e.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(e);return s.push(S$(e.slice(i),i>0,!1)),s.join("")}function S$(t,e,n){let r=0,i=t.length;if(e){let s=t.codePointAt(r);for(;s===x$||s===w$;)r++,s=t.codePointAt(r)}if(n){let s=t.codePointAt(i-1);for(;s===x$||s===w$;)i--,s=t.codePointAt(i-1)}return i>r?t.slice(r,i):""}function D_e(t,e){const n={type:"text",value:P_e(String(e.value))};return t.patch(e,n),t.applyData(e,n)}function I_e(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)}const L_e={blockquote:u_e,break:h_e,code:f_e,delete:d_e,emphasis:p_e,footnoteReference:m_e,heading:g_e,html:y_e,imageReference:b_e,image:v_e,inlineCode:x_e,linkReference:w_e,link:S_e,listItem:__e,list:A_e,paragraph:E_e,root:k_e,strong:T_e,table:R_e,tableCell:O_e,tableRow:M_e,text:D_e,thematicBreak:I_e,toml:Gy,yaml:Gy,definition:Gy,footnoteDefinition:Gy};function Gy(){}const BW=-1,Sw=0,jp=1,Zv=2,SR=3,_R=4,CR=5,AR=6,FW=7,zW=8,_$=typeof self=="object"?self:globalThis,N_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 Sw:case BW:return n(o,i);case jp:{const a=n([],i);for(const c of o)a.push(r(c));return a}case Zv:{const a=n({},i);for(const[c,h]of o)a[r(c)]=r(h);return a}case SR:return n(new Date(o),i);case _R:{const{source:a,flags:c}=o;return n(new RegExp(a,c),i)}case CR:{const a=n(new Map,i);for(const[c,h]of o)a.set(r(c),r(h));return a}case AR:{const a=n(new Set,i);for(const c of o)a.add(r(c));return a}case FW:{const{name:a,message:c}=o;return n(new _$[a](c),i)}case zW: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 _$[s](o),i)};return r},C$=t=>N_e(new Map,t)(0),Vu="",{toString:$_e}={},{keys:j_e}=Object,Fd=t=>{const e=typeof t;if(e!=="object"||!t)return[Sw,e];const n=$_e.call(t).slice(8,-1);switch(n){case"Array":return[jp,Vu];case"Object":return[Zv,Vu];case"Date":return[SR,Vu];case"RegExp":return[_R,Vu];case"Map":return[CR,Vu];case"Set":return[AR,Vu];case"DataView":return[jp,n]}return n.includes("Array")?[jp,n]:n.includes("Error")?[FW,n]:[Zv,n]},Ky=([t,e])=>t===Sw&&(e==="function"||e==="symbol"),B_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 Sw:{let f=o;switch(c){case"bigint":a=zW,f=o.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+c);f=null;break;case"undefined":return i([BW],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 Zv:{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 j_e(o))(t||!Ky(Fd(o[m])))&&f.push([s(m),s(o[m])]);return d}case SR:return i([a,o.toISOString()],o);case _R:{const{source:f,flags:d}=o;return i([a,{source:f,flags:d}],o)}case CR:{const f=[],d=i([a,f],o);for(const[m,y]of o)(t||!(Ky(Fd(m))||Ky(Fd(y))))&&f.push([s(m),s(y)]);return d}case AR:{const f=[],d=i([a,f],o);for(const m of o)(t||!Ky(Fd(m)))&&f.push(s(m));return d}}const{message:h}=o;return i([a,{name:c,message:h}],o)};return s},A$=(t,{json:e,lossy:n}={})=>{const r=[];return B_e(!(e||n),!!e,new Map,r)(t),r},ex=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?C$(A$(t,e)):structuredClone(t):(t,e)=>C$(A$(t,e));function F_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 z_e(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function V_e(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=t.options.footnoteBackContent||F_e,r=t.options.footnoteBackLabel||z_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:{...ex(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 uE={}.hasOwnProperty,U_e={};function H_e(t,e){const n=e||U_e,r=new Map,i=new Map,s=new Map,o={...L_e,...n.handlers},a={all:h,applyData:q_e,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:c,options:n,patch:W_e,wrap:K_e};return hR(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(uE.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,_=ex(S);return _.children=a.all(f),_}return ex(f)}return(a.options.unknownHandler||G_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=E$(b.value)),!Array.isArray(b)&&b.type==="element")){const x=b.children[0];x&&x.type==="text"&&(x.value=E$(x.value))}Array.isArray(b)?d.push(...b):d.push(b)}}}return d}}function W_e(t,e){t.position&&(e.position=dSe(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,ex(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function G_e(t,e){const n=e.data||{},r="value"in e&&!(uE.call(n,"hProperties")||uE.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 K_e(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 E$(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function k$(t,e){const n=H_e(t,e),r=n.one(t,void 0),i=V_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 Y_e(t,e){return t&&"run"in t?async function(n,r){const i=k$(n,{file:r,...e});await t.run(i,r)}:function(n,r){return k$(n,{file:r,...t||e})}}function T$(t){if(t)throw t}var x2,R$;function X_e(){if(R$)return x2;R$=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 x2=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},x2}var J_e=X_e();const w2=Pc(J_e);function hE(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 Q_e(){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?Z_e(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 Z_e(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 Xs={basename:e2e,dirname:t2e,extname:n2e,join:r2e,sep:"/"};function e2e(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');sg(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 t2e(t){if(sg(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 n2e(t){sg(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 r2e(...t){let e=-1,n;for(;++e<t.length;)sg(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":i2e(n)}function i2e(t){sg(t);const e=t.codePointAt(0)===47;let n=s2e(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function s2e(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 sg(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const o2e={cwd:a2e};function a2e(){return"/"}function fE(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function l2e(t){if(typeof t=="string")t=new URL(t);else if(!fE(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 c2e(t)}function c2e(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 S2=["history","path","basename","stem","extname","dirname"];class VW{constructor(e){let n;e?fE(e)?n={path:e}:typeof e=="string"||u2e(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":o2e.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<S2.length;){const s=S2[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)S2.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Xs.basename(this.path):void 0}set basename(e){C2(e,"basename"),_2(e,"basename"),this.path=Xs.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Xs.dirname(this.path):void 0}set dirname(e){M$(this.basename,"dirname"),this.path=Xs.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Xs.extname(this.path):void 0}set extname(e){if(_2(e,"extname"),M$(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=Xs.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){fE(e)&&(e=l2e(e)),C2(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Xs.basename(this.path,this.extname):void 0}set stem(e){C2(e,"stem"),_2(e,"stem"),this.path=Xs.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 _2(t,e){if(t&&t.includes(Xs.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Xs.sep+"`")}function C2(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function M$(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function u2e(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const h2e=(function(t){const r=this.constructor.prototype,i=r[t],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),f2e={}.hasOwnProperty;class ER extends h2e{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=Q_e()}copy(){const e=new ER;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];e.use(...r)}return e.data(w2(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(k2("data",this.frozen),this.namespace[e]=n,this):f2e.call(this.namespace,e)&&this.namespace[e]||void 0:e?(k2("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=Yy(e),r=this.parser||this.Parser;return A2("parse",r),r(String(n),n)}process(e,n){const r=this;return this.freeze(),A2("process",this.parser||this.Parser),E2("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const a=Yy(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);m2e(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(),A2("processSync",this.parser||this.Parser),E2("processSync",this.compiler||this.Compiler),this.process(e,i),P$("processSync","process",n),r;function i(s,o){n=!0,T$(s),r=o}}run(e,n,r){O$(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=Yy(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),P$("runSync","run",r),i;function s(o,a){T$(o),i=a,r=!0}}stringify(e,n){this.freeze();const r=Yy(n),i=this.compiler||this.Compiler;return E2("stringify",i),O$(e),i(e,r)}use(e,...n){const r=this.attachers,i=this.namespace;if(k2("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=w2(!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];hE(x)&&hE(y)&&(y=w2(!0,x,y)),r[m]=[h,y,...b]}}}}const d2e=new ER().freeze();function A2(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function E2(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function k2(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 O$(t){if(!hE(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function P$(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Yy(t){return p2e(t)?t:new VW(t)}function p2e(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function m2e(t){return typeof t=="string"||g2e(t)}function g2e(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const y2e="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",D$=[],I$={allowDangerousHtml:!0},b2e=/^(https?|ircs?|mailto|xmpp)$/i,v2e=[{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 x2e(t){const e=w2e(t),n=S2e(t);return _2e(e.runSync(e.parse(n),n),t)}function w2e(t){const e=t.rehypePlugins||D$,n=t.remarkPlugins||D$,r=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...I$}:I$;return d2e().use(c_e).use(n).use(Y_e,r).use(e)}function S2e(t){const e=t.children||"",n=new VW;return typeof e=="string"&&(n.value=e),n}function _2e(t,e){const n=e.allowedElements,r=e.allowElement,i=e.components,s=e.disallowedElements,o=e.skipHtml,a=e.unwrapDisallowed,c=e.urlTransform||C2e;for(const f of v2e)Object.hasOwn(e,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+y2e+f.id,void 0);return hR(t,h),RW(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 v2)if(Object.hasOwn(v2,y)&&Object.hasOwn(f.properties,y)){const b=f.properties[y],x=v2[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 C2e(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||b2e.test(t.slice(0,e))?t:""}var A2e=(t,e)=>typeof t=="string"?t===e:JSON.stringify(t)===JSON.stringify(e),E2e=(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))&&A2e(t.children,e.children)},kR=(t,e)=>E2e(t.node,e.node),k2e=(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,kR)]})),TR=k.createContext(null),UW=()=>k.useContext(TR)!==null,T2e=({children:t,...e})=>C.jsx(TR.Provider,{value:e,children:t}),R2e=k.memo(T2e,kR),M2e=({node:t,...e})=>C.jsx("pre",{...e}),O2e=({node:t,...e})=>C.jsx("code",{...e}),RR=({node:t,components:{Pre:e,Code:n},code:r})=>C.jsx(e,{children:C.jsx(n,{node:t,children:r})}),P2e=()=>null,D2e=({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:RR;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})]})},T2={exports:{}};/*!
|
||
Copyright (c) 2018 Jed Watson.
|
||
Licensed under the MIT License (MIT), see
|
||
http://jedwatson.github.io/classnames
|
||
*/var L$;function I2e(){return L$||(L$=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})()})(T2)),T2.exports}var L2e=I2e();const HW=Pc(L2e);var N$=({className:t,...e})=>({className:n,...r})=>({className:HW(t,n),...e,...r}),N2e=({node:t,components:{Pre:e,Code:n,SyntaxHighlighter:r,CodeHeader:i},componentsByLanguage:s={},children:o,...a})=>{const c=k.useContext(TR),h=N$(c),f=Lr(S=>C.jsx(e,{...h(S)})),d=N$(a),m=Lr(S=>C.jsx(n,{...d(S)})),y=/language-(\w+)/.exec(a.className||"")?.[1]??"";if(typeof o!="string")return C.jsx(RR,{node:t,components:{Pre:f,Code:m},code:o});const b=s[y]?.SyntaxHighlighter??r,x=s[y]?.CodeHeader??i;return C.jsx(D2e,{node:t,components:{Pre:f,Code:m,SyntaxHighlighter:b,CodeHeader:x},language:y||"unknown",code:o})},$2e=({node:t,components:e,componentsByLanguage:n,...r})=>UW()?C.jsx(N2e,{node:t,components:e,componentsByLanguage:n,...r}):C.jsx(e.Code,{...r}),j2e=k.memo($2e,(t,e)=>t.components===e.components&&t.componentsByLanguage===e.componentsByLanguage&&kR(t,e)),{useSmooth:B2e,useSmoothStatus:F2e,withSmoothContextProvider:z2e}=HX,V2e=({components:t,componentsByLanguage:e,smooth:n=!0,preprocess:r,...i})=>{const s=Yj(),o=k.useMemo(()=>r?{...s,text:r(s.text)}:s,[s,r]),{text:a}=B2e(o,n),{pre:c=M2e,code:h=O2e,SyntaxHighlighter:f=RR,CodeHeader:d=P2e}=t??{},m=k.useMemo(()=>({Pre:c,Code:h,SyntaxHighlighter:f,CodeHeader:d}),[c,h,f,d]),y=Lr(x=>C.jsx(j2e,{components:m,componentsByLanguage:e,...x})),b=k.useMemo(()=>{const{pre:x,code:S,SyntaxHighlighter:_,CodeHeader:A,...E}=t??{};return{...E,pre:R2e,code:y}},[y,t]);return C.jsx(x2e,{components:b,...i,children:a})},WW=k.forwardRef(({className:t,containerProps:e,containerComponent:n="div",...r},i)=>{const s=F2e();return C.jsx(n,{"data-status":s.type,...e,className:HW(t,e?.className),ref:i,children:C.jsx(V2e,{...r})})});WW.displayName="MarkdownTextPrimitive";var U2e=z2e(WW),$$=Object.prototype.hasOwnProperty;function j$(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=j$(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=j$(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($$.call(t,n)&&++r&&!$$.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 R2=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])},H2e=(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)},qW=(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 W2e(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 B$={light:"github-light",dark:"github-dark"},G2e=(t,e,n,r,i={})=>{const[s,o]=k.useState(null),[a,c]=R2(e),[h,f]=R2(n),[d,m]=R2(i),{languageId:y,langsToLoad:b}=k.useMemo(()=>qW(a,d.customLanguages,d.langAlias),[a,d.customLanguages,d.langAlias]),{isMultiTheme:x,themeId:S,multiTheme:_,singleTheme:A,themesToLoad:E}=k.useMemo(()=>W2e(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:_||B$,defaultColor:D,cssVariablePrefix:N}:{theme:A||B$.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):RW(H.codeToHast(t,q),{jsx:C.jsx,jsxs:C.jsxs,Fragment:C.Fragment});o(X)}},{delay:N}=d;return N?H2e(D,P,N):D().catch(console.error),()=>{M=!1,clearTimeout(P.current.timeoutId)}},[t,O,d.delay,d.highlighter,b,E]),s};function K2e(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))}K2e(`.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 Y2e=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}=qW(e,_),M=t(x,e,n,P),D=typeof M=="string";return C.jsxs(S,{ref:E,"data-testid":"shiki-container",className:pv("relative","not-prose",a&&"defaultStyles",f),style:c,id:"shiki-container",children:[m&&O?C.jsx("span",{className:pv("languageLabel",d),style:h,id:"language-label",children:O}):null,D?C.jsx("div",{dangerouslySetInnerHTML:{__html:M}}):M]})});const X2e="modulepreload",J2e=function(t){return"/"+t},F$={},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=J2e(f),f in F$)return;F$[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":X2e,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 Q2e(t){return MR(t)}function MR(t){return Array.isArray(t)?Z2e(t):t instanceof RegExp?t:typeof t=="object"?eCe(t):t}function Z2e(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=MR(t[n]);return e}function eCe(t){let e={};for(let n in t)e[n]=MR(t[n]);return e}function GW(t,...e){return e.forEach(n=>{for(let r in n)t[r]=n[r]}),t}function KW(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?KW(t.substring(0,t.length-1)):t.substr(~e+1)}var M2=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Xy=class{static hasCaptures(t){return t===null?!1:(M2.lastIndex=0,M2.test(t))}static replaceCaptures(t,e,n){return t.replace(M2,(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 YW(t,e){return t<e?-1:t>e?1:0}function XW(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=YW(t[i],e[i]);if(s!==0)return s}return 0}return n-r}function z$(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 JW(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var QW=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}},tx=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(rCe(t),e)}static createFromParsedTheme(t,e){return sCe(t,e)}_cachedMatchRoot=new QW(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=>tCe(t.parent,i.parentScopes));return r?new ZW(r.fontStyle,r.foreground,r.background):null}},O2=class Ub{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const r of n)e=new Ub(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new Ub(n,e[r]);return n}push(e){return new Ub(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 tCe(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&&!nCe(t.scopeName,r);){if(i)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function nCe(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var ZW=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function rCe(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"&&z$(o.settings.foreground)&&(h=o.settings.foreground);let f=null;typeof o.settings.background=="string"&&z$(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 iCe(x,S,i,c,h,f)}}return n}var iCe=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 sCe(t,e){t.sort((c,h)=>{let f=YW(c.scope,h.scope);return f!==0||(f=XW(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 oCe(e),o=new ZW(n,s.getId(r),s.getId(i)),a=new lCe(new dE(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 tx(s,o,a)}var oCe=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)}},aCe=Object.freeze([]),dE=class eq{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,i,s){this.scopeDepth=e,this.parentScopes=n||aCe,this.fontStyle=r,this.foreground=i,this.background=s}clone(){return new eq(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)}},lCe=class pE{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(pE._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 pE(this._mainRule.clone(),dE.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(XW(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 dE(e,n,r,i,s))}},Uh=class Vi{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=Vi.getLanguageId(e),r=Vi.getTokenType(e),i=Vi.getFontStyle(e),s=Vi.getForeground(e),o=Vi.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=Vi.getLanguageId(e),h=Vi.getTokenType(e),f=Vi.containsBalancedBrackets(e)?1:0,d=Vi.getFontStyle(e),m=Vi.getForeground(e),y=Vi.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 nx(t,e){const n=[],r=cCe(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(V$(i)){const c=[];do c.push(i),i=r.next();while(V$(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 V$(t){return!!t&&!!t.match(/[\w\.:]+/)}function cCe(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 tq(t){typeof t.dispose=="function"&&t.dispose()}var km=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},uCe=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},hCe=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))}},fCe=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 hCe;for(const n of t)dCe(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 dCe(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?Hb({baseGrammar:s,selfGrammar:i},r):mE(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 mE(t,e,n){if(e.repository&&e.repository[t]){const r=e.repository[t];rx([r],e,n)}}function Hb(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&rx(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&rx(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function rx(t,e,n){for(const r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const i=r.repository?GW({},e.repository,r.repository):e.repository;Array.isArray(r.patterns)&&rx(r.patterns,{...e,repository:i},n);const s=r.include;if(!s)continue;const o=nq(s);switch(o.kind){case 0:Hb({...e,selfGrammar:e.baseGrammar},n);break;case 1:Hb(e,n);break;case 2:mE(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?mE(o.ruleName,c,n):Hb(c,n)}else o.kind===4?n.add(new uCe(o.scopeName,o.ruleName)):n.add(new km(o.scopeName));break}}}var pCe=class{kind=0},mCe=class{kind=1},gCe=class{constructor(t){this.ruleName=t}kind=2},yCe=class{constructor(t){this.scopeName=t}kind=3},bCe=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function nq(t){if(t==="$base")return new pCe;if(t==="$self")return new mCe;const e=t.indexOf("#");if(e===-1)return new yCe(t);if(e===0)return new gCe(t.substring(1));{const n=t.substring(0,e),r=t.substring(e+1);return new bCe(n,r)}}var vCe=/\\(\d+)/,U$=/\\(\d+)/g,xCe=-1,rq=-2;var og=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=Xy.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Xy.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${KW(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:Xy.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Xy.replaceCaptures(this._contentName,t,e)}},wCe=class extends og{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!")}},SCe=class extends og{_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}},H$=class extends og{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}},gE=class extends og{_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}},ix=class extends og{_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,rq),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}},iq=class ur{static createCaptureRule(e,n,r,i,s){return e.registerRule(o=>new wCe(n,o,r,i,s))}static getCompiledRuleId(e,n,r){return e.id||n.registerRule(i=>{if(e.id=i,e.match)return new SCe(e.$vscodeTextmateLocation,e.id,e.name,e.match,ur._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){e.repository&&(r=GW({},r,e.repository));let s=e.patterns;return typeof s>"u"&&e.include&&(s=[{include:e.include}]),new H$(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,ur._compilePatterns(s,n,r))}return e.while?new ix(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 gE(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=nq(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 H$||h instanceof gE||h instanceof ix)&&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 sq{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=vCe.test(this.source):this.hasBackReferences=!1}clone(){return new sq(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 U$.lastIndex=0,this.source.replace(U$,(i,s)=>JW(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 W$(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 W$(t,r,this._items.map(i=>i.ruleId))}},W$=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}},P2=class{constructor(t,e){this.languageId=t,this.tokenType=e}},_Ce=class yE{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,n){this._defaultAttributes=new P2(e,8),this._embeddedLanguagesMatcher=new CCe(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?yE._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new P2(0,0);_getBasicScopeAttributes=new QW(e=>{const n=this._scopeToLanguage(e),r=this._toStandardTokenType(e);return new P2(n,r)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const n=e.match(yE.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/},CCe=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])=>JW(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])}},q$=class{constructor(t,e){this.stack=t,this.stoppedEarly=e}};function oq(t,e,n,r,i,s,o,a){const c=e.content.length;let h=!1,f=-1;if(o){const y=ACe(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 q$(i,!0);m()}return new q$(i,!1);function m(){const y=ECe(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===xCe){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 gE){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 ix){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 ACe(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 ix&&a.push({rule:h,stack:c})}for(let c=a.pop();c;c=a.pop()){const{ruleScanner:h,findOptions:f}=RCe(c.rule,t,c.stack.endRule,n,r===o),d=h.findNextMatchSync(e,r,f);if(d){if(d.ruleId!==rq){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 ECe(t,e,n,r,i,s){const o=kCe(t,e,n,r,i,s),a=t.getInjections();if(a.length===0)return o;const c=TCe(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 kCe(t,e,n,r,i,s){const o=i.getRule(t),{ruleScanner:a,findOptions:c}=aq(o,t,i.endRule,n,r===s),h=a.findNextMatchSync(e,r,c);return h?{captureIndices:h.captureIndices,matchedRuleId:h.ruleId}:null}function TCe(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:_}=aq(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 aq(t,e,n,r,i){return{ruleScanner:t.compileAG(e,n,r,i),findOptions:0}}function RCe(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));oq(t,P,n&&y.start===0,y.start,E,i,!1,0),tq(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 MCe(S,y.end))}}for(;h.length>0;)i.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop()}var MCe=class{scopes;endPos;constructor(t,e){this.scopes=t,this.endPos=e}};function OCe(t,e,n,r,i,s,o,a){return new DCe(t,e,n,r,i,s,o,a)}function G$(t,e,n,r,i){const s=nx(e,sx),o=iq.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 sx(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(PCe(e[i],r))return n=i+1,!0;return!1})}function PCe(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 DCe=class{constructor(t,e,n,r,i,s,o,a){if(this._rootScopeName=t,this.balancedBracketSelectors=s,this._onigLib=a,this._basicScopeAttributesProvider=new _Ce(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=K$(e,null),this._injections=null,this._tokenTypeMatchers=[],i)for(const c of Object.keys(i)){const h=nx(c,sx);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)G$(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&&G$(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]=K$(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=iq.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!e||e===bE.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 bE(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 LCe(n,t,this._tokenTypeMatchers,this.balancedBracketSelectors),c=oq(this,s,i,0,e,a,!0,r);return tq(s),{lineLength:o,lineTokens:a,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function K$(t,e){return t=Q2e(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 Ks{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=O2.push(i,s.scopeNames),r=new Ks(r,i,s.encodedTokenAttributes);return r}static createRoot(e,n){return new Ks(null,new O2(null,e),n)}static createRootAndLookUpScopeName(e,n,r){const i=r.getMetadataForScope(e),s=new O2(null,e),o=r.themeProvider.themeMatch(s),a=Ks.mergeAttributes(n,i,o);return new Ks(null,s,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return Ks.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 Ks._pushAttributed(this,e,n);const r=e.split(/ /g);let i=this;for(const s of r)i=Ks._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=Ks.mergeAttributes(e.tokenAttributes,i,o);return new Ks(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}},bE=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))}},ICe=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(t,e){this.balancedBracketScopes=t.flatMap(n=>n==="*"?(this.allowAny=!0,[]):nx(n,sx).map(r=>r.matcher)),this.unbalancedBracketScopes=e.flatMap(n=>nx(n,sx).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}},LCe=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}},NCe=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,OCe(t,s,e,n,r,i,this,this._onigLib))}return this._grammars.get(t)}},$Ce=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new NCe(tx.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,n){this._syncRegistry.setTheme(tx.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 ICe(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,n,r,i,s){const o=new fCe(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)}},vE=bE.NULL;const jCe=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],BCe=/["&'<>`]/g,FCe=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,zCe=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,VCe=/[|\\{}()[\]^$+*?.]/g,Y$=new WeakMap;function UCe(t,e){if(t=t.replace(e.subset?HCe(e.subset):BCe,r),e.subset||e.escapeOnly)return t;return t.replace(FCe,n).replace(zCe,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 HCe(t){let e=Y$.get(t);return e||(e=WCe(t),Y$.set(t,e)),e}function WCe(t){const e=[];let n=-1;for(;++n<t.length;)e.push(t[n].replace(VCe,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const qCe=/[\dA-Fa-f]/;function GCe(t,e,n){const r="&#x"+t.toString(16).toUpperCase();return n&&e&&!qCe.test(String.fromCharCode(e))?r:r+";"}const KCe=/\d/;function YCe(t,e,n){const r="&#"+String(t);return n&&e&&!KCe.test(String.fromCharCode(e))?r:r+";"}const XCe=["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"],D2={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:"€"},JCe=["cent","copy","divide","gt","lt","not","para","times"],lq={}.hasOwnProperty,xE={};let Jy;for(Jy in D2)lq.call(D2,Jy)&&(xE[D2[Jy]]=Jy);const QCe=/[^\dA-Za-z]/;function ZCe(t,e,n,r){const i=String.fromCharCode(t);if(lq.call(xE,i)){const s=xE[i],o="&"+s;return n&&XCe.includes(s)&&!JCe.includes(s)&&(!r||e&&e!==61&&QCe.test(String.fromCharCode(e)))?o:o+";"}return""}function eAe(t,e,n){let r=GCe(t,e,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=ZCe(t,e,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){const s=YCe(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 UCe(t,Object.assign({format:eAe},e))}const tAe=/^>|^->|<!--|-->|--!>|<!-$/g,nAe=[">"],rAe=["<",">"];function iAe(t,e,n,r){return r.settings.bogusComments?"<?"+kh(t.value,Object.assign({},r.settings.characterReferences,{subset:nAe}))+">":"<!--"+t.value.replace(tAe,i)+"-->";function i(s){return kh(s,Object.assign({},r.settings.characterReferences,{subset:rAe}))}}function sAe(t,e,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}const Rn=uq(1),cq=uq(-1),oAe=[];function uq(t){return e;function e(n,r,i){const s=n?n.children:oAe;let o=(r||0)+t,a=s[o];if(!i)for(;a&&ww(a);)o+=t,a=s[o];return a}}const aAe={}.hasOwnProperty;function hq(t){return e;function e(n,r,i){return aAe.call(t,n.tagName)&&t[n.tagName](n,r,i)}}const OR=hq({body:cAe,caption:I2,colgroup:I2,dd:dAe,dt:fAe,head:I2,html:lAe,li:hAe,optgroup:pAe,option:mAe,p:uAe,rp:X$,rt:X$,tbody:yAe,td:J$,tfoot:bAe,th:J$,thead:gAe,tr:vAe});function I2(t,e,n){const r=Rn(n,e,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&ww(r.value.charAt(0)))}function lAe(t,e,n){const r=Rn(n,e);return!r||r.type!=="comment"}function cAe(t,e,n){const r=Rn(n,e);return!r||r.type!=="comment"}function uAe(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 hAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&r.tagName==="li"}function fAe(t,e,n){const r=Rn(n,e);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function dAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function X$(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function pAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&r.tagName==="optgroup"}function mAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function gAe(t,e,n){const r=Rn(n,e);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function yAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function bAe(t,e,n){return!Rn(n,e)}function vAe(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&r.tagName==="tr"}function J$(t,e,n){const r=Rn(n,e);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const xAe=hq({body:_Ae,colgroup:CAe,head:SAe,html:wAe,tbody:AAe});function wAe(t){const e=Rn(t,-1);return!e||e.type!=="comment"}function SAe(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 _Ae(t){const e=Rn(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&ww(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function CAe(t,e,n){const r=cq(n,e),i=Rn(t,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&OR(r,n.children.indexOf(r),n)?!1:!!(i&&i.type==="element"&&i.tagName==="col")}function AAe(t,e,n){const r=cq(n,e),i=Rn(t,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&OR(r,n.children.indexOf(r),n)?!1:!!(i&&i.type==="element"&&i.tagName==="tr")}const Qy={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 EAe(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=ig);const h=kAe(r,t.properties),f=r.all(i.space==="html"&&t.tagName==="template"?t.content:t);return r.schema=i,f&&(o=!1),(h||!s||!xAe(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||!OR(t,e,n))&&a.push("</"+t.tagName+">"),a.join("")}function kAe(t,e){const n=[];let r=-1,i;if(e){for(i in e)if(e[i]!==null&&e[i]!==void 0){const s=TAe(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 TAe(t,e,n){const r=_W(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:Qy.name[i][s]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?mW:AW)(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:Qy.unquoted[i][s]}))),a!==n&&(t.settings.quoteSmart&&Xv(n,o)>Xv(n,t.alternative)&&(o=t.alternative),a=o+kh(n,Object.assign({},t.settings.characterReferences,{subset:(o==="'"?Qy.single:Qy.double)[i][s],attribute:!0}))+o),c+(a&&"="+a))}const RAe=["<","&"];function fq(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:RAe}))}function MAe(t,e,n,r){return r.settings.allowDangerousHtml?t.value:fq(t,e,n,r)}function OAe(t,e,n,r){return r.all(t)}const PAe=txe("type",{invalid:DAe,unknown:IAe,handlers:{comment:iAe,doctype:sAe,element:EAe,raw:MAe,root:OAe,text:fq}});function DAe(t){throw new Error("Expected node, not `"+t+"`")}function IAe(t){const e=t;throw new Error("Cannot compile unknown node `"+e.type+"`")}const LAe={},NAe={},$Ae=[];function jAe(t,e){const n=e||LAe,r=n.quote||'"',i=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:BAe,all:FAe,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||jCe,characterReferences:n.characterReferences||NAe,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?ig:CW,quote:r,alternative:i}.one(Array.isArray(t)?{type:"root",children:t}:t,void 0,void 0)}function BAe(t,e,n){return PAe(t,e,n,this)}function FAe(t){const e=[],n=t&&t.children||$Ae;let r=-1;for(;++r<n.length;)e[r]=this.one(n[r],r,t);return e.join("")}function ox(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 zAe(t){return Array.isArray(t)?t:[t]}async function dq(t){return Promise.resolve(typeof t=="function"?t():t).then(e=>e.default||e)}function PR(t){return!t||["plaintext","txt","text","plain"].includes(t)}function pq(t){return t==="ansi"||PR(t)}function DR(t){return t==="none"}function mq(t){return DR(t)}function gq(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 _w(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 VAe(t){const e=_w(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 UAe(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 IR="light-dark()",HAe=["color","background-color"];function WAe(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?WAe(i,s):i})):t}function GAe(t,e,n,r,i="css-vars"){const s={content:t.content,explanation:t.explanation,offset:t.offset},o=e.map(f=>ax(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&&HAe.includes(m))if(r===IR&&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 ax(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 wE(t){return typeof t=="string"?t:Object.entries(t).map(([e,n])=>`${e}:${n}`).join(";")}const yq=new WeakMap;function Cw(t,e){yq.set(t,e)}function Mm(t){return yq.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(zAe(n).map(r=>[r,vE])),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 KAe(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function KAe(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 YAe(t,e){if(!(t instanceof af))throw new pn("Invalid grammar state");return t.getInternalStack(e)}function XAe(){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=VAe(n.source),s=(n.options.decorations||[]).map(o=>({...o,start:r(o.start),end:r(o.end)}));JAe(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+=bq(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&&gq(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 JAe(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 bq(t){return t.type==="text"?t.value:t.type==="element"?t.children.map(bq).join(""):""}const QAe=[XAe()];function lx(t){const e=ZAe(t.transformers||[]);return[...e.pre,...e.normal,...e.post,...QAe]}function ZAe(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"],L2={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function eEe(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 Q$(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 tEe(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)L2[r]&&e.push({type:"setDecoration",value:L2[r]});else if(r<=29){const i=L2[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=Q$(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=Q$(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 nEe(){let t=null,e=null,n=new Set;return{parse(r){const i=[];let s=0;do{const o=eEe(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=tEe(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 rEe={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 iEe(t=rEe){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 sEe(t,e,n){const r=ox(t,n),i=_w(e),s=iEe(Object.fromEntries(mc.map(a=>[a,t.colors?.[`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`]]))),o=nEe();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=oEe(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 oEe(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 LR(t,e,n={}){const{lang:r="text",theme:i=t.getLoadedThemes()[0]}=n;if(PR(r)||DR(i))return _w(e).map(c=>[{content:c[0],offset:c[1]}]);const{theme:s,colorMap:o}=t.setTheme(i);if(r==="ansi")return sEe(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 lEe(e,a,s,o,n)}function aEe(...t){if(t.length===2)return Mm(t[1]);const[e,n,r={}]=t,{lang:i="text",theme:s=e.getLoadedThemes()[0]}=r;if(PR(i)||DR(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(cx(n,c,o,a,r).stateStack,c.name,o.name)}function lEe(t,e,n,r,i){const s=cx(t,e,n,r,i),o=new af(cx(t,e,n,r,i).stateStack,e.name,n.name);return Cw(s.tokens,o),s.tokens}function cx(t,e,n,r,i){const s=ox(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:a=500}=i,c=_w(t);let h=i.grammarState?YAe(i.grammarState,n.name)??vE:i.grammarContextCode!=null?cx(i.grammarContextCode,e,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack:vE,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"?cEe(Y.scopes):uEe(q,Y.scopes)}),A+=1}}f.push(V)}d.push(f),f=[],h=E.ruleStack}return{tokens:d,stateStack:h}}function cEe(t){return t.map(e=>({scopeName:e}))}function uEe(t,e){const n=[];for(let r=0,i=e.length;r<i;r++){const s=e[r];n[r]={scopeName:s,themeMatches:fEe(t,s,e.slice(0,r))}}return n}function Z$(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function hEe(t,e,n){if(!Z$(t[t.length-1],e))return!1;let r=t.length-2,i=n.length-1;for(;r>=0&&i>=0;)Z$(t[r],n[i])&&(r-=1),i-=1;return r===-1}function fEe(t,e,n){const r=[];for(const{selectors:i,settings:s}of t)for(const o of i)if(hEe(o,e,n)){r.push(s);break}return r}function vq(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=LR(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=dEe(...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&&Cw(o,a),o}function dEe(...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 ux(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=vq(t,e,n);if(c=Mm(y),h&&IR!==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=>GAe(A,x,f,h,d))),c&&Cw(s,c);const S=m.map(_=>ox(_.theme,n));i=e5(m,b,S,f,h,"fg",d),r=e5(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=ox(n.theme,n);s=LR(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 e5(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===IR&&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 hx(t,e,n,r={meta:{},options:n,codeToHast:(i,s)=>hx(t,i,s),codeToTokens:(i,s)=>ux(t,i,s)}){let i=e;for(const b of lx(n))i=b.preprocess?.call(r,i,n)||i;let{tokens:s,fg:o,bg:a,themeName:c,rootStyle:h,grammarState:f}=ux(t,i,n);const{mergeWhitespaces:d=!0,mergeSameStyleTokens:m=!1}=n;d===!0?s=mEe(s):d==="never"&&(s=gEe(s)),m&&(s=yEe(s));const y={...r,get source(){return i}};for(const b of lx(n))s=b.tokens?.call(y,s)||s;return pEe(s,{...n,fg:o,bg:a,themeName:c,rootStyle:h},y,f)}function pEe(t,e,n,r=Mm(t)){const i=lx(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:gq,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=wE(A.htmlStyle||ax(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&&Cw(y,r),y}function mEe(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 gEe(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 yEe(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=wE(i.htmlStyle||ax(i)),o=wE(r.htmlStyle||ax(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 bEe=jAe;function vEe(t,e,n){const r={meta:{},options:n,codeToHast:(s,o)=>hx(t,s,o),codeToTokens:(s,o)=>ux(t,s,o)};let i=bEe(hx(t,e,n,r));for(const s of lx(n))i=s.postprocess?.call(r,i,n)||i;return i}const t5={light:"#333333",dark:"#bbbbbb"},n5={light:"#fffffe",dark:"#1e1e1e"},r5="__shiki_resolved";function NR(t){if(t?.[r5])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"?t5.light:t5.dark),n||(n=e.type==="light"?n5.light:n5.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,r5,{enumerable:!1,writable:!1,value:!0}),e}async function xq(t){return Array.from(new Set((await Promise.all(t.filter(e=>!pq(e)).map(async e=>await dq(e).then(n=>Array.isArray(n)?n:[n])))).flat()))}async function wq(t){return(await Promise.all(t.map(async n=>mq(n)?null:NR(await dq(n))))).filter(n=>!!n)}let xEe=3;function wEe(t,e=3){e>xEe||console.trace(`[SHIKI DEPRECATE]: ${t}`)}let hh=class extends Error{constructor(e){super(e),this.name="ShikiError"}};class SEe extends $Ce{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=NR(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=tx.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 _Ee{_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 CEe(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(NR),i=new _Ee(t.engine,n),s=new SEe(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 xq(A))}function b(...A){S();for(const E of A.flat(1))s.loadTheme(E)}async function x(...A){return S(),b(await wq(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 AEe(t){t.engine||wEe("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[e,n,r]=await Promise.all([wq(t.themes||[]),xq(t.langs||[]),t.engine]);return CEe({...t,themes:e,langs:n,engine:r})}async function EEe(t){const e=await AEe(t);return{getLastGrammarState:(...n)=>aEe(e,...n),codeToTokensBase:(n,r)=>LR(e,n,r),codeToTokensWithThemes:(n,r)=>vq(e,n,r),codeToTokens:(n,r)=>ux(e,n,r),codeToHast:(n,r)=>hx(e,n,r),codeToHtml:(n,r)=>vEe(e,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...e,getInternalContext:()=>e}}function kEe(t){const e=t.langs,n=t.themes,r=t.engine;async function i(s){function o(d){if(typeof d=="string"){if(pq(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(mq(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 EEe({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 TEe(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 REe(t,e){const n=TEe(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 Sq=[{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"),[]))}],MEe=Object.fromEntries(Sq.map(t=>[t.id,t.import])),OEe=Object.fromEntries(Sq.flatMap(t=>t.aliases?.map(e=>[e,t.import])||[])),PEe={...MEe,...OEe},DEe=[{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"),[]))}],IEe=Object.fromEntries(DEe.map(t=>[t.id,t.import]));class $R extends Error{constructor(e){super(e),this.name="ShikiError"}}function LEe(){return 2147483648}function NEe(){return typeof performance<"u"?performance.now():Date.now()}const $Ee=(t,e)=>t+(e-t%e)%e;async function jEe(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=LEe();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,$Ee(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:NEe,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 BEe=Object.defineProperty,FEe=(t,e,n)=>e in t?BEe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,An=(t,e,n)=>FEe(t,typeof e!="symbol"?e+"":e,n);let Nn=null;function zEe(t){throw new $R(t.UTF8ToString(t.getLastOnigError()))}class Aw{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=Aw._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 Ew=class Ys{constructor(e){if(An(this,"id",++Ys.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 $R("Must invoke loadWasm first.");this._onigBinding=Nn,this.content=e;const n=new Aw(e);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!Ys._sharedPtrInUse?(Ys._sharedPtr||(Ys._sharedPtr=Nn.omalloc(1e4)),Ys._sharedPtrInUse=!0,Nn.HEAPU8.set(n.utf8Value,Ys._sharedPtr),this.ptr=Ys._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===Ys._sharedPtr?Ys._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};An(Ew,"LAST_ID",0);An(Ew,"_sharedPtr",0);An(Ew,"_sharedPtrInUse",!1);let _q=Ew;class VEe{constructor(e){if(An(this,"_onigBinding"),An(this,"_ptr"),!Nn)throw new $R("Must invoke loadWasm first.");const n=[],r=[];for(let a=0,c=e.length;a<c;a++){const h=new Aw(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&&zEe(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 _q(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 UEe(t){return typeof t.instantiator=="function"}function HEe(t){return typeof t.default=="function"}function WEe(t){return typeof t.data<"u"}function qEe(t){return typeof Response<"u"&&t instanceof Response}function GEe(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 Zy;function KEe(t){if(Zy)return Zy;async function e(){Nn=await jEe(async n=>{let r=t;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),UEe(r)?r=await r.instantiator(n):HEe(r)?r=await r.default(n):(WEe(r)&&(r=r.data),qEe(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await YEe(r)(n):r=await XEe(r)(n):GEe(r)?r=await N2(r)(n):r instanceof WebAssembly.Module?r=await N2(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await N2(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return Zy=e(),Zy}function N2(t){return e=>WebAssembly.instantiate(t,e)}function YEe(t){return e=>WebAssembly.instantiateStreaming(t,e)}function XEe(t){return async e=>{const n=await t.arrayBuffer();return WebAssembly.instantiate(n,e)}}async function JEe(t){return t&&await KEe(t),{createScanner(e){return new VEe(e.map(n=>typeof n=="string"?n:n.source))},createString(e){return new _q(e)}}}const QEe=kEe({langs:PEe,themes:IEe,engine:()=>JEe(B(()=>import("./wasm2.js"),[]))}),{getSingletonHighlighter:i5}=REe(QEe,{guessEmbeddedLanguages:UAe});async function ZEe(t,e){try{return await i5({langs:[t],themes:e})}catch(n){if(n instanceof Error&&n.message.includes("Language"))return await i5({langs:["plaintext"],themes:e});throw n}}var Cq=(t,e,n,r={})=>G2e(t,e,n,ZEe,r),eke=Y2e(Cq),tke=eke;const Aq=({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 Cq(t,e,n)?C.jsx(tke,{...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()})})};Aq.displayName="SyntaxHighlighter";const fx="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 nke=({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)})}}},rke=({language:t,code:e})=>{const{isCopied:n,copyToClipboard:r}=nke(),i=()=>{!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:"Copy",onClick:i,visible:!n,children:[!n&&C.jsx(Gt,{className:"cursor-pointer",src:fx}),n&&C.jsx(Gt,{src:Oh})]})]})},ike=k2e({SyntaxHighlighter:Aq,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=UW();return C.jsx("code",{className:je(!r&&"font-bold italic",e),...n})},CodeHeader:rke}),ske=()=>C.jsx(U2e,{remarkPlugins:[K1e],className:"aui-md",components:ike}),Eq=k.memo(ske),oke=()=>{const e=Q5().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(HE,{asChild:!0,children:C.jsxs(cR.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(DH,{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(WE,{components:{Text:Eq}})})]})})},kq="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",ake="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",lke="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",SE="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",s5="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",Tq=({toolName:t,argsText:e,result:n})=>{const{t:r}=wt(),[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=Zt.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(MT,{size:16}):C.jsx(Gt,{src:ake}),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(Gt,{src:SE,beforeInjection:_}):b?null:C.jsx(Gt,{src:lke,beforeInjection:A}),C.jsx("span",{className:"truncate",children:y?x:b?`${d} | ${x}`:d})]}),b?C.jsx(Gt,{src:s5,beforeInjection:A}):y&&n===void 0?null:C.jsx(Gt,{src:i?Hk:ZF,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(Gt,{src:o?Oh:fx,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(xt,{iconName:SE,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(xt,{iconName:s5,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(Gt,{src:c?Oh:fx,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)})]})})]})]})},cke=()=>C.jsx(Zj,{children:C.jsx(sB,{className:"border border-[var(--chat-message-error-border-color)] rounded-[4px] p-[6px]",children:C.jsx(oB,{className:"text-[var(--chat-message-error-color)] text-[14px] leading-[20px] font-normal"})})}),uke=()=>{const{t}=wt(),{isStreamRunning:e,messages:n}=Yh(),r=Q5();if(r.status?.type==="incomplete"&&r.status?.error)return;const i=()=>{const s=n[Number(r.parentId)],o=S9([s,r]),a=Lie(o);window.AscDesktopEditor.SaveFilenameDialog(`${a}.docx`,c=>{c&&window.AscDesktopEditor.saveAndOpen(o,92,c,65,h=>{h||console.log("Conversion error")})})};return C.jsxs(oj,{hidden:e,className:"col-start-3 row-start-2 ml-3 mt-3 flex gap-[8px]",children:[C.jsx(aj,{asChild:!0,children:C.jsxs(ta,{tooltip:"Copy",children:[C.jsx(K2,{copied:!0,children:C.jsx(xt,{iconName:Oh,size:24,isStroke:!0,disabled:!0})}),C.jsx(K2,{copied:!1,children:C.jsx(xt,{iconName:fx,size:24})})]})}),C.jsx("div",{children:C.jsx(ta,{tooltip:t("Save"),children:C.jsx(xt,{iconName:kq,size:24,onClick:i,isStroke:!0})})})]})},hke=()=>C.jsx(HE,{asChild:!0,children:C.jsxs(cR.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(WE,{components:{Text:Eq,tools:{Fallback:Tq}}}),C.jsx(cke,{})]}),C.jsx(uke,{})]})}),ag=na(t=>({currentModel:null,isInitLoading:!1,initCurrentModel:()=>{try{const e=localStorage.getItem(m_);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(m_,JSON.stringify(e))},deleteSelectedModel:()=>{t({currentModel:null}),localStorage.removeItem(m_),$t.setCurrentProviderModel("")}})),fke="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",dke=()=>{const{servers:t,changeToolStatus:e,webSearchEnabled:n,getWebSearchEnabled:r}=Ts(),[i,s]=k.useState(!1),{t:o}=wt(),a=k.useMemo(()=>C.jsx(ta,{visible:!i,tooltip:o("MCPServers"),children:C.jsx(xt,{iconName:fke,size:24,isActive:i})}),[i,o]),c=k.useMemo(()=>[{text:o("WebSearch"),onClick:()=>{},icon:C.jsx(xt,{iconName:SE,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})},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='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",mke=()=>{const[t,e]=be.useState(!1),{addAttachmentFile:n}=gw(),r=f=>{e(f)},i=(f,d)=>{const m=Eb(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=Eb(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=tE;return A9(f.type)?d=RH:Eb(f.type)?d=MH:_9(f.type)?d=tE:C9(f.type)?d=OH:d=PH,{text:f.path.includes("\\")?f.path.split("\\").pop()??"":f.path.split("/").pop()??"",key:f.path,id:f.path,icon:d?C.jsx(Gt,{src:d}):null,onClick:()=>i(f.path,f.type)}}).filter(Boolean),{t:a}=wt(),c=C.jsx(ta,{tooltip:a("Attachments"),visible:!t,children:C.jsx(xt,{iconName:pke,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})},gke=()=>{const{currentModel:t,selectModel:e}=ag(),{providers:n,providersModels:r,currentProvider:i,setCurrentProvider:s}=ns(),{tools:o}=Ts(),{messages:a}=Yh(),{t:c}=wt(),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(Qx,{placeholder:c("SelectModel"),value:d&&t?.name||"",items:f,withoutBg:!0})},yke="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",bke="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",o5="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]",vke=()=>{const{isStreamRunning:t}=Yh(),{currentModel:e}=ag(),{currentProvider:n}=ns();return t?C.jsx(see,{asChild:!0,children:C.jsx(xt,{iconName:bke,size:24,className:o5})}):C.jsx(Qb,{running:!1,children:C.jsx(zZ,{asChild:!0,disabled:!e||!n,children:C.jsx(xt,{iconName:yke,size:24,color:"var(--chat-composer-action-send-color)",className:o5})})})},xke=()=>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(mke,{}),C.jsx(dke,{})]}),C.jsxs("div",{className:"flex items-center gap-[12px] flex-row",children:[C.jsx(gke,{}),C.jsx(vke,{})]})]})}),a5=()=>{const{attachmentFiles:t}=gw(),{currentProvider:e}=ns(),{currentModel:n}=ag(),{t:r}=wt();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(tB,{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(DH,{file:i},i.path))}):null,C.jsx(iB,{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(xke,{})]}),C.jsx("p",{className:"text-center font-normal text-[12px] leading-[16px] text-[var(--text-tertiary)]",children:r("CheckInfo")})]})},wke=()=>{const{isStreamRunning:t,isRequestRunning:e}=Yh(),{t:n}=wt();return C.jsxs(aB,{className:"flex h-full flex-col",style:{"--thread-max-width":"687px","--thread-padding-x":"1rem"},children:[C.jsx(Qb,{empty:!0,children:C.jsx(Y2,{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(ive,{}),C.jsx(a5,{})]})})}),C.jsxs(Qb,{empty:!1,children:[C.jsxs(Y2,{className:"relative flex min-w-0 flex-1 flex-col gap-6 overflow-y-auto",children:[C.jsx(fee,{components:{UserMessage:oke,AssistantMessage:hke}}),!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(MT,{}),C.jsx("p",{className:"text-[14px] leading-[20px] font-normal text-[var(--chat-message-analyze-color)]",children:n("Analyzing")})]})}):null,C.jsx(cR.div,{className:"min-h-6 min-w-6 shrink-0"})]}),C.jsx(a5,{})]})]})},Ske="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",_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='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",Cke=async(t,e)=>{const n=ts.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()})},Ake=async()=>{const t=ts.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)}})},Eke=async(t,e)=>{const n=ts.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()}})},kke=async t=>{const e=ts.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()}})},Tke=async t=>{await Dre(t);const e=ts.getDB();return new Promise((n,r)=>{const o=e.transaction(["threads"],"readwrite").objectStore("threads").delete(t);o.onerror=()=>r(o.error),o.onsuccess=()=>n()})},lg=na((t,e)=>({threadId:crypto.randomUUID(),threads:[],initThreads:async()=>{const n=await Ake();t({threads:n})},insertThread:n=>{const r=e();t({threads:[{threadId:r.threadId,title:n},...r.threads]}),Cke(r.threadId,n)},insertNewMessageToThread:()=>{const n=e();kke(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 a9(n),o=i?.title||"Chat Export",a=S9(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)}),Eke(n,r)},onDeleteThread:n=>{const r=e();r.threadId===n&&r.onSwitchToNewThread(),t({threads:r.threads.filter(i=>i.threadId!==n)}),Tke(n)}})),Rke=()=>{const{t}=wt(),{currentPage:e,setCurrentPage:n}=zm(),{onSwitchToNewThread:r}=lg();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(xt,{iconName:_ke,size:24,isStroke:!0,onClick:()=>{n("chat"),r()}})})]}),C.jsx(ta,{tooltip:t("Settings"),children:C.jsx(xt,{iconName:Ske,size:24,isStroke:!0,isActive:e==="settings",onClick:()=>n(e==="settings"?"chat":"settings")})})]})},Mke="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='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",Oke="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",Pke="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",Dke="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",Ike=({id:t,onClose:e})=>{const{onDeleteThread:n}=lg(),{t:r}=wt(),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(tn,{variant:"default",onClick:e,children:r("No")}),C.jsx(tn,{onClick:i,children:r("Yes")})]})]})})})},Lke=t=>{const e=t.querySelector("path");e&&e.setAttribute("stroke","var(--icon-button-color)")},Nke=t=>{const e=t.querySelector("path");e&&e.setAttribute("fill","var(--icon-button-color)")},$ke=t=>{const e=t.querySelector("path");e&&e.setAttribute("fill","var(--icon-button-color)")},jke=()=>C.jsx(Gt,{src:kq,beforeInjection:Lke}),Bke=()=>C.jsx(Gt,{src:Dke,beforeInjection:Nke}),Fke=()=>C.jsx(Gt,{src:Nk,beforeInjection:$ke}),zke=({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}=wt();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(lo,{ref:_,value:b,onChange:D=>x(D.target.value),onBlur:()=>{d(!1),b&&r(t.threadId,b)},autoFocus:!0,className:"w-full"}):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(xt,{iconName:Lk,size:20,isActive:o,insideElement:!0}),items:[{icon:C.jsx(jke,{}),text:A("Save"),onClick:M},{icon:C.jsx(Bke,{}),text:A("Rename"),onClick:O},{icon:C.jsx(Fke,{}),text:A("Delete"),onClick:P}],side:"right",align:"start",sideOffset:0,containerRef:S.current}):null]}),m?C.jsx(Ike,{id:t.threadId,onClose:()=>y(!1)}):null]},t.threadId)},Vke=()=>{const{threads:t,threadId:e,onSwitchToThread:n,onRenameThread:r,onDownloadThread:i}=lg(),{setCurrentPage:s}=zm(),[o,a]=be.useState(!1),[c,h]=be.useState(""),[f,d]=be.useState(t),{t:m}=wt(),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(xt,{iconName:Oke,size:24,isStroke:!0,onClick:()=>a(!1)})]}),!b&&C.jsx("div",{className:"mt-[32px]",children:C.jsx(lo,{className:"w-full",type:"search",placeholder:m("Search"),icon:Pke,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(zke,{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(xt,{iconName:Mke,size:24,onClick:()=>{s("chat"),a(!0)}})})})},l5=t=>t==="dark"?"theme-night":"theme-white",c5=({children:t})=>{const{currentPage:e}=zm(),{i18n:n}=wt(),[r,i]=be.useState(()=>window.RendererProcessVariable?window.RendererProcessVariable.theme.id==="theme-system"?l5(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(l5(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(Rke,{}),C.jsxs("div",{className:"flex flex-row flex-1",style:{height:"calc(100dvh - 56px)"},children:[s?null:C.jsx(Vke,{}),C.jsx("div",{className:"w-full",children:t})]})]})})},Uke=({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(Gt,{src:Oh,className:"flex items-center justify-center",beforeInjection:o}):null})})]})},Hke=({onAllow:t,onDeny:e,onClose:n})=>{const{t:r}=wt(),{manageToolData:i}=Ts(),[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(Tq,{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(Uke,{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(tn,{variant:"default",onClick:c,children:r("Deny")}),C.jsx(tn,{onClick:a,children:r("Allow")})]})]})})},Wke=async t=>{const e=ts.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}=lg(),{manageToolData:f,callTools:d,checkAllowAlways:m,setAllowAlways:y,setManageToolData:b}=Ts(),{attachmentFiles:x,clearAttachmentFiles:S}=gw(),{currentProvider:_}=ns(),{currentModel:A}=ag(),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=Zt.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=Zt.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?(Pre(Y,te),E.current===a&&s(te)):(V||r(!0),i(te),hy(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 Wke(a))h(),(async()=>{await hy(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 hy(a,crypto.randomUUID(),U);await hy(a,crypto.randomUUID(),X)}})}i(X);const te=$t.sendMessage([X]);te&&N(te)},handleStream:N,approveToolCall:O,denyToolCall:M}},Gke=({isReady:t})=>{const{initThreads:e}=lg();return k.useEffect(()=>{t&&e()},[t,e]),{}},Kke=()=>{const{initCurrentModel:t,currentModel:e}=ag();return k.useEffect(()=>{e&&$t.setCurrentProviderModel(e.id)},[e]),k.useEffect(()=>{t()},[t]),{}},Yke=({isReady:t})=>{const{initServers:e,getTools:n,tools:r}=Ts(),{currentProvider:i}=ns();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},u5=t=>t==null?"":""+t,Xke=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Jke=/###/g,h5=t=>t&&t.indexOf("###")>-1?t.replace(Jke,"."):t,f5=t=>!t||Ke(t),zp=(t,e,n)=>{const r=Ke(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(f5(t))return{};const s=h5(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return f5(t)?{}:{obj:t,k:h5(r[i])}},d5=(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},Qke=(t,e,n,r)=>{const{obj:i,k:s}=zp(t,e,Object);i[s]=i[s]||[],i[s].push(n)},dx=(t,e)=>{const{obj:n,k:r}=zp(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Zke=(t,e,n)=>{const r=dx(t,n);return r!==void 0?r:dx(e,n)},Rq=(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]):Rq(t[r],e[r],n):t[r]=e[r]);return t},Uu=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var eTe={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const tTe=t=>Ke(t)?t.replace(/[&<>"'\/]/g,e=>eTe[e]):t;class nTe{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 rTe=[" ",",","?","!",";"],iTe=new nTe(20),sTe=(t,e,n)=>{e=e||"",n=n||"";const r=rTe.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=iTe.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},_E=(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("_","-"),oTe={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 px{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||oTe,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 px(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new px(this.logger,e)}}var oo=new px;class kw{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 p5 extends kw{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=dx(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:_E(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),d5(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=dx(this.data,a)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?Rq(c,r,s):c={...c,...r},d5(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 Mq={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 Oq=Symbol("i18next/PATH_KEY");function aTe(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===Oq?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function CE(t,e){const{[Oq]:n}=t(aTe());return n.join(e?.keySeparator??".")}const m5={},g5=t=>!Ke(t)&&typeof t!="boolean"&&typeof t!="number";class mx extends kw{constructor(e,n={}){super(),Xke(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=oo.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&&!sTe(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=CE(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=mx.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=g5(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:g5(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=Mq.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,!m5[`${x[0]}-${S}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(m5[`${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 y5{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=oo.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 b5={zero:0,one:1,two:2,few:3,many:4,other:5},v5={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class lTe{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=oo.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!"),v5;if(!e.match(/-|_/))return v5;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)=>b5[i]-b5[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 x5=(t,e,n,r=".",i=!0)=>{let s=Zke(t,e,n);return!s&&i&&Ke(n)&&(s=_E(t,n,r),s===void 0&&(s=_E(e,n,r))),s},$2=t=>t.replace(/\$/g,"$$$$");class cTe{constructor(e={}){this.logger=oo.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:tTe,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 _=x5(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(x5(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=>$2(y)},{regex:this.regexp,safeValue:y=>this.escapeValue?$2(this.escape(y)):$2(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=u5(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=u5(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 uTe=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}},w5=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)}},hTe=t=>(e,n,r)=>t(Om(n),r)(e);class fTe{constructor(e={}){this.logger=oo.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?w5:hTe;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()]=w5(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}=uTe(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 dTe=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class pTe extends kw{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=oo.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=>{Qke(c.loaded,[s],o),dTe(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 S5=()=>({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}),_5=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),eb=()=>{},mTe=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Pm extends kw{constructor(e={},n){if(super(),this.options=_5(e),this.services={},this.logger=oo,this.modules={external:[]},mTe(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=S5();this.options={...r,...this.options,..._5(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?oo.init(i(this.modules.logger),this.options):oo.init(null,this.options);let h;this.modules.formatter?h=this.modules.formatter:h=fTe;const f=new y5(this.options);this.store=new p5(this.options.resources,this.options);const d=this.services;d.logger=oo,d.resourceStore=this.store,d.languageUtils=f,d.pluralResolver=new lTe(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 cTe(this.options),d.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},d.backendConnector=new pTe(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 mx(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=eb),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=eb){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=eb),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"&&Mq.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=CE(d,{...this.options,...o})),`${c.keyPrefix}${h}${d}`)):(typeof s=="function"&&(s=CE(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 y5(S5());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=eb){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 p5(a,i),s.services.resourceStore=s.store}return s.translator=new mx(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 gTe="AI agent",yTe="AI agent Settings",bTe="Settings",vTe="Connect an AI Model to Get Started",xTe="No AI model is connected yet. Link a model to start interacting with it right here in the interface.",wTe="Connect an AI Model",STe="Chat history",_Te="There is no chat history yet...",CTe="Choose how to connect AI",ATe="Select how you want to enable AI features in ONLYOFFICE.",ETe="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.",kTe="ONLYOFFICE Wallet",TTe="Top up your balance with a card and instantly use all AI features.",RTe="Your AI provider",MTe="Connect your own AI source — either via API key from a provider or a locally hosted model.",OTe="Register & Connect Wallet",PTe="Add provider",DTe="Connection",ITe="MCP Servers",LTe="AI Provider",NTe="Edit AI Provider",$Te="Provider",jTe="Name",BTe="URL",FTe="Enter name",zTe="Enter URL",VTe="API key",UTe="Enter API key",HTe="Cancel",WTe="Save",qTe="Edit",GTe="Delete",KTe="Warning",YTe="Are you sure you want to delete this provider?",XTe="Are you sure you want to delete this chat?",JTe="Yes",QTe="No",ZTe="How can I help?",eRe="Free Al chat, writing assistant & idea generator",tRe="Rename",nRe="Download",rRe="Search...",iRe="Add local file...",sRe="Recent files",oRe="Attachments",aRe="API key",lRe="New chat",cRe="Ask AI",uRe="Analyzing...",hRe="Al would like to use this tool:",fRe=`Review each action carefully before approving
|
||
We cannot guarantee the security or privacy practices of third-party integrations.`,dRe="Always allow this tool to perform this action without asking again",pRe="Deny",mRe="Allow",gRe="Tool call arguments",yRe="Tool call result",bRe="Tool executed",vRe="Confirmation",xRe="Select model",wRe="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.",SRe="Edit configuration",_Re="Enter your JSON configuration:",CRe="Available tools",ARe="tools",ERe="tools enabled",kRe="Enable all tools",TRe="Disable all tools",RRe="Restart",MRe="Logs",ORe="Copy to clipboard",PRe="Close",DRe="Web Search",IRe="Connect a web search engine to enhance AI chats with real-time information from the internet.",LRe="Reset settings",NRe="Web Search Engine",$Re="Select engine",jRe="All tools",BRe="Enable web search in settings",FRe="This server will be deleted from your list. Continue?",zRe="Provider not available",VRe="AI Chat can make mistakes. Check important info.",URe={AIAgent:gTe,AIAgentSettings:yTe,Settings:bTe,ConnectAIModel:vTe,ConnectAIModelDescription:xTe,ConnectAIModelBtn:wTe,ChatHistory:STe,NoChatYet:_Te,ChooseHowConnect:CTe,SelectHowConnect:ATe,SelectHowConnectDescription:ETe,ONLYOFFICEWallet:kTe,ONLYOFFICEWalletDescription:TTe,AIProviders:RTe,AIProvidersDescription:MTe,RegisterConnectWallet:OTe,AddProvider:PTe,Connection:DTe,MCPServers:ITe,AIProvider:LTe,EditAIProvider:NTe,Provider:$Te,Name:jTe,URL:BTe,EnterName:FTe,EnterURL:zTe,Key:VTe,EnterKey:UTe,Cancel:HTe,Save:WTe,Edit:qTe,Delete:GTe,Warning:KTe,WantDeleteProvider:YTe,WantDeleteChat:XTe,Yes:JTe,No:QTe,WelcomeTitle:ZTe,WelcomeDescription:eRe,Rename:tRe,Download:nRe,Search:rRe,AddLocalFile:iRe,RecentFiles:sRe,Attachments:oRe,APIKey:aRe,NewChat:lRe,AskAI:cRe,Analyzing:uRe,AIWouldLikeUseThisTool:hRe,ReviewEachAction:fRe,AlwaysAllow:dRe,Deny:pRe,Allow:mRe,ToolCallArguments:gRe,ToolCallResult:yRe,ToolExecuted:bRe,Confirmation:vRe,SelectModel:xRe,CustomServersDescription:wRe,EditConfiguration:SRe,EnterYourJSONConfiguration:_Re,AvailableTools:CRe,Tools:ARe,ToolsEnabled:ERe,EnableAllTools:kRe,DisableAllTools:TRe,Restart:RRe,Logs:MRe,CopyToClipboard:ORe,Close:PRe,WebSearch:DRe,WebSearchDescription:IRe,ResetSettings:LRe,WebSearchEngine:NRe,SelectEngine:$Re,AllTools:jRe,EnableWebSearch:BRe,WantDeleteServer:FRe,NoModelsAvailable:zRe,CheckInfo:VRe},HRe="ИИ-агент",WRe="Настройки ИИ-агента",qRe="Настройки",GRe="Чтобы начать, подключите ИИ-модель",KRe="Нет подключенных ИИ-моделей. Подключите модель, чтобы начать работать с ней прямо в интерфейсе.",YRe="Подключить ИИ-модель",XRe="История чатов",JRe="Здесь пока нет истории чатов...",QRe="Выберите, как вы хотите включить искусственный интеллект",ZRe="Выберите, как вы хотите включить функции искусственного интеллекта в ONLYOFFICE.",eMe="Вы можете использовать встроенный кошелек для быстрого запуска или подключить собственную ИИ-модель с помощью ключа API или модели, размещенной локально.",tMe="Кошелек ONLYOFFICE",nMe="Пополните баланс с помощью карты и сразу используйте все функциональные возможности искусственного интеллекта.",rMe="Ваш ИИ-провайдер",iMe="Подключите собственный источник искусственного интеллекта с помощью ключа API провайдера или модели, размещенной локально.",sMe="Зарегистрируйтесь и подключите кошелек",oMe="Добавить провайдера",aMe="Подключение",lMe="MCP-серверы",cMe="ИИ-провайдер",uMe="Изменить ИИ-провайдера",hMe="Провайдер",fMe="Название",dMe="URL-адрес",pMe="Введите название",mMe="Введите URL-адрес",gMe="Ключ API",yMe="Введите ключ API",bMe="Отменить",vMe="Сохранить",xMe="Редактировать",wMe="Удалить",SMe="Предупреждение",_Me="Вы уверены, что хотите удалить этого провайдера?",CMe="Вы уверены, что хотите удалить этот чат?",AMe="Да",EMe="Нет",kMe="Чем я могу помочь?",TMe="Бесплатный ИИ-чат, помощник в создании документов и генератор идей",RMe="Переименовать",MMe="Загрузить",OMe="Поиск...",PMe="Добавить локальный файл...",DMe="Недавние файлы",IMe="Вложения",LMe="Ключ API",NMe="Новый чат",$Me="Спросить ИИ",jMe="Анализ...",BMe="Искусственный интеллект хочет использовать этот инструмент:",FMe=`Внимательно проверяйте каждое действие перед подтверждением
|
||
Мы не можем гарантировать соответствие правил обеспечения безопасности и конфиденциальности сторонних интеграций.`,zMe="Всегда разрешать этому инструменту выполнять данное действие без повторного запроса",VMe="Отклонить",UMe="Разрешить",HMe="Аргументы вызова инструмента",WMe="Результат вызова инструмента",qMe="Работа с инструментом завершена",GMe="Подтверждение",KMe="Выбрать модель",YMe="В этом разделе можно настроить MCP-серверы для использования в ИИ-агенте. Вы можете редактировать конфигурацию, чтобы добавлять новые MCP-серверы и включать необходимые инструменты.",XMe="Редактировать конфигурацию",JMe="Введите конфигурацию JSON:",QMe="Доступные инструменты",ZMe="инструменты",eOe="включенные инструменты",tOe="Включить все инструменты",nOe="Отключить все инструменты",rOe="Перезапустить",iOe="Журналы",sOe="Копировать в буфер обмена",oOe="Закрыть",aOe="Веб-поиск",lOe="Включите поисковую систему, чтобы дополнять ИИ-чаты информацией из Интернета в режиме реального времени.",cOe="Сбросить настройки",uOe="Поисковая система",hOe="Выберите движок",fOe="Все инструменты",dOe="Включить веб-поиск в настройках",pOe="Этот сервер будет удален из вашего списка. Продолжить?",mOe="Поставщик недоступен",gOe="ИИ-чат может ошибаться. Проверьте важную информацию.",yOe={AIAgent:HRe,AIAgentSettings:WRe,Settings:qRe,ConnectAIModel:GRe,ConnectAIModelDescription:KRe,ConnectAIModelBtn:YRe,ChatHistory:XRe,NoChatYet:JRe,ChooseHowConnect:QRe,SelectHowConnect:ZRe,SelectHowConnectDescription:eMe,ONLYOFFICEWallet:tMe,ONLYOFFICEWalletDescription:nMe,AIProviders:rMe,AIProvidersDescription:iMe,RegisterConnectWallet:sMe,AddProvider:oMe,Connection:aMe,MCPServers:lMe,AIProvider:cMe,EditAIProvider:uMe,Provider:hMe,Name:fMe,URL:dMe,EnterName:pMe,EnterURL:mMe,Key:gMe,EnterKey:yMe,Cancel:bMe,Save:vMe,Edit:xMe,Delete:wMe,Warning:SMe,WantDeleteProvider:_Me,WantDeleteChat:CMe,Yes:AMe,No:EMe,WelcomeTitle:kMe,WelcomeDescription:TMe,Rename:RMe,Download:MMe,Search:OMe,AddLocalFile:PMe,RecentFiles:DMe,Attachments:IMe,APIKey:LMe,NewChat:NMe,AskAI:$Me,Analyzing:jMe,AIWouldLikeUseThisTool:BMe,ReviewEachAction:FMe,AlwaysAllow:zMe,Deny:VMe,Allow:UMe,ToolCallArguments:HMe,ToolCallResult:WMe,ToolExecuted:qMe,Confirmation:GMe,SelectModel:KMe,CustomServersDescription:YMe,EditConfiguration:XMe,EnterYourJSONConfiguration:JMe,AvailableTools:QMe,Tools:ZMe,ToolsEnabled:eOe,EnableAllTools:tOe,DisableAllTools:nOe,Restart:rOe,Logs:iOe,CopyToClipboard:sOe,Close:oOe,WebSearch:aOe,WebSearchDescription:lOe,ResetSettings:cOe,WebSearchEngine:uOe,SelectEngine:hOe,AllTools:fOe,EnableWebSearch:dOe,WantDeleteServer:pOe,NoModelsAvailable:mOe,CheckInfo:gOe},bOe="Agent AI",vOe="Nastavení agenta AI",xOe="Nastavení",wOe="Připojte model AI a začněte",SOe="Zatím není připojen žádný model AI. Propojte model a začněte s ním komunikovat přímo zde v rozhraní.",_Oe="Připojit model AI",COe="Historie chatu",AOe="Zatím neexistuje žádná historie chatu...",EOe="Vyberte způsob připojení AI",kOe="Vyberte, jak chcete povolit funkce AI v ONLYOFFICE.",TOe="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.",ROe="Peněženka ONLYOFFICE",MOe="Doplňte svůj zůstatek kartou a okamžitě používejte všechny funkce AI.",OOe="Váš poskytovatel AI",POe="Připojte svůj vlastní zdroj AI – buď pomocí API klíče od poskytovatele, nebo lokálně hostovaného modelu.",DOe="Registrovat a připojit peněženku",IOe="Přidat poskytovatele",LOe="Připojení",NOe="Servery MCP",$Oe="Poskytovatel AI",jOe="Upravit poskytovatele AI",BOe="Poskytovatel",FOe="Název",zOe="URL",VOe="Zadat název",UOe="Zadat URL",HOe="API klíč",WOe="Zadat API klíč",qOe="Zrušit",GOe="Uložit",KOe="Upravit",YOe="Odstranit",XOe="Varování",JOe="Opravdu chcete odstranit tohoto poskytovatele?",QOe="Opravdu chcete odstranit tento chat?",ZOe="Ano",ePe="Ne",tPe="Jak vám mohu pomoci?",nPe="Bezplatný Al chat, pomocník při psaní a generátor nápadů",rPe="Přejmenovat",iPe="Stáhnout",sPe="Hledat...",oPe="Přidat místní soubor...",aPe="Poslední soubory",lPe="Přílohy",cPe="API klíč",uPe="Nový chat",hPe="Zeptejte se AI",fPe="Probíhá analýza...",dPe="Al by ráda použila tento nástroj:",pPe=`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.`,mPe="Vždy povolit tomuto nástroji provést tuto akci bez dalšího dotazu",gPe="Odmítnout",yPe="Povolit",bPe="Argumenty volání nástroje",vPe="Výsledek volání nástroje",xPe="Nástroj proveden",wPe="Potvrzení",SPe="Vybrat model",_Pe="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.",CPe="Upravit konfiguraci",APe="Zadejte svou konfiguraci JSON:",EPe="Dostupné nástroje",kPe="nástroje",TPe="povolené nástroje",RPe="Povolit všechny nástroje",MPe="Zakázat všechny nástroje",OPe="Restartovat",PPe="Protokoly",DPe="Kopírovat do schránky",IPe="Zavřít",LPe="Webové vyhledávání",NPe="Připojte webový vyhledávač a vylepšete AI chaty pomocí informací z internetu v reálném čase.",$Pe="Obnovit nastavení",jPe="Webový vyhledávač",BPe="Vybrat vyhledávač",FPe="Všechny nástroje",zPe="Povolit webové vyhledávání v nastavení",VPe="Tento server bude odstraněn z vašeho seznamu. Pokračovat?",UPe="Poskytovatel není k dispozici",HPe="AI chat může dělat chyby. Zkontrolujte důležité informace.",WPe={AIAgent:bOe,AIAgentSettings:vOe,Settings:xOe,ConnectAIModel:wOe,ConnectAIModelDescription:SOe,ConnectAIModelBtn:_Oe,ChatHistory:COe,NoChatYet:AOe,ChooseHowConnect:EOe,SelectHowConnect:kOe,SelectHowConnectDescription:TOe,ONLYOFFICEWallet:ROe,ONLYOFFICEWalletDescription:MOe,AIProviders:OOe,AIProvidersDescription:POe,RegisterConnectWallet:DOe,AddProvider:IOe,Connection:LOe,MCPServers:NOe,AIProvider:$Oe,EditAIProvider:jOe,Provider:BOe,Name:FOe,URL:zOe,EnterName:VOe,EnterURL:UOe,Key:HOe,EnterKey:WOe,Cancel:qOe,Save:GOe,Edit:KOe,Delete:YOe,Warning:XOe,WantDeleteProvider:JOe,WantDeleteChat:QOe,Yes:ZOe,No:ePe,WelcomeTitle:tPe,WelcomeDescription:nPe,Rename:rPe,Download:iPe,Search:sPe,AddLocalFile:oPe,RecentFiles:aPe,Attachments:lPe,APIKey:cPe,NewChat:uPe,AskAI:hPe,Analyzing:fPe,AIWouldLikeUseThisTool:dPe,ReviewEachAction:pPe,AlwaysAllow:mPe,Deny:gPe,Allow:yPe,ToolCallArguments:bPe,ToolCallResult:vPe,ToolExecuted:xPe,Confirmation:wPe,SelectModel:SPe,CustomServersDescription:_Pe,EditConfiguration:CPe,EnterYourJSONConfiguration:APe,AvailableTools:EPe,Tools:kPe,ToolsEnabled:TPe,EnableAllTools:RPe,DisableAllTools:MPe,Restart:OPe,Logs:PPe,CopyToClipboard:DPe,Close:IPe,WebSearch:LPe,WebSearchDescription:NPe,ResetSettings:$Pe,WebSearchEngine:jPe,SelectEngine:BPe,AllTools:FPe,EnableWebSearch:zPe,WantDeleteServer:VPe,NoModelsAvailable:UPe,CheckInfo:HPe},qPe="KI-Agent",GPe="Einstellungen des KI-Agenten",KPe="Einstellungen",YPe="Verbinden Sie ein KI-Modell, um loszulegen",XPe="Es ist noch kein KI-Modell verbunden. Verbinden Sie ein Modell, um direkt hier in der Benutzeroberfläche damit zu interagieren.",JPe="KI-Modell verbinden",QPe="Chatverlauf",ZPe="Es gibt noch keinen Chatverlauf...",eDe="Wählen Sie aus, wie Sie die KI verbinden möchten",tDe="Wählen Sie aus, wie Sie die KI-Funktionen in ONLYOFFICE aktivieren möchten.",nDe="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.",rDe="ONLYOFFICE Wallet",iDe="Laden Sie Ihr Guthaben mit einer Karte auf und nutzen Sie sofort alle KI-Funktionen.",sDe="Ihr KI-Anbieter",oDe="Verbinden Sie Ihre eigene KI-Quelle – entweder über einen API-Schlüssel eines Anbieters oder über ein lokal gehostetes Modell.",aDe="Registrieren und Wallet verbinden",lDe="Anbieter hinzufügen",cDe="Verbindung",uDe="MCP-Server",hDe="KI-Anbieter",fDe="KI-Anbieter bearbeiten",dDe="Anbieter",pDe="Name",mDe="URL",gDe="Name eingeben",yDe="URL eingeben",bDe="API-Schlüssel",vDe="API-Schlüssel eingeben",xDe="Abbrechen",wDe="Speichern",SDe="Bearbeiten",_De="Löschen",CDe="Warnung",ADe="Möchten Sie diesen Anbieter wirklich löschen?",EDe="Möchten Sie diesen Chat wirklich löschen?",kDe="Ja",TDe="Nein",RDe="Wie kann ich helfen?",MDe="Kostenloser KI-Chat, Schreibassistent und Ideengenerator",ODe="Umbenennen",PDe="Herunterladen",DDe="Suchen...",IDe="Lokale Datei hinzufügen...",LDe="Zuletzt verwendete Dateien",NDe="Anlagen",$De="API-Schlüssel",jDe="Neuer Chat",BDe="KI fragen",FDe="Analyse läuft...",zDe="KI möchte dieses Tool verwenden:",VDe=`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.`,UDe="Diesem Tool immer erlauben, diese Aktion ohne erneute Nachfrage auszuführen.",HDe="Ablehnen",WDe="Erlauben",qDe="Argumente des Toolaufrufs",GDe="Ergebnis des Toolaufrufs",KDe="Tool ausgeführt",YDe="Bestätigung",XDe="Modell auswählen",JDe=" 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.",QDe="Konfiguration bearbeiten",ZDe="Geben Sie Ihre JSON-Konfiguration ein:",eIe="Verfügbare Tools",tIe="Tools",nIe="Tools aktiviert",rIe="Alle Tools aktivieren",iIe="Alle Tools deaktivieren",sIe="Neustart",oIe="Protokolle",aIe="In die Zwischenablage kopieren",lIe="Schließen",cIe="Websuche",uIe="Verbinden Sie eine Websuchmaschine, um KI-Chats mit Echtzeitinformationen aus dem Internet zu verbessern.",hIe="Einstellungen zurücksetzen",fIe="Web-Suchmaschine",dIe="Engine auswählen",pIe="Alle Tools",mIe="Aktivieren Sie die Websuche in den Einstellungen",gIe="Dieser Server wird aus Ihrer Liste gelöscht. Weiter?",yIe="Anbieter nicht verfügbar",bIe="KI-Chat kann Fehler machen. Überprüfen Sie wichtige Informationen.",vIe={AIAgent:qPe,AIAgentSettings:GPe,Settings:KPe,ConnectAIModel:YPe,ConnectAIModelDescription:XPe,ConnectAIModelBtn:JPe,ChatHistory:QPe,NoChatYet:ZPe,ChooseHowConnect:eDe,SelectHowConnect:tDe,SelectHowConnectDescription:nDe,ONLYOFFICEWallet:rDe,ONLYOFFICEWalletDescription:iDe,AIProviders:sDe,AIProvidersDescription:oDe,RegisterConnectWallet:aDe,AddProvider:lDe,Connection:cDe,MCPServers:uDe,AIProvider:hDe,EditAIProvider:fDe,Provider:dDe,Name:pDe,URL:mDe,EnterName:gDe,EnterURL:yDe,Key:bDe,EnterKey:vDe,Cancel:xDe,Save:wDe,Edit:SDe,Delete:_De,Warning:CDe,WantDeleteProvider:ADe,WantDeleteChat:EDe,Yes:kDe,No:TDe,WelcomeTitle:RDe,WelcomeDescription:MDe,Rename:ODe,Download:PDe,Search:DDe,AddLocalFile:IDe,RecentFiles:LDe,Attachments:NDe,APIKey:$De,NewChat:jDe,AskAI:BDe,Analyzing:FDe,AIWouldLikeUseThisTool:zDe,ReviewEachAction:VDe,AlwaysAllow:UDe,Deny:HDe,Allow:WDe,ToolCallArguments:qDe,ToolCallResult:GDe,ToolExecuted:KDe,Confirmation:YDe,SelectModel:XDe,CustomServersDescription:JDe,EditConfiguration:QDe,EnterYourJSONConfiguration:ZDe,AvailableTools:eIe,Tools:tIe,ToolsEnabled:nIe,EnableAllTools:rIe,DisableAllTools:iIe,Restart:sIe,Logs:oIe,CopyToClipboard:aIe,Close:lIe,WebSearch:cIe,WebSearchDescription:uIe,ResetSettings:hIe,WebSearchEngine:fIe,SelectEngine:dIe,AllTools:pIe,EnableWebSearch:mIe,WantDeleteServer:gIe,NoModelsAvailable:yIe,CheckInfo:bIe},xIe="Agente de IA",wIe="Configuración del agente de IA",SIe="Configuración",_Ie="Conecte un modelo de IA para empezar",CIe="Aún no hay ningún modelo de IA conectado. Conecte un modelo para empezar a interactuar con él aquí mismo, en la interfaz.",AIe="Conectar un modelo de IA",EIe="Historial del chat",kIe="Todavía no hay historial de chat...",TIe="Elija cómo conectar la IA",RIe="Seleccione cómo desea activar las funciones de IA en ONLYOFFICE.",MIe="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.",OIe="Monedero de ONLYOFFICE",PIe="Recargue su saldo con una tarjeta y utilice al instante todas las funciones de IA.",DIe="Su proveedor de IA",IIe="Conecte su propia fuente de IA, ya sea mediante una clave de la API de un proveedor o un modelo alojado localmente.",LIe="Regístrese y conecte su monedero",NIe="Añadir proveedor",$Ie="Conexión",jIe="Servidores MCP",BIe="Proveedor de IA",FIe="Editar proveedor de IA",zIe="Proveedor",VIe="Nombre",UIe="URL",HIe="Introduzca el nombre",WIe="Introduzca la URL",qIe="Clave de la API",GIe="Introduzca la clave de la API",KIe="Cancelar",YIe="Guardar",XIe="Editar",JIe="Eliminar",QIe="Advertencia",ZIe="¿Está seguro de que desea eliminar este proveedor?",eLe="¿Está seguro de que desea eliminar este chat?",tLe="Sí",nLe="No",rLe="¿En qué puedo ayudarle?",iLe="Chat gratuito, asistente de escritura y generador de ideas",sLe="Renombrar",oLe="Descargar",aLe="Búsqueda...",lLe="Añadir archivo local...",cLe="Archivos recientes",uLe="Archivos adjuntos",hLe="Clave de la API",fLe="Nuevo chat",dLe="Preguntarle a la IA",pLe="Analizando...",mLe="A la IA le gustaría utilizar esta herramienta:",gLe=`Revise cada acción cuidadosamente antes de aprobarla
|
||
No podemos garantizar la seguridad o las prácticas de privacidad de las integraciones de terceros.`,yLe="Siempre permitir que esta herramienta realice esta acción sin preguntar de nuevo",bLe="Denegar",vLe="Permitir",xLe="Argumentos de la llamada a la herramienta",wLe="Resultado de la llamada a la herramienta",SLe="Herramienta ejecutada",_Le="Confirmación",CLe="Seleccionar modelo",ALe="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.",ELe="Editar configuración",kLe="Introduzca su configuración JSON:",TLe="Herramientas disponibles",RLe="herramientas",MLe="herramientas habilitadas",OLe="Habilitar todas las herramientas",PLe="Deshabilitar todas las herramientas",DLe="Reiniciar",ILe="Registros",LLe="Copiar al portapapeles",NLe="Cerrar",$Le="Búsqueda en la Web",jLe="Conecte un motor de búsqueda web para mejorar los chats de IA con información en tiempo real procedente de Internet.",BLe="Restablecer configuración",FLe="Motor de búsqueda web",zLe="Seleccionar motor",VLe="Todas las herramientas",ULe="Habilite la búsqueda web en la configuración",HLe="Este servidor se eliminará de su lista. ¿Continuar?",WLe="Proveedor no disponible",qLe="El Chat de IA puede cometer errores. Compruebe la información importante.",GLe={AIAgent:xIe,AIAgentSettings:wIe,Settings:SIe,ConnectAIModel:_Ie,ConnectAIModelDescription:CIe,ConnectAIModelBtn:AIe,ChatHistory:EIe,NoChatYet:kIe,ChooseHowConnect:TIe,SelectHowConnect:RIe,SelectHowConnectDescription:MIe,ONLYOFFICEWallet:OIe,ONLYOFFICEWalletDescription:PIe,AIProviders:DIe,AIProvidersDescription:IIe,RegisterConnectWallet:LIe,AddProvider:NIe,Connection:$Ie,MCPServers:jIe,AIProvider:BIe,EditAIProvider:FIe,Provider:zIe,Name:VIe,URL:UIe,EnterName:HIe,EnterURL:WIe,Key:qIe,EnterKey:GIe,Cancel:KIe,Save:YIe,Edit:XIe,Delete:JIe,Warning:QIe,WantDeleteProvider:ZIe,WantDeleteChat:eLe,Yes:tLe,No:nLe,WelcomeTitle:rLe,WelcomeDescription:iLe,Rename:sLe,Download:oLe,Search:aLe,AddLocalFile:lLe,RecentFiles:cLe,Attachments:uLe,APIKey:hLe,NewChat:fLe,AskAI:dLe,Analyzing:pLe,AIWouldLikeUseThisTool:mLe,ReviewEachAction:gLe,AlwaysAllow:yLe,Deny:bLe,Allow:vLe,ToolCallArguments:xLe,ToolCallResult:wLe,ToolExecuted:SLe,Confirmation:_Le,SelectModel:CLe,CustomServersDescription:ALe,EditConfiguration:ELe,EnterYourJSONConfiguration:kLe,AvailableTools:TLe,Tools:RLe,ToolsEnabled:MLe,EnableAllTools:OLe,DisableAllTools:PLe,Restart:DLe,Logs:ILe,CopyToClipboard:LLe,Close:NLe,WebSearch:$Le,WebSearchDescription:jLe,ResetSettings:BLe,WebSearchEngine:FLe,SelectEngine:zLe,AllTools:VLe,EnableWebSearch:ULe,WantDeleteServer:HLe,NoModelsAvailable:WLe,CheckInfo:qLe},KLe="Agent IA",YLe="Paramètres de l'agent IA",XLe="Paramètres",JLe="Connectez un modèle d'IA pour commencer",QLe="Aucun modèle d'IA n'est encore connecté. Associez un modèle pour commencer à interagir avec lui directement dans l'interface.",ZLe="Connecter un modèle d'IA",eNe="Historique de chat",tNe="Il n'y a pas encore d'historique de chat...",nNe="Choisissez comment connecter l'IA",rNe="Sélectionnez comment vous souhaitez activer les fonctionnalités IA dans ONLYOFFICE.",iNe="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.",sNe="Wallet ONLYOFFICE",oNe="Rechargez votre solde avec une carte et utilisez instantanément toutes les fonctionnalités de l'IA.",aNe="Votre fournisseur d'IA",lNe="Connectez votre propre source d'IA, soit via une clé API fournie par un fournisseur, soit via un modèle hébergé localement.",cNe="Enregistrez et connectez votre Wallet",uNe="Ajouter un fournisseur",hNe="Connexion",fNe="Serveurs MCP",dNe="Fournisseur d'IA",pNe="Modifier le fournisseur d'IA",mNe="Fournisseur",gNe="Nom",yNe="URL",bNe="Saisissez le nom",vNe="Saisissez l'URL",xNe="Clé API",wNe="Saisissez la clé API",SNe="Annuler",_Ne="Enregistrer",CNe="Modifier",ANe="Supprimer",ENe="Avertissement",kNe="Souhaitez-vous vraiment supprimer ce fournisseur ?",TNe="Souhaitez-vous vraiment supprimer ce chat ?",RNe="Oui",MNe="Non",ONe="Comment puis-je vous aider ?",PNe="Chat Al gratuit, assistant de rédaction et générateur d'idées",DNe="Renommer",INe="Télécharger",LNe="Recherche...",NNe="Ajout d'un fichier local...",$Ne="Fichiers récents",jNe="Pièces jointes",BNe="Clé API",FNe="Nouveau chat",zNe="Demander à l'IA",VNe="Analyse en cours...",UNe="lA aimerait utiliser cet outil :",HNe="Examinez attentivement chaque action avant de l'approuver. Nous ne pouvons garantir la sécurité ou les pratiques de confidentialité des intégrations tierces.",WNe="Toujours autoriser cet outil à effectuer cette action sans demander à nouveau",qNe="Refuser",GNe="Autoriser",KNe="Arguments d'appel d'outil",YNe="Résultat de l'appel de l'outil",XNe="Outil exécuté",JNe="Confirmation",QNe="Sélectionner le modèle",ZNe=" 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.",e3e="Modifier la configuration",t3e="Entrez votre configuration JSON :",n3e="Outils disponibles",r3e="outils",i3e="outils activés",s3e="Activer tous les outils",o3e="Désactiver tous les outils",a3e="Redémarrer",l3e="Logs",c3e="Copier dans le presse-papiers",u3e="Fermer",h3e="Recherche sur le Web",f3e="Connectez un moteur de recherche Web pour améliorer les conversations IA grâce à des informations en temps réel provenant d'Internet.",d3e="Réinitialiser les paramètres",p3e="Moteur de recherche Web",m3e="Sélectionner le moteur",g3e="Tous les outils",y3e="Activer la recherche Web dans les paramètres",b3e="Ce serveur sera supprimé de votre liste. Continuer ?",v3e="Fournisseur indisponible",x3e="Le chatbot IA peut faire des erreurs. Vérifiez les informations importantes.",w3e={AIAgent:KLe,AIAgentSettings:YLe,Settings:XLe,ConnectAIModel:JLe,ConnectAIModelDescription:QLe,ConnectAIModelBtn:ZLe,ChatHistory:eNe,NoChatYet:tNe,ChooseHowConnect:nNe,SelectHowConnect:rNe,SelectHowConnectDescription:iNe,ONLYOFFICEWallet:sNe,ONLYOFFICEWalletDescription:oNe,AIProviders:aNe,AIProvidersDescription:lNe,RegisterConnectWallet:cNe,AddProvider:uNe,Connection:hNe,MCPServers:fNe,AIProvider:dNe,EditAIProvider:pNe,Provider:mNe,Name:gNe,URL:yNe,EnterName:bNe,EnterURL:vNe,Key:xNe,EnterKey:wNe,Cancel:SNe,Save:_Ne,Edit:CNe,Delete:ANe,Warning:ENe,WantDeleteProvider:kNe,WantDeleteChat:TNe,Yes:RNe,No:MNe,WelcomeTitle:ONe,WelcomeDescription:PNe,Rename:DNe,Download:INe,Search:LNe,AddLocalFile:NNe,RecentFiles:$Ne,Attachments:jNe,APIKey:BNe,NewChat:FNe,AskAI:zNe,Analyzing:VNe,AIWouldLikeUseThisTool:UNe,ReviewEachAction:HNe,AlwaysAllow:WNe,Deny:qNe,Allow:GNe,ToolCallArguments:KNe,ToolCallResult:YNe,ToolExecuted:XNe,Confirmation:JNe,SelectModel:QNe,CustomServersDescription:ZNe,EditConfiguration:e3e,EnterYourJSONConfiguration:t3e,AvailableTools:n3e,Tools:r3e,ToolsEnabled:i3e,EnableAllTools:s3e,DisableAllTools:o3e,Restart:a3e,Logs:l3e,CopyToClipboard:c3e,Close:u3e,WebSearch:h3e,WebSearchDescription:f3e,ResetSettings:d3e,WebSearchEngine:p3e,SelectEngine:m3e,AllTools:g3e,EnableWebSearch:y3e,WantDeleteServer:b3e,NoModelsAvailable:v3e,CheckInfo:x3e},S3e="Agente AI",_3e="Impostazioni agente AI",C3e="Impostazioni",A3e="Collega un modello AI per iniziare",E3e="Nessun modello AI è stato collegato. Collega un modello per iniziare a interagire direttamente da questa interfaccia.",k3e="Collega un modello AI",T3e="Cronologia chat",R3e="Non c'è ancora alcuna cronologia chat...",M3e="Scegli come collegare l'AI",O3e="Scegli come desideri abilitare le funzionalità AI in ONLYOFFICE.",P3e="Puoi usare il Wallet integrato per iniziare subito oppure collegare il tuo modello AI tramite una chiave API o un modello ospitato localmente.",D3e="Wallet ONLYOFFICE",I3e="Ricarica il saldo con una carta e usa subito tutte le funzioni AI.",L3e="Il tuo provider AI",N3e="Collega la tua fonte AI tramite chiave API di un provider o modello ospitato localmente.",$3e="Registrati e collega il Wallet",j3e="Aggiungi provider",B3e="Connessione",F3e="Server MCP",z3e="Provider AI",V3e="Modifica provider AI",U3e="Provider",H3e="Nome",W3e="URL",q3e="Inserisci nome",G3e="Inserisci URL",K3e="Chiave API",Y3e="Inserisci chiave API",X3e="Annulla",J3e="Salva",Q3e="Modifica",Z3e="Elimina",e4e="Avviso",t4e="Vuoi davvero eliminare questo provider?",n4e="Vuoi davvero eliminare questa chat?",r4e="Sì",i4e="No",s4e="Come posso aiutarti?",o4e="Chat AI gratuita, assistente di scrittura e generatore di idee",a4e="Rinomina",l4e="Scarica",c4e="Cerca...",u4e="Aggiungi file locale...",h4e="File recenti",f4e="Allegati",d4e="Chiave API",p4e="Nuova chat",m4e="Chiedi all'AI",g4e="Analisi in corso...",y4e="L'AI vorrebbe usare questo strumento:",b4e=`Controlla attentamente ogni azione prima di approvarla
|
||
Non possiamo garantire la sicurezza o le pratiche sulla privacy delle integrazioni di terze parti.`,v4e="Consenti sempre a questo strumento di eseguire questa azione senza chiedere di nuovo",x4e="Nega",w4e="Consenti",S4e="Argomenti della chiamata dello strumento",_4e="Risultato della chiamata dello strumento",C4e="Strumento eseguito",A4e="Conferma",E4e="Seleziona modello",k4e="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.",T4e="Modifica configurazione",R4e="Inserisci la tua configurazione JSON:",M4e="Strumenti disponibili",O4e="strumenti",P4e="strumenti abilitati",D4e="Abilita tutti gli strumenti",I4e="Disabilita tutti gli strumenti",L4e="Riavvia",N4e="Log",$4e="Copia negli appunti",j4e="Chiudi",B4e="Ricerca web",F4e="Collega un motore di ricerca web per arricchire le chat AI con informazioni aggiornate da Internet.",z4e="Reimposta impostazioni",V4e="Motore di ricerca web",U4e="Seleziona motore",H4e="Tutti gli strumenti",W4e="Abilita la ricerca web nelle impostazioni",q4e="Questo server verrà rimosso dall'elenco. Continuare?",G4e="Provider non disponibile",K4e="L'AI può commettere errori. Verifica le informazioni importanti.",Y4e={AIAgent:S3e,AIAgentSettings:_3e,Settings:C3e,ConnectAIModel:A3e,ConnectAIModelDescription:E3e,ConnectAIModelBtn:k3e,ChatHistory:T3e,NoChatYet:R3e,ChooseHowConnect:M3e,SelectHowConnect:O3e,SelectHowConnectDescription:P3e,ONLYOFFICEWallet:D3e,ONLYOFFICEWalletDescription:I3e,AIProviders:L3e,AIProvidersDescription:N3e,RegisterConnectWallet:$3e,AddProvider:j3e,Connection:B3e,MCPServers:F3e,AIProvider:z3e,EditAIProvider:V3e,Provider:U3e,Name:H3e,URL:W3e,EnterName:q3e,EnterURL:G3e,Key:K3e,EnterKey:Y3e,Cancel:X3e,Save:J3e,Edit:Q3e,Delete:Z3e,Warning:e4e,WantDeleteProvider:t4e,WantDeleteChat:n4e,Yes:r4e,No:i4e,WelcomeTitle:s4e,WelcomeDescription:o4e,Rename:a4e,Download:l4e,Search:c4e,AddLocalFile:u4e,RecentFiles:h4e,Attachments:f4e,APIKey:d4e,NewChat:p4e,AskAI:m4e,Analyzing:g4e,AIWouldLikeUseThisTool:y4e,ReviewEachAction:b4e,AlwaysAllow:v4e,Deny:x4e,Allow:w4e,ToolCallArguments:S4e,ToolCallResult:_4e,ToolExecuted:C4e,Confirmation:A4e,SelectModel:E4e,CustomServersDescription:k4e,EditConfiguration:T4e,EnterYourJSONConfiguration:R4e,AvailableTools:M4e,Tools:O4e,ToolsEnabled:P4e,EnableAllTools:D4e,DisableAllTools:I4e,Restart:L4e,Logs:N4e,CopyToClipboard:$4e,Close:j4e,WebSearch:B4e,WebSearchDescription:F4e,ResetSettings:z4e,WebSearchEngine:V4e,SelectEngine:U4e,AllTools:H4e,EnableWebSearch:W4e,WantDeleteServer:q4e,NoModelsAvailable:G4e,CheckInfo:K4e},X4e="Asystent AI",J4e="Ustawienia asystenta AI",Q4e="Ustawienia",Z4e="Podłącz model AI, aby rozpocząć",e$e="Nie podłączono jeszcze żadnego modelu AI. Podłącz model, aby rozpocząć interakcje z nim bezpośrednio w interfejsie.",t$e="Podłącz model AI",n$e="Historia czatów",r$e="Nie ma jeszcze historii czatów...",i$e="Wybierz, jak podłączyć AI",s$e="Wybierz, jak chcesz włączyć funkcje AI w ONLYOFFICE.",o$e="Użyj wbudowanego Portfela, aby szybko rozpocząć pracę bądź skonfiguruj własny model AI za pomocą klucza API lub lokalnie hostowanego modelu.",a$e="Portfel ONLYOFFICE",l$e="Zasil saldo kartą, aby uzyskać natychmiastowy dostęp do wszystkich funkcji AI.",c$e="Twój dostawca AI",u$e="Skonfiguruj własne źródło AI za pomocą klucza API od usługodawcy lub łącząc się z lokalnie hostowanym modelem.",h$e="Zarejestruj się i Podłącz Portfel",f$e="Dodaj dostawcę",d$e="Połączenie",p$e="Serwery MCP",m$e="Dostawca AI",g$e="Edytuj dostawcę AI",y$e="Dostawca",b$e="Nazwa",v$e="URL",x$e="Wpisz nazwę",w$e="Wpisz adres URL",S$e="Klucz API",_$e="Wpisz klucz API",C$e="Anuluj",A$e="Zapisz",E$e="Edytuj",k$e="Usuń",T$e="Uwaga",R$e="Czy na pewno chcesz usunąć tego dostawcę?",M$e="Czy na pewno chcesz usunąć ten czat?",O$e="Tak",P$e="Nie",D$e="Jak mogę pomóc?",I$e="Darmowy czat AI, asystent pisania i generator pomysłów",L$e="Zmień nazwę",N$e="Pobierz",$$e="Wyszukaj...",j$e="Dodaj plik lokalny...",B$e="Ostatnie pliki",F$e="Załączniki",z$e="Klucz API",V$e="Nowy czat",U$e="Zapytaj AI",H$e="Analizowanie...",W$e="AI chce skorzystać z tego narzędzia:",q$e=`Sprawdź każde działanie przed zatwierdzeniem
|
||
Nie gwarantujemy bezpieczeństwa ani prywatności w integracjach z podmiotami trzecimi.`,G$e="Zawsze zezwalaj narzędziu na to działanie bez ponownego pytania",K$e="Odmów",Y$e="Zezwól",X$e="Parametry wywołania narzędzia",J$e="Rezultat wywołania narzędzia",Q$e="Działanie narzędzia zakończone",Z$e="Potwierdzenie",e5e="Wybierz model",t5e="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.",n5e="Edytuj konfigurację",r5e="Wpisz swoją konfigurację JSON:",i5e="Dostępne narzędzia",s5e="narzędzia",o5e="włączone narzędzia",a5e="Włącz wszystkie narzędzia",l5e="Wyłącz wszystkie narzędzia",c5e="Uruchom ponownie",u5e="Logi",h5e="Skopiuj do schowka",f5e="Zamknij",d5e="Wyszukiwanie w internecie",p5e="Podłącz wyszukiwarkę, aby wzbogacić czat AI o najnowsze informacje z internetu.",m5e="Resetuj ustawienia",g5e="Wyszukiwarka internetowa",y5e="Wybierz wyszukiwarkę",b5e="Wszystkie narzędzia",v5e="Włącz wyszukiwanie w internecie w ustawieniach",x5e="Serwer zostanie usunięty z Twojej listy. Kontynuować?",w5e="Dostawca jest niedostępny",S5e="Czat AI może popełniać błędy. Sprawdź ważne informacje.",_5e={AIAgent:X4e,AIAgentSettings:J4e,Settings:Q4e,ConnectAIModel:Z4e,ConnectAIModelDescription:e$e,ConnectAIModelBtn:t$e,ChatHistory:n$e,NoChatYet:r$e,ChooseHowConnect:i$e,SelectHowConnect:s$e,SelectHowConnectDescription:o$e,ONLYOFFICEWallet:a$e,ONLYOFFICEWalletDescription:l$e,AIProviders:c$e,AIProvidersDescription:u$e,RegisterConnectWallet:h$e,AddProvider:f$e,Connection:d$e,MCPServers:p$e,AIProvider:m$e,EditAIProvider:g$e,Provider:y$e,Name:b$e,URL:v$e,EnterName:x$e,EnterURL:w$e,Key:S$e,EnterKey:_$e,Cancel:C$e,Save:A$e,Edit:E$e,Delete:k$e,Warning:T$e,WantDeleteProvider:R$e,WantDeleteChat:M$e,Yes:O$e,No:P$e,WelcomeTitle:D$e,WelcomeDescription:I$e,Rename:L$e,Download:N$e,Search:$$e,AddLocalFile:j$e,RecentFiles:B$e,Attachments:F$e,APIKey:z$e,NewChat:V$e,AskAI:U$e,Analyzing:H$e,AIWouldLikeUseThisTool:W$e,ReviewEachAction:q$e,AlwaysAllow:G$e,Deny:K$e,Allow:Y$e,ToolCallArguments:X$e,ToolCallResult:J$e,ToolExecuted:Q$e,Confirmation:Z$e,SelectModel:e5e,CustomServersDescription:t5e,EditConfiguration:n5e,EnterYourJSONConfiguration:r5e,AvailableTools:i5e,Tools:s5e,ToolsEnabled:o5e,EnableAllTools:a5e,DisableAllTools:l5e,Restart:c5e,Logs:u5e,CopyToClipboard:h5e,Close:f5e,WebSearch:d5e,WebSearchDescription:p5e,ResetSettings:m5e,WebSearchEngine:g5e,SelectEngine:y5e,AllTools:b5e,EnableWebSearch:v5e,WantDeleteServer:x5e,NoModelsAvailable:w5e,CheckInfo:S5e},C5e="Agente de IA",A5e="Configurações do agente de IA",E5e="Configurações",k5e="Conecte um modelo de IA para começar",T5e="Nenhum modelo de IA está conectado ainda. Conecte um modelo para começar a interagir com ele aqui mesmo na interface.",R5e="Conectar um modelo de IA",M5e="Histórico do bate-papo",O5e="Ainda não há histórico de bate-papo...",P5e="Escolha como conectar a IA",D5e="Selecione como deseja ativar os recursos de IA no ONLYOFFICE.",I5e="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.",L5e="Carteira ONLYOFFICE",N5e="Recarregue seu saldo com um cartão e use instantaneamente todos os recursos de IA.",$5e="Seu provedor de IA",j5e="Conecte sua própria fonte de IA — seja por meio de uma chave de API de um provedor ou um modelo hospedado localmente.",B5e="Registre e conecte sua carteira",F5e="Adicionar provedor",z5e="Conexão",V5e="Servidores MCP",U5e="Provedor de IA",H5e="Editar provedor de IA",W5e="Fornecedor",q5e="Nome",G5e="URL",K5e="Digite o nome",Y5e="Inserir URL",X5e="Chave de API",J5e="Cancelar",Q5e="Salvar",Z5e="Editar",eje="Excluir",tje="Aviso",nje="Tem certeza de que deseja excluir este provedor?",rje="Tem certeza de que deseja excluir este chat?",ije="Sim",sje="Não",oje="Como posso ajudar?",aje="Chat gratuito com IA, assistente de escrita e gerador de ideias",lje="Renomear",cje="Baixar",uje="Pesquisar...",hje="Adicionar arquivo local...",fje="Arquivos recentes",dje="Anexos",pje="Chave de API",mje="Novo bate-papo",gje="Pergunte à IA",yje="Analisando...",bje="Al gostaria de usar esta ferramenta:",vje="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.",xje="Permitir que esta ferramenta execute esta ação sem perguntar novamente",wje="Negar",Sje="Permitir",_je="Argumentos da chamada da ferramenta",Cje="Resultado da chamada da ferramenta",Aje="Ferramenta executada",Eje="Confirmação",kje="Selecionar modelo",Tje="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.",Rje="Editar configuração",Mje="Digite sua configuração JSON:",Oje="Ferramentas disponíveis",Pje="ferramentas",Dje="ferramentas ativadas",Ije="Ativar todas as ferramentas",Lje="Desativar todas as ferramentas",Nje="Reiniciar",$je="Registros",jje="Copiar para a área de transferência",Bje="Fechar",Fje="Busca na Web",zje="Conecte um mecanismo de busca na web para aprimorar bate-papos com IA com informações em tempo real da internet.",Vje="Redefinir configurações",Uje="Mecanismo de busca na Web",Hje="Selecionar motor",Wje="Todas as ferramentas",qje="Ativar pesquisa na Web nas configurações",Gje="Este servidor será removido da sua lista. Deseja continuar ?",Kje="Fornecedor não disponível",Yje="IA Bater papo Podem ocorrer erros. Verifique informações importantes.",Xje={AIAgent:C5e,AIAgentSettings:A5e,Settings:E5e,ConnectAIModel:k5e,ConnectAIModelDescription:T5e,ConnectAIModelBtn:R5e,ChatHistory:M5e,NoChatYet:O5e,ChooseHowConnect:P5e,SelectHowConnect:D5e,SelectHowConnectDescription:I5e,ONLYOFFICEWallet:L5e,ONLYOFFICEWalletDescription:N5e,AIProviders:$5e,AIProvidersDescription:j5e,RegisterConnectWallet:B5e,AddProvider:F5e,Connection:z5e,MCPServers:V5e,AIProvider:U5e,EditAIProvider:H5e,Provider:W5e,Name:q5e,URL:G5e,EnterName:K5e,EnterURL:Y5e,Key:X5e,"EnterKey ":"Insira a chave da API",Cancel:J5e,Save:Q5e,Edit:Z5e,Delete:eje,Warning:tje,WantDeleteProvider:nje,WantDeleteChat:rje,Yes:ije,No:sje,WelcomeTitle:oje,WelcomeDescription:aje,Rename:lje,Download:cje,Search:uje,AddLocalFile:hje,RecentFiles:fje,Anexos:dje,APIKey:pje,Attachments:mje,AskAI:gje,Analyzing:yje,AIWouldLikeUseThisTool:bje,ReviewEachAction:vje,AlwaysAllow:xje,Deny:wje,Allow:Sje,ToolCallArguments:_je,ToolCallResult:Cje,ToolExecuted:Aje,Confirmation:Eje,SelectModel:kje,CustomServersDescription:Tje,EditConfiguration:Rje,EnterYourJSONConfiguration:Mje,AvailableTools:Oje,Tools:Pje,ToolsEnabled:Dje,EnableAllTools:Ije,DisableAllTools:Lje,Restart:Nje,Logs:$je,CopyToClipboard:jje,Close:Bje,WebSearch:Fje,WebSearchDescription:zje,ResetSettings:Vje,WebSearchEngine:Uje,SelectEngine:Hje,AllTools:Wje,EnableWebSearch:qje,WantDeleteServer:Gje,NoModelsAvailable:Kje,CheckInfo:Yje},Jje="Agent AI",Qje="Nastavenia agenta AI",Zje="Nastavenia",eBe="Pripojte model AI, aby ste mohli začať",tBe="Zatiaľ nie je pripojený žiadny model AI. Pripojte model AI, aby ste s ním mohli komunikovať priamo v tomto rozhraní.",nBe="Pripojiť model AI",rBe="História chatu",iBe="Zatiaľ tu nie je žiadna história chatu...",sBe="Vyberte spôsob pripojenia AI",oBe="Vyberte, ako chcete povoliť funkcie AI v ONLYOFFICE.",aBe="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.",lBe="ONLYOFFICE Peňaženka",cBe="Dobíjajte svoj kredit pomocou karty a okamžite využívajte všetky funkcie AI.",uBe="Váš provider pre AI",hBe="Pripojte svoj vlastný model AI – buď prostredníctvom API kľúča od providera, alebo nainštalujte lokálny model AI",fBe="Registrovať a pripojiť Peňaženku",dBe="Pridať providera",pBe="Pripojenie",mBe="MCP Servery",gBe="AI Provider",yBe="Upraviť AI Providera",bBe="Provider",vBe="Názov",xBe="URL",wBe="Zadať názov",SBe="Zadať URL",_Be="API kľúč",CBe="Zadať API kľúč",ABe="Zrušiť",EBe="Uložiť",kBe="Upraviť",TBe="Vymazať",RBe="Upozornenie",MBe="Naozaj chcete vymazať tohto providera?",OBe="Naozaj chcete vymazať tento chat?",PBe="Áno",DBe="Nie",IBe="Ako môžem pomôcť?",LBe="Bezplatný AI chat, asistent na písanie textov a generátor nápadov.",NBe="Premenovať",$Be="Stiahnuť",jBe="Hľadať...",BBe="Pridať lokálny súbor...",FBe="Nedávne súbory",zBe="Prílohy",VBe="API kľúč",UBe="Nový chat",HBe="Opýtať sa AI",WBe="Prebieha analýza...",qBe="Al by chcel použiť tento nástroj:",GBe=`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.`,KBe="Vždy povoliť tomuto nástroju vykonať túto akciu bez opýtania",YBe="Odmietnuť",XBe="Povoliť",JBe="Argumenty volania nástroja",QBe="Výsledok volania nástroja",ZBe="Nástroj vykonaný",e8e="Potvrdenie",t8e="Vybrať model",n8e="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.",r8e="Upraviť konfiguráciu",i8e="Zadajte svoju konfiguráciu JSON:",s8e="Dostupné nástroje",o8e="nástroje",a8e="povolené nástroje",l8e="Povoliť všetky nástroje",c8e="Vypnúť všetky nástroje",u8e="Reštartovať",h8e="Protokoly",f8e="Kopírovať do schránky",d8e="Zatvoriť",p8e="Hľadať na webe",m8e="Pripojte webový vyhľadávač, aby mohol AI chat využívať aktuálne údaje z internetu v reálnom čase.",g8e="Obnoviť nastavenia",y8e="Webový vyhľadávač",b8e="Vybrať vyhľadávač",v8e="Všetky nástroje",x8e="Povoliť vyhľadávanie na webe v nastaveniach",w8e="Tento server bude odstránený z vášho zoznamu. Pokračovať?",S8e="Provider nie je dostupný",_8e="AI chat môže robiť chyby. Kontrolujte dôležité informácie.",C8e={AIAgent:Jje,AIAgentSettings:Qje,Settings:Zje,ConnectAIModel:eBe,ConnectAIModelDescription:tBe,ConnectAIModelBtn:nBe,ChatHistory:rBe,NoChatYet:iBe,ChooseHowConnect:sBe,SelectHowConnect:oBe,SelectHowConnectDescription:aBe,ONLYOFFICEWallet:lBe,ONLYOFFICEWalletDescription:cBe,AIProviders:uBe,AIProvidersDescription:hBe,RegisterConnectWallet:fBe,AddProvider:dBe,Connection:pBe,MCPServers:mBe,AIProvider:gBe,EditAIProvider:yBe,Provider:bBe,Name:vBe,URL:xBe,EnterName:wBe,EnterURL:SBe,Key:_Be,EnterKey:CBe,Cancel:ABe,Save:EBe,Edit:kBe,Delete:TBe,Warning:RBe,WantDeleteProvider:MBe,WantDeleteChat:OBe,Yes:PBe,No:DBe,WelcomeTitle:IBe,WelcomeDescription:LBe,Rename:NBe,Download:$Be,Search:jBe,AddLocalFile:BBe,RecentFiles:FBe,Attachments:zBe,APIKey:VBe,NewChat:UBe,AskAI:HBe,Analyzing:WBe,AIWouldLikeUseThisTool:qBe,ReviewEachAction:GBe,AlwaysAllow:KBe,Deny:YBe,Allow:XBe,ToolCallArguments:JBe,ToolCallResult:QBe,ToolExecuted:ZBe,Confirmation:e8e,SelectModel:t8e,CustomServersDescription:n8e,EditConfiguration:r8e,EnterYourJSONConfiguration:i8e,AvailableTools:s8e,Tools:o8e,ToolsEnabled:a8e,EnableAllTools:l8e,DisableAllTools:c8e,Restart:u8e,Logs:h8e,CopyToClipboard:f8e,Close:d8e,WebSearch:p8e,WebSearchDescription:m8e,ResetSettings:g8e,WebSearchEngine:y8e,SelectEngine:b8e,AllTools:v8e,EnableWebSearch:x8e,WantDeleteServer:w8e,NoModelsAvailable:S8e,CheckInfo:_8e};wr.use(Yre).init({resources:{en:{translation:URe},ru:{translation:yOe},"cs-CZ":{translation:WPe},de:{translation:vIe},es:{translation:GLe},fr:{translation:w3e},it:{translation:Y4e},pl:{translation:_5e},"pt-BR":{translation:Xje},"sl-SI":{translation:C8e}},fallbackLng:"en",interpolation:{escapeValue:!1}});const A8e=()=>{const[t,e]=k.useState(!1),[n,r]=k.useState(!1),{messages:i,stopMessage:s}=Yh(),{providers:o,fetchProvidersModels:a}=ns(),{currentPage:c}=zm(),{manageToolData:h}=Ts();Gke({isReady:t}),Kke(),Yke({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(()=>(Ore().then(()=>e(!0)),()=>{ts.close()}),[]);const b=OY({messages:i,onNew:f,onCancel:async()=>{s()},convertMessage:d,adapters:{attachments:new vY([new mY,new yY])}});return c!=="settings"&&!o.length&&!i.length?C.jsx(c5,{children:C.jsx(Xie,{})}):C.jsxs(c5,{children:[C.jsx(EX,{runtime:b,children:c==="settings"?C.jsx(Ame,{}):C.jsx(wke,{})}),n?C.jsx(Hke,{onAllow:m,onDeny:y,onClose:()=>r(!1)}):null]})},C5=()=>{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"),$K.createRoot(t).render(C.jsx(k.StrictMode,{children:C.jsx(A8e,{})})))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",C5):C5();
|