/* Copyright (c) 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2010, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: Felipe Heidrich (IBM Corporation) - initial API and implementation Silenio Quarti (IBM Corporation) - initial API and implementation Copyright (c) 2010, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: Felipe Heidrich (IBM Corporation) - initial API and implementation Silenio Quarti (IBM Corporation) - initial API and implementation Copyright (c) 2010, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: Felipe Heidrich (IBM Corporation) - initial API and implementation Silenio Quarti (IBM Corporation) - initial API and implementation Mihai Sucan (Mozilla Foundation) - fix for Bug#334583 Bug#348471 Bug#349485 Bug#350595 Bug#360726 Bug#361180 Bug#362835 Bug#362428 Bug#362286 Bug#354270 Bug#361474 Bug#363945 Bug#366312 Bug#370584 Copyright (c) 2010, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: Felipe Heidrich (IBM Corporation) - initial API and implementation Silenio Quarti (IBM Corporation) - initial API and implementation Copyright (c) 2010, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: Felipe Heidrich (IBM Corporation) - initial API and implementation Silenio Quarti (IBM Corporation) - initial API and implementation Copyright (c) 2010, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: Felipe Heidrich (IBM Corporation) - initial API and implementation Silenio Quarti (IBM Corporation) - initial API and implementation Copyright (c) 2010, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: Felipe Heidrich (IBM Corporation) - initial API and implementation Silenio Quarti (IBM Corporation) - initial API and implementation Copyright (c) 2010, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2010, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2010, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2010, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: Felipe Heidrich (IBM Corporation) - initial API and implementation Silenio Quarti (IBM Corporation) - initial API and implementation Copyright (c) 2009, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2011, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2011, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2011, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2011, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2011, 2012 IBM Corporation and others. Copyright (c) 2012 VMware, Inc. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Andrew Eisenberg - rename to jsTemplateContentAssist.js Copyright (c) 2011, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2011, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2011, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2011, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Copyright (c) 2010, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation Alex Lakatos - fix for bug#369781 Copyright (c) 2013 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation RequireJS i18n 1.0.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved. Available via the MIT or new BSD license. see: http://github.com/jrburke/requirejs for details Copyright (c) 2011 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). Contributors: IBM Corporation - initial API and implementation */ var requirejs,require,define; (function(s){function r(c,j){var q,a,b,d,e,i,f,g,k,h=j&&j.split("/"),l=o.map,m=l&&l["*"]||{};if(c&&c.charAt(0)===".")if(j){h=h.slice(0,h.length-1);c=h.concat(c.split("/"));for(g=0;g0&&(c.splice(g-1,2),g-=2);c=c.join("/")}else c.indexOf("./")===0&&(c=c.substring(2));if((h||m)&&l){q=c.split("/");for(g=q.length;g>0;g-=1){a=q.slice(0,g).join("/");if(h)for(k=h.length;k>0;k-=1)if(b=l[h.slice(0, k).join("/")])if(b=b[a]){d=b;e=g;break}if(d)break;!i&&m&&m[a]&&(i=m[a],f=g)}!d&&i&&(d=i,e=f);d&&(q.splice(0,e,d),c=q.join("/"))}return c}function p(c,j){return function(){return a.apply(s,q.call(arguments,0).concat([c,j]))}}function f(c){return function(j){return r(j,c)}}function h(c){return function(j){i[c]=j}}function l(u){if(j.call(g,u)){var q=g[u];delete g[u];c[u]=!0;e.apply(s,q)}if(!j.call(i,u)&&!j.call(c,u))throw Error("No "+u);return i[u]}function k(c){var j,q=c?c.indexOf("!"):-1;q>-1&&(j= c.substring(0,q),c=c.substring(q+1,c.length));return[j,c]}function m(c){return function(){return o&&o.config&&o.config[c]||{}}}var e,a,b,d,i={},g={},o={},c={},j=Object.prototype.hasOwnProperty,q=[].slice;b=function(c,j){var q,a=k(c),b=a[0],c=a[1];b&&(b=r(b,j),q=l(b));b?c=q&&q.normalize?q.normalize(c,f(j)):r(c,j):(c=r(c,j),a=k(c),b=a[0],c=a[1],b&&(q=l(b)));return{f:b?b+"!"+c:c,n:c,pr:b,p:q}};d={require:function(c){return p(c)},exports:function(c){var j=i[c];return typeof j!=="undefined"?j:i[c]={}}, module:function(c){return{id:c,uri:"",exports:i[c],config:m(c)}}};e=function(q,a,e,n){var B,f,t,o,k=[],m,n=n||q;if(typeof e==="function"){a=!a.length&&e.length?["require","exports","module"]:a;for(o=0;o=0;l--)h[l]||h.splice(l,1);h.length===0&&delete this._eventTypes[r];f.compact=!1}}}},isListening:function(r){return!this._eventTypes?!1:this._eventTypes[r]!==void 0},removeEventListener:function(r, p,f){if(this._eventTypes){var h=this._eventTypes[r];if(h){for(var l=h.listeners,k=0,m=l.length;k1)this._text=[this._text.join("")];var h=f.string,l=h;!f.regex&&h&&(l=h.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&"));var k=null,m;if(l){var h=f.reverse,e=f.wrap,a=f.wholeWord,b=f.caseInsensitive,d=f.start||0,i=f.end,f=f.end!==void 0,g= "";g.indexOf("g")===-1&&(g+="g");b&&g.indexOf("i")===-1&&(g+="i");a&&(l="\\b"+l+"\\b");var o=this._text[0],c,j,q=0;f&&(o=o.substring(d,i),q=d);var u=RegExp(l,g);if(h)m=function(){var a=null;for(u.lastIndex=0;;){j=u.lastIndex;c=u.exec(o);if(j===u.lastIndex)return null;if(c){if(!(c.index1;)if(e=Math.floor((a+b)/2),k=this._lineOffsets[e],m=e+11&&(f=this.getText(this.getLineEnd(0), this.getLineEnd(0,!0))));this._lineDelimiter=f?f:r.platformDelimiter;if(h){var l=this.getLineCount();if(l>1){for(var k=Array(l),m=0;m0;)(!f.isIE||f.isIE>=9||f.isIE<9&&q[u].specified)&&j.removeAttribute(q[u].name)}if(c){if(c.styleClass)j.className=c.styleClass;if(q=c.style)for(var a in q)q.hasOwnProperty(a)&& (j.style[a]=q[a]);if(c=c.attributes)for(var b in c)c.hasOwnProperty(b)&&j.setAttribute(b,c[b])}}function k(c){return c instanceof Array?c.slice(0):c}function m(c,j){if(c===j)return!0;if(c&&!j||!c&&j)return!1;if(c&&c.constructor===String||j&&j.constructor===String)return!1;if(c instanceof Array||j instanceof Array){if(!(c instanceof Array&&j instanceof Array))return!1;if(c.length!==j.length)return!1;for(var q=0;qthis.end)c=this.start,this.start=this.end,this.end=c,this.caret=!this.caret},setCaret:function(c){this.end=this.start=c;this.caret=!1},getCaret:function(){return this.caret?this.start:this.end},toString:function(){return"start="+this.start+" end="+this.end+(this.caret?" caret is at start":" caret is at end")},isEmpty:function(){return this.start===this.end},equals:function(c){return this.caret===c.caret&&this.start===c.start&&this.end===c.end}};i.prototype={toString:function(){return"{l="+ this.left+", t="+this.top+", r="+this.right+", b="+this.bottom+"}"}};g.prototype={create:function(c,j){if(!this._lineDiv){var q=this._lineDiv=this._createLine(c,j,this.lineIndex);q._line=this;return q}},_createLine:function(c,j,q){var a=this.view,b=a._model,d=b.getLine(q),n=b.getLineStart(q),e={type:"LineStyle",textView:a,lineIndex:q,lineText:d,lineStart:n};if(d.length<2E3)a.onLineStyle(e);b=j||f.createElement(c.ownerDocument,"div");if(!j||!m(j.viewStyle,e.style)){l(e.style,b,j);if(j)j._trim=null; b.viewStyle=e.style;b.setAttribute("role","presentation")}b.lineIndex=q;q=[];this._createRanges(e.ranges,d,0,d.length,n,{tabOffset:0,ranges:q});d=" ";!a._fullSelection&&f.isIE<9&&(d="\ufeff");f.isWebkit&&(d="\u200c");q.push({text:d,style:a._metrics.largestFontStyle,ignoreChars:1});var i,t,g,o,k,d=a=0,h,w;if(j){if(t=j.modelChangedEvent)t.removedLineCount===0&&t.addedLineCount===0?(w=t.start-n,h=t.addedCharCount-t.removedCharCount):w=-1,j.modelChangedEvent=void 0;t=j.firstChild}for(n=0;n=w&&(g-=h);k=(k=t.firstChild.data)?k.length:0;if(d+k>g)break;d+=k}g=t.nextSibling;b.removeChild(t);t=g}i=this._createSpan(b,o,e,i.ignoreChars);t?b.insertBefore(i,t):b.appendChild(i);if(j)j.lineWidth=void 0}if(j)for(c=i?i.nextSibling:null;c;)g=c.nextSibling,j.removeChild(c),c=g;else c.appendChild(b);return b},_createRanges:function(c, j,q,a,b,d){if(!(q>=a)){if(c)for(var n=0;n=a)break;var f=Math.min(b+a,e.end)-b;if(i=q)){var d=this.view._customTabSize;if(d&&d!==8)for(var n= c.indexOf("\t",j);n!==-1&&n0){for(var e="\u00a0",i=1;ic){e=c-b;if(a._isRangeRects)d=d.createRange(),d.setStart(g,e),d.setEnd(g,e+1),e=new i(d.getBoundingClientRect());else if(f.isIE)d=d.body.createTextRange(),d.moveToElementText(n),d.collapse(),d.moveEnd("character",e+1),d.moveStart("character",e),e=new i(d.getBoundingClientRect());else{var o=g.data;n.removeChild(g);n.appendChild(d.createTextNode(o.substring(0, e)));var k=f.createElement(d,"span");k.appendChild(d.createTextNode(o.substring(e,e+1)));n.appendChild(k);n.appendChild(d.createTextNode(o.substring(e+1)));e=new i(k.getBoundingClientRect());n.innerHTML="";n.appendChild(g);this._createdDiv||(d=a._getSelection(),(b<=d.start&&d.startb.right)b.right=e.right;if(e.bottom>b.bottom)b.bottom=e.bottom}}}a=a.nextSibling}return c!==void 0?q[c]:q},_getLineBoundingClientRect:function(c,j){var q=new i(c.getBoundingClientRect());if(!this.view._wrapMode){q.right=q.left;for(var a=c.lastChild;a&&a.ignoreChars===a.firstChild.length;)a=a.previousSibling;if(a)a=a.getBoundingClientRect(),q.right=a.right+b(c).right}j&&(a=b(c),q.left+=a.left,q.right-=a.right);return q},getLineCount:function(){return!this.view._wrapMode? 1:this.getClientRects().length},getLineIndex:function(c){if(!this.view._wrapMode)return 0;for(var j=this.getClientRects(),c=this.getBoundingClientRect(c),c=c.top+(c.bottom-c.top)/2,q=0;qi.right&&(c=i.right-1)}else c<0&&(c=0),c>b.right-b.left&&(c=b.right-b.left);var o=n.ownerDocument,g=o.defaultView||o.parentWindow,k=f.isIE?g.screen.logicalXDPI/g.screen.deviceXDPI:1,h=f.isIE?g.screen.logicalYDPI/g.screen.deviceYDPI:1,g=d,l=n.firstChild; a:for(;l;){var m=l.firstChild,n=m.length;l.ignoreChars&&(n-=l.ignoreChars);var p,r,s;e=this._getClientRects(l,b);for(var y=0;y1;){var G=Math.floor((y+F)/2);i=F+1;e=G===n-1&&l.ignoreChars?m.length:G+1;q._isRangeRects?(o.setStart(m,i),o.setEnd(m,e)):(o.moveToElementText(l),o.move("character",i),o.moveEnd("character", e-i));e=o.getClientRects();for(var L=!1,I=0;Ip+(s-p)/2&&g++}else{i=[];for(k=0;k"), k===n-1?i.push(m.data.substring(k)):i.push(m.data.substring(k,k+1)),i.push("");l.innerHTML=i.join("");for(k=l.firstChild;k;){i=k.getBoundingClientRect();p=i.left-b.left;s=i.right-b.left;if(p<=c&&cp+(s-p)/2&&g++;break}g++;k=k.nextSibling}if(!this._createdDiv)l.innerHTML="",l.appendChild(m),b=q._getSelection(),(g<=b.start&&b.start0?j.getLineEnd(c):j.getLineStart(c)):j==="wordend"?this._getNextOffset_W3C(c,j,q):f.isIE?this._getNextOffset_IE(c,j,q):this._getNextOffset_W3C(c,j,q)},_getNextOffset_W3C:function(c,j,q){function a(c){return 33<=c&&c<=47||58<=c&&c<=64||91<=c&&c<=94||c===96||123<=c&&c<=126}if(j==="word"||j==="wordend"){var b=this.view._model,d=b.getLineAtOffset(c),n=b.getLine(d),e=b.getLineStart(d),d=b.getLineEnd(d),b=n.length;c-=e;var i,f;if(q>0){if(c===b)return d;i=n.charCodeAt(c); f=a(i);q=!f&&!(i===32||i===9);for(c++;cc){n=i.body.createTextRange();c===e&&q<0?n.moveToElementText(a.previousSibling):(n.moveToElementText(a),n.collapse(),n.moveEnd("character", c-e));e=n.text.length;n.moveEnd(j,q);n=c+n.text.length-e;break}e=b+e;a=a.nextSibling}return n},destroy:function(){var c=this._createdDiv;if(c)c.parentNode.removeChild(c),this._createdDiv=null}};o.prototype={addRuler:function(c,j){c.setView(this);var a=this._rulers;if(j!==void 0){var b,d;for(b=0,d=0;b0)){var c=this._model.getLineCount();this.redrawRulers(0,c);this.redrawLines(0,c)}},redrawRulers:function(c,j){if(!(this._redrawCount>0))for(var a=this.getRulers(),b=0;b0)&&(c===void 0&&(c=0),j===void 0&&(j=this._model.getLineCount()),c!==j)){var b=this._clientDiv;if(b){if(a)for(var d= (a.getLocation()==="left"?this._leftDiv:this._rightDiv).firstChild.rows[0].cells,e=0;e0)){var a=this._model;c===void 0&&(c=0);j===void 0&&(j=a.getCharCount());var b=a.getLineAtOffset(c),a=a.getLineAtOffset(Math.max(c,j-1))+1;this.redrawLines(b,a)}},removeRuler:function(c){for(var j=this._rulers,a=0;aj;if(b)var e=c,c=j,j=e;e=this._model.getCharCount();c=Math.max(0,Math.min(c,e));j=Math.max(0,Math.min(j,e));this._setSelection(new d(c,j,b),a===void 0||a)},setText:function(c,j,a){var b=j===void 0&&a===void 0;j===void 0&&(j=0);a===void 0&&(a=this._model.getCharCount());this._modifyContent({text:c,start:j,end:a,_code:!0},!b);if(b)this._columnX=-1,this._setSelection(new d(0,0,!1),!0),f.isFirefox&&this._fixCaret()},setTopIndex:function(c){this._clientDiv&& this._scrollView(0,this._getLinePixel(Math.max(0,c))-this._getScroll().y)},setTopPixel:function(c){this._clientDiv&&this._scrollView(0,Math.max(0,c)-this._getScroll().y)},showSelection:function(){return this._showCaret(!0)},update:function(c,j){this._clientDiv&&(c&&this._updateStyle(),j===void 0||j?this._update():this._queueUpdate())},_handleRootMouseDown:function(c){if(f.isFirefox&&c.which===1)this._clientDiv.contentEditable=!1,this._ignoreBlur=(this._overlayDiv||this._clientDiv).draggable=!0;var j= this._overlayDiv||this._clientDiv;if(f.isIE<9)j=this._viewDiv;for(var a=c.target?c.target:c.srcElement;a;){if(j===a)return;a=a.parentNode}c.preventDefault&&c.preventDefault();c.stopPropagation&&c.stopPropagation();if(!this._isW3CEvents){var b=this;this._getWindow().setTimeout(function(){b._clientDiv.focus()},0)}},_handleRootMouseUp:function(c){if(f.isFirefox&&c.which===1)this._clientDiv.contentEditable=!0,(this._overlayDiv||this._clientDiv).draggable=!1,this._fixCaret(),this._ignoreBlur=!1},_handleBlur:function(){if(!this._ignoreBlur){this._hasFocus= !1;if(f.isIE<9&&!this._getSelection().isEmpty()){var c=this._rootDiv,j=f.createElement(c.ownerDocument,"div");c.appendChild(j);c.removeChild(j)}if(this._selDiv1)if(this._selDiv1.style.background="lightgray",this._selDiv2.style.background="lightgray",this._selDiv3.style.background="lightgray",c=this._getWindow(),j=this._selDiv1.ownerDocument,c.getSelection){j=c.getSelection();for(c=j.anchorNode;c;){if(c===this._clientDiv){j.rangeCount>0&&j.removeAllRanges();break}c=c.parentNode}}else if(j.selection){this._ignoreSelect= !1;for(c=j.selection.createRange().parentElement();c;){if(c===this._clientDiv){j.selection.empty();break}c=c.parentNode}this._ignoreSelect=!0}if(!this._ignoreFocus)this.onBlur({type:"Blur"})}},_handleContextMenu:function(c){f.isIE&&this._lastMouseButton===3&&this._updateDOMSelection();var j=!1;if(this.isListening("ContextMenu"))j=this._createMouseEvent("ContextMenu",c),j.screenX=c.screenX,j.screenY=c.screenY,this.onContextMenu(j),j=j.defaultPrevented;if(j)return c.preventDefault&&c.preventDefault(), !1},_handleCopy:function(c){if(!this._ignoreCopy&&this._doCopy(c))return c.preventDefault&&c.preventDefault(),!1},_handleCut:function(c){if(this._doCut(c))return c.preventDefault&&c.preventDefault(),!1},_handleDataModified:function(){this._startIME()},_handleDblclick:function(c){this._lastMouseTime=c.timeStamp?c.timeStamp:(new Date).getTime();if(this._clickCount!==2)this._clickCount=2,this._handleMouse(c)},_handleDragStart:function(c){if(f.isFirefox){var j=this;this._getWindow().setTimeout(function(){j._clientDiv.contentEditable= !0;j._clientDiv.draggable=!1;j._ignoreBlur=!1},0)}if(this.isListening("DragStart")&&this._dragOffset!==-1)this._isMouseDown=!1,this.onDragStart(this._createMouseEvent("DragStart",c)),this._dragOffset=-1;else return c.preventDefault&&c.preventDefault(),!1},_handleDrag:function(c){if(this.isListening("Drag"))this.onDrag(this._createMouseEvent("Drag",c))},_handleDragEnd:function(c){this._dropTarget=!1;this._dragOffset=-1;if(this.isListening("DragEnd"))this.onDragEnd(this._createMouseEvent("DragEnd", c));f.isFirefox&&(this._fixCaret(),c.dataTransfer.dropEffect==="none"&&!c.dataTransfer.mozUserCancelled&&this._fixCaret())},_handleDragEnter:function(c){var j=!0;this._dropTarget=!0;this.isListening("DragEnter")&&(j=!1,this.onDragEnter(this._createMouseEvent("DragEnter",c)));if(f.isWebkit||j)return c.preventDefault&&c.preventDefault(),!1},_handleDragOver:function(c){var j=!0;this.isListening("DragOver")&&(j=!1,this.onDragOver(this._createMouseEvent("DragOver",c)));if(f.isWebkit||j){if(j)c.dataTransfer.dropEffect= "none";c.preventDefault&&c.preventDefault();return!1}},_handleDragLeave:function(c){this._dropTarget=!1;if(this.isListening("DragLeave"))this.onDragLeave(this._createMouseEvent("DragLeave",c))},_handleDrop:function(c){this._dropTarget=!1;if(this.isListening("Drop"))this.onDrop(this._createMouseEvent("Drop",c));c.preventDefault&&c.preventDefault();return!1},_handleFocus:function(){this._hasFocus=!0;f.isIOS&&this._lastTouchOffset!==void 0?(this.setCaretOffset(this._lastTouchOffset,!0),this._lastTouchOffset= void 0):this._updateDOMSelection();if(this._selDiv1){var c=this._highlightRGB;this._selDiv1.style.background=c;this._selDiv2.style.background=c;this._selDiv3.style.background=c}if(!this._ignoreFocus)this.onFocus({type:"Focus"})},_handleKeyDown:function(c){var j=!1;switch(c.keyCode){case 16:case 17:case 18:case 91:j=!0;break;default:this._setLinksVisible(!1)}if(c.keyCode===229){if(this._readonly)return c.preventDefault&&c.preventDefault(),!1;j=!0;f.isSafari&&f.isMac&&c.ctrlKey&&(j=!1);j&&this._startIME()}else j|| this._commitIME();if((f.isMac||f.isLinux)&&f.isFirefox<4||f.isOpera)return this._keyDownEvent=c,!0;if(this._doAction(c))return c.preventDefault?(c.preventDefault(),c.stopPropagation()):(c.cancelBubble=!0,c.returnValue=!1,c.keyCode=0),!1},_handleKeyPress:function(c){if(f.isMac&&f.isWebkit&&(63232<=c.keyCode&&c.keyCode<=63487||c.keyCode===13||c.keyCode===8))return c.preventDefault&&c.preventDefault(),!1;if(((f.isMac||f.isLinux)&&f.isFirefox<4||f.isOpera)&&this._doAction(this._keyDownEvent))return c.preventDefault&& c.preventDefault(),!1;var j=f.isMac?c.metaKey:c.ctrlKey;if(c.charCode!==void 0&&j)switch(c.charCode){case 99:case 118:case 120:return!0}j=!1;if(f.isMac){if(c.ctrlKey||c.metaKey)j=!0}else if(f.isFirefox){if(c.ctrlKey||c.altKey)j=!0}else c.ctrlKey^c.altKey&&(j=!0);if(!j&&(j=f.isOpera?c.which:c.charCode!==void 0?c.charCode:c.keyCode,j>31))return this._doContent(String.fromCharCode(j)),c.preventDefault&&c.preventDefault(),!1},_handleKeyUp:function(c){(f.isMac?c.metaKey:c.ctrlKey)||this._setLinksVisible(!1); c.keyCode===13&&this._commitIME()},_handleLinkClick:function(c){if(!(f.isMac?c.metaKey:c.ctrlKey))return c.preventDefault&&c.preventDefault(),!1},_handleMouse:function(c){var j=this._getWindow(),a=!0,b=j;if(f.isIE||f.isFirefox&&!this._overlayDiv)b=this._clientDiv;if(this._overlayDiv){if(this._hasFocus)this._ignoreFocus=!0;var d=this;j.setTimeout(function(){d.focus();d._ignoreFocus=!1},0)}this._clickCount===1?(a=this._setSelectionTo(c.clientX,c.clientY,c.shiftKey,!f.isOpera&&this._hasFocus&&this.isListening("DragStart")))&& this._setGrab(b):(this._isW3CEvents&&this._setGrab(b),this._doubleClickSelection=null,this._setSelectionTo(c.clientX,c.clientY,c.shiftKey),this._doubleClickSelection=this._getSelection());return a},_handleMouseDown:function(c){if(this._linksVisible)if((c.target||c.srcElement).tagName!=="A")this._setLinksVisible(!1);else return;this._commitIME();var j=c.which;j||(c.button===4&&(j=2),c.button===2&&(j=3),c.button===1&&(j=1));var a=j!==2&&c.timeStamp?c.timeStamp:(new Date).getTime(),b=a-this._lastMouseTime, d=Math.abs(this._lastMouseX-c.clientX),e=Math.abs(this._lastMouseY-c.clientY),n=this._lastMouseButton===j;this._lastMouseX=c.clientX;this._lastMouseY=c.clientY;this._lastMouseTime=a;this._lastMouseButton=j;if(j===1)this._isMouseDown=!0,n&&b<=this._clickTime&&d<=this._clickDist&&e<=this._clickDist?this._clickCount++:this._clickCount=1;if(this.isListening("MouseDown")&&(a=this._createMouseEvent("MouseDown",c),this.onMouseDown(a),a.defaultPrevented)){c.preventDefault();return}if(j===1&&this._handleMouse(c)&& (f.isIE>=9||f.isOpera||f.isChrome||f.isSafari||f.isFirefox&&!this._overlayDiv))this._hasFocus||this.focus(),c.preventDefault();f.isFirefox&&this._lastMouseButton===3&&this._updateDOMSelection()},_handleMouseOver:function(c){if(this.isListening("MouseOver"))this.onMouseOver(this._createMouseEvent("MouseOver",c))},_handleMouseOut:function(c){if(this.isListening("MouseOut"))this.onMouseOut(this._createMouseEvent("MouseOut",c))},_handleMouseMove:function(c){var j=this._isClientDiv(c);if(this.isListening("MouseMove")&& j)this.onMouseMove(this._createMouseEvent("MouseMove",c));if(!this._dropTarget){var a=this._linksVisible||this._lastMouseMoveX!==c.clientX||this._lastMouseMoveY!==c.clientY;this._lastMouseMoveX=c.clientX;this._lastMouseMoveY=c.clientY;this._setLinksVisible(a&&!this._isMouseDown&&(f.isMac?c.metaKey:c.ctrlKey));if(!this._isW3CEvents){if(c.button===0)return this._setGrab(null),!0;if(!this._isMouseDown&&c.button===1&&(this._clickCount&1)!==0&&j)return this._clickCount=2,this._handleMouse(c,this._clickCount)}if(this._isMouseDown&& this._dragOffset===-1){var j=c.clientX,c=c.clientY,b=this._getViewPadding(),d=this._viewDiv.getBoundingClientRect(),e=this._getClientWidth(),n=this._getClientHeight(),a=d.left+b.left,i=d.top+b.top,e=d.left+b.left+e,b=d.top+b.top+n,d=this._model,n=d.getLineAtOffset(this._getSelection().getCaret());cb&&n!==d.getLineCount()-1?this._doAutoScroll("down",j,c-b):je&&!this._wrapMode?this._doAutoScroll("right", j-e,c):(this._endAutoScroll(),this._setSelectionTo(j,c,!0))}}},_isClientDiv:function(c){for(var j=this._overlayDiv||this._clientDiv,c=c.target?c.target:c.srcElement;c;){if(j===c)return!0;c=c.parentNode}return!1},_createMouseEvent:function(c,j){var a=this.convert({x:j.clientX,y:j.clientY},"page","document");return{type:c,event:j,clickCount:this._clickCount,x:a.x,y:a.y,preventDefault:function(){this.defaultPrevented=!0}}},_handleMouseUp:function(c){var j=c.which?c.button===0:c.button===1;if(this.isListening("MouseUp")&& (this._isClientDiv(c)||j&&this._isMouseDown))this.onMouseUp(this._createMouseEvent("MouseUp",c));if(!this._linksVisible&&j&&this._isMouseDown){if(this._dragOffset!==-1)j=this._getSelection(),j.extend(this._dragOffset),j.collapse(),this._setSelection(j,!0,!0),this._dragOffset=-1;this._isMouseDown=!1;this._endAutoScroll();this._isW3CEvents&&this._setGrab(null);f.isFirefox&&c.preventDefault()}},_handleMouseWheel:function(c){var j=this._getLineHeight(),a=0,b=0;f.isIE||f.isOpera?b=-c.wheelDelta/40*j:f.isFirefox? (j=f.isMac?c.detail*3:Math.max(-256,Math.min(256,c.detail))*j,c.axis===c.HORIZONTAL_AXIS?a=j:b=j):f.isMac?(b=a=40,c.wheelDeltaX%120!==0&&(a=1),c.wheelDeltaY%120!==0&&(b=1),a=-c.wheelDeltaX/a,-10)a.getRangeAt(0).deleteContents(),e=b.ownerDocument.createTextNode(c.data),a.getRangeAt(0).insertNode(e),g=this._getDOMText(b,e),n=g.text,g=g.offset,e.parentNode.removeChild(e);b.lineRemoved=!0;for(b=0;i.charCodeAt(b)===n.charCodeAt(b)&&b=g+c.data.length;)a--;a++;i=n.substring(b,a+e);b+=d;a+=d;this._modifyContent({text:i,start:b,end:a,_ignoreDOMSelection:!0},!0)}}else this._doContent(c.data);c.preventDefault()},_handleTouchStart:function(c){this._commitIME();var a=this._getWindow();if(this._touchScrollTimer)this._vScrollDiv.style.display="none",this._hScrollDiv.style.display="none",a.clearInterval(this._touchScrollTimer),this._touchScrollTimer=null;var b=c.touches;if(b.length===1){var b=b[0],d=b.clientX,e=b.clientY; this._touchStartX=d;this._touchStartY=e;if(f.isAndroid&&(e0&&a.extend(b.getLineEnd(e-1));else{var n=!1;this._expandTab&&c.unit==="character"&&(d-i)%this._tabSize===0&&(n=!/[^ ]/.test(b.getText(i,d)));n?a.extend(d-this._tabSize):(b=this._getLine(e),a.extend(b.getNextOffset(d,c.unit,-1)),b.destroy())}}this._modifyContent({text:"", start:a.start,end:a.end},!0);return!0},_doContent:function(c){var a=this._getSelection();this._modifyContent({text:c,start:a.start,end:a.end,_ignoreDOMSelection:!0},!0)},_doCopy:function(c){var a=this._getSelection();return!a.isEmpty()?this._setClipboardText(this._getBaseText(a.start,a.end),c):!0},_doCursorNext:function(c){if(!c.select&&this._clearSelection("next"))return!0;var a=this._model,b=this._getSelection(),d=b.getCaret(),e=a.getLineAtOffset(d);d===a.getLineEnd(e)?e+10&&b.extend(a.getLineEnd(e-1)):(a=this._getLine(e),b.extend(a.getNextOffset(d,c.unit,-1)),a.destroy());c.select||b.collapse();this._setSelection(b,!0);return!0},_doCut:function(c){var a= this._getSelection();return!a.isEmpty()?(a=this._getBaseText(a.start,a.end),this._doContent(""),this._setClipboardText(a,c)):!0},_doDelete:function(c){var a=this._getSelection();if(a.isEmpty()){var b=this._model,d=a.getCaret(),e=b.getLineAtOffset(d);d===b.getLineEnd(e)?e+10?o=i.getClientRects(d-1).top+1:(g=e===0,g||(e--,o=this._getLineHeight(e)-1));g?c.select&&(b.extend(0),this._setSelection(b,!0,!0)):(i.lineIndex!==e&&(i.destroy(),i=this._getLine(e)),b.extend(i.getOffset(n,o)),c.select||b.collapse(),this._setSelection(b,!0,!0));this._columnX=n;i.destroy();return!0},_doPageDown:function(c){var a=this._model,b=this._getSelection(), d=b.getCaret(),e=a.getLineAtOffset(d),i=a.getLineCount(),n=this._getScroll(),g=this._getClientHeight(),o;if(this._lineHeight){a=this._columnX;n=this._getBoundsAtOffset(d);if(a===-1||c.select&&f.isIE)a=n.left;d=this._getLineIndex(n.top+g);o=this._getLine(d);e=this._getLinePixel(d);d=o.getOffset(a,n.top+g-e);g=o.getBoundingClientRect(d);o.destroy();b.extend(d);c.select||b.collapse();this._setSelection(b,!0,!0,g.top+e-n.top);this._columnX=a;return!0}if(ec&&(d=c-g);this._setSelection(b,!0,!0,d-n.y);this._columnX=a}return!0},_doPageUp:function(c){var a=this._model,b=this._getSelection(),d=b.getCaret(),e=a.getLineAtOffset(d),i=this._getScroll(),n=this._getClientHeight(),g;if(this._lineHeight){a=this._columnX; i=this._getBoundsAtOffset(d);if(a===-1||c.select&&f.isIE)a=i.left;d=this._getLineIndex(i.bottom-n);g=this._getLine(d);e=this._getLinePixel(d);d=g.getOffset(a,i.bottom-n-e);n=g.getBoundingClientRect(d);g.destroy();b.extend(d);c.select||b.collapse();this._setSelection(b,!0,!0,n.top+e-i.top);this._columnX=a;return!0}if(e>0){var o=this._getLineHeight(),n=Math.max(1,Math.min(e,Math.floor(n/o))),a=this._columnX;if(a===-1||c.select&&f.isIE)g=this._getLine(e),a=g.getBoundingClientRect(d).left,g.destroy(); g=this._getLine(e-n);b.extend(g.getOffset(a,this._getLineHeight(e-n)-1));g.destroy();c.select||b.collapse();c=Math.max(0,i.y-n*o);this._setSelection(b,!0,!0,c-i.y);this._columnX=a}return!0},_doPaste:function(c){var a=this;return this._getClipboardText(c,function(c){c&&(f.isLinux&&a._lastMouseButton===2&&(new Date).getTime()-a._lastMouseTime<=a._clickTime&&a._setSelectionTo(a._lastMouseX,a._lastMouseY),a._doContent(c))})!==null},_doScroll:function(c){var a=c.type,b=this._model,d=b.getLineCount(),c= this._getClientHeight(),e=this._getLineHeight();d*=e;var i=this._getScroll().y,n;switch(a){case "textStart":n=0;break;case "textEnd":n=d-c;break;case "pageDown":n=i+c;break;case "pageUp":n=i-c;break;case "centerLine":a=this._getSelection(),n=b.getLineAtOffset(a.start),b=(b.getLineAtOffset(a.end)-n+1)*e,n=n*e-c/2+b/2}n!==void 0&&(n=Math.min(Math.max(0,n),d-c),this._scrollView(0,n-i));return!0},_doSelectAll:function(){var c=this._model,a=this._getSelection();a.setCaret(0);a.extend(c.getCharCount()); this._setSelection(a,!1);return!0},_doTab:function(){if(this._tabMode&&!this._readonly){var c="\t";if(this._expandTab)var a=this._model,c=this._getSelection().getCaret(),b=a.getLineAtOffset(c),a=a.getLineStart(b),c=Array(this._tabSize-(c-a)%this._tabSize+1).join(" ");this._doContent(c);return!0}},_doShiftTab:function(){return!this._tabMode||this._readonly?void 0:!0},_doTabMode:function(){this._tabMode=!this._tabMode;return!0},_doWrapMode:function(){this.setOptions({wrapMode:!this.getOptions("wrapMode")}); return!0},_autoScroll:function(){var c=this._getSelection(),a=this.convert({x:this._autoScrollX,y:this._autoScrollY},"page","document"),b=c.getCaret(),d=this._model.getLineAtOffset(b),e;if(this._autoScrollDir==="up"||this._autoScrollDir==="down")b=this._autoScrollY/this._getLineHeight(),b=b<0?Math.floor(b):Math.ceil(b),e=d,e=Math.max(0,Math.min(this._model.getLineCount()-1,e+b));else if(this._autoScrollDir==="left"||this._autoScrollDir==="right")e=this._getLineIndex(a.y),d=this._getLine(d),a.x+=d.getBoundingClientRect(b, !1).left,d.destroy();d=this._getLine(e);c.extend(d.getOffset(a.x,a.y-this._getLinePixel(e)));d.destroy();this._setSelection(c,!0)},_autoScrollTimer:function(){this._autoScroll();var c=this;this._autoScrollTimerID=this._getWindow().setTimeout(function(){c._autoScrollTimer()},this._AUTO_SCROLL_RATE)},_calculateLineHeightTimer:function(c){if(this._lineHeight&&!this._calculateLHTimer){var a=this._model.getLineCount(),b=0;if(c){for(var c=0,d=(new Date).getTime(),e=0;b100)break;this.redrawRulers(0,a);this._queueUpdate()}c=this._getWindow();if(b!==a){var i=this;this._calculateLHTimer=c.setTimeout(function(){i._calculateLHTimer=null;i._calculateLineHeightTimer(!0)},0)}else if(this._calculateLHTimer)c.clearTimeout(this._calculateLHTimer),this._calculateLHTimer=void 0}},_calculateLineHeight:function(c){var c=this._getLine(c),a=c.getBoundingClientRect();c.destroy();return Math.max(1, Math.ceil(a.bottom-a.top))},_calculateMetrics:function(){var c=this._clientDiv,j=c.ownerDocument,d=f.createElement(j,"div");d.style.lineHeight="normal";var e={type:"LineStyle",textView:this,0:0,lineText:this._model.getLine(0),lineStart:0};this.onLineStyle(e);l(e.style,d);d.style.position="fixed";d.style.left="-1000px";var i=f.createElement(j,"span");i.appendChild(j.createTextNode(" "));d.appendChild(i);var g=f.createElement(j,"span");g.style.fontStyle="italic";g.appendChild(j.createTextNode(" ")); d.appendChild(g);var n=f.createElement(j,"span");n.style.fontWeight="bold";n.appendChild(j.createTextNode(" "));d.appendChild(n);e=f.createElement(j,"span");e.style.fontWeight="bold";e.style.fontStyle="italic";e.appendChild(j.createTextNode(" "));d.appendChild(e);c.appendChild(d);var o=d.getBoundingClientRect(),i=i.getBoundingClientRect(),g=g.getBoundingClientRect(),n=n.getBoundingClientRect(),e=e.getBoundingClientRect(),i=i.bottom-i.top,g=g.bottom-g.top,n=n.bottom-n.top,k=e.bottom-e.top,t=0,e=o.bottom- o.top<=0,o=Math.max(1,o.bottom-o.top);g>i&&(t=1);n>g&&(t=2);k>n&&(t=3);var h;if(t!==0){h={style:{}};if((t&1)!==0)h.style.fontStyle="italic";if((t&2)!==0)h.style.fontWeight="bold"}i=b(d);c.removeChild(d);g=a(this._viewDiv);d=f.createElement(j,"div");d.style.position="fixed";d.style.left="-1000px";d.style.paddingLeft=g.left+"px";d.style.paddingTop=g.top+"px";d.style.paddingRight=g.right+"px";d.style.paddingBottom=g.bottom+"px";d.style.width="100px";d.style.height="100px";n=f.createElement(j,"div"); n.style.width="100%";n.style.height="100%";d.appendChild(n);c.appendChild(d);j=d.getBoundingClientRect();g=n.getBoundingClientRect();d.style.overflow="hidden";n.style.height="200px";n=d.clientWidth;d.style.overflow="scroll";k=d.clientWidth;c.removeChild(d);g={left:g.left-j.left,top:g.top-j.top,right:j.right-g.right,bottom:j.bottom-g.bottom};return{lineHeight:o,largestFontStyle:h,lineTrim:i,viewPadding:g,scrollWidth:n-k,invalid:e}},_checkOverlayScroll:function(){if(f.isMac){var c=this,a=this._getWindow(); this._overlayScrollTimer&&a.clearTimeout(this._overlayScrollTimer);var b=function(){var d=c._isOverOverlayScroll();d.vertical||d.horizontal?c._overlayScrollTimer=a.setTimeout(b,200):(c._overlayScrollTimer=void 0,c._update())};this._overlayScrollTimer=a.setTimeout(b,200)}},_clearSelection:function(c){var a=this._getSelection();if(a.isEmpty())return!1;c==="next"?a.start=a.end:a.end=a.start;this._setSelection(a,!0);return!0},_commitIME:function(){if(this._imeOffset!==-1){this._scrollDiv.focus();this._clientDiv.focus(); var c=this._model,a=c.getLineAtOffset(this._imeOffset),b=c.getLineStart(a),d=this._getDOMText(this._getLineNode(a)).text,c=c.getLine(a),b=this._imeOffset-b,c=b+d.length-c.length;b!==c&&this._doContent(d.substring(b,c));this._imeOffset=-1}},_createActions:function(){var c=r.KeyBinding,a=this._keyBindings=[];a.push({actionID:"lineUp",keyBinding:new c(38),predefined:!0});a.push({actionID:"lineDown",keyBinding:new c(40),predefined:!0});a.push({actionID:"charPrevious",keyBinding:new c(37),predefined:!0}); a.push({actionID:"charNext",keyBinding:new c(39),predefined:!0});f.isMac?(a.push({actionID:"scrollPageUp",keyBinding:new c(33),predefined:!0}),a.push({actionID:"scrollPageDown",keyBinding:new c(34),predefined:!0}),a.push({actionID:"pageUp",keyBinding:new c(33,null,null,!0),predefined:!0}),a.push({actionID:"pageDown",keyBinding:new c(34,null,null,!0),predefined:!0}),a.push({actionID:"lineStart",keyBinding:new c(37,!0),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c(39,!0),predefined:!0}), a.push({actionID:"wordPrevious",keyBinding:new c(37,null,null,!0),predefined:!0}),a.push({actionID:"wordNext",keyBinding:new c(39,null,null,!0),predefined:!0}),a.push({actionID:"scrollTextStart",keyBinding:new c(36),predefined:!0}),a.push({actionID:"scrollTextEnd",keyBinding:new c(35),predefined:!0}),a.push({actionID:"textStart",keyBinding:new c(38,!0),predefined:!0}),a.push({actionID:"textEnd",keyBinding:new c(40,!0),predefined:!0}),a.push({actionID:"scrollPageUp",keyBinding:new c(38,null,null,null, !0),predefined:!0}),a.push({actionID:"scrollPageDown",keyBinding:new c(40,null,null,null,!0),predefined:!0}),a.push({actionID:"lineStart",keyBinding:new c(37,null,null,null,!0),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c(39,null,null,null,!0),predefined:!0}),a.push({actionID:"lineStart",keyBinding:new c(38,null,null,!0),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c(40,null,null,!0),predefined:!0})):(a.push({actionID:"pageUp",keyBinding:new c(33),predefined:!0}),a.push({actionID:"pageDown", keyBinding:new c(34),predefined:!0}),a.push({actionID:"lineStart",keyBinding:new c(36),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c(35),predefined:!0}),a.push({actionID:"wordPrevious",keyBinding:new c(37,!0),predefined:!0}),a.push({actionID:"wordNext",keyBinding:new c(39,!0),predefined:!0}),a.push({actionID:"textStart",keyBinding:new c(36,!0),predefined:!0}),a.push({actionID:"textEnd",keyBinding:new c(35,!0),predefined:!0}));f.isFirefox&&f.isLinux&&(a.push({actionID:"lineUp",keyBinding:new c(38, !0),predefined:!0}),a.push({actionID:"lineDown",keyBinding:new c(40,!0),predefined:!0}));a.push({actionID:"selectLineUp",keyBinding:new c(38,null,!0),predefined:!0});a.push({actionID:"selectLineDown",keyBinding:new c(40,null,!0),predefined:!0});a.push({actionID:"selectCharPrevious",keyBinding:new c(37,null,!0),predefined:!0});a.push({actionID:"selectCharNext",keyBinding:new c(39,null,!0),predefined:!0});a.push({actionID:"selectPageUp",keyBinding:new c(33,null,!0),predefined:!0});a.push({actionID:"selectPageDown", keyBinding:new c(34,null,!0),predefined:!0});f.isMac?(a.push({actionID:"selectLineStart",keyBinding:new c(37,!0,!0),predefined:!0}),a.push({actionID:"selectLineEnd",keyBinding:new c(39,!0,!0),predefined:!0}),a.push({actionID:"selectWordPrevious",keyBinding:new c(37,null,!0,!0),predefined:!0}),a.push({actionID:"selectWordNext",keyBinding:new c(39,null,!0,!0),predefined:!0}),a.push({actionID:"selectTextStart",keyBinding:new c(36,null,!0),predefined:!0}),a.push({actionID:"selectTextEnd",keyBinding:new c(35, null,!0),predefined:!0}),a.push({actionID:"selectTextStart",keyBinding:new c(38,!0,!0),predefined:!0}),a.push({actionID:"selectTextEnd",keyBinding:new c(40,!0,!0),predefined:!0}),a.push({actionID:"selectLineStart",keyBinding:new c(37,null,!0,null,!0),predefined:!0}),a.push({actionID:"selectLineEnd",keyBinding:new c(39,null,!0,null,!0),predefined:!0}),a.push({actionID:"selectLineStart",keyBinding:new c(38,null,!0,!0),predefined:!0}),a.push({actionID:"selectLineEnd",keyBinding:new c(40,null,!0,!0), predefined:!0})):(f.isLinux&&(a.push({actionID:"selectWholeLineUp",keyBinding:new c(38,!0,!0),predefined:!0}),a.push({actionID:"selectWholeLineDown",keyBinding:new c(40,!0,!0),predefined:!0})),a.push({actionID:"selectLineStart",keyBinding:new c(36,null,!0),predefined:!0}),a.push({actionID:"selectLineEnd",keyBinding:new c(35,null,!0),predefined:!0}),a.push({actionID:"selectWordPrevious",keyBinding:new c(37,!0,!0),predefined:!0}),a.push({actionID:"selectWordNext",keyBinding:new c(39,!0,!0),predefined:!0}), a.push({actionID:"selectTextStart",keyBinding:new c(36,!0,!0),predefined:!0}),a.push({actionID:"selectTextEnd",keyBinding:new c(35,!0,!0),predefined:!0}));a.push({actionID:"undo",keyBinding:new r.KeyBinding("z",!0),predefined:!0});f.isMac?a.push({actionID:"redo",keyBinding:new r.KeyBinding("z",!0,!0),predefined:!0}):a.push({actionID:"redo",keyBinding:new r.KeyBinding("y",!0),predefined:!0});a.push({actionID:"deletePrevious",keyBinding:new c(8),predefined:!0});a.push({actionID:"deletePrevious",keyBinding:new c(8, null,!0),predefined:!0});a.push({actionID:"deleteNext",keyBinding:new c(46),predefined:!0});a.push({actionID:"deleteWordPrevious",keyBinding:new c(8,!0),predefined:!0});a.push({actionID:"deleteWordPrevious",keyBinding:new c(8,!0,!0),predefined:!0});a.push({actionID:"deleteWordNext",keyBinding:new c(46,!0),predefined:!0});a.push({actionID:"tab",keyBinding:new c(9),predefined:!0});a.push({actionID:"shiftTab",keyBinding:new c(9,null,!0),predefined:!0});a.push({actionID:"enter",keyBinding:new c(13),predefined:!0}); a.push({actionID:"enter",keyBinding:new c(13,null,!0),predefined:!0});a.push({actionID:"selectAll",keyBinding:new c("a",!0),predefined:!0});a.push({actionID:"toggleTabMode",keyBinding:new c("m",!0),predefined:!0});f.isMac&&(a.push({actionID:"deleteNext",keyBinding:new c(46,null,!0),predefined:!0}),a.push({actionID:"deleteWordPrevious",keyBinding:new c(8,null,null,!0),predefined:!0}),a.push({actionID:"deleteWordNext",keyBinding:new c(46,null,null,!0),predefined:!0}));if(!f.isFirefox){var b=f.isMac&& f.isChrome;a.push({actionID:null,keyBinding:new c("u",!b,!1,!1,b),predefined:!0});a.push({actionID:null,keyBinding:new c("i",!b,!1,!1,b),predefined:!0});a.push({actionID:null,keyBinding:new c("b",!b,!1,!1,b),predefined:!0})}f.isFirefox&&(a.push({actionID:"copy",keyBinding:new c(45,!0),predefined:!0}),a.push({actionID:"paste",keyBinding:new c(45,null,!0),predefined:!0}),a.push({actionID:"cut",keyBinding:new c(46,null,!0),predefined:!0}));f.isMac&&(a.push({actionID:"lineStart",keyBinding:new c("a", !1,!1,!1,!0),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c("e",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"lineUp",keyBinding:new c("p",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"lineDown",keyBinding:new c("n",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"charPrevious",keyBinding:new c("b",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"charNext",keyBinding:new c("f",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"deletePrevious",keyBinding:new c("h",!1,!1,!1,!0),predefined:!0}), a.push({actionID:"deleteNext",keyBinding:new c("d",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"deleteLineEnd",keyBinding:new c("k",!1,!1,!1,!0),predefined:!0}),f.isFirefox?(a.push({actionID:"scrollPageDown",keyBinding:new c("v",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"deleteLineStart",keyBinding:new c("u",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"deleteWordPrevious",keyBinding:new c("w",!1,!1,!1,!0),predefined:!0})):(a.push({actionID:"pageDown",keyBinding:new c("v",!1,!1,!1,!0),predefined:!0}), a.push({actionID:"centerLine",keyBinding:new c("l",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"enterNoCursor",keyBinding:new c("o",!1,!1,!1,!0),predefined:!0})));var d=this;this._actions={lineUp:{defaultHandler:function(){return d._doLineUp({select:!1})}},lineDown:{defaultHandler:function(){return d._doLineDown({select:!1})}},lineStart:{defaultHandler:function(){return d._doHome({select:!1,ctrl:!1})}},lineEnd:{defaultHandler:function(){return d._doEnd({select:!1,ctrl:!1})}},charPrevious:{defaultHandler:function(){return d._doCursorPrevious({select:!1, unit:"character"})}},charNext:{defaultHandler:function(){return d._doCursorNext({select:!1,unit:"character"})}},pageUp:{defaultHandler:function(){return d._doPageUp({select:!1})}},pageDown:{defaultHandler:function(){return d._doPageDown({select:!1})}},scrollPageUp:{defaultHandler:function(){return d._doScroll({type:"pageUp"})}},scrollPageDown:{defaultHandler:function(){return d._doScroll({type:"pageDown"})}},wordPrevious:{defaultHandler:function(){return d._doCursorPrevious({select:!1,unit:"word"})}}, wordNext:{defaultHandler:function(){return d._doCursorNext({select:!1,unit:"word"})}},textStart:{defaultHandler:function(){return d._doHome({select:!1,ctrl:!0})}},textEnd:{defaultHandler:function(){return d._doEnd({select:!1,ctrl:!0})}},scrollTextStart:{defaultHandler:function(){return d._doScroll({type:"textStart"})}},scrollTextEnd:{defaultHandler:function(){return d._doScroll({type:"textEnd"})}},centerLine:{defaultHandler:function(){return d._doScroll({type:"centerLine"})}},selectLineUp:{defaultHandler:function(){return d._doLineUp({select:!0})}}, selectLineDown:{defaultHandler:function(){return d._doLineDown({select:!0})}},selectWholeLineUp:{defaultHandler:function(){return d._doLineUp({select:!0,wholeLine:!0})}},selectWholeLineDown:{defaultHandler:function(){return d._doLineDown({select:!0,wholeLine:!0})}},selectLineStart:{defaultHandler:function(){return d._doHome({select:!0,ctrl:!1})}},selectLineEnd:{defaultHandler:function(){return d._doEnd({select:!0,ctrl:!1})}},selectCharPrevious:{defaultHandler:function(){return d._doCursorPrevious({select:!0, unit:"character"})}},selectCharNext:{defaultHandler:function(){return d._doCursorNext({select:!0,unit:"character"})}},selectPageUp:{defaultHandler:function(){return d._doPageUp({select:!0})}},selectPageDown:{defaultHandler:function(){return d._doPageDown({select:!0})}},selectWordPrevious:{defaultHandler:function(){return d._doCursorPrevious({select:!0,unit:"word"})}},selectWordNext:{defaultHandler:function(){return d._doCursorNext({select:!0,unit:"word"})}},selectTextStart:{defaultHandler:function(){return d._doHome({select:!0, ctrl:!0})}},selectTextEnd:{defaultHandler:function(){return d._doEnd({select:!0,ctrl:!0})}},deletePrevious:{defaultHandler:function(){return d._doBackspace({unit:"character"})}},deleteNext:{defaultHandler:function(){return d._doDelete({unit:"character"})}},deleteWordPrevious:{defaultHandler:function(){return d._doBackspace({unit:"word"})}},deleteWordNext:{defaultHandler:function(){return d._doDelete({unit:"word"})}},deleteLineStart:{defaultHandler:function(){return d._doBackspace({unit:"line"})}}, deleteLineEnd:{defaultHandler:function(){return d._doDelete({unit:"line"})}},tab:{defaultHandler:function(){return d._doTab()}},shiftTab:{defaultHandler:function(){return d._doShiftTab()}},enter:{defaultHandler:function(){return d._doEnter()}},enterNoCursor:{defaultHandler:function(){return d._doEnter({noCursor:!0})}},selectAll:{defaultHandler:function(){return d._doSelectAll()}},copy:{defaultHandler:function(){return d._doCopy()}},cut:{defaultHandler:function(){return d._doCut()}},paste:{defaultHandler:function(){return d._doPaste()}}, toggleWrapMode:{defaultHandler:function(){return d._doWrapMode()}},toggleTabMode:{defaultHandler:function(){return d._doTabMode()}}}},_createRuler:function(c,a){if(this._clientDiv){var b=c.getLocation()==="left"?this._leftDiv:this._rightDiv;b.style.display="block";var d=f.createElement(b.ownerDocument,"div");d._ruler=c;d.rulerChanged=!0;d.style.position="relative";var b=b.firstChild.rows[0],e=b.cells.length,b=b.insertCell(a===void 0||a<0||a>e?e:a);b.vAlign="top";b.style.verticalAlign="top";b.style.borderWidth= "0px";b.style.margin="0px";b.style.padding="0px";b.style.outline="none";b.appendChild(d)}},_createView:function(){if(!this._clientDiv){for(var c=this._parent;c.hasChildNodes();)c.removeChild(c.lastChild);var a=c.ownerDocument,b=f.createElement(a,"div");this._rootDiv=b;b.tabIndex=-1;b.style.position="relative";b.style.overflow="hidden";b.style.width="100%";b.style.height="100%";c.style.overflow="hidden";b.setAttribute("role","application");c.appendChild(b);c=f.createElement(a,"div");c.className="textviewLeftRuler"; this._leftDiv=c;c.tabIndex=-1;c.style.overflow="hidden";c.style.MozUserSelect="none";c.style.WebkitUserSelect="none";c.style.position="absolute";c.style.cursor="default";c.style.display="none";c.setAttribute("aria-hidden","true");var d=f.createElement(a,"table");c.appendChild(d);d.cellPadding="0px";d.cellSpacing="0px";d.border="0px";d.style.borderWidth="0px";d.style.margin="0px";d.style.padding="0px";d.style.outline="none";d.style.lineHeight="normal";d=d.insertRow(0);d.style.borderWidth="0px";d.style.margin= "0px";d.style.padding="0px";d.style.outline="none";d.style.lineHeight="normal";b.appendChild(c);c=f.createElement(a,"div");c.className="textview";this._viewDiv=c;c.tabIndex=-1;c.style.overflow="auto";c.style.position="absolute";c.style.top="0px";c.style.bottom="0px";c.style.borderWidth="0px";c.style.margin="0px";c.style.outline="none";b.appendChild(c);var e=f.createElement(a,"div");e.className="textviewRightRuler";this._rightDiv=e;e.tabIndex=-1;e.style.display="none";e.style.overflow="hidden";e.style.MozUserSelect= "none";e.style.WebkitUserSelect="none";e.style.position="absolute";e.style.cursor="default";e.style.right="0px";e.setAttribute("aria-hidden","true");d=f.createElement(a,"table");e.appendChild(d);d.cellPadding="0px";d.cellSpacing="0px";d.border="0px";d.style.borderWidth="0px";d.style.margin="0px";d.style.padding="0px";d.style.outline="none";d.style.lineHeight="normal";d=d.insertRow(0);d.style.borderWidth="0px";d.style.margin="0px";d.style.padding="0px";d.style.outline="none";d.style.lineHeight="normal"; b.appendChild(e);this._scrollDiv=d=f.createElement(a,"div");d.style.margin="0px";d.style.borderWidth="0px";d.style.padding="0px";c.appendChild(d);if(f.isFirefox)this._clipboardDiv=c=f.createElement(a,"div"),c.style.position="fixed",c.style.whiteSpace="pre",c.style.left="-1000px",b.appendChild(c);if(!f.isIE&&!f.isIOS)this._clipDiv=c=f.createElement(a,"div"),c.style.position="absolute",c.style.overflow="hidden",c.style.margin="0px",c.style.borderWidth="0px",c.style.padding="0px",b.appendChild(c),this._clipScrollDiv= d=f.createElement(a,"div"),d.style.position="absolute",d.style.height="1px",d.style.top="-1000px",c.appendChild(d);this._setFullSelection(this._fullSelection,!0);c=f.createElement(a,"div");c.className="textviewContent";this._clientDiv=c;c.style.position="absolute";c.style.borderWidth="0px";c.style.margin="0px";c.style.padding="0px";c.style.outline="none";c.style.zIndex="1";c.style.WebkitUserSelect="text";c.setAttribute("spellcheck","false");if(f.isIOS||f.isAndroid)c.style.WebkitTapHighlightColor= "transparent";(this._clipDiv||b).appendChild(c);if(f.isIOS||f.isAndroid)this._vScrollDiv=d=f.createElement(a,"div"),d.style.position="absolute",d.style.borderWidth="1px",d.style.borderColor="white",d.style.borderStyle="solid",d.style.borderRadius="4px",d.style.backgroundColor="black",d.style.opacity="0.5",d.style.margin="0px",d.style.padding="0px",d.style.outline="none",d.style.zIndex="3",d.style.width="8px",d.style.display="none",b.appendChild(d),this._hScrollDiv=d=f.createElement(a,"div"),d.style.position= "absolute",d.style.borderWidth="1px",d.style.borderColor="white",d.style.borderStyle="solid",d.style.borderRadius="4px",d.style.backgroundColor="black",d.style.opacity="0.5",d.style.margin="0px",d.style.padding="0px",d.style.outline="none",d.style.zIndex="3",d.style.height="8px",d.style.display="none",b.appendChild(d);if(f.isFirefox&&!c.setCapture)this._overlayDiv=d=f.createElement(a,"div"),d.style.position=c.style.position,d.style.borderWidth=c.style.borderWidth,d.style.margin=c.style.margin,d.style.padding= c.style.padding,d.style.cursor="text",d.style.zIndex="2",(this._clipDiv||b).appendChild(d);c.contentEditable="true";c.setAttribute("role","textbox");c.setAttribute("aria-multiline","true");this._setWrapMode(this._wrapMode,!0);this._setReadOnly(this._readonly);this._setThemeClass(this._themeClass,!0);this._setTabSize(this._tabSize,!0);if(!a.getElementById("_textviewStyle")&&(b="",f.isWebkit&&this._metrics.scrollWidth>0&&(b+="\n.textviewContainer ::-webkit-scrollbar-corner {background: #eeeeee;}"), f.isFirefox&&f.isMac&&this._highlightRGB&&this._highlightRGB!=="Highlight"&&(b+="\n.textviewContainer ::-moz-selection {background: "+this._highlightRGB+";}"),b))c=f.createElement(a,"style"),c.id="_textviewStyle",d=a.getElementsByTagName("head")[0]||a.documentElement,c.appendChild(a.createTextNode(b)),d.insertBefore(c,d.firstChild);this._hookEvents();a=this._rulers;for(b=0;bthis._getLineHeight()){var c=a.getBoundingClientRect(),b=this._clientDiv.getBoundingClientRect();c.bottom>b.bottom&&(a=this._getLinePrevious(a)|| a)}return a.lineIndex},_getBoundsAtOffset:function(c){var a=this._getLine(this._model.getLineAtOffset(c)),c=a.getBoundingClientRect(c),b=this._getLinePixel(a.lineIndex);c.top+=b;c.bottom+=b;a.destroy();return c},_getClientHeight:function(){var c=this._getViewPadding();return Math.max(0,this._viewDiv.clientHeight-c.top-c.bottom)},_getClientWidth:function(){var c=this._getViewPadding();return Math.max(0,this._viewDiv.clientWidth-c.left-c.right)},_getClipboardText:function(c,a){var b=this._model.getLineDelimiter(), d,i,g=this._getWindow();if(g.clipboardData)return d=[],i=g.clipboardData.getData("Text"),e(i,function(c){d.push(c)},function(){d.push(b)}),i=d.join(""),a&&a(i),i;if(f.isFirefox){this._ignoreFocus=!0;var n=this._clipboardDiv;n.innerHTML="
";n.firstChild.focus();var o=this,k=function(){var c=o._getTextFromElement(n);n.innerHTML="";d=[];e(c,function(c){d.push(c)},function(){d.push(b)});return d.join("")},t=!1;this._ignorePaste=!0;if(!f.isLinux||this._lastMouseButton!==2)try{t=
n.ownerDocument.execCommand("paste",!1,null)}catch(h){t=n.childNodes.length>1||n.firstChild&&n.firstChild.childNodes.length>0}this._ignorePaste=!1;if(!t)return c?(g.setTimeout(function(){o.focus();(i=k())&&a&&a(i);o._ignoreFocus=!1},0),null):(this.focus(),this._ignoreFocus=!1,"");this.focus();this._ignoreFocus=!1;(i=k())&&a&&a(i);return i}return c&&c.clipboardData?(d=[],i=c.clipboardData.getData("text/plain"),e(i,function(c){d.push(c)},function(){d.push(b)}),(i=d.join(""))&&a&&a(i),i):""},_getDOMText:function(c,
a){for(var b=c.firstChild,d="",e=0;b;){var i;if(b.ignoreChars){i=b.lastChild;for(var n=0,g=[],f=-1;i;){for(var o=i.data,k=o.length-1;k>=0;k--){var h=o.substring(k,k+1);na)for(;a=c;a--)b-=this._getLineHeight(a);return b}return this._getLineHeight()*c},_getLineIndex:function(c){var a,b=0,d=this._model.getLineCount();if(this._lineHeight){var b=this._getTopIndex(),
e=-this._topIndexY+this._getScroll().y;if(c!==e)if(c0;)c+=this._getLineHeight(--b);else for(a=this._getLineHeight(b);c-a>=e&&bthis._getLineHeight()){var c=
a.getBoundingClientRect(),b=this._getViewPadding(),d=this._viewDiv.getBoundingClientRect();c.top=15))(d=g.MutationObserver||g.MozMutationObserver)?(this._mutationObserver=new d(function(a){c._handleDataModified(a)}),this._mutationObserver.observe(b,{subtree:!0,characterData:!0})):a.push({target:this._clientDiv,type:"DOMCharacterDataModified",handler:function(a){return c._handleDataModified(a?a:g.event)}});this._overlayDiv&&(a.push({target:this._overlayDiv,
type:"mousedown",handler:function(a){return c._handleMouseDown(a?a:g.event)}}),a.push({target:this._overlayDiv,type:"mouseover",handler:function(a){return c._handleMouseOver(a?a:g.event)}}),a.push({target:this._overlayDiv,type:"mouseout",handler:function(a){return c._handleMouseOut(a?a:g.event)}}),a.push({target:this._overlayDiv,type:"contextmenu",handler:function(a){return c._handleContextMenu(a?a:g.event)}}));this._isW3CEvents||a.push({target:this._clientDiv,type:"dblclick",handler:function(a){return c._handleDblclick(a?
a:g.event)}})}d=this._leftDiv;e=this._rightDiv;f.isIE&&a.push({target:d,type:"selectstart",handler:function(){return!1}});a.push({target:d,type:f.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(a){return c._handleMouseWheel(a?a:g.event)}});a.push({target:d,type:"click",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:d,type:"dblclick",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:d,type:"mousemove",handler:function(a){c._handleRulerEvent(a?a:
g.event)}});a.push({target:d,type:"mouseover",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:d,type:"mouseout",handler:function(a){c._handleRulerEvent(a?a:g.event)}});f.isIE&&a.push({target:e,type:"selectstart",handler:function(){return!1}});a.push({target:e,type:f.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(a){return c._handleMouseWheel(a?a:g.event)}});a.push({target:e,type:"click",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:e,type:"dblclick",
handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:e,type:"mousemove",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:e,type:"mouseover",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:e,type:"mouseout",handler:function(a){c._handleRulerEvent(a?a:g.event)}});for(d=0;d=9)&&typeof b.ownerDocument.createRange().getBoundingClientRect==="function";this._isW3CEvents=b.addEventListener;this._autoScrollTimerID=this._autoScrollY=this._autoScrollX=null;this._AUTO_SCROLL_RATE=50;this._mouseUpClosure=this._moseMoveClosure=this._grabControl=null;this._clickCount=this._lastMouseTime=this._lastMouseY=this._lastMouseX=0;this._clickTime=250;this._clickDist=5;this._isMouseDown=!1;this._doubleClickSelection=null;this._vScroll=this._hScroll=0;this._imeOffset=-1;
this._createActions();this._createView()},_isOverOverlayScroll:function(){if(!f.isMac)return{};var a=this._viewDiv.getBoundingClientRect(),b=this._lastMouseMoveX,d=this._lastMouseMoveY;return{vertical:a.top<=d&&db&&(n.end>b&&n.startb+g)d.lineIndex=e+i-g,d._line.lineIndex=d.lineIndex;d=this._getLineNext(d)}if(!this._wrapMode&&b<=this._maxLineIndex&&this._maxLineIndex<=b+g)this._checkMaxLineIndex=this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0;this._update()},_onModelChanging:function(a){a.type=
"ModelChanging";this.onModelChanging(a);a.type="Changing"},_queueUpdate:function(){if(!this._updateTimer&&!this._ignoreQueueUpdate){var a=this;this._updateTimer=this._getWindow().setTimeout(function(){a._updateTimer=null;a._update()},0)}},_resetLineHeight:function(a,b){if(this._wrapMode){if(a!==void 0&&b!==void 0)for(var d=a;d0&&k.removeAllRanges();k.addRange(n);var h=this,n=function(){o&&o.parentNode===
h._clientDiv&&h._clientDiv.removeChild(o);h._updateDOMSelection()},k=!1;this._ignoreCopy=!0;try{k=i.execCommand("copy",!1,null)}catch(l){}this._ignoreCopy=!1;if(!k&&b)return g.setTimeout(n,0),!1;n();return!0},_setDOMSelection:function(a,b,d,e){for(var i,g,n,o,k=0,h=a.firstChild,l,m,z=this._model.getLine(a.lineIndex).length;h;){l=h.firstChild;m=l.length;h.ignoreChars&&(m-=h.ignoreChars);if(k+m>b||k+m>=z){i=l;g=b-k;h.ignoreChars&&m>0&&g===m&&(g+=h.ignoreChars);break}k+=m;h=h.nextSibling}for(var k=0,
h=d.firstChild,p=this._model.getLine(d.lineIndex).length;h;){l=h.firstChild;m=l.length;h.ignoreChars&&(m-=h.ignoreChars);if(m+k>e||k+m>=p){n=l;o=e-k;h.ignoreChars&&m>0&&o===m&&(o+=h.ignoreChars);break}k+=m;h=h.nextSibling}this._setDOMFullSelection(a,b,z,d,e,p);if(this._hasFocus)if(b=this._getWindow(),a=this._parent.ownerDocument,b.getSelection){if(b=b.getSelection(),!(b.anchorNode===i&&b.anchorOffset===g&&b.focusNode===n&&b.focusOffset===o||b.anchorNode===n&&b.anchorOffset===o&&b.focusNode===i&&b.focusOffset===
g))a=a.createRange(),a.setStart(i,g),a.setEnd(n,o),this._ignoreSelect=!1,b.rangeCount>0&&b.removeAllRanges(),b.addRange(a),this._ignoreSelect=!0}else if(a.selection)b=a.body,a=f.createElement(a,"div"),b.appendChild(a),b.removeChild(a),a=b.createTextRange(),a.moveToElementText(i.parentNode),a.moveStart("character",g),i=b.createTextRange(),i.moveToElementText(n.parentNode),i.moveStart("character",o),a.setEndPoint("EndToStart",i),this._ignoreSelect=!1,a.select(),this._ignoreSelect=!0},_setDOMFullSelection:function(a,
b,d,e,i){if(this._selDiv1&&(d=this._selDiv1,d.style.width="0px",d.style.height="0px",d=this._selDiv2,d.style.width="0px",d.style.height="0px",d=this._selDiv3,d.style.width="0px",d.style.height="0px",!(a===e&&b===i))){var f=this._model,n=this._getViewPadding(),o=this._clientDiv.getBoundingClientRect(),k=this._viewDiv.getBoundingClientRect(),d=k.left+n.left,h=o.right,n=k.top+n.top,l=o.bottom,k=o=0;this._clipDiv?(k=this._clipDiv.getBoundingClientRect(),o=k.left-this._clipDiv.scrollLeft):(k=this._rootDiv.getBoundingClientRect(),
o=k.left);k=k.top;this._ignoreDOMSelection=!0;var a=(new g(this,a.lineIndex,a)).getBoundingClientRect(f.getLineStart(a.lineIndex)+b,!1),m=a.left,i=(new g(this,e.lineIndex,e)).getBoundingClientRect(f.getLineStart(e.lineIndex)+i,!1),b=i.left;this._ignoreDOMSelection=!1;var f=this._selDiv1,m=Math.min(h,Math.max(d,m)),z=Math.min(l,Math.max(n,a.top)),p=h,e=Math.min(l,Math.max(n,a.bottom));f.style.left=m-o+"px";f.style.top=z-k+"px";f.style.width=Math.max(0,p-m)+"px";f.style.height=Math.max(0,e-z)+"px";
if(a.top===i.top)p=Math.min(b,h),f.style.width=Math.max(0,p-m)+"px";else if(a=Math.min(l,Math.max(n,i.top)),b=Math.min(h,Math.max(d,b)),n=Math.min(l,Math.max(n,i.bottom)),l=this._selDiv3,l.style.left=d-o+"px",l.style.top=a-k+"px",l.style.width=Math.max(0,b-d)+"px",l.style.height=Math.max(0,n-a)+"px",a-e>0)n=this._selDiv2,n.style.left=d-o+"px",n.style.top=e-k+"px",n.style.width=Math.max(0,h-d)+"px",n.style.height=Math.max(0,a-e)+"px"}},_setGrab:function(a){if(a!==this._grabControl)a?(a.setCapture&&
a.setCapture(),this._grabControl=a):(this._grabControl.releaseCapture&&this._grabControl.releaseCapture(),this._grabControl=null)},_setLinksVisible:function(a){if(this._linksVisible!==a){this._linksVisible=a;if(f.isIE&&a)this._hadFocus=this._hasFocus;var b=this._clientDiv;b.contentEditable=!a;this._hadFocus&&!a&&b.focus();if(this._overlayDiv)this._overlayDiv.style.zIndex=a?"-1":"1";for(a=this._getLineNext();a;){if(a.hasLink)for(b=a.firstChild;b;){var d=b.nextSibling,e=b.viewStyle;e&&e.tagName==="A"&&
a.replaceChild(a._line._createSpan(a,b.firstChild.data,e),b);b=d}a=this._getLineNext(a)}}},_setSelection:function(a,b,d,e){if(a){this._columnX=-1;d===void 0&&(d=!0);var i=this._selection;this._selection=a;b&&this._showCaret(!1,e);d&&this._updateDOMSelection();if(!i.equals(a))this.onSelection({type:"Selection",oldValue:{start:i.start,end:i.end},newValue:{start:a.start,end:a.end}})}},_setSelectionTo:function(a,b,d,e){var i=this._model,g=this._getSelection(),b=this.convert({x:a,y:b},"page","document"),
a=this._getLineIndex(b.y);if(this._clickCount===1){i=this._getLine(a);a=i.getOffset(b.x,b.y-this._getLinePixel(a));i.destroy();if(e&&!d&&g.start<=a&&a=this._doubleClickSelection.start?(d=this._doubleClickSelection.start,e=i.getNextOffset(a,"wordend",1)):(d=i.getNextOffset(a,"word",-1),e=this._doubleClickSelection.end):
(d=i.getNextOffset(a,"word",-1),e=i.getNextOffset(d,"wordend",1)),i.destroy()):this._doubleClickSelection?(e=i.getLineAtOffset(this._doubleClickSelection.start),a>=e?(d=i.getLineStart(e),e=i.getLineEnd(a)):(d=i.getLineStart(a),e=i.getLineEnd(e))):(d=i.getLineStart(a),e=i.getLineEnd(a)),g.setCaret(d),g.extend(e);this._setSelection(g,!0,!0);return!0},_setFullSelection:function(a,b){this._fullSelection=a;if(f.isWebkit)this._fullSelection=!0;var d=this._clipDiv||this._rootDiv;if(d)if(this._fullSelection){if(!this._selDiv1&&
this._fullSelection&&!f.isIOS){var e=d.ownerDocument;this._highlightRGB=f.isWebkit?"transparent":"Highlight";var i=f.createElement(e,"div");this._selDiv1=i;i.style.position="absolute";i.style.borderWidth="0px";i.style.margin="0px";i.style.padding="0px";i.style.outline="none";i.style.background=this._highlightRGB;i.style.width="0px";i.style.height="0px";i.style.zIndex="0";d.appendChild(i);var g=f.createElement(e,"div");this._selDiv2=g;g.style.position="absolute";g.style.borderWidth="0px";g.style.margin=
"0px";g.style.padding="0px";g.style.outline="none";g.style.background=this._highlightRGB;g.style.width="0px";g.style.height="0px";g.style.zIndex="0";d.appendChild(g);this._selDiv3=e=f.createElement(e,"div");e.style.position="absolute";e.style.borderWidth="0px";e.style.margin="0px";e.style.padding="0px";e.style.outline="none";e.style.background=this._highlightRGB;e.style.width="0px";e.style.height="0px";e.style.zIndex="0";d.appendChild(e);if(f.isFirefox&&f.isMac){d=this._getWindow().getComputedStyle(e,
null).getPropertyValue("background-color");switch(d){case "rgb(119, 141, 168)":d="rgb(199, 208, 218)";break;case "rgb(127, 127, 127)":d="rgb(198, 198, 198)";break;case "rgb(255, 193, 31)":d="rgb(250, 236, 115)";break;case "rgb(243, 70, 72)":d="rgb(255, 176, 139)";break;case "rgb(255, 138, 34)":d="rgb(255, 209, 129)";break;case "rgb(102, 197, 71)":d="rgb(194, 249, 144)";break;case "rgb(140, 78, 184)":d="rgb(232, 184, 255)";break;default:d="rgb(180, 213, 255)"}this._highlightRGB=d;i.style.background=
d;g.style.background=d;e.style.background=d}b||this._updateDOMSelection()}}else{if(this._selDiv1)d.removeChild(this._selDiv1),this._selDiv1=null;if(this._selDiv2)d.removeChild(this._selDiv2),this._selDiv2=null;if(this._selDiv3)d.removeChild(this._selDiv3),this._selDiv3=null}},_setReadOnly:function(a){this._readonly=a;this._clientDiv.setAttribute("aria-readonly",a?"true":"false")},_setTabSize:function(a,b){this._tabSize=a;this._customTabSize=void 0;var d=this._clientDiv;if(f.isOpera){if(d)d.style.OTabSize=
this._tabSize+""}else if(f.isWebkit>=537.1){if(d)d.style.tabSize=this._tabSize+""}else if(f.isFirefox>=4){if(d)d.style.MozTabSize=this._tabSize+""}else if(this._tabSize!==8)this._customTabSize=this._tabSize;b||(this.redrawLines(),this._resetLineWidth())},_setThemeClass:function(a,b){this._themeClass=a;var d="textviewContainer";this._themeClass&&(d+=" "+this._themeClass);this._rootDiv.className=d;this._updateStyle(b)},_setWrapMode:function(a,b){this._wrapMode=a;var d=this._clientDiv,e=this._viewDiv;
a?(d.style.whiteSpace="pre-wrap",d.style.wordWrap="break-word",e.style.overflowX="hidden",e.style.overflowY="scroll"):(d.style.whiteSpace="pre",d.style.wordWrap="normal",e.style.overflowX="auto",e.style.overflowY="auto");b||(this.redraw(),this._resetLineWidth());this._resetLineHeight()},_showCaret:function(a,b){if(this._clientDiv){var d=this._model,e=this._getSelection(),i=this._getScroll(),g=e.getCaret(),n=e.start,f=e.end,o=d.getLineAtOffset(f),k=Math.max(Math.max(n,d.getLineStart(o)),f-1),d=this._getClientWidth(),
o=this._getClientHeight(),h=d/4,l=this._getBoundsAtOffset(g===n?n:k),m=l.left,p=l.right,w=l.top,r=l.bottom;a&&!e.isEmpty()&&(l=this._getBoundsAtOffset(g===f?n:k),l.top===w?g===n?p=m+Math.min(l.right-m,d):m=p-Math.min(p-l.left,d):g===n?r=w+Math.min(l.bottom-w,o):w=r-Math.min(r-l.top,o));e=0;mi.x+d&&(e=Math.max(p-i.x-d,h));g=0;wi.y+o&&(g=r-i.y-o);b&&(b>0?g>0&&(g=Math.max(g,b)):g<0&&(g=Math.min(g,b)));return e!==0||g!==0?(this._scrollView(e,g),o!==this._getClientHeight()||
d!==this._getClientWidth()?this._showCaret():this._ensureCaretVisible=!0,!0):!1}},_startIME:function(){if(this._imeOffset===-1){var a=this._getSelection();a.isEmpty()||this._modifyContent({text:"",start:a.start,end:a.end},!0);this._imeOffset=a.start}},_unhookEvents:function(){this._model.removeEventListener("preChanging",this._modelListener.onChanging);this._model.removeEventListener("postChanged",this._modelListener.onChanged);this._modelListener=null;for(var a=0;ag.lineIndex?(n=g,d=0):(n=this._getLineNode(d),d=a.start-b.getLineStart(d));eg.lineIndex?(i=g,a=0):(i=this._getLineNode(e),a=a.end-b.getLineStart(e));this._setDOMSelection(n,d,i,a)}}},_update:function(a){if(!(this._redrawCount>0)){if(this._updateTimer)this._getWindow().clearTimeout(this._updateTimer),this._updateTimer=null,a=!1;var b=this._clientDiv;if(b){if(this._metrics.invalid)this._ignoreQueueUpdate=!0,this._updateStyle(),this._ignoreQueueUpdate=!1;var d=this._model,
e=this._getScroll(),i=this._getViewPadding(),o=d.getLineCount(),n=this._getLineHeight(),k=this._getClientWidth();if(this._wrapMode)b.style.width=k+"px";var h,l,m,v,p=0,r=0;if(this._lineHeight){for(;re.y)break;p+=m;r++}h=r;l=Math.max(0,h-1);m=d=e.y-p;h>0&&(d+=this._getLineHeight(h-1))}else v=Math.max(0,e.y)/n,h=Math.floor(v),l=Math.max(0,h-1),d=Math.round((v-l)*n),m=Math.round((v-h)*n);this._topIndexY=m;v=this._parent;var w=v.clientWidth,s=v.clientHeight;v=this._getClientHeight();
if(a){l=0;this._leftDiv&&(h=this._leftDiv.getBoundingClientRect(),l=h.right-h.left);h=k;for(this._wrapMode||(h=Math.max(this._maxLineWidth,h));rm)(new g(this,m)).create(y,null);else{y.firstChild&&(b.insertBefore(y,n),y=C.createDocumentFragment());if(n&&n.lineChanged)n=(new g(this,m)).create(y,n),n.lineChanged=!1;n=this._getLineNext(n)}y.firstChild&&b.insertBefore(y,n);if(f.isWebkit&&!this._wrapMode)b.style.width="0x7fffffffpx";n=this._getLineNext();m=v+d;for(C=!1;n;){l=n.lineWidth;if(l===void 0)x=n._line.getBoundingClientRect(),l=n.lineWidth=Math.ceil(x.right-x.left),this._lineHeight&&
(this._lineHeight[n.lineIndex]=Math.ceil(x.bottom-x.top));if(this._lineHeight&&!C&&(m-=this._lineHeight[n.lineIndex],m<0))e=n.lineIndex,C=!0;if(!this._wrapMode){if(l>=this._maxLineWidth)this._maxLineWidth=l,this._maxLineIndex=n.lineIndex;if(this._checkMaxLineIndex===n.lineIndex)this._checkMaxLineIndex=-1}if(n.lineIndex===h)this._topChild=n;if(n.lineIndex===e)this._bottomChild=n;n=this._getLineNext(n)}if(this._checkMaxLineIndex!==-1&&(m=this._checkMaxLineIndex,this._checkMaxLineIndex=-1,0<=m&&m=this._maxLineWidth)this._maxLineWidth=l,this._maxLineIndex=m;n.destroy()}for(;r=9)&&this._maxLineWidth>k)p+=i.right+i.left;e.style.width=p+"px";if(this._clipScrollDiv)this._clipScrollDiv.style.width=p+"px";e=this._getScroll();p=v+i.top+i.bottom;this._updateRulerSize(this._leftDiv,p);this._updateRulerSize(this._rightDiv,p)}if(this._vScrollDiv)p=v-8,r=Math.max(15,Math.ceil(Math.min(1,p/(o+i.top+i.bottom))*p)),this._vScrollDiv.style.left=l+k-8+"px",this._vScrollDiv.style.top=Math.floor(Math.max(0,
e.y*p/o))+"px",this._vScrollDiv.style.height=r+"px";if(!this._wrapMode&&this._hScrollDiv)p=k-8,r=Math.max(15,Math.ceil(Math.min(1,p/(this._maxLineWidth+i.left+i.right))*p)),this._hScrollDiv.style.left=l+Math.floor(Math.max(0,Math.floor(e.x*p/this._maxLineWidth)))+"px",this._hScrollDiv.style.top=v-9+"px",this._hScrollDiv.style.width=r+"px";x=e.x;m=this._clipDiv;p=this._overlayDiv;if(m){m.scrollLeft=x;r=l+i.left;n=i.top;a=k;l=v;x=0;C=-d;if(e.x===0)r-=i.left,a+=i.left,x=i.left;e.x+k===h&&(a+=i.right);
e.y===0&&(n-=i.top,l+=i.top,C+=i.top);e.y+v===o&&(l+=i.bottom);m.style.left=r+"px";m.style.top=n+"px";i=this._isOverOverlayScroll();m.style.right=w-a-r+(this._overlayScrollTimer&&i.vertical?15:0)+"px";m.style.bottom=s-l-n+(this._overlayScrollTimer&&i.horizontal?15:0)+"px";b.style.left=x+"px";b.style.top=C+"px";b.style.width=h+"px";b.style.height=v+d+"px";if(p)p.style.left=b.style.left,p.style.top=b.style.top,p.style.width=b.style.width,p.style.height=b.style.height}else{r=x;n=d;w=x+k;s=d+v;r===0&&
(r-=i.left);n===0&&(n-=i.top);w===h&&(w+=i.right);e.y+v===o&&(s+=i.bottom);b.style.clip="rect("+n+"px,"+w+"px,"+s+"px,"+r+"px)";b.style.left=-x+l+i.left+"px";b.style.width=(f.isWebkit?h:k+x)+"px";if(!a)b.style.top=-d+i.top+"px",b.style.height=v+d+"px";if(p&&(p.style.clip=b.style.clip,p.style.left=b.style.left,p.style.width=b.style.width,!a))p.style.top=b.style.top,p.style.height=b.style.height}this._updateDOMSelection();b=this._ensureCaretVisible;this._ensureCaretVisible=!1;v!==this._getClientHeight()&&
(this._update(),b&&this._showCaret())}}},_updateRulerSize:function(a,b){if(a){for(var d=this._topIndexY,e=this._getLineHeight(),i=a.firstChild.rows[0].cells,g=0;gp){s=f.createElement(e,"div");if(r=k[p]){l(r.style,s);if(r.html)s.innerHTML=r.html;s.annotation=r}s.lineIndex=p;s.style.height=this._getLineHeight(p)+"px";w.appendChild(s)}else if(w.firstChild&&(o.insertBefore(w,m),w=e.createDocumentFragment()),m)m=m.nextSibling;w.firstChild&&o.insertBefore(w,m)}else{r=this._getClientHeight();p=this._model.getLineCount();m=r+g.top+g.bottom-2*this._metrics.scrollWidth;h=i*p
1;)o.removeChild(o.lastChild),r--;k=k.getAnnotations(0,p);w=e.createDocumentFragment();for(var K in k)if(p=K>>>0,!(p<0)){s=f.createElement(e,"div");r=k[K];l(r.style,s);s.style.position="absolute";s.style.top=this._metrics.scrollWidth+i+Math.floor(p*h)+"px";if(r.html)s.innerHTML=r.html;s.annotation=r;s.lineIndex=p;w.appendChild(s)}o.appendChild(w)}else if(o._oldTrackHeight!==m)for(s=o.firstChild?o.firstChild.nextSibling:null;s;)s.style.top=this._metrics.scrollWidth+i+Math.floor(s.lineIndex*h)+"px",
s=s.nextSibling;o._oldTrackHeight=m}o.rulerChanged=!1}},_updateStyle:function(a){if(!a&&f.isIE)this._rootDiv.style.lineHeight="normal";var b=this._metrics=this._calculateMetrics();this._rootDiv.style.lineHeight=f.isIE?b.lineHeight-(b.lineTrim.top+b.lineTrim.bottom)+"px":"normal";a||(this.redraw(),this._resetLineWidth())}};p.EventTarget.addMixin(o.prototype);return{TextView:o}});
define("orion/editor/projectionTextModel",["orion/editor/textModel","orion/editor/eventTarget"],function(s,r){function p(f){this._model=f;this._projections=[]}p.prototype={addProjection:function(f){if(f){var h=this._model,l=this._projections;f._lineIndex=h.getLineAtOffset(f.start);f._lineCount=h.getLineAtOffset(f.end)-f._lineIndex;var k=f.text;k||(k="");f._model=typeof k==="string"?new s.TextModel(k,h.getLineDelimiter()):k;var h=this.mapOffset(f.start,!0),k=f.end-f.start,m=f._lineCount,e=f._model.getCharCount(),
a=f._model.getLineCount()-1;this.onChanging({type:"Changing",text:f._model.getText(),start:h,removedCharCount:k,addedCharCount:e,removedLineCount:m,addedLineCount:a});var b=this._binarySearch(l,f.start);l.splice(b,0,f);this.onChanged({type:"Changed",start:h,removedCharCount:k,addedCharCount:e,removedLineCount:m,addedLineCount:a})}},getProjections:function(){return this._projections.slice(0)},getBaseModel:function(){return this._model},mapOffset:function(f,h){var l=this._projections,k=0,m,e;if(h){for(m=
0;mf)break;if(e.end>f)return-1;k+=e._model.getCharCount()-(e.end-e.start)}return f+k}for(m=0;mf-k)break;var a=e._model.getCharCount();if(e.start+a>f-k)return-1;k+=a-(e.end-e.start)}return f-k},removeProjection:function(f){var h,l=0;for(h=0;h1;)m=Math.floor((l+k)/2),h<=f[m].start?l=m:k=m;return l},getCharCount:function(){for(var f=
this._model.getCharCount(),h=this._projections,l=0;l=f-m)break;d=i._model.getLineCount()-1;if(i._lineIndex+d>=f-m)if(a=f-(i._lineIndex+m),af-m)break;e.push(l.getText(a,i.start));d=i._model.getLineCount()-1;if(i._lineIndex+d>f-m)return e.push(i._model.getLine(0,h)),e.join("");e.push(i._model.getText());a=i.end;m+=d-i._lineCount}k=l.getLineEnd(f-m,h);af-k)break;var b=a._model.getCharCount();if(a.start+b>f-k){l=f-(a.start+k);m+=a._model.getLineAtOffset(l);
k+=l;break}m+=a._model.getLineCount()-1-a._lineCount;k+=b-(a.end-a.start)}return h.getLineAtOffset(f-k)+m},getLineCount:function(){for(var f=this._projections,h=this._model.getLineCount(),l=0;lf-m)break;var d=b._model.getLineCount()-
1;if(b._lineIndex+d>f-m)return b._model.getLineEnd(f-(b._lineIndex+m),h)+b.start+e;e+=b._model.getCharCount()-(b.end-b.start);m+=d-b._lineCount}return l.getLineEnd(f-m,h)+e},getLineStart:function(f){if(f<0)return-1;for(var h=this._model,l=this._projections,k=0,m=0,e=0;e=f-k)break;var b=a._model.getLineCount()-1;if(a._lineIndex+b>=f-k)return a._model.getLineStart(f-(a._lineIndex+k))+a.start+m;m+=a._model.getCharCount()-(a.end-a.start);k+=b-a._lineCount}return h.getLineStart(f-
k)+m},getText:function(f,h){f===void 0&&(f=0);var l=this._model,k=this._projections,m=0,e=[],a,b,d;for(a=0;af-m)break;d=b._model.getCharCount();if(b.start+d>f-m)if(h!==void 0&&b.start+d>h-m)return b._model.getText(f-(b.start+m),h-(b.start+m));else e.push(b._model.getText(f-(b.start+m))),f=b.end+m+d-(b.end-b.start);m+=d-(b.end-b.start)}var i=f-m;if(h!==void 0){for(;ah-m)break;e.push(l.getText(i,b.start));d=b._model.getCharCount();if(b.start+
d>h-m)return e.push(b._model.getText(0,h-(b.start+m))),e.join("");e.push(b._model.getText());i=b.end;m+=d-(b.end-b.start)}e.push(l.getText(i,h-m))}else{for(;ah)break;i+=l._model.getCharCount()-(l.end-l.start)}h+=i;for(var c=d;d
o)break;i+=l._model.getCharCount()-(l.end-l.start);g+=l._model.getLineCount()-1-l._lineCount}l=o+i;i=d;this.onChanging(h,l-h,k,m+g,e);b.splice(b,i-c);for(f=f.length-(l-h);dh-b)break;o=g._model.getCharCount();if(g.start+o>h-b)if(l!==void 0&&g.start+o>l-b){g._model.setText(f,h-(g.start+b),l-(g.start+b));return}else q=g._model.getLineCount()-1-g._model.getLineAtOffset(h-(g.start+b)),c={projection:g,start:h-(g.start+b)},h=g.end+b+o-(g.end-g.start);d+=g._model.getLineCount()-1-g._lineCount;b+=o-(g.end-g.start)}h-=b;var u=i,q=e.getLineAtOffset(h)+d-q;if(l!==void 0)for(;il-b)break;o=g._model.getCharCount();if(g.start+o>l-b){d+=g._model.getLineAtOffset(l-(g.start+b));o=l-(g.start+b);l=g.end+b;j={projection:g,end:o};break}d+=g._model.getLineCount()-1-g._lineCount;b+=o-(g.end-g.start)}else{for(;i-1&&(j=e[c]);c--){i=b[j];if(i===!0||i===1)i=l(a+j+"/"+d);var g=o,q=void 0;for(q in i)!(q in f)&&!(q in g)&&(g[q]=i[q])}k(o)})})}})})();
define("orion/editor/i18n",{load:function(s,r,p){r.specified&&r.specified("orion/bootstrap")?r(["orion/i18n!"+s],function(f){p(f)}):p({})}});
define("orion/editor/nls/root/messages",{multipleAnnotations:"Multiple annotations:",line:"Line: ${0}",breakpoint:"Breakpoint",bookmark:"Bookmark",task:"Task",error:"Error",warning:"Warning",matchingSearch:"Matching Search",currentSearch:"Current Search",currentLine:"Current Line",matchingBracket:"Matching Bracket",currentBracket:"Current Bracket",Comment:"Comment","Flat outline":"Flat outline",incrementalFind:"Incremental find: ${0}",incrementalFindNotFound:"Incremental find: ${0} (not found)",find:"Find...",
undo:"Undo",redo:"Redo",cancelMode:"Cancel Current Mode",findNext:"Find Next Occurrence",findPrevious:"Find Previous Occurrence",incrementalFindKey:"Incremental Find",indentLines:"Indent Lines",unindentLines:"Unindent Lines",moveLinesUp:"Move Lines Up",moveLinesDown:"Move Lines Down",copyLinesUp:"Copy Lines Up",copyLinesDown:"Copy Lines Down",deleteLines:"Delete Lines",gotoLine:"Goto Line...",gotoLinePrompty:"Goto Line:",nextAnnotation:"Next Annotation",prevAnnotation:"Previous Annotation",expand:"Expand",
collapse:"Collapse",expandAll:"Expand All",collapseAll:"Collapse All",lastEdit:"Last Edit Location",toggleLineComment:"Toggle Line Comment",addBlockComment:"Add Block Comment",removeBlockComment:"Remove Block Comment",linkedModeEntered:"Linked Mode entered",linkedModeExited:"Linked Mode exited",syntaxError:"Syntax Error",contentAssist:"Content Assist",lineColumn:"Line ${0} : Col ${1}"});
define("orion/editor/nls/messages",["orion/editor/i18n!orion/editor/nls/messages","orion/editor/nls/root/messages"],function(s,r){var p={root:r},f;for(f in s)s.hasOwnProperty(f)&&typeof p[f]==="undefined"&&(p[f]=s[f]);return p});
define("orion/editor/annotations",["i18n!orion/editor/nls/messages","orion/editor/eventTarget"],function(s,r){function p(a,b,d){this.start=a;this.end=b;this._projectionModel=d;this.html=this._expandedHTML;this.style=this._expandedStyle;this.expanded=!0}function f(){}function h(a,b){var d=a.lastIndexOf("."),d=a.substring(d+1),e={title:s[d],style:{styleClass:"annotation "+d},html:"
",overviewStyle:{styleClass:"annotationOverview "+d}};b?e.lineStyle={styleClass:"annotationLine "+ d}:e.rangeStyle={styleClass:"annotationRange "+d};f.registerType(a,e)}function l(){}function k(a){this._annotations=[];var b=this;this._listener={onChanged:function(a){b._onChanged(a)}};this.setTextModel(a)}function m(a,b){this._view=a;this._annotationModel=b;var d=this;this._listener={onDestroy:function(a){d._onDestroy(a)},onLineStyle:function(a){d._onLineStyle(a)},onChanged:function(a){d._onAnnotationModelChanged(a)}};a.addEventListener("Destroy",this._listener.onDestroy);a.addEventListener("postLineStyle", this._listener.onLineStyle);b.addEventListener("Changed",this._listener.onChanged)}p.prototype={_expandedHTML:"
",_expandedStyle:{styleClass:"annotation expanded"},_collapsedHTML:"",_collapsedStyle:{styleClass:"annotation collapsed"},collapse:function(){if(this.expanded){this.expanded=!1;this.html=this._collapsedHTML;this.style=this._collapsedStyle;var a=this._projectionModel,b=a.getBaseModel();this._projection= {start:b.getLineStart(b.getLineAtOffset(this.start)+1),end:b.getLineEnd(b.getLineAtOffset(this.end),!0)};a.addProjection(this._projection)}},expand:function(){if(!this.expanded)this.expanded=!0,this.html=this._expandedHTML,this.style=this._expandedStyle,this._projectionModel.removeProjection(this._projection)}};f.ANNOTATION_ERROR="orion.annotation.error";f.ANNOTATION_WARNING="orion.annotation.warning";f.ANNOTATION_TASK="orion.annotation.task";f.ANNOTATION_BREAKPOINT="orion.annotation.breakpoint"; f.ANNOTATION_BOOKMARK="orion.annotation.bookmark";f.ANNOTATION_FOLDING="orion.annotation.folding";f.ANNOTATION_CURRENT_BRACKET="orion.annotation.currentBracket";f.ANNOTATION_MATCHING_BRACKET="orion.annotation.matchingBracket";f.ANNOTATION_CURRENT_LINE="orion.annotation.currentLine";f.ANNOTATION_CURRENT_SEARCH="orion.annotation.currentSearch";f.ANNOTATION_MATCHING_SEARCH="orion.annotation.matchingSearch";f.ANNOTATION_READ_OCCURRENCE="orion.annotation.readOccurrence";f.ANNOTATION_WRITE_OCCURRENCE="orion.annotation.writeOccurrence"; var e={};f.registerType=function(a,b){var d=b;if(typeof d!=="function")d=function(a,b,d){this.start=a;this.end=b;if(d)this.title=d},d.prototype=b;d.prototype.type=a;e[a]=d;return a};f.createAnnotation=function(a,b,d,e){return new (this.getType(a))(b,d,e)};f.getType=function(a){return e[a]};h(f.ANNOTATION_ERROR);h(f.ANNOTATION_WARNING);h(f.ANNOTATION_TASK);h(f.ANNOTATION_BREAKPOINT);h(f.ANNOTATION_BOOKMARK);h(f.ANNOTATION_CURRENT_BRACKET);h(f.ANNOTATION_MATCHING_BRACKET);h(f.ANNOTATION_CURRENT_SEARCH); h(f.ANNOTATION_MATCHING_SEARCH);h(f.ANNOTATION_READ_OCCURRENCE);h(f.ANNOTATION_WRITE_OCCURRENCE);h(f.ANNOTATION_CURRENT_LINE,!0);f.registerType(f.ANNOTATION_FOLDING,p);l.addMixin=function(a){var b=l.prototype,d;for(d in b)b.hasOwnProperty(d)&&(a[d]=b[d])};l.prototype={addAnnotationType:function(a){if(!this._annotationTypes)this._annotationTypes=[];this._annotationTypes.push(a)},getAnnotationTypePriority:function(a){if(this._annotationTypes)for(var b=0;bc.start?a=b)break}return null};e=f();return{next:function(){var a=e; a&&(e=f());return a},hasNext:function(){return e!==null}}},modifyAnnotation:function(a){if(a&&!(this._getAnnotationIndex(a)<0))this.onChanged({type:"Changed",added:[],removed:[],changed:[a]})},onChanged:function(a){return this.dispatchEvent(a)},removeAnnotations:function(a){var b=this._annotations,d,e;if(a){d=[];for(e=b.length-1;e>=0;e--){var g=b[e];g.type===a&&b.splice(e,1);d.splice(0,0,g)}}else d=b;this.onChanged({type:"Changed",removed:d,added:[],changed:[]})},removeAnnotation:function(a){if(a&& (a=this._getAnnotationIndex(a),!(a<0)))this.onChanged({type:"Changed",removed:this._annotations.splice(a,1),added:[],changed:[]})},replaceAnnotations:function(a,b){var d=this._annotations,e,g,f,c=[];if(a)for(e=a.length-1;e>=0;e--)f=a[e],g=this._getAnnotationIndex(f),g<0||(d.splice(g,1),c.splice(0,0,f));b||(b=[]);for(e=0;e1;)g=Math.floor((d+e)/2),b<=a[g].start?d=g:e=g;return d},_getAnnotationIndex:function(a){for(var b=this._annotations,d=this._binarySearch(b,a.start);d=g?(c.start+=a,c.end+=a,f.changed.push(c)):c.end<=b||(c.start0||f.removed.length>0||f.changed.length>0)this.onChanged(f)}}};r.EventTarget.addMixin(k.prototype);m.prototype={destroy:function(){var a=this._view;if(a)a.removeEventListener("Destroy",this._listener.onDestroy),a.removeEventListener("LineStyle", this._listener.onLineStyle),this.view=null;(a=this._annotationModel)&&a.removeEventListener("Changed",this._listener.onChanged)},_mergeStyle:function(a,b){if(b){a||(a={});a.styleClass&&b.styleClass&&a.styleClass!==b.styleClass?a.styleClass+=" "+b.styleClass:a.styleClass=b.styleClass;var d;if(b.style){if(!a.style)a.style={};for(d in b.style)a.style[d]||(a.style[d]=b.style[d])}if(b.attributes){if(!a.attributes)a.attributes={};for(d in b.attributes)a.attributes[d]||(a.attributes[d]=b.attributes[d])}}return a}, _mergeStyleRanges:function(a,b){a||(a=[]);var d,e;for(e=0;e=g.end)){d=this._mergeStyle({},g.style);d=this._mergeStyle(d,b.style);var f=[];f.push(e,1);b.startg.start&&f.push({start:g.start,end:b.start,style:g.style});f.push({start:Math.max(g.start,b.start),end:Math.min(g.end,b.end),style:d});b.endg.end?{start:g.end, end:b.end,style:b.style}:null;Array.prototype.splice.apply(a,f)}}b&&(d=this._mergeStyle({},b.style),a.splice(e,0,{start:b.start,end:b.end,style:d}));return a},_onAnnotationModelChanged:function(a){function b(a){for(var b=0;b0?(a-=0.1,e.style.opacity=a):o.hide()},50)},5E3)}}}},_getAnnotationContents:function(k){function h(b){var d=b.title;if(d==="")return null;var e="
";b.html&&(e+=b.html+" ");if(!d)d=b.end,b=a.getLineStart(a.getLineAtOffset(b.start)),d=a.getLineEnd(a.getLineAtOffset(d),!0),d=a.getText(b,d);d=d.replace(//g, ">");e+=""+d+"
";return e}if(k.length===0)return null;var e=this._view.getModel(),a=e.getBaseModel?e.getBaseModel():e;if(k.length===1)if(e=k[0],e.title!==void 0)return h(e);else{var k=new f.ProjectionTextModel(a),b=a.getLineStart(a.getLineAtOffset(e.start)),d=a.getCharCount();e.end!==d&&k.addProjection({start:e.end,end:d});b>0&&k.addProjection({start:0,end:b});return k}else{b="
"+s.multipleAnnotations+"
";for(d=0;d=0;l--)this.changes[l].undo(f,!1);if(h){var l=this.startSelection.start,k=this.startSelection.end;f.setSelection(this.startCaret?l:k,this.startCaret?k:l)}},redo:function(f,h){for(var l=0;lthis.size&&(this.stack.shift(),this.index--,this.cleanIndex--))},markClean:function(){this.endCompoundChange();this._commitUndo();this.cleanIndex=this.index},isClean:function(){return this.cleanIndex=== this.getSize().undo},canUndo:function(){return this.getSize().undo>0},canRedo:function(){return this.getSize().redo>0},endCompoundChange:function(){this.compoundChange&&this.compoundChange.end(this.view);this.compoundChange=void 0},getSize:function(){var f=this.index,h=this.stack.length;this._undoStart!==void 0&&f++;return{undo:f,redo:h-f}},undo:function(){this._commitUndo();if(this.index<=0)return!1;var f=this.stack[--this.index];this._ignoreUndo=!0;f.undo(this.view,!0);this._ignoreUndo=!1;return!0}, redo:function(){this._commitUndo();if(this.index>=this.stack.length)return!1;var f=this.stack[this.index++];this._ignoreUndo=!0;f.redo(this.view,!0);this._ignoreUndo=!1;return!0},reset:function(){this.index=this.cleanIndex=0;this.stack=[];this._undoStart=void 0;this._undoText="";this._undoType=0;this._ignoreUndo=!1;this._compoundChange=void 0},startCompoundChange:function(){this._commitUndo();var f=new r;this.add(f);this.compoundChange=f;this.compoundChange.start(this.view)},_commitUndo:function(){if(this._undoStart!== void 0)this._undoType===-1?this.add(new s(this._undoStart,"",this._undoText)):this.add(new s(this._undoStart,this._undoText,"")),this._undoStart=void 0,this._undoText="",this._undoType=0},_onDestroy:function(){this.model.removeEventListener("Changing",this._listener.onChanging);this.view.removeEventListener("Destroy",this._listener.onDestroy)},_onChanging:function(f){var h=f.text,l=f.start,k=f.removedCharCount,f=f.addedCharCount;if(!this._ignoreUndo){this._undoStart!==void 0&&!(f===1&&k===0&&this._undoType=== 1&&l===this._undoStart+this._undoText.length||f===0&&k===1&&this._undoType===-1&&(l+1===this._undoStart||l===this._undoStart))&&this._commitUndo();if(!this.compoundChange)if(f===1&&k===0){if(this._undoStart===void 0)this._undoStart=l;this._undoText+=h;this._undoType=1;return}else if(f===0&&k===1){h=this._undoText.length>0&&this._undoStart===l;this._undoStart=l;this._undoType=-1;h?this._undoText+=this.model.getText(l,l+k):this._undoText=this.model.getText(l,l+k)+this._undoText;return}this.add(new s(l, h,this.model.getText(l,l+k)))}}};return{UndoStack:p}}); define("orion/editor/textDND",[],function(){function s(r,p){this._view=r;this._undoStack=p;this._dragSelection=null;this._dropOffset=-1;this._dropText=null;var f=this;this._listener={onDragStart:function(h){f._onDragStart(h)},onDragEnd:function(h){f._onDragEnd(h)},onDragEnter:function(h){f._onDragEnter(h)},onDragOver:function(h){f._onDragOver(h)},onDrop:function(h){f._onDrop(h)},onDestroy:function(h){f._onDestroy(h)}};r.addEventListener("DragStart",this._listener.onDragStart);r.addEventListener("DragEnd", this._listener.onDragEnd);r.addEventListener("DragEnter",this._listener.onDragEnter);r.addEventListener("DragOver",this._listener.onDragOver);r.addEventListener("Drop",this._listener.onDrop);r.addEventListener("Destroy",this._listener.onDestroy)}s.prototype={destroy:function(){var r=this._view;if(r)r.removeEventListener("DragStart",this._listener.onDragStart),r.removeEventListener("DragEnd",this._listener.onDragEnd),r.removeEventListener("DragEnter",this._listener.onDragEnter),r.removeEventListener("DragOver", this._listener.onDragOver),r.removeEventListener("Drop",this._listener.onDrop),r.removeEventListener("Destroy",this._listener.onDestroy),this._view=null},_onDestroy:function(){this.destroy()},_onDragStart:function(r){var p=this._view,f=p.getSelection(),p=p.getModel();if(p.getBaseModel)f.start=p.mapOffset(f.start),f.end=p.mapOffset(f.end),p=p.getBaseModel();if(p=p.getText(f.start,f.end))this._dragSelection=f,r.event.dataTransfer.effectAllowed="copyMove",r.event.dataTransfer.setData("Text",p)},_onDragEnd:function(r){var p= this._view;if(this._dragSelection){this._undoStack&&this._undoStack.startCompoundChange();(r=r.event.dataTransfer.dropEffect==="move")&&p.setText("",this._dragSelection.start,this._dragSelection.end);if(this._dropText){var f=this._dropText,h=this._dropOffset;if(r)if(h>=this._dragSelection.end)h-=this._dragSelection.end-this._dragSelection.start;else if(h>=this._dragSelection.start)h=this._dragSelection.start;p.setText(f,h,h);p.setSelection(h,h+f.length);this._dropText=null;this._dropOffset=-1}this._undoStack&& this._undoStack.endCompoundChange()}this._dragSelection=null},_onDragEnter:function(r){this._onDragOver(r)},_onDragOver:function(r){var p=r.event.dataTransfer.types;if(p){var f=!this._view.getOptions("readonly");f&&(f=p.contains?p.contains("text/plain"):p.indexOf("text/plain")!==-1);if(!f)r.event.dataTransfer.dropEffect="none"}},_onDrop:function(r){var p=this._view,f=r.event.dataTransfer.getData("Text");if(f)r=p.getOffsetAtLocation(r.x,r.y),this._dragSelection?(this._dropOffset=r,this._dropText=f): (p.setText(f,r,r),p.setSelection(r,r+f.length))}};return{TextDND:s}}); define("orion/editor/editor","i18n!orion/editor/nls/messages,orion/editor/keyBinding,orion/editor/eventTarget,orion/editor/tooltip,orion/editor/annotations,orion/editor/util".split(","),function(s,r,p,f,h,l){function k(a){this._textViewFactory=a.textViewFactory;this._undoStackFactory=a.undoStackFactory;this._textDNDFactory=a.textDNDFactory;this._annotationFactory=a.annotationFactory;this._foldingRulerFactory=a.foldingRulerFactory;this._lineNumberRulerFactory=a.lineNumberRulerFactory;this._contentAssistFactory= a.contentAssistFactory;this._keyBindingFactory=a.keyBindingFactory;this._statusReporter=a.statusReporter;this._domNode=a.domNode;this._foldingRuler=this._overviewRuler=this._lineNumberRuler=this._annotationRuler=this._annotationModel=this._annotationStyler=null;this._dirty=!1;this._title=this._contentAssist=null;this._keyModes=[]}function m(a){var b=this,d=Array.prototype.slice.call(arguments,1);return d.length?function(){return arguments.length?b.apply(a,d.concat(Array.prototype.slice.call(arguments))): b.apply(a,d)}:function(){return arguments.length?b.apply(a,arguments):b.call(a)}}var e;k.prototype={destroy:function(){this.uninstallTextView();this._textViewFactory=this._undoStackFactory=this._textDNDFactory=this._annotationFactory=this._foldingRulerFactory=this._lineNumberRulerFactory=this._contentAssistFactory=this._keyBindingFactory=this._statusReporter=this._domNode=null},getAnnotationModel:function(){return this._annotationModel},getAnnotationRuler:function(){return this._annotationRuler}, getAnnotationStyler:function(){return this._annotationStyler},getFoldingRuler:function(){return this._foldingRuler},getLineNumberRuler:function(){return this._lineNumberRuler},getModel:function(){var a=this._textView.getModel();a.getBaseModel&&(a=a.getBaseModel());return a},getOverviewRuler:function(){return this._overviewRuler},getTextView:function(){return this._textView},getTitle:function(){return this._title},getKeyModes:function(){return this._keyModes},isDirty:function(){return this._dirty}, setAnnotationRulerVisible:function(a){if(this._annotationRulerVisible!==a&&(this._annotationRulerVisible=a,this._annotationRuler)){var b=this._textView;a?b.addRuler(this._annotationRuler,0):b.removeRuler(this._annotationRuler)}},setFoldingRulerVisible:function(a){if(this._foldingRulerVisible!==a&&(this._foldingRulerVisible=a,this._foldingRuler)){var b=this._textView;b.getModel().getBaseModel&&(a?b.addRuler(this._foldingRuler,100):b.removeRuler(this._foldingRuler))}},setDirty:function(a){if(this._dirty!== a)this._dirty=a,this.onDirtyChanged({type:"DirtyChanged"})},setLineNumberRulerVisible:function(a){if(this._lineNumberRulerVisible!==a&&(this._lineNumberRulerVisible=a,this._lineNumberRuler)){var b=this._textView;a?b.addRuler(this._lineNumberRuler,1):b.removeRuler(this._lineNumberRuler)}},setOverviewRulerVisible:function(a){if(this._overviewRulerVisible!==a&&(this._overviewRulerVisible=a,this._overviewRuler)){var b=this._textView;a?b.addRuler(this._overviewRuler):b.removeRuler(this._overviewRuler)}}, mapOffset:function(a,b){var d=this._textView.getModel();d.getBaseModel&&(a=d.mapOffset(a,b));return a},getCaretOffset:function(){return this.mapOffset(this._textView.getCaretOffset())},getSelection:function(){var a=this._textView,b=a.getSelection(),a=a.getModel();if(a.getBaseModel)b.start=a.mapOffset(b.start),b.end=a.mapOffset(b.end);return b},getText:function(a,b){var d=this._textView.getModel();d.getBaseModel&&(d=d.getBaseModel());return d.getText(a,b)},_expandOffset:function(a){var b=this._textView.getModel(), d=this._annotationModel;if(d&&b.getBaseModel)for(a=d.getAnnotations(a,a+1);a.hasNext();)b=a.next(),b.type===h.AnnotationType.ANNOTATION_FOLDING&&b.expand&&(b.expand(),d.modifyAnnotation(b))},setCaretOffset:function(a){var b=this._textView,d=b.getModel();d.getBaseModel&&(this._expandOffset(a),a=d.mapOffset(a,!0));b.setCaretOffset(a)},setText:function(a,b,d){var e=this._textView,f=e.getModel();f.getBaseModel&&(b!==void 0&&(this._expandOffset(b),b=f.mapOffset(b,!0)),d!==void 0&&(this._expandOffset(d), d=f.mapOffset(d,!0)));e.setText(a,b,d)},setFoldingEnabled:function(a){this.setFoldingRulerVisible(a)},setSelection:function(a,b,d){var e=this._textView,f=e.getModel();f.getBaseModel&&(this._expandOffset(a),this._expandOffset(b),a=f.mapOffset(a,!0),b=f.mapOffset(b,!0));e.setSelection(a,b,d)},moveSelection:function(a,b,d,i){var f=this._textView;this.setSelection(a,b||a,!1);var b=f.getTopPixel(),o=f.getBottomPixel(),a=this.getModel().getLineAtOffset(a),a=f.getLinePixel(a);ao?(o=Math.max(0,a-Math.floor((a< b?3:1)*(o-b)/4)),(new e({node:f,duration:300,curve:[b,o],onAnimate:function(a){f.setTopPixel(Math.floor(a))},onEnd:function(){f.showSelection();(i===void 0||i)&&f.focus();d&&d()}})).play()):(f.showSelection(),(i===void 0||i)&&f.focus(),d&&d())},checkDirty:function(){this.setDirty(!this._undoStack.isClean())},reportStatus:function(a,b,d){this._statusReporter&&this._statusReporter(a,b,d)},_getTooltipInfo:function(a,b){var d=this._textView,e=this.getAnnotationModel();if(!e)return null;var f=this._annotationStyler; if(!f)return null;var o=d.getOffsetAtLocation(a,b);if(o===-1)return null;o=this.mapOffset(o);f=f.getAnnotationsByType(e,o,o+1);e=[];for(o=0;o
"}),o.addAnnotationType(h.AnnotationType.ANNOTATION_ERROR), o.addAnnotationType(h.AnnotationType.ANNOTATION_WARNING),o.addAnnotationType(h.AnnotationType.ANNOTATION_TASK),o.addAnnotationType(h.AnnotationType.ANNOTATION_BOOKMARK);this.setAnnotationRulerVisible(!0);if(o=this._overviewRuler=g.overviewRuler)o.onClick=function(a){a!==void 0&&(a=d.getModel().getLineStart(a),b.moveSelection(b.mapOffset(a)))},o.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_SEARCH),o.addAnnotationType(h.AnnotationType.ANNOTATION_MATCHING_SEARCH),o.addAnnotationType(h.AnnotationType.ANNOTATION_ERROR), o.addAnnotationType(h.AnnotationType.ANNOTATION_WARNING),o.addAnnotationType(h.AnnotationType.ANNOTATION_TASK),o.addAnnotationType(h.AnnotationType.ANNOTATION_BOOKMARK),o.addAnnotationType(h.AnnotationType.ANNOTATION_MATCHING_BRACKET),o.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_BRACKET),o.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_LINE),o.addAnnotationType(h.AnnotationType.ANNOTATION_READ_OCCURRENCE),o.addAnnotationType(h.AnnotationType.ANNOTATION_WRITE_OCCURRENCE);this.setOverviewRulerVisible(!0)}if(this._lineNumberRulerFactory)this._lineNumberRuler= this._lineNumberRulerFactory.createLineNumberRuler(this._annotationModel),this._lineNumberRuler.onDblClick=a,this.setLineNumberRulerVisible(!0);if(this._foldingRulerFactory)this._foldingRuler=this._foldingRulerFactory.createFoldingRuler(this._annotationModel),this._foldingRuler.addAnnotationType(h.AnnotationType.ANNOTATION_FOLDING),this.setFoldingRulerVisible(!1);this.dispatchEvent({type:"TextViewInstalled",textView:d})},uninstallTextView:function(){var a=this._textView;if(a)a.destroy(),this._textView= this._undoStack=this._textDND=this._contentAssist=this._listener=this._annotationModel=this._annotationStyler=this._annotationRuler=this._overviewRuler=this._lineNumberRuler=this._foldingRuler=this._currentLineAnnotation=this._title=null,this._dirty=!1,this._keyModes=[],this.dispatchEvent({type:"TextViewUninstalled",textView:a})},_updateCursorStatus:function(){var a=this.getModel(),b=this.getCaretOffset(),d=a.getLineAtOffset(b),a=a.getLineStart(d);b-=a;for(a=0;a=e.offset&&a.end<=e.offset+e.length)b=e.length,e.length=a.start-e.offset+a.text.length+(e.offset+e.length-a.end),c=e.length-b,b=!0}b?this.linkedModeEscapePosition+=c:this.cancel()}.bind(this)}}a.prototype={createUndoStack:function(a){var a=a.getTextView(),b=new r.UndoStack(a,200);a.setAction("undo",function(){b.undo();return!0}, {name:s.undo});a.setAction("redo",function(){b.redo();return!0},{name:s.redo});return b}};b.prototype={createLineNumberRuler:function(a){return new f.LineNumberRuler(a,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"})}};d.prototype={createFoldingRuler:function(a){return new f.FoldingRuler(a,"left",{styleClass:"ruler folding"})}};i.prototype={createAnnotationModel:function(a){return new h.AnnotationModel(a)},createAnnotationStyler:function(a,b){return new h.AnnotationStyler(a, b)},createAnnotationRulers:function(a){var b=new f.AnnotationRuler(a,"left",{styleClass:"ruler annotations"}),a=new f.OverviewRuler(a,"right",{styleClass:"ruler overview"});return{annotationRuler:b,overviewRuler:a}}};g.prototype={createTextDND:function(a,b){return new k.TextDND(a.getTextView(),b)}};o.prototype={init:function(){var a=this;this._incrementalFindListener={onVerify:function(b){var c=a.editor,d=c.getModel(),f=c.mapOffset(b.start),i=c.mapOffset(b.end),f=d.getText(f,i),d=a._incrementalFindPrefix; if((d=d.match(RegExp("^"+m.escape(f),"i")))&&d.length>0)d=a._incrementalFindPrefix+=b.text,a.editor.reportStatus(e.formatMessage(s.incrementalFind,d)),f=c.getSelection().start,(f=c.getModel().find({string:d,start:f,caseInsensitive:d.toLowerCase()===d}).next())?(a._incrementalFindSuccess=!0,a._incrementalFindIgnoreSelection=!0,c.moveSelection(f.start,f.end),a._incrementalFindIgnoreSelection=!1):(c.reportStatus(e.formatMessage(s.incrementalFindNotFound,d),"error"),a._incrementalFindSuccess=!1),b.text= null},onSelection:function(){a._incrementalFindIgnoreSelection||a.toggleIncrementalFind()}};this._lastEditListener={onModelChanged:function(b){if(a.editor.isDirty())a._lastEditLocation=b.start+b.addedCharCount}};this.textView.addEventListener("ModelChanged",this._lastEditListener.onModelChanged);this.textView.setKeyBinding(new p.KeyBinding("k",!0),"findNext");this.textView.setAction("findNext",function(){if(this._searcher){var a=this.textView.getSelection();a.startc.start?c.end-1:c.end);if(d!==e){var f=[];f.push("");for(var i=d;i<=e;i++)f.push(b.getLine(i,!0));var i=b.getLineStart(d),b=b.getLineEnd(e,!0),g=this.textView.getOptions("tabSize","expandTab"),g=g.expandTab?Array(g.tabSize+ 1).join(" "):"\t";a.setText(f.join(g),i,b);a.setSelection(i===c.start?c.start:c.start+g.length,c.end+(e-d+1)*g.length);return!0}a=a.getKeyModes();for(c=0;cc.start?c.end-1:c.end),f=this.textView.getOptions("tabSize"), i=Array(f+1).join(" "),g=[],j=0,o=0,k=d;k<=e;k++){var h=b.getLine(k,!0);if(b.getLineStart(k)!==b.getLineEnd(k))if(h.indexOf("\t")===0)h=h.substring(1),j++;else if(h.indexOf(i)===0)h=h.substring(f),j+=f;else return!0;k===d&&(o=j);g.push(h)}d=b.getLineStart(d);f=b.getLineEnd(e,!0);b=b.getLineStart(e);a.setText(g.join(""),d,f);g=d===c.start?c.start:c.start-o;c=Math.max(g,c.end-j+(c.end===b+1&&c.start!==c.end?1:0));a.setSelection(g,c);return!0}}.bind(this),{name:s.unindentLines});this.textView.setKeyBinding(new p.KeyBinding(38, !1,!1,!0),"moveLinesUp");this.textView.setAction("moveLinesUp",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start);if(d===0)return!0;var e=b.getLineAtOffset(c.end>c.start?c.end-1:c.end),f=b.getLineCount(),c=b.getLineStart(d-1),i=b.getLineStart(d),g=b.getLineEnd(e,!0),j=b.getText(i,g),k=0;e===f-1&&(e=b.getLineEnd(d-1),d=b.getLineEnd(d-1,!0),j+=b.getText(e,d),i=e,k=d-e);this.startUndo();a.setText("",i,g);a.setText(j, c,c);a.setSelection(c,c+j.length-k);this.endUndo();return!0}.bind(this),{name:s.moveLinesUp});this.textView.setKeyBinding(new p.KeyBinding(40,!1,!1,!0),"moveLinesDown");this.textView.setAction("moveLinesDown",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),e=b.getLineAtOffset(c.end>c.start?c.end-1:c.end),f=b.getLineCount();if(e===f-1)return!0;var d=b.getLineStart(d),c=b.getLineEnd(e,!0),i=b.getLineEnd(e+1, !0)-(c-d),g=0;e!==f-2?b=b.getText(d,c):(e=b.getLineEnd(e),b=b.getText(e,c)+b.getText(d,e),g+=c-e);this.startUndo();a.setText("",d,c);a.setText(b,i,i);a.setSelection(i+g,i+g+b.length);this.endUndo();return!0}.bind(this),{name:s.moveLinesDown});this.textView.setKeyBinding(new p.KeyBinding(38,!0,!1,!0),"copyLinesUp");this.textView.setAction("copyLinesUp",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),c=b.getLineAtOffset(c.end> c.start?c.end-1:c.end),d=b.getLineStart(d),e=b.getLineEnd(c,!0),f=b.getLineCount(),i="",e=b.getText(d,e);c===f-1&&(e+=i=b.getLineDelimiter());a.setText(e,d,d);a.setSelection(d,d+e.length-i.length);return!0}.bind(this),{name:s.copyLinesUp});this.textView.setKeyBinding(new p.KeyBinding(40,!0,!1,!0),"copyLinesDown");this.textView.setAction("copyLinesDown",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),c=b.getLineAtOffset(c.end> c.start?c.end-1:c.end),e=b.getLineStart(d),d=b.getLineEnd(c,!0),f=b.getLineCount(),i="",e=b.getText(e,d);c===f-1&&(e=(i=b.getLineDelimiter())+e);a.setText(e,d,d);a.setSelection(d+i.length,d+e.length);return!0}.bind(this),{name:s.copyLinesDown});this.textView.setKeyBinding(new p.KeyBinding("d",!0,!1,!1),"deleteLines");this.textView.setAction("deleteLines",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getSelection(),c=a.getModel(),d=c.getLineAtOffset(b.start),b=c.getLineAtOffset(b.end> b.start?b.end-1:b.end),d=c.getLineStart(d),c=c.getLineEnd(b,!0);a.setText("",d,c);return!0}.bind(this),{name:s.deleteLines});this.textView.setKeyBinding(new p.KeyBinding("l",!0),"gotoLine");this.textView.setAction("gotoLine",function(){var a=this.editor,b=a.getModel().getLineAtOffset(a.getCaretOffset());if(b=prompt(s.gotoLinePrompty,b+1))b=parseInt(b,10),a.onGotoLine(b-1,0);return!0}.bind(this),{name:s.gotoLine});this.textView.setKeyBinding(new p.KeyBinding(190,!0),"nextAnnotation");this.textView.setAction("nextAnnotation", function(){var a=this.editor,b=a.getAnnotationModel();if(!b)return!0;for(var c=a.getModel(),d=a.getCaretOffset(),b=b.getAnnotations(d,c.getCharCount());b.hasNext();){var e=b.next();if(!(e.start<=d)&&!(e.type!==h.AnnotationType.ANNOTATION_ERROR&&e.type!==h.AnnotationType.ANNOTATION_WARNING&&e.type!==h.AnnotationType.ANNOTATION_TASK&&e.type!==h.AnnotationType.ANNOTATION_BOOKMARK)){var f=l.Tooltip.getTooltip(this.textView);if(!f){a.moveSelection(e.start);break}var i=c.getLineAtOffset(e.start),g=this.textView; a.moveSelection(e.start,e.start,function(){setTimeout(function(){f.setTarget({getTooltipInfo:function(){var a=g.convert({x:g.getLocationAtOffset(e.start).x,y:g.getLocationAtOffset(c.getLineStart(i)).y},"document","page");return{contents:[e],x:a.x,y:a.y+Math.floor(g.getLineHeight(i)*1.33)}}},0)},0)});break}}return!0}.bind(this),{name:s.nextAnnotation});this.textView.setKeyBinding(new p.KeyBinding(188,!0),"previousAnnotation");this.textView.setAction("previousAnnotation",function(){var a=this.editor, b=a.getAnnotationModel();if(!b)return!0;for(var c=a.getModel(),d=a.getCaretOffset(),b=b.getAnnotations(0,d),e=null;b.hasNext();){var f=b.next();f.start>=d||f.type!==h.AnnotationType.ANNOTATION_ERROR&&f.type!==h.AnnotationType.ANNOTATION_WARNING&&f.type!==h.AnnotationType.ANNOTATION_TASK&&f.type!==h.AnnotationType.ANNOTATION_BOOKMARK||(e=f)}if(e){var i=c.getLineAtOffset(e.start),g=l.Tooltip.getTooltip(this.textView);if(!g)return a.moveSelection(e.start),!0;var j=this.textView;a.moveSelection(e.start, e.start,function(){setTimeout(function(){g.setTarget({getTooltipInfo:function(){var a=j.convert({x:j.getLocationAtOffset(e.start).x,y:j.getLocationAtOffset(c.getLineStart(i)).y},"document","page");return{contents:[e],x:a.x,y:a.y+Math.floor(j.getLineHeight(i)*1.33)}}},0)},0)})}return!0}.bind(this),{name:s.prevAnnotation});this.textView.setKeyBinding(new p.KeyBinding("e",!0,!1,!0,!1),"expand");this.textView.setAction("expand",function(){var a=this.editor,b=a.getAnnotationModel();if(!b)return!0;var c= a.getModel(),a=a.getCaretOffset(),d=c.getLineAtOffset(a),a=c.getLineStart(d),d=c.getLineEnd(d,!0);c.getBaseModel&&(a=c.mapOffset(a),d=c.mapOffset(d),c.getBaseModel());for(var e,c=b.getAnnotations(a,d);!e&&c.hasNext();)a=c.next(),a.type===h.AnnotationType.ANNOTATION_FOLDING&&(a.expanded||(e=a));e&&!e.expanded&&(e.expand(),b.modifyAnnotation(e));return!0}.bind(this),{name:s.expand});this.textView.setKeyBinding(new p.KeyBinding("c",!0,!1,!0,!1),"collapse");this.textView.setAction("collapse",function(){var a= this.editor,b=a.getAnnotationModel();if(!b)return!0;var c=a.getModel(),d=a.getCaretOffset(),e=c.getLineAtOffset(d),d=c.getLineStart(e),e=c.getLineEnd(e,!0);c.getBaseModel&&(d=c.mapOffset(d),e=c.mapOffset(e),c.getBaseModel());for(var f,c=b.getAnnotations(d,e);!f&&c.hasNext();)d=c.next(),d.type===h.AnnotationType.ANNOTATION_FOLDING&&(f=d);f&&f.expanded&&(a.setCaretOffset(f.start),f.collapse(),b.modifyAnnotation(f));return!0}.bind(this),{name:s.collapse});this.textView.setKeyBinding(new p.KeyBinding("e", !0,!0,!0,!1),"expandAll");this.textView.setAction("expandAll",function(){var a=this.editor,b=a.getAnnotationModel();if(!b)return!0;var a=a.getModel(),c=b.getAnnotations(0,a.getCharCount());for(this.textView.setRedraw(!1);c.hasNext();)a=c.next(),a.type===h.AnnotationType.ANNOTATION_FOLDING&&!a.expanded&&(a.expand(),b.modifyAnnotation(a));this.textView.setRedraw(!0);return!0}.bind(this),{name:s.expandAll});this.textView.setKeyBinding(new p.KeyBinding("c",!0,!0,!0,!1),"collapseAll");this.textView.setAction("collapseAll", function(){var a=this.editor,b=a.getAnnotationModel();if(!b)return!0;var a=a.getModel(),c=b.getAnnotations(0,a.getCharCount());for(this.textView.setRedraw(!1);c.hasNext();)a=c.next(),a.type===h.AnnotationType.ANNOTATION_FOLDING&&a.expanded&&(a.collapse(),b.modifyAnnotation(a));this.textView.setRedraw(!0);return!0}.bind(this),{name:s.collapseAll});this.textView.setKeyBinding(new p.KeyBinding("q",!e.isMac,!1,!1,e.isMac),"lastEdit");this.textView.setAction("lastEdit",function(){typeof this._lastEditLocation=== "number"&&this.editor.showSelection(this._lastEditLocation);return!0}.bind(this),{name:s.lastEdit})},toggleIncrementalFind:function(){(this._incrementalFindActive=!this._incrementalFindActive)?(this.editor.reportStatus(e.formatMessage(s.incrementalFind,this._incrementalFindPrefix)),this.textView.addEventListener("Verify",this._incrementalFindListener.onVerify),this.textView.addEventListener("Selection",this._incrementalFindListener.onSelection)):(this._incrementalFindPrefix="",this.editor.reportStatus(""), this.textView.removeEventListener("Verify",this._incrementalFindListener.onVerify),this.textView.removeEventListener("Selection",this._incrementalFindListener.onSelection),this.textView.setCaretOffset(this.textView.getCaretOffset()))},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},cancel:function(){this.toggleIncrementalFind()},isActive:function(){return this._incrementalFindActive},isStatusActive:function(){return this._incrementalFindActive}, lineUp:function(){if(this._incrementalFindActive){var a=this._incrementalFindPrefix;if(a.length===0)return!1;var b=this.editor,c=b.getModel(),c=this._incrementalFindSuccess?b.getCaretOffset()-a.length-1:c.getCharCount()-1;(c=b.getModel().find({string:a,start:c,reverse:!0,caseInsensitive:a.toLowerCase()===a}).next())?(this._incrementalFindIgnoreSelection=this._incrementalFindSuccess=!0,b.moveSelection(c.start,c.end),this._incrementalFindIgnoreSelection=!1,b.reportStatus(e.formatMessage(s.incrementalFind, a))):(b.reportStatus(e.formatMessage(s.incrementalFindNotFound,a),"error"),this._incrementalFindSuccess=!1);return!0}return!1},lineDown:function(){if(this._incrementalFindActive){var a=this._incrementalFindPrefix;if(a.length===0)return!1;var b=this.editor,c=0;this._incrementalFindSuccess&&(c=b.getSelection().start+1);(c=b.getModel().find({string:a,start:c,caseInsensitive:a.toLowerCase()===a}).next())?(this._incrementalFindIgnoreSelection=this._incrementalFindSuccess=!0,b.moveSelection(c.start,c.end), this._incrementalFindIgnoreSelection=!1,b.reportStatus(e.formatMessage(s.incrementalFind,a))):(b.reportStatus(e.formatMessage(s.incrementalFindNotFound,a),"error"),this._incrementalFindSuccess=!1);return!0}return!1},enter:function(){return!1}};c.prototype={startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},init:function(){function a(b,c,d){var e=b.getLineAtOffset(c),f=b.getLineAtOffset(d),i,g,j,k,o,h;for(i= e;i>=0;i--)if(g=b.getLine(i),j=i===e?c-b.getLineStart(e):g.length,k=g.lastIndexOf("/*",j),g=g.lastIndexOf("*/",j),g>k)break;else if(k!==-1){o=b.getLineStart(i)+k;break}for(i=f;ic.start?c.end-1:c.end),f=!0,i=[],g,j,k=d;k<=e;k++)if(g= b.getLine(k,!0),i.push(g),!f||(j=g.indexOf("//"))===-1)f=!1;else if(j!==0){var o;for(o=0;o0){for(var g=e.substring(0,d),d=f;d0?this.linkedModeCurrentPositionIndex-1:this.linkedModePositions.length-1;this.selectTextForLinkedModePosition(this.linkedModePositions[this.linkedModeCurrentPositionIndex]); return!0}.bind(this));this.editor.reportStatus(s.linkedModeEntered,null,!0)}},isActive:function(){return this.linkedModeActive},isStatusActive:function(){return this.linkedModeActive},enter:function(){this.cancel();return!0},cancel:function(a){if(this.linkedModeActive)this.linkedModeActive=!1,this.textView.removeEventListener("Verify",this.linkedModeListener.onVerify),this.textView.setKeyBinding(new p.KeyBinding(9),"tab"),this.textView.setKeyBinding(new p.KeyBinding(9,!1,!0),"shiftTab"),a||this.textView.setCaretOffset(this.linkedModeEscapePosition, !1),this.editor.reportStatus(s.linkedModeExited,null,!0)},lineUp:function(){this.cancel(!0);return!1},lineDown:function(){this.cancel(!0);return!1},selectTextForLinkedModePosition:function(a){this.textView.setSelection(a.offset,a.offset+a.length)}};return{UndoFactory:a,LineNumberRulerFactory:b,FoldingRulerFactory:d,AnnotationFactory:i,TextDNDFactory:g,TextActions:o,SourceCodeActions:c,LinkedMode:j}}); (function(s,r){typeof define==="function"&&define.amd?define("orion/Deferred",r):typeof exports==="object"?module.exports=r():(s.orion=s.orion||{},s.orion.Deferred=r())})(this,function(){function s(){for(var a;a=k.shift()||m.shift();)a();e=!1}function r(a,b){(b?m:k).push(a);e||(e=!0,b?setTimeout(s,0):s())}function p(a){return function(){a.apply(null,arguments)}}function f(){}function h(){var a=Error("Cancel");a.name="Cancel";return a}function l(){function a(){for(var a;a=e.shift();){var c=a.deferred, g=d==="resolved"?"resolve":"reject";if(typeof a[g]==="function")try{var k=a[g](b);k&&typeof k.then==="function"?(c.cancel=k.cancel||f,k.then(p(c.resolve),p(c.reject),c.progress)):c.resolve(k)}catch(h){c.reject(h)}else c[g](b)}}var b,d,e=[],g=this;this.reject=function(f){d||(d="rejected",b=f,e.length&&r(a));return g.promise};this.resolve=function(f){d||(d="resolved",b=f,e.length&&r(a));return g.promise};this.progress=function(a){d||e.forEach(function(b){b.progress&&b.progress(a)});return g.promise}; this.cancel=function(){d||g.reject(h())};this.then=function(b,c,f){var b={resolve:b,reject:c,progress:f,deferred:new l},g=b.deferred,k=this.cancel.bind(this),h=function(){r(function(){(g.cancel===h?k:g.cancel)()},!0)};g.cancel=h;c=g.promise;c.cancel=function(){g.cancel()};e.push(b);d&&r(a,!0);return c};this.promise={then:this.then,cancel:this.cancel}}var k=[],m=[],e=!1;l.all=function(a,b){function d(a,b){c||(k[a]=b,--f===0&&j.resolve(k))}function e(a,f){if(!c){if(b)try{d(a,b(f));return}catch(i){f= i}j.reject(f)}}var f=a.length,k=[],c=!1,j=new l;j.then(null,function(){c=!0;a.forEach(function(a){a.cancel&&a.cancel()})});f===0?j.resolve(k):a.forEach(function(a,b){a.then(d.bind(null,b),e.bind(null,b))});return j.promise};l.when=function(a,b,d,e){var f;if(!(a&&typeof a.then==="function"))f=new l,f.resolve(a),a=f.promise;return a.then(b,d,e)};return l}); define("orion/editor/contentAssist",["i18n!orion/editor/nls/messages","orion/editor/keyBinding","orion/editor/eventTarget","orion/Deferred","orion/editor/util"],function(s,r,p,f,h){var l,k,m;function e(a){this.textView=a;this.state=l;this.providers=[];var b=this;this.contentAssistListener={onModelChanging:function(a){b.isDeactivatingChange(a)?b.setState(l):b.state===k&&b.setState(m)},onScroll:function(){b.setState(l)},onSelection:function(){var a=b.state;if(a===k||a===m)b.computeProposals(),b.setState(m)}}; a.setKeyBinding(h.isMac?new r.KeyBinding(" ",!1,!1,!1,!0):new r.KeyBinding(" ",!0),"contentAssist");a.setAction("contentAssist",function(){b.activate();return!0},{name:s.contentAssist})}function a(a,b){this.contentAssist=a;this.widget=b;this.proposals=[];var d=this;this.contentAssist.addEventListener("ProposalsComputed",function(a){d.proposals=a.data.proposals;d.selectedIndex=d.proposals.length?0:-1})}function b(a,b){this.contentAssist=a;this.textView=this.contentAssist.getTextView();this.isShowing= this.textViewListenerAdded=!1;var d=this.textView.getOptions("parent").ownerDocument;this.parentNode=typeof b==="string"?d.getElementById(b):b;if(!this.parentNode){this.parentNode=h.createElement(d,"div");this.parentNode.className="contentassist";var c=d.getElementsByTagName("body")[0];if(c)c.appendChild(this.parentNode);else throw Error("parentNode is required");}var e=this;this.textViewListener={onMouseDown:function(a){a.event.target.parentElement!==e.parentNode&&e.contentAssist.deactivate()}}; this.contentAssist.addEventListener("ProposalsComputed",function(a){e.setProposals(a.data.proposals);e.show();if(!e.textViewListenerAdded)e.textView.addEventListener("MouseDown",e.textViewListener.onMouseDown),e.textViewListenerAdded=!0});this.contentAssist.addEventListener("Deactivating",function(){e.setProposals([]);e.hide();if(e.textViewListenerAdded)e.textView.removeEventListener("MouseDown",e.textViewListener.onMouseDown),e.textViewListenerAdded=!1;e.textViewListenerAdded=!1});this.scrollListener= function(){e.isShowing&&e.position()};d.addEventListener("scroll",this.scrollListener)}l=1;k=2;m=3;var d={selected:" selected",hr:"proposal-hr",emphasis:"proposal-emphasis",noemphasis:"proposal-noemphasis",dfault:"proposal-default"};e.prototype={apply:function(a){if(!a)return!1;var b=this.textView.getCaretOffset(),d={proposal:a,start:b,end:b};this.setState(l);this.textView.setText(a.proposal||a,b,b);this.dispatchEvent({type:"ProposalApplied",data:d});return!0},activate:function(){this.state===l&& this.setState(k)},deactivate:function(){this.setState(l)},getTextView:function(){return this.textView},isActive:function(){return this.state===k||this.state===m},isDeactivatingChange:function(a){var b=a.removedCharCount>0&&a.addedCharCount===0,d=this.textView,d=a.start+1<=d.getModel().getCharCount()&&/^\s*$/.test(d.getText(a.start,a.start+1));return a.removedLineCount>0||a.addedLineCount>0||b&&d},setState:function(a){var b;a===k?b="Activating":a===l&&(b="Deactivating");b&&this.dispatchEvent({type:b}); this.state=a;this.onStateChange(a)},onStateChange:function(a){if(a===l){if(this.listenerAdded)this.textView.removeEventListener("ModelChanging",this.contentAssistListener.onModelChanging),this.textView.removeEventListener("Scroll",this.contentAssistListener.onScroll),this.textView.removeEventListener("Selection",this.contentAssistListener.onSelection),this.listenerAdded=!1}else if(a===k){if(!this.listenerAdded)this.textView.addEventListener("ModelChanging",this.contentAssistListener.onModelChanging), this.textView.addEventListener("Scroll",this.contentAssistListener.onScroll),this.textView.addEventListener("Selection",this.contentAssistListener.onSelection),this.listenerAdded=!0;this.computeProposals()}},computeProposals:function(){var a=this;this._computeProposals(this.textView.getCaretOffset()).then(function(b){a.dispatchEvent({type:"ProposalsComputed",data:{proposals:b}})})},getPrefixStart:function(a){for(;a>0&&/[A-Za-z0-9_]/.test(this.textView.getText(a-1,a));)a--;return a},handleError:function(a){typeof console!== "undefined"&&(console.log("Error retrieving content assist proposals"),console.log(a))},_computeProposals:function(a){var b=this.providers,d=this.textView,c=d.getModel(),e=d.getText(),k={line:c.getLine(c.getLineAtOffset(a)),prefix:d.getText(this.getPrefixStart(a),a),selection:d.getSelection()},h=this,b=b.map(function(b){var c=b.computeProposals||b.getProposals,d;try{typeof c==="function"&&(d=h.progress?h.progress.progress(c.apply(b,[e,a,k]),"Generating content assist proposal"):c.apply(b,[e,a,k]))}catch(g){h.handleError(g)}return f.when(d)}); return f.all(b,this.handleError).then(function(a){return a.reduce(function(a,b){return b instanceof Array?a.concat(b):a},[])})},setProviders:function(a){this.providers=a.slice(0)},setProgress:function(a){this.progress=a}};p.EventTarget.addMixin(e.prototype);a.prototype={cancel:function(){this.getContentAssist().deactivate()},getContentAssist:function(){return this.contentAssist},isActive:function(){return this.getContentAssist().isActive()},lineUp:function(){for(var a=this.selectedIndex===0?this.proposals.length- 1:this.selectedIndex-1;this.proposals[a].unselectable&&a>0;)a--;this.selectedIndex=a;this.widget&&this.widget.setSelectedIndex(this.selectedIndex);return!0},lineDown:function(){for(var a=this.selectedIndex===this.proposals.length-1?0:this.selectedIndex+1;this.proposals[a].unselectable&&a=0)c.className=c.className.substring(0, f)+c.className.substring(f+d.selected.length);c===a&&(c.className+=d.selected,this.parentNode.setAttribute("aria-activedescendant",c.id),c.focus(),c.offsetTopthis.parentNode.scrollTop+this.parentNode.clientHeight&&c.scrollIntoView(!1))}},setProposals:function(a){this.proposals=a},show:function(){if(this.proposals.length===0)this.hide();else{this.parentNode.innerHTML="";for(var a=0;ab.documentElement.clientHeight)this.parentNode.style.top=a.y-this.parentNode.offsetHeight-this.textView.getLineHeight()+"px";if(a.x+this.parentNode.offsetWidth>d)this.parentNode.style.left=d-this.parentNode.offsetWidth+"px"}};return{ContentAssist:e,ContentAssistMode:a, ContentAssistWidget:b}}); define("orion/editor/cssContentAssist",[],function(){function s(){}var r="alignment-adjust,alignment-baseline,animation,animation-delay,animation-direction,animation-duration,animation-iteration-count,animation-name,animation-play-state,animation-timing-function,appearance,azimuth,backface-visibility,background,background-attachment,background-clip,background-color,background-image,background-origin,background-position,background-repeat,background-size,baseline-shift,binding,bleed,bookmark-label,bookmark-level,bookmark-state,bookmark-target,border,border-bottom,border-bottom-color,border-bottom-left-radius,border-bottom-right-radius,border-bottom-style,border-bottom-width,border-collapse,border-color,border-image,border-image-outset,border-image-repeat,border-image-slice,border-image-source,border-image-width,border-left,border-left-color,border-left-style,border-left-width,border-radius,border-right,border-right-color,border-right-style,border-right-width,border-spacing,border-style,border-top,border-top-color,border-top-left-radius,border-top-right-radius,border-top-style,border-top-width,border-width,bottom,box-align,box-decoration-break,box-direction,box-flex,box-flex-group,box-lines,box-ordinal-group,box-orient,box-pack,box-shadow,box-sizing,break-after,break-before,break-inside,caption-side,clear,clip,color,color-profile,column-count,column-fill,column-gap,column-rule,column-rule-color,column-rule-style,column-rule-width,column-span,column-width,columns,content,counter-increment,counter-reset,crop,cue,cue-after,cue-before,cursor,direction,display,dominant-baseline,drop-initial-after-adjust,drop-initial-after-align,drop-initial-before-adjust,drop-initial-before-align,drop-initial-size,drop-initial-value,elevation,empty-cells,fit,fit-position,flex-align,flex-flow,flex-inline-pack,flex-order,flex-pack,float,float-offset,font,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,grid-columns,grid-rows,hanging-punctuation,height,hyphenate-after,hyphenate-before,hyphenate-character,hyphenate-lines,hyphenate-resource,hyphens,icon,image-orientation,image-rendering,image-resolution,inline-box-align,left,letter-spacing,line-height,line-stacking,line-stacking-ruby,line-stacking-shift,line-stacking-strategy,list-style,list-style-image,list-style-position,list-style-type,margin,margin-bottom,margin-left,margin-right,margin-top,mark,mark-after,mark-before,marker-offset,marks,marquee-direction,marquee-loop,marquee-play-count,marquee-speed,marquee-style,max-height,max-width,min-height,min-width,move-to,nav-down,nav-index,nav-left,nav-right,nav-up,opacity,orphans,outline,outline-color,outline-offset,outline-style,outline-width,overflow,overflow-style,overflow-x,overflow-y,padding,padding-bottom,padding-left,padding-right,padding-top,page,page-break-after,page-break-before,page-break-inside,page-policy,pause,pause-after,pause-before,perspective,perspective-origin,phonemes,pitch,pitch-range,play-during,position,presentation-level,punctuation-trim,quotes,rendering-intent,resize,rest,rest-after,rest-before,richness,right,rotation,rotation-point,ruby-align,ruby-overhang,ruby-position,ruby-span,size,speak,speak-header,speak-numeral,speak-punctuation,speech-rate,stress,string-set,table-layout,target,target-name,target-new,target-position,text-align,text-align-last,text-decoration,text-emphasis,text-height,text-indent,text-justify,text-outline,text-shadow,text-transform,text-wrap,top,transform,transform-origin,transform-style,transition,transition-delay,transition-duration,transition-property,transition-timing-function,unicode-bidi,vertical-align,visibility,voice-balance,voice-duration,voice-family,voice-pitch,voice-pitch-range,voice-rate,voice-stress,voice-volume,volume,white-space,white-space-collapse,widows,width,word-break,word-spacing,word-wrap,z-index".split(",");s.prototype= {computeProposals:function(p,f){var h;for(h=f;h&&/[A-Za-z\-]/.test(p.charAt(h-1));)h--;h=h?p.substring(h,f):"";for(var l=[],k=0;k0;){var h=r.charAt(p--);if(h==="\n"||h==="\r")break;f=/\s/.test(h)?h.concat(f):""}return f},computeProposals:function(r,p,f){function h(a){return a.substring(f.prefix.length)}var l=[];if(r.length===0)return l.push({proposal:'\n\n\t\n\t\t\n\t\tMy Document\n\t\n\t\n\t\t

A basic HTML document

\n\t\t

\n\t\t\t\n\t\t

\n\t\n', description:"Simple HTML document",escapePosition:p+152}),l;var k=f.prefix;if(r.charAt(p-k.length-1)!=="<")return l;for(var m,e,a="abbr,b,button,canvas,cite,command,dd,del,dfn,dt,em,embed,font,h1,h2,h3,h4,h5,h6,i,ins,kbd,label,li,mark,meter,object,option,output,progress,q,rp,rt,samp,small,strong,sub,sup,td,time,title,tt,u,var".split(","),b=0;b",m=p+m.length-k.length+1,l.push({proposal:h(e),description:"<"+e,escapePosition:m}));a="address,article,aside,audio,bdo,blockquote,body,caption,code,colgroup,datalist,details,div,fieldset,figure,footer,form,head,header,hgroup,iframe,legend,map,menu,nav,noframes,noscript,optgroup,p,pre,ruby,script,section,select,span,style,tbody,textarea,tfoot,th,thead,tr,video".split(","); r=this.leadingWhitespace(r,p);for(b=0;b\n"+r+"\t\n"+r+"",m=p+m.length-k.length+r.length+3,l.push({proposal:h(e),description:"<"+e,escapePosition:m}));a="area,base,br,col,hr,input,link,meta,param,keygen,source".split(",");for(b=0;b",m=p+m.length-k.length+2,l.push({proposal:h(e),description:"<"+e,escapePosition:m}));"img".indexOf(k)===0&&(e='img src="" alt="Image"/>',l.push({proposal:h(e),description:"<"+ e,escapePosition:p+9-k.length}));k==="a"&&l.push({proposal:h('a href="">'),description:" - HTML anchor element",escapePosition:p+7});"ul".indexOf(k)===0&&(e="
    - unordered list",m=p-k.length+r.length+9,l.push({proposal:h("ul>\n"+r+"\t
  • \n"+r+"
"),description:e,escapePosition:m}));"ol".indexOf(k)===0&&(e="
    - ordered list",m=p-k.length+r.length+9,l.push({proposal:h("ol>\n"+r+"\t
  1. \n"+r+"
"),description:e,escapePosition:m}));"dl".indexOf(k)===0&&(e="
- definition list", m=p-k.length+r.length+9,l.push({proposal:h("dl>\n"+r+"\t
\n"+r+"\t
\n"+r+"
"),description:e,escapePosition:m}));"table".indexOf(k)===0&&(e=" - basic HTML table",m=p-k.length+r.length*2+19,l.push({proposal:h("table>\n"+r+"\t\n"+r+"\t\t\n"+r+"\t\n"+r+"
"),description:e,escapePosition:m}));return l}};return{HTMLContentAssistProvider:s}}); define("orion/editor/jsTemplateContentAssist",[],function(){function s(f,l,k){var m=k-f.length,e=[],a="";for(k-=1;k>0;){var b=l.charAt(k--);if(b==="\n"||b==="\r")break;a=/\s/.test(b)?b.concat(a):""}l=a;"if".indexOf(f)===0&&(k="if - if statement",a=[{offset:m+4,length:9}],b=m+l.length+18,e.push({proposal:("if (condition) {\n"+l+"\t\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}),k="if - if else statement",a=[{offset:m+4,length:9}],b=m+l.length+18,e.push({proposal:("if (condition) {\n"+ l+"\t\n"+l+"} else {\n"+l+"\t\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}));"for".indexOf(f)===0&&(k="for - iterate over array",a=[{offset:m+9,length:1},{offset:m+20,length:5}],b=m+l.length+42,e.push({proposal:("for (var i = 0; i < array.length; i++) {\n"+l+"\t\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}),k="for..in - iterate over properties of an object",a=[{offset:m+9,length:8},{offset:m+21,length:6}],b=m+2*l.length+73,e.push({proposal:("for (var property in object) {\n"+ l+"\tif (object.hasOwnProperty(property)) {\n"+l+"\t\t\n"+l+"\t}\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}));"while".indexOf(f)===0&&(k="while - while loop with condition",a=[{offset:m+7,length:9}],b=m+l.length+21,e.push({proposal:("while (condition) {\n"+l+"\t\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}));"do".indexOf(f)===0&&(k="do - do while loop with condition",a=[{offset:m+16,length:9}],b=m+l.length+6,e.push({proposal:("do {\n"+l+ "\t\n"+l+"} while (condition);").substring(f.length),description:k,positions:a,escapePosition:b}));"switch".indexOf(f)===0&&(k="switch - switch case statement",a=[{offset:m+8,length:10},{offset:m+28,length:6}],b=m+2*l.length+38,e.push({proposal:("switch (expression) {\n"+l+"\tcase value1:\n"+l+"\t\t\n"+l+"\t\tbreak;\n"+l+"\tdefault:\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}));"try".indexOf(f)===0&&(k="try - try..catch statement",b=m+l.length+7,e.push({proposal:("try {\n"+ l+"\t\n"+l+"} catch (err) {\n"+l+"}").substring(f.length),description:k,escapePosition:b}),k="try - try..catch statement with finally block",b=m+l.length+7,e.push({proposal:("try {\n"+l+"\t\n"+l+"} catch (err) {\n"+l+"} finally {\n"+l+"}").substring(f.length),description:k,escapePosition:b}));return e}function r(f){for(var l="break,case,catch,continue,debugger,default,delete,do,else,finally,for,function,if,in,instanceof,new,return,switch,this,throw,try,typeof,var,void,while,with".split(","),k=[], m=0;m":">"};p.prototype={computeProposals:function(h,l,k){for(var k=k.prefix,m=[],e=l-k.length-1,a="";e>=0;)if(a=h[e],a==="\n"||a==="\r")break;else if(/\s/.test(a))e--;else break;if(f[a])return m;m=m.concat(s(k,h,l));return m=m.concat(r(k,h,l))}};return{JSTemplateContentAssistProvider:p}}); define("orion/editor/AsyncStyler",["i18n!orion/editor/nls/messages","orion/editor/annotations"],function(s,r){function p(f){return f.getProperty("objectClass").indexOf(h)!==-1&&f.getProperty("type")==="highlighter"}function f(f,h,e){this.initialize(f,h,e);this.lineStyles=[]}var h="orion.edit.highlighter",l=h+" service must be an event emitter";r.AnnotationType.registerType("orion.annotation.highlightError",{title:s.syntaxError,html:"
",rangeStyle:{styleClass:"annotationRange error"}}); f.prototype={initialize:function(f,l,e){this.textView=f;this.serviceRegistry=l;this.annotationModel=e;this.services=[];var a=this;this.listener={onModelChanging:function(b){a.onModelChanging(b)},onModelChanged:function(b){a.onModelChanged(b)},onDestroy:function(b){a.onDestroy(b)},onLineStyle:function(b){a.onLineStyle(b)},onStyleReady:function(b){a.onStyleReady(b)},onServiceAdded:function(b){a.onServiceAdded(b.serviceReference,a.serviceRegistry.getService(b.serviceReference))},onServiceRemoved:function(b){a.onServiceRemoved(b.serviceReference, a.serviceRegistry.getService(b.serviceReference))}};f.addEventListener("ModelChanging",this.listener.onModelChanging);f.addEventListener("ModelChanged",this.listener.onModelChanged);f.addEventListener("Destroy",this.listener.onDestroy);f.addEventListener("LineStyle",this.listener.onLineStyle);l.addEventListener("registered",this.listener.onServiceAdded);l.addEventListener("unregistering",this.listener.onServiceRemoved);f=l.getServiceReferences(h);for(e=0;e=this.string.length},sol:function(){return this.pos===0},peek:function(){return this.string[this.pos]},next:function(){return this.string[this.pos++]},eat:function(e){var a=this.string[this.pos];return typeof a==="string"&&(a===e||e.test&&e.test(a)||typeof e==="function"&& e(a))?this.string[this.pos++]:void 0},eatWhile:function(e){for(var a=!1;this.eat(e)!==void 0;)a=!0;return a},eatSpace:function(){return this.eatWhile(/\s/)},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){e=this.string.indexOf(e,this.pos);return e!==-1?(this.pos=e,!0):!1},match:function(e,a,b){a=a===!0||typeof a==="undefined";if(typeof e==="string"){var d=b?this.string.toLowerCase():this.string,e=b?e.toLowerCase():e,b=d.indexOf(e,this.pos);if(b!==-1&&a)this.pos=b+e.length;return b!== -1}else return(e=this.string.substring(this.pos).match(e))&&a&&typeof e[0]==="string"&&(this.pos+=e.index+e[0].length),e},backUp:function(e){this.pos-=e},column:function(){for(var e=0,a=0;a=b)break;this._expandRange(d,d);for(var f=this._getResumeLineIndex(d),d=f+1,f=(f=f>= 0&&this.lines[f].eolState)?this.codeMirror.copyState(this.mode,f):this.mode.startState(),g=0,h=d;h3;if(c||l)break;else if(!j||k)g=0;j=he&&j){this.highlightLater(h+1);this.onHighlightDone();return}}}this.onHighlightDone()},onHighlightDone:function(){this.startLine!==Number.MAX_VALUE&& this.endLine!==-1&&this.dispatchEvent({type:"Highlight",start:this.startLine,end:this.endLine});this.startLine=Number.MAX_VALUE;this.endLine=-1},_getResumeLineIndex:function(e){for(var a=this.lines,b=e-1;b>=0;b--)if(a[b].eolState||e-b>40)return b;return-1},getState:function(e){var a=this.mode,b=this.lines,d,f;for(d=e-1;d>=0;d--)if(f=b[d],f.eolState||e-d>40)break;var g=d>=0&&b[d].eolState;if(g){g=this.codeMirror.copyState(a,g);for(d=Math.max(0,d);d
", rangeStyle:{styleClass:"annotationRange error"}});m.prototype={init:function(e,a,b){this.textView=e;this.annotationModel=b;this.modeApplier=new k(e.getModel(),a);var d=this;this.listener={onLineStyle:function(a){d.onLineStyle(a)},onDestroy:function(a){d.onDestroy(a)},onHighlight:function(a){d.onHighlight(a)}};e.addEventListener("LineStyle",this.listener.onLineStyle);e.addEventListener("Destroy",this.listener.onDestroy);this.modeApplier.addEventListener("Highlight",this.listener.onHighlight)},destroy:function(){this.modeApplier&& (this.modeApplier.removeEventListener("Highlight",this.listener.onHighlight),this.modeApplier.destroy());this.textView&&(this.textView.removeEventListener("LineStyle",this.listener.onLineStyle),this.textView.removeEventListener("Destroy",this.listener.onDestroy));this.listener=this.modeApplier=this.annotationModel=this.textView=null},setMode:function(e){this.modeApplier.setMode(e)},onLineStyle:function(e){var a=e.lineIndex,b=this.modeApplier,d=b.getLineStyle(a);if(!d||!d.eolState){var f=this.textView.getModel().getLineCount(); b.highlight(a,Math.min(a+20,f-1),!0);d=b.getLineStyle(a)}f=this.textView.getModel();if(d){var g=b.toStyleRangesAndErrors(d,a);if(g&&(e.ranges=g[0],e=this.annotationModel)){b=[];d=[];if(g=g[1])for(var h=0;h/,func:function(){return"atomic group"}}],toRegExp:function(e){function a(a,b){throw Error('Unsupported regex feature "'+a+'": "'+b[0]+'" at index: '+b.index+" in "+b.input);}var b="",d,e=m.processGlobalFlag("x",e,function(a){for(var b="",c=!1,d=a.length,e=0;e=0;t--);v=b.charAt(t-1);s=t-1;D=b.substring(t,p+1)}t=h[h.length-1];if(v===")"&&(t.type===2||t.type===4)){k.splice(t.start,0,"(");k.push(D);k.push(")");r={start:t.start,end:k.length-1,type:4,num:t.num};for(v=0;v=t.start&&n.end<=s)if(n.start+=1,n.end+=1,n.num+=1,n.type===2)l[n.oldNum]=n.num;h.push(r);j++;break}default:r!=="|"&&n!==2&&n!==4&&g===0&&(f.push(4),h.push({start:p,end:-1,type:4,num:j}),k.push("("),m[j]=null,j++),k.push(r),r==="\\"&&(r=b.charAt(p+1),k.push(r),p+=1)}}for(;f.length;)f.pop(),k.push(")");var b=RegExp(k.join("")),d={},a=a||l,z;for(z in a)a.hasOwnProperty(z)&&(d[z]="\\"+a[z]);b=this.getSubstitutedRegex(b,d,!1);return[b,l,m]},complexCaptures:function(e){if(!e)return!1; for(var a in e)if(e.hasOwnProperty(a)&&a!=="0")return!0;return!1}};l.prototype={initialize:function(e,a,b){this.textView=e;this.textView.stylerOptions=this;var d=this;this.textView&&a&&a.startup().then(function(a){k=a.preferences;d.preferences=k;d._updateStylesheet(k,b);d.storageKey=k.listenForChangedSettings(d._listener.onStorage)});this._listener={onModelChanged:function(a){d.onModelChanged(a)},onDestroy:function(a){d.onDestroy(a)},onLineStyle:function(a){d.onLineStyle(a)},onStorage:function(a){d.onStorage(a)}}; e.addEventListener("ModelChanged",this._listener.onModelChanged);e.addEventListener("Destroy",this._listener.onDestroy);e.addEventListener("LineStyle",this._listener.onLineStyle);e.redrawLines()},onDestroy:function(){this.destroy()},onStorage:function(e){e.key===this.storageKey&&this._updateStylesheet(this.preferences)},destroy:function(){if(this.textView)this.textView.removeEventListener("ModelChanged",this._listener.onModelChanged),this.textView.removeEventListener("Destroy",this._listener.onDestroy), this.textView.removeEventListener("LineStyle",this._listener.onLineStyle),this.textView=null;this._listener=this._tree=this._styles=this.grammar=null},preprocess:function(e){for(e=[e];e.length!==0;){var a=e.pop();if(!a._resolvedRule||!a._typedRule)if(a._resolvedRule=this._resolve(a),a._typedRule=this._createTypedRule(a),this.addStyles(a.name),this.addStyles(a.contentName),this.addStylesForCaptures(a.captures),this.addStylesForCaptures(a.beginCaptures),this.addStylesForCaptures(a.endCaptures),a._resolvedRule!== a&&e.push(a._resolvedRule),a.patterns)for(var b=0;b0;)e.push(a[--b])},exec:function(e,a,b){(a=e.exec(a))&&(a.index+=b);e.lastIndex=0;return a},afterMatch:function(e){return e.index+e[0].length},getEndMatch:function(e,a,b){if(e instanceof this.BeginEndNode){var d=e.rule,e=e.endRegexSubstituted||d.endRegex;return!e?null:this.exec(e, a,b)}return null},initialParse:function(){this.textView.getModel().getCharCount();this._tree=new this.ContainerNode(null,this.grammar._typedRule);this.parse(this._tree,!1,0)},onModelChanged:function(e){var a=e.addedCharCount,b=e.removedCharCount,e=e.start;if(this._tree){var d=this.textView.getModel(),f=d.getCharCount(),d=d.getLineEnd(d.getLineAtOffset(e)-1),g=this.getFirstDamaged(d,d),d=d===-1?0:d,a=g?this.parse(g,!0,d,e,a,b):f;this.textView.redrawRange(d,a)}else this.initialParse()},getFirstDamaged:function(e, a){if(e<0)return this._tree;for(var b=[this._tree],d=null;b.length;){var f=b.pop();if(!f.parent||this.isDamaged(f,e,a)){f instanceof this.BeginEndNode&&(d=f);for(var g=0;ga},parse:function(e,a,b,d,f,g){var h=this.textView.getModel(),c=h.getLineStart(h.getLineCount()-1),j=h.getCharCount(),k=this.getInitialExpected(e,b),l=-1;if(a)e.repaired=!0,e.endNeedsUpdate=!0,l=(l=e.children[e.children.length- 1])?h.getLineEnd(h.getLineAtOffset(l.end+(f-g))):-1,d=h.getLineEnd(h.getLineAtOffset(d+g)),l=Math.max(l,d);for(var l=l===-1?j:l,d=k,m=e,p=!1,n=b,r=-1;m&&(!a||n=c?j:h.getLineStart(h.getLineAtOffset(n)+1));var t=s&&s.match,D=s&&s.rule,v=s&&s.isEnd;if(s&&s.isSub){if(n=this.afterMatch(t),D instanceof this.BeginEndRule)p=!0,a&&D===d.rule&&m===d.parent?(m=d,m.setStart(t),m.repaired=!0,m.endNeedsUpdate=!0,d=this.getNextExpected(d,"begin")):(a&&(this.prune(m,d), a=!1),t=new this.BeginEndNode(m,D,t),m.addChild(t),m=t)}else if(v||n===j){if(m instanceof this.BeginEndNode)t?(p=!0,r=Math.max(r,m.end),m.setEnd(t),n=this.afterMatch(t),a&&m===d&&m.parent===d.parent?(m.repaired=!0,delete m.endNeedsUpdate,d=this.getNextExpected(d,"end")):a&&(this.prune(m,d),a=!1)):(m.setEnd(j),delete m.endNeedsUpdate);m=m.parent}a&&n>=l&&!p&&(this.prune(e,k),a=!1)}this.removeUnrepairedChildren(e,a,b);this.cleanup(a,e,b,l,j,f,g);return a?Math.max(r,n):n},removeUnrepairedChildren:function(e, a,b){if(a){for(var a=e.children,d=-1,f=0;f=a)return d}else if(e instanceof this.BeginEndNode&&e.endMatch){var f=e.endMatch.index;for(b=0;b=a)break;if(d&&d.start< f)return d}return e},getNextExpected:function(e,a){if(a==="begin"){var b=e.children[0];return b?b:e}else if(a==="end"&&(b=e.parent)){var d=b.children[b.children.indexOf(e)+1];return d?d:b}return null},prune:function(e,a){if(a.parent===e)e.children.length=a.getIndexInParent();else if(e instanceof this.BeginEndNode)e.endMatch=null,e.end=null;if(e.parent)e.parent.children.length=e.getIndexInParent()+1},onLineStyle:function(e){this._tree||this.initialParse();var a=e.lineStart,b=this.textView.getModel(), d=b.getLineEnd(e.lineIndex),f=b.getLineEnd(b.getLineAtOffset(a)-1),f=this.getFirstDamaged(f,f),a=this.getLineScope(b,f,a,d);e.ranges=this.toStyleRanges(a);e.ranges.sort(function(a,b){return a.start-b.start})},getLineScope:function(e,a,b,d){for(var f=b,g=this.getInitialExpected(a,b),h=[],c=[];a&&f",contentName:"entity.name.tag.doctype.html",beginCaptures:{0:{name:"entity.name.tag.doctype.html"}},endCaptures:{0:{name:"entity.name.tag.doctype.html"}}},{begin:"<\!--",end:"--\>",beginCaptures:{0:{name:"punctuation.definition.comment.html"}},endCaptures:{0:{name:"punctuation.definition.comment.html"}}, patterns:[{match:"--",name:"invalid.illegal.badcomment.html"}],contentName:"comment.block.html"},{match:"<[A-Za-z0-9_\\-:]+(?= ?)",name:"entity.name.tag.html"},{include:"#attrName"},{include:"#qString"},{include:"#qqString"},{include:"#entity"},{match:"",name:"entity.name.tag.html"},{match:">",name:"entity.name.tag.html"}],repository:{attrName:{match:"[A-Za-z\\-:]+(?=\\s*=\\s*['\"])",name:"entity.other.attribute.name.html"},qqString:{match:'(")[^"]+(")',name:"token.string"},qString:{match:"(')[^']+(')", name:"token.string"},entity:{match:"&[A-Za-z0-9]+;",name:"constant.character.entity.html"}}}}}}); define("examples/editor/textStyler",["orion/editor/annotations"],function(s){function r(a,b){this.keywords=a;this.whitespacesVisible=b;this.setText("")}function p(){r.call(this,null,!0)}function f(a){r.call(this,null,a)}function h(){r.call(this,null,!1)}function l(a,b,c){this.commentStart="/*";this.commentEnd="*/";var d=[];switch(b){case "java":d=m;break;case "js":d=k;break;case "css":d=e}this.whitespacesVisible=!1;this.detectHyperlinks=!0;this.highlightCaretLine=!1;this.detectTasks=this.foldingEnabled= !0;this._scanner=new r(d,this.whitespacesVisible);this._firstScanner=new h;this._commentScanner=new f(this.whitespacesVisible);this._whitespaceScanner=new p;if(b==="css")this._scanner.isCSS=!0,this._firstScanner.isCSS=!0;this.view=a;this.annotationModel=c;this._bracketAnnotations=void 0;var g=this;this._listener={onChanged:function(a){g._onModelChanged(a)},onDestroy:function(a){g._onDestroy(a)},onLineStyle:function(a){g._onLineStyle(a)},onMouseDown:function(a){g._onMouseDown(a)},onSelection:function(a){g._onSelection(a)}}; b=a.getModel();b.getBaseModel&&(b=b.getBaseModel());b.addEventListener("Changed",this._listener.onChanged);a.addEventListener("MouseDown",this._listener.onMouseDown);a.addEventListener("Selection",this._listener.onSelection);a.addEventListener("Destroy",this._listener.onDestroy);a.addEventListener("LineStyle",this._listener.onLineStyle);this._computeComments();this._computeFolding();a.redrawLines()}var k="break,case,class,catch,continue,const,debugger,default,delete,do,else,enum,export,extends,false,finally,for,function,if,implements,import,in,instanceof,interface,let,new,null,package,private,protected,public,return,static,super,switch,this,throw,true,try,typeof,undefined,var,void,while,with,yield".split(","), m="abstract,boolean,break,byte,case,catch,char,class,continue,default,do,double,else,extends,false,final,finally,float,for,if,implements,import,instanceof,int,interface,long,native,new,null,package,private,protected,public,return,short,static,super,switch,synchronized,this,throw,throws,transient,true,try,void,volatile,while".split(","),e="alignment-adjust,alignment-baseline,animation,animation-delay,animation-direction,animation-duration,animation-iteration-count,animation-name,animation-play-state,animation-timing-function,appearance,azimuth,backface-visibility,background,background-attachment,background-clip,background-color,background-image,background-origin,background-position,background-repeat,background-size,baseline-shift,binding,bleed,bookmark-label,bookmark-level,bookmark-state,bookmark-target,border,border-bottom,border-bottom-color,border-bottom-left-radius,border-bottom-right-radius,border-bottom-style,border-bottom-width,border-collapse,border-color,border-image,border-image-outset,border-image-repeat,border-image-slice,border-image-source,border-image-width,border-left,border-left-color,border-left-style,border-left-width,border-radius,border-right,border-right-color,border-right-style,border-right-width,border-spacing,border-style,border-top,border-top-color,border-top-left-radius,border-top-right-radius,border-top-style,border-top-width,border-width,bottom,box-align,box-decoration-break,box-direction,box-flex,box-flex-group,box-lines,box-ordinal-group,box-orient,box-pack,box-shadow,box-sizing,break-after,break-before,break-inside,caption-side,clear,clip,color,color-profile,column-count,column-fill,column-gap,column-rule,column-rule-color,column-rule-style,column-rule-width,column-span,column-width,columns,content,counter-increment,counter-reset,crop,cue,cue-after,cue-before,cursor,direction,display,dominant-baseline,drop-initial-after-adjust,drop-initial-after-align,drop-initial-before-adjust,drop-initial-before-align,drop-initial-size,drop-initial-value,elevation,empty-cells,fit,fit-position,flex-align,flex-flow,flex-inline-pack,flex-order,flex-pack,float,float-offset,font,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,grid-columns,grid-rows,hanging-punctuation,height,hyphenate-after,hyphenate-before,hyphenate-character,hyphenate-lines,hyphenate-resource,hyphens,icon,image-orientation,image-rendering,image-resolution,inline-box-align,left,letter-spacing,line-height,line-stacking,line-stacking-ruby,line-stacking-shift,line-stacking-strategy,list-style,list-style-image,list-style-position,list-style-type,margin,margin-bottom,margin-left,margin-right,margin-top,mark,mark-after,mark-before,marker-offset,marks,marquee-direction,marquee-loop,marquee-play-count,marquee-speed,marquee-style,max-height,max-width,min-height,min-width,move-to,nav-down,nav-index,nav-left,nav-right,nav-up,opacity,orphans,outline,outline-color,outline-offset,outline-style,outline-width,overflow,overflow-style,overflow-x,overflow-y,padding,padding-bottom,padding-left,padding-right,padding-top,page,page-break-after,page-break-before,page-break-inside,page-policy,pause,pause-after,pause-before,perspective,perspective-origin,phonemes,pitch,pitch-range,play-during,position,presentation-level,punctuation-trim,quotes,rendering-intent,resize,rest,rest-after,rest-before,richness,right,rotation,rotation-point,ruby-align,ruby-overhang,ruby-position,ruby-span,size,speak,speak-header,speak-numeral,speak-punctuation,speech-rate,stress,string-set,table-layout,target,target-name,target-new,target-position,text-align,text-align-last,text-decoration,text-emphasis,text-height,text-indent,text-justify,text-outline,text-shadow,text-transform,text-wrap,top,transform,transform-origin,transform-style,transition,transition-delay,transition-duration,transition-property,transition-timing-function,unicode-bidi,vertical-align,visibility,voice-balance,voice-duration,voice-family,voice-pitch,voice-pitch-range,voice-rate,voice-stress,voice-volume,volume,white-space,white-space-collapse,widows,width,word-break,word-spacing,word-wrap,z-index".split(","), a={styleClass:"comment"},b={styleClass:"token_multiline_comment"},d={styleClass:"token_doc_comment"},i={styleClass:"token_doc_html_markup"},g={styleClass:"token_task_tag"},o={styleClass:"token_doc_tag"},c={styleClass:"token-string"},j={styleClass:"token_number"},q={styleClass:"token_keyword"},u={styleClass:"token_space"},A={styleClass:"token_tab"},E={styleClass:"line_caret"};r.prototype={getOffset:function(){return this.offset},getStartOffset:function(){return this.startOffset},getData:function(){return this.text.substring(this.startOffset, this.offset)},getDataLength:function(){return this.offset-this.startOffset},_default:function(a){switch(a){case 32:case 9:if(this.whitespacesVisible)return a===32?11:10;do a=this._read();while(a===32||a===9);this._unread(a);return 9;case 123:case 125:case 40:case 41:case 91:case 93:case 60:case 62:return a;default:var b=this.isCSS,c=this.offset-1;if(!b&&48<=a&&a<=57){var d=b=!1,e=!1,f=a;do if(a=this._read(),a===46&&!b)b=!0;else if(a===101&&!d)b=d=!0,a=this._read(),a!==45&&this._unread(a);else if(a=== 120&&f===48&&this.offset-c===2)b=d=e=!0;else if(!(48<=a&&a<=57||e&&(65<=a&&a<=70||97<=a&&a<=102)))break;while(1);this._unread(a);return 3}if(97<=a&&a<=122||65<=a&&a<=90||a===95||45===a&&b){do a=this._read();while(97<=a&&a<=122||65<=a&&a<=90||a===95||48<=a&&a<=57||45===a&&b);this._unread(a);a=this.keywords;if(a.length>0){c=this.text.substring(c,this.offset);for(b=0;b1;)if(f=Math.floor((e+d)/2),b<=a[f].start)e=f;else if(c&&b=g)break;var l= j[k].start,m=j[k].end;i0){for(var e=a,g=f;g>0;){f=e.charCodeAt(g-1);if(!(97<=f&&f<=122||65<=f&&f<=90||45===f||48<=f&&f<=57))break;g--}if(g>0&&(f="\"\"''(){}[]<>".indexOf(e.substring(g- 1,g)),f!==-1&&(f&1)===0&&(f=e.lastIndexOf("\"\"''(){}[]<>".substring(f+1,f+2)))!==-1)){var h=f;f=this._clone(d);f.tagName="A";f.attributes={href:e.substring(g,h)};c.push({start:b,end:b+g,style:d});c.push({start:b+g,end:b+h,style:f});c.push({start:b+h,end:b+a.length,style:d});return null}}else a.toLowerCase().indexOf("bug#")===0&&(e="https://bugs.eclipse.org/bugs/show_bug.cgi?id="+parseInt(a.substring(4),10));return e?(f=this._clone(d),f.tagName="A",f.attributes={href:e},f):d},_clone:function(a){if(!a)return a; var b={},c;for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b},_findComments:function(a,b){var b=b||0,c=this._firstScanner,d;c.setText(a);for(var e=[];d=c.nextToken();)(d===7||d===8||d===5)&&e.push({start:c.getStartOffset()+b,end:c.getOffset()+b,type:d}),(d===6||d===7||d===8)&&this._computeTasks(d,c.getStartOffset()+b,c.getOffset()+b);return e},_findMatchingBracket:function(a,b){var c="{}()[]<>",d=a.getText(b,b+1),e=c.indexOf(d,0);if(e===-1)return-1;var f;f=e&1?c.substring(e-1,e):c.substring(e+ 1,e+2);for(var g=a.getLineAtOffset(b),c=a.getLine(g),h=a.getLineStart(g),i=a.getLineEnd(g),c=this._findBrackets(d,f,c,h,h,i),i=0;i=0?1:-1,c[i]*h-1===b){var j=1;if(e&1){for(i--;i>=0;i--)if(h=c[i]>=0?1:-1,j+=h,j===0)return c[i]*h-1;for(g-=1;g>=0;){c=a.getLine(g);h=a.getLineStart(g);i=a.getLineEnd(g);c=this._findBrackets(d,f,c,h,h,i);for(e=c.length-1;e>=0;e--)if(h=c[e]>=0?1:-1,j+=h,j===0)return c[e]*h-1;g--}}else{for(i++;i=0?1:-1,j+=h,j===0)return c[i]* h-1;g+=1;for(e=a.getLineCount();g=0?1:-1,j+=h,j===0)return c[i]*h-1;g++}}break}return-1},_findBrackets:function(a,b,c,d,e,f){for(var g=[],a=a.charCodeAt(0),b=b.charCodeAt(0),h=e,i=this._scanner,j,k=this.comments,l=this._binarySearch(k,e,!0);l=f)break;j=k[l].start;var m=k[l].end;if(h0)i-=1,a.getBaseModel&&(i=a.mapOffset(i),a=a.getBaseModel()),a=this._findMatchingBracket(a,i),a!==-1&&(h=[s.AnnotationType.createAnnotation(s.AnnotationType.ANNOTATION_MATCHING_BRACKET,a,a+1),s.AnnotationType.createAnnotation(s.AnnotationType.ANNOTATION_CURRENT_BRACKET, i,i+1)]);this._bracketAnnotations=h;this.annotationModel.replaceAnnotations(b,h)}},_onMouseDown:function(a){if(a.clickCount===2){var b=this.view,c=b.getModel(),d=b.getOffsetAtLocation(a.x,a.y);if(d>0){var e=d-1,f=c;c.getBaseModel&&(e=c.mapOffset(e),f=c.getBaseModel());e=this._findMatchingBracket(f,e);e!==-1&&(a.preventDefault(),a=e,c.getBaseModel&&(a=c.mapOffset(a,!0)),d>a&&(d--,a++),b.setSelection(a,d))}}},_onModelChanged:function(a){var b=a.start,c=a.removedCharCount,d=a.addedCharCount-c,e=this.view, a=e.getModel(),f=a.getBaseModel?a.getBaseModel():a,c=b+c,g=f.getCharCount(),h=this.comments.length,i=f.getLineStart(f.getLineAtOffset(b)),j=this._binarySearch(this.comments,i,!0),k=this._binarySearch(this.comments,c,!1,j-1,h);jb&&(i+=d)):i=j===h&&h>0&&g-d===this.comments[h-1].end?this.comments[h-1].start:i;var l;kb&&(l+=d),k+=1):(k=h,l=g);for(var m,g=this._findComments(f.getText(i,l),i), h=j;hb&&(m.start+=d),m.start>b&&(m.end+=d);var o=k-j!==g.length;if(!o)for(h=0;hb&&(h-=d),k>b&&(k-=d),h<=b&&b