mathjax
Version:
Beautiful and accessible math in all browsers. MathJax is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all browsers. This package includes the packaged components (install mathjax-full to get the source
1 lines • 75.1 kB
JavaScript
(()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var e={};t.r(e),t.d(e,{MJContextMenu:()=>lt});var s={};t.r(s),t.d(s,{clearspeakMenu:()=>St,localeMenu:()=>wt});var i={};t.r(i),t.d(i,{copyToClipboard:()=>It,isMac:()=>Lt});var n={};t.r(n),t.d(n,{annotation:()=>Pt,copyAnnotations:()=>Dt,showAnnotations:()=>Nt});var o={};t.r(o),t.d(o,{RadioCompare:()=>Xt});var a={};t.r(a),t.d(a,{MmlVisitor:()=>Kt});var r={};t.r(r),t.d(r,{Menu:()=>Zt});var l={};t.r(l),t.d(l,{MenuHandler:()=>te,MenuMathDocumentMixin:()=>Qt,MenuMathItemMixin:()=>Yt});const h=("undefined"!=typeof window?window:t.g).MathJax._.components.global,c=(h.GLOBAL,h.isObject,h.combineConfig,h.combineDefaults,h.combineWithMathJax),u=h.MathJax;var d;!function(t){t[t.RETURN=13]="RETURN",t[t.ESCAPE=27]="ESCAPE",t[t.SPACE=32]="SPACE",t[t.LEFT=37]="LEFT",t[t.UP=38]="UP",t[t.RIGHT=39]="RIGHT",t[t.DOWN=40]="DOWN"}(d||(d={}));const p="click",m="dblclick",b="mousedown",g="mouseup",f="mouseover",v="mouseout",x="selectstart";class E{constructor(){this.bubble=!1}bubbleKey(){this.bubble=!0}keydown(t){switch(t.keyCode){case d.ESCAPE:this.escape(t);break;case d.RIGHT:this.right(t);break;case d.LEFT:this.left(t);break;case d.UP:this.up(t);break;case d.DOWN:this.down(t);break;case d.RETURN:case d.SPACE:this.space(t);break;default:return}this.bubble?this.bubble=!1:this.stop(t)}escape(t){}space(t){}left(t){}right(t){}up(t){}down(t){}stop(t){t&&(t.stopPropagation(),t.preventDefault(),t.cancelBubble=!0)}mousedown(t){return this.stop(t)}mouseup(t){return this.stop(t)}mouseover(t){return this.stop(t)}mouseout(t){return this.stop(t)}click(t){return this.stop(t)}addEvents(t){t.addEventListener(b,this.mousedown.bind(this)),t.addEventListener(g,this.mouseup.bind(this)),t.addEventListener(f,this.mouseover.bind(this)),t.addEventListener(v,this.mouseout.bind(this)),t.addEventListener(p,this.click.bind(this)),t.addEventListener("keydown",this.keydown.bind(this)),t.addEventListener("dragstart",this.stop.bind(this)),t.addEventListener(x,this.stop.bind(this)),t.addEventListener("contextmenu",this.stop.bind(this)),t.addEventListener(m,this.stop.bind(this))}}class y extends E{addAttributes(t){for(const e in t)this.html.setAttribute(e,t[e])}get html(){return this._html||this.generateHtml(),this._html}set html(t){this._html=t,this.addEvents(t)}generateHtml(){const t=document.createElement("div");t.classList.add(this.className),t.setAttribute("role",this.role),this.html=t}focus(){const t=this.html;t.setAttribute("tabindex","0"),setTimeout((()=>t.focus()),50)}unfocus(){const t=this.html;t.hasAttribute("tabindex")&&t.setAttribute("tabindex","-1");try{t.blur()}catch(t){}t.blur()}}class M extends y{constructor(){super(...arguments),this.posted=!1}isPosted(){return this.posted}post(t,e){this.posted||(void 0!==t&&void 0!==e&&this.html.setAttribute("style","left: "+t+"px; top: "+e+"px;"),this.display(),this.posted=!0)}unpost(){if(!this.posted)return;const t=this.html;t.parentNode&&t.parentNode.removeChild(t),this.posted=!1}}function C(t){return"CtxtMenu_"+t}function S(t){return C(t)}function O(t){return C(t)}const w={ATTACHED:S("Attached"),CONTEXTMENU:S("ContextMenu"),MENU:S("Menu"),MENUARROW:S("MenuArrow"),MENUACTIVE:S("MenuActive"),MENUCHECK:S("MenuCheck"),MENUCLOSE:S("MenuClose"),MENUCOMBOBOX:S("MenuComboBox"),MENUDISABLED:S("MenuDisabled"),MENUFRAME:S("MenuFrame"),MENUITEM:S("MenuItem"),MENULABEL:S("MenuLabel"),MENURADIOCHECK:S("MenuRadioCheck"),MENUINPUTBOX:S("MenuInputBox"),MENURULE:S("MenuRule"),MENUSLIDER:S("MenuSlider"),MOUSEPOST:S("MousePost"),RTL:S("RTL"),INFO:S("Info"),INFOCLOSE:S("InfoClose"),INFOCONTENT:S("InfoContent"),INFOSIGNATURE:S("InfoSignature"),INFOTITLE:S("InfoTitle"),SLIDERVALUE:S("SliderValue"),SLIDERBAR:S("SliderBar"),SELECTION:S("Selection"),SELECTIONBOX:S("SelectionBox"),SELECTIONMENU:S("SelectionMenu"),SELECTIONDIVIDER:S("SelectionDivider"),SELECTIONITEM:S("SelectionItem")},k={COUNTER:O("Counter"),KEYDOWNFUNC:O("keydownFunc"),CONTEXTMENUFUNC:O("contextmenuFunc"),OLDTAB:O("Oldtabindex"),TOUCHFUNC:O("TouchFunc")};class A extends y{constructor(t,e){super(),this._menu=t,this._type=e,this.className=w.MENUITEM,this.role="menuitem",this.hidden=!1}get menu(){return this._menu}set menu(t){this._menu=t}get type(){return this._type}hide(){this.hidden=!0,this.menu.generateMenu()}show(){this.hidden=!1,this.menu.generateMenu()}isHidden(){return this.hidden}}function T(t){const e=t.menu;e.baseMenu?e.baseMenu.unpost():e.unpost()}function L(t){const e=t.menu;return(e.baseMenu?e.baseMenu:e).store.active}function I(t,e){console.error("ContextMenu Error: "+e)}function N(){return D++}let D=0;class R extends A{constructor(t,e,s,i){super(t,e),this._content=s,this.disabled=!1,this.callbacks=[],this._id=i||s}get content(){return this._content}set content(t){this._content=t,this.generateHtml(),this.menu&&this.menu.generateHtml()}get id(){return this._id}press(){this.disabled||(this.executeAction(),this.executeCallbacks_())}executeAction(){}registerCallback(t){-1===this.callbacks.indexOf(t)&&this.callbacks.push(t)}unregisterCallback(t){const e=this.callbacks.indexOf(t);-1!==e&&this.callbacks.splice(e,1)}mousedown(t){this.press(),this.stop(t)}mouseover(t){this.focus(),this.stop(t)}mouseout(t){this.deactivate(),this.stop(t)}generateHtml(){super.generateHtml();const t=this.html;t.setAttribute("aria-disabled","false"),t.textContent=this.content}activate(){this.disabled||this.html.classList.add(w.MENUACTIVE)}deactivate(){this.html.classList.remove(w.MENUACTIVE)}focus(){this.menu.focused=this,super.focus(),this.activate()}unfocus(){this.deactivate(),super.unfocus()}escape(t){T(this)}up(t){this.menu.up(t)}down(t){this.menu.down(t)}left(t){this.menu.left(t)}right(t){this.menu.right(t)}space(t){this.press()}disable(){this.disabled=!0;const t=this.html;t.classList.add(w.MENUDISABLED),t.setAttribute("aria-disabled","true")}enable(){this.disabled=!1;const t=this.html;t.classList.remove(w.MENUDISABLED),t.removeAttribute("aria-disabled")}executeCallbacks_(){for(const t of this.callbacks)try{t(this)}catch(t){I(0,"Callback for menu entry "+this.id+" failed.")}}}class P extends R{static fromJson(t,{content:e,menu:s,id:i},n){const o=new this(n,e,i),a=t.get("subMenu")(t,s,o);return o.submenu=a,o}constructor(t,e,s){super(t,"submenu",e,s),this._submenu=null}set submenu(t){this._submenu=t}get submenu(){return this._submenu}mouseover(t){this.focus(),this.stop(t)}mouseout(t){this.stop(t)}unfocus(){if(this.submenu.isPosted()){if(this.menu.focused!==this)return super.unfocus(),void this.menu.unpostSubmenus();this.html.setAttribute("tabindex","-1"),this.html.blur()}else super.unfocus()}focus(){super.focus(),this.submenu.isPosted()||this.disabled||this.submenu.post()}executeAction(){this.submenu.isPosted()?this.submenu.unpost():this.submenu.post()}generateHtml(){super.generateHtml();const t=this.html;this.span=document.createElement("span"),this.span.textContent="\u25ba",this.span.classList.add(w.MENUARROW),this.span.setAttribute("aria-hidden","true"),t.appendChild(this.span),t.setAttribute("aria-haspopup","true")}left(t){this.submenu.isPosted()?this.submenu.unpost():super.left(t)}right(t){this.submenu.isPosted()?this.submenu.down(t):this.submenu.post()}toJson(){return{type:""}}}class U extends M{constructor(){super(...arguments),this.className=w.CONTEXTMENU,this.role="menu",this._items=[],this._baseMenu=null}set baseMenu(t){this._baseMenu=t}get baseMenu(){return this._baseMenu}get items(){return this._items}set items(t){this._items=t}get pool(){return this.variablePool}get focused(){return this._focused}set focused(t){if(this._focused===t)return;this._focused||this.unfocus();const e=this._focused;this._focused=t,e&&e.unfocus()}up(t){const e=this.items.filter((t=>t instanceof R&&!t.isHidden()));if(0===e.length)return;if(!this.focused)return void e[e.length-1].focus();let s=e.indexOf(this.focused);-1!==s&&(s=s?--s:e.length-1,e[s].focus())}down(t){const e=this.items.filter((t=>t instanceof R&&!t.isHidden()));if(0===e.length)return;if(!this.focused)return void e[0].focus();let s=e.indexOf(this.focused);-1!==s&&(s++,s=s===e.length?0:s,e[s].focus())}generateHtml(){super.generateHtml(),this.generateMenu()}generateMenu(){const t=this.html;t.classList.add(w.MENU);for(const e of this.items){if(!e.isHidden()){t.appendChild(e.html);continue}const s=e.html;s.parentNode&&s.parentNode.removeChild(s)}}post(t,e){this.variablePool.update(),super.post(t,e)}unpostSubmenus(){const t=this.items.filter((t=>t instanceof P));for(const e of t)e.submenu.unpost(),e!==this.focused&&e.unfocus()}unpost(){super.unpost(),this.unpostSubmenus(),this.focused=null}find(t){for(const e of this.items)if("rule"!==e.type){if(e.id===t)return e;if("submenu"===e.type){const s=e.submenu.find(t);if(s)return s}}return null}}class _{constructor(t){this.menu=t,this.store=[],this._active=null,this.counter=0,this.attachedClass=w.ATTACHED+"_"+N(),this.taborder=!0,this.attrMap={}}set active(t){do{if(-1!==this.store.indexOf(t)){this._active=t;break}t=t.parentNode}while(t)}get active(){return this._active}next(){const t=this.store.length;if(0===t)return this.active=null,null;let e=this.store.indexOf(this.active);return e=-1===e?0:e<t-1?e+1:0,this.active=this.store[e],this.active}previous(){const t=this.store.length;if(0===t)return this.active=null,null;const e=t-1;let s=this.store.indexOf(this.active);return s=-1===s||0===s?e:s-1,this.active=this.store[s],this.active}clear(){this.remove(this.store)}insert(t){const e=t instanceof HTMLElement?[t]:t;for(const t of e)this.insertElement(t);this.sort()}remove(t){const e=t instanceof HTMLElement?[t]:t;for(const t of e)this.removeElement(t);this.sort()}inTaborder(t){this.taborder&&!t&&this.removeTaborder(),!this.taborder&&t&&this.insertTaborder(),this.taborder=t}insertTaborder(){this.taborder&&this.insertTaborder_()}removeTaborder(){this.taborder&&this.removeTaborder_()}insertElement(t){t.classList.contains(this.attachedClass)||(t.classList.add(this.attachedClass),this.taborder&&this.addTabindex(t),this.addEvents(t))}removeElement(t){t.classList.contains(this.attachedClass)&&(t.classList.remove(this.attachedClass),this.taborder&&this.removeTabindex(t),this.removeEvents(t))}sort(){const t=document.getElementsByClassName(this.attachedClass);this.store=[].slice.call(t)}insertTaborder_(){this.store.forEach((t=>t.setAttribute("tabindex","0")))}removeTaborder_(){this.store.forEach((t=>t.setAttribute("tabindex","-1")))}addTabindex(t){t.hasAttribute("tabindex")&&t.setAttribute(k.OLDTAB,t.getAttribute("tabindex")),t.setAttribute("tabindex","0")}removeTabindex(t){t.hasAttribute(k.OLDTAB)?(t.setAttribute("tabindex",t.getAttribute(k.OLDTAB)),t.removeAttribute(k.OLDTAB)):t.removeAttribute("tabindex")}addEvents(t){t.hasAttribute(k.COUNTER)||(this.addEvent(t,"contextmenu",this.menu.post.bind(this.menu)),this.addEvent(t,"keydown",this.keydown.bind(this)),t.setAttribute(k.COUNTER,this.counter.toString()),this.counter++)}addEvent(t,e,s){const i=k[e.toUpperCase()+"FUNC"];this.attrMap[i+this.counter]=s,t.addEventListener(e,s)}removeEvents(t){if(!t.hasAttribute(k.COUNTER))return;const e=t.getAttribute(k.COUNTER);this.removeEvent(t,"contextmenu",e),this.removeEvent(t,"keydown",e),t.removeAttribute(k.COUNTER)}removeEvent(t,e,s){const i=k[e.toUpperCase()+"FUNC"],n=this.attrMap[i+s];t.removeEventListener(e,n)}keydown(t){t.keyCode===d.SPACE&&(this.menu.post(t),t.preventDefault(),t.stopImmediatePropagation())}}class J{constructor(){this.pool={}}insert(t){this.pool[t.name]=t}lookup(t){return this.pool[t]}remove(t){delete this.pool[t]}update(){for(const t in this.pool)this.pool[t].update()}}class V extends U{static fromJson(t,{pool:e,items:s,id:i=""}){const n=new this(t);n.id=i;const o=t.get("variable");e.forEach((e=>o(t,e,n.pool)));const a=t.get("items")(t,s,n);return n.items=a,n}constructor(t){super(),this.factory=t,this.id="",this.moving=!1,this._store=new _(this),this.widgets=[],this.variablePool=new J}generateHtml(){this.isPosted()&&this.unpost(),super.generateHtml(),this._frame=document.createElement("div"),this._frame.classList.add(w.MENUFRAME);const t="left: 0px; top: 0px; z-index: 200; width: 100%; height: 100%; border: 0px; padding: 0px; margin: 0px;";this._frame.setAttribute("style","position: absolute; "+t);const e=document.createElement("div");e.setAttribute("style","position: fixed; "+t),this._frame.appendChild(e),e.addEventListener("mousedown",function(t){this.unpost(),this.unpostWidgets(),this.stop(t)}.bind(this))}display(){document.body.appendChild(this.frame),this.frame.appendChild(this.html),this.focus()}escape(t){this.unpost(),this.unpostWidgets()}unpost(){if(super.unpost(),this.widgets.length>0)return;this.frame.parentNode.removeChild(this.frame);const t=this.store;this.moving||t.insertTaborder(),t.active.focus()}left(t){this.move_(this.store.previous())}right(t){this.move_(this.store.next())}get frame(){return this._frame}get store(){return this._store}post(t,e){if(void 0!==e)return this.moving||this.store.removeTaborder(),void super.post(t,e);const s=t;let i,n,o;if(s instanceof Event?(i=s.target,this.stop(s)):i=s,s instanceof MouseEvent&&(n=s.pageX,o=s.pageY,n||o||!s.clientX||(n=s.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,o=s.clientY+document.body.scrollTop+document.documentElement.scrollTop)),!n&&!o&&i){const t=window.pageXOffset||document.documentElement.scrollLeft,e=window.pageYOffset||document.documentElement.scrollTop,s=i.getBoundingClientRect();n=(s.right+s.left)/2+t,o=(s.bottom+s.top)/2+e}this.store.active=i,this.anchor=this.store.active;const a=this.html;n+a.offsetWidth>document.body.offsetWidth-5&&(n=document.body.offsetWidth-a.offsetWidth-5),this.post(n,o)}registerWidget(t){this.widgets.push(t)}unregisterWidget(t){const e=this.widgets.indexOf(t);e>-1&&this.widgets.splice(e,1),0===this.widgets.length&&this.unpost()}unpostWidgets(){this.widgets.forEach((t=>t.unpost()))}toJson(){return{type:""}}move_(t){this.anchor&&t!==this.anchor&&(this.moving=!0,this.unpost(),this.post(t),this.moving=!1)}}class B extends U{static fromJson(t,{items:e},s){const i=new this(s),n=t.get("items")(t,e,i);return i.items=n,i}constructor(t){super(),this._anchor=t,this.variablePool=this.anchor.menu.pool,this.setBaseMenu()}get anchor(){return this._anchor}post(){if(!this.anchor.menu.isPosted())return;let t=this.anchor.html;const e=this.html,s=this.baseMenu.frame,i=t.offsetWidth;let n=i-2,o=0;for(;t&&t!==s;)n+=t.offsetLeft,o+=t.offsetTop,t=t.parentNode;n+e.offsetWidth>document.body.offsetWidth-5&&(n=Math.max(5,n-i-e.offsetWidth+6)),super.post(n,o)}display(){this.baseMenu.frame.appendChild(this.html)}setBaseMenu(){let t=this;do{t=t.anchor.menu}while(t instanceof B);this.baseMenu=t}left(t){this.focused=null,this.anchor.focus()}toJson(){return{type:""}}}class H extends R{generateHtml(){super.generateHtml();const t=this.html;this.span||this.generateSpan(),t.appendChild(this.span),this.update()}register(){this.variable.register(this)}unregister(){this.variable.unregister(this)}update(){this.updateAria(),this.span&&this.updateSpan()}}class j extends H{static fromJson(t,{content:e,variable:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"radio",e,i),this.role="menuitemradio",this.variable=t.pool.lookup(s),this.register()}executeAction(){this.variable.setValue(this.id),T(this)}generateSpan(){this.span=document.createElement("span"),this.span.textContent="\u2713",this.span.classList.add(w.MENURADIOCHECK),this.span.setAttribute("aria-hidden","true")}updateAria(){this.html.setAttribute("aria-checked",this.variable.getValue()===this.id?"true":"false")}updateSpan(){this.span.style.display=this.variable.getValue()===this.id?"":"none"}toJson(){return{type:""}}}class F extends A{static fromJson(t,e,s){return new this(s)}constructor(t){super(t,"rule"),this.className=w.MENUITEM,this.role="separator"}generateHtml(){super.generateHtml();const t=this.html;t.classList.add(w.MENURULE),t.setAttribute("aria-orientation","vertical")}addEvents(t){}toJson(){return{type:"rule"}}}class G extends R{static fromJson(t,{content:e,action:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"command",e,i),this.command=s}mousedown(t){this.stop(t)}mouseup(t){this.press(),this.stop(t)}executeAction(){try{this.command(L(this))}catch(t){I(0,"Illegal command callback.")}T(this)}toJson(){return{type:""}}}class z{static fromJson(t,{name:e,getter:s,setter:i},n){const o=new this(e,s,i);n.insert(o)}constructor(t,e,s){this._name=t,this.getter=e,this.setter=s,this.items=[]}get name(){return this._name}getValue(t){try{return this.getter(t)}catch(t){return I(0,"Command of variable "+this.name+" failed."),null}}setValue(t,e){try{this.setter(t,e)}catch(t){I(0,"Command of variable "+this.name+" failed.")}this.update()}register(t){-1===this.items.indexOf(t)&&this.items.push(t)}unregister(t){const e=this.items.indexOf(t);-1!==e&&this.items.splice(e,1)}update(){this.items.forEach((t=>t.update()))}registerCallback(t){this.items.forEach((e=>e.registerCallback(t)))}unregisterCallback(t){this.items.forEach((e=>e.unregisterCallback(t)))}toJson(){return{type:"variable",name:this.name,getter:this.getter.toString(),setter:this.setter.toString()}}}class X extends H{static fromJson(t,{content:e,variable:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"checkbox",e,i),this.role="menuitemcheckbox",this.variable=t.pool.lookup(s),this.register()}executeAction(){this.variable.setValue(!this.variable.getValue()),T(this)}generateSpan(){this.span=document.createElement("span"),this.span.textContent="\u2713",this.span.classList.add(w.MENUCHECK),this.span.setAttribute("aria-hidden","true")}updateAria(){this.html.setAttribute("aria-checked",this.variable.getValue()?"true":"false")}updateSpan(){this.span.style.display=this.variable.getValue()?"":"none"}toJson(){return{type:""}}}class W extends H{static fromJson(t,{content:e,variable:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"combobox",e,i),this.role="combobox",this.inputEvent=!1,this.variable=t.pool.lookup(s),this.register()}executeAction(){this.variable.setValue(this.input.value,L(this))}space(t){super.space(t),T(this)}focus(){super.focus(),this.input.focus()}unfocus(){super.unfocus(),this.updateSpan()}generateHtml(){super.generateHtml();this.html.classList.add(w.MENUCOMBOBOX)}generateSpan(){this.span=document.createElement("span"),this.span.classList.add(w.MENUINPUTBOX),this.input=document.createElement("input"),this.input.addEventListener("keydown",this.inputKey.bind(this)),this.input.setAttribute("size","10em"),this.input.setAttribute("type","text"),this.input.setAttribute("tabindex","-1"),this.span.appendChild(this.input)}inputKey(t){this.bubbleKey(),this.inputEvent=!0}keydown(t){if(this.inputEvent&&t.keyCode!==d.ESCAPE&&t.keyCode!==d.RETURN)return this.inputEvent=!1,void t.stopPropagation();super.keydown(t),t.stopPropagation()}updateAria(){}updateSpan(){let t;try{t=this.variable.getValue(L(this))}catch(e){t=""}this.input.value=t}toJson(){return{type:""}}}class K extends R{static fromJson(t,{content:e,id:s},i){return new this(i,e,s)}constructor(t,e,s){super(t,"label",e,s)}generateHtml(){super.generateHtml();this.html.classList.add(w.MENULABEL)}toJson(){return{type:""}}}class $ extends H{static fromJson(t,{content:e,variable:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"slider",e,i),this.role="slider",this.labelId="ctx_slideLabel"+N(),this.valueId="ctx_slideValue"+N(),this.inputEvent=!1,this.variable=t.pool.lookup(s),this.register()}executeAction(){this.variable.setValue(this.input.value,L(this)),this.update()}space(t){super.space(t),T(this)}focus(){super.focus(),this.input.focus()}unfocus(){super.unfocus(),this.updateSpan()}generateHtml(){super.generateHtml();this.html.classList.add(w.MENUSLIDER),this.valueSpan=document.createElement("span"),this.valueSpan.setAttribute("id",this.valueId),this.valueSpan.classList.add(w.SLIDERVALUE),this.html.appendChild(this.valueSpan)}generateSpan(){this.span=document.createElement("span"),this.labelSpan=document.createElement("span"),this.labelSpan.setAttribute("id",this.labelId),this.labelSpan.appendChild(this.html.childNodes[0]),this.html.appendChild(this.labelSpan),this.input=document.createElement("input"),this.input.setAttribute("type","range"),this.input.setAttribute("min","0"),this.input.setAttribute("max","100"),this.input.setAttribute("aria-valuemin","0"),this.input.setAttribute("aria-valuemax","100"),this.input.setAttribute("aria-labelledby",this.labelId),this.input.addEventListener("keydown",this.inputKey.bind(this)),this.input.addEventListener("input",this.executeAction.bind(this)),this.input.classList.add(w.SLIDERBAR),this.span.appendChild(this.input)}inputKey(t){this.inputEvent=!0}mousedown(t){t.stopPropagation()}mouseup(t){T(this),t.stopPropagation()}keydown(t){const e=t.keyCode;return e===d.UP||e===d.DOWN?(t.preventDefault(),void super.keydown(t)):this.inputEvent&&e!==d.ESCAPE&&e!==d.RETURN?(this.inputEvent=!1,void t.stopPropagation()):(super.keydown(t),void t.stopPropagation())}updateAria(){const t=this.variable.getValue();t&&this.input&&(this.input.setAttribute("aria-valuenow",t),this.input.setAttribute("aria-valuetext",t+"%"))}updateSpan(){let t;try{t=this.variable.getValue(L(this)),this.valueSpan.innerHTML=t+"%"}catch(e){t=""}this.input.value=t}toJson(){return{type:""}}}class q extends M{constructor(t){super(),this.element=t,this.className=w.MENUCLOSE,this.role="button"}generateHtml(){const t=document.createElement("span");t.classList.add(this.className),t.setAttribute("role",this.role),t.setAttribute("tabindex","0");const e=document.createElement("span");e.textContent="\xd7",t.appendChild(e),this.html=t}display(){}unpost(){super.unpost(),this.element.unpost()}keydown(t){this.bubbleKey(),super.keydown(t)}space(t){this.unpost(),this.stop(t)}mousedown(t){this.unpost(),this.stop(t)}}class Z extends M{constructor(t,e,s){super(),this.title=t,this.signature=s,this.className=w.INFO,this.role="dialog",this.contentDiv=this.generateContent(),this.close=this.generateClose(),this.content=e||function(){return""}}attachMenu(t){this.menu=t}generateHtml(){super.generateHtml();const t=this.html;t.appendChild(this.generateTitle()),t.appendChild(this.contentDiv),t.appendChild(this.generateSignature()),t.appendChild(this.close.html),t.setAttribute("tabindex","0")}post(){super.post();const t=document.documentElement,e=this.html,s=window.innerHeight||t.clientHeight||t.scrollHeight||0,i=Math.floor(-e.offsetWidth/2),n=Math.floor((s-e.offsetHeight)/3);e.setAttribute("style","margin-left: "+i+"px; top: "+n+"px;"),window.event instanceof MouseEvent&&e.classList.add(w.MOUSEPOST),e.focus()}display(){this.menu.registerWidget(this),this.contentDiv.innerHTML=this.content();const t=this.menu.html;t.parentNode&&t.parentNode.removeChild(t),this.menu.frame.appendChild(this.html)}click(t){}keydown(t){this.bubbleKey(),super.keydown(t)}escape(t){this.unpost()}unpost(){super.unpost(),this.html.classList.remove(w.MOUSEPOST),this.menu.unregisterWidget(this)}generateClose(){const t=new q(this),e=t.html;return e.classList.add(w.INFOCLOSE),e.setAttribute("aria-label","Close Dialog Box"),t}generateTitle(){const t=document.createElement("span");return t.innerHTML=this.title,t.classList.add(w.INFOTITLE),t}generateContent(){const t=document.createElement("div");return t.classList.add(w.INFOCONTENT),t.setAttribute("tabindex","0"),t}generateSignature(){const t=document.createElement("span");return t.innerHTML=this.signature,t.classList.add(w.INFOSIGNATURE),t}toJson(){return{type:""}}}class Y extends U{static fromJson(t,{title:e,values:s,variable:i},n){const o=new this(n),a=t.get("label")(t,{content:e||"",id:e||"id"},o),r=t.get("rule")(t,{},o),l=s.map((e=>t.get("radio")(t,{content:e,variable:i,id:e},o))),h=[a,r].concat(l);return o.items=h,o}constructor(t){super(),this.anchor=t,this.className=w.SELECTIONMENU,this.variablePool=this.anchor.menu.pool,this.baseMenu=this.anchor.menu}generateHtml(){super.generateHtml(),this.items.forEach((t=>t.html.classList.add(w.SELECTIONITEM)))}display(){}right(t){this.anchor.right(t)}left(t){this.anchor.left(t)}}class Q extends Z{static fromJson(t,{title:e,signature:s,selections:i,order:n,grid:o},a){const r=new this(e,s,n,o);r.attachMenu(a);const l=i.map((e=>t.get("selectionMenu")(t,e,r)));return r.selections=l,r}constructor(t,e,s="none",i="vertical"){super(t,null,e),this.style=s,this.grid=i,this._selections=[],this.prefix="ctxt-selection",this._balanced=!0}attachMenu(t){this.menu=t}get selections(){return this._selections}set selections(t){this._selections=[],t.forEach((t=>this.addSelection(t)))}addSelection(t){t.anchor=this,this._selections.push(t)}rowDiv(t){const e=document.createElement("div");this.contentDiv.appendChild(e);const s=t.map((t=>(e.appendChild(t.html),t.html.id||(t.html.id=this.prefix+N()),t.html.getBoundingClientRect()))),i=s.map((t=>t.width)),n=i.reduce(((t,e)=>t+e),0),o=s.reduce(((t,e)=>Math.max(t,e.height)),0);return e.classList.add(w.SELECTIONDIVIDER),e.setAttribute("style","height: "+o+"px;"),[e,n,o,i]}display(){if(super.display(),this.order(),!this.selections.length)return;const t=[];let e=0,s=[];const i=this.getChunkSize(this.selections.length);for(let n=0;n<this.selections.length;n+=i){const o=this.selections.slice(n,n+i),[a,r,l,h]=this.rowDiv(o);t.push(a),e=Math.max(e,r),o.forEach((t=>t.html.style.height=l+"px")),s=this.combineColumn(s,h)}this._balanced&&(this.balanceColumn(t,s),e=s.reduce(((t,e)=>t+e),20)),t.forEach((t=>t.style.width=e+"px"))}getChunkSize(t){switch(this.grid){case"square":return Math.floor(Math.sqrt(t));case"horizontal":return Math.floor(t/Q.chunkSize);default:return Q.chunkSize}}balanceColumn(t,e){t.forEach((t=>{const s=Array.from(t.children);for(let t,i=0;t=s[i];i++)t.style.width=e[i]+"px"}))}combineColumn(t,e){let s=[],i=0;for(;t[i]||e[i];){if(!t[i]){s=s.concat(e.slice(i));break}if(!e[i]){s=s.concat(t.slice(i));break}s.push(Math.max(t[i],e[i])),i++}return s}left(t){this.move(t,(t=>(0===t?this.selections.length:t)-1))}right(t){this.move(t,(t=>t===this.selections.length-1?0:t+1))}generateHtml(){super.generateHtml(),this.html.classList.add(w.SELECTION)}generateContent(){const t=super.generateContent();return t.classList.add(w.SELECTIONBOX),t.removeAttribute("tabindex"),t}findSelection(t){const e=t.target;let s=null;if(e.id&&(s=this.selections.find((t=>t.html.id===e.id))),!s){const t=e.parentElement.id;s=this.selections.find((e=>e.html.id===t))}return s}move(t,e){const s=this.findSelection(t);s.focused&&s.focused.unfocus();const i=e(this.selections.indexOf(s));this.selections[i].focus()}order(){this.selections.sort(Q.orderMethod.get(this.style))}toJson(){return{type:""}}}Q.chunkSize=4,Q.orderMethod=new Map([["alphabetical",(t,e)=>t.items[0].content.localeCompare(e.items[0].content)],["none",(t,e)=>1],["decreasing",(t,e)=>{const s=t.items.length,i=e.items.length;return s<i?1:i<s?-1:0}],["increasing",(t,e)=>{const s=t.items.length,i=e.items.length;return s<i?-1:i<s?1:0}]]);class tt{constructor(t){this._parser=new Map(t)}get(t){return this._parser.get(t)}add(t,e){this._parser.set(t,e)}}var et=function(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(s[i[n]]=t[i[n]])}return s};class st{constructor(t=[]){this._initList=[["command",G.fromJson.bind(G)],["checkbox",X.fromJson.bind(X)],["combo",W.fromJson.bind(W)],["slider",$.fromJson.bind($)],["label",K.fromJson.bind(K)],["radio",j.fromJson.bind(j)],["rule",F.fromJson.bind(F)],["submenu",P.fromJson.bind(P)],["contextMenu",V.fromJson.bind(V)],["subMenu",B.fromJson.bind(B)],["variable",z.fromJson.bind(z)],["items",this.items.bind(this)],["selectionMenu",Y.fromJson.bind(Y)],["selectionBox",Q.fromJson.bind(Q)]],this._factory=new tt(this._initList),t.forEach((([t,e])=>this.factory.add(t,e)))}get factory(){return this._factory}items(t,e,s){const i=[];for(const t of e){const e=this.parse(t,s);e&&(s.items.push(e),t.disabled&&e.disable(),t.hidden&&i.push(e))}return i.forEach((t=>t.hide())),s.items}parse(t,...e){var{type:s}=t,i=et(t,["type"]);const n=this.factory.get(s);return n?n(this.factory,i,...e):null}}function it(t){return"."+(w[t]||t)}function nt(t,e=";"){return"{\n "+t.join(e+"\n ")+";\n}"}const ot={};ot[it("MENU")]=nt(["position: absolute","background-color: white","color: black","width: auto","padding: 5px 0px","border: 1px solid #CCCCCC","margin: 0","cursor: default","font: menu","text-align: left","text-indent: 0","text-transform: none","line-height: normal","letter-spacing: normal","word-spacing: normal","word-wrap: normal","white-space: nowrap","float: none","z-index: 1001","border-radius: 5px","box-shadow: 0px 10px 20px #808080"]),ot[it("MENUITEM")]=nt(["padding: 1px 2em","background: transparent"]),ot[it("MENUARROW")]=nt(["position: absolute","right: 0.5em","padding-top: 0.25em","color: #666666","font-family: null","font-size: 0.75em"]),ot[it("MENUACTIVE")+" "+it("MENUARROW")]=nt(["color: white"]),ot[it("MENUARROW")+it("RTL")]=nt(["left: 0.5em","right: auto"]),ot[it("MENUCHECK")]=nt(["position: absolute","left: 0.7em","font-family: null"]),ot[it("MENUCHECK")+it("RTL")]=nt(["right: 0.7em","left: auto"]),ot[it("MENURADIOCHECK")]=nt(["position: absolute","left: 0.7em"]),ot[it("MENURADIOCHECK")+it("RTL")]=nt(["right: 0.7em","left: auto"]),ot[it("MENUINPUTBOX")]=nt(["padding-left: 1em","right: 0.5em","color: #666666","font-family: null"]),ot[it("MENUINPUTBOX")+it("RTL")]=nt(["left: 0.1em"]),ot[it("MENUCOMBOBOX")]=nt(["left: 0.1em","padding-bottom: 0.5em"]),ot[it("MENUSLIDER")]=nt(["left: 0.1em"]),ot[it("SLIDERVALUE")]=nt(["position: absolute","right: 0.1em","padding-top: 0.25em","color: #333333","font-size: 0.75em"]),ot[it("MENUACTIVE")+" "+it("SLIDERVALUE")]=nt(["color: #DDDDDD"]),ot[it("SLIDERBAR")]=nt(["outline: none","background: #D3D3D3"]),ot[it("MENULABEL")]=nt(["padding: 1px 2em 3px 1.33em","font-style: italic"]),ot[it("MENURULE")]=nt(["border-top: 1px solid #DDDDDD","margin: 4px 3px"]),ot[it("MENUDISABLED")]=nt(["color: #999"]),ot[it("MENUACTIVE")]=nt(["background-color: #606872","color: white"]),ot[it("MENUDISABLED")+":focus"]=nt(["background-color: #E8E8E8"]),ot[it("MENULABEL")+":focus"]=nt(["background-color: #E8E8E8"]),ot[it("CONTEXTMENU")+":focus"]=nt(["outline: none"]),ot[it("CONTEXTMENU")+" "+it("MENUITEM")+":focus"]=nt(["outline: none"]),ot[it("SELECTIONMENU")]=nt(["position: relative","float: left","border-bottom: none","box-shadow: none ! important","border-radius: 0px !important"]),ot[it("SELECTIONITEM")]=nt(["padding-right: 1em"]),ot[it("SELECTION")]=nt(["right: 40%","width: 50%"]),ot[it("SELECTIONBOX")]=nt(["padding: 0em","max-height: 20em","max-width: none","background-color: #FFFFFF"]),ot[it("SELECTIONDIVIDER")]=nt(["clear: both","border-top: 2px solid #000000"]),ot[it("MENU")+" "+it("MENUCLOSE")]=nt(["top: -10px","left: -10px"]),ot["@media (prefers-color-scheme: dark) /* menu */"]=nt([it("MENU")+" "+nt(["color: #E0E0E0","background-color: #242436","box-shadow: 0px 10px 20px #000","border: 1px solid #808080"]),it("SLIDERVALUE")+" "+nt(["color: #D0D0D0"]),it("MENUDISABLED")+":focus "+nt(["background-color: #383838"]),it("MENULABEL")+":focus "+nt(["background-color: #585858"]),it("MENURULE")+" "+nt(["border-top: 1px solid #808080"]),it("SELECTIONDIVIDER")+" "+nt(["border-top: 2px solid #808080"])],"");const at={};at[it("MENUCLOSE")]=nt(["position: absolute","cursor: pointer","display: inline-block","border: 2px solid #AAA","border-radius: 18px",'font-family: "Courier New", Courier',"font-size: 24px","color: #F0F0F0"]),at[it("MENUCLOSE")+" span"]=nt(["display: block","background-color: #AAA","border: 1.5px solid","border-radius: 18px","line-height: 0","padding: 8px 0 6px"]),at[it("MENUCLOSE")+":hover"]=nt(["color: white !important","border: 2px solid #CCC !important"]),at[it("MENUCLOSE")+":hover span"]=nt(["background-color: #CCC !important"]),at[it("MENUCLOSE")+":hover:focus"]=nt(["outline: none"]);function rt(t,e=document,s="MJX-Menu-styles"){if(e.head.querySelector("#"+s))return;const i=e.createElement("style");i.id=s;const n=[];for(const e in t)n.push(`${e} ${t[e]}`);i.textContent=n.join("\n"),e.head.appendChild(i)}class lt extends V{constructor(){super(...arguments),this.mathItem=null,this.nofocus=!1,this.errorMsg=""}post(t,e){var s,i;if(this.mathItem){const n=null===(i=null===(s=this.mathItem)||void 0===s?void 0:s.explorers)||void 0===i?void 0:i.speech;(null==n?void 0:n.active)&&(n.restarted=n.semanticFocus()),void 0!==e&&(this.getOriginalMenu(),this.getSemanticsMenu(),this.getSpeechMenu(),this.getBrailleMenu(),this.getSvgMenu(),this.getErrorMessage(),this.dynamicSubmenus()),super.post(t,e)}}unpost(){this.posted&&super.unpost(),this.mathItem&&(this.mathItem.outputData.nofocus=this.nofocus),this.mathItem=null,this.nofocus=!1}findID(...t){let e=this,s=null;for(const i of t){if(!e)return null;for(s of e.items){if(s.id===i){e=s instanceof P?s.submenu:null;break}e=s=null}}return s}setJax(t){this.jax=t}getOriginalMenu(){const t=this.mathItem.inputJax.name,e=this.findID("Show","Original");e.content="MathML"===t?"Original MathML":t+" Commands";this.findID("Copy","Original").content=e.content}getSemanticsMenu(){const t=this.findID("Settings","MathmlIncludes","semantics");"MathML"===this.mathItem.inputJax.name?t.disable():t.enable()}getSpeechMenu(){const t=this.mathItem.outputData.speech;this.findID("Show","Speech")[t?"enable":"disable"](),this.findID("Copy","Speech")[t?"enable":"disable"]()}getBrailleMenu(){const t=this.mathItem.outputData.braille;this.findID("Show","Braille")[t?"enable":"disable"](),this.findID("Copy","Braille")[t?"enable":"disable"]()}getSvgMenu(){const t=this.jax.SVG;this.findID("Show","SVG")[t?"enable":"disable"](),this.findID("Copy","SVG")[t?"enable":"disable"]()}getErrorMessage(){const t=this.mathItem.root.childNodes[0].childNodes;let e=!0;if(this.errorMsg="",1===t.length&&t[0].isKind("merror")){const s=t[0].attributes;this.errorMsg=s.get("data-mjx-error")||s.get("data-mjx-message")||"",e=!this.errorMsg}this.findID("Show","Error")[e?"disable":"enable"](),this.findID("Copy","Error")[e?"disable":"enable"]()}dynamicSubmenus(){for(const[t,[e,s]]of lt.DynamicSubmenus){const i=this.find(t);i&&e(this,i,(t=>{var e;i.submenu=t,!(null===(e=null==t?void 0:t.items)||void 0===e?void 0:e.length)||s&&!this.settings[s]?i.disable():i.enable()}))}}}lt.DynamicSubmenus=new Map;const ht=MathJax._.ui.dialog.InfoDialog.InfoDialog;class ct extends Q{constructor(t,e,s,i,n,o){super(t,e,i,n),this.attachMenu(o);const a=o.factory;this.selections=s.map((t=>a.get("selectionMenu")(a,t,this)))}post(){const t=Array.from(Object.values(this.menu.jax)).filter((t=>!!t))[0],e=new ht({title:this.title,message:"",adaptor:t.adaptor,styles:{"mjx-dialog > div":{padding:0}}});e.attach(),this.contentDiv=e.content,this.display()}display(){const t=this;if(t.order(),!this.selections.length)return;const e=[];let s=0,i=[];const n=t.getChunkSize(this.selections.length);for(let o=0;o<this.selections.length;o+=n){const a=this.selections.slice(o,o+n),[r,l,h,c]=t.rowDiv(a);e.push(r),s=Math.max(s,l),a.forEach((t=>t.html.style.height=h+"px")),i=t.combineColumn(i,c)}t._balanced&&(t.balanceColumn(e,i),s=i.reduce(((t,e)=>t+e-2),20)),e.forEach((t=>t.style.width=s+"px"))}}const ut=MathJax._.a11y.sre_ts,dt=ut.locales,pt=(ut.setupEngine,ut.engineSetup,ut.toEnriched,ut.parseDOM,ut.addPreference),mt=ut.fromPreference,bt=ut.toPreference;var gt=function(t,e,s,i){return new(s||(s=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))};let ft={},vt=null;function xt(t){var e,s;const i=null==t?void 0:t.match(/^clearspeak-(.*)/);return vt=null!==(s=null!==(e=i&&i[1])&&void 0!==e?e:vt)&&void 0!==s?s:"default",vt}const Et=new Map;const yt=new Map;let Mt=0;function Ct(t,e){const s=Et.get(e);!function(t,e){const s=t.pool.lookup("speechRules"),i=xt(t.settings.speechRules);ft=mt(i);for(const i of e)t.factory.get("variable")(t.factory,{name:"csprf_"+i,setter:t=>{ft[i]=t,s.setValue("clearspeak-"+bt(ft))},getter:()=>ft[i]||"Auto"},t.pool)}(t,Object.keys(s));const i=[];for(const t of Object.getOwnPropertyNames(s))i.push({title:t,values:s[t].map((e=>e.replace(RegExp("^"+t+"_"),""))),variable:"csprf_"+t});const n=new ct("Clearspeak Preferences","",i,"alphabetical","square",t);return{type:"command",id:"ClearspeakPreferences",content:"Select Preferences",action:()=>n.post()}}function St(t,e,s){return gt(this,void 0,void 0,(function*(){var i,n;const o=i=>{s(t.factory.get("subMenu")(t.factory,{items:i,id:"Clearspeak"},e))};if(!t.settings.speech||!t.settings.enrich)return void o([]);const a=t.pool.lookup("locale").getValue();if(yield function(t,e){return gt(this,void 0,void 0,(function*(){Et.has(e)||(yield t.mathItem.generatorPool.getLocalePreferences(Et))}))}(t,a),!Et.get(a))return void o([]);const r=Ct(t,a);let l=[];if(t.settings.speech){const e=t.mathItem,s=null===(i=null==e?void 0:e.explorers)||void 0===i?void 0:i.speech,o=xt(t.settings.speechRules);l=l.concat(function(t){return[{type:"radio",content:"No Preferences",id:"clearspeak-default",variable:"speechRules"},{type:"radio",content:"Current Preferences",id:"clearspeak-"+t,variable:"speechRules"},{type:"rule"}]}(o));const r=null==s?void 0:s.refocus,h=null!==(n=null==r?void 0:r.getAttribute("data-semantic-id"))&&void 0!==n?n:null,c=Mt++;yield e.generatorPool.getRelevantPreferences(e,h,yt,c);const u=yt.get(c);if(yt.delete(c),u){const t=function(t,e,s){const i=Et.get(s);return[{type:"label",content:"Preferences for "+e},{type:"rule"}].concat(i[e].map((function(e){const[s,i]=e.split("_");return{type:"radioCompare",content:i,id:"clearspeak-"+pt(t,s,i),variable:"speechRules",comparator:(t,e)=>{if(t===e)return!0;if("Auto"!==i)return!1;const[n,o]=t.split("-"),[a]=e.split("-");return n===a&&!mt(o)[s]}}})))}(o,u,a);l=l.concat(t)}}l.splice(2,0,r),o(l)}))}lt.DynamicSubmenus.set("Clearspeak",[St,"speech"]);let Ot=null;function wt(t,e,s){if(Ot)return void s(Ot);const i=[];for(const t of dt.keys())"nemeth"!==t&&"euro"!==t&&i.push({type:"radio",id:t,content:dt.get(t)||t,variable:"locale"});i.sort(((t,e)=>t.content.localeCompare(e.content,"en"))),Ot=t.factory.get("subMenu")(t.factory,{items:i,id:"Language"},e),s(Ot)}lt.DynamicSubmenus.set("A11yLanguage",[wt,"speech"]);const kt=MathJax._.util.context,At=kt.hasWindow,Tt=kt.context,Lt="MacOS"===Tt.os;function It(t){const e=Tt.document,s=e.createElement("textarea");s.value=t,s.setAttribute("readonly",""),s.style.cssText="height: 1px; width: 1px; padding: 1px; position: absolute; left: -10px",e.body.appendChild(s),s.select();try{e.execCommand("copy")}catch(t){alert(`Can't copy to clipboard: ${t.message}`)}e.body.removeChild(s)}function Nt(t,e,s){return(i,n,o)=>{!function(t,e,s){if(!t)return;for(const i of t.childNodes)if(i.isKind("annotation")){const t=Rt(i,e);if(t){const e=i.childNodes.reduce(((t,e)=>t+e.toString()),"");s.push([t,e])}}}(function(t){var e;let s=null===(e=t.mathItem)||void 0===e?void 0:e.root;for(;s&&!s.isKind("semantics");){if(s.isToken||1!==s.childNodes.length)return null;s=s.childNodes[0]}return s}(i),e,s),o(Ut(i,n,s,t))}}function Dt(t){return(e,s,i)=>{const n=t.slice();t.length=0,i(Ut(e,s,n,(()=>It(Pt.trim()))))}}function Rt(t,e){const s=t.attributes.get("encoding");for(const t of Object.keys(e))if(e[t].includes(s))return t;return null}let Pt="";function Ut(t,e,s,i){return t.factory.get("subMenu")(t.factory,{items:s.map((([t,e])=>({type:"command",id:t,content:t,action:()=>{Pt=e,i()}}))),id:"annotations"},e)}const _t=MathJax._.mathjax.mathjax,Jt=MathJax._.core.MathItem,Vt=(Jt.protoItem,Jt.AbstractMathItem,Jt.STATE),Bt=Jt.newState,Ht=MathJax._.util.Options,jt=(Ht.isObject,Ht.APPEND,Ht.REMOVE,Ht.OPTIONS,Ht.Expandable,Ht.expandable),Ft=(Ht.makeArray,Ht.keys,Ht.copy,Ht.insert,Ht.defaultOptions),Gt=Ht.userOptions;Ht.selectOptions,Ht.selectOptionsFromKeys,Ht.separateOptions,Ht.lookup;class zt extends ht{static post(t){return super.post(t)}html(t){var e;null!==(e=t.extraNodes)&&void 0!==e||(t.extraNodes=[]);const s=t.adaptor.node("input",{type:"button",value:"Copy to Clipboard","data-drag":"none"});return s.addEventListener("click",this.copyToClipboard.bind(this)),t.extraNodes.push(s),t.code&&(t.message="<pre>"+this.formatSource(t.message)+"</pre>"),super.html(t)}formatSource(t){return t.trim().replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}}class Xt extends j{static fromJson(t,{content:e,variable:s,id:i,comparator:n},o){return new this(o,e,s,i,n)}constructor(t,e,s,i,n){super(t,e,s,i),this.comparator=n,this.role="menuitemradiocompare"}updateAria(){this.html.setAttribute("aria-checked",this.comparator(this.variable.getValue(),this.id)?"true":"false")}updateSpan(){this.span.style.display=this.comparator(this.variable.getValue(),this.id)?"":"none"}}const Wt=MathJax._.core.MmlTree.SerializedMmlVisitor.SerializedMmlVisitor;class Kt extends Wt{constructor(){super(...arguments),this.options={filterSRE:!0,filterTex:!0,texHints:!0,semantics:!1},this.mathItem=null}visitTree(t,e=null,s={}){return this.mathItem=e,Gt(this.options,s),this.visitNode(t,"")}visitTeXAtomNode(t,e){return this.options.texHints?super.visitDefault(t,e):t.childNodes[0]&&1===t.childNodes[0].childNodes.length?this.visitNode(t.childNodes[0],e):`${e}<mrow${this.getAttributes(t)}>\n`+this.childNodeMml(t,e+" ","\n")+`${e}</mrow>`}visitMathNode(t,e){if(!this.options.semantics||"TeX"!==this.mathItem.inputJax.name)return super.visitDefault(t,e);const s=t.childNodes.length&&t.childNodes[0].childNodes.length>1;return`${e}<math${this.getAttributes(t)}>\n${e} <semantics>\n`+(s?e+" <mrow>\n":"")+this.childNodeMml(t,e+(s?" ":" "),"\n")+(s?e+" </mrow>\n":"")+`${e} <annotation encoding="application/x-tex">`+this.mathItem.math+`</annotation>\n${e} </semantics>\n${e}</math>`}getAttributeList(t){const e=super.getAttributeList(t);if(this.options.filterTex&&(delete e["data-latex"],delete e["data-latex-item"]),this.options.filterSRE){const t=Object.keys(e).filter((t=>t.match(/^(?:data-semantic-.*?|data-speech-node|role|aria-(?:level|posinset|setsize|owns))$/)));for(const s of t)delete e[s]}return e}}var $t=function(t,e,s,i){return new(s||(s=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))};const qt=u;class Zt{get isLoading(){return Zt.loading>0}get loadingPromise(){return this.isLoading?(Zt._loadingPromise||(Zt._loadingPromise=new Promise(((t,e)=>{Zt._loadingOK=t,Zt._loadingFailed=e}))),Zt._loadingPromise):Promise.resolve()}about(){const t=[];if(t.push("Input Jax: "+this.document.inputJax.map((t=>t.name)).join(", ")),t.push("Output Jax: "+this.document.outputJax.name),t.push("Document Type: "+this.document.kind),qt&&qt.loader){t.push("<hr/>Modules Loaded:");const e=qt._.components.package.Package,s=qt.loader.versions;for(const i of Array.from(e.packages.keys()).sort(this.sortPackages)){const n=s.get(e.resolvePath(i));n&&t.push(`    ${i} <mjx-v>(${n})</mjx-v>`)}}ht.post({title:"MathJax <mjx-v>v"+_t.version+"</mjx-v>",message:t.join("<br/>"),adaptor:this.document.adaptor,styles:{".mjx-dialog":{"max-height":"calc(min(20em, 85%))"},"mjx-dialog > div":{"white-space":"nowrap"},"dialog.mjx-dialog-help > mjx-dialog > div":{"white-space":"normal"},"mjx-v":{"font-size":"80%"}},extraNodes:[this.document.adaptor.node("a",{href:"https://www.mathjax.org","data-drag":"false"},[this.document.adaptor.text("https://www.mathjax.org")])]})}sortPackages(t,e){const[s,i]=t.includes("/")?t.split(/\//):["",t],[n,o]=e.includes("/")?e.split(/\//):["",e];return s===n?i<o?-1:1:"["===s.charAt(0)?"["===n.charAt(0)&&s<n?-1:1:"["===n.charAt(0)||s<n?-1:1}help(){ht.post({title:"MathJax Help",message:["<p><b>MathJax</b> is a JavaScript library that allows page"," authors to include mathematics within their web pages."," As a reader, you don't need to do anything to make that happen.</p>","<p><b>Browsers</b>: MathJax works with all modern browsers including"," Edge, Firefox, Chrome, Safari, Opera, and most mobile browsers.</p>","<p><b>Math Menu</b>: MathJax adds a contextual menu to equations."," Right-click or CTRL-click on any mathematics to access the menu.</p>",'<div style="margin-left: 1em;">',"<p><b>Show Math As:</b> These options allow you to view the formula's"," source markup (as MathML or in its original format).</p>","<p><b>Copy to Clipboard:</b> These options copy the formula's source markup,"," as MathML or in its original format, to the clipboard"," (in browsers that support that).</p>","<p><b>Math Settings:</b> These give you control over features of MathJax,"," such the size of the mathematics, the mechanism used to display equations,"," how to handle equations that are too wide, and the language to use for"," MathJax's menus and error messages (not yet implemented in v4).","</p>","<p><b>Accessibility</b>: MathJax can work with screen"," readers to make mathematics accessible to the visually impaired."," Turn on speech or braille generation to enable creation of speech strings"," and the ability to investigate expressions interactively. You can control"," the style of the explorer in its menu.</p>","</div>","<p><b>Math Zoom</b>: If you are having difficulty reading an"," equation, MathJax can enlarge it to help you see it better, or"," you can scale all the math on the page to make it larger."," Turn these features on in the <b>Math Settings</b> menu.</p>","<p><b>Preferences</b>: MathJax uses your browser's localStorage database"," to save the preferences set via this menu locally in your browser. These"," are not used to track you, and are not transferred or used remotely by"," MathJax in any way.</p>"].join("\n"),adaptor:this.document.adaptor,extraNodes:[this.document.adaptor.node("a",{href:"https://www.mathjax.org","data-drag":"none"},[this.document.adaptor.text("https://www.mathjax.org")])]})}mathMLCode(){zt.post({title:"MathJax MathML Expression",message:this.menu.mathItem?this.toMML(this.menu.mathItem):"",adaptor:this.document.adaptor,code:!0})}originalText(){var t,e;zt.post({title:"MathJax Original Source",message:null!==(e=null===(t=this.menu.mathItem)||void 0===t?void 0:t.math)&&void 0!==e?e:"",adaptor:this.document.adaptor,code:!0})}annotationBox(){zt.post({title:"MathJax Annotation Text",message:Pt,adaptor:this.document.adaptor,code:!0})}svgImage(){return $t(this,void 0,void 0,(function*(){zt.post({title:"MathJax SVG Image",message:yield this.toSVG(this.menu.mathItem),adaptor:this.document.adaptor,code:!0})}))}speechText(){var t,e,s;zt.post({title:"MathJax Speech Text",message:null!==(s=null===(e=null===(t=this.menu.mathItem)||void 0===t?void 0:t.outputData)||void 0===e?void 0:e.speech)&&void 0!==s?s:"",adaptor:this.document.adaptor,code:!0})}brailleText(){var t,e,s;zt.post({title:"MathJax Braille Text",message:null!==(s=null===(e=null===(t=this.menu.mathItem)||void 0===t?void 0:t.outputData)||void 0===e?void 0:e.braille)&&void 0!==s?s:"",adaptor:this.document.adaptor,code:!0})}errorMessage(){zt.post({title:"MathJax Error Message",message:this.menu.mathItem?this.menu.errorMsg:"",adaptor:this.document.adaptor,code:!0})}zoomBox(){let t="";if(this.menu.mathItem){const e=this.menu.mathItem.typesetRoot,s=this.document.adaptor.fontSize(e),i=e.cloneNode(!0);i.style.margin="0";t=`<div style="font-size: ${s*parseFloat(this.settings.zscale)/100}px">${i.outerHTML}</div>`}ht.post({title:"MathJax Zoomed Expression",message:t,adaptor:this.document.adaptor,styles:{"mjx-dialog > div":{padding:"1.8em"}}})}constructor(t,e={}){this.settings=null,this.defaultSettings=null,this.menu=null,this.current=null,this.MmlVisitor=new Kt,this.jax={CHTML:null,SVG:null},this.rerenderStart=Vt.LAST,this.requiredExtensions=[],this.document=t,this.options=Gt(Ft({},this.constructor.OPTIONS),e),this.initSettings(),this.mergeUserSettings(),this.initMenu(),this.applySettings()}initSettings(){var t;this.settings=this.options.settings,this.jax=this.options.jax;const e=this.document.outputJax;this.jax[e.name]=e,this.settings.renderer=e.name,this.settings.scale=e.options.scale,e.options.displayOverflow&&(this.settings.overflow=e.options.displayOverflow.substring(0,1).toUpperCase()+e.options.displayOverflow.substring(1).toLowerCase()),this.settings.breakInline=null===(t=e.options.linebreaks)||void 0===t?void 0:t.inline,this.defaultSettings=Object.assign({},this.document.options.a11y,this.settings),this.setA11y({roleDescription:this.settings.roleDescription})}initMenu(){const t=new st([["contextMenu",lt.fromJson.bind(lt)],["radioCompare",Xt.fromJson.bind(Xt)]]);this.menu=t.parse({type:"contextMenu",id:"MathJax_Menu",pool:[this.variable("showSRE"),this.variable("showTex"),this.variable("texHints"),this.variable("semantics"),this.variable("zoom"),this.variable("zscale"),this.variable("renderer",(t=>this.setRenderer(t))),this.variable("overflow",(t=>this.setOverflow(t))),this.variable("breakInline",(t=>this.setInlineBreaks(t))),this.variable("alt"),this.variable("cmd"),this.variable("ctrl"),this.variable("shift"),this.variable("scale",(t=>this.setScale(t))),this.a11yVar("speech",(t=>this.setSpeech(t))),this.a11yVar("braille",(t=>this.setBraille(t))),this.variable("brailleCode",(t=>this.setBraill