(()=>{"use strict";var t={d:(e,s)=>{for(var a in s)t.o(s,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:s[a]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{LAZYID:()=>c,LazyHandler:()=>d,LazyList:()=>h,LazyMathDocumentMixin:()=>u,LazyMathItemMixin:()=>z});const s=("undefined"!=typeof window?window:global).MathJax._.components.global,a=(s.GLOBAL,s.isObject,s.combineConfig,s.combineDefaults,s.combineWithMathJax),i=(s.MathJax,MathJax._.core.MathItem),l=(i.protoItem,i.AbstractMathItem,i.STATE),r=i.newState,n=MathJax._.util.Retries,o=n.handleRetriesFor;n.retryAfter;var y=function(t,e,s,a){return new(s||(s=Promise))((function(i,l){function r(t){try{o(a.next(t))}catch(t){l(t)}}function n(t){try{o(a.throw(t))}catch(t){l(t)}}function o(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,n)}o((a=a.apply(t,e||[])).next())}))};class h{constructor(){this.id=0,this.items=new Map}add(t){const e=String(this.id++);return this.items.set(e,t),e}get(t){return this.items.get(t)}delete(t){return this.items.delete(t)}}r("LAZYALWAYS",l.FINDMATH+3);const c="data-mjx-lazy";function z(t){return class extends t{constructor(...t){super(...t),this.lazyCompile=!0,this.lazyTypeset=!0,this.lazyTex=!1,this.attachSpeech=t=>{var e;this.state()>=l.ATTACHSPEECH||(this.lazyTypeset||null===(e=super.attachSpeech)||void 0===e||e.call(this,t),this.state(l.ATTACHSPEECH))},this.end.node||(this.lazyCompile=this.lazyTypeset=!1)}compile(t){this.lazyCompile?this.state()window.requestIdleCallback(s):()=>setTimeout(s,10),window){let t=!1;const e=()=>{t||this.lazyTypesetAll(),t=!0};window.matchMedia("print").addListener(e),window.addEventListener("beforeprint",e)}}lazyAlways(){if(this.lazyAlwaysContainers&&!this.processed.isSet("lazyAlways")){for(const t of this.math){const e=t;e.lazyTypeset&&this.lazyIsAlways(e)&&(e.lazyCompile=e.lazyTypeset=!1)}this.processed.set("lazyAlways")}}lazyIsAlways(t){if(t.state()=i&&(this.lazyAlwaysIndex=0)}while(this.lazyAlwaysIndex!==a)}return!1}state(t,e=!1){return super.state(t,e),tthis.render())).then((()=>{e&&(this.outputJax.options.fontCache=e)}))}))}lazyObserve(t){for(const e of t){const t=this.adaptor.getAttribute(e.target,c);this.lazyList.get(t)&&(e.isIntersecting?(this.lazySet.add(t),this.lazyIdle||(this.lazyIdle=!0,this.lazyProcessSet())):this.lazySet.delete(t))}}lazyHandleSet(){const t=this.lazySet;this.lazySet=new Set,this.lazyPromise=this.lazyPromise.then((()=>{let e=this.compileEarlierItems(t)?l.COMPILED:l.TYPESET;return e=this.resetStates(t,e),this.state(e-1,null),o((()=>{this.render(),this.lazyIdle=!1}))}))}resetStates(t,e){for(const s of t.values()){const t=this.lazyList.get(s);t.lazyCompile?(t.state(l.COMPILED-1),e=l.COMPILED):Object.hasOwn(t.metrics,"em")?t.state(l.TYPESET-1):(t.state(l.METRICS-1),e=l.METRICS),t.lazyCompile=t.lazyTypeset=!1,t.lazyMarker&&this.lazyObserver.unobserve(t.lazyMarker)}return e}compileEarlierItems(t){const e=this.earliestTex(t);if(!e)return!1;let s=!1;for(const t of this.math){const a=t;if(a===e||!(null==a?void 0:a.lazyCompile)||!a.lazyTex)break;a.lazyCompile=!1,a.lazyMarker&&this.lazyObserver.unobserve(a.lazyMarker),a.state(l.COMPILED-1),s=!0}return s}earliestTex(t){let e=null,s=null;for(const a of t.values()){const t=this.lazyList.get(a);t.lazyTex&&((null===e||parseInt(a)d(t)))})();