mathquill_swiftcalcs_rails 0.9.3.115 → 0.9.3.116
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5329f18a078bf429b5e00f78dc6c84db19ca3068
|
4
|
+
data.tar.gz: b6b9b13e6fb985570f3a8873ea35ad5d29ad3017
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5987e28432fe2c94e11abaf586c9b15d4df6312b3ff98af9b173e38dcb6744243cec617b02a495c496497660b925823381467bcb3f6b5e8adedabf408afa838d
|
7
|
+
data.tar.gz: 7a77ec1cd64b5249814df82eca1ed5d64b4acdee0f2173d9d889c047949e221f5bf282a5ab7102e0a8d6897e9716dbde85491de54cdc815fb0be9ee53c3586c1
|
@@ -1,3 +1,3 @@
|
|
1
|
-
!function(){function t(){}function e(t){var e=t.length-1;return function(){var n=xe.call(arguments,0,e),i=xe.call(arguments,e);return t.apply(this,n.concat([i]))}}function n(t){return e(function(e,n){"function"!=typeof e&&(e=ke(e));var i=function(t){return e.apply(t,[t].concat(n))};return t.call(this,i)})}function i(t){var e=xe.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===ye||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[ye]===n}()),s("rightward is properly set up",function(){return n?n[ye]===e&&n.parent===t:t.ends[Se]===e}())}function a(t){if(!t||!t.nodeType)return null;var e=Ce(t).children(".mq-root-block").attr(qe);return e?Qe.byId[e].controller.API:null}function c(t){function e(e,n){var i=a(e);return i instanceof t||!e||!e.nodeType?i:t(Ce(e),n)}return e.prototype=t.prototype,e}function l(t){var e,n="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){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 u(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);U(this.delimjQs,ve(1+.2*(t-1),1.2),1.05*t)}}function f(t,e){var e=e||t,n=fe[t],s=fe[e];Ae[t]=i(ue,ye,t,n,e,s,e,s),Ae[n]=i(ue,Se,t,n,e,s,e,s)}var p,d,m,g,b,q,v,w,x,k,O,y,S,C,j,Q,T,_,A,L,D,E,R,I,z,B,M,F,P,W,$,N,G,U,H,V,X,Z,K,Y,J,te,ee,ne,ie,se,re,oe,ae,ce,le,he,ue,fe,pe,de,me,ge=window.jQuery,be="mathquill-command-id",qe="mathquill-block-id",ve=Math.min,we=Math.max,xe=[].slice,ke=e(function(t,n){return e(function(e,i){return t in e?e[t].apply(e,n.concat(i)):void 0})}),Oe=function(t,e,n){function i(t){return"object"==typeof t}function s(t){return"function"==typeof t}function r(){}return function o(a,c){function l(){var t=new h;return s(t.init)&&t.init.apply(t,arguments),t}function h(){}var u,f,p;return c===n&&(c=a,a=Object),l.Bare=h,u=r[t]=a[t],f=h[t]=l[t]=l.p=new r,f.constructor=l,l.mixin=function(e){return h[t]=l[t]=o(l,e)[t],l},(l.open=function(t){if(p={},s(t)?p=t.call(l,f,u,l,a):i(t)&&(p=t),i(p))for(var n in p)e.call(p,n)&&(f[n]=p[n]);return s(f.init)||(f.init=a),l})(c)}}("prototype",{}.hasOwnProperty),ye=a.L=-1,Se=a.R=1,Ce=Oe(ge,function(t){t.insDirOf=function(t,e){return t===ye?this.insertBefore(e.first()):this.insertAfter(e.last())},t.insAtDirEnd=function(t,e){return t===ye?this.prependTo(e):this.appendTo(e)}}),je=Oe(function(t){t.parent=0,t[ye]=0,t[Se]=0,t.init=function(t,e,n){this.parent=t,this[ye]=e,this[Se]=n},this.copy=function(t){return je(t.parent,t[ye],t[Se])}}),Qe=Oe(function(t){function e(){return i+=1}t[ye]=0,t[Se]=0,t.parent=0;var i=0;this.byId={},t.init=function(){this.id=e(),Qe.byId[this.id]=this,this.ends={},this.ends[ye]=0,this.ends[Se]=0},t.dispose=function(){delete Qe.byId[this.id]},t.toString=function(){return"{{ MathQuill Node #"+this.id+" }}"},t.jQ=Ce(),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&&Qe.byId[n].jQadd(t),i&&Qe.byId[i].jQadd(t)),t=t.firstChild;t;t=t.nextSibling)e(t)}var n;for(t=Ce(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[ye],e[Se]),n},t.createLeftOf=function(t){return this.createDir(ye,t)},t.selectChildren=function(t,e){return De(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[ye]&&0===this.ends[Se]},t.children=function(){return Te(this.ends[ye],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 Te(this,this).withDirAdopt(t,e,n,i),this},t.adopt=function(t,e,n){return Te(this,this).adopt(t,e,n),this},t.disown=function(){return Te(this,this).disown(),this},t.remove=function(){return this.jQ.remove(),this.postOrder("dispose"),this.disown()}}),Te=Oe(function(t){t.init=function(t,e,n){n===p&&(n=ye),r(n),s("no half-empty fragments",!t==!e),this.ends={},t&&(s("withDir is passed to Fragment",t instanceof Qe),s("oppDir is passed to Fragment",e instanceof Qe),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=Ce(),t.withDirAdopt=function(t,e,n,i){return t===ye?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[ye])?(r=i.ends[Se],e||(t.ends[ye]=s),n?n[ye]=r:t.ends[Se]=r,i.ends[Se][Se]=n,i.each(function(n){n[ye]=e,n.parent=t,e&&(e[Se]=n),e=n}),i):this},t.disown=function(){var t,e,n=this,i=n.ends[ye];return!i||n.disowned?n:(n.disowned=!0,t=n.ends[Se],e=i.parent,o(e,i[ye],i),o(e,t,t[Se]),i[ye]?i[ye][Se]=t[Se]:e.ends[ye]=t[Se],t[Se]?t[Se][ye]=i[ye]:e.ends[Se]=i[ye],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[ye];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}}),_e={},Ae={},Le=Oe(je,function(t){t.init=function(t,e,n){this.parent=t,this.options=e,this.container=n;var i=this.jQ=this._jQ=Ce('<span class="mq-cursor">​</span>');this.blink=function(){i.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[ye][ye]===this[ye]?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=Ce(),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(ye,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(ye,t)},t.insAtRightEnd=function(t){return this.insAtDirEnd(Se,t)},t.jumpUpDown=function(t,e){var n,i,s=this;s.upDownCache[t.id]=je.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[ye];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[ye])this[Se]=this[ye][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[ye]}this[Se]?this.insLeftOf(this[Se]):this.insAtRightEnd(e),t.jQ.remove(),t[ye].siblingDeleted&&t[ye].siblingDeleted(i.options,Se),t[Se].siblingDeleted&&t[Se].siblingDeleted(i.options,ye)},t.workingGroupChange=function(){var t,e=this.container,n=!1;e.find(".active_block").replaceWith(function(){return Ce(this).contents()}),e.find(".hasCursor_highlighting").removeClass("hasCursor_highlighting"),t=this.jQ,t.addClass("hasCursor_highlighting"),n=!1,t.prevAll().each(function(){var t=Ce(this);t.hasClass("mq-binary-operator")&&(n=!0),n||t.addClass("hasCursor_highlighting")}),n=!1,t.nextAll().each(function(){var t=Ce(this);t.hasClass("mq-binary-operator")&&(n=!0),n||t.addClass("hasCursor_highlighting")}),e.find(".mq-hasCursor").first().children(".hasCursor_highlighting").wrapAll("<span class='active_block'></span>")},t.startSelection=function(){var t,e=this.anticursor=je.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,c=this.anticursor;if(this[ye]===c[ye]&&this.parent===c.parent)return!1;for(t=this;t.parent;t=t.parent)if(t.parent.id in c.ancestors){e=t.parent;break}if(s("cursor and anticursor in the same tree",e),n=c.ancestors[e.id],o=Se,t[ye]!==n)for(a=t;a;a=a[Se])if(a[Se]===n[Se]){o=ye,i=t,r=n;break}return o===Se&&(i=n,r=t),i instanceof je&&(i=i[Se]),r instanceof je&&(r=r[ye]),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[ye]=this.selection.ends[ye][ye],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[ye]=t.ends[ye][ye],this[Se]=t.ends[Se][Se],delete this.selection),t}}),De=Oe(Te,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]()})}}),Ee=Oe(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=Le(e,t.__options,n)},t.handle=function(t,e){var n=this.API.__options.handlers;n&&n[t]&&(e===ye||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=d,a},d=window.MathQuill,window.MathQuill=a,m=Oe(),g={},a.__options=m.p,b=Oe(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=m(),this.config(n),i=Ee(this,t,e),i.createTextarea(),s=e.contents().detach(),t.jQ=Ce('<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=g[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=b.prototype,a.StaticMath=c(Oe(b,function(t,e){t.init=function(t){this.initRoot(j(),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}})),q=a.EditableField=Oe(b,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[ye];)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(ye)},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}}),v=Oe(function(t,e,n){function i(t,e){throw t=t?"'"+t+"'":"EOF","Parse Error: "+e+" at "+t}var r,o,a,c,l,h,u,f,p,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 l=e,n=t,!1}function c(){return!1}var l,h,u=[],f=!0;for(h=0;t>h;h+=1)if(f=i._(n,o,a),!f)return r(n,l);for(;e>h&&f;h+=1)f=i._(n,o,c);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)})},c=n.fail=function(t){return n(function(e,n,i){return i(e,t)})},l=n.letter=o(/^[a-z]/i),h=n.letters=o(/^[a-z]*/i),u=n.digit=o(/^[0-9]/),f=n.digits=o(/^[0-9]*/),p=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)})}),w=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){w=t,clearTimeout(d),d=setTimeout(t)}function r(e){w(),w=t,clearTimeout(d),q.val(e),e&&q[0].select(),m=!!e}function o(){var t=q[0];return"selectionStart"in t?t.selectionStart!==t.selectionEnd:!1}function a(){i.keystroke(e(g),g)}function c(e){g=e,b=null,a(),m&&s(function(){q[0].select(),w=t,clearTimeout(d)})}function l(t){g&&b&&a(),b=t,s(h)}function h(){if(!o()){var t=q.val();1===t.length?(q.val(""),i.typedText(t)):t&&q[0].select()}}function u(){g=b=null}function f(){q.focus(),s(p)}function p(){var t=q.val();q.val(""),t&&i.paste(t)}var d,m,g=null,b=null,q=ge(n),v=ge(i.container||q),w=t;return v.bind("keydown keypress input keyup focusout paste",function(){w()}),m=!1,v.bind({keydown:c,keypress:l,focusout:u,paste:f}),{select:r}}}(),Ee.open(function(t){t.exportText=function(t){return this.root.foldChildren("",function(e,n){return e+n.text(t)})}}),Ee.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"),Ce(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()}),Ce(window).on("blur",t)}),i.blurred=!0,r.hide().parent.blur()}}),Ee.open(function(t){t.keystroke=function(t,e){this.cursor.parent.keystroke(t,e,this)}}),Qe.open(function(t){t.keystroke=function(t,e,n){var i=n.cursor;switch(t){case"Ctrl-Shift-Backspace":case"Ctrl-Backspace":for(;i[ye]||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(ye,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[ye];)n.selectLeft();break;case"Ctrl-Shift-Home":for(;i[ye]||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[ye])for(;i[ye];)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[ye];)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")}}),Ee.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[ye][i]?n.insAtRightEnd(n[ye][i]):n.parent.bubble(function(t){var e=t[s];return e&&("function"==typeof e&&(e=t[s](n)),e instanceof Qe&&n.jumpUpDown(t,e),e!==!0)?!1:void 0}),n.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.workingGroupChange(),this.notify("move")):void 0},g.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.workingGroupChange(),this.notify("move")},t.moveLeft=function(){return this.moveDir(ye)},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[ye].siblingDeleted&&e[ye].siblingDeleted(e.options,Se),e[Se].siblingDeleted&&e[Se].siblingDeleted(e.options,ye),e.parent.bubble("reflow"),e.workingGroupChange(),this},t.backspace=function(){return this.deleteDir(ye)},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(ye)},t.selectRight=function(){return this.selectDir(Se)}}),x=function(){function t(t){var e,n,i=j();if(t instanceof A&&t.ctrlSeq.length>1)for(e=t.ctrlSeq,n=0;n<e.length;n+=1)A(e[n]).adopt(i,i.ends[Se],0);else t.adopt(i,0,0);return i}function e(t){var e,n=t[0]||j();for(e=1;e<t.length;e+=1)t[e].children().adopt(n,n.ends[Se],0);return n}var n=v.string,i=v.regex,s=(v.letter,v.any),r=v.optWhitespace,o=v.succeed,a=v.fail,c=i(/^[a-z]+[0-9]*/i).map(function(t){return A(t)}),l=i(/^[^${}\\_^]/).map(function(t){return S(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(c).or(l),f=n("{").then(function(){return d}).skip(n("}")),p=r.then(f.or(u.map(t))),d=p.many().map(e).skip(r),m=n("[").then(p.then(function(t){return"]"!==t.join("latex")?o(t):a()}).many().map(e).skip(r)).skip(n("]")),g=d;return g.block=p,g.optBlock=m,g}(),Ee.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=v.all,s=v.eof,r=x.skip(s).or(i.result(!1)).parse(t);return r&&!r.isEmpty()&&(r.children().adopt(n.parent,n[ye],n[Se]),e=r.jQize(),e.insertBefore(n.jQ),n[ye]=r.ends[Se],r.finalizeInsert(n.options,n),r.ends[Se][Se].siblingCreated&&r.ends[Se][Se].siblingCreated(n.options,ye),r.ends[ye][ye].siblingCreated&&r.ends[ye][ye].siblingCreated(n.options,Se),n.parent.bubble("reflow")),this},t.renderLatexMath=function(t){var e,n,i=this.root,s=this.cursor,r=v.all,o=v.eof,a=x.skip(o).or(r.result(!1)).parse(t);i.eachChild("postOrder","dispose"),i.ends[ye]=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)}}),Ee.open(function(e){e.delegateMouseEvents=function(){var e=this.root.jQ;this.container.bind("contextmenu.mathquill",function(t){for(var n=Ce(t.target).closest(".mq-root-block"),i=Qe.byId[n.attr(qe)||e.attr(qe)],s=i.controller,r=s.cursor,o=s.seek(Ce(t.target),t.pageX,t.pageY).cursor.parent;!(o instanceof O);)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=Ce(t.target)}function s(t){h.anticursor||h.startSelection(),l.seek(o,t.pageX,t.pageY).cursor.select(),o=p}function r(t){h.blink=u,h.selection||(l.editable?h.show():f.detach()),a.unbind("mousemove",i),Ce(t.target.ownerDocument).unbind("mousemove",s).unbind("mouseup",r)}var o,a=Ce(n.target).closest(".mq-root-block"),c=Qe.byId[a.attr(qe)||e.attr(qe)],l=c.controller,h=l.cursor,u=h.blink,f=l.textareaSpan,d=l.textarea;l.blurred&&(l.editable||a.prepend(f),d.focus()),n.preventDefault(),n.target.unselectable=!0,h.blink=t,l.seek(Ce(n.target),n.pageX,n.pageY).cursor.startSelection(),a.mousemove(i),Ce(n.target.ownerDocument).mousemove(s).mouseup(r)})}}),Ee.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(be),n||(i=t.parent(),n=i.attr(qe)||i.attr(be))),r=n?Qe.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.workingGroupChange(),this}}),Ee.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[ye]===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)}}),Ee.open(function(t){m.p.substituteTextarea=function(){return Ce("<textarea>")[0]},t.createTextarea=function(){var t,e=this.textareaSpan=Ce('<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=Ce(n).appendTo(e),t=this,t.cursor.selectionChanged=function(){t.selectionChanged()},t.container.bind("copy",function(){t.setTextareaSelection()})},t.selectionChanged=function(){var t=this;H(t.container[0]),t.textareaSelectionTimeout===p&&(t.textareaSelectionTimeout=setTimeout(function(){t.setTextareaSelection()}))},t.setTextareaSelection=function(){this.textareaSelectionTimeout=p;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=w(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()}}),k=Oe(Qe,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,ye),n[ye].siblingCreated&&n[ye].siblingCreated(t,Se),n.bubble("reflow")},t.contextMenu=function(){},t.showPopupMenu=function(t,e){var n,i;for(1==Ce("#mq-popup-menu").length&&Ce("#mq-popup-menu").remove(),n=Ce("<ul></ul>").attr("id","mq-popup-menu").appendTo("body"),i=0;i<t.length;i++)Ce("<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(),Ce(document).bind("click",function(t){n.hide(),Ce(this).unbind(t)})}}),O=Oe(k,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=x.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,s,r=this;if("undefined"!=typeof t.parent&&t.parent.parent instanceof he){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 ue&&"\\left["===t.parent.parent.ctrlSeq&&(","==r.ctrlSeq||";"==r.ctrlSeq))return n=t.parent.parent,0!==n[ye]?t.insRightOf(n[ye]):t.insAtLeftEnd(n.parent),i=he("\\bmatrix",1,1),i.createLeftOf(t),n.ends[ye].children().disown().adopt(i.ends[ye],0,0).jQ.appendTo(i.ends[ye].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[ye],0,0),s.jQ.appendTo(r.ends[ye].jQ)),r.finalizeInsert(t.options),r.placeCursor(t),(this instanceof C||this instanceof re||this instanceof ne||this instanceof ae)&&t.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]=j(),e.adopt(n,n.ends[Se],0)},t.placeCursor=function(t){t.insAtRightEnd(this.foldChildren(this.ends[ye],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 De(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[ye]=t.jQ.offset().left,e[Se]=e[ye]+t.jQ.outerWidth(),e}var i,s=this,r=n(s);return t<r[ye]?e.insLeftOf(s):t>r[Se]?e.insRightOf(s):(i=r[ye],void s.eachChild(function(o){var a=n(o);return t<a[ye]?(t-i<a[ye]-t?o[ye]?e.insAtRightEnd(o[ye]):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]||"")
|
2
|
-
})}}),y=Oe(O,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 v.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}}),S=Oe(y,function(t,e){t.init=function(t,n,i){e.init.call(this,t,"<span>"+(n||t)+"</span>",i||t)},t.createLeftOf=function(t){if("."===this.ctrlSeq)if(0===t[ye]||t[ye]instanceof C)S("0").createLeftOf(t);else if(0!==t[ye]&&"."===t[ye].ctrlSeq)return t[ye].ctrlSeq="…",t[ye].jQ.html('<span class="mq-nonSymbola" style="font-size:0.6em;">…</span>'),void(t[ye].textTemplate="..");e.createLeftOf.call(this,t)}}),C=Oe(y,function(t,e){t.init=function(t,n,i){e.init.call(this,t,'<span class="mq-binary-operator">'+n+"</span>",i)}}),j=Oe(k,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[ye]&&0===this.ends[Se]?"":this.ends[ye]===this.ends[Se]?this.ends[ye].text(t):this.foldChildren("",function(e,n){return e+n.text(t)})},t.keystroke=function(t,n,i){var s;return!i.API.__options.spaceBehavesLikeTab||"Spacebar"!==t&&"Shift-Spacebar"!==t?("Tab"===t&&(s=i.cursor,s[ye]instanceof A&&s[ye].autoOperator(s)),e.keystroke.apply(this,arguments)):(s=i.cursor,s[ye]instanceof A&&s[ye].autoOperator(s),n.preventDefault(),void i.escapeDir("Shift-Spacebar"===t?ye: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[ye].jQ.offset().left)return e.insAtLeftEnd(this);for(;t<n.jQ.offset().left;)n=n[ye];return n.seek(t,e)},t.write=function(t,e,n){var i;if(e.match(/^[a-eg-zA-Z]$/)?i=A(e):e.match(/^[0-9\+\-]$/)&&t[ye]instanceof _&&"e"===t[ye].ctrlSeq&&0!==t[ye][ye]&&"undefined"!=typeof t[ye][ye]&&t[ye][ye].ctrlSeq.match(/^[0-9]$/)?i=ie(e):e.match(/^[0-9\+\-]$/)&&t[ye]instanceof _&&"e"===t[ye].ctrlSeq&&0!==t[ye][ye]&&"\\cdot "===t[ye][ye].ctrlSeq&&0!==t[ye][ye][ye]&&"undefined"!=typeof t[ye][ye][ye]&&t[ye][ye][ye].ctrlSeq.match(/^[0-9]$/)?(t[ye][ye].remove(),i=ie(e)):i=e.match(/^[0-9\.]$/)&&(t[ye]instanceof _||t.parent&&t.parent.parent instanceof ne&&"sub"===t.parent.parent.supsub)?A(e):(i=Ae[e]||_e[e])?i(e):S(e),!(!(i instanceof _)&&t[ye]instanceof A&&t[ye].autoOperator(t)&&i instanceof ue&&i.side===ye)){if(t.parent&&t.parent.parent instanceof D&&t.parent===t.parent.parent.ends[ye]){if(!(i instanceof _||"_"===e&&0===t[Se]))return;if(t[ye]instanceof ne||"_"===e&&0===t[ye])return}!((i instanceof _||i instanceof R)&&t[ye]instanceof S)||t[ye].ctrlSeq.match(/^[\,\u2026]$/)||t.parent&&t.parent.parent instanceof ne?i instanceof C||i instanceof re||i instanceof ne||i instanceof ue&&i.side===Se||0===t[ye]||!(t[ye]instanceof re||t[ye]instanceof ue||t[ye]instanceof ie||t[ye]instanceof ne&&!(i instanceof ue))||_e.cdot().createLeftOf(t):_e.cdot().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}}),Q=Oe(j,l),a.MathField=c(Oe(q,function(t){t.init=function(t,e){t.addClass("mq-editable-field mq-math-mode"),this.initRootAndEvents(Q(),t,e)}})),T=Ae["\\"]=Oe(O,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[ye].focus=function(){return this.parent.jQ.addClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.removeClass("mq-empty"),this},this.ends[ye].blur=function(){return this.parent.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.addClass("mq-empty"),this},this.ends[ye].write=function(t,e,n){return n&&n.remove(),0==this.parent.ends[ye].latex().indexOf("matrix")?void(/^matrix\dx\d$/.test(this.parent.ends[ye].latex())?(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)):S(e).createLeftOf(t)):void(e.match(/[a-z]/i)?S(e).createLeftOf(t):(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)))},this.ends[ye].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 Ce(t.target=n).trigger(t),!1}).insertBefore(this.jQ).add(this.jQ)}},t.latex=function(){return"\\"+this.ends[ye].latex()+" "},t.renderCommand=function(t){var e,n,i;if(this.jQ=this.jQ.last(),this.remove(),this[Se]?t.insLeftOf(this[Se]):t.insAtRightEnd(this.parent),e=this.ends[ye].latex(),e||(e=" "),n=_e[e])n=n(e),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t);else{for(n=D(),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t),t.insAtRightEnd(n.blocks[0]),i=0;i<e.length;i++)A(e[i]).createLeftOf(t);t.insAtRightEnd(n.blocks[1])}}}),_e.notin=_e.sim=_e.cong=_e.equiv=_e.oplus=_e.otimes=Oe(C,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),_e.ast=_e.star=_e.loast=_e.lowast=i(C,"\\ast ","∗"),_e.therefor=_e.therefore=i(C,"\\therefore ","∴"),_e.cuz=_e.because=i(C,"\\because ","∵"),_e.prop=_e.propto=i(C,"\\propto ","∝"),_e["≈"]=_e.asymp=_e.approx=i(C,"\\approx ","≈"),_e.isin=_e["in"]=i(C,"\\in ","∈"),_e.ni=_e.contains=i(C,"\\ni ","∋"),_e.notni=_e.niton=_e.notcontains=_e.doesnotcontain=i(C,"\\not\\ni ","∌"),_e.sub=_e.subset=i(C,"\\subset ","⊂"),_e.sup=_e.supset=_e.superset=i(C,"\\supset ","⊃"),_e.nsub=_e.notsub=_e.nsubset=_e.notsubset=i(C,"\\not\\subset ","⊄"),_e.nsup=_e.notsup=_e.nsupset=_e.notsupset=_e.nsuperset=_e.notsuperset=i(C,"\\not\\supset ","⊅"),_e.sube=_e.subeq=_e.subsete=_e.subseteq=i(C,"\\subseteq ","⊆"),_e.supe=_e.supeq=_e.supsete=_e.supseteq=_e.supersete=_e.superseteq=i(C,"\\supseteq ","⊇"),_e.nsube=_e.nsubeq=_e.notsube=_e.notsubeq=_e.nsubsete=_e.nsubseteq=_e.notsubsete=_e.notsubseteq=i(C,"\\not\\subseteq ","⊈"),_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(C,"\\not\\supseteq ","⊉"),_e.N=_e.naturals=_e.Naturals=i(S,"\\mathbb{N}","ℕ"),_e.P=_e.primes=_e.Primes=_e.projective=_e.Projective=_e.probability=_e.Probability=i(S,"\\mathbb{P}","ℙ"),_e.Z=_e.integers=_e.Integers=i(S,"\\mathbb{Z}","ℤ"),_e.Q=_e.rationals=_e.Rationals=i(S,"\\mathbb{Q}","ℚ"),_e.R=_e.reals=_e.Reals=i(S,"\\mathbb{R}","ℝ"),_e.C=_e.complex=_e.Complex=_e.complexes=_e.Complexes=_e.complexplane=_e.Complexplane=_e.ComplexPlane=i(S,"\\mathbb{C}","ℂ"),_e.H=_e.Hamiltonian=_e.quaternions=_e.Quaternions=i(S,"\\mathbb{H}","ℍ"),_e.quad=_e.emsp=i(S,"\\quad "," "),_e.qquad=i(S,"\\qquad "," "),_e.diamond=i(S,"\\diamond ","◇"),_e.bigtriangleup=i(S,"\\bigtriangleup ","△"),_e.ominus=i(S,"\\ominus ","⊖"),_e.uplus=i(S,"\\uplus ","⊎"),_e.bigtriangledown=i(S,"\\bigtriangledown ","▽"),_e.sqcap=i(S,"\\sqcap ","⊓"),_e.triangleleft=i(S,"\\triangleleft ","⊲"),_e.sqcup=i(S,"\\sqcup ","⊔"),_e.triangleright=i(S,"\\triangleright ","⊳"),_e.odot=i(S,"\\odot ","⊙"),_e.bigcirc=i(S,"\\bigcirc ","◯"),_e.dagger=i(S,"\\dagger ","†"),_e.ddagger=i(S,"\\ddagger ","‡"),_e.wr=i(S,"\\wr ","≀"),_e.amalg=i(S,"\\amalg ","∐"),_e.models=i(S,"\\models ","⊨"),_e.prec=i(S,"\\prec ","≺"),_e.succ=i(S,"\\succ ","≻"),_e.preceq=i(S,"\\preceq ","≼"),_e.succeq=i(S,"\\succeq ","≽"),_e.simeq=i(S,"\\simeq ","≃"),_e.mid=i(S,"\\mid ","∣"),_e.ll=i(S,"\\ll ","≪"),_e.gg=i(S,"\\gg ","≫"),_e.parallel=i(S,"\\parallel ","∥"),_e.bowtie=i(S,"\\bowtie ","⋈"),_e.sqsubset=i(S,"\\sqsubset ","⊏"),_e.sqsupset=i(S,"\\sqsupset ","⊐"),_e.smile=i(S,"\\smile ","⌣"),_e.sqsubseteq=i(S,"\\sqsubseteq ","⊑"),_e.sqsupseteq=i(S,"\\sqsupseteq ","⊒"),_e.doteq=i(S,"\\doteq ","≐"),_e.frown=i(S,"\\frown ","⌢"),_e.vdash=i(S,"\\vdash ","⊦"),_e.dashv=i(S,"\\dashv ","⊣"),_e.longleftarrow=i(S,"\\longleftarrow ","←"),_e.longrightarrow=i(S,"\\longrightarrow ","→"),_e.Longleftarrow=i(S,"\\Longleftarrow ","⇐"),_e.Longrightarrow=i(S,"\\Longrightarrow ","⇒"),_e.longleftrightarrow=i(S,"\\longleftrightarrow ","↔"),_e.updownarrow=i(S,"\\updownarrow ","↕"),_e.Longleftrightarrow=i(S,"\\Longleftrightarrow ","⇔"),_e.Updownarrow=i(S,"\\Updownarrow ","⇕"),_e.mapsto=i(S,"\\mapsto ","↦"),_e.nearrow=i(S,"\\nearrow ","↗"),_e.hookleftarrow=i(S,"\\hookleftarrow ","↩"),_e.hookrightarrow=i(S,"\\hookrightarrow ","↪"),_e.searrow=i(S,"\\searrow ","↘"),_e.leftharpoonup=i(S,"\\leftharpoonup ","↼"),_e.rightharpoonup=i(S,"\\rightharpoonup ","⇀"),_e.swarrow=i(S,"\\swarrow ","↙"),_e.leftharpoondown=i(S,"\\leftharpoondown ","↽"),_e.rightharpoondown=i(S,"\\rightharpoondown ","⇁"),_e.nwarrow=i(S,"\\nwarrow ","↖"),_e.ldots=i(S,"\\ldots ","…"),_e.cdots=i(S,"\\cdots ","⋯"),_e.vdots=i(S,"\\vdots ","⋮"),_e.ddots=i(S,"\\ddots ","⋰"),_e.surd=i(S,"\\surd ","√"),_e.triangle=i(S,"\\triangle ","▵"),_e.ell=i(S,"\\ell ","ℓ"),_e.top=i(S,"\\top ","⊤"),_e.flat=i(S,"\\flat ","♭"),_e.natural=i(S,"\\natural ","♮"),_e.sharp=i(S,"\\sharp ","♯"),_e.wp=i(S,"\\wp ","℘"),_e.bot=i(S,"\\bot ","⊥"),_e.clubsuit=i(S,"\\clubsuit ","♣"),_e.diamondsuit=i(S,"\\diamondsuit ","♢"),_e.heartsuit=i(S,"\\heartsuit ","♡"),_e.spadesuit=i(S,"\\spadesuit ","♠"),_e.oint=i(S,"\\oint ","∮"),_e.bigcap=i(S,"\\bigcap ","∩"),_e.bigcup=i(S,"\\bigcup ","∪"),_e.bigsqcup=i(S,"\\bigsqcup ","⊔"),_e.bigvee=i(S,"\\bigvee ","∨"),_e.bigwedge=i(S,"\\bigwedge ","∧"),_e.bigodot=i(S,"\\bigodot ","⊙"),_e.bigotimes=i(S,"\\bigotimes ","⊗"),_e.bigoplus=i(S,"\\bigoplus ","⊕"),_e.biguplus=i(S,"\\biguplus ","⊎"),_e.lfloor=i(S,"\\lfloor ","⌊"),_e.rfloor=i(S,"\\rfloor ","⌋"),_e.lceil=i(S,"\\lceil ","⌈"),_e.rceil=i(S,"\\rceil ","⌉"),_e.opencurlybrace=_e.lbrace=i(S,"\\lbrace ","{"),_e.closecurlybrace=_e.rbrace=i(S,"\\rbrace ","}"),_e["∫"]=_e["int"]=_e.integral=i(y,"\\int ","<big>∫</big>"),_e.caret=i(S,"\\text{^}","^"),_e.underscore=i(S,"\\_","_"),_e.slash=i(S,"/"),_e.vert=i(S,"|"),_e.perp=_e.perpendicular=i(S,"\\perp ","⊥"),_e.nabla=_e.del=i(S,"\\nabla ","∇"),_e.hbar=i(S,"\\hbar ","ℏ"),_e.AA=_e.Angstrom=_e.angstrom=i(S,"\\text\\AA ","Å"),_e.ring=_e.circ=_e.circle=i(S,"\\circ ","∘"),_e.bull=_e.bullet=i(S,"\\bullet ","•"),_e.setminus=_e.smallsetminus=i(S,"\\setminus ","∖"),_e.not=_e["¬"]=_e.neg=i(S,"\\neg ","¬"),_e.dots=_e.ellip=_e.hellip=_e.ellipsis=_e.hellipsis=i(S,"\\dots ","…"),_e["…"]=i(S,"…",'<span class="mq-nonSymbola" style="font-size:0.6em;">…</span>',".."),_e.converges=_e.darr=_e.dnarr=_e.dnarrow=_e.downarrow=i(S,"\\downarrow ","↓"),_e.dArr=_e.dnArr=_e.dnArrow=_e.Downarrow=i(S,"\\Downarrow ","⇓"),_e.diverges=_e.uarr=_e.uparrow=i(S,"\\uparrow ","↑"),_e.uArr=_e.Uparrow=i(S,"\\Uparrow ","⇑"),_e.to=i(C,"\\to ","→"),_e.rarr=_e.rightarrow=i(S,"\\rightarrow ","→"),_e.implies=i(C,"\\Rightarrow ","⇒"),_e.rArr=_e.Rightarrow=i(S,"\\Rightarrow ","⇒"),_e.gets=i(C,"\\gets ","←"),_e.larr=_e.leftarrow=i(S,"\\leftarrow ","←"),_e.impliedby=i(C,"\\Leftarrow ","⇐"),_e.lArr=_e.Leftarrow=i(S,"\\Leftarrow ","⇐"),_e.harr=_e.lrarr=_e.leftrightarrow=i(S,"\\leftrightarrow ","↔"),_e.iff=i(C,"\\Leftrightarrow ","⇔"),_e.hArr=_e.lrArr=_e.Leftrightarrow=i(S,"\\Leftrightarrow ","⇔"),_e.Re=_e.Real=_e.real=i(S,"\\Re ","ℜ"),_e.Im=_e.imag=_e.image=_e.imagin=_e.imaginary=_e.Imaginary=i(S,"\\Im ","ℑ"),_e.part=_e.partial=i(S,"\\partial ","∂"),_e.infty=_e.infin=_e.infinity=i(S,"\\infty ","∞"),_e.alef=_e.alefsym=_e.aleph=_e.alephsym=i(S,"\\aleph ","ℵ"),_e.xist=_e.xists=_e.exist=_e.exists=i(S,"\\exists ","∃"),_e.and=_e.land=_e.wedge=i(S,"\\wedge ","∧"),_e.or=_e.lor=_e.vee=i(S,"\\vee ","∨"),_e.o=_e.O=_e.empty=_e.emptyset=_e.oslash=_e.Oslash=_e.nothing=_e.varnothing=i(C,"\\varnothing ","∅"),_e.cup=_e.union=i(C,"\\cup ","∪"),_e.cap=_e.intersect=_e.intersection=i(C,"\\cap ","∩"),_e.deg=_e.degree=i(S,"^\\circ ","°"),_e.ang=_e.angle=i(S,"\\angle ","∠"),_=Oe(y,function(t,e){t.init=function(t,n){e.init.call(this,t,"<var>"+(n||t)+"</var>")},t.text=function(){return this.textTemplate},t.autoUnItalicize=function(t){var e,n,i,s,r="",o=[];for(e=this;e instanceof _;e=e[ye])r=e.ctrlSeq+r,o.push(e);if(t.parent&&t.parent.parent instanceof ne&&"sub"===t.parent.parent.supsub){for(r="_"+r,o=[t.parent.parent],e=t.parent.parent[ye];e instanceof _;e=e[ye])r=e.ctrlSeq+r,o.push(e);t.insRightOf(t.parent.parent)}for(n=D(),n.createLeftOf(t),i=0;i<o.length;i++){if("f"===o[i].ctrlSeq&&o[i].jQ.removeClass("mq-florin").html("f"),o[i]instanceof ne&&"sub"===o[i].supsub)for(s=o[i].blocks[0].ends[ye];0!==s;s=s[Se])"f"===s.ctrlSeq&&s.jQ.removeClass("mq-florin").html("f");o[i].disown(),o[i].adopt(n.ends[ye],0,n.ends[ye].ends[ye]),o[i].jQ.prependTo(n.ends[ye].jQ)}n.ends[ye].jQ.removeClass("mq-empty")},t.fullWord=function(){var t,e=this.ctrlSeq;for(t=this[ye];t instanceof _;t=t[ye])e=t.ctrlSeq+e;if(this.parent&&this.parent.parent instanceof ne&&"sub"===this.parent.parent.supsub)for(e="_"+e,t=this.parent.parent[ye];t instanceof _;t=t[ye])e=t.ctrlSeq+e;for(t=this[Se];t instanceof _;t=t[Se])e+=t.ctrlSeq;if(t instanceof ne&&"sub"===t.supsub)for(e+="_",t=t.sub.ends[ye];t instanceof _;t=t[Se])e+=t.ctrlSeq;return e},t.finalizeTree=function(){var t=this.fullWord();t.length>2&&console.log(t),e.finalizeTree.call(this)}}),m.p.autoCommands={_maxLength:0},g.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]===D)throw'"'+r+'" is a built-in operator name';n[r]=1,i=we(i,r.length)}return n._maxLength=i,n},A=Oe(_,function(t,e){t.init=function(t){return e.init.call(this,this.letter=t)},t.autoOperator=function(t){for(var e=t.options.autoCommands,n=t[ye].letter,i=t[ye][ye],s=1;i instanceof A;)n=i.letter+n,i=i[ye],s+=1;if(n.length>1&&e.hasOwnProperty(n)){for(s=1,i=t[ye];s<n.length;s+=1,i=i[ye]);return Te(i,t[ye]).remove(),t[ye]=i[ye],_e[n](n).createLeftOf(t),!0}return!1}}),L={},function(){var t,e,n,i=m.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)L[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)L[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}(),g.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=we(i,r.length)}return n._maxLength=i,n},D=_e.operatorname=Oe(O,function(t,e){t.htmlTemplate='<span><span class="mq-operator-name">&0</span><span class="mq-non-leaf"><span class="mq-scaled mq-paren">(</span><span class="mq-non-leaf">&1</span><span class="mq-scaled mq-paren">)</span></span></span>',t.init=function(t){e.init.call(this,t)},t.createLeftOf=function(t){e.createLeftOf.apply(this,arguments),t.insAtRightEnd(this.blocks[1])},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);U(t,ve(1+.2*(n-1),1.2),1.05*n)},t.text=function(t){return this.blocks[0].text(t)+"("+this.blocks[1].text(t)+")"},t.latex=function(){return L.hasOwnProperty(this.blocks[0].text())?"\\"+this.blocks[0].latex()+"\\left({"+this.blocks[1].latex()+"}\\right)":"\\operatorname{"+this.blocks[0].latex()+"}\\left({"+this.blocks[1].latex()+"}\\right)"},t.parser=function(){var t,e=v.string,n=v.optWhitespace,i=v.succeed,s=x.block,r=this.ctrlSeq,o=this,a=o.blocks=[j(),j()];for(t=0;t<a.length;t+=1)a[t].adopt(o,o.ends[Se],0);if(L.hasOwnProperty(this.ctrlSeq)){for(t=0;t<r.length;t+=1)A(r.charAt(t)).adopt(this.ends[ye],this.ends[ye].ends[Se],0);return n.then(e("\\left(")).then(function(){var t=a[1];return s.then(function(e){return e.children().adopt(t,t.ends[Se],0),i(o)})}).then(e("\\right)")).result(o)}return n.then(function(){var t=a[0];return s.then(function(e){var n,s;for(e.children().adopt(t,t.ends[Se],0),n=e.ends[ye];0!==n;n=n[Se])if("f"===n.ctrlSeq)n.htmlTemplate="<var>f</var>";else if(n instanceof ne&&"sub"===n.supsub)for(s=n.blocks[0].ends[ye];0!==s;s=s[Se])"f"===s.ctrlSeq&&(s.htmlTemplate="<var>f</var>");return i(o)})}).then(e("\\left(")).then(function(){var t=a[1];return s.then(function(e){return e.children().adopt(t,t.ends[Se],0),i(o)})}).then(e("\\right)")).result(o)}});for(E in L)L.hasOwnProperty(E)&&(_e[E]=D);_e.f=Oe(A,function(t,e){t.init=function(){y.p.init.call(this,this.letter="f",'<var class="mq-florin">ƒ</var>')},t.createLeftOf=function(t){t.parent&&t.parent.parent instanceof D&&t.parent===t.parent.parent.blocks[0]?A("f").createLeftOf(t):t.parent&&t.parent.parent&&t.parent.parent instanceof ne&&"sub"===t.parent.parent.supsub&&t.parent.parent.parent&&t.parent.parent.parent.parent instanceof D&&t.parent.parent.parent===t.parent.parent.parent.parent.blocks[0]?A("f").createLeftOf(t):e.createLeftOf.call(this,t)}}),_e[" "]=_e.space=i(S,"\\ "," "),_e["'"]=_e.prime=i(S,"'","′"),_e.backslash=i(S,"\\backslash ","\\"),Ae["\\"]||(Ae["\\"]=_e.backslash),R=Oe(O,function(t,e){t.init=function(t,n){this.htmlTemplate="<span><span>"+n+"</span><span>&0</span></span>",this.textTemplate=[" "+n," "],e.init.call(this,t)},t.finalizeTree=function(){this.ends[ye].write=function(t,e){RegExp(/[0-9\.]/).test(e)||t.insRightOf(this.parent),j.p.write.apply(this,arguments)}}}),_e.$=i(R,"\\$","$"),I=Oe(_,function(t,e){t.init=function(t,n){e.init.call(this,t,'<span class="mq-nonSymbola">'+(n||t)+"</span>")}}),_e["@"]=I,_e["&"]=i(I,"\\&","&"),_e["%"]=i(I,"\\%","%"),_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=Oe(_,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),_e.phi=i(_,"\\phi ","ϕ"),_e.phiv=_e.varphi=i(_,"\\varphi ","φ"),_e.epsilon=i(_,"\\epsilon ","ϵ"),_e.epsiv=_e.varepsilon=i(_,"\\varepsilon ","ε"),_e.piv=_e.varpi=i(_,"\\varpi ","ϖ"),_e.sigmaf=_e.sigmav=_e.varsigma=i(_,"\\varsigma ","ς"),_e.thetav=_e.vartheta=_e.thetasym=i(_,"\\vartheta ","ϑ"),_e.upsilon=_e.upsi=i(_,"\\upsilon ","υ"),_e.gammad=_e.Gammad=_e.digamma=i(_,"\\digamma ","ϝ"),_e.kappav=_e.varkappa=i(_,"\\varkappa ","ϰ"),_e.rhov=_e.varrho=i(_,"\\varrho ","ϱ"),_e.pi=_e["π"]=i(I,"\\pi ","π"),_e.lambda=i(I,"\\lambda ","λ"),_e.Upsilon=_e.Upsi=_e.upsih=_e.Upsih=i(y,"\\Upsilon ",'<var style="font-family: serif">ϒ</var>'),_e.Gamma=_e.Delta=_e.Theta=_e.Lambda=_e.Xi=_e.Pi=_e.Sigma=_e.Phi=_e.Psi=_e.Omega=_e.forall=Oe(S,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),z=Oe(O,function(t){t.init=function(t){this.latex=t},t.createLeftOf=function(t){var e=x.parse(this.latex);e.children().adopt(t.parent,t[ye],t[Se]),t[ye]=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,ye),e.ends[ye][ye].siblingCreated&&e.ends[ye][ye].siblingCreated(t.options,Se),t.parent.bubble("reflow")},t.parser=function(){var t=x.parse(this.latex).children();return v.succeed(t)}}),_e["¹"]=i(z,"^1"),_e["²"]=i(z,"^2"),_e["³"]=i(z,"^3"),_e["¼"]=i(z,"\\frac14"),_e["½"]=i(z,"\\frac12"),_e["¾"]=i(z,"\\frac34"),B=Oe(C,function(t){t.init=S.prototype.init,t.contactWeld=t.siblingCreated=t.siblingDeleted=function(t,e){return e!==Se?(this.jQ[0].className=!this[ye]||this[ye]instanceof C?"":"mq-binary-operator",this):void 0}}),M=Oe(C,function(t){t.finalizeTree=function(){var t,e;if(this[ye]&&"."===this[ye].ctrlSeq){for(t=[this[ye]],this[ye][ye]&&this[ye][ye][ye]&&"0"===this[ye][ye].ctrlSeq&&"\\cdot "===this[ye][ye][ye].ctrlSeq&&(t.push(this[ye][ye]),t.push(this[ye][ye][ye])),e=0;e<t.length;e++)t[e].remove();this.jQ.html("⊙"),this.jQ.addClass("mq-multiply-elementWise"),this.ctrlSeq="."+this.ctrlSeq,this.textTemplate="."+this.textTemplate}}}),_e["+"]=i(B,"+","+"),_e["–"]=_e["-"]=i(B,"-","−"),_e["±"]=_e.pm=_e.plusmn=_e.plusminus=i(B,"\\pm ","±"),_e.mp=_e.mnplus=_e.minusplus=i(B,"\\mp ","∓"),Ae["*"]=_e.sdot=_e.cdot=i(M,"\\cdot ","·","*"),F=Oe(C,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!==ye||this.strict?void e.deleteTowards.apply(this,arguments):void this.swap(!0)}}),P={ctrlSeq:"\\le ",html:"≤",text:" <= ",ctrlSeqStrict:"<",htmlStrict:"<",textStrict:" < "},W={ctrlSeq:"\\ge ",html:"≥",text:" >= ",ctrlSeqStrict:">",htmlStrict:">",textStrict:" > "},$={ctrlSeq:"\\ne ",html:"≠",text:" != ",ctrlSeqStrict:"!",htmlStrict:"!",textStrict:"!"},_e["<"]=_e.lt=i(F,P,!0),_e[">"]=_e.gt=i(F,W,!0),_e["≤"]=_e.le=_e.leq=i(F,P,!1),_e["≥"]=_e.ge=_e.geq=i(F,W,!1),_e["!"]=i(F,$,!0),_e["≠"]=_e.ne=_e.neq=i(F,$,!1),N=Oe(F,function(t,e){t.init=function(t,n){e.init.call(this,t,n)},t.createLeftOf=function(t){return(t[ye]instanceof F||t[ye]instanceof N)&&t[ye].strict?void t[ye].swap(!1):void e.createLeftOf.apply(this,arguments)}}),G={ctrlSeq:"\\eq ",html:"==",text:" == ",ctrlSeqStrict:"=",htmlStrict:"=",textStrict:" := "},_e["="]=i(N,G,!0),_e.eq=i(N,G,!1),_e.times=i(C,"\\times ","×","[x]"),_e["÷"]=_e.div=_e.divide=_e.divides=i(C,"\\div ","÷","[/]"),H=t,V=document.createElement("div"),X=V.style,Z={transform:1,WebkitTransform:1,MozTransform:1,OTransform:1,msTransform:1};for(Y in Z)if(Y in X){K=Y;break}K?U=function(t,e,n){t.css(K,"scale("+e+","+n+")")}:"filter"in X?(H=function(t){t.className=t.className},U=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),Ce(window).load(function(){clearTimeout(r),i()})}):U=function(t,e,n){t.css("fontSize",n+"em")},J=Oe(O,function(t,e){t.init=function(t,n,i){e.init.call(this,t,"<"+n+" "+i+">&0</"+n+">")}}),_e.mathrm=i(J,"\\mathrm","span",'class="mq-roman mq-font"'),_e.mathit=i(J,"\\mathit","i",'class="mq-font"'),_e.mathbf=i(J,"\\mathbf","b",'class="mq-font"'),_e.mathsf=i(J,"\\mathsf","span",'class="mq-sans-serif mq-font"'),_e.mathtt=i(J,"\\mathtt","span",'class="mq-monospace mq-font"'),_e.underline=i(J,"\\underline","span",'class="mq-non-leaf mq-underline"'),_e.overline=_e.bar=i(J,"\\overline","span",'class="mq-non-leaf mq-overline"'),te=_e.textcolor=Oe(O,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=v.optWhitespace,i=v.string,s=v.regex;return n.then(i("{")).then(s(/^[#\w\s.,()%-]*/)).skip(i("}")).then(function(n){return t.setColor(n),e.parser.call(t)})}}),ee=_e["class"]=Oe(O,function(t,e){t.parser=function(){var t=this,n=v.string,i=v.regex;return v.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)})}}),ne=Oe(O,function(t,e){t.ctrlSeq="_{...}^{...}",t.createLeftOf=function(t){var n,i,s,r,o,a,c,l;if("sub"===this.supsub){if(!(t[ye]instanceof _))return;t[ye]instanceof _&&t[Se]instanceof _&&(n=_e.cdot(),n.createLeftOf(t),t.insLeftOf(n))}else{if(0===t[ye]||t[ye]instanceof C)return;if("."===t[ye].ctrlSeq&&t[ye][ye]){for(i=[t[ye]],t[ye][ye]&&t[ye][ye][ye]&&t[ye][ye][ye][ye]&&"0"===t[ye][ye].ctrlSeq&&"\\cdot "===t[ye][ye][ye].ctrlSeq?(i.push(t[ye][ye]),i.push(t[ye][ye][ye]),s=t[ye][ye][ye][ye]):s=t[ye][ye],r=0;r<i.length;r++)i[r].remove();this.elementWise=!0,t.insRightOf(s)}if((t[ye]instanceof re||t[ye]instanceof ie||t[ye]instanceof se)&&(o=Ae["("](),a=t[ye],o.createLeftOf(t),a.disown(),a.adopt(o.ends[ye],0,0),a.jQ.prependTo(o.ends[ye].jQ),c=Ae[")"](),c.createLeftOf(t),o.reflow()),t[ye]instanceof ne&&"sup"===t[ye].supsub){for(o=Ae["("](),a=[t[ye]],l=t[ye];!(l instanceof C)&&0!==l;l=l[ye])a.push(l);for(o.createLeftOf(t),r=0;r<a.length;r++)a[r].disown(),a[r].adopt(o.ends[ye],0,o.ends[ye].ends[ye]),a[r].jQ.prependTo(o.ends[ye].jQ);c=Ae[")"](),c.createLeftOf(t),o.reflow()}}return e.createLeftOf.call(this,t)},m.p.charsThatBreakOutOfSupSub="",t.finalizeTree=function(){var t=this.supsub;this.ends[ye].write=function(e,n){("sub"!=t||"_"!==n)&&(e.options.charsThatBreakOutOfSupSub.indexOf(n)>-1&&e.insRightOf(this.parent),"sub"!=t||RegExp(/[A-Za-z0-9]/).test(n)||e.insRightOf(this.parent),j.p.write.apply(this,arguments))},this.sup&&this.sup.ends[ye]&&"."===this.sup.ends[ye].ctrlSeq&&(this.sup.ends[ye].remove(),this.elementWise=!0),this.elementWise&&this.jQ.addClass("mq-elementwise")},t.latex=function(){function t(t,n){var i=n&&n.latex();return n?t+(1===i.length?i:"{"+(e?".":"")+(i||" ")+"}"):""}var e=this.elementWise;return t("_",this.sub)+t("^",this.sup)},t.text=function(t){var e="";return this.sub&&(e+="_"+(this.sub&&0!==this.sub.ends[ye]&&this.sub.ends[ye]===this.sub.ends[Se]?this.sub.ends[ye].text(t):this.sub.foldChildren("",function(e,n){return e+n.text(t)}))),this.sup&&(this.elementWise&&(e+="."),e+="^"+(this.sup&&this.sup.ends[ye]===this.sup.ends[Se]?this.sup.ends[ye].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[ye].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=Ce('<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=Ce('<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"> </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"]=h,delete t[n].deleteOutOf,"sub"===e&&Ce(t.jQ.addClass("mq-sup-only")[0].lastChild).remove(),this.remove()}})(this,"sub sup".split(" ")[e],"sup sub".split(" ")[e],"down up".split(" ")[e])}}),ie=_e.scientificNotation=Oe(O,function(t,e){t.ctrlSeq="ScientificNotation{...}{...}",t.htmlTemplate='<span><span>&0</span><span style="font-size:0.7em;">×</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[ye],this.upInto=this.ends[Se],this.ends[ye].upOutOf=this.ends[Se],this.ends[Se].downOutOf=this.ends[ye],this.ends[ye].write=function(t,e){RegExp(/[0-9]/).test(e)||t.insRightOf(this.parent),j.p.write.apply(this,arguments)},this.ends[Se].write=function(t,e){if(RegExp(/[0-9\+\-]/).test(e)){if("+"===e||"-"===e){if(0===t[ye]&&0!==t[Se]&&("-"===t[Se].ctrlSeq||"+"===t[Se].ctrlSeq))return t[Se].ctrlSeq=e,t[Se].textTemplate=e,void t[Se].jQ.html(e);if(0!==t[ye]&&0===t[ye][ye]&&("-"===t[ye].ctrlSeq||"+"===t[ye].ctrlSeq))return t[ye].ctrlSeq=e,t[ye].textTemplate=e,void t[ye].jQ.html(e);0!==t[ye]&&t.insRightOf(this.parent)}}else t.insRightOf(this.parent);j.p.write.apply(this,arguments)}},t.createLeftOf=function(t){if(e.createLeftOf.apply(this,arguments),"undefined"!=typeof this.incorporate_previous){var n=this[ye];if(0===n)return;if(0===n[ye])return;for(next=n[ye];0!==next&&"undefined"!=typeof next.ctrlSeq&&next.ctrlSeq.match(/^[0-9\.]$/);next=n[ye])next.disown().adopt(this.ends[ye],0,this.ends[ye].ends[ye]),next.jQ.prependTo(this.ends[ye].jQ);n.remove(),t.insAtLeftEnd(this.ends[Se]),this.ends[Se].write(t,this.incorporate_previous)}}}),se=Oe(O,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>';y.prototype.init.call(this,t,n)},t.createLeftOf=function(t){e.createLeftOf.apply(this,arguments),A("n").createLeftOf(t),_e["="]().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);U(t,ve(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)"},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=v.string,n=v.optWhitespace,i=(v.whitespace,v.succeed),s=x.block,r=this,o=r.blocks=[j(),j(),j()];for(t=0;t<o.length;t+=1)o[t].adopt(r,r.ends[Se],0);return n.then(e("_")).then(function(){var t=o[0];return s.then(function(e){return e.children().adopt(t,t.ends[Se],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[Se],0),i(r)})}).then(e("\\left(")).then(function(){var t=o[2];return s.then(function(e){return e.children().adopt(t,t.ends[Se],0),i(r)
|
3
|
-
})}).then(e("\\right)")).result(r)},t.finalizeTree=function(){this.downInto=this.ends[ye],this.upInto=this.ends[Se],this.ends[ye].upOutOf=this.ends[Se],this.ends[Se].downOutOf=this.ends[ye]}}),_e["∑"]=_e.sum=_e.summation=i(se,"\\sum ","∑"),_e["∏"]=_e.prod=_e.product=i(se,"\\prod ","∏"),_e.coprod=_e.coproduct=i(se,"\\coprod ","∐"),_e.subscript=_e._=Oe(ne,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"> </span></span>',t.textTemplate=["_"],t.finalizeTree=function(){this.downInto=this.sub=this.ends[ye],this.sub.upOutOf=h,e.finalizeTree.call(this)}}),_e.superscript=_e.supscript=_e["^"]=Oe(ne,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=h,e.finalizeTree.call(this)}}),re=_e.frac=_e.dfrac=_e.cfrac=_e.fraction=Oe(O,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"> </span></span>',t.textTemplate=["((",")/(","))"],t.finalizeTree=function(){this.upInto=this.ends[Se].upOutOf=this.ends[ye],this.downInto=this.ends[ye].downOutOf=this.ends[Se],this.blocks[1].ends[ye]&&"."===this.blocks[1].ends[ye].ctrlSeq&&(this.blocks[1].ends[ye].remove(),this.elementWise=!0),this.elementWise&&(this.jQ.wrap("<span class='mq-fraction-elementwise'></span>"),this.jQ=this.jQ.parent())},t.text=function(t){return"(("+this.blocks[0].text(t)+")"+(this.elementWise?".":"")+"/("+this.blocks[1].text(t)+"))"},t.latex=function(){return this.ctrlSeq+"{"+this.blocks[0].latex()+"}{"+(this.elementWise?".":"")+this.blocks[1].latex()+"}"}}),oe=_e.over=Ae["/"]=Oe(re,function(e,n){e.createLeftOf=function(e){var i,s,r,o;if(!this.replacedFragment){if(e[ye]&&"."===e[ye].ctrlSeq&&e[ye][ye]){for(i=[e[ye]],e[ye][ye]&&e[ye][ye][ye]&&e[ye][ye][ye][ye]&&"0"===e[ye][ye].ctrlSeq&&"\\cdot "===e[ye][ye][ye].ctrlSeq?(i.push(e[ye][ye]),i.push(e[ye][ye][ye]),s=e[ye][ye][ye][ye]):s=e[ye][ye],r=0;r<i.length;r++)i[r].remove();this.elementWise=!0,e.insRightOf(s)}for(o=e[ye];o&&!(o instanceof C||o instanceof(_e.text||t)||o instanceof se||"\\ "===o.ctrlSeq||/^[,;:]$/.test(o.ctrlSeq));)o=o[ye];o instanceof se&&o[Se]instanceof ne&&(o=o[Se],o[Se]instanceof ne&&o[Se].ctrlSeq!=o.ctrlSeq&&(o=o[Se])),o!==e[ye]&&(this.replaces(Te(o[Se]||e.parent.ends[ye],e[ye])),e[ye]=o)}n.createLeftOf.call(this,e)}}),ae=_e.sqrt=_e["√"]=Oe(O,function(t,e){t.ctrlSeq="\\sqrt",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-sqrt-prefix">√</span><span class="mq-non-leaf mq-sqrt-stem">&0</span></span>',t.textTemplate=[" sqrt(",")"],t.parser=function(){return x.optBlock.then(function(t){return x.block.map(function(e){var n=le();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;U(t.prev(),1,t.innerHeight()/+t.css("fontSize").slice(0,-2)-.1)}}),ce=_e.vec=Oe(O,function(t){t.ctrlSeq="\\vec",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-vector-prefix">→</span><span class="mq-vector-stem">&0</span></span>',t.textTemplate=["vec(",")"]}),le=_e.nthroot=Oe(ae,function(t){t.htmlTemplate='<sup class="mq-nthroot mq-non-leaf">&0</sup><span class="mq-scaled"><span class="mq-sqrt-prefix mq-scaled">√</span><span class="mq-sqrt-stem mq-non-leaf">&1</span></span>',t.textTemplate=["sqrt[","](",")"],t.latex=function(){return"\\sqrt["+this.ends[ye].latex()+"]{"+this.ends[Se].latex()+"}"},t.text=function(t){return" "+this.ends[Se].text(t)+"^(1/"+this.ends[ye].text(t)+")"}}),he=_e.begin=Oe(O,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));U(t,ve(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,ye)}},{text:"Insert Column After",handler:function(){n.insertColumn(t,Se)}},{text:"Insert Row Before",handler:function(){n.insertRow(t,ye)}},{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[ye]&&(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[ye]?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=(x.block,v.string,v.regex);v.optWhitespace}return t(/^\{[pbvBV]?matrix\}[\s\S]*?\\end\{[pbvBV]?matrix\}/).map(function(t){var e,n,i,s,r,o,a,c,l;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=he("\\"+e,s,i),a=o.blocks=Array(o.numBlocks()),c=0;c<a.length;c++)l=a[c]=x.parse(r[c]),l.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[ye];)e++,e==this.col&&(e=0,n++),i=i[ye];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][ye]=this.blocks[n-1],this.blocks[n-1][Se]=this.blocks[n]):0==n?this.blocks[n][ye]=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(),t.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][ye]=this.blocks[n-1],this.blocks[n-1][Se]=this.blocks[n]):0==n?this.blocks[n][ye]=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(),t.workingGroupChange()}},t.insertRow=function(t,e){var n,i,s,r,o=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[ye]&&0!==t[Se]:e==ye?!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=j(),r.adopt(this,i+s>0?this.blocks[i+s-1]:0,i+s>0?this.blocks[i+s-1][Se]:this.ends[ye]),r.jQ=Ce('<span class="mq-cell mq-empty" '+qe+'="'+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][ye]=r,r[Se]=this.blocks[i+s]),this.row++,this.finalizeTree(),t.insAtLeftEnd(this.blocks[i]),this.reflow(),t.workingGroupChange()},t.insertColumn=function(t,e){var n,i,s,r=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[ye]&&0!==t[Se]:e==ye?!0:!1,i=this.row-1;i>=0;i--)s=j(),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=Ce('<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][Se]=s),this.blocks[i*this.col+r.col][ye]=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=Ce('<span class="mq-cell mq-empty" '+qe+'="'+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][ye]=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?ye:Se]),this.reflow(),t.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 t.workingGroupChange())}}),_e.matrix=i(he,"\\matrix",1,1),_e.bmatrix=i(he,"\\bmatrix",1,1),_e.Bmatrix=i(he,"\\Bmatrix",1,1),_e.vmatrix=i(he,"\\vmatrix",1,1),_e.Vmatrix=i(he,"\\Vmatrix",1,1),_e.pmatrix=i(he,"\\pmatrix",1,1),ue=Oe(Oe(O,u),function(e,n){e.init=function(t,e,i,s,r,o,a){n.init.call(this,"\\left"+s,p,[e,i]),this.side=t,this.sides={},this.sides[ye]={ch:e,ctrlSeq:s,textTemplate:o},this.sides[Se]={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===Se?" mq-ghost":"")+'">'+this.sides[ye].ch+'</span><span class="mq-non-leaf">&0</span><span class="mq-scaled mq-paren'+(this.side===ye?" mq-ghost":"")+'">'+this.sides[Se].ch+"</span></span>",n.html.call(this)},e.latex=function(){return"\\left"+this.sides[ye].ctrlSeq+this.ends[ye].latex()+"\\right"+this.sides[Se].ctrlSeq},e.text=function(t){return"\\left["!==this.ctrlSeq||this[ye]instanceof _?this.sides[ye].textTemplate+this.ends[ye].text(t)+this.sides[Se].textTemplate:"("+this.ends[ye].text(t)+")"},e.oppBrack=function(t,e){return t instanceof ue&&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===ye?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){for(e=this.oppBrack(t[ye],ye)||this.oppBrack(t[Se],Se),i=t.parent.parent;0!==i&&!e;i=i.parent)e=this.oppBrack(i);if(!e&&"\\left("===this.ctrlSeq&&t[ye]instanceof _&&this.side===ye)return t[ye].autoUnItalicize(t);if(!e&&"\\left("===this.ctrlSeq&&t[ye]instanceof ne&&this.side===ye&&"sub"===t[ye].supsub&&t[ye].sub.ends[Se]instanceof _)return t.insAtRightEnd(t[ye].sub),t[ye].autoUnItalicize(t);if(e||this.side!==Se||"\\left("!==this.ctrlSeq){if(e||this.side!==Se||"\\left["!==this.ctrlSeq){if(!e&&"\\left["===this.ctrlSeq&&0===t[ye]&&0===t[Se]&&"undefined"!=typeof t.parent.parent&&t.parent.parent.ctrlSeq===this.ctrlSeq)return s=t.parent.parent[ye],r=t.parent.parent.parent,t.parent.parent.unwrap(),0!==s?t.insRightOf(s):t.insAtLeftEnd(r),o=he("\\bmatrix",1,1),void o.createLeftOf(t)}else for(i=t.parent;0!==i;i=i.parent)if(i instanceof he)return t.insRightOf(i)}else for(i=t.parent;0!==i;i=i.parent){if(i instanceof D)return t.insRightOf(i);if(i instanceof se)return t.insRightOf(i)}}e?(a=this.side=-e.side,this.closeOpposing(e),e===t.parent.parent&&t[a]&&(Te(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(Te(t[-a],t.parent.ends[-a],a)),t[-a]=0),n.createLeftOf.call(e,t)),a===ye?t.insAtLeftEnd(e.ends[ye]):t.insRightOf(e),t.workingGroupChange()},e.placeCursor=t,e.unwrap=function(){this.ends[ye].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[ye].ends[this.side],t)?(this.closeOpposing(this.ends[ye].ends[this.side]),i=this.ends[ye].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:fe[this.sides[this.side].ch],ctrlSeq:fe[this.sides[this.side].ctrlSeq]},this.delimjQs.removeClass("mq-ghost").eq(t===ye?0:1).addClass("mq-ghost").html(this.sides[t].ch)),r?(i=this.ends[ye].ends[t],Te(r,o,-t).disown().withDirAdopt(-t,this.ends[ye],i,0).jQ.insAtDirEnd(t,this.ends[ye].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[ye]))))},e.deleteTowards=function(t,e){this.deleteSide(-t,!1,e)},e.finalizeTree=function(){this.ends[ye].deleteOutOf=function(t,e){this.parent.deleteSide(t,!0,e)},this.finalizeTree=this.intentionalBlur=function(){this.delimjQs.eq(this.side===ye?1:0).removeClass("mq-ghost"),this.side=0}},e.siblingCreated=function(t,e){e===-this.side&&this.finalizeTree()}}),fe={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","\\{":"\\}","\\}":"\\{","⟨":"⟩","⟩":"⟨","\\langle ":"\\rangle ","\\rangle ":"\\langle ","|":"|"},f("("),f("["),_e.langle=i(ue,ye,"⟨","⟩","\\langle ","\\rangle ","(",")"),_e.rangle=i(ue,Se,"⟨","⟩","\\langle ","\\rangle ","(",")"),Ae["|"]=i(ue,ye,"|","|","|","|","abs(",")"),Ae["{"]=i(ue,ye,"{","}","\\{","\\}","(",")"),Ae["}"]=i(ue,Se,"{","}","\\{","\\}","(",")"),_e.left=Oe(O,function(t){t.parser=function(){var t=v.regex,e=v.string,n=(v.succeed,v.optWhitespace);return n.then(t(/^(?:[([|]|\\\{)/)).then(function(i){var s="\\"===i.charAt(0)?i.slice(1):i;return x.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=ue(0,s,e,i,t,n,o);return a.blocks=[r],r.adopt(a,0,0),a})})})}}),_e.right=Oe(O,function(t){t.parser=function(){return v.fail("unmatched \\right")}}),pe=_e.binom=_e.binomial=Oe(Oe(O,u),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(",",",")"]}),de=_e.choose=Oe(pe,function(t){t.createLeftOf=oe.prototype.createLeftOf}),me=Oe(a.MathField,function(t){t.init=function(t,e){l(t),this.__options=m();var n=Ee(this,t,e);n.editable=!0,n.createTextarea(),n.editablesTextareaEvents(),n.cursor.insAtRightEnd(t)}}),_e.MathQuillMathField=Oe(O,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=v.string,i=v.regex,s=v.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(){me(this.ends[ye],this.jQ)},t.registerInnerField=function(t){t.push(t[this.name]=this.ends[ye].controller.API)},t.latex=function(){return this.ends[ye].latex()},t.text=function(t){return this.ends[ye].text(t)}})}();
|
1
|
+
!function(){function t(){}function e(t){var e=t.length-1;return function(){var n=xe.call(arguments,0,e),s=xe.call(arguments,e);return t.apply(this,n.concat([s]))}}function n(t){return e(function(e,n){"function"!=typeof e&&(e=ke(e));var s=function(t){return e.apply(t,[t].concat(n))};return t.call(this,s)})}function s(t){var e=xe.call(arguments,1);return function(){return t.apply(this,e)}}function i(t,e){if(!e)throw new Error("prayer failed: "+t)}function r(t){i("a direction was passed",t===Ce||t===ye)}function o(t,e,n){i("a parent is always present",t),i("leftward is properly set up",function(){return e?e[ye]===n&&e.parent===t:t.ends[Ce]===n}()),i("rightward is properly set up",function(){return n?n[Ce]===e&&n.parent===t:t.ends[ye]===e}())}function a(t){if(!t||!t.nodeType)return null;var e=Se(t).children(".mq-root-block").attr(qe);return e?Qe.byId[e].controller.API:null}function l(t){function e(e,n){var s=a(e);return s instanceof t||!e||!e.nodeType?s:t(Se(e),n)}return e.prototype=t.prototype,e}function c(t){var e,n="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){var e=this.parent,n=t;do{if(n[ye])return t.insLeftOf(e);n=n.parent.parent}while(n!==e);t.insRightOf(e)}function u(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);U(this.delimjQs,ve(1+.2*(t-1),1.2),1.05*t)}}function p(t,e){var e=e||t,n=pe[t],i=pe[e];Ae[t]=s(ue,Ce,t,n,e,i,e,i),Ae[n]=s(ue,ye,t,n,e,i,e,i)}var f,d,m,g,b,q,v,w,x,k,O,C,y,S,j,Q,T,_,A,L,D,E,R,I,z,B,P,M,F,W,$,G,N,U,H,V,X,Z,K,Y,J,te,ee,ne,se,ie,re,oe,ae,le,ce,he,ue,pe,fe,de,me,ge=window.jQuery,be="mathquill-command-id",qe="mathquill-block-id",ve=Math.min,we=Math.max,xe=[].slice,ke=e(function(t,n){return e(function(e,s){return t in e?e[t].apply(e,n.concat(s)):void 0})}),Oe=function(t,e,n){function s(t){return"object"==typeof t}function i(t){return"function"==typeof t}function r(){}return function o(a,l){function c(){var t=new h;return i(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={},i(t)?f=t.call(c,p,u,c,a):s(t)&&(f=t),s(f))for(var n in f)e.call(f,n)&&(p[n]=f[n]);return i(p.init)||(p.init=a),c})(l)}}("prototype",{}.hasOwnProperty),Ce=a.L=-1,ye=a.R=1,Se=Oe(ge,function(t){t.insDirOf=function(t,e){return t===Ce?this.insertBefore(e.first()):this.insertAfter(e.last())},t.insAtDirEnd=function(t,e){return t===Ce?this.prependTo(e):this.appendTo(e)}}),je=Oe(function(t){t.parent=0,t[Ce]=0,t[ye]=0,t.init=function(t,e,n){this.parent=t,this[Ce]=e,this[ye]=n},this.copy=function(t){return je(t.parent,t[Ce],t[ye])}}),Qe=Oe(function(t){function e(){return s+=1}t[Ce]=0,t[ye]=0,t.parent=0;var s=0;this.byId={},t.init=function(){this.id=e(),Qe.byId[this.id]=this,this.ends={},this.ends[Ce]=0,this.ends[ye]=0},t.getController=function(){return this.controller?this.controller:(this.controller=this.parent.getController(),this.controller)},t.dispose=function(){delete Qe.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,s;for(t.getAttribute&&(n=t.getAttribute("mathquill-command-id"),s=t.getAttribute("mathquill-block-id"),n&&Qe.byId[n].jQadd(t),s&&Qe.byId[s].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[Ce],e[ye]),n},t.createLeftOf=function(t){return this.createDir(Ce,t)},t.selectChildren=function(t,e){return De(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[Ce]&&0===this.ends[ye]},t.children=function(){return Te(this.ends[Ce],this.ends[ye])},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,s){return Te(this,this).withDirAdopt(t,e,n,s),this},t.adopt=function(t,e,n){return Te(this,this).adopt(t,e,n),this},t.disown=function(){return Te(this,this).disown(),this},t.remove=function(){return this.jQ.remove(),this.postOrder("dispose"),this.disown()}}),Te=Oe(function(t){t.init=function(t,e,n){n===f&&(n=Ce),r(n),i("no half-empty fragments",!t==!e),this.ends={},t&&(i("withDir is passed to Fragment",t instanceof Qe),i("oppDir is passed to Fragment",e instanceof Qe),i("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,s){return t===Ce?this.adopt(e,n,s):this.adopt(e,s,n)},t.adopt=function(t,e,n){var s,i,r;return o(t,e,n),s=this,s.disowned=!1,(i=s.ends[Ce])?(r=s.ends[ye],e||(t.ends[Ce]=i),n?n[Ce]=r:t.ends[ye]=r,s.ends[ye][ye]=n,s.each(function(n){n[Ce]=e,n.parent=t,e&&(e[ye]=n),e=n}),s):this},t.disown=function(){var t,e,n=this,s=n.ends[Ce];return!s||n.disowned?n:(n.disowned=!0,t=n.ends[ye],e=s.parent,o(e,s[Ce],s),o(e,t,t[ye]),s[Ce]?s[Ce][ye]=t[ye]:e.ends[Ce]=t[ye],t[ye]?t[ye][Ce]=s[Ce]:e.ends[ye]=s[Ce],n)},t.remove=function(){return this.jQ.remove(),this.each("postOrder","dispose"),this.disown()},t.each=n(function(t){var e,n=this,s=n.ends[Ce];if(!s)return n;for(;s!==n.ends[ye][ye]&&(e=t(s),e!==!1);s=s[ye]);return n}),t.fold=function(t,e){return this.each(function(n){t=e.call(this,t,n)}),t}}),_e={},Ae={},Le=Oe(je,function(t){t.init=function(t,e,n){this.parent=t,this.options=e,this.container=n;var s=this.jQ=this._jQ=Se('<span class="mq-cursor">​</span>');this.blink=function(){s.toggleClass("mq-blink")},this.upDownCache={}},t.show=function(){return this.jQ=this._jQ.removeClass("mq-blink"),"intervalId"in this?clearInterval(this.intervalId):(this[ye]?this.jQ.insertBefore(this.selection&&this.selection.ends[Ce][Ce]===this[Ce]?this.selection.jQ:this[ye].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,s){e!==this.parent&&this.parent.blur&&this.parent.blur(),this.parent=e,this[t]=n,this[-t]=s},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(Ce,t)},t.insRightOf=function(t){return this.insDirOf(ye,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(Ce,t)},t.insAtRightEnd=function(t){return this.insAtDirEnd(ye,t)},t.jumpUpDown=function(t,e){var n,s,i=this;i.upDownCache[t.id]=je.copy(i),n=i.upDownCache[e.id],n?n[ye]?i.insLeftOf(n[ye]):i.insAtRightEnd(n.parent):(s=i.offset().left,e.seek(s,i))},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[ye],s=this,i=t[Ce];if(t.disown().eachChild(function(s){s.isEmpty()||(s.children().adopt(e,i,n).each(function(e){e.jQ.insertBefore(t.jQ.first())}),i=s.ends[ye])}),!this[ye])if(this[Ce])this[ye]=this[Ce][ye];else for(;!this[ye];){if(this.parent=this.parent[ye],!this.parent){this[ye]=t[ye],this.parent=e;break}this[ye]=this.parent.ends[Ce]}this[ye]?this.insLeftOf(this[ye]):this.insAtRightEnd(e),t.jQ.remove(),t[Ce].siblingDeleted&&t[Ce].siblingDeleted(s.options,ye),t[ye].siblingDeleted&&t[ye].siblingDeleted(s.options,Ce)},t.workingGroupChange=function(){var t,e=this.container,n=!1;e.find(".active_block").replaceWith(function(){return Se(this).contents()}),e.find(".hasCursor_highlighting").removeClass("hasCursor_highlighting"),t=this.jQ,t.addClass("hasCursor_highlighting"),n=!1,t.prevAll().each(function(){var t=Se(this);t.hasClass("mq-binary-operator")&&(n=!0),n||t.addClass("hasCursor_highlighting")}),n=!1,t.nextAll().each(function(){var t=Se(this);t.hasClass("mq-binary-operator")&&(n=!0),n||t.addClass("hasCursor_highlighting")}),e.find(".mq-hasCursor").first().children(".hasCursor_highlighting").wrapAll("<span class='active_block'></span>")},t.startSelection=function(){var t,e=this.anticursor=je.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,s,r,o,a,l=this.anticursor;if(this[Ce]===l[Ce]&&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(i("cursor and anticursor in the same tree",e),n=l.ancestors[e.id],o=ye,t[Ce]!==n)for(a=t;a;a=a[ye])if(a[ye]===n[ye]){o=Ce,s=t,r=n;break}return o===ye&&(s=n,r=t),s instanceof je&&(s=s[ye]),r instanceof je&&(r=r[Ce]),this.hide().selection=e.selectChildren(s,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[Ce]=this.selection.ends[Ce][Ce],this[ye]=this.selection.ends[ye][ye],this.selection.remove(),this.selectionChanged(),delete this.selection)},t.replaceSelection=function(){var t=this.selection;return t&&(this[Ce]=t.ends[Ce][Ce],this[ye]=t.ends[ye][ye],delete this.selection),t}}),De=Oe(Te,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]()})}}),Ee=Oe(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=Le(e,t.__options,n)},t.handle=function(t,e){var n=this.API.__options.handlers;n&&n[t]&&(e===Ce||e===ye?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},t.createPopup=function(t,e,n,s){var i=this.container.children(".mq-popup").first();0==i.length&&(i=Se("<div class='mq-popup mq-autocomplete'></div>"),this.container.append(i)),i.css({top:Math.ceil(e)+"px",left:Math.floor(n)+"px"}),i.html(t),i.find("li").mouseenter(function(){Se(this).closest("ul").find("li").removeClass("mq-popup-selected"),Se(this).addClass("mq-popup-selected")}).click(s)},t.closePopup=function(){this.container.children(".mq-popup").remove()}});a.noConflict=function(){return window.MathQuill=d,a},d=window.MathQuill,window.MathQuill=a,m=Oe(),g={},a.__options=m.p,b=Oe(function(t){t.init=function(){throw"wtf don't call me, I'm 'abstract'"},t.initRoot=function(t,e,n){var s,i;this.__options=m(),this.config(n),s=Ee(this,t,e),s.createTextarea(),i=e.contents().detach(),t.jQ=Se('<span class="mq-root-block"/>').attr(qe,t.id).appendTo(e),this.latex(i.text()),this.revert=function(){return e.empty().unbind(".mathquill").removeClass("mq-editable-field mq-math-mode mq-text-mode").append(i)}},t.config=a.config=function(t){var e,n,s;for(e in t)t.hasOwnProperty(e)&&(n=t[e],s=g[e],this.__options[e]=s?s(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=b.prototype,a.StaticMath=l(Oe(b,function(t,e){t.init=function(t){this.initRoot(j(),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}})),q=a.EditableField=Oe(b,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.setAutocomplete=function(t){return this.__options.autocomplete=t.sort(function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}),this},e.addAutocomplete=function(t){return"undefined"==typeof this.__options.autocomplete?this.__options.autocomplete=[t]:this.__options.autocomplete.push(t),this},e.cmd=function(t){var e,n=this.__controller.notify(),s=n.cursor.show();return/^\\[a-z]+$/i.test(t)?(t=t.slice(1),e=_e[t],e&&(t=e(t),s.selection&&t.replaces(s.replaceSelection()),t.createLeftOf(s))):s.parent.write(s,t,s.replaceSelection()),n.blurred&&s.hide().parent.blur(),this},e.select=function(){var t=this.__controller;for(t.notify("move").cursor.insAtRightEnd(t.root);t.cursor[Ce];)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(Ce)},e.moveToRightEnd=function(){return this.moveToDirEnd(ye)},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}}),v=Oe(function(t,e,n){function s(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,s)},t.or=function(t){i("or is passed a parser",t instanceof n);var e=this;return n(function(n,s,i){function r(){return t._(n,s,i)}return e._(n,s,r)})},t.then=function(t){var e=this;return n(function(s,r,o){function a(e,s){var a=t instanceof n?t:t(s);return i("a parser is returned",a instanceof n),a._(e,r,o)}return e._(s,a,o)})},t.many=function(){var t=this;return n(function(e,n){function s(t,n){return e=t,r.push(n),!0}function i(){return!1}for(var r=[];t._(e,s,i););return n(e,r)})},t.times=function(t,e){arguments.length<2&&(e=t);var s=this;return n(function(n,i,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=s._(n,o,a),!p)return r(n,c);for(;e>h&&p;h+=1)p=s._(n,o,l);return i(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,s="expected '"+t+"'";return n(function(n,i,r){var o=n.slice(0,e);return o===t?i(n.slice(e),o):r(n,s)})},o=this.regex=function(t){i("regexp parser is anchored","^"===t.toString().charAt(1));var e="expected "+t;return n(function(n,s,i){var r,o=t.exec(n);return o?(r=o[0],s(n.slice(r.length),r)):i(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,s){return s(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)})}),w=function(){function e(t){var e,s=t.which||t.keyCode,i=n[s],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=i||String.fromCharCode(s),r.length||i?(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,s){function i(t){w=t,clearTimeout(d),d=setTimeout(t)}function r(e){w(),w=t,clearTimeout(d),q.val(e),e&&q[0].select(),m=!!e}function o(){var t=q[0];return"selectionStart"in t?t.selectionStart!==t.selectionEnd:!1}function a(){s.keystroke(e(g),g)}function l(e){g=e,b=null,a(),m&&i(function(){q[0].select(),w=t,clearTimeout(d)})}function c(t){g&&b&&a(),b=t,i(h)}function h(){if(!o()){var t=q.val();1===t.length?(q.val(""),s.typedText(t)):t&&q[0].select()}}function u(){g=b=null}function p(){q.focus(),i(f)}function f(){var t=q.val();q.val(""),t&&s.paste(t)}var d,m,g=null,b=null,q=ge(n),v=ge(s.container||q),w=t;return v.bind("keydown keypress input keyup focusout paste",function(){w()}),m=!1,v.bind({keydown:l,keypress:c,focusout:u,paste:p}),{select:r}}}(),Ee.open(function(t){t.exportText=function(t){return this.root.foldChildren("",function(e,n){return e+n.text(t)})}}),Ee.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(),s.closePopup(),s.container.removeClass("mq-focused"),Se(window).off("blur",t)}var n,s=this,i=s.root,r=s.cursor;s.textarea.focus(function(){s.blurred=!1,clearTimeout(n),s.container.addClass("mq-focused"),r.parent||r.insAtRightEnd(i),r.selection?(r.selection.jQ.removeClass("mq-blur"),s.selectionChanged()):r.show()}).blur(function(){s.blurred=!0,n=setTimeout(function(){i.postOrder("intentionalBlur"),r.clearSelection(),e()}),Se(window).on("blur",t)}),s.blurred=!0,r.hide().parent.blur()}}),Ee.open(function(t){t.keystroke=function(t,e){this.cursor.parent.keystroke(t,e,this)}}),Qe.open(function(t){t.keystroke=function(t,e,n){var s,i=n.cursor;switch(t){case"Ctrl-Shift-Backspace":case"Ctrl-Backspace":for(;i[Ce]||i.selection;)n.backspace();break;case"Shift-Backspace":case"Backspace":n.backspace();break;case"Enter":if(s=n.container.children(".mq-popup"),s.length>0){s.find("li.mq-popup-selected").click();break}return;case"Esc":case"Tab":if(s=n.container.children(".mq-popup"),s.length>0){s.find("li.mq-popup-selected").click();break}return void n.escapeDir(ye,t,e);case"Shift-Tab":case"Shift-Esc":return void n.escapeDir(Ce,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[ye];)n.selectRight();break;case"Ctrl-Shift-End":for(;i[ye]||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[Ce];)n.selectLeft();break;case"Ctrl-Shift-Home":for(;i[Ce]||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[Ce])for(;i[Ce];)n.selectLeft();else n.selectLeft();case"Shift-Down":if(i[ye])for(;i[ye];)n.selectRight();else n.selectRight();case"Ctrl-Up":break;case"Ctrl-Down":break;case"Ctrl-Shift-Del":case"Ctrl-Del":for(;i[ye]||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[Ce];)n.selectLeft();break;default:return}e.preventDefault(),n.scrollHoriz()},t.moveOutOf=t.moveTowards=t.deleteOutOf=t.deleteTowards=t.unselectInto=t.selectOutOf=t.selectTowards=function(){i("overridden or never called on this node")}}),Ee.open(function(t){function e(t,e){var n,s,i,r,o,a=t.container.children(".mq-popup");return a.length>0?(n=a.find("li.mq-popup-selected"),s="up"===e?n.prev("li"):n.next("li"),0==s.length?t:(n.removeClass("mq-popup-selected"),s.addClass("mq-popup-selected"),t)):(i=t.notify("upDown").cursor,r=e+"Into",o=e+"OutOf",i[ye][r]?i.insAtLeftEnd(i[ye][r]):i[Ce][r]?i.insAtRightEnd(i[Ce][r]):i.parent.bubble(function(t){var e=t[o];return e&&("function"==typeof e&&(e=t[o](i)),e instanceof Qe&&i.jumpUpDown(t,e),e!==!0)?!1:void 0}),i.workingGroupChange(),t)}this.onNotify(function(t){("move"===t||"upDown"===t)&&this.show().clearSelection()}),t.escapeDir=function(t,e,n){r(t);var s=this.cursor;return s.parent!==this.root&&n.preventDefault(),s.parent!==this.root?(s.parent.moveOutOf(t,s),s.workingGroupChange(),this.notify("move")):void 0},g.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),this.container.children(".mq-autocomplete").length>0&&(e[Ce]instanceof _?e[Ce].autoComplete():e[ye]instanceof _?e[ye].autoComplete():e[Ce]instanceof ne&&"sub"==e[Ce].supsub&&e[Ce].sub.ends[ye]?e[Ce].sub.ends[ye].autoComplete():this.container.children(".mq-autocomplete").remove()),e.workingGroupChange(),this.notify("move")},t.moveLeft=function(){return this.moveDir(Ce)},t.moveRight=function(){return this.moveDir(ye)},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[Ce].siblingDeleted&&e[Ce].siblingDeleted(e.options,ye),e[ye].siblingDeleted&&e[ye].siblingDeleted(e.options,Ce),e.parent.bubble("reflow"),e.workingGroupChange(),this},t.backspace=function(){return this.deleteDir(Ce)},t.deleteForward=function(){return this.deleteDir(ye)},this.onNotify(function(t){"select"!==t&&this.endSelection()}),t.selectDir=function(t){var e,n=this.notify("select").cursor,s=n.selection;r(t),n.anticursor||n.startSelection(),e=n[t],e?s&&s.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(Ce)},t.selectRight=function(){return this.selectDir(ye)}}),x=function(){function t(t){var e,n,s=j();if(t instanceof A&&t.ctrlSeq.length>1)for(e=t.ctrlSeq,n=0;n<e.length;n+=1)A(e[n]).adopt(s,s.ends[ye],0);else t.adopt(s,0,0);return s}function e(t){var e,n=t[0]||j();for(e=1;e<t.length;e+=1)t[e].children().adopt(n,n.ends[ye],0);return n}var n=v.string,s=v.regex,i=(v.letter,v.any),r=v.optWhitespace,o=v.succeed,a=v.fail,l=s(/^[a-z]+[0-9]*/i).map(function(t){return A(t)}),c=s(/^[^${}\\_^]/).map(function(t){return y(t)}),h=s(/^[^\\a-eg-zA-Z]/).or(n("\\").then(s(/^[a-z]+/i).or(s(/^\s+/).result(" ")).or(i))).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}(),Ee.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,s=v.all,i=v.eof,r=x.skip(i).or(s.result(!1)).parse(t);return r&&!r.isEmpty()&&(r.children().adopt(n.parent,n[Ce],n[ye]),e=r.jQize(),e.insertBefore(n.jQ),n[Ce]=r.ends[ye],r.finalizeInsert(n.options,n),r.ends[ye][ye].siblingCreated&&r.ends[ye][ye].siblingCreated(n.options,Ce),r.ends[Ce][Ce].siblingCreated&&r.ends[Ce][Ce].siblingCreated(n.options,ye),n.parent.bubble("reflow")),this},t.renderLatexMath=function(t){var e,n,s=this.root,i=this.cursor,r=v.all,o=v.eof,a=x.skip(o).or(r.result(!1)).parse(t);s.eachChild("postOrder","dispose"),s.ends[Ce]=s.ends[ye]=0,a&&a.children().adopt(s,0,0),e=s.jQ,a?(n=a.join("html"),e.html(n),s.jQize(e.children()),s.finalizeInsert(i.options)):e.empty(),delete i.selection,i.insAtRightEnd(s)}}),Ee.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"),s=Qe.byId[n.attr(qe)||e.attr(qe)],i=s.controller,r=i.cursor,o=i.seek(Se(t.target),t.pageX,t.pageY).cursor.parent;!(o instanceof O);)if(o=o.parent,"undefined"==typeof o){o=s;break}return o.contextMenu(r,t),t.preventDefault(),!1}),this.container.bind("mousedown.mathquill",function(n){function s(t){o=Se(t.target)}function i(t){h.anticursor||h.startSelection(),c.seek(o,t.pageX,t.pageY).cursor.select(),o=f}function r(t){h.blink=u,h.selection||(c.editable?h.show():p.detach()),a.unbind("mousemove",s),Se(t.target.ownerDocument).unbind("mousemove",i).unbind("mouseup",r)}var o,a=Se(n.target).closest(".mq-root-block"),l=Qe.byId[a.attr(qe)||e.attr(qe)],c=l.controller,h=c.cursor,u=h.blink,p=c.textareaSpan,d=c.textarea;c.closePopup(),c.blurred&&(c.editable||a.prepend(p),d.focus()),n.preventDefault(),n.target.unselectable=!0,h.blink=t,c.seek(Se(n.target),n.pageX,n.pageY).cursor.startSelection(),a.mousemove(s),Se(n.target.ownerDocument).mousemove(i).mouseup(r)})}}),Ee.open(function(t){t.seek=function(t,e){var n,s,r,o=this.notify("select").cursor;return t&&(n=t.attr(qe)||t.attr(be),n||(s=t.parent(),n=s.attr(qe)||s.attr(be))),r=n?Qe.byId[n]:this.root,i("nodeId is the id of some Node that exists",r),o.clearSelection().show(),r.seek(e,o),this.scrollHoriz(),o.workingGroupChange(),this}}),Ee.open(function(t){t.scrollHoriz=function(){var t,e,n,s,i,r=this.cursor,o=r.selection,a=this.root.jQ[0].getBoundingClientRect();if(o)if(n=o.jQ[0].getBoundingClientRect(),s=n.left-(a.left+20),i=n.right-(a.right-20),o.ends[Ce]===r[ye])if(0>s)e=s;else{if(!(i>0))return;e=n.left-i<a.left+20?s:i}else if(i>0)e=i;else{if(!(0>s))return;e=n.right-s>a.right-20?i:s}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)}}),Ee.open(function(t){m.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;H(t.container[0]),t.textareaSelectionTimeout===f&&(t.textareaSelectionTimeout=setTimeout(function(){t.setTextareaSelection()}))},t.setTextareaSelection=function(){this.textareaSelectionTimeout=f;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(){i.detach(),e.blurred=!0}var e=this,n=(e.root,e.cursor),s=e.textarea,i=e.textareaSpan;this.container.prepend('<span class="mq-selectable">$'+e.exportLatex()+"$</span>"),e.blurred=!0,s.bind("cut paste",!1).focus(function(){e.blurred=!1}).blur(function(){n.selection&&n.selection.clear(),setTimeout(t)}),e.selectFn=function(t){s.val(t),t&&s.select()}},t.editablesTextareaEvents=function(){var t=this,e=(t.root,t.cursor),n=t.textarea,s=t.textareaSpan,i=w(n,this);this.selectFn=function(t){i.select(t)},this.container.prepend(s).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()}}),k=Oe(Qe,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[ye].siblingCreated&&n[ye].siblingCreated(t,Ce),n[Ce].siblingCreated&&n[Ce].siblingCreated(t,ye),n.bubble("reflow")},t.contextMenu=function(){}}),O=Oe(k,function(t,e){t.init=function(t,n,s){var i=this;e.init.call(i),i.ctrlSeq||(i.ctrlSeq=t),n&&(i.htmlTemplate=n),s&&(i.textTemplate=s)},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=x.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[ye],0);return e})},t.createLeftOf=function(t){var n,s,i,r=this;if(this instanceof _||"sub"===this.supsub||t.container.children(".mq-popup").remove(),"undefined"!=typeof t.parent&&t.parent.parent instanceof he){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 ue&&"\\left["===t.parent.parent.ctrlSeq&&(","==r.ctrlSeq||";"==r.ctrlSeq))return n=t.parent.parent,0!==n[Ce]?t.insRightOf(n[Ce]):t.insAtLeftEnd(n.parent),s=he("\\bmatrix",1,1),s.createLeftOf(t),n.ends[Ce].children().disown().adopt(s.ends[Ce],0,0).jQ.appendTo(s.ends[Ce].jQ),n.remove(),","==r.ctrlSeq?s.insertColumn(t):s.insertRow(t);i=r.replacedFragment,r.createBlocks(),e.createLeftOf.call(r,t),i&&(i.adopt(r.ends[Ce],0,0),i.jQ.appendTo(r.ends[Ce].jQ)),r.finalizeInsert(t.options),r.placeCursor(t),(this instanceof S||this instanceof re||this instanceof ne||this instanceof ae)&&t.workingGroupChange()},t.createBlocks=function(){var t,e,n=this,s=n.numBlocks(),i=n.blocks=Array(s);for(t=0;s>t;t+=1)e=i[t]=j(),e.adopt(n,n.ends[ye],0)},t.placeCursor=function(t){t.insAtRightEnd(this.foldChildren(this.ends[Ce],function(t,e){return t.isEmpty()?t:e}))},t.moveTowards=function(t,e,n){var s=n&&this[n+"Into"];e.insAtDirEnd(-t,s||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 De(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[Ce]=t.jQ.offset().left,e[ye]=e[Ce]+t.jQ.outerWidth(),e}var s,i=this,r=n(i);return t<r[Ce]?e.insLeftOf(i):t>r[ye]?e.insRightOf(i):(s=r[Ce],void i.eachChild(function(o){var a=n(o);
|
2
|
+
return t<a[Ce]?(t-s<a[Ce]-t?o[Ce]?e.insAtRightEnd(o[Ce]):e.insLeftOf(i):e.insAtLeftEnd(o),!1):t>a[ye]?void(o[ye]?s=a[ye]:r[ye]-t<t-a[ye]?e.insRightOf(i):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,s=this,r=s.blocks,o=" mathquill-command-id="+s.id,a=s.htmlTemplate.match(/<[^<>]+>|[^<>]+/g);for(i("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)){i("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],i("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(s,i){n+=1;var r=i.text(t);return s&&"("===e.textTemplate[n]&&"("===r[0]&&")"===r.slice(-1)?s+r.slice(1,-1)+e.textTemplate[n]:s+i.text(t)+(e.textTemplate[n]||"")})}}),C=Oe(O,function(e,n){e.init=function(t,e,s){s||(s=(t&&t.length>1?t.slice(1):t).trim()),n.init.call(this,t,e,[s])},e.parser=function(){return v.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}}),y=Oe(C,function(t,e){t.init=function(t,n,s){e.init.call(this,t,"<span>"+(n||t)+"</span>",s||t)},t.createLeftOf=function(t){if("."===this.ctrlSeq)if(0===t[Ce]||t[Ce]instanceof S)y("0").createLeftOf(t);else if(0!==t[Ce]&&"."===t[Ce].ctrlSeq)return t[Ce].ctrlSeq="…",t[Ce].jQ.html('<span class="mq-nonSymbola" style="font-size:0.6em;">…</span>'),void(t[Ce].textTemplate="..");e.createLeftOf.call(this,t)}}),S=Oe(C,function(t,e){t.init=function(t,n,s){e.init.call(this,t,'<span class="mq-binary-operator">'+n+"</span>",s)}}),j=Oe(k,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[Ce]&&0===this.ends[ye]?"":this.ends[Ce]===this.ends[ye]?this.ends[Ce].text(t):this.foldChildren("",function(e,n){return e+n.text(t)})},t.keystroke=function(t,n,s){var i,r,o;if(s.API.__options.spaceBehavesLikeTab&&("Spacebar"===t||"Shift-Spacebar"===t))return i=s.container.children(".mq-popup"),i.length>0?i.find("li.mq-popup-selected").click():(r=s.cursor,r[Ce]instanceof A&&r[Ce].autoOperator(r),s.escapeDir("Shift-Spacebar"===t?Ce:ye,t,n)),void n.preventDefault();if("Tab"===t)r=s.cursor,r[Ce]instanceof A&&r[Ce].autoOperator(r);else if("Backspace"===t||"Del"===t)return o=e.keystroke.apply(this,arguments),r=s.cursor,r[Ce]&&r[Ce]instanceof _?r[Ce].autoComplete():0===r[Ce]&&r.parent&&r.parent.parent instanceof ne&&"sub"===r.parent.parent.supsub&&r.parent.parent[Ce]?r.parent.parent[Ce].autoComplete():s.closePopup(),o;return e.keystroke.apply(this,arguments)},t.moveOutOf=function(t,e,n){var s=n&&this.parent[n+"Into"];!s&&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[ye];if(!n||n.jQ.offset().left+n.jQ.outerWidth()<t)return e.insAtRightEnd(this);if(t<this.ends[Ce].jQ.offset().left)return e.insAtLeftEnd(this);for(;t<n.jQ.offset().left;)n=n[Ce];return n.seek(t,e)},t.write=function(t,e,n){var s;if(e.match(/^[a-eg-zA-Z]$/)?s=A(e):e.match(/^[0-9\+\-]$/)&&t[Ce]instanceof _&&"e"===t[Ce].ctrlSeq&&0!==t[Ce][Ce]&&"undefined"!=typeof t[Ce][Ce]&&t[Ce][Ce].ctrlSeq.match(/^[0-9]$/)?s=se(e):e.match(/^[0-9\+\-]$/)&&t[Ce]instanceof _&&"e"===t[Ce].ctrlSeq&&0!==t[Ce][Ce]&&"\\cdot "===t[Ce][Ce].ctrlSeq&&0!==t[Ce][Ce][Ce]&&"undefined"!=typeof t[Ce][Ce][Ce]&&t[Ce][Ce][Ce].ctrlSeq.match(/^[0-9]$/)?(t[Ce][Ce].remove(),s=se(e)):s=e.match(/^[0-9\.]$/)&&(t[Ce]instanceof _||t.parent&&t.parent.parent instanceof ne&&"sub"===t.parent.parent.supsub)?A(e):(s=Ae[e]||_e[e])?s(e):y(e),!(!(s instanceof _)&&t[Ce]instanceof A&&t[Ce].autoOperator(t)&&s instanceof ue&&s.side===Ce)){if(t.parent&&t.parent.parent instanceof D&&t.parent===t.parent.parent.ends[Ce]){if(!(s instanceof _||"_"===e&&0===t[ye]))return;if(t[Ce]instanceof ne||"_"===e&&0===t[Ce])return}!((s instanceof _||s instanceof R)&&t[Ce]instanceof y)||t[Ce].ctrlSeq.match(/^[\,\u2026]$/)||t.parent&&t.parent.parent instanceof ne?s instanceof S||s instanceof re||s instanceof ne||s instanceof ue&&s.side===ye||0===t[Ce]||!(t[Ce]instanceof re||t[Ce]instanceof ue||t[Ce]instanceof se||t[Ce]instanceof ne&&!(s instanceof ue))||_e.cdot().createLeftOf(t):_e.cdot().createLeftOf(t),n&&s.replaces(n),s.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}}),Q=Oe(j,c),a.MathField=l(Oe(q,function(t){t.init=function(t,e){t.addClass("mq-editable-field mq-math-mode"),this.initRootAndEvents(Q(),t,e)}})),T=Ae["\\"]=Oe(O,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[Ce].focus=function(){return this.parent.jQ.addClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.removeClass("mq-empty"),this},this.ends[Ce].blur=function(){return this.parent.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.addClass("mq-empty"),this},this.ends[Ce].write=function(t,e,n){return n&&n.remove(),0==this.parent.ends[Ce].latex().indexOf("matrix")?void(/^matrix\dx\d$/.test(this.parent.ends[Ce].latex())?(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)):y(e).createLeftOf(t)):void(e.match(/[a-z]/i)?y(e).createLeftOf(t):(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)))},this.ends[Ce].keystroke=function(t,n,s){return"Tab"===t||"Enter"===t||"Spacebar"===t?(this.parent.renderCommand(s.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[Ce].latex()+" "},t.renderCommand=function(t){var e,n,s;if(this.jQ=this.jQ.last(),this.remove(),this[ye]?t.insLeftOf(this[ye]):t.insAtRightEnd(this.parent),e=this.ends[Ce].latex(),e||(e=" "),n=_e[e])n=n(e),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t);else{for(n=D(),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t),t.insAtRightEnd(n.blocks[0]),s=0;s<e.length;s++)A(e[s]).createLeftOf(t);t.insAtRightEnd(n.blocks[1])}}}),_e.notin=_e.sim=_e.cong=_e.equiv=_e.oplus=_e.otimes=Oe(S,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),_e.ast=_e.star=_e.loast=_e.lowast=s(S,"\\ast ","∗"),_e.therefor=_e.therefore=s(S,"\\therefore ","∴"),_e.cuz=_e.because=s(S,"\\because ","∵"),_e.prop=_e.propto=s(S,"\\propto ","∝"),_e["≈"]=_e.asymp=_e.approx=s(S,"\\approx ","≈"),_e.isin=_e["in"]=s(S,"\\in ","∈"),_e.ni=_e.contains=s(S,"\\ni ","∋"),_e.notni=_e.niton=_e.notcontains=_e.doesnotcontain=s(S,"\\not\\ni ","∌"),_e.sub=_e.subset=s(S,"\\subset ","⊂"),_e.sup=_e.supset=_e.superset=s(S,"\\supset ","⊃"),_e.nsub=_e.notsub=_e.nsubset=_e.notsubset=s(S,"\\not\\subset ","⊄"),_e.nsup=_e.notsup=_e.nsupset=_e.notsupset=_e.nsuperset=_e.notsuperset=s(S,"\\not\\supset ","⊅"),_e.sube=_e.subeq=_e.subsete=_e.subseteq=s(S,"\\subseteq ","⊆"),_e.supe=_e.supeq=_e.supsete=_e.supseteq=_e.supersete=_e.superseteq=s(S,"\\supseteq ","⊇"),_e.nsube=_e.nsubeq=_e.notsube=_e.notsubeq=_e.nsubsete=_e.nsubseteq=_e.notsubsete=_e.notsubseteq=s(S,"\\not\\subseteq ","⊈"),_e.nsupe=_e.nsupeq=_e.notsupe=_e.notsupeq=_e.nsupsete=_e.nsupseteq=_e.notsupsete=_e.notsupseteq=_e.nsupersete=_e.nsuperseteq=_e.notsupersete=_e.notsuperseteq=s(S,"\\not\\supseteq ","⊉"),_e.N=_e.naturals=_e.Naturals=s(y,"\\mathbb{N}","ℕ"),_e.P=_e.primes=_e.Primes=_e.projective=_e.Projective=_e.probability=_e.Probability=s(y,"\\mathbb{P}","ℙ"),_e.Z=_e.integers=_e.Integers=s(y,"\\mathbb{Z}","ℤ"),_e.Q=_e.rationals=_e.Rationals=s(y,"\\mathbb{Q}","ℚ"),_e.R=_e.reals=_e.Reals=s(y,"\\mathbb{R}","ℝ"),_e.C=_e.complex=_e.Complex=_e.complexes=_e.Complexes=_e.complexplane=_e.Complexplane=_e.ComplexPlane=s(y,"\\mathbb{C}","ℂ"),_e.H=_e.Hamiltonian=_e.quaternions=_e.Quaternions=s(y,"\\mathbb{H}","ℍ"),_e.quad=_e.emsp=s(y,"\\quad "," "),_e.qquad=s(y,"\\qquad "," "),_e.diamond=s(y,"\\diamond ","◇"),_e.bigtriangleup=s(y,"\\bigtriangleup ","△"),_e.ominus=s(y,"\\ominus ","⊖"),_e.uplus=s(y,"\\uplus ","⊎"),_e.bigtriangledown=s(y,"\\bigtriangledown ","▽"),_e.sqcap=s(y,"\\sqcap ","⊓"),_e.triangleleft=s(y,"\\triangleleft ","⊲"),_e.sqcup=s(y,"\\sqcup ","⊔"),_e.triangleright=s(y,"\\triangleright ","⊳"),_e.odot=s(y,"\\odot ","⊙"),_e.bigcirc=s(y,"\\bigcirc ","◯"),_e.dagger=s(y,"\\dagger ","†"),_e.ddagger=s(y,"\\ddagger ","‡"),_e.wr=s(y,"\\wr ","≀"),_e.amalg=s(y,"\\amalg ","∐"),_e.models=s(y,"\\models ","⊨"),_e.prec=s(y,"\\prec ","≺"),_e.succ=s(y,"\\succ ","≻"),_e.preceq=s(y,"\\preceq ","≼"),_e.succeq=s(y,"\\succeq ","≽"),_e.simeq=s(y,"\\simeq ","≃"),_e.mid=s(y,"\\mid ","∣"),_e.ll=s(y,"\\ll ","≪"),_e.gg=s(y,"\\gg ","≫"),_e.parallel=s(y,"\\parallel ","∥"),_e.bowtie=s(y,"\\bowtie ","⋈"),_e.sqsubset=s(y,"\\sqsubset ","⊏"),_e.sqsupset=s(y,"\\sqsupset ","⊐"),_e.smile=s(y,"\\smile ","⌣"),_e.sqsubseteq=s(y,"\\sqsubseteq ","⊑"),_e.sqsupseteq=s(y,"\\sqsupseteq ","⊒"),_e.doteq=s(y,"\\doteq ","≐"),_e.frown=s(y,"\\frown ","⌢"),_e.vdash=s(y,"\\vdash ","⊦"),_e.dashv=s(y,"\\dashv ","⊣"),_e.longleftarrow=s(y,"\\longleftarrow ","←"),_e.longrightarrow=s(y,"\\longrightarrow ","→"),_e.Longleftarrow=s(y,"\\Longleftarrow ","⇐"),_e.Longrightarrow=s(y,"\\Longrightarrow ","⇒"),_e.longleftrightarrow=s(y,"\\longleftrightarrow ","↔"),_e.updownarrow=s(y,"\\updownarrow ","↕"),_e.Longleftrightarrow=s(y,"\\Longleftrightarrow ","⇔"),_e.Updownarrow=s(y,"\\Updownarrow ","⇕"),_e.mapsto=s(y,"\\mapsto ","↦"),_e.nearrow=s(y,"\\nearrow ","↗"),_e.hookleftarrow=s(y,"\\hookleftarrow ","↩"),_e.hookrightarrow=s(y,"\\hookrightarrow ","↪"),_e.searrow=s(y,"\\searrow ","↘"),_e.leftharpoonup=s(y,"\\leftharpoonup ","↼"),_e.rightharpoonup=s(y,"\\rightharpoonup ","⇀"),_e.swarrow=s(y,"\\swarrow ","↙"),_e.leftharpoondown=s(y,"\\leftharpoondown ","↽"),_e.rightharpoondown=s(y,"\\rightharpoondown ","⇁"),_e.nwarrow=s(y,"\\nwarrow ","↖"),_e.ldots=s(y,"\\ldots ","…"),_e.cdots=s(y,"\\cdots ","⋯"),_e.vdots=s(y,"\\vdots ","⋮"),_e.ddots=s(y,"\\ddots ","⋰"),_e.surd=s(y,"\\surd ","√"),_e.triangle=s(y,"\\triangle ","▵"),_e.ell=s(y,"\\ell ","ℓ"),_e.top=s(y,"\\top ","⊤"),_e.flat=s(y,"\\flat ","♭"),_e.natural=s(y,"\\natural ","♮"),_e.sharp=s(y,"\\sharp ","♯"),_e.wp=s(y,"\\wp ","℘"),_e.bot=s(y,"\\bot ","⊥"),_e.clubsuit=s(y,"\\clubsuit ","♣"),_e.diamondsuit=s(y,"\\diamondsuit ","♢"),_e.heartsuit=s(y,"\\heartsuit ","♡"),_e.spadesuit=s(y,"\\spadesuit ","♠"),_e.oint=s(y,"\\oint ","∮"),_e.bigcap=s(y,"\\bigcap ","∩"),_e.bigcup=s(y,"\\bigcup ","∪"),_e.bigsqcup=s(y,"\\bigsqcup ","⊔"),_e.bigvee=s(y,"\\bigvee ","∨"),_e.bigwedge=s(y,"\\bigwedge ","∧"),_e.bigodot=s(y,"\\bigodot ","⊙"),_e.bigotimes=s(y,"\\bigotimes ","⊗"),_e.bigoplus=s(y,"\\bigoplus ","⊕"),_e.biguplus=s(y,"\\biguplus ","⊎"),_e.lfloor=s(y,"\\lfloor ","⌊"),_e.rfloor=s(y,"\\rfloor ","⌋"),_e.lceil=s(y,"\\lceil ","⌈"),_e.rceil=s(y,"\\rceil ","⌉"),_e.opencurlybrace=_e.lbrace=s(y,"\\lbrace ","{"),_e.closecurlybrace=_e.rbrace=s(y,"\\rbrace ","}"),_e["∫"]=_e["int"]=_e.integral=s(C,"\\int ","<big>∫</big>"),_e.caret=s(y,"\\text{^}","^"),_e.underscore=s(y,"\\_","_"),_e.slash=s(y,"/"),_e.vert=s(y,"|"),_e.perp=_e.perpendicular=s(y,"\\perp ","⊥"),_e.nabla=_e.del=s(y,"\\nabla ","∇"),_e.hbar=s(y,"\\hbar ","ℏ"),_e.AA=_e.Angstrom=_e.angstrom=s(y,"\\text\\AA ","Å"),_e.ring=_e.circ=_e.circle=s(y,"\\circ ","∘"),_e.bull=_e.bullet=s(y,"\\bullet ","•"),_e.setminus=_e.smallsetminus=s(y,"\\setminus ","∖"),_e.not=_e["¬"]=_e.neg=s(y,"\\neg ","¬"),_e.dots=_e.ellip=_e.hellip=_e.ellipsis=_e.hellipsis=s(y,"\\dots ","…"),_e["…"]=s(y,"…",'<span class="mq-nonSymbola" style="font-size:0.6em;">…</span>',".."),_e.converges=_e.darr=_e.dnarr=_e.dnarrow=_e.downarrow=s(y,"\\downarrow ","↓"),_e.dArr=_e.dnArr=_e.dnArrow=_e.Downarrow=s(y,"\\Downarrow ","⇓"),_e.diverges=_e.uarr=_e.uparrow=s(y,"\\uparrow ","↑"),_e.uArr=_e.Uparrow=s(y,"\\Uparrow ","⇑"),_e.to=s(S,"\\to ","→"),_e.rarr=_e.rightarrow=s(y,"\\rightarrow ","→"),_e.implies=s(S,"\\Rightarrow ","⇒"),_e.rArr=_e.Rightarrow=s(y,"\\Rightarrow ","⇒"),_e.gets=s(S,"\\gets ","←"),_e.larr=_e.leftarrow=s(y,"\\leftarrow ","←"),_e.impliedby=s(S,"\\Leftarrow ","⇐"),_e.lArr=_e.Leftarrow=s(y,"\\Leftarrow ","⇐"),_e.harr=_e.lrarr=_e.leftrightarrow=s(y,"\\leftrightarrow ","↔"),_e.iff=s(S,"\\Leftrightarrow ","⇔"),_e.hArr=_e.lrArr=_e.Leftrightarrow=s(y,"\\Leftrightarrow ","⇔"),_e.Re=_e.Real=_e.real=s(y,"\\Re ","ℜ"),_e.Im=_e.imag=_e.image=_e.imagin=_e.imaginary=_e.Imaginary=s(y,"\\Im ","ℑ"),_e.part=_e.partial=s(y,"\\partial ","∂"),_e.infty=_e.infin=_e.infinity=s(y,"\\infty ","∞"),_e.alef=_e.alefsym=_e.aleph=_e.alephsym=s(y,"\\aleph ","ℵ"),_e.xist=_e.xists=_e.exist=_e.exists=s(y,"\\exists ","∃"),_e.and=_e.land=_e.wedge=s(y,"\\wedge ","∧"),_e.or=_e.lor=_e.vee=s(y,"\\vee ","∨"),_e.o=_e.O=_e.empty=_e.emptyset=_e.oslash=_e.Oslash=_e.nothing=_e.varnothing=s(S,"\\varnothing ","∅"),_e.cup=_e.union=s(S,"\\cup ","∪"),_e.cap=_e.intersect=_e.intersection=s(S,"\\cap ","∩"),_e.deg=_e.degree=s(y,"^\\circ ","°"),_e.ang=_e.angle=s(y,"\\angle ","∠"),_=Oe(C,function(t,e){t.init=function(t,n){e.init.call(this,t,"<var>"+(n||t)+"</var>")},t.text=function(){return this.textTemplate},t.autoUnItalicize=function(t){var e,n,s,i,r="",o=[];for(e=this;e instanceof _;e=e[Ce])r=e.ctrlSeq+r,o.push(e);if(t.parent&&t.parent.parent instanceof ne&&"sub"===t.parent.parent.supsub){for(r="_"+r,o=[t.parent.parent],e=t.parent.parent[Ce];e instanceof _;e=e[Ce])r=e.ctrlSeq+r,o.push(e);t.insRightOf(t.parent.parent)}for(n=D(),n.createLeftOf(t),s=0;s<o.length;s++){if("f"===o[s].ctrlSeq&&o[s].jQ.removeClass("mq-florin").html("f"),o[s]instanceof ne&&"sub"===o[s].supsub)for(i=o[s].blocks[0].ends[Ce];0!==i;i=i[ye])"f"===i.ctrlSeq&&i.jQ.removeClass("mq-florin").html("f");o[s].disown(),o[s].adopt(n.ends[Ce],0,n.ends[Ce].ends[Ce]),o[s].jQ.prependTo(n.ends[Ce].jQ)}n.ends[Ce].jQ.removeClass("mq-empty")},t.fullWord=function(){var t,e=this.text()+"",n=[this];for(t=this[Ce];t instanceof _;t=t[Ce])n.unshift(t),e=t.text()+e;if(this.parent&&this.parent.parent instanceof ne&&"sub"===this.parent.parent.supsub)for(e="_"+e,n=[this.parent.parent],t=this.parent.parent[Ce];t instanceof _;t=t[Ce])n.unshift(t),e=t.text()+e;for(t=this[ye];t instanceof _;t=t[ye])n.push(t),e+=t.text();if(t instanceof ne&&"sub"===t.supsub)for(e+="_",n.push(t),t=t.sub.ends[Ce];t instanceof _;t=t[ye])e+=t.text();return[e,n]},t.finalizeTree=function(){this.autoComplete()},t.autoComplete=function(){var t,e,n,s,i,r,o,a,l,c,h,u,p,f,d;if(this.controller||this.getController(),t=this.fullWord(),e=t[0],n=t[1],e.length>2){for(s=function(t,e){var n,s=Object.keys(e.controller.API.__options.autoCommands);for(n=0;n<s.length;n++){if(t===s[n]){t=_e[s[n]](s[n]).htmlTemplate;break}t=t.replace(new RegExp("^"+s[n]+"_",""),_e[s[n]](s[n]).htmlTemplate+"_")}return t.indexOf("_")>-1?t.replace("_","<sub>")+"</sub>":t},i=this.controller.API.__options.autocomplete||[],r=this.controller.API.__options.staticAutocomplete||[],o=[],a=new RegExp("^"+e+".*$","i"),l=0;l<i.length;l++)i[l].match(a)&&o.push("<li data-word='"+i[l]+"'><span class='mq-nonSymbola'><i>"+s(i[l],this)+"</i></span></li>");for(l=0;l<r.length;l++)r[l].match(a)&&o.push("<li data-word='"+r[l]+"('><span class='mq-operator-name'>"+(r[l].indexOf("_")>-1?r[l].replace("_","<sub>")+"</sub>":r[l])+"(<span class='mq-inline-box'></span>)</span></li>");o.length>0?(o[0]=o[0].replace("<li",'<li class="mq-popup-selected"'),c=n[0].jQ,h=n[n.length-1].jQ,u=c.position(),p=h.position(),f=this,d=function(){var t,e=Se(this).attr("data-word"),n=f.fullWord()[1],s=n[0][Ce],i=n[0].parent;for(t=0;t<n.length;t++)n[t].remove();s?f.controller.cursor.insRightOf(s):f.controller.cursor.insAtRightEnd(i),f.controller.API.typedText(e),f.controller.closePopup(),"("!==e[e.length-1]&&f.controller.cursor.parent&&f.controller.cursor.parent.parent instanceof ne&&"sub"===f.controller.cursor.parent.parent.supsub&&f.controller.cursor.insRightOf(f.controller.cursor.parent.parent),f.controller.cursor.workingGroupChange()},this.controller.createPopup("<ul>"+o.join("\n")+"</ul>",p.top+h.height(),u.left,d)):this.controller.closePopup()}else this.controller.closePopup()}}),m.p.autoCommands={_maxLength:0},g.autoCommands=function(t){var e,n,s,i,r;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},s=0,i=0;i<e.length;i+=1){if(r=e[i],r.length<2)throw'autocommand "'+r+'" not minimum length of 2';if(_e[r]===D)throw'"'+r+'" is a built-in operator name';n[r]=1,s=we(s,r.length)}return n},A=Oe(_,function(t,e){t.init=function(t){return e.init.call(this,this.letter=t)},t.autoOperator=function(t){for(var e=t.options.autoCommands,n=t[Ce].letter,s=t[Ce][Ce],i=1;s instanceof A;)n=s.letter+n,s=s[Ce],i+=1;if(n.length>1&&e.hasOwnProperty(n)){for(i=1,s=t[Ce];i<n.length;i+=1,s=s[Ce]);return Te(s,t[Ce]).remove(),t[Ce]=s[Ce],_e[n](n).createLeftOf(t),!0}return!1}}),L={},function(){var t,e,n,s=m.p.autoOperatorNames={_maxLength:9},i="arg deg det dim exp gcd hom inf ker lg lim ln log max min sup limsup liminf injlim projlim Pr".split(" ");for(t=0;t<i.length;t+=1)L[i[t]]=s[i[t]]=1;for(e="sin cos tan arcsin arccos arctan sinh cosh tanh sec csc cot coth".split(" "),t=0;t<e.length;t+=1)L[e[t]]=1;for(n="sin cos tan sec cosec csc cotan cot ctg".split(" "),t=0;t<n.length;t+=1)s[n[t]]=s["arc"+n[t]]=s[n[t]+"h"]=s["ar"+n[t]+"h"]=s["arc"+n[t]+"h"]=1}(),g.autoOperatorNames=function(t){var e,n,s,i,r;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},s=0,i=0;i<e.length;i+=1){if(r=e[i],r.length<2)throw'"'+r+'" not minimum length of 2';n[r]=1,s=we(s,r.length)}return n._maxLength=s,n},D=_e.operatorname=Oe(O,function(t,e){t.htmlTemplate='<span><span class="mq-operator-name">&0</span><span class="mq-non-leaf"><span class="mq-scaled mq-paren">(</span><span class="mq-non-leaf">&1</span><span class="mq-scaled mq-paren">)</span></span></span>',t.init=function(t){e.init.call(this,t)},t.createLeftOf=function(t){e.createLeftOf.apply(this,arguments),t.insAtRightEnd(this.blocks[1])},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);U(t,ve(1+.2*(n-1),1.2),1.05*n)},t.text=function(t){return this.blocks[0].text(t)+"("+this.blocks[1].text(t)+")"},t.latex=function(){return L.hasOwnProperty(this.blocks[0].text())?"\\"+this.blocks[0].latex()+"\\left({"+this.blocks[1].latex()+"}\\right)":"\\operatorname{"+this.blocks[0].latex()+"}\\left({"+this.blocks[1].latex()+"}\\right)"},t.parser=function(){var t,e=v.string,n=v.optWhitespace,s=v.succeed,i=x.block,r=this.ctrlSeq,o=this,a=o.blocks=[j(),j()];for(t=0;t<a.length;t+=1)a[t].adopt(o,o.ends[ye],0);if(L.hasOwnProperty(this.ctrlSeq)){for(t=0;t<r.length;t+=1)A(r.charAt(t)).adopt(this.ends[Ce],this.ends[Ce].ends[ye],0);return n.then(e("\\left(")).then(function(){var t=a[1];return i.then(function(e){return e.children().adopt(t,t.ends[ye],0),s(o)})}).then(e("\\right)")).result(o)}return n.then(function(){var t=a[0];return i.then(function(e){var n,i;for(e.children().adopt(t,t.ends[ye],0),n=e.ends[Ce];0!==n;n=n[ye])if("f"===n.ctrlSeq)n.htmlTemplate="<var>f</var>";else if(n instanceof ne&&"sub"===n.supsub)for(i=n.blocks[0].ends[Ce];0!==i;i=i[ye])"f"===i.ctrlSeq&&(i.htmlTemplate="<var>f</var>");return s(o)})}).then(e("\\left(")).then(function(){var t=a[1];return i.then(function(e){return e.children().adopt(t,t.ends[ye],0),s(o)})}).then(e("\\right)")).result(o)}});for(E in L)L.hasOwnProperty(E)&&(_e[E]=D);_e.f=Oe(A,function(t,e){t.init=function(){C.p.init.call(this,this.letter="f",'<var class="mq-florin">ƒ</var>')},t.createLeftOf=function(t){t.parent&&t.parent.parent instanceof D&&t.parent===t.parent.parent.blocks[0]?A("f").createLeftOf(t):t.parent&&t.parent.parent&&t.parent.parent instanceof ne&&"sub"===t.parent.parent.supsub&&t.parent.parent.parent&&t.parent.parent.parent.parent instanceof D&&t.parent.parent.parent===t.parent.parent.parent.parent.blocks[0]?A("f").createLeftOf(t):e.createLeftOf.call(this,t)}}),_e[" "]=_e.space=s(y,"\\ "," "),_e["'"]=_e.prime=s(y,"'","′"),_e.backslash=s(y,"\\backslash ","\\"),Ae["\\"]||(Ae["\\"]=_e.backslash),R=Oe(O,function(t,e){t.init=function(t,n){this.htmlTemplate="<span><span>"+n+"</span><span>&0</span></span>",this.textTemplate=[" "+n," "],e.init.call(this,t)},t.finalizeTree=function(){this.ends[Ce].write=function(t,e){RegExp(/[0-9\.]/).test(e)||t.insRightOf(this.parent),j.p.write.apply(this,arguments)}}}),_e.$=s(R,"\\$","$"),I=Oe(_,function(t,e){t.init=function(t,n){e.init.call(this,t,'<span class="mq-nonSymbola">'+(n||t)+"</span>")}}),_e["@"]=I,_e["&"]=s(I,"\\&","&"),_e["%"]=s(I,"\\%","%"),_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=Oe(_,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),_e.phi=s(_,"\\phi ","ϕ"),_e.phiv=_e.varphi=s(_,"\\varphi ","φ"),_e.epsilon=s(_,"\\epsilon ","ϵ"),_e.epsiv=_e.varepsilon=s(_,"\\varepsilon ","ε"),_e.piv=_e.varpi=s(_,"\\varpi ","ϖ"),_e.sigmaf=_e.sigmav=_e.varsigma=s(_,"\\varsigma ","ς"),_e.thetav=_e.vartheta=_e.thetasym=s(_,"\\vartheta ","ϑ"),_e.upsilon=_e.upsi=s(_,"\\upsilon ","υ"),_e.gammad=_e.Gammad=_e.digamma=s(_,"\\digamma ","ϝ"),_e.kappav=_e.varkappa=s(_,"\\varkappa ","ϰ"),_e.rhov=_e.varrho=s(_,"\\varrho ","ϱ"),_e.pi=_e["π"]=s(I,"\\pi ","π"),_e.lambda=s(I,"\\lambda ","λ"),_e.Upsilon=_e.Upsi=_e.upsih=_e.Upsih=s(C,"\\Upsilon ",'<var style="font-family: serif">ϒ</var>'),_e.Gamma=_e.Delta=_e.Theta=_e.Lambda=_e.Xi=_e.Pi=_e.Sigma=_e.Phi=_e.Psi=_e.Omega=_e.forall=Oe(y,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),z=Oe(O,function(t){t.init=function(t){this.latex=t},t.createLeftOf=function(t){var e=x.parse(this.latex);e.children().adopt(t.parent,t[Ce],t[ye]),t[Ce]=e.ends[ye],e.jQize().insertBefore(t.jQ),e.finalizeInsert(t.options,t),e.ends[ye][ye].siblingCreated&&e.ends[ye][ye].siblingCreated(t.options,Ce),e.ends[Ce][Ce].siblingCreated&&e.ends[Ce][Ce].siblingCreated(t.options,ye),t.parent.bubble("reflow")},t.parser=function(){var t=x.parse(this.latex).children();return v.succeed(t)}}),_e["¹"]=s(z,"^1"),_e["²"]=s(z,"^2"),_e["³"]=s(z,"^3"),_e["¼"]=s(z,"\\frac14"),_e["½"]=s(z,"\\frac12"),_e["¾"]=s(z,"\\frac34"),B=Oe(S,function(t){t.init=y.prototype.init,t.contactWeld=t.siblingCreated=t.siblingDeleted=function(t,e){return e!==ye?(this.jQ[0].className=!this[Ce]||this[Ce]instanceof S?"":"mq-binary-operator",this):void 0}}),P=Oe(S,function(t){t.finalizeTree=function(){var t,e;if(this[Ce]&&"."===this[Ce].ctrlSeq){for(t=[this[Ce]],this[Ce][Ce]&&this[Ce][Ce][Ce]&&"0"===this[Ce][Ce].ctrlSeq&&"\\cdot "===this[Ce][Ce][Ce].ctrlSeq&&(t.push(this[Ce][Ce]),t.push(this[Ce][Ce][Ce])),e=0;e<t.length;e++)t[e].remove();this.jQ.html("⊙"),this.jQ.addClass("mq-multiply-elementWise"),this.ctrlSeq="."+this.ctrlSeq,this.textTemplate="."+this.textTemplate}}}),_e["+"]=s(B,"+","+"),_e["–"]=_e["-"]=s(B,"-","−"),_e["±"]=_e.pm=_e.plusmn=_e.plusminus=s(B,"\\pm ","±"),_e.mp=_e.mnplus=_e.minusplus=s(B,"\\mp ","∓"),Ae["*"]=_e.sdot=_e.cdot=s(P,"\\cdot ","·","*"),M=Oe(S,function(t,e){t.init=function(t,n){this.data=t,this.strict=n;var s=n?"Strict":"";e.init.call(this,t["ctrlSeq"+s],t["html"+s],t["text"+s])},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!==Ce||this.strict?void e.deleteTowards.apply(this,arguments):void this.swap(!0)}}),F={ctrlSeq:"\\le ",html:"≤",text:" <= ",ctrlSeqStrict:"<",htmlStrict:"<",textStrict:" < "},W={ctrlSeq:"\\ge ",html:"≥",text:" >= ",ctrlSeqStrict:">",htmlStrict:">",textStrict:" > "},$={ctrlSeq:"\\ne ",html:"≠",text:" != ",ctrlSeqStrict:"!",htmlStrict:"!",textStrict:"!"},_e["<"]=_e.lt=s(M,F,!0),_e[">"]=_e.gt=s(M,W,!0),_e["≤"]=_e.le=_e.leq=s(M,F,!1),_e["≥"]=_e.ge=_e.geq=s(M,W,!1),_e["!"]=s(M,$,!0),_e["≠"]=_e.ne=_e.neq=s(M,$,!1),G=Oe(M,function(t,e){t.init=function(t,n){e.init.call(this,t,n)},t.createLeftOf=function(t){return(t[Ce]instanceof M||t[Ce]instanceof G)&&t[Ce].strict?void t[Ce].swap(!1):void e.createLeftOf.apply(this,arguments)}}),N={ctrlSeq:"\\eq ",html:"==",text:" == ",ctrlSeqStrict:"=",htmlStrict:"=",textStrict:" := "},_e["="]=s(G,N,!0),_e.eq=s(G,N,!1),_e.times=s(S,"\\times ","×","[x]"),_e["÷"]=_e.div=_e.divide=_e.divides=s(S,"\\div ","÷","[/]"),H=t,V=document.createElement("div"),X=V.style,Z={transform:1,WebkitTransform:1,MozTransform:1,OTransform:1,msTransform:1};for(Y in Z)if(Y in X){K=Y;break}K?U=function(t,e,n){t.css(K,"scale("+e+","+n+")")}:"filter"in X?(H=function(t){t.className=t.className},U=function(t,e,n){function s(){t.css("marginRight",(i.width()-1)*(e-1)/e+"px")}var i,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>'),i=t.children().css("filter","progid:DXImageTransform.Microsoft.Matrix(M11="+e+",SizingMethod='auto expand')"),s(),r=setInterval(s),Se(window).load(function(){clearTimeout(r),s()})}):U=function(t,e,n){t.css("fontSize",n+"em")},J=Oe(O,function(t,e){t.init=function(t,n,s){e.init.call(this,t,"<"+n+" "+s+">&0</"+n+">")}}),_e.mathrm=s(J,"\\mathrm","span",'class="mq-roman mq-font"'),_e.mathit=s(J,"\\mathit","i",'class="mq-font"'),_e.mathbf=s(J,"\\mathbf","b",'class="mq-font"'),_e.mathsf=s(J,"\\mathsf","span",'class="mq-sans-serif mq-font"'),_e.mathtt=s(J,"\\mathtt","span",'class="mq-monospace mq-font"'),_e.underline=s(J,"\\underline","span",'class="mq-non-leaf mq-underline"'),_e.overline=_e.bar=s(J,"\\overline","span",'class="mq-non-leaf mq-overline"'),te=_e.textcolor=Oe(O,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=v.optWhitespace,s=v.string,i=v.regex;return n.then(s("{")).then(i(/^[#\w\s.,()%-]*/)).skip(s("}")).then(function(n){return t.setColor(n),e.parser.call(t)})}}),ee=_e["class"]=Oe(O,function(t,e){t.parser=function(){var t=this,n=v.string,s=v.regex;return v.optWhitespace.then(n("{")).then(s(/^[-\w\s\\\xA0-\xFF]*/)).skip(n("}")).then(function(n){return t.htmlTemplate='<span class="mq-class '+n+'">&0</span>',e.parser.call(t)})}}),ne=Oe(O,function(t,e){t.ctrlSeq="_{...}^{...}",t.createLeftOf=function(t){var n,s,i,r,o,a,l,c;if("sub"===this.supsub){if(!(t[Ce]instanceof _))return;t[Ce]instanceof _&&t[ye]instanceof _&&(n=_e.cdot(),n.createLeftOf(t),t.insLeftOf(n))}else{if(0===t[Ce]||t[Ce]instanceof S)return;if("."===t[Ce].ctrlSeq&&t[Ce][Ce]){for(s=[t[Ce]],t[Ce][Ce]&&t[Ce][Ce][Ce]&&t[Ce][Ce][Ce][Ce]&&"0"===t[Ce][Ce].ctrlSeq&&"\\cdot "===t[Ce][Ce][Ce].ctrlSeq?(s.push(t[Ce][Ce]),s.push(t[Ce][Ce][Ce]),i=t[Ce][Ce][Ce][Ce]):i=t[Ce][Ce],r=0;r<s.length;r++)s[r].remove();this.elementWise=!0,t.insRightOf(i)}if((t[Ce]instanceof re||t[Ce]instanceof se||t[Ce]instanceof ie)&&(o=Ae["("](),a=t[Ce],o.createLeftOf(t),a.disown(),a.adopt(o.ends[Ce],0,0),a.jQ.prependTo(o.ends[Ce].jQ),l=Ae[")"](),l.createLeftOf(t),o.reflow()),t[Ce]instanceof ne&&"sup"===t[Ce].supsub){for(o=Ae["("](),a=[t[Ce]],c=t[Ce];!(c instanceof S)&&0!==c;c=c[Ce])a.push(c);for(o.createLeftOf(t),r=0;r<a.length;r++)a[r].disown(),a[r].adopt(o.ends[Ce],0,o.ends[Ce].ends[Ce]),a[r].jQ.prependTo(o.ends[Ce].jQ);l=Ae[")"](),l.createLeftOf(t),o.reflow()}}return e.createLeftOf.call(this,t)},m.p.charsThatBreakOutOfSupSub="",t.finalizeTree=function(){var t,e,n,s=this.supsub;this.ends[Ce].write=function(t,e){("sub"!=s||"_"!==e)&&(t.options.charsThatBreakOutOfSupSub.indexOf(e)>-1&&t.insRightOf(this.parent),"sub"!=s||RegExp(/[A-Za-z0-9]/).test(e)||t.insRightOf(this.parent),j.p.write.apply(this,arguments))},this.sup&&this.sup.ends[Ce]&&"."===this.sup.ends[Ce].ctrlSeq&&(this.sup.ends[Ce].remove(),this.elementWise=!0),this.elementWise&&this.jQ.addClass("mq-elementwise"),this.sub&&(t=this.jQ.closest(".mq-editable-field").children(".mq-autocomplete").first(),t.length>0&&(e=this.jQ,n=e.position(),t.css({top:Math.ceil(n.top+e.height())+"px"})))},t.latex=function(){function t(t,n){var s=n&&n.latex();return n?t+(1===s.length?s:"{"+(e?".":"")+(s||" ")+"}"):""}var e=this.elementWise;return t("_",this.sub)+t("^",this.sup)},t.text=function(t){var e="";return this.sub&&(e+="_"+(this.sub&&0!==this.sub.ends[Ce]&&this.sub.ends[Ce]===this.sub.ends[ye]?this.sub.ends[Ce].text(t):this.sub.foldChildren("",function(e,n){return e+n.text(t)}))),this.sup&&(this.elementWise&&(e+="."),e+="^"+(this.sup&&this.sup.ends[Ce]===this.sup.ends[ye]?this.sup.ends[Ce].text(t):"("+this.sup.foldChildren("",function(e,n){return e+n.text(t)})+")")),e},t.respace=t.siblingCreated=t.siblingDeleted=function(t,e){e!==ye&&this.jQ.toggleClass("mq-limit","\\int "===this[Ce].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"> </span>'));for(var e=0;2>e;e+=1)(function(t,e,n,s){t[e].deleteOutOf=function(i,r){r.insDirOf(i,this.parent),this.isEmpty()||(r[-i]=this.ends[i],this.children().disown().withDirAdopt(i,r.parent,r[i],this.parent).jQ.insDirOf(i,this.parent.jQ)),t.supsub=n,delete t[e],delete t[s+"Into"],t[n][s+"OutOf"]=h,delete t[n].deleteOutOf,"sub"===e&&Se(t.jQ.addClass("mq-sup-only")[0].lastChild).remove(),this.remove()
|
3
|
+
}})(this,"sub sup".split(" ")[e],"sup sub".split(" ")[e],"down up".split(" ")[e])}}),se=_e.scientificNotation=Oe(O,function(t,e){t.ctrlSeq="ScientificNotation{...}{...}",t.htmlTemplate='<span><span>&0</span><span style="font-size:0.7em;">×</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[Ce],this.upInto=this.ends[ye],this.ends[Ce].upOutOf=this.ends[ye],this.ends[ye].downOutOf=this.ends[Ce],this.ends[Ce].write=function(t,e){RegExp(/[0-9]/).test(e)||t.insRightOf(this.parent),j.p.write.apply(this,arguments)},this.ends[ye].write=function(t,e){if(RegExp(/[0-9\+\-]/).test(e)){if("+"===e||"-"===e){if(0===t[Ce]&&0!==t[ye]&&("-"===t[ye].ctrlSeq||"+"===t[ye].ctrlSeq))return t[ye].ctrlSeq=e,t[ye].textTemplate=e,void t[ye].jQ.html(e);if(0!==t[Ce]&&0===t[Ce][Ce]&&("-"===t[Ce].ctrlSeq||"+"===t[Ce].ctrlSeq))return t[Ce].ctrlSeq=e,t[Ce].textTemplate=e,void t[Ce].jQ.html(e);0!==t[Ce]&&t.insRightOf(this.parent)}}else t.insRightOf(this.parent);j.p.write.apply(this,arguments)}},t.createLeftOf=function(t){if(e.createLeftOf.apply(this,arguments),"undefined"!=typeof this.incorporate_previous){var n=this[Ce];if(0===n)return;if(0===n[Ce])return;for(next=n[Ce];0!==next&&"undefined"!=typeof next.ctrlSeq&&next.ctrlSeq.match(/^[0-9\.]$/);next=n[Ce])next.disown().adopt(this.ends[Ce],0,this.ends[Ce].ends[Ce]),next.jQ.prependTo(this.ends[Ce].jQ);n.remove(),t.insAtLeftEnd(this.ends[ye]),this.ends[ye].write(t,this.incorporate_previous)}}}),ie=Oe(O,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>';C.prototype.init.call(this,t,n)},t.createLeftOf=function(t){e.createLeftOf.apply(this,arguments),A("n").createLeftOf(t),_e["="]().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);U(t,ve(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)"},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=v.string,n=v.optWhitespace,s=(v.whitespace,v.succeed),i=x.block,r=this,o=r.blocks=[j(),j(),j()];for(t=0;t<o.length;t+=1)o[t].adopt(r,r.ends[ye],0);return n.then(e("_")).then(function(){var t=o[0];return i.then(function(e){return e.children().adopt(t,t.ends[ye],0),s(r)})}).then(n).then(e("^")).then(function(){var t=o[1];return i.then(function(e){return e.children().adopt(t,t.ends[ye],0),s(r)})}).then(e("\\left(")).then(function(){var t=o[2];return i.then(function(e){return e.children().adopt(t,t.ends[ye],0),s(r)})}).then(e("\\right)")).result(r)},t.finalizeTree=function(){this.downInto=this.ends[Ce],this.upInto=this.ends[ye],this.ends[Ce].upOutOf=this.ends[ye],this.ends[ye].downOutOf=this.ends[Ce]}}),_e["∑"]=_e.sum=_e.summation=s(ie,"\\sum ","∑"),_e["∏"]=_e.prod=_e.product=s(ie,"\\prod ","∏"),_e.coprod=_e.coproduct=s(ie,"\\coprod ","∐"),_e.subscript=_e._=Oe(ne,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"> </span></span>',t.textTemplate=["_"],t.finalizeTree=function(){this.downInto=this.sub=this.ends[Ce],this.sub.upOutOf=h,e.finalizeTree.call(this)}}),_e.superscript=_e.supscript=_e["^"]=Oe(ne,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[ye],this.sup.downOutOf=h,e.finalizeTree.call(this)}}),re=_e.frac=_e.dfrac=_e.cfrac=_e.fraction=Oe(O,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"> </span></span>',t.textTemplate=["((",")/(","))"],t.finalizeTree=function(){this.jQ.closest(".mq-editable-field").children(".mq-popup").remove(),this.upInto=this.ends[ye].upOutOf=this.ends[Ce],this.downInto=this.ends[Ce].downOutOf=this.ends[ye],this.blocks[1].ends[Ce]&&"."===this.blocks[1].ends[Ce].ctrlSeq&&(this.blocks[1].ends[Ce].remove(),this.elementWise=!0),this.elementWise&&(this.jQ.wrap("<span class='mq-fraction-elementwise'></span>"),this.jQ=this.jQ.parent())},t.text=function(t){return"(("+this.blocks[0].text(t)+")"+(this.elementWise?".":"")+"/("+this.blocks[1].text(t)+"))"},t.latex=function(){return this.ctrlSeq+"{"+this.blocks[0].latex()+"}{"+(this.elementWise?".":"")+this.blocks[1].latex()+"}"}}),oe=_e.over=Ae["/"]=Oe(re,function(e,n){e.createLeftOf=function(e){var s,i,r,o;if(!this.replacedFragment){if(e[Ce]&&"."===e[Ce].ctrlSeq&&e[Ce][Ce]){for(s=[e[Ce]],e[Ce][Ce]&&e[Ce][Ce][Ce]&&e[Ce][Ce][Ce][Ce]&&"0"===e[Ce][Ce].ctrlSeq&&"\\cdot "===e[Ce][Ce][Ce].ctrlSeq?(s.push(e[Ce][Ce]),s.push(e[Ce][Ce][Ce]),i=e[Ce][Ce][Ce][Ce]):i=e[Ce][Ce],r=0;r<s.length;r++)s[r].remove();this.elementWise=!0,e.insRightOf(i)}for(o=e[Ce];o&&!(o instanceof S||o instanceof(_e.text||t)||o instanceof ie||"\\ "===o.ctrlSeq||/^[,;:]$/.test(o.ctrlSeq));)o=o[Ce];o instanceof ie&&o[ye]instanceof ne&&(o=o[ye],o[ye]instanceof ne&&o[ye].ctrlSeq!=o.ctrlSeq&&(o=o[ye])),o!==e[Ce]&&(this.replaces(Te(o[ye]||e.parent.ends[Ce],e[Ce])),e[Ce]=o)}n.createLeftOf.call(this,e)}}),ae=_e.sqrt=_e["√"]=Oe(O,function(t,e){t.ctrlSeq="\\sqrt",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-sqrt-prefix">√</span><span class="mq-non-leaf mq-sqrt-stem">&0</span></span>',t.textTemplate=[" sqrt(",")"],t.parser=function(){return x.optBlock.then(function(t){return x.block.map(function(e){var n=ce();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[ye].jQ;U(t.prev(),1,t.innerHeight()/+t.css("fontSize").slice(0,-2)-.1)}}),le=_e.vec=Oe(O,function(t){t.ctrlSeq="\\vec",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-vector-prefix">→</span><span class="mq-vector-stem">&0</span></span>',t.textTemplate=["vec(",")"]}),ce=_e.nthroot=Oe(ae,function(t){t.htmlTemplate='<sup class="mq-nthroot mq-non-leaf">&0</sup><span class="mq-scaled"><span class="mq-sqrt-prefix mq-scaled">√</span><span class="mq-sqrt-stem mq-non-leaf">&1</span></span>',t.textTemplate=["sqrt[","](",")"],t.latex=function(){return"\\sqrt["+this.ends[Ce].latex()+"]{"+this.ends[ye].latex()+"}"},t.text=function(t){return" "+this.ends[ye].text(t)+"^(1/"+this.ends[Ce].text(t)+")"}}),he=_e.begin=Oe(O,function(t,e){t.numBlocks=function(){return this.col*this.row},t.init=function(t,n,s){var i,r,o,a;for(this.col=n,this.row=s,this.ctrlSeq=t,i="",r=0;s>r;r++){for(o="",a=0;n>a;a++)o+='<span class="mq-cell">&'+(r*n+a)+"</span>";i+='<span class="mq-row">'+o+"</span>"}switch(this.ctrlSeq){case"\\pmatrix":i='<span class="mq-scaled mq-paren">(</span><span class="mq-matrix">'+i+'</span><span class="mq-scaled mq-paren">)</span>';break;case"\\bmatrix":i='<span class="mq-scaled mq-paren">[</span><span class="mq-matrix">'+i+'</span><span class="mq-scaled mq-paren">]</span>';break;case"\\Bmatrix":i='<span class="mq-scaled mq-paren">{</span><span class="mq-matrix">'+i+'</span><span class="mq-scaled mq-paren">}</span>';break;case"\\vmatrix":i='<span class="mq-scaled mq-paren">|</span><span class="mq-matrix">'+i+'</span><span class="mq-scaled mq-paren">|</span>';break;case"\\Vmatrix":i='<span class="mq-scaled mq-paren">||</span><span class="mq-matrix">'+i+'</span><span class="mq-scaled mq-paren">||</span>';break;default:i='<span class="mq-matrix">'+i+"</span>"}e.init.call(this,this.ctrlSeq,'<span class="mq-matrix-outer mq-non-leaf">'+i+"</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));U(t,ve(1+.2*(n-1),1.2),1.05*n),t.css("position","relative"),t.css("top",Math.round(.6*n)+"px")},t.contextMenuOLD=function(t,e){var n=this,s=[{text:"Insert Column Before",handler:function(){n.insertColumn(t,Ce)}},{text:"Insert Column After",handler:function(){n.insertColumn(t,ye)}},{text:"Insert Row Before",handler:function(){n.insertRow(t,Ce)}},{text:"Insert Row After",handler:function(){n.insertRow(t,ye)}}];this.col>1&&s.push({text:"Delete Column",handler:function(){n.deleteColumn(t)}}),this.row>1&&s.push({text:"Delete Row",handler:function(){n.deleteRow(t)}}),this.showPopupMenu(s,e)},t.latex=function(){var t="",e=1,n=this.col,s=this.numBlocks(),i=this.ctrlSeq.substring(1,this.ctrlSeq.length);return this.eachChild(function(i){i.ends[Ce]&&(t+=i.latex()),e!=s&&(t+=e%n==0?" \\\\ ":" & "),e++}),"\\begin{"+i+"}"+t+"\\end{"+i+"}"},t.text=function(t){var e,n,s=[];for(this.eachChild(function(e){s.push(e.ends[Ce]?e.text(t):0)}),e="",n=0;n<s.length;n++)n>0&&n%this.col==0?e+="],[":n>0&&(e+=","),e+=s[n];return this.row>1?"[["+e+"]]":"["+e+"]"},t.parser=function(){{var t=(x.block,v.string,v.regex);v.optWhitespace}return t(/^\{[pbvBV]?matrix\}[\s\S]*?\\end\{[pbvBV]?matrix\}/).map(function(t){var e,n,s,i,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()}),s=n.length,i=0,r=[],n.forEach(function(t){var e=t.split(/&/);i=Math.max(i,e.length),r=r.concat(e)}),o=he("\\"+e,i,s),a=o.blocks=Array(o.numBlocks()),l=0;l<a.length;l++)c=a[l]=x.parse(r[l]),c.adopt(o,o.ends[ye],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,s=t.parent;0!==s[Ce];)e++,e==this.col&&(e=0,n++),s=s[Ce];return{row:n,col:e}},t.deleteRow=function(t){var e,n,s;if(1!=this.row){for(e=this.cursorRowCol(t),n=e.row*this.col,s=0;s<this.col;s++)this.blocks[n].remove(),this.blocks.splice(n,1);n>0&&n<this.blocks.length?(this.blocks[n][Ce]=this.blocks[n-1],this.blocks[n-1][ye]=this.blocks[n]):0==n?this.blocks[n][Ce]=0:this.blocks[n-1][ye]=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(),t.workingGroupChange()}},t.deleteColumn=function(t){var e,n,s;if(1!=this.col){for(e=this.cursorRowCol(t),n=e.col,s=0;s<this.row;s++)this.blocks[n].remove(),this.blocks.splice(n,1),n>0&&n<this.blocks.length?(this.blocks[n][Ce]=this.blocks[n-1],this.blocks[n-1][ye]=this.blocks[n]):0==n?this.blocks[n][Ce]=0:this.blocks[n-1][ye]=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(),t.workingGroupChange()}},t.insertRow=function(t,e){var n,s,i,r,o=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[Ce]&&0!==t[ye]:e==Ce?!0:!1,s=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>'),i=0;i<this.col;i++)r=j(),r.adopt(this,s+i>0?this.blocks[s+i-1]:0,s+i>0?this.blocks[s+i-1][ye]:this.ends[Ce]),r.jQ=Se('<span class="mq-cell mq-empty" '+qe+'="'+r.id+'"></span>'),s+i>0&&(this.blocks[s+i-1][ye]=r),this.blocks.splice(s+i,0,r),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(o.row+(n?0:1)).append(r.jQ);s+i<this.blocks.length&&(this.blocks[s+i][Ce]=r,r[ye]=this.blocks[s+i]),this.row++,this.finalizeTree(),t.insAtLeftEnd(this.blocks[s]),this.reflow(),t.workingGroupChange()},t.insertColumn=function(t,e){var n,s,i,r=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[Ce]&&0!==t[ye]:e==Ce?!0:!1,s=this.row-1;s>=0;s--)i=j(),n?(i.adopt(this,s*this.col+r.col-1>=0?this.blocks[s*this.col+r.col-1]:0,this.blocks[s*this.col+r.col]),i.jQ=Se('<span class="mq-cell mq-empty" '+qe+'="'+i.id+'"></span>'),s*this.col+r.col-1>=0&&(this.blocks[s*this.col+r.col-1][ye]=i),this.blocks[s*this.col+r.col][Ce]=i,this.blocks.splice(s*this.col+r.col,0,i),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(s).children(".mq-cell").eq(r.col).before(i.jQ)):(i.adopt(this,this.blocks[s*this.col+r.col],s*this.col+r.col+1<this.row*this.col?this.blocks[s*this.col+r.col+1]:0),i.jQ=Se('<span class="mq-cell mq-empty" '+qe+'="'+i.id+'"></span>'),this.blocks[s*this.col+r.col][ye]=i,s*this.col+r.col+1<this.row*this.col&&(this.blocks[s*this.col+r.col+1][Ce]=i),this.blocks.splice(s*this.col+r.col+1,0,i),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(s).children(".mq-cell").eq(r.col).after(i.jQ));this.col++,this.finalizeTree(),t.insAtLeftEnd(t.parent[n?Ce:ye]),this.reflow(),t.workingGroupChange()},t.moveOrInsertColumn=function(t){var e=this.cursorRowCol(t);return e.col+1==this.col?this.insertColumn(t):(t.insAtLeftEnd(t.parent[ye]),void t.workingGroupChange())}}),_e.matrix=s(he,"\\matrix",1,1),_e.bmatrix=s(he,"\\bmatrix",1,1),_e.Bmatrix=s(he,"\\Bmatrix",1,1),_e.vmatrix=s(he,"\\vmatrix",1,1),_e.Vmatrix=s(he,"\\Vmatrix",1,1),_e.pmatrix=s(he,"\\pmatrix",1,1),ue=Oe(Oe(O,u),function(e,n){e.init=function(t,e,s,i,r,o,a){n.init.call(this,"\\left"+i,f,[e,s]),this.side=t,this.sides={},this.sides[Ce]={ch:e,ctrlSeq:i,textTemplate:o},this.sides[ye]={ch:s,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===ye?" mq-ghost":"")+'">'+this.sides[Ce].ch+'</span><span class="mq-non-leaf">&0</span><span class="mq-scaled mq-paren'+(this.side===Ce?" mq-ghost":"")+'">'+this.sides[ye].ch+"</span></span>",n.html.call(this)},e.latex=function(){return"\\left"+this.sides[Ce].ctrlSeq+this.ends[Ce].latex()+"\\right"+this.sides[ye].ctrlSeq},e.text=function(t){return"\\left["!==this.ctrlSeq||this[Ce]instanceof _?this.sides[Ce].textTemplate+this.ends[Ce].text(t)+this.sides[ye].textTemplate:"("+this.ends[Ce].text(t)+")"},e.oppBrack=function(t,e){return t instanceof ue&&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===Ce?0:1).removeClass("mq-ghost").html(this.sides[this.side].ch)},e.createLeftOf=function(t){var e,s,i,r,o,a;if(!this.replacedFragment){for(e=this.oppBrack(t[Ce],Ce)||this.oppBrack(t[ye],ye),s=t.parent.parent;0!==s&&!e;s=s.parent)e=this.oppBrack(s);if(!e&&"\\left("===this.ctrlSeq&&t[Ce]instanceof _&&this.side===Ce)return t[Ce].autoUnItalicize(t);if(!e&&"\\left("===this.ctrlSeq&&t[Ce]instanceof ne&&this.side===Ce&&"sub"===t[Ce].supsub&&t[Ce].sub.ends[ye]instanceof _)return t.insAtRightEnd(t[Ce].sub),t[Ce].autoUnItalicize(t);if(e||this.side!==ye||"\\left("!==this.ctrlSeq){if(e||this.side!==ye||"\\left["!==this.ctrlSeq){if(!e&&"\\left["===this.ctrlSeq&&0===t[Ce]&&0===t[ye]&&"undefined"!=typeof t.parent.parent&&t.parent.parent.ctrlSeq===this.ctrlSeq)return i=t.parent.parent[Ce],r=t.parent.parent.parent,t.parent.parent.unwrap(),0!==i?t.insRightOf(i):t.insAtLeftEnd(r),o=he("\\bmatrix",1,1),void o.createLeftOf(t)}else for(s=t.parent;0!==s;s=s.parent)if(s instanceof he)return t.insRightOf(s),t.workingGroupChange()}else for(s=t.parent;0!==s;s=s.parent){if(s instanceof D)return t.insRightOf(s),t.workingGroupChange();if(s instanceof ie)return t.insRightOf(s),t.workingGroupChange()}}e?(a=this.side=-e.side,this.closeOpposing(e),e===t.parent.parent&&t[a]&&(Te(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(Te(t[-a],t.parent.ends[-a],a)),t[-a]=0),n.createLeftOf.call(e,t)),a===Ce?t.insAtLeftEnd(e.ends[Ce]):t.insRightOf(e),t.workingGroupChange()},e.placeCursor=t,e.unwrap=function(){this.ends[Ce].children().disown().adopt(this.parent,this,this[ye]).jQ.insertAfter(this.jQ),this.remove()},e.deleteSide=function(t,e,n){var s,i=this.parent,r=this[t],o=i.ends[t];return t===this.side?(this.unwrap(),void(r?n.insDirOf(-t,r):n.insAtDirEnd(t,i))):(this.side=-t,void(this.oppBrack(this.ends[Ce].ends[this.side],t)?(this.closeOpposing(this.ends[Ce].ends[this.side]),s=this.ends[Ce].ends[t],this.unwrap(),s.siblingCreated&&s.siblingCreated(n.options,t),r?n.insDirOf(-t,r):n.insAtDirEnd(t,i)):(this.oppBrack(this.parent.parent,t)?(this.parent.parent.closeOpposing(this),this.parent.parent.unwrap()):(this.sides[t]={ch:pe[this.sides[this.side].ch],ctrlSeq:pe[this.sides[this.side].ctrlSeq]},this.delimjQs.removeClass("mq-ghost").eq(t===Ce?0:1).addClass("mq-ghost").html(this.sides[t].ch)),r?(s=this.ends[Ce].ends[t],Te(r,o,-t).disown().withDirAdopt(-t,this.ends[Ce],s,0).jQ.insAtDirEnd(t,this.ends[Ce].jQ.removeClass("mq-empty")),s.siblingCreated&&s.siblingCreated(n.options,t),n.insDirOf(-t,r)):e?n.insDirOf(t,this):n.insAtDirEnd(t,this.ends[Ce]))))},e.deleteTowards=function(t,e){this.deleteSide(-t,!1,e)},e.finalizeTree=function(){this.ends[Ce].deleteOutOf=function(t,e){this.parent.deleteSide(t,!0,e)},this.finalizeTree=this.intentionalBlur=function(){this.delimjQs.eq(this.side===Ce?1:0).removeClass("mq-ghost"),this.side=0}},e.siblingCreated=function(t,e){e===-this.side&&this.finalizeTree()}}),pe={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","\\{":"\\}","\\}":"\\{","⟨":"⟩","⟩":"⟨","\\langle ":"\\rangle ","\\rangle ":"\\langle ","|":"|"},p("("),p("["),_e.langle=s(ue,Ce,"⟨","⟩","\\langle ","\\rangle ","(",")"),_e.rangle=s(ue,ye,"⟨","⟩","\\langle ","\\rangle ","(",")"),Ae["|"]=s(ue,Ce,"|","|","|","|","abs(",")"),Ae["{"]=s(ue,Ce,"{","}","\\{","\\}","(",")"),Ae["}"]=s(ue,ye,"{","}","\\{","\\}","(",")"),_e.left=Oe(O,function(t){t.parser=function(){var t=v.regex,e=v.string,n=(v.succeed,v.optWhitespace);return n.then(t(/^(?:[([|]|\\\{)/)).then(function(s){var i="\\"===s.charAt(0)?s.slice(1):s;return x.then(function(r){return e("\\right").skip(n).then(t(/^(?:[\])|]|\\\})/)).map(function(t){var e="\\"===t.charAt(0)?t.slice(1):t,n="["===i?"[":"|"===i?"abs(":"(",o="["===i?"]":")",a=ue(0,i,e,s,t,n,o);return a.blocks=[r],r.adopt(a,0,0),a})})})}}),_e.right=Oe(O,function(t){t.parser=function(){return v.fail("unmatched \\right")}}),fe=_e.binom=_e.binomial=Oe(Oe(O,u),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(",",",")"]}),de=_e.choose=Oe(fe,function(t){t.createLeftOf=oe.prototype.createLeftOf}),me=Oe(a.MathField,function(t){t.init=function(t,e){c(t),this.__options=m();var n=Ee(this,t,e);n.editable=!0,n.createTextarea(),n.editablesTextareaEvents(),n.cursor.insAtRightEnd(t)}}),_e.MathQuillMathField=Oe(O,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=v.string,s=v.regex,i=v.succeed;return n("[").then(s(/^[a-z][a-z0-9]*/i)).skip(n("]")).map(function(e){t.name=e}).or(i()).then(e.parser.call(t))},t.finalizeTree=function(){me(this.ends[Ce],this.jQ)},t.registerInnerField=function(t){t.push(t[this.name]=this.ends[Ce].controller.API)},t.latex=function(){return this.ends[Ce].latex()},t.text=function(t){return this.ends[Ce].text(t)}})}();
|
@@ -459,10 +459,37 @@
|
|
459
459
|
filter: progid:DXImageTransform.Microsoft.Chroma(color='white');
|
460
460
|
margin-top: -0.1em;
|
461
461
|
}
|
462
|
-
.
|
463
|
-
|
464
|
-
}
|
465
|
-
#mq-popup-menu {
|
462
|
+
.mq-popup {
|
463
|
+
display: block;
|
466
464
|
position: absolute;
|
467
|
-
|
465
|
+
min-width: 200px;
|
466
|
+
max-height: 200px;
|
467
|
+
overflow-y: scroll;
|
468
|
+
background-color: white;
|
469
|
+
border: 1px solid black;
|
470
|
+
}
|
471
|
+
.mq-popup ul {
|
472
|
+
list-style-type: none;
|
473
|
+
margin: 0px;
|
474
|
+
padding: 0px;
|
475
|
+
}
|
476
|
+
.mq-popup ul li {
|
477
|
+
list-style-type: none;
|
478
|
+
padding: 5px 2px;
|
479
|
+
cursor: pointer;
|
480
|
+
}
|
481
|
+
.mq-popup ul li.mq-popup-selected {
|
482
|
+
background-color: #d7efed;
|
483
|
+
}
|
484
|
+
.mq-popup .mq-inline-box {
|
485
|
+
display: inline-block;
|
486
|
+
border-width: 0px;
|
487
|
+
background-color: #cccccc;
|
488
|
+
width: 10px;
|
489
|
+
height: 10px;
|
490
|
+
padding: 0px;
|
491
|
+
margin: 0px 2px;
|
492
|
+
}
|
493
|
+
.mq-editable_field {
|
494
|
+
position: relative;
|
468
495
|
}
|
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.
|
4
|
+
version: 0.9.3.116
|
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-03-
|
11
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|