@khanacademy/math-input 25.0.5 → 25.1.0

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/dist/index.js CHANGED
@@ -10,7 +10,6 @@ var wonderStuffCore = require('@khanacademy/wonder-stuff-core');
10
10
  var aphrodite = require('aphrodite');
11
11
  var ReactDOM = require('react-dom');
12
12
  var mathjaxRenderer = require('@khanacademy/mathjax-renderer');
13
- var MathQuill = require('mathquill');
14
13
  var perseusCore = require('@khanacademy/perseus-core');
15
14
  var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
16
15
  var Clickable = require('@khanacademy/wonder-blocks-clickable');
@@ -21,30 +20,33 @@ var PropTypes = require('prop-types');
21
20
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
22
21
 
23
22
  function _interopNamespaceCompat(e) {
24
- if (e && typeof e === 'object' && 'default' in e) return e;
25
- var n = Object.create(null);
26
- if (e) {
27
- Object.keys(e).forEach(function (k) {
28
- if (k !== 'default') {
29
- var d = Object.getOwnPropertyDescriptor(e, k);
30
- Object.defineProperty(n, k, d.get ? d : {
31
- enumerable: true,
32
- get: function () { return e[k]; }
33
- });
34
- }
35
- });
36
- }
37
- n.default = e;
38
- return Object.freeze(n);
23
+ if (e && typeof e === 'object' && 'default' in e) return e;
24
+ var n = Object.create(null);
25
+ if (e) {
26
+ Object.keys(e).forEach(function (k) {
27
+ if (k !== 'default') {
28
+ var d = Object.getOwnPropertyDescriptor(e, k);
29
+ Object.defineProperty(n, k, d.get ? d : {
30
+ enumerable: true,
31
+ get: function () { return e[k]; }
32
+ });
33
+ }
34
+ });
35
+ }
36
+ n.default = e;
37
+ return Object.freeze(n);
39
38
  }
40
39
 
41
40
  var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
42
41
  var ReactDOM__default = /*#__PURE__*/_interopDefaultCompat(ReactDOM);
43
- var MathQuill__default = /*#__PURE__*/_interopDefaultCompat(MathQuill);
44
42
  var Clickable__default = /*#__PURE__*/_interopDefaultCompat(Clickable);
45
43
  var PropTypes__default = /*#__PURE__*/_interopDefaultCompat(PropTypes);
46
44
 
47
- const libName="@khanacademy/math-input";const libVersion="25.0.5";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
45
+ const libName="@khanacademy/math-input";const libVersion="25.1.0";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
46
+
47
+ function getDefaultExportFromCjs (x) {
48
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
49
+ }
48
50
 
49
51
  var jsxRuntime = {exports: {}};
50
52
 
@@ -1425,9 +1427,40 @@ var MathFieldActionType=/*#__PURE__*/function(MathFieldActionType){MathFieldActi
1425
1427
 
1426
1428
  var CursorContext=/*#__PURE__*/function(CursorContext){CursorContext["NONE"]="NONE";CursorContext["IN_PARENS"]="IN_PARENS";CursorContext["IN_SUPER_SCRIPT"]="IN_SUPER_SCRIPT";CursorContext["IN_SUB_SCRIPT"]="IN_SUB_SCRIPT";CursorContext["IN_NUMERATOR"]="IN_NUMERATOR";CursorContext["IN_DENOMINATOR"]="IN_DENOMINATOR";CursorContext["BEFORE_FRACTION"]="BEFORE_FRACTION";return CursorContext}({});
1427
1429
 
1430
+ var mathquill_min$1 = {exports: {}};
1431
+
1432
+ /**
1433
+ * @license
1434
+ * MathQuill v1.0.3, by Han, Jeanine, and Mary
1435
+ * http://mathquill.com | maintainers@mathquill.com
1436
+ *
1437
+ * This Source Code Form is subject to the terms of the
1438
+ * Mozilla Public License, v. 2.0. If a copy of the MPL
1439
+ * was not distributed with this file, You can obtain
1440
+ * one at http://mozilla.org/MPL/2.0/.
1441
+ */
1442
+ var mathquill_min = mathquill_min$1.exports;
1443
+
1444
+ var hasRequiredMathquill_min;
1445
+
1446
+ function requireMathquill_min () {
1447
+ if (hasRequiredMathquill_min) return mathquill_min$1.exports;
1448
+ hasRequiredMathquill_min = 1;
1449
+ function noop(){}function walkUpAsFarAsPossible(t){for(;t;){if(!t.parent)return t;t=t.parent;}}function pray(t,e,n){var r,o,i,a,s,l;if(!e){if(r=new Error("prayer failed: "+t),n){o={},r.dcgExtraErrorMetaData=o;for(i in n)a=n[i],s=o[i]={},a?(s.localLatex=a.latex(),(l=walkUpAsFarAsPossible(a))&&(s.rootLatex=l.latex())):s.emptyNode=true;}throw r}}function prayDirection(t){pray("a direction was passed",t===L||t===R);}function parseHTML(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 closest(t,e){var n,r,o,i,a;if("function"==typeof(null===(n=t)||void 0===n?void 0:n.closest))return t.closest(e);if(!(t instanceof HTMLElement))return null;i=Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,a=t;do{if(i.call(a,e))return a;a=null!==(o=null!==(r=null===a||void 0===a?void 0:a.parentElement)&&void 0!==r?r:null===a||void 0===a?void 0:a.parentNode)&&void 0!==o?o:null;}while(null!==a&&1===a.nodeType);return null}function getBoundingClientRect(t){return t.getClientRects().length?t.getBoundingClientRect():{top:0,left:0,height:0,width:0,x:0,y:0,bottom:0,right:0}}function getScrollX(){return void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft}function getScrollY(){return void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}function _insDirOf(t,e,n,r){e.insertBefore(n,t===L?r:r.nextSibling);}function _insAtDirEnd(t,e,n){t===L?n.insertBefore(e,n.firstChild):n.appendChild(e);}function eachNode(t,e){var n,r=t[L];if(r&&(n=t[R]))for(n=n[R];r!==n&&false!==e(r);r=r[R]);}function foldNodes(t,e,n){var r,o=t[L];if(!o)return e;if(!(r=t[R]))return e;for(r=r[R];o!==r;o=o[R])e=n(e,o);return e}function prayWellFormed(t,e,n){pray("a parent is always present",t),pray("leftward is properly set up",function(){return e?e[R]===n&&e.parent===t:t.getEnd(L)===n}(),{parent:t,leftward:e,leftwardL:e&&e[L],leftwardR:e&&e[R],rightwardL:n&&n[L],rightwardR:n&&n[R]}),pray("rightward is properly set up",function(){return n?n[L]===e&&n.parent===t:t.getEnd(R)===e}(),{parent:t,rightward:n,leftwardL:e&&e[L],leftwardR:e&&e[R],rightwardL:n&&n[L],rightwardR:n&&n[R],rightwardParent:n&&n.parent});}function isMQNodeClass(t){return t&&t.prototype instanceof MQNode}function MathQuill(t){return insistOnInterVer(),MQ1||(MQ1=getInterface(1)),MQ1(t)}function getInterface(t){function e(t,e){var n,o,a;for(n in e)if(e.hasOwnProperty(n)){if("substituteKeyboardEvents"===n&&r>=3)throw new Error(["As of interface version 3, the 'substituteKeyboardEvents'","option is no longer supported. Use 'overrideTypedText' and","'overrideKeystroke' instead."].join(" "));o=e[n],a=i[n],t[n]=a?a(o):o;}}function n(t,e){function n(n,o){var i,s;return n&&n.nodeType?(i=u(n))instanceof e?i:(s=new Controller(new e.RootBlock,n,new a(r)),s.KIND_OF_MQ=t,new e(s).__mathquillify(o||{},r)):null}return pray(t+" is defined",e),n.prototype=e.prototype,n}var r,o,i,a,s,l,c,u;if(1!==t&&2!==t&&3!==t)throw "Only interface versions between "+MIN+" and "+MAX+" supported. You specified: "+t;if((r=t)<3){if(!(o=window.jQuery))throw "MathQuill interface version ".concat(r," requires jQuery 1.5.2+ to be loaded first");Options.prototype.jQuery=o;}return i=__assign(__assign({},baseOptionProcessors),{handlers:function(t){return {fns:t||{},APIClasses:c}}}),a=r<3?Options:function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(Options),s=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,o=n.root,i=n.container;n.createTextarea(),e=domFrag(i).addClass(t).children().detach(),o.setDOM(domFrag(h("span",{class:"mq-root-block","aria-hidden":true})).appendTo(i).oneElement()),NodeBase.linkElementByBlockNode(o.domFrag().oneElement(),o),this.latex(e.text()),this.revert=function(){return n.removeMouseEventListener(),domFrag(i).removeClass("mq-editable-field mq-math-mode mq-text-mode").empty().append(e),r<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),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(){return this.__controller.exportLatexSelection()},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.cursor=function(){return this.__controller.cursor},n.prototype.controller=function(){return this.__controller},n.prototype.setAriaStringsOverrideMap=function(t){return this.__controller.setAriaStringsOverrideMap(t),this},n}(Progenote),l=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.setMathspeakOverride=function(t){return NodeBase.prototype.mathspeakOverride=t,e},e}return __extends(e,t),e.prototype.mathquillify=function(e){return t.prototype.mathquillify.call(this,e),this.__controller.editable=true,this.__controller.addMouseEventListener(),this.__controller.editablesTextareaEvents(),this},e.prototype.focus=function(){return this.__controller.getTextareaOrThrow().focus(),this.__controller.scrollHoriz(),this},e.prototype.blur=function(){return this.__controller.getTextareaOrThrow().blur(),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[L]=0,t[R]=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=LatexCmds[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.select=function(){return this.__controller.selectAll(),this},e.prototype.clearSelection=function(){return this.__controller.cursor.clearSelection(),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(L)},e.prototype.moveToRightEnd=function(){return this.moveToDirEnd(R)},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-getScrollX(),i=e-getScrollY(),a=document.elementFromPoint(o,i);this.__controller.seek(a,o,i),r=(new EmbedNode).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}(s),c={AbstractMathQuill:s,EditableField:l},pray("API.StaticMath defined",API.StaticMath),c.StaticMath=API.StaticMath(c),pray("API.MathField defined",API.MathField),c.MathField=API.MathField(c),pray("API.InnerMathField defined",API.InnerMathField),c.InnerMathField=API.InnerMathField(c),API.TextField&&(c.TextField=API.TextField(c)),u=function(t){var e,n,r,o,i,a,s,l;if(!t||!t.nodeType)return null;for(n=domFrag(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 a=NodeBase.getNodeOfElement(e),s=a&&a.controller,l=s&&c[s.KIND_OF_MQ],s&&l?new l(s):null},u.L=L,u.R=R,u.config=function(t){return e(a.prototype,t),this},u.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";EMBEDS[t]=e;},u.StaticMath=n("StaticMath",c.StaticMath),u.MathField=n("MathField",c.MathField),u.InnerMathField=n("InnerMathField",c.InnerMathField),c.TextField&&(u.TextField=n("TextField",c.TextField)),u.prototype=s.prototype,u.EditableField=function(){throw "wtf don't call me, I'm 'abstract'"},u.EditableField.prototype=l.prototype,r<3&&(u.saneKeyboardEvents=defaultSubstituteKeyboardEvents),u}function RootBlockMixin(t){t.moveOutOf=function(t){pray("controller is defined",this.controller),this.controller.handle("moveOutOf",t);},t.deleteOutOf=function(t){pray("controller is defined",this.controller),this.controller.handle("deleteOutOf",t);},t.selectOutOf=function(t){pray("controller is defined",this.controller),this.controller.handle("selectOutOf",t);},t.upOutOf=function(){pray("controller is defined",this.controller),this.controller.handle("upOutOf");},t.downOutOf=function(){pray("controller is defined",this.controller),this.controller.handle("downOutOf");},t.reflow=function(){pray("controller is defined",this.controller),this.controller.handle("reflow"),this.controller.handle("edited"),this.controller.handle("edit");};}function parseError(t,e){throw t=t?"'"+t+"'":"EOF","Parse Error: "+e+" at "+t}function defaultSubstituteKeyboardEvents(t,e){return saneKeyboardEvents(t[0],e)}function bindVanillaSymbol(t,e,n){return function(){return new VanillaSymbol(t,e?h.entityText(e):void 0,n)}}function bindBinaryOperator(t,e,n,r){return function(){return new BinaryOperator(t,e?h.entityText(e):void 0,n,r)}}function bindVariable(t,e,n){return function(){return new Variable(t,h.entityText(e))}}function defaultAutoOpNames(){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)BuiltInOpNames[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)BuiltInOpNames[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}function isBinaryOperator(t){if(!t)return false;var e=t[L];return e?!(e instanceof BinaryOperator||/^(\\ )|[,;:\(\[]$/.test(e.ctrlSeq)):!!(t.parent&&t.parent.parent&&t.parent.parent.isStyleBlock())&&isBinaryOperator(t.parent.parent)}function getCtrlSeqsFromBlock(t){if(!t)return "";var e="";return t.eachChild(function(t){ void 0!==t.ctrlSeq&&(e+=t.ctrlSeq);}),e}function insLeftOfMeUnlessAtEnd(t){var e=this.parent,n=t;do{if(n[R])return t.insLeftOf(e);n=n.parent.parent;}while(n!==e);t.insRightOf(e);}function getOppBracketSide(t){var e=t.side,n=t.sides[e];return {ch:OPP_BRACKS[n.ch],ctrlSeq:OPP_BRACKS[n.ctrlSeq]}}function bindCharBracketPair(t,e,n){var r,o;e=e||t,r=OPP_BRACKS[t],o=OPP_BRACKS[e],CharCmds[t]=function(){return new Bracket(L,t,r,e,o)},CharCmds[r]=function(){return new Bracket(R,t,r,e,o)},BRACKET_NAMES[t]=BRACKET_NAMES[r]=n;}function TextBlockFuseChildren(t){var e,n,r;if(t.domFrag().oneElement().normalize(),e=t.domFrag().children(),!e.isEmpty())return n=e.oneText(),pray("only node in TextBlock span is Text node",3===n.nodeType),r=new TextPiece(n.data),r.setDOM(n),t.children().disown(),r.adopt(t,0,0),r}function makeTextBlock(t,e,n,r){return function(o){function i(){var n=null!==o&&o.apply(this,arguments)||this;return n.ctrlSeq=t,n.mathspeakTemplate=["Start"+e,"End"+e],n.ariaLabel=e,n}return __extends(i,o),i.prototype.html=function(){var t=h(n,r,[h.text(this.textContents())]);return this.setDOM(t),NodeBase.linkElementByCmdNode(t,this),t},i}(TextBlock)}var U_NO_BREAK_SPACE,U_ZERO_WIDTH_SPACE,U_DOT_ABOVE,U_NARY_SUMMATION,U_NARY_PRODUCT,U_NARY_COPRODUCT,U_INTEGRAL,animate,Aria,DOMFragment,domFrag,Point,NodeBase,Fragment,LatexCmds,CharCmds,Anticursor,Cursor,MQSelection,ControllerBase,API,EMBEDS,baseOptionProcessors,Options,Progenote,insistOnInterVer,MQ1,MIN,MAX,Parser,EveryTick,saneKeyboardEvents,Controller_exportText,Controller_focusBlur,INCREMENTAL_SELECTION_OPEN,MQNode,Controller_keystroke,latexMathParser,Controller_latex,ignoreNextMouseDownNoop,cancelSelectionOnEdit,Controller_mouse,Controller_scrollHoriz,Controller,MathElement,DOMView,MathCommand,MQSymbol,VanillaSymbol,BinaryOperator,MathBlock,RootMathBlock,DigitGroupingChar,Digit,Variable,Letter,BuiltInOpNames,TwoWordOpNames,OperatorName,fn,NonSymbolaSymbol,LatexFragment,PlusMinus,MinusNode,To,Inequality,less,greater,Greater,Equality,Sim,Approx,SVG_SYMBOLS,Style,intRgx,SupSub,SubscriptCommand,SummationNotation,Fraction,LiveFraction,AnsBuilder,PercentOfBuilder,Token,SquareRoot,NthRoot,DiacriticAbove,DelimsNode,Bracket,OPP_BRACKS,BRACKET_NAMES,leftBinomialSymbol,rightBinomialSymbol,Binomial,MathFieldNode,EmbedNode,TextBlock,TextPiece,RootMathCommand,RootTextBlock,__extends=mathquill_min&&mathquill_min.__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=mathquill_min&&mathquill_min.__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)},L=-1,R=1,min=Math.min,max=Math.max,h=function(t,e,n){var r,o,i,a;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(a=0;a<n.length;a++)r.appendChild(n[a]);return r};h.text=function(t){return document.createTextNode(t)},h.block=function(t,e,n){var r=h(t,e,[n.html()]);return n.setDOM(r),NodeBase.linkElementByBlockNode(r,n),r},h.entityText=function(t){var e=parseHTML(t);return pray("entity parses to a single text node",e instanceof DocumentFragment&&1===e.childNodes.length&&e.childNodes[0]instanceof Text),e.childNodes[0]},U_NO_BREAK_SPACE=" ",U_ZERO_WIDTH_SPACE="​",U_DOT_ABOVE="˙",U_NARY_SUMMATION="∑",U_NARY_PRODUCT="∏",U_NARY_COPRODUCT="∐",U_INTEGRAL="∫",animate=function(){var t,e;return "function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame?(t=requestAnimationFrame,e=cancelAnimationFrame):(t=function(t){return window.setTimeout(t,13)},e=clearTimeout),function(n,r){function o(){var t=(Date.now()-l)/n;t<=c?a():c=t,r(c,a,i);}function i(){ void 0!==s&&e(s),s=void 0;}function a(){i(),s=t(o);}var s,l=Date.now(),c=0;r(n<=0?1:0,a,i);}}(),Aria=function(){function t(t){this.span=h("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&&domFrag(t).prepend(domFrag(this.span));},t.prototype.queue=function(t,e){return void 0===e&&(e=false),this.items.push(this.processQueueItems(t,e)),this},t.prototype.processQueueItems=function(t,e){var n,r;return void 0===e&&(e=false),n=Array.isArray(t)?t:[t],r=n.map(function(t){if(t instanceof MQNode){var n=t.mathspeak({ignoreShorthand:true});if(e){if(t.parent&&t.parent.ariaLabel&&"block"===t.ariaLabel)return t.parent.ariaLabel+" "+n;if(t.ariaLabel)return t.ariaLabel+" "+n}return n}return t||""}),r.join(" ")},t.prototype.queueDirOf=function(t,e,n){ void 0===n&&(n=false),prayDirection(t);var r=t===L?"before":"after";return this.queueDir(r,e,n)},t.prototype.queueDirEndOf=function(t,e,n){ void 0===n&&(n=false),prayDirection(t);var r=t===L?"beginning of":"end of";return this.queueDir(r,e,n)},t.prototype.queueDir=function(t,e,n){var r;return void 0===n&&(n=false),(null===(r=this.controller.ariaStringsOverrideMap)||void 0===r?void 0:r[t])?this.queue(this.controller.ariaStringsOverrideMap[t](this.processQueueItems(e,n))):this.queue(t).queue(e,n)},t.prototype.queueSelected=function(t,e){return void 0===e&&(e=false),this.controller.ariaStringsOverrideMap&&this.controller.ariaStringsOverrideMap.selected?this.queue(this.controller.ariaStringsOverrideMap.selected(this.processQueueItems(t,e)),e):this.queue(t,e).queue(" selected")},t.prototype.queueTranslatableString=function(t){var e,n=null===(e=this.controller.ariaStringsOverrideMap)||void 0===e?void 0:e[t];return n&&"string"==typeof n?this.queue(n):this.queue(t)},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(){return this.items.length=0,this},t}(),DOMFragment=function(){function t(t,e){var n;1===arguments.length&&(e=t),t&&e&&(this.ends=(n={},n[L]=t,n[R]=e,n));}return t.create=function(e,n){1===arguments.length&&(n=e),pray("No half-empty DOMFragments",!!e==!!n);var r=new t(e,n);return pray("last is a forward sibling of first",r.isValid()),r},t.prototype.isEmpty=function(){return void 0===this.ends},t.prototype.isOneNode=function(){return !(!this.ends||this.ends[L]!==this.ends[R])},t.prototype.isValid=function(){if(!this.ends)return true;if(this.ends[L]===this.ends[R])return true;var t;return this.eachNode(function(e){return t=e}),t===this.ends[R]},t.prototype.firstNode=function(){return pray("Fragment is not empty",this.ends),this.ends[L]},t.prototype.lastNode=function(){return pray("Fragment is not empty",this.ends),this.ends[R]},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 n,r;if(!this.ends)return e;if(!e.ends)return this;for(n=false,r=this.ends[R].nextSibling;r;){if(r===e.ends[L]){n=true;break}r=r.nextSibling;}return pray("sibling must be a forward DOM sibling of this fragment",n),new t(this.ends[L],e.ends[R])},t.prototype.oneNode=function(){return pray("Fragment has a single node",this.ends&&this.ends[L]===this.ends[R]),this.ends[L]},t.prototype.oneElement=function(){var t=this.oneNode();return pray("Node is an Element",t.nodeType===Node.ELEMENT_NODE),t},t.prototype.oneText=function(){var t=this.oneNode();return pray("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[R],n=this.ends[L],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(L,t)},t.prototype.insertAfter=function(t){return this.insDirOf(R,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(R,t)},t.prototype.prependTo=function(t){return this.insAtDirEnd(L,t)},t.prototype.parent=function(){if(!this.ends)return this;var e=this.ends[L].parentNode;return e?new t(e):new t},t.prototype.wrapAll=function(t){var e,n;return t.textContent="",this.ends?(e=this.ends[L].parentNode,n=this.ends[R].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[R],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[L];e;){if(e.nodeType===Node.ELEMENT_NODE){if(t<=0)return e;t-=1;}if(e===this.ends[R])return;e=e.nextSibling;}},t.prototype.firstElement=function(){return this.nthElement(0)},t.prototype.lastElement=function(){if(this.ends)for(var t=this.ends[R];t;){if(t.nodeType===Node.ELEMENT_NODE)return t;if(t===this.ends[L])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[R]):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?(_insDirOf(t,r.parentNode,this.toDocumentFragment(),r),this):this.detach():this},t.prototype.insAtDirEnd=function(t,e){return this.ends?(_insAtDirEnd(t,this.toDocumentFragment(),e),this):this},t.prototype.hasClass=function(t){var e=false;return this.eachElement(function(n){n.classList.contains(t)&&(e=true);}),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,a;if(true===e)return this.addClass(t);if(false===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++)a=i[o],n(a);return this},t}(),domFrag=DOMFragment.create,Point=function(){function t(t,e,n){this.init(t,e,n);}return t.prototype.init=function(t,e,n){this.parent=t,this[L]=e,this[R]=n;},t.copy=function(e){return new t(e.parent,e[L],e[R])},t}(),NodeBase=function(){function t(){var r;this[e]=0,this[n]=0,this.parent=0,this.ends=(r={},r[L]=0,r[R]=0,r),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,pray("No half-empty node ends",!!this.ends[L]==!!this.ends[R]);},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&&pray("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 domFrag(this._el)},t.prototype.createDir=function(t,e){prayDirection(t);var n=this;return n.html(),n.domFrag().insDirOf(t,e.domFrag()),e[t]=n.adopt(e.parent,e[L],e[R]),n},t.prototype.createLeftOf=function(t){this.createDir(L,t);},t.prototype.selectChildren=function(t,e){return new MQSelection(t,e)},t.prototype.bubble=function(t){var e,n=this.getSelfNode();for(e=n;e&&false!==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),true)}(e),e},t.prototype.isEmpty=function(){return 0===this.ends[L]&&0===this.ends[R]},t.prototype.isQuietEmptyDelimiter=function(t){if(!this.isEmpty())return false;if(!t)return false;if(!this.parent||void 0===this.parent.ctrlSeq)return false;var e=this.parent.ctrlSeq.replace(/^\\(left|right)?/,"");return t.hasOwnProperty(e)},t.prototype.isStyleBlock=function(){return false},t.prototype.isTextBlock=function(){return false},t.prototype.children=function(){return new Fragment(this.getEnd(L),this.getEnd(R))},t.prototype.eachChild=function(t){return eachNode(this.ends,t),this},t.prototype.foldChildren=function(t,e){return foldNodes(this.ends,t,e)},t.prototype.withDirAdopt=function(t,e,n,r){var o=this.getSelfNode();return new Fragment(o,o).withDirAdopt(t,e,n,r),this},t.prototype.adopt=function(t,e,n){var r=this.getSelfNode();return new Fragment(r,r).adopt(t,e,n),this.getSelfNode()},t.prototype.disown=function(){var t=this.getSelfNode();return new Fragment(t,t).disown(),this},t.prototype.remove=function(){return this.domFrag().remove(),this.disown()},t.prototype.shouldIgnoreSubstitutionInSimpleSubscript=function(t){return !!t.disableAutoSubstitutionInSubscripts&&(!!this.parent&&(this.parent.parent instanceof SupSub&&!!this.parent.domFrag().hasClass("mq-sub")))},t.prototype.getSelfNode=function(){return this},t.prototype.parser=function(){pray("Abstract parser() method is never called",false);},t.prototype.html=function(){throw new Error("html() unimplemented in NodeBase")},t.prototype.text=function(){return ""},t.prototype.latex=function(){var t={latex:"",startIndex:-1,endIndex:-1};return this.latexRecursive(t),t.latex},t.prototype.latexRecursive=function(t){},t.prototype.checkCursorContextOpen=function(t){t.startSelectionBefore===this&&(t.startIndex=t.latex.length),t.endSelectionBefore===this&&(t.endIndex=t.latex.length);},t.prototype.checkCursorContextClose=function(t){t.startSelectionAfter===this&&(t.startIndex=t.latex.length),t.endSelectionAfter===this&&(t.endIndex=t.latex.length);},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){pray("Abstract chToCmd() method is never called",false);},t.prototype.mathspeak=function(t){return this.mathspeakOverride?this.mathspeakOverride(this.latex()):""},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,n;return e=L,n=R,t.idCounter=0,t}(),Fragment=function(){function t(t,e,n){var r,o,i,a;if(this.disowned=false,void 0===n&&(n=L),prayDirection(n),pray("no half-empty fragments",!t==!e,{withDir:t,oppDir:e}),!t||!e)return void this.setEnds((r={},r[L]=0,r[R]=0,r));pray("withDir is passed to Fragment",t instanceof MQNode),pray("oppDir is passed to Fragment",e instanceof MQNode),pray("withDir and oppDir have the same parent",t.parent===e.parent),o={},o[n]=t,o[-n]=e,i=o,this.setEnds(i),a=0,this.each(function(t){a=t;}),pray("following direction siblings from start reaches end",a===i[R]);}return t.prototype.getDOMFragFromEnds=function(){var t=this.ends[L],e=this.ends[R];return 0===t||0===e?domFrag():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===L?this.adopt(e,n,r):this.adopt(e,r,n)},t.prototype.adopt=function(t,e,n){var r,o,i,a,s;return prayWellFormed(t,e,n),o=this,this.disowned=false,(i=o.ends[L])&&(a=o.ends[R])?(r={},r[L]=t.getEnd(L),r[R]=t.getEnd(R),s=r,e||(s[L]=i),n?n[L]=a:s[R]=a,t.setEnds(s),a[R]=n,o.each(function(n){return n[L]=e,n.parent=t,e&&(e[R]=n),e=n,true}),o):this},t.prototype.disown=function(){var t,e,n,r,o,i,a=this,s=a.ends[L];return !s||a.disowned?a:(this.disowned=true,(e=a.ends[R])?(n=s.parent,prayWellFormed(n,s[L],s),prayWellFormed(n,e,e[R]),t={},t[L]=n.getEnd(L),t[R]=n.getEnd(R),r=t,s[L]?(o=s[L],o[R]=e[R]):r[L]=e[R],e[R]?(i=e[R],i[L]=s[L]):r[R]=s[L],r[L]&&r[R]?n.setEnds(r):n.ends=r,a):a)},t.prototype.remove=function(){return this.domFrag().remove(),this.disown()},t.prototype.each=function(t){return eachNode(this.ends,t),this},t.prototype.fold=function(t,e){return foldNodes(this.ends,t,e)},t}(),LatexCmds={},CharCmds={},Anticursor=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[L],t[R])},e}(Point),Cursor=function(t){function e(e,n,r){var o=t.call(this,e,0,0)||this;return o.upDownCache={},o.cursorElement=h("span",{class:"mq-cursor"},[h.text(U_ZERO_WIDTH_SPACE)]),o._domFrag=domFrag(),o.controller=r,o.options=n,o.setDOMFrag(domFrag(o.cursorElement)),o.blink=function(){domFrag(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 domFrag(this.cursorElement).removeClass("mq-blink"),this.setDOMFrag(domFrag(this.cursorElement)),this.intervalId?clearInterval(this.intervalId):(t=this[R],t?(e=this.selection,e&&e.getEnd(L)[L]===this[L]?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(domFrag()),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 prayDirection(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(L,t)},e.prototype.insRightOf=function(t){return this.insDirOf(R,t)},e.prototype.insAtDirEnd=function(t,e){return prayDirection(t),this.domFrag().insAtDirEnd(t,e.domFrag().oneElement()),this.withDirInsertAt(t,e,0,e.getEnd(t)),e.focus(),this},
1450
+ e.prototype.insAtLeftEnd=function(t){return this.insAtDirEnd(L,t)},e.prototype.insAtRightEnd=function(t){return this.insAtDirEnd(R,t)},e.prototype.jumpUpDown=function(t,e){var n,r,o,i=this;i.upDownCache[t.id]=Point.copy(i),n=i.upDownCache[e.id],n?(r=n[R],r?i.insLeftOf(r):i.insAtRightEnd(n.parent)):(o=i.getBoundingClientRectWithoutMargin().left,e.seek(o,i)),i.controller.aria.queue(e,true);},e.prototype.getBoundingClientRectWithoutMargin=function(){var t,e,n,r=this.domFrag();return r.removeClass("mq-cursor"),t=getBoundingClientRect(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,a=i.parent,s=i[R],l=this,c=i[L];if(i.disown().eachChild(function(t){return !!t.isEmpty()||(t.children().adopt(a,c,s).each(function(t){return t.domFrag().insertBefore(i.domFrag()),true}),c=t.getEnd(R),true)}),!this[R])if(t=this[L])this[R]=t[R];else for(;!this[R];){if(!(e=this.parent[R])){this[R]=i[R],this.parent=a;break}this.parent=e,this[R]=e.getEnd(L);}n=this[R],n?this.insLeftOf(n):this.insAtRightEnd(a),i.domFrag().remove(),r=i[L],o=i[R],r&&r.siblingDeleted(l.options,R),o&&o.siblingDeleted(l.options,L);},e.prototype.startSelection=function(){var t,e=this.anticursor=Anticursor.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,n,r,o,i,a,s,l,c=this.anticursor;if(this[L]===c[L]&&this.parent===c.parent)return false;for(e=this;e.parent;e=e.parent)if(e.parent.id in c.ancestors){t=e.parent;break}if(pray("cursor and anticursor in the same tree",t),n=t,r=c.ancestors[n.id],a=R,e[L]!==r)for(s=e;s;s=s[R])if(s[R]===r[R]){a=L,o=e,i=r;break}return a===R&&(o=r,i=e),o instanceof Point&&(o=o[R]),i instanceof Point&&(i=i[L]),this.hide().selection=n.selectChildren(o,i),l=this.selection.getEnd(a),this.insDirOf(a,l),this.selectionChanged(),true},e.prototype.resetToEnd=function(t){this.clearSelection();var e=t.root;this[R]=0,this[L]=e.getEnd(R),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[L]=t.getEnd(L)[L],this[R]=t.getEnd(R)[R],t.remove(),this.selectionChanged(),delete this.selection);},e.prototype.replaceSelection=function(){var t=this.selection;return t&&(this[L]=t.getEnd(L)[L],this[R]=t.getEnd(R)[R],delete this.selection),t},e.prototype.depth=function(){for(var t=this,e=0;t=t.parent;)e+=t instanceof MathBlock?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}(Point),MQSelection=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o._el=h("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():domFrag(this._el)},e.prototype.setEnds=function(t){pray("Selection ends are never empty",t[L]&&t[R]),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}(Fragment),ControllerBase=function(){function t(t,e,n){this.textareaEventListeners={},this.id=t.id,this.data={},this.root=t,this.container=e,this.options=n,this.aria=new Aria(this.getControllerSelf()),this.ariaLabel="Math Input",this.ariaPostLabel="",this.mathSpeakCallback=void 0,t.controller=this.getControllerSelf(),this.cursor=t.cursor=new Cursor(t,n,this.getControllerSelf());}return t.prototype.getControllerSelf=function(){return this},t.prototype.handle=function(t,e){var n,r,o,i=this.options.handlers,a=null===(n=this.options.handlers)||void 0===n?void 0:n.fns[t];a&&(r=null===i||void 0===i?void 0:i.APIClasses[this.KIND_OF_MQ],pray("APIClass is defined",r),o=new r(this),e===L||e===R?a(e,o):a(o));},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&&"string"==typeof t&&""!==t?this.ariaLabel=t:this.editable?this.ariaLabel="Math Input":this.ariaLabel="",this.ariaLabel===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=window.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.getTextareaOrThrow=function(){var t=this.textarea;if(!t)throw new Error("expected a textarea");return t},t.prototype.getTextareaSpanOrThrow=function(){var t=this.textareaSpan;if(!t)throw new Error("expected a textareaSpan");return 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.setAriaStringsOverrideMap=function(t){return this.ariaStringsOverrideMap=t,this},t.prototype.updateMathspeak=function(){},t.prototype.scrollHoriz=function(){},t.prototype.selectionChanged=function(){},t.prototype.setOverflowClasses=function(){},t.notifyees=[],t}(),API={},EMBEDS={},baseOptionProcessors={},Options=function(){function t(t){this.version=t;}return t.prototype.assertJquery=function(){return pray("Interface versions > 2 do not depend on JQuery",this.version<=2),pray("JQuery is set for interface v < 3",this.jQuery),this.jQuery},t}(),Progenote=function(){function t(){}return t}(),insistOnInterVer=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');},MathQuill.prototype=Progenote.prototype,MathQuill.VERSION="v1.0.3",MathQuill.interfaceVersion=function(t){if(1!==t)throw "Only interface version 1 supported. You specified: "+t;return insistOnInterVer=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');},insistOnInterVer(),MathQuill},MathQuill.getInterface=getInterface,MIN=getInterface.MIN=1,MAX=getInterface.MAX=3,Parser=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,parseError)},t.prototype.or=function(e){pray("or is passed a parser",e instanceof t);var n=this;return new t(function(t,r,o){function i(n){return e._(t,r,o)}return n._(t,r,i)})},t.prototype.then=function(e){var n=this;return new t(function(r,o,i){function a(n,r){var a=e instanceof t?e:e(r);return pray("a parser is returned",a instanceof t),a._(n,o,i)}return n._(r,a,i)})},t.prototype.many=function(){var e=this;return new t(function(t,n,r){function o(e,n){return t=e,a.push(n),true}function i(){return false}for(var a=[];e._(t,o,i););return n(t,a)})},t.prototype.times=function(e,n){arguments.length<2&&(n=e);var r=this;return new t(function(t,o,i){function a(e,n){return p.push(n),t=e,true}function s(e,n){return c=n,t=e,false}function l(t,e){return false}var c,u,p=[],d=true;for(u=0;u<e;u+=1)if(!(d=!!r._(t,a,s)))return i(t,c);for(;u<n&&d;u+=1)r._(t,a,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 a=t.slice(0,n);return a===e?o(t.slice(n),a):i(t,r)})},t.regex=function(e){pray("regexp parser is anchored","^"===e.toString().charAt(1));var n="expected "+e;return new t(function(t,r,o){var i,a=e.exec(t);return a?(i=a[0],r(t.slice(i.length),i)):o(t,n)})},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}(),EveryTick=function(){function t(){this.fn=noop;}return t.prototype.listen=function(t){this.fn=t,clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(this.fn);},t.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);});},t.prototype.clearListener=function(){this.fn=noop,clearTimeout(this.timeoutId);},t.prototype.trigger=function(){var t,e=[];for(t=0;t<arguments.length;t++)e[t]=arguments[t];this.fn.apply(this,e);},t}(),saneKeyboardEvents=function(){function t(t){switch(n(t)){case "Right":case "Left":case "Down":case "Up":return true}return false}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(),L=!!t;}function a(){return "selectionStart"in e&&(e instanceof HTMLTextAreaElement&&e.selectionStart!==e.selectionEnd)}function s(){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,g=null,L&&x.listenOnce(function(t){t&&"focusout"===t.type||o();}),s());}function c(n){x.trigger(n),n.target===e&&(y&&g&&s(),g=n,t(n)?x.listenOnce(d):x.listen(p));}function u(n){x.trigger(n),n.target===e&&y&&!g&&(t(n)?x.listenOnce(d):x.listen(p));}function p(){if(!a()&&e instanceof HTMLTextAreaElement){var t=e.value;(!y||y.altKey||!y.ctrlKey||y.metaKey||!y.shiftKey||"U"!==y.key&&"Unidentified"!==y.key&&"Process"!==y.key)&&(1===t.length?(e.value="",n.options&&n.options.overrideTypedText?n.options.overrideTypedText(t):n.typedText(t)):d());}}function d(){e instanceof HTMLTextAreaElement&&e.value.length>1&&o();}function h(){y=null,g=null,x.clearListener(),e instanceof HTMLTextAreaElement&&(e.value="");}function m(t){x.trigger(),t.target===e&&(document.activeElement!==e&&e.focus(),x.listen(function(){if(e instanceof HTMLTextAreaElement){var t=e.value;e.value="",t&&n.paste(t);}}));}function f(t){x.trigger(t);}var y=null,g=null,x=new EveryTick,L=false;return n.options&&n.options.disableCopyPaste?n.addTextareaEventListeners({keydown:l,keypress:c,keyup:u,focusout:h,copy:function(t){t.preventDefault();},cut:function(t){t.preventDefault();},paste:function(t){x.trigger(),t.preventDefault();},input:f}):n.addTextareaEventListeners({keydown:l,keypress:c,keyup:u,focusout:h,cut:function(){x.listenOnce(function(){n.cut();});},copy:function(){x.listenOnce(function(){n.copy();});},paste:m,input:f}),{select:i}}}(),Controller_exportText=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}(ControllerBase),ControllerBase.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(false!==n.blurred)return;n.disableGroupingForSeconds(1);}}),Controller_focusBlur=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=false,clearTimeout(e.blurTimeout),domFrag(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=true,e.blurTimeout=window.setTimeout(function(){e.root.postOrder(function(t){t.intentionalBlur();}),e.cursor.clearSelection().endSelection(),e.blur(),e.updateMathspeak(),e.scrollHoriz();}),window.addEventListener("blur",e.handleWindowBlur);},e.handleTextareaFocusStatic=function(){e.blurred=false;},e.handleTextareaBlurStatic=function(){e.cursor.selection&&e.cursor.selection.clear(),window.setTimeout(function(){domFrag(e.getTextareaSpanOrThrow()).detach(),e.blurred=true;});},e.handleWindowBlur=function(){clearTimeout(e.blurTimeout),e.cursor.selection&&e.cursor.selection.domFrag().addClass("mq-blur"),e.blur(),e.updateMathspeak();},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=window.setTimeout(function(){e.root.domFrag().removeClass("mq-suppress-grouping");},1e3*t));},e.prototype.blur=function(){this.cursor.hide().parent.blur(this.cursor),domFrag(this.container).removeClass("mq-focused"),window.removeEventListener("blur",this.handleWindowBlur),this.options&&this.options.resetCursorOnBlur&&this.cursor.resetToEnd(this);},e.prototype.addEditableFocusBlurListeners=function(){var t=this,e=t.cursor;this.addTextareaEventListeners({focus:this.handleTextareaFocusEditable,blur:this.handleTextareaBlurEditable}),t.blurred=true,e.hide().parent.blur(e);},e.prototype.addStaticFocusBlurListeners=function(){this.addTextareaEventListeners({focus:this.handleTextareaFocusStatic,blur:this.handleTextareaBlurStatic});},e}(Controller_exportText),INCREMENTAL_SELECTION_OPEN=false,MQNode=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(L);break;case "Shift-Backspace":case "Backspace":r.backspace();break;case "Esc":case "Tab":return void r.escapeDir(R,t,n);case "Shift-Tab":case "Shift-Esc":return void r.escapeDir(L,t,n);case "End":r.notify("move").cursor.insAtRightEnd(o.parent),r.aria.queueDirEndOf(R,o.parent,true);break;case "Ctrl-End":r.notify("move").cursor.insAtRightEnd(r.root),r.aria.queueDirEndOf(R,[r.ariaLabel,r.root,r.ariaPostLabel]);break;case "Shift-End":r.selectToBlockEndInDir(R);break;case "Ctrl-Shift-End":r.selectToRootEndInDir(R);break;case "Home":r.notify("move").cursor.insAtLeftEnd(o.parent),r.aria.queueDirEndOf(L,o.parent,true);break;case "Ctrl-Home":r.notify("move").cursor.insAtLeftEnd(r.root),r.aria.queueDirEndOf(L,[r.ariaLabel,r.root,r.ariaPostLabel]);break;case "Shift-Home":r.selectToBlockEndInDir(L);break;case "Ctrl-Shift-Home":r.selectToRootEndInDir(L);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[L])for(;o[L];)t(L);else t(L);});break;case "Shift-Down":r.withIncrementalSelection(function(t){if(o[R])for(;o[R];)t(R);else t(R);});break;case "Ctrl-Up":case "Ctrl-Down":break;case "Ctrl-Shift-Del":case "Ctrl-Del":r.ctrlDeleteDir(R);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.queueTranslatableString("nothing above");break;case "Ctrl-Alt-Down":o.parent&&o.parent instanceof e?r.aria.queue(o.parent):r.aria.queueTranslatableString("block is empty");break;case "Ctrl-Alt-Left":o.parent.parent&&o.parent.parent.getEnd(L)?r.aria.queue(o.parent.parent.getEnd(L)):r.aria.queueTranslatableString("nothing to the left");break;case "Ctrl-Alt-Right":o.parent.parent&&o.parent.parent.getEnd(R)?r.aria.queue(o.parent.parent.getEnd(R)):r.aria.queueTranslatableString("nothing to the right");break;case "Ctrl-Alt-Shift-Down":o.selection?r.aria.queueSelected(o.selection.join("mathspeak"," ").trim()):r.aria.queueTranslatableString("nothing selected");break;case "Ctrl-Alt-=":case "Ctrl-Alt-Shift-Right":r.ariaPostLabel.length?r.aria.queue(r.ariaPostLabel):r.aria.queueTranslatableString("no answer");break;default:return}r.aria.alert(),null===n||void 0===n||n.preventDefault(),r.scrollHoriz();},e.prototype.moveOutOf=function(t,e,n){pray("overridden or never called on this node",false);},e.prototype.moveTowards=function(t,e,n){pray("overridden or never called on this node",false);},e.prototype.deleteOutOf=function(t,e){pray("overridden or never called on this node",false);},e.prototype.deleteTowards=function(t,e){pray("overridden or never called on this node",false);},e.prototype.unselectInto=function(t,e){pray("overridden or never called on this node",false);},e.prototype.selectOutOf=function(t,e){pray("overridden or never called on this node",false);},e.prototype.selectTowards=function(t,e){pray("overridden or never called on this node",false);},e}(NodeBase),ControllerBase.onNotify(function(t,e){"move"!==e&&"upDown"!==e||t.show().clearSelection();}),baseOptionProcessors.leftRightIntoCmdGoes=function(t){if(t&&"up"!==t&&"down"!==t)throw '"up" or "down" required for leftRightIntoCmdGoes option, got "'+t+'"';return t},ControllerBase.onNotify(function(t,e){"upDown"!==e&&(t.upDownCache={});}),ControllerBase.onNotify(function(t,e){"edit"===e&&t.show().deleteSelection();}),ControllerBase.onNotify(function(t,e){"select"!==e&&t.endSelection();}),Controller_keystroke=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){prayDirection(t);var r=this.cursor;if(r.parent!==this.root&&(null===n||void 0===n||n.preventDefault()),r.parent!==this.root)return r.clearSelection(),r.parent.moveOutOf(t,r),r.controller.aria.alert(),this.notify("move")},e.prototype.moveDir=function(t){var e,n,r;return prayDirection(t),e=this.cursor,n=e.options.leftRightIntoCmdGoes,r=e[t],e.selection?e.insDirOf(t,e.selection.getEnd(t)):r?r.moveTowards(t,e,n):e.parent.moveOutOf(t,e,n),this.notify("move")},e.prototype.moveLeft=function(){return this.moveDir(L)},e.prototype.moveRight=function(){return this.moveDir(R)},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,a,s=this,l=s.notify("upDown").cursor;return "up"===t?(e="upInto",n="upOutOf"):(e="downInto",n="downOutOf"),r=l[L],o=l[R],i=o&&o[e],a=r&&r[e],i?l.insAtLeftEnd(i):a?l.insAtRightEnd(a):l.parent.bubble(function(t){var e=t[n];if(e&&("function"==typeof e&&(e=e.call(t,l)),e instanceof MQNode&&l.jumpUpDown(t,e),true!==e))return false}),s},e.prototype.deleteDir=function(t){var e,n,r,o,i,a,s,l,c,u;return prayDirection(t),e=this.cursor,n=e[t],r=e.parent.parent,o=e.controller,n&&n instanceof MQNode?n.sides?o.aria.queue(n.parent.chToCmd(n.sides[-t].ch).mathspeak({createdLeftOf:e})):n.blocks||"\\text"===n.parent.ctrlSeq||o.aria.queue(n):r&&r instanceof MQNode&&(r.sides?o.aria.queue(r.parent.chToCmd(r.sides[t].ch).mathspeak({createdLeftOf:e})):r.blocks&&r.mathspeakTemplate?r.upInto&&r.downInto?o.aria.queue(r.mathspeakTemplate[1]):(i=r.mathspeakTemplate,a=t===L?i[0]:i[i.length-1],o.aria.queue(a)):o.aria.queue(r)),s=e.selection,this.notify("edit"),s||(l=e[t],l?l.deleteTowards(t,e):e.parent.deleteOutOf(t,e)),c=e[L],u=e[R],c.siblingDeleted&&c.siblingDeleted(e.options,R),u.siblingDeleted&&u.siblingDeleted(e.options,L),e.parent.bubble(function(t){t.reflow();}),this},e.prototype.ctrlDeleteDir=function(t){var e,n,r,o;return prayDirection(t),e=this.cursor,!e[t]||e.selection?this.deleteDir(t):(this.notify("edit"),n=t===L?new Fragment(e.parent.getEnd(L),e[L]):new Fragment(e[R],e.parent.getEnd(R)),e.controller.aria.queue(n),n.remove(),e.insAtDirEnd(t,e.parent),r=e[L],o=e[R],r&&r.siblingDeleted(e.options,R),o&&o.siblingDeleted(e.options,L),e.parent.bubble(function(t){t.reflow();}),this)},e.prototype.backspace=function(){return this.deleteDir(L)},e.prototype.deleteForward=function(){return this.deleteDir(R)},e.prototype.startIncrementalSelection=function(){pray("Multiple selections can't be simultaneously open",!INCREMENTAL_SELECTION_OPEN),INCREMENTAL_SELECTION_OPEN=true,this.notify("select");var t=this.cursor;t.anticursor||t.startSelection();},e.prototype.selectDirIncremental=function(t){var e,n,r;pray("A selection is open",INCREMENTAL_SELECTION_OPEN),INCREMENTAL_SELECTION_OPEN=true,e=this.cursor,n=e.selection,prayDirection(t),r=e[t],r?n&&n.getEnd(t)===r&&e.anticursor[-t]!==r?r.unselectInto(t,e):r.selectTowards(t,e):e.parent.selectOutOf(t,e);},e.prototype.finishIncrementalSelection=function(){var t,e;pray("A selection is open",INCREMENTAL_SELECTION_OPEN),t=this.cursor,t.clearSelection(),t.select()||t.show(),e=t.selection,e&&t.controller.aria.clear().queueSelected(e.join("mathspeak"," ").trim()),INCREMENTAL_SELECTION_OPEN=false;},e.prototype.withIncrementalSelection=function(t){var e=this;try{this.startIncrementalSelection();try{t(function(t){return e.selectDirIncremental(t)});}finally{this.finishIncrementalSelection();}}finally{INCREMENTAL_SELECTION_OPEN=false;}},e.prototype.selectDir=function(t){this.withIncrementalSelection(function(e){return e(t)});},e.prototype.selectLeft=function(){return this.selectDir(L)},e.prototype.selectRight=function(){return this.selectDir(R)},e.prototype.selectAll=function(){this.notify("move");var t=this.cursor;t.insAtRightEnd(this.root),this.withIncrementalSelection(function(e){for(;t[L];)e(L);});},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}(Controller_focusBlur),function(t){function e(e){return t.call(this)||this}return __extends(e,t),e}(MQNode),latexMathParser=function(){function t(t){var e=new MathBlock;return t.adopt(e,0,0),e}function e(t){var e,n=t[0]||new MathBlock;for(e=1;e<t.length;e+=1)t[e].children().adopt(n,n.getEnd(R),0);return n}var n=Parser.string,r=Parser.regex,o=Parser.letter,i=Parser.digit,a=Parser.any,s=Parser.optWhitespace,l=Parser.succeed,c=Parser.fail,u=o.map(function(t){return new Letter(t)}),p=i.map(function(t){return new Digit(t)}),d=r(/^[^${}\\_^]/).map(function(t){return new VanillaSymbol(t)}),h=r(/^[^\\a-eg-zA-Z]/).or(n("\\").then(r(/^[a-z]+/i).or(r(/^\s+/).result(" ")).or(a))).then(function(t){var e,n,r=LatexCmds[t];return r?r.constructor?(e=r,new e(t).parser()):(n=r,n(t).parser()):c("unknown command: \\"+t)}),m=h.or(u).or(p).or(d),f=n("{").then(function(){return g}).skip(n("}")),y=s.then(f.or(m.map(t))),g=y.many().map(e).skip(s),x=n("[").then(y.then(function(t){return "]"!==t.join("latex")?l(t):c("")}).many().map(e).skip(s)).skip(n("]")),L=g;return L.block=y,L.optBlock=x,L}(),baseOptionProcessors.maxDepth=function(t){return "number"==typeof t?t:void 0},Controller_latex=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.exportLatexSelection=function(){var t,e,n,r,o,i,a,s,l,c,u={latex:"",startIndex:-1,endIndex:-1},p=this.cursor.selection;for(p?(u.startSelectionBefore=p.getEnd(L),u.endSelectionAfter=p.getEnd(R)):(n=this.cursor[L],n?u.startSelectionAfter=n:u.startSelectionBefore=this.cursor.parent,r=this.cursor[R],r?u.endSelectionBefore=r:u.endSelectionAfter=this.cursor.parent),null===(e=(t=this.root).latexRecursive)||void 0===e||e.call(t,u),o=u.latex,i=this.cleanLatex(o),a=u.startIndex,s=u.endIndex,l=0,c=0;c<u.endIndex;c++)o[c]!==i[l]?(c<u.startIndex&&(a-=1),s-=1):l+=1;return {latex:i,startIndex:a,endIndex:s}},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,a,s,l,c,u,p,d,h,m,f,y,g,x,b,C,v,w,S,E,O,k,_=this.root,q=this.classifyLatexForEfficientUpdate(t);if(!q)return false;if(!(a=this.classifyLatexForEfficientUpdate(e))||a.prefix!==q.prefix)return false;for(s=a.digits,l=q.digits,c=false,u=false,"-"===s[0]&&(c=true,s=s.substr(1)),"-"===l[0]&&(u=true,l=l.substr(1)),p=this.root.getEnd(R),d=[],h=s.length-1;h>=0;h--){if(!p||p.ctrlSeq!==s[h])return false;if(p.parent!==_)return false;d.unshift(p),p=p[L];}if(c&&!u){if(!(m=p))return false;if("-"!==m.ctrlSeq)return false;if(m[R]!==d[0])return false;if(m.parent!==_)return false;if((f=m[L])&&f.parent!==_)return false;d[0][L]=m[L],_.getEnd(L)===m&&_.setEnds((n={},n[L]=d[0],n[R]=_.getEnd(R),n)),f&&(f[R]=d[0]),m.domFrag().remove();}for(!c&&u&&(y=new PlusMinus("-"),g=document.createElement("span"),g.textContent="-",y.setDOM(g),x=d[0][L],x&&(x[R]=y),_.getEnd(L)===d[0]&&_.setEnds((r={},r[L]=y,r[R]=_.getEnd(R),r)),y.parent=_,y[L]=d[0][L],y[R]=d[0],d[0][L]=y,y.contactWeld(this.cursor),y.domFrag().insertBefore(d[0].domFrag())),b=Math.min(s.length,l.length),h=0;h<b;h++)C=l[h],p=d[h],p.ctrlSeq!==C&&(p.ctrlSeq=C,p.domFrag().oneElement().textContent=C,p.mathspeakName=C);if(s.length>l.length)for(p=d[l.length-1],_.setEnds((o={},o[L]=_.getEnd(L),o[R]=p,o)),p[R]=0,h=s.length-1;h>=b;h--)d[h].domFrag().remove();if(l.length>s.length){for(v=document.createDocumentFragment(),h=b;h<l.length;h++)w=document.createElement("span"),w.className="mq-digit",w.textContent=l[h],S=new Digit(l[h]),S.parent=_,S.setDOM(w),v.appendChild(w),S[L]=_.getEnd(R),S[R]=0,E=S[L],E[R]=S,_.setEnds((i={},i[L]=_.getEnd(L),i[R]=S,i));_.domFrag().oneElement().appendChild(v);}return (O=this.exportLatex())!==t?(console.warn("tried updating latex efficiently but did not work. Attempted: "+t+" but wrote: "+O),false):(k=_.getEnd(R),k&&k.fixDigitGrouping(this.cursor.options),true)},e.prototype.renderLatexMathFromScratch=function(t){var e,n,r=this.root,o=this.cursor,i=Parser.all,a=Parser.eof,s=latexMathParser.skip(a).or(i.result(false)).parse(t);r.setEnds((e={},e[L]=0,e[R]=0,e)),s&&s.children().adopt(r,0,0),s?(n=r.domFrag(),n.children().remove(),n.oneElement().appendChild(s.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(L)&&r.getEnd(R)&&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,a,s,l,c,u,p,d=this.root,h=this.cursor;if(d.domFrag().children().slice(1).remove(),d.setEnds((e={},e[L]=0,e[R]=0,e)),delete h.selection,h.show().insAtRightEnd(d),n=Parser.regex,r=Parser.string,o=Parser.eof,i=Parser.all,a=r("$").then(latexMathParser).skip(r("$").or(o)).map(function(t){var e,n=new RootMathCommand(h);return n.createBlocks(),e=n.getEnd(L),t.children().adopt(e,0,0),n}),s=r("\\$").result("$"),l=s.or(n(/^[^$]/)).map(function(t){return new VanillaSymbol(t)}),c=a.or(l).many(),u=c.skip(o).or(i.result(false)).parse(t)){for(p=0;p<u.length;p+=1)u[p].adopt(d,d.getEnd(R),0);domFrag(d.html()).appendTo(d.domFrag().oneElement()),d.finalizeInsert(h.options,h);}},e}(Controller_keystroke),ignoreNextMouseDownNoop=function(t){return false},Options.prototype.ignoreNextMousedown=ignoreNextMouseDownNoop,function(){ControllerBase.onNotify(function(t,e){"edit"!==e&&"replace"!==e||cancelSelectionOnEdit&&cancelSelectionOnEdit.cursor===t&&cancelSelectionOnEdit.cb();});}(),Controller_mouse=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.handleMouseDown=function(t){function n(t){s=t.target;}function r(t){h.anticursor||h.startSelection(),d.seek(s,t.clientX,t.clientY).cursor.select(),h.selection&&h.controller.aria.clear().queue(h.selection.join("mathspeak")+" selected").alert(),s=null;}function o(){null===c||void 0===c||c.removeEventListener("mousemove",n),null===p||void 0===p||p.removeEventListener("mousemove",r),null===p||void 0===p||p.removeEventListener("mouseup",a),cancelSelectionOnEdit=void 0;}function i(){d.editable?(h.show(),h.controller.aria.queue(h.parent).alert()):domFrag(f).detach();}function a(){h.blink=m,h.selection||i(),o();}var s,l,c=closest(t.target,".mq-root-block"),u=c&&NodeBase.getNodeOfElement(c)||NodeBase.getNodeOfElement(e.root.domFrag().oneElement()),p=u.domFrag().firstNode().ownerDocument,d=u.controller,h=d.cursor,m=h.blink,f=d.getTextareaSpanOrThrow(),y=d.getTextareaOrThrow();if(t.preventDefault(),t.target.unselectable=true,!h.options.ignoreNextMousedown(t)&&!closest(t.target,".mq-ignore-mousedown")){if(3===t.detail)return void d.selectAll();s=null,cancelSelectionOnEdit={cursor:h,cb:function(){l=true,h.blink=m,h.clearSelection(),i(),o();}},d.blurred&&(c&&!d.editable&&domFrag(c).prepend(domFrag(f)),y.focus(),l)||(h.blink=noop,d.seek(t.target,t.clientX,t.clientY).cursor.startSelection(),
1451
+ null===c||void 0===c||c.addEventListener("mousemove",n),null===p||void 0===p||p.addEventListener("mousemove",r),null===p||void 0===p||p.addEventListener("mouseup",a));}},e}return __extends(e,t),e.prototype.addMouseEventListener=function(){this.container.addEventListener("mousedown",this.handleMouseDown);},e.prototype.removeMouseEventListener=function(){this.container.removeEventListener("mousedown",this.handleMouseDown);},e.prototype.seek=function(t,e,n){for(var r,o=this.notify("select").cursor;t&&!(r=NodeBase.getNodeOfElement(t));)t=t.parentElement;return r||(r=this.root),o.clearSelection().show(),r.seek(e,o),this.scrollHoriz(),this},e}(Controller_latex),Controller_scrollHoriz=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=false,i=false;this.blurred||(t=getBoundingClientRect(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,s,l,c,u=this,p=this.cursor,d=p.selection,h=getBoundingClientRect(this.root.domFrag().oneElement());if(p.domFrag().isEmpty()&&!d)return this.cancelScrollHoriz&&(this.cancelScrollHoriz(),this.cancelScrollHoriz=void 0),t=this.root.domFrag().oneElement(),e=t.scrollLeft,void animate(this.getScrollAnimationDuration(),function(n,r,o){n>=1?(u.cancelScrollHoriz=void 0,t.scrollLeft=0,u.setOverflowClasses()):(u.cancelScrollHoriz=o,r(),t.scrollLeft=Math.round((1-n)*e));});if(d)if(o=getBoundingClientRect(d.domFrag().oneElement()),i=o.left-(h.left+20),a=o.right-(h.right-20),d.getEnd(L)===p[R])if(i<0)r=i;else {if(!(a>0))return;r=o.left-a<h.left+20?i:a;}else if(a>0)r=a;else {if(!(i<0))return;r=o.right-i>h.right-20?a:i;}else if((n=getBoundingClientRect(p.domFrag().oneElement()).left)>h.right-20)r=n-(h.right-20);else {if(!(n<h.left+20))return;r=n-(h.left+20);}s=this.root.domFrag().oneElement(),r<0&&0===s.scrollLeft||r>0&&s.scrollWidth<=s.scrollLeft+h.width||(this.cancelScrollHoriz&&(this.cancelScrollHoriz(),this.cancelScrollHoriz=void 0),l=this.root.domFrag().oneElement(),c=l.scrollLeft,animate(this.getScrollAnimationDuration(),function(t,e,n){t>=1?(u.cancelScrollHoriz=void 0,l.scrollLeft=Math.round(c+r),u.setOverflowClasses()):(u.cancelScrollHoriz=n,e(),l.scrollLeft=Math.round(c+t*r));}));},e.prototype.getScrollAnimationDuration=function(){var t;return null!==(t=this.options.scrollAnimationDuration)&&void 0!==t?t:100},e}(Controller_mouse),Options.prototype.substituteTextarea=function(){return h("textarea",{autocapitalize:"off",autocomplete:"off",autocorrect:"off",spellcheck:false,"x-palm-disable-ste-all":true})},Options.prototype.substituteKeyboardEvents=defaultSubstituteKeyboardEvents,Controller=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.selectFn=noop,e}return __extends(e,t),e.prototype.createTextarea=function(){var t,e;if(this.textareaSpan=h("span",{class:"mq-textarea"}),t=this.options.substituteTextarea(),!t.nodeType)throw "substituteTextarea() must return a DOM element, got "+t;this.textarea=domFrag(t).appendTo(this.textareaSpan).oneElement(),e=this,e.cursor.selectionChanged=function(){e.selectionChanged();};},e.prototype.selectionChanged=function(){var t=this;t.textareaSelectionTimeout||(t.textareaSelectionTimeout=window.setTimeout(function(){t.setTextareaSelection();}));},e.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);},e.prototype.staticMathTextareaEvents=function(){var t=this;this.removeTextareaEventListener("cut"),this.removeTextareaEventListener("paste"),t.options.disableCopyPaste?this.removeTextareaEventListener("copy"):this.addTextareaEventListeners({copy:function(){t.setTextareaSelection();}}),this.addStaticFocusBlurListeners(),t.selectFn=function(e){var n=t.getTextareaOrThrow();n instanceof HTMLTextAreaElement&&(n.value=e,e&&n.select());};},e.prototype.editablesTextareaEvents=function(){var t,e,n,r=this,o=r.getTextareaOrThrow(),i=r.getTextareaSpanOrThrow();this.options.version<3?(t=this.options.assertJquery(),e=this.options.substituteKeyboardEvents(t(o),this),this.selectFn=function(t){e.select(t);}):(n=saneKeyboardEvents(o,this).select,this.selectFn=n),domFrag(this.container).prepend(domFrag(i)),this.addEditableFocusBlurListeners(),this.updateMathspeak();},e.prototype.unbindEditablesEvents=function(){var t=this,e=t.getTextareaOrThrow(),n=t.getTextareaSpanOrThrow();this.selectFn=function(t){e instanceof HTMLTextAreaElement&&(e.value=t,t&&e.select());},domFrag(n).remove(),this.removeTextareaEventListener("focus"),this.removeTextareaEventListener("blur"),t.blurred=true,this.removeTextareaEventListener("cut"),this.removeTextareaEventListener("paste");},e.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();},e.prototype.cut=function(){var t=this,e=t.cursor;e.selection&&window.setTimeout(function(){t.notify("edit"),e.parent.bubble(function(t){t.reflow();}),t.options&&t.options.onCut&&t.options.onCut();});},e.prototype.copy=function(){this.setTextareaSelection();},e.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();},e.prototype.setupStaticField=function(){this.mathspeakSpan=h("span",{class:"mq-mathspeak"}),domFrag(this.container).prepend(domFrag(this.mathspeakSpan)),this.updateMathspeak(),this.blurred=true,this.cursor.hide().parent.blur(this.cursor);},e.prototype.updateMathspeak=function(){var t,e,n,r=this,o=r.getAriaLabel(),i=/[A-Za-z0-9]$/.test(o)?o+":":o,a=r.root.mathspeak().trim();this.aria.clear(),e=(null===(t=r.ariaStringsOverrideMap)||void 0===t?void 0:t.labelValue)?r.ariaStringsOverrideMap.labelValue(o,a):i+" "+a,n=r.getTextareaOrThrow(),r.mathspeakSpan?(n.setAttribute("aria-label",""),r.mathspeakSpan.textContent=e.trim()):n.setAttribute("aria-label",[e,r.ariaPostLabel].join(" ").trim());},e}(Controller_scrollHoriz),MathElement=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[R],r=o[L],n&&n.siblingCreated(t,L),r&&r.siblingCreated(t,R),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 false;this.removeNodesDeeperThan(n-e);}return true},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 MathBlock?1:0;r=n[1]+i,r<=t?o.push([e,r]):(i?e.children():e).remove();});},e}(MQNode),DOMView=function(){function t(t,e){this.childCount=t,this.render=e;}return t}(),MathCommand=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){pray("MathCommand ends are never empty",t[L]&&t[R]),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(true,function(t,e){return t&&e.isEmpty()})},e.prototype.parser=function(){var t=this;return latexMathParser.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(R),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(L),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 MathBlock,e.adopt(n,n.getEnd(R),0);},e.prototype.placeCursor=function(t){t.insAtRightEnd(this.foldChildren(this.getEnd(L),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,e.parent,true);},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 MQSelection(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=getBoundingClientRect(n).left,o=r+n.offsetWidth;return e={},e[L]=r,e[R]=o,e}var r,o=this,i=n(o);return t<i[L]?e.insLeftOf(o):t>i[R]?e.insRightOf(o):(r=i[L],void o.eachChild(function(a){var s=n(a);return t<s[L]?(t-r<s[L]-t?a[L]?e.insAtRightEnd(a[L]):e.insLeftOf(o):e.insAtLeftEnd(a),false):t>s[R]?void(a[R]?r=s[R]:i[R]-t<t-s[R]?e.insRightOf(o):e.insAtRightEnd(a)):(a.seek(t,e),false)}))},e.prototype.numBlocks=function(){return this.domView.childCount},e.prototype.html=function(){var t,e,n=this.blocks;return pray("domView is defined",this.domView),t=this.domView,e=t.render(n||[]),this.setDOM(e),NodeBase.linkElementByCmdNode(e,this),e},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.latex+=this.ctrlSeq||"",this.eachChild(function(e){var n,r,o;t.latex+="{",r=t.latex.length,null===(n=e.latexRecursive)||void 0===n||n.call(e,t),o=t.latex.length,r===o&&(t.latex+=" "),t.latex+="}";}),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,e,n;return this.mathspeakOverride&&(t=this.latex(),!/^(\\)+$/.test(t))?this.mathspeakOverride(t):(e=this,n=0,e.foldChildren(e.mathspeakTemplate[n]||"Start"+e.ctrlSeq+" ",function(t,r){return n+=1,t+" "+r.mathspeak()+" "+(e.mathspeakTemplate[n]+" "||"End"+e.ctrlSeq+" ")}))},e}(MathElement),MQSymbol=function(t){function e(e,n,r,o){var i=t.call(this)||this;return i.setCtrlSeqHtmlTextAndMathspeak(e,n?new DOMView(0,function(){return n.cloneNode(true)}):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 Parser.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-getBoundingClientRect(n).left<n.offsetWidth/2?e.insLeftOf(this):e.insRightOf(this),e},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.latex+=this.ctrlSeq||"",this.checkCursorContextClose(t);},e.prototype.text=function(){return this.textTemplate.join("")},e.prototype.mathspeak=function(e){return this.mathspeakOverride?t.prototype.mathspeak.call(this):this.mathspeakName||""},e.prototype.placeCursor=function(){},e.prototype.isEmpty=function(){return true},e}(MathCommand),VanillaSymbol=function(t){function e(e,n,r){return t.call(this,e,h("span",{},[n||h.text(e)]),void 0,r)||this}return __extends(e,t),e}(MQSymbol),BinaryOperator=function(t){function e(e,n,r,o,i){return i?t.call(this,e,h("span",{},[n||h.text(e||"")]),void 0,o)||this:t.call(this,e,h("span",{class:"mq-binary-operator"},n?[n]:[]),r,o)||this}return __extends(e,t),e}(MQSymbol),MathBlock=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){var n;return null===(n=e.latexRecursive)||void 0===n?void 0:n.call(e,t)}),this.checkCursorContextClose(t);},e.prototype.text=function(){var t=this.getEnd(L);return t===this.getEnd(R)&&0!==t?t.text():this.join("text")},e.prototype.mathspeak=function(){var t="",e={};return this.controller&&(e=this.controller.options.autoOperatorNames),this.foldChildren([],function(n,r){var o,i,a;return r.isPartOfOperator?t+=r.mathspeak():(""!==t&&(e._maxLength>0&&"string"==typeof(o=e[t.toLowerCase()])&&(t=o),n.push(t+" "),t=""),i=r.mathspeak(),a=r.ctrlSeq,!isNaN(a)||"."===a||r.parent&&r.parent.parent&&r.parent.parent.isTextBlock()||(i=" "+i+" "),n.push(i)),n}).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?L:R,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,e.parent,true)):(e.insDirOf(t,this.parent),e.controller.aria.queueDirOf(t,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(R);if(!o)return e.insAtRightEnd(this);if(n=o.domFrag().oneElement(),getBoundingClientRect(n).left+n.offsetWidth<t)return e.insAtRightEnd(this);if(r=this.getEnd(L),t<getBoundingClientRect(r.domFrag().oneElement()).left)return e.insAtLeftEnd(this);for(;t<getBoundingClientRect(o.domFrag().oneElement()).left;)o=o[L];return o.seek(t,e)},e.prototype.chToCmd=function(t,e){var n;return t.match(/^[a-eg-zA-Z]$/)?new Letter(t):/^\d$/.test(t)?new Digit(t):e&&e.typingSlashWritesDivisionSymbol&&"/"===t?LatexCmds["÷"](t):e&&e.typingAsteriskWritesTimesSymbol&&"*"===t?LatexCmds["×"](t):e&&e.typingPercentWritesPercentOf&&"%"===t?LatexCmds.percentof(t):(n=CharCmds[t]||LatexCmds[t])?n.constructor?new n(t):n(t):new VanillaSymbol(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,a=Parser.all,s=Parser.eof,l=latexMathParser.skip(s).or(a.result(false)).parse(e);l&&!l.isEmpty()&&l.prepareInsertionAt(t)&&(l.children().adopt(t.parent,t[L],t[R]),domFrag(l.html()).insertBefore(t.domFrag()),t[L]=l.getEnd(R),l.finalizeInsert(t.options,t),n=l.getEnd(R),r=l.getEnd(L),o=n[R],i=r[L],o&&o.siblingCreated(t.options,L),i&&i.siblingCreated(t.options,R),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}(MathElement),Options.prototype.mouseEvents=true,API.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=MathBlock,e},RootMathBlock=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(MathBlock),RootBlockMixin(RootMathBlock.prototype),API.MathField=function(t){var e;return e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.__mathquillify=function(e,n){return this.config(e),n>1&&(this.__controller.root.reflow=noop),t.prototype.mathquillify.call(this,"mq-editable-field mq-math-mode"),delete this.__controller.root.reflow,this},e}(t.EditableField),e.RootBlock=RootMathBlock,e},API.InnerMathField=function(t){return pray("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=false,this.__controller.root.blur(),this.__controller.unbindEditablesEvents(),domFrag(this.__controller.container).removeClass("mq-editable-field");},e.prototype.makeEditable=function(){this.__controller.editable=true,this.__controller.editablesTextareaEvents(),this.__controller.cursor.insAtRightEnd(this.__controller.root),domFrag(this.__controller.container).addClass("mq-editable-field");},e}(t.MathField)},LatexCmds.notin=LatexCmds.cong=LatexCmds.equiv=LatexCmds.oplus=LatexCmds.otimes=function(t){return new BinaryOperator("\\"+t+" ",h.entityText("&"+t+";"))},LatexCmds["∗"]=LatexCmds.ast=LatexCmds.star=LatexCmds.loast=LatexCmds.lowast=bindBinaryOperator("\\ast ","&lowast;","low asterisk"),LatexCmds.therefor=LatexCmds.therefore=bindBinaryOperator("\\therefore ","&there4;","therefore"),LatexCmds.cuz=LatexCmds.because=bindBinaryOperator("\\because ","&#8757;","because"),LatexCmds.prop=LatexCmds.propto=bindBinaryOperator("\\propto ","&prop;","proportional to"),LatexCmds["≈"]=LatexCmds.asymp=LatexCmds.approx=bindBinaryOperator("\\approx ","&asymp;","approximately equal to"),LatexCmds.isin=LatexCmds.in=bindBinaryOperator("\\in ","&isin;","is in"),LatexCmds.ni=LatexCmds.contains=bindBinaryOperator("\\ni ","&ni;","is not in"),LatexCmds.notni=LatexCmds.niton=LatexCmds.notcontains=LatexCmds.doesnotcontain=bindBinaryOperator("\\not\\ni ","&#8716;","does not contain"),LatexCmds.sub=LatexCmds.subset=bindBinaryOperator("\\subset ","&sub;","subset"),LatexCmds.sup=LatexCmds.supset=LatexCmds.superset=bindBinaryOperator("\\supset ","&sup;","superset"),LatexCmds.nsub=LatexCmds.notsub=LatexCmds.nsubset=LatexCmds.notsubset=bindBinaryOperator("\\not\\subset ","&#8836;","not a subset"),LatexCmds.nsup=LatexCmds.notsup=LatexCmds.nsupset=LatexCmds.notsupset=LatexCmds.nsuperset=LatexCmds.notsuperset=bindBinaryOperator("\\not\\supset ","&#8837;","not a superset"),LatexCmds.sube=LatexCmds.subeq=LatexCmds.subsete=LatexCmds.subseteq=bindBinaryOperator("\\subseteq ","&sube;","subset or equal to"),LatexCmds.supe=LatexCmds.supeq=LatexCmds.supsete=LatexCmds.supseteq=LatexCmds.supersete=LatexCmds.superseteq=bindBinaryOperator("\\supseteq ","&supe;","superset or equal to"),LatexCmds.nsube=LatexCmds.nsubeq=LatexCmds.notsube=LatexCmds.notsubeq=LatexCmds.nsubsete=LatexCmds.nsubseteq=LatexCmds.notsubsete=LatexCmds.notsubseteq=bindBinaryOperator("\\not\\subseteq ","&#8840;","not subset or equal to"),LatexCmds.nsupe=LatexCmds.nsupeq=LatexCmds.notsupe=LatexCmds.notsupeq=LatexCmds.nsupsete=LatexCmds.nsupseteq=LatexCmds.notsupsete=LatexCmds.notsupseteq=LatexCmds.nsupersete=LatexCmds.nsuperseteq=LatexCmds.notsupersete=LatexCmds.notsuperseteq=bindBinaryOperator("\\not\\supseteq ","&#8841;","not superset or equal to"),LatexCmds.mathbb=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(t){},e.prototype.numBlocks=function(){return 1},e.prototype.parser=function(){var t=Parser.string,e=Parser.regex,n=Parser.optWhitespace;return n.then(t("{")).then(n).then(e(/^[NPZQRCH]/)).skip(n).skip(t("}")).map(function(t){var e=LatexCmds[t];return isMQNodeClass(e)?new e:e()})},e}(MathCommand),LatexCmds.N=LatexCmds.naturals=LatexCmds.Naturals=bindVanillaSymbol("\\mathbb{N}","&#8469;","naturals"),LatexCmds.P=LatexCmds.primes=LatexCmds.Primes=LatexCmds.projective=LatexCmds.Projective=LatexCmds.probability=LatexCmds.Probability=bindVanillaSymbol("\\mathbb{P}","&#8473;","P"),LatexCmds.Z=LatexCmds.integers=LatexCmds.Integers=bindVanillaSymbol("\\mathbb{Z}","&#8484;","integers"),LatexCmds.Q=LatexCmds.rationals=LatexCmds.Rationals=bindVanillaSymbol("\\mathbb{Q}","&#8474;","rationals"),LatexCmds.R=LatexCmds.reals=LatexCmds.Reals=bindVanillaSymbol("\\mathbb{R}","&#8477;","reals"),LatexCmds.C=LatexCmds.complex=LatexCmds.Complex=LatexCmds.complexes=LatexCmds.Complexes=LatexCmds.complexplane=LatexCmds.Complexplane=LatexCmds.ComplexPlane=bindVanillaSymbol("\\mathbb{C}","&#8450;","complexes"),LatexCmds.H=LatexCmds.Hamiltonian=LatexCmds.quaternions=LatexCmds.Quaternions=bindVanillaSymbol("\\mathbb{H}","&#8461;","quaternions"),LatexCmds.quad=LatexCmds.emsp=bindVanillaSymbol("\\quad "," ","4 spaces"),LatexCmds.qquad=bindVanillaSymbol("\\qquad "," ","8 spaces"),LatexCmds.diamond=bindVanillaSymbol("\\diamond ","&#9671;","diamond"),LatexCmds.bigtriangleup=bindVanillaSymbol("\\bigtriangleup ","&#9651;","triangle up"),LatexCmds.ominus=bindVanillaSymbol("\\ominus ","&#8854;","o minus"),LatexCmds.uplus=bindVanillaSymbol("\\uplus ","&#8846;","disjoint union"),LatexCmds.bigtriangledown=bindVanillaSymbol("\\bigtriangledown ","&#9661;","triangle down"),LatexCmds.sqcap=bindVanillaSymbol("\\sqcap ","&#8851;","greatest lower bound"),LatexCmds.triangleleft=bindVanillaSymbol("\\triangleleft ","&#8882;","triangle left"),LatexCmds.sqcup=bindVanillaSymbol("\\sqcup ","&#8852;","least upper bound"),LatexCmds.triangleright=bindVanillaSymbol("\\triangleright ","&#8883;","triangle right"),LatexCmds.odot=LatexCmds.circledot=bindVanillaSymbol("\\odot ","&#8857;","circle dot"),LatexCmds.bigcirc=bindVanillaSymbol("\\bigcirc ","&#9711;","circle"),LatexCmds.dagger=bindVanillaSymbol("\\dagger ","&#0134;","dagger"),LatexCmds.ddagger=bindVanillaSymbol("\\ddagger ","&#135;","big dagger"),LatexCmds.wr=bindVanillaSymbol("\\wr ","&#8768;","wreath"),LatexCmds.amalg=bindVanillaSymbol("\\amalg ","&#8720;","amalgam"),LatexCmds.models=bindVanillaSymbol("\\models ","&#8872;","models"),LatexCmds.prec=bindVanillaSymbol("\\prec ","&#8826;","precedes"),LatexCmds.succ=bindVanillaSymbol("\\succ ","&#8827;","succeeds"),LatexCmds.preceq=bindVanillaSymbol("\\preceq ","&#8828;","precedes or equals"),LatexCmds.succeq=bindVanillaSymbol("\\succeq ","&#8829;","succeeds or equals"),LatexCmds.simeq=bindVanillaSymbol("\\simeq ","&#8771;","similar or equal to"),LatexCmds.mid=bindVanillaSymbol("\\mid ","&#8739;","divides"),LatexCmds.ll=bindVanillaSymbol("\\ll ","&#8810;","ll"),LatexCmds.gg=bindVanillaSymbol("\\gg ","&#8811;","gg"),LatexCmds.parallel=bindVanillaSymbol("\\parallel ","&#8741;","parallel with"),LatexCmds.nparallel=bindVanillaSymbol("\\nparallel ","&#8742;","not parallel with"),LatexCmds.bowtie=bindVanillaSymbol("\\bowtie ","&#8904;","bowtie"),LatexCmds.sqsubset=bindVanillaSymbol("\\sqsubset ","&#8847;","square subset"),LatexCmds.sqsupset=bindVanillaSymbol("\\sqsupset ","&#8848;","square superset"),LatexCmds.smile=bindVanillaSymbol("\\smile ","&#8995;","smile"),LatexCmds.sqsubseteq=bindVanillaSymbol("\\sqsubseteq ","&#8849;","square subset or equal to"),LatexCmds.sqsupseteq=bindVanillaSymbol("\\sqsupseteq ","&#8850;","square superset or equal to"),LatexCmds.doteq=bindVanillaSymbol("\\doteq ","&#8784;","dotted equals"),LatexCmds.frown=bindVanillaSymbol("\\frown ","&#8994;","frown"),LatexCmds.vdash=bindVanillaSymbol("\\vdash ","&#8870;","v dash"),LatexCmds.dashv=bindVanillaSymbol("\\dashv ","&#8867;","dash v"),LatexCmds.nless=bindVanillaSymbol("\\nless ","&#8814;","not less than"),LatexCmds.ngtr=bindVanillaSymbol("\\ngtr ","&#8815;","not greater than"),LatexCmds.longleftarrow=bindVanillaSymbol("\\longleftarrow ","&#8592;","left arrow"),LatexCmds.longrightarrow=bindVanillaSymbol("\\longrightarrow ","&#8594;","right arrow"),LatexCmds.Longleftarrow=bindVanillaSymbol("\\Longleftarrow ","&#8656;","left arrow"),LatexCmds.Longrightarrow=bindVanillaSymbol("\\Longrightarrow ","&#8658;","right arrow"),LatexCmds.longleftrightarrow=bindVanillaSymbol("\\longleftrightarrow ","&#8596;","left and right arrow"),LatexCmds.updownarrow=bindVanillaSymbol("\\updownarrow ","&#8597;","up and down arrow"),LatexCmds.Longleftrightarrow=bindVanillaSymbol("\\Longleftrightarrow ","&#8660;","left and right arrow"),LatexCmds.Updownarrow=bindVanillaSymbol("\\Updownarrow ","&#8661;","up and down arrow"),LatexCmds.mapsto=bindVanillaSymbol("\\mapsto ","&#8614;","maps to"),LatexCmds.nearrow=bindVanillaSymbol("\\nearrow ","&#8599;","northeast arrow"),LatexCmds.hookleftarrow=bindVanillaSymbol("\\hookleftarrow ","&#8617;","hook left arrow"),LatexCmds.hookrightarrow=bindVanillaSymbol("\\hookrightarrow ","&#8618;","hook right arrow"),LatexCmds.searrow=bindVanillaSymbol("\\searrow ","&#8600;","southeast arrow"),LatexCmds.leftharpoonup=bindVanillaSymbol("\\leftharpoonup ","&#8636;","left harpoon up"),LatexCmds.rightharpoonup=bindVanillaSymbol("\\rightharpoonup ","&#8640;","right harpoon up"),LatexCmds.swarrow=bindVanillaSymbol("\\swarrow ","&#8601;","southwest arrow"),LatexCmds.leftharpoondown=bindVanillaSymbol("\\leftharpoondown ","&#8637;","left harpoon down"),LatexCmds.rightharpoondown=bindVanillaSymbol("\\rightharpoondown ","&#8641;","right harpoon down"),LatexCmds.nwarrow=bindVanillaSymbol("\\nwarrow ","&#8598;","northwest arrow"),LatexCmds.ldots=bindVanillaSymbol("\\ldots ","&#8230;","l dots"),LatexCmds.cdots=bindVanillaSymbol("\\cdots ","&#8943;","c dots"),LatexCmds.vdots=bindVanillaSymbol("\\vdots ","&#8942;","v dots"),LatexCmds.ddots=bindVanillaSymbol("\\ddots ","&#8945;","d dots"),LatexCmds.surd=bindVanillaSymbol("\\surd ","&#8730;","unresolved root"),LatexCmds.triangle=bindVanillaSymbol("\\triangle ","&#9651;","triangle"),LatexCmds.ell=bindVanillaSymbol("\\ell ","&#8467;","ell"),LatexCmds.top=bindVanillaSymbol("\\top ","&#8868;","top"),LatexCmds.flat=bindVanillaSymbol("\\flat ","&#9837;","flat"),LatexCmds.natural=bindVanillaSymbol("\\natural ","&#9838;","natural"),LatexCmds.sharp=bindVanillaSymbol("\\sharp ","&#9839;","sharp"),LatexCmds.wp=bindVanillaSymbol("\\wp ","&#8472;","wp"),LatexCmds.bot=bindVanillaSymbol("\\bot ","&#8869;","bot"),LatexCmds.clubsuit=bindVanillaSymbol("\\clubsuit ","&#9827;","club suit"),LatexCmds.diamondsuit=bindVanillaSymbol("\\diamondsuit ","&#9826;","diamond suit"),LatexCmds.heartsuit=bindVanillaSymbol("\\heartsuit ","&#9825;","heart suit"),LatexCmds.spadesuit=bindVanillaSymbol("\\spadesuit ","&#9824;","spade suit"),LatexCmds.parallelogram=bindVanillaSymbol("\\parallelogram ","&#9649;","parallelogram"),LatexCmds.square=bindVanillaSymbol("\\square ","&#11036;","square"),LatexCmds.oint=bindVanillaSymbol("\\oint ","&#8750;","o int"),LatexCmds.bigcap=bindVanillaSymbol("\\bigcap ","&#8745;","big cap"),LatexCmds.bigcup=bindVanillaSymbol("\\bigcup ","&#8746;","big cup"),LatexCmds.bigsqcup=bindVanillaSymbol("\\bigsqcup ","&#8852;","big square cup"),LatexCmds.bigvee=bindVanillaSymbol("\\bigvee ","&#8744;","big vee"),LatexCmds.bigwedge=bindVanillaSymbol("\\bigwedge ","&#8743;","big wedge"),LatexCmds.bigodot=bindVanillaSymbol("\\bigodot ","&#8857;","big o dot"),LatexCmds.bigotimes=bindVanillaSymbol("\\bigotimes ","&#8855;","big o times"),LatexCmds.bigoplus=bindVanillaSymbol("\\bigoplus ","&#8853;","big o plus"),LatexCmds.biguplus=bindVanillaSymbol("\\biguplus ","&#8846;","big u plus"),LatexCmds.lfloor=bindVanillaSymbol("\\lfloor ","&#8970;","left floor"),LatexCmds.rfloor=bindVanillaSymbol("\\rfloor ","&#8971;","right floor"),LatexCmds.lceil=bindVanillaSymbol("\\lceil ","&#8968;","left ceiling"),LatexCmds.rceil=bindVanillaSymbol("\\rceil ","&#8969;","right ceiling"),LatexCmds.opencurlybrace=LatexCmds.lbrace=bindVanillaSymbol("\\lbrace ","{","left brace"),LatexCmds.closecurlybrace=LatexCmds.rbrace=bindVanillaSymbol("\\rbrace ","}","right brace"),LatexCmds.lbrack=bindVanillaSymbol("[","left bracket"),LatexCmds.rbrack=bindVanillaSymbol("]","right bracket"),LatexCmds.slash=bindVanillaSymbol("/","slash"),LatexCmds.vert=bindVanillaSymbol("|","vertical bar"),LatexCmds.perp=LatexCmds.perpendicular=bindVanillaSymbol("\\perp ","&perp;","perpendicular"),LatexCmds.nabla=LatexCmds.del=bindVanillaSymbol("\\nabla ","&nabla;"),LatexCmds.hbar=bindVanillaSymbol("\\hbar ","&#8463;","horizontal bar"),LatexCmds.AA=LatexCmds.Angstrom=LatexCmds.angstrom=bindVanillaSymbol("\\text\\AA ","&#8491;","AA"),LatexCmds.ring=LatexCmds.circ=LatexCmds.circle=bindVanillaSymbol("\\circ ","&#8728;","circle"),LatexCmds.bull=LatexCmds.bullet=bindVanillaSymbol("\\bullet ","&bull;","bullet"),LatexCmds.setminus=LatexCmds.smallsetminus=bindVanillaSymbol("\\setminus ","&#8726;","set minus"),LatexCmds.not=LatexCmds["¬"]=LatexCmds.neg=bindVanillaSymbol("\\neg ","&not;","not"),LatexCmds["…"]=LatexCmds.dots=LatexCmds.ellip=LatexCmds.hellip=LatexCmds.ellipsis=LatexCmds.hellipsis=bindVanillaSymbol("\\dots ","&hellip;","ellipsis"),LatexCmds.converges=LatexCmds.darr=LatexCmds.dnarr=LatexCmds.dnarrow=LatexCmds.downarrow=bindVanillaSymbol("\\downarrow ","&darr;","converges with"),LatexCmds.dArr=LatexCmds.dnArr=LatexCmds.dnArrow=LatexCmds.Downarrow=bindVanillaSymbol("\\Downarrow ","&dArr;","down arrow"),LatexCmds.diverges=LatexCmds.uarr=LatexCmds.uparrow=bindVanillaSymbol("\\uparrow ","&uarr;","diverges from"),LatexCmds.uArr=LatexCmds.Uparrow=bindVanillaSymbol("\\Uparrow ","&uArr;","up arrow"),LatexCmds.rarr=LatexCmds.rightarrow=bindVanillaSymbol("\\rightarrow ","&rarr;","right arrow"),LatexCmds.implies=bindBinaryOperator("\\Rightarrow ","&rArr;","implies"),LatexCmds.rArr=LatexCmds.Rightarrow=bindVanillaSymbol("\\Rightarrow ","&rArr;","right arrow"),LatexCmds.gets=bindBinaryOperator("\\gets ","&larr;","gets"),LatexCmds.larr=LatexCmds.leftarrow=bindVanillaSymbol("\\leftarrow ","&larr;","left arrow"),LatexCmds.impliedby=bindBinaryOperator("\\Leftarrow ","&lArr;","implied by"),LatexCmds.lArr=LatexCmds.Leftarrow=bindVanillaSymbol("\\Leftarrow ","&lArr;","left arrow"),LatexCmds.harr=LatexCmds.lrarr=LatexCmds.leftrightarrow=bindVanillaSymbol("\\leftrightarrow ","&harr;","left and right arrow"),LatexCmds.iff=bindBinaryOperator("\\Leftrightarrow ","&hArr;","if and only if"),LatexCmds.hArr=LatexCmds.lrArr=LatexCmds.Leftrightarrow=bindVanillaSymbol("\\Leftrightarrow ","&hArr;","left and right arrow"),LatexCmds.Re=LatexCmds.Real=LatexCmds.real=bindVanillaSymbol("\\Re ","&real;","real"),LatexCmds.Im=LatexCmds.imag=LatexCmds.image=LatexCmds.imagin=LatexCmds.imaginary=LatexCmds.Imaginary=bindVanillaSymbol("\\Im ","&image;","imaginary"),LatexCmds.part=LatexCmds.partial=bindVanillaSymbol("\\partial ","&part;","partial"),LatexCmds.pounds=bindVanillaSymbol("\\pounds ","&pound;"),
1452
+ LatexCmds.alef=LatexCmds.alefsym=LatexCmds.aleph=LatexCmds.alephsym=bindVanillaSymbol("\\aleph ","&alefsym;","alef sym"),LatexCmds.xist=LatexCmds.xists=LatexCmds.exist=LatexCmds.exists=bindVanillaSymbol("\\exists ","&exist;","there exists at least 1"),LatexCmds.nexists=LatexCmds.nexist=bindVanillaSymbol("\\nexists ","&#8708;","there is no"),LatexCmds.and=LatexCmds.land=LatexCmds.wedge=bindBinaryOperator("\\wedge ","&and;","and"),LatexCmds.or=LatexCmds.lor=LatexCmds.vee=bindBinaryOperator("\\vee ","&or;","or"),LatexCmds.o=LatexCmds.O=LatexCmds.empty=LatexCmds.emptyset=LatexCmds.oslash=LatexCmds.Oslash=LatexCmds.nothing=LatexCmds.varnothing=bindBinaryOperator("\\varnothing ","&empty;","nothing"),LatexCmds.cup=LatexCmds.union=bindBinaryOperator("\\cup ","&cup;","union"),LatexCmds.cap=LatexCmds.intersect=LatexCmds.intersection=bindBinaryOperator("\\cap ","&cap;","intersection"),LatexCmds.deg=LatexCmds.degree=bindVanillaSymbol("\\degree ","&deg;","degrees"),LatexCmds.ang=LatexCmds.angle=bindVanillaSymbol("\\angle ","&ang;","angle"),LatexCmds.measuredangle=bindVanillaSymbol("\\measuredangle ","&#8737;","measured angle"),DigitGroupingChar=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!==L&&this[R]instanceof e||this.fixDigitGrouping(t);},e.prototype.fixDigitGrouping=function(t){var e,n,r,o,i,a,s,l;if(t.enableDigitGrouping){e=this,n=this,r=0,o=[],i="\\ ",a=".",s=e;do{if(/^[0-9]$/.test(s.ctrlSeq))e=s;else if(s.ctrlSeq===i)e=s,r+=1;else {if(s.ctrlSeq!==a)break;e=s,o.push(s);}}while(s=e[L]);for(;s=n[R];)if(/^[0-9]$/.test(s.ctrlSeq))n=s;else if(s.ctrlSeq===i)n=s,r+=1;else {if(s.ctrlSeq!==a)break;n=s,o.push(s);}for(;n!==e&&e&&e.ctrlSeq===i;)e=e[R],r-=1;for(;n!==e&&n&&n.ctrlSeq===i;)n=n[L],r-=1;e===n&&e&&e.ctrlSeq===i||(l=r>0||o.length>1,l?this.removeGroupingBetween(e,n):o[0]?(o[0]!==e&&this.addGroupingBetween(o[0][L],e),o[0]!==n&&this.removeGroupingBetween(o[0][R],n)):this.addGroupingBetween(n,e));}},e.prototype.removeGroupingBetween=function(t,n){var r=t;do{if(r instanceof e&&r.setGroupingClass(void 0),!r||r===n)break}while(r=r[R])},e.prototype.addGroupingBetween=function(t,n){var r,o,i=t,a=0,s=0;for(i=t;i&&(s+=1,i!==n);)i=i[L];for(r=s%3,0===r&&(r=3),i=t;i&&(a+=1,o=void 0,s>=4&&(a===s?o="mq-group-leading-"+r:a%3==0&&a!==s&&(o="mq-group-start"),o||(o="mq-group-other")),i instanceof e&&i.setGroupingClass(o),i!==n);)i=i[L];},e.prototype.setGroupingClass=function(t){this._groupingClass!==t&&(this._groupingClass&&this.domFrag().removeClass(this._groupingClass),t&&this.domFrag().addClass(t),this._groupingClass=t);},e}(MQSymbol),Digit=function(t){function e(e,n){return t.call(this,e,h("span",{class:"mq-digit"},[h.text(e)]),void 0,n)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n=e[L],r=n&&n[L],o=e.parent.parent instanceof SupSub?e.parent.parent.sub:void 0;e.options.autoSubscriptNumerals&&e.parent!==o&&(n instanceof Variable&&false!==n.isItalic||n instanceof SupSub&&r instanceof Variable&&false!==r.isItalic)?((new SubscriptCommand).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[L],o=r&&r[L],i=n.parent.parent instanceof SupSub?n.parent.parent.sub:void 0,n.options.autoSubscriptNumerals&&n.parent!==i&&(r instanceof Variable&&false!==r.isItalic||n[L]instanceof SupSub&&o instanceof Variable&&false!==o.isItalic))?"Subscript "+t.prototype.mathspeak.call(this)+" Baseline":t.prototype.mathspeak.call(this)},e}(DigitGroupingChar),Variable=function(t){function e(e,n){return t.call(this,e,h("var",{},[n||h.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[L]||this[L]instanceof e||this[L]instanceof BinaryOperator||"\\ "===this[L].ctrlSeq||(t="*"+t),!this[R]||this[R]instanceof BinaryOperator||this[R]instanceof SupSub||(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}(MQSymbol),Options.prototype.autoCommands={_maxLength:0},baseOptionProcessors.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(LatexCmds[i]===OperatorName)throw '"'+i+'" is a built-in operator name';n[i]=1,r=max(r,i.length);}return n._maxLength=r,n},Options.prototype.quietEmptyDelimiters={},baseOptionProcessors.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},Options.prototype.autoParenthesizedFunctions={_maxLength:0},baseOptionProcessors.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=max(r,i.length);}return n._maxLength=r,n},Letter=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 n,r,o,i,a,s,l;if(!this.shouldIgnoreSubstitutionInSimpleSubscript(t.options)&&(n=t.options.autoCommands,(r=n._maxLength||0)>0)){for(o="",i=this,a=0;i instanceof e&&i.ctrlSeq===i.letter&&a<r;)o=i.letter+o,i=i[L],a+=1;for(;o.length;){if(n.hasOwnProperty(o)){for(i=this,a=1;i&&a<o.length;a+=1,i=i[L]);return new Fragment(i,this).remove(),t[L]=i[L],s=LatexCmds[o],l=isMQNodeClass(s)?new s(o):s(o),l.createLeftOf(t)}o=o.slice(1);}}},e.prototype.autoParenthesize=function(t){var n,r,o,i,a,s,l=t.parent.getEnd(R);if(!(l&&l instanceof Bracket&&"\\left("===l.ctrlSeq||this.shouldIgnoreSubstitutionInSimpleSubscript(t.options))){for(n="",r=this,o=0,i=t.options.autoParenthesizedFunctions,a=i._maxLength||0,s=t.options.autoOperatorNames;r instanceof e&&o<a;)n=r.letter+n,r=r[L],o+=1;for(;n.length;){if(i.hasOwnProperty(n)&&s.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,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!==L&&this[R]instanceof e||this.autoUnItalicize(t);},e.prototype.autoUnItalicize=function(t){var n,r,o,i,a,s,l,c,u,p,d,h,m,f,y,g,x,b,C=t.autoOperatorNames;if(0!==C._maxLength&&!this.shouldIgnoreSubstitutionInSimpleSubscript(t)){for(n=this.letter,r=this[L];r instanceof e;r=r[L])n=r.letter+n;for(o=this[R];o instanceof e;o=o[R])n+=o.letter;i=r&&r[R],a=o&&o[L],new Fragment(i||this.parent.getEnd(L),a||this.parent.getEnd(R)).each(function(t){t instanceof e&&(t.italicize(true).domFrag().removeClass("mq-first mq-last mq-followed-by-supsub"),t.ctrlSeq=t.letter);}),s=C._maxLength||0;t:for(l=0,c=r[R]||this.parent.getEnd(L);c&&l<n.length;l+=1,c=c[R])for(u=min(s,n.length-l);u>0;u-=1)if(p=n.slice(l,l+u),d=void 0,C.hasOwnProperty(p)){for(h=0,m=c;h<u;h+=1,m=m[R])m instanceof e&&(m.italicize(false),d=m);f=BuiltInOpNames.hasOwnProperty(p),c.ctrlSeq=(f?"\\":"\\operatorname{")+c.ctrlSeq,d.ctrlSeq+=f?" ":"}",TwoWordOpNames.hasOwnProperty(p)&&(y=d[L],g=y&&y[L],x=g&&g[L],x.domFrag().addClass("mq-last")),this.shouldOmitPadding(c[L])||c.domFrag().addClass("mq-first"),this.shouldOmitPadding(d[R])||(d[R]instanceof SupSub?(b=d[R],(b.siblingCreated=b.siblingDeleted=function(){b.domFrag().toggleClass("mq-after-operator-name",!(b[R]instanceof Bracket));})()):d.domFrag().toggleClass("mq-last",!(d[R]instanceof Bracket))),l+=u-1,c=d;continue t}}},e.prototype.shouldOmitPadding=function(t){return !t||("."===t.ctrlSeq||(t instanceof BinaryOperator||t instanceof SummationNotation))},e}(Variable),BuiltInOpNames={},Options.prototype.autoOperatorNames=defaultAutoOpNames(),TwoWordOpNames={limsup:1,liminf:1,projlim:1,injlim:1},baseOptionProcessors.autoOperatorNames=function(t){var e,n,r,o,i,a;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=max(r,i.length);else {if(a=i.split("|"),a.length>2)throw '"'+i+'" has more than 1 mathspeak delimiter';if(a[0].length<2)throw '"'+i[0]+'" not minimum length of 2';n[a[0]]=a[1].replace(/-/g," "),r=max(r,a[0].length);}}return n._maxLength=r,n},OperatorName=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 Letter(n.charAt(e)).createLeftOf(t);},e.prototype.parser=function(){var t,e=this.ctrlSeq,n=new MathBlock;for(t=0;t<e.length;t+=1)new Letter(e.charAt(t)).adopt(n,n.getEnd(R),0);return Parser.succeed(n.children())},e}(MQSymbol);for(fn in Options.prototype.autoOperatorNames)Options.prototype.autoOperatorNames.hasOwnProperty(fn)&&(LatexCmds[fn]=OperatorName);LatexCmds.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 latexMathParser.block.map(function(t){var e=true,n="",r=t.children();return r.each(function(t){t instanceof Letter?n+=t.letter:e=false;}),e&&"ans"===n?AnsBuilder():r})},e}(MathCommand),LatexCmds.f=function(t){function e(){var e=this,n="f";return e=t.call(this,n)||this,e.letter=n,e.domView=new DOMView(0,function(){return h("var",{class:"mq-f"},[h.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}(Letter),LatexCmds[" "]=LatexCmds.space=function(){return new DigitGroupingChar("\\ ",h("span",{},[h.text(U_NO_BREAK_SPACE)])," ")},LatexCmds["."]=function(){return new DigitGroupingChar(".",h("span",{class:"mq-digit"},[h.text(".")]),".")},LatexCmds["'"]=LatexCmds.prime=bindVanillaSymbol("'","&prime;","prime"),LatexCmds["″"]=LatexCmds.dprime=bindVanillaSymbol("″","&Prime;","double prime"),LatexCmds.backslash=bindVanillaSymbol("\\backslash ","\\","backslash"),CharCmds["\\"]||(CharCmds["\\"]=LatexCmds.backslash),LatexCmds.$=bindVanillaSymbol("\\$","$","dollar"),LatexCmds.square=bindVanillaSymbol("\\square ","□","square"),LatexCmds.mid=bindVanillaSymbol("\\mid ","∣","mid"),NonSymbolaSymbol=function(t){function e(e,n,r){return t.call(this,e,h("span",{class:"mq-nonSymbola"},[n||h.text(e)]))||this}return __extends(e,t),e}(MQSymbol),LatexCmds["@"]=function(){return new NonSymbolaSymbol("@")},LatexCmds["&"]=function(){return new NonSymbolaSymbol("\\&",h.entityText("&amp;"),"and")},LatexCmds["%"]=function(t){function e(){return t.call(this,"\\%",h.text("%"),"percent")||this}return __extends(e,t),e.prototype.parser=function(){var e=Parser.optWhitespace,n=Parser.string;return e.then(n("\\operatorname{of}").map(function(){return PercentOfBuilder()})).or(t.prototype.parser.call(this))},e}(NonSymbolaSymbol),LatexCmds["∥"]=LatexCmds.parallel=bindVanillaSymbol("\\parallel ","&#x2225;","parallel"),LatexCmds["∦"]=LatexCmds.nparallel=bindVanillaSymbol("\\nparallel ","&#x2226;","not parallel"),LatexCmds["⟂"]=LatexCmds.perp=bindVanillaSymbol("\\perp ","&#x27C2;","perpendicular"),LatexCmds.alpha=LatexCmds.beta=LatexCmds.gamma=LatexCmds.delta=LatexCmds.zeta=LatexCmds.eta=LatexCmds.theta=LatexCmds.iota=LatexCmds.kappa=LatexCmds.mu=LatexCmds.nu=LatexCmds.xi=LatexCmds.rho=LatexCmds.sigma=LatexCmds.tau=LatexCmds.chi=LatexCmds.psi=LatexCmds.omega=function(t){return new Variable("\\"+t+" ",h.entityText("&"+t+";"))},LatexCmds.phi=bindVariable("\\phi ","&#981;"),LatexCmds.phiv=LatexCmds.varphi=bindVariable("\\varphi ","&phi;"),LatexCmds.epsilon=bindVariable("\\epsilon ","&#1013;"),LatexCmds.epsiv=LatexCmds.varepsilon=bindVariable("\\varepsilon ","&epsilon;"),LatexCmds.piv=LatexCmds.varpi=bindVariable("\\varpi ","&piv;"),LatexCmds.sigmaf=LatexCmds.sigmav=LatexCmds.varsigma=bindVariable("\\varsigma ","&sigmaf;"),LatexCmds.thetav=LatexCmds.vartheta=LatexCmds.thetasym=bindVariable("\\vartheta ","&thetasym;"),LatexCmds.upsilon=LatexCmds.upsi=bindVariable("\\upsilon ","&upsilon;"),LatexCmds.gammad=LatexCmds.Gammad=LatexCmds.digamma=bindVariable("\\digamma ","&#989;"),LatexCmds.kappav=LatexCmds.varkappa=bindVariable("\\varkappa ","&#1008;"),LatexCmds.rhov=LatexCmds.varrho=bindVariable("\\varrho ","&#1009;"),LatexCmds.pi=LatexCmds["π"]=function(){return new NonSymbolaSymbol("\\pi ",h.entityText("&pi;"),"pi")},LatexCmds.lambda=function(){return new NonSymbolaSymbol("\\lambda ",h.entityText("&lambda;"),"lambda")},LatexCmds.Upsilon=LatexCmds.Upsi=LatexCmds.upsih=LatexCmds.Upsih=function(){return new MQSymbol("\\Upsilon ",h("var",{style:"font-family: serif"},[h.entityText("&upsih;")]),"capital upsilon")},LatexCmds.Gamma=LatexCmds.Delta=LatexCmds.Theta=LatexCmds.Lambda=LatexCmds.Xi=LatexCmds.Pi=LatexCmds.Sigma=LatexCmds.Phi=LatexCmds.Psi=LatexCmds.Omega=LatexCmds.forall=function(t){return new VanillaSymbol("\\"+t+" ",h.entityText("&"+t+";"))},LatexFragment=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=latexMathParser.parse(this.latexStr);i.children().adopt(t.parent,t[L],t[R]),t[L]=i.getEnd(R),domFrag(i.html()).insertBefore(t.domFrag()),i.finalizeInsert(t.options,t),e=i.getEnd(R),n=e&&e[R],n&&n.siblingCreated(t.options,L),r=i.getEnd(L),o=r&&r[L],o&&o.siblingCreated(t.options,R),t.parent.bubble(function(t){t.reflow();});},e.prototype.mathspeak=function(){return this.mathspeakOverride?t.prototype.mathspeak.call(this):latexMathParser.parse(this.latexStr).mathspeak()},e.prototype.parser=function(){var t=latexMathParser.parse(this.latexStr).children();return Parser.succeed(t)},e}(MathCommand),LatexCmds["⁰"]=function(){return new LatexFragment("^0")},LatexCmds["¹"]=function(){return new LatexFragment("^1")},LatexCmds["²"]=function(){return new LatexFragment("^2")},LatexCmds["³"]=function(){return new LatexFragment("^3")},LatexCmds["⁴"]=function(){return new LatexFragment("^4")},LatexCmds["⁵"]=function(){return new LatexFragment("^5")},LatexCmds["⁶"]=function(){return new LatexFragment("^6")},LatexCmds["⁷"]=function(){return new LatexFragment("^7")},LatexCmds["⁸"]=function(){return new LatexFragment("^8")},LatexCmds["⁹"]=function(){return new LatexFragment("^9")},LatexCmds["¼"]=function(){return new LatexFragment("\\frac14")},LatexCmds["½"]=function(){return new LatexFragment("\\frac12")},LatexCmds["¾"]=function(){return new LatexFragment("\\frac34")},LatexCmds["√"]=function(){return new LatexFragment("\\sqrt{}")},PlusMinus=function(t){function e(e,n,r){return t.call(this,e,n,void 0,r,true)||this}return __extends(e,t),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!==R)return this.domFrag().oneElement().className=isBinaryOperator(this)?"mq-binary-operator":"",this},e}(BinaryOperator),LatexCmds["+"]=function(t){function e(){return t.call(this,"+",h.text("+"))||this}return __extends(e,t),e.prototype.mathspeak=function(){return isBinaryOperator(this)?"plus":"positive"},e}(PlusMinus),MinusNode=function(t){function e(){return t.call(this,"-",h.entityText("&minus;"))||this}return __extends(e,t),e.prototype.mathspeak=function(){return isBinaryOperator(this)?"minus":"negative"},e}(PlusMinus),LatexCmds["−"]=LatexCmds["—"]=LatexCmds["–"]=LatexCmds["-"]=MinusNode,LatexCmds["±"]=LatexCmds.pm=LatexCmds.plusmn=LatexCmds.plusminus=function(){return new PlusMinus("\\pm ",h.entityText("&plusmn;"),"plus-or-minus")},LatexCmds.mp=LatexCmds.mnplus=LatexCmds.minusplus=function(){return new PlusMinus("\\mp ",h.entityText("&#8723;"),"minus-or-plus")},CharCmds["*"]=LatexCmds.sdot=LatexCmds.cdot=bindBinaryOperator("\\cdot ","&middot;","*","times"),To=function(t){function e(){return t.call(this,"\\to ",h.entityText("&rarr;"),"to")||this}return __extends(e,t),e.prototype.deleteTowards=function(e,n){if(e===L){var r=n[L];return new Fragment(r,this).remove(),n[L]=r[L],(new MinusNode).createLeftOf(n),void n[L].bubble(function(t){t.reflow();})}t.prototype.deleteTowards.call(this,e,n);},e}(BinaryOperator),LatexCmds["→"]=LatexCmds.to=To,Inequality=function(t){function e(e,n){var r=this,o=n?"Strict":"";return r=t.call(this,e["ctrlSeq".concat(o)],h.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(domFrag(h.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===L&&!this.strict)return this.swap(true),void this.bubble(function(t){t.reflow();});t.prototype.deleteTowards.call(this,e,n);},e}(BinaryOperator),less={ctrlSeq:"\\le ",htmlEntity:"&le;",text:"≤",mathspeak:"less than or equal to",ctrlSeqStrict:"<",htmlEntityStrict:"&lt;",textStrict:"<",mathspeakStrict:"less than"},greater={ctrlSeq:"\\ge ",htmlEntity:"&ge;",text:"≥",mathspeak:"greater than or equal to",ctrlSeqStrict:">",htmlEntityStrict:"&gt;",textStrict:">",mathspeakStrict:"greater than"},Greater=function(t){function e(){return t.call(this,greater,true)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n,r=e[L];if(r instanceof BinaryOperator&&"-"===r.ctrlSeq)return n=r,e[L]=n[L],n.remove(),(new To).createLeftOf(e),void e[L].bubble(function(t){t.reflow();});t.prototype.createLeftOf.call(this,e);},e}(Inequality),LatexCmds["<"]=LatexCmds.lt=function(){return new Inequality(less,true)},LatexCmds[">"]=LatexCmds.gt=Greater,LatexCmds["≤"]=LatexCmds.le=LatexCmds.leq=function(){return new Inequality(less,false)},LatexCmds["≥"]=LatexCmds.ge=LatexCmds.geq=function(){return new Inequality(greater,false)},LatexCmds.infty=LatexCmds.infin=LatexCmds.infinity=bindVanillaSymbol("\\infty ","&infin;","infinity"),LatexCmds["≠"]=LatexCmds.ne=LatexCmds.neq=bindBinaryOperator("\\ne ","&ne;","not equal"),Equality=function(t){function e(){return t.call(this,"=",h.text("="),"=","equals")||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n=e[L];if(n instanceof Inequality&&n.strict)return n.swap(false),void n.bubble(function(t){t.reflow();});t.prototype.createLeftOf.call(this,e);},e}(BinaryOperator),LatexCmds["="]=Equality,LatexCmds["×"]=LatexCmds.times=LatexCmds.cross=bindBinaryOperator("\\times ","&times;","[x]","times"),LatexCmds["÷"]=LatexCmds.div=LatexCmds.divide=LatexCmds.divides=bindBinaryOperator("\\div ","&divide;","[/]","over"),Sim=function(t){function e(){return t.call(this,"\\sim ",h.text("~"),"~","tilde")||this}return __extends(e,t),e.prototype.createLeftOf=function(n){if(n[L]instanceof e){var r=n[L];return n[L]=r[L],r.remove(),(new Approx).createLeftOf(n),void n[L].bubble(function(t){t.reflow();})}t.prototype.createLeftOf.call(this,n);},e}(BinaryOperator),Approx=function(t){function e(){return t.call(this,"\\approx ",h.entityText("&approx;"),"≈","approximately equal")||this}return __extends(e,t),e.prototype.deleteTowards=function(e,n){if(e===L){var r=n[L];return new Fragment(r,this).remove(),n[L]=r[L],(new Sim).createLeftOf(n),void n[L].bubble(function(t){t.reflow();})}t.prototype.deleteTowards.call(this,e,n);},e}(BinaryOperator),LatexCmds.tildeNbsp=bindVanillaSymbol("~",U_NO_BREAK_SPACE," "),LatexCmds.sim=Sim,LatexCmds["≈"]=LatexCmds.approx=Approx,CharCmds["~"]=LatexCmds.sim,LatexCmds["~"]=LatexCmds.tildeNbsp,baseOptionProcessors.interpretTildeAsSim=function(t){var e=!!t;return LatexCmds["~"]=e?LatexCmds.sim:LatexCmds.tildeNbsp,e},SVG_SYMBOLS={sqrt:{width:"",html:function(){return h("svg",{preserveAspectRatio:"none",viewBox:"0 0 32 54"},[h("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 h("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[h("path",{d:"M4.4 0 L4.4 54 L5.6 54 L5.6 0"})])}},"[":{width:".55em",html:function(){return h("svg",{preserveAspectRatio:"none",viewBox:"0 0 11 24"},[h("path",{d:"M8 0 L3 0 L3 24 L8 24 L8 23 L4 23 L4 1 L8 1"})])}},"]":{width:".55em",html:function(){return h("svg",{preserveAspectRatio:"none",viewBox:"0 0 11 24"},[h("path",{d:"M3 0 L8 0 L8 24 L3 24 L3 23 L7 23 L7 1 L3 1"})])}},"(":{width:".55em",html:function(){return h("svg",{preserveAspectRatio:"none",viewBox:"3 0 106 186"},[h("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 h("svg",{preserveAspectRatio:"none",viewBox:"3 0 106 186"},[h("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 h("svg",{preserveAspectRatio:"none",viewBox:"10 0 210 350"},[h("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 h("svg",{preserveAspectRatio:"none",viewBox:"10 0 210 350"},[h("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 h("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[h("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 h("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[h("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 h("svg",{preserveAspectRatio:"none",viewBox:"0 0 10 54"},[h("path",{d:"M3.2 0 L6.8 27 L3.2 54 L2.2 54 L5.8 27 L2.2 0"})])}}},Style=function(t){function e(e,n,r,o,i){var a=t.call(this,e,new DOMView(1,function(t){return h.block(n,r,t[0])}))||this;return a.ariaLabel=o||e.replace(/^\\/,""),a.mathspeakTemplate=["Start"+a.ariaLabel+",","End"+a.ariaLabel],a.shouldNotSpeakDelimiters=i&&i.shouldNotSpeakDelimiters,a}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}(MathCommand),LatexCmds.mathrm=function(t){function e(){return t.call(this,"\\mathrm","span",{class:"mq-roman mq-font"},"Roman Font",{shouldNotSpeakDelimiters:true})||this}return __extends(e,t),e.prototype.isTextBlock=function(){return true},e}(Style),LatexCmds.mathit=function(){return new Style("\\mathit","i",{class:"mq-font"},"Italic Font")},LatexCmds.mathbf=function(){return new Style("\\mathbf","b",{class:"mq-font"},"Bold Font")},LatexCmds.mathsf=function(){return new Style("\\mathsf","span",{class:"mq-sans-serif mq-font"},"Serif Font")},LatexCmds.mathtt=function(){return new Style("\\mathtt","span",{class:"mq-monospace mq-font"},"Math Text")},LatexCmds.underline=function(){return new Style("\\underline","span",{class:"mq-non-leaf mq-underline"},"Underline")},LatexCmds.overline=LatexCmds.bar=function(){return new Style("\\overline","span",{class:"mq-non-leaf mq-overline"},"Overline")},LatexCmds.overrightarrow=function(){return new Style("\\overrightarrow","span",{class:"mq-non-leaf mq-overarrow mq-arrow-right"},"Over Right Arrow")},LatexCmds.overleftarrow=function(){return new Style("\\overleftarrow","span",{class:"mq-non-leaf mq-overarrow mq-arrow-left"},"Over Left Arrow")},LatexCmds.overleftrightarrow=function(){return new Style("\\overleftrightarrow ","span",{class:"mq-non-leaf mq-overarrow mq-arrow-leftright"},"Over Left and Right Arrow")},LatexCmds.overarc=function(){return new Style("\\overarc","span",{class:"mq-non-leaf mq-overarc"},"Over Arc")},LatexCmds.dot=function(){return new MathCommand("\\dot",new DOMView(1,function(t){return h("span",{class:"mq-non-leaf"},[h("span",{class:"mq-dot-recurring-inner"},[h("span",{class:"mq-dot-recurring"},[h.text(U_DOT_ABOVE)]),h.block("span",{class:"mq-empty-box"},t[0])])])}))},LatexCmds.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 DOMView(1,function(e){return h.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){var e,n;this.checkCursorContextOpen(t),n=this.blocks[0],t.latex+="\\textcolor{"+this.color+"}{",null===(e=n.latexRecursive)||void 0===e||e.call(n,t),t.latex+="}",this.checkCursorContextClose(t);},e.prototype.parser=function(){var e=this,n=Parser.optWhitespace,r=Parser.string,o=Parser.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 true},e}(MathCommand),LatexCmds.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=Parser.string,r=Parser.regex;return Parser.optWhitespace.then(n("{")).then(r(/^[-\w\s\\\xA0-\xFF]*/)).skip(n("}")).then(function(n){return e.cls=n||"",e.domView=new DOMView(1,function(t){return h.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){var e,n;this.checkCursorContextOpen(t),n=this.blocks[0],t.latex+="\\class{"+this.cls+"}{",null===(e=n.latexRecursive)||void 0===e||e.call(n,t),t.latex+="}",this.checkCursorContextClose(t);},e.prototype.isStyleBlock=function(){return true},e}(MathCommand),intRgx=/^[\+\-]?[\d]+$/,Options.prototype.charsThatBreakOutOfSupSub="",SupSub=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="_{...}^{...}",e}return __extends(e,t),e.prototype.setEnds=function(t){pray("SupSub ends must be MathBlocks",t[L]instanceof MathBlock&&t[R]instanceof MathBlock),this.ends=t;},e.prototype.getEnd=function(t){return this.ends[t]},e.prototype.createLeftOf=function(e){if(this.replacedFragment||e[L]||!e.options.supSubsRequireOperand)return t.prototype.createLeftOf.call(this,e)},e.prototype.contactWeld=function(t){var n,r,o,i,a,s,l;for(n=L;n;n=n===L&&R)if(r=this[n],o=void 0,r instanceof e){for(i="sub";i;i="sub"===i&&"sup")a=this[i],s=r[i],a&&(s?a.isEmpty()?o=new Point(s,0,s.getEnd(L)):(a.domFrag().children().insAtDirEnd(-n,s.domFrag().oneElement()),l=a.children().disown(),o=new Point(s,l.getEnd(R),s.getEnd(L)),n===L?l.adopt(s,s.getEnd(R),0):l.adopt(s,0,s.getEnd(L))):r.addBlock(a.disown()),this.placeCursor=function(t,e){return function(r){r.insAtDirEnd(-n,t||e);}}(s,a));this.remove(),t&&t[L]===this&&(n===R&&o?o[L]?t.insRightOf(o[L]):t.insAtLeftEnd(o.parent):t.insRightOf(r));break}},e.prototype.finalizeTree=function(){this.getEnd(L).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 MQSymbol?t.deleteSelection():t.clearSelection().insRightOf(this.parent),n.createLeftOf(t.show()),void t.controller.aria.queueTranslatableString("Baseline").alert(n.mathspeak({createdLeftOf:t}))}t[L]&&!t[R]&&!t.selection&&t.options.charsThatBreakOutOfSupSub.indexOf(e)>-1&&(t.insRightOf(this.parent),t.controller.aria.queueTranslatableString("Baseline")),MathBlock.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 MQSymbol?r.remove():r&&r.deleteTowards(e,n.insAtDirEnd(-e,this.sub)),this.sub.isEmpty()&&(this.sub.deleteOutOf(L,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,r,o,i,a;this.checkCursorContextOpen(t),this.sub&&(t.latex+="_{",i=t.latex.length,null===(n=(e=this.sub).latexRecursive)||void 0===n||n.call(e,t),a=t.latex.length,i===a&&(t.latex+=" "),t.latex+="}"),this.sup&&(t.latex+="^{",i=t.latex.length,null===(o=(r=this.sup).latexRecursive)||void 0===o||o.call(r,t),a=t.latex.length,i===a&&(t.latex+=" "),t.latex+="}"),this.checkCursorContextClose(t);},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){"sub"===this.supsub?(this.sup=this.upInto=this.sub.upOutOf=t,t.adopt(this,this.sub,0).downOutOf=this.sub,t.setDOM(domFrag(h("span",{class:"mq-sup"})).append(t.domFrag().children()).prependTo(this.domFrag().oneElement()).oneElement()),NodeBase.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(domFrag(h("span",{class:"mq-sub"})).append(t.domFrag().children()).appendTo(this.domFrag().oneElement()).oneElement()),NodeBase.linkElementByBlockNode(t.domFrag().oneElement(),t),this.domFrag().append(domFrag(h("span",{style:"display:inline-block;width:0"},[h.text(U_ZERO_WIDTH_SPACE)]))));for(var e=0;e<2;e+=1)!function(t,e,n,r){t[e].deleteOutOf=function(o,i){var a,s;i.insDirOf(this[o]?-o:o,this.parent),this.isEmpty()||(a=this.getEnd(o),this.children().disown().withDirAdopt(o,i.parent,i[o],i[-o]).domFrag().insDirOf(-o,i.domFrag()),i[-o]=a),t.supsub=n,delete t[e],delete t["".concat(r,"Into")],s=t[n],s["".concat(r,"OutOf")]=insLeftOfMeUnlessAtEnd,delete s.deleteOutOf,"sub"===e&&t.domFrag().addClass("mq-sup-only").children().last().remove(),this.remove();};}(this,"sub sup".split(" ")[e],"sup sub".split(" ")[e],"down up".split(" ")[e]);},e}(MathCommand),SubscriptCommand=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.supsub="sub",e.domView=new DOMView(1,function(t){return h("span",{class:"mq-supsub mq-non-leaf"},[h.block("span",{class:"mq-sub"},t[0]),h("span",{style:"display:inline-block;width:0"},[h.text(U_ZERO_WIDTH_SPACE)])])}),e.textTemplate=["_"],e.mathspeakTemplate=["Subscript,",", Baseline"],e.ariaLabel="subscript",e}return __extends(e,t),e.prototype.finalizeTree=function(){this.downInto=this.sub=this.getEnd(L),this.sub.upOutOf=insLeftOfMeUnlessAtEnd,t.prototype.finalizeTree.call(this);},e}(SupSub),LatexCmds.subscript=LatexCmds._=SubscriptCommand,
1453
+ LatexCmds.superscript=LatexCmds.supscript=LatexCmds["^"]=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.supsub="sup",e.domView=new DOMView(1,function(t){return h("span",{class:"mq-supsub mq-non-leaf mq-sup-only"},[h.block("span",{class:"mq-sup"},t[0])])}),e.textTemplate=["^(",")"],e.ariaLabel="superscript",e.mathspeakTemplate=["Superscript,",", Baseline"],e}return __extends(e,t),e.prototype.mathspeak=function(e){var n,r,o;return this.mathspeakOverride?t.prototype.mathspeak.call(this):(n=this.upInto,void 0===n||(r=getCtrlSeqsFromBlock(n),e&&e.ignoreShorthand||!intRgx.test(r))?t.prototype.mathspeak.call(this):"0"===r?"to the 0 power":"2"===r?"squared":"3"===r?"cubed":(o="",/^[+-]?\d{1,3}$/.test(r)&&(/(11|12|13|4|5|6|7|8|9|0)$/.test(r)?o="th":/1$/.test(r)?o="st":/2$/.test(r)?o="nd":/3$/.test(r)&&(o="rd")),"to the "+("object"==typeof n?n.mathspeak():r)+o+" power"))},e.prototype.finalizeTree=function(){this.upInto=this.sup=this.getEnd(R),this.sup.downOutOf=insLeftOfMeUnlessAtEnd,t.prototype.finalizeTree.call(this);},e}(SupSub),SummationNotation=function(t){function e(e,n,r){var o,i=t.call(this)||this;return i.ariaLabel=r||e.replace(/^\\/,""),o=new DOMView(2,function(t){return h("span",{class:"mq-large-operator mq-non-leaf"},[h("span",{class:"mq-to"},[h.block("span",{},t[1])]),h("big",{},[h.text(n)]),h("span",{class:"mq-from"},[h.block("span",{},t[0])])])}),MQSymbol.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 Letter("n").createLeftOf(e),(new Equality).createLeftOf(e));},e.prototype.latexRecursive=function(t){var e,n,r,o,i,a;this.checkCursorContextOpen(t),t.latex+=this.ctrlSeq+"_{",i=t.latex.length,null===(n=(e=this.getEnd(L)).latexRecursive)||void 0===n||n.call(e,t),a=t.latex.length,a===i&&(t.latex+=" "),t.latex+="}^{",i=t.latex.length,null===(o=(r=this.getEnd(R)).latexRecursive)||void 0===o||o.call(r,t),a=t.latex.length,i===a&&(t.latex+=" "),t.latex+="}",this.checkCursorContextClose(t);},e.prototype.mathspeak=function(){return this.mathspeakOverride?t.prototype.mathspeak.call(this):"Start "+this.ariaLabel+" from "+this.getEnd(L).mathspeak()+" to "+this.getEnd(R).mathspeak()+", end "+this.ariaLabel+", "},e.prototype.parser=function(){var t,e=Parser.string,n=Parser.optWhitespace,r=Parser.succeed,o=latexMathParser.block,i=this,a=i.blocks=[new MathBlock,new MathBlock];for(t=0;t<a.length;t+=1)a[t].adopt(i,i.getEnd(R),0);return n.then(e("_").or(e("^"))).then(function(t){var e=a["_"===t?0:1];return o.then(function(t){return t.children().adopt(e,e.getEnd(R),0),r(i)})}).many().result(i)},e.prototype.finalizeTree=function(){var t=this.getEnd(L),e=this.getEnd(R);t.ariaLabel="lower bound",e.ariaLabel="upper bound",this.downInto=t,this.upInto=e,t.upOutOf=e,e.downOutOf=t;},e}(MathCommand),LatexCmds["∑"]=LatexCmds.sum=LatexCmds.summation=function(){return new SummationNotation("\\sum ",U_NARY_SUMMATION,"sum")},LatexCmds["∏"]=LatexCmds.prod=LatexCmds.product=function(){return new SummationNotation("\\prod ",U_NARY_PRODUCT,"product")},LatexCmds.coprod=LatexCmds.coproduct=function(){return new SummationNotation("\\coprod ",U_NARY_COPRODUCT,"co product")},LatexCmds["∫"]=LatexCmds.int=LatexCmds.integral=function(t){function e(){var e=t.call(this,"\\int ","","integral")||this;return e.ariaLabel="integral",e.domView=new DOMView(2,function(t){return h("span",{class:"mq-int mq-non-leaf"},[h("big",{},[h.text(U_INTEGRAL)]),h("span",{class:"mq-supsub mq-non-leaf"},[h("span",{class:"mq-sup"},[h.block("span",{class:"mq-sup-inner"},t[1])]),h.block("span",{class:"mq-sub"},t[0]),h("span",{style:"display:inline-block;width:0"},[h.text(U_ZERO_WIDTH_SPACE)])])])}),e}return __extends(e,t),e.prototype.createLeftOf=function(t){MathCommand.prototype.createLeftOf.call(this,t);},e}(SummationNotation),Fraction=LatexCmds.frac=LatexCmds.dfrac=LatexCmds.cfrac=LatexCmds.fraction=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\frac",e.domView=new DOMView(2,function(t){return h("span",{class:"mq-fraction mq-non-leaf"},[h.block("span",{class:"mq-numerator"},t[0]),h.block("span",{class:"mq-denominator"},t[1]),h("span",{style:"display:inline-block;width:0"},[h.text(U_ZERO_WIDTH_SPACE)])])}),e.textTemplate=["(",")/(",")"],e}return __extends(e,t),e.prototype.finalizeTree=function(){var t=this.getEnd(L),e=this.getEnd(R);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,a,s,l,c;if(e&&e.createdLeftOf)return n=e.createdLeftOf,n.parent.mathspeak();if(this.mathspeakOverride)return t.prototype.mathspeak.call(this);if(r=getCtrlSeqsFromBlock(this.getEnd(L)),o=getCtrlSeqsFromBlock(this.getEnd(R)),(!e||!e.ignoreShorthand)&&intRgx.test(r)&&intRgx.test(o)&&(i="1"===r||"-1"===r,a="","2"===o?a=i?"half":"halves":"3"===o?a=i?"third":"thirds":"4"===o?a=i?"quarter":"quarters":"5"===o?a=i?"fifth":"fifths":"6"===o?a=i?"sixth":"sixths":"7"===o?a=i?"seventh":"sevenths":"8"===o?a=i?"eighth":"eighths":"9"===o&&(a=i?"ninth":"ninths"),""!==a)){for(s="",l=false,c=this[L];c&&void 0!==c[L];c=c[L])if("\\ "!==c.ctrlSeq){if(!intRgx.test(c.ctrlSeq||"")){l=false;break}l=true;}return l&&(s+="and "),s+=this.getEnd(L).mathspeak()+" "+a}return t.prototype.mathspeak.call(this)},e.prototype.getFracDepth=function(){var t=function(e,n){return e instanceof MQNode&&e.ctrlSeq&&e.ctrlSeq.toLowerCase().search("frac")>=0&&(n+=1),e&&e.parent?t(e.parent,n):n};return t(this,0)},e}(MathCommand),LiveFraction=LatexCmds.over=CharCmds["/"]=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(e){var n,r,o;if(!this.replacedFragment){if(n=e[L],!e.options.typingSlashCreatesNewFraction)for(;n&&!(n instanceof BinaryOperator||n instanceof(LatexCmds.text||noop)||n instanceof SummationNotation||"\\ "===n.ctrlSeq||/^[,;:]$/.test(n.ctrlSeq));)n=n[L];n instanceof SummationNotation&&n[R]instanceof SupSub&&(n=n[R],(r=n[R])instanceof SupSub&&r.ctrlSeq!=n.ctrlSeq&&(n=n[R])),n===e[L]||e.isTooDeep(1)||(r=n[R],o=e[L],this.replaces(new Fragment(r||e.parent.getEnd(L),o)),e[L]=n);}t.prototype.createLeftOf.call(this,e);},e}(Fraction),AnsBuilder=function(){return new MQSymbol("\\operatorname{ans}",h("span",{class:"mq-ans"},[h.text("ans")]),"ans")},LatexCmds.ans=AnsBuilder,PercentOfBuilder=function(){return new MQSymbol("\\%\\operatorname{of}",h("span",{class:"mq-nonSymbola mq-operator-name"},[h.text("% of ")]),"percent of")},LatexCmds.percent=LatexCmds.percentof=PercentOfBuilder,Token=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=h("span",{class:"mq-token mq-ignore-mousedown","data-mq-token":this.tokenId});return this.setDOM(t),NodeBase.linkElementByCmdNode(t,this),t},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.latex+="\\token{"+this.tokenId+"}",this.checkCursorContextClose(t);},e.prototype.mathspeak=function(){if(this.mathspeakOverride)return t.prototype.mathspeak.call(this);var e=[];return this.domFrag().children().eachElement(function(t){var n=t.getAttribute("aria-label");"string"==typeof n&&""!==n&&e.push(n);}),e.length>0?e.join(" ").trim():"token "+this.tokenId},e.prototype.parser=function(){var t=this;return latexMathParser.block.map(function(e){var n=e.getEnd(L);if(n)for(t.tokenId+=n.ctrlSeq;n=n[R];)t.tokenId+=n.ctrlSeq;return t})},e}(MQSymbol),LatexCmds.token=Token,SquareRoot=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\sqrt",e.domView=new DOMView(1,function(t){return h("span",{class:"mq-non-leaf mq-sqrt-container"},[h("span",{class:"mq-scaled mq-sqrt-prefix"},[SVG_SYMBOLS.sqrt.html()]),h.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 latexMathParser.optBlock.then(function(t){return latexMathParser.block.map(function(e){var n=new NthRoot;return n.blocks=[t,e],t.adopt(n,0,0),e.adopt(n,t,0),n})}).or(t.prototype.parser.call(this))},e}(MathCommand),LatexCmds.sqrt=SquareRoot,LatexCmds.hat=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\hat",e.domView=new DOMView(1,function(t){return h("span",{class:"mq-non-leaf"},[h("span",{class:"mq-hat-prefix"},[h.text("^")]),h.block("span",{class:"mq-hat-stem"},t[0])])}),e.textTemplate=["hat(",")"],e}return __extends(e,t),e}(MathCommand),NthRoot=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.domView=new DOMView(2,function(t){return h("span",{class:"mq-nthroot-container mq-non-leaf"},[h.block("sup",{class:"mq-nthroot mq-non-leaf"},t[0]),h("span",{class:"mq-scaled mq-sqrt-container"},[h("span",{class:"mq-sqrt-prefix mq-scaled"},[SVG_SYMBOLS.sqrt.html()]),h.block("span",{class:"mq-sqrt-stem mq-non-leaf"},t[1])])])}),e.textTemplate=["sqrt[","](",")"],e}return __extends(e,t),e.prototype.latexRecursive=function(t){var e,n,r,o;this.checkCursorContextOpen(t),t.latex+="\\sqrt[",null===(n=(e=this.getEnd(L)).latexRecursive)||void 0===n||n.call(e,t),t.latex+="]{",null===(o=(r=this.getEnd(R)).latexRecursive)||void 0===o||o.call(r,t),t.latex+="}",this.checkCursorContextClose(t);},e.prototype.mathspeak=function(){var e,n;return this.mathspeakOverride?t.prototype.mathspeak.call(this):(e=this.getEnd(L).mathspeak(),n=this.getEnd(R).mathspeak(),this.getEnd(L).ariaLabel="Index",this.getEnd(R).ariaLabel="Radicand","3"===e?"Start Cube Root, "+n+", End Cube Root":"Root Index "+e+", Start Root, "+n+", End Root")},e}(SquareRoot),LatexCmds.nthroot=NthRoot,LatexCmds.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 Digit("3").createLeftOf(e),e.controller.moveRight();},e}(NthRoot),DiacriticAbove=function(t){function e(e,n,r){var o=new DOMView(1,function(t){return h("span",{class:"mq-non-leaf"},[h("span",{class:"mq-diacritic-above"},[n]),h.block("span",{class:"mq-diacritic-stem"},t[0])])});return t.call(this,e,o,r)||this}return __extends(e,t),e}(MathCommand),LatexCmds.vec=function(){return new DiacriticAbove("\\vec",h.entityText("&rarr;"),["vec(",")"])},LatexCmds.tilde=function(){return new DiacriticAbove("\\tilde",h.text("~"),["tilde(",")"])},DelimsNode=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[L]=r.first(),n[R]=r.last(),n)),this},e}(MathCommand),Bracket=function(t){function e(e,n,r,o,i){var a,s=t.call(this,"\\left"+o,void 0,[n,r])||this;return s.side=e,s.sides=(a={},a[L]={ch:n,ctrlSeq:o},a[R]={ch:r,ctrlSeq:i},a),s}return __extends(e,t),e.prototype.numBlocks=function(){return 1},e.prototype.html=function(){var e=this,n=this.getSymbol(L),r=this.getSymbol(R);return this.domView=new DOMView(1,function(t){return h("span",{class:"mq-non-leaf mq-bracket-container"},[h("span",{style:"width:"+n.width,class:"mq-scaled mq-bracket-l mq-paren"+(e.side===R?" mq-ghost":"")},[n.html()]),h.block("span",{style:"margin-left:"+n.width+";margin-right:"+r.width,class:"mq-bracket-middle mq-non-leaf"},t[0]),h("span",{style:"width:"+r.width,class:"mq-scaled mq-bracket-r mq-paren"+(e.side===L?" mq-ghost":"")},[r.html()])])}),t.prototype.html.call(this)},e.prototype.getSymbol=function(t){var e=this.sides[t||R].ch;return SVG_SYMBOLS[e]||{width:"0",html:""}},e.prototype.latexRecursive=function(t){var e,n;this.checkCursorContextOpen(t),t.latex+="\\left"+this.sides[L].ctrlSeq,null===(n=(e=this.getEnd(L)).latexRecursive)||void 0===n||n.call(e,t),t.latex+="\\right"+this.sides[R].ctrlSeq,this.checkCursorContextClose(t);},e.prototype.mathspeak=function(e){var n,r,o;if(this.mathspeakOverride)return (null===e||void 0===e?void 0:e.createdLeftOf)?this.mathspeakOverride(this.sides[this.side].ch):t.prototype.mathspeak.call(this);if(n=this.sides[L].ch,r=this.sides[R].ch,"|"===n&&"|"===r)this.mathspeakTemplate=["StartAbsoluteValue,",", EndAbsoluteValue"],this.ariaLabel="absolute value";else {if(e&&e.createdLeftOf&&this.side)return o="",this.side===L?o=this.textTemplate[0]:this.side===R&&(o=this.textTemplate[1]),(this.side===L?"left ":"right ")+BRACKET_NAMES[o];this.mathspeakTemplate=["left "+BRACKET_NAMES[n]+",",", right "+BRACKET_NAMES[r]],this.ariaLabel=BRACKET_NAMES[n]+" 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||OPP_BRACKS[this.sides[this.side].ch]===r.sides[r.side].ch||{"(":"]","[":")"}[this.sides[L].ch]===r.sides[R].ch)&&r},e.prototype.closeOpposing=function(t){t.side=0,t.sides[this.side]=this.sides[this.side];var e=t.delimFrags[this.side===L?L:R].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[L].ch?this.matchBrack(r,R,e[R])||this.matchBrack(r,L,e[L])||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 Fragment(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 Fragment(e[-o],e.parent.getEnd(-o),o)),e[-o]=0),t.prototype.createLeftOf.call(this,e)),o===L?e.insAtLeftEnd(n.getEnd(L)):e.insRightOf(n);},e.prototype.placeCursor=function(){},e.prototype.unwrap=function(){this.getEnd(L).children().disown().adopt(this.parent,this,this[R]).domFrag().insertAfter(this.domFrag()),this.remove();},e.prototype.deleteSide=function(t,e,n){var r,o,i,a,s,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(L).getEnd(this.side)))this.closeOpposing(this.getEnd(L).getEnd(this.side)),i=this.getEnd(L).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]=getOppBracketSide(this),this.delimFrags[L].removeClass("mq-ghost"),this.delimFrags[R].removeClass("mq-ghost"),a=this.delimFrags[t].addClass("mq-ghost"),this.replaceBracket(a,t);}c?(s=this.getEnd(L),i=s.getEnd(t),s.domFrag().removeClass("mq-empty"),new Fragment(c,u,-t).disown().withDirAdopt(-t,s,i,0).domFrag().insAtDirEnd(t,s.domFrag().oneElement()),i&&i.siblingCreated(n.options,t),n.insDirOf(-t,c)):e?n.insDirOf(t,this):n.insAtDirEnd(t,this.getEnd(L));}},e.prototype.replaceBracket=function(t,e){var n,r,o=this.getSymbol(e);t.children().replaceWith(domFrag(o.html())),t.oneElement().style.width=o.width,e===L?(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,false,e);},e.prototype.finalizeTree=function(){this.getEnd(L).deleteOutOf=function(t,e){this.parent.deleteSide(t,true,e);},this.finalizeTree=this.intentionalBlur=function(){this.delimFrags[this.side===L?R:L].removeClass("mq-ghost"),this.side=0;};},e.prototype.siblingCreated=function(t,e){e===-this.side&&this.finalizeTree();},e}(DelimsNode),OPP_BRACKS={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","\\{":"\\}","\\}":"\\{","&lang;":"&rang;","&rang;":"&lang;","\\langle ":"\\rangle ","\\rangle ":"\\langle ","|":"|","\\lVert ":"\\rVert ","\\rVert ":"\\lVert "},BRACKET_NAMES={"&lang;":"angle-bracket","&rang;":"angle-bracket","|":"pipe"},bindCharBracketPair("(","","parenthesis"),bindCharBracketPair("[","","bracket"),bindCharBracketPair("{","\\{","brace"),LatexCmds.langle=function(){return new Bracket(L,"&lang;","&rang;","\\langle ","\\rangle ")},LatexCmds.rangle=function(){return new Bracket(R,"&lang;","&rang;","\\langle ","\\rangle ")},CharCmds["|"]=function(){return new Bracket(L,"|","|","|","|")},LatexCmds.lVert=function(){return new Bracket(L,"&#8741;","&#8741;","\\lVert ","\\rVert ")},LatexCmds.rVert=function(){return new Bracket(R,"&#8741;","&#8741;","\\lVert ","\\rVert ")},LatexCmds.left=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){var t=Parser.regex,e=Parser.string,n=Parser.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+=" "),latexMathParser.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 Bracket(0,o,n,r,t),e.blocks=[i],i.adopt(e,0,0),e})})})},e}(MathCommand),LatexCmds.right=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.parser=function(){return Parser.fail("unmatched \\right")},e}(MathCommand),leftBinomialSymbol=SVG_SYMBOLS["("],rightBinomialSymbol=SVG_SYMBOLS[")"],Binomial=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\binom",e.domView=new DOMView(2,function(t){return h("span",{class:"mq-non-leaf mq-bracket-container"},[h("span",{style:"width:"+leftBinomialSymbol.width,class:"mq-paren mq-bracket-l mq-scaled"},[leftBinomialSymbol.html()]),h("span",{style:"margin-left:"+leftBinomialSymbol.width+"; margin-right:"+rightBinomialSymbol.width,class:"mq-non-leaf mq-bracket-middle"},[h("span",{class:"mq-array mq-non-leaf"},[h.block("span",{},t[0]),h.block("span",{},t[1])])]),h("span",{style:"width:"+rightBinomialSymbol.width,class:"mq-paren mq-bracket-r mq-scaled"},[rightBinomialSymbol.html()])])}),e.textTemplate=["choose(",",",")"],e.mathspeakTemplate=["StartBinomial,","Choose",", EndBinomial"],e.ariaLabel="binomial",e}return __extends(e,t),e}(DelimsNode),LatexCmds.binom=LatexCmds.binomial=Binomial,LatexCmds.choose=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.createLeftOf=function(t){LiveFraction.prototype.createLeftOf(t);},e}(Binomial),MathFieldNode=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\MathQuillMathField",e.domView=new DOMView(1,function(t){return h("span",{class:"mq-editable-field"},[h.block("span",{class:"mq-root-block","aria-hidden":"true"},t[0])])}),e}return __extends(e,t),e.prototype.parser=function(){var e=this,n=Parser.string,r=Parser.regex,o=Parser.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&&!domFrag(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"),domFrag(t).children().eachElement(function(t){t.setAttribute("aria-hidden","true");}));}}var n=new Controller(this.getEnd(L),this.domFrag().oneElement(),t);n.KIND_OF_MQ="MathField",n.editable=true,n.createTextarea(),n.editablesTextareaEvents(),n.cursor.insAtRightEnd(n.root),RootBlockMixin(n.root),e(this.domFrag().parent().oneElement()),this.domFrag().oneElement().removeAttribute("aria-hidden");},e.prototype.registerInnerField=function(t,e){var n=this.getEnd(L).controller,r=new e(n);t[this.name]=r,t.push(r);},e.prototype.latexRecursive=function(t){var e,n;this.checkCursorContextOpen(t),null===(n=(e=this.getEnd(L)).latexRecursive)||void 0===n||n.call(e,t),this.checkCursorContextClose(t);},e.prototype.text=function(){return this.getEnd(L).text()},e}(MathCommand),LatexCmds.editable=LatexCmds.MathQuillMathField=MathFieldNode,EmbedNode=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 DOMView(0,function(){return h("span",{},[parseHTML(t.htmlString||"")])}),this.latex=t.latex||e,this},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.latex+=this.latex(),this.checkCursorContextClose(t);},e.prototype.parser=function(){var t=this,e=Parser.string,n=Parser.regex,r=Parser.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(EMBEDS[o](e))})})},e}(MQSymbol),LatexCmds.embed=EmbedNode,TextBlock=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\text",e.ariaLabel="Text",e.mathspeakTemplate=["StartText","EndText"],e}return __extends(e,t),e.prototype.replaces=function(t){t instanceof Fragment?this.replacedText=t.remove().domFrag().text():"string"==typeof t&&(this.replacedText=t);},e.prototype.setDOMFrag=function(e){var n,r;return t.prototype.setDOM.call(this,e),n=this.getEnd(L),n&&(r=this.domFrag().children(),r.isEmpty()||n.setDOM(r.oneText())),this},e.prototype.createLeftOf=function(e){var n,r,o,i=this;if(t.prototype.createLeftOf.call(this,e),e.insAtRightEnd(i),i.replacedText)for(n=0;n<i.replacedText.length;n+=1)i.write(e,i.replacedText.charAt(n));r=i[R],r&&r.siblingCreated(e.options,L),o=i[L],o&&o.siblingCreated(e.options,R),i.bubble(function(t){t.reflow();});},e.prototype.parser=function(){var t=this,e=Parser.string,n=Parser.regex;return Parser.optWhitespace.then(e("{")).then(n(/^[^}]*/)).skip(e("}")).map(function(e){return 0===e.length?new Fragment(0,0):(new TextPiece(e).adopt(t,0,0),t)})},e.prototype.textContents=function(){return this.foldChildren("",function(t,e){return t+e.textStr})},e.prototype.text=function(){return '"'+this.textContents()+'"'},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t);var e=this.textContents();e.length>0&&(t.latex+=this.ctrlSeq+"{",t.latex+=e.replace(/\\/g,"\\backslash ").replace(/[{}]/g,"\\$&"),t.latex+="}"),this.checkCursorContextClose(t);},e.prototype.html=function(){var t=h("span",{class:"mq-text-mode"},[h.text(this.textContents())]);return this.setDOM(t),NodeBase.linkElementByCmdNode(t,this),t},e.prototype.mathspeak=function(e){return e&&e.ignoreShorthand?this.mathspeakOverride?t.prototype.mathspeak.call(this):this.mathspeakTemplate[0]+", "+this.textContents()+", "+this.mathspeakTemplate[1]:this.textContents()},e.prototype.isTextBlock=function(){return true},e.prototype.moveTowards=function(t,e){e.insAtDirEnd(-t,this),e.controller.aria.queueDirEndOf(-t,e.parent,true);},e.prototype.moveOutOf=function(t,e){e.insDirOf(t,this),e.controller.aria.queueDirOf(t,this);},e.prototype.unselectInto=function(t,e){this.moveTowards(t,e);},e.prototype.selectTowards=function(t,e){MathCommand.prototype.selectTowards.call(this,t,e);},e.prototype.deleteTowards=function(t,e){MathCommand.prototype.deleteTowards.call(this,t,e);},e.prototype.selectOutOf=function(t,e){e.insDirOf(t,this);},e.prototype.deleteOutOf=function(t,e){this.isEmpty()&&e.insRightOf(this);},e.prototype.write=function(n,r){var o,i,a;n.show().deleteSelection(),"$"!==r?(o=n[L],o?o instanceof TextPiece&&o.appendText(r):new TextPiece(r).createLeftOf(n)):this.isEmpty()?(n.insRightOf(this),new VanillaSymbol("\\$",h.text("$")).createLeftOf(n)):n[R]?n[L]?(i=new e,a=this.getEnd(L),a&&(a.disown().domFrag().detach(),a.adopt(i,0,0)),n.insLeftOf(this),t.prototype.createLeftOf.call(i,n)):n.insLeftOf(this):n.insRightOf(this),this.bubble(function(t){t.reflow();}),n.controller.aria.alert(r);},e.prototype.writeLatex=function(t,e){var n=t[L];n?n instanceof TextPiece&&n.appendText(e):new TextPiece(e).createLeftOf(t),this.bubble(function(t){t.reflow();});},e.prototype.seek=function(t,e){var n,r,o,i,a,s,l,c,u,p,d,h,m,f,y,g;if(e.hide(),n=TextBlockFuseChildren(this)){for(r=this.domFrag().children().oneText(),o=document.createRange(),o.selectNodeContents(r),i=o.getClientRects(),1===i.length?(a=i[0],s=a.width,l=a.left,c=s/this.textContents().length,u=Math.round((t-l)/c),u<=0?e.insAtLeftEnd(this):u>=n.textStr.length?e.insAtRightEnd(this):e.insLeftOf(n.splitRight(u))):e.insAtLeftEnd(this),p=t-e.show().getBoundingClientRectWithoutMargin().left,d=p&&p<0?L:R,h=d;e[d]&&p*h>0;)e[d].moveTowards(d,e),h=p,p=t-e.getBoundingClientRectWithoutMargin().left;d*p<-d*h&&e[-d].moveTowards(-d,e),e.anticursor?e.anticursor.parent===this&&(m=e[L],f=m&&m.textStr.length,this.anticursorPosition===f?e.anticursor=Anticursor.fromCursor(e):(this.anticursorPosition<f?(y=m.splitRight(this.anticursorPosition),e[L]=y):(g=e[R],y=g.splitRight(this.anticursorPosition-f)),e.anticursor=new Anticursor(this,y[L],y))):(m=e[L],this.anticursorPosition=m&&m.textStr.length);}},e.prototype.blur=function(t){MathBlock.prototype.blur.call(this,t),t&&(""===this.textContents()?(this.remove(),t[L]===this?t[L]=this[L]:t[R]===this&&(t[R]=this[R])):TextBlockFuseChildren(this));},e.prototype.focus=function(){MathBlock.prototype.focus.call(this);},e}(MQNode),TextPiece=function(t){function e(e){var n=t.call(this)||this;return n.textStr=e,n}return __extends(e,t),e.prototype.html=function(){var t=h.text(this.textStr);return this.setDOM(t),t},e.prototype.appendText=function(t){this.textStr+=t,this.domFrag().oneText().appendData(t);},e.prototype.prependText=function(t){this.textStr=t+this.textStr,this.domFrag().oneText().insertData(0,t);},e.prototype.insTextAtDirEnd=function(t,e){prayDirection(e),e===R?this.appendText(t):this.prependText(t);},e.prototype.splitRight=function(t){var n=new e(this.textStr.slice(t)).adopt(this.parent,this,this[R]);return n.setDOM(this.domFrag().oneText().splitText(t)),this.textStr=this.textStr.slice(0,t),n},e.prototype.endChar=function(t,e){return e.charAt(t===L?0:-1+e.length)},e.prototype.moveTowards=function(t,n){var r,o;return prayDirection(t),r=this.endChar(-t,this.textStr),o=this[-t],o instanceof e?o.insTextAtDirEnd(r,t):new e(r).createDir(-t,n),this.deleteTowards(t,n)},e.prototype.mathspeak=function(){return this.textStr},e.prototype.latexRecursive=function(t){this.checkCursorContextOpen(t),t.latex+=this.textStr,this.checkCursorContextClose(t);},e.prototype.deleteTowards=function(t,e){if(this.textStr.length>1){var n;t===R?(this.domFrag().oneText().deleteData(0,1),n=this.textStr[0],this.textStr=this.textStr.slice(1)):(this.domFrag().oneText().deleteData(-1+this.textStr.length,1),n=this.textStr[this.textStr.length-1],this.textStr=this.textStr.slice(0,-1)),e.controller.aria.queue(n);}else this.remove(),e[t]=this[t],e.controller.aria.queue(this.textStr);},e.prototype.selectTowards=function(t,n){var r,o,i,a,s;if(prayDirection(t),r=n.anticursor)return o=this.endChar(-t,this.textStr),r[t]===this?(i=new e(o).createDir(t,n),r[t]=i,n.insDirOf(t,i)):(a=this[-t],a instanceof e?a.insTextAtDirEnd(o,t):(i=new e(o).createDir(-t,n),(s=n.selection)&&i.domFrag().insDirOf(-t,s.domFrag())),1===this.textStr.length&&r[-t]===this&&(r[-t]=this[-t])),this.deleteTowards(t,n)},e}(MQNode),LatexCmds.text=LatexCmds.textnormal=LatexCmds.textrm=LatexCmds.textup=LatexCmds.textmd=TextBlock,LatexCmds.em=LatexCmds.italic=LatexCmds.italics=LatexCmds.emph=LatexCmds.textit=LatexCmds.textsl=makeTextBlock("\\textit","Italic","i",{class:"mq-text-mode"}),LatexCmds.strong=LatexCmds.bold=LatexCmds.textbf=makeTextBlock("\\textbf","Bold","b",{class:"mq-text-mode"}),LatexCmds.sf=LatexCmds.textsf=makeTextBlock("\\textsf","Sans serif font","span",{class:"mq-sans-serif mq-text-mode"}),LatexCmds.tt=LatexCmds.texttt=makeTextBlock("\\texttt","Mono space font","span",{class:"mq-monospace mq-text-mode"}),LatexCmds.textsc=makeTextBlock("\\textsc","Variable font","span",{style:"font-variant:small-caps",class:"mq-text-mode"}),LatexCmds.uppercase=makeTextBlock("\\uppercase","Uppercase","span",{style:"text-transform:uppercase",class:"mq-text-mode"}),LatexCmds.lowercase=makeTextBlock("\\lowercase","Lowercase","span",{style:"text-transform:lowercase",class:"mq-text-mode"}),RootMathCommand=function(t){function e(e){var n=t.call(this,"$")||this;return n.domView=new DOMView(1,function(t){return h.block("span",{class:"mq-math-mode"},t[0])}),n.cursor=e,n}return __extends(e,t),e.prototype.createBlocks=function(){t.prototype.createBlocks.call(this);var e=this.getEnd(L);e.cursor=this.cursor,e.write=function(t,e){"$"!==e?MathBlock.prototype.write.call(this,t,e):this.isEmpty()?(t.insRightOf(this.parent),this.parent.deleteTowards(void 0,t),new VanillaSymbol("\\$",h.text("$")).createLeftOf(t.show())):t[R]?t[L]?MathBlock.prototype.write.call(this,t,e):t.insLeftOf(this.parent):t.insRightOf(this.parent);};},e.prototype.latexRecursive=function(t){var e,n;this.checkCursorContextOpen(t),t.latex+="$",null===(n=(e=this.getEnd(L)).latexRecursive)||void 0===n||n.call(e,t),t.latex+="$",this.checkCursorContextClose(t);},e}(MathCommand),RootTextBlock=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.keystroke=function(e,n,r){if("Spacebar"!==e&&"Shift-Spacebar"!==e)return t.prototype.keystroke.call(this,e,n,r)},e.prototype.write=function(t,e){if(t.show().deleteSelection(),"$"===e)new RootMathCommand(t).createLeftOf(t);else {var n;"<"===e?n=h.entityText("&lt;"):">"===e&&(n=h.entityText("&gt;")),new VanillaSymbol(e,n).createLeftOf(t);}},e}(RootMathBlock),API.TextField=function(t){var e;return e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.__mathquillify=function(){return t.prototype.mathquillify.call(this,"mq-editable-field mq-text-mode"),this},e.prototype.latex=function(t){if(t){this.__controller.renderLatexText(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur();return this}return this.__controller.exportLatex()},e}(t.EditableField),e.RootBlock=RootTextBlock,e},CharCmds["\\"]=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ctrlSeq="\\",e.domView=new DOMView(1,function(t){return h("span",{class:"mq-latex-command-input-wrapper mq-non-leaf"},[h("span",{class:"mq-latex-command-input mq-non-leaf"},[h.text("\\"),h.block("span",{},t[0])])])}),e.textTemplate=["\\"],e}return __extends(e,t),e.prototype.replaces=function(t){this._replacedFragment=t.disown(),this.isEmpty=function(){return false};},e.prototype.createBlocks=function(){var e,n;t.prototype.createBlocks.call(this),e=this.getEnd(L),e.focus=function(){return this.parent.domFrag().addClass("mq-hasCursor"),this.isEmpty()&&this.parent.domFrag().removeClass("mq-empty"),this},e.blur=function(){return this.parent.domFrag().removeClass("mq-hasCursor"),this.isEmpty()&&this.parent.domFrag().addClass("mq-empty"),this},e.write=function(t,e){if(t.show().deleteSelection(),e.match(/[a-z]/i))new VanillaSymbol(e).createLeftOf(t),t.controller.aria.alert(e);else {var n=this.parent.renderCommand(t);t.controller.aria.queue(n.mathspeak({createdLeftOf:t})),"\\"===e&&this.isEmpty()?t.controller.aria.alert():t.parent.write(t,e);}},n=e.keystroke,e.keystroke=function(t,e,r){if("Tab"===t||"Enter"===t||"Spacebar"===t){var o=this.parent.renderCommand(r.cursor);return r.aria.alert(o.mathspeak({createdLeftOf:r.cursor})),void(null===e||void 0===e||e.preventDefault())}return n.call(this,t,e,r)};},e.prototype.createLeftOf=function(e){var n,r,o;t.prototype.createLeftOf.call(this,e),
1454
+ this._replacedFragment&&(n=this.domFrag(),r=n.oneElement(),this._replacedFragment.domFrag().addClass("mq-blur"),o=function(t){return t.target=r,r.dispatchEvent(t),false},r.addEventListener("mousedown",o),r.addEventListener("mouseup",o),this._replacedFragment.domFrag().insertBefore(n.children().first()));},e.prototype.latexRecursive=function(t){var e,n;this.checkCursorContextOpen(t),t.latex+="\\",null===(n=(e=this.getEnd(L)).latexRecursive)||void 0===n||n.call(e,t),t.latex+=" ",this.checkCursorContextClose(t);},e.prototype.renderCommand=function(t){var e,n,r;return this.setDOM(this.domFrag().children().lastElement()),this.remove(),this[R]?t.insLeftOf(this[R]):t.insAtRightEnd(this.parent),e=this.getEnd(L).latex(),e||(e=" "),n=LatexCmds[e],n?(r=void 0,r=isMQNodeClass(n)?new n(e):n(e),this._replacedFragment&&r.replaces(this._replacedFragment),r.createLeftOf(t),r):(r=new TextBlock,r.replaces(e),r.createLeftOf(t),t.insRightOf(r),this._replacedFragment&&this._replacedFragment.remove(),r)},e}(MathCommand),mathquill_min$1.exports=MathQuill;
1455
+ return mathquill_min$1.exports;
1456
+ }
1457
+
1458
+ var mathquill_minExports = requireMathquill_min();
1459
+ var MathQuill = /*@__PURE__*/getDefaultExportFromCjs(mathquill_minExports);
1460
+
1428
1461
  const CDOT_ONLY=["az","cs","da","de","hu","hy","kk","ky","lt","lv","nb","sk","sr","sv","uz"];const TIMES_ONLY=["fr","tr","pt-pt"];function convertDotToTimesByLocale(locale,convertDotToTimes){if(CDOT_ONLY.includes(locale)){return false}if(TIMES_ONLY.includes(locale)){return true}return convertDotToTimes}const inJest=typeof process!=="undefined"&&!!process?.env?.JEST_WORKER_ID;
1429
1462
 
1430
- const mathQuillInstance=MathQuill__default.default.getInterface(3);const createBaseConfig=()=>({autoCommands:"pi theta phi sqrt nthroot",autoOperatorNames:["arccos","arcsin","arctan","arctg","arg","cos","cosec","cossec","cosh","cot","cotg","coth","csc","ctg","deg","det","dim","exp","gcd","hom","inf","ker","lg","lim","liminf","limsup","ln","log","max","min","Pr","projlim","sec","sen","sin","sinh","sup","tan","tanh","tg"].join(" "),charsThatBreakOutOfSupSub:"+-*/=<>≠≤≥",supSubsRequireOperand:true,spaceBehavesLikeTab:true});function createMathField(container,locale,strings,configCallback){const baseConfig=createBaseConfig();const config=configCallback?configCallback(baseConfig):baseConfig;const mathField=mathQuillInstance.MathField(container,config).setAriaLabel(strings.mathInputBox).setAriaStringsOverrideMap({before:obj=>strings.before({obj}),after:obj=>strings.after({obj}),"beginning of":obj=>strings["beginning of"]({obj}),"end of":obj=>strings["end of"]({obj}),Baseline:strings.Baseline,Superscript:strings.Superscript,selected:obj=>strings.selected({obj}),"no answer":strings["no answer"],"nothing selected":strings["nothing selected"],"nothing to the right":strings["nothing to the right"],"nothing to the left":strings["nothing to the left"],"block is empty":strings["block is empty"],"nothing above":strings["nothing above"],labelValue:(label,value)=>strings.labelValue({label,value})});!inJest&&mathjaxRenderer.SpeechRuleEngine.setup(locale).then(SRE=>mathField.setMathspeakOverride(SRE.texToSpeech));return mathField}
1463
+ const mathQuillInstance=MathQuill.getInterface(3);const createBaseConfig=()=>({autoCommands:"pi theta phi sqrt nthroot",autoOperatorNames:["arccos","arcsin","arctan","arctg","arg","cos","cosec","cossec","cosh","cot","cotg","coth","csc","ctg","deg","det","dim","exp","gcd","hom","inf","ker","lg","lim","liminf","limsup","ln","log","max","min","Pr","projlim","sec","sen","sin","sinh","sup","tan","tanh","tg"].join(" "),charsThatBreakOutOfSupSub:"+-*/=<>≠≤≥",supSubsRequireOperand:true,spaceBehavesLikeTab:true});function createMathField(container,locale,strings,configCallback){const baseConfig=createBaseConfig();const config=configCallback?configCallback(baseConfig):baseConfig;const mathField=mathQuillInstance.MathField(container,config).setAriaLabel(strings.mathInputBox).setAriaStringsOverrideMap({before:obj=>strings.before({obj}),after:obj=>strings.after({obj}),"beginning of":obj=>strings["beginning of"]({obj}),"end of":obj=>strings["end of"]({obj}),Baseline:strings.Baseline,Superscript:strings.Superscript,selected:obj=>strings.selected({obj}),"no answer":strings["no answer"],"nothing selected":strings["nothing selected"],"nothing to the right":strings["nothing to the right"],"nothing to the left":strings["nothing to the left"],"block is empty":strings["block is empty"],"nothing above":strings["nothing above"],labelValue:(label,value)=>strings.labelValue({label,value})});!inJest&&mathjaxRenderer.SpeechRuleEngine.setup(locale).then(SRE=>mathField.setMathspeakOverride(SRE.texToSpeech));return mathField}
1431
1464
 
1432
1465
  const Numerals=["0","1","2","3","4","5","6","7","8","9"];const GreekLetters=["\\theta","\\pi"];const Letters=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];const ValidLeaves=[...Numerals,...GreekLetters,...Letters.map(letter=>letter.toLowerCase()),...Letters.map(letter=>letter.toUpperCase())];const mqNodeHasClass=(node,className)=>node._el&&node._el.classList.contains(className);function isFraction(node){return mqNodeHasClass(node,"mq-fraction")}function isNumerator(node){return mqNodeHasClass(node,"mq-numerator")}function isDenominator(node){return mqNodeHasClass(node,"mq-denominator")}function isSubScript(node){return mqNodeHasClass(node,"mq-sub-only")||mqNodeHasClass(node,"mq-sub")}function isSuperScript(node){return mqNodeHasClass(node,"mq-sup-only")||mqNodeHasClass(node,"mq-sup")}function isParens(node){return node&&node.ctrlSeq==="\\left("}function isLeaf(node){return node&&node.ctrlSeq&&ValidLeaves.includes(node.ctrlSeq.trim())}function isSquareRoot(node){return node.blocks&&mqNodeHasClass(node.blocks[0],"mq-sqrt-stem")}function isNthRoot(node){return node.blocks&&mqNodeHasClass(node.blocks[0],"mq-nthroot")}function isNthRootIndex(node){return mqNodeHasClass(node,"mq-nthroot")}function isInsideLogIndex(cursor){const grandparent=cursor.parent.parent;if(grandparent&&mqNodeHasClass(grandparent,"mq-supsub")){const command=maybeFindCommandBeforeParens(grandparent);if(command&&command.name==="\\log"){return true}}return false}function isInsideEmptyNode(cursor){return cursor[mathQuillInstance.L]===MathFieldActionType.MQ_END&&cursor[mathQuillInstance.R]===MathFieldActionType.MQ_END}function selectNode(node,cursor){cursor.insLeftOf(node);cursor.startSelection();cursor.insRightOf(node);cursor.select();cursor.endSelection();}function maybeFindCommand(initialNode){if(!initialNode){return null}const commandCharRegex=/^[a-z]$/;const commandStartRegex=/^\\[a-z]$/;const commandEndSeq="\\left(";const validCommands=["\\log","\\ln","\\cos","\\sin","\\tan"];let name="";let startNode;let endNode;let node=initialNode;while(node!==0){const ctrlSeq=node.ctrlSeq.trim();if(commandCharRegex.test(ctrlSeq)){name=ctrlSeq+name;}else if(commandStartRegex.test(ctrlSeq)){name=ctrlSeq+name;startNode=node;break}else {break}node=node[mathQuillInstance.L];}if(startNode){node=initialNode[mathQuillInstance.R];while(node!==0){const ctrlSeq=node.ctrlSeq.trim();if(commandCharRegex.test(ctrlSeq)){name=name+ctrlSeq;}else if(ctrlSeq===commandEndSeq){endNode=node;break}node=node[mathQuillInstance.R];}if(validCommands.includes(name)){return {name,startNode,endNode}}else {return null}}else {return null}}function maybeFindCommandBeforeParens(leftParenNode){return maybeFindCommand(leftParenNode[mathQuillInstance.L])}function getCursorContext(mathField){if(!mathField){return CursorContext.NONE}const cursor=mathField.cursor();let visitor=cursor;while(visitor[mathQuillInstance.R]!==MathFieldActionType.MQ_END){if(isFraction(visitor[mathQuillInstance.R])){return CursorContext.BEFORE_FRACTION}else if(!isLeaf(visitor[mathQuillInstance.R])){break}visitor=visitor[mathQuillInstance.R];}if(isParens(cursor.parent&&cursor.parent.parent)){return CursorContext.IN_PARENS}else if(isNumerator(cursor.parent)){return CursorContext.IN_NUMERATOR}else if(isDenominator(cursor.parent)){return CursorContext.IN_DENOMINATOR}else if(isSubScript(cursor.parent)){return CursorContext.IN_SUB_SCRIPT}else if(isSuperScript(cursor.parent)){return CursorContext.IN_SUPER_SCRIPT}else {return CursorContext.NONE}}
1433
1466