mathquill_swiftcalcs_rails 0.9.3.112 → 0.9.3.113

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a59ae5ffab1a64e7a019826377389460fcaf448
4
- data.tar.gz: 85eb072c32ecca5b4e5196405d6a28fccd2ebfa5
3
+ metadata.gz: c30ead6a492fb40eb90d23c6e63ef9be317ea22c
4
+ data.tar.gz: 388f7271de8c74247c09c5ffd129a0a828b76f25
5
5
  SHA512:
6
- metadata.gz: 0c09949ba10696f91ee3eba2e7460cf0b0a0773a14a7088fb7f30b57544d6b655fc5e72b0c929b3a9369f4bde2eddc1810a70cfac59156a5b4c97360cb9022f8
7
- data.tar.gz: 667a752976bf41b053dfd7ffe898b7f85ee1dc485475f43a256093a99cfd9c024a8a2647c64b8ad46e0d99a38e25243dc12537cf771683af491dc71a0537a181
6
+ metadata.gz: e3fda0fdbbe94f3560811e707532ba265f1765a3e504218c1911a0721e7f014f9b532374ed6911513f7eae686f130bbc2f46f34587e7c740e813270d2375fd0e
7
+ data.tar.gz: b22c0aa929c5effddaf615913614261b2ea8442e6e788af4a6c6f772a94496fe9f1dfe9aa3777314a5b968f0a467e5bb31bb94b10b53f871e7aa0193254650be
@@ -1,3 +1,3 @@
1
- !function(){function t(){}function e(t){var e=t.length-1;return function(){var n=ye.call(arguments,0,e),i=ye.call(arguments,e);return t.apply(this,n.concat([i]))}}function n(t){return e(function(e,n){"function"!=typeof e&&(e=Ce(e));var i=function(t){return e.apply(t,[t].concat(n))};return t.call(this,i)})}function i(t){var e=ye.call(arguments,1);return function(){return t.apply(this,e)}}function s(t,e){if(!e)throw new Error("prayer failed: "+t)}function r(t){s("a direction was passed",t===Qe||t===Se)}function o(t,e,n){s("a parent is always present",t),s("leftward is properly set up",function(){return e?e[Se]===n&&e.parent===t:t.ends[Qe]===n}()),s("rightward is properly set up",function(){return n?n[Qe]===e&&n.parent===t:t.ends[Se]===e}())}function a(t){if(!t||!t.nodeType)return null;var e=Te(t).children(".mq-root-block").attr(xe);return e?De.byId[e].controller.API:null}function l(t){function e(e,n){var i=a(e);return i instanceof t||!e||!e.nodeType?i:t(Te(e),n)}return e.prototype=t.prototype,e}function c(t){var e,n="workingGroupChange moveOutOf deleteOutOf selectOutOf upOutOf downOutOf reflow".split(" ");for(e=0;e<n.length;e+=1)(function(e){t[e]=function(t){this.controller.handle(e,t)}})(n[e])}function h(t,e,n){return je(A,{ctrlSeq:t,htmlTemplate:"<"+e+" "+n+">&0</"+e+">"})}function u(t){var e=this.parent,n=t;do{if(n[Se])return t.insLeftOf(e);n=n.parent.parent}while(n!==e);t.insRightOf(e)}function p(t,e){t.jQadd=function(){e.jQadd.apply(this,arguments),this.delimjQs=this.jQ.children(":first").add(this.jQ.children(":last")),this.contentjQ=this.jQ.children(":eq(1)")},t.reflow=function(){var t=this.contentjQ.outerHeight()/parseInt(this.contentjQ.css("fontSize"),10);Z(this.delimjQs,ke(1+.2*(t-1),1.2),1.05*t)}}function f(t,e){var e=e||t,n=me[t],s=me[e];Ee[t]=i(de,Qe,t,n,e,s),Ee[n]=i(de,Se,t,n,e,s)}var d,m,g,b,v,w,q,x,k,O,y,C,j,Q,S,T,A,D,_,L,E,R,I,z,B,P,M,F,$,N,G,U,W,H,V,X,Z,K,Y,J,te,ee,ne,ie,se,re,oe,ae,le,ce,he,ue,pe,fe,de,me,ge,be,ve,we=window.jQuery,qe="mathquill-command-id",xe="mathquill-block-id",ke=Math.min,Oe=Math.max,ye=[].slice,Ce=e(function(t,n){return e(function(e,i){return t in e?e[t].apply(e,n.concat(i)):void 0})}),je=function(t,e,n){function i(t){return"object"==typeof t}function s(t){return"function"==typeof t}function r(){}return function o(a,l){function c(){var t=new h;return s(t.init)&&t.init.apply(t,arguments),t}function h(){}var u,p,f;return l===n&&(l=a,a=Object),c.Bare=h,u=r[t]=a[t],p=h[t]=c[t]=c.p=new r,p.constructor=c,c.mixin=function(e){return h[t]=c[t]=o(c,e)[t],c},(c.open=function(t){if(f={},s(t)?f=t.call(c,p,u,c,a):i(t)&&(f=t),i(f))for(var n in f)e.call(f,n)&&(p[n]=f[n]);return s(p.init)||(p.init=a),c})(l)}}("prototype",{}.hasOwnProperty),Qe=a.L=-1,Se=a.R=1,Te=je(we,function(t){t.insDirOf=function(t,e){return t===Qe?this.insertBefore(e.first()):this.insertAfter(e.last())},t.insAtDirEnd=function(t,e){return t===Qe?this.prependTo(e):this.appendTo(e)}}),Ae=je(function(t){t.parent=0,t[Qe]=0,t[Se]=0,t.init=function(t,e,n){this.parent=t,this[Qe]=e,this[Se]=n},this.copy=function(t){return Ae(t.parent,t[Qe],t[Se])}}),De=je(function(t){function e(){return i+=1}t[Qe]=0,t[Se]=0,t.parent=0;var i=0;this.byId={},t.init=function(){this.id=e(),De.byId[this.id]=this,this.ends={},this.ends[Qe]=0,this.ends[Se]=0},t.dispose=function(){delete De.byId[this.id]},t.toString=function(){return"{{ MathQuill Node #"+this.id+" }}"},t.jQ=Te(),t.jQadd=function(t){return this.jQ=this.jQ.add(t)},t.jQize=function(t){function e(t){var n,i;for(t.getAttribute&&(n=t.getAttribute("mathquill-command-id"),i=t.getAttribute("mathquill-block-id"),n&&De.byId[n].jQadd(t),i&&De.byId[i].jQadd(t)),t=t.firstChild;t;t=t.nextSibling)e(t)}var n;for(t=Te(t||this.html()),n=0;n<t.length;n+=1)e(t[n]);return t},t.createDir=function(t,e){r(t);var n=this;return n.jQize(),n.jQ.insDirOf(t,e.jQ),e[t]=n.adopt(e.parent,e[Qe],e[Se]),n},t.createLeftOf=function(t){return this.createDir(Qe,t)},t.selectChildren=function(t,e){return Ie(t,e)},t.bubble=n(function(t){var e,n;for(e=this;e&&(n=t(e),n!==!1);e=e.parent);return this}),t.postOrder=n(function(t){return function e(n){n.eachChild(e),t(n)}(this),this}),t.isEmpty=function(){return 0===this.ends[Qe]&&0===this.ends[Se]},t.children=function(){return _e(this.ends[Qe],this.ends[Se])},t.eachChild=function(){var t=this.children();return t.each.apply(t,arguments),this},t.foldChildren=function(t,e){return this.children().fold(t,e)},t.withDirAdopt=function(t,e,n,i){return _e(this,this).withDirAdopt(t,e,n,i),this},t.adopt=function(t,e,n){return _e(this,this).adopt(t,e,n),this},t.disown=function(){return _e(this,this).disown(),this},t.remove=function(){return this.jQ.remove(),this.postOrder("dispose"),this.disown()}}),_e=je(function(t){t.init=function(t,e,n){n===d&&(n=Qe),r(n),s("no half-empty fragments",!t==!e),this.ends={},t&&(s("withDir is passed to Fragment",t instanceof De),s("oppDir is passed to Fragment",e instanceof De),s("withDir and oppDir have the same parent",t.parent===e.parent),this.ends[n]=t,this.ends[-n]=e,this.jQ=this.fold(this.jQ,function(t,e){return t.add(e.jQ)}))},t.jQ=Te(),t.withDirAdopt=function(t,e,n,i){return t===Qe?this.adopt(e,n,i):this.adopt(e,i,n)},t.adopt=function(t,e,n){var i,s,r;return o(t,e,n),i=this,i.disowned=!1,(s=i.ends[Qe])?(r=i.ends[Se],e||(t.ends[Qe]=s),n?n[Qe]=r:t.ends[Se]=r,i.ends[Se][Se]=n,i.each(function(n){n[Qe]=e,n.parent=t,e&&(e[Se]=n),e=n}),i):this},t.disown=function(){var t,e,n=this,i=n.ends[Qe];return!i||n.disowned?n:(n.disowned=!0,t=n.ends[Se],e=i.parent,o(e,i[Qe],i),o(e,t,t[Se]),i[Qe]?i[Qe][Se]=t[Se]:e.ends[Qe]=t[Se],t[Se]?t[Se][Qe]=i[Qe]:e.ends[Se]=i[Qe],n)},t.remove=function(){return this.jQ.remove(),this.each("postOrder","dispose"),this.disown()},t.each=n(function(t){var e,n=this,i=n.ends[Qe];if(!i)return n;for(;i!==n.ends[Se][Se]&&(e=t(i),e!==!1);i=i[Se]);return n}),t.fold=function(t,e){return this.each(function(n){t=e.call(this,t,n)}),t}}),Le={},Ee={},Re=je(Ae,function(t){t.init=function(t,e){this.parent=t,this.options=e;var n=this.jQ=this._jQ=Te('<span class="mq-cursor">&#8203;</span>');this.blink=function(){n.toggleClass("mq-blink")},this.upDownCache={}},t.show=function(){return this.jQ=this._jQ.removeClass("mq-blink"),"intervalId"in this?clearInterval(this.intervalId):(this[Se]?this.jQ.insertBefore(this.selection&&this.selection.ends[Qe][Qe]===this[Qe]?this.selection.jQ:this[Se].jQ.first()):this.jQ.appendTo(this.parent.jQ),this.parent.focus()),this.intervalId=setInterval(this.blink,500),this},t.hide=function(){return"intervalId"in this&&clearInterval(this.intervalId),delete this.intervalId,this.jQ.detach(),this.jQ=Te(),this},t.withDirInsertAt=function(t,e,n,i){e!==this.parent&&this.parent.blur&&this.parent.blur(),this.parent=e,this[t]=n,this[-t]=i},t.insDirOf=function(t,e){return r(t),this.withDirInsertAt(t,e.parent,e[t],e),this.parent.jQ.addClass("mq-hasCursor"),this.jQ.insDirOf(t,e.jQ),this},t.insLeftOf=function(t){return this.insDirOf(Qe,t)},t.insRightOf=function(t){return this.insDirOf(Se,t)},t.insAtDirEnd=function(t,e){return r(t),this.withDirInsertAt(t,e,0,e.ends[t]),this.jQ.insAtDirEnd(t,e.jQ),e.focus(),this},t.insAtLeftEnd=function(t){return this.insAtDirEnd(Qe,t)},t.insAtRightEnd=function(t){return this.insAtDirEnd(Se,t)},t.jumpUpDown=function(t,e){var n,i,s=this;s.upDownCache[t.id]=Ae.copy(s),n=s.upDownCache[e.id],n?n[Se]?s.insLeftOf(n[Se]):s.insAtRightEnd(n.parent):(i=s.offset().left,e.seek(i,s))},t.offset=function(){var t=this,e=t.jQ.removeClass("mq-cursor").offset();return t.jQ.addClass("mq-cursor"),e},t.unwrapGramp=function(){var t=this.parent.parent,e=t.parent,n=t[Se],i=this,s=t[Qe];if(t.disown().eachChild(function(i){i.isEmpty()||(i.children().adopt(e,s,n).each(function(e){e.jQ.insertBefore(t.jQ.first())}),s=i.ends[Se])}),!this[Se])if(this[Qe])this[Se]=this[Qe][Se];else for(;!this[Se];){if(this.parent=this.parent[Se],!this.parent){this[Se]=t[Se],this.parent=e;break}this[Se]=this.parent.ends[Qe]}this[Se]?this.insLeftOf(this[Se]):this.insAtRightEnd(e),t.jQ.remove(),t[Qe].siblingDeleted&&t[Qe].siblingDeleted(i.options,Se),t[Se].siblingDeleted&&t[Se].siblingDeleted(i.options,Qe)},t.startSelection=function(){var t,e=this.anticursor=Ae.copy(this),n=e.ancestors={};for(t=e;t.parent;t=t.parent)n[t.parent.id]=t},t.endSelection=function(){delete this.anticursor},t.select=function(){var t,e,n,i,r,o,a,l=this.anticursor;if(this[Qe]===l[Qe]&&this.parent===l.parent)return!1;for(t=this;t.parent;t=t.parent)if(t.parent.id in l.ancestors){e=t.parent;break}if(s("cursor and anticursor in the same tree",e),n=l.ancestors[e.id],o=Se,t[Qe]!==n)for(a=t;a;a=a[Se])if(a[Se]===n[Se]){o=Qe,i=t,r=n;break}return o===Se&&(i=n,r=t),i instanceof Ae&&(i=i[Se]),r instanceof Ae&&(r=r[Qe]),this.hide().selection=e.selectChildren(i,r),this.insDirOf(o,this.selection.ends[o]),this.selectionChanged(),!0},t.clearSelection=function(){return this.selection&&(this.selection.clear(),delete this.selection,this.selectionChanged()),this},t.deleteSelection=function(){this.selection&&(this[Qe]=this.selection.ends[Qe][Qe],this[Se]=this.selection.ends[Se][Se],this.selection.remove(),this.selectionChanged(),delete this.selection)},t.replaceSelection=function(){var t=this.selection;return t&&(this[Qe]=t.ends[Qe][Qe],this[Se]=t.ends[Se][Se],delete this.selection),t}}),Ie=je(_e,function(t,e){t.init=function(){e.init.apply(this,arguments),this.jQ=this.jQ.wrapAll('<span class="mq-selection"></span>').parent()},t.adopt=function(){return this.jQ.replaceWith(this.jQ=this.jQ.children()),e.adopt.apply(this,arguments)},t.clear=function(){return this.jQ.replaceWith(this.jQ[0].childNodes),this},t.join=function(t){return this.fold("",function(e,n){return e+n[t]()})}}),ze=je(function(t){t.init=function(t,e,n){this.API=t,this.root=e,this.container=n,t.__controller=e.controller=this,this.cursor=e.cursor=Re(e,t.__options)},t.handle=function(t,e){var n=this.API.__options.handlers;n&&n[t]&&(e===Qe||e===Se?n[t](e,this.API):n[t](this.API))};var e=[];this.onNotify=function(t){e.push(t)},t.notify=function(){for(var t=0;t<e.length;t+=1)e[t].apply(this.cursor,arguments);return this}});a.noConflict=function(){return window.MathQuill=m,a},m=window.MathQuill,window.MathQuill=a,g=je(),b={},a.__options=g.p,v=je(function(t){t.init=function(){throw"wtf don't call me, I'm 'abstract'"},t.initRoot=function(t,e,n){var i,s;this.__options=g(),this.config(n),i=ze(this,t,e),i.createTextarea(),s=e.contents().detach(),t.jQ=Te('<span class="mq-root-block"/>').attr(xe,t.id).appendTo(e),this.latex(s.text()),this.revert=function(){return e.empty().unbind(".mathquill").removeClass("mq-editable-field mq-math-mode mq-text-mode").append(s)}},t.config=a.config=function(t){var e,n,i;for(e in t)t.hasOwnProperty(e)&&(n=t[e],i=b[e],this.__options[e]=i?i(n):n);return this},t.el=function(){return this.__controller.container[0]},t.text=function(){return this.__controller.exportText(this.__options)},t.latex=function(t){return arguments.length>0?(this.__controller.renderLatexMath(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this):this.__controller.exportLatex()},t.html=function(){return this.__controller.root.jQ.html().replace(/ mathquill-(?:command|block)-id="?\d+"?/g,"").replace(/<span class="?mq-cursor( mq-blink)?"?>.?<\/span>/i,"").replace(/ mq-hasCursor|mq-hasCursor ?/,"").replace(/ class=(""|(?= |>))/g,"")},t.reflow=function(){return this.__controller.root.postOrder("reflow"),this}}),a.prototype=v.prototype,a.StaticMath=l(je(v,function(t,e){t.init=function(t){this.initRoot(S(),t.addClass("mq-math-mode")),this.__controller.delegateMouseEvents(),this.__controller.staticMathTextareaEvents()},t.latex=function(){var t=e.latex.apply(this,arguments);return arguments.length>0&&this.__controller.root.postOrder("registerInnerField",this.innerFields=[]),t}})),w=a.EditableField=je(v,function(e){e.initRootAndEvents=function(t,e,n){this.initRoot(t,e,n),this.__controller.editable=!0,this.__controller.delegateMouseEvents(),this.__controller.editablesTextareaEvents()},e.focus=function(){return this.__controller.textarea.focus(),this},e.blur=function(){return this.__controller.textarea.blur(),this},e.write=function(t){return this.__controller.writeLatex(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this},e.cmd=function(t){var e,n=this.__controller.notify(),i=n.cursor.show();return/^\\[a-z]+$/i.test(t)?(t=t.slice(1),e=Le[t],e&&(t=e(t),i.selection&&t.replaces(i.replaceSelection()),t.createLeftOf(i))):i.parent.write(i,t,i.replaceSelection()),n.blurred&&i.hide().parent.blur(),this},e.select=function(){var t=this.__controller;for(t.notify("move").cursor.insAtRightEnd(t.root);t.cursor[Qe];)t.selectLeft();return this},e.clearSelection=function(){return this.__controller.cursor.clearSelection(),this},e.moveToDirEnd=function(t){return this.__controller.notify("move").cursor.insAtDirEnd(t,this.__controller.root),this},e.moveToLeftEnd=function(){return this.moveToDirEnd(Qe)},e.moveToRightEnd=function(){return this.moveToDirEnd(Se)},e.keystroke=function(e){var n;for(e=e.replace(/^\s+|\s+$/g,"").split(/\s+/),n=0;n<e.length;n+=1)this.__controller.keystroke(e[n],{preventDefault:t});return this},e.typedText=function(t){for(var e=0;e<t.length;e+=1)this.__controller.typedText(t.charAt(e));return this}}),q=je(function(t,e,n){function i(t,e){throw t=t?"'"+t+"'":"EOF","Parse Error: "+e+" at "+t}var r,o,a,l,c,h,u,p,f,d,m,g,b;t.init=function(t){this._=t},t.parse=function(t){function e(t,e){return e}return this.skip(b)._(t,e,i)},t.or=function(t){s("or is passed a parser",t instanceof n);var e=this;return n(function(n,i,s){function r(){return t._(n,i,s)}return e._(n,i,r)})},t.then=function(t){var e=this;return n(function(i,r,o){function a(e,i){var a=t instanceof n?t:t(i);return s("a parser is returned",a instanceof n),a._(e,r,o)}return e._(i,a,o)})},t.many=function(){var t=this;return n(function(e,n){function i(t,n){return e=t,r.push(n),!0}function s(){return!1}for(var r=[];t._(e,i,s););return n(e,r)})},t.times=function(t,e){arguments.length<2&&(e=t);var i=this;return n(function(n,s,r){function o(t,e){return u.push(e),n=t,!0}function a(t,e){return c=e,n=t,!1}function l(){return!1}var c,h,u=[],p=!0;for(h=0;t>h;h+=1)if(p=i._(n,o,a),!p)return r(n,c);for(;e>h&&p;h+=1)p=i._(n,o,l);return s(n,u)})},t.result=function(t){return this.then(a(t))},t.atMost=function(t){return this.times(0,t)},t.atLeast=function(t){var e=this;return e.times(t).then(function(t){return e.many().map(function(e){return t.concat(e)})})},t.map=function(t){return this.then(function(e){return a(t(e))})},t.skip=function(t){return this.then(function(e){return t.result(e)})},r=this.string=function(t){var e=t.length,i="expected '"+t+"'";return n(function(n,s,r){var o=n.slice(0,e);return o===t?s(n.slice(e),o):r(n,i)})},o=this.regex=function(t){s("regexp parser is anchored","^"===t.toString().charAt(1));var e="expected "+t;return n(function(n,i,s){var r,o=t.exec(n);return o?(r=o[0],i(n.slice(r.length),r)):s(n,e)})},a=n.succeed=function(t){return n(function(e,n){return n(e,t)})},l=n.fail=function(t){return n(function(e,n,i){return i(e,t)})},c=n.letter=o(/^[a-z]/i),h=n.letters=o(/^[a-z]*/i),u=n.digit=o(/^[0-9]/),p=n.digits=o(/^[0-9]*/),f=n.whitespace=o(/^\s+/),d=n.optWhitespace=o(/^\s*/),m=n.any=n(function(t,e,n){return t?e(t.slice(1),t.charAt(0)):n(t,"expected any character")}),g=n.all=n(function(t,e){return e("",t)}),b=n.eof=n(function(t,e,n){return t?n(t,"expected EOF"):e(t,t)})}),x=function(){function e(t){var e,i=t.which||t.keyCode,s=n[i],r=[];return t.ctrlKey&&r.push("Ctrl"),t.originalEvent&&t.originalEvent.metaKey&&r.push("Meta"),t.altKey&&r.push("Alt"),t.shiftKey&&r.push("Shift"),e=s||String.fromCharCode(i),r.length||s?(r.push(e),r.join("-")):e}var n={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"};return function(n,i){function s(t){q=t,clearTimeout(d),d=setTimeout(t)}function r(e){q(),q=t,clearTimeout(d),v.val(e),e&&v[0].select(),m=!!e}function o(){var t=v[0];return"selectionStart"in t?t.selectionStart!==t.selectionEnd:!1}function a(){i.keystroke(e(g),g)}function l(e){g=e,b=null,a(),m&&s(function(){v[0].select(),q=t,clearTimeout(d)})}function c(t){g&&b&&a(),b=t,s(h)}function h(){if(!o()){var t=v.val();1===t.length?(v.val(""),i.typedText(t)):t&&v[0].select()}}function u(){g=b=null}function p(){v.focus(),s(f)}function f(){var t=v.val();v.val(""),t&&i.paste(t)}var d,m,g=null,b=null,v=we(n),w=we(i.container||v),q=t;return w.bind("keydown keypress input keyup focusout paste",function(){q()}),m=!1,w.bind({keydown:l,keypress:c,focusout:u,paste:p}),{select:r}}}(),ze.open(function(t){t.exportText=function(t){return this.root.foldChildren("",function(e,n){return e+n.text(t)})}}),ze.open(function(t){t.focusBlurEvents=function(){function t(){clearTimeout(n),r.selection&&r.selection.jQ.addClass("mq-blur"),e()}function e(){r.hide().parent.blur(),i.container.removeClass("mq-focused"),Te(window).off("blur",t)}var n,i=this,s=i.root,r=i.cursor;i.textarea.focus(function(){i.blurred=!1,clearTimeout(n),i.container.addClass("mq-focused"),r.parent||r.insAtRightEnd(s),r.selection?(r.selection.jQ.removeClass("mq-blur"),i.selectionChanged()):r.show()}).blur(function(){i.blurred=!0,n=setTimeout(function(){s.postOrder("intentionalBlur"),r.clearSelection(),e()}),Te(window).on("blur",t)}),i.blurred=!0,r.hide().parent.blur()}}),ze.open(function(t){t.keystroke=function(t,e){this.cursor.parent.keystroke(t,e,this)}}),De.open(function(t){t.keystroke=function(t,e,n){var i=n.cursor;switch(t){case"Ctrl-Shift-Backspace":case"Ctrl-Backspace":for(;i[Qe]||i.selection;)n.backspace();break;case"Shift-Backspace":case"Backspace":n.backspace();break;case"Esc":case"Tab":return void n.escapeDir(Se,t,e);case"Shift-Tab":case"Shift-Esc":return void n.escapeDir(Qe,t,e);case"End":n.notify("move").cursor.insAtRightEnd(i.parent);break;case"Ctrl-End":n.notify("move").cursor.insAtRightEnd(n.root);break;case"Shift-End":for(;i[Se];)n.selectRight();break;case"Ctrl-Shift-End":for(;i[Se]||i.parent!==n.root;)n.selectRight();break;case"Home":n.notify("move").cursor.insAtLeftEnd(i.parent);break;case"Ctrl-Home":n.notify("move").cursor.insAtLeftEnd(n.root);break;case"Shift-Home":for(;i[Qe];)n.selectLeft();break;case"Ctrl-Shift-Home":for(;i[Qe]||i.parent!==n.root;)n.selectLeft();break;case"Left":n.moveLeft();break;case"Shift-Left":n.selectLeft();break;case"Ctrl-Left":break;case"Right":n.moveRight();break;case"Shift-Right":n.selectRight();break;case"Ctrl-Right":break;case"Up":n.moveUp();break;case"Down":n.moveDown();break;case"Shift-Up":if(i[Qe])for(;i[Qe];)n.selectLeft();else n.selectLeft();case"Shift-Down":if(i[Se])for(;i[Se];)n.selectRight();else n.selectRight();case"Ctrl-Up":break;case"Ctrl-Down":break;case"Ctrl-Shift-Del":case"Ctrl-Del":for(;i[Se]||i.selection;)n.deleteForward();break;case"Shift-Del":case"Del":n.deleteForward();break;case"Meta-A":case"Ctrl-A":for(n.notify("move").cursor.insAtRightEnd(n.root);i[Qe];)n.selectLeft();break;default:return}e.preventDefault(),n.scrollHoriz()},t.moveOutOf=t.moveTowards=t.deleteOutOf=t.deleteTowards=t.unselectInto=t.selectOutOf=t.selectTowards=function(){s("overridden or never called on this node")}}),ze.open(function(t){function e(t,e){var n=t.notify("upDown").cursor,i=e+"Into",s=e+"OutOf";return n[Se][i]?n.insAtLeftEnd(n[Se][i]):n[Qe][i]?n.insAtRightEnd(n[Qe][i]):n.parent.bubble(function(t){var e=t[s];return e&&("function"==typeof e&&(e=t[s](n)),e instanceof De&&n.jumpUpDown(t,e),e!==!0)?!1:void 0}),n.parent.bubble("workingGroupChange"),t}this.onNotify(function(t){("move"===t||"upDown"===t)&&this.show().clearSelection()}),t.escapeDir=function(t,e,n){r(t);var i=this.cursor;return i.parent!==this.root&&n.preventDefault(),i.parent!==this.root?(i.parent.moveOutOf(t,i),i.parent.bubble("workingGroupChange"),this.notify("move")):void 0},b.leftRightIntoCmdGoes=function(t){if(t&&"up"!==t&&"down"!==t)throw'"up" or "down" required for leftRightIntoCmdGoes option, got "'+t+'"';return t},t.moveDir=function(t){r(t);var e=this.cursor,n=e.options.leftRightIntoCmdGoes;return e.selection?e.insDirOf(t,e.selection.ends[t]):e[t]?e[t].moveTowards(t,e,n):e.parent.moveOutOf(t,e,n),e.parent.bubble("workingGroupChange"),this.notify("move")},t.moveLeft=function(){return this.moveDir(Qe)},t.moveRight=function(){return this.moveDir(Se)},t.moveUp=function(){return e(this,"up")},t.moveDown=function(){return e(this,"down")},this.onNotify(function(t){"upDown"!==t&&(this.upDownCache={})}),this.onNotify(function(t){"edit"===t&&this.show().deleteSelection()}),t.deleteDir=function(t){var e,n;return r(t),e=this.cursor,n=e.selection,this.notify("edit"),n||(e[t]?e[t].deleteTowards(t,e):e.parent.deleteOutOf(t,e)),e[Qe].siblingDeleted&&e[Qe].siblingDeleted(e.options,Se),e[Se].siblingDeleted&&e[Se].siblingDeleted(e.options,Qe),e.parent.bubble("reflow"),e.parent.bubble("workingGroupChange"),this},t.backspace=function(){return this.deleteDir(Qe)},t.deleteForward=function(){return this.deleteDir(Se)},this.onNotify(function(t){"select"!==t&&this.endSelection()}),t.selectDir=function(t){var e,n=this.notify("select").cursor,i=n.selection;r(t),n.anticursor||n.startSelection(),e=n[t],e?i&&i.ends[t]===e&&n.anticursor[-t]!==e?e.unselectInto(t,n):e.selectTowards(t,n):n.parent.selectOutOf(t,n),n.clearSelection(),n.select()||n.show()},t.selectLeft=function(){return this.selectDir(Qe)},t.selectRight=function(){return this.selectDir(Se)}}),k=function(){function t(t){var e=S();return t.adopt(e,0,0),e}function e(t){var e,n=t[0]||S();for(e=1;e<t.length;e+=1)t[e].children().adopt(n,n.ends[Se],0);return n}var n=q.string,i=q.regex,s=q.letter,r=q.any,o=q.optWhitespace,a=q.succeed,l=q.fail,c=s.map(function(t){return I(t)}),h=i(/^[^${}\\_^]/).map(function(t){return j(t)}),u=i(/^[^\\a-eg-zA-Z]/).or(n("\\").then(i(/^[a-z]+/i).or(i(/^\s+/).result(" ")).or(r))).then(function(t){var e=Le[t];return e?e(t).parser():l("unknown command: \\"+t)}),p=u.or(c).or(h),f=n("{").then(function(){return m}).skip(n("}")),d=o.then(f.or(p.map(t))),m=d.many().map(e).skip(o),g=n("[").then(d.then(function(t){return"]"!==t.join("latex")?a(t):l()}).many().map(e).skip(o)).skip(n("]")),b=m;return b.block=d,b.optBlock=g,b}(),ze.open(function(t){t.exportLatex=function(){return this.root.latex().replace(/(\\[a-z]+) (?![a-z])/gi,"$1")},t.writeLatex=function(t){var e,n=this.notify("edit").cursor,i=q.all,s=q.eof,r=k.skip(s).or(i.result(!1)).parse(t);return r&&!r.isEmpty()&&(r.children().adopt(n.parent,n[Qe],n[Se]),e=r.jQize(),e.insertBefore(n.jQ),n[Qe]=r.ends[Se],r.finalizeInsert(n.options,n),r.ends[Se][Se].siblingCreated&&r.ends[Se][Se].siblingCreated(n.options,Qe),r.ends[Qe][Qe].siblingCreated&&r.ends[Qe][Qe].siblingCreated(n.options,Se),n.parent.bubble("reflow")),this},t.renderLatexMath=function(t){var e,n,i=this.root,s=this.cursor,r=q.all,o=q.eof,a=k.skip(o).or(r.result(!1)).parse(t);i.eachChild("postOrder","dispose"),i.ends[Qe]=i.ends[Se]=0,a&&a.children().adopt(i,0,0),e=i.jQ,a?(n=a.join("html"),e.html(n),i.jQize(e.children()),i.finalizeInsert(s.options)):e.empty(),delete s.selection,s.insAtRightEnd(i)},t.renderLatexText=function(t){var e,n,i,s,r,o,a,l,c,h,u=this.root,p=this.cursor;if(u.jQ.children().slice(1).remove(),u.eachChild("postOrder","dispose"),u.ends[Qe]=u.ends[Se]=0,delete p.selection,p.show().insAtRightEnd(u),e=q.regex,n=q.string,i=q.eof,s=q.all,r=n("$").then(k).skip(n("$").or(i)).map(function(t){var e,n=_(p);return n.createBlocks(),e=n.ends[Qe],t.children().adopt(e,0,0),n}),o=n("\\$").result("$"),a=o.or(e(/^[^$]/)).map(j),l=r.or(a).many(),c=l.skip(i).or(s.result(!1)).parse(t)){for(h=0;h<c.length;h+=1)c[h].adopt(u,u.ends[Se],0);u.jQize().appendTo(u.jQ),u.finalizeInsert(p.options)}}}),ze.open(function(e){e.delegateMouseEvents=function(){var e=this.root.jQ;this.container.bind("contextmenu.mathquill",function(t){for(var n=Te(t.target).closest(".mq-root-block"),i=De.byId[n.attr(xe)||e.attr(xe)],s=i.controller,r=s.cursor,o=s.seek(Te(t.target),t.pageX,t.pageY).cursor.parent;!(o instanceof y);)if(o=o.parent,"undefined"==typeof o){o=i;break}return o.contextMenu(r,t),t.preventDefault(),!1}),this.container.bind("mousedown.mathquill",function(n){function i(t){o=Te(t.target)}function s(t){h.anticursor||h.startSelection(),c.seek(o,t.pageX,t.pageY).cursor.select(),o=d}function r(t){h.blink=u,h.selection||(c.editable?h.show():p.detach()),a.unbind("mousemove",i),Te(t.target.ownerDocument).unbind("mousemove",s).unbind("mouseup",r)}var o,a=Te(n.target).closest(".mq-root-block"),l=De.byId[a.attr(xe)||e.attr(xe)],c=l.controller,h=c.cursor,u=h.blink,p=c.textareaSpan,f=c.textarea;c.blurred&&(c.editable||a.prepend(p),f.focus()),n.preventDefault(),n.target.unselectable=!0,h.blink=t,c.seek(Te(n.target),n.pageX,n.pageY).cursor.startSelection(),a.mousemove(i),Te(n.target.ownerDocument).mousemove(s).mouseup(r)})}}),ze.open(function(t){t.seek=function(t,e){var n,i,r,o=this.notify("select").cursor;return t&&(n=t.attr(xe)||t.attr(qe),n||(i=t.parent(),n=i.attr(xe)||i.attr(qe))),r=n?De.byId[n]:this.root,s("nodeId is the id of some Node that exists",r),o.clearSelection().show(),r.seek(e,o),this.scrollHoriz(),o.parent.bubble("workingGroupChange"),this}}),ze.open(function(t){t.scrollHoriz=function(){var t,e,n,i,s,r=this.cursor,o=r.selection,a=this.root.jQ[0].getBoundingClientRect();if(o)if(n=o.jQ[0].getBoundingClientRect(),i=n.left-(a.left+20),s=n.right-(a.right-20),o.ends[Qe]===r[Se])if(0>i)e=i;else{if(!(s>0))return;e=n.left-s<a.left+20?i:s}else if(s>0)e=s;else{if(!(0>i))return;e=n.right-i>a.right-20?s:i}else if(t=r.jQ[0].getBoundingClientRect().left,t>a.right-20)e=t-(a.right-20);else{if(!(t<a.left+20))return;e=t-(a.left+20)}this.root.jQ.stop().animate({scrollLeft:"+="+e},100)}}),ze.open(function(t){g.p.substituteTextarea=function(){return Te("<textarea>")[0]},t.createTextarea=function(){var t,e=this.textareaSpan=Te('<span class="mq-textarea"></span>'),n=this.API.__options.substituteTextarea();if(!n.nodeType)throw"substituteTextarea() must return a DOM element, got "+n;n=this.textarea=Te(n).appendTo(e),t=this,t.cursor.selectionChanged=function(){t.selectionChanged()},t.container.bind("copy",function(){t.setTextareaSelection()})},t.selectionChanged=function(){var t=this;K(t.container[0]),t.textareaSelectionTimeout===d&&(t.textareaSelectionTimeout=setTimeout(function(){t.setTextareaSelection()}))},t.setTextareaSelection=function(){this.textareaSelectionTimeout=d;var t="";this.cursor.selection&&(t=this.cursor.selection.join("latex"),this.API.__options.statelessClipboard&&(t="$"+t+"$")),this.selectFn(t)},t.staticMathTextareaEvents=function(){function t(){s.detach(),e.blurred=!0}var e=this,n=(e.root,e.cursor),i=e.textarea,s=e.textareaSpan;this.container.prepend('<span class="mq-selectable">$'+e.exportLatex()+"$</span>"),e.blurred=!0,i.bind("cut paste",!1).focus(function(){e.blurred=!1}).blur(function(){n.selection&&n.selection.clear(),setTimeout(t)}),e.selectFn=function(t){i.val(t),t&&i.select()}},t.editablesTextareaEvents=function(){var t=this,e=(t.root,t.cursor),n=t.textarea,i=t.textareaSpan,s=x(n,this);this.selectFn=function(t){s.select(t)},this.container.prepend(i).on("cut",function(){e.selection&&setTimeout(function(){t.notify("edit"),e.parent.bubble("reflow")})}),this.focusBlurEvents()},t.typedText=function(t){if("\n"===t)return this.handle("enter");var e=this.notify().cursor;e.parent.write(e,t,e.show().replaceSelection()),this.scrollHoriz()},t.paste=function(t){this.API.__options.statelessClipboard&&(t="$"===t.slice(0,1)&&"$"===t.slice(-1)?t.slice(1,-1):"\\text{"+t+"}"),this.writeLatex(t).cursor.show()}}),O=je(De,function(t){t.finalizeInsert=function(t,e){var n=this;n.postOrder("finalizeTree",t),n.postOrder("contactWeld",e),n.postOrder("blur"),n.postOrder("reflow"),n[Se].siblingCreated&&n[Se].siblingCreated(t,Qe),n[Qe].siblingCreated&&n[Qe].siblingCreated(t,Se),n.bubble("reflow")},t.contextMenu=function(){},t.showPopupMenu=function(t,e){var n,i;for(1==Te("#mq-popup-menu").length&&Te("#mq-popup-menu").remove(),n=Te("<ul></ul>").attr("id","mq-popup-menu").appendTo("body"),i=0;i<t.length;i++)Te("<li></li>").attr("mq-menu-id",i).html(t[i].text).appendTo(n);n.menu({select:function(e,i){var s=1*i.item.attr("mq-menu-id");t[s].handler(e),n.hide()}}),n.position({my:"left top",of:e}),n.show(),Te(document).bind("click",function(t){n.hide(),Te(this).unbind(t)})}}),y=je(O,function(t,e){t.init=function(t,n,i){var s=this;e.init.call(s),s.ctrlSeq||(s.ctrlSeq=t),n&&(s.htmlTemplate=n),i&&(s.textTemplate=i)},t.replaces=function(t){t.disown(),this.replacedFragment=t},t.isEmpty=function(){return this.foldChildren(!0,function(t,e){return t&&e.isEmpty()})},t.parser=function(){var t=k.block,e=this;return t.times(e.numBlocks()).map(function(t){e.blocks=t;for(var n=0;n<t.length;n+=1)t[n].adopt(e,e.ends[Se],0);return e})},t.createLeftOf=function(t){var n,i=this;if(t.options.enableMatrixShortcuts&&"undefined"!=typeof t.parent&&"undefined"!=typeof t.parent&&t.parent.parent instanceof fe){if(","==i.ctrlSeq)return t.parent.parent.moveOrInsertColumn(t);if(";"==i.ctrlSeq)return t.parent.parent.insertRow(t);if(":"==i.ctrlSeq)return t.parent.parent.deleteRow(t);if("<"==i.ctrlSeq)return t.parent.parent.deleteColumn(t);if(">"==i.ctrlSeq)return t.parent.parent.insertColumn(t)}n=i.replacedFragment,i.createBlocks(),e.createLeftOf.call(i,t),n&&(n.adopt(i.ends[Qe],0,0),n.jQ.appendTo(i.ends[Qe].jQ)),i.finalizeInsert(t.options),i.placeCursor(t),(this instanceof Q||this instanceof le||this instanceof oe||this instanceof he)&&this.bubble("workingGroupChange")},t.createBlocks=function(){var t,e,n=this,i=n.numBlocks(),s=n.blocks=Array(i);for(t=0;i>t;t+=1)e=s[t]=S(),e.adopt(n,n.ends[Se],0)},t.placeCursor=function(t){t.insAtRightEnd(this.foldChildren(this.ends[Qe],function(t,e){return t.isEmpty()?t:e}))},t.moveTowards=function(t,e,n){var i=n&&this[n+"Into"];e.insAtDirEnd(-t,i||this.ends[-t])},t.deleteTowards=function(t,e){e.startSelection(),this.selectTowards(t,e),e.select()},t.selectTowards=function(t,e){e[-t]=this,e[t]=this[t]},t.selectChildren=function(){return Ie(this,this)},t.unselectInto=function(t,e){e.insAtDirEnd(-t,e.anticursor.ancestors[this.id])},t.seek=function(t,e){function n(t){var e={};return e[Qe]=t.jQ.offset().left,e[Se]=e[Qe]+t.jQ.outerWidth(),e}var i,s=this,r=n(s);return t<r[Qe]?e.insLeftOf(s):t>r[Se]?e.insRightOf(s):(i=r[Qe],void s.eachChild(function(o){var a=n(o);return t<a[Qe]?(t-i<a[Qe]-t?o[Qe]?e.insAtRightEnd(o[Qe]):e.insLeftOf(s):e.insAtLeftEnd(o),!1):t>a[Se]?void(o[Se]?i=a[Se]:r[Se]-t<t-a[Se]?e.insRightOf(s):e.insAtRightEnd(o)):(o.seek(t,e),!1)}))},t.numBlocks=function(){var t=this.htmlTemplate.match(/&\d+/g);return t?t.length:0},t.html=function(){var t,e,n,i=this,r=i.blocks,o=" mathquill-command-id="+i.id,a=i.htmlTemplate.match(/<[^<>]+>|[^<>]+/g);for(s("no unmatched angle brackets",a.join("")===this.htmlTemplate),t=0,e=a[0];e;t+=1,e=a[t])if("/>"===e.slice(-2))a[t]=e.slice(0,-2)+o+"/>";else if("<"===e.charAt(0)){s("not an unmatched top-level close tag","/"!==e.charAt(1)),a[t]=e.slice(0,-1)+o+">",n=1;do t+=1,e=a[t],s("no missing close tags",e),"</"===e.slice(0,2)?n-=1:"<"===e.charAt(0)&&"/>"!==e.slice(-2)&&(n+=1);while(n>0)}return a.join("").replace(/>&(\d+)/g,function(t,e){return" mathquill-block-id="+r[e].id+">"+r[e].join("html")})},t.latex=function(){return this.foldChildren(this.ctrlSeq,function(t,e){return t+"{"+(e.latex()||" ")+"}"})},t.textTemplate=[""],t.text=function(t){var e=this,n=0;return e.foldChildren(e.textTemplate[n],function(i,s){n+=1;var r=s.text(t);return i&&"("===e.textTemplate[n]&&"("===r[0]&&")"===r.slice(-1)?i+r.slice(1,-1)+e.textTemplate[n]:i+s.text(t)+(e.textTemplate[n]||"")})}}),C=je(y,function(e,n){e.init=function(t,e,i){i||(i=t&&t.length>1?t.slice(1):t),n.init.call(this,t,e,[i])},e.parser=function(){return q.succeed(this)},e.numBlocks=function(){return 0},e.replaces=function(t){t.remove()},e.createBlocks=t,e.moveTowards=function(t,e){e.jQ.insDirOf(t,this.jQ),e[-t]=this,e[t]=this[t]},e.deleteTowards=function(t,e){e[t]=this.remove()[t]
2
- },e.seek=function(t,e){t-this.jQ.offset().left<this.jQ.outerWidth()/2?e.insLeftOf(this):e.insRightOf(this)},e.latex=function(){return this.ctrlSeq},e.text=function(){return this.textTemplate},e.placeCursor=t,e.isEmpty=function(){return!0}}),j=je(C,function(t,e){t.init=function(t,n){e.init.call(this,t,"<span>"+(n||t)+"</span>")}}),Q=je(C,function(t,e){t.init=function(t,n,i){e.init.call(this,t,'<span class="mq-binary-operator">'+n+"</span>",i)}}),S=je(O,function(t,e){t.join=function(t){return this.foldChildren("",function(e,n){return e+n[t]()})},t.html=function(){return this.join("html")},t.latex=function(){return this.join("latex")},t.text=function(t){return 0===this.ends[Qe]&&0===this.ends[Se]?"":this.ends[Qe]===this.ends[Se]?this.ends[Qe].text(t):this.foldChildren("",function(e,n){return e+n.text(t)})},t.keystroke=function(t,n,i){return!i.API.__options.spaceBehavesLikeTab||"Spacebar"!==t&&"Shift-Spacebar"!==t?e.keystroke.apply(this,arguments):(n.preventDefault(),void i.escapeDir("Shift-Spacebar"===t?Qe:Se,t,n))},t.moveOutOf=function(t,e,n){var i=n&&this.parent[n+"Into"];!i&&this[t]?e.insAtDirEnd(-t,this[t]):e.insDirOf(t,this.parent)},t.selectOutOf=function(t,e){e.insDirOf(t,this.parent)},t.deleteOutOf=function(t,e){e.unwrapGramp()},t.seek=function(t,e){var n=this.ends[Se];if(!n||n.jQ.offset().left+n.jQ.outerWidth()<t)return e.insAtRightEnd(this);if(t<this.ends[Qe].jQ.offset().left)return e.insAtLeftEnd(this);for(;t<n.jQ.offset().left;)n=n[Qe];return n.seek(t,e)},t.write=function(t,e,n){var i;i=e.match(/^[a-eg-zA-Z]$/)?I(e):(i=Ee[e]||Le[e])?i(e):j(e),n&&i.replaces(n),i.createLeftOf(t)},t.focus=function(){return this.jQ.addClass("mq-hasCursor"),this.jQ.removeClass("mq-empty"),this},t.blur=function(){return this.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.jQ.addClass("mq-empty"),this}}),T=je(S,c),a.MathField=l(je(w,function(t){t.init=function(t,e){t.addClass("mq-editable-field mq-math-mode"),this.initRootAndEvents(T(),t,e)}})),A=je(De,function(t,e){function n(t){var e,n;return t.jQ[0].normalize(),e=t.jQ[0].firstChild,n=D(e.data),n.jQadd(e),t.children().disown(),n.adopt(t,0,0)}t.ctrlSeq="\\text",t.replaces=function(t){t instanceof _e?this.replacedText=t.remove().jQ.text():"string"==typeof t&&(this.replacedText=t)},t.jQadd=function(t){e.jQadd.call(this,t),this.ends[Qe]&&this.ends[Qe].jQadd(this.jQ[0].firstChild)},t.createLeftOf=function(t){var n,i=this;if(e.createLeftOf.call(this,t),i[Se].siblingCreated&&i[Se].siblingCreated(t.options,Qe),i[Qe].siblingCreated&&i[Qe].siblingCreated(t.options,Se),i.bubble("reflow"),t.insAtRightEnd(i),i.replacedText)for(n=0;n<i.replacedText.length;n+=1)i.write(t,i.replacedText.charAt(n))},t.parser=function(){var t=this,e=q.string,n=q.regex,i=q.optWhitespace;return i.then(e("{")).then(n(/^[^}]*/)).skip(e("}")).map(function(e){return D(e).adopt(t,0,0),t})},t.textContents=function(){return this.foldChildren("",function(t,e){return t+e.text})},t.text=function(t){return t.dropTextFieldsOnTextOutput?"":'"'+this.textContents()+'"'},t.latex=function(){return"\\text{"+this.textContents()+"}"},t.html=function(){return'<span class="mq-text-mode" mathquill-command-id='+this.id+">"+this.textContents()+"</span>"},t.moveTowards=function(t,e){e.insAtDirEnd(-t,this)},t.moveOutOf=function(t,e){e.insDirOf(t,this)},t.unselectInto=t.moveTowards,t.selectTowards=y.prototype.selectTowards,t.deleteTowards=y.prototype.deleteTowards,t.selectOutOf=function(t,e){e.insDirOf(t,this)},t.deleteOutOf=function(t,e){this.isEmpty()&&e.insRightOf(this)},t.write=function(t,n,i){var s,r;i&&i.remove(),"$"!==n?t[Qe]?t[Qe].appendText(n):D(n).createLeftOf(t):this.isEmpty()?(t.insRightOf(this),j("\\$","$").createLeftOf(t)):t[Se]?t[Qe]?(s=A(),r=this.ends[Qe],r.disown(),r.adopt(s,0,0),t.insLeftOf(this),e.createLeftOf.call(s,t)):t.insLeftOf(this):t.insRightOf(this)},t.seek=function(t,e){var i,s,r,o,a,l,c,h;for(e.hide(),i=n(this),s=this.jQ.width()/this.text.length,r=Math.round((t-this.jQ.offset().left)/s),0>=r?e.insAtLeftEnd(this):r>=i.text.length?e.insAtRightEnd(this):e.insLeftOf(i.splitRight(r)),o=t-e.show().offset().left,a=o&&0>o?Qe:Se,l=a;e[a]&&o*l>0;)e[a].moveTowards(a,e),l=o,o=t-e.offset().left;-a*l>a*o&&e[-a].moveTowards(-a,e),e.anticursor?e.anticursor.parent===this&&(c=e[Qe]&&e[Qe].text.length,this.anticursorPosition===c?e.anticursor=Ae.copy(e):(this.anticursorPosition<c?(h=e[Qe].splitRight(this.anticursorPosition),e[Qe]=h):h=e[Se].splitRight(this.anticursorPosition-c),e.anticursor=Ae(this,h[Qe],h))):this.anticursorPosition=e[Qe]&&e[Qe].text.length},t.blur=function(){S.prototype.blur.call(this),n(this)},t.focus=S.prototype.focus}),D=je(De,function(t,e){function n(t,e){return e.charAt(t===Qe?0:-1+e.length)}t.init=function(t){e.init.call(this),this.text=t},t.jQadd=function(t){this.dom=t,this.jQ=Te(t)},t.jQize=function(){return this.jQadd(document.createTextNode(this.text))},t.appendText=function(t){this.text+=t,this.dom.appendData(t)},t.prependText=function(t){this.text=t+this.text,this.dom.insertData(0,t)},t.insTextAtDirEnd=function(t,e){r(e),e===Se?this.appendText(t):this.prependText(t)},t.splitRight=function(t){var e=D(this.text.slice(t)).adopt(this.parent,this,this[Se]);return e.jQadd(this.dom.splitText(t)),this.text=this.text.slice(0,t),e},t.moveTowards=function(t,e){var i,s;return r(t),i=n(-t,this.text),s=this[-t],s?s.insTextAtDirEnd(i,t):D(i).createDir(-t,e),this.deleteTowards(t,e)},t.latex=function(){return this.text},t.deleteTowards=function(t,e){this.text.length>1?t===Se?(this.dom.deleteData(0,1),this.text=this.text.slice(1)):(this.dom.deleteData(-1+this.text.length,1),this.text=this.text.slice(0,-1)):(this.remove(),this.jQ.remove(),e[t]=this[t])},t.selectTowards=function(t,e){var i,s,o,a;return r(t),i=e.anticursor,s=n(-t,this.text),i[t]===this?(o=D(s).createDir(t,e),i[t]=o,e.insDirOf(t,o)):(a=this[-t],a?a.insTextAtDirEnd(s,t):(o=D(s).createDir(-t,e),o.jQ.insDirOf(-t,e.selection.jQ)),1===this.text.length&&i[-t]===this&&(i[-t]=this[-t])),this.deleteTowards(t,e)}}),Ee.$=Le.text=Le.textnormal=Le.textrm=Le.textup=Le.textmd=A,Le.em=Le.italic=Le.italics=Le.emph=Le.textit=Le.textsl=h("\\textit","i",'class="mq-text-mode"'),Le.strong=Le.bold=Le.textbf=h("\\textbf","b",'class="mq-text-mode"'),Le.sf=Le.textsf=h("\\textsf","span",'class="mq-sans-serif mq-text-mode"'),Le.tt=Le.texttt=h("\\texttt","span",'class="mq-monospace mq-text-mode"'),Le.textsc=h("\\textsc","span",'style="font-variant:small-caps" class="mq-text-mode"'),Le.uppercase=h("\\uppercase","span",'style="text-transform:uppercase" class="mq-text-mode"'),Le.lowercase=h("\\lowercase","span",'style="text-transform:lowercase" class="mq-text-mode"'),_=je(y,function(t,e){t.init=function(t){e.init.call(this,"$"),this.cursor=t},t.htmlTemplate='<span class="mq-math-mode">&0</span>',t.createBlocks=function(){e.createBlocks.call(this),this.ends[Qe].cursor=this.cursor,this.ends[Qe].write=function(t,e,n){"$"!==e?S.prototype.write.call(this,t,e,n):this.isEmpty()?(t.insRightOf(this.parent),this.parent.deleteTowards(dir,t),j("\\$","$").createLeftOf(t.show())):t[Se]?t[Qe]?S.prototype.write.call(this,t,e,n):t.insLeftOf(this.parent):t.insRightOf(this.parent)}},t.latex=function(){return"$"+this.ends[Qe].latex()+"$"}}),L=je(T,function(t,e){t.keystroke=function(t){return"Spacebar"!==t&&"Shift-Spacebar"!==t?e.keystroke.apply(this,arguments):void 0},t.write=function(t,e,n){if(n&&n.remove(),"$"===e)_(t).createLeftOf(t);else{var i;"<"===e?i="&lt;":">"===e&&(i="&gt;"),j(e,i).createLeftOf(t)}}}),a.TextField=l(je(w,function(t){t.init=function(t){t.addClass("mq-editable-field mq-text-mode"),this.initRootAndEvents(L(),t)},t.latex=function(t){return arguments.length>0?(this.__controller.renderLatexText(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this):this.__controller.exportLatex()}})),E=Ee["\\"]=je(y,function(t,e){t.ctrlSeq="\\",t.replaces=function(t){this._replacedFragment=t.disown(),this.isEmpty=function(){return!1}},t.htmlTemplate='<span class="mq-latex-command-input mq-non-leaf">\\<span>&0</span></span>',t.textTemplate=["\\"],t.createBlocks=function(){e.createBlocks.call(this),this.ends[Qe].focus=function(){return this.parent.jQ.addClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.removeClass("mq-empty"),this},this.ends[Qe].blur=function(){return this.parent.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.addClass("mq-empty"),this},this.ends[Qe].write=function(t,e,n){return n&&n.remove(),0==this.parent.ends[Qe].latex().indexOf("matrix")?void(/^matrix\dx\d$/.test(this.parent.ends[Qe].latex())?(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)):j(e).createLeftOf(t)):void(e.match(/[a-z]/i)?j(e).createLeftOf(t):(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)))},this.ends[Qe].keystroke=function(t,n,i){return"Tab"===t||"Enter"===t||"Spacebar"===t?(this.parent.renderCommand(i.cursor),void n.preventDefault()):e.keystroke.apply(this,arguments)}},t.createLeftOf=function(t){if(e.createLeftOf.call(this,t),this._replacedFragment){var n=this.jQ[0];this.jQ=this._replacedFragment.jQ.addClass("mq-blur").bind("mousedown mousemove",function(t){return Te(t.target=n).trigger(t),!1}).insertBefore(this.jQ).add(this.jQ)}},t.latex=function(){return"\\"+this.ends[Qe].latex()+" "},t.renderCommand=function(t){var e,n;this.jQ=this.jQ.last(),this.remove(),this[Se]?t.insLeftOf(this[Se]):t.insAtRightEnd(this.parent),e=this.ends[Qe].latex(),e||(e=" "),n=Le[e],n?(n=n(e),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t)):(n=A(),n.replaces(e),n.createLeftOf(t),t.insRightOf(n),this._replacedFragment&&this._replacedFragment.remove())}}),Le.notin=Le.sim=Le.cong=Le.equiv=Le.oplus=Le.otimes=je(Q,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),Le.ast=Le.star=Le.loast=Le.lowast=i(Q,"\\ast ","&lowast;"),Le.therefor=Le.therefore=i(Q,"\\therefore ","&there4;"),Le.cuz=Le.because=i(Q,"\\because ","&#8757;"),Le.prop=Le.propto=i(Q,"\\propto ","&prop;"),Le["≈"]=Le.asymp=Le.approx=i(Q,"\\approx ","&asymp;"),Le.isin=Le["in"]=i(Q,"\\in ","&isin;"),Le.ni=Le.contains=i(Q,"\\ni ","&ni;"),Le.notni=Le.niton=Le.notcontains=Le.doesnotcontain=i(Q,"\\not\\ni ","&#8716;"),Le.sub=Le.subset=i(Q,"\\subset ","&sub;"),Le.sup=Le.supset=Le.superset=i(Q,"\\supset ","&sup;"),Le.nsub=Le.notsub=Le.nsubset=Le.notsubset=i(Q,"\\not\\subset ","&#8836;"),Le.nsup=Le.notsup=Le.nsupset=Le.notsupset=Le.nsuperset=Le.notsuperset=i(Q,"\\not\\supset ","&#8837;"),Le.sube=Le.subeq=Le.subsete=Le.subseteq=i(Q,"\\subseteq ","&sube;"),Le.supe=Le.supeq=Le.supsete=Le.supseteq=Le.supersete=Le.superseteq=i(Q,"\\supseteq ","&supe;"),Le.nsube=Le.nsubeq=Le.notsube=Le.notsubeq=Le.nsubsete=Le.nsubseteq=Le.notsubsete=Le.notsubseteq=i(Q,"\\not\\subseteq ","&#8840;"),Le.nsupe=Le.nsupeq=Le.notsupe=Le.notsupeq=Le.nsupsete=Le.nsupseteq=Le.notsupsete=Le.notsupseteq=Le.nsupersete=Le.nsuperseteq=Le.notsupersete=Le.notsuperseteq=i(Q,"\\not\\supseteq ","&#8841;"),Le.N=Le.naturals=Le.Naturals=i(j,"\\mathbb{N}","&#8469;"),Le.P=Le.primes=Le.Primes=Le.projective=Le.Projective=Le.probability=Le.Probability=i(j,"\\mathbb{P}","&#8473;"),Le.Z=Le.integers=Le.Integers=i(j,"\\mathbb{Z}","&#8484;"),Le.Q=Le.rationals=Le.Rationals=i(j,"\\mathbb{Q}","&#8474;"),Le.R=Le.reals=Le.Reals=i(j,"\\mathbb{R}","&#8477;"),Le.C=Le.complex=Le.Complex=Le.complexes=Le.Complexes=Le.complexplane=Le.Complexplane=Le.ComplexPlane=i(j,"\\mathbb{C}","&#8450;"),Le.H=Le.Hamiltonian=Le.quaternions=Le.Quaternions=i(j,"\\mathbb{H}","&#8461;"),Le.quad=Le.emsp=i(j,"\\quad "," "),Le.qquad=i(j,"\\qquad "," "),Le.diamond=i(j,"\\diamond ","&#9671;"),Le.bigtriangleup=i(j,"\\bigtriangleup ","&#9651;"),Le.ominus=i(j,"\\ominus ","&#8854;"),Le.uplus=i(j,"\\uplus ","&#8846;"),Le.bigtriangledown=i(j,"\\bigtriangledown ","&#9661;"),Le.sqcap=i(j,"\\sqcap ","&#8851;"),Le.triangleleft=i(j,"\\triangleleft ","&#8882;"),Le.sqcup=i(j,"\\sqcup ","&#8852;"),Le.triangleright=i(j,"\\triangleright ","&#8883;"),Le.odot=i(j,"\\odot ","&#8857;"),Le.bigcirc=i(j,"\\bigcirc ","&#9711;"),Le.dagger=i(j,"\\dagger ","&#0134;"),Le.ddagger=i(j,"\\ddagger ","&#135;"),Le.wr=i(j,"\\wr ","&#8768;"),Le.amalg=i(j,"\\amalg ","&#8720;"),Le.models=i(j,"\\models ","&#8872;"),Le.prec=i(j,"\\prec ","&#8826;"),Le.succ=i(j,"\\succ ","&#8827;"),Le.preceq=i(j,"\\preceq ","&#8828;"),Le.succeq=i(j,"\\succeq ","&#8829;"),Le.simeq=i(j,"\\simeq ","&#8771;"),Le.mid=i(j,"\\mid ","&#8739;"),Le.ll=i(j,"\\ll ","&#8810;"),Le.gg=i(j,"\\gg ","&#8811;"),Le.parallel=i(j,"\\parallel ","&#8741;"),Le.bowtie=i(j,"\\bowtie ","&#8904;"),Le.sqsubset=i(j,"\\sqsubset ","&#8847;"),Le.sqsupset=i(j,"\\sqsupset ","&#8848;"),Le.smile=i(j,"\\smile ","&#8995;"),Le.sqsubseteq=i(j,"\\sqsubseteq ","&#8849;"),Le.sqsupseteq=i(j,"\\sqsupseteq ","&#8850;"),Le.doteq=i(j,"\\doteq ","&#8784;"),Le.frown=i(j,"\\frown ","&#8994;"),Le.vdash=i(j,"\\vdash ","&#8870;"),Le.dashv=i(j,"\\dashv ","&#8867;"),Le.longleftarrow=i(j,"\\longleftarrow ","&#8592;"),Le.longrightarrow=i(j,"\\longrightarrow ","&#8594;"),Le.Longleftarrow=i(j,"\\Longleftarrow ","&#8656;"),Le.Longrightarrow=i(j,"\\Longrightarrow ","&#8658;"),Le.longleftrightarrow=i(j,"\\longleftrightarrow ","&#8596;"),Le.updownarrow=i(j,"\\updownarrow ","&#8597;"),Le.Longleftrightarrow=i(j,"\\Longleftrightarrow ","&#8660;"),Le.Updownarrow=i(j,"\\Updownarrow ","&#8661;"),Le.mapsto=i(j,"\\mapsto ","&#8614;"),Le.nearrow=i(j,"\\nearrow ","&#8599;"),Le.hookleftarrow=i(j,"\\hookleftarrow ","&#8617;"),Le.hookrightarrow=i(j,"\\hookrightarrow ","&#8618;"),Le.searrow=i(j,"\\searrow ","&#8600;"),Le.leftharpoonup=i(j,"\\leftharpoonup ","&#8636;"),Le.rightharpoonup=i(j,"\\rightharpoonup ","&#8640;"),Le.swarrow=i(j,"\\swarrow ","&#8601;"),Le.leftharpoondown=i(j,"\\leftharpoondown ","&#8637;"),Le.rightharpoondown=i(j,"\\rightharpoondown ","&#8641;"),Le.nwarrow=i(j,"\\nwarrow ","&#8598;"),Le.ldots=i(j,"\\ldots ","&#8230;"),Le.cdots=i(j,"\\cdots ","&#8943;"),Le.vdots=i(j,"\\vdots ","&#8942;"),Le.ddots=i(j,"\\ddots ","&#8944;"),Le.surd=i(j,"\\surd ","&#8730;"),Le.triangle=i(j,"\\triangle ","&#9653;"),Le.ell=i(j,"\\ell ","&#8467;"),Le.top=i(j,"\\top ","&#8868;"),Le.flat=i(j,"\\flat ","&#9837;"),Le.natural=i(j,"\\natural ","&#9838;"),Le.sharp=i(j,"\\sharp ","&#9839;"),Le.wp=i(j,"\\wp ","&#8472;"),Le.bot=i(j,"\\bot ","&#8869;"),Le.clubsuit=i(j,"\\clubsuit ","&#9827;"),Le.diamondsuit=i(j,"\\diamondsuit ","&#9826;"),Le.heartsuit=i(j,"\\heartsuit ","&#9825;"),Le.spadesuit=i(j,"\\spadesuit ","&#9824;"),Le.oint=i(j,"\\oint ","&#8750;"),Le.bigcap=i(j,"\\bigcap ","&#8745;"),Le.bigcup=i(j,"\\bigcup ","&#8746;"),Le.bigsqcup=i(j,"\\bigsqcup ","&#8852;"),Le.bigvee=i(j,"\\bigvee ","&#8744;"),Le.bigwedge=i(j,"\\bigwedge ","&#8743;"),Le.bigodot=i(j,"\\bigodot ","&#8857;"),Le.bigotimes=i(j,"\\bigotimes ","&#8855;"),Le.bigoplus=i(j,"\\bigoplus ","&#8853;"),Le.biguplus=i(j,"\\biguplus ","&#8846;"),Le.lfloor=i(j,"\\lfloor ","&#8970;"),Le.rfloor=i(j,"\\rfloor ","&#8971;"),Le.lceil=i(j,"\\lceil ","&#8968;"),Le.rceil=i(j,"\\rceil ","&#8969;"),Le.opencurlybrace=Le.lbrace=i(j,"\\lbrace ","{"),Le.closecurlybrace=Le.rbrace=i(j,"\\rbrace ","}"),Le["∫"]=Le["int"]=Le.integral=i(C,"\\int ","<big>&int;</big>"),Le.caret=i(j,"\\text{^}","^"),Le.underscore=i(j,"\\_","_"),Le.slash=i(j,"/"),Le.vert=i(j,"|"),Le.perp=Le.perpendicular=i(j,"\\perp ","&perp;"),Le.nabla=Le.del=i(j,"\\nabla ","&nabla;"),Le.hbar=i(j,"\\hbar ","&#8463;"),Le.AA=Le.Angstrom=Le.angstrom=i(j,"\\text\\AA ","&#8491;"),Le.ring=Le.circ=Le.circle=i(j,"\\circ ","&#8728;"),Le.bull=Le.bullet=i(j,"\\bullet ","&bull;"),Le.setminus=Le.smallsetminus=i(j,"\\setminus ","&#8726;"),Le.not=Le["¬"]=Le.neg=i(j,"\\neg ","&not;"),Le["…"]=Le.dots=Le.ellip=Le.hellip=Le.ellipsis=Le.hellipsis=i(j,"\\dots ","&hellip;"),Le.converges=Le.darr=Le.dnarr=Le.dnarrow=Le.downarrow=i(j,"\\downarrow ","&darr;"),Le.dArr=Le.dnArr=Le.dnArrow=Le.Downarrow=i(j,"\\Downarrow ","&dArr;"),Le.diverges=Le.uarr=Le.uparrow=i(j,"\\uparrow ","&uarr;"),Le.uArr=Le.Uparrow=i(j,"\\Uparrow ","&uArr;"),Le.to=i(Q,"\\to ","&rarr;"),Le.rarr=Le.rightarrow=i(j,"\\rightarrow ","&rarr;"),Le.implies=i(Q,"\\Rightarrow ","&rArr;"),Le.rArr=Le.Rightarrow=i(j,"\\Rightarrow ","&rArr;"),Le.gets=i(Q,"\\gets ","&larr;"),Le.larr=Le.leftarrow=i(j,"\\leftarrow ","&larr;"),Le.impliedby=i(Q,"\\Leftarrow ","&lArr;"),Le.lArr=Le.Leftarrow=i(j,"\\Leftarrow ","&lArr;"),Le.harr=Le.lrarr=Le.leftrightarrow=i(j,"\\leftrightarrow ","&harr;"),Le.iff=i(Q,"\\Leftrightarrow ","&hArr;"),Le.hArr=Le.lrArr=Le.Leftrightarrow=i(j,"\\Leftrightarrow ","&hArr;"),Le.Re=Le.Real=Le.real=i(j,"\\Re ","&real;"),Le.Im=Le.imag=Le.image=Le.imagin=Le.imaginary=Le.Imaginary=i(j,"\\Im ","&image;"),Le.part=Le.partial=i(j,"\\partial ","&part;"),Le.infty=Le.infin=Le.infinity=i(j,"\\infty ","&infin;"),Le.alef=Le.alefsym=Le.aleph=Le.alephsym=i(j,"\\aleph ","&alefsym;"),Le.xist=Le.xists=Le.exist=Le.exists=i(j,"\\exists ","&exist;"),Le.and=Le.land=Le.wedge=i(j,"\\wedge ","&and;"),Le.or=Le.lor=Le.vee=i(j,"\\vee ","&or;"),Le.o=Le.O=Le.empty=Le.emptyset=Le.oslash=Le.Oslash=Le.nothing=Le.varnothing=i(Q,"\\varnothing ","&empty;"),Le.cup=Le.union=i(Q,"\\cup ","&cup;"),Le.cap=Le.intersect=Le.intersection=i(Q,"\\cap ","&cap;"),Le.deg=Le.degree=i(j,"^\\circ ","&deg;"),Le.ang=Le.angle=i(j,"\\angle ","&ang;"),R=je(C,function(t,e){t.init=function(t,n){e.init.call(this,t,"<var>"+(n||t)+"</var>")},t.text=function(){return this.textTemplate}}),g.p.autoCommands={_maxLength:0},b.autoCommands=function(t){var e,n,i,s,r;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},i=0,s=0;s<e.length;s+=1){if(r=e[s],r.length<2)throw'autocommand "'+r+'" not minimum length of 2';if(Le[r]===P)throw'"'+r+'" is a built-in operator name';n[r]=1,i=Oe(i,r.length)}return n._maxLength=i,n},I=je(R,function(t,e){function n(t){return t instanceof C&&!(t instanceof Q)}t.init=function(t){return e.init.call(this,this.letter=t)},t.createLeftOf=function(t){var n,i,s,r=t.options.autoCommands,o=r._maxLength;if(o>0){for(n=this.letter,i=t[Qe],s=1;i instanceof I&&o>s;)n=i.letter+n,i=i[Qe],s+=1;for(;n.length;){if(r.hasOwnProperty(n)){for(s=2,i=t[Qe];s<n.length;s+=1,i=i[Qe]);return _e(i,t[Qe]).remove(),t[Qe]=i[Qe],Le[n](n).createLeftOf(t)}if(t.options.autoCommandFullWordOnly)break;n=n.slice(1)}}e.createLeftOf.apply(this,arguments)},t.italicize=function(t){return this.jQ.toggleClass("mq-operator-name",!t),this},t.finalizeTree=t.siblingDeleted=t.siblingCreated=function(t,e){t.autoOnBrackets||e!==Qe&&this[Se]instanceof I||this.autoUnItalicize(t,!0)},t.autoUnItalicize=function(t,e){var i,s,r,o,a,l,c,h,u,p,f,d,m=t.autoOperatorNames;if(0!==m._maxLength){for(i=this.letter,s=this[Qe];s instanceof I;s=s[Qe])i=s.letter+i;for(r=this[Se];r instanceof I;r=r[Se])i+=r.letter;_e(s[Se]||this.parent.ends[Qe],r[Qe]||this.parent.ends[Se]).each(function(t){t.italicize(!0).jQ.removeClass("mq-first mq-last"),t.ctrlSeq=t.letter});t:for(o=0,a=s[Se]||this.parent.ends[Qe];o<i.length;o+=1,a=a[Se])for(l=t.autoAllFunctions?i.length-o:ke(m._maxLength,i.length-o),c=l;c>0;c-=1)if(h=i.slice(o,o+c),t.autoAllFunctions||m.hasOwnProperty(h)){for(u=0,p=a;c>u;u+=1,p=p[Se])e&&p.italicize(!1),f=p;d=z.hasOwnProperty(h),a.ctrlSeq=(d?"\\":"\\operatorname{")+a.ctrlSeq,f.ctrlSeq+=d?" ":"}",B.hasOwnProperty(h)&&f[Qe][Qe][Qe].jQ.addClass("mq-last"),n(a[Qe])&&a.jQ.addClass("mq-first"),n(f[Se])&&f.jQ.addClass("mq-last"),o+=c-1,a=f;continue t}}}}),z={},B={limsup:1,liminf:1,projlim:1,injlim:1},function(){var t,e,n,i=g.p.autoOperatorNames={_maxLength:9},s="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<s.length;t+=1)z[s[t]]=i[s[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)z[e[t]]=1;for(n="sin cos tan sec cosec csc cotan cot ctg".split(" "),t=0;t<n.length;t+=1)i[n[t]]=i["arc"+n[t]]=i[n[t]+"h"]=i["ar"+n[t]+"h"]=i["arc"+n[t]+"h"]=1}(),b.autoOperatorNames=function(t){var e,n,i,s,r;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},i=0,s=0;s<e.length;s+=1){if(r=e[s],r.length<2)throw'"'+r+'" not minimum length of 2';n[r]=1,i=Oe(i,r.length)}return n._maxLength=i,n},P=je(C,function(t){t.init=function(t){this.ctrlSeq=t},t.createLeftOf=function(t){var e,n=this.ctrlSeq;for(e=0;e<n.length;e+=1)I(n.charAt(e)).createLeftOf(t)},t.parser=function(){var t,e=this.ctrlSeq,n=S();for(t=0;t<e.length;t+=1)I(e.charAt(t)).adopt(n,n.ends[Se],0);return q.succeed(n.children())}});for(M in z)z.hasOwnProperty(M)&&(Le[M]=P);Le.operatorname=je(y,function(e){e.createLeftOf=t,e.numBlocks=function(){return 1},e.parser=function(){return k.block.map(function(t){return t.children()})}}),Le.f=je(I,function(t,e){t.init=function(){C.p.init.call(this,this.letter="f",'<var class="mq-florin">&fnof;</var>')},t.italicize=function(t){return this.jQ.html(t?"&fnof;":"f").toggleClass("mq-florin",t),e.italicize.apply(this,arguments)}}),Le[" "]=Le.space=i(j,"\\ "," "),Le["'"]=Le.prime=i(j,"'","&prime;"),Le.backslash=i(j,"\\backslash ","\\"),Ee["\\"]||(Ee["\\"]=Le.backslash),Le.$=i(j,"\\$","$"),F=je(C,function(t,e){t.init=function(t,n){e.init.call(this,t,'<span class="mq-nonSymbola">'+(n||t)+"</span>")}}),Le["@"]=F,Le["&"]=i(F,"\\&","&amp;"),Le["%"]=i(F,"\\%","%"),Le.alpha=Le.beta=Le.gamma=Le.delta=Le.zeta=Le.eta=Le.theta=Le.iota=Le.kappa=Le.mu=Le.nu=Le.xi=Le.rho=Le.sigma=Le.tau=Le.chi=Le.psi=Le.omega=je(R,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),Le.phi=i(R,"\\phi ","&#981;"),Le.phiv=Le.varphi=i(R,"\\varphi ","&phi;"),Le.epsilon=i(R,"\\epsilon ","&#1013;"),Le.epsiv=Le.varepsilon=i(R,"\\varepsilon ","&epsilon;"),Le.piv=Le.varpi=i(R,"\\varpi ","&piv;"),Le.sigmaf=Le.sigmav=Le.varsigma=i(R,"\\varsigma ","&sigmaf;"),Le.thetav=Le.vartheta=Le.thetasym=i(R,"\\vartheta ","&thetasym;"),Le.upsilon=Le.upsi=i(R,"\\upsilon ","&upsilon;"),Le.gammad=Le.Gammad=Le.digamma=i(R,"\\digamma ","&#989;"),Le.kappav=Le.varkappa=i(R,"\\varkappa ","&#1008;"),Le.rhov=Le.varrho=i(R,"\\varrho ","&#1009;"),Le.pi=Le["π"]=i(F,"\\pi ","&pi;"),Le.lambda=i(F,"\\lambda ","&lambda;"),Le.Upsilon=Le.Upsi=Le.upsih=Le.Upsih=i(C,"\\Upsilon ",'<var style="font-family: serif">&upsih;</var>'),Le.Gamma=Le.Delta=Le.Theta=Le.Lambda=Le.Xi=Le.Pi=Le.Sigma=Le.Phi=Le.Psi=Le.Omega=Le.forall=je(j,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),$=je(y,function(t){t.init=function(t){this.latex=t},t.createLeftOf=function(t){var e=k.parse(this.latex);e.children().adopt(t.parent,t[Qe],t[Se]),t[Qe]=e.ends[Se],e.jQize().insertBefore(t.jQ),e.finalizeInsert(t.options,t),e.ends[Se][Se].siblingCreated&&e.ends[Se][Se].siblingCreated(t.options,Qe),e.ends[Qe][Qe].siblingCreated&&e.ends[Qe][Qe].siblingCreated(t.options,Se),t.parent.bubble("reflow")},t.parser=function(){var t=k.parse(this.latex).children();return q.succeed(t)}}),Le["¹"]=i($,"^1"),Le["²"]=i($,"^2"),Le["³"]=i($,"^3"),Le["¼"]=i($,"\\frac14"),Le["½"]=i($,"\\frac12"),Le["¾"]=i($,"\\frac34"),N=je(Q,function(t){t.init=j.prototype.init,t.contactWeld=t.siblingCreated=t.siblingDeleted=function(t,e){return e!==Se?(this.jQ[0].className=!this[Qe]||this[Qe]instanceof Q?"":"mq-binary-operator",this):void 0}}),Le["+"]=i(N,"+","+"),Le["–"]=Le["-"]=i(N,"-","&minus;"),Le["±"]=Le.pm=Le.plusmn=Le.plusminus=i(N,"\\pm ","&plusmn;"),Le.mp=Le.mnplus=Le.minusplus=i(N,"\\mp ","&#8723;"),Ee["*"]=Le.sdot=Le.cdot=i(Q,"\\cdot ","&middot;","*"),G=je(Q,function(t,e){t.init=function(t,n){this.data=t,this.strict=n;var i=n?"Strict":"";e.init.call(this,t["ctrlSeq"+i],t["html"+i],t["text"+i])},t.swap=function(t){this.strict=t;var e=t?"Strict":"";this.ctrlSeq=this.data["ctrlSeq"+e],this.jQ.html(this.data["html"+e]),this.textTemplate=[this.data["text"+e]]},t.deleteTowards=function(t){return t!==Qe||this.strict?void e.deleteTowards.apply(this,arguments):void this.swap(!0)}}),U={ctrlSeq:"\\le ",html:"&le;",text:" <= ",ctrlSeqStrict:"<",htmlStrict:"&lt;",textStrict:" < "},W={ctrlSeq:"\\ge ",html:"&ge;",text:" >= ",ctrlSeqStrict:">",htmlStrict:"&gt;",textStrict:" > "},H={ctrlSeq:"\\ne ",html:"&ne;",text:" != ",ctrlSeqStrict:"!",htmlStrict:"!",textStrict:"!"},Le["<"]=Le.lt=i(G,U,!0),Le[">"]=Le.gt=i(G,W,!0),Le["≤"]=Le.le=Le.leq=i(G,U,!1),Le["≥"]=Le.ge=Le.geq=i(G,W,!1),Le["!"]=i(G,H,!0),Le["≠"]=Le.ne=Le.neq=i(G,H,!1),V=je(G,function(t,e){t.init=function(t,n){e.init.call(this,t,n)},t.createLeftOf=function(t){return(t[Qe]instanceof G||t[Qe]instanceof V)&&t[Qe].strict?void t[Qe].swap(!1):void e.createLeftOf.apply(this,arguments)}}),X={ctrlSeq:"\\eq ",html:"==",text:" == ",ctrlSeqStrict:"=",htmlStrict:"=",textStrict:" = "},Le["="]=i(V,X,!0),Le.eq=i(V,X,!1),Le.times=i(Q,"\\times ","&times;","[x]"),Le["÷"]=Le.div=Le.divide=Le.divides=i(Q,"\\div ","&divide;","[/]"),K=t,Y=document.createElement("div"),J=Y.style,te={transform:1,WebkitTransform:1,MozTransform:1,OTransform:1,msTransform:1};for(ne in te)if(ne in J){ee=ne;break}ee?Z=function(t,e,n){t.css(ee,"scale("+e+","+n+")")}:"filter"in J?(K=function(t){t.className=t.className},Z=function(t,e,n){function i(){t.css("marginRight",(s.width()-1)*(e-1)/e+"px")}var s,r;e/=1+(n-1)/2,t.css("fontSize",n+"em"),t.hasClass("mq-matrixed-container")||t.addClass("mq-matrixed-container").wrapInner('<span class="mq-matrixed"></span>'),s=t.children().css("filter","progid:DXImageTransform.Microsoft.Matrix(M11="+e+",SizingMethod='auto expand')"),i(),r=setInterval(i),Te(window).load(function(){clearTimeout(r),i()})}):Z=function(t,e,n){t.css("fontSize",n+"em")},ie=je(y,function(t,e){t.init=function(t,n,i){e.init.call(this,t,"<"+n+" "+i+">&0</"+n+">")}}),Le.mathrm=i(ie,"\\mathrm","span",'class="mq-roman mq-font"'),Le.mathit=i(ie,"\\mathit","i",'class="mq-font"'),Le.mathbf=i(ie,"\\mathbf","b",'class="mq-font"'),Le.mathsf=i(ie,"\\mathsf","span",'class="mq-sans-serif mq-font"'),Le.mathtt=i(ie,"\\mathtt","span",'class="mq-monospace mq-font"'),Le.underline=i(ie,"\\underline","span",'class="mq-non-leaf mq-underline"'),Le.overline=Le.bar=i(ie,"\\overline","span",'class="mq-non-leaf mq-overline"'),se=Le.textcolor=je(y,function(t,e){t.setColor=function(t){this.color=t,this.htmlTemplate='<span class="mq-textcolor" style="color:'+t+'">&0</span>'},t.latex=function(){return"\\textcolor{"+this.color+"}{"+this.blocks[0].latex()+"}"},t.parser=function(){var t=this,n=q.optWhitespace,i=q.string,s=q.regex;return n.then(i("{")).then(s(/^[#\w\s.,()%-]*/)).skip(i("}")).then(function(n){return t.setColor(n),e.parser.call(t)})}}),re=Le["class"]=je(y,function(t,e){t.parser=function(){var t=this,n=q.string,i=q.regex;return q.optWhitespace.then(n("{")).then(i(/^[-\w\s\\\xA0-\xFF]*/)).skip(n("}")).then(function(n){return t.htmlTemplate='<span class="mq-class '+n+'">&0</span>',e.parser.call(t)})}}),oe=je(y,function(t,e){t.ctrlSeq="_{...}^{...}",t.createLeftOf=function(t){return t[Qe]||!t.options.supSubsRequireOperand?e.createLeftOf.apply(this,arguments):void 0},t.contactWeld=function(t){var e,n,i,s,r,o;for(e=Qe;e;e=e===Qe?Se:!1)if(this[e]instanceof oe){for(n="sub";n;n="sub"===n?"sup":!1)i=this[n],s=this[e][n],i&&(s?i.isEmpty()?o=Ae(s,0,s.ends[Qe]):(i.jQ.children().insAtDirEnd(-e,s.jQ),r=i.children().disown(),o=Ae(s,r.ends[Se],s.ends[Qe]),e===Qe?r.adopt(s,s.ends[Se],0):r.adopt(s,0,s.ends[Qe])):this[e].addBlock(i.disown()),this.placeCursor=function(t,n){return function(i){i.insAtDirEnd(-e,t||n)}}(s,i));this.remove(),t&&t[Qe]===this&&(e===Se&&o?o[Qe]?t.insRightOf(o[Qe]):t.insAtLeftEnd(o.parent):t.insRightOf(this[e]));break}this.respace()},g.p.charsThatBreakOutOfSupSub="",t.finalizeTree=function(){var t=this.supsub;this.ends[Qe].write=function(e,n){e.options.charsThatBreakOutOfSupSub.indexOf(n)>-1&&e.insRightOf(this.parent),"sub"==t&&e.options.noOperatorsInSubscript&&!RegExp(/[A-Za-z0-9]/).test(n)&&e.insRightOf(this.parent),S.p.write.apply(this,arguments)}},t.latex=function(){function t(t,e){var n=e&&e.latex();return e?t+(1===n.length?n:"{"+(n||" ")+"}"):""}return t("_",this.sub)+t("^",this.sup)},t.text=function(t){var e="";return this.sub&&(e+=t.noOperatorsInSubscript?"_"+(this.sub&&this.sub.ends[Qe]===this.sub.ends[Se]?this.sub.ends[Qe].text(t):this.sub.foldChildren("",function(e,n){return e+n.text(t)})):"_"+(this.sub&&this.sub.ends[Qe]===this.sub.ends[Se]?this.sub.ends[Qe].text(t):"("+this.sub.foldChildren("",function(e,n){return e+n.text(t)})+")")),this.sup&&(e+="^"+(this.sup&&this.sup.ends[Qe]===this.sup.ends[Se]?this.sup.ends[Qe].text(t):"("+this.sup.foldChildren("",function(e,n){return e+n.text(t)})+")")),e},t.respace=t.siblingCreated=t.siblingDeleted=function(t,e){e!==Se&&this.jQ.toggleClass("mq-limit","\\int "===this[Qe].ctrlSeq)},t.addBlock=function(t){"sub"===this.supsub?(this.sup=this.upInto=this.sub.upOutOf=t,t.adopt(this,this.sub,0).downOutOf=this.sub,t.jQ=Te('<span class="mq-sup"/>').append(t.jQ.children()).attr(xe,t.id).prependTo(this.jQ)):(this.sub=this.downInto=this.sup.downOutOf=t,t.adopt(this,0,this.sup).upOutOf=this.sup,t.jQ=Te('<span class="mq-sub"></span>').append(t.jQ.children()).attr(xe,t.id).appendTo(this.jQ.removeClass("mq-sup-only")),this.jQ.append('<span style="display:inline-block;width:0">&nbsp;</span>'));for(var e=0;2>e;e+=1)(function(t,e,n,i){t[e].deleteOutOf=function(s,r){r.insDirOf(s,this.parent),this.isEmpty()||(r[-s]=this.ends[s],this.children().disown().withDirAdopt(s,r.parent,r[s],this.parent).jQ.insDirOf(s,this.parent.jQ)),t.supsub=n,delete t[e],delete t[i+"Into"],t[n][i+"OutOf"]=u,delete t[n].deleteOutOf,"sub"===e&&Te(t.jQ.addClass("mq-sup-only")[0].lastChild).remove(),this.remove()}})(this,"sub sup".split(" ")[e],"sup sub".split(" ")[e],"down up".split(" ")[e])}}),ae=je(y,function(t,e){t.init=function(t,e){var n;n=g.p.autoParensSummationNotation?'<span><span class="mq-large-operator mq-non-leaf"><span class="mq-to"><span>&1</span></span><big>'+e+'</big><span class="mq-from"><span>&0</span></span></span><span class="mq-non-leaf"><span class="mq-scaled mq-paren">(</span><span class="mq-non-leaf">&2</span><span class="mq-scaled mq-paren">)</span></span></span>':'<span class="mq-large-operator mq-non-leaf"><span class="mq-to"><span>&1</span></span><big>'+e+'</big><span class="mq-from"><span>&0</span></span></span>',C.prototype.init.call(this,t,n)},t.createLeftOf=function(t){e.createLeftOf.apply(this,arguments),t.options.sumStartsWithNEquals&&(I("n").createLeftOf(t),V().createLeftOf(t))},t.reflow=function(){var t,e,n;g.p.autoParensSummationNotation&&(t=this.jQ.children(":last").children(":first").add(this.jQ.children(":last").children(":last")),e=this.jQ.children(":last").children(":eq(1)"),n=e.outerHeight()/parseInt(e.css("fontSize"),10),Z(t,ke(1+.2*(n-1),1.2),1.05*n))},t.latex=function(){function t(t){return 1===t.length?t:"{"+(t||" ")+"}"}return g.p.autoParensSummationNotation?this.ctrlSeq+"_{"+this.blocks[0].latex()+"}^{"+this.blocks[1].latex()+"}\\left({"+this.blocks[2].latex()+"}\\right)":this.ctrlSeq+"_"+t(this.ends[Qe].latex())+"^"+t(this.ends[Se].latex())},t.text=function(t){return g.p.autoParensSummationNotation?" "+this.ctrlSeq+'("'+this.blocks[0].text(t).replace("=",'" , ')+" , "+this.blocks[1].text(t)+","+this.blocks[2].text(t)+")":" "+this.ctrlSeq+'("'+this.ends[Qe].text(t).replace("=",'" , ')+" , "+this.ends[Se].text(t)+")"},t.parser=function(){var t,e,n=q.string,i=q.optWhitespace,s=(q.whitespace,q.succeed),r=k.block,o=this;for(t=o.blocks=g.p.autoParensSummationNotation?[S(),S(),S()]:[S(),S()],e=0;e<t.length;e+=1)t[e].adopt(o,o.ends[Se],0);return g.p.autoParensSummationNotation?i.then(n("_")).then(function(){var e=t[0];return r.then(function(t){return t.children().adopt(e,e.ends[Se],0),s(o)})}).then(i).then(n("^")).then(function(){var e=t[1];return r.then(function(t){return t.children().adopt(e,e.ends[Se],0),s(o)})}).then(n("\\left(")).then(function(){var e=t[2];return r.then(function(t){return t.children().adopt(e,e.ends[Se],0),s(o)})}).then(n("\\right)")).result(o):i.then(n("_").or(n("^"))).then(function(e){var n=t["_"===e?0:1];return r.then(function(t){return t.children().adopt(n,n.ends[Se],0),s(o)})}).many().result(o)},t.finalizeTree=function(){this.downInto=this.ends[Qe],this.upInto=this.ends[Se],this.ends[Qe].upOutOf=this.ends[Se],this.ends[Se].downOutOf=this.ends[Qe]
3
- }}),Le["∑"]=Le.sum=Le.summation=i(ae,"\\sum ","&sum;"),Le["∏"]=Le.prod=Le.product=i(ae,"\\prod ","&prod;"),Le.coprod=Le.coproduct=i(ae,"\\coprod ","&#8720;"),Le.subscript=Le._=je(oe,function(t,e){t.supsub="sub",t.ctrlSeq="_",t.htmlTemplate='<span class="mq-supsub mq-non-leaf"><span class="mq-sub">&0</span><span style="display:inline-block;width:0">&nbsp;</span></span>',t.textTemplate=["_"],t.finalizeTree=function(){this.downInto=this.sub=this.ends[Qe],this.sub.upOutOf=u,e.finalizeTree.call(this)}}),Le.superscript=Le.supscript=Le["^"]=je(oe,function(t,e){t.supsub="sup",t.ctrlSeq="^",t.htmlTemplate='<span class="mq-supsub mq-non-leaf mq-sup-only"><span class="mq-sup">&0</span></span>',t.textTemplate=["^"],t.finalizeTree=function(){this.upInto=this.sup=this.ends[Se],this.sup.downOutOf=u,e.finalizeTree.call(this)}}),le=Le.frac=Le.dfrac=Le.cfrac=Le.fraction=je(y,function(t){t.ctrlSeq="\\frac",t.htmlTemplate='<span class="mq-fraction mq-non-leaf"><span class="mq-numerator">&0</span><span class="mq-denominator">&1</span><span style="display:inline-block;width:0">&nbsp;</span></span>',t.textTemplate=["((",")/(","))"],t.finalizeTree=function(){this.upInto=this.ends[Se].upOutOf=this.ends[Qe],this.downInto=this.ends[Qe].downOutOf=this.ends[Se]}}),ce=Le.over=Ee["/"]=je(le,function(e,n){e.createLeftOf=function(e){if(!this.replacedFragment){for(var i=e[Qe];i&&!(i instanceof Q||i instanceof(Le.text||t)||i instanceof ae||"\\ "===i.ctrlSeq||/^[,;:]$/.test(i.ctrlSeq));)i=i[Qe];i instanceof ae&&i[Se]instanceof oe&&(i=i[Se],i[Se]instanceof oe&&i[Se].ctrlSeq!=i.ctrlSeq&&(i=i[Se])),i!==e[Qe]&&(this.replaces(_e(i[Se]||e.parent.ends[Qe],e[Qe])),e[Qe]=i)}n.createLeftOf.call(this,e)}}),he=Le.sqrt=Le["√"]=je(y,function(t,e){t.ctrlSeq="\\sqrt",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-sqrt-prefix">&radic;</span><span class="mq-non-leaf mq-sqrt-stem">&0</span></span>',t.textTemplate=[" sqrt(",")"],t.parser=function(){return k.optBlock.then(function(t){return k.block.map(function(e){var n=pe();return n.blocks=[t,e],t.adopt(n,0,0),e.adopt(n,t,0),n})}).or(e.parser.call(this))},t.reflow=function(){var t=this.ends[Se].jQ;Z(t.prev(),1,t.innerHeight()/+t.css("fontSize").slice(0,-2)-.1)}}),ue=Le.vec=je(y,function(t){t.ctrlSeq="\\vec",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-vector-prefix">&rarr;</span><span class="mq-vector-stem">&0</span></span>',t.textTemplate=["vec(",")"]}),pe=Le.nthroot=je(he,function(t){t.htmlTemplate='<sup class="mq-nthroot mq-non-leaf">&0</sup><span class="mq-scaled"><span class="mq-sqrt-prefix mq-scaled">&radic;</span><span class="mq-sqrt-stem mq-non-leaf">&1</span></span>',t.textTemplate=["sqrt[","](",")"],t.latex=function(){return"\\sqrt["+this.ends[Qe].latex()+"]{"+this.ends[Se].latex()+"}"},t.text=function(t){return" "+this.ends[Se].text(t)+"^(1/"+this.ends[Qe].text(t)+")"}}),fe=Le.begin=je(y,function(t,e){t.numBlocks=function(){return this.col*this.row},t.init=function(t,n,i){var s,r,o,a;for(this.col=n,this.row=i,this.ctrlSeq=t,s="",r=0;i>r;r++){for(o="",a=0;n>a;a++)o+='<span class="mq-cell">&'+(r*n+a)+"</span>";s+='<span class="mq-row">'+o+"</span>"}switch(this.ctrlSeq){case"\\pmatrix":s='<span class="mq-scaled mq-paren">(</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">)</span>';break;case"\\bmatrix":s='<span class="mq-scaled mq-paren">[</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">]</span>';break;case"\\Bmatrix":s='<span class="mq-scaled mq-paren">{</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">}</span>';break;case"\\vmatrix":s='<span class="mq-scaled mq-paren">|</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">|</span>';break;case"\\Vmatrix":s='<span class="mq-scaled mq-paren">||</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">||</span>';break;default:s='<span class="mq-matrix">'+s+"</span>"}e.init.call(this,this.ctrlSeq,'<span class="mq-matrix-outer mq-non-leaf">'+s+"</span>",["text"])},t.reflow=function(){var t=this.jQ.children(".mq-paren"),e=this.jQ.children(".mq-matrix").first(),n=e.outerHeight()/(1.133333*parseInt(e.css("fontSize"),10));Z(t,ke(1+.2*(n-1),1.2),1.05*n),t.css("position","relative"),t.css("top",Math.round(.6*n)+"px")},t.contextMenu=function(t,e){var n=this,i=[{text:"Insert Column Before",handler:function(){n.insertColumn(t,Qe)}},{text:"Insert Column After",handler:function(){n.insertColumn(t,Se)}},{text:"Insert Row Before",handler:function(){n.insertRow(t,Qe)}},{text:"Insert Row After",handler:function(){n.insertRow(t,Se)}}];this.col>1&&i.push({text:"Delete Column",handler:function(){n.deleteColumn(t)}}),this.row>1&&i.push({text:"Delete Row",handler:function(){n.deleteRow(t)}}),this.showPopupMenu(i,e)},t.latex=function(){var t="",e=1,n=this.col,i=this.numBlocks(),s=this.ctrlSeq.substring(1,this.ctrlSeq.length);return this.eachChild(function(s){s.ends[Qe]&&(t+=s.latex()),e!=i&&(t+=e%n==0?" \\\\ ":" & "),e++}),"\\begin{"+s+"}"+t+"\\end{"+s+"}"},t.text=function(t){var e,n,i=[];for(this.eachChild(function(e){i.push(e.ends[Qe]?e.text(t):0)}),e="",n=0;n<i.length;n++)n>0&&n%this.col==0?e+="],[":n>0&&(e+=","),e+=i[n];return this.row>1?"[["+e+"]]":"["+e+"]"},t.parser=function(){{var t=(k.block,q.string,q.regex);q.optWhitespace}return t(/^\{[pbvBV]?matrix\}[\s\S]*?\\end\{[pbvBV]?matrix\}/).map(function(t){var e,n,i,s,r,o,a,l,c;for("}"==t.substring(7,1)?(e=t.substring(1,7),t=t.substring(8,t.length-12).trim()):(e=t.substring(1,8),t=t.substring(9,t.length-13).trim()),n=t.split(/\\\\/).map(function(t){return t.trim()}),i=n.length,s=0,r=[],n.forEach(function(t){var e=t.split(/&/);s=Math.max(s,e.length),r=r.concat(e)}),o=fe("\\"+e,s,i),a=o.blocks=Array(o.numBlocks()),l=0;l<a.length;l++)c=a[l]=k.parse(r[l]),c.adopt(o,o.ends[Se],0);return o})},t.finalizeTree=function(){var t,e,n;for(t=0;t<this.row;t++)for(e=0;e<this.col;e++)n=this.blocks[t*this.col+e],n.upOutOf=0==t&&0!=e?this.blocks[this.row*this.col-this.row+e-1]:this.blocks[(t-1)*this.col+e],n.downOutOf=t+1==this.row&&e+1!=this.col?this.blocks[e+1]:this.blocks[(t+1)*this.col+e]},t.cursorRowCol=function(t){for(var e=0,n=0,i=t.parent;0!==i[Qe];)e++,e==this.col&&(e=0,n++),i=i[Qe];return{row:n,col:e}},t.deleteRow=function(t){var e,n,i;if(1!=this.row){for(e=this.cursorRowCol(t),n=e.row*this.col,i=0;i<this.col;i++)this.blocks[n].remove(),this.blocks.splice(n,1);n>0&&n<this.blocks.length?(this.blocks[n][Qe]=this.blocks[n-1],this.blocks[n-1][Se]=this.blocks[n]):0==n?this.blocks[n][Qe]=0:this.blocks[n-1][Se]=0,this.jQ.children(".mq-matrix").first().children(".mq-row").eq(e.row).remove(),this.row--,this.finalizeTree(),t.insAtLeftEnd(this.blocks[e.row>0?(e.row-1)*this.col+e.col:e.col]),this.reflow(),this.bubble("workingGroupChange")}},t.deleteColumn=function(t){var e,n,i;if(1!=this.col){for(e=this.cursorRowCol(t),n=e.col,i=0;i<this.row;i++)this.blocks[n].remove(),this.blocks.splice(n,1),n>0&&n<this.blocks.length?(this.blocks[n][Qe]=this.blocks[n-1],this.blocks[n-1][Se]=this.blocks[n]):0==n?this.blocks[n][Qe]=0:this.blocks[n-1][Se]=0,n+=this.col-1;this.col--,this.finalizeTree(),t.insAtLeftEnd(this.blocks[e.col<this.col?e.row*this.col+e.col:e.row*this.col+e.col-1]),this.reflow(),this.bubble("workingGroupChange")}},t.insertRow=function(t,e){var n,i,s,r,o=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[Qe]&&0!==t[Se]:e==Qe?!0:!1,i=o.row*this.col+(n?0:this.col),n?this.jQ.children(".mq-matrix").first().children(".mq-row").eq(o.row).before('<span class="mq-row"></span>'):this.jQ.children(".mq-matrix").first().children(".mq-row").eq(o.row).after('<span class="mq-row"></span>'),s=0;s<this.col;s++)r=S(),r.adopt(this,i+s>0?this.blocks[i+s-1]:0,i+s>0?this.blocks[i+s-1][Se]:this.ends[Qe]),r.jQ=Te('<span class="mq-cell mq-empty" '+xe+'="'+r.id+'"></span>'),i+s>0&&(this.blocks[i+s-1][Se]=r),this.blocks.splice(i+s,0,r),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(o.row+(n?0:1)).append(r.jQ);i+s<this.blocks.length&&(this.blocks[i+s][Qe]=r,r[Se]=this.blocks[i+s]),this.row++,this.finalizeTree(),t.insAtLeftEnd(this.blocks[i]),this.reflow(),this.bubble("workingGroupChange")},t.insertColumn=function(t,e){var n,i,s,r=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[Qe]&&0!==t[Se]:e==Qe?!0:!1,i=this.row-1;i>=0;i--)s=S(),n?(s.adopt(this,i*this.col+r.col-1>=0?this.blocks[i*this.col+r.col-1]:0,this.blocks[i*this.col+r.col]),s.jQ=Te('<span class="mq-cell mq-empty" '+xe+'="'+s.id+'"></span>'),i*this.col+r.col-1>=0&&(this.blocks[i*this.col+r.col-1][Se]=s),this.blocks[i*this.col+r.col][Qe]=s,this.blocks.splice(i*this.col+r.col,0,s),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(i).children(".mq-cell").eq(r.col).before(s.jQ)):(s.adopt(this,this.blocks[i*this.col+r.col],i*this.col+r.col+1<this.row*this.col?this.blocks[i*this.col+r.col+1]:0),s.jQ=Te('<span class="mq-cell mq-empty" '+xe+'="'+s.id+'"></span>'),this.blocks[i*this.col+r.col][Se]=s,i*this.col+r.col+1<this.row*this.col&&(this.blocks[i*this.col+r.col+1][Qe]=s),this.blocks.splice(i*this.col+r.col+1,0,s),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(i).children(".mq-cell").eq(r.col).after(s.jQ));this.col++,this.finalizeTree(),t.insAtLeftEnd(t.parent[n?Qe:Se]),this.reflow(),this.bubble("workingGroupChange")},t.moveOrInsertColumn=function(t){var e=this.cursorRowCol(t);return e.col+1==this.col?this.insertColumn(t):(t.insAtLeftEnd(t.parent[Se]),void this.bubble("workingGroupChange"))}}),Le.matrix=i(fe,"\\matrix",1,1),Le.bmatrix=i(fe,"\\bmatrix",1,1),Le.Bmatrix=i(fe,"\\Bmatrix",1,1),Le.vmatrix=i(fe,"\\vmatrix",1,1),Le.Vmatrix=i(fe,"\\Vmatrix",1,1),Le.pmatrix=i(fe,"\\pmatrix",1,1),de=je(je(y,p),function(e,n){e.init=function(t,e,i,s,r){n.init.call(this,"\\left"+s,d,[e,i]),this.side=t,this.sides={},this.sides[Qe]={ch:e,ctrlSeq:s},this.sides[Se]={ch:i,ctrlSeq:r}},e.numBlocks=function(){return 1},e.html=function(){return this.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-paren'+(this.side===Se?" mq-ghost":"")+'">'+this.sides[Qe].ch+'</span><span class="mq-non-leaf">&0</span><span class="mq-scaled mq-paren'+(this.side===Qe?" mq-ghost":"")+'">'+this.sides[Se].ch+"</span></span>",n.html.call(this)},e.latex=function(){return"\\left"+this.sides[Qe].ctrlSeq+this.ends[Qe].latex()+"\\right"+this.sides[Se].ctrlSeq},e.oppBrack=function(t,e){return t instanceof de&&t.side&&t.side!==-e&&("|"===this.sides[this.side].ch||t.side===-this.side)&&t},e.closeOpposing=function(t){t.side=0,t.sides[this.side]=this.sides[this.side],t.delimjQs.eq(this.side===Qe?0:1).removeClass("mq-ghost").html(this.sides[this.side].ch)},e.createLeftOf=function(t){var e,i,s,r,o,a;if(!this.replacedFragment&&(e=this.oppBrack(t[Qe],Qe)||this.oppBrack(t[Se],Se)||this.oppBrack(t.parent.parent),!e&&t.options.enableMatrixShortcuts&&"\\left["===this.ctrlSeq&&0===t[Qe]&&0===t[Se]&&"undefined"!=typeof t.parent.parent&&t.parent.parent.ctrlSeq===this.ctrlSeq)){if(i=t.parent.parent[Qe],s=t.parent.parent.parent,t.parent.parent.unwrap(),0!==i?t.insRightOf(i):t.insAtLeftEnd(s),t.options.autoOnBrackets)for(r=t[Qe];r instanceof I;)r.jQ.hasClass("mq-operator-name")&&r.italicize(!0),r.ctrlSeq=r.ctrlSeq.replace("\\","").replace("operatorname{","").replace("}","").trim(),r=r[Qe];return o=fe("\\bmatrix",1,1),void o.createLeftOf(t)}e?(a=this.side=-e.side,this.closeOpposing(e),e===t.parent.parent&&t[a]&&(_e(t[a],t.parent.ends[a],-a).disown().withDirAdopt(-a,e.parent,e,e[a]).jQ.insDirOf(a,e.jQ),e.bubble("reflow"))):(e=this,a=e.side,e.replacedFragment?e.side=0:t[-a]&&(e.replaces(_e(t[-a],t.parent.ends[-a],a)),t[-a]=0),n.createLeftOf.call(e,t)),a===Qe?t.insAtLeftEnd(e.ends[Qe]):t.insRightOf(e),t.parent.bubble("workingGroupChange")},e.placeCursor=t,e.unwrap=function(){this.ends[Qe].children().disown().adopt(this.parent,this,this[Se]).jQ.insertAfter(this.jQ),this.remove()},e.deleteSide=function(t,e,n){var i,s=this.parent,r=this[t],o=s.ends[t];return t===this.side?(this.unwrap(),void(r?n.insDirOf(-t,r):n.insAtDirEnd(t,s))):(this.side=-t,void(this.oppBrack(this.ends[Qe].ends[this.side],t)?(this.closeOpposing(this.ends[Qe].ends[this.side]),i=this.ends[Qe].ends[t],this.unwrap(),i.siblingCreated&&i.siblingCreated(n.options,t),r?n.insDirOf(-t,r):n.insAtDirEnd(t,s)):(this.oppBrack(this.parent.parent,t)?(this.parent.parent.closeOpposing(this),this.parent.parent.unwrap()):(this.sides[t]={ch:me[this.sides[this.side].ch],ctrlSeq:me[this.sides[this.side].ctrlSeq]},this.delimjQs.removeClass("mq-ghost").eq(t===Qe?0:1).addClass("mq-ghost").html(this.sides[t].ch)),r?(i=this.ends[Qe].ends[t],_e(r,o,-t).disown().withDirAdopt(-t,this.ends[Qe],i,0).jQ.insAtDirEnd(t,this.ends[Qe].jQ.removeClass("mq-empty")),i.siblingCreated&&i.siblingCreated(n.options,t),n.insDirOf(-t,r)):e?n.insDirOf(t,this):n.insAtDirEnd(t,this.ends[Qe]))))},e.deleteTowards=function(t,e){this.deleteSide(-t,!1,e)},e.finalizeTree=function(t){this.ends[Qe].deleteOutOf=function(t,e){this.parent.deleteSide(t,!0,e)},t.autoOnBrackets&&this[Qe]instanceof I&&this[Qe].autoUnItalicize(t,"\\left["!==this.ctrlSeq),this.finalizeTree=this.intentionalBlur=function(){this.delimjQs.eq(this.side===Qe?1:0).removeClass("mq-ghost"),this.side=0}},e.siblingCreated=function(t,e){e===-this.side&&this.finalizeTree()}}),me={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","\\{":"\\}","\\}":"\\{","&lang;":"&rang;","&rang;":"&lang;","\\langle ":"\\rangle ","\\rangle ":"\\langle ","|":"|"},f("("),f("["),f("{","\\{"),Le.langle=i(de,Qe,"&lang;","&rang;","\\langle ","\\rangle "),Le.rangle=i(de,Se,"&lang;","&rang;","\\langle ","\\rangle "),Ee["|"]=i(de,Qe,"|","|","|","|"),Le.left=je(y,function(t){t.parser=function(){var t=q.regex,e=q.string,n=(q.succeed,q.optWhitespace);return n.then(t(/^(?:[([|]|\\\{)/)).then(function(i){var s="\\"===i.charAt(0)?i.slice(1):i;return k.then(function(r){return e("\\right").skip(n).then(t(/^(?:[\])|]|\\\})/)).map(function(t){var e="\\"===t.charAt(0)?t.slice(1):t,n=de(0,s,e,i,t);return n.blocks=[r],r.adopt(n,0,0),n})})})}}),Le.right=je(y,function(t){t.parser=function(){return q.fail("unmatched \\right")}}),ge=Le.binom=Le.binomial=je(je(y,p),function(t){t.ctrlSeq="\\binom",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-paren mq-scaled">(</span><span class="mq-non-leaf"><span class="mq-array mq-non-leaf"><span>&0</span><span>&1</span></span></span><span class="mq-paren mq-scaled">)</span></span>',t.textTemplate=["choose(",",",")"]}),be=Le.choose=je(ge,function(t){t.createLeftOf=ce.prototype.createLeftOf}),ve=je(a.MathField,function(t){t.init=function(t,e){c(t),this.__options=g();var n=ze(this,t,e);n.editable=!0,n.createTextarea(),n.editablesTextareaEvents(),n.cursor.insAtRightEnd(t)}}),Le.MathQuillMathField=je(y,function(t,e){t.ctrlSeq="\\MathQuillMathField",t.htmlTemplate='<span class="mq-editable-field"><span class="mq-root-block">&0</span></span>',t.parser=function(){var t=this,n=q.string,i=q.regex,s=q.succeed;return n("[").then(i(/^[a-z][a-z0-9]*/i)).skip(n("]")).map(function(e){t.name=e}).or(s()).then(e.parser.call(t))},t.finalizeTree=function(){ve(this.ends[Qe],this.jQ)},t.registerInnerField=function(t){t.push(t[this.name]=this.ends[Qe].controller.API)},t.latex=function(){return this.ends[Qe].latex()},t.text=function(t){return this.ends[Qe].text(t)}})}();
1
+ !function(){function t(){}function e(t){var e=t.length-1;return function(){var n=ye.call(arguments,0,e),i=ye.call(arguments,e);return t.apply(this,n.concat([i]))}}function n(t){return e(function(e,n){"function"!=typeof e&&(e=je(e));var i=function(t){return e.apply(t,[t].concat(n))};return t.call(this,i)})}function i(t){var e=ye.call(arguments,1);return function(){return t.apply(this,e)}}function s(t,e){if(!e)throw new Error("prayer failed: "+t)}function r(t){s("a direction was passed",t===Te||t===Qe)}function o(t,e,n){s("a parent is always present",t),s("leftward is properly set up",function(){return e?e[Qe]===n&&e.parent===t:t.ends[Te]===n}()),s("rightward is properly set up",function(){return n?n[Te]===e&&n.parent===t:t.ends[Qe]===e}())}function a(t){if(!t||!t.nodeType)return null;var e=Se(t).children(".mq-root-block").attr(qe);return e?De.byId[e].controller.API:null}function l(t){function e(e,n){var i=a(e);return i instanceof t||!e||!e.nodeType?i:t(Se(e),n)}return e.prototype=t.prototype,e}function c(t){var e,n="workingGroupChange moveOutOf deleteOutOf selectOutOf upOutOf downOutOf reflow".split(" ");for(e=0;e<n.length;e+=1)(function(e){t[e]=function(t){this.controller.handle(e,t)}})(n[e])}function h(t,e,n){return Ce(A,{ctrlSeq:t,htmlTemplate:"<"+e+" "+n+">&0</"+e+">"})}function u(t){var e=this.parent,n=t;do{if(n[Qe])return t.insLeftOf(e);n=n.parent.parent}while(n!==e);t.insRightOf(e)}function p(t,e){t.jQadd=function(){e.jQadd.apply(this,arguments),this.delimjQs=this.jQ.children(":first").add(this.jQ.children(":last")),this.contentjQ=this.jQ.children(":eq(1)")},t.reflow=function(){var t=this.contentjQ.outerHeight()/parseInt(this.contentjQ.css("fontSize"),10);X(this.delimjQs,ke(1+.2*(t-1),1.2),1.05*t)}}function f(t,e){var e=e||t,n=me[t],s=me[e];Ee[t]=i(de,Te,t,n,e,s,e,s),Ee[n]=i(de,Qe,t,n,e,s,e,s)}var d,m,g,b,v,w,x,q,k,O,y,j,C,T,Q,S,A,D,L,_,E,R,I,z,B,$,M,P,F,N,G,U,W,H,V,X,Z,K,Y,J,te,ee,ne,ie,se,re,oe,ae,le,ce,he,ue,pe,fe,de,me,ge,be,ve,we=window.jQuery,xe="mathquill-command-id",qe="mathquill-block-id",ke=Math.min,Oe=Math.max,ye=[].slice,je=e(function(t,n){return e(function(e,i){return t in e?e[t].apply(e,n.concat(i)):void 0})}),Ce=function(t,e,n){function i(t){return"object"==typeof t}function s(t){return"function"==typeof t}function r(){}return function o(a,l){function c(){var t=new h;return s(t.init)&&t.init.apply(t,arguments),t}function h(){}var u,p,f;return l===n&&(l=a,a=Object),c.Bare=h,u=r[t]=a[t],p=h[t]=c[t]=c.p=new r,p.constructor=c,c.mixin=function(e){return h[t]=c[t]=o(c,e)[t],c},(c.open=function(t){if(f={},s(t)?f=t.call(c,p,u,c,a):i(t)&&(f=t),i(f))for(var n in f)e.call(f,n)&&(p[n]=f[n]);return s(p.init)||(p.init=a),c})(l)}}("prototype",{}.hasOwnProperty),Te=a.L=-1,Qe=a.R=1,Se=Ce(we,function(t){t.insDirOf=function(t,e){return t===Te?this.insertBefore(e.first()):this.insertAfter(e.last())},t.insAtDirEnd=function(t,e){return t===Te?this.prependTo(e):this.appendTo(e)}}),Ae=Ce(function(t){t.parent=0,t[Te]=0,t[Qe]=0,t.init=function(t,e,n){this.parent=t,this[Te]=e,this[Qe]=n},this.copy=function(t){return Ae(t.parent,t[Te],t[Qe])}}),De=Ce(function(t){function e(){return i+=1}t[Te]=0,t[Qe]=0,t.parent=0;var i=0;this.byId={},t.init=function(){this.id=e(),De.byId[this.id]=this,this.ends={},this.ends[Te]=0,this.ends[Qe]=0},t.dispose=function(){delete De.byId[this.id]},t.toString=function(){return"{{ MathQuill Node #"+this.id+" }}"},t.jQ=Se(),t.jQadd=function(t){return this.jQ=this.jQ.add(t)},t.jQize=function(t){function e(t){var n,i;for(t.getAttribute&&(n=t.getAttribute("mathquill-command-id"),i=t.getAttribute("mathquill-block-id"),n&&De.byId[n].jQadd(t),i&&De.byId[i].jQadd(t)),t=t.firstChild;t;t=t.nextSibling)e(t)}var n;for(t=Se(t||this.html()),n=0;n<t.length;n+=1)e(t[n]);return t},t.createDir=function(t,e){r(t);var n=this;return n.jQize(),n.jQ.insDirOf(t,e.jQ),e[t]=n.adopt(e.parent,e[Te],e[Qe]),n},t.createLeftOf=function(t){return this.createDir(Te,t)},t.selectChildren=function(t,e){return Ie(t,e)},t.bubble=n(function(t){var e,n;for(e=this;e&&(n=t(e),n!==!1);e=e.parent);return this}),t.postOrder=n(function(t){return function e(n){n.eachChild(e),t(n)}(this),this}),t.isEmpty=function(){return 0===this.ends[Te]&&0===this.ends[Qe]},t.children=function(){return Le(this.ends[Te],this.ends[Qe])},t.eachChild=function(){var t=this.children();return t.each.apply(t,arguments),this},t.foldChildren=function(t,e){return this.children().fold(t,e)},t.withDirAdopt=function(t,e,n,i){return Le(this,this).withDirAdopt(t,e,n,i),this},t.adopt=function(t,e,n){return Le(this,this).adopt(t,e,n),this},t.disown=function(){return Le(this,this).disown(),this},t.remove=function(){return this.jQ.remove(),this.postOrder("dispose"),this.disown()}}),Le=Ce(function(t){t.init=function(t,e,n){n===d&&(n=Te),r(n),s("no half-empty fragments",!t==!e),this.ends={},t&&(s("withDir is passed to Fragment",t instanceof De),s("oppDir is passed to Fragment",e instanceof De),s("withDir and oppDir have the same parent",t.parent===e.parent),this.ends[n]=t,this.ends[-n]=e,this.jQ=this.fold(this.jQ,function(t,e){return t.add(e.jQ)}))},t.jQ=Se(),t.withDirAdopt=function(t,e,n,i){return t===Te?this.adopt(e,n,i):this.adopt(e,i,n)},t.adopt=function(t,e,n){var i,s,r;return o(t,e,n),i=this,i.disowned=!1,(s=i.ends[Te])?(r=i.ends[Qe],e||(t.ends[Te]=s),n?n[Te]=r:t.ends[Qe]=r,i.ends[Qe][Qe]=n,i.each(function(n){n[Te]=e,n.parent=t,e&&(e[Qe]=n),e=n}),i):this},t.disown=function(){var t,e,n=this,i=n.ends[Te];return!i||n.disowned?n:(n.disowned=!0,t=n.ends[Qe],e=i.parent,o(e,i[Te],i),o(e,t,t[Qe]),i[Te]?i[Te][Qe]=t[Qe]:e.ends[Te]=t[Qe],t[Qe]?t[Qe][Te]=i[Te]:e.ends[Qe]=i[Te],n)},t.remove=function(){return this.jQ.remove(),this.each("postOrder","dispose"),this.disown()},t.each=n(function(t){var e,n=this,i=n.ends[Te];if(!i)return n;for(;i!==n.ends[Qe][Qe]&&(e=t(i),e!==!1);i=i[Qe]);return n}),t.fold=function(t,e){return this.each(function(n){t=e.call(this,t,n)}),t}}),_e={},Ee={},Re=Ce(Ae,function(t){t.init=function(t,e){this.parent=t,this.options=e;var n=this.jQ=this._jQ=Se('<span class="mq-cursor">&#8203;</span>');this.blink=function(){n.toggleClass("mq-blink")},this.upDownCache={}},t.show=function(){return this.jQ=this._jQ.removeClass("mq-blink"),"intervalId"in this?clearInterval(this.intervalId):(this[Qe]?this.jQ.insertBefore(this.selection&&this.selection.ends[Te][Te]===this[Te]?this.selection.jQ:this[Qe].jQ.first()):this.jQ.appendTo(this.parent.jQ),this.parent.focus()),this.intervalId=setInterval(this.blink,500),this},t.hide=function(){return"intervalId"in this&&clearInterval(this.intervalId),delete this.intervalId,this.jQ.detach(),this.jQ=Se(),this},t.withDirInsertAt=function(t,e,n,i){e!==this.parent&&this.parent.blur&&this.parent.blur(),this.parent=e,this[t]=n,this[-t]=i},t.insDirOf=function(t,e){return r(t),this.withDirInsertAt(t,e.parent,e[t],e),this.parent.jQ.addClass("mq-hasCursor"),this.jQ.insDirOf(t,e.jQ),this},t.insLeftOf=function(t){return this.insDirOf(Te,t)},t.insRightOf=function(t){return this.insDirOf(Qe,t)},t.insAtDirEnd=function(t,e){return r(t),this.withDirInsertAt(t,e,0,e.ends[t]),this.jQ.insAtDirEnd(t,e.jQ),e.focus(),this},t.insAtLeftEnd=function(t){return this.insAtDirEnd(Te,t)},t.insAtRightEnd=function(t){return this.insAtDirEnd(Qe,t)},t.jumpUpDown=function(t,e){var n,i,s=this;s.upDownCache[t.id]=Ae.copy(s),n=s.upDownCache[e.id],n?n[Qe]?s.insLeftOf(n[Qe]):s.insAtRightEnd(n.parent):(i=s.offset().left,e.seek(i,s))},t.offset=function(){var t=this,e=t.jQ.removeClass("mq-cursor").offset();return t.jQ.addClass("mq-cursor"),e},t.unwrapGramp=function(){var t=this.parent.parent,e=t.parent,n=t[Qe],i=this,s=t[Te];if(t.disown().eachChild(function(i){i.isEmpty()||(i.children().adopt(e,s,n).each(function(e){e.jQ.insertBefore(t.jQ.first())}),s=i.ends[Qe])}),!this[Qe])if(this[Te])this[Qe]=this[Te][Qe];else for(;!this[Qe];){if(this.parent=this.parent[Qe],!this.parent){this[Qe]=t[Qe],this.parent=e;break}this[Qe]=this.parent.ends[Te]}this[Qe]?this.insLeftOf(this[Qe]):this.insAtRightEnd(e),t.jQ.remove(),t[Te].siblingDeleted&&t[Te].siblingDeleted(i.options,Qe),t[Qe].siblingDeleted&&t[Qe].siblingDeleted(i.options,Te)},t.startSelection=function(){var t,e=this.anticursor=Ae.copy(this),n=e.ancestors={};for(t=e;t.parent;t=t.parent)n[t.parent.id]=t},t.endSelection=function(){delete this.anticursor},t.select=function(){var t,e,n,i,r,o,a,l=this.anticursor;if(this[Te]===l[Te]&&this.parent===l.parent)return!1;for(t=this;t.parent;t=t.parent)if(t.parent.id in l.ancestors){e=t.parent;break}if(s("cursor and anticursor in the same tree",e),n=l.ancestors[e.id],o=Qe,t[Te]!==n)for(a=t;a;a=a[Qe])if(a[Qe]===n[Qe]){o=Te,i=t,r=n;break}return o===Qe&&(i=n,r=t),i instanceof Ae&&(i=i[Qe]),r instanceof Ae&&(r=r[Te]),this.hide().selection=e.selectChildren(i,r),this.insDirOf(o,this.selection.ends[o]),this.selectionChanged(),!0},t.clearSelection=function(){return this.selection&&(this.selection.clear(),delete this.selection,this.selectionChanged()),this},t.deleteSelection=function(){this.selection&&(this[Te]=this.selection.ends[Te][Te],this[Qe]=this.selection.ends[Qe][Qe],this.selection.remove(),this.selectionChanged(),delete this.selection)},t.replaceSelection=function(){var t=this.selection;return t&&(this[Te]=t.ends[Te][Te],this[Qe]=t.ends[Qe][Qe],delete this.selection),t}}),Ie=Ce(Le,function(t,e){t.init=function(){e.init.apply(this,arguments),this.jQ=this.jQ.wrapAll('<span class="mq-selection"></span>').parent()},t.adopt=function(){return this.jQ.replaceWith(this.jQ=this.jQ.children()),e.adopt.apply(this,arguments)},t.clear=function(){return this.jQ.replaceWith(this.jQ[0].childNodes),this},t.join=function(t){return this.fold("",function(e,n){return e+n[t]()})}}),ze=Ce(function(t){t.init=function(t,e,n){this.API=t,this.root=e,this.container=n,t.__controller=e.controller=this,this.cursor=e.cursor=Re(e,t.__options)},t.handle=function(t,e){var n=this.API.__options.handlers;n&&n[t]&&(e===Te||e===Qe?n[t](e,this.API):n[t](this.API))};var e=[];this.onNotify=function(t){e.push(t)},t.notify=function(){for(var t=0;t<e.length;t+=1)e[t].apply(this.cursor,arguments);return this}});a.noConflict=function(){return window.MathQuill=m,a},m=window.MathQuill,window.MathQuill=a,g=Ce(),b={},a.__options=g.p,v=Ce(function(t){t.init=function(){throw"wtf don't call me, I'm 'abstract'"},t.initRoot=function(t,e,n){var i,s;this.__options=g(),this.config(n),i=ze(this,t,e),i.createTextarea(),s=e.contents().detach(),t.jQ=Se('<span class="mq-root-block"/>').attr(qe,t.id).appendTo(e),this.latex(s.text()),this.revert=function(){return e.empty().unbind(".mathquill").removeClass("mq-editable-field mq-math-mode mq-text-mode").append(s)}},t.config=a.config=function(t){var e,n,i;for(e in t)t.hasOwnProperty(e)&&(n=t[e],i=b[e],this.__options[e]=i?i(n):n);return this},t.el=function(){return this.__controller.container[0]},t.text=function(){return this.__controller.exportText(this.__options)},t.latex=function(t){return arguments.length>0?(this.__controller.renderLatexMath(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this):this.__controller.exportLatex()},t.html=function(){return this.__controller.root.jQ.html().replace(/ mathquill-(?:command|block)-id="?\d+"?/g,"").replace(/<span class="?mq-cursor( mq-blink)?"?>.?<\/span>/i,"").replace(/ mq-hasCursor|mq-hasCursor ?/,"").replace(/ class=(""|(?= |>))/g,"")},t.reflow=function(){return this.__controller.root.postOrder("reflow"),this}}),a.prototype=v.prototype,a.StaticMath=l(Ce(v,function(t,e){t.init=function(t){this.initRoot(Q(),t.addClass("mq-math-mode")),this.__controller.delegateMouseEvents(),this.__controller.staticMathTextareaEvents()},t.latex=function(){var t=e.latex.apply(this,arguments);return arguments.length>0&&this.__controller.root.postOrder("registerInnerField",this.innerFields=[]),t}})),w=a.EditableField=Ce(v,function(e){e.initRootAndEvents=function(t,e,n){this.initRoot(t,e,n),this.__controller.editable=!0,this.__controller.delegateMouseEvents(),this.__controller.editablesTextareaEvents()},e.focus=function(){return this.__controller.textarea.focus(),this},e.blur=function(){return this.__controller.textarea.blur(),this},e.write=function(t){return this.__controller.writeLatex(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this},e.cmd=function(t){var e,n=this.__controller.notify(),i=n.cursor.show();return/^\\[a-z]+$/i.test(t)?(t=t.slice(1),e=_e[t],e&&(t=e(t),i.selection&&t.replaces(i.replaceSelection()),t.createLeftOf(i))):i.parent.write(i,t,i.replaceSelection()),n.blurred&&i.hide().parent.blur(),this},e.select=function(){var t=this.__controller;for(t.notify("move").cursor.insAtRightEnd(t.root);t.cursor[Te];)t.selectLeft();return this},e.clearSelection=function(){return this.__controller.cursor.clearSelection(),this},e.moveToDirEnd=function(t){return this.__controller.notify("move").cursor.insAtDirEnd(t,this.__controller.root),this},e.moveToLeftEnd=function(){return this.moveToDirEnd(Te)},e.moveToRightEnd=function(){return this.moveToDirEnd(Qe)},e.keystroke=function(e){var n;for(e=e.replace(/^\s+|\s+$/g,"").split(/\s+/),n=0;n<e.length;n+=1)this.__controller.keystroke(e[n],{preventDefault:t});return this},e.typedText=function(t){for(var e=0;e<t.length;e+=1)this.__controller.typedText(t.charAt(e));return this}}),x=Ce(function(t,e,n){function i(t,e){throw t=t?"'"+t+"'":"EOF","Parse Error: "+e+" at "+t}var r,o,a,l,c,h,u,p,f,d,m,g,b;t.init=function(t){this._=t},t.parse=function(t){function e(t,e){return e}return this.skip(b)._(t,e,i)},t.or=function(t){s("or is passed a parser",t instanceof n);var e=this;return n(function(n,i,s){function r(){return t._(n,i,s)}return e._(n,i,r)})},t.then=function(t){var e=this;return n(function(i,r,o){function a(e,i){var a=t instanceof n?t:t(i);return s("a parser is returned",a instanceof n),a._(e,r,o)}return e._(i,a,o)})},t.many=function(){var t=this;return n(function(e,n){function i(t,n){return e=t,r.push(n),!0}function s(){return!1}for(var r=[];t._(e,i,s););return n(e,r)})},t.times=function(t,e){arguments.length<2&&(e=t);var i=this;return n(function(n,s,r){function o(t,e){return u.push(e),n=t,!0}function a(t,e){return c=e,n=t,!1}function l(){return!1}var c,h,u=[],p=!0;for(h=0;t>h;h+=1)if(p=i._(n,o,a),!p)return r(n,c);for(;e>h&&p;h+=1)p=i._(n,o,l);return s(n,u)})},t.result=function(t){return this.then(a(t))},t.atMost=function(t){return this.times(0,t)},t.atLeast=function(t){var e=this;return e.times(t).then(function(t){return e.many().map(function(e){return t.concat(e)})})},t.map=function(t){return this.then(function(e){return a(t(e))})},t.skip=function(t){return this.then(function(e){return t.result(e)})},r=this.string=function(t){var e=t.length,i="expected '"+t+"'";return n(function(n,s,r){var o=n.slice(0,e);return o===t?s(n.slice(e),o):r(n,i)})},o=this.regex=function(t){s("regexp parser is anchored","^"===t.toString().charAt(1));var e="expected "+t;return n(function(n,i,s){var r,o=t.exec(n);return o?(r=o[0],i(n.slice(r.length),r)):s(n,e)})},a=n.succeed=function(t){return n(function(e,n){return n(e,t)})},l=n.fail=function(t){return n(function(e,n,i){return i(e,t)})},c=n.letter=o(/^[a-z]/i),h=n.letters=o(/^[a-z]*/i),u=n.digit=o(/^[0-9]/),p=n.digits=o(/^[0-9]*/),f=n.whitespace=o(/^\s+/),d=n.optWhitespace=o(/^\s*/),m=n.any=n(function(t,e,n){return t?e(t.slice(1),t.charAt(0)):n(t,"expected any character")}),g=n.all=n(function(t,e){return e("",t)}),b=n.eof=n(function(t,e,n){return t?n(t,"expected EOF"):e(t,t)})}),q=function(){function e(t){var e,i=t.which||t.keyCode,s=n[i],r=[];return t.ctrlKey&&r.push("Ctrl"),t.originalEvent&&t.originalEvent.metaKey&&r.push("Meta"),t.altKey&&r.push("Alt"),t.shiftKey&&r.push("Shift"),e=s||String.fromCharCode(i),r.length||s?(r.push(e),r.join("-")):e}var n={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"};return function(n,i){function s(t){x=t,clearTimeout(d),d=setTimeout(t)}function r(e){x(),x=t,clearTimeout(d),v.val(e),e&&v[0].select(),m=!!e}function o(){var t=v[0];return"selectionStart"in t?t.selectionStart!==t.selectionEnd:!1}function a(){i.keystroke(e(g),g)}function l(e){g=e,b=null,a(),m&&s(function(){v[0].select(),x=t,clearTimeout(d)})}function c(t){g&&b&&a(),b=t,s(h)}function h(){if(!o()){var t=v.val();1===t.length?(v.val(""),i.typedText(t)):t&&v[0].select()}}function u(){g=b=null}function p(){v.focus(),s(f)}function f(){var t=v.val();v.val(""),t&&i.paste(t)}var d,m,g=null,b=null,v=we(n),w=we(i.container||v),x=t;return w.bind("keydown keypress input keyup focusout paste",function(){x()}),m=!1,w.bind({keydown:l,keypress:c,focusout:u,paste:p}),{select:r}}}(),ze.open(function(t){t.exportText=function(t){return this.root.foldChildren("",function(e,n){return e+n.text(t)})}}),ze.open(function(t){t.focusBlurEvents=function(){function t(){clearTimeout(n),r.selection&&r.selection.jQ.addClass("mq-blur"),e()}function e(){r.hide().parent.blur(),i.container.removeClass("mq-focused"),Se(window).off("blur",t)}var n,i=this,s=i.root,r=i.cursor;i.textarea.focus(function(){i.blurred=!1,clearTimeout(n),i.container.addClass("mq-focused"),r.parent||r.insAtRightEnd(s),r.selection?(r.selection.jQ.removeClass("mq-blur"),i.selectionChanged()):r.show()}).blur(function(){i.blurred=!0,n=setTimeout(function(){s.postOrder("intentionalBlur"),r.clearSelection(),e()}),Se(window).on("blur",t)}),i.blurred=!0,r.hide().parent.blur()}}),ze.open(function(t){t.keystroke=function(t,e){this.cursor.parent.keystroke(t,e,this)}}),De.open(function(t){t.keystroke=function(t,e,n){var i=n.cursor;switch(t){case"Ctrl-Shift-Backspace":case"Ctrl-Backspace":for(;i[Te]||i.selection;)n.backspace();break;case"Shift-Backspace":case"Backspace":n.backspace();break;case"Esc":case"Tab":return void n.escapeDir(Qe,t,e);case"Shift-Tab":case"Shift-Esc":return void n.escapeDir(Te,t,e);case"End":n.notify("move").cursor.insAtRightEnd(i.parent);break;case"Ctrl-End":n.notify("move").cursor.insAtRightEnd(n.root);break;case"Shift-End":for(;i[Qe];)n.selectRight();break;case"Ctrl-Shift-End":for(;i[Qe]||i.parent!==n.root;)n.selectRight();break;case"Home":n.notify("move").cursor.insAtLeftEnd(i.parent);break;case"Ctrl-Home":n.notify("move").cursor.insAtLeftEnd(n.root);break;case"Shift-Home":for(;i[Te];)n.selectLeft();break;case"Ctrl-Shift-Home":for(;i[Te]||i.parent!==n.root;)n.selectLeft();break;case"Left":n.moveLeft();break;case"Shift-Left":n.selectLeft();break;case"Ctrl-Left":break;case"Right":n.moveRight();break;case"Shift-Right":n.selectRight();break;case"Ctrl-Right":break;case"Up":n.moveUp();break;case"Down":n.moveDown();break;case"Shift-Up":if(i[Te])for(;i[Te];)n.selectLeft();else n.selectLeft();case"Shift-Down":if(i[Qe])for(;i[Qe];)n.selectRight();else n.selectRight();case"Ctrl-Up":break;case"Ctrl-Down":break;case"Ctrl-Shift-Del":case"Ctrl-Del":for(;i[Qe]||i.selection;)n.deleteForward();break;case"Shift-Del":case"Del":n.deleteForward();break;case"Meta-A":case"Ctrl-A":for(n.notify("move").cursor.insAtRightEnd(n.root);i[Te];)n.selectLeft();break;default:return}e.preventDefault(),n.scrollHoriz()},t.moveOutOf=t.moveTowards=t.deleteOutOf=t.deleteTowards=t.unselectInto=t.selectOutOf=t.selectTowards=function(){s("overridden or never called on this node")}}),ze.open(function(t){function e(t,e){var n=t.notify("upDown").cursor,i=e+"Into",s=e+"OutOf";return n[Qe][i]?n.insAtLeftEnd(n[Qe][i]):n[Te][i]?n.insAtRightEnd(n[Te][i]):n.parent.bubble(function(t){var e=t[s];return e&&("function"==typeof e&&(e=t[s](n)),e instanceof De&&n.jumpUpDown(t,e),e!==!0)?!1:void 0}),n.parent.bubble("workingGroupChange"),t}this.onNotify(function(t){("move"===t||"upDown"===t)&&this.show().clearSelection()}),t.escapeDir=function(t,e,n){r(t);var i=this.cursor;return i.parent!==this.root&&n.preventDefault(),i.parent!==this.root?(i.parent.moveOutOf(t,i),i.parent.bubble("workingGroupChange"),this.notify("move")):void 0},b.leftRightIntoCmdGoes=function(t){if(t&&"up"!==t&&"down"!==t)throw'"up" or "down" required for leftRightIntoCmdGoes option, got "'+t+'"';return t},t.moveDir=function(t){r(t);var e=this.cursor,n=e.options.leftRightIntoCmdGoes;return e.selection?e.insDirOf(t,e.selection.ends[t]):e[t]?e[t].moveTowards(t,e,n):e.parent.moveOutOf(t,e,n),e.parent.bubble("workingGroupChange"),this.notify("move")},t.moveLeft=function(){return this.moveDir(Te)},t.moveRight=function(){return this.moveDir(Qe)},t.moveUp=function(){return e(this,"up")},t.moveDown=function(){return e(this,"down")},this.onNotify(function(t){"upDown"!==t&&(this.upDownCache={})}),this.onNotify(function(t){"edit"===t&&this.show().deleteSelection()}),t.deleteDir=function(t){var e,n;return r(t),e=this.cursor,n=e.selection,this.notify("edit"),n||(e[t]?e[t].deleteTowards(t,e):e.parent.deleteOutOf(t,e)),e[Te].siblingDeleted&&e[Te].siblingDeleted(e.options,Qe),e[Qe].siblingDeleted&&e[Qe].siblingDeleted(e.options,Te),e.parent.bubble("reflow"),e.parent.bubble("workingGroupChange"),this},t.backspace=function(){return this.deleteDir(Te)},t.deleteForward=function(){return this.deleteDir(Qe)},this.onNotify(function(t){"select"!==t&&this.endSelection()}),t.selectDir=function(t){var e,n=this.notify("select").cursor,i=n.selection;r(t),n.anticursor||n.startSelection(),e=n[t],e?i&&i.ends[t]===e&&n.anticursor[-t]!==e?e.unselectInto(t,n):e.selectTowards(t,n):n.parent.selectOutOf(t,n),n.clearSelection(),n.select()||n.show()},t.selectLeft=function(){return this.selectDir(Te)},t.selectRight=function(){return this.selectDir(Qe)}}),k=function(){function t(t){var e,n,i=Q();if(t instanceof I&&t.ctrlSeq.length>1)for(e=t.ctrlSeq,n=0;n<e.length;n+=1)I(e[n]).adopt(i,i.ends[Qe],0);else t.adopt(i,0,0);return i}function e(t){var e,n=t[0]||Q();for(e=1;e<t.length;e+=1)t[e].children().adopt(n,n.ends[Qe],0);return n}var n=x.string,i=x.regex,s=(x.letter,x.any),r=x.optWhitespace,o=x.succeed,a=x.fail,l=i(/^[a-z]+[0-9]*/i).map(function(t){return I(t)}),c=i(/^[^${}\\_^]/).map(function(t){return C(t)}),h=i(/^[^\\a-eg-zA-Z]/).or(n("\\").then(i(/^[a-z]+/i).or(i(/^\s+/).result(" ")).or(s))).then(function(t){var e=_e[t];return e?e(t).parser():a("unknown command: \\"+t)}),u=h.or(l).or(c),p=n("{").then(function(){return d}).skip(n("}")),f=r.then(p.or(u.map(t))),d=f.many().map(e).skip(r),m=n("[").then(f.then(function(t){return"]"!==t.join("latex")?o(t):a()}).many().map(e).skip(r)).skip(n("]")),g=d;return g.block=f,g.optBlock=m,g}(),ze.open(function(t){t.exportLatex=function(){return this.root.latex().replace(/(\\[a-z]+) (?![a-z])/gi,"$1")},t.writeLatex=function(t){var e,n=this.notify("edit").cursor,i=x.all,s=x.eof,r=k.skip(s).or(i.result(!1)).parse(t);return r&&!r.isEmpty()&&(r.children().adopt(n.parent,n[Te],n[Qe]),e=r.jQize(),e.insertBefore(n.jQ),n[Te]=r.ends[Qe],r.finalizeInsert(n.options,n),r.ends[Qe][Qe].siblingCreated&&r.ends[Qe][Qe].siblingCreated(n.options,Te),r.ends[Te][Te].siblingCreated&&r.ends[Te][Te].siblingCreated(n.options,Qe),n.parent.bubble("reflow")),this},t.renderLatexMath=function(t){var e,n,i=this.root,s=this.cursor,r=x.all,o=x.eof,a=k.skip(o).or(r.result(!1)).parse(t);i.eachChild("postOrder","dispose"),i.ends[Te]=i.ends[Qe]=0,a&&a.children().adopt(i,0,0),e=i.jQ,a?(n=a.join("html"),e.html(n),i.jQize(e.children()),i.finalizeInsert(s.options)):e.empty(),delete s.selection,s.insAtRightEnd(i)},t.renderLatexText=function(t){var e,n,i,s,r,o,a,l,c,h,u=this.root,p=this.cursor;if(u.jQ.children().slice(1).remove(),u.eachChild("postOrder","dispose"),u.ends[Te]=u.ends[Qe]=0,delete p.selection,p.show().insAtRightEnd(u),e=x.regex,n=x.string,i=x.eof,s=x.all,r=n("$").then(k).skip(n("$").or(i)).map(function(t){var e,n=L(p);return n.createBlocks(),e=n.ends[Te],t.children().adopt(e,0,0),n}),o=n("\\$").result("$"),a=o.or(e(/^[^$]/)).map(C),l=r.or(a).many(),c=l.skip(i).or(s.result(!1)).parse(t)){for(h=0;h<c.length;h+=1)c[h].adopt(u,u.ends[Qe],0);u.jQize().appendTo(u.jQ),u.finalizeInsert(p.options)}}}),ze.open(function(e){e.delegateMouseEvents=function(){var e=this.root.jQ;this.container.bind("contextmenu.mathquill",function(t){for(var n=Se(t.target).closest(".mq-root-block"),i=De.byId[n.attr(qe)||e.attr(qe)],s=i.controller,r=s.cursor,o=s.seek(Se(t.target),t.pageX,t.pageY).cursor.parent;!(o instanceof y);)if(o=o.parent,"undefined"==typeof o){o=i;break}return o.contextMenu(r,t),t.preventDefault(),!1}),this.container.bind("mousedown.mathquill",function(n){function i(t){o=Se(t.target)}function s(t){h.anticursor||h.startSelection(),c.seek(o,t.pageX,t.pageY).cursor.select(),o=d}function r(t){h.blink=u,h.selection||(c.editable?h.show():p.detach()),a.unbind("mousemove",i),Se(t.target.ownerDocument).unbind("mousemove",s).unbind("mouseup",r)}var o,a=Se(n.target).closest(".mq-root-block"),l=De.byId[a.attr(qe)||e.attr(qe)],c=l.controller,h=c.cursor,u=h.blink,p=c.textareaSpan,f=c.textarea;c.blurred&&(c.editable||a.prepend(p),f.focus()),n.preventDefault(),n.target.unselectable=!0,h.blink=t,c.seek(Se(n.target),n.pageX,n.pageY).cursor.startSelection(),a.mousemove(i),Se(n.target.ownerDocument).mousemove(s).mouseup(r)})}}),ze.open(function(t){t.seek=function(t,e){var n,i,r,o=this.notify("select").cursor;return t&&(n=t.attr(qe)||t.attr(xe),n||(i=t.parent(),n=i.attr(qe)||i.attr(xe))),r=n?De.byId[n]:this.root,s("nodeId is the id of some Node that exists",r),o.clearSelection().show(),r.seek(e,o),this.scrollHoriz(),o.parent.bubble("workingGroupChange"),this}}),ze.open(function(t){t.scrollHoriz=function(){var t,e,n,i,s,r=this.cursor,o=r.selection,a=this.root.jQ[0].getBoundingClientRect();if(o)if(n=o.jQ[0].getBoundingClientRect(),i=n.left-(a.left+20),s=n.right-(a.right-20),o.ends[Te]===r[Qe])if(0>i)e=i;else{if(!(s>0))return;e=n.left-s<a.left+20?i:s}else if(s>0)e=s;else{if(!(0>i))return;e=n.right-i>a.right-20?s:i}else if(t=r.jQ[0].getBoundingClientRect().left,t>a.right-20)e=t-(a.right-20);else{if(!(t<a.left+20))return;e=t-(a.left+20)}this.root.jQ.stop().animate({scrollLeft:"+="+e},100)}}),ze.open(function(t){g.p.substituteTextarea=function(){return Se("<textarea>")[0]},t.createTextarea=function(){var t,e=this.textareaSpan=Se('<span class="mq-textarea"></span>'),n=this.API.__options.substituteTextarea();if(!n.nodeType)throw"substituteTextarea() must return a DOM element, got "+n;n=this.textarea=Se(n).appendTo(e),t=this,t.cursor.selectionChanged=function(){t.selectionChanged()},t.container.bind("copy",function(){t.setTextareaSelection()})},t.selectionChanged=function(){var t=this;Z(t.container[0]),t.textareaSelectionTimeout===d&&(t.textareaSelectionTimeout=setTimeout(function(){t.setTextareaSelection()}))},t.setTextareaSelection=function(){this.textareaSelectionTimeout=d;var t="";this.cursor.selection&&(t=this.cursor.selection.join("latex"),this.API.__options.statelessClipboard&&(t="$"+t+"$")),this.selectFn(t)},t.staticMathTextareaEvents=function(){function t(){s.detach(),e.blurred=!0}var e=this,n=(e.root,e.cursor),i=e.textarea,s=e.textareaSpan;this.container.prepend('<span class="mq-selectable">$'+e.exportLatex()+"$</span>"),e.blurred=!0,i.bind("cut paste",!1).focus(function(){e.blurred=!1}).blur(function(){n.selection&&n.selection.clear(),setTimeout(t)}),e.selectFn=function(t){i.val(t),t&&i.select()}},t.editablesTextareaEvents=function(){var t=this,e=(t.root,t.cursor),n=t.textarea,i=t.textareaSpan,s=q(n,this);this.selectFn=function(t){s.select(t)},this.container.prepend(i).on("cut",function(){e.selection&&setTimeout(function(){t.notify("edit"),e.parent.bubble("reflow")})}),this.focusBlurEvents()},t.typedText=function(t){if("\n"===t)return this.handle("enter");var e=this.notify().cursor;e.parent.write(e,t,e.show().replaceSelection()),this.scrollHoriz()},t.paste=function(t){this.API.__options.statelessClipboard&&(t="$"===t.slice(0,1)&&"$"===t.slice(-1)?t.slice(1,-1):"\\text{"+t+"}"),this.writeLatex(t).cursor.show()}}),O=Ce(De,function(t){t.finalizeInsert=function(t,e){var n=this;n.postOrder("finalizeTree",t),n.postOrder("contactWeld",e),n.postOrder("blur"),n.postOrder("reflow"),n[Qe].siblingCreated&&n[Qe].siblingCreated(t,Te),n[Te].siblingCreated&&n[Te].siblingCreated(t,Qe),n.bubble("reflow")},t.contextMenu=function(){},t.showPopupMenu=function(t,e){var n,i;for(1==Se("#mq-popup-menu").length&&Se("#mq-popup-menu").remove(),n=Se("<ul></ul>").attr("id","mq-popup-menu").appendTo("body"),i=0;i<t.length;i++)Se("<li></li>").attr("mq-menu-id",i).html(t[i].text).appendTo(n);n.menu({select:function(e,i){var s=1*i.item.attr("mq-menu-id");t[s].handler(e),n.hide()}}),n.position({my:"left top",of:e}),n.show(),Se(document).bind("click",function(t){n.hide(),Se(this).unbind(t)})}}),y=Ce(O,function(t,e){t.init=function(t,n,i){var s=this;e.init.call(s),s.ctrlSeq||(s.ctrlSeq=t),n&&(s.htmlTemplate=n),i&&(s.textTemplate=i)},t.replaces=function(t){t.disown(),this.replacedFragment=t},t.isEmpty=function(){return this.foldChildren(!0,function(t,e){return t&&e.isEmpty()})},t.parser=function(){var t=k.block,e=this;return t.times(e.numBlocks()).map(function(t){e.blocks=t;for(var n=0;n<t.length;n+=1)t[n].adopt(e,e.ends[Qe],0);return e})},t.createLeftOf=function(t){var n,i,s,r=this;if("undefined"!=typeof t.parent&&t.parent.parent instanceof fe){if(","==r.ctrlSeq)return t.parent.parent.moveOrInsertColumn(t);if(";"==r.ctrlSeq)return t.parent.parent.insertRow(t);if(":"==r.ctrlSeq)return t.parent.parent.deleteRow(t);if("<"==r.ctrlSeq)return t.parent.parent.deleteColumn(t);if(">"==r.ctrlSeq)return t.parent.parent.insertColumn(t)}else if("undefined"!=typeof t.parent&&t.parent.parent instanceof de&&"\\left["===t.parent.parent.ctrlSeq&&(","==r.ctrlSeq||";"==r.ctrlSeq))return n=t.parent.parent,0!==n[Te]?t.insRightOf(n[Te]):t.insAtLeftEnd(n.parent),i=fe("\\bmatrix",1,1),i.createLeftOf(t),n.ends[Te].children().disown().adopt(i.ends[Te],0,0).jQ.appendTo(i.ends[Te].jQ),n.remove(),","==r.ctrlSeq?i.insertColumn(t):i.insertRow(t);s=r.replacedFragment,r.createBlocks(),e.createLeftOf.call(r,t),s&&(s.adopt(r.ends[Te],0,0),s.jQ.appendTo(r.ends[Te].jQ)),r.finalizeInsert(t.options),r.placeCursor(t),(this instanceof T||this instanceof le||this instanceof re||this instanceof he)&&this.bubble("workingGroupChange")},t.createBlocks=function(){var t,e,n=this,i=n.numBlocks(),s=n.blocks=Array(i);for(t=0;i>t;t+=1)e=s[t]=Q(),e.adopt(n,n.ends[Qe],0)},t.placeCursor=function(t){t.insAtRightEnd(this.foldChildren(this.ends[Te],function(t,e){return t.isEmpty()?t:e}))},t.moveTowards=function(t,e,n){var i=n&&this[n+"Into"];e.insAtDirEnd(-t,i||this.ends[-t])},t.deleteTowards=function(t,e){e.startSelection(),this.selectTowards(t,e),e.select()},t.selectTowards=function(t,e){e[-t]=this,e[t]=this[t]},t.selectChildren=function(){return Ie(this,this)},t.unselectInto=function(t,e){e.insAtDirEnd(-t,e.anticursor.ancestors[this.id])},t.seek=function(t,e){function n(t){var e={};return e[Te]=t.jQ.offset().left,e[Qe]=e[Te]+t.jQ.outerWidth(),e}var i,s=this,r=n(s);return t<r[Te]?e.insLeftOf(s):t>r[Qe]?e.insRightOf(s):(i=r[Te],void s.eachChild(function(o){var a=n(o);return t<a[Te]?(t-i<a[Te]-t?o[Te]?e.insAtRightEnd(o[Te]):e.insLeftOf(s):e.insAtLeftEnd(o),!1):t>a[Qe]?void(o[Qe]?i=a[Qe]:r[Qe]-t<t-a[Qe]?e.insRightOf(s):e.insAtRightEnd(o)):(o.seek(t,e),!1)}))},t.numBlocks=function(){var t=this.htmlTemplate.match(/&\d+/g);return t?t.length:0},t.html=function(){var t,e,n,i=this,r=i.blocks,o=" mathquill-command-id="+i.id,a=i.htmlTemplate.match(/<[^<>]+>|[^<>]+/g);for(s("no unmatched angle brackets",a.join("")===this.htmlTemplate),t=0,e=a[0];e;t+=1,e=a[t])if("/>"===e.slice(-2))a[t]=e.slice(0,-2)+o+"/>";else if("<"===e.charAt(0)){s("not an unmatched top-level close tag","/"!==e.charAt(1)),a[t]=e.slice(0,-1)+o+">",n=1;do t+=1,e=a[t],s("no missing close tags",e),"</"===e.slice(0,2)?n-=1:"<"===e.charAt(0)&&"/>"!==e.slice(-2)&&(n+=1);while(n>0)}return a.join("").replace(/>&(\d+)/g,function(t,e){return" mathquill-block-id="+r[e].id+">"+r[e].join("html")})},t.latex=function(){return this.foldChildren(this.ctrlSeq,function(t,e){return t+"{"+(e.latex()||" ")+"}"})},t.textTemplate=[""],t.text=function(t){var e=this,n=0;return e.foldChildren(e.textTemplate[n],function(i,s){n+=1;var r=s.text(t);
2
+ return i&&"("===e.textTemplate[n]&&"("===r[0]&&")"===r.slice(-1)?i+r.slice(1,-1)+e.textTemplate[n]:i+s.text(t)+(e.textTemplate[n]||"")})}}),j=Ce(y,function(e,n){e.init=function(t,e,i){i||(i=t&&t.length>1?t.slice(1):t),n.init.call(this,t,e,[i])},e.parser=function(){return x.succeed(this)},e.numBlocks=function(){return 0},e.replaces=function(t){t.remove()},e.createBlocks=t,e.moveTowards=function(t,e){e.jQ.insDirOf(t,this.jQ),e[-t]=this,e[t]=this[t]},e.deleteTowards=function(t,e){e[t]=this.remove()[t]},e.seek=function(t,e){t-this.jQ.offset().left<this.jQ.outerWidth()/2?e.insLeftOf(this):e.insRightOf(this)},e.latex=function(){return this.ctrlSeq},e.text=function(){return this.textTemplate},e.placeCursor=t,e.isEmpty=function(){return!0}}),C=Ce(j,function(t,e){t.init=function(t,n,i){e.init.call(this,t,"<span>"+(n||t)+"</span>",i||t)},t.createLeftOf=function(t){"."===this.ctrlSeq&&0!==t[Te]&&"."===t[Te].ctrlSeq?(t[Te].ctrlSeq="…",t[Te].jQ.html('<span class="mq-nonSymbola" style="font-size:0.6em;">&#8230;</span>'),t[Te].textTemplate=".."):e.createLeftOf.call(this,t)}}),T=Ce(j,function(t,e){t.init=function(t,n,i){e.init.call(this,t,'<span class="mq-binary-operator">'+n+"</span>",i)}}),Q=Ce(O,function(t,e){t.join=function(t){return this.foldChildren("",function(e,n){return e+n[t]()})},t.html=function(){return this.join("html")},t.latex=function(){return this.join("latex")},t.text=function(t){return 0===this.ends[Te]&&0===this.ends[Qe]?"":this.ends[Te]===this.ends[Qe]?this.ends[Te].text(t):this.foldChildren("",function(e,n){return e+n.text(t)})},t.keystroke=function(t,n,i){return!i.API.__options.spaceBehavesLikeTab||"Spacebar"!==t&&"Shift-Spacebar"!==t?e.keystroke.apply(this,arguments):(n.preventDefault(),i.escapeDir("Shift-Spacebar"===t?Te:Qe,t,n),console.log(i),void alert("pause"))},t.moveOutOf=function(t,e,n){var i=n&&this.parent[n+"Into"];!i&&this[t]?e.insAtDirEnd(-t,this[t]):e.insDirOf(t,this.parent)},t.selectOutOf=function(t,e){e.insDirOf(t,this.parent)},t.deleteOutOf=function(t,e){e.unwrapGramp()},t.seek=function(t,e){var n=this.ends[Qe];if(!n||n.jQ.offset().left+n.jQ.outerWidth()<t)return e.insAtRightEnd(this);if(t<this.ends[Te].jQ.offset().left)return e.insAtLeftEnd(this);for(;t<n.jQ.offset().left;)n=n[Te];return n.seek(t,e)},t.write=function(t,e,n){var i,s,r,o,a;if(i=e.match(/^[a-eg-zA-Z]$/)?I(e):e.match(/^[0-9\+\-]$/)&&t[Te]instanceof I&&"e"===t[Te].ctrlSeq&&0!==t[Te][Te]&&"undefined"!=typeof t[Te][Te]&&t[Te][Te].ctrlSeq.match(/^[0-9]$/)?oe(e):e.match(/^[0-9]$/)&&t[Te]instanceof I?I(e):(i=Ee[e]||_e[e])?i(e):C(e),!(i instanceof I)&&t[Te]instanceof I){for(s=t.options.autoCommands,r=t[Te].letter,o=t[Te][Te],a=1;o instanceof I;)r=o.letter+r,o=o[Te],a+=1;if(r.length>1&&s.hasOwnProperty(r)){for(a=1,o=t[Te];a<r.length;a+=1,o=o[Te]);Le(o,t[Te]).remove(),t[Te]=o[Te],_e[r](r).createLeftOf(t)}}n&&i.replaces(n),i.createLeftOf(t)},t.focus=function(){return this.jQ.addClass("mq-hasCursor"),this.jQ.removeClass("mq-empty"),this},t.blur=function(){return this.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.jQ.addClass("mq-empty"),this}}),S=Ce(Q,c),a.MathField=l(Ce(w,function(t){t.init=function(t,e){t.addClass("mq-editable-field mq-math-mode"),this.initRootAndEvents(S(),t,e)}})),A=Ce(De,function(t,e){function n(t){var e,n;return t.jQ[0].normalize(),e=t.jQ[0].firstChild,n=D(e.data),n.jQadd(e),t.children().disown(),n.adopt(t,0,0)}t.ctrlSeq="\\text",t.replaces=function(t){t instanceof Le?this.replacedText=t.remove().jQ.text():"string"==typeof t&&(this.replacedText=t)},t.jQadd=function(t){e.jQadd.call(this,t),this.ends[Te]&&this.ends[Te].jQadd(this.jQ[0].firstChild)},t.createLeftOf=function(t){var n,i=this;if(e.createLeftOf.call(this,t),i[Qe].siblingCreated&&i[Qe].siblingCreated(t.options,Te),i[Te].siblingCreated&&i[Te].siblingCreated(t.options,Qe),i.bubble("reflow"),t.insAtRightEnd(i),i.replacedText)for(n=0;n<i.replacedText.length;n+=1)i.write(t,i.replacedText.charAt(n))},t.parser=function(){var t=this,e=x.string,n=x.regex,i=x.optWhitespace;return i.then(e("{")).then(n(/^[^}]*/)).skip(e("}")).map(function(e){return D(e).adopt(t,0,0),t})},t.textContents=function(){return this.foldChildren("",function(t,e){return t+e.text})},t.text=function(t){return t.dropTextFieldsOnTextOutput?"":'"'+this.textContents()+'"'},t.latex=function(){return"\\text{"+this.textContents()+"}"},t.html=function(){return'<span class="mq-text-mode" mathquill-command-id='+this.id+">"+this.textContents()+"</span>"},t.moveTowards=function(t,e){e.insAtDirEnd(-t,this)},t.moveOutOf=function(t,e){e.insDirOf(t,this)},t.unselectInto=t.moveTowards,t.selectTowards=y.prototype.selectTowards,t.deleteTowards=y.prototype.deleteTowards,t.selectOutOf=function(t,e){e.insDirOf(t,this)},t.deleteOutOf=function(t,e){this.isEmpty()&&e.insRightOf(this)},t.write=function(t,n,i){var s,r;i&&i.remove(),"$"!==n?t[Te]?t[Te].appendText(n):D(n).createLeftOf(t):this.isEmpty()?(t.insRightOf(this),C("\\$","$").createLeftOf(t)):t[Qe]?t[Te]?(s=A(),r=this.ends[Te],r.disown(),r.adopt(s,0,0),t.insLeftOf(this),e.createLeftOf.call(s,t)):t.insLeftOf(this):t.insRightOf(this)},t.seek=function(t,e){var i,s,r,o,a,l,c,h;for(e.hide(),i=n(this),s=this.jQ.width()/this.text.length,r=Math.round((t-this.jQ.offset().left)/s),0>=r?e.insAtLeftEnd(this):r>=i.text.length?e.insAtRightEnd(this):e.insLeftOf(i.splitRight(r)),o=t-e.show().offset().left,a=o&&0>o?Te:Qe,l=a;e[a]&&o*l>0;)e[a].moveTowards(a,e),l=o,o=t-e.offset().left;-a*l>a*o&&e[-a].moveTowards(-a,e),e.anticursor?e.anticursor.parent===this&&(c=e[Te]&&e[Te].text.length,this.anticursorPosition===c?e.anticursor=Ae.copy(e):(this.anticursorPosition<c?(h=e[Te].splitRight(this.anticursorPosition),e[Te]=h):h=e[Qe].splitRight(this.anticursorPosition-c),e.anticursor=Ae(this,h[Te],h))):this.anticursorPosition=e[Te]&&e[Te].text.length},t.blur=function(){Q.prototype.blur.call(this),n(this)},t.focus=Q.prototype.focus}),D=Ce(De,function(t,e){function n(t,e){return e.charAt(t===Te?0:-1+e.length)}t.init=function(t){e.init.call(this),this.text=t},t.jQadd=function(t){this.dom=t,this.jQ=Se(t)},t.jQize=function(){return this.jQadd(document.createTextNode(this.text))},t.appendText=function(t){this.text+=t,this.dom.appendData(t)},t.prependText=function(t){this.text=t+this.text,this.dom.insertData(0,t)},t.insTextAtDirEnd=function(t,e){r(e),e===Qe?this.appendText(t):this.prependText(t)},t.splitRight=function(t){var e=D(this.text.slice(t)).adopt(this.parent,this,this[Qe]);return e.jQadd(this.dom.splitText(t)),this.text=this.text.slice(0,t),e},t.moveTowards=function(t,e){var i,s;return r(t),i=n(-t,this.text),s=this[-t],s?s.insTextAtDirEnd(i,t):D(i).createDir(-t,e),this.deleteTowards(t,e)},t.latex=function(){return this.text},t.deleteTowards=function(t,e){this.text.length>1?t===Qe?(this.dom.deleteData(0,1),this.text=this.text.slice(1)):(this.dom.deleteData(-1+this.text.length,1),this.text=this.text.slice(0,-1)):(this.remove(),this.jQ.remove(),e[t]=this[t])},t.selectTowards=function(t,e){var i,s,o,a;return r(t),i=e.anticursor,s=n(-t,this.text),i[t]===this?(o=D(s).createDir(t,e),i[t]=o,e.insDirOf(t,o)):(a=this[-t],a?a.insTextAtDirEnd(s,t):(o=D(s).createDir(-t,e),o.jQ.insDirOf(-t,e.selection.jQ)),1===this.text.length&&i[-t]===this&&(i[-t]=this[-t])),this.deleteTowards(t,e)}}),Ee.$=_e.text=_e.textnormal=_e.textrm=_e.textup=_e.textmd=A,_e.em=_e.italic=_e.italics=_e.emph=_e.textit=_e.textsl=h("\\textit","i",'class="mq-text-mode"'),_e.strong=_e.bold=_e.textbf=h("\\textbf","b",'class="mq-text-mode"'),_e.sf=_e.textsf=h("\\textsf","span",'class="mq-sans-serif mq-text-mode"'),_e.tt=_e.texttt=h("\\texttt","span",'class="mq-monospace mq-text-mode"'),_e.textsc=h("\\textsc","span",'style="font-variant:small-caps" class="mq-text-mode"'),_e.uppercase=h("\\uppercase","span",'style="text-transform:uppercase" class="mq-text-mode"'),_e.lowercase=h("\\lowercase","span",'style="text-transform:lowercase" class="mq-text-mode"'),L=Ce(y,function(t,e){t.init=function(t){e.init.call(this,"$"),this.cursor=t},t.htmlTemplate='<span class="mq-math-mode">&0</span>',t.createBlocks=function(){e.createBlocks.call(this),this.ends[Te].cursor=this.cursor,this.ends[Te].write=function(t,e,n){"$"!==e?Q.prototype.write.call(this,t,e,n):this.isEmpty()?(t.insRightOf(this.parent),this.parent.deleteTowards(dir,t),C("\\$","$").createLeftOf(t.show())):t[Qe]?t[Te]?Q.prototype.write.call(this,t,e,n):t.insLeftOf(this.parent):t.insRightOf(this.parent)}},t.latex=function(){return"$"+this.ends[Te].latex()+"$"}}),_=Ce(S,function(t,e){t.keystroke=function(t){return"Spacebar"!==t&&"Shift-Spacebar"!==t?e.keystroke.apply(this,arguments):void 0},t.write=function(t,e,n){if(n&&n.remove(),"$"===e)L(t).createLeftOf(t);else{var i;"<"===e?i="&lt;":">"===e&&(i="&gt;"),C(e,i).createLeftOf(t)}}}),a.TextField=l(Ce(w,function(t){t.init=function(t){t.addClass("mq-editable-field mq-text-mode"),this.initRootAndEvents(_(),t)},t.latex=function(t){return arguments.length>0?(this.__controller.renderLatexText(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this):this.__controller.exportLatex()}})),E=Ee["\\"]=Ce(y,function(t,e){t.ctrlSeq="\\",t.replaces=function(t){this._replacedFragment=t.disown(),this.isEmpty=function(){return!1}},t.htmlTemplate='<span class="mq-latex-command-input mq-non-leaf">\\<span>&0</span></span>',t.textTemplate=["\\"],t.createBlocks=function(){e.createBlocks.call(this),this.ends[Te].focus=function(){return this.parent.jQ.addClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.removeClass("mq-empty"),this},this.ends[Te].blur=function(){return this.parent.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.addClass("mq-empty"),this},this.ends[Te].write=function(t,e,n){return n&&n.remove(),0==this.parent.ends[Te].latex().indexOf("matrix")?void(/^matrix\dx\d$/.test(this.parent.ends[Te].latex())?(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)):C(e).createLeftOf(t)):void(e.match(/[a-z]/i)?C(e).createLeftOf(t):(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)))},this.ends[Te].keystroke=function(t,n,i){return"Tab"===t||"Enter"===t||"Spacebar"===t?(this.parent.renderCommand(i.cursor),void n.preventDefault()):e.keystroke.apply(this,arguments)}},t.createLeftOf=function(t){if(e.createLeftOf.call(this,t),this._replacedFragment){var n=this.jQ[0];this.jQ=this._replacedFragment.jQ.addClass("mq-blur").bind("mousedown mousemove",function(t){return Se(t.target=n).trigger(t),!1}).insertBefore(this.jQ).add(this.jQ)}},t.latex=function(){return"\\"+this.ends[Te].latex()+" "},t.renderCommand=function(t){var e,n;this.jQ=this.jQ.last(),this.remove(),this[Qe]?t.insLeftOf(this[Qe]):t.insAtRightEnd(this.parent),e=this.ends[Te].latex(),e||(e=" "),n=_e[e],n?(n=n(e),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t)):(n=A(),n.replaces(e),n.createLeftOf(t),t.insRightOf(n),this._replacedFragment&&this._replacedFragment.remove())}}),_e.notin=_e.sim=_e.cong=_e.equiv=_e.oplus=_e.otimes=Ce(T,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),_e.ast=_e.star=_e.loast=_e.lowast=i(T,"\\ast ","&lowast;"),_e.therefor=_e.therefore=i(T,"\\therefore ","&there4;"),_e.cuz=_e.because=i(T,"\\because ","&#8757;"),_e.prop=_e.propto=i(T,"\\propto ","&prop;"),_e["≈"]=_e.asymp=_e.approx=i(T,"\\approx ","&asymp;"),_e.isin=_e["in"]=i(T,"\\in ","&isin;"),_e.ni=_e.contains=i(T,"\\ni ","&ni;"),_e.notni=_e.niton=_e.notcontains=_e.doesnotcontain=i(T,"\\not\\ni ","&#8716;"),_e.sub=_e.subset=i(T,"\\subset ","&sub;"),_e.sup=_e.supset=_e.superset=i(T,"\\supset ","&sup;"),_e.nsub=_e.notsub=_e.nsubset=_e.notsubset=i(T,"\\not\\subset ","&#8836;"),_e.nsup=_e.notsup=_e.nsupset=_e.notsupset=_e.nsuperset=_e.notsuperset=i(T,"\\not\\supset ","&#8837;"),_e.sube=_e.subeq=_e.subsete=_e.subseteq=i(T,"\\subseteq ","&sube;"),_e.supe=_e.supeq=_e.supsete=_e.supseteq=_e.supersete=_e.superseteq=i(T,"\\supseteq ","&supe;"),_e.nsube=_e.nsubeq=_e.notsube=_e.notsubeq=_e.nsubsete=_e.nsubseteq=_e.notsubsete=_e.notsubseteq=i(T,"\\not\\subseteq ","&#8840;"),_e.nsupe=_e.nsupeq=_e.notsupe=_e.notsupeq=_e.nsupsete=_e.nsupseteq=_e.notsupsete=_e.notsupseteq=_e.nsupersete=_e.nsuperseteq=_e.notsupersete=_e.notsuperseteq=i(T,"\\not\\supseteq ","&#8841;"),_e.N=_e.naturals=_e.Naturals=i(C,"\\mathbb{N}","&#8469;"),_e.P=_e.primes=_e.Primes=_e.projective=_e.Projective=_e.probability=_e.Probability=i(C,"\\mathbb{P}","&#8473;"),_e.Z=_e.integers=_e.Integers=i(C,"\\mathbb{Z}","&#8484;"),_e.Q=_e.rationals=_e.Rationals=i(C,"\\mathbb{Q}","&#8474;"),_e.R=_e.reals=_e.Reals=i(C,"\\mathbb{R}","&#8477;"),_e.C=_e.complex=_e.Complex=_e.complexes=_e.Complexes=_e.complexplane=_e.Complexplane=_e.ComplexPlane=i(C,"\\mathbb{C}","&#8450;"),_e.H=_e.Hamiltonian=_e.quaternions=_e.Quaternions=i(C,"\\mathbb{H}","&#8461;"),_e.quad=_e.emsp=i(C,"\\quad "," "),_e.qquad=i(C,"\\qquad "," "),_e.diamond=i(C,"\\diamond ","&#9671;"),_e.bigtriangleup=i(C,"\\bigtriangleup ","&#9651;"),_e.ominus=i(C,"\\ominus ","&#8854;"),_e.uplus=i(C,"\\uplus ","&#8846;"),_e.bigtriangledown=i(C,"\\bigtriangledown ","&#9661;"),_e.sqcap=i(C,"\\sqcap ","&#8851;"),_e.triangleleft=i(C,"\\triangleleft ","&#8882;"),_e.sqcup=i(C,"\\sqcup ","&#8852;"),_e.triangleright=i(C,"\\triangleright ","&#8883;"),_e.odot=i(C,"\\odot ","&#8857;"),_e.bigcirc=i(C,"\\bigcirc ","&#9711;"),_e.dagger=i(C,"\\dagger ","&#0134;"),_e.ddagger=i(C,"\\ddagger ","&#135;"),_e.wr=i(C,"\\wr ","&#8768;"),_e.amalg=i(C,"\\amalg ","&#8720;"),_e.models=i(C,"\\models ","&#8872;"),_e.prec=i(C,"\\prec ","&#8826;"),_e.succ=i(C,"\\succ ","&#8827;"),_e.preceq=i(C,"\\preceq ","&#8828;"),_e.succeq=i(C,"\\succeq ","&#8829;"),_e.simeq=i(C,"\\simeq ","&#8771;"),_e.mid=i(C,"\\mid ","&#8739;"),_e.ll=i(C,"\\ll ","&#8810;"),_e.gg=i(C,"\\gg ","&#8811;"),_e.parallel=i(C,"\\parallel ","&#8741;"),_e.bowtie=i(C,"\\bowtie ","&#8904;"),_e.sqsubset=i(C,"\\sqsubset ","&#8847;"),_e.sqsupset=i(C,"\\sqsupset ","&#8848;"),_e.smile=i(C,"\\smile ","&#8995;"),_e.sqsubseteq=i(C,"\\sqsubseteq ","&#8849;"),_e.sqsupseteq=i(C,"\\sqsupseteq ","&#8850;"),_e.doteq=i(C,"\\doteq ","&#8784;"),_e.frown=i(C,"\\frown ","&#8994;"),_e.vdash=i(C,"\\vdash ","&#8870;"),_e.dashv=i(C,"\\dashv ","&#8867;"),_e.longleftarrow=i(C,"\\longleftarrow ","&#8592;"),_e.longrightarrow=i(C,"\\longrightarrow ","&#8594;"),_e.Longleftarrow=i(C,"\\Longleftarrow ","&#8656;"),_e.Longrightarrow=i(C,"\\Longrightarrow ","&#8658;"),_e.longleftrightarrow=i(C,"\\longleftrightarrow ","&#8596;"),_e.updownarrow=i(C,"\\updownarrow ","&#8597;"),_e.Longleftrightarrow=i(C,"\\Longleftrightarrow ","&#8660;"),_e.Updownarrow=i(C,"\\Updownarrow ","&#8661;"),_e.mapsto=i(C,"\\mapsto ","&#8614;"),_e.nearrow=i(C,"\\nearrow ","&#8599;"),_e.hookleftarrow=i(C,"\\hookleftarrow ","&#8617;"),_e.hookrightarrow=i(C,"\\hookrightarrow ","&#8618;"),_e.searrow=i(C,"\\searrow ","&#8600;"),_e.leftharpoonup=i(C,"\\leftharpoonup ","&#8636;"),_e.rightharpoonup=i(C,"\\rightharpoonup ","&#8640;"),_e.swarrow=i(C,"\\swarrow ","&#8601;"),_e.leftharpoondown=i(C,"\\leftharpoondown ","&#8637;"),_e.rightharpoondown=i(C,"\\rightharpoondown ","&#8641;"),_e.nwarrow=i(C,"\\nwarrow ","&#8598;"),_e.ldots=i(C,"\\ldots ","&#8230;"),_e.cdots=i(C,"\\cdots ","&#8943;"),_e.vdots=i(C,"\\vdots ","&#8942;"),_e.ddots=i(C,"\\ddots ","&#8944;"),_e.surd=i(C,"\\surd ","&#8730;"),_e.triangle=i(C,"\\triangle ","&#9653;"),_e.ell=i(C,"\\ell ","&#8467;"),_e.top=i(C,"\\top ","&#8868;"),_e.flat=i(C,"\\flat ","&#9837;"),_e.natural=i(C,"\\natural ","&#9838;"),_e.sharp=i(C,"\\sharp ","&#9839;"),_e.wp=i(C,"\\wp ","&#8472;"),_e.bot=i(C,"\\bot ","&#8869;"),_e.clubsuit=i(C,"\\clubsuit ","&#9827;"),_e.diamondsuit=i(C,"\\diamondsuit ","&#9826;"),_e.heartsuit=i(C,"\\heartsuit ","&#9825;"),_e.spadesuit=i(C,"\\spadesuit ","&#9824;"),_e.oint=i(C,"\\oint ","&#8750;"),_e.bigcap=i(C,"\\bigcap ","&#8745;"),_e.bigcup=i(C,"\\bigcup ","&#8746;"),_e.bigsqcup=i(C,"\\bigsqcup ","&#8852;"),_e.bigvee=i(C,"\\bigvee ","&#8744;"),_e.bigwedge=i(C,"\\bigwedge ","&#8743;"),_e.bigodot=i(C,"\\bigodot ","&#8857;"),_e.bigotimes=i(C,"\\bigotimes ","&#8855;"),_e.bigoplus=i(C,"\\bigoplus ","&#8853;"),_e.biguplus=i(C,"\\biguplus ","&#8846;"),_e.lfloor=i(C,"\\lfloor ","&#8970;"),_e.rfloor=i(C,"\\rfloor ","&#8971;"),_e.lceil=i(C,"\\lceil ","&#8968;"),_e.rceil=i(C,"\\rceil ","&#8969;"),_e.opencurlybrace=_e.lbrace=i(C,"\\lbrace ","{"),_e.closecurlybrace=_e.rbrace=i(C,"\\rbrace ","}"),_e["∫"]=_e["int"]=_e.integral=i(j,"\\int ","<big>&int;</big>"),_e.caret=i(C,"\\text{^}","^"),_e.underscore=i(C,"\\_","_"),_e.slash=i(C,"/"),_e.vert=i(C,"|"),_e.perp=_e.perpendicular=i(C,"\\perp ","&perp;"),_e.nabla=_e.del=i(C,"\\nabla ","&nabla;"),_e.hbar=i(C,"\\hbar ","&#8463;"),_e.AA=_e.Angstrom=_e.angstrom=i(C,"\\text\\AA ","&#8491;"),_e.ring=_e.circ=_e.circle=i(C,"\\circ ","&#8728;"),_e.bull=_e.bullet=i(C,"\\bullet ","&bull;"),_e.setminus=_e.smallsetminus=i(C,"\\setminus ","&#8726;"),_e.not=_e["¬"]=_e.neg=i(C,"\\neg ","&not;"),_e.dots=_e.ellip=_e.hellip=_e.ellipsis=_e.hellipsis=i(C,"\\dots ","&hellip;"),_e["…"]=i(C,"…",'<span class="mq-nonSymbola" style="font-size:0.6em;">&#8230;</span>',".."),_e.converges=_e.darr=_e.dnarr=_e.dnarrow=_e.downarrow=i(C,"\\downarrow ","&darr;"),_e.dArr=_e.dnArr=_e.dnArrow=_e.Downarrow=i(C,"\\Downarrow ","&dArr;"),_e.diverges=_e.uarr=_e.uparrow=i(C,"\\uparrow ","&uarr;"),_e.uArr=_e.Uparrow=i(C,"\\Uparrow ","&uArr;"),_e.to=i(T,"\\to ","&rarr;"),_e.rarr=_e.rightarrow=i(C,"\\rightarrow ","&rarr;"),_e.implies=i(T,"\\Rightarrow ","&rArr;"),_e.rArr=_e.Rightarrow=i(C,"\\Rightarrow ","&rArr;"),_e.gets=i(T,"\\gets ","&larr;"),_e.larr=_e.leftarrow=i(C,"\\leftarrow ","&larr;"),_e.impliedby=i(T,"\\Leftarrow ","&lArr;"),_e.lArr=_e.Leftarrow=i(C,"\\Leftarrow ","&lArr;"),_e.harr=_e.lrarr=_e.leftrightarrow=i(C,"\\leftrightarrow ","&harr;"),_e.iff=i(T,"\\Leftrightarrow ","&hArr;"),_e.hArr=_e.lrArr=_e.Leftrightarrow=i(C,"\\Leftrightarrow ","&hArr;"),_e.Re=_e.Real=_e.real=i(C,"\\Re ","&real;"),_e.Im=_e.imag=_e.image=_e.imagin=_e.imaginary=_e.Imaginary=i(C,"\\Im ","&image;"),_e.part=_e.partial=i(C,"\\partial ","&part;"),_e.infty=_e.infin=_e.infinity=i(C,"\\infty ","&infin;"),_e.alef=_e.alefsym=_e.aleph=_e.alephsym=i(C,"\\aleph ","&alefsym;"),_e.xist=_e.xists=_e.exist=_e.exists=i(C,"\\exists ","&exist;"),_e.and=_e.land=_e.wedge=i(C,"\\wedge ","&and;"),_e.or=_e.lor=_e.vee=i(C,"\\vee ","&or;"),_e.o=_e.O=_e.empty=_e.emptyset=_e.oslash=_e.Oslash=_e.nothing=_e.varnothing=i(T,"\\varnothing ","&empty;"),_e.cup=_e.union=i(T,"\\cup ","&cup;"),_e.cap=_e.intersect=_e.intersection=i(T,"\\cap ","&cap;"),_e.deg=_e.degree=i(C,"^\\circ ","&deg;"),_e.ang=_e.angle=i(C,"\\angle ","&ang;"),R=Ce(j,function(t,e){t.init=function(t,n){e.init.call(this,t,"<var>"+(n||t)+"</var>")},t.text=function(){return this.textTemplate}}),g.p.autoCommands={_maxLength:0},b.autoCommands=function(t){var e,n,i,s,r;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},i=0,s=0;s<e.length;s+=1){if(r=e[s],r.length<2)throw'autocommand "'+r+'" not minimum length of 2';if(_e[r]===B)throw'"'+r+'" is a built-in operator name';n[r]=1,i=Oe(i,r.length)}return n._maxLength=i,n},I=Ce(R,function(t,e){t.init=function(t){return e.init.call(this,this.letter=t)},t.autoUnItalicize=function(t){var e,n,i,s="",r=[];for(e=this;e instanceof I;e=e[Te])s=e.letter+s,r.push(e);for(n=B(s).createLeftOf(t),i=0;i<r.length;i++)r[i].remove()}}),z={},function(){var t,e,n,i=g.p.autoOperatorNames={_maxLength:9},s="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<s.length;t+=1)z[s[t]]=i[s[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)z[e[t]]=1;for(n="sin cos tan sec cosec csc cotan cot ctg".split(" "),t=0;t<n.length;t+=1)i[n[t]]=i["arc"+n[t]]=i[n[t]+"h"]=i["ar"+n[t]+"h"]=i["arc"+n[t]+"h"]=1}(),b.autoOperatorNames=function(t){var e,n,i,s,r;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},i=0,s=0;s<e.length;s+=1){if(r=e[s],r.length<2)throw'"'+r+'" not minimum length of 2';n[r]=1,i=Oe(i,r.length)}return n._maxLength=i,n},B=_e.operatorname=Ce(y,function(t,e){t.htmlTemplate='<span class="mq-operator-name">&0</span>',t.init=function(t){e.init.call(this,t)},t.createLeftOf=function(t){var n,i;for(e.createLeftOf.apply(this,arguments),n=this.ctrlSeq,i=0;i<n.length;i+=1)I(n.charAt(i)).createLeftOf(t);t.insRightOf(this)},t.text=function(t){return this.blocks[0].text(t)},t.latex=function(){return z.hasOwnProperty(this.blocks[0].text())?"\\"+this.blocks[0].latex()+" ":"\\operatorname{"+this.blocks[0].latex()+"}"},t.parser=function(){var t,n;if(z.hasOwnProperty(this.ctrlSeq)){for(t=this.ctrlSeq,this.createBlocks(),n=0;n<t.length;n+=1)I(t.charAt(n)).adopt(this.ends[Te],this.ends[Te].ends[Qe],0);return x.succeed(this)}return e.parser.call(this)}});for($ in z)z.hasOwnProperty($)&&(_e[$]=B);_e.f=Ce(I,function(t){t.init=function(){j.p.init.call(this,this.letter="f",'<var class="mq-florin">&fnof;</var>')}}),_e[" "]=_e.space=i(C,"\\ "," "),_e["'"]=_e.prime=i(C,"'","&prime;"),_e.backslash=i(C,"\\backslash ","\\"),Ee["\\"]||(Ee["\\"]=_e.backslash),_e.$=i(C,"\\$","$"),M=Ce(j,function(t,e){t.init=function(t,n){e.init.call(this,t,'<span class="mq-nonSymbola">'+(n||t)+"</span>")}}),_e["@"]=M,_e["&"]=i(M,"\\&","&amp;"),_e["%"]=i(M,"\\%","%"),_e.alpha=_e.beta=_e.gamma=_e.delta=_e.zeta=_e.eta=_e.theta=_e.iota=_e.kappa=_e.mu=_e.nu=_e.xi=_e.rho=_e.sigma=_e.tau=_e.chi=_e.psi=_e.omega=Ce(R,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),_e.phi=i(R,"\\phi ","&#981;"),_e.phiv=_e.varphi=i(R,"\\varphi ","&phi;"),_e.epsilon=i(R,"\\epsilon ","&#1013;"),_e.epsiv=_e.varepsilon=i(R,"\\varepsilon ","&epsilon;"),_e.piv=_e.varpi=i(R,"\\varpi ","&piv;"),_e.sigmaf=_e.sigmav=_e.varsigma=i(R,"\\varsigma ","&sigmaf;"),_e.thetav=_e.vartheta=_e.thetasym=i(R,"\\vartheta ","&thetasym;"),_e.upsilon=_e.upsi=i(R,"\\upsilon ","&upsilon;"),_e.gammad=_e.Gammad=_e.digamma=i(R,"\\digamma ","&#989;"),_e.kappav=_e.varkappa=i(R,"\\varkappa ","&#1008;"),_e.rhov=_e.varrho=i(R,"\\varrho ","&#1009;"),_e.pi=_e["π"]=i(M,"\\pi ","&pi;"),_e.lambda=i(M,"\\lambda ","&lambda;"),_e.Upsilon=_e.Upsi=_e.upsih=_e.Upsih=i(j,"\\Upsilon ",'<var style="font-family: serif">&upsih;</var>'),_e.Gamma=_e.Delta=_e.Theta=_e.Lambda=_e.Xi=_e.Pi=_e.Sigma=_e.Phi=_e.Psi=_e.Omega=_e.forall=Ce(C,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),P=Ce(y,function(t){t.init=function(t){this.latex=t},t.createLeftOf=function(t){var e=k.parse(this.latex);e.children().adopt(t.parent,t[Te],t[Qe]),t[Te]=e.ends[Qe],e.jQize().insertBefore(t.jQ),e.finalizeInsert(t.options,t),e.ends[Qe][Qe].siblingCreated&&e.ends[Qe][Qe].siblingCreated(t.options,Te),e.ends[Te][Te].siblingCreated&&e.ends[Te][Te].siblingCreated(t.options,Qe),t.parent.bubble("reflow")},t.parser=function(){var t=k.parse(this.latex).children();return x.succeed(t)}}),_e["¹"]=i(P,"^1"),_e["²"]=i(P,"^2"),_e["³"]=i(P,"^3"),_e["¼"]=i(P,"\\frac14"),_e["½"]=i(P,"\\frac12"),_e["¾"]=i(P,"\\frac34"),F=Ce(T,function(t){t.init=C.prototype.init,t.contactWeld=t.siblingCreated=t.siblingDeleted=function(t,e){return e!==Qe?(this.jQ[0].className=!this[Te]||this[Te]instanceof T?"":"mq-binary-operator",this):void 0}}),_e["+"]=i(F,"+","+"),_e["–"]=_e["-"]=i(F,"-","&minus;"),_e["±"]=_e.pm=_e.plusmn=_e.plusminus=i(F,"\\pm ","&plusmn;"),_e.mp=_e.mnplus=_e.minusplus=i(F,"\\mp ","&#8723;"),Ee["*"]=_e.sdot=_e.cdot=i(T,"\\cdot ","&middot;","*"),N=Ce(T,function(t,e){t.init=function(t,n){this.data=t,this.strict=n;var i=n?"Strict":"";e.init.call(this,t["ctrlSeq"+i],t["html"+i],t["text"+i])},t.swap=function(t){this.strict=t;var e=t?"Strict":"";this.ctrlSeq=this.data["ctrlSeq"+e],this.jQ.html(this.data["html"+e]),this.textTemplate=[this.data["text"+e]]},t.deleteTowards=function(t){return t!==Te||this.strict?void e.deleteTowards.apply(this,arguments):void this.swap(!0)}}),G={ctrlSeq:"\\le ",html:"&le;",text:" <= ",ctrlSeqStrict:"<",htmlStrict:"&lt;",textStrict:" < "},U={ctrlSeq:"\\ge ",html:"&ge;",text:" >= ",ctrlSeqStrict:">",htmlStrict:"&gt;",textStrict:" > "},W={ctrlSeq:"\\ne ",html:"&ne;",text:" != ",ctrlSeqStrict:"!",htmlStrict:"!",textStrict:"!"},_e["<"]=_e.lt=i(N,G,!0),_e[">"]=_e.gt=i(N,U,!0),_e["≤"]=_e.le=_e.leq=i(N,G,!1),_e["≥"]=_e.ge=_e.geq=i(N,U,!1),_e["!"]=i(N,W,!0),_e["≠"]=_e.ne=_e.neq=i(N,W,!1),H=Ce(N,function(t,e){t.init=function(t,n){e.init.call(this,t,n)},t.createLeftOf=function(t){return(t[Te]instanceof N||t[Te]instanceof H)&&t[Te].strict?void t[Te].swap(!1):void e.createLeftOf.apply(this,arguments)}}),V={ctrlSeq:"\\eq ",html:"==",text:" == ",ctrlSeqStrict:"=",htmlStrict:"=",textStrict:" = "},_e["="]=i(H,V,!0),_e.eq=i(H,V,!1),_e.times=i(T,"\\times ","&times;","[x]"),_e["÷"]=_e.div=_e.divide=_e.divides=i(T,"\\div ","&divide;","[/]"),Z=t,K=document.createElement("div"),Y=K.style,J={transform:1,WebkitTransform:1,MozTransform:1,OTransform:1,msTransform:1};for(ee in J)if(ee in Y){te=ee;break}te?X=function(t,e,n){t.css(te,"scale("+e+","+n+")")}:"filter"in Y?(Z=function(t){t.className=t.className},X=function(t,e,n){function i(){t.css("marginRight",(s.width()-1)*(e-1)/e+"px")}var s,r;e/=1+(n-1)/2,t.css("fontSize",n+"em"),t.hasClass("mq-matrixed-container")||t.addClass("mq-matrixed-container").wrapInner('<span class="mq-matrixed"></span>'),s=t.children().css("filter","progid:DXImageTransform.Microsoft.Matrix(M11="+e+",SizingMethod='auto expand')"),i(),r=setInterval(i),Se(window).load(function(){clearTimeout(r),i()})}):X=function(t,e,n){t.css("fontSize",n+"em")},ne=Ce(y,function(t,e){t.init=function(t,n,i){e.init.call(this,t,"<"+n+" "+i+">&0</"+n+">")}}),_e.mathrm=i(ne,"\\mathrm","span",'class="mq-roman mq-font"'),_e.mathit=i(ne,"\\mathit","i",'class="mq-font"'),_e.mathbf=i(ne,"\\mathbf","b",'class="mq-font"'),_e.mathsf=i(ne,"\\mathsf","span",'class="mq-sans-serif mq-font"'),_e.mathtt=i(ne,"\\mathtt","span",'class="mq-monospace mq-font"'),_e.underline=i(ne,"\\underline","span",'class="mq-non-leaf mq-underline"'),_e.overline=_e.bar=i(ne,"\\overline","span",'class="mq-non-leaf mq-overline"'),ie=_e.textcolor=Ce(y,function(t,e){t.setColor=function(t){this.color=t,this.htmlTemplate='<span class="mq-textcolor" style="color:'+t+'">&0</span>'},t.latex=function(){return"\\textcolor{"+this.color+"}{"+this.blocks[0].latex()+"}"},t.parser=function(){var t=this,n=x.optWhitespace,i=x.string,s=x.regex;return n.then(i("{")).then(s(/^[#\w\s.,()%-]*/)).skip(i("}")).then(function(n){return t.setColor(n),e.parser.call(t)})}}),se=_e["class"]=Ce(y,function(t,e){t.parser=function(){var t=this,n=x.string,i=x.regex;return x.optWhitespace.then(n("{")).then(i(/^[-\w\s\\\xA0-\xFF]*/)).skip(n("}")).then(function(n){return t.htmlTemplate='<span class="mq-class '+n+'">&0</span>',e.parser.call(t)})}}),re=Ce(y,function(t,e){t.ctrlSeq="_{...}^{...}",t.createLeftOf=function(t){return t[Te]||!t.options.supSubsRequireOperand?e.createLeftOf.apply(this,arguments):void 0},t.contactWeld=function(t){var e,n,i,s,r,o;for(e=Te;e;e=e===Te?Qe:!1)if(this[e]instanceof re){for(n="sub";n;n="sub"===n?"sup":!1)i=this[n],s=this[e][n],i&&(s?i.isEmpty()?o=Ae(s,0,s.ends[Te]):(i.jQ.children().insAtDirEnd(-e,s.jQ),r=i.children().disown(),o=Ae(s,r.ends[Qe],s.ends[Te]),e===Te?r.adopt(s,s.ends[Qe],0):r.adopt(s,0,s.ends[Te])):this[e].addBlock(i.disown()),this.placeCursor=function(t,n){return function(i){i.insAtDirEnd(-e,t||n)}}(s,i));this.remove(),t&&t[Te]===this&&(e===Qe&&o?o[Te]?t.insRightOf(o[Te]):t.insAtLeftEnd(o.parent):t.insRightOf(this[e]));break}this.respace()},g.p.charsThatBreakOutOfSupSub="",t.finalizeTree=function(){var t=this.supsub;this.ends[Te].write=function(e,n){e.options.charsThatBreakOutOfSupSub.indexOf(n)>-1&&e.insRightOf(this.parent),"sub"!=t||RegExp(/[A-Za-z0-9]/).test(n)||e.insRightOf(this.parent),Q.p.write.apply(this,arguments)}},t.latex=function(){function t(t,e){var n=e&&e.latex();return e?t+(1===n.length?n:"{"+(n||" ")+"}"):""}return t("_",this.sub)+t("^",this.sup)},t.text=function(t){var e="";return this.sub&&(e+="_"+(this.sub&&0!==this.sub.ends[Te]&&this.sub.ends[Te]===this.sub.ends[Qe]?this.sub.ends[Te].text(t):this.sub.foldChildren("",function(e,n){return e+n.text(t)}))),this.sup&&(e+="^"+(this.sup&&this.sup.ends[Te]===this.sup.ends[Qe]?this.sup.ends[Te].text(t):"("+this.sup.foldChildren("",function(e,n){return e+n.text(t)})+")")),e},t.respace=t.siblingCreated=t.siblingDeleted=function(t,e){e!==Qe&&this.jQ.toggleClass("mq-limit","\\int "===this[Te].ctrlSeq)},t.addBlock=function(t){"sub"===this.supsub?(this.sup=this.upInto=this.sub.upOutOf=t,t.adopt(this,this.sub,0).downOutOf=this.sub,t.jQ=Se('<span class="mq-sup"/>').append(t.jQ.children()).attr(qe,t.id).prependTo(this.jQ)):(this.sub=this.downInto=this.sup.downOutOf=t,t.adopt(this,0,this.sup).upOutOf=this.sup,t.jQ=Se('<span class="mq-sub"></span>').append(t.jQ.children()).attr(qe,t.id).appendTo(this.jQ.removeClass("mq-sup-only")),this.jQ.append('<span style="display:inline-block;width:0">&nbsp;</span>'));for(var e=0;2>e;e+=1)(function(t,e,n,i){t[e].deleteOutOf=function(s,r){r.insDirOf(s,this.parent),this.isEmpty()||(r[-s]=this.ends[s],this.children().disown().withDirAdopt(s,r.parent,r[s],this.parent).jQ.insDirOf(s,this.parent.jQ)),t.supsub=n,delete t[e],delete t[i+"Into"],t[n][i+"OutOf"]=u,delete t[n].deleteOutOf,"sub"===e&&Se(t.jQ.addClass("mq-sup-only")[0].lastChild).remove(),this.remove()}})(this,"sub sup".split(" ")[e],"sup sub".split(" ")[e],"down up".split(" ")[e])}}),oe=_e.scientificNotation=Ce(y,function(t,e){t.ctrlSeq="ScientificNotation{...}{...}",t.htmlTemplate='<span><span>&0</span><span style="font-size:0.7em;">&times;</span><span>10</span><span class="mq-supsub mq-non-leaf mq-sup-only"><span class="mq-sup">&1</span></span></span>',t.init=function(t){"scientificNotation"!==t&&(this.incorporate_previous=t),e.init.call(this)},t.text=function(t){return this.blocks[0].text(t)+"e"+this.blocks[1].text(t)},t.latex=function(){return"\\scientificNotation{"+this.blocks[0].latex()+"}{"+this.blocks[1].latex()+"}"},t.finalizeTree=function(){this.downInto=this.ends[Te],this.upInto=this.ends[Qe],this.ends[Te].upOutOf=this.ends[Qe],this.ends[Qe].downOutOf=this.ends[Te],this.ends[Te].write=function(t,e){RegExp(/[0-9]/).test(e)||t.insRightOf(this.parent),Q.p.write.apply(this,arguments)},this.ends[Qe].write=function(t,e){if(RegExp(/[0-9\+\-]/).test(e)){if("+"===e||"-"===e){if(0===t[Te]&&0!==t[Qe]&&("-"===t[Qe].ctrlSeq||"+"===t[Qe].ctrlSeq))return t[Qe].ctrlSeq=e,t[Qe].textTemplate=e,void t[Qe].jQ.html(e);if(0!==t[Te]&&0===t[Te][Te]&&("-"===t[Te].ctrlSeq||"+"===t[Te].ctrlSeq))return t[Te].ctrlSeq=e,t[Te].textTemplate=e,void t[Te].jQ.html(e);0!==t[Te]&&t.insRightOf(this.parent)}}else t.insRightOf(this.parent);Q.p.write.apply(this,arguments)}},t.createLeftOf=function(t){if(e.createLeftOf.apply(this,arguments),"undefined"!=typeof this.incorporate_previous){var n=this[Te];if(0===n)return;if(0===n[Te])return;for(next=n[Te];0!==next&&"undefined"!=typeof next.ctrlSeq&&next.ctrlSeq.match(/^[0-9\.]$/);next=n[Te])next.disown().adopt(this.ends[Te],0,this.ends[Te].ends[Te]),next.jQ.prependTo(this.ends[Te].jQ);n.remove(),t.insAtLeftEnd(this.ends[Qe]),this.ends[Qe].write(t,this.incorporate_previous)}}}),ae=Ce(y,function(t,e){t.init=function(t,e){var n='<span><span class="mq-large-operator mq-non-leaf"><span class="mq-to"><span>&1</span></span><big>'+e+'</big><span class="mq-from"><span>&0</span></span></span><span class="mq-non-leaf"><span class="mq-scaled mq-paren">(</span><span class="mq-non-leaf">&2</span><span class="mq-scaled mq-paren">)</span></span></span>';j.prototype.init.call(this,t,n)},t.createLeftOf=function(t){e.createLeftOf.apply(this,arguments),I("n").createLeftOf(t),H().createLeftOf(t)},t.reflow=function(){var t=this.jQ.children(":last").children(":first").add(this.jQ.children(":last").children(":last")),e=this.jQ.children(":last").children(":eq(1)"),n=e.outerHeight()/parseInt(e.css("fontSize"),10);X(t,ke(1+.2*(n-1),1.2),1.05*n)},t.latex=function(){return this.ctrlSeq+"_{"+this.blocks[0].latex()+"}^{"+this.blocks[1].latex()+"}\\left({"+this.blocks[2].latex()+"}\\right)"
3
+ },t.text=function(t){return" "+this.ctrlSeq+'("'+this.blocks[0].text(t).replace("=",'" , ')+" , "+this.blocks[1].text(t)+","+this.blocks[2].text(t)+")"},t.parser=function(){var t,e=x.string,n=x.optWhitespace,i=(x.whitespace,x.succeed),s=k.block,r=this,o=r.blocks=[Q(),Q(),Q()];for(t=0;t<o.length;t+=1)o[t].adopt(r,r.ends[Qe],0);return n.then(e("_")).then(function(){var t=o[0];return s.then(function(e){return e.children().adopt(t,t.ends[Qe],0),i(r)})}).then(n).then(e("^")).then(function(){var t=o[1];return s.then(function(e){return e.children().adopt(t,t.ends[Qe],0),i(r)})}).then(e("\\left(")).then(function(){var t=o[2];return s.then(function(e){return e.children().adopt(t,t.ends[Qe],0),i(r)})}).then(e("\\right)")).result(r)},t.finalizeTree=function(){this.downInto=this.ends[Te],this.upInto=this.ends[Qe],this.ends[Te].upOutOf=this.ends[Qe],this.ends[Qe].downOutOf=this.ends[Te]}}),_e["∑"]=_e.sum=_e.summation=i(ae,"\\sum ","&sum;"),_e["∏"]=_e.prod=_e.product=i(ae,"\\prod ","&prod;"),_e.coprod=_e.coproduct=i(ae,"\\coprod ","&#8720;"),_e.subscript=_e._=Ce(re,function(t,e){t.supsub="sub",t.ctrlSeq="_",t.htmlTemplate='<span class="mq-supsub mq-non-leaf"><span class="mq-sub">&0</span><span style="display:inline-block;width:0">&nbsp;</span></span>',t.textTemplate=["_"],t.finalizeTree=function(){this.downInto=this.sub=this.ends[Te],this.sub.upOutOf=u,e.finalizeTree.call(this)}}),_e.superscript=_e.supscript=_e["^"]=Ce(re,function(t,e){t.supsub="sup",t.ctrlSeq="^",t.htmlTemplate='<span class="mq-supsub mq-non-leaf mq-sup-only"><span class="mq-sup">&0</span></span>',t.textTemplate=["^"],t.finalizeTree=function(){this.upInto=this.sup=this.ends[Qe],this.sup.downOutOf=u,e.finalizeTree.call(this)}}),le=_e.frac=_e.dfrac=_e.cfrac=_e.fraction=Ce(y,function(t){t.ctrlSeq="\\frac",t.htmlTemplate='<span class="mq-fraction mq-non-leaf"><span class="mq-numerator">&0</span><span class="mq-denominator">&1</span><span style="display:inline-block;width:0">&nbsp;</span></span>',t.textTemplate=["((",")/(","))"],t.finalizeTree=function(){this.upInto=this.ends[Qe].upOutOf=this.ends[Te],this.downInto=this.ends[Te].downOutOf=this.ends[Qe]}}),ce=_e.over=Ee["/"]=Ce(le,function(e,n){e.createLeftOf=function(e){if(!this.replacedFragment){for(var i=e[Te];i&&!(i instanceof T||i instanceof(_e.text||t)||i instanceof ae||"\\ "===i.ctrlSeq||/^[,;:]$/.test(i.ctrlSeq));)i=i[Te];i instanceof ae&&i[Qe]instanceof re&&(i=i[Qe],i[Qe]instanceof re&&i[Qe].ctrlSeq!=i.ctrlSeq&&(i=i[Qe])),i!==e[Te]&&(this.replaces(Le(i[Qe]||e.parent.ends[Te],e[Te])),e[Te]=i)}n.createLeftOf.call(this,e)}}),he=_e.sqrt=_e["√"]=Ce(y,function(t,e){t.ctrlSeq="\\sqrt",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-sqrt-prefix">&radic;</span><span class="mq-non-leaf mq-sqrt-stem">&0</span></span>',t.textTemplate=[" sqrt(",")"],t.parser=function(){return k.optBlock.then(function(t){return k.block.map(function(e){var n=pe();return n.blocks=[t,e],t.adopt(n,0,0),e.adopt(n,t,0),n})}).or(e.parser.call(this))},t.reflow=function(){var t=this.ends[Qe].jQ;X(t.prev(),1,t.innerHeight()/+t.css("fontSize").slice(0,-2)-.1)}}),ue=_e.vec=Ce(y,function(t){t.ctrlSeq="\\vec",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-vector-prefix">&rarr;</span><span class="mq-vector-stem">&0</span></span>',t.textTemplate=["vec(",")"]}),pe=_e.nthroot=Ce(he,function(t){t.htmlTemplate='<sup class="mq-nthroot mq-non-leaf">&0</sup><span class="mq-scaled"><span class="mq-sqrt-prefix mq-scaled">&radic;</span><span class="mq-sqrt-stem mq-non-leaf">&1</span></span>',t.textTemplate=["sqrt[","](",")"],t.latex=function(){return"\\sqrt["+this.ends[Te].latex()+"]{"+this.ends[Qe].latex()+"}"},t.text=function(t){return" "+this.ends[Qe].text(t)+"^(1/"+this.ends[Te].text(t)+")"}}),fe=_e.begin=Ce(y,function(t,e){t.numBlocks=function(){return this.col*this.row},t.init=function(t,n,i){var s,r,o,a;for(this.col=n,this.row=i,this.ctrlSeq=t,s="",r=0;i>r;r++){for(o="",a=0;n>a;a++)o+='<span class="mq-cell">&'+(r*n+a)+"</span>";s+='<span class="mq-row">'+o+"</span>"}switch(this.ctrlSeq){case"\\pmatrix":s='<span class="mq-scaled mq-paren">(</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">)</span>';break;case"\\bmatrix":s='<span class="mq-scaled mq-paren">[</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">]</span>';break;case"\\Bmatrix":s='<span class="mq-scaled mq-paren">{</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">}</span>';break;case"\\vmatrix":s='<span class="mq-scaled mq-paren">|</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">|</span>';break;case"\\Vmatrix":s='<span class="mq-scaled mq-paren">||</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">||</span>';break;default:s='<span class="mq-matrix">'+s+"</span>"}e.init.call(this,this.ctrlSeq,'<span class="mq-matrix-outer mq-non-leaf">'+s+"</span>",["text"])},t.reflow=function(){var t=this.jQ.children(".mq-paren"),e=this.jQ.children(".mq-matrix").first(),n=e.outerHeight()/(1.133333*parseInt(e.css("fontSize"),10));X(t,ke(1+.2*(n-1),1.2),1.05*n),t.css("position","relative"),t.css("top",Math.round(.6*n)+"px")},t.contextMenu=function(t,e){var n=this,i=[{text:"Insert Column Before",handler:function(){n.insertColumn(t,Te)}},{text:"Insert Column After",handler:function(){n.insertColumn(t,Qe)}},{text:"Insert Row Before",handler:function(){n.insertRow(t,Te)}},{text:"Insert Row After",handler:function(){n.insertRow(t,Qe)}}];this.col>1&&i.push({text:"Delete Column",handler:function(){n.deleteColumn(t)}}),this.row>1&&i.push({text:"Delete Row",handler:function(){n.deleteRow(t)}}),this.showPopupMenu(i,e)},t.latex=function(){var t="",e=1,n=this.col,i=this.numBlocks(),s=this.ctrlSeq.substring(1,this.ctrlSeq.length);return this.eachChild(function(s){s.ends[Te]&&(t+=s.latex()),e!=i&&(t+=e%n==0?" \\\\ ":" & "),e++}),"\\begin{"+s+"}"+t+"\\end{"+s+"}"},t.text=function(t){var e,n,i=[];for(this.eachChild(function(e){i.push(e.ends[Te]?e.text(t):0)}),e="",n=0;n<i.length;n++)n>0&&n%this.col==0?e+="],[":n>0&&(e+=","),e+=i[n];return this.row>1?"[["+e+"]]":"["+e+"]"},t.parser=function(){{var t=(k.block,x.string,x.regex);x.optWhitespace}return t(/^\{[pbvBV]?matrix\}[\s\S]*?\\end\{[pbvBV]?matrix\}/).map(function(t){var e,n,i,s,r,o,a,l,c;for("}"==t.substring(7,1)?(e=t.substring(1,7),t=t.substring(8,t.length-12).trim()):(e=t.substring(1,8),t=t.substring(9,t.length-13).trim()),n=t.split(/\\\\/).map(function(t){return t.trim()}),i=n.length,s=0,r=[],n.forEach(function(t){var e=t.split(/&/);s=Math.max(s,e.length),r=r.concat(e)}),o=fe("\\"+e,s,i),a=o.blocks=Array(o.numBlocks()),l=0;l<a.length;l++)c=a[l]=k.parse(r[l]),c.adopt(o,o.ends[Qe],0);return o})},t.finalizeTree=function(){var t,e,n;for(t=0;t<this.row;t++)for(e=0;e<this.col;e++)n=this.blocks[t*this.col+e],n.upOutOf=0==t&&0!=e?this.blocks[this.row*this.col-this.row+e-1]:this.blocks[(t-1)*this.col+e],n.downOutOf=t+1==this.row&&e+1!=this.col?this.blocks[e+1]:this.blocks[(t+1)*this.col+e]},t.cursorRowCol=function(t){for(var e=0,n=0,i=t.parent;0!==i[Te];)e++,e==this.col&&(e=0,n++),i=i[Te];return{row:n,col:e}},t.deleteRow=function(t){var e,n,i;if(1!=this.row){for(e=this.cursorRowCol(t),n=e.row*this.col,i=0;i<this.col;i++)this.blocks[n].remove(),this.blocks.splice(n,1);n>0&&n<this.blocks.length?(this.blocks[n][Te]=this.blocks[n-1],this.blocks[n-1][Qe]=this.blocks[n]):0==n?this.blocks[n][Te]=0:this.blocks[n-1][Qe]=0,this.jQ.children(".mq-matrix").first().children(".mq-row").eq(e.row).remove(),this.row--,this.finalizeTree(),t.insAtLeftEnd(this.blocks[e.row>0?(e.row-1)*this.col+e.col:e.col]),this.reflow(),this.bubble("workingGroupChange")}},t.deleteColumn=function(t){var e,n,i;if(1!=this.col){for(e=this.cursorRowCol(t),n=e.col,i=0;i<this.row;i++)this.blocks[n].remove(),this.blocks.splice(n,1),n>0&&n<this.blocks.length?(this.blocks[n][Te]=this.blocks[n-1],this.blocks[n-1][Qe]=this.blocks[n]):0==n?this.blocks[n][Te]=0:this.blocks[n-1][Qe]=0,n+=this.col-1;this.col--,this.finalizeTree(),t.insAtLeftEnd(this.blocks[e.col<this.col?e.row*this.col+e.col:e.row*this.col+e.col-1]),this.reflow(),this.bubble("workingGroupChange")}},t.insertRow=function(t,e){var n,i,s,r,o=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[Te]&&0!==t[Qe]:e==Te?!0:!1,i=o.row*this.col+(n?0:this.col),n?this.jQ.children(".mq-matrix").first().children(".mq-row").eq(o.row).before('<span class="mq-row"></span>'):this.jQ.children(".mq-matrix").first().children(".mq-row").eq(o.row).after('<span class="mq-row"></span>'),s=0;s<this.col;s++)r=Q(),r.adopt(this,i+s>0?this.blocks[i+s-1]:0,i+s>0?this.blocks[i+s-1][Qe]:this.ends[Te]),r.jQ=Se('<span class="mq-cell mq-empty" '+qe+'="'+r.id+'"></span>'),i+s>0&&(this.blocks[i+s-1][Qe]=r),this.blocks.splice(i+s,0,r),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(o.row+(n?0:1)).append(r.jQ);i+s<this.blocks.length&&(this.blocks[i+s][Te]=r,r[Qe]=this.blocks[i+s]),this.row++,this.finalizeTree(),t.insAtLeftEnd(this.blocks[i]),this.reflow(),this.bubble("workingGroupChange")},t.insertColumn=function(t,e){var n,i,s,r=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[Te]&&0!==t[Qe]:e==Te?!0:!1,i=this.row-1;i>=0;i--)s=Q(),n?(s.adopt(this,i*this.col+r.col-1>=0?this.blocks[i*this.col+r.col-1]:0,this.blocks[i*this.col+r.col]),s.jQ=Se('<span class="mq-cell mq-empty" '+qe+'="'+s.id+'"></span>'),i*this.col+r.col-1>=0&&(this.blocks[i*this.col+r.col-1][Qe]=s),this.blocks[i*this.col+r.col][Te]=s,this.blocks.splice(i*this.col+r.col,0,s),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(i).children(".mq-cell").eq(r.col).before(s.jQ)):(s.adopt(this,this.blocks[i*this.col+r.col],i*this.col+r.col+1<this.row*this.col?this.blocks[i*this.col+r.col+1]:0),s.jQ=Se('<span class="mq-cell mq-empty" '+qe+'="'+s.id+'"></span>'),this.blocks[i*this.col+r.col][Qe]=s,i*this.col+r.col+1<this.row*this.col&&(this.blocks[i*this.col+r.col+1][Te]=s),this.blocks.splice(i*this.col+r.col+1,0,s),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(i).children(".mq-cell").eq(r.col).after(s.jQ));this.col++,this.finalizeTree(),t.insAtLeftEnd(t.parent[n?Te:Qe]),this.reflow(),this.bubble("workingGroupChange")},t.moveOrInsertColumn=function(t){var e=this.cursorRowCol(t);return e.col+1==this.col?this.insertColumn(t):(t.insAtLeftEnd(t.parent[Qe]),void this.bubble("workingGroupChange"))}}),_e.matrix=i(fe,"\\matrix",1,1),_e.bmatrix=i(fe,"\\bmatrix",1,1),_e.Bmatrix=i(fe,"\\Bmatrix",1,1),_e.vmatrix=i(fe,"\\vmatrix",1,1),_e.Vmatrix=i(fe,"\\Vmatrix",1,1),_e.pmatrix=i(fe,"\\pmatrix",1,1),de=Ce(Ce(y,p),function(e,n){e.init=function(t,e,i,s,r,o,a){n.init.call(this,"\\left"+s,d,[e,i]),this.side=t,this.sides={},this.sides[Te]={ch:e,ctrlSeq:s,textTemplate:o},this.sides[Qe]={ch:i,ctrlSeq:r,textTemplate:a}},e.numBlocks=function(){return 1},e.html=function(){return this.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-paren'+(this.side===Qe?" mq-ghost":"")+'">'+this.sides[Te].ch+'</span><span class="mq-non-leaf">&0</span><span class="mq-scaled mq-paren'+(this.side===Te?" mq-ghost":"")+'">'+this.sides[Qe].ch+"</span></span>",n.html.call(this)},e.latex=function(){return"\\left"+this.sides[Te].ctrlSeq+this.ends[Te].latex()+"\\right"+this.sides[Qe].ctrlSeq},e.text=function(t){return"\\left["!==this.ctrlSeq||this[Te]instanceof I?this.sides[Te].textTemplate+this.ends[Te].text(t)+this.sides[Qe].textTemplate:"("+this.ends[Te].text(t)+")"},e.oppBrack=function(t,e){return t instanceof de&&t.side&&t.side!==-e&&("|"===this.sides[this.side].ch||t.side===-this.side)&&t},e.closeOpposing=function(t){t.side=0,t.sides[this.side]=this.sides[this.side],t.delimjQs.eq(this.side===Te?0:1).removeClass("mq-ghost").html(this.sides[this.side].ch)},e.createLeftOf=function(t){var e,i,s,r,o;return this.replacedFragment||(e=this.oppBrack(t[Te],Te)||this.oppBrack(t[Qe],Qe)||this.oppBrack(t.parent.parent),!e&&"\\left("===this.ctrlSeq&&t[Te]instanceof I&&t[Te].autoUnItalicize(t),e||"\\left["!==this.ctrlSeq||0!==t[Te]||0!==t[Qe]||"undefined"==typeof t.parent.parent||t.parent.parent.ctrlSeq!==this.ctrlSeq)?(e?(o=this.side=-e.side,this.closeOpposing(e),e===t.parent.parent&&t[o]&&(Le(t[o],t.parent.ends[o],-o).disown().withDirAdopt(-o,e.parent,e,e[o]).jQ.insDirOf(o,e.jQ),e.bubble("reflow"))):(e=this,o=e.side,e.replacedFragment?e.side=0:t[-o]&&(e.replaces(Le(t[-o],t.parent.ends[-o],o)),t[-o]=0),n.createLeftOf.call(e,t)),o===Te?t.insAtLeftEnd(e.ends[Te]):t.insRightOf(e),void t.parent.bubble("workingGroupChange")):(i=t.parent.parent[Te],s=t.parent.parent.parent,t.parent.parent.unwrap(),0!==i?t.insRightOf(i):t.insAtLeftEnd(s),r=fe("\\bmatrix",1,1),void r.createLeftOf(t))},e.placeCursor=t,e.unwrap=function(){this.ends[Te].children().disown().adopt(this.parent,this,this[Qe]).jQ.insertAfter(this.jQ),this.remove()},e.deleteSide=function(t,e,n){var i,s=this.parent,r=this[t],o=s.ends[t];return t===this.side?(this.unwrap(),void(r?n.insDirOf(-t,r):n.insAtDirEnd(t,s))):(this.side=-t,void(this.oppBrack(this.ends[Te].ends[this.side],t)?(this.closeOpposing(this.ends[Te].ends[this.side]),i=this.ends[Te].ends[t],this.unwrap(),i.siblingCreated&&i.siblingCreated(n.options,t),r?n.insDirOf(-t,r):n.insAtDirEnd(t,s)):(this.oppBrack(this.parent.parent,t)?(this.parent.parent.closeOpposing(this),this.parent.parent.unwrap()):(this.sides[t]={ch:me[this.sides[this.side].ch],ctrlSeq:me[this.sides[this.side].ctrlSeq]},this.delimjQs.removeClass("mq-ghost").eq(t===Te?0:1).addClass("mq-ghost").html(this.sides[t].ch)),r?(i=this.ends[Te].ends[t],Le(r,o,-t).disown().withDirAdopt(-t,this.ends[Te],i,0).jQ.insAtDirEnd(t,this.ends[Te].jQ.removeClass("mq-empty")),i.siblingCreated&&i.siblingCreated(n.options,t),n.insDirOf(-t,r)):e?n.insDirOf(t,this):n.insAtDirEnd(t,this.ends[Te]))))},e.deleteTowards=function(t,e){this.deleteSide(-t,!1,e)},e.finalizeTree=function(){this.ends[Te].deleteOutOf=function(t,e){this.parent.deleteSide(t,!0,e)},this.finalizeTree=this.intentionalBlur=function(){this.delimjQs.eq(this.side===Te?1:0).removeClass("mq-ghost"),this.side=0}},e.siblingCreated=function(t,e){e===-this.side&&this.finalizeTree()}}),me={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","\\{":"\\}","\\}":"\\{","&lang;":"&rang;","&rang;":"&lang;","\\langle ":"\\rangle ","\\rangle ":"\\langle ","|":"|"},f("("),f("["),_e.langle=i(de,Te,"&lang;","&rang;","\\langle ","\\rangle ","(",")"),_e.rangle=i(de,Qe,"&lang;","&rang;","\\langle ","\\rangle ","(",")"),Ee["|"]=i(de,Te,"|","|","|","|","abs(",")"),Ee["{"]=i(de,Te,"{","}","\\{","\\}","(",")"),Ee["}"]=i(de,Qe,"{","}","\\{","\\}","(",")"),_e.left=Ce(y,function(t){t.parser=function(){var t=x.regex,e=x.string,n=(x.succeed,x.optWhitespace);return n.then(t(/^(?:[([|]|\\\{)/)).then(function(i){var s="\\"===i.charAt(0)?i.slice(1):i;return k.then(function(r){return e("\\right").skip(n).then(t(/^(?:[\])|]|\\\})/)).map(function(t){var e="\\"===t.charAt(0)?t.slice(1):t,n="["===s?"[":"|"===s?"abs(":"(",o="["===s?"]":")",a=de(0,s,e,i,t,n,o);return a.blocks=[r],r.adopt(a,0,0),a})})})}}),_e.right=Ce(y,function(t){t.parser=function(){return x.fail("unmatched \\right")}}),ge=_e.binom=_e.binomial=Ce(Ce(y,p),function(t){t.ctrlSeq="\\binom",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-paren mq-scaled">(</span><span class="mq-non-leaf"><span class="mq-array mq-non-leaf"><span>&0</span><span>&1</span></span></span><span class="mq-paren mq-scaled">)</span></span>',t.textTemplate=["choose(",",",")"]}),be=_e.choose=Ce(ge,function(t){t.createLeftOf=ce.prototype.createLeftOf}),ve=Ce(a.MathField,function(t){t.init=function(t,e){c(t),this.__options=g();var n=ze(this,t,e);n.editable=!0,n.createTextarea(),n.editablesTextareaEvents(),n.cursor.insAtRightEnd(t)}}),_e.MathQuillMathField=Ce(y,function(t,e){t.ctrlSeq="\\MathQuillMathField",t.htmlTemplate='<span class="mq-editable-field"><span class="mq-root-block">&0</span></span>',t.parser=function(){var t=this,n=x.string,i=x.regex,s=x.succeed;return n("[").then(i(/^[a-z][a-z0-9]*/i)).skip(n("]")).map(function(e){t.name=e}).or(s()).then(e.parser.call(t))},t.finalizeTree=function(){ve(this.ends[Te],this.jQ)},t.registerInnerField=function(t){t.push(t[this.name]=this.ends[Te].controller.API)},t.latex=function(){return this.ends[Te].latex()},t.text=function(t){return this.ends[Te].text(t)}})}();
@@ -202,6 +202,10 @@
202
202
  display: block;
203
203
  float: left;
204
204
  }
205
+ .mq-math-mode .mq-supsub .mq-sub span {
206
+ font-family: "Times New Roman", Symbola, serif;
207
+ font-style: italic;
208
+ }
205
209
  .mq-math-mode .mq-supsub.mq-limit .mq-sub {
206
210
  margin-left: -0.25em;
207
211
  }
@@ -267,17 +271,12 @@
267
271
  .mq-math-mode .mq-matrix > span.mq-row > span.mq-cell.mq-empty {
268
272
  border-color: rgba(0, 0, 0, 0.1);
269
273
  }
270
- .mq-math-mode .mq-operator-name {
274
+ .mq-math-mode span.mq-operator-name var,
275
+ .mq-math-mode span.mq-operator-name span {
271
276
  font-family: Symbola, "Times New Roman", serif;
272
277
  line-height: .9;
273
278
  font-style: normal;
274
279
  }
275
- .mq-math-mode var.mq-operator-name.mq-first {
276
- padding-left: .2em;
277
- }
278
- .mq-math-mode var.mq-operator-name.mq-last {
279
- padding-right: .2em;
280
- }
281
280
  .mq-math-mode .mq-fraction {
282
281
  font-size: 90%;
283
282
  text-align: center;
@@ -1,3 +1,3 @@
1
1
  module MathquillSwiftCalcsRails
2
- VERSION = "0.9.3.112"
2
+ VERSION = "0.9.3.113"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mathquill_swiftcalcs_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3.112
4
+ version: 0.9.3.113
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brentan Alexander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-26 00:00:00.000000000 Z
11
+ date: 2015-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties