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 • 73.5 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]})},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,{MJContextMenu:()=>mt});var s={};t.r(s),t.d(s,{clearspeakMenu:()=>It,localeMenu:()=>kt});var i={};t.r(i),t.d(i,{copyToClipboard:()=>Rt,isMac:()=>Dt});var n={};t.r(n),t.d(n,{annotation:()=>Jt,copyAnnotations:()=>_t,showAnnotations:()=>Pt});var o={};t.r(o),t.d(o,{RadioCompare:()=>Wt});var a={};t.r(a),t.d(a,{MmlVisitor:()=>$t});var r={};t.r(r),t.d(r,{SelectableInfo:()=>Zt});var l={};t.r(l),t.d(l,{Menu:()=>te});var h={};t.r(h),t.d(h,{MenuHandler:()=>ie,MenuMathDocumentMixin:()=>se,MenuMathItemMixin:()=>ee});const u=("undefined"!=typeof window?window:global).MathJax._.components.global,c=(u.GLOBAL,u.isObject,u.combineConfig,u.combineDefaults,u.combineWithMathJax),d=u.MathJax;var m;!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"}(m||(m={}));const p="click",b="dblclick",f="mousedown",g="mouseup",v="mouseover",x="mouseout",E="selectstart";class y{constructor(){this.bubble=!1}bubbleKey(){this.bubble=!0}keydown(t){switch(t.keyCode){case m.ESCAPE:this.escape(t);break;case m.RIGHT:this.right(t);break;case m.LEFT:this.left(t);break;case m.UP:this.up(t);break;case m.DOWN:this.down(t);break;case m.RETURN:case m.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(f,this.mousedown.bind(this)),t.addEventListener(g,this.mouseup.bind(this)),t.addEventListener(v,this.mouseover.bind(this)),t.addEventListener(x,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(E,this.stop.bind(this)),t.addEventListener("contextmenu",this.stop.bind(this)),t.addEventListener(b,this.stop.bind(this))}}class M extends y{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"),t.focus()}unfocus(){const t=this.html;t.hasAttribute("tabindex")&&t.setAttribute("tabindex","-1");try{t.blur()}catch(t){}t.blur()}}class C extends M{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 S(t){return"CtxtMenu_"+t}function O(t){return S(t)}function w(t){return S(t)}const I={ATTACHED:O("Attached"),CONTEXTMENU:O("ContextMenu"),MENU:O("Menu"),MENUARROW:O("MenuArrow"),MENUACTIVE:O("MenuActive"),MENUCHECK:O("MenuCheck"),MENUCLOSE:O("MenuClose"),MENUCOMBOBOX:O("MenuComboBox"),MENUDISABLED:O("MenuDisabled"),MENUFRAME:O("MenuFrame"),MENUITEM:O("MenuItem"),MENULABEL:O("MenuLabel"),MENURADIOCHECK:O("MenuRadioCheck"),MENUINPUTBOX:O("MenuInputBox"),MENURULE:O("MenuRule"),MENUSLIDER:O("MenuSlider"),MOUSEPOST:O("MousePost"),RTL:O("RTL"),INFO:O("Info"),INFOCLOSE:O("InfoClose"),INFOCONTENT:O("InfoContent"),INFOSIGNATURE:O("InfoSignature"),INFOTITLE:O("InfoTitle"),SLIDERVALUE:O("SliderValue"),SLIDERBAR:O("SliderBar"),SELECTION:O("Selection"),SELECTIONBOX:O("SelectionBox"),SELECTIONMENU:O("SelectionMenu"),SELECTIONDIVIDER:O("SelectionDivider"),SELECTIONITEM:O("SelectionItem")},T={COUNTER:w("Counter"),KEYDOWNFUNC:w("keydownFunc"),CONTEXTMENUFUNC:w("contextmenuFunc"),OLDTAB:w("Oldtabindex"),TOUCHFUNC:w("TouchFunc")};class k extends M{constructor(t,e){super(),this._menu=t,this._type=e,this.className=I.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 A(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 N(t,e){console.error("ContextMenu Error: "+e)}function D(){return R++}let R=0;class P extends k{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(I.MENUACTIVE)}deactivate(){this.html.classList.remove(I.MENUACTIVE)}focus(){this.menu.focused=this,super.focus(),this.activate()}unfocus(){this.deactivate(),super.unfocus()}escape(t){A(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(I.MENUDISABLED),t.setAttribute("aria-disabled","true")}enable(){this.disabled=!1;const t=this.html;t.classList.remove(I.MENUDISABLED),t.removeAttribute("aria-disabled")}executeCallbacks_(){for(const t of this.callbacks)try{t(this)}catch(t){N(0,"Callback for menu entry "+this.id+" failed.")}}}class _ extends P{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(I.MENUARROW),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 C{constructor(){super(...arguments),this.className=I.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 P&&!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 P&&!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(I.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 _));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 J{constructor(t){this.menu=t,this.store=[],this._active=null,this.counter=0,this.attachedClass=I.ATTACHED+"_"+D(),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(T.OLDTAB,t.getAttribute("tabindex")),t.setAttribute("tabindex","0")}removeTabindex(t){t.hasAttribute(T.OLDTAB)?(t.setAttribute("tabindex",t.getAttribute(T.OLDTAB)),t.removeAttribute(T.OLDTAB)):t.removeAttribute("tabindex")}addEvents(t){t.hasAttribute(T.COUNTER)||(this.addEvent(t,"contextmenu",this.menu.post.bind(this.menu)),this.addEvent(t,"keydown",this.keydown.bind(this)),t.setAttribute(T.COUNTER,this.counter.toString()),this.counter++)}addEvent(t,e,s){const i=T[e.toUpperCase()+"FUNC"];this.attrMap[i+this.counter]=s,t.addEventListener(e,s)}removeEvents(t){if(!t.hasAttribute(T.COUNTER))return;const e=t.getAttribute(T.COUNTER);this.removeEvent(t,"contextmenu",e),this.removeEvent(t,"keydown",e),t.removeAttribute(T.COUNTER)}removeEvent(t,e,s){const i=T[e.toUpperCase()+"FUNC"],n=this.attrMap[i+s];t.removeEventListener(e,n)}keydown(t){t.keyCode===m.SPACE&&(this.menu.post(t),t.preventDefault(),t.stopImmediatePropagation())}}class B{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 H 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 J(this),this.widgets=[],this.variablePool=new B}generateHtml(){this.isPosted()&&this.unpost(),super.generateHtml(),this._frame=document.createElement("div"),this._frame.classList.add(I.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 V 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 V);this.baseMenu=t}left(t){this.focused=null,this.anchor.focus()}toJson(){return{type:""}}}class F extends C{constructor(t){super(),this.element=t,this.className=I.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 j extends C{constructor(t,e,s){super(),this.title=t,this.signature=s,this.className=I.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(I.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(I.MOUSEPOST),this.menu.unregisterWidget(this)}generateClose(){const t=new F(this),e=t.html;return e.classList.add(I.INFOCLOSE),e.setAttribute("aria-label","Close Dialog Box"),t}generateTitle(){const t=document.createElement("span");return t.innerHTML=this.title,t.classList.add(I.INFOTITLE),t}generateContent(){const t=document.createElement("div");return t.classList.add(I.INFOCONTENT),t.setAttribute("tabindex","0"),t}generateSignature(){const t=document.createElement("span");return t.innerHTML=this.signature,t.classList.add(I.INFOSIGNATURE),t}toJson(){return{type:""}}}class G extends P{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 z extends G{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),A(this)}generateSpan(){this.span=document.createElement("span"),this.span.textContent="\u2713",this.span.classList.add(I.MENURADIOCHECK)}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 K extends k{static fromJson(t,e,s){return new this(s)}constructor(t){super(t,"rule"),this.className=I.MENUITEM,this.role="separator"}generateHtml(){super.generateHtml();const t=this.html;t.classList.add(I.MENURULE),t.setAttribute("aria-orientation","vertical")}addEvents(t){}toJson(){return{type:"rule"}}}class X extends P{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}executeAction(){try{this.command(L(this))}catch(t){N(0,"Illegal command callback.")}A(this)}toJson(){return{type:""}}}class W{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 N(0,"Command of variable "+this.name+" failed."),null}}setValue(t,e){try{this.setter(t,e)}catch(t){N(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 q extends G{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()),A(this)}generateSpan(){this.span=document.createElement("span"),this.span.textContent="\u2713",this.span.classList.add(I.MENUCHECK)}updateAria(){this.html.setAttribute("aria-checked",this.variable.getValue()?"true":"false")}updateSpan(){this.span.style.display=this.variable.getValue()?"":"none"}toJson(){return{type:""}}}class $ extends G{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),A(this)}focus(){super.focus(),this.input.focus()}unfocus(){super.unfocus(),this.updateSpan()}generateHtml(){super.generateHtml();this.html.classList.add(I.MENUCOMBOBOX)}generateSpan(){this.span=document.createElement("span"),this.span.classList.add(I.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!==m.ESCAPE&&t.keyCode!==m.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 Z extends P{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(I.MENULABEL)}toJson(){return{type:""}}}class Y extends G{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"+D(),this.valueId="ctx_slideValue"+D(),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),A(this)}focus(){super.focus(),this.input.focus()}unfocus(){super.unfocus(),this.updateSpan()}generateHtml(){super.generateHtml();this.html.classList.add(I.MENUSLIDER),this.valueSpan=document.createElement("span"),this.valueSpan.setAttribute("id",this.valueId),this.valueSpan.classList.add(I.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(I.SLIDERBAR),this.span.appendChild(this.input)}inputKey(t){this.inputEvent=!0}mousedown(t){t.stopPropagation()}mouseup(t){event.stopPropagation()}keydown(t){const e=t.keyCode;return e===m.UP||e===m.DOWN?(t.preventDefault(),void super.keydown(t)):this.inputEvent&&e!==m.ESCAPE&&e!==m.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 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=I.SELECTIONMENU,this.variablePool=this.anchor.menu.pool,this.baseMenu=this.anchor.menu}generateHtml(){super.generateHtml(),this.items.forEach((t=>t.html.classList.add(I.SELECTIONITEM)))}display(){}right(t){this.anchor.right(t)}left(t){this.anchor.left(t)}}class tt extends j{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+D()),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(I.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/tt.chunkSize);default:return tt.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(I.SELECTION)}generateContent(){const t=super.generateContent();return t.classList.add(I.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(tt.orderMethod.get(this.style))}toJson(){return{type:""}}}tt.chunkSize=4,tt.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 et{constructor(t){this._parser=new Map(t)}get(t){return this._parser.get(t)}add(t,e){this._parser.set(t,e)}}var st=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 it{constructor(t=[]){this._initList=[["command",X.fromJson.bind(X)],["checkbox",q.fromJson.bind(q)],["combo",$.fromJson.bind($)],["slider",Y.fromJson.bind(Y)],["label",Z.fromJson.bind(Z)],["radio",z.fromJson.bind(z)],["rule",K.fromJson.bind(K)],["submenu",_.fromJson.bind(_)],["contextMenu",H.fromJson.bind(H)],["subMenu",V.fromJson.bind(V)],["variable",W.fromJson.bind(W)],["items",this.items.bind(this)],["selectionMenu",Q.fromJson.bind(Q)],["selectionBox",tt.fromJson.bind(tt)]],this._factory=new et(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=st(t,["type"]);const n=this.factory.get(s);return n?n(this.factory,i,...e):null}}function nt(t){return"."+(I[t]||t)}const ot={};ot[nt("INFOCLOSE")]="{ top:.2em; right:.2em;}",ot[nt("INFOCONTENT")]="{ overflow:auto; text-align:left; font-size:80%; padding:.4em .6em; border:1px inset; margin:1em 0px; max-height:20em; max-width:30em; background-color:#EEEEEE; white-space:normal;}",ot[nt("INFO")+nt("MOUSEPOST")]="{outline:none;}",ot[nt("INFO")]='{ position:fixed; left:50%; width:auto; text-align:center; border:3px outset; padding:1em 2em; background-color:#DDDDDD; color:black; cursor:default; font-family:message-box; font-size:120%; font-style:normal; 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:201; border-radius: 15px; /* Opera 10.5 and IE9 */ -webkit-border-radius:15px; /* Safari and Chrome */ -moz-border-radius:15px; /* Firefox */ -khtml-border-radius:15px; /* Konqueror */ box-shadow:0px 10px 20px #808080; /* Opera 10.5 and IE9 */ -webkit-box-shadow:0px 10px 20px #808080; /* Safari 3 & Chrome */ -moz-box-shadow:0px 10px 20px #808080; /* Forefox 3.5 */ -khtml-box-shadow:0px 10px 20px #808080; /* Konqueror */ filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color="gray", Positive="true"); /* IE */}';const at={};at[nt("MENU")]="{ 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:201; border-radius: 5px; /* Opera 10.5 and IE9 */ -webkit-border-radius: 5px; /* Safari and Chrome */ -moz-border-radius: 5px; /* Firefox */ -khtml-border-radius: 5px; /* Konqueror */ box-shadow:0px 10px 20px #808080; /* Opera 10.5 and IE9 */ -webkit-box-shadow:0px 10px 20px #808080; /* Safari 3 & Chrome */ -moz-box-shadow:0px 10px 20px #808080; /* Forefox 3.5 */ -khtml-box-shadow:0px 10px 20px #808080; /* Konqueror */}",at[nt("MENUITEM")]="{ padding: 1px 2em; background:transparent;}",at[nt("MENUARROW")]="{ position:absolute; right:.5em; padding-top:.25em; color:#666666; font-family: null; font-size: .75em}",at[nt("MENUACTIVE")+" "+nt("MENUARROW")]="{color:white}",at[nt("MENUARROW")+nt("RTL")]="{left:.5em; right:auto}",at[nt("MENUCHECK")]="{ position:absolute; left:.7em; font-family: null}",at[nt("MENUCHECK")+nt("RTL")]="{ right:.7em; left:auto }",at[nt("MENURADIOCHECK")]="{ position:absolute; left: .7em;}",at[nt("MENURADIOCHECK")+nt("RTL")]="{ right: .7em; left:auto}",at[nt("MENUINPUTBOX")]="{ padding-left: 1em; right:.5em; color:#666666; font-family: null;}",at[nt("MENUINPUTBOX")+nt("RTL")]="{ left: .1em;}",at[nt("MENUCOMBOBOX")]="{ left:.1em; padding-bottom:.5em;}",at[nt("MENUSLIDER")]="{ left: .1em;}",at[nt("SLIDERVALUE")]="{ position:absolute; right:.1em; padding-top:.25em; color:#333333; font-size: .75em}",at[nt("SLIDERBAR")]="{ outline: none; background: #d3d3d3}",at[nt("MENULABEL")]="{ padding: 1px 2em 3px 1.33em; font-style:italic}",at[nt("MENURULE")]="{ border-top: 1px solid #DDDDDD; margin: 4px 3px;}",at[nt("MENUDISABLED")]="{ color:GrayText}",at[nt("MENUACTIVE")]="{ background-color: #606872; color: white;}",at[nt("MENUDISABLED")+":focus"]="{ background-color: #E8E8E8}",at[nt("MENULABEL")+":focus"]="{ background-color: #E8E8E8}",at[nt("CONTEXTMENU")+":focus"]="{ outline:none}",at[nt("CONTEXTMENU")+" "+nt("MENUITEM")+":focus"]="{ outline:none}",at[nt("SELECTIONMENU")]="{ position:relative; float:left; border-bottom: none; -webkit-box-shadow:none; -webkit-border-radius:0px; }",at[nt("SELECTIONITEM")]="{ padding-right: 1em;}",at[nt("SELECTION")]="{ right: 40%; width:50%; }",at[nt("SELECTIONBOX")]="{ padding: 0em; max-height:20em; max-width: none; background-color:#FFFFFF;}",at[nt("SELECTIONDIVIDER")]="{ clear: both; border-top: 2px solid #000000;}",at[nt("MENU")+" "+nt("MENUCLOSE")]="{ top:-10px; left:-10px}";const rt={};rt[nt("MENUCLOSE")]='{ position:absolute; cursor:pointer; display:inline-block; border:2px solid #AAA; border-radius:18px; -webkit-border-radius: 18px; /* Safari and Chrome */ -moz-border-radius: 18px; /* Firefox */ -khtml-border-radius: 18px; /* Konqueror */ font-family: "Courier New", Courier; font-size:24px; color:#F0F0F0}',rt[nt("MENUCLOSE")+" span"]="{ display:block; background-color:#AAA; border:1.5px solid; border-radius:18px; -webkit-border-radius: 18px; /* Safari and Chrome */ -moz-border-radius: 18px; /* Firefox */ -khtml-border-radius: 18px; /* Konqueror */ line-height:0; padding:8px 0 6px /* may need to be browser-specific */}",rt[nt("MENUCLOSE")+":hover"]="{ color:white!important; border:2px solid #CCC!important}",rt[nt("MENUCLOSE")+":hover span"]="{ background-color:#CCC!important}",rt[nt("MENUCLOSE")+":hover:focus"]="{ outline:none}";let lt=!1,ht=!1,ut=!1;function ct(t){ut||(dt(rt,t),ut=!0)}function dt(t,e){const s=e||document,i=s.createElement("style");i.type="text/css";let n="";for(const e in t)n+=e,n+=" ",n+=t[e],n+="\n";i.innerHTML=n,s.head.appendChild(i)}class mt extends H{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(){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 _?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 mt.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()}))}}}mt.DynamicSubmenus=new Map;const pt=MathJax._.a11y.sre_ts,bt=pt.locales,ft=(pt.setupEngine,pt.engineSetup,pt.toEnriched,pt.parseDOM,pt.addPreference),gt=pt.fromPreference,vt=pt.toPreference;var xt=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 Et={},yt=null;function Mt(t){var e,s;const i=null==t?void 0:t.match(/^clearspeak-(.*)/);return yt=null!==(s=null!==(e=i&&i[1])&&void 0!==e?e:yt)&&void 0!==s?s:"default",yt}const Ct=new Map;const St=new Map;let Ot=0;function wt(t,e){const s=Ct.get(e);!function(t,e){const s=t.pool.lookup("speechRules"),i=Mt(t.settings.speechRules);Et=gt(i);for(const i of e)t.factory.get("variable")(t.factory,{name:"csprf_"+i,setter:t=>{Et[i]=t,s.setValue("clearspeak-"+vt(Et))},getter:()=>Et[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=t.factory.get("selectionBox")(t.factory,{title:"Clearspeak Preferences",signature:"",order:"alphabetic",grid:"square",selections:i},t);return{type:"command",id:"ClearspeakPreferences",content:"Select Preferences",action:()=>n.post(0,0)}}function It(t,e,s){return xt(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 xt(this,void 0,void 0,(function*(){Ct.has(e)||(yield t.mathItem.generatorPool.getLocalePreferences(Ct))}))}(t,a),!Ct.get(a))return void o([]);const r=wt(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=Mt(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,u=Ot++;yield e.generatorPool.getRelevantPreferences(e,h,St,u);const c=St.get(u);if(St.delete(u),c){const t=function(t,e,s){const i=Ct.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-"+ft(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&&!gt(o)[s]}}})))}(o,c,a);l=l.concat(t)}}l.splice(2,0,r),o(l)}))}mt.DynamicSubmenus.set("Clearspeak",[It,"speech"]);let Tt=null;function kt(t,e,s){if(Tt)return void s(Tt);const i=[];for(const t of bt.keys())"nemeth"!==t&&"euro"!==t&&i.push({type:"radio",id:t,content:bt.get(t)||t,variable:"locale"});i.sort(((t,e)=>t.content.localeCompare(e.content,"en"))),Tt=t.factory.get("subMenu")(t.factory,{items:i,id:"Language"},e),s(Tt)}mt.DynamicSubmenus.set("A11yLanguage",[kt,"speech"]);const At=MathJax._.util.context,Lt=At.hasWindow,Nt=At.context,Dt="MacOS"===Nt.os;function Rt(t){const e=Nt.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 Pt(t,e,s){return(i,n)=>(function(t,e,s){if(!t)return;for(const i of t.childNodes)if(i.isKind("annotation")){const t=Ut(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),t.attachMenu(i),Bt(i,n,s,(()=>t.post())))}function _t(t){return(e,s)=>{const i=t.slice();return t.length=0,Bt(e,s,i,(()=>Rt(Jt.trim())))}}function Ut(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 Jt="";function Bt(t,e,s,i){return t.factory.get("subMenu")(t.factory,{items:s.map((([t,e])=>({type:"command",id:t,content:t,action:()=>{Jt=e,i()}}))),id:"annotations"},e)}const Ht=MathJax._.mathjax.mathjax,Vt=MathJax._.core.MathItem,Ft=(Vt.protoItem,Vt.AbstractMathItem,Vt.STATE),jt=Vt.newState,Gt=MathJax._.util.Options,zt=(Gt.isObject,Gt.APPEND,Gt.REMOVE,Gt.OPTIONS,Gt.Expandable,Gt.expandable),Kt=(Gt.makeArray,Gt.keys,Gt.copy,Gt.insert,Gt.defaultOptions),Xt=Gt.userOptions;Gt.selectOptions,Gt.selectOptionsFromKeys,Gt.separateOptions,Gt.lookup;class Wt extends z{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 qt=MathJax._.core.MmlTree.SerializedMmlVisitor.SerializedMmlVisitor;class $t extends qt{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,Xt(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}}class Zt extends j{keydown(t){if("a"===t.key&&(t.ctrlKey||t.metaKey))return this.selectAll(),void this.stop(t);super.keydown(t)}selectAll(){document.getSelection().selectAllChildren(this.html.querySelector(".CtxtMenu_InfoContent").firstChild)}copyToClipboard(){this.selectAll();try{document.execCommand("copy")}catch(t){alert(`Can't copy to clipboard: ${t.message}`)}document.getSelection().removeAllRanges()}generateHtml(){super.generateHtml();const t=this.html.querySelector("span."+I.INFOSIGNATURE).appendChild(document.createElement("input"));t.type="button",t.value="Copy to Clipboard",t.addEventListener("click",(t=>this.copyToClipboard()))}}var Yt=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=d;class te{get isLoading(){return te.loading>0}get loadingPromise(){return this.isLoading?(te._loadingPromise||(te._loadingPromise=new Promise(((t,e)=>{te._loadingOK=t,te._loadingFailed=e}))),te._loadingPromise):Promise.resolve()}postInfo(t){this.menu.mathItem&&(this.menu.nofocus=!!this.menu.mathItem.outputData.nofocus),t.post()}constructor(t,e={}){this.settings=null,this.defaultSettings=null,this.menu=null,this.current=null,this.MmlVisitor=new $t,this.jax={CHTML:null,SVG:null},this.rerenderStart=Ft.LAST,this.requiredExtensions=[],this.about=new j('<b style="font-size:120%;">MathJax</b> v'+Ht.version,(()=>{const t=[];return 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),t.join("<br/>")}),'<a href="https://www.mathjax.org">www.mathjax.org</a>'),this.help=new j("<b>MathJax Help</b>",(()=>["<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")),'<a href="https://www.mathjax.org">www.mathjax.org</a>'),this.mathmlCode=new Zt("MathJax MathML Expression",(()=>{if(!this.menu.mathItem)return"";const t=this.toMML(this.menu.mathItem);return"<pre>"+this.formatSource(t)+"</pre>"}),""),this.originalText=new Zt("MathJax Original Source",(()=>{if(!this.menu.mathItem)return"";const t=this.menu.mathItem.math;return'<pre style="font-size:125%; margin:0">'+this.formatSource(t)+"</pre>"}),""),this.annotationBox=new Zt("MathJax Annotation Text",(()=>{const t=Jt;return'<pre style="font-size:125%; margin:0">'+this.formatSource(t)+"</pre>"}),""),this.svgImage=new Zt("MathJax SVG Image",(()=>'<div id="svg-image" style="font-family: monospace; font-size:125%; margin:0">Generative SVG Image...</div>'),""),this.speechText=new Zt("MathJax Speech Text",(()=>this.menu.mathItem?'<div style="font-size:125%; margin:0">'+this.formatSource(this.menu.mathItem.outputData.speech)+"</div>":""),""),this.brailleText=new Zt("MathJax Braille Code",(()=>this.menu.mathItem?'<div style="font-size:125%; margin:0">'+this.formatSource(this.menu.mathItem.outputData.braille)+"</div>":""),""),this.errorMessage=new Zt("MathJax Error Message",(()=>this.menu.mathItem?'<pre style="font-size:125%; margin:0">'+this.formatSource(this.menu.errorMsg)+"</pre>":""),""),this.zoomBox=new j("MathJax Zoomed Expression",(()=>{if(!this.menu.mathItem)return"";const t=this.menu.mathItem.typesetRoot.cloneNode(!0);t.style.margin="0";return'<div style="font-size: '+1.25*parseFloat(this.settings.zscale)+'%">'+t.outerHTML+"</div>"}),""),this.document=t,this.options=Xt(Kt({},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 it([["contextMenu",mt.fromJson.bind(mt)],["radioCompare",Wt.fromJson.bind(Wt)]]);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.setBrailleCode(t))),this.a11yVar("highlight",(t=>this.setHighlight(t))),this.a11yVar("backgroundColor"),this.a11yVar("backgroundOpacity"),this.a11yVar("foregroundColor"),this.a11yVar("foregroundOpacity"),this.a11yVar("subtitles"),this.a11yVar("viewBraille"),this.a11yVar("voicing"),this.a11yVar("roleDescription",(()=>this.setRoleDescription())),this.a11yVar("help"),this.a11yVar("locale",(t=>this.setLocale(t))),this.variable("speechRules",(t=>{const[e,s]=t.split("-");this.document.options.sre.domain=e,this.document.options.sre.style=s,this.re