@desmos-community/mathquill 2026.2.8 → 2026.2.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,12 +19,12 @@ Add the following tags to your HTML:
19
19
 
20
20
  ```html
21
21
  <link rel="stylesheet"
22
- href="https://cdn.jsdelivr.net/npm/@desmos-community/mathquill@2026.2.8/dist/style.css"
22
+ href="https://cdn.jsdelivr.net/npm/@desmos-community/mathquill@2026.2.25/dist/style.css"
23
23
  integrity="sha384-EwTGPJ5T8P/KXJk/NW5ysp5Sp2u6Tv6HQZgViiSZBtUW4jGQW0JHIjLjAdD9qHMu"
24
24
  crossorigin="anonymous"
25
25
  referrerpolicy="no-referrer">
26
- <script src="https://cdn.jsdelivr.net/npm/@desmos-community/mathquill@2026.2.8/dist/index.global.js"
27
- integrity="sha384-Y2IEyQlqHgLMtNeUtGOvMVwi7F+xkxu/apGQwYoJEMvNDxFuq4qIlyR5d3fBJbUw"
26
+ <script src="https://cdn.jsdelivr.net/npm/@desmos-community/mathquill@2026.2.25/dist/index.global.js"
27
+ integrity="sha384-bYWNv0UbrGa3pgmiHJet8MxLig2TMEflqbaQFkdeIvC/f236qt4R20py+g+I6xj9"
28
28
  crossorigin="anonymous"
29
29
  referrerpolicy="no-referrer"></script>
30
30
  ```
@@ -7,8 +7,8 @@
7
7
  * was not distributed with this file, You can obtain
8
8
  * one at http://mozilla.org/MPL/2.0/.
9
9
  */
10
- var __extends=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(t){var e,n,r,o;for(n=1,r=arguments.length;n<r;n++){e=arguments[n];for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},__assign.apply(this,arguments)};!function(){function t(){}function e(t){for(;t;){if(!t.parent)return t;t=t.parent}}function n(t,n,r){var o,i,s,a,l,c;if(!n){if(o=new Error("prayer failed: "+t),r){i={},o.dcgExtraErrorMetaData=i;for(s in r)a=r[s],l=i[s]={},a?(l.localLatex=a.latex(),(c=e(a))&&(l.rootLatex=c.latex())):l.emptyNode=!0}throw o}}function r(t){n("a direction was passed",t===Ae||t===Me)}function o(t){var e,n=document.implementation.createHTMLDocument("");if(n.body.innerHTML=t,1===n.body.children.length)return n.body.children[0];for(e=document.createDocumentFragment();n.body.firstChild;)e.appendChild(n.body.firstChild);return e}function i(t,e){var n,r,o,i;if("function"==typeof(null===t||void 0===t?void 0:t.closest))return t.closest(e);if(!(t instanceof HTMLElement))return null;o=Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,i=t;do{if(o.call(i,e))return i;i=null!==(r=null!==(n=null===i||void 0===i?void 0:i.parentElement)&&void 0!==n?n:null===i||void 0===i?void 0:i.parentNode)&&void 0!==r?r:null}while(null!==i&&1===i.nodeType);return null}function s(t){return t.getClientRects().length?t.getBoundingClientRect():{top:0,left:0,height:0,width:0,x:0,y:0,bottom:0,right:0}}function a(){return void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft}function l(){return void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}function c(t,e,n,r){e.insertBefore(n,t===Ae?r:r.nextSibling)}function u(t,e,n){t===Ae?n.insertBefore(e,n.firstChild):n.appendChild(e)}function p(t,e){var n,r=t[Ae];if(r&&(n=t[Me]))for(n=n[Me];r!==n&&!1!==e(r);r=r[Me]);}function h(t,e,n){var r,o=t[Ae];if(!o)return e;if(!(r=t[Me]))return e;for(r=r[Me];o!==r;o=o[Me])e=n(e,o);return e}function d(t,e,r){n("a parent is always present",t),n("leftward is properly set up",function(){return e?e[Me]===r&&e.parent===t:t.getEnd(Ae)===r}(),{parent:t,leftward:e,leftwardL:e&&e[Ae],leftwardR:e&&e[Me],rightwardL:r&&r[Ae],rightwardR:r&&r[Me]}),n("rightward is properly set up",function(){return r?r[Ae]===e&&r.parent===t:t.getEnd(Me)===e}(),{parent:t,rightward:r,leftwardL:e&&e[Ae],leftwardR:e&&e[Me],rightwardL:r&&r[Ae],rightwardR:r&&r[Me],rightwardParent:r&&r.parent})}function f(t){return t&&t.prototype instanceof bt}function m(t){return ct(),ut||(ut=g(1)),ut(t)}function g(t){function e(t,e){var n,r,i;for(n in e)if(e.hasOwnProperty(n)){if("substituteKeyboardEvents"===n&&o>=3)throw new Error(["As of interface version 3, the 'substituteKeyboardEvents'","option is no longer supported. Use 'overrideTypedText' and","'overrideKeystroke' instead."].join(" "));r=e[n],i=s[n],t[n]=i?i(r):r}}function r(t,e){function r(n,r){var i,s;return n&&n.nodeType?(i=d(n))instanceof e?i:(s=new Ot(new e.RootBlock,n,new c(o)),s.KIND_OF_MQ=t,new e(s).__mathquillify(r||{},o)):null}return n(t+" is defined",e),r.prototype=e.prototype,r}var o,i,s,c,u,p,h,d;if(1!==t&&2!==t&&3!==t)throw"Only interface versions between "+pt+" and "+ht+" supported. You specified: "+t;if((o=t)<3){if(!(i=window.jQuery))throw"MathQuill interface version ".concat(o," requires jQuery 1.5.2+ to be loaded first");at.prototype.jQuery=i}return s=__assign(__assign({},st),{handlers:function(t){return{fns:t||{},APIClasses:h}}}),c=o<3?at:function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(at),u=function(t){function n(e){var n=t.call(this)||this;return n.__controller=e,n.__options=e.options,n.id=e.id,n.data=e.data,n}return __extends(n,t),n.prototype.mathquillify=function(t){var e,n=this.__controller,r=n.root,i=n.container;n.createTextarea(),e=U(i).addClass(t).children().detach(),r.setDOM(U(Be("span",{class:"mq-root-block","aria-hidden":!0})).appendTo(i).oneElement()),X.linkElementByBlockNode(r.domFrag().oneElement(),r),this.latex(e.text()),this.revert=function(){return n.removeMouseEventListener(),U(i).removeClass("mq-editable-field mq-math-mode mq-text-mode").empty().append(e),o<3?this.__options.assertJquery()(i):i}},n.prototype.setAriaLabel=function(t){return this.__controller.setAriaLabel(t),this},n.prototype.getAriaLabel=function(){return this.__controller.getAriaLabel()},n.prototype.config=function(t){return e(this.__options,t),void 0!==t.tabindex&&this.__controller.setTabindex(t.tabindex),this},n.prototype.el=function(){return this.__controller.container},n.prototype.text=function(){return this.__controller.exportText()},n.prototype.mathspeak=function(){return this.__controller.exportMathSpeak()},n.prototype.latex=function(t){if(arguments.length>0){this.__controller.renderLatexMath(t);var e=this.__controller.cursor;return this.__controller.blurred&&e.hide().parent.blur(e),this}return this.__controller.exportLatex()},n.prototype.selection=function(t){return t?(this.__controller.restoreLatexSelection(t),this):this.__controller.exportLatexSelection().selection},n.prototype.domNodeToSpan=function(t){return this.__controller.domNodeToSpan(t)},n.prototype.html=function(){return this.__controller.root.domFrag().oneElement().innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/ mathquill-(?:command|block)-id="?\d+"?/g,"").replace(/<span class="?mq-cursor( mq-blink)?"?>.?<\/span>/i,"").replace(/ mq-hasCursor|mq-hasCursor ?/,"").replace(/ class=(""|(?= |>))/g,"")},n.prototype.reflow=function(){return this.__controller.root.postOrder(function(t){t.reflow()}),this},n.prototype.focus=function(){return this.__controller.getTextarea().focus(),this.__controller.editable&&this.__controller.scrollHoriz(),this},n.prototype.select=function(){return this.__controller.selectAll(),this},n.prototype.blur=function(){return this.__controller.getTextarea().blur(),this},n}(lt),p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.mathquillify=function(e){return t.prototype.mathquillify.call(this,e),this.__controller.editable=!0,this.__controller.addMouseEventListener(),this.__controller.editablesTextareaEvents(),this},e.prototype.clearSelection=function(){return this.__controller.cursor.clearSelection(),this},e.prototype.write=function(t){this.__controller.writeLatex(t),this.__controller.scrollHoriz();var e=this.__controller.cursor;return this.__controller.blurred&&e.hide().parent.blur(e),this},e.prototype.empty=function(){var t,e=this.__controller.root,n=this.__controller.cursor;return e.setEnds((t={},t[Ae]=0,t[Me]=0,t)),e.domFrag().empty(),delete n.selection,n.insAtRightEnd(e),this},e.prototype.cmd=function(t){var e,n,r=this.__controller.notify(void 0),o=r.cursor;return/^\\[a-z]+$/i.test(t)&&!o.isTooDeep()?(t=t.slice(1),(e=Z[t])&&(n=e.constructor?new e(t):e(t),o.selection&&n.replaces(o.replaceSelection()),n.createLeftOf(o.show()))):o.parent.write(o,t),r.scrollHoriz(),r.blurred&&o.hide().parent.blur(o),this},e.prototype.moveToDirEnd=function(t){return this.__controller.notify("move").cursor.insAtDirEnd(t,this.__controller.root),this},e.prototype.moveToLeftEnd=function(){return this.moveToDirEnd(Ae)},e.prototype.moveToRightEnd=function(){return this.moveToDirEnd(Me)},e.prototype.keystroke=function(t,e){var n,r=t.replace(/^\s+|\s+$/g,"").split(/\s+/);for(n=0;n<r.length;n+=1)this.__controller.keystroke(r[n],e);return this},e.prototype.typedText=function(t){for(var e=0;e<t.length;e+=1)this.__controller.typedText(t.charAt(e));return this},e.prototype.dropEmbedded=function(t,e,n){var r,o=t-a(),i=e-l(),s=document.elementFromPoint(o,i);this.__controller.seek(s,o,i),r=(new Fe).setOptions(n),r.createLeftOf(this.__controller.cursor)},e.prototype.setAriaPostLabel=function(t,e){return this.__controller.setAriaPostLabel(t,e),this},e.prototype.getAriaPostLabel=function(){return this.__controller.getAriaPostLabel()},e.prototype.clickAt=function(t,e,n){var r,o,i;return n=n||document.elementFromPoint(t,e),r=this.__controller,o=r.root,i=o.domFrag().oneElement(),i.contains(n)||(n=i),r.seek(n,t,e),r.blurred&&this.focus(),this},e.prototype.ignoreNextMousedown=function(t){return this.__controller.cursor.options.ignoreNextMousedown=t,this},e.prototype.isUserSelecting=function(){return this.__controller.isMouseSelecting},e}(u),h={AbstractMathQuill:u,EditableField:p},n("API.StaticMath defined",ot.StaticMath),h.StaticMath=ot.StaticMath(h),n("API.MathField defined",ot.MathField),h.MathField=ot.MathField(h),n("API.InnerMathField defined",ot.InnerMathField),h.InnerMathField=ot.InnerMathField(h),ot.TextField&&(h.TextField=ot.TextField(h)),d=function(t){var e,n,r,o,i,s,a,l;if(!t||!t.nodeType)return null;for(n=U(t).children().toElementArray(),r=0,o=n;r<o.length;r++)if(i=o[r],i.classList.contains("mq-root-block")){e=i;break}return s=X.getNodeOfElement(e),a=s&&s.controller,l=a&&h[a.KIND_OF_MQ],a&&l?new l(a):null},d.L=Ae,d.R=Me,d.config=function(t){return e(c.prototype,t),this},d.registerEmbed=function(t,e){if(!/^[a-z][a-z0-9]*$/i.test(t))throw"Embed name must start with letter and be only letters and digits";it[t]=e},d.StaticMath=r("StaticMath",h.StaticMath),d.MathField=r("MathField",h.MathField),d.InnerMathField=r("InnerMathField",h.InnerMathField),h.TextField&&(d.TextField=r("TextField",h.TextField)),d.prototype=u.prototype,d.EditableField=function(){throw"wtf don't call me, I'm 'abstract'"},d.EditableField.prototype=p.prototype,o<3&&(d.saneKeyboardEvents=k),d}function y(t){t.moveOutOf=function(t){n("controller is defined",this.controller),this.controller.handle("moveOutOf",t)},t.deleteOutOf=function(t){n("controller is defined",this.controller),this.controller.handle("deleteOutOf",t)},t.selectOutOf=function(t){n("controller is defined",this.controller),this.controller.handle("selectOutOf",t)},t.upOutOf=function(){n("controller is defined",this.controller),this.controller.handle("upOutOf")},t.downOutOf=function(){n("controller is defined",this.controller),this.controller.handle("downOutOf")},t.reflow=function(){n("controller is defined",this.controller),this.controller.handle("reflow"),this.controller.handle("edited"),this.controller.handle("edit")}}function v(t,e){throw t=t?"'"+t+"'":"EOF","Parse Error: "+e+" at "+t}function x(t,e,n){var r,o,i=n.uncleanedStartIndex,s=n.uncleanedEndIndex;for(r=0,o=0;r<n.uncleanedEndIndex;r++)t[r]!==e[o]?(r<n.uncleanedStartIndex&&(i-=1),s-=1):o+=1;return{startIndex:i,endIndex:s}}function b(t,e,n){var r,o,i=n.startIndex,s=n.endIndex,a=i,l=s;for(r=0,o=0;r<e.length;r++)e[r]!==t[o]?(o<=i&&(a+=1),o<=s&&(l+=1)):o+=1;return{uncleanStartIndex:a,uncleanEndIndex:l}}function w(t){for(;t;){if(rt.isControllerRoot(t))return t;t=t.parent}}function E(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function k(t,e){return gt(t[0],e)}function L(t,e,n){return function(){return new At(t,e?Be.entityText(e):void 0,n)}}function S(t,e,n,r){return function(){return new Mt(t,e?Be.entityText(e):void 0,n,r)}}function _(t,e,n){return function(){return new Ht(t,Be.entityText(e))}}function q(t,e){for(var n="",r=0;t instanceof jt&&t.ctrlSeq===t.letter&&r<e;)n=t.letter+n,t=t[Ae],r+=1;return n}function O(t){var e,n,r,o;if("string"!=typeof t)throw'"'+t+'" not a space-delimited list';if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of letters';for(e=t.split(" "),n={},r=0;r<e.length;r+=1){if(o=e[r],o.length<2)throw'"'+o+'" not minimum length of 2';n[o]=!0}return n}function C(t){return _("\\"+t+" ","&"+t+";",t)}function T(t){return function(){return new At("\\"+t+" ",Be.entityText("&"+t+";"))}}function F(t){return t instanceof Mt||t instanceof jt&&"infix"==t.endsCategory}function D(t){if(!t)return!1;var e=t[Ae];return e?!(F(e)||e instanceof jt&&"prefix"==e.endsCategory||!(e instanceof Le)&&/^(\\ )|[,;:\(\[]$/.test(e.ctrlSeq)):!!(t.parent&&t.parent.parent&&t.parent.parent.isStyleBlock())&&D(t.parent.parent)}function A(t){if(!t)return"";var e="";return t.eachChild(function(t){void 0!==t.ctrlSeq&&(e+=t.ctrlSeq)}),e}function M(t){var e=this.parent,n=t;do{if(n[Me])return t.insLeftOf(e);n=n.parent.parent}while(n!==e);t.insRightOf(e)}function I(t,e){var n;return"0"===e?"to the 0 power":"2"===e?"squared":"3"===e?"cubed":(n="",/^[+-]?\d{1,3}$/.test(e)&&(/(11|12|13|4|5|6|7|8|9|0)$/.test(e)?n="th":/1$/.test(e)?n="st":/2$/.test(e)?n="nd":/3$/.test(e)&&(n="rd")),"to the "+("object"==typeof t?t.mathspeak():e)+n+" power")}function N(t){var e=t.side,n=t.sides[e];return{ch:Se[n.ch],ctrlSeq:Se[n.ctrlSeq]}}function B(t,e,n){var r,o;e=e||t,r=Se[t],o=Se[e],J[t]=function(){return new Le(Ae,t,r,e,o)},J[r]=function(){return new Le(Me,t,r,e,o)},_e[t]=_e[r]=n}var R,z,P,H,j,G,V,W,Q,$,U,K,X,Y,Z,J,tt,et,nt,rt,ot,it,st,at,lt,ct,ut,pt,ht,dt,ft,mt,gt,yt,vt,xt,bt,wt,Et,kt,Lt,St,_t,qt,Ot,Ct,Tt,Ft,Dt,At,Mt,It,Nt,Bt,Rt,zt,Pt,Ht,jt,Gt,Vt,Wt,Qt,$t,Ut,Kt,Xt,Yt,Zt,Jt,te,ee,ne,re,oe,ie,se,ae,le,ce,ue,pe,he,de,fe,me,ge,ye,ve,xe,be,we,Ee,ke,Le,Se,_e,qe,Oe,Ce,Te,Fe,De,Ae=-1,Me=1,Ie=Math.min,Ne=Math.max,Be=function(t,e,n){var r,o,i,s;switch(t){case"svg":case"path":r=document.createElementNS("http://www.w3.org/2000/svg",t);break;default:r=document.createElement(t)}for(o in e)void 0!==(i=e[o])&&r.setAttribute(o,"string"==typeof i?i:String(i));if(n)for(s=0;s<n.length;s++)r.appendChild(n[s]);return r};Be.text=function(t){return document.createTextNode(t)},Be.block=function(t,e,n,r){var o,i=[n.html()];return(null===r||void 0===r?void 0:r.beforeChild)&&i.unshift(r.beforeChild),(null===r||void 0===r?void 0:r.afterChild)&&i.push(r.afterChild),o=Be(t,e,i),n.setDOM(o),X.linkElementByBlockNode(o,n),o},Be.entityText=function(t){var e=o(t);return n("entity parses to a single text node",e instanceof DocumentFragment&&1===e.childNodes.length&&e.childNodes[0]instanceof Text),e.childNodes[0]},R=" ",z="​",P="˙",H="∑",j="∏",G="∐",V="∫",W=function(){var t,e;return"function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame?(t=requestAnimationFrame,e=cancelAnimationFrame):(t=function(t){return setTimeout(t,13)},e=clearTimeout),function(n,r){function o(){var t=(Date.now()-l)/n;t<=c?s():c=t,r(c,s,i)}function i(){void 0!==a&&e(a),a=void 0}function s(){i(),a=t(o)}var a,l=Date.now(),c=0;r(n<=0?1:0,s,i)}}(),Q=function(){function t(t){this.span=Be("span",{class:"mq-aria-alert","aria-live":"assertive","aria-atomic":"true"}),this.msg="",this.items=[],this.controller=t}return t.prototype.attach=function(){var t=this.controller.container;this.span.parentNode!==t&&U(t).prepend(U(this.span))},t.prototype.queue=function(t,e){var n,r;return void 0===e&&(e=!1),n="",t instanceof bt?(r=t.mathspeak({ignoreShorthand:!0}),e&&(t.parent&&t.parent.ariaLabel&&"block"===t.ariaLabel?n=t.parent.ariaLabel+" "+r:t.ariaLabel&&(n=t.ariaLabel+" "+r)),""===n&&(n=r)):n=t||"",this.items.push(n),this},t.prototype.queueDirOf=function(t){return r(t),this.queue(t===Ae?"before":"after")},t.prototype.queueDirEndOf=function(t){return r(t),this.queue(t===Ae?"beginning of":"end of")},t.prototype.alert=function(t){return this.attach(),t&&this.queue(t),this.items.length&&(this.msg=this.items.join(" ").replace(/ +(?= )/g,"").trim(),this.controller.containerHasFocus()&&(this.controller.options.logAriaAlerts&&this.msg&&console.log(this.msg),this.span.textContent=this.msg)),this.clear()},t.prototype.clear=function(t){return this.items.length=0,(null===t||void 0===t?void 0:t.emptyContent)&&(this.span.textContent=""),this},t}(),$=function(){function t(t,e){var n;1===arguments.length&&(e=t),t&&e&&(this.ends=(n={},n[Ae]=t,n[Me]=e,n))}return t.create=function(e,r){1===arguments.length&&(r=e),n("No half-empty DOMFragments",!!e==!!r);var o=new t(e,r);return n("last is a forward sibling of first",o.isValid()),o},t.prototype.isEmpty=function(){return void 0===this.ends},t.prototype.isOneNode=function(){return!(!this.ends||this.ends[Ae]!==this.ends[Me])},t.prototype.isValid=function(){if(!this.ends)return!0;if(this.ends[Ae]===this.ends[Me])return!0;var t;return this.eachNode(function(e){return t=e}),t===this.ends[Me]},t.prototype.firstNode=function(){return n("Fragment is not empty",this.ends),this.ends[Ae]},t.prototype.lastNode=function(){return n("Fragment is not empty",this.ends),this.ends[Me]},t.prototype.children=function(){var e=this.oneNode(),n=e.firstChild,r=e.lastChild;return n&&r?new t(n,r):new t},t.prototype.join=function(e){var r,o;if(!this.ends)return e;if(!e.ends)return this;for(r=!1,o=this.ends[Me].nextSibling;o;){if(o===e.ends[Ae]){r=!0;break}o=o.nextSibling}return n("sibling must be a forward DOM sibling of this fragment",r),new t(this.ends[Ae],e.ends[Me])},t.prototype.oneNode=function(){return n("Fragment has a single node",this.ends&&this.ends[Ae]===this.ends[Me]),this.ends[Ae]},t.prototype.oneElement=function(){var t=this.oneNode();return n("Node is an Element",t.nodeType===Node.ELEMENT_NODE),t},t.prototype.oneText=function(){var t=this.oneNode();return n("Node is Text",t.nodeType===Node.TEXT_NODE),t},t.prototype.eachNode=function(t){var e,n,r;if(!this.ends)return this;for(e=this.ends[Me],n=this.ends[Ae],r=void 0;n&&(r=n.nextSibling,t(n),n!==e);n=r);return this},t.prototype.eachElement=function(t){return this.eachNode(function(e){e.nodeType===Node.ELEMENT_NODE&&t(e)}),this},t.prototype.text=function(){var t="";return this.eachNode(function(e){t+=e.textContent||""}),t},t.prototype.toNodeArray=function(){var t=[];return this.eachNode(function(e){return t.push(e)}),t},t.prototype.toElementArray=function(){var t=[];return this.eachElement(function(e){return t.push(e)}),t},t.prototype.toDocumentFragment=function(){var t=document.createDocumentFragment();return this.eachNode(function(e){return t.appendChild(e)}),t},t.prototype.insertBefore=function(t){return this.insDirOf(Ae,t)},t.prototype.insertAfter=function(t){return this.insDirOf(Me,t)},t.prototype.append=function(t){return t.appendTo(this.oneElement()),this},t.prototype.prepend=function(t){return t.prependTo(this.oneElement()),this},t.prototype.appendTo=function(t){return this.insAtDirEnd(Me,t)},t.prototype.prependTo=function(t){return this.insAtDirEnd(Ae,t)},t.prototype.parent=function(){if(!this.ends)return this;var e=this.ends[Ae].parentNode;return e?new t(e):new t},t.prototype.wrapAll=function(t){var e,n;return t.textContent="",this.ends?(e=this.ends[Ae].parentNode,n=this.ends[Me].nextSibling,this.appendTo(t),e&&e.insertBefore(t,n),this):this},t.prototype.replaceWith=function(t){var e,n,r=null===(e=this.ends)||void 0===e?void 0:e[Me],o=null===r||void 0===r?void 0:r.parentNode,i=null===r||void 0===r?void 0:r.nextSibling;return this.detach(),n=t.toDocumentFragment(),r&&o?(o.insertBefore(n,i||null),this):this},t.prototype.nthElement=function(t){if(this.ends&&!(t<0||t!==Math.floor(t)))for(var e=this.ends[Ae];e;){if(e.nodeType===Node.ELEMENT_NODE){if(t<=0)return e;t-=1}if(e===this.ends[Me])return;e=e.nextSibling}},t.prototype.firstElement=function(){return this.nthElement(0)},t.prototype.lastElement=function(){if(this.ends)for(var t=this.ends[Me];t;){if(t.nodeType===Node.ELEMENT_NODE)return t;if(t===this.ends[Ae])return;t=t.previousSibling}},t.prototype.first=function(){return new t(this.firstElement())},t.prototype.last=function(){return new t(this.lastElement())},t.prototype.eq=function(e){return new t(this.nthElement(e))},t.prototype.slice=function(e){if(!this.ends)return this;var n=this.nthElement(e);return n?new t(n,this.ends[Me]):new t},t.prototype.next=function(){for(var e=this.oneNode();e;)if((e=e.nextSibling)&&e.nodeType===Node.ELEMENT_NODE)return new t(e);return new t},t.prototype.prev=function(){for(var e=this.oneNode();e;)if((e=e.previousSibling)&&e.nodeType===Node.ELEMENT_NODE)return new t(e);return new t},t.prototype.empty=function(){return this.eachElement(function(t){t.textContent=""}),this},t.prototype.remove=function(){return this.toDocumentFragment(),this},t.prototype.detach=function(){return this.remove()},t.prototype.insDirOf=function(t,e){var n,r;return this.ends?(r=null===(n=e.ends)||void 0===n?void 0:n[t])&&r.parentNode?(c(t,r.parentNode,this.toDocumentFragment(),r),this):this.detach():this},t.prototype.insAtDirEnd=function(t,e){return this.ends?(u(t,this.toDocumentFragment(),e),this):this},t.prototype.hasClass=function(t){var e=!1;return this.eachElement(function(n){n.classList.contains(t)&&(e=!0)}),e},t.prototype.addClass=function(t){var e,n,r,o=function(t){if(!t)return"continue";i.eachElement(function(e){e.classList.add(t)})},i=this;for(e=0,n=t.split(/\s+/);e<n.length;e++)r=n[e],o(r);return this},t.prototype.removeClass=function(t){var e,n,r,o=function(t){if(!t)return"continue";i.eachElement(function(e){e.classList.remove(t)})},i=this;for(e=0,n=t.split(/\s+/);e<n.length;e++)r=n[e],o(r);return this},t.prototype.toggleClass=function(t,e){var n,r,o,i,s;if(!0===e)return this.addClass(t);if(!1===e)return this.removeClass(t);for(n=function(t){if(!t)return"continue";r.eachElement(function(e){e.classList.toggle(t)})},r=this,o=0,i=t.split(/\s+/);o<i.length;o++)s=i[o],n(s);return this},t}(),U=$.create,K=function(){function t(t,e,n){this.init(t,e,n)}return t.prototype.init=function(t,e,n){this.parent=t,this[Ae]=e,this[Me]=n},t.copy=function(e){return new t(e.parent,e[Ae],e[Me])},t}(),X=function(){function t(){var n;this[e]=0,this[o]=0,this.parent=0,this.ends=(n={},n[Ae]=0,n[Me]=0,n),this.id=t.uniqueNodeId()}t.uniqueNodeId=function(){return t.idCounter+=1},t.getNodeOfElement=function(t){if(t){if(!t.nodeType)throw new Error("must pass an Element to NodeBase.getNodeOfElement");var e=t;return e.mqBlockNode||e.mqCmdNode}},t.linkElementByBlockNode=function(t,e){t.mqBlockNode=e},t.linkElementByCmdNode=function(t,e){t.mqCmdNode=e},t.prototype.setEnds=function(t){this.ends=t,n("No half-empty node ends",!!this.ends[Ae]==!!this.ends[Me])},t.prototype.getEnd=function(t){return this.ends[t]},t.prototype.toString=function(){return"{{ MathQuill Node #"+this.id+" }}"},t.prototype.setDOM=function(t){return t&&n("DOM is an element or a text node",t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE),this._el=t,this},t.prototype.domFrag=function(){return U(this._el)},t.prototype.createDir=function(t,e){r(t);var n=this;return n.html(),n.domFrag().insDirOf(t,e.domFrag()),e[t]=n.adopt(e.parent,e[Ae],e[Me]),n},t.prototype.createLeftOf=function(t){this.createDir(Ae,t)},t.prototype.selectChildren=function(t,e){return new nt(t,e)},t.prototype.bubble=function(t){var e,n=this.getSelfNode();for(e=n;e&&!1!==t(e);e=e.parent);return this},t.prototype.postOrder=function(t){var e=this.getSelfNode();return function e(n){return!!n&&(n.eachChild(e),t(n),!0)}(e),e},t.prototype.isEmpty=function(){return 0===this.ends[Ae]&&0===this.ends[Me]},t.prototype.isQuietEmptyDelimiter=function(t){if(!this.isEmpty())return!1;if(!t)return!1;if(!this.parent||void 0===this.parent.ctrlSeq)return!1;var e=this.parent.ctrlSeq.replace(/^\\(left|right)?/,"");return t.hasOwnProperty(e)},t.prototype.isStyleBlock=function(){return!1},t.prototype.isTextBlock=function(){return!1},t.prototype.children=function(){return new Y(this.getEnd(Ae),this.getEnd(Me))},t.prototype.eachChild=function(t){return p(this.ends,t),this},t.prototype.foldChildren=function(t,e){return h(this.ends,t,e)},t.prototype.withDirAdopt=function(t,e,n,r){var o=this.getSelfNode();return new Y(o,o).withDirAdopt(t,e,n,r),this},t.prototype.adopt=function(t,e,n){var r=this.getSelfNode();return new Y(r,r).adopt(t,e,n),this.getSelfNode()},t.prototype.disown=function(){var t=this.getSelfNode();return new Y(t,t).disown(),this},t.prototype.remove=function(){return this.domFrag().remove(),this.disown()},t.prototype.shouldIgnoreSubstitutionInSimpleSubscript=function(t){var e,n=t.disableAutoSubstitutionInSubscripts;return!!n&&(!!this.parent&&(this.parent.parent instanceof ue&&(e=this.parent.parent[Ae],!("object"==typeof n&&e instanceof jt&&e.endsWord&&n.except[e.endsWord])&&!!this.parent.domFrag().hasClass("mq-sub"))))},t.prototype.getSelfNode=function(){return this},t.prototype.parser=function(){n("Abstract parser() method is never called",!1)},t.prototype.html=function(){throw new Error("html() unimplemented in NodeBase")},t.prototype.text=function(){return""},t.prototype.latex=function(){var t={uncleanedLatex:"",uncleanedStartIndex:-1,uncleanedEndIndex:-1};return this.latexRecursive(t),t.uncleanedLatex},t.prototype.latexRecursive=function(t){},t.prototype.checkCursorContextOpen=function(t){var e,n=t.uncleanedLatex.length;t.startSelectionBefore===this&&(t.uncleanedStartIndex=n),t.endSelectionBefore===this&&(t.uncleanedEndIndex=n),(e=t.restoreInfo)&&n===e.uncleanedStartIndex&&(e.uncleanedEndIndex===e.uncleanedStartIndex?n===e.uncleanedStartIndex&&(e.cursorParent=this.parent):e.selectionL=this)},t.prototype.checkCursorContextClose=function(t){var e,n=t.uncleanedLatex.length;t.startSelectionAfter===this&&(t.uncleanedStartIndex=n),t.endSelectionAfter===this&&(t.uncleanedEndIndex=n),(e=t.restoreInfo)&&n===e.uncleanedEndIndex&&(e.uncleanedStartIndex===e.uncleanedEndIndex?(e.cursorL||(e.cursorL=this),e.cursorParent?e.cursorParent===this.parent&&(e.cursorParent=this,e.cursorL=0):e.cursorParent=this.parent):e.selectionR||(e.selectionR=this))},t.prototype.finalizeTree=function(t,e){},t.prototype.contactWeld=function(t,e){},t.prototype.blur=function(t){},t.prototype.focus=function(){},t.prototype.intentionalBlur=function(){},t.prototype.reflow=function(){},t.prototype.registerInnerField=function(t,e){},t.prototype.chToCmd=function(t,e){n("Abstract chToCmd() method is never called",!1)},t.prototype.mathspeak=function(t){return""},t.prototype.seek=function(t,e){},t.prototype.siblingDeleted=function(t,e){},t.prototype.siblingCreated=function(t,e){},t.prototype.finalizeInsert=function(t,e){},t.prototype.fixDigitGrouping=function(t){},t.prototype.writeLatex=function(t,e){},t.prototype.write=function(t,e){};var e,o;return e=Ae,o=Me,t.idCounter=0,t}(),Y=function(){function t(t,e,o){var i,s,a,l;if(this.disowned=!1,void 0===o&&(o=Ae),r(o),n("no half-empty fragments",!t==!e,{withDir:t,oppDir:e}),!t||!e)return void this.setEnds((i={},i[Ae]=0,i[Me]=0,i));n("withDir is passed to Fragment",t instanceof bt),n("oppDir is passed to Fragment",e instanceof bt),n("withDir and oppDir have the same parent",t.parent===e.parent),s={},s[o]=t,s[-o]=e,a=s,this.setEnds(a),l=0,this.each(function(t){l=t}),n("following direction siblings from start reaches end",l===a[Me])}return t.prototype.getDOMFragFromEnds=function(){var t=this.ends[Ae],e=this.ends[Me];return 0===t||0===e?U():t===e?t.domFrag():t.domFrag().join(e.domFrag())},t.prototype.setEnds=function(t){this.ends=t},t.prototype.getEnd=function(t){return this.ends?this.ends[t]:0},t.prototype.domFrag=function(){return this.getDOMFragFromEnds()},t.prototype.withDirAdopt=function(t,e,n,r){return t===Ae?this.adopt(e,n,r):this.adopt(e,r,n)},t.prototype.adopt=function(t,e,n){var r,o,i,s,a;return d(t,e,n),o=this,this.disowned=!1,(i=o.ends[Ae])&&(s=o.ends[Me])?(r={},r[Ae]=t.getEnd(Ae),r[Me]=t.getEnd(Me),a=r,e||(a[Ae]=i),n?n[Ae]=s:a[Me]=s,t.setEnds(a),s[Me]=n,o.each(function(n){return n[Ae]=e,n.parent=t,e&&(e[Me]=n),e=n,!0}),o):this},t.prototype.disown=function(){var t,e,n,r,o,i,s=this,a=s.ends[Ae];return!a||s.disowned?s:(this.disowned=!0,(e=s.ends[Me])?(n=a.parent,d(n,a[Ae],a),d(n,e,e[Me]),t={},t[Ae]=n.getEnd(Ae),t[Me]=n.getEnd(Me),r=t,a[Ae]?(o=a[Ae],o[Me]=e[Me]):r[Ae]=e[Me],e[Me]?(i=e[Me],i[Ae]=a[Ae]):r[Me]=a[Ae],r[Ae]&&r[Me]?n.setEnds(r):n.ends=r,s):s)},t.prototype.remove=function(){return this.domFrag().remove(),this.disown()},t.prototype.each=function(t){return p(this.ends,t),this},t.prototype.fold=function(t,e){return h(this.ends,t,e)},t}(),Z={},J={},tt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.ancestors={},o}return __extends(e,t),e.fromCursor=function(t){return new e(t.parent,t[Ae],t[Me])},e}(K),et=function(t){function e(e,n,r){var o=t.call(this,e,0,0)||this;return o.upDownCache={},o.cursorElement=Be("span",{class:"mq-cursor"},[Be.text(z)]),o._domFrag=U(),o.controller=r,o.options=n,o.setDOMFrag(U(o.cursorElement)),o.blink=function(){U(o.cursorElement).toggleClass("mq-blink")},o}return __extends(e,t),e.prototype.setDOMFrag=function(t){return this._domFrag=t,this},e.prototype.domFrag=function(){return this._domFrag},e.prototype.show=function(){var t,e;return U(this.cursorElement).removeClass("mq-blink"),this.setDOMFrag(U(this.cursorElement)),this.intervalId?clearInterval(this.intervalId):(t=this[Me],t?(e=this.selection,e&&e.getEnd(Ae)[Ae]===this[Ae]?this.domFrag().insertBefore(e.domFrag()):this.domFrag().insertBefore(t.domFrag())):this.domFrag().appendTo(this.parent.domFrag().oneElement()),this.parent.focus()),this.intervalId=setInterval(this.blink,500),this},e.prototype.hide=function(){return this.intervalId&&clearInterval(this.intervalId),this.intervalId=0,this.domFrag().detach(),this.setDOMFrag(U()),this},e.prototype.withDirInsertAt=function(t,e,n,r){var o=this.parent;this.parent=e,this[t]=n,this[-t]=r,o!==e&&o.blur&&o.blur(this)},e.prototype.insDirOf=function(t,e){return r(t),this.domFrag().insDirOf(t,e.domFrag()),this.withDirInsertAt(t,e.parent,e[t],e),this.parent.domFrag().addClass("mq-hasCursor"),this},e.prototype.insLeftOf=function(t){return this.insDirOf(Ae,t)},e.prototype.insRightOf=function(t){return this.insDirOf(Me,t)},e.prototype.insAtDirEnd=function(t,e){return r(t),this.domFrag().insAtDirEnd(t,e.domFrag().oneElement()),this.withDirInsertAt(t,e,0,e.getEnd(t)),e.focus(),this},e.prototype.insAtLeftEnd=function(t){return this.insAtDirEnd(Ae,t)},e.prototype.insAtRightEnd=function(t){return this.insAtDirEnd(Me,t)},e.prototype.jumpUpDown=function(t,e){var n,r,o,i=this;i.upDownCache[t.id]=K.copy(i),n=i.upDownCache[e.id],n?(r=n[Me],r?i.insLeftOf(r):i.insAtRightEnd(n.parent)):(o=i.getBoundingClientRectWithoutMargin().left,e.seek(o,i)),i.controller.aria.queue(e,!0)},e.prototype.getBoundingClientRectWithoutMargin=function(){var t,e,n,r=this.domFrag();return r.removeClass("mq-cursor"),t=s(r.oneElement()),e=t.left,n=t.right,r.addClass("mq-cursor"),{left:e,right:n}},e.prototype.unwrapGramp=function(){var t,e,n,r,o,i=this.parent.parent,s=i.parent,a=i[Me],l=this,c=i[Ae];if(i.disown().eachChild(function(t){return!!t.isEmpty()||(t.children().adopt(s,c,a).each(function(t){return t.domFrag().insertBefore(i.domFrag()),!0}),c=t.getEnd(Me),!0)}),!this[Me])if(t=this[Ae])this[Me]=t[Me];else for(;!this[Me];){if(!(e=this.parent[Me])){this[Me]=i[Me],this.parent=s;break}this.parent=e,this[Me]=e.getEnd(Ae)}n=this[Me],n?this.insLeftOf(n):this.insAtRightEnd(s),i.domFrag().remove(),r=i[Ae],o=i[Me],r&&r.siblingDeleted(l.options,Me),o&&o.siblingDeleted(l.options,Ae)},e.prototype.startSelection=function(){var t,e=this.anticursor=tt.fromCursor(this),n=e.ancestors;for(t=e;t.parent;t=t.parent)n[t.parent.id]=t},e.prototype.endSelection=function(){delete this.anticursor},e.prototype.select=function(){var t,e,r,o,i,s,a,l,c,u=this.anticursor;if(this[Ae]===u[Ae]&&this.parent===u.parent)return!1;for(e=this;e.parent;e=e.parent)if(e.parent.id in u.ancestors){t=e.parent;break}if(n("cursor and anticursor in the same tree",t),r=t,o=u.ancestors[r.id],a=Me,e[Ae]!==o)for(l=e;l;l=l[Me])if(l[Me]===o[Me]){a=Ae,i=e,s=o;break}return a===Me&&(i=o,s=e),i instanceof K&&(i=i[Me]),s instanceof K&&(s=s[Ae]),this.hide().selection=r.selectChildren(i,s),c=this.selection.getEnd(a),this.insDirOf(a,c),this.selectionChanged(),!0},e.prototype.resetToEnd=function(t){
11
- this.clearSelection();var e=t.root;this[Me]=0,this[Ae]=e.getEnd(Me),this.parent=e},e.prototype.clearSelection=function(){return this.selection&&(this.selection.clear(),delete this.selection,this.selectionChanged()),this},e.prototype.deleteSelection=function(){var t=this.selection;t&&(this[Ae]=t.getEnd(Ae)[Ae],this[Me]=t.getEnd(Me)[Me],t.remove(),this.selectionChanged(),delete this.selection)},e.prototype.replaceSelection=function(){var t=this.selection;return t&&(this[Ae]=t.getEnd(Ae)[Ae],this[Me]=t.getEnd(Me)[Me],delete this.selection),t},e.prototype.depth=function(){for(var t=this,e=0;t=t.parent;)e+=t instanceof It?1:0;return e},e.prototype.isTooDeep=function(t){return void 0!==this.options.maxDepth&&this.depth()+(t||0)>this.options.maxDepth},e.prototype.selectionChanged=function(){},e}(K),nt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o._el=Be("span",{class:"mq-selection"}),o.getDOMFragFromEnds().wrapAll(o._el),o}return __extends(e,t),e.prototype.isCleared=function(){return void 0===this._el},e.prototype.domFrag=function(){return this.isCleared()?this.getDOMFragFromEnds():U(this._el)},e.prototype.setEnds=function(t){n("Selection ends are never empty",t[Ae]&&t[Me]),this.ends=t},e.prototype.getEnd=function(t){return this.ends[t]},e.prototype.adopt=function(e,n,r){return this.clear(),t.prototype.adopt.call(this,e,n,r)},e.prototype.clear=function(){var t=this.getDOMFragFromEnds();return this.domFrag().replaceWith(t),this._el=void 0,this},e.prototype.join=function(t,e){return void 0===e&&(e=""),this.fold("",function(n,r){return n+e+r[t]()})},e}(Y),rt=function(){function t(t,e,n){this.isMouseSelecting=!1,this.textareaEventListeners={},this.id=t.id,this.data={},this.root=t,this.container=e,this.options=n,this.aria=new Q(this.getControllerSelf()),this.ariaLabel="Math Input",this.ariaPostLabel="",t.controller=this.getControllerSelf(),this.cursor=t.cursor=new et(t,n,this.getControllerSelf())}return t.isControllerRoot=function(t){var e=t.controller;return e&&e.root===t},t.prototype.getControllerSelf=function(){return this},t.prototype.handle=function(t,e){var r,o,i,s=this.options.handlers,a=null===(r=this.options.handlers)||void 0===r?void 0:r.fns[t];a&&(o=null===s||void 0===s?void 0:s.APIClasses[this.KIND_OF_MQ],n("APIClass is defined",o),i=new o(this),e===Ae||e===Me?a(e,i):a(i))},t.onNotify=function(e){t.notifyees.push(e)},t.prototype.notify=function(e){for(var n=0;n<t.notifyees.length;n+=1)t.notifyees[n](this.cursor,e);return this},t.prototype.setAriaLabel=function(t){var e=this.getAriaLabel();return!t&&this.editable?this.ariaLabel="Math Input":this.ariaLabel=t,t===e||this.containerHasFocus()||this.updateMathspeak(),this},t.prototype.getAriaLabel=function(){return"Math Input"!==this.ariaLabel?this.ariaLabel:this.editable?"Math Input":""},t.prototype.setAriaPostLabel=function(t,e){var n=this;return t&&"string"==typeof t&&""!==t?(t!==this.ariaPostLabel&&"number"==typeof e&&(this._ariaAlertTimeout&&clearTimeout(this._ariaAlertTimeout),this._ariaAlertTimeout=setTimeout(function(){n.containerHasFocus()?n.aria.alert(n.root.mathspeak().trim()+" "+t.trim()):n.updateMathspeak()},e)),this.ariaPostLabel=t):(this._ariaAlertTimeout&&clearTimeout(this._ariaAlertTimeout),this.ariaPostLabel=""),this},t.prototype.getAriaPostLabel=function(){return this.ariaPostLabel||""},t.prototype.containerHasFocus=function(){return document.activeElement&&this.container.contains(document.activeElement)},t.prototype.getTextarea=function(){var t=this.textarea;return n("textarea initialized",t),t},t.prototype.getTextareaSpan=function(){var t=this.textareaSpan;return n("textareaSpan initialized",t),t},t.prototype.addTextareaEventListeners=function(t){var e,n;if(this.textarea)for(e in t)n=e,this.removeTextareaEventListener(n),this.textarea.addEventListener(n,t[n])},t.prototype.removeTextareaEventListener=function(t){if(this.textarea){var e=this.textareaEventListeners[t];e&&this.textarea.removeEventListener(t,e)}},t.prototype.exportMathSpeak=function(){return this.root.mathspeak()},t.prototype.updateMathspeak=function(t){},t.prototype.scrollHoriz=function(){},t.prototype.selectionChanged=function(){},t.prototype.setOverflowClasses=function(){},t.notifyees=[],t}(),ot={},it={},st={},at=function(){function t(t){this.version=t}return t.prototype.assertJquery=function(){return n("Interface versions > 2 do not depend on JQuery",this.version<=2),n("JQuery is set for interface v < 3",this.jQuery),this.jQuery},t}(),lt=function(){function t(){}return t}(),ct=function(){window.console&&console.warn('You are using the MathQuill API without specifying an interface version, which will fail in v1.0.0. Easiest fix is to do the following before doing anything else:\n\n MathQuill = MathQuill.getInterface(1);\n // now MathQuill.MathField() works like it used to\n\nSee also the "`dev` branch (2014–2015) → v0.10.0 Migration Guide" at\n https://github.com/mathquill/mathquill/wiki/%60dev%60-branch-(2014%E2%80%932015)-%E2%86%92-v0.10.0-Migration-Guide')},m.prototype=lt.prototype,m.VERSION="v0.10.1",m.interfaceVersion=function(t){if(1!==t)throw"Only interface version 1 supported. You specified: "+t;return ct=function(){window.console&&console.warn('You called MathQuill.interfaceVersion(1); to specify the interface version, which will fail in v1.0.0. You can fix this easily by doing this before doing anything else:\n\n MathQuill = MathQuill.getInterface(1);\n // now MathQuill.MathField() works like it used to\n\nSee also the "`dev` branch (2014–2015) → v0.10.0 Migration Guide" at\n https://github.com/mathquill/mathquill/wiki/%60dev%60-branch-(2014%E2%80%932015)-%E2%86%92-v0.10.0-Migration-Guide')},ct(),m},m.getInterface=g,pt=g.MIN=1,ht=g.MAX=3,m.noConflict=function(){return window.MathQuill=dt,m},dt=window.MathQuill,window.MathQuill=m,ft=function(){function t(t){this._=t}return t.prototype.parse=function(e){function n(t,e){return e}return this.skip(t.eof)._(""+e,n,v)},t.prototype.or=function(e){n("or is passed a parser",e instanceof t);var r=this;return new t(function(t,n,o){function i(r){return e._(t,n,o)}return r._(t,n,i)})},t.prototype.then=function(e){var r=this;return new t(function(o,i,s){function a(r,o){var a=e instanceof t?e:e(o);return n("a parser is returned",a instanceof t),a._(r,i,s)}return r._(o,a,s)})},t.prototype.many=function(){var e=this;return new t(function(t,n,r){function o(e,n){return t=e,s.push(n),!0}function i(){return!1}for(var s=[];e._(t,o,i););return n(t,s)})},t.prototype.times=function(e,n){arguments.length<2&&(n=e);var r=this;return new t(function(t,o,i){function s(e,n){return p.push(n),t=e,!0}function a(e,n){return c=n,t=e,!1}function l(t,e){return!1}var c,u,p=[],h=!0;for(u=0;u<e;u+=1)if(!(h=!!r._(t,s,a)))return i(t,c);for(;u<n&&h;u+=1)r._(t,s,l);return o(t,p)})},t.prototype.result=function(e){return this.then(t.succeed(e))},t.prototype.atMost=function(t){return this.times(0,t)},t.prototype.atLeast=function(t){var e=this;return e.times(t).then(function(t){return e.many().map(function(e){return t.concat(e)})})},t.prototype.map=function(e){return this.then(function(n){return t.succeed(e(n))})},t.prototype.skip=function(t){return this.then(function(e){return t.result(e)})},t.string=function(e){var n=e.length,r="expected '"+e+"'";return new t(function(t,o,i){var s=t.slice(0,n);return s===e?o(t.slice(n),s):i(t,r)})},t.regex=function(e){n("regexp parser is anchored","^"===e.toString().charAt(1));var r="expected "+e;return new t(function(t,n,o){var i,s=e.exec(t);return s?(i=s[0],n(t.slice(i.length),i)):o(t,r)})},t.succeed=function(e){return new t(function(t,n){return n(t,e)})},t.fail=function(e){return new t(function(t,n,r){return r(t,e)})},t.letter=t.regex(/^[a-z]/i),t.letters=t.regex(/^[a-z]*/i),t.digit=t.regex(/^[0-9]/),t.digits=t.regex(/^[0-9]*/),t.whitespace=t.regex(/^\s+/),t.optWhitespace=t.regex(/^\s*/),t.any=new t(function(t,e,n){return t?e(t.slice(1),t.charAt(0)):n(t,"expected any character")}),t.all=new t(function(t,e,n){return e("",t)}),t.eof=new t(function(t,e,n){return t?n(t,"expected EOF"):e(t,t)}),t}(),mt=function(){function e(){this.fn=t}return e.prototype.listen=function(t){this.fn=t,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(this.fn)},e.prototype.listenOnce=function(t){var e=this;this.listen(function(){var n,r=[];for(n=0;n<arguments.length;n++)r[n]=arguments[n];e.clearListener(),t.apply(void 0,r)})},e.prototype.clearListener=function(){this.fn=t,clearTimeout(this.timeoutId)},e.prototype.trigger=function(){var t,e=[];for(t=0;t<arguments.length;t++)e[t]=arguments[t];this.fn.apply(this,e)},e}(),gt=function(){function t(t){switch(n(t)){case"Right":case"Left":case"Down":case"Up":return!0}return!1}function e(t){return 1===t.length&&t>="a"&&t<="z"}function n(t){var n,r;return void 0===t.key?(r=t.which||t.keyCode,o[r]||String.fromCharCode(r)):e(t.key)?t.key.toUpperCase():null!==(n=i[t.key])&&void 0!==n?n:t.key}function r(t){var e=n(t),r=[];return t.ctrlKey&&r.push("Ctrl"),t.metaKey&&r.push("Meta"),t.altKey&&r.push("Alt"),t.shiftKey&&r.push("Shift"),r.length?("Alt"!==e&&"Control"!==e&&"Meta"!==e&&"Shift"!==e&&r.push(e),r.join("-")):e}var o={8:"Backspace",9:"Tab",10:"Enter",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Esc",32:"Spacebar",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",45:"Insert",46:"Del",144:"NumLock"},i={ArrowRight:"Right",ArrowLeft:"Left",ArrowDown:"Down",ArrowUp:"Up",Delete:"Del",Escape:"Esc"," ":"Spacebar"};return function(e,n){function o(){try{e instanceof HTMLTextAreaElement&&e.select()}catch(t){}}function i(t){v.trigger(),v.clearListener(),e instanceof HTMLTextAreaElement&&(e.value=t),t&&o(),x=!!t}function s(){return"selectionStart"in e&&(e instanceof HTMLTextAreaElement&&e.selectionStart!==e.selectionEnd)}function a(){n.options&&n.options.overrideKeystroke?n.options.overrideKeystroke(r(g),g):n.keystroke(r(g),g)}function l(t){v.trigger(t),t.target===e&&(g=t,y=null,x&&v.listenOnce(function(t){t&&"focusout"===t.type||o()}),a())}function c(n){v.trigger(n),n.target===e&&(g&&y&&a(),y=n,t(n)?v.listenOnce(h):v.listen(p))}function u(n){v.trigger(n),n.target===e&&g&&!y&&(t(n)?v.listenOnce(h):v.listen(p))}function p(){if(!s()&&e instanceof HTMLTextAreaElement){var t=e.value;(!g||"Unidentified"!==g.key&&(g.altKey||!g.ctrlKey||g.metaKey||!g.shiftKey||"U"!==g.key&&"Process"!==g.key))&&(1===t.length?(e.value="",n.options&&n.options.overrideTypedText?n.options.overrideTypedText(t):n.typedText(t)):h())}}function h(){e instanceof HTMLTextAreaElement&&e.value.length>1&&o()}function d(){g=null,y=null,v.clearListener(),e instanceof HTMLTextAreaElement&&(e.value="")}function f(t){v.trigger(),t.target===e&&(document.activeElement!==e&&e.focus(),v.listen(function(){if(e instanceof HTMLTextAreaElement){var t=e.value;e.value="",t&&n.paste(t)}}))}function m(t){v.trigger(t)}var g=null,y=null,v=new mt,x=!1;return"StaticMath"===n.KIND_OF_MQ?(n.addTextareaEventListeners({keydown:function(t){var e,o;null===(o=(e=n.options).overrideKeystroke)||void 0===o||o.call(e,r(t),t)}}),{select:i}):(n.options&&n.options.disableCopyPaste?n.addTextareaEventListeners({keydown:l,keypress:c,keyup:u,focusout:d,copy:function(t){t.preventDefault()},cut:function(t){t.preventDefault()},paste:function(t){v.trigger(),t.preventDefault()},input:m}):n.addTextareaEventListeners({keydown:l,keypress:c,keyup:u,focusout:d,cut:function(){v.listenOnce(function(){n.cut()})},copy:function(){v.listenOnce(function(){n.copy()})},paste:f,input:m}),{select:i})}}(),yt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.exportText=function(){return this.root.foldChildren("",function(t,e){return t+e.text()})},e}(rt),rt.onNotify(function(t,e){if("edit"===e||"replace"===e||void 0===e){var n=t.controller;if(!n)return;if(!n.options.enableDigitGrouping)return;if(!1!==n.blurred)return;n.disableGroupingForSeconds(1)}}),vt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.handleTextareaFocusEditable=function(){var t=e.cursor;e.updateMathspeak(),e.blurred=!1,clearTimeout(e.blurTimeout),U(e.container).addClass("mq-focused"),t.parent||t.insAtRightEnd(e.root),t.selection?(t.selection.domFrag().removeClass("mq-blur"),e.selectionChanged()):t.show(),e.setOverflowClasses()},e.handleTextareaBlurEditable=function(){e.textareaSelectionTimeout&&(clearTimeout(e.textareaSelectionTimeout),e.textareaSelectionTimeout=0),e.disableGroupingForSeconds(0),e.blurred=!0,e.blurTimeout=setTimeout(function(){e.root.postOrder(function(t){t.intentionalBlur()}),e.cursor.clearSelection().endSelection(),e.blur(),e.updateMathspeak({emptyContent:!0}),e.scrollHoriz()}),window.addEventListener("blur",e.handleWindowBlur)},e.handleTextareaFocusStatic=function(){e.cursor.selection||e.cursor.controller.selectAll(),e.blurred=!1},e.handleTextareaBlurStatic=function(){e.cursor.clearSelection(),e.updateMathspeak({emptyContent:!0})},e.handleWindowBlur=function(){clearTimeout(e.blurTimeout),e.cursor.selection&&e.cursor.selection.domFrag().addClass("mq-blur"),e.blurWithoutResettingCursor(),e.updateMathspeak({emptyContent:!0})},e}return __extends(e,t),e.prototype.disableGroupingForSeconds=function(t){var e=this;clearTimeout(this.__disableGroupingTimeout),0===t?this.root.domFrag().removeClass("mq-suppress-grouping"):(this.root.domFrag().addClass("mq-suppress-grouping"),this.__disableGroupingTimeout=setTimeout(function(){e.root.domFrag().removeClass("mq-suppress-grouping")},1e3*t))},e.prototype.blur=function(){this.blurWithoutResettingCursor(),this.options&&this.options.resetCursorOnBlur&&this.cursor.resetToEnd(this)},e.prototype.blurWithoutResettingCursor=function(){this.cursor.hide().parent.blur(this.cursor),U(this.container).removeClass("mq-focused"),window.removeEventListener("blur",this.handleWindowBlur)},e.prototype.addEditableFocusBlurListeners=function(){var t=this,e=t.cursor;this.addTextareaEventListeners({focus:this.handleTextareaFocusEditable,blur:this.handleTextareaBlurEditable}),t.blurred=!0,e.hide().parent.blur(e)},e.prototype.addStaticFocusBlurListeners=function(){this.addTextareaEventListeners({focus:this.handleTextareaFocusStatic,blur:this.handleTextareaBlurStatic})},e}(yt),xt=!1,bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.keystroke=function(t,n,r){var o=r.cursor;switch(t){case"Ctrl-Shift-Backspace":case"Ctrl-Backspace":r.ctrlDeleteDir(Ae);break;case"Shift-Backspace":case"Backspace":r.backspace();break;case"Esc":case"Tab":return void r.escapeDir(Me,t,n);case"Shift-Tab":case"Shift-Esc":return void r.escapeDir(Ae,t,n);case"End":r.notify("move").cursor.insAtRightEnd(o.parent),r.aria.queue("end of").queue(o.parent,!0);break;case"Ctrl-End":r.notify("move").cursor.insAtRightEnd(r.root),r.aria.queue("end of").queue(r.ariaLabel).queue(r.root).queue(r.ariaPostLabel);break;case"Shift-End":r.selectToBlockEndInDir(Me);break;case"Ctrl-Shift-End":r.selectToRootEndInDir(Me);break;case"Home":r.notify("move").cursor.insAtLeftEnd(o.parent),r.aria.queue("beginning of").queue(o.parent,!0);break;case"Ctrl-Home":r.notify("move").cursor.insAtLeftEnd(r.root),r.aria.queue("beginning of").queue(r.ariaLabel).queue(r.root).queue(r.ariaPostLabel);break;case"Shift-Home":r.selectToBlockEndInDir(Ae);break;case"Ctrl-Shift-Home":r.selectToRootEndInDir(Ae);break;case"Left":r.moveLeft();break;case"Shift-Left":r.selectLeft();break;case"Ctrl-Left":break;case"Right":r.moveRight();break;case"Shift-Right":r.selectRight();break;case"Ctrl-Right":break;case"Up":r.moveUp();break;case"Down":r.moveDown();break;case"Shift-Up":r.withIncrementalSelection(function(t){if(o[Ae])for(;o[Ae];)t(Ae);else t(Ae)});break;case"Shift-Down":r.withIncrementalSelection(function(t){if(o[Me])for(;o[Me];)t(Me);else t(Me)});break;case"Ctrl-Up":case"Ctrl-Down":break;case"Ctrl-Shift-Del":case"Ctrl-Del":r.ctrlDeleteDir(Me);break;case"Shift-Del":case"Del":r.deleteForward();break;case"Meta-A":case"Ctrl-A":r.selectAll();break;case"Ctrl-Alt-Up":o.parent.parent&&o.parent.parent instanceof e?r.aria.queue(o.parent.parent):r.aria.queue("nothing above");break;case"Ctrl-Alt-Down":o.parent&&o.parent instanceof e?r.aria.queue(o.parent):r.aria.queue("block is empty");break;case"Ctrl-Alt-Left":o.parent.parent&&o.parent.parent.getEnd(Ae)?r.aria.queue(o.parent.parent.getEnd(Ae)):r.aria.queue("nothing to the left");break;case"Ctrl-Alt-Right":o.parent.parent&&o.parent.parent.getEnd(Me)?r.aria.queue(o.parent.parent.getEnd(Me)):r.aria.queue("nothing to the right");break;case"Ctrl-Alt-Shift-Down":o.selection?r.aria.queue(o.selection.join("mathspeak"," ").trim()+" selected"):r.aria.queue("nothing selected");break;case"Ctrl-Alt-=":case"Ctrl-Alt-Shift-Right":r.ariaPostLabel.length?r.aria.queue(r.ariaPostLabel):r.aria.queue("no answer");break;default:return}r.aria.alert(),null===n||void 0===n||n.preventDefault(),r.scrollHoriz()},e.prototype.moveOutOf=function(t,e,r){n("overridden or never called on this node",!1)},e.prototype.moveTowards=function(t,e,r){n("overridden or never called on this node",!1)},e.prototype.deleteOutOf=function(t,e){n("overridden or never called on this node",!1)},e.prototype.deleteTowards=function(t,e){n("overridden or never called on this node",!1)},e.prototype.unselectInto=function(t,e){n("overridden or never called on this node",!1)},e.prototype.selectOutOf=function(t,e){n("overridden or never called on this node",!1)},e.prototype.selectTowards=function(t,e){n("overridden or never called on this node",!1)},e}(X),rt.onNotify(function(t,e){"move"!==e&&"upDown"!==e||t.show().clearSelection()}),st.leftRightIntoCmdGoes=function(t){if(t&&"up"!==t&&"down"!==t)throw'"up" or "down" required for leftRightIntoCmdGoes option, got "'+t+'"';return t},rt.onNotify(function(t,e){"upDown"!==e&&(t.upDownCache={})}),rt.onNotify(function(t,e){"edit"===e&&t.show().deleteSelection()}),rt.onNotify(function(t,e){"select"!==e&&t.endSelection()}),wt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.keystroke=function(t,e){this.cursor.parent.keystroke(t,e,this.getControllerSelf())},e.prototype.escapeDir=function(t,e,n){r(t);var o=this.cursor;if(o.parent!==this.root&&(null===n||void 0===n||n.preventDefault()),o.parent!==this.root)return o.clearSelection(),o.parent.moveOutOf(t,o),o.controller.aria.alert(),this.notify("move")},e.prototype.moveDir=function(t){var e,n,o;return r(t),e=this.cursor,n=e.options.leftRightIntoCmdGoes,o=e[t],e.selection?e.insDirOf(t,e.selection.getEnd(t)):o?o.moveTowards(t,e,n):e.parent.moveOutOf(t,e,n),this.notify("move")},e.prototype.moveLeft=function(){return this.moveDir(Ae)},e.prototype.moveRight=function(){return this.moveDir(Me)},e.prototype.moveUp=function(){return this.moveUpDown("up")},e.prototype.moveDown=function(){return this.moveUpDown("down")},e.prototype.moveUpDown=function(t){var e,n,r,o,i,s,a=this,l=a.notify("upDown").cursor;return"up"===t?(e="upInto",n="upOutOf"):(e="downInto",n="downOutOf"),r=l[Ae],o=l[Me],i=o&&o[e],s=r&&r[e],i?l.insAtLeftEnd(i):s?l.insAtRightEnd(s):l.parent.bubble(function(t){var e=t[n];if(e&&("function"==typeof e&&(e=e.call(t,l)),e instanceof bt&&l.jumpUpDown(t,e),!0!==e))return!1}),a},e.prototype.deleteDir=function(t){var e,n,o,i,s,a,l,c,u,p;return r(t),e=this.cursor,n=e[t],o=e.parent.parent,i=e.controller,n&&n instanceof bt?n.sides?i.aria.queue(n.parent.chToCmd(n.sides[-t].ch).mathspeak({createdLeftOf:e})):n.blocks||"\\text"===n.parent.ctrlSeq||i.aria.queue(n):o&&o instanceof bt&&(o.sides?i.aria.queue(o.parent.chToCmd(o.sides[t].ch).mathspeak({createdLeftOf:e})):o.blocks&&o.mathspeakTemplate?o.upInto&&o.downInto?i.aria.queue(o.mathspeakTemplate[1]):(s=o.mathspeakTemplate,a=t===Ae?s[0]:s[s.length-1],i.aria.queue(a)):i.aria.queue(o)),l=e.selection,this.notify("edit"),l||(c=e[t],c?c.deleteTowards(t,e):e.parent.deleteOutOf(t,e)),u=e[Ae],p=e[Me],u.siblingDeleted&&u.siblingDeleted(e.options,Me),p.siblingDeleted&&p.siblingDeleted(e.options,Ae),e.parent.bubble(function(t){t.reflow()}),this},e.prototype.ctrlDeleteDir=function(t){var e,n,o,i;return r(t),e=this.cursor,!e[t]||e.selection?this.deleteDir(t):(this.notify("edit"),n=t===Ae?new Y(e.parent.getEnd(Ae),e[Ae]):new Y(e[Me],e.parent.getEnd(Me)),e.controller.aria.queue(n),n.remove(),e.insAtDirEnd(t,e.parent),o=e[Ae],i=e[Me],o&&o.siblingDeleted(e.options,Me),i&&i.siblingDeleted(e.options,Ae),e.parent.bubble(function(t){t.reflow()}),this)},e.prototype.backspace=function(){return this.deleteDir(Ae)},e.prototype.deleteForward=function(){return this.deleteDir(Me)},e.prototype.startIncrementalSelection=function(){n("Multiple selections can't be simultaneously open",!xt),xt=!0,this.notify("select");var t=this.cursor;t.anticursor||t.startSelection()},e.prototype.selectDirIncremental=function(t){var e,o,i;n("A selection is open",xt),xt=!0,e=this.cursor,o=e.selection,r(t),i=e[t],i?o&&o.getEnd(t)===i&&e.anticursor[-t]!==i?i.unselectInto(t,e):i.selectTowards(t,e):e.parent.selectOutOf(t,e)},e.prototype.finishIncrementalSelection=function(){var t,e;n("A selection is open",xt),t=this.cursor,t.clearSelection(),t.select()||t.show(),e=t.selection,e&&t.controller.aria.clear().queue(e.join("mathspeak"," ").trim()+" selected"),xt=!1},e.prototype.withIncrementalSelection=function(t){var e=this;try{this.startIncrementalSelection();try{t(function(t){return e.selectDirIncremental(t)})}finally{this.finishIncrementalSelection()}}finally{xt=!1}},e.prototype.selectDir=function(t){this.withIncrementalSelection(function(e){return e(t)})},e.prototype.selectLeft=function(){return this.selectDir(Ae)},e.prototype.selectRight=function(){return this.selectDir(Me)},e.prototype.selectAll=function(){this.notify("move");var t=this.cursor;t.insAtRightEnd(this.root),this.withIncrementalSelection(function(e){for(;t[Ae];)e(Ae)})},e.prototype.selectToBlockEndInDir=function(t){var e=this.cursor;this.withIncrementalSelection(function(n){for(;e[t];)n(t)})},e.prototype.selectToRootEndInDir=function(t){var e=this,n=this.cursor;this.withIncrementalSelection(function(r){for(;n[t]||n.parent!==e.root;)r(t)})},e}(vt),function(t){function e(e){return t.call(this)||this}__extends(e,t)}(bt),Et=function(){function t(t){var e=new It;return t.adopt(e,0,0),e}function e(t){var e,n=t[0]||new It;for(e=1;e<t.length;e+=1)t[e].children().adopt(n,n.getEnd(Me),0);return n}var n=ft.string,r=ft.regex,o=ft.letter,i=ft.digit,s=ft.any,a=ft.optWhitespace,l=ft.succeed,c=ft.fail,u=o.map(function(t){return new jt(t)}),p=i.map(function(t){return new Pt(t)}),h=r(/^[^${}\\_^]/).map(function(t){return new At(t)}),d=r(/^[^\\a-eg-zA-Z]/).or(n("\\").then(r(/^[a-z]+/i).or(r(/^\s+/).result(" ")).or(s))).then(function(t){var e,n,r=Z[t];return r?r.constructor?(e=r,new e(t).parser()):(n=r,n(t).parser()):c("unknown command: \\"+t)}),f=d.or(u).or(p).or(h),m=n("{").then(function(){return y}).skip(n("}")),g=a.then(m.or(f.map(t))),y=g.many().map(e).skip(a),v=n("[").then(g.then(function(t){return"]"!==t.join("latex")?l(t):c("")}).many().map(e).skip(a)).skip(n("]")),x=y;return x.block=g,x.optBlock=v,x}(),st.maxDepth=function(t){return"number"==typeof t?t:void 0},kt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.cleanLatex=function(t){return t.replace(/(\\[a-z]+) (?![a-z])/gi,"$1")},e.prototype.exportLatex=function(){return this.cleanLatex(this.root.latex())},e.prototype.writeLatex=function(t){var e=this.notify("edit").cursor;return e.parent.writeLatex(e,t),this},e.prototype.prepareCursorForRestoration=function(){return this.cursor.clearSelection().endSelection(),this.notify("move").cursor},e.prototype.restoreLatexSelection=function(t){var e,n,r,o=this,i=this.exportLatexSelection(),s=i.selection,a=s.latex,l=t.latex;l===a&&(t.startIndex===s.startIndex&&t.endIndex===s.endIndex||(0===t.endIndex?this.prepareCursorForRestoration().insAtDirEnd(Ae,this.root):t.startIndex===l.length?this.prepareCursorForRestoration().insAtDirEnd(Me,this.root):(e=b(a,i.ctx.uncleanedLatex,t),n=this.exportLatexSelection(e).ctx.restoreInfo,t.startIndex===t.endIndex?(null===n||void 0===n?void 0:n.cursorL)?this.prepareCursorForRestoration().insRightOf(n.cursorL):(null===n||void 0===n?void 0:n.cursorParent)&&this.prepareCursorForRestoration().insAtLeftEnd(n.cursorParent):(null===n||void 0===n?void 0:n.selectionL)&&n.selectionR&&(this.prepareCursorForRestoration().insRightOf(n.selectionR),r=this.cursor.controller.root,this.withIncrementalSelection(function(t){do{if(t(Ae),!o.cursor[Ae]&&o.cursor.parent===r)break}while(o.cursor[Me]!==n.selectionL)})))))},e.prototype.exportLatexSelection=function(t){var e,n,r,o,i,s,a,l,c={uncleanedLatex:"",uncleanedStartIndex:-1,uncleanedEndIndex:-1};return t&&(c.restoreInfo={uncleanedStartIndex:t.uncleanStartIndex,uncleanedEndIndex:t.uncleanEndIndex}),e=this.cursor.selection,e&&this.cursor.anticursor?(c.startSelectionBefore=e.getEnd(Ae),c.endSelectionAfter=e.getEnd(Me)):(n=this.cursor[Ae],n?c.startSelectionAfter=n:c.startSelectionBefore=this.cursor.parent,r=this.cursor[Me],r?c.endSelectionBefore=r:c.endSelectionAfter=this.cursor.parent),this.root.latexRecursive(c),o=c.uncleanedLatex,i=this.cleanLatex(o),s=x(o,i,c),a=s.startIndex,l=s.endIndex,{selection:{latex:i,startIndex:a,endIndex:l},ctx:c}},e.prototype.domNodeToMqNode=function(t){for(var e,n;t;){if(e=X.getNodeOfElement(t)){if(!(n=w(e))||n===this.root)return e;t=n.controller.container}t=t.parentElement}},e.prototype.domNodeToSpan=function(t){var e,n,r,o,i,s,a,l={uncleanedLatex:"",uncleanedStartIndex:-1,uncleanedEndIndex:-1},c=this.domNodeToMqNode(t);if(c)return c instanceof It?(l.startSelectionBefore=c,l.endSelectionAfter=c):(e=c[Ae],e?l.startSelectionAfter=e:l.startSelectionBefore=c.parent,n=c[Me],n?l.endSelectionBefore=n:l.endSelectionAfter=c.parent),this.root.latexRecursive(l),r=l.uncleanedLatex,o=this.cleanLatex(r),i=x(r,o,l),s=i.startIndex,a=i.endIndex,{latex:o,startIndex:s,endIndex:a}},e.prototype.classifyLatexForEfficientUpdate=function(t){if("string"==typeof t){var e=t.match(/-?[0-9.]+$/g);return e&&1===e.length?{latex:t,prefix:t.substr(0,t.length-e[0].length),digits:e[0]}:void 0}},e.prototype.updateLatexMathEfficiently=function(t,e){var n,r,o,i,s,a,l,c,u,p,h,d,f,m,g,y,v,x,b,w,E,k,L,S,_,q=this.root,O=this.classifyLatexForEfficientUpdate(t);if(!O)return!1;if(!(s=this.classifyLatexForEfficientUpdate(e))||s.prefix!==O.prefix)return!1;for(a=s.digits,l=O.digits,c=!1,u=!1,"-"===a[0]&&(c=!0,a=a.substr(1)),"-"===l[0]&&(u=!0,l=l.substr(1)),p=this.root.getEnd(Me),h=[],d=a.length-1;d>=0;d--){if(!p||p.ctrlSeq!==a[d])return!1;if(p.parent!==q)return!1;h.unshift(p),p=p[Ae]}if(c&&!u){if(!(f=p))return!1;if("-"!==f.ctrlSeq)return!1;if(f[Me]!==h[0])return!1;if(f.parent!==q)return!1;if((m=f[Ae])&&m.parent!==q)return!1;h[0][Ae]=f[Ae],q.getEnd(Ae)===f&&q.setEnds((n={},n[Ae]=h[0],n[Me]=q.getEnd(Me),n)),m&&(m[Me]=h[0]),f.domFrag().remove()}for(!c&&u&&(g=new Xt("-"),y=document.createElement("span"),y.textContent="−",g.setDOM(y),v=h[0][Ae],v&&(v[Me]=g),q.getEnd(Ae)===h[0]&&q.setEnds((r={},r[Ae]=g,r[Me]=q.getEnd(Me),r)),g.parent=q,g[Ae]=h[0][Ae],g[Me]=h[0],h[0][Ae]=g,g.contactWeld(this.cursor),g.domFrag().insertBefore(h[0].domFrag())),x=Math.min(a.length,l.length),d=0;d<x;d++)b=l[d],p=h[d],p.ctrlSeq!==b&&(p.ctrlSeq=b,p.domFrag().oneElement().textContent=b,p.mathspeakName=b);if(a.length>l.length)for(p=h[l.length-1],q.setEnds((o={},o[Ae]=q.getEnd(Ae),o[Me]=p,o)),p[Me]=0,d=a.length-1;d>=x;d--)h[d].domFrag().remove();if(l.length>a.length){for(w=document.createDocumentFragment(),d=x;d<l.length;d++)E=document.createElement("span"),E.className="mq-digit",E.textContent=l[d],k=new Pt(l[d]),k.parent=q,k.setDOM(E),w.appendChild(E),k[Ae]=q.getEnd(Me),k[Me]=0,L=k[Ae],L[Me]=k,q.setEnds((i={},i[Ae]=q.getEnd(Ae),i[Me]=k,i));q.domFrag().oneElement().appendChild(w)}return(S=this.exportLatex())!==t?(console.warn("tried updating latex efficiently but did not work. Attempted: "+t+" but wrote: "+S),!1):(_=q.getEnd(Me),_&&_.fixDigitGrouping(this.cursor.options),!0)},e.prototype.renderLatexMathFromScratch=function(t){var e,n,r=this.root,o=this.cursor,i=ft.all,s=ft.eof,a=Et.skip(s).or(i.result(!1)).parse(t);r.setEnds((e={},e[Ae]=0,e[Me]=0,e)),a&&a.children().adopt(r,0,0),a?(n=r.domFrag(),n.children().remove(),n.oneElement().appendChild(a.html()),r.finalizeInsert(o.options,o)):r.domFrag().empty()},e.prototype.renderLatexMath=function(t){var e,n=this.cursor,r=this.root;this.notify("replace"),n.clearSelection(),e=this.exportLatex(),r.getEnd(Ae)&&r.getEnd(Me)&&e===t||(this.updateLatexMathEfficiently(t,e)||this.renderLatexMathFromScratch(t),this.updateMathspeak()),n.insAtRightEnd(r)},e.prototype.renderLatexText=function(t){var e,n,r,o,i,s,a,l,c,u,p,h=this.root,d=this.cursor;if(h.domFrag().children().slice(1).remove(),h.setEnds((e={},e[Ae]=0,e[Me]=0,e)),delete d.selection,d.show().insAtRightEnd(h),n=ft.regex,r=ft.string,o=ft.eof,i=ft.all,s=r("$").then(Et).skip(r("$").or(o)).map(function(t){var e,n=new RootMathCommand(d);return n.createBlocks(),e=n.getEnd(Ae),t.children().adopt(e,0,0),n}),a=r("\\$").result("$"),l=a.or(n(/^[^$]/)).map(function(t){return new At(t)}),c=s.or(l).many(),u=c.skip(o).or(i.result(!1)).parse(t)){for(p=0;p<u.length;p+=1)u[p].adopt(h,h.getEnd(Me),0);U(h.html()).appendTo(h.domFrag().oneElement()),h.finalizeInsert(d.options,d)}},e}(wt),Lt=function(t){return!1},at.prototype.ignoreNextMousedown=Lt,function(){rt.onNotify(function(t,e){"edit"!==e&&"replace"!==e||St&&St.cursor===t&&St.cb()})}(),_t=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.handleMouseDown=function(e){function r(t){c=t.target}function o(t){m.anticursor||m.startSelection(),f.seek(c,t.clientX,t.clientY).cursor.select(),m.selection&&m.controller.aria.clear().queue(m.selection.join("mathspeak")+" selected").alert(),c=null}function s(){null===p||void 0===p||p.removeEventListener("mousemove",r),null===d||void 0===d||d.removeEventListener("mousemove",o),null===d||void 0===d||d.removeEventListener("mouseup",l),St=void 0,f.isMouseSelecting=!1}function a(){f.editable&&(m.show(),m.controller.aria.queue(m.parent).alert())}function l(){m.blink=g,m.selection||a(),s()}var c,u,p=i(e.target,".mq-root-block"),h=p&&X.getNodeOfElement(p)||X.getNodeOfElement(n.root.domFrag().oneElement()),d=h.domFrag().firstNode().ownerDocument,f=h.controller,m=f.cursor,g=m.blink,y=f.getTextarea();e.preventDefault(),e.target.unselectable=!0,m.options.ignoreNextMousedown(e)||i(e.target,".mq-ignore-mousedown")||(c=null,St={cursor:m,cb:function(){u=!0,m.blink=g,m.clearSelection(),a(),s()}},f.blurred&&(n.editable&&y.focus(),u)||(m.blink=t,f.isMouseSelecting=!0,f.seek(e.target,e.clientX,e.clientY).cursor.startSelection(),null===p||void 0===p||p.addEventListener("mousemove",r),null===d||void 0===d||d.addEventListener("mousemove",o),null===d||void 0===d||d.addEventListener("mouseup",l)))},n}return __extends(n,e),n.prototype.addMouseEventListener=function(){this.container.addEventListener("mousedown",this.handleMouseDown)},n.prototype.removeMouseEventListener=function(){this.container.removeEventListener("mousedown",this.handleMouseDown)},n.prototype.seek=function(t,e,n){var r=this.notify("select").cursor,o=this.domNodeToMqNode(t);return o||(o=this.root),r.clearSelection().show(),o.seek(e,r),this.scrollHoriz(),this},n}(kt),qt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setOverflowClasses=function(){var t,e,n,r=this.root.domFrag().oneElement(),o=!1,i=!1;this.blurred||(t=s(r).width,e=r.scrollWidth,n=r.scrollLeft,o=e>t+n,i=n>0),r.classList.contains("mq-editing-overflow-right")!==o&&r.classList.toggle("mq-editing-overflow-right"),r.classList.contains("mq-editing-overflow-left")!==i&&r.classList.toggle("mq-editing-overflow-left")},e.prototype.scrollHoriz=function(){var t,e,n,r,o,i,a,l,c,u,p=this,h=this.cursor,d=h.selection,f=s(this.root.domFrag().oneElement());if(h.domFrag().isEmpty()&&!d)return this.cancelScrollHoriz&&(this.cancelScrollHoriz(),this.cancelScrollHoriz=void 0),
12
- t=this.root.domFrag().oneElement(),e=t.scrollLeft,void W(this.getScrollAnimationDuration(),function(n,r,o){n>=1?(p.cancelScrollHoriz=void 0,t.scrollLeft=0,p.setOverflowClasses()):(p.cancelScrollHoriz=o,r(),t.scrollLeft=Math.round((1-n)*e))});if(d)if(o=s(d.domFrag().oneElement()),i=o.left-(f.left+20),a=o.right-(f.right-20),d.getEnd(Ae)===h[Me])if(i<0)r=i;else{if(!(a>0))return;r=o.left-a<f.left+20?i:a}else if(a>0)r=a;else{if(!(i<0))return;r=o.right-i>f.right-20?a:i}else if((n=s(h.domFrag().oneElement()).left)>f.right-20)r=n-(f.right-20);else{if(!(n<f.left+20))return;r=n-(f.left+20)}l=this.root.domFrag().oneElement(),r<0&&0===l.scrollLeft||r>0&&l.scrollWidth<=l.scrollLeft+f.width||(this.cancelScrollHoriz&&(this.cancelScrollHoriz(),this.cancelScrollHoriz=void 0),c=this.root.domFrag().oneElement(),u=c.scrollLeft,W(this.getScrollAnimationDuration(),function(t,e,n){t>=1?(p.cancelScrollHoriz=void 0,c.scrollLeft=Math.round(u+r),p.setOverflowClasses()):(p.cancelScrollHoriz=n,e(),c.scrollLeft=Math.round(u+t*r))}))},e.prototype.getScrollAnimationDuration=function(){var t;return null!==(t=this.options.scrollAnimationDuration)&&void 0!==t?t:100},e}(_t),at.prototype.substituteTextarea=function(){return Be("textarea",{autocapitalize:"off",autocomplete:"off",autocorrect:"off",spellcheck:!1,"x-palm-disable-ste-all":!0})},at.prototype.substituteKeyboardEvents=k,Ot=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.selectFn=t,n}return __extends(n,e),n.prototype.createTextarea=function(){var t,e,n;if(this.textareaSpan=Be("span",{class:"mq-textarea"}),t=this.options.substituteTextarea(),!t.nodeType)throw"substituteTextarea() must return a DOM element, got "+t;this.textarea=U(t).appendTo(this.textareaSpan).oneElement(),this.mathspeakSpan||(this.mathspeakId=E(),this.mathspeakSpan=Be("span",{class:"mq-mathspeak",id:this.mathspeakId}),U(this.textareaSpan).prepend(U(this.mathspeakSpan))),this.mathspeakId&&(null===t||void 0===t||t.setAttribute("aria-labelledby",this.mathspeakId)),e=this,e.cursor.selectionChanged=function(){e.selectionChanged()},n=void 0!==this.options.tabindex?this.options.tabindex:"StaticMath"===this.KIND_OF_MQ?-1:0,this.setTabindex(n)},n.prototype.setTabindex=function(t){var e,n,r,o,i;t!==this.previousTabindex&&this.textarea&&(this.previousTabindex=t,null===(e=this.textarea)||void 0===e||e.setAttribute("tabindex",""+t),t<0&&"StaticMath"===this.KIND_OF_MQ?null===(n=this.textarea)||void 0===n||n.setAttribute("aria-hidden","true"):null===(r=this.textarea)||void 0===r||r.removeAttribute("aria-hidden"),t>=0?null===(o=this.mathspeakSpan)||void 0===o||o.setAttribute("aria-hidden","true"):null===(i=this.mathspeakSpan)||void 0===i||i.removeAttribute("aria-hidden"))},n.prototype.selectionChanged=function(){var t=this;t.textareaSelectionTimeout||(t.textareaSelectionTimeout=setTimeout(function(){t.setTextareaSelection()}))},n.prototype.setTextareaSelection=function(){this.textareaSelectionTimeout=0;var t="";this.cursor.selection&&(t=this.cleanLatex(this.cursor.selection.join("latex")),this.options.statelessClipboard&&(t="$"+t+"$")),this.selectFn(t)},n.prototype.staticMathTextareaEvents=function(){var t,e,n,r=this;this.removeTextareaEventListener("cut"),this.removeTextareaEventListener("paste"),r.options.disableCopyPaste?this.removeTextareaEventListener("copy"):this.addTextareaEventListeners({copy:function(){r.setTextareaSelection()}}),this.addStaticFocusBlurListeners(),t=this.getTextarea(),e=gt(t,this).select,this.selectFn=e,n=this.getTextareaSpan(),U(this.container).prepend(U(n))},n.prototype.editablesTextareaEvents=function(){var t,e,n,r=this,o=r.getTextarea(),i=r.getTextareaSpan();this.options.version<3?(t=this.options.assertJquery(),e=this.options.substituteKeyboardEvents(t(o),this),this.selectFn=function(t){e.select(t)}):(n=gt(o,this).select,this.selectFn=n),U(this.container).prepend(U(i)),this.addEditableFocusBlurListeners(),this.updateMathspeak()},n.prototype.unbindEditablesEvents=function(){var t=this,e=t.getTextarea(),n=t.getTextareaSpan();this.selectFn=function(t){e instanceof HTMLTextAreaElement&&(e.value=t,t&&e.select())},U(n).remove(),this.removeTextareaEventListener("focus"),this.removeTextareaEventListener("blur"),t.blurred=!0,this.removeTextareaEventListener("cut"),this.removeTextareaEventListener("paste")},n.prototype.typedText=function(t){if("\n"===t)return this.handle("enter");var e=this.notify(void 0).cursor;e.parent.write(e,t),this.scrollHoriz()},n.prototype.cut=function(){var t=this,e=t.cursor;e.selection&&setTimeout(function(){t.notify("edit"),e.parent.bubble(function(t){t.reflow()}),t.options&&t.options.onCut&&t.options.onCut()})},n.prototype.copy=function(){this.setTextareaSelection()},n.prototype.paste=function(t){this.options.statelessClipboard&&(t="$"===t.slice(0,1)&&"$"===t.slice(-1)?t.slice(1,-1):"\\text{"+t+"}"),this.writeLatex(t).cursor.show(),this.scrollHoriz(),this.options&&this.options.onPaste&&this.options.onPaste()},n.prototype.setupStaticField=function(){this.updateMathspeak(),this.blurred=!0,this.cursor.hide().parent.blur(this.cursor)},n.prototype.updateMathspeak=function(t){var e=this,n=e.getAriaLabel(),r=/[A-Za-z0-9]$/.test(n)?n+":":n,o=e.root.mathspeak().trim(),i=!!(null===t||void 0===t?void 0:t.emptyContent);this.aria.clear({emptyContent:i}),e.mathspeakSpan&&(e.mathspeakSpan.textContent=(r+" "+o+" "+e.ariaPostLabel).trim())},n}(qt),Ct=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.finalizeInsert=function(t,e){var n,r,o=this;o.postOrder(function(e){e.finalizeTree(t)}),o.postOrder(function(t){t.contactWeld(e)}),o.postOrder(function(t){t.blur(e)}),o.postOrder(function(t){t.reflow()}),n=o[Me],r=o[Ae],n&&n.siblingCreated(t,Ae),r&&r.siblingCreated(t,Me),o.bubble(function(t){t.reflow()})},e.prototype.prepareInsertionAt=function(t){var e,n=t.options.maxDepth;if(void 0!==n){if((e=t.depth())>n)return!1;this.removeNodesDeeperThan(n-e)}return!0},e.prototype.removeNodesDeeperThan=function(t){for(var e,n,r=0,o=[[this,r]];e=o.shift();)n=e,n[0].children().each(function(e){var i=e instanceof It?1:0;r=n[1]+i,r<=t?o.push([e,r]):(i?e.children():e).remove()})},e}(bt),Tt=function(){function t(t,e){this.childCount=t,this.render=e}return t}(),Ft=function(t){function e(e,n,r){var o=t.call(this)||this;return o.textTemplate=[""],o.mathspeakTemplate=[""],o.setCtrlSeqHtmlAndText(e,n,r),o}return __extends(e,t),e.prototype.setEnds=function(t){n("MathCommand ends are never empty",t[Ae]&&t[Me]),this.ends=t},e.prototype.getEnd=function(t){return this.ends[t]},e.prototype.setCtrlSeqHtmlAndText=function(t,e,n){this.ctrlSeq||(this.ctrlSeq=t),e&&(this.domView=e),n&&(this.textTemplate=n)},e.prototype.replaces=function(t){t.disown(),this.replacedFragment=t},e.prototype.isEmpty=function(){return this.foldChildren(!0,function(t,e){return t&&e.isEmpty()})},e.prototype.parser=function(){var t=this;return Et.block.times(this.numBlocks()).map(function(e){t.blocks=e;for(var n=0;n<e.length;n+=1)e[n].adopt(t,t.getEnd(Me),0);return t})},e.prototype.createLeftOf=function(e){var n,r=this,o=r.replacedFragment;r.createBlocks(),t.prototype.createLeftOf.call(this,e),o&&(n=r.getEnd(Ae),o.adopt(n,0,0),o.domFrag().appendTo(n.domFrag().oneElement()),r.placeCursor(e),r.prepareInsertionAt(e)),r.finalizeInsert(e.options,e),r.placeCursor(e)},e.prototype.createBlocks=function(){var t,e,n=this,r=n.numBlocks(),o=n.blocks=Array(r);for(t=0;t<r;t+=1)e=o[t]=new It,e.adopt(n,n.getEnd(Me),0)},e.prototype.placeCursor=function(t){t.insAtRightEnd(this.foldChildren(this.getEnd(Ae),function(t,e){return t.isEmpty()?t:e}))},e.prototype.moveTowards=function(t,e,n){var r,o;"up"===n?r=this.upInto:"down"===n&&(r=this.downInto),o=r||this.getEnd(-t),e.insAtDirEnd(-t,o),e.controller.aria.queueDirEndOf(-t).queue(e.parent,!0)},e.prototype.deleteTowards=function(t,e){this.isEmpty()?e[t]=this.remove()[t]:this.moveTowards(t,e)},e.prototype.selectTowards=function(t,e){e[-t]=this,e[t]=this[t]},e.prototype.selectChildren=function(){return new nt(this,this)},e.prototype.unselectInto=function(t,e){var n=e.anticursor,r=n.ancestors[this.id];e.insAtDirEnd(-t,r)},e.prototype.seek=function(t,e){function n(t){var e,n=t.domFrag().oneElement(),r=s(n).left,o=r+n.offsetWidth;return e={},e[Ae]=r,e[Me]=o,e}var r,o=this,i=n(o);return t<i[Ae]?e.insLeftOf(o):t>i[Me]?e.insRightOf(o):(r=i[Ae],void o.eachChild(function(s){var a=n(s);return t<a[Ae]?(t-r<a[Ae]-t?s[Ae]?e.insAtRightEnd(s[Ae]):e.insLeftOf(o):e.insAtLeftEnd(s),!1):t>a[Me]?void(s[Me]?r=a[Me]:i[Me]-t<t-a[Me]?e.insRightOf(o):e.insAtRightEnd(s)):(s.seek(t,e),!1)}))},e.prototype.numBlocks=function(){return this.domView.childCount},e.prototype.html=function(){var t,e,r=this.blocks;return n("domView is defined",this.domView),t=this.domView,e=t.render(r||[]),this.setDOM(e),X.linkElementByCmdNode(e,this),e},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+=this.ctrlSeq||"",this.eachChild(function(e){var n,r;t.uncleanedLatex+="{",n=t.uncleanedLatex.length,e.latexRecursive(t),r=t.uncleanedLatex.length,n===r&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}"}),this.checkCursorContextClose(t)},e.prototype.text=function(){var t=this,e=0;return t.foldChildren(t.textTemplate[e],function(n,r){e+=1;var o=r.text();return n&&"("===t.textTemplate[e]&&"("===o[0]&&")"===o.slice(-1)?n+o.slice(1,-1)+t.textTemplate[e]:n+o+(t.textTemplate[e]||"")})},e.prototype.mathspeak=function(){var t=this,e=0;return t.foldChildren(t.mathspeakTemplate[e]||"Start"+t.ctrlSeq+" ",function(n,r){return e+=1,n+" "+r.mathspeak()+" "+(t.mathspeakTemplate[e]+" "||"End"+t.ctrlSeq+" ")})},e}(Ct),Dt=function(t){function e(e,n,r,o){var i=t.call(this)||this;return i.setCtrlSeqHtmlTextAndMathspeak(e,n?new Tt(0,function(){return n.cloneNode(!0)}):void 0,r,o),i}return __extends(e,t),e.prototype.setCtrlSeqHtmlTextAndMathspeak=function(e,n,r,o){!r&&e&&(r=e.replace(/^\\/,"")),this.mathspeakName=o||r,t.prototype.setCtrlSeqHtmlAndText.call(this,e,n,[r||""])},e.prototype.parser=function(){return ft.succeed(this)},e.prototype.numBlocks=function(){return 0},e.prototype.replaces=function(t){t.remove()},e.prototype.createBlocks=function(){},e.prototype.moveTowards=function(t,e){e.domFrag().insDirOf(t,this.domFrag()),e[-t]=this,e[t]=this[t],e.controller.aria.queue(this)},e.prototype.deleteTowards=function(t,e){e[t]=this.remove()[t]},e.prototype.seek=function(t,e){var n=this.domFrag().oneElement();return t-s(n).left<n.offsetWidth/2?e.insLeftOf(this):e.insRightOf(this),e},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+=this.ctrlSeq||"",this.checkCursorContextClose(t)},e.prototype.text=function(){return this.textTemplate.join("")},e.prototype.mathspeak=function(t){return this.mathspeakName||""},e.prototype.placeCursor=function(){},e.prototype.isEmpty=function(){return!0},e}(Ft),At=function(t){function e(e,n,r){return t.call(this,e,Be("span",{},[n||Be.text(e)]),void 0,r)||this}return __extends(e,t),e}(Dt),Mt=function(t){function e(e,n,r,o,i){return i?t.call(this,e,Be("span",{},[n||Be.text(e||"")]),void 0,o)||this:t.call(this,e,Be("span",{class:"mq-binary-operator"},n?[n]:[]),r,o)||this}return __extends(e,t),e.prototype.isBinaryOperator=function(){return!0},e}(Dt),It=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ariaLabel="block",e}return __extends(e,t),e.prototype.join=function(t){return this.foldChildren("",function(e,n){return e+n[t]()})},e.prototype.html=function(){var t=document.createDocumentFragment();return this.eachChild(function(e){var n=e.html();t.appendChild(n)}),t},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),this.eachChild(function(e){return e.latexRecursive(t)}),this.checkCursorContextClose(t)},e.prototype.text=function(){var t=this.getEnd(Ae);return t===this.getEnd(Me)&&0!==t?t.text():this.join("text")},e.prototype.mathspeak=function(){var t,e,n="",r={};return this.controller&&(r=this.controller.options.autoOperatorNames),t=this.foldChildren([],function(t,e){var o,i,s;return e.isPartOfOperator?n+=e.mathspeak():(""!==n&&(r._maxLength>0&&"string"==typeof(o=r[n.toLowerCase()])&&(n=o),t.push(n+" "),n=""),i=e.mathspeak(),s=e.ctrlSeq,!isNaN(s)||"."===s||e.parent&&e.parent.parent&&e.parent.parent.isTextBlock()||(i=" "+i+" "),t.push(i)),t}),""!==n&&(r._maxLength>0&&"string"==typeof(e=r[n.toLowerCase()])&&(n=e),t.push(n+" "),n=""),t.join("").replace(/ +(?= )/g,"").replace(/(\.)([0-9]+)/g,function(t,e,n){return e+n.split("").join(" ").trim()})},e.prototype.keystroke=function(e,n,r){return!r.options.spaceBehavesLikeTab||"Spacebar"!==e&&"Shift-Spacebar"!==e?t.prototype.keystroke.call(this,e,n,r):(null===n||void 0===n||n.preventDefault(),void r.escapeDir("Shift-Spacebar"===e?Ae:Me,e,n))},e.prototype.moveOutOf=function(t,e,n){var r,o;"up"===n?r=this.parent.upInto:"down"===n&&(r=this.parent.downInto),!r&&this[t]?(o=-t,e.insAtDirEnd(o,this[t]),e.controller.aria.queueDirEndOf(o).queue(e.parent,!0)):(e.insDirOf(t,this.parent),e.controller.aria.queueDirOf(t).queue(this.parent))},e.prototype.selectOutOf=function(t,e){e.insDirOf(t,this.parent)},e.prototype.deleteOutOf=function(t,e){e.unwrapGramp()},e.prototype.seek=function(t,e){var n,r,o=this.getEnd(Me);if(!o)return e.insAtRightEnd(this);if(n=o.domFrag().oneElement(),s(n).left+n.offsetWidth<t)return e.insAtRightEnd(this);if(r=this.getEnd(Ae),t<s(r.domFrag().oneElement()).left)return e.insAtLeftEnd(this);for(;t<s(o.domFrag().oneElement()).left;)o=o[Ae];return o.seek(t,e)},e.prototype.chToCmd=function(t,e){var n;return t.match(/^[a-eg-zA-Z]$/)?new jt(t):/^\d$/.test(t)?new Pt(t):e&&e.typingSlashWritesDivisionSymbol&&"/"===t?Z["÷"](t):e&&e.typingAsteriskWritesTimesSymbol&&"*"===t?Z["×"](t):e&&e.typingPercentWritesPercentOf&&"%"===t?Z.percentof(t):(n=J[t]||Z[t])?n.constructor?new n(t):n(t):new At(t)},e.prototype.write=function(t,e){var n=this.chToCmd(e,t.options);t.selection&&n.replaces(t.replaceSelection()),t.isTooDeep()||(n.createLeftOf(t.show()),"/"===e?t.controller.aria.alert("over"):t.controller.aria.alert(n.mathspeak({createdLeftOf:t})))},e.prototype.writeLatex=function(t,e){var n,r,o,i,s=ft.all,a=ft.eof,l=Et.skip(a).or(s.result(!1)).parse(e);l&&!l.isEmpty()&&l.prepareInsertionAt(t)&&(l.children().adopt(t.parent,t[Ae],t[Me]),U(l.html()).insertBefore(t.domFrag()),t[Ae]=l.getEnd(Me),l.finalizeInsert(t.options,t),n=l.getEnd(Me),r=l.getEnd(Ae),o=n[Me],i=r[Ae],o&&o.siblingCreated(t.options,Ae),i&&i.siblingCreated(t.options,Me),t.parent.bubble(function(t){t.reflow()}))},e.prototype.focus=function(){return this.domFrag().addClass("mq-hasCursor"),this.domFrag().removeClass("mq-empty"),this},e.prototype.blur=function(t){return this.domFrag().removeClass("mq-hasCursor"),this.isEmpty()&&(this.domFrag().addClass("mq-empty"),t&&this.isQuietEmptyDelimiter(t.options.quietEmptyDelimiters)&&this.domFrag().addClass("mq-quiet-delimiter")),this},e}(Ct),at.prototype.mouseEvents=!0,ot.StaticMath=function(t){var e;return e=function(e){function n(n){var r=e.call(this,n)||this,o=r.innerFields=[];return r.__controller.root.postOrder(function(e){e.registerInnerField(o,t.InnerMathField)}),r}return __extends(n,e),n.prototype.__mathquillify=function(t,n){return this.config(t),e.prototype.mathquillify.call(this,"mq-math-mode"),this.__controller.setupStaticField(),this.__options.mouseEvents&&this.__controller.addMouseEventListener(),this.__controller.staticMathTextareaEvents(),this},n.prototype.latex=function(n){var r,o=e.prototype.latex.apply(this,arguments);return arguments.length>0&&(r=this.innerFields=[],this.__controller.root.postOrder(function(e){e.registerInnerField(r,t.InnerMathField)}),this.__controller.updateMathspeak()),o},n.prototype.setAriaLabel=function(t){return this.__controller.setAriaLabel(t),this},n.prototype.getAriaLabel=function(){return this.__controller.getAriaLabel()},n}(t.AbstractMathQuill),e.RootBlock=It,e},Nt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(It),y(Nt.prototype),ot.MathField=function(e){var n;return n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.__mathquillify=function(n,r){return this.config(n),r>1&&(this.__controller.root.reflow=t),e.prototype.mathquillify.call(this,"mq-editable-field mq-math-mode"),delete this.__controller.root.reflow,this},n}(e.EditableField),n.RootBlock=Nt,n},ot.InnerMathField=function(t){return n("MathField class is defined",t.MathField),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.makeStatic=function(){this.__controller.editable=!1,this.__controller.root.blur(),this.__controller.unbindEditablesEvents(),U(this.__controller.container).removeClass("mq-editable-field")},e.prototype.makeEditable=function(){this.__controller.editable=!0,this.__controller.editablesTextareaEvents(),this.__controller.cursor.insAtRightEnd(this.__controller.root),U(this.__controller.container).addClass("mq-editable-field")},e}(t.MathField)},Bt="\\ ",Rt=".",zt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.finalizeTree=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingDeleted=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingCreated=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.sharedSiblingMethod=function(t,n){n!==Ae&&this[Me]instanceof e||this.fixDigitGrouping(t)},e.prototype.fixDigitGrouping=function(t){var n,r;if(t.enableDigitGrouping){n=this,r=n;do{if(/^[0-9]$/.test(r.ctrlSeq))n=r;else if(r.ctrlSeq===Bt)n=r;else{if(r.ctrlSeq!==Rt)break;n=r}}while(r=n[Ae]);e.fixDigitGroupingFromLeft(t,n)}},e.fixDigitGroupingFromLeft=function(t,r){for(var o,i,s,a,l,c,u,p,h;r&&r.ctrlSeq===Bt;){if(!r[Me])return;r=r[Me]}if(r instanceof e){o=r,n("node",o),i=r,s=0,a=0,l=[];do{if(/^[0-9]$/.test(o.ctrlSeq))i=o,a=0;else if(o.ctrlSeq===Bt)i=o,s+=1,a=0;else{if(!(o.ctrlSeq===Rt&&o instanceof e))break;i=o,l.push(o),t.tripleDotsAreEllipsis&&(a+=1)}if(3==a)break}while(o=i[Me]);if(3!==a||(c=l.pop(),u=l.pop(),p=l.pop(),c[Me]instanceof e&&e.fixDigitGroupingFromLeft(t,c[Me]),c.setGroupingClass("mq-ellipsis-end"),u.setGroupingClass("mq-ellipsis-middle"),p.setGroupingClass("mq-ellipsis-start"),i=p[Ae],r!==p)){for(;i!==r&&i&&i.ctrlSeq===Bt;)i=i[Ae],s-=1;r===i&&r&&r.ctrlSeq===Bt||(h=s>0||l.length>1,h?e.removeGroupingBetween(r,i):l[0]?(l[0]!==r&&e.addGroupingBetween(l[0][Ae],r),l[0]!==i&&e.removeGroupingBetween(l[0],i)):e.addGroupingBetween(i,r))}}},e.removeGroupingBetween=function(t,n){var r=t;do{if(r instanceof e&&r.setGroupingClass(void 0),!r||r===n)break}while(r=r[Me])},e.addGroupingBetween=function(t,r){for(var o,i,s=t,a=0,l=0;s&&(l+=1,n("digit",s instanceof e),s!==r);)s=s[Ae];for(o=l%3,0===o&&(o=3),s=t;s&&(a+=1,i=void 0,l>=4&&(a===l?i="mq-group-leading-"+o:a%3==0&&a!==l&&(i="mq-group-start"),i||(i="mq-group-other")),s instanceof e&&s.setGroupingClass(i),s!==r);)s=s[Ae]},e.prototype.setGroupingClass=function(t){this._groupingClass!==t&&(this._groupingClass&&this.domFrag().removeClass(this._groupingClass),t&&this.domFrag().addClass(t),this._groupingClass=t)},e}(Dt),Pt=function(t){function e(e,n){return t.call(this,e,Be("span",{class:"mq-digit"},[Be.text(e)]),void 0,n)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n=e[Ae],r=n&&n[Ae],o=e.parent.parent instanceof ue?e.parent.parent.sub:void 0;e.options.autoSubscriptNumerals&&e.parent!==o&&(n instanceof Ht&&!1!==n.isItalic||n instanceof ue&&r instanceof Ht&&!1!==r.isItalic)?(new ue("sub").createLeftOf(e),t.prototype.createLeftOf.call(this,e),e.insRightOf(e.parent.parent)):t.prototype.createLeftOf.call(this,e)},e.prototype.mathspeak=function(e){var n,r,o,i;return e&&e.createdLeftOf&&(n=e.createdLeftOf,r=n[Ae],o=r&&r[Ae],i=n.parent.parent instanceof ue?n.parent.parent.sub:void 0,n.options.autoSubscriptNumerals&&n.parent!==i&&(r instanceof Ht&&!1!==r.isItalic||n[Ae]instanceof ue&&o instanceof Ht&&!1!==o.isItalic))?"Subscript "+t.prototype.mathspeak.call(this)+" Baseline":t.prototype.mathspeak.call(this)},e}(zt),Ht=function(t){function e(e,n){return t.call(this,e,Be("var",{},[n||Be.text(e)]))||this}return __extends(e,t),e.prototype.text=function(){var t=this.ctrlSeq||"";return this.isPartOfOperator?"\\"==t[0]?t=t.slice(1,t.length):" "==t[t.length-1]&&(t=t.slice(0,-1)):(!this[Ae]||this[Ae]instanceof e||this[Ae]instanceof Mt||"\\ "===this[Ae].ctrlSeq||(t="*"+t),!this[Me]||this[Me]instanceof Mt||this[Me]instanceof ue||(t+="*")),t},e.prototype.mathspeak=function(){var e=this.ctrlSeq||"";return this.isPartOfOperator||e.length>1||this.parent&&this.parent.parent&&this.parent.parent.isTextBlock()?t.prototype.mathspeak.call(this):'"'+e+'"'},e}(Dt),at.prototype.autoCommands={_maxLength:0},st.autoCommands=function(t){var e,n,r,o,i;if("string"!=typeof t||!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},r=0,o=0;o<e.length;o+=1){if(i=e[o],i.length<2)throw'autocommand "'+i+'" not minimum length of 2';if(Z[i]===Wt)throw'"'+i+'" is a built-in operator name';n[i]=1,r=Ne(r,i.length)}return n._maxLength=r,n},at.prototype.quietEmptyDelimiters={},st.quietEmptyDelimiters=function(t){var e,n,r,o;for(void 0===t&&(t=""),e=t.split(" "),n={},r=0;r<e.length;r+=1)o=e[r],n[o]=1;return n},at.prototype.autoParenthesizedFunctions={_maxLength:0},st.autoParenthesizedFunctions=function(t){var e,n,r,o,i;if("string"!=typeof t||!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},r=0,o=0;o<e.length;o+=1){if(i=e[o],i.length<2)throw'autocommand "'+i+'" not minimum length of 2';n[i]=1,r=Ne(r,i.length)}return n._maxLength=r,n},jt=function(t){function e(e){var n=t.call(this,e)||this;return n.letter=e,n}return __extends(e,t),e.prototype.checkAutoCmds=function(t){var e,n,r,o,i,s,a,l;if(!this.shouldIgnoreSubstitutionInSimpleSubscript(t.options)&&(n=t.options.autoCommands,(r=n._maxLength||0)>0))for(o=null!==(e=q(this,r))&&void 0!==e?e:"";o.length;){if(n.hasOwnProperty(o)){for(i=this,s=1;i&&s<o.length;s+=1,i=i[Ae]);return new Y(i,this).remove(),t[Ae]=i[Ae],a=Z[o],l=f(a)?new a(o):a(o),l.createLeftOf(t)}o=o.slice(1)}},e.prototype.autoParenthesize=function(t){var n,r,o,i,s,a,l=t.parent.getEnd(Me);if(!(l&&l instanceof Le&&"\\left("===l.ctrlSeq||this.shouldIgnoreSubstitutionInSimpleSubscript(t.options))){for(n="",r=this,o=0,i=t.options.autoParenthesizedFunctions,s=i._maxLength||0,a=t.options.autoOperatorNames;r instanceof e&&o<s;)n=r.letter+n,r=r[Ae],o+=1;for(;n.length;){if(i.hasOwnProperty(n)&&a.hasOwnProperty(n))return t.parent.write(t,"(");n=n.slice(1)}}},e.prototype.createLeftOf=function(e){t.prototype.createLeftOf.call(this,e),this.checkAutoCmds(e),this.autoParenthesize(e)},e.prototype.italicize=function(t){return this.isItalic=t,this.isPartOfOperator=!t,t&&(delete this.endsCategory,delete this.endsWord),this.domFrag().toggleClass("mq-operator-name",!t),this},e.prototype.finalizeTree=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingDeleted=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingCreated=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.sharedSiblingMethod=function(t,n){n!==Ae&&this[Me]instanceof e||this.autoUnItalicize(t)},e.prototype.autoUnItalicize=function(t){var n,r,o,i,s,a,l,c,u,p,h,d,f,m,g,y,v,x,b=t.autoOperatorNames;if(0!==b._maxLength&&!this.shouldIgnoreSubstitutionInSimpleSubscript(t)){for(n=this.letter,r=this[Ae];r instanceof e;r=r[Ae])n=r.letter+n;for(o=this[Me];o instanceof e;o=o[Me])n+=o.letter;i=r&&r[Me],s=o&&o[Ae],new Y(i||this.parent.getEnd(Ae),s||this.parent.getEnd(Me)).each(function(t){t instanceof e&&(t.italicize(!0).domFrag().removeClass("mq-first mq-last mq-followed-by-supsub"),t.ctrlSeq=t.letter)}),a=b._maxLength||0;t:for(l=0,c=r[Me]||this.parent.getEnd(Ae);c&&l<n.length;l+=1,c=c[Me])for(u=Ie(a,n.length-l);u>0;u-=1)if(p=n.slice(l,l+u),h=void 0,b.hasOwnProperty(p)){for(d=0,f=c;d<u;d+=1,f=f[Me])f instanceof e&&(f.italicize(!1),h=f);m=Gt.hasOwnProperty(p),c.ctrlSeq=(m?"\\":"\\operatorname{")+c.ctrlSeq,h.ctrlSeq+=m?" ":"}",h.endsWord=p,t.infixOperatorNames[p]?h.endsCategory="infix":t.prefixOperatorNames[p]&&(h.endsCategory="prefix"),Vt.hasOwnProperty(p)&&(g=h[Ae],y=g&&g[Ae],v=y&&y[Ae],v.domFrag().addClass("mq-last")),this.shouldOmitPadding(c[Ae])||c.domFrag().addClass("mq-first"),this.shouldOmitPadding(h[Me])||(h[Me]instanceof ue?(x=h[Me],(x.siblingCreated=x.siblingDeleted=function(){x.domFrag().toggleClass("mq-after-operator-name",!(x[Me]instanceof Le))})()):h.domFrag().toggleClass("mq-last",!(h[Me]instanceof Le))),l+=u-1,c=h;continue t}}},e.prototype.shouldOmitPadding=function(t){return!t||("."===t.ctrlSeq||(!!(t instanceof Mt&&t.isBinaryOperator())||t instanceof fe))},e}(Ht),Gt={},at.prototype.autoOperatorNames=function(){var t,e,n,r,o={_maxLength:9},i="arg deg det dim exp gcd hom inf ker lg lim ln log max min sup limsup liminf injlim projlim Pr".split(" ");for(t=0;t<i.length;t+=1)Gt[i[t]]=o[i[t]]=1;for(e="sin cos tan arcsin arccos arctan sinh cosh tanh sec csc cot coth".split(" "),t=0;t<e.length;t+=1)Gt[e[t]]=1;for(n="sin cos tan sec cosec csc cotan cot ctg".split(" "),t=0;t<n.length;t+=1)o[n[t]]=o["arc"+n[t]]=o[n[t]+"h"]=o["ar"+n[t]+"h"]=o["arc"+n[t]+"h"]=1;for(r="gcf hcf lcm proj span".split(" "),t=0;t<r.length;t+=1)o[r[t]]=1;return o}(),Vt={limsup:1,liminf:1,projlim:1,injlim:1},st.autoOperatorNames=function(t){var e,n,r,o,i,s;if("string"!=typeof t)throw'"'+t+'" not a space-delimited list';if(!/^[a-z\|\-]+(?: [a-z\|\-]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of letters or "|"';for(e=t.split(" "),n={},r=0,o=0;o<e.length;o+=1){if(i=e[o],i.length<2)throw'"'+i+'" not minimum length of 2';if(i.indexOf("|")<0)n[i]=i,r=Ne(r,i.length);else{if(s=i.split("|"),s.length>2)throw'"'+i+'" has more than 1 mathspeak delimiter';if(s[0].length<2)throw'"'+i[0]+'" not minimum length of 2';n[s[0]]=s[1].replace(/-/g," "),r=Ne(r,s[0].length)}}return n._maxLength=r,n},at.prototype.infixOperatorNames={},st.infixOperatorNames=O,at.prototype.prefixOperatorNames={},st.prefixOperatorNames=O,at.prototype.disableAutoSubstitutionInSubscripts=!1,st.disableAutoSubstitutionInSubscripts=function(t){if("boolean"==typeof t)return t;if("object"!=typeof t||null===t||!("except"in t))throw'"'+t+'" not an object with property "except"';return{except:O(t.except)}},Wt=function(t){function e(e){return t.call(this,e||"")||this}return __extends(e,t),e.prototype.createLeftOf=function(t){var e,n=this.ctrlSeq;for(e=0;e<n.length;e+=1)new jt(n.charAt(e)).createLeftOf(t)},e.prototype.parser=function(){var t,e=this.ctrlSeq,n=new It;for(t=0;t<e.length;t+=1)new jt(e.charAt(t)).adopt(n,n.getEnd(Me),0);return ft.succeed(n.children())},e}(Dt);for(Qt in at.prototype.autoOperatorNames)at.prototype.autoOperatorNames.hasOwnProperty(Qt)&&(Z[Qt]=Wt);if(Z.operatorname=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(){},e.prototype.numBlocks=function(){return 1},e.prototype.parser=function(){return Et.block.map(function(t){var e=!0,n="",r=t.children();return r.each(function(t){t instanceof jt?n+=t.letter:e=!1}),e&&"ans"===n?ye():r})},e}(Ft),Z.f=function(t){function e(){var e=this,n="f";return e=t.call(this,n)||this,e.letter=n,e.domView=new Tt(0,function(){return Be("var",{class:"mq-f"},[Be.text("f")])}),e}return __extends(e,t),e.prototype.italicize=function(e){return this.domFrag().eachElement(function(t){return t.textContent="f"}),this.domFrag().toggleClass("mq-f",e),t.prototype.italicize.call(this,e)},e}(jt),Z[" "]=Z.space=function(){return new zt("\\ ",Be("span",{},[Be.text(R)])," ")},Z["."]=function(){return new zt(".",Be("span",{class:"mq-digit"},[Be.text(".")]),".")},Z["'"]=Z.prime=L("'","&prime;","prime"),Z["″"]=Z.dprime=L("″","&Prime;","double prime"),Z.backslash=L("\\backslash ","\\","backslash"),J["\\"]||(J["\\"]=Z.backslash),Z.$=L("\\$","$","dollar"),Z["?"]=L("?","?","question mark"),Z["□"]=Z.square=L("\\square ","□","square"),Z.mid=L("\\mid ","∣","mid"),$t=function(t){function e(e,n){return t.call(this,e,Be("span",{class:n},[Be.text(e)]))||this}return __extends(e,t),e}(Dt),Z[","]=function(){return new $t(",","mq-comma")},Ut=function(t){function e(e,n,r){return t.call(this,e,Be("span",{class:"mq-nonSymbola"},[n||Be.text(e)]))||this}return __extends(e,t),e}(Dt),Z["@"]=function(){return new Ut("@")},Z["&"]=function(){return new Ut("\\&",Be.entityText("&amp;"),"and")},Z["%"]=function(t){function e(){return t.call(this,"\\%",Be.text("%"),"percent")||this}return __extends(e,t),e.prototype.parser=function(){var e=ft.optWhitespace,n=ft.string;return e.then(n("\\operatorname{of}").map(function(){return ve()})).or(t.prototype.parser.call(this))},e}(Ut),Z["∥"]=Z.parallel=L("\\parallel ","&#x2225;","parallel"),Z["∦"]=Z.nparallel=L("\\nparallel ","&#x2226;","not parallel"),Z["⟂"]=Z.perp=L("\\perp ","&#x27C2;","perpendicular"),Z["α"]=Z.alpha=C("alpha"),Z["β"]=Z.beta=C("beta"),Z["γ"]=Z.gamma=C("gamma"),Z["δ"]=Z.delta=C("delta"),Z["ζ"]=Z.zeta=C("zeta"),Z["η"]=Z.eta=C("eta"),Z["θ"]=Z.theta=C("theta"),Z["ι"]=Z.iota=C("iota"),Z["κ"]=Z.kappa=C("kappa"),Z["μ"]=Z.mu=C("mu"),Z["ν"]=Z.nu=C("nu"),Z["ξ"]=Z.xi=C("xi"),Z["ρ"]=Z.rho=C("rho"),Z["σ"]=Z.sigma=C("sigma"),Z["τ"]=Z.tau=C("tau"),Z["χ"]=Z.chi=C("chi"),Z["ψ"]=Z.psi=C("psi"),Z["ω"]=Z.omega=C("omega"),Z["ϕ"]=Z.phi=_("\\phi ","&#981;","phi"),Z["φ"]=Z.phiv=Z.varphi=_("\\varphi ","&phi;","phi"),Z["ϵ"]=Z.epsilon=_("\\epsilon ","&#1013;","epsilon"),Z["ε"]=Z.epsiv=Z.varepsilon=_("\\varepsilon ","&epsilon;","epsilon"),Z["ϖ"]=Z.piv=Z.varpi=_("\\varpi ","&piv;","piv"),Z["ς"]=Z.sigmaf=Z.sigmav=Z.varsigma=_("\\varsigma ","&sigmaf;","sigma"),Z["ϑ"]=Z.thetav=Z.vartheta=Z.thetasym=_("\\vartheta ","&thetasym;","theta"),Z["υ"]=Z.upsilon=Z.upsi=_("\\upsilon ","&upsilon;","upsilon"),Z["Ϝ"]=Z.gammad=Z.Gammad=Z.digamma=_("\\digamma ","&#989;","gamma"),Z["ϰ"]=Z.kappav=Z.varkappa=_("\\varkappa ","&#1008;","kappa"),Z["ϱ"]=Z.rhov=Z.varrho=_("\\varrho ","&#1009;","rho"),Z.pi=Z["π"]=function(){return new Ut("\\pi ",Be.entityText("&pi;"),"pi")},Z["λ"]=Z.lambda=function(){return new Ut("\\lambda ",Be.entityText("&lambda;"),"lambda")},Z["Υ"]=Z.Upsilon=Z.Upsi=Z.upsih=Z.Upsih=function(){return new Dt("\\Upsilon ",Be("var",{style:"font-family: serif"},[Be.entityText("&upsih;")]),"capital upsilon")},Z["Γ"]=Z.Gamma=T("Gamma"),Z["Δ"]=Z.Delta=T("Delta"),Z["Θ"]=Z.Theta=T("Theta"),Z["Λ"]=Z.Lambda=T("Lambda"),Z["Ξ"]=Z.Xi=T("Xi"),Z["Π"]=Z.Pi=T("Pi"),Z["Σ"]=Z.Sigma=T("Sigma"),Z["Φ"]=Z.Phi=T("Phi"),Z["Ψ"]=Z.Psi=T("Psi"),Z["Ω"]=Z.Omega=T("Omega"),Z["∀"]=Z.forall=T("forall"),Kt=function(t){function e(e){var n=t.call(this)||this;return n.latexStr=e,n}return __extends(e,t),e.prototype.createLeftOf=function(t){var e,n,r,o,i=Et.parse(this.latexStr);i.children().adopt(t.parent,t[Ae],t[Me]),t[Ae]=i.getEnd(Me),U(i.html()).insertBefore(t.domFrag()),i.finalizeInsert(t.options,t),e=i.getEnd(Me),n=e&&e[Me],n&&n.siblingCreated(t.options,Ae),r=i.getEnd(Ae),o=r&&r[Ae],o&&o.siblingCreated(t.options,Me),t.parent.bubble(function(t){t.reflow()})},e.prototype.mathspeak=function(){return Et.parse(this.latexStr).mathspeak()},e.prototype.parser=function(){var t=Et.parse(this.latexStr).children();return ft.succeed(t)},e}(Ft),Z["⁰"]=function(){return new Kt("^0")},Z["¹"]=function(){return new Kt("^1")},Z["²"]=function(){return new Kt("^2")},Z["³"]=function(){return new Kt("^3")},Z["⁴"]=function(){return new Kt("^4")},Z["⁵"]=function(){return new Kt("^5")},Z["⁶"]=function(){return new Kt("^6")},Z["⁷"]=function(){return new Kt("^7")},Z["⁸"]=function(){return new Kt("^8")},Z["⁹"]=function(){return new Kt("^9")},Z["¼"]=function(){return new Kt("\\frac14")},Z["½"]=function(){return new Kt("\\frac12")},Z["¾"]=function(){return new Kt("\\frac34")},Z["√"]=function(){return new Kt("\\sqrt{}")},Xt=function(t){function e(e,n,r){return t.call(this,e,n,void 0,r,!0)||this}return __extends(e,t),e.prototype.isBinaryOperator=function(){return D(this)},e.prototype.contactWeld=function(t,e){
13
- this.sharedSiblingMethod(t.options,e)},e.prototype.siblingCreated=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingDeleted=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.sharedSiblingMethod=function(t,e){if(e!==Me)return this.domFrag().oneElement().className=D(this)?"mq-binary-operator":"",this},e}(Mt),Z["+"]=function(t){function e(){return t.call(this,"+",Be.text("+"))||this}return __extends(e,t),e.prototype.mathspeak=function(){return D(this)?"plus":"positive"},e}(Xt),Yt=function(t){function e(){return t.call(this,"-",Be.entityText("&minus;"))||this}return __extends(e,t),e.prototype.mathspeak=function(){return D(this)?"minus":"negative"},e}(Xt),Z["−"]=Z["—"]=Z["–"]=Z["-"]=Yt,Z["±"]=Z.pm=Z.plusmn=Z.plusminus=function(){return new Xt("\\pm ",Be.entityText("&plusmn;"),"plus-or-minus")},Z["∓"]=Z.mp=Z.mnplus=Z.minusplus=function(){return new Xt("\\mp ",Be.entityText("&#8723;"),"minus-or-plus")},J["*"]=Z.sdot=Z.cdot=S("\\cdot ","&middot;","*","times"),Zt=function(t){function e(){return t.call(this,"\\to ",Be.entityText("&rarr;"),"to")||this}return __extends(e,t),e.prototype.deleteTowards=function(e,n){if(e===Ae){var r=n[Ae];return new Y(r,this).remove(),n[Ae]=r[Ae],(new Yt).createLeftOf(n),void n[Ae].bubble(function(t){t.reflow()})}t.prototype.deleteTowards.call(this,e,n)},e}(Mt),Z["→"]=Z.to=Zt,Jt=function(t){function e(e,n){var r=this,o=n?"Strict":"";return r=t.call(this,e["ctrlSeq".concat(o)],Be.entityText(e["htmlEntity".concat(o)]),e["text".concat(o)],e["mathspeak".concat(o)])||this,r.data=e,r.strict=n,r}return __extends(e,t),e.prototype.swap=function(t){this.strict=t;var e=t?"Strict":"";this.ctrlSeq=this.data["ctrlSeq".concat(e)],this.domFrag().children().replaceWith(U(Be.entityText(this.data["htmlEntity".concat(e)]))),this.textTemplate=[this.data["text".concat(e)]],this.mathspeakName=this.data["mathspeak".concat(e)]},e.prototype.deleteTowards=function(e,n){if(e===Ae&&!this.strict)return this.swap(!0),void this.bubble(function(t){t.reflow()});t.prototype.deleteTowards.call(this,e,n)},e}(Mt),te={ctrlSeq:"\\le ",htmlEntity:"&le;",text:"≤",mathspeak:"less than or equal to",ctrlSeqStrict:"<",htmlEntityStrict:"&lt;",textStrict:"<",mathspeakStrict:"less than"},ee={ctrlSeq:"\\ge ",htmlEntity:"&ge;",text:"≥",mathspeak:"greater than or equal to",ctrlSeqStrict:">",htmlEntityStrict:"&gt;",textStrict:">",mathspeakStrict:"greater than"},ne=function(t){function e(){return t.call(this,ee,!0)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n,r=e[Ae];if(r instanceof Mt&&"-"===r.ctrlSeq)return n=r,e[Ae]=n[Ae],n.remove(),(new Zt).createLeftOf(e),void e[Ae].bubble(function(t){t.reflow()});t.prototype.createLeftOf.call(this,e)},e}(Jt),Z["<"]=Z.lt=function(){return new Jt(te,!0)},Z[">"]=Z.gt=ne,Z["≤"]=Z.le=Z.leq=function(){return new Jt(te,!1)},Z["≥"]=Z.ge=Z.geq=function(){return new Jt(ee,!1)},Z["∞"]=Z.infty=Z.infin=Z.infinity=L("\\infty ","&infin;","infinity"),Z["≠"]=Z.ne=Z.neq=S("\\ne ","&ne;","not equal"),re=function(t){function e(){return t.call(this,"=",Be.text("="),"=","equals")||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n=e[Ae];if(n instanceof Jt&&n.strict)return n.swap(!1),void n.bubble(function(t){t.reflow()});t.prototype.createLeftOf.call(this,e)},e}(Mt),Z["="]=re,Z["×"]=Z.times=Z.cross=S("\\times ","&times;","[x]","times"),Z["÷"]=Z.div=Z.divide=Z.divides=S("\\div ","&divide;","[/]","divided by"),oe=function(t){function e(){return t.call(this,"\\sim ",Be.text("~"),"~","tilde")||this}return __extends(e,t),e.prototype.createLeftOf=function(n){if(n[Ae]instanceof e){var r=n[Ae];return n[Ae]=r[Ae],r.remove(),(new ie).createLeftOf(n),void n[Ae].bubble(function(t){t.reflow()})}t.prototype.createLeftOf.call(this,n)},e}(Mt),ie=function(t){function e(){return t.call(this,"\\approx ",Be.entityText("&approx;"),"≈","approximately equal")||this}return __extends(e,t),e.prototype.deleteTowards=function(e,n){if(e===Ae){var r=n[Ae];return new Y(r,this).remove(),n[Ae]=r[Ae],(new oe).createLeftOf(n),void n[Ae].bubble(function(t){t.reflow()})}t.prototype.deleteTowards.call(this,e,n)},e}(Mt),Z.tildeNbsp=L("~",R," "),Z.sim=oe,Z["≈"]=Z.approx=ie,J["~"]=Z.sim,Z["~"]=Z.tildeNbsp,st.interpretTildeAsSim=function(t){var e=!!t;return Z["~"]=e?Z.sim:Z.tildeNbsp,e},Z["◯"]=Z.bigcirc=L("\\bigcirc ","&#9711;","circle"),Z["∠"]=Z.ang=Z.angle=L("\\angle ","&ang;","angle"),Z["°"]=Z.degree=L("\\degree ","&deg;","degrees"),Z["△"]=Z.triangle=L("\\triangle ","&#9651;","triangle"),Z["≅"]=Z.cong=S("\\cong ","&cong;","cong","congruent"),Z["∡"]=Z.measuredangle=L("\\measuredangle ","&#8737;","measured angle"),Z["▱"]=Z.parallelogram=L("\\parallelogram ","&#9649;","parallelogram"),Z["≇"]=Z.ncong=S("\\ncong ","&ncong;","ncong","not congruent"),Z["≁"]=Z.nsim=S("\\nsim ","&nsim;","nsim","not similar"),se={sqrt:{width:"",html:function(){return Be("svg",{preserveAspectRatio:"none",viewBox:"0 0 32 54"},[Be("path",{d:"M0 33 L7 27 L12.5 47 L13 47 L30 0 L32 0 L13 54 L11 54 L4.5 31 L0 33"})])}},"|":{width:".4em",html:function(){return Be("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Be("path",{d:"M4.4 0 L4.4 54 L5.6 54 L5.6 0"})])}},"[":{width:".55em",html:function(){return Be("svg",{preserveAspectRatio:"none",viewBox:"0 0 11 24"},[Be("path",{d:"M8 0 L3 0 L3 24 L8 24 L8 23 L4 23 L4 1 L8 1"})])}},"]":{width:".55em",html:function(){return Be("svg",{preserveAspectRatio:"none",viewBox:"0 0 11 24"},[Be("path",{d:"M3 0 L8 0 L8 24 L3 24 L3 23 L7 23 L7 1 L3 1"})])}},"(":{width:".55em",html:function(){return Be("svg",{preserveAspectRatio:"none",viewBox:"3 0 106 186"},[Be("path",{d:"M85 0 A61 101 0 0 0 85 186 L75 186 A75 101 0 0 1 75 0"})])}},")":{width:".55em",html:function(){return Be("svg",{preserveAspectRatio:"none",viewBox:"3 0 106 186"},[Be("path",{d:"M24 0 A61 101 0 0 1 24 186 L34 186 A75 101 0 0 0 34 0"})])}},"{":{width:".7em",html:function(){return Be("svg",{preserveAspectRatio:"none",viewBox:"10 0 210 350"},[Be("path",{d:"M170 0 L170 6 A47 52 0 0 0 123 60 L123 127 A35 48 0 0 1 88 175 A35 48 0 0 1 123 223 L123 290 A47 52 0 0 0 170 344 L170 350 L160 350 A58 49 0 0 1 102 301 L103 220 A45 40 0 0 0 58 180 L58 170 A45 40 0 0 0 103 130 L103 49 A58 49 0 0 1 161 0"})])}},"}":{width:".7em",html:function(){return Be("svg",{preserveAspectRatio:"none",viewBox:"10 0 210 350"},[Be("path",{d:"M60 0 L60 6 A47 52 0 0 1 107 60 L107 127 A35 48 0 0 0 142 175 A35 48 0 0 0 107 223 L107 290 A47 52 0 0 1 60 344 L60 350 L70 350 A58 49 0 0 0 128 301 L127 220 A45 40 0 0 1 172 180 L172 170 A45 40 0 0 1 127 130 L127 49 A58 49 0 0 0 70 0"})])}},"&#8741;":{width:".7em",html:function(){return Be("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Be("path",{d:"M3.2 0 L3.2 54 L4 54 L4 0 M6.8 0 L6.8 54 L6 54 L6 0"})])}},"&lang;":{width:".55em",html:function(){return Be("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Be("path",{d:"M6.8 0 L3.2 27 L6.8 54 L7.8 54 L4.2 27 L7.8 0"})])}},"&rang;":{width:".55em",html:function(){return Be("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Be("path",{d:"M3.2 0 L6.8 27 L3.2 54 L2.2 54 L5.8 27 L2.2 0"})])}}},ae="➤",le=function(t){function e(e,n,r,o,i){var s=t.call(this,e,new Tt(1,function(t){var e,o;return Be.block(n,r,t[0],{beforeChild:null===(e=null===i||void 0===i?void 0:i.beforeChild)||void 0===e?void 0:e.call(i),afterChild:null===(o=null===i||void 0===i?void 0:i.afterChild)||void 0===o?void 0:o.call(i)})}))||this;return s.ariaLabel=o||e.replace(/^\\/,""),s.mathspeakTemplate=["Start"+s.ariaLabel+",","End"+s.ariaLabel],s.shouldNotSpeakDelimiters=i&&i.shouldNotSpeakDelimiters,s}return __extends(e,t),e.prototype.mathspeak=function(e){return!this.shouldNotSpeakDelimiters||e&&e.ignoreShorthand?t.prototype.mathspeak.call(this):this.foldChildren("",function(t,n){return t+" "+n.mathspeak(e)}).trim()},e}(Ft),Z.mathrm=function(t){function e(){return t.call(this,"\\mathrm","span",{class:"mq-roman mq-font"},"Roman Font",{shouldNotSpeakDelimiters:!0})||this}return __extends(e,t),e.prototype.isTextBlock=function(){return!0},e}(le),Z.mathit=function(){return new le("\\mathit","i",{class:"mq-font"},"Italic Font")},Z.mathbf=function(){return new le("\\mathbf","b",{class:"mq-font"},"Bold Font")},Z.mathsf=function(){return new le("\\mathsf","span",{class:"mq-sans-serif mq-font"},"Serif Font")},Z.mathtt=function(){return new le("\\mathtt","span",{class:"mq-monospace mq-font"},"Math Text")},Z.underline=function(){return new le("\\underline","span",{class:"mq-non-leaf mq-underline"},"Underline")},Z.overline=Z.bar=function(){return new le("\\overline","span",{class:"mq-non-leaf mq-overline"},"Overline")},Z.overrightarrow=function(){return new le("\\overrightarrow","span",{class:"mq-non-leaf mq-overarrow"},"Over Right Arrow",{afterChild:function(){return Be("span",{class:"mq-arrow-right-content"},[Be.text(ae)])}})},Z.overleftarrow=function(){return new le("\\overleftarrow","span",{class:"mq-non-leaf mq-overarrow"},"Over Left Arrow",{beforeChild:function(){return Be("span",{class:"mq-arrow-left-content"},[Be.text(ae)])}})},Z.overleftrightarrow=function(){return new le("\\overleftrightarrow ","span",{class:"mq-non-leaf mq-overarrow"},"Over Left and Right Arrow",{beforeChild:function(){return Be("span",{class:"mq-arrow-left-content"},[Be.text(ae)])},afterChild:function(){return Be("span",{class:"mq-arrow-right-content"},[Be.text(ae)])}})},Z.overarc=function(){return new le("\\overarc","span",{class:"mq-non-leaf mq-overarc"},"Over Arc")},Z.dot=function(){return new Ft("\\dot",new Tt(1,function(t){return Be("span",{class:"mq-non-leaf"},[Be("span",{class:"mq-dot-recurring-inner"},[Be("span",{class:"mq-dot-recurring"},[Be.text(P)]),Be.block("span",{class:"mq-empty-box"},t[0])])])}))},Z.textcolor=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setColor=function(t){this.color=t,this.domView=new Tt(1,function(e){return Be.block("span",{class:"mq-textcolor",style:"color:"+t},e[0])}),this.ariaLabel=t.replace(/^\\/,""),this.mathspeakTemplate=["Start "+this.ariaLabel+",","End "+this.ariaLabel]},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t);var e=this.blocks[0];t.uncleanedLatex+="\\textcolor{"+this.color+"}{",e.latexRecursive(t),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.parser=function(){var e=this,n=ft.optWhitespace,r=ft.string,o=ft.regex;return n.then(r("{")).then(o(/^[#\w\s.,()%-]*/)).skip(r("}")).then(function(n){return e.setColor(n),t.prototype.parser.call(e)})},e.prototype.isStyleBlock=function(){return!0},e}(Ft),Z.class=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){var e=this,n=ft.string,r=ft.regex;return ft.optWhitespace.then(n("{")).then(r(/^[-\w\s\\\xA0-\xFF]*/)).skip(n("}")).then(function(n){return e.cls=n||"",e.domView=new Tt(1,function(t){return Be.block("span",{class:"mq-class ".concat(n)},t[0])}),e.ariaLabel=n+" class",e.mathspeakTemplate=["Start "+e.ariaLabel+",","End "+e.ariaLabel],t.prototype.parser.call(e)})},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t);var e=this.blocks[0];t.uncleanedLatex+="\\class{"+this.cls+"}{",e.latexRecursive(t),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.isStyleBlock=function(){return!0},e}(Ft),ce=/^[\+\-]?[\d]+$/,at.prototype.charsThatBreakOutOfSupSub="",ue=function(t){function e(e){var n,r=this;return n="sub"===e?new Tt(1,function(t){return Be("span",{class:"mq-supsub mq-non-leaf"},[Be.block("span",{class:"mq-sub"},t[0]),Be("span",{style:"display:inline-block;width:0"},[Be.text(z)])])}):new Tt(1,function(t){return Be("span",{class:"mq-supsub mq-non-leaf mq-sup-only"},[Be.block("span",{class:"mq-sup"},t[0])])}),r=t.call(this,"_{...}^{...}",n)||this,r.ariaLabel="sub"===e?"subscript":"superscript",r.supsub=e,r}return __extends(e,t),e.prototype.setEnds=function(t){n("SupSub ends must be MathBlocks",t[Ae]instanceof It&&t[Me]instanceof It),this.ends=t},e.prototype.getEnd=function(t){return this.ends[t]},e.prototype.createLeftOf=function(e){if(this.replacedFragment||e[Ae]||!e.options.supSubsRequireOperand)return t.prototype.createLeftOf.call(this,e)},e.prototype.contactWeld=function(t){var n,r,o,i,s,a,l;for(n=Ae;n;n=n===Ae&&Me)if(r=this[n],o=void 0,r instanceof e){for(i="sub";i;i="sub"===i&&"sup")s=this[i],a=r[i],s&&(a?s.isEmpty()?o=new K(a,0,a.getEnd(Ae)):(s.domFrag().children().insAtDirEnd(-n,a.domFrag().oneElement()),l=s.children().disown(),o=new K(a,l.getEnd(Me),a.getEnd(Ae)),n===Ae?l.adopt(a,a.getEnd(Me),0):l.adopt(a,0,a.getEnd(Ae))):r.addBlock(s.disown()),this.placeCursor=function(t,e){return function(r){r.insAtDirEnd(-n,t||e)}}(a,s));this.remove(),t&&t[Ae]===this&&(n===Me&&o?o[Ae]?t.insRightOf(o[Ae]):t.insAtLeftEnd(o.parent):t.insRightOf(r));break}},e.prototype.finalizeTree=function(){"sub"===this.supsub?(this.downInto=this.sub=this.getEnd(Ae),this.sub.upOutOf=M):"sup"===this.supsub&&(this.upInto=this.sup=this.getEnd(Me),this.sup.downOutOf=M),this.getEnd(Ae).write=function(t,e){if(t.options.autoSubscriptNumerals&&this===this.parent.sub&&"0123456789".indexOf(e)>=0){var n=this.chToCmd(e,t.options);return n instanceof Dt?t.deleteSelection():t.clearSelection().insRightOf(this.parent),n.createLeftOf(t.show()),void t.controller.aria.queue("Baseline").alert(n.mathspeak({createdLeftOf:t}))}t[Ae]&&!t[Me]&&!t.selection&&t.options.charsThatBreakOutOfSupSub.indexOf(e)>-1&&(t.insRightOf(this.parent),t.controller.aria.queue("Baseline")),It.prototype.write.call(this,t,e)}},e.prototype.moveTowards=function(e,n,r){n.options.autoSubscriptNumerals&&!this.sup?n.insDirOf(e,this):t.prototype.moveTowards.call(this,e,n,r)},e.prototype.deleteTowards=function(e,n){if(n.options.autoSubscriptNumerals&&this.sub){var r=this.sub.getEnd(-e);r instanceof Dt?r.remove():r&&r.deleteTowards(e,n.insAtDirEnd(-e,this.sub)),this.sub.isEmpty()&&(this.sub.deleteOutOf(Ae,n.insAtLeftEnd(this.sub)),this.sup&&n.insDirOf(-e,this))}else t.prototype.deleteTowards.call(this,e,n)},e.prototype.latexRecursive=function(t){var e,n;this.checkCursorContextOpen(t),this.sub&&(t.uncleanedLatex+="_{",e=t.uncleanedLatex.length,this.sub.latexRecursive(t),n=t.uncleanedLatex.length,e===n&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}"),this.sup&&(t.uncleanedLatex+="^{",e=t.uncleanedLatex.length,this.sup.latexRecursive(t),n=t.uncleanedLatex.length,e===n&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}"),this.checkCursorContextClose(t)},e.prototype.mathspeak=function(e){var n,r;return void 0===this.sup||(n=A(this.sup),e&&e.ignoreShorthand||!ce.test(n))?(this.mathspeakTemplate=this.getMathspeakTemplate(),t.prototype.mathspeak.call(this)):(r="",this.sub&&(r=pe[0]+" "+this.sub.mathspeak()+" "+pe[1]+" "),r+I(this.sup,n))},e.prototype.getMathspeakTemplate=function(){return this.sub&&this.sup?de:this.sup?he:pe},e.prototype.text=function(){function t(t,e){var n=e&&e.text()||"";return e?t+(1===n.length?n:"("+(n||" ")+")"):""}return t("_",this.sub)+t("^",this.sup)},e.prototype.addBlock=function(t){var e,n,r;for("sub"===this.supsub?(this.sup=this.upInto=this.sub.upOutOf=t,t.adopt(this,this.sub,0).downOutOf=this.sub,t.setDOM(U(Be("span",{class:"mq-sup"})).append(t.domFrag().children()).prependTo(this.domFrag().oneElement()).oneElement()),X.linkElementByBlockNode(t.domFrag().oneElement(),t)):(this.sub=this.downInto=this.sup.downOutOf=t,t.adopt(this,0,this.sup).upOutOf=this.sup,this.domFrag().removeClass("mq-sup-only"),t.setDOM(U(Be("span",{class:"mq-sub"})).append(t.domFrag().children()).appendTo(this.domFrag().oneElement()).oneElement()),X.linkElementByBlockNode(t.domFrag().oneElement(),t),this.domFrag().append(U(Be("span",{style:"display:inline-block;width:0"},[Be.text(z)])))),e=function(t){var e=n,r=["sub","sup"][t],o=["sup","sub"][t],i=["down","up"][t];e[r].deleteOutOf=function(t,n){var s,a;n.insDirOf(this[t]?-t:t,this.parent),this.isEmpty()||(s=this.getEnd(t),this.children().disown().withDirAdopt(t,n.parent,n[t],n[-t]).domFrag().insDirOf(-t,n.domFrag()),n[-t]=s),e.supsub=o,delete e[r],delete e["".concat(i,"Into")],a=e[o],a["".concat(i,"OutOf")]=M,delete a.deleteOutOf,"sub"===r&&e.domFrag().addClass("mq-sup-only").children().last().remove(),this.remove()}},n=this,r=0;r<2;r+=1)e(r)},e}(Ft),pe=["Subscript,",", Baseline"],he=["Superscript,",", Baseline"],de=["Subscript,",", Baseline Superscript,",", Baseline"],Z.subscript=Z._=function(){return new ue("sub")},Z.superscript=Z.supscript=Z["^"]=function(){return new ue("sup")},fe=function(t){function e(e,n,r){var o,i=t.call(this)||this;return i.ariaLabel=r||e.replace(/^\\/,""),o=new Tt(2,function(t){return Be("span",{class:"mq-large-operator mq-non-leaf"},[Be("span",{class:"mq-to"},[Be.block("span",{},t[1])]),Be("big",{},[Be.text(n)]),Be("span",{class:"mq-from"},[Be.block("span",{},t[0])])])}),Dt.prototype.setCtrlSeqHtmlTextAndMathspeak.call(i,e,o),i}return __extends(e,t),e.prototype.createLeftOf=function(e){t.prototype.createLeftOf.call(this,e),e.options.sumStartsWithNEquals&&(new jt("n").createLeftOf(e),(new re).createLeftOf(e))},e.prototype.latexRecursive=function(t){var e,n;this.checkCursorContextOpen(t),t.uncleanedLatex+=this.ctrlSeq+"_{",e=t.uncleanedLatex.length,this.getEnd(Ae).latexRecursive(t),n=t.uncleanedLatex.length,n===e&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}^{",e=t.uncleanedLatex.length,this.getEnd(Me).latexRecursive(t),n=t.uncleanedLatex.length,e===n&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.mathspeak=function(){return"Start "+this.ariaLabel+" from "+this.getEnd(Ae).mathspeak()+" to "+this.getEnd(Me).mathspeak()+", end "+this.ariaLabel+", "},e.prototype.parser=function(){var t,e=ft.string,n=ft.optWhitespace,r=ft.succeed,o=Et.block,i=this,s=i.blocks=[new It,new It];for(t=0;t<s.length;t+=1)s[t].adopt(i,i.getEnd(Me),0);return n.then(e("_").or(e("^"))).then(function(t){var e=s["_"===t?0:1];return o.then(function(t){return t.children().adopt(e,e.getEnd(Me),0),r(i)})}).many().result(i)},e.prototype.finalizeTree=function(){var t=this.getEnd(Ae),e=this.getEnd(Me);t.ariaLabel="lower bound",e.ariaLabel="upper bound",this.downInto=t,this.upInto=e,t.upOutOf=e,e.downOutOf=t},e}(Ft),Z["∑"]=Z.sum=Z.summation=function(){return new fe("\\sum ",H,"sum")},Z["∏"]=Z.prod=Z.product=function(){return new fe("\\prod ",j,"product")},Z.coprod=Z.coproduct=function(){return new fe("\\coprod ",G,"co product")},Z["∫"]=Z.int=Z.integral=function(t){function e(){var e=t.call(this,"\\int ","","integral")||this;return e.ariaLabel="integral",e.domView=new Tt(2,function(t){return Be("span",{class:"mq-int mq-non-leaf"},[Be("big",{},[Be.text(V)]),Be("span",{class:"mq-supsub mq-non-leaf"},[Be("span",{class:"mq-sup"},[Be.block("span",{class:"mq-sup-inner"},t[1])]),Be.block("span",{class:"mq-sub"},t[0]),Be("span",{style:"display:inline-block;width:0"},[Be.text(z)])])])}),e}return __extends(e,t),e.prototype.createLeftOf=function(t){Ft.prototype.createLeftOf.call(this,t)},e}(fe),me=Z.frac=Z.dfrac=Z.cfrac=Z.fraction=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\frac",e.domView=new Tt(2,function(t){return Be("span",{class:"mq-fraction mq-non-leaf"},[Be.block("span",{class:"mq-numerator"},t[0]),Be.block("span",{class:"mq-denominator"},t[1]),Be("span",{style:"display:inline-block;width:0"},[Be.text(z)])])}),e.textTemplate=["(",")/(",")"],e}return __extends(e,t),e.prototype.finalizeTree=function(){var t=this.getEnd(Ae),e=this.getEnd(Me);this.upInto=e.upOutOf=t,this.downInto=t.downOutOf=e,t.ariaLabel="numerator",e.ariaLabel="denominator",this.getFracDepth()>1?this.mathspeakTemplate=["StartNestedFraction,","NestedOver",", EndNestedFraction"]:this.mathspeakTemplate=["StartFraction,","Over",", EndFraction"]},e.prototype.mathspeak=function(e){var n,r,o,i,s,a,l,c;if(e&&e.createdLeftOf)return n=e.createdLeftOf,n.parent.mathspeak();if(r=A(this.getEnd(Ae)),o=A(this.getEnd(Me)),(!e||!e.ignoreShorthand)&&ce.test(r)&&ce.test(o)&&(i="1"===r||"-1"===r,s="","2"===o?s=i?"half":"halves":"3"===o?s=i?"third":"thirds":"4"===o?s=i?"fourth":"fourths":"5"===o?s=i?"fifth":"fifths":"6"===o?s=i?"sixth":"sixths":"7"===o?s=i?"seventh":"sevenths":"8"===o?s=i?"eighth":"eighths":"9"===o?s=i?"ninth":"ninths":"10"===o?s=i?"tenth":"tenths":"11"===o?s=i?"eleventh":"elevenths":"12"===o?s=i?"twelfth":"twelfths":"100"===o&&(s=i?"hundredth":"hundredths"),""!==s)){for(a="",l=!1,c=this[Ae];c&&void 0!==c[Ae];c=c[Ae])if("\\ "!==c.ctrlSeq){if(!ce.test(c.ctrlSeq||"")){l=!1;break}l=!0}return l&&(a+="and "),a+=this.getEnd(Ae).mathspeak()+" "+s}return t.prototype.mathspeak.call(this)},e.prototype.getFracDepth=function(){var t=function(e,n){return e instanceof bt&&e.ctrlSeq&&e.ctrlSeq.toLowerCase().search("frac")>=0&&(n+=1),e&&e.parent?t(e.parent,n):n};return t(this,0)},e}(Ft),ge=Z.over=J["/"]=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.createLeftOf=function(n){var r,o,i;if(!this.replacedFragment){if(r=n[Ae],!(n.options.typingSlashCreatesNewFraction&&this instanceof me))for(;r&&!(F(r)||r instanceof zt&&"mq-ellipsis-end"===r._groupingClass||r instanceof(Z.text||t)||r instanceof fe||"\\ "===r.ctrlSeq||/^[,;:]$/.test(r.ctrlSeq));)r=r[Ae];r instanceof fe&&r[Me]instanceof ue&&(r=r[Me],(o=r[Me])instanceof ue&&o.ctrlSeq!=r.ctrlSeq&&(r=r[Me])),r===n[Ae]||n.isTooDeep(1)||(o=r[Me],i=n[Ae],this.replaces(new Y(o||n.parent.getEnd(Ae),i)),n[Ae]=r)}e.prototype.createLeftOf.call(this,n)},n}(me),ye=function(){return new Dt("\\operatorname{ans}",Be("span",{class:"mq-ans"},[Be.text("ans")]),"ans")},Z.ans=ye,ve=function(){return new Dt("\\%\\operatorname{of}",Be("span",{class:"mq-nonSymbola mq-operator-name"},[Be.text("% of ")]),"percent of")},Z.percent=Z.percentof=ve,xe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.tokenId="",e.ctrlSeq="\\token",e.textTemplate=["token(",")"],e.mathspeakTemplate=["StartToken,",", EndToken"],e.ariaLabel="token",e}return __extends(e,t),e.prototype.html=function(){var t=Be("span",{class:"mq-token mq-ignore-mousedown","data-mq-token":this.tokenId});return this.setDOM(t),X.linkElementByCmdNode(t,this),t},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+="\\token{"+this.tokenId+"}",this.checkCursorContextClose(t)},e.prototype.mathspeak=function(){var t=[];return this.domFrag().children().eachElement(function(e){var n=e.getAttribute("aria-label");"string"==typeof n&&""!==n&&t.push(n)}),t.length>0?t.join(" ").trim():"token "+this.tokenId},e.prototype.parser=function(){var t=this;return Et.block.map(function(e){var n=e.getEnd(Ae);if(n)for(t.tokenId+=n.ctrlSeq;n=n[Me];)t.tokenId+=n.ctrlSeq;return t})},e}(Dt),Z.token=xe,be=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\sqrt",e.domView=new Tt(1,function(t){return Be("span",{class:"mq-non-leaf mq-sqrt-container"},[Be("span",{class:"mq-scaled mq-sqrt-prefix"},[se.sqrt.html()]),Be.block("span",{class:"mq-non-leaf mq-sqrt-stem"},t[0])])}),e.textTemplate=["sqrt(",")"],e.mathspeakTemplate=["StartRoot,",", EndRoot"],e.ariaLabel="root",e}return __extends(e,t),e.prototype.parser=function(){return Et.optBlock.then(function(t){return Et.block.map(function(e){var n=new we;return n.blocks=[t,e],t.adopt(n,0,0),e.adopt(n,t,0),n})}).or(t.prototype.parser.call(this))},e.prototype.deleteTowards=function(e,n){if(!this.isEmpty()&&1===e)return this.moveTowards(Me,n),void n.parent.deleteOutOf(Ae,n);t.prototype.deleteTowards.call(this,e,n)},e}(Ft),Z.sqrt=J["√"]=be,Z.hat=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\hat",e.domView=new Tt(1,function(t){return Be("span",{class:"mq-non-leaf"},[Be("span",{class:"mq-hat-prefix"},[Be.text("^")]),Be.block("span",{class:"mq-hat-stem"},t[0])])}),e.textTemplate=["hat(",")"],e}return __extends(e,t),e}(Ft),we=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.domView=new Tt(2,function(t){return Be("span",{class:"mq-nthroot-container mq-non-leaf"},[Be.block("sup",{class:"mq-nthroot mq-non-leaf"},t[0]),Be("span",{class:"mq-scaled mq-sqrt-container"},[Be("span",{class:"mq-sqrt-prefix mq-scaled"},[se.sqrt.html()]),Be.block("span",{class:"mq-sqrt-stem mq-non-leaf"},t[1])])])}),e.textTemplate=["sqrt[","](",")"],e}return __extends(e,t),e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+="\\sqrt[",this.getEnd(Ae).latexRecursive(t),t.uncleanedLatex+="]{",this.getEnd(Me).latexRecursive(t),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.mathspeak=function(){var t=this.getEnd(Ae).mathspeak(),e=this.getEnd(Me).mathspeak();return this.getEnd(Ae).ariaLabel="Index",this.getEnd(Me).ariaLabel="Radicand","3"===t?"Start Cube Root, "+e+", End Cube Root":"Root Index "+t+", Start Root, "+e+", End Root"},e.prototype.deleteTowards=function(t,e){Ft.prototype.deleteTowards.call(this,t,e)},e}(be),Z.nthroot=we,Z.cbrt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){t.prototype.createLeftOf.call(this,e),new Pt("3").createLeftOf(e),e.controller.moveRight()},e}(we),Ee=function(t){function e(e,n,r){var o=new Tt(1,function(t){return Be("span",{class:"mq-non-leaf"},[Be("span",{class:"mq-diacritic-above"},[n]),Be.block("span",{class:"mq-diacritic-stem"},t[0])])});return t.call(this,e,o,r)||this}return __extends(e,t),e}(Ft),Z.vec=function(){return new Ee("\\vec",Be.entityText("&rarr;"),["vec(",")"])},Z.tilde=function(){return new Ee("\\tilde",Be.text("~"),["tilde(",")"])},ke=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setDOM=function(e){var n,r;return t.prototype.setDOM.call(this,e),r=this.domFrag().children(),r.isEmpty()||(this.delimFrags=(n={},n[Ae]=r.first(),n[Me]=r.last(),n)),this},e}(Ft),Le=function(t){function e(e,n,r,o,i){var s,a=t.call(this,"\\left"+o,void 0,[n,r])||this;return a.side=e,a.sides=(s={},s[Ae]={ch:n,ctrlSeq:o},s[Me]={ch:r,ctrlSeq:i},s),a}return __extends(e,t),e.prototype.numBlocks=function(){return 1},e.prototype.html=function(){var e=this,n=this.getSymbol(Ae),r=this.getSymbol(Me);return this.domView=new Tt(1,function(t){return Be("span",{class:"mq-non-leaf mq-bracket-container"},[Be("span",{style:"width:"+n.width,class:"mq-scaled mq-bracket-l mq-paren"+(e.side===Me?" mq-ghost":"")},[n.html()]),Be.block("span",{style:"margin-left:"+n.width+";margin-right:"+r.width,class:"mq-bracket-middle mq-non-leaf"},t[0]),Be("span",{style:"width:"+r.width,class:"mq-scaled mq-bracket-r mq-paren"+(e.side===Ae?" mq-ghost":"")},[r.html()])])}),t.prototype.html.call(this)},e.prototype.getSymbol=function(t){var e=this.sides[t||Me].ch;return se[e]||{width:"0",html:""}},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+="\\left"+this.sides[Ae].ctrlSeq,this.getEnd(Ae).latexRecursive(t),t.uncleanedLatex+="\\right"+this.sides[Me].ctrlSeq,this.checkCursorContextClose(t)},e.prototype.mathspeak=function(e){var n,r=this.sides[Ae].ch,o=this.sides[Me].ch;if("|"===r&&"|"===o)this.mathspeakTemplate=["StartAbsoluteValue,",", EndAbsoluteValue"],this.ariaLabel="absolute value";else{if(e&&e.createdLeftOf&&this.side)return n="",this.side===Ae?n=this.textTemplate[0]:this.side===Me&&(n=this.textTemplate[1]),(this.side===Ae?"left ":"right ")+_e[n];this.mathspeakTemplate=["left "+_e[r]+",",", right "+_e[o]],this.ariaLabel=_e[r]+" block"}return t.prototype.mathspeak.call(this)},e.prototype.matchBrack=function(t,n,r){return r instanceof e&&r.side&&r.side!==-n&&(!t.restrictMismatchedBrackets||Se[this.sides[this.side].ch]===r.sides[r.side].ch||"none"!==t.restrictMismatchedBrackets&&{"(":"]","[":")"}[this.sides[Ae].ch]===r.sides[Me].ch)&&r},e.prototype.closeOpposing=function(t){t.side=0,t.sides[this.side]=this.sides[this.side];var e=t.delimFrags[this.side===Ae?Ae:Me].removeClass("mq-ghost");this.replaceBracket(e,this.side)},e.prototype.createLeftOf=function(e){var n,r,o;this.replacedFragment||(r=e.options,n="|"===this.sides[Ae].ch?this.matchBrack(r,Me,e[Me])||this.matchBrack(r,Ae,e[Ae])||this.matchBrack(r,0,e.parent.parent):this.matchBrack(r,-this.side,e[-this.side])||this.matchBrack(r,-this.side,e.parent.parent)),n?(o=this.side=-n.side,this.closeOpposing(n),n===e.parent.parent&&e[o]&&new Y(e[o],e.parent.getEnd(o),-o).disown().withDirAdopt(-o,n.parent,n,n[o]).domFrag().insDirOf(o,n.domFrag()),n.bubble(function(t){t.reflow()})):(n=this,o=n.side,n.replacedFragment?n.side=0:e[-o]&&(n.replaces(new Y(e[-o],e.parent.getEnd(-o),o)),e[-o]=0),t.prototype.createLeftOf.call(this,e)),o===Ae?e.insAtLeftEnd(n.getEnd(Ae)):e.insRightOf(n)},e.prototype.placeCursor=function(){},e.prototype.unwrap=function(){this.getEnd(Ae).children().disown().adopt(this.parent,this,this[Me]).domFrag().insertAfter(this.domFrag()),this.remove()},e.prototype.deleteSide=function(t,e,n){var r,o,i,s,a,l=this.parent,c=this[t],u=l.getEnd(t);if(t===this.side)return this.unwrap(),void(c?n.insDirOf(-t,c):n.insAtDirEnd(t,l));if(r=n.options,o=!this.side,this.side=-t,this.matchBrack(r,t,this.getEnd(Ae).getEnd(this.side)))this.closeOpposing(this.getEnd(Ae).getEnd(this.side)),i=this.getEnd(Ae).getEnd(t),this.unwrap(),i&&i.siblingCreated(n.options,t),c?n.insDirOf(-t,c):n.insAtDirEnd(t,l);else{if(this.matchBrack(r,t,this.parent.parent))this.parent.parent.closeOpposing(this),this.parent.parent.unwrap();else{if(e&&o)return this.unwrap(),void(c?n.insDirOf(-t,c):n.insAtDirEnd(t,l));this.sides[t]=N(this),this.delimFrags[Ae].removeClass("mq-ghost"),this.delimFrags[Me].removeClass("mq-ghost"),s=this.delimFrags[t].addClass("mq-ghost"),this.replaceBracket(s,t)}c?(a=this.getEnd(Ae),i=a.getEnd(t),a.domFrag().removeClass("mq-empty"),new Y(c,u,-t).disown().withDirAdopt(-t,a,i,0).domFrag().insAtDirEnd(t,a.domFrag().oneElement()),i&&i.siblingCreated(n.options,t),n.insDirOf(-t,c)):e?n.insDirOf(t,this):n.insAtDirEnd(t,this.getEnd(Ae))}},e.prototype.replaceBracket=function(t,e){var n,r,o=this.getSymbol(e);t.children().replaceWith(U(o.html())),t.oneElement().style.width=o.width,e===Ae?(n=t.next(),n.isEmpty()||(n.oneElement().style.marginLeft=o.width)):(r=t.prev(),r.isEmpty()||(r.oneElement().style.marginRight=o.width))},e.prototype.deleteTowards=function(t,e){this.deleteSide(-t,!1,e)},e.prototype.finalizeTree=function(){this.getEnd(Ae).deleteOutOf=function(t,e){this.parent.deleteSide(t,!0,e)},this.finalizeTree=this.intentionalBlur=function(){this.delimFrags[this.side===Ae?Me:Ae].removeClass("mq-ghost"),this.side=0}},e.prototype.siblingCreated=function(t,e){e===-this.side&&this.finalizeTree()},e}(ke),Se={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","\\{":"\\}","\\}":"\\{","&lang;":"&rang;","&rang;":"&lang;","\\langle ":"\\rangle ","\\rangle ":"\\langle ","|":"|","\\lVert ":"\\rVert ","\\rVert ":"\\lVert "},_e={"&lang;":"angle-bracket","&rang;":"angle-bracket","|":"pipe"},B("(","","parenthesis"),B("[","","bracket"),B("{","\\{","brace"),Z.langle=function(){return new Le(Ae,"&lang;","&rang;","\\langle ","\\rangle ")},Z.rangle=function(){return new Le(Me,"&lang;","&rang;","\\langle ","\\rangle ")},J["|"]=function(){return new Le(Ae,"|","|","|","|")},Z.lVert=function(){return new Le(Ae,"&#8741;","&#8741;","\\lVert ","\\rVert ")},Z.rVert=function(){return new Le(Me,"&#8741;","&#8741;","\\lVert ","\\rVert ")},Z.left=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){var t=ft.regex,e=ft.string,n=ft.optWhitespace;return n.then(t(/^(?:[([|]|\\\{|\\langle(?![a-zA-Z])|\\lVert(?![a-zA-Z]))/)).then(function(r){var o=r.replace(/^\\/,"");return"\\langle"==r&&(o="&lang;",r+=" "),"\\lVert"==r&&(o="&#8741;",r+=" "),Et.then(function(i){return e("\\right").skip(n).then(t(/^(?:[\])|]|\\\}|\\rangle(?![a-zA-Z])|\\rVert(?![a-zA-Z]))/)).map(function(t){var e,n=t.replace(/^\\/,"");return"\\rangle"==t&&(n="&rang;",t+=" "),"\\rVert"==t&&(n="&#8741;",t+=" "),e=new Le(0,o,n,r,t),e.blocks=[i],i.adopt(e,0,0),e})})})},e}(Ft),Z.right=function(t){function e(){
14
- return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){return ft.fail("unmatched \\right")},e}(Ft),qe=se["("],Oe=se[")"],Ce=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\binom",e.domView=new Tt(2,function(t){return Be("span",{class:"mq-non-leaf mq-bracket-container"},[Be("span",{style:"width:"+qe.width,class:"mq-paren mq-bracket-l mq-scaled"},[qe.html()]),Be("span",{style:"margin-left:"+qe.width+"; margin-right:"+Oe.width,class:"mq-non-leaf mq-bracket-middle"},[Be("span",{class:"mq-array mq-non-leaf"},[Be.block("span",{},t[0]),Be.block("span",{},t[1])])]),Be("span",{style:"width:"+Oe.width,class:"mq-paren mq-bracket-r mq-scaled"},[Oe.html()])])}),e.textTemplate=["choose(",",",")"],e.mathspeakTemplate=["StartBinomial,","Choose",", EndBinomial"],e.ariaLabel="binomial",e}return __extends(e,t),e.prototype.finalizeTree=function(){var t=this.getEnd(Ae),e=this.getEnd(Me);this.upInto=e.upOutOf=t,this.downInto=t.downOutOf=e,t.ariaLabel="upper index",e.ariaLabel="lower index"},e}(ke),Z.binom=Z.binomial=Ce,Z.choose=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(t){ge.prototype.createLeftOf.call(this,t)},e}(Ce),Te=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\MathQuillMathField",e.domView=new Tt(1,function(t){return Be("span",{class:"mq-editable-field"},[Be.block("span",{class:"mq-root-block","aria-hidden":"true"},t[0])])}),e}return __extends(e,t),e.prototype.parser=function(){var e=this,n=ft.string,r=ft.regex,o=ft.succeed;return n("[").then(r(/^[a-z][a-z0-9]*/i)).skip(n("]")).map(function(t){e.name=t}).or(o(void 0)).then(t.prototype.parser.call(this))},e.prototype.finalizeTree=function(t){function e(t){if(t.parentNode&&!U(t).hasClass("mq-root-block")&&e(t.parentNode),t.nodeType===Node.ELEMENT_NODE){var n=t;"true"===n.getAttribute("aria-hidden")&&(n.removeAttribute("aria-hidden"),U(t).children().eachElement(function(t){t.setAttribute("aria-hidden","true")}))}}var n=new Ot(this.getEnd(Ae),this.domFrag().oneElement(),t);n.KIND_OF_MQ="MathField",n.editable=!0,n.createTextarea(),n.editablesTextareaEvents(),n.cursor.insAtRightEnd(n.root),y(n.root),e(this.domFrag().parent().oneElement()),this.domFrag().oneElement().removeAttribute("aria-hidden")},e.prototype.registerInnerField=function(t,e){var n=this.getEnd(Ae).controller,r=new e(n);t[this.name]=r,t.push(r)},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),this.getEnd(Ae).latexRecursive(t),this.checkCursorContextClose(t)},e.prototype.text=function(){return this.getEnd(Ae).text()},e}(Ft),Z.editable=Z.MathQuillMathField=Te,Fe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setOptions=function(t){function e(){return""}return this.text=t.text||e,this.domView=new Tt(0,function(){return Be("span",{},[o(t.htmlString||"")])}),this.latex=t.latex||e,this},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+=this.latex(),this.checkCursorContextClose(t)},e.prototype.parser=function(){var t=this,e=ft.string,n=ft.regex,r=ft.succeed;return e("{").then(n(/^[a-z][a-z0-9]*/i)).skip(e("}")).then(function(o){return e("[").then(n(/^[-\w\s]*/)).skip(e("]")).or(r(void 0)).map(function(e){return t.setOptions(it[o](e))})})},e}(Dt),Z.embed=Fe,window.jQuery){ut=g(1);for(De in ut)!function(t,e){"function"==typeof e?(m[t]=function(){return ct(),e.apply(this,arguments)},m[t].prototype=e.prototype):m[t]=e}(De,ut[De])}}();
10
+ var __extends=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(t){var e,n,r,o;for(n=1,r=arguments.length;n<r;n++){e=arguments[n];for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},__assign.apply(this,arguments)};!function(){function t(){}function e(t){for(;t;){if(!t.parent)return t;t=t.parent}}function n(t,n,r){var o,i,s,a,l,c;if(!n){if(o=new Error("prayer failed: "+t),r){i={},o.dcgExtraErrorMetaData=i;for(s in r)a=r[s],l=i[s]={},a?(l.localLatex=a.latex(),(c=e(a))&&(l.rootLatex=c.latex())):l.emptyNode=!0}throw o}}function r(t){n("a direction was passed",t===Me||t===Ie)}function o(t){var e,n=document.implementation.createHTMLDocument("");if(n.body.innerHTML=t,1===n.body.children.length)return n.body.children[0];for(e=document.createDocumentFragment();n.body.firstChild;)e.appendChild(n.body.firstChild);return e}function i(t,e){var n,r,o,i;if("function"==typeof(null===t||void 0===t?void 0:t.closest))return t.closest(e);if(!(t instanceof HTMLElement))return null;o=Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,i=t;do{if(o.call(i,e))return i;i=null!==(r=null!==(n=null===i||void 0===i?void 0:i.parentElement)&&void 0!==n?n:null===i||void 0===i?void 0:i.parentNode)&&void 0!==r?r:null}while(null!==i&&1===i.nodeType);return null}function s(t){return t.getClientRects().length?t.getBoundingClientRect():{top:0,left:0,height:0,width:0,x:0,y:0,bottom:0,right:0}}function a(){return void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft}function l(){return void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}function c(t,e,n,r){e.insertBefore(n,t===Me?r:r.nextSibling)}function u(t,e,n){t===Me?n.insertBefore(e,n.firstChild):n.appendChild(e)}function p(t,e){var n,r=t[Me];if(r&&(n=t[Ie]))for(n=n[Ie];r!==n&&!1!==e(r);r=r[Ie]);}function h(t,e,n){var r,o=t[Me];if(!o)return e;if(!(r=t[Ie]))return e;for(r=r[Ie];o!==r;o=o[Ie])e=n(e,o);return e}function d(t,e,r){n("a parent is always present",t),n("leftward is properly set up",function(){return e?e[Ie]===r&&e.parent===t:t.getEnd(Me)===r}(),{parent:t,leftward:e,leftwardL:e&&e[Me],leftwardR:e&&e[Ie],rightwardL:r&&r[Me],rightwardR:r&&r[Ie]}),n("rightward is properly set up",function(){return r?r[Me]===e&&r.parent===t:t.getEnd(Ie)===e}(),{parent:t,rightward:r,leftwardL:e&&e[Me],leftwardR:e&&e[Ie],rightwardL:r&&r[Me],rightwardR:r&&r[Ie],rightwardParent:r&&r.parent})}function f(t){return t&&t.prototype instanceof bt}function m(t){return ct(),ut||(ut=g(1)),ut(t)}function g(t){function e(t,e){var n,r,i;for(n in e)if(e.hasOwnProperty(n)){if("substituteKeyboardEvents"===n&&o>=3)throw new Error(["As of interface version 3, the 'substituteKeyboardEvents'","option is no longer supported. Use 'overrideTypedText' and","'overrideKeystroke' instead."].join(" "));r=e[n],i=s[n],t[n]=i?i(r):r}}function r(t,e){function r(n,r){var i,s;return n&&n.nodeType?(i=d(n))instanceof e?i:(s=new Ct(new e.RootBlock,n,new c(o)),s.KIND_OF_MQ=t,new e(s).__mathquillify(r||{},o)):null}return n(t+" is defined",e),r.prototype=e.prototype,r}var o,i,s,c,u,p,h,d;if(1!==t&&2!==t&&3!==t)throw"Only interface versions between "+pt+" and "+ht+" supported. You specified: "+t;if((o=t)<3){if(!(i=window.jQuery))throw"MathQuill interface version ".concat(o," requires jQuery 1.5.2+ to be loaded first");at.prototype.jQuery=i}return s=__assign(__assign({},st),{handlers:function(t){return{fns:t||{},APIClasses:h}}}),c=o<3?at:function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(at),u=function(t){function n(e){var n=t.call(this)||this;return n.__controller=e,n.__options=e.options,n.id=e.id,n.data=e.data,n}return __extends(n,t),n.prototype.mathquillify=function(t){var e,n=this.__controller,r=n.root,i=n.container;n.createTextarea(),e=U(i).addClass(t).children().detach(),r.setDOM(U(Re("span",{class:"mq-root-block","aria-hidden":!0})).appendTo(i).oneElement()),X.linkElementByBlockNode(r.domFrag().oneElement(),r),this.latex(e.text()),this.revert=function(){return n.removeMouseEventListener(),U(i).removeClass("mq-editable-field mq-math-mode mq-text-mode").empty().append(e),o<3?this.__options.assertJquery()(i):i}},n.prototype.setAriaLabel=function(t){return this.__controller.setAriaLabel(t),this},n.prototype.getAriaLabel=function(){return this.__controller.getAriaLabel()},n.prototype.config=function(t){return e(this.__options,t),void 0!==t.tabindex&&this.__controller.setTabindex(t.tabindex),this},n.prototype.el=function(){return this.__controller.container},n.prototype.text=function(){return this.__controller.exportText()},n.prototype.mathspeak=function(){return this.__controller.exportMathSpeak()},n.prototype.latex=function(t){if(arguments.length>0){this.__controller.renderLatexMath(t);var e=this.__controller.cursor;return this.__controller.blurred&&e.hide().parent.blur(e),this}return this.__controller.exportLatex()},n.prototype.selection=function(t){return t?(this.__controller.restoreLatexSelection(t),this):this.__controller.exportLatexSelection().selection},n.prototype.domNodeToSpan=function(t){return this.__controller.domNodeToSpan(t)},n.prototype.html=function(){return this.__controller.root.domFrag().oneElement().innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/ mathquill-(?:command|block)-id="?\d+"?/g,"").replace(/<span class="?mq-cursor( mq-blink)?"?>.?<\/span>/i,"").replace(/ mq-hasCursor|mq-hasCursor ?/,"").replace(/ class=(""|(?= |>))/g,"")},n.prototype.reflow=function(){return this.__controller.root.postOrder(function(t){t.reflow()}),this},n.prototype.focus=function(){return this.__controller.getTextarea().focus(),this.__controller.editable&&this.__controller.scrollHoriz(),this},n.prototype.select=function(){return this.__controller.selectAll(),this},n.prototype.blur=function(){return this.__controller.getTextarea().blur(),this},n}(lt),p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.mathquillify=function(e){return t.prototype.mathquillify.call(this,e),this.__controller.editable=!0,this.__controller.addMouseEventListener(),this.__controller.editablesTextareaEvents(),this},e.prototype.clearSelection=function(){return this.__controller.cursor.clearSelection(),this},e.prototype.write=function(t){this.__controller.writeLatex(t),this.__controller.scrollHoriz();var e=this.__controller.cursor;return this.__controller.blurred&&e.hide().parent.blur(e),this},e.prototype.empty=function(){var t,e=this.__controller.root,n=this.__controller.cursor;return e.setEnds((t={},t[Me]=0,t[Ie]=0,t)),e.domFrag().empty(),delete n.selection,n.insAtRightEnd(e),this},e.prototype.cmd=function(t){var e,n,r=this.__controller.notify(void 0),o=r.cursor;return/^\\[a-z]+$/i.test(t)&&!o.isTooDeep()?(t=t.slice(1),(e=Z[t])&&(n=e.constructor?new e(t):e(t),o.selection&&n.replaces(o.replaceSelection()),n.createLeftOf(o.show()))):o.parent.write(o,t),r.scrollHoriz(),r.blurred&&o.hide().parent.blur(o),this},e.prototype.moveToDirEnd=function(t){return this.__controller.notify("move").cursor.insAtDirEnd(t,this.__controller.root),this},e.prototype.moveToLeftEnd=function(){return this.moveToDirEnd(Me)},e.prototype.moveToRightEnd=function(){return this.moveToDirEnd(Ie)},e.prototype.keystroke=function(t,e){var n,r=t.replace(/^\s+|\s+$/g,"").split(/\s+/);for(n=0;n<r.length;n+=1)this.__controller.keystroke(r[n],e);return this},e.prototype.typedText=function(t){for(var e=0;e<t.length;e+=1)this.__controller.typedText(t.charAt(e));return this},e.prototype.dropEmbedded=function(t,e,n){var r,o=t-a(),i=e-l(),s=document.elementFromPoint(o,i);this.__controller.seek(s,o,i),r=(new De).setOptions(n),r.createLeftOf(this.__controller.cursor)},e.prototype.setAriaPostLabel=function(t,e){return this.__controller.setAriaPostLabel(t,e),this},e.prototype.getAriaPostLabel=function(){return this.__controller.getAriaPostLabel()},e.prototype.clickAt=function(t,e,n){var r,o,i;return n=n||document.elementFromPoint(t,e),r=this.__controller,o=r.root,i=o.domFrag().oneElement(),i.contains(n)||(n=i),r.seek(n,t,e),r.blurred&&this.focus(),this},e.prototype.ignoreNextMousedown=function(t){return this.__controller.cursor.options.ignoreNextMousedown=t,this},e.prototype.isUserSelecting=function(){return this.__controller.isMouseSelecting},e}(u),h={AbstractMathQuill:u,EditableField:p},n("API.StaticMath defined",ot.StaticMath),h.StaticMath=ot.StaticMath(h),n("API.MathField defined",ot.MathField),h.MathField=ot.MathField(h),n("API.InnerMathField defined",ot.InnerMathField),h.InnerMathField=ot.InnerMathField(h),ot.TextField&&(h.TextField=ot.TextField(h)),d=function(t){var e,n,r,o,i,s,a,l;if(!t||!t.nodeType)return null;for(n=U(t).children().toElementArray(),r=0,o=n;r<o.length;r++)if(i=o[r],i.classList.contains("mq-root-block")){e=i;break}return s=X.getNodeOfElement(e),a=s&&s.controller,l=a&&h[a.KIND_OF_MQ],a&&l?new l(a):null},d.L=Me,d.R=Ie,d.config=function(t){return e(c.prototype,t),this},d.registerEmbed=function(t,e){if(!/^[a-z][a-z0-9]*$/i.test(t))throw"Embed name must start with letter and be only letters and digits";it[t]=e},d.StaticMath=r("StaticMath",h.StaticMath),d.MathField=r("MathField",h.MathField),d.InnerMathField=r("InnerMathField",h.InnerMathField),h.TextField&&(d.TextField=r("TextField",h.TextField)),d.prototype=u.prototype,d.EditableField=function(){throw"wtf don't call me, I'm 'abstract'"},d.EditableField.prototype=p.prototype,o<3&&(d.saneKeyboardEvents=k),d}function y(t){t.moveOutOf=function(t){n("controller is defined",this.controller),this.controller.handle("moveOutOf",t)},t.deleteOutOf=function(t){n("controller is defined",this.controller),this.controller.handle("deleteOutOf",t)},t.selectOutOf=function(t){n("controller is defined",this.controller),this.controller.handle("selectOutOf",t)},t.upOutOf=function(){n("controller is defined",this.controller),this.controller.handle("upOutOf")},t.downOutOf=function(){n("controller is defined",this.controller),this.controller.handle("downOutOf")},t.reflow=function(){n("controller is defined",this.controller),this.controller.handle("reflow"),this.controller.handle("edited"),this.controller.handle("edit")}}function v(t,e){throw t=t?"'"+t+"'":"EOF","Parse Error: "+e+" at "+t}function x(t,e,n){var r,o,i=n.uncleanedStartIndex,s=n.uncleanedEndIndex;for(r=0,o=0;r<n.uncleanedEndIndex;r++)t[r]!==e[o]?(r<n.uncleanedStartIndex&&(i-=1),s-=1):o+=1;return{startIndex:i,endIndex:s}}function b(t,e,n){var r,o,i=n.startIndex,s=n.endIndex,a=i,l=s;for(r=0,o=0;r<e.length;r++)e[r]!==t[o]?(o<=i&&(a+=1),o<=s&&(l+=1)):o+=1;return{uncleanStartIndex:a,uncleanEndIndex:l}}function w(t){for(;t;){if(rt.isControllerRoot(t))return t;t=t.parent}}function E(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function k(t,e){return gt(t[0],e)}function L(t,e,n){return function(){return new At(t,e?Re.entityText(e):void 0,n)}}function S(t,e,n,r){return function(){return new Mt(t,e?Re.entityText(e):void 0,n,r)}}function _(t,e,n){return function(){return new Ht(t,Re.entityText(e))}}function q(t,e){for(var n="",r=0;t instanceof jt&&t.ctrlSeq===t.letter&&r<e;)n=t.letter+n,t=t[Me],r+=1;return n}function C(t){var e,n,r,o;if("string"!=typeof t)throw'"'+t+'" not a space-delimited list';if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of letters';for(e=t.split(" "),n={},r=0;r<e.length;r+=1){if(o=e[r],o.length<2)throw'"'+o+'" not minimum length of 2';n[o]=!0}return n}function O(t){return _("\\"+t+" ","&"+t+";",t)}function T(t){return function(){return new At("\\"+t+" ",Re.entityText("&"+t+";"))}}function F(t){return t instanceof Mt||t instanceof jt&&"infix"==t.endsCategory}function D(t){if(!t)return!1;var e=t[Me];return e?!(F(e)||e instanceof jt&&"prefix"==e.endsCategory||!(e instanceof Se)&&/^(\\ )|[,;:\(\[]$/.test(e.ctrlSeq)):!!(t.parent&&t.parent.parent&&t.parent.parent.isStyleBlock())&&D(t.parent.parent)}function A(t){if(!t)return"";var e="";return t.eachChild(function(t){void 0!==t.ctrlSeq&&(e+=t.ctrlSeq)}),e}function M(t){var e=this.parent,n=t;do{if(n[Ie])return t.insLeftOf(e);n=n.parent.parent}while(n!==e);t.insRightOf(e)}function I(t,e){var n;return"0"===e?"to the 0 power":"2"===e?"squared":"3"===e?"cubed":(n="",/^[+-]?\d{1,3}$/.test(e)&&(/(11|12|13|4|5|6|7|8|9|0)$/.test(e)?n="th":/1$/.test(e)?n="st":/2$/.test(e)?n="nd":/3$/.test(e)&&(n="rd")),"to the "+("object"==typeof t?t.mathspeak():e)+n+" power")}function N(t){var e=t.side,n=t.sides[e];return{ch:_e[n.ch],ctrlSeq:_e[n.ctrlSeq]}}function B(t,e,n){var r,o;e=e||t,r=_e[t],o=_e[e],J[t]=function(){return new Se(Me,t,r,e,o)},J[r]=function(){return new Se(Ie,t,r,e,o)},qe[t]=qe[r]=n}var R,z,P,H,j,G,V,W,Q,$,U,K,X,Y,Z,J,tt,et,nt,rt,ot,it,st,at,lt,ct,ut,pt,ht,dt,ft,mt,gt,yt,vt,xt,bt,wt,Et,kt,Lt,St,_t,qt,Ct,Ot,Tt,Ft,Dt,At,Mt,It,Nt,Bt,Rt,zt,Pt,Ht,jt,Gt,Vt,Wt,Qt,$t,Ut,Kt,Xt,Yt,Zt,Jt,te,ee,ne,re,oe,ie,se,ae,le,ce,ue,pe,he,de,fe,me,ge,ye,ve,xe,be,we,Ee,ke,Le,Se,_e,qe,Ce,Oe,Te,Fe,De,Ae,Me=-1,Ie=1,Ne=Math.min,Be=Math.max,Re=function(t,e,n){var r,o,i,s;switch(t){case"svg":case"path":r=document.createElementNS("http://www.w3.org/2000/svg",t);break;default:r=document.createElement(t)}for(o in e)void 0!==(i=e[o])&&r.setAttribute(o,"string"==typeof i?i:String(i));if(n)for(s=0;s<n.length;s++)r.appendChild(n[s]);return r};Re.text=function(t){return document.createTextNode(t)},Re.block=function(t,e,n,r){var o,i=[n.html()];return(null===r||void 0===r?void 0:r.beforeChild)&&i.unshift(r.beforeChild),(null===r||void 0===r?void 0:r.afterChild)&&i.push(r.afterChild),o=Re(t,e,i),n.setDOM(o),X.linkElementByBlockNode(o,n),o},Re.entityText=function(t){var e=o(t);return n("entity parses to a single text node",e instanceof DocumentFragment&&1===e.childNodes.length&&e.childNodes[0]instanceof Text),e.childNodes[0]},R=" ",z="​",P="˙",H="∑",j="∏",G="∐",V="∫",W=function(){var t,e;return"function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame?(t=requestAnimationFrame,e=cancelAnimationFrame):(t=function(t){return setTimeout(t,13)},e=clearTimeout),function(n,r){function o(){var t=(Date.now()-l)/n;t<=c?s():c=t,r(c,s,i)}function i(){void 0!==a&&e(a),a=void 0}function s(){i(),a=t(o)}var a,l=Date.now(),c=0;r(n<=0?1:0,s,i)}}(),Q=function(){function t(t){this.span=Re("span",{class:"mq-aria-alert","aria-live":"assertive","aria-atomic":"true"}),this.msg="",this.items=[],this.controller=t}return t.prototype.attach=function(){var t=this.controller.container;this.span.parentNode!==t&&U(t).prepend(U(this.span))},t.prototype.queue=function(t,e){var n,r;return void 0===e&&(e=!1),n="",t instanceof bt?(r=t.mathspeak({ignoreShorthand:!0}),e&&(t.parent&&t.parent.ariaLabel&&"block"===t.ariaLabel?n=t.parent.ariaLabel+" "+r:t.ariaLabel&&(n=t.ariaLabel+" "+r)),""===n&&(n=r)):n=t||"",this.items.push(n),this},t.prototype.queueDirOf=function(t){return r(t),this.queue(t===Me?"before":"after")},t.prototype.queueDirEndOf=function(t){return r(t),this.queue(t===Me?"beginning of":"end of")},t.prototype.alert=function(t){return this.attach(),t&&this.queue(t),this.items.length&&(this.msg=this.items.join(" ").replace(/ +(?= )/g,"").trim(),this.controller.containerHasFocus()&&(this.controller.options.logAriaAlerts&&this.msg&&console.log(this.msg),this.span.textContent=this.msg)),this.clear()},t.prototype.clear=function(t){return this.items.length=0,(null===t||void 0===t?void 0:t.emptyContent)&&(this.span.textContent=""),this},t}(),$=function(){function t(t,e){var n;1===arguments.length&&(e=t),t&&e&&(this.ends=(n={},n[Me]=t,n[Ie]=e,n))}return t.create=function(e,r){1===arguments.length&&(r=e),n("No half-empty DOMFragments",!!e==!!r);var o=new t(e,r);return n("last is a forward sibling of first",o.isValid()),o},t.prototype.isEmpty=function(){return void 0===this.ends},t.prototype.isOneNode=function(){return!(!this.ends||this.ends[Me]!==this.ends[Ie])},t.prototype.isValid=function(){if(!this.ends)return!0;if(this.ends[Me]===this.ends[Ie])return!0;var t;return this.eachNode(function(e){return t=e}),t===this.ends[Ie]},t.prototype.firstNode=function(){return n("Fragment is not empty",this.ends),this.ends[Me]},t.prototype.lastNode=function(){return n("Fragment is not empty",this.ends),this.ends[Ie]},t.prototype.children=function(){var e=this.oneNode(),n=e.firstChild,r=e.lastChild;return n&&r?new t(n,r):new t},t.prototype.join=function(e){var r,o;if(!this.ends)return e;if(!e.ends)return this;for(r=!1,o=this.ends[Ie].nextSibling;o;){if(o===e.ends[Me]){r=!0;break}o=o.nextSibling}return n("sibling must be a forward DOM sibling of this fragment",r),new t(this.ends[Me],e.ends[Ie])},t.prototype.oneNode=function(){return n("Fragment has a single node",this.ends&&this.ends[Me]===this.ends[Ie]),this.ends[Me]},t.prototype.oneElement=function(){var t=this.oneNode();return n("Node is an Element",t.nodeType===Node.ELEMENT_NODE),t},t.prototype.oneText=function(){var t=this.oneNode();return n("Node is Text",t.nodeType===Node.TEXT_NODE),t},t.prototype.eachNode=function(t){var e,n,r;if(!this.ends)return this;for(e=this.ends[Ie],n=this.ends[Me],r=void 0;n&&(r=n.nextSibling,t(n),n!==e);n=r);return this},t.prototype.eachElement=function(t){return this.eachNode(function(e){e.nodeType===Node.ELEMENT_NODE&&t(e)}),this},t.prototype.text=function(){var t="";return this.eachNode(function(e){t+=e.textContent||""}),t},t.prototype.toNodeArray=function(){var t=[];return this.eachNode(function(e){return t.push(e)}),t},t.prototype.toElementArray=function(){var t=[];return this.eachElement(function(e){return t.push(e)}),t},t.prototype.toDocumentFragment=function(){var t=document.createDocumentFragment();return this.eachNode(function(e){return t.appendChild(e)}),t},t.prototype.insertBefore=function(t){return this.insDirOf(Me,t)},t.prototype.insertAfter=function(t){return this.insDirOf(Ie,t)},t.prototype.append=function(t){return t.appendTo(this.oneElement()),this},t.prototype.prepend=function(t){return t.prependTo(this.oneElement()),this},t.prototype.appendTo=function(t){return this.insAtDirEnd(Ie,t)},t.prototype.prependTo=function(t){return this.insAtDirEnd(Me,t)},t.prototype.parent=function(){if(!this.ends)return this;var e=this.ends[Me].parentNode;return e?new t(e):new t},t.prototype.wrapAll=function(t){var e,n;return t.textContent="",this.ends?(e=this.ends[Me].parentNode,n=this.ends[Ie].nextSibling,this.appendTo(t),e&&e.insertBefore(t,n),this):this},t.prototype.replaceWith=function(t){var e,n,r=null===(e=this.ends)||void 0===e?void 0:e[Ie],o=null===r||void 0===r?void 0:r.parentNode,i=null===r||void 0===r?void 0:r.nextSibling;return this.detach(),n=t.toDocumentFragment(),r&&o?(o.insertBefore(n,i||null),this):this},t.prototype.nthElement=function(t){if(this.ends&&!(t<0||t!==Math.floor(t)))for(var e=this.ends[Me];e;){if(e.nodeType===Node.ELEMENT_NODE){if(t<=0)return e;t-=1}if(e===this.ends[Ie])return;e=e.nextSibling}},t.prototype.firstElement=function(){return this.nthElement(0)},t.prototype.lastElement=function(){if(this.ends)for(var t=this.ends[Ie];t;){if(t.nodeType===Node.ELEMENT_NODE)return t;if(t===this.ends[Me])return;t=t.previousSibling}},t.prototype.first=function(){return new t(this.firstElement())},t.prototype.last=function(){return new t(this.lastElement())},t.prototype.eq=function(e){return new t(this.nthElement(e))},t.prototype.slice=function(e){if(!this.ends)return this;var n=this.nthElement(e);return n?new t(n,this.ends[Ie]):new t},t.prototype.next=function(){for(var e=this.oneNode();e;)if((e=e.nextSibling)&&e.nodeType===Node.ELEMENT_NODE)return new t(e);return new t},t.prototype.prev=function(){for(var e=this.oneNode();e;)if((e=e.previousSibling)&&e.nodeType===Node.ELEMENT_NODE)return new t(e);return new t},t.prototype.empty=function(){return this.eachElement(function(t){t.textContent=""}),this},t.prototype.remove=function(){return this.toDocumentFragment(),this},t.prototype.detach=function(){return this.remove()},t.prototype.insDirOf=function(t,e){var n,r;return this.ends?(r=null===(n=e.ends)||void 0===n?void 0:n[t])&&r.parentNode?(c(t,r.parentNode,this.toDocumentFragment(),r),this):this.detach():this},t.prototype.insAtDirEnd=function(t,e){return this.ends?(u(t,this.toDocumentFragment(),e),this):this},t.prototype.hasClass=function(t){var e=!1;return this.eachElement(function(n){n.classList.contains(t)&&(e=!0)}),e},t.prototype.addClass=function(t){var e,n,r,o=function(t){if(!t)return"continue";i.eachElement(function(e){e.classList.add(t)})},i=this;for(e=0,n=t.split(/\s+/);e<n.length;e++)r=n[e],o(r);return this},t.prototype.removeClass=function(t){var e,n,r,o=function(t){if(!t)return"continue";i.eachElement(function(e){e.classList.remove(t)})},i=this;for(e=0,n=t.split(/\s+/);e<n.length;e++)r=n[e],o(r);return this},t.prototype.toggleClass=function(t,e){var n,r,o,i,s;if(!0===e)return this.addClass(t);if(!1===e)return this.removeClass(t);for(n=function(t){if(!t)return"continue";r.eachElement(function(e){e.classList.toggle(t)})},r=this,o=0,i=t.split(/\s+/);o<i.length;o++)s=i[o],n(s);return this},t}(),U=$.create,K=function(){function t(t,e,n){this.init(t,e,n)}return t.prototype.init=function(t,e,n){this.parent=t,this[Me]=e,this[Ie]=n},t.copy=function(e){return new t(e.parent,e[Me],e[Ie])},t}(),X=function(){function t(){var n;this[e]=0,this[o]=0,this.parent=0,this.ends=(n={},n[Me]=0,n[Ie]=0,n),this.id=t.uniqueNodeId()}t.uniqueNodeId=function(){return t.idCounter+=1},t.getNodeOfElement=function(t){if(t){if(!t.nodeType)throw new Error("must pass an Element to NodeBase.getNodeOfElement");var e=t;return e.mqBlockNode||e.mqCmdNode}},t.linkElementByBlockNode=function(t,e){t.mqBlockNode=e},t.linkElementByCmdNode=function(t,e){t.mqCmdNode=e},t.prototype.setEnds=function(t){this.ends=t,n("No half-empty node ends",!!this.ends[Me]==!!this.ends[Ie])},t.prototype.getEnd=function(t){return this.ends[t]},t.prototype.toString=function(){return"{{ MathQuill Node #"+this.id+" }}"},t.prototype.setDOM=function(t){return t&&n("DOM is an element or a text node",t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE),this._el=t,this},t.prototype.domFrag=function(){return U(this._el)},t.prototype.createDir=function(t,e){r(t);var n=this;return n.html(),n.domFrag().insDirOf(t,e.domFrag()),e[t]=n.adopt(e.parent,e[Me],e[Ie]),n},t.prototype.createLeftOf=function(t){this.createDir(Me,t)},t.prototype.selectChildren=function(t,e){return new nt(t,e)},t.prototype.bubble=function(t){var e,n=this.getSelfNode();for(e=n;e&&!1!==t(e);e=e.parent);return this},t.prototype.postOrder=function(t){var e=this.getSelfNode();return function e(n){return!!n&&(n.eachChild(e),t(n),!0)}(e),e},t.prototype.isEmpty=function(){return 0===this.ends[Me]&&0===this.ends[Ie]},t.prototype.isQuietEmptyDelimiter=function(t){if(!this.isEmpty())return!1;if(!t)return!1;if(!this.parent||void 0===this.parent.ctrlSeq)return!1;var e=this.parent.ctrlSeq.replace(/^\\(left|right)?/,"");return t.hasOwnProperty(e)},t.prototype.isStyleBlock=function(){return!1},t.prototype.isTextBlock=function(){return!1},t.prototype.children=function(){return new Y(this.getEnd(Me),this.getEnd(Ie))},t.prototype.eachChild=function(t){return p(this.ends,t),this},t.prototype.foldChildren=function(t,e){return h(this.ends,t,e)},t.prototype.withDirAdopt=function(t,e,n,r){var o=this.getSelfNode();return new Y(o,o).withDirAdopt(t,e,n,r),this},t.prototype.adopt=function(t,e,n){var r=this.getSelfNode();return new Y(r,r).adopt(t,e,n),this.getSelfNode()},t.prototype.disown=function(){var t=this.getSelfNode();return new Y(t,t).disown(),this},t.prototype.remove=function(){return this.domFrag().remove(),this.disown()},t.prototype.shouldIgnoreSubstitutionInSimpleSubscript=function(t){var e,n=t.disableAutoSubstitutionInSubscripts;return!!n&&(!!this.parent&&(this.parent.parent instanceof ue&&(e=this.parent.parent[Me],!("object"==typeof n&&e instanceof jt&&e.endsWord&&n.except[e.endsWord])&&!!this.parent.domFrag().hasClass("mq-sub"))))},t.prototype.getSelfNode=function(){return this},t.prototype.parser=function(){n("Abstract parser() method is never called",!1)},t.prototype.html=function(){throw new Error("html() unimplemented in NodeBase")},t.prototype.text=function(){return""},t.prototype.latex=function(){var t={uncleanedLatex:"",uncleanedStartIndex:-1,uncleanedEndIndex:-1};return this.latexRecursive(t),t.uncleanedLatex},t.prototype.latexRecursive=function(t){},t.prototype.checkCursorContextOpen=function(t){var e,n=t.uncleanedLatex.length;t.startSelectionBefore===this&&(t.uncleanedStartIndex=n),t.endSelectionBefore===this&&(t.uncleanedEndIndex=n),(e=t.restoreInfo)&&n===e.uncleanedStartIndex&&(e.uncleanedEndIndex===e.uncleanedStartIndex?n===e.uncleanedStartIndex&&(e.cursorParent=this.parent):e.selectionL=this)},t.prototype.checkCursorContextClose=function(t){var e,n=t.uncleanedLatex.length;t.startSelectionAfter===this&&(t.uncleanedStartIndex=n),t.endSelectionAfter===this&&(t.uncleanedEndIndex=n),(e=t.restoreInfo)&&n===e.uncleanedEndIndex&&(e.uncleanedStartIndex===e.uncleanedEndIndex?(e.cursorL||(e.cursorL=this),e.cursorParent?e.cursorParent===this.parent&&(e.cursorParent=this,e.cursorL=0):e.cursorParent=this.parent):e.selectionR||(e.selectionR=this))},t.prototype.finalizeTree=function(t,e){},t.prototype.contactWeld=function(t,e){},t.prototype.blur=function(t){},t.prototype.focus=function(){},t.prototype.intentionalBlur=function(){},t.prototype.reflow=function(){},t.prototype.registerInnerField=function(t,e){},t.prototype.chToCmd=function(t,e){n("Abstract chToCmd() method is never called",!1)},t.prototype.mathspeak=function(t){return""},t.prototype.seek=function(t,e){},t.prototype.siblingDeleted=function(t,e){},t.prototype.siblingCreated=function(t,e){},t.prototype.finalizeInsert=function(t,e){},t.prototype.fixDigitGrouping=function(t){},t.prototype.writeLatex=function(t,e){},t.prototype.write=function(t,e){};var e,o;return e=Me,o=Ie,t.idCounter=0,t}(),Y=function(){function t(t,e,o){var i,s,a,l;if(this.disowned=!1,void 0===o&&(o=Me),r(o),n("no half-empty fragments",!t==!e,{withDir:t,oppDir:e}),!t||!e)return void this.setEnds((i={},i[Me]=0,i[Ie]=0,i));n("withDir is passed to Fragment",t instanceof bt),n("oppDir is passed to Fragment",e instanceof bt),n("withDir and oppDir have the same parent",t.parent===e.parent),s={},s[o]=t,s[-o]=e,a=s,this.setEnds(a),l=0,this.each(function(t){l=t}),n("following direction siblings from start reaches end",l===a[Ie])}return t.prototype.getDOMFragFromEnds=function(){var t=this.ends[Me],e=this.ends[Ie];return 0===t||0===e?U():t===e?t.domFrag():t.domFrag().join(e.domFrag())},t.prototype.setEnds=function(t){this.ends=t},t.prototype.getEnd=function(t){return this.ends?this.ends[t]:0},t.prototype.domFrag=function(){return this.getDOMFragFromEnds()},t.prototype.withDirAdopt=function(t,e,n,r){return t===Me?this.adopt(e,n,r):this.adopt(e,r,n)},t.prototype.adopt=function(t,e,n){var r,o,i,s,a;return d(t,e,n),o=this,this.disowned=!1,(i=o.ends[Me])&&(s=o.ends[Ie])?(r={},r[Me]=t.getEnd(Me),r[Ie]=t.getEnd(Ie),a=r,e||(a[Me]=i),n?n[Me]=s:a[Ie]=s,t.setEnds(a),s[Ie]=n,o.each(function(n){return n[Me]=e,n.parent=t,e&&(e[Ie]=n),e=n,!0}),o):this},t.prototype.disown=function(){var t,e,n,r,o,i,s=this,a=s.ends[Me];return!a||s.disowned?s:(this.disowned=!0,(e=s.ends[Ie])?(n=a.parent,d(n,a[Me],a),d(n,e,e[Ie]),t={},t[Me]=n.getEnd(Me),t[Ie]=n.getEnd(Ie),r=t,a[Me]?(o=a[Me],o[Ie]=e[Ie]):r[Me]=e[Ie],e[Ie]?(i=e[Ie],i[Me]=a[Me]):r[Ie]=a[Me],r[Me]&&r[Ie]?n.setEnds(r):n.ends=r,s):s)},t.prototype.remove=function(){return this.domFrag().remove(),this.disown()},t.prototype.each=function(t){return p(this.ends,t),this},t.prototype.fold=function(t,e){return h(this.ends,t,e)},t}(),Z={},J={},tt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.ancestors={},o}return __extends(e,t),e.fromCursor=function(t){return new e(t.parent,t[Me],t[Ie])},e}(K),et=function(t){function e(e,n,r){var o=t.call(this,e,0,0)||this;return o.upDownCache={},o.cursorElement=Re("span",{class:"mq-cursor"},[Re.text(z)]),o._domFrag=U(),o.controller=r,o.options=n,o.setDOMFrag(U(o.cursorElement)),o.blink=function(){U(o.cursorElement).toggleClass("mq-blink")},o}return __extends(e,t),e.prototype.setDOMFrag=function(t){return this._domFrag=t,this},e.prototype.domFrag=function(){return this._domFrag},e.prototype.show=function(){var t,e;return U(this.cursorElement).removeClass("mq-blink"),this.setDOMFrag(U(this.cursorElement)),this.intervalId?clearInterval(this.intervalId):(t=this[Ie],t?(e=this.selection,e&&e.getEnd(Me)[Me]===this[Me]?this.domFrag().insertBefore(e.domFrag()):this.domFrag().insertBefore(t.domFrag())):this.domFrag().appendTo(this.parent.domFrag().oneElement()),this.parent.focus()),this.intervalId=setInterval(this.blink,500),this},e.prototype.hide=function(){return this.intervalId&&clearInterval(this.intervalId),this.intervalId=0,this.domFrag().detach(),this.setDOMFrag(U()),this},e.prototype.withDirInsertAt=function(t,e,n,r){var o=this.parent;this.parent=e,this[t]=n,this[-t]=r,o!==e&&o.blur&&o.blur(this)},e.prototype.insDirOf=function(t,e){return r(t),this.domFrag().insDirOf(t,e.domFrag()),this.withDirInsertAt(t,e.parent,e[t],e),this.parent.domFrag().addClass("mq-hasCursor"),this},e.prototype.insLeftOf=function(t){return this.insDirOf(Me,t)},e.prototype.insRightOf=function(t){return this.insDirOf(Ie,t)},e.prototype.insAtDirEnd=function(t,e){return r(t),this.domFrag().insAtDirEnd(t,e.domFrag().oneElement()),this.withDirInsertAt(t,e,0,e.getEnd(t)),e.focus(),this},e.prototype.insAtLeftEnd=function(t){return this.insAtDirEnd(Me,t)},e.prototype.insAtRightEnd=function(t){return this.insAtDirEnd(Ie,t)},e.prototype.jumpUpDown=function(t,e){var n,r,o,i=this;i.upDownCache[t.id]=K.copy(i),n=i.upDownCache[e.id],n?(r=n[Ie],r?i.insLeftOf(r):i.insAtRightEnd(n.parent)):(o=i.getBoundingClientRectWithoutMargin().left,e.seek(o,i)),i.controller.aria.queue(e,!0)},e.prototype.getBoundingClientRectWithoutMargin=function(){var t,e,n,r=this.domFrag();return r.removeClass("mq-cursor"),t=s(r.oneElement()),e=t.left,n=t.right,r.addClass("mq-cursor"),{left:e,right:n}},e.prototype.unwrapGramp=function(){var t,e,n,r,o,i=this.parent.parent,s=i.parent,a=i[Ie],l=this,c=i[Me];if(i.disown().eachChild(function(t){return!!t.isEmpty()||(t.children().adopt(s,c,a).each(function(t){return t.domFrag().insertBefore(i.domFrag()),!0}),c=t.getEnd(Ie),!0)}),!this[Ie])if(t=this[Me])this[Ie]=t[Ie];else for(;!this[Ie];){if(!(e=this.parent[Ie])){this[Ie]=i[Ie],this.parent=s;break}this.parent=e,this[Ie]=e.getEnd(Me)}n=this[Ie],n?this.insLeftOf(n):this.insAtRightEnd(s),i.domFrag().remove(),r=i[Me],o=i[Ie],r&&r.siblingDeleted(l.options,Ie),o&&o.siblingDeleted(l.options,Me)},e.prototype.startSelection=function(){var t,e=this.anticursor=tt.fromCursor(this),n=e.ancestors;for(t=e;t.parent;t=t.parent)n[t.parent.id]=t},e.prototype.endSelection=function(){delete this.anticursor},e.prototype.select=function(){var t,e,r,o,i,s,a,l,c,u=this.anticursor;if(this[Me]===u[Me]&&this.parent===u.parent)return!1;for(e=this;e.parent;e=e.parent)if(e.parent.id in u.ancestors){t=e.parent;break}if(n("cursor and anticursor in the same tree",t),r=t,o=u.ancestors[r.id],a=Ie,e[Me]!==o)for(l=e;l;l=l[Ie])if(l[Ie]===o[Ie]){a=Me,i=e,s=o;break}return a===Ie&&(i=o,s=e),i instanceof K&&(i=i[Ie]),s instanceof K&&(s=s[Me]),this.hide().selection=r.selectChildren(i,s),c=this.selection.getEnd(a),this.insDirOf(a,c),this.selectionChanged(),!0},
11
+ e.prototype.resetToEnd=function(t){this.clearSelection();var e=t.root;this[Ie]=0,this[Me]=e.getEnd(Ie),this.parent=e},e.prototype.clearSelection=function(){return this.selection&&(this.selection.clear(),delete this.selection,this.selectionChanged()),this},e.prototype.deleteSelection=function(){var t=this.selection;t&&(this[Me]=t.getEnd(Me)[Me],this[Ie]=t.getEnd(Ie)[Ie],t.remove(),this.selectionChanged(),delete this.selection)},e.prototype.replaceSelection=function(){var t=this.selection;return t&&(this[Me]=t.getEnd(Me)[Me],this[Ie]=t.getEnd(Ie)[Ie],delete this.selection),t},e.prototype.depth=function(){for(var t=this,e=0;t=t.parent;)e+=t instanceof It?1:0;return e},e.prototype.isTooDeep=function(t){return void 0!==this.options.maxDepth&&this.depth()+(t||0)>this.options.maxDepth},e.prototype.selectionChanged=function(){},e}(K),nt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o._el=Re("span",{class:"mq-selection"}),o.getDOMFragFromEnds().wrapAll(o._el),o}return __extends(e,t),e.prototype.isCleared=function(){return void 0===this._el},e.prototype.domFrag=function(){return this.isCleared()?this.getDOMFragFromEnds():U(this._el)},e.prototype.setEnds=function(t){n("Selection ends are never empty",t[Me]&&t[Ie]),this.ends=t},e.prototype.getEnd=function(t){return this.ends[t]},e.prototype.adopt=function(e,n,r){return this.clear(),t.prototype.adopt.call(this,e,n,r)},e.prototype.clear=function(){var t=this.getDOMFragFromEnds();return this.domFrag().replaceWith(t),this._el=void 0,this},e.prototype.join=function(t,e){return void 0===e&&(e=""),this.fold("",function(n,r){return n+e+r[t]()})},e}(Y),rt=function(){function t(t,e,n){this.isMouseSelecting=!1,this.textareaEventListeners={},this.id=t.id,this.data={},this.root=t,this.container=e,this.options=n,this.aria=new Q(this.getControllerSelf()),this.ariaLabel="Math Input",this.ariaPostLabel="",t.controller=this.getControllerSelf(),this.cursor=t.cursor=new et(t,n,this.getControllerSelf())}return t.isControllerRoot=function(t){var e=t.controller;return e&&e.root===t},t.prototype.getControllerSelf=function(){return this},t.prototype.handle=function(t,e){var r,o,i,s=this.options.handlers,a=null===(r=this.options.handlers)||void 0===r?void 0:r.fns[t];a&&(o=null===s||void 0===s?void 0:s.APIClasses[this.KIND_OF_MQ],n("APIClass is defined",o),i=new o(this),e===Me||e===Ie?a(e,i):a(i))},t.onNotify=function(e){t.notifyees.push(e)},t.prototype.notify=function(e){for(var n=0;n<t.notifyees.length;n+=1)t.notifyees[n](this.cursor,e);return this},t.prototype.setAriaLabel=function(t){var e=this.getAriaLabel();return!t&&this.editable?this.ariaLabel="Math Input":this.ariaLabel=t,t===e||this.containerHasFocus()||this.updateMathspeak(),this},t.prototype.getAriaLabel=function(){return"Math Input"!==this.ariaLabel?this.ariaLabel:this.editable?"Math Input":""},t.prototype.setAriaPostLabel=function(t,e){var n=this;return t&&"string"==typeof t&&""!==t?(t!==this.ariaPostLabel&&"number"==typeof e&&(this._ariaAlertTimeout&&clearTimeout(this._ariaAlertTimeout),this._ariaAlertTimeout=setTimeout(function(){n.containerHasFocus()?n.aria.alert(n.root.mathspeak().trim()+" "+t.trim()):n.updateMathspeak()},e)),this.ariaPostLabel=t):(this._ariaAlertTimeout&&clearTimeout(this._ariaAlertTimeout),this.ariaPostLabel=""),this},t.prototype.getAriaPostLabel=function(){return this.ariaPostLabel||""},t.prototype.containerHasFocus=function(){return document.activeElement&&this.container.contains(document.activeElement)},t.prototype.getTextarea=function(){var t=this.textarea;return n("textarea initialized",t),t},t.prototype.getTextareaSpan=function(){var t=this.textareaSpan;return n("textareaSpan initialized",t),t},t.prototype.addTextareaEventListeners=function(t){var e,n;if(this.textarea)for(e in t)n=e,this.removeTextareaEventListener(n),this.textarea.addEventListener(n,t[n])},t.prototype.removeTextareaEventListener=function(t){if(this.textarea){var e=this.textareaEventListeners[t];e&&this.textarea.removeEventListener(t,e)}},t.prototype.exportMathSpeak=function(){return this.root.mathspeak()},t.prototype.updateMathspeak=function(t){},t.prototype.scrollHoriz=function(){},t.prototype.selectionChanged=function(){},t.prototype.setOverflowClasses=function(){},t.notifyees=[],t}(),ot={},it={},st={},at=function(){function t(t){this.version=t}return t.prototype.assertJquery=function(){return n("Interface versions > 2 do not depend on JQuery",this.version<=2),n("JQuery is set for interface v < 3",this.jQuery),this.jQuery},t}(),lt=function(){function t(){}return t}(),ct=function(){window.console&&console.warn('You are using the MathQuill API without specifying an interface version, which will fail in v1.0.0. Easiest fix is to do the following before doing anything else:\n\n MathQuill = MathQuill.getInterface(1);\n // now MathQuill.MathField() works like it used to\n\nSee also the "`dev` branch (2014–2015) → v0.10.0 Migration Guide" at\n https://github.com/mathquill/mathquill/wiki/%60dev%60-branch-(2014%E2%80%932015)-%E2%86%92-v0.10.0-Migration-Guide')},m.prototype=lt.prototype,m.VERSION="v0.10.1",m.interfaceVersion=function(t){if(1!==t)throw"Only interface version 1 supported. You specified: "+t;return ct=function(){window.console&&console.warn('You called MathQuill.interfaceVersion(1); to specify the interface version, which will fail in v1.0.0. You can fix this easily by doing this before doing anything else:\n\n MathQuill = MathQuill.getInterface(1);\n // now MathQuill.MathField() works like it used to\n\nSee also the "`dev` branch (2014–2015) → v0.10.0 Migration Guide" at\n https://github.com/mathquill/mathquill/wiki/%60dev%60-branch-(2014%E2%80%932015)-%E2%86%92-v0.10.0-Migration-Guide')},ct(),m},m.getInterface=g,pt=g.MIN=1,ht=g.MAX=3,m.noConflict=function(){return window.MathQuill=dt,m},dt=window.MathQuill,window.MathQuill=m,ft=function(){function t(t){this._=t}return t.prototype.parse=function(e){function n(t,e){return e}return this.skip(t.eof)._(""+e,n,v)},t.prototype.or=function(e){n("or is passed a parser",e instanceof t);var r=this;return new t(function(t,n,o){function i(r){return e._(t,n,o)}return r._(t,n,i)})},t.prototype.then=function(e){var r=this;return new t(function(o,i,s){function a(r,o){var a=e instanceof t?e:e(o);return n("a parser is returned",a instanceof t),a._(r,i,s)}return r._(o,a,s)})},t.prototype.many=function(){var e=this;return new t(function(t,n,r){function o(e,n){return t=e,s.push(n),!0}function i(){return!1}for(var s=[];e._(t,o,i););return n(t,s)})},t.prototype.times=function(e,n){arguments.length<2&&(n=e);var r=this;return new t(function(t,o,i){function s(e,n){return p.push(n),t=e,!0}function a(e,n){return c=n,t=e,!1}function l(t,e){return!1}var c,u,p=[],h=!0;for(u=0;u<e;u+=1)if(!(h=!!r._(t,s,a)))return i(t,c);for(;u<n&&h;u+=1)r._(t,s,l);return o(t,p)})},t.prototype.result=function(e){return this.then(t.succeed(e))},t.prototype.atMost=function(t){return this.times(0,t)},t.prototype.atLeast=function(t){var e=this;return e.times(t).then(function(t){return e.many().map(function(e){return t.concat(e)})})},t.prototype.map=function(e){return this.then(function(n){return t.succeed(e(n))})},t.prototype.skip=function(t){return this.then(function(e){return t.result(e)})},t.string=function(e){var n=e.length,r="expected '"+e+"'";return new t(function(t,o,i){var s=t.slice(0,n);return s===e?o(t.slice(n),s):i(t,r)})},t.regex=function(e){n("regexp parser is anchored","^"===e.toString().charAt(1));var r="expected "+e;return new t(function(t,n,o){var i,s=e.exec(t);return s?(i=s[0],n(t.slice(i.length),i)):o(t,r)})},t.succeed=function(e){return new t(function(t,n){return n(t,e)})},t.fail=function(e){return new t(function(t,n,r){return r(t,e)})},t.letter=t.regex(/^[a-z]/i),t.letters=t.regex(/^[a-z]*/i),t.digit=t.regex(/^[0-9]/),t.digits=t.regex(/^[0-9]*/),t.whitespace=t.regex(/^\s+/),t.optWhitespace=t.regex(/^\s*/),t.any=new t(function(t,e,n){return t?e(t.slice(1),t.charAt(0)):n(t,"expected any character")}),t.all=new t(function(t,e,n){return e("",t)}),t.eof=new t(function(t,e,n){return t?n(t,"expected EOF"):e(t,t)}),t}(),mt=function(){function e(){this.fn=t}return e.prototype.listen=function(t){this.fn=t,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(this.fn)},e.prototype.listenOnce=function(t){var e=this;this.listen(function(){var n,r=[];for(n=0;n<arguments.length;n++)r[n]=arguments[n];e.clearListener(),t.apply(void 0,r)})},e.prototype.clearListener=function(){this.fn=t,clearTimeout(this.timeoutId)},e.prototype.trigger=function(){var t,e=[];for(t=0;t<arguments.length;t++)e[t]=arguments[t];this.fn.apply(this,e)},e}(),gt=function(){function t(t){switch(n(t)){case"Right":case"Left":case"Down":case"Up":return!0}return!1}function e(t){return 1===t.length&&t>="a"&&t<="z"}function n(t){var n,r;return void 0===t.key?(r=t.which||t.keyCode,o[r]||String.fromCharCode(r)):e(t.key)?t.key.toUpperCase():null!==(n=i[t.key])&&void 0!==n?n:t.key}function r(t){var e=n(t),r=[];return t.ctrlKey&&r.push("Ctrl"),t.metaKey&&r.push("Meta"),t.altKey&&r.push("Alt"),t.shiftKey&&r.push("Shift"),r.length?("Alt"!==e&&"Control"!==e&&"Meta"!==e&&"Shift"!==e&&r.push(e),r.join("-")):e}var o={8:"Backspace",9:"Tab",10:"Enter",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Esc",32:"Spacebar",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",45:"Insert",46:"Del",144:"NumLock"},i={ArrowRight:"Right",ArrowLeft:"Left",ArrowDown:"Down",ArrowUp:"Up",Delete:"Del",Escape:"Esc"," ":"Spacebar"};return function(e,n){function o(){try{e instanceof HTMLTextAreaElement&&e.select()}catch(t){}}function i(t){x.trigger(),x.clearListener(),e instanceof HTMLTextAreaElement&&(e.value=t),t&&o(),b=!!t}function s(){return"selectionStart"in e&&(e instanceof HTMLTextAreaElement&&e.selectionStart!==e.selectionEnd)}function a(){n.options&&n.options.overrideKeystroke?n.options.overrideKeystroke(r(y),y):n.keystroke(r(y),y)}function l(t){x.trigger(t),t.target===e&&(y=t,v=null,b&&x.listenOnce(function(t){t&&"focusout"===t.type||o()}),a())}function c(n){x.trigger(n),n.target===e&&(y&&v&&a(),v=n,t(n)?x.listenOnce(h):x.listen(p))}function u(n){x.trigger(n),n.target===e&&y&&!v&&(t(n)?x.listenOnce(h):x.listen(p))}function p(){if(!s()&&e instanceof HTMLTextAreaElement){var t=e.value;(!y||"Unidentified"!==y.key&&(y.altKey||!y.ctrlKey||y.metaKey||!y.shiftKey||"U"!==y.key&&"Process"!==y.key))&&(1===t.length?(e.value="",n.options&&n.options.overrideTypedText?n.options.overrideTypedText(t):n.typedText(t)):h())}}function h(){e instanceof HTMLTextAreaElement&&e.value.length>1&&o()}function d(){y=null,v=null,x.clearListener(),e instanceof HTMLTextAreaElement&&(e.value="")}function f(t){var r,o;x.trigger(),t.target===e&&(document.activeElement!==e&&e.focus(),(o=t instanceof ClipboardEvent?t:void 0)&&(null===(r=n.options)||void 0===r?void 0:r.overridePaste)&&n.options.overridePaste(o)||x.listen(function(){if(e instanceof HTMLTextAreaElement){var t=e.value;e.value="",t&&n.paste(t)}}))}function m(t){x.trigger(t)}function g(t){var e,r;(null===t||void 0===t?void 0:t.clipboardData)&&(e=n.exportLatexSelection().selection,e.startIndex!==e.endIndex&&(r=e.latex.slice(e.startIndex,e.endIndex),t.clipboardData.setData("text/plain",r),t.clipboardData.setData("application/x-latex",r),t.preventDefault()))}var y=null,v=null,x=new mt,b=!1;return"StaticMath"===n.KIND_OF_MQ?(n.addTextareaEventListeners({keydown:function(t){var e,o;null===(o=(e=n.options).overrideKeystroke)||void 0===o||o.call(e,r(t),t)}}),{select:i}):(n.options&&n.options.disableCopyPaste?n.addTextareaEventListeners({keydown:l,keypress:c,keyup:u,focusout:d,copy:function(t){t.preventDefault()},cut:function(t){t.preventDefault()},paste:function(t){x.trigger(),t.preventDefault()},input:m}):n.addTextareaEventListeners({keydown:l,keypress:c,keyup:u,focusout:d,cut:function(t){var e,r=t instanceof ClipboardEvent?t:void 0;r&&(null===(e=n.options)||void 0===e?void 0:e.overrideCut)&&n.options.overrideCut(r)||(g(r),x.listenOnce(function(){n.cut()}))},copy:function(t){var e,r=t instanceof ClipboardEvent?t:void 0;r&&(null===(e=n.options)||void 0===e?void 0:e.overrideCopy)&&n.options.overrideCopy(r)||g(r)},paste:f,input:m}),{select:i})}}(),yt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.exportText=function(){return this.root.foldChildren("",function(t,e){return t+e.text()})},e}(rt),rt.onNotify(function(t,e){if("edit"===e||"replace"===e||void 0===e){var n=t.controller;if(!n)return;if(!n.options.enableDigitGrouping)return;if(!1!==n.blurred)return;n.disableGroupingForSeconds(1)}}),vt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.handleTextareaFocusEditable=function(){var t=e.cursor;e.updateMathspeak(),e.blurred=!1,clearTimeout(e.blurTimeout),U(e.container).addClass("mq-focused"),t.parent||t.insAtRightEnd(e.root),t.selection?(t.selection.domFrag().removeClass("mq-blur"),e.selectionChanged()):t.show(),e.setOverflowClasses()},e.handleTextareaBlurEditable=function(){e.textareaSelectionTimeout&&(clearTimeout(e.textareaSelectionTimeout),e.textareaSelectionTimeout=0),e.disableGroupingForSeconds(0),e.blurred=!0,e.blurTimeout=setTimeout(function(){e.root.postOrder(function(t){t.intentionalBlur()}),e.cursor.clearSelection().endSelection(),e.blur(),e.updateMathspeak({emptyContent:!0}),e.scrollHoriz()}),window.addEventListener("blur",e.handleWindowBlur)},e.handleTextareaFocusStatic=function(){e.cursor.selection||e.cursor.controller.selectAll(),e.blurred=!1},e.handleTextareaBlurStatic=function(){e.cursor.clearSelection(),e.updateMathspeak({emptyContent:!0})},e.handleWindowBlur=function(){clearTimeout(e.blurTimeout),e.cursor.selection&&e.cursor.selection.domFrag().addClass("mq-blur"),e.blurWithoutResettingCursor(),e.updateMathspeak({emptyContent:!0})},e}return __extends(e,t),e.prototype.disableGroupingForSeconds=function(t){var e=this;clearTimeout(this.__disableGroupingTimeout),0===t?this.root.domFrag().removeClass("mq-suppress-grouping"):(this.root.domFrag().addClass("mq-suppress-grouping"),this.__disableGroupingTimeout=setTimeout(function(){e.root.domFrag().removeClass("mq-suppress-grouping")},1e3*t))},e.prototype.blur=function(){this.blurWithoutResettingCursor(),this.options&&this.options.resetCursorOnBlur&&this.cursor.resetToEnd(this)},e.prototype.blurWithoutResettingCursor=function(){this.cursor.hide().parent.blur(this.cursor),U(this.container).removeClass("mq-focused"),window.removeEventListener("blur",this.handleWindowBlur)},e.prototype.addEditableFocusBlurListeners=function(){var t=this,e=t.cursor;this.addTextareaEventListeners({focus:this.handleTextareaFocusEditable,blur:this.handleTextareaBlurEditable}),t.blurred=!0,e.hide().parent.blur(e)},e.prototype.addStaticFocusBlurListeners=function(){this.addTextareaEventListeners({focus:this.handleTextareaFocusStatic,blur:this.handleTextareaBlurStatic})},e}(yt),xt=!1,bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.keystroke=function(t,n,r){var o=r.cursor;switch(t){case"Ctrl-Shift-Backspace":case"Ctrl-Backspace":r.ctrlDeleteDir(Me);break;case"Shift-Backspace":case"Backspace":r.backspace();break;case"Esc":case"Tab":return void r.escapeDir(Ie,t,n);case"Shift-Tab":case"Shift-Esc":return void r.escapeDir(Me,t,n);case"End":r.notify("move").cursor.insAtRightEnd(o.parent),r.aria.queue("end of").queue(o.parent,!0);break;case"Ctrl-End":r.notify("move").cursor.insAtRightEnd(r.root),r.aria.queue("end of").queue(r.ariaLabel).queue(r.root).queue(r.ariaPostLabel);break;case"Shift-End":r.selectToBlockEndInDir(Ie);break;case"Ctrl-Shift-End":r.selectToRootEndInDir(Ie);break;case"Home":r.notify("move").cursor.insAtLeftEnd(o.parent),r.aria.queue("beginning of").queue(o.parent,!0);break;case"Ctrl-Home":r.notify("move").cursor.insAtLeftEnd(r.root),r.aria.queue("beginning of").queue(r.ariaLabel).queue(r.root).queue(r.ariaPostLabel);break;case"Shift-Home":r.selectToBlockEndInDir(Me);break;case"Ctrl-Shift-Home":r.selectToRootEndInDir(Me);break;case"Left":r.moveLeft();break;case"Shift-Left":r.selectLeft();break;case"Ctrl-Left":break;case"Right":r.moveRight();break;case"Shift-Right":r.selectRight();break;case"Ctrl-Right":break;case"Up":r.moveUp();break;case"Down":r.moveDown();break;case"Shift-Up":r.withIncrementalSelection(function(t){if(o[Me])for(;o[Me];)t(Me);else t(Me)});break;case"Shift-Down":r.withIncrementalSelection(function(t){if(o[Ie])for(;o[Ie];)t(Ie);else t(Ie)});break;case"Ctrl-Up":case"Ctrl-Down":break;case"Ctrl-Shift-Del":case"Ctrl-Del":r.ctrlDeleteDir(Ie);break;case"Shift-Del":case"Del":r.deleteForward();break;case"Meta-A":case"Ctrl-A":r.selectAll();break;case"Ctrl-Alt-Up":o.parent.parent&&o.parent.parent instanceof e?r.aria.queue(o.parent.parent):r.aria.queue("nothing above");break;case"Ctrl-Alt-Down":o.parent&&o.parent instanceof e?r.aria.queue(o.parent):r.aria.queue("block is empty");break;case"Ctrl-Alt-Left":o.parent.parent&&o.parent.parent.getEnd(Me)?r.aria.queue(o.parent.parent.getEnd(Me)):r.aria.queue("nothing to the left");break;case"Ctrl-Alt-Right":o.parent.parent&&o.parent.parent.getEnd(Ie)?r.aria.queue(o.parent.parent.getEnd(Ie)):r.aria.queue("nothing to the right");break;case"Ctrl-Alt-Shift-Down":o.selection?r.aria.queue(o.selection.join("mathspeak"," ").trim()+" selected"):r.aria.queue("nothing selected");break;case"Ctrl-Alt-=":case"Ctrl-Alt-Shift-Right":r.ariaPostLabel.length?r.aria.queue(r.ariaPostLabel):r.aria.queue("no answer");break;default:return}r.aria.alert(),null===n||void 0===n||n.preventDefault(),r.scrollHoriz()},e.prototype.moveOutOf=function(t,e,r){n("overridden or never called on this node",!1)},e.prototype.moveTowards=function(t,e,r){n("overridden or never called on this node",!1)},e.prototype.deleteOutOf=function(t,e){n("overridden or never called on this node",!1)},e.prototype.deleteTowards=function(t,e){n("overridden or never called on this node",!1)},e.prototype.unselectInto=function(t,e){n("overridden or never called on this node",!1)},e.prototype.selectOutOf=function(t,e){n("overridden or never called on this node",!1)},e.prototype.selectTowards=function(t,e){n("overridden or never called on this node",!1)},e}(X),rt.onNotify(function(t,e){"move"!==e&&"upDown"!==e||t.show().clearSelection()}),st.leftRightIntoCmdGoes=function(t){if(t&&"up"!==t&&"down"!==t)throw'"up" or "down" required for leftRightIntoCmdGoes option, got "'+t+'"';return t},rt.onNotify(function(t,e){"upDown"!==e&&(t.upDownCache={})}),rt.onNotify(function(t,e){"edit"===e&&t.show().deleteSelection()}),rt.onNotify(function(t,e){"select"!==e&&t.endSelection()}),wt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.keystroke=function(t,e){this.cursor.parent.keystroke(t,e,this.getControllerSelf())},e.prototype.escapeDir=function(t,e,n){r(t);var o=this.cursor;if(o.parent!==this.root&&(null===n||void 0===n||n.preventDefault()),o.parent!==this.root)return o.clearSelection(),o.parent.moveOutOf(t,o),o.controller.aria.alert(),this.notify("move")},e.prototype.moveDir=function(t){var e,n,o;return r(t),e=this.cursor,n=e.options.leftRightIntoCmdGoes,o=e[t],e.selection?e.insDirOf(t,e.selection.getEnd(t)):o?o.moveTowards(t,e,n):e.parent.moveOutOf(t,e,n),this.notify("move")},e.prototype.moveLeft=function(){return this.moveDir(Me)},e.prototype.moveRight=function(){return this.moveDir(Ie)},e.prototype.moveUp=function(){return this.moveUpDown("up")},e.prototype.moveDown=function(){return this.moveUpDown("down")},e.prototype.moveUpDown=function(t){var e,n,r,o,i,s,a=this,l=a.notify("upDown").cursor;return"up"===t?(e="upInto",n="upOutOf"):(e="downInto",n="downOutOf"),r=l[Me],o=l[Ie],i=o&&o[e],s=r&&r[e],i?l.insAtLeftEnd(i):s?l.insAtRightEnd(s):l.parent.bubble(function(t){var e=t[n];if(e&&("function"==typeof e&&(e=e.call(t,l)),e instanceof bt&&l.jumpUpDown(t,e),!0!==e))return!1}),a},e.prototype.deleteDir=function(t){var e,n,o,i,s,a,l,c,u,p;return r(t),e=this.cursor,n=e[t],o=e.parent.parent,i=e.controller,n&&n instanceof bt?n.sides?i.aria.queue(n.parent.chToCmd(n.sides[-t].ch).mathspeak({createdLeftOf:e})):n.blocks||"\\text"===n.parent.ctrlSeq||i.aria.queue(n):o&&o instanceof bt&&(o.sides?i.aria.queue(o.parent.chToCmd(o.sides[t].ch).mathspeak({createdLeftOf:e})):o.blocks&&o.mathspeakTemplate?o.upInto&&o.downInto?i.aria.queue(o.mathspeakTemplate[1]):(s=o.mathspeakTemplate,a=t===Me?s[0]:s[s.length-1],i.aria.queue(a)):i.aria.queue(o)),l=e.selection,this.notify("edit"),l||(c=e[t],c?c.deleteTowards(t,e):e.parent.deleteOutOf(t,e)),u=e[Me],p=e[Ie],u.siblingDeleted&&u.siblingDeleted(e.options,Ie),p.siblingDeleted&&p.siblingDeleted(e.options,Me),e.parent.bubble(function(t){t.reflow()}),this},e.prototype.ctrlDeleteDir=function(t){var e,n,o,i;return r(t),e=this.cursor,!e[t]||e.selection?this.deleteDir(t):(this.notify("edit"),n=t===Me?new Y(e.parent.getEnd(Me),e[Me]):new Y(e[Ie],e.parent.getEnd(Ie)),e.controller.aria.queue(n),n.remove(),e.insAtDirEnd(t,e.parent),o=e[Me],i=e[Ie],o&&o.siblingDeleted(e.options,Ie),i&&i.siblingDeleted(e.options,Me),e.parent.bubble(function(t){t.reflow()}),this)},e.prototype.backspace=function(){return this.deleteDir(Me)},e.prototype.deleteForward=function(){return this.deleteDir(Ie)},e.prototype.startIncrementalSelection=function(){n("Multiple selections can't be simultaneously open",!xt),xt=!0,this.notify("select");var t=this.cursor;t.anticursor||t.startSelection()},e.prototype.selectDirIncremental=function(t){var e,o,i;n("A selection is open",xt),xt=!0,e=this.cursor,o=e.selection,r(t),i=e[t],i?o&&o.getEnd(t)===i&&e.anticursor[-t]!==i?i.unselectInto(t,e):i.selectTowards(t,e):e.parent.selectOutOf(t,e)},e.prototype.finishIncrementalSelection=function(){var t,e;n("A selection is open",xt),t=this.cursor,t.clearSelection(),t.select()||t.show(),e=t.selection,e&&t.controller.aria.clear().queue(e.join("mathspeak"," ").trim()+" selected"),xt=!1},e.prototype.withIncrementalSelection=function(t){var e=this;try{this.startIncrementalSelection();try{t(function(t){return e.selectDirIncremental(t)})}finally{this.finishIncrementalSelection()}}finally{xt=!1}},e.prototype.selectDir=function(t){this.withIncrementalSelection(function(e){return e(t)})},e.prototype.selectLeft=function(){return this.selectDir(Me)},e.prototype.selectRight=function(){return this.selectDir(Ie)},e.prototype.selectAll=function(){this.notify("move");var t=this.cursor;t.insAtRightEnd(this.root),this.withIncrementalSelection(function(e){for(;t[Me];)e(Me)})},e.prototype.selectToBlockEndInDir=function(t){var e=this.cursor;this.withIncrementalSelection(function(n){for(;e[t];)n(t)})},e.prototype.selectToRootEndInDir=function(t){var e=this,n=this.cursor;this.withIncrementalSelection(function(r){for(;n[t]||n.parent!==e.root;)r(t)})},e}(vt),function(t){function e(e){return t.call(this)||this}__extends(e,t)}(bt),Et=function(){function t(t){var e=new It;return t.adopt(e,0,0),e}function e(t){var e,n=t[0]||new It;for(e=1;e<t.length;e+=1)t[e].children().adopt(n,n.getEnd(Ie),0);return n}var n=ft.string,r=ft.regex,o=ft.letter,i=ft.digit,s=ft.any,a=ft.optWhitespace,l=ft.succeed,c=ft.fail,u=o.map(function(t){return new jt(t)}),p=i.map(function(t){return new Pt(t)}),h=r(/^[^${}\\_^]/).map(function(t){return new At(t)}),d=r(/^[^\\a-eg-zA-Z]/).or(n("\\").then(r(/^[a-z]+/i).or(r(/^\s+/).result(" ")).or(s))).then(function(t){var e,n,r=Z[t];return r?r.constructor?(e=r,new e(t).parser()):(n=r,n(t).parser()):c("unknown command: \\"+t)}),f=d.or(u).or(p).or(h),m=n("{").then(function(){return y}).skip(n("}")),g=a.then(m.or(f.map(t))),y=g.many().map(e).skip(a),v=n("[").then(g.then(function(t){return"]"!==t.join("latex")?l(t):c("")}).many().map(e).skip(a)).skip(n("]")),x=y;return x.block=g,x.optBlock=v,x}(),st.maxDepth=function(t){return"number"==typeof t?t:void 0},kt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.cleanLatex=function(t){return t.replace(/(\\[a-z]+) (?![a-z])/gi,"$1")},e.prototype.exportLatex=function(){return this.cleanLatex(this.root.latex())},e.prototype.writeLatex=function(t){var e=this.notify("edit").cursor;return e.parent.writeLatex(e,t),this},e.prototype.prepareCursorForRestoration=function(){return this.cursor.clearSelection().endSelection(),this.notify("move").cursor},e.prototype.restoreLatexSelection=function(t){var e,n,r,o=this,i=this.exportLatexSelection(),s=i.selection,a=s.latex,l=t.latex;l===a&&(t.startIndex===s.startIndex&&t.endIndex===s.endIndex||(0===t.endIndex?this.prepareCursorForRestoration().insAtDirEnd(Me,this.root):t.startIndex===l.length?this.prepareCursorForRestoration().insAtDirEnd(Ie,this.root):(e=b(a,i.ctx.uncleanedLatex,t),n=this.exportLatexSelection(e).ctx.restoreInfo,t.startIndex===t.endIndex?(null===n||void 0===n?void 0:n.cursorL)?this.prepareCursorForRestoration().insRightOf(n.cursorL):(null===n||void 0===n?void 0:n.cursorParent)&&this.prepareCursorForRestoration().insAtLeftEnd(n.cursorParent):(null===n||void 0===n?void 0:n.selectionL)&&n.selectionR&&(this.prepareCursorForRestoration().insRightOf(n.selectionR),r=this.cursor.controller.root,this.withIncrementalSelection(function(t){do{if(t(Me),!o.cursor[Me]&&o.cursor.parent===r)break}while(o.cursor[Ie]!==n.selectionL)})))))},e.prototype.exportLatexSelection=function(t){var e,n,r,o,i,s,a,l,c={uncleanedLatex:"",uncleanedStartIndex:-1,uncleanedEndIndex:-1};return t&&(c.restoreInfo={uncleanedStartIndex:t.uncleanStartIndex,uncleanedEndIndex:t.uncleanEndIndex}),e=this.cursor.selection,e&&this.cursor.anticursor?(c.startSelectionBefore=e.getEnd(Me),c.endSelectionAfter=e.getEnd(Ie)):(n=this.cursor[Me],n?c.startSelectionAfter=n:c.startSelectionBefore=this.cursor.parent,r=this.cursor[Ie],r?c.endSelectionBefore=r:c.endSelectionAfter=this.cursor.parent),this.root.latexRecursive(c),o=c.uncleanedLatex,i=this.cleanLatex(o),s=x(o,i,c),a=s.startIndex,l=s.endIndex,{selection:{latex:i,startIndex:a,endIndex:l},ctx:c}},e.prototype.domNodeToMqNode=function(t){for(var e,n;t;){if(e=X.getNodeOfElement(t)){if(!(n=w(e))||n===this.root)return e;t=n.controller.container}t=t.parentElement}},e.prototype.domNodeToSpan=function(t){var e,n,r,o,i,s,a,l={uncleanedLatex:"",uncleanedStartIndex:-1,uncleanedEndIndex:-1},c=this.domNodeToMqNode(t);if(c)return c instanceof It?(l.startSelectionBefore=c,l.endSelectionAfter=c):(e=c[Me],e?l.startSelectionAfter=e:l.startSelectionBefore=c.parent,n=c[Ie],n?l.endSelectionBefore=n:l.endSelectionAfter=c.parent),this.root.latexRecursive(l),r=l.uncleanedLatex,o=this.cleanLatex(r),i=x(r,o,l),s=i.startIndex,a=i.endIndex,{latex:o,startIndex:s,endIndex:a}},e.prototype.classifyLatexForEfficientUpdate=function(t){if("string"==typeof t){var e=t.match(/-?[0-9.]+$/g);return e&&1===e.length?{latex:t,prefix:t.substr(0,t.length-e[0].length),digits:e[0]}:void 0}},e.prototype.updateLatexMathEfficiently=function(t,e){var n,r,o,i,s,a,l,c,u,p,h,d,f,m,g,y,v,x,b,w,E,k,L,S,_,q=this.root,C=this.classifyLatexForEfficientUpdate(t);if(!C)return!1;if(!(s=this.classifyLatexForEfficientUpdate(e))||s.prefix!==C.prefix)return!1;for(a=s.digits,l=C.digits,c=!1,u=!1,"-"===a[0]&&(c=!0,a=a.substr(1)),"-"===l[0]&&(u=!0,l=l.substr(1)),p=this.root.getEnd(Ie),h=[],d=a.length-1;d>=0;d--){if(!p||p.ctrlSeq!==a[d])return!1;if(p.parent!==q)return!1;h.unshift(p),p=p[Me]}if(c&&!u){if(!(f=p))return!1;if("-"!==f.ctrlSeq)return!1;if(f[Ie]!==h[0])return!1;if(f.parent!==q)return!1;if((m=f[Me])&&m.parent!==q)return!1;h[0][Me]=f[Me],q.getEnd(Me)===f&&q.setEnds((n={},n[Me]=h[0],n[Ie]=q.getEnd(Ie),n)),m&&(m[Ie]=h[0]),f.domFrag().remove()}for(!c&&u&&(g=new Xt("-"),y=document.createElement("span"),y.textContent="−",g.setDOM(y),v=h[0][Me],v&&(v[Ie]=g),q.getEnd(Me)===h[0]&&q.setEnds((r={},r[Me]=g,r[Ie]=q.getEnd(Ie),r)),g.parent=q,g[Me]=h[0][Me],g[Ie]=h[0],h[0][Me]=g,g.contactWeld(this.cursor),g.domFrag().insertBefore(h[0].domFrag())),x=Math.min(a.length,l.length),d=0;d<x;d++)b=l[d],p=h[d],p.ctrlSeq!==b&&(p.ctrlSeq=b,p.domFrag().oneElement().textContent=b,p.mathspeakName=b);if(a.length>l.length)for(p=h[l.length-1],q.setEnds((o={},o[Me]=q.getEnd(Me),o[Ie]=p,o)),p[Ie]=0,d=a.length-1;d>=x;d--)h[d].domFrag().remove();if(l.length>a.length){for(w=document.createDocumentFragment(),d=x;d<l.length;d++)E=document.createElement("span"),E.className="mq-digit",E.textContent=l[d],k=new Pt(l[d]),k.parent=q,k.setDOM(E),w.appendChild(E),k[Me]=q.getEnd(Ie),k[Ie]=0,L=k[Me],L[Ie]=k,q.setEnds((i={},i[Me]=q.getEnd(Me),i[Ie]=k,i));q.domFrag().oneElement().appendChild(w)}return(S=this.exportLatex())!==t?(console.warn("tried updating latex efficiently but did not work. Attempted: "+t+" but wrote: "+S),!1):(_=q.getEnd(Ie),_&&_.fixDigitGrouping(this.cursor.options),!0)},e.prototype.renderLatexMathFromScratch=function(t){var e,n,r=this.root,o=this.cursor,i=ft.all,s=ft.eof,a=Et.skip(s).or(i.result(!1)).parse(t);r.setEnds((e={},e[Me]=0,e[Ie]=0,e)),a&&a.children().adopt(r,0,0),a?(n=r.domFrag(),n.children().remove(),n.oneElement().appendChild(a.html()),r.finalizeInsert(o.options,o)):r.domFrag().empty()},e.prototype.renderLatexMath=function(t){var e,n=this.cursor,r=this.root;this.notify("replace"),n.clearSelection(),e=this.exportLatex(),r.getEnd(Me)&&r.getEnd(Ie)&&e===t||(this.updateLatexMathEfficiently(t,e)||this.renderLatexMathFromScratch(t),this.updateMathspeak()),n.insAtRightEnd(r)},e.prototype.renderLatexText=function(t){var e,n,r,o,i,s,a,l,c,u,p,h=this.root,d=this.cursor;if(h.domFrag().children().slice(1).remove(),h.setEnds((e={},e[Me]=0,e[Ie]=0,e)),delete d.selection,d.show().insAtRightEnd(h),n=ft.regex,r=ft.string,o=ft.eof,i=ft.all,s=r("$").then(Et).skip(r("$").or(o)).map(function(t){var e,n=new RootMathCommand(d);return n.createBlocks(),e=n.getEnd(Me),t.children().adopt(e,0,0),n}),a=r("\\$").result("$"),l=a.or(n(/^[^$]/)).map(function(t){return new At(t)}),c=s.or(l).many(),u=c.skip(o).or(i.result(!1)).parse(t)){for(p=0;p<u.length;p+=1)u[p].adopt(h,h.getEnd(Ie),0);U(h.html()).appendTo(h.domFrag().oneElement()),h.finalizeInsert(d.options,d)}},e}(wt),Lt=function(t){return!1},at.prototype.ignoreNextMousedown=Lt,function(){rt.onNotify(function(t,e){"edit"!==e&&"replace"!==e||St&&St.cursor===t&&St.cb()})}(),_t=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.handleMouseDown=function(e){function r(t){c=t.target}function o(t){m.anticursor||m.startSelection(),f.seek(c,t.clientX,t.clientY).cursor.select(),m.selection&&m.controller.aria.clear().queue(m.selection.join("mathspeak")+" selected").alert(),c=null}function s(){null===p||void 0===p||p.removeEventListener("mousemove",r),null===d||void 0===d||d.removeEventListener("mousemove",o),null===d||void 0===d||d.removeEventListener("mouseup",l),St=void 0,f.isMouseSelecting=!1}function a(){f.editable&&(m.show(),m.controller.aria.queue(m.parent).alert())}function l(){m.blink=g,m.selection||a(),s()}var c,u,p=i(e.target,".mq-root-block"),h=p&&X.getNodeOfElement(p)||X.getNodeOfElement(n.root.domFrag().oneElement()),d=h.domFrag().firstNode().ownerDocument,f=h.controller,m=f.cursor,g=m.blink,y=f.getTextarea();e.preventDefault(),e.target.unselectable=!0,m.options.ignoreNextMousedown(e)||i(e.target,".mq-ignore-mousedown")||(c=null,St={cursor:m,cb:function(){u=!0,m.blink=g,m.clearSelection(),a(),s()}},f.blurred&&(n.editable&&y.focus(),u)||(m.blink=t,f.isMouseSelecting=!0,f.seek(e.target,e.clientX,e.clientY).cursor.startSelection(),null===p||void 0===p||p.addEventListener("mousemove",r),null===d||void 0===d||d.addEventListener("mousemove",o),null===d||void 0===d||d.addEventListener("mouseup",l)))},n}return __extends(n,e),n.prototype.addMouseEventListener=function(){this.container.addEventListener("mousedown",this.handleMouseDown)},n.prototype.removeMouseEventListener=function(){this.container.removeEventListener("mousedown",this.handleMouseDown)},n.prototype.seek=function(t,e,n){var r=this.notify("select").cursor,o=this.domNodeToMqNode(t);return o||(o=this.root),r.clearSelection().show(),o.seek(e,r),this.scrollHoriz(),this},n}(kt),qt=function(t){function e(){
12
+ return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setOverflowClasses=function(){var t,e,n,r=this.root.domFrag().oneElement(),o=!1,i=!1;this.blurred||(t=s(r).width,e=r.scrollWidth,n=r.scrollLeft,o=e>t+n,i=n>0),r.classList.contains("mq-editing-overflow-right")!==o&&r.classList.toggle("mq-editing-overflow-right"),r.classList.contains("mq-editing-overflow-left")!==i&&r.classList.toggle("mq-editing-overflow-left")},e.prototype.scrollHoriz=function(){var t,e,n,r,o,i,a,l,c,u,p=this,h=this.cursor,d=h.selection,f=s(this.root.domFrag().oneElement());if(h.domFrag().isEmpty()&&!d)return this.cancelScrollHoriz&&(this.cancelScrollHoriz(),this.cancelScrollHoriz=void 0),t=this.root.domFrag().oneElement(),e=t.scrollLeft,void W(this.getScrollAnimationDuration(),function(n,r,o){n>=1?(p.cancelScrollHoriz=void 0,t.scrollLeft=0,p.setOverflowClasses()):(p.cancelScrollHoriz=o,r(),t.scrollLeft=Math.round((1-n)*e))});if(d)if(o=s(d.domFrag().oneElement()),i=o.left-(f.left+20),a=o.right-(f.right-20),d.getEnd(Me)===h[Ie])if(i<0)r=i;else{if(!(a>0))return;r=o.left-a<f.left+20?i:a}else if(a>0)r=a;else{if(!(i<0))return;r=o.right-i>f.right-20?a:i}else if((n=s(h.domFrag().oneElement()).left)>f.right-20)r=n-(f.right-20);else{if(!(n<f.left+20))return;r=n-(f.left+20)}l=this.root.domFrag().oneElement(),r<0&&0===l.scrollLeft||r>0&&l.scrollWidth<=l.scrollLeft+f.width||(this.cancelScrollHoriz&&(this.cancelScrollHoriz(),this.cancelScrollHoriz=void 0),c=this.root.domFrag().oneElement(),u=c.scrollLeft,W(this.getScrollAnimationDuration(),function(t,e,n){t>=1?(p.cancelScrollHoriz=void 0,c.scrollLeft=Math.round(u+r),p.setOverflowClasses()):(p.cancelScrollHoriz=n,e(),c.scrollLeft=Math.round(u+t*r))}))},e.prototype.getScrollAnimationDuration=function(){var t;return null!==(t=this.options.scrollAnimationDuration)&&void 0!==t?t:100},e}(_t),at.prototype.substituteTextarea=function(){return Re("textarea",{autocapitalize:"off",autocomplete:"off",autocorrect:"off",spellcheck:!1,"x-palm-disable-ste-all":!0})},at.prototype.substituteKeyboardEvents=k,Ct=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.selectFn=t,n}return __extends(n,e),n.prototype.createTextarea=function(){var t,e,n;if(this.textareaSpan=Re("span",{class:"mq-textarea"}),t=this.options.substituteTextarea(),!t.nodeType)throw"substituteTextarea() must return a DOM element, got "+t;this.textarea=U(t).appendTo(this.textareaSpan).oneElement(),this.mathspeakSpan||(this.mathspeakId=E(),this.mathspeakSpan=Re("span",{class:"mq-mathspeak",id:this.mathspeakId}),U(this.textareaSpan).prepend(U(this.mathspeakSpan))),this.mathspeakId&&(null===t||void 0===t||t.setAttribute("aria-labelledby",this.mathspeakId)),e=this,e.cursor.selectionChanged=function(){e.selectionChanged()},n=void 0!==this.options.tabindex?this.options.tabindex:"StaticMath"===this.KIND_OF_MQ?-1:0,this.setTabindex(n)},n.prototype.setTabindex=function(t){var e,n,r,o,i;t!==this.previousTabindex&&this.textarea&&(this.previousTabindex=t,null===(e=this.textarea)||void 0===e||e.setAttribute("tabindex",""+t),t<0&&"StaticMath"===this.KIND_OF_MQ?null===(n=this.textarea)||void 0===n||n.setAttribute("aria-hidden","true"):null===(r=this.textarea)||void 0===r||r.removeAttribute("aria-hidden"),t>=0?null===(o=this.mathspeakSpan)||void 0===o||o.setAttribute("aria-hidden","true"):null===(i=this.mathspeakSpan)||void 0===i||i.removeAttribute("aria-hidden"))},n.prototype.selectionChanged=function(){var t=this;t.textareaSelectionTimeout||(t.textareaSelectionTimeout=setTimeout(function(){t.setTextareaSelection()}))},n.prototype.setTextareaSelection=function(){this.textareaSelectionTimeout=0;var t="";this.cursor.selection&&(t=this.cleanLatex(this.cursor.selection.join("latex")),this.options.statelessClipboard&&(t="$"+t+"$")),this.selectFn(t)},n.prototype.staticMathTextareaEvents=function(){var t,e,n,r=this;this.removeTextareaEventListener("cut"),this.removeTextareaEventListener("paste"),r.options.disableCopyPaste?this.removeTextareaEventListener("copy"):this.addTextareaEventListeners({copy:function(){r.setTextareaSelection()}}),this.addStaticFocusBlurListeners(),t=this.getTextarea(),e=gt(t,this).select,this.selectFn=e,n=this.getTextareaSpan(),U(this.container).prepend(U(n))},n.prototype.editablesTextareaEvents=function(){var t,e,n,r=this,o=r.getTextarea(),i=r.getTextareaSpan();this.options.version<3?(t=this.options.assertJquery(),e=this.options.substituteKeyboardEvents(t(o),this),this.selectFn=function(t){e.select(t)}):(n=gt(o,this).select,this.selectFn=n),U(this.container).prepend(U(i)),this.addEditableFocusBlurListeners(),this.updateMathspeak()},n.prototype.unbindEditablesEvents=function(){var t=this,e=t.getTextarea(),n=t.getTextareaSpan();this.selectFn=function(t){e instanceof HTMLTextAreaElement&&(e.value=t,t&&e.select())},U(n).remove(),this.removeTextareaEventListener("focus"),this.removeTextareaEventListener("blur"),t.blurred=!0,this.removeTextareaEventListener("cut"),this.removeTextareaEventListener("paste")},n.prototype.typedText=function(t){if("\n"===t)return this.handle("enter");var e=this.notify(void 0).cursor;e.parent.write(e,t),this.scrollHoriz()},n.prototype.cut=function(){var t=this,e=t.cursor;e.selection&&setTimeout(function(){t.notify("edit"),e.parent.bubble(function(t){t.reflow()}),t.options&&t.options.onCut&&t.options.onCut()})},n.prototype.copy=function(){this.setTextareaSelection()},n.prototype.paste=function(t){this.options.statelessClipboard&&(t="$"===t.slice(0,1)&&"$"===t.slice(-1)?t.slice(1,-1):"\\text{"+t+"}"),this.writeLatex(t).cursor.show(),this.scrollHoriz(),this.options&&this.options.onPaste&&this.options.onPaste()},n.prototype.setupStaticField=function(){this.updateMathspeak(),this.blurred=!0,this.cursor.hide().parent.blur(this.cursor)},n.prototype.updateMathspeak=function(t){var e=this,n=e.getAriaLabel(),r=/[A-Za-z0-9]$/.test(n)?n+":":n,o=e.root.mathspeak().trim(),i=!!(null===t||void 0===t?void 0:t.emptyContent);this.aria.clear({emptyContent:i}),e.mathspeakSpan&&(e.mathspeakSpan.textContent=(r+" "+o+" "+e.ariaPostLabel).trim())},n}(qt),Ot=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.finalizeInsert=function(t,e){var n,r,o=this;o.postOrder(function(e){e.finalizeTree(t)}),o.postOrder(function(t){t.contactWeld(e)}),o.postOrder(function(t){t.blur(e)}),o.postOrder(function(t){t.reflow()}),n=o[Ie],r=o[Me],n&&n.siblingCreated(t,Me),r&&r.siblingCreated(t,Ie),o.bubble(function(t){t.reflow()})},e.prototype.prepareInsertionAt=function(t){var e,n=t.options.maxDepth;if(void 0!==n){if((e=t.depth())>n)return!1;this.removeNodesDeeperThan(n-e)}return!0},e.prototype.removeNodesDeeperThan=function(t){for(var e,n,r=0,o=[[this,r]];e=o.shift();)n=e,n[0].children().each(function(e){var i=e instanceof It?1:0;r=n[1]+i,r<=t?o.push([e,r]):(i?e.children():e).remove()})},e}(bt),Tt=function(){function t(t,e){this.childCount=t,this.render=e}return t}(),Ft=function(t){function e(e,n,r){var o=t.call(this)||this;return o.textTemplate=[""],o.mathspeakTemplate=[""],o.setCtrlSeqHtmlAndText(e,n,r),o}return __extends(e,t),e.prototype.setEnds=function(t){n("MathCommand ends are never empty",t[Me]&&t[Ie]),this.ends=t},e.prototype.getEnd=function(t){return this.ends[t]},e.prototype.setCtrlSeqHtmlAndText=function(t,e,n){this.ctrlSeq||(this.ctrlSeq=t),e&&(this.domView=e),n&&(this.textTemplate=n)},e.prototype.replaces=function(t){t.disown(),this.replacedFragment=t},e.prototype.isEmpty=function(){return this.foldChildren(!0,function(t,e){return t&&e.isEmpty()})},e.prototype.parser=function(){var t=this;return Et.block.times(this.numBlocks()).map(function(e){t.blocks=e;for(var n=0;n<e.length;n+=1)e[n].adopt(t,t.getEnd(Ie),0);return t})},e.prototype.createLeftOf=function(e){var n,r=this,o=r.replacedFragment;r.createBlocks(),t.prototype.createLeftOf.call(this,e),o&&(n=r.getEnd(Me),o.adopt(n,0,0),o.domFrag().appendTo(n.domFrag().oneElement()),r.placeCursor(e),r.prepareInsertionAt(e)),r.finalizeInsert(e.options,e),r.placeCursor(e)},e.prototype.createBlocks=function(){var t,e,n=this,r=n.numBlocks(),o=n.blocks=Array(r);for(t=0;t<r;t+=1)e=o[t]=new It,e.adopt(n,n.getEnd(Ie),0)},e.prototype.placeCursor=function(t){t.insAtRightEnd(this.foldChildren(this.getEnd(Me),function(t,e){return t.isEmpty()?t:e}))},e.prototype.moveTowards=function(t,e,n){var r,o;"up"===n?r=this.upInto:"down"===n&&(r=this.downInto),o=r||this.getEnd(-t),e.insAtDirEnd(-t,o),e.controller.aria.queueDirEndOf(-t).queue(e.parent,!0)},e.prototype.deleteTowards=function(t,e){this.isEmpty()?e[t]=this.remove()[t]:this.moveTowards(t,e)},e.prototype.selectTowards=function(t,e){e[-t]=this,e[t]=this[t]},e.prototype.selectChildren=function(){return new nt(this,this)},e.prototype.unselectInto=function(t,e){var n=e.anticursor,r=n.ancestors[this.id];e.insAtDirEnd(-t,r)},e.prototype.seek=function(t,e){function n(t){var e,n=t.domFrag().oneElement(),r=s(n).left,o=r+n.offsetWidth;return e={},e[Me]=r,e[Ie]=o,e}var r,o=this,i=n(o);return t<i[Me]?e.insLeftOf(o):t>i[Ie]?e.insRightOf(o):(r=i[Me],void o.eachChild(function(s){var a=n(s);return t<a[Me]?(t-r<a[Me]-t?s[Me]?e.insAtRightEnd(s[Me]):e.insLeftOf(o):e.insAtLeftEnd(s),!1):t>a[Ie]?void(s[Ie]?r=a[Ie]:i[Ie]-t<t-a[Ie]?e.insRightOf(o):e.insAtRightEnd(s)):(s.seek(t,e),!1)}))},e.prototype.numBlocks=function(){return this.domView.childCount},e.prototype.html=function(){var t,e,r=this.blocks;return n("domView is defined",this.domView),t=this.domView,e=t.render(r||[]),this.setDOM(e),X.linkElementByCmdNode(e,this),e},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+=this.ctrlSeq||"",this.eachChild(function(e){var n,r;t.uncleanedLatex+="{",n=t.uncleanedLatex.length,e.latexRecursive(t),r=t.uncleanedLatex.length,n===r&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}"}),this.checkCursorContextClose(t)},e.prototype.text=function(){var t=this,e=0;return t.foldChildren(t.textTemplate[e],function(n,r){e+=1;var o=r.text();return n&&"("===t.textTemplate[e]&&"("===o[0]&&")"===o.slice(-1)?n+o.slice(1,-1)+t.textTemplate[e]:n+o+(t.textTemplate[e]||"")})},e.prototype.mathspeak=function(){var t=this,e=0;return t.foldChildren(t.mathspeakTemplate[e]||"Start"+t.ctrlSeq+" ",function(n,r){return e+=1,n+" "+r.mathspeak()+" "+(t.mathspeakTemplate[e]+" "||"End"+t.ctrlSeq+" ")})},e}(Ot),Dt=function(t){function e(e,n,r,o){var i=t.call(this)||this;return i.setCtrlSeqHtmlTextAndMathspeak(e,n?new Tt(0,function(){return n.cloneNode(!0)}):void 0,r,o),i}return __extends(e,t),e.prototype.setCtrlSeqHtmlTextAndMathspeak=function(e,n,r,o){!r&&e&&(r=e.replace(/^\\/,"")),this.mathspeakName=o||r,t.prototype.setCtrlSeqHtmlAndText.call(this,e,n,[r||""])},e.prototype.parser=function(){return ft.succeed(this)},e.prototype.numBlocks=function(){return 0},e.prototype.replaces=function(t){t.remove()},e.prototype.createBlocks=function(){},e.prototype.moveTowards=function(t,e){e.domFrag().insDirOf(t,this.domFrag()),e[-t]=this,e[t]=this[t],e.controller.aria.queue(this)},e.prototype.deleteTowards=function(t,e){e[t]=this.remove()[t]},e.prototype.seek=function(t,e){var n=this.domFrag().oneElement();return t-s(n).left<n.offsetWidth/2?e.insLeftOf(this):e.insRightOf(this),e},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+=this.ctrlSeq||"",this.checkCursorContextClose(t)},e.prototype.text=function(){return this.textTemplate.join("")},e.prototype.mathspeak=function(t){return this.mathspeakName||""},e.prototype.placeCursor=function(){},e.prototype.isEmpty=function(){return!0},e}(Ft),At=function(t){function e(e,n,r){return t.call(this,e,Re("span",{},[n||Re.text(e)]),void 0,r)||this}return __extends(e,t),e}(Dt),Mt=function(t){function e(e,n,r,o,i){return i?t.call(this,e,Re("span",{},[n||Re.text(e||"")]),void 0,o)||this:t.call(this,e,Re("span",{class:"mq-binary-operator"},n?[n]:[]),r,o)||this}return __extends(e,t),e.prototype.isBinaryOperator=function(){return!0},e}(Dt),It=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ariaLabel="block",e}return __extends(e,t),e.prototype.join=function(t){return this.foldChildren("",function(e,n){return e+n[t]()})},e.prototype.html=function(){var t=document.createDocumentFragment();return this.eachChild(function(e){var n=e.html();t.appendChild(n)}),t},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),this.eachChild(function(e){return e.latexRecursive(t)}),this.checkCursorContextClose(t)},e.prototype.text=function(){var t=this.getEnd(Me);return t===this.getEnd(Ie)&&0!==t?t.text():this.join("text")},e.prototype.mathspeak=function(){var t,e,n="",r={};return this.controller&&(r=this.controller.options.autoOperatorNames),t=this.foldChildren([],function(t,e){var o,i,s;return e.isPartOfOperator?n+=e.mathspeak():(""!==n&&(r._maxLength>0&&"string"==typeof(o=r[n.toLowerCase()])&&(n=o),t.push(n+" "),n=""),i=e.mathspeak(),s=e.ctrlSeq,!isNaN(s)||"."===s||e.parent&&e.parent.parent&&e.parent.parent.isTextBlock()||(i=" "+i+" "),t.push(i)),t}),""!==n&&(r._maxLength>0&&"string"==typeof(e=r[n.toLowerCase()])&&(n=e),t.push(n+" "),n=""),t.join("").replace(/ +(?= )/g,"").replace(/(\.)([0-9]+)/g,function(t,e,n){return e+n.split("").join(" ").trim()})},e.prototype.keystroke=function(e,n,r){return!r.options.spaceBehavesLikeTab||"Spacebar"!==e&&"Shift-Spacebar"!==e?t.prototype.keystroke.call(this,e,n,r):(null===n||void 0===n||n.preventDefault(),void r.escapeDir("Shift-Spacebar"===e?Me:Ie,e,n))},e.prototype.moveOutOf=function(t,e,n){var r,o;"up"===n?r=this.parent.upInto:"down"===n&&(r=this.parent.downInto),!r&&this[t]?(o=-t,e.insAtDirEnd(o,this[t]),e.controller.aria.queueDirEndOf(o).queue(e.parent,!0)):(e.insDirOf(t,this.parent),e.controller.aria.queueDirOf(t).queue(this.parent))},e.prototype.selectOutOf=function(t,e){e.insDirOf(t,this.parent)},e.prototype.deleteOutOf=function(t,e){e.unwrapGramp()},e.prototype.seek=function(t,e){var n,r,o=this.getEnd(Ie);if(!o)return e.insAtRightEnd(this);if(n=o.domFrag().oneElement(),s(n).left+n.offsetWidth<t)return e.insAtRightEnd(this);if(r=this.getEnd(Me),t<s(r.domFrag().oneElement()).left)return e.insAtLeftEnd(this);for(;t<s(o.domFrag().oneElement()).left;)o=o[Me];return o.seek(t,e)},e.prototype.chToCmd=function(t,e){var n;return t.match(/^[a-eg-zA-Z]$/)?new jt(t):/^\d$/.test(t)?new Pt(t):e&&e.typingSlashWritesDivisionSymbol&&"/"===t?Z["÷"](t):e&&e.typingAsteriskWritesTimesSymbol&&"*"===t?Z["×"](t):e&&e.typingPercentWritesPercentOf&&"%"===t?Z.percentof(t):(n=J[t]||Z[t])?n.constructor?new n(t):n(t):new At(t)},e.prototype.write=function(t,e){var n=this.chToCmd(e,t.options);t.selection&&n.replaces(t.replaceSelection()),t.isTooDeep()||(n.createLeftOf(t.show()),"/"===e?t.controller.aria.alert("over"):t.controller.aria.alert(n.mathspeak({createdLeftOf:t})))},e.prototype.writeLatex=function(t,e){var n,r,o,i,s=ft.all,a=ft.eof,l=Et.skip(a).or(s.result(!1)).parse(e);l&&!l.isEmpty()&&l.prepareInsertionAt(t)&&(l.children().adopt(t.parent,t[Me],t[Ie]),U(l.html()).insertBefore(t.domFrag()),t[Me]=l.getEnd(Ie),l.finalizeInsert(t.options,t),n=l.getEnd(Ie),r=l.getEnd(Me),o=n[Ie],i=r[Me],o&&o.siblingCreated(t.options,Me),i&&i.siblingCreated(t.options,Ie),t.parent.bubble(function(t){t.reflow()}))},e.prototype.focus=function(){return this.domFrag().addClass("mq-hasCursor"),this.domFrag().removeClass("mq-empty"),this},e.prototype.blur=function(t){return this.domFrag().removeClass("mq-hasCursor"),this.isEmpty()&&(this.domFrag().addClass("mq-empty"),t&&this.isQuietEmptyDelimiter(t.options.quietEmptyDelimiters)&&this.domFrag().addClass("mq-quiet-delimiter")),this},e}(Ot),at.prototype.mouseEvents=!0,ot.StaticMath=function(t){var e;return e=function(e){function n(n){var r=e.call(this,n)||this,o=r.innerFields=[];return r.__controller.root.postOrder(function(e){e.registerInnerField(o,t.InnerMathField)}),r}return __extends(n,e),n.prototype.__mathquillify=function(t,n){return this.config(t),e.prototype.mathquillify.call(this,"mq-math-mode"),this.__controller.setupStaticField(),this.__options.mouseEvents&&this.__controller.addMouseEventListener(),this.__controller.staticMathTextareaEvents(),this},n.prototype.latex=function(n){var r,o=e.prototype.latex.apply(this,arguments);return arguments.length>0&&(r=this.innerFields=[],this.__controller.root.postOrder(function(e){e.registerInnerField(r,t.InnerMathField)}),this.__controller.updateMathspeak()),o},n.prototype.setAriaLabel=function(t){return this.__controller.setAriaLabel(t),this},n.prototype.getAriaLabel=function(){return this.__controller.getAriaLabel()},n}(t.AbstractMathQuill),e.RootBlock=It,e},Nt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(It),y(Nt.prototype),ot.MathField=function(e){var n;return n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.__mathquillify=function(n,r){return this.config(n),r>1&&(this.__controller.root.reflow=t),e.prototype.mathquillify.call(this,"mq-editable-field mq-math-mode"),delete this.__controller.root.reflow,this},n}(e.EditableField),n.RootBlock=Nt,n},ot.InnerMathField=function(t){return n("MathField class is defined",t.MathField),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.makeStatic=function(){this.__controller.editable=!1,this.__controller.root.blur(),this.__controller.unbindEditablesEvents(),U(this.__controller.container).removeClass("mq-editable-field")},e.prototype.makeEditable=function(){this.__controller.editable=!0,this.__controller.editablesTextareaEvents(),this.__controller.cursor.insAtRightEnd(this.__controller.root),U(this.__controller.container).addClass("mq-editable-field")},e}(t.MathField)},Bt="\\ ",Rt=".",zt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.finalizeTree=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingDeleted=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingCreated=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.sharedSiblingMethod=function(t,n){n!==Me&&this[Ie]instanceof e||this.fixDigitGrouping(t)},e.prototype.fixDigitGrouping=function(t){var n,r;if(t.enableDigitGrouping){n=this,r=n;do{if(/^[0-9]$/.test(r.ctrlSeq))n=r;else if(r.ctrlSeq===Bt)n=r;else{if(r.ctrlSeq!==Rt)break;n=r}}while(r=n[Me]);e.fixDigitGroupingFromLeft(t,n)}},e.fixDigitGroupingFromLeft=function(t,r){for(var o,i,s,a,l,c,u,p,h;r&&r.ctrlSeq===Bt;){if(!r[Ie])return;r=r[Ie]}if(r instanceof e){o=r,n("node",o),i=r,s=0,a=0,l=[];do{if(/^[0-9]$/.test(o.ctrlSeq))i=o,a=0;else if(o.ctrlSeq===Bt)i=o,s+=1,a=0;else{if(!(o.ctrlSeq===Rt&&o instanceof e))break;i=o,l.push(o),t.tripleDotsAreEllipsis&&(a+=1)}if(3==a)break}while(o=i[Ie]);if(3!==a||(c=l.pop(),u=l.pop(),p=l.pop(),c[Ie]instanceof e&&e.fixDigitGroupingFromLeft(t,c[Ie]),c.setGroupingClass("mq-ellipsis-end"),u.setGroupingClass("mq-ellipsis-middle"),p.setGroupingClass("mq-ellipsis-start"),i=p[Me],r!==p)){for(;i!==r&&i&&i.ctrlSeq===Bt;)i=i[Me],s-=1;r===i&&r&&r.ctrlSeq===Bt||(h=s>0||l.length>1,h?e.removeGroupingBetween(r,i):l[0]?(l[0]!==r&&e.addGroupingBetween(l[0][Me],r),l[0]!==i&&e.removeGroupingBetween(l[0],i)):e.addGroupingBetween(i,r))}}},e.removeGroupingBetween=function(t,n){var r=t;do{if(r instanceof e&&r.setGroupingClass(void 0),!r||r===n)break}while(r=r[Ie])},e.addGroupingBetween=function(t,r){for(var o,i,s=t,a=0,l=0;s&&(l+=1,n("digit",s instanceof e),s!==r);)s=s[Me];for(o=l%3,0===o&&(o=3),s=t;s&&(a+=1,i=void 0,l>=4&&(a===l?i="mq-group-leading-"+o:a%3==0&&a!==l&&(i="mq-group-start"),i||(i="mq-group-other")),s instanceof e&&s.setGroupingClass(i),s!==r);)s=s[Me]},e.prototype.setGroupingClass=function(t){this._groupingClass!==t&&(this._groupingClass&&this.domFrag().removeClass(this._groupingClass),t&&this.domFrag().addClass(t),this._groupingClass=t)},e}(Dt),Pt=function(t){function e(e,n){return t.call(this,e,Re("span",{class:"mq-digit"},[Re.text(e)]),void 0,n)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n=e[Me],r=n&&n[Me],o=e.parent.parent instanceof ue?e.parent.parent.sub:void 0;e.options.autoSubscriptNumerals&&e.parent!==o&&(n instanceof Ht&&!1!==n.isItalic||n instanceof ue&&r instanceof Ht&&!1!==r.isItalic)?(new ue("sub").createLeftOf(e),t.prototype.createLeftOf.call(this,e),e.insRightOf(e.parent.parent)):t.prototype.createLeftOf.call(this,e)},e.prototype.mathspeak=function(e){var n,r,o,i;return e&&e.createdLeftOf&&(n=e.createdLeftOf,r=n[Me],o=r&&r[Me],i=n.parent.parent instanceof ue?n.parent.parent.sub:void 0,n.options.autoSubscriptNumerals&&n.parent!==i&&(r instanceof Ht&&!1!==r.isItalic||n[Me]instanceof ue&&o instanceof Ht&&!1!==o.isItalic))?"Subscript "+t.prototype.mathspeak.call(this)+" Baseline":t.prototype.mathspeak.call(this)},e}(zt),Ht=function(t){function e(e,n){return t.call(this,e,Re("var",{},[n||Re.text(e)]))||this}return __extends(e,t),e.prototype.text=function(){var t=this.ctrlSeq||"";return this.isPartOfOperator?"\\"==t[0]?t=t.slice(1,t.length):" "==t[t.length-1]&&(t=t.slice(0,-1)):(!this[Me]||this[Me]instanceof e||this[Me]instanceof Mt||"\\ "===this[Me].ctrlSeq||(t="*"+t),!this[Ie]||this[Ie]instanceof Mt||this[Ie]instanceof ue||(t+="*")),t},e.prototype.mathspeak=function(){var e=this.ctrlSeq||"";return this.isPartOfOperator||e.length>1||this.parent&&this.parent.parent&&this.parent.parent.isTextBlock()?t.prototype.mathspeak.call(this):'"'+e+'"'},e}(Dt),at.prototype.autoCommands={_maxLength:0},st.autoCommands=function(t){var e,n,r,o,i;if("string"!=typeof t||!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},r=0,o=0;o<e.length;o+=1){if(i=e[o],i.length<2)throw'autocommand "'+i+'" not minimum length of 2';if(Z[i]===Wt)throw'"'+i+'" is a built-in operator name';n[i]=1,r=Be(r,i.length)}return n._maxLength=r,n},at.prototype.quietEmptyDelimiters={},st.quietEmptyDelimiters=function(t){var e,n,r,o;for(void 0===t&&(t=""),e=t.split(" "),n={},r=0;r<e.length;r+=1)o=e[r],n[o]=1;return n},at.prototype.autoParenthesizedFunctions={_maxLength:0},st.autoParenthesizedFunctions=function(t){var e,n,r,o,i;if("string"!=typeof t||!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},r=0,o=0;o<e.length;o+=1){if(i=e[o],i.length<2)throw'autocommand "'+i+'" not minimum length of 2';n[i]=1,r=Be(r,i.length)}return n._maxLength=r,n},jt=function(t){function e(e){var n=t.call(this,e)||this;return n.letter=e,n}return __extends(e,t),e.prototype.checkAutoCmds=function(t){var e,n,r,o,i,s,a,l;if(!this.shouldIgnoreSubstitutionInSimpleSubscript(t.options)&&(n=t.options.autoCommands,(r=n._maxLength||0)>0))for(o=null!==(e=q(this,r))&&void 0!==e?e:"";o.length;){if(n.hasOwnProperty(o)){for(i=this,s=1;i&&s<o.length;s+=1,i=i[Me]);return new Y(i,this).remove(),t[Me]=i[Me],a=Z[o],l=f(a)?new a(o):a(o),l.createLeftOf(t)}o=o.slice(1)}},e.prototype.autoParenthesize=function(t){var n,r,o,i,s,a,l=t.parent.getEnd(Ie);if(!(l&&l instanceof Se&&"\\left("===l.ctrlSeq||this.shouldIgnoreSubstitutionInSimpleSubscript(t.options))){for(n="",r=this,o=0,i=t.options.autoParenthesizedFunctions,s=i._maxLength||0,a=t.options.autoOperatorNames;r instanceof e&&o<s;)n=r.letter+n,r=r[Me],o+=1;for(;n.length;){if(i.hasOwnProperty(n)&&a.hasOwnProperty(n))return t.parent.write(t,"(");n=n.slice(1)}}},e.prototype.createLeftOf=function(e){t.prototype.createLeftOf.call(this,e),this.checkAutoCmds(e),this.autoParenthesize(e)},e.prototype.italicize=function(t){return this.isItalic=t,this.isPartOfOperator=!t,t&&(delete this.endsCategory,delete this.endsWord),this.domFrag().toggleClass("mq-operator-name",!t),this},e.prototype.finalizeTree=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingDeleted=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingCreated=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.sharedSiblingMethod=function(t,n){n!==Me&&this[Ie]instanceof e||this.autoUnItalicize(t)},e.prototype.autoUnItalicize=function(t){var n,r,o,i,s,a,l,c,u,p,h,d,f,m,g,y,v,x,b=t.autoOperatorNames;if(0!==b._maxLength&&!this.shouldIgnoreSubstitutionInSimpleSubscript(t)){for(n=this.letter,r=this[Me];r instanceof e;r=r[Me])n=r.letter+n;for(o=this[Ie];o instanceof e;o=o[Ie])n+=o.letter;i=r&&r[Ie],s=o&&o[Me],new Y(i||this.parent.getEnd(Me),s||this.parent.getEnd(Ie)).each(function(t){t instanceof e&&(t.italicize(!0).domFrag().removeClass("mq-first mq-last mq-followed-by-supsub"),t.ctrlSeq=t.letter)}),a=b._maxLength||0;t:for(l=0,c=r[Ie]||this.parent.getEnd(Me);c&&l<n.length;l+=1,c=c[Ie])for(u=Ne(a,n.length-l);u>0;u-=1)if(p=n.slice(l,l+u),h=void 0,b.hasOwnProperty(p)){for(d=0,f=c;d<u;d+=1,f=f[Ie])f instanceof e&&(f.italicize(!1),h=f);m=Gt.hasOwnProperty(p),c.ctrlSeq=(m?"\\":"\\operatorname{")+c.ctrlSeq,h.ctrlSeq+=m?" ":"}",h.endsWord=p,t.infixOperatorNames[p]?h.endsCategory="infix":t.prefixOperatorNames[p]&&(h.endsCategory="prefix"),Vt.hasOwnProperty(p)&&(g=h[Me],y=g&&g[Me],v=y&&y[Me],v.domFrag().addClass("mq-last")),this.shouldOmitPadding(c[Me])||c.domFrag().addClass("mq-first"),this.shouldOmitPadding(h[Ie])||(h[Ie]instanceof ue?(x=h[Ie],(x.siblingCreated=x.siblingDeleted=function(){x.domFrag().toggleClass("mq-after-operator-name",!(x[Ie]instanceof Se))})()):h.domFrag().toggleClass("mq-last",!(h[Ie]instanceof Se))),l+=u-1,c=h;continue t}}},e.prototype.shouldOmitPadding=function(t){return!t||("."===t.ctrlSeq||(!!(t instanceof Mt&&t.isBinaryOperator())||t instanceof fe))},e}(Ht),Gt={},at.prototype.autoOperatorNames=function(){var t,e,n,r,o={_maxLength:9},i="arg deg det dim exp gcd hom inf ker lg lim ln log max min sup limsup liminf injlim projlim Pr".split(" ");for(t=0;t<i.length;t+=1)Gt[i[t]]=o[i[t]]=1;for(e="sin cos tan arcsin arccos arctan sinh cosh tanh sec csc cot coth".split(" "),t=0;t<e.length;t+=1)Gt[e[t]]=1;for(n="sin cos tan sec cosec csc cotan cot ctg".split(" "),t=0;t<n.length;t+=1)o[n[t]]=o["arc"+n[t]]=o[n[t]+"h"]=o["ar"+n[t]+"h"]=o["arc"+n[t]+"h"]=1;for(r="gcf hcf lcm proj span".split(" "),t=0;t<r.length;t+=1)o[r[t]]=1;return o}(),Vt={limsup:1,liminf:1,projlim:1,injlim:1},st.autoOperatorNames=function(t){var e,n,r,o,i,s;if("string"!=typeof t)throw'"'+t+'" not a space-delimited list';if(!/^[a-z\|\-]+(?: [a-z\|\-]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of letters or "|"';for(e=t.split(" "),n={},r=0,o=0;o<e.length;o+=1){if(i=e[o],i.length<2)throw'"'+i+'" not minimum length of 2';if(i.indexOf("|")<0)n[i]=i,r=Be(r,i.length);else{if(s=i.split("|"),s.length>2)throw'"'+i+'" has more than 1 mathspeak delimiter';if(s[0].length<2)throw'"'+i[0]+'" not minimum length of 2';n[s[0]]=s[1].replace(/-/g," "),r=Be(r,s[0].length)}}return n._maxLength=r,n},at.prototype.infixOperatorNames={},st.infixOperatorNames=C,at.prototype.prefixOperatorNames={},st.prefixOperatorNames=C,at.prototype.disableAutoSubstitutionInSubscripts=!1,st.disableAutoSubstitutionInSubscripts=function(t){if("boolean"==typeof t)return t;if("object"!=typeof t||null===t||!("except"in t))throw'"'+t+'" not an object with property "except"';return{except:C(t.except)}},Wt=function(t){function e(e){return t.call(this,e||"")||this}return __extends(e,t),e.prototype.createLeftOf=function(t){var e,n=this.ctrlSeq;for(e=0;e<n.length;e+=1)new jt(n.charAt(e)).createLeftOf(t)},e.prototype.parser=function(){var t,e=this.ctrlSeq,n=new It;for(t=0;t<e.length;t+=1)new jt(e.charAt(t)).adopt(n,n.getEnd(Ie),0);return ft.succeed(n.children())},e}(Dt);for(Qt in at.prototype.autoOperatorNames)at.prototype.autoOperatorNames.hasOwnProperty(Qt)&&(Z[Qt]=Wt);if(Z.operatorname=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(){},e.prototype.numBlocks=function(){return 1},e.prototype.parser=function(){return Et.block.map(function(t){var e=!0,n="",r=t.children();return r.each(function(t){t instanceof jt?n+=t.letter:e=!1}),e&&"ans"===n?ye():r})},e}(Ft),Z.f=function(t){function e(){var e=this,n="f";return e=t.call(this,n)||this,e.letter=n,e.domView=new Tt(0,function(){return Re("var",{class:"mq-f"},[Re.text("f")])}),e}return __extends(e,t),e.prototype.italicize=function(e){return this.domFrag().eachElement(function(t){return t.textContent="f"}),this.domFrag().toggleClass("mq-f",e),t.prototype.italicize.call(this,e)},e}(jt),Z[" "]=Z.space=function(){return new zt("\\ ",Re("span",{},[Re.text(R)])," ")},Z["."]=function(){return new zt(".",Re("span",{class:"mq-digit"},[Re.text(".")]),".")},Z["'"]=Z.prime=L("'","&prime;","prime"),Z["″"]=Z.dprime=L("″","&Prime;","double prime"),Z.backslash=L("\\backslash ","\\","backslash"),J["\\"]||(J["\\"]=Z.backslash),Z.$=L("\\$","$","dollar"),Z["?"]=L("?","?","question mark"),Z["□"]=Z.square=L("\\square ","□","square"),Z.mid=L("\\mid ","∣","mid"),$t=function(t){function e(e,n){return t.call(this,e,Re("span",{class:n},[Re.text(e)]))||this}return __extends(e,t),e}(Dt),Z[","]=function(){return new $t(",","mq-comma")},Ut=function(t){function e(e,n,r){return t.call(this,e,Re("span",{class:"mq-nonSymbola"},[n||Re.text(e)]))||this}return __extends(e,t),e}(Dt),Z["@"]=function(){return new Ut("@")},Z["&"]=function(){return new Ut("\\&",Re.entityText("&amp;"),"and")},Z["%"]=function(t){function e(){return t.call(this,"\\%",Re.text("%"),"percent")||this}return __extends(e,t),e.prototype.parser=function(){var e=ft.optWhitespace,n=ft.string;return e.then(n("\\operatorname{of}").map(function(){return ve()})).or(t.prototype.parser.call(this))},e}(Ut),Z["∥"]=Z.parallel=L("\\parallel ","&#x2225;","parallel"),Z["∦"]=Z.nparallel=L("\\nparallel ","&#x2226;","not parallel"),Z["⟂"]=Z.perp=L("\\perp ","&#x27C2;","perpendicular"),Z["α"]=Z.alpha=O("alpha"),Z["β"]=Z.beta=O("beta"),Z["γ"]=Z.gamma=O("gamma"),Z["δ"]=Z.delta=O("delta"),Z["ζ"]=Z.zeta=O("zeta"),Z["η"]=Z.eta=O("eta"),Z["θ"]=Z.theta=O("theta"),Z["ι"]=Z.iota=O("iota"),Z["κ"]=Z.kappa=O("kappa"),Z["μ"]=Z.mu=O("mu"),Z["ν"]=Z.nu=O("nu"),Z["ξ"]=Z.xi=O("xi"),Z["ρ"]=Z.rho=O("rho"),Z["σ"]=Z.sigma=O("sigma"),Z["τ"]=Z.tau=O("tau"),Z["χ"]=Z.chi=O("chi"),Z["ψ"]=Z.psi=O("psi"),Z["ω"]=Z.omega=O("omega"),Z["ϕ"]=Z.phi=_("\\phi ","&#981;","phi"),Z["φ"]=Z.phiv=Z.varphi=_("\\varphi ","&phi;","phi"),Z["ϵ"]=Z.epsilon=_("\\epsilon ","&#1013;","epsilon"),Z["ε"]=Z.epsiv=Z.varepsilon=_("\\varepsilon ","&epsilon;","epsilon"),Z["ϖ"]=Z.piv=Z.varpi=_("\\varpi ","&piv;","piv"),Z["ς"]=Z.sigmaf=Z.sigmav=Z.varsigma=_("\\varsigma ","&sigmaf;","sigma"),Z["ϑ"]=Z.thetav=Z.vartheta=Z.thetasym=_("\\vartheta ","&thetasym;","theta"),Z["υ"]=Z.upsilon=Z.upsi=_("\\upsilon ","&upsilon;","upsilon"),Z["Ϝ"]=Z.gammad=Z.Gammad=Z.digamma=_("\\digamma ","&#989;","gamma"),Z["ϰ"]=Z.kappav=Z.varkappa=_("\\varkappa ","&#1008;","kappa"),Z["ϱ"]=Z.rhov=Z.varrho=_("\\varrho ","&#1009;","rho"),Z.pi=Z["π"]=function(){return new Ut("\\pi ",Re.entityText("&pi;"),"pi")},Z["λ"]=Z.lambda=function(){return new Ut("\\lambda ",Re.entityText("&lambda;"),"lambda")},Z["Υ"]=Z.Upsilon=Z.Upsi=Z.upsih=Z.Upsih=function(){return new Dt("\\Upsilon ",Re("var",{style:"font-family: serif"},[Re.entityText("&upsih;")]),"capital upsilon")},Z["Γ"]=Z.Gamma=T("Gamma"),Z["Δ"]=Z.Delta=T("Delta"),Z["Θ"]=Z.Theta=T("Theta"),Z["Λ"]=Z.Lambda=T("Lambda"),Z["Ξ"]=Z.Xi=T("Xi"),Z["Π"]=Z.Pi=T("Pi"),Z["Σ"]=Z.Sigma=T("Sigma"),Z["Φ"]=Z.Phi=T("Phi"),Z["Ψ"]=Z.Psi=T("Psi"),Z["Ω"]=Z.Omega=T("Omega"),Z["∀"]=Z.forall=T("forall"),Kt=function(t){function e(e){var n=t.call(this)||this;return n.latexStr=e,n}return __extends(e,t),e.prototype.createLeftOf=function(t){var e,n,r,o,i=Et.parse(this.latexStr);i.children().adopt(t.parent,t[Me],t[Ie]),t[Me]=i.getEnd(Ie),U(i.html()).insertBefore(t.domFrag()),i.finalizeInsert(t.options,t),e=i.getEnd(Ie),n=e&&e[Ie],n&&n.siblingCreated(t.options,Me),r=i.getEnd(Me),o=r&&r[Me],o&&o.siblingCreated(t.options,Ie),t.parent.bubble(function(t){t.reflow()})},e.prototype.mathspeak=function(){return Et.parse(this.latexStr).mathspeak()},e.prototype.parser=function(){var t=Et.parse(this.latexStr).children();return ft.succeed(t)},e}(Ft),Z["⁰"]=function(){return new Kt("^0")},Z["¹"]=function(){
13
+ return new Kt("^1")},Z["²"]=function(){return new Kt("^2")},Z["³"]=function(){return new Kt("^3")},Z["⁴"]=function(){return new Kt("^4")},Z["⁵"]=function(){return new Kt("^5")},Z["⁶"]=function(){return new Kt("^6")},Z["⁷"]=function(){return new Kt("^7")},Z["⁸"]=function(){return new Kt("^8")},Z["⁹"]=function(){return new Kt("^9")},Z["¼"]=function(){return new Kt("\\frac14")},Z["½"]=function(){return new Kt("\\frac12")},Z["¾"]=function(){return new Kt("\\frac34")},Z["√"]=function(){return new Kt("\\sqrt{}")},Xt=function(t){function e(e,n,r){return t.call(this,e,n,void 0,r,!0)||this}return __extends(e,t),e.prototype.isBinaryOperator=function(){return D(this)},e.prototype.contactWeld=function(t,e){this.sharedSiblingMethod(t.options,e)},e.prototype.siblingCreated=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.siblingDeleted=function(t,e){this.sharedSiblingMethod(t,e)},e.prototype.sharedSiblingMethod=function(t,e){if(e!==Ie)return this.domFrag().oneElement().className=D(this)?"mq-binary-operator":"",this},e}(Mt),Z["+"]=function(t){function e(){return t.call(this,"+",Re.text("+"))||this}return __extends(e,t),e.prototype.mathspeak=function(){return D(this)?"plus":"positive"},e}(Xt),Yt=function(t){function e(){return t.call(this,"-",Re.entityText("&minus;"))||this}return __extends(e,t),e.prototype.mathspeak=function(){return D(this)?"minus":"negative"},e}(Xt),Z["−"]=Z["—"]=Z["–"]=Z["-"]=Yt,Z["±"]=Z.pm=Z.plusmn=Z.plusminus=function(){return new Xt("\\pm ",Re.entityText("&plusmn;"),"plus-or-minus")},Z["∓"]=Z.mp=Z.mnplus=Z.minusplus=function(){return new Xt("\\mp ",Re.entityText("&#8723;"),"minus-or-plus")},J["*"]=Z.sdot=Z.cdot=S("\\cdot ","&middot;","*","times"),Zt=function(t){function e(){return t.call(this,"\\to ",Re.entityText("&rarr;"),"to")||this}return __extends(e,t),e.prototype.deleteTowards=function(e,n){if(e===Me){var r=n[Me];return new Y(r,this).remove(),n[Me]=r[Me],(new Yt).createLeftOf(n),void n[Me].bubble(function(t){t.reflow()})}t.prototype.deleteTowards.call(this,e,n)},e}(Mt),Z["→"]=Z.to=Zt,Jt=function(t){function e(e,n){var r=this,o=n?"Strict":"";return r=t.call(this,e["ctrlSeq".concat(o)],Re.entityText(e["htmlEntity".concat(o)]),e["text".concat(o)],e["mathspeak".concat(o)])||this,r.data=e,r.strict=n,r}return __extends(e,t),e.prototype.swap=function(t){this.strict=t;var e=t?"Strict":"";this.ctrlSeq=this.data["ctrlSeq".concat(e)],this.domFrag().children().replaceWith(U(Re.entityText(this.data["htmlEntity".concat(e)]))),this.textTemplate=[this.data["text".concat(e)]],this.mathspeakName=this.data["mathspeak".concat(e)]},e.prototype.deleteTowards=function(e,n){if(e===Me&&!this.strict)return this.swap(!0),void this.bubble(function(t){t.reflow()});t.prototype.deleteTowards.call(this,e,n)},e}(Mt),te={ctrlSeq:"\\le ",htmlEntity:"&le;",text:"≤",mathspeak:"less than or equal to",ctrlSeqStrict:"<",htmlEntityStrict:"&lt;",textStrict:"<",mathspeakStrict:"less than"},ee={ctrlSeq:"\\ge ",htmlEntity:"&ge;",text:"≥",mathspeak:"greater than or equal to",ctrlSeqStrict:">",htmlEntityStrict:"&gt;",textStrict:">",mathspeakStrict:"greater than"},ne=function(t){function e(){return t.call(this,ee,!0)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n,r=e[Me];if(r instanceof Mt&&"-"===r.ctrlSeq)return n=r,e[Me]=n[Me],n.remove(),(new Zt).createLeftOf(e),void e[Me].bubble(function(t){t.reflow()});t.prototype.createLeftOf.call(this,e)},e}(Jt),Z["<"]=Z.lt=function(){return new Jt(te,!0)},Z[">"]=Z.gt=ne,Z["≤"]=Z.le=Z.leq=function(){return new Jt(te,!1)},Z["≥"]=Z.ge=Z.geq=function(){return new Jt(ee,!1)},Z["∞"]=Z.infty=Z.infin=Z.infinity=L("\\infty ","&infin;","infinity"),Z["≠"]=Z.ne=Z.neq=S("\\ne ","&ne;","not equal"),re=function(t){function e(){return t.call(this,"=",Re.text("="),"=","equals")||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n=e[Me];if(n instanceof Jt&&n.strict)return n.swap(!1),void n.bubble(function(t){t.reflow()});t.prototype.createLeftOf.call(this,e)},e}(Mt),Z["="]=re,Z["×"]=Z.times=Z.cross=S("\\times ","&times;","[x]","times"),Z["÷"]=Z.div=Z.divide=Z.divides=S("\\div ","&divide;","[/]","divided by"),oe=function(t){function e(){return t.call(this,"\\sim ",Re.text("~"),"~","tilde")||this}return __extends(e,t),e.prototype.createLeftOf=function(n){if(n[Me]instanceof e){var r=n[Me];return n[Me]=r[Me],r.remove(),(new ie).createLeftOf(n),void n[Me].bubble(function(t){t.reflow()})}t.prototype.createLeftOf.call(this,n)},e}(Mt),ie=function(t){function e(){return t.call(this,"\\approx ",Re.entityText("&approx;"),"≈","approximately equal")||this}return __extends(e,t),e.prototype.deleteTowards=function(e,n){if(e===Me){var r=n[Me];return new Y(r,this).remove(),n[Me]=r[Me],(new oe).createLeftOf(n),void n[Me].bubble(function(t){t.reflow()})}t.prototype.deleteTowards.call(this,e,n)},e}(Mt),Z.tildeNbsp=L("~",R," "),Z.sim=oe,Z["≈"]=Z.approx=ie,J["~"]=Z.sim,Z["~"]=Z.tildeNbsp,st.interpretTildeAsSim=function(t){var e=!!t;return Z["~"]=e?Z.sim:Z.tildeNbsp,e},Z["◯"]=Z.bigcirc=L("\\bigcirc ","&#9711;","circle"),Z["∠"]=Z.ang=Z.angle=L("\\angle ","&ang;","angle"),Z["°"]=Z.degree=L("\\degree ","&deg;","degrees"),Z["△"]=Z.triangle=L("\\triangle ","&#9651;","triangle"),Z["≅"]=Z.cong=S("\\cong ","&cong;","cong","congruent"),Z["∡"]=Z.measuredangle=L("\\measuredangle ","&#8737;","measured angle"),Z["▱"]=Z.parallelogram=L("\\parallelogram ","&#9649;","parallelogram"),Z["≇"]=Z.ncong=S("\\ncong ","&ncong;","ncong","not congruent"),Z["≁"]=Z.nsim=S("\\nsim ","&nsim;","nsim","not similar"),se={sqrt:{width:"",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 32 54"},[Re("path",{d:"M0 33 L7 27 L12.5 47 L13 47 L30 0 L32 0 L13 54 L11 54 L4.5 31 L0 33"})])}},"|":{width:".4em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Re("path",{d:"M4.4 0 L4.4 54 L5.6 54 L5.6 0"})])}},"[":{width:".55em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 11 24"},[Re("path",{d:"M8 0 L3 0 L3 24 L8 24 L8 23 L4 23 L4 1 L8 1"})])}},"]":{width:".55em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 11 24"},[Re("path",{d:"M3 0 L8 0 L8 24 L3 24 L3 23 L7 23 L7 1 L3 1"})])}},"(":{width:".55em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"3 0 106 186"},[Re("path",{d:"M85 0 A61 101 0 0 0 85 186 L75 186 A75 101 0 0 1 75 0"})])}},")":{width:".55em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"3 0 106 186"},[Re("path",{d:"M24 0 A61 101 0 0 1 24 186 L34 186 A75 101 0 0 0 34 0"})])}},"{":{width:".7em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"10 0 210 350"},[Re("path",{d:"M170 0 L170 6 A47 52 0 0 0 123 60 L123 127 A35 48 0 0 1 88 175 A35 48 0 0 1 123 223 L123 290 A47 52 0 0 0 170 344 L170 350 L160 350 A58 49 0 0 1 102 301 L103 220 A45 40 0 0 0 58 180 L58 170 A45 40 0 0 0 103 130 L103 49 A58 49 0 0 1 161 0"})])}},"}":{width:".7em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"10 0 210 350"},[Re("path",{d:"M60 0 L60 6 A47 52 0 0 1 107 60 L107 127 A35 48 0 0 0 142 175 A35 48 0 0 0 107 223 L107 290 A47 52 0 0 1 60 344 L60 350 L70 350 A58 49 0 0 0 128 301 L127 220 A45 40 0 0 1 172 180 L172 170 A45 40 0 0 1 127 130 L127 49 A58 49 0 0 0 70 0"})])}},"&#8741;":{width:".7em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Re("path",{d:"M3.2 0 L3.2 54 L4 54 L4 0 M6.8 0 L6.8 54 L6 54 L6 0"})])}},"&lang;":{width:".55em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Re("path",{d:"M6.8 0 L3.2 27 L6.8 54 L7.8 54 L4.2 27 L7.8 0"})])}},"&rang;":{width:".55em",html:function(){return Re("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[Re("path",{d:"M3.2 0 L6.8 27 L3.2 54 L2.2 54 L5.8 27 L2.2 0"})])}}},ae="➤",le=function(t){function e(e,n,r,o,i){var s=t.call(this,e,new Tt(1,function(t){var e,o;return Re.block(n,r,t[0],{beforeChild:null===(e=null===i||void 0===i?void 0:i.beforeChild)||void 0===e?void 0:e.call(i),afterChild:null===(o=null===i||void 0===i?void 0:i.afterChild)||void 0===o?void 0:o.call(i)})}))||this;return s.ariaLabel=o||e.replace(/^\\/,""),s.mathspeakTemplate=["Start"+s.ariaLabel+",","End"+s.ariaLabel],s.shouldNotSpeakDelimiters=i&&i.shouldNotSpeakDelimiters,s}return __extends(e,t),e.prototype.mathspeak=function(e){return!this.shouldNotSpeakDelimiters||e&&e.ignoreShorthand?t.prototype.mathspeak.call(this):this.foldChildren("",function(t,n){return t+" "+n.mathspeak(e)}).trim()},e}(Ft),Z.mathrm=function(t){function e(){return t.call(this,"\\mathrm","span",{class:"mq-roman mq-font"},"Roman Font",{shouldNotSpeakDelimiters:!0})||this}return __extends(e,t),e.prototype.isTextBlock=function(){return!0},e}(le),Z.mathit=function(){return new le("\\mathit","i",{class:"mq-font"},"Italic Font")},Z.mathbf=function(){return new le("\\mathbf","b",{class:"mq-font"},"Bold Font")},Z.mathsf=function(){return new le("\\mathsf","span",{class:"mq-sans-serif mq-font"},"Serif Font")},Z.mathtt=function(){return new le("\\mathtt","span",{class:"mq-monospace mq-font"},"Math Text")},Z.underline=function(){return new le("\\underline","span",{class:"mq-non-leaf mq-underline"},"Underline")},Z.overline=Z.bar=function(){return new le("\\overline","span",{class:"mq-non-leaf mq-overline"},"Overline")},Z.overrightarrow=function(){return new le("\\overrightarrow","span",{class:"mq-non-leaf mq-overarrow"},"Over Right Arrow",{afterChild:function(){return Re("span",{class:"mq-arrow-right-content"},[Re.text(ae)])}})},Z.overleftarrow=function(){return new le("\\overleftarrow","span",{class:"mq-non-leaf mq-overarrow"},"Over Left Arrow",{beforeChild:function(){return Re("span",{class:"mq-arrow-left-content"},[Re.text(ae)])}})},Z.overleftrightarrow=function(){return new le("\\overleftrightarrow ","span",{class:"mq-non-leaf mq-overarrow"},"Over Left and Right Arrow",{beforeChild:function(){return Re("span",{class:"mq-arrow-left-content"},[Re.text(ae)])},afterChild:function(){return Re("span",{class:"mq-arrow-right-content"},[Re.text(ae)])}})},Z.overarc=function(){return new le("\\overarc","span",{class:"mq-non-leaf mq-overarc"},"Over Arc")},Z.dot=function(){return new Ft("\\dot",new Tt(1,function(t){return Re("span",{class:"mq-non-leaf"},[Re("span",{class:"mq-dot-recurring-inner"},[Re("span",{class:"mq-dot-recurring"},[Re.text(P)]),Re.block("span",{class:"mq-empty-box"},t[0])])])}))},Z.textcolor=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setColor=function(t){this.color=t,this.domView=new Tt(1,function(e){return Re.block("span",{class:"mq-textcolor",style:"color:"+t},e[0])}),this.ariaLabel=t.replace(/^\\/,""),this.mathspeakTemplate=["Start "+this.ariaLabel+",","End "+this.ariaLabel]},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t);var e=this.blocks[0];t.uncleanedLatex+="\\textcolor{"+this.color+"}{",e.latexRecursive(t),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.parser=function(){var e=this,n=ft.optWhitespace,r=ft.string,o=ft.regex;return n.then(r("{")).then(o(/^[#\w\s.,()%-]*/)).skip(r("}")).then(function(n){return e.setColor(n),t.prototype.parser.call(e)})},e.prototype.isStyleBlock=function(){return!0},e}(Ft),Z.class=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){var e=this,n=ft.string,r=ft.regex;return ft.optWhitespace.then(n("{")).then(r(/^[-\w\s\\\xA0-\xFF]*/)).skip(n("}")).then(function(n){return e.cls=n||"",e.domView=new Tt(1,function(t){return Re.block("span",{class:"mq-class ".concat(n)},t[0])}),e.ariaLabel=n+" class",e.mathspeakTemplate=["Start "+e.ariaLabel+",","End "+e.ariaLabel],t.prototype.parser.call(e)})},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t);var e=this.blocks[0];t.uncleanedLatex+="\\class{"+this.cls+"}{",e.latexRecursive(t),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.isStyleBlock=function(){return!0},e}(Ft),ce=/^[\+\-]?[\d]+$/,at.prototype.charsThatBreakOutOfSupSub="",ue=function(t){function e(e){var n,r=this;return n="sub"===e?new Tt(1,function(t){return Re("span",{class:"mq-supsub mq-non-leaf"},[Re.block("span",{class:"mq-sub"},t[0]),Re("span",{style:"display:inline-block;width:0"},[Re.text(z)])])}):new Tt(1,function(t){return Re("span",{class:"mq-supsub mq-non-leaf mq-sup-only"},[Re.block("span",{class:"mq-sup"},t[0])])}),r=t.call(this,"_{...}^{...}",n)||this,r.ariaLabel="sub"===e?"subscript":"superscript",r.supsub=e,r}return __extends(e,t),e.prototype.setEnds=function(t){n("SupSub ends must be MathBlocks",t[Me]instanceof It&&t[Ie]instanceof It),this.ends=t},e.prototype.getEnd=function(t){return this.ends[t]},e.prototype.createLeftOf=function(e){if(this.replacedFragment||e[Me]||!e.options.supSubsRequireOperand)return t.prototype.createLeftOf.call(this,e)},e.prototype.contactWeld=function(t){var n,r,o,i,s,a,l;for(n=Me;n;n=n===Me&&Ie)if(r=this[n],o=void 0,r instanceof e){for(i="sub";i;i="sub"===i&&"sup")s=this[i],a=r[i],s&&(a?s.isEmpty()?o=new K(a,0,a.getEnd(Me)):(s.domFrag().children().insAtDirEnd(-n,a.domFrag().oneElement()),l=s.children().disown(),o=new K(a,l.getEnd(Ie),a.getEnd(Me)),n===Me?l.adopt(a,a.getEnd(Ie),0):l.adopt(a,0,a.getEnd(Me))):r.addBlock(s.disown()),this.placeCursor=function(t,e){return function(r){r.insAtDirEnd(-n,t||e)}}(a,s));this.remove(),t&&t[Me]===this&&(n===Ie&&o?o[Me]?t.insRightOf(o[Me]):t.insAtLeftEnd(o.parent):t.insRightOf(r));break}},e.prototype.finalizeTree=function(){"sub"===this.supsub?(this.downInto=this.sub=this.getEnd(Me),this.sub.upOutOf=M):"sup"===this.supsub&&(this.upInto=this.sup=this.getEnd(Ie),this.sup.downOutOf=M),this.getEnd(Me).write=function(t,e){if(t.options.autoSubscriptNumerals&&this===this.parent.sub&&"0123456789".indexOf(e)>=0){var n=this.chToCmd(e,t.options);return n instanceof Dt?t.deleteSelection():t.clearSelection().insRightOf(this.parent),n.createLeftOf(t.show()),void t.controller.aria.queue("Baseline").alert(n.mathspeak({createdLeftOf:t}))}t[Me]&&!t[Ie]&&!t.selection&&t.options.charsThatBreakOutOfSupSub.indexOf(e)>-1&&(t.insRightOf(this.parent),t.controller.aria.queue("Baseline")),It.prototype.write.call(this,t,e)}},e.prototype.moveTowards=function(e,n,r){n.options.autoSubscriptNumerals&&!this.sup?n.insDirOf(e,this):t.prototype.moveTowards.call(this,e,n,r)},e.prototype.deleteTowards=function(e,n){if(n.options.autoSubscriptNumerals&&this.sub){var r=this.sub.getEnd(-e);r instanceof Dt?r.remove():r&&r.deleteTowards(e,n.insAtDirEnd(-e,this.sub)),this.sub.isEmpty()&&(this.sub.deleteOutOf(Me,n.insAtLeftEnd(this.sub)),this.sup&&n.insDirOf(-e,this))}else t.prototype.deleteTowards.call(this,e,n)},e.prototype.latexRecursive=function(t){var e,n;this.checkCursorContextOpen(t),this.sub&&(t.uncleanedLatex+="_{",e=t.uncleanedLatex.length,this.sub.latexRecursive(t),n=t.uncleanedLatex.length,e===n&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}"),this.sup&&(t.uncleanedLatex+="^{",e=t.uncleanedLatex.length,this.sup.latexRecursive(t),n=t.uncleanedLatex.length,e===n&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}"),this.checkCursorContextClose(t)},e.prototype.mathspeak=function(e){var n,r;return void 0===this.sup||(n=A(this.sup),e&&e.ignoreShorthand||!ce.test(n))?(this.mathspeakTemplate=this.getMathspeakTemplate(),t.prototype.mathspeak.call(this)):(r="",this.sub&&(r=pe[0]+" "+this.sub.mathspeak()+" "+pe[1]+" "),r+I(this.sup,n))},e.prototype.getMathspeakTemplate=function(){return this.sub&&this.sup?de:this.sup?he:pe},e.prototype.text=function(){function t(t,e){var n=e&&e.text()||"";return e?t+(1===n.length?n:"("+(n||" ")+")"):""}return t("_",this.sub)+t("^",this.sup)},e.prototype.addBlock=function(t){var e,n,r;for("sub"===this.supsub?(this.sup=this.upInto=this.sub.upOutOf=t,t.adopt(this,this.sub,0).downOutOf=this.sub,t.setDOM(U(Re("span",{class:"mq-sup"})).append(t.domFrag().children()).prependTo(this.domFrag().oneElement()).oneElement()),X.linkElementByBlockNode(t.domFrag().oneElement(),t)):(this.sub=this.downInto=this.sup.downOutOf=t,t.adopt(this,0,this.sup).upOutOf=this.sup,this.domFrag().removeClass("mq-sup-only"),t.setDOM(U(Re("span",{class:"mq-sub"})).append(t.domFrag().children()).appendTo(this.domFrag().oneElement()).oneElement()),X.linkElementByBlockNode(t.domFrag().oneElement(),t),this.domFrag().append(U(Re("span",{style:"display:inline-block;width:0"},[Re.text(z)])))),e=function(t){var e=n,r=["sub","sup"][t],o=["sup","sub"][t],i=["down","up"][t];e[r].deleteOutOf=function(t,n){var s,a;n.insDirOf(this[t]?-t:t,this.parent),this.isEmpty()||(s=this.getEnd(t),this.children().disown().withDirAdopt(t,n.parent,n[t],n[-t]).domFrag().insDirOf(-t,n.domFrag()),n[-t]=s),e.supsub=o,delete e[r],delete e["".concat(i,"Into")],a=e[o],a["".concat(i,"OutOf")]=M,delete a.deleteOutOf,"sub"===r&&e.domFrag().addClass("mq-sup-only").children().last().remove(),this.remove()}},n=this,r=0;r<2;r+=1)e(r)},e}(Ft),pe=["Subscript,",", Baseline"],he=["Superscript,",", Baseline"],de=["Subscript,",", Baseline Superscript,",", Baseline"],Z.subscript=Z._=function(){return new ue("sub")},Z.superscript=Z.supscript=Z["^"]=function(){return new ue("sup")},fe=function(t){function e(e,n,r){var o,i=t.call(this)||this;return i.ariaLabel=r||e.replace(/^\\/,""),o=new Tt(2,function(t){return Re("span",{class:"mq-large-operator mq-non-leaf"},[Re("span",{class:"mq-to"},[Re.block("span",{},t[1])]),Re("big",{},[Re.text(n)]),Re("span",{class:"mq-from"},[Re.block("span",{},t[0])])])}),Dt.prototype.setCtrlSeqHtmlTextAndMathspeak.call(i,e,o),i}return __extends(e,t),e.prototype.createLeftOf=function(e){t.prototype.createLeftOf.call(this,e),e.options.sumStartsWithNEquals&&(new jt("n").createLeftOf(e),(new re).createLeftOf(e))},e.prototype.latexRecursive=function(t){var e,n;this.checkCursorContextOpen(t),t.uncleanedLatex+=this.ctrlSeq+"_{",e=t.uncleanedLatex.length,this.getEnd(Me).latexRecursive(t),n=t.uncleanedLatex.length,n===e&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}^{",e=t.uncleanedLatex.length,this.getEnd(Ie).latexRecursive(t),n=t.uncleanedLatex.length,e===n&&(t.uncleanedLatex+=" "),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.mathspeak=function(){return"Start "+this.ariaLabel+" from "+this.getEnd(Me).mathspeak()+" to "+this.getEnd(Ie).mathspeak()+", end "+this.ariaLabel+", "},e.prototype.parser=function(){var t,e=ft.string,n=ft.optWhitespace,r=ft.succeed,o=Et.block,i=this,s=i.blocks=[new It,new It];for(t=0;t<s.length;t+=1)s[t].adopt(i,i.getEnd(Ie),0);return n.then(e("_").or(e("^"))).then(function(t){var e=s["_"===t?0:1];return o.then(function(t){return t.children().adopt(e,e.getEnd(Ie),0),r(i)})}).many().result(i)},e.prototype.finalizeTree=function(){var t=this.getEnd(Me),e=this.getEnd(Ie);t.ariaLabel="lower bound",e.ariaLabel="upper bound",this.downInto=t,this.upInto=e,t.upOutOf=e,e.downOutOf=t},e}(Ft),Z["∑"]=Z.sum=Z.summation=function(){return new fe("\\sum ",H,"sum")},Z["∏"]=Z.prod=Z.product=function(){return new fe("\\prod ",j,"product")},Z.coprod=Z.coproduct=function(){return new fe("\\coprod ",G,"co product")},Z["∫"]=Z.int=Z.integral=function(t){function e(){var e=t.call(this,"\\int ","","integral")||this;return e.ariaLabel="integral",e.domView=new Tt(2,function(t){return Re("span",{class:"mq-int mq-non-leaf"},[Re("big",{},[Re.text(V)]),Re("span",{class:"mq-supsub mq-non-leaf"},[Re("span",{class:"mq-sup"},[Re.block("span",{class:"mq-sup-inner"},t[1])]),Re.block("span",{class:"mq-sub"},t[0]),Re("span",{style:"display:inline-block;width:0"},[Re.text(z)])])])}),e}return __extends(e,t),e.prototype.createLeftOf=function(t){Ft.prototype.createLeftOf.call(this,t)},e}(fe),me=Z.frac=Z.dfrac=Z.cfrac=Z.fraction=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\frac",e.domView=new Tt(2,function(t){return Re("span",{class:"mq-fraction mq-non-leaf"},[Re.block("span",{class:"mq-numerator"},t[0]),Re.block("span",{class:"mq-denominator"},t[1]),Re("span",{style:"display:inline-block;width:0"},[Re.text(z)])])}),e.textTemplate=["(",")/(",")"],e}return __extends(e,t),e.prototype.finalizeTree=function(){var t=this.getEnd(Me),e=this.getEnd(Ie);this.upInto=e.upOutOf=t,this.downInto=t.downOutOf=e,t.ariaLabel="numerator",e.ariaLabel="denominator",this.getFracDepth()>1?this.mathspeakTemplate=["StartNestedFraction,","NestedOver",", EndNestedFraction"]:this.mathspeakTemplate=["StartFraction,","Over",", EndFraction"]},e.prototype.mathspeak=function(e){var n,r,o,i,s,a,l,c;if(e&&e.createdLeftOf)return n=e.createdLeftOf,n.parent.mathspeak();if(r=A(this.getEnd(Me)),o=A(this.getEnd(Ie)),(!e||!e.ignoreShorthand)&&ce.test(r)&&ce.test(o)&&(i="1"===r||"-1"===r,s="","2"===o?s=i?"half":"halves":"3"===o?s=i?"third":"thirds":"4"===o?s=i?"fourth":"fourths":"5"===o?s=i?"fifth":"fifths":"6"===o?s=i?"sixth":"sixths":"7"===o?s=i?"seventh":"sevenths":"8"===o?s=i?"eighth":"eighths":"9"===o?s=i?"ninth":"ninths":"10"===o?s=i?"tenth":"tenths":"11"===o?s=i?"eleventh":"elevenths":"12"===o?s=i?"twelfth":"twelfths":"100"===o&&(s=i?"hundredth":"hundredths"),""!==s)){for(a="",l=!1,c=this[Me];c&&void 0!==c[Me];c=c[Me])if("\\ "!==c.ctrlSeq){if(!ce.test(c.ctrlSeq||"")){l=!1;break}l=!0}return l&&(a+="and "),a+=this.getEnd(Me).mathspeak()+" "+s}return t.prototype.mathspeak.call(this)},e.prototype.getFracDepth=function(){var t=function(e,n){return e instanceof bt&&e.ctrlSeq&&e.ctrlSeq.toLowerCase().search("frac")>=0&&(n+=1),e&&e.parent?t(e.parent,n):n};return t(this,0)},e}(Ft),ge=Z.over=J["/"]=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.createLeftOf=function(n){var r,o,i;if(!this.replacedFragment){if(r=n[Me],!(n.options.typingSlashCreatesNewFraction&&this instanceof me))for(;r&&!(F(r)||r instanceof zt&&"mq-ellipsis-end"===r._groupingClass||r instanceof(Z.text||t)||r instanceof fe||"\\ "===r.ctrlSeq||/^[,;:]$/.test(r.ctrlSeq));)r=r[Me];r instanceof fe&&r[Ie]instanceof ue&&(r=r[Ie],(o=r[Ie])instanceof ue&&o.ctrlSeq!=r.ctrlSeq&&(r=r[Ie])),r===n[Me]||n.isTooDeep(1)||(o=r[Ie],i=n[Me],this.replaces(new Y(o||n.parent.getEnd(Me),i)),n[Me]=r)}e.prototype.createLeftOf.call(this,n)},n}(me),ye=function(){return new Dt("\\operatorname{ans}",Re("span",{class:"mq-ans"},[Re.text("ans")]),"ans")},Z.ans=ye,ve=function(){return new Dt("\\%\\operatorname{of}",Re("span",{class:"mq-nonSymbola mq-operator-name"},[Re.text("% of ")]),"percent of")},Z.percent=Z.percentof=ve,xe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.tokenId="",e.ctrlSeq="\\token",e.textTemplate=["token(",")"],e.mathspeakTemplate=["StartToken,",", EndToken"],e.ariaLabel="token",e}return __extends(e,t),e.prototype.html=function(){var t=Re("span",{class:"mq-token mq-ignore-mousedown","data-mq-token":this.tokenId});return this.setDOM(t),X.linkElementByCmdNode(t,this),t},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+="".concat(this.ctrlSeq,"{")+this.tokenId+"}",this.checkCursorContextClose(t)},e.prototype.mathspeak=function(){var t=[];return this.domFrag().children().eachElement(function(e){var n=e.getAttribute("aria-label");"string"==typeof n&&""!==n&&t.push(n)}),t.length>0?t.join(" ").trim():"token "+this.tokenId},e.prototype.parser=function(){var t=this;return Et.block.map(function(e){var n=e.getEnd(Me);if(n)for(t.tokenId+=n.ctrlSeq;n=n[Ie];)t.tokenId+=n.ctrlSeq;return t})},e}(Dt),Z.token=xe,be=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\tokenName",e.textTemplate=["tokenName(",")"],e.ariaLabel="token name",e}return __extends(e,t),e}(xe),Z.tokenName=be,we=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\sqrt",e.domView=new Tt(1,function(t){return Re("span",{class:"mq-non-leaf mq-sqrt-container"},[Re("span",{class:"mq-scaled mq-sqrt-prefix"},[se.sqrt.html()]),Re.block("span",{class:"mq-non-leaf mq-sqrt-stem"},t[0])])}),e.textTemplate=["sqrt(",")"],e.mathspeakTemplate=["StartRoot,",", EndRoot"],e.ariaLabel="root",e}return __extends(e,t),e.prototype.parser=function(){return Et.optBlock.then(function(t){return Et.block.map(function(e){var n=new Ee;return n.blocks=[t,e],t.adopt(n,0,0),e.adopt(n,t,0),n})}).or(t.prototype.parser.call(this))},e.prototype.deleteTowards=function(e,n){if(!this.isEmpty()&&1===e)return this.moveTowards(Ie,n),void n.parent.deleteOutOf(Me,n);t.prototype.deleteTowards.call(this,e,n)},e}(Ft),Z.sqrt=J["√"]=we,Z.hat=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\hat",e.domView=new Tt(1,function(t){return Re("span",{class:"mq-non-leaf"},[Re("span",{class:"mq-hat-prefix"},[Re.text("^")]),Re.block("span",{class:"mq-hat-stem"},t[0])])}),e.textTemplate=["hat(",")"],e}return __extends(e,t),e}(Ft),Ee=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.domView=new Tt(2,function(t){return Re("span",{class:"mq-nthroot-container mq-non-leaf"},[Re.block("sup",{class:"mq-nthroot mq-non-leaf"},t[0]),Re("span",{class:"mq-scaled mq-sqrt-container"},[Re("span",{class:"mq-sqrt-prefix mq-scaled"},[se.sqrt.html()]),Re.block("span",{class:"mq-sqrt-stem mq-non-leaf"},t[1])])])}),e.textTemplate=["sqrt[","](",")"],e}return __extends(e,t),e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+="\\sqrt[",this.getEnd(Me).latexRecursive(t),t.uncleanedLatex+="]{",this.getEnd(Ie).latexRecursive(t),t.uncleanedLatex+="}",this.checkCursorContextClose(t)},e.prototype.mathspeak=function(){var t=this.getEnd(Me).mathspeak(),e=this.getEnd(Ie).mathspeak();return this.getEnd(Me).ariaLabel="Index",this.getEnd(Ie).ariaLabel="Radicand","3"===t?"Start Cube Root, "+e+", End Cube Root":"Root Index "+t+", Start Root, "+e+", End Root"},e.prototype.deleteTowards=function(t,e){Ft.prototype.deleteTowards.call(this,t,e)},e}(we),Z.nthroot=Ee,Z.cbrt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){t.prototype.createLeftOf.call(this,e),new Pt("3").createLeftOf(e),e.controller.moveRight()},e}(Ee),ke=function(t){function e(e,n,r){var o=new Tt(1,function(t){return Re("span",{class:"mq-non-leaf"},[Re("span",{class:"mq-diacritic-above"},[n]),Re.block("span",{class:"mq-diacritic-stem"},t[0])])});return t.call(this,e,o,r)||this}return __extends(e,t),e}(Ft),Z.vec=function(){return new ke("\\vec",Re.entityText("&rarr;"),["vec(",")"])},Z.tilde=function(){return new ke("\\tilde",Re.text("~"),["tilde(",")"])},Le=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setDOM=function(e){var n,r;return t.prototype.setDOM.call(this,e),r=this.domFrag().children(),r.isEmpty()||(this.delimFrags=(n={},n[Me]=r.first(),n[Ie]=r.last(),n)),this},e}(Ft),Se=function(t){function e(e,n,r,o,i){var s,a=t.call(this,"\\left"+o,void 0,[n,r])||this;return a.side=e,a.sides=(s={},s[Me]={ch:n,ctrlSeq:o},s[Ie]={ch:r,ctrlSeq:i},s),a}return __extends(e,t),e.prototype.numBlocks=function(){return 1},e.prototype.html=function(){var e=this,n=this.getSymbol(Me),r=this.getSymbol(Ie);return this.domView=new Tt(1,function(t){return Re("span",{class:"mq-non-leaf mq-bracket-container"},[Re("span",{style:"width:"+n.width,class:"mq-scaled mq-bracket-l mq-paren"+(e.side===Ie?" mq-ghost":"")},[n.html()]),Re.block("span",{style:"margin-left:"+n.width+";margin-right:"+r.width,class:"mq-bracket-middle mq-non-leaf"},t[0]),Re("span",{style:"width:"+r.width,class:"mq-scaled mq-bracket-r mq-paren"+(e.side===Me?" mq-ghost":"")},[r.html()])])}),t.prototype.html.call(this)},e.prototype.getSymbol=function(t){var e=this.sides[t||Ie].ch;return se[e]||{width:"0",html:""}},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+="\\left"+this.sides[Me].ctrlSeq,this.getEnd(Me).latexRecursive(t),t.uncleanedLatex+="\\right"+this.sides[Ie].ctrlSeq,this.checkCursorContextClose(t)},e.prototype.mathspeak=function(e){var n,r=this.sides[Me].ch,o=this.sides[Ie].ch;if("|"===r&&"|"===o)this.mathspeakTemplate=["StartAbsoluteValue,",", EndAbsoluteValue"],this.ariaLabel="absolute value";else{if(e&&e.createdLeftOf&&this.side)return n="",this.side===Me?n=this.textTemplate[0]:this.side===Ie&&(n=this.textTemplate[1]),(this.side===Me?"left ":"right ")+qe[n];this.mathspeakTemplate=["left "+qe[r]+",",", right "+qe[o]],this.ariaLabel=qe[r]+" block"}return t.prototype.mathspeak.call(this)},e.prototype.matchBrack=function(t,n,r){return r instanceof e&&r.side&&r.side!==-n&&(!t.restrictMismatchedBrackets||_e[this.sides[this.side].ch]===r.sides[r.side].ch||"none"!==t.restrictMismatchedBrackets&&{"(":"]","[":")"}[this.sides[Me].ch]===r.sides[Ie].ch)&&r},e.prototype.closeOpposing=function(t){t.side=0,t.sides[this.side]=this.sides[this.side];var e=t.delimFrags[this.side===Me?Me:Ie].removeClass("mq-ghost");this.replaceBracket(e,this.side)},e.prototype.createLeftOf=function(e){var n,r,o;this.replacedFragment||(r=e.options,n="|"===this.sides[Me].ch?this.matchBrack(r,Ie,e[Ie])||this.matchBrack(r,Me,e[Me])||this.matchBrack(r,0,e.parent.parent):this.matchBrack(r,-this.side,e[-this.side])||this.matchBrack(r,-this.side,e.parent.parent)),n?(o=this.side=-n.side,this.closeOpposing(n),n===e.parent.parent&&e[o]&&new Y(e[o],e.parent.getEnd(o),-o).disown().withDirAdopt(-o,n.parent,n,n[o]).domFrag().insDirOf(o,n.domFrag()),n.bubble(function(t){t.reflow()})):(n=this,o=n.side,n.replacedFragment?n.side=0:e[-o]&&(n.replaces(new Y(e[-o],e.parent.getEnd(-o),o)),e[-o]=0),t.prototype.createLeftOf.call(this,e)),o===Me?e.insAtLeftEnd(n.getEnd(Me)):e.insRightOf(n)},e.prototype.placeCursor=function(){},e.prototype.unwrap=function(){this.getEnd(Me).children().disown().adopt(this.parent,this,this[Ie]).domFrag().insertAfter(this.domFrag()),this.remove()},e.prototype.deleteSide=function(t,e,n){var r,o,i,s,a,l=this.parent,c=this[t],u=l.getEnd(t);if(t===this.side)return this.unwrap(),void(c?n.insDirOf(-t,c):n.insAtDirEnd(t,l));if(r=n.options,o=!this.side,this.side=-t,this.matchBrack(r,t,this.getEnd(Me).getEnd(this.side)))this.closeOpposing(this.getEnd(Me).getEnd(this.side)),i=this.getEnd(Me).getEnd(t),this.unwrap(),i&&i.siblingCreated(n.options,t),c?n.insDirOf(-t,c):n.insAtDirEnd(t,l);else{if(this.matchBrack(r,t,this.parent.parent))this.parent.parent.closeOpposing(this),this.parent.parent.unwrap();else{if(e&&o)return this.unwrap(),void(c?n.insDirOf(-t,c):n.insAtDirEnd(t,l));this.sides[t]=N(this),this.delimFrags[Me].removeClass("mq-ghost"),this.delimFrags[Ie].removeClass("mq-ghost"),s=this.delimFrags[t].addClass("mq-ghost"),this.replaceBracket(s,t)}c?(a=this.getEnd(Me),i=a.getEnd(t),a.domFrag().removeClass("mq-empty"),new Y(c,u,-t).disown().withDirAdopt(-t,a,i,0).domFrag().insAtDirEnd(t,a.domFrag().oneElement()),i&&i.siblingCreated(n.options,t),n.insDirOf(-t,c)):e?n.insDirOf(t,this):n.insAtDirEnd(t,this.getEnd(Me))}},e.prototype.replaceBracket=function(t,e){var n,r,o=this.getSymbol(e);t.children().replaceWith(U(o.html())),t.oneElement().style.width=o.width,e===Me?(n=t.next(),n.isEmpty()||(n.oneElement().style.marginLeft=o.width)):(r=t.prev(),r.isEmpty()||(r.oneElement().style.marginRight=o.width))},e.prototype.deleteTowards=function(t,e){this.deleteSide(-t,!1,e)},e.prototype.finalizeTree=function(){this.getEnd(Me).deleteOutOf=function(t,e){this.parent.deleteSide(t,!0,e)},this.finalizeTree=this.intentionalBlur=function(){this.delimFrags[this.side===Me?Ie:Me].removeClass("mq-ghost"),this.side=0}},e.prototype.siblingCreated=function(t,e){e===-this.side&&this.finalizeTree()},e}(Le),_e={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","\\{":"\\}","\\}":"\\{","&lang;":"&rang;","&rang;":"&lang;","\\langle ":"\\rangle ","\\rangle ":"\\langle ","|":"|","\\lVert ":"\\rVert ","\\rVert ":"\\lVert "},qe={"&lang;":"angle-bracket","&rang;":"angle-bracket","|":"pipe"},B("(","","parenthesis"),B("[","","bracket"),B("{","\\{","brace"),Z.langle=function(){return new Se(Me,"&lang;","&rang;","\\langle ","\\rangle ")},Z.rangle=function(){return new Se(Ie,"&lang;","&rang;","\\langle ","\\rangle ")},
14
+ J["|"]=function(){return new Se(Me,"|","|","|","|")},Z.lVert=function(){return new Se(Me,"&#8741;","&#8741;","\\lVert ","\\rVert ")},Z.rVert=function(){return new Se(Ie,"&#8741;","&#8741;","\\lVert ","\\rVert ")},Z.left=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){var t=ft.regex,e=ft.string,n=ft.optWhitespace;return n.then(t(/^(?:[([|]|\\\{|\\langle(?![a-zA-Z])|\\lVert(?![a-zA-Z]))/)).then(function(r){var o=r.replace(/^\\/,"");return"\\langle"==r&&(o="&lang;",r+=" "),"\\lVert"==r&&(o="&#8741;",r+=" "),Et.then(function(i){return e("\\right").skip(n).then(t(/^(?:[\])|]|\\\}|\\rangle(?![a-zA-Z])|\\rVert(?![a-zA-Z]))/)).map(function(t){var e,n=t.replace(/^\\/,"");return"\\rangle"==t&&(n="&rang;",t+=" "),"\\rVert"==t&&(n="&#8741;",t+=" "),e=new Se(0,o,n,r,t),e.blocks=[i],i.adopt(e,0,0),e})})})},e}(Ft),Z.right=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){return ft.fail("unmatched \\right")},e}(Ft),Ce=se["("],Oe=se[")"],Te=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\binom",e.domView=new Tt(2,function(t){return Re("span",{class:"mq-non-leaf mq-bracket-container"},[Re("span",{style:"width:"+Ce.width,class:"mq-paren mq-bracket-l mq-scaled"},[Ce.html()]),Re("span",{style:"margin-left:"+Ce.width+"; margin-right:"+Oe.width,class:"mq-non-leaf mq-bracket-middle"},[Re("span",{class:"mq-array mq-non-leaf"},[Re.block("span",{},t[0]),Re.block("span",{},t[1])])]),Re("span",{style:"width:"+Oe.width,class:"mq-paren mq-bracket-r mq-scaled"},[Oe.html()])])}),e.textTemplate=["choose(",",",")"],e.mathspeakTemplate=["StartBinomial,","Choose",", EndBinomial"],e.ariaLabel="binomial",e}return __extends(e,t),e.prototype.finalizeTree=function(){var t=this.getEnd(Me),e=this.getEnd(Ie);this.upInto=e.upOutOf=t,this.downInto=t.downOutOf=e,t.ariaLabel="upper index",e.ariaLabel="lower index"},e}(Le),Z.binom=Z.binomial=Te,Z.choose=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(t){ge.prototype.createLeftOf.call(this,t)},e}(Te),Fe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\MathQuillMathField",e.domView=new Tt(1,function(t){return Re("span",{class:"mq-editable-field"},[Re.block("span",{class:"mq-root-block","aria-hidden":"true"},t[0])])}),e}return __extends(e,t),e.prototype.parser=function(){var e=this,n=ft.string,r=ft.regex,o=ft.succeed;return n("[").then(r(/^[a-z][a-z0-9]*/i)).skip(n("]")).map(function(t){e.name=t}).or(o(void 0)).then(t.prototype.parser.call(this))},e.prototype.finalizeTree=function(t){function e(t){if(t.parentNode&&!U(t).hasClass("mq-root-block")&&e(t.parentNode),t.nodeType===Node.ELEMENT_NODE){var n=t;"true"===n.getAttribute("aria-hidden")&&(n.removeAttribute("aria-hidden"),U(t).children().eachElement(function(t){t.setAttribute("aria-hidden","true")}))}}var n=new Ct(this.getEnd(Me),this.domFrag().oneElement(),t);n.KIND_OF_MQ="MathField",n.editable=!0,n.createTextarea(),n.editablesTextareaEvents(),n.cursor.insAtRightEnd(n.root),y(n.root),e(this.domFrag().parent().oneElement()),this.domFrag().oneElement().removeAttribute("aria-hidden")},e.prototype.registerInnerField=function(t,e){var n=this.getEnd(Me).controller,r=new e(n);t[this.name]=r,t.push(r)},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),this.getEnd(Me).latexRecursive(t),this.checkCursorContextClose(t)},e.prototype.text=function(){return this.getEnd(Me).text()},e}(Ft),Z.editable=Z.MathQuillMathField=Fe,De=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setOptions=function(t){function e(){return""}return this.text=t.text||e,this.domView=new Tt(0,function(){return Re("span",{},[o(t.htmlString||"")])}),this.latex=t.latex||e,this},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.uncleanedLatex+=this.latex(),this.checkCursorContextClose(t)},e.prototype.parser=function(){var t=this,e=ft.string,n=ft.regex,r=ft.succeed;return e("{").then(n(/^[a-z][a-z0-9]*/i)).skip(e("}")).then(function(o){return e("[").then(n(/^[-\w\s]*/)).skip(e("]")).or(r(void 0)).map(function(e){return t.setOptions(it[o](e))})})},e}(Dt),Z.embed=De,window.jQuery){ut=g(1);for(Ae in ut)!function(t,e){"function"==typeof e?(m[t]=function(){return ct(),e.apply(this,arguments)},m[t].prototype=e.prototype):m[t]=e}(Ae,ut[Ae])}}();
package/dist/lib.d.ts CHANGED
@@ -122,6 +122,9 @@ export namespace MathQuill {
122
122
  statelessClipboard?: boolean;
123
123
  onPaste?: () => void;
124
124
  onCut?: () => void;
125
+ overridePaste?: (event?: ClipboardEvent) => boolean;
126
+ overrideCopy?: (event?: ClipboardEvent) => boolean;
127
+ overrideCut?: (event?: ClipboardEvent) => boolean;
125
128
  overrideTypedText?: (text: string) => void;
126
129
  overrideKeystroke?: (key: string, event: KeyboardEvent) => void;
127
130
  autoOperatorNames?: string;
package/package.json CHANGED
@@ -23,5 +23,5 @@
23
23
  "./dist/index.global.js",
24
24
  "./style.css"
25
25
  ],
26
- "version": "2026.2.8"
26
+ "version": "2026.2.25"
27
27
  }