-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuilt-compare.min.js
1 lines (1 loc) · 390 KB
/
built-compare.min.js
1
define("orion/util",[],function(){function v(e){var t=arguments;return e.replace(/\$\{([^\}]+)\}/g,function(e,n){return t[(n<<0)+1]})}function g(e,t){return e.createElementNS?e.createElementNS(m,t):e.createElement(t)}var e=navigator.userAgent,t=e.indexOf("MSIE")!==-1||e.indexOf("Trident")!==-1?document.documentMode:undefined,n=parseFloat(e.split("Firefox/")[1]||e.split("Minefield/")[1])||undefined,r=e.indexOf("Opera")!==-1,i=parseFloat(e.split("Chrome/")[1])||undefined,s=e.indexOf("Safari")!==-1&&!i,o=parseFloat(e.split("WebKit/")[1])||undefined,u=e.indexOf("Android")!==-1,a=e.indexOf("iPad")!==-1,f=e.indexOf("iPhone")!==-1,l=a||f,c=navigator.platform.indexOf("Mac")!==-1,h=navigator.platform.indexOf("Win")!==-1,p=navigator.platform.indexOf("Linux")!==-1,d=h?"\r\n":"\n",m="http://www.w3.org/1999/xhtml";return{formatMessage:v,createElement:g,isIE:t,isFirefox:n,isOpera:r,isChrome:i,isSafari:s,isWebkit:o,isAndroid:u,isIPad:a,isIPhone:f,isIOS:l,isMac:c,isWindows:h,isLinux:p,platformDelimiter:d}}),define("orion/webui/littlelib",[],function(){function e(e,t){return t||(t=document),t.querySelector(e)}function t(e,t){return t||(t=document),t.querySelectorAll(e)}function n(e,n){return Array.prototype.slice.call(t(e,n))}function r(e){var t=e;return typeof e=="string"&&(t=document.getElementById(e)),t}function i(e,t){if(!e||!t)return!1;if(e===t)return!0;var n=e.compareDocumentPosition(t);return Boolean(n&16)}function s(e){var t=e.getBoundingClientRect();return{left:t.left+document.body.scrollLeft,top:t.top+document.body.scrollTop,width:t.width,height:t.height}}function o(e){while(e.hasChildNodes()){var t=e.firstChild;e.removeChild(t)}}function u(e){if(e.tabIndex>=0)return e;if(e.hasChildNodes())for(var t=0;t<e.childNodes.length;t++){var n=u(e.childNodes[t]);if(n)return n}return null}function a(e){if(e.tabIndex>=0)return e;if(e.hasChildNodes())for(var t=e.childNodes.length-1;t>=0;t--){var n=a(e.childNodes[t]);if(n)return n}return null}function l(e,t){if(e.nodeType===3){var n=f.exec(e.nodeValue);n&&n.length>1&&t(e,n)}if(e.hasChildNodes())for(var r=0;r<e.childNodes.length;r++)l(e.childNodes[r],t)}function c(e,t){l(e,function(e,n){var r=t[n[1]]||n[1];e.parentNode.replaceChild(document.createTextNode(r),e)})}function h(e,t){l(e,function(e,n){var r=t[n[1]];if(r){var i=document.createRange(),s=n.index;i.setStart(e,s),i.setEnd(e,s+n[0].length),i.deleteContents(),i.insertNode(r)}})}function d(e,t){p.length===0&&document.addEventListener("click",function(e){var t=[];for(var n=0;n<p.length;n++){var r=p[n].excludeNodes,s=p[n].dismiss,o=!1,u,a=r.every(function(t){if(t){o=document.compareDocumentPosition(document,t)!==1;if(o&&i(t,e.target))return u=t,!1}return!0});if(a){try{s()}catch(f){typeof console!="undefined"&&console&&console.error(f&&f.message)}o=document.compareDocumentPosition(document,u)!==1}o&&t.push(p[n])}p=t},!0),p.push({excludeNodes:e,dismiss:t})}function v(e){window.document.all&&(e.keyCode=0),e.preventDefault&&(e.preventDefault(),e.stopPropagation())}var f=/\$\{([^\}]+)\}/,p=[],m={BKSPC:8,TAB:9,ENTER:13,ESCAPE:27,SPACE:32,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DEL:46};return{$:e,$$:t,$$array:n,node:r,contains:i,bounds:s,empty:o,firstTabbable:u,lastTabbable:a,stop:v,processTextNodes:c,processDOMNodes:h,addAutoDismiss:d,KEY:m}}),define("orion/webui/dropdown",["require","orion/webui/littlelib"],function(e,t){function n(e){this._init(e)}return n.prototype={_init:function(e){this._dropdownNode=t.node(e.dropdown);if(!this._dropdownNode)throw"no dom node for dropdown found";this._triggerNode=t.$(".dropdownTrigger",this._dropdownNode.parentNode);if(!this._triggerNode)throw"no dom node for dropdown trigger found";this._populate=e.populate,this._selectionClass=e.selectionClass;var n=this;this._triggerNode.addEventListener("click",function(e){n.toggle()&&t.stop(e)},!1),this._triggerNode.tagName.toLowerCase()==="span"&&this._triggerNode.addEventListener("keydown",function(e){if(e.keyCode===t.KEY.ENTER||e.keyCode===t.KEY.SPACE)n.toggle(),t.stop(e)},!1),this._dropdownNode.addEventListener("keydown",this._dropdownKeyDown.bind(this),!1)},toggle:function(e){return this._triggerNode.classList.contains("dropdownTriggerOpen")?this.close():this.open()},open:function(){this._populate&&(this.empty(),this._populate(this._dropdownNode));var e=this.getItems();if(e.length>0){if(!this._hookedAutoDismiss){var n=t.$$(".dropdownSubMenu",this._dropdownNode);t.addAutoDismiss([this._triggerNode].concat(Array.prototype.slice.call(n)),this.close.bind(this)),this._hookedAutoDismiss=!0}return this._triggerNode.classList.add("dropdownTriggerOpen"),this._selectionClass&&this._triggerNode.classList.add(this._selectionClass),this._dropdownNode.classList.add("dropdownMenuOpen"),this._positionDropdown(),e[0].focus(),!0}return!1},_positionDropdown:function(){this._dropdownNode.style.left="";var e=t.bounds(this._dropdownNode),n=t.bounds(document.body);if(e.left+e.width>n.left+n.width)if(this._triggerNode.classList.contains("dropdownMenuItem"))this._dropdownNode.style.left=-e.width+"px";else{var r=t.bounds(this._boundingNode(this._triggerNode)),i=t.bounds(this._triggerNode);this._dropdownNode.style.left=i.left-r.left-e.width+i.width+"px"}},_boundingNode:function(e){var t=window.getComputedStyle(e,null);if(t===null)return e;var n=t.getPropertyValue("position");return n==="absolute"||!e.parentNode||e===document.body?e:this._boundingNode(e.parentNode)},close:function(e){return this._triggerNode.classList.remove("dropdownTriggerOpen"),this._selectionClass&&this._triggerNode.classList.remove(this._selectionClass),this._dropdownNode.classList.remove("dropdownMenuOpen"),e&&this._triggerNode.focus(),!0},getItems:function(){var e=t.$$array("li:not(.dropdownSeparator) > .dropdownMenuItem",this._dropdownNode,!0),n=[],r=this;return e.forEach(function(e){e.parentNode.parentNode===r._dropdownNode&&n.push(e)}),n},empty:function(){var e=t.$$array("li",this._dropdownNode),n=this;e.forEach(function(e){e.parentNode===n._dropdownNode&&e.parentNode.removeChild(e)})},_dropdownKeyDown:function(e){if(e.keyCode===t.KEY.UP||e.keyCode===t.KEY.DOWN||e.keyCode===t.KEY.RIGHT||e.keyCode===t.KEY.ENTER||e.keyCode===t.KEY.LEFT){var n=this.getItems(),r=document.activeElement;if(n.length&&n.length>0&&r){var i=n.indexOf(r);i<0&&(i=n.indexOf(r.parentNode)),i>=0&&(e.keyCode===t.KEY.UP&&i>0?(i--,n[i].focus()):e.keyCode===t.KEY.DOWN&&i<n.length-1?(i++,n[i].focus()):e.keyCode===t.KEY.ENTER||e.keyCode===t.KEY.RIGHT?r.classList.contains("dropdownTrigger")&&r.dropdown&&r.dropdown.open():e.keyCode===t.KEY.LEFT&&r.parentNode.parentNode.classList.contains("dropdownMenuOpen")&&this.close(!0),t.stop(e))}}else e.keyCode===t.KEY.ESCAPE&&(this.close(!0),t.stop(e))}},n.prototype.constructor=n,{Dropdown:n}}),define("text",["module"],function(e){var t,n,r=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],i=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,s=/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,o=typeof location!="undefined"&&location.href,u=o&&location.protocol&&location.protocol.replace(/\:/,""),a=o&&location.hostname,f=o&&(location.port||undefined),l=[],c=e.config&&e.config()||{};t={version:"2.0.5",strip:function(e){if(e){e=e.replace(i,"");var t=e.match(s);t&&(e=t[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")},createXhr:c.createXhr||function(){var e,t,n;if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;if(typeof ActiveXObject!="undefined")for(t=0;t<3;t+=1){n=r[t];try{e=new ActiveXObject(n)}catch(i){}if(e){r=[n];break}}return e},parseName:function(e){var t,n,r,i=!1,s=e.indexOf("."),o=e.indexOf("./")===0||e.indexOf("../")===0;return s!==-1&&(!o||s>1)?(t=e.substring(0,s),n=e.substring(s+1,e.length)):t=e,r=n||t,s=r.indexOf("!"),s!==-1&&(i=r.substring(s+1)==="strip",r=r.substring(0,s),n?n=r:t=r),{moduleName:t,ext:n,strip:i}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(e,n,r,i){var s,o,u,a=t.xdRegExp.exec(e);return a?(s=a[2],o=a[3],o=o.split(":"),u=o[1],o=o[0],(!s||s===n)&&(!o||o.toLowerCase()===r.toLowerCase())&&(!u&&!o||u===i)):!0},finishLoad:function(e,n,r,i){r=n?t.strip(r):r,c.isBuild&&(l[e]=r),i(r)},load:function(e,n,r,i){if(i.isBuild&&!i.inlineText){r();return}c.isBuild=i.isBuild;var s=t.parseName(e),l=s.moduleName+(s.ext?"."+s.ext:""),h=n.toUrl(l),p=c.useXhr||t.useXhr;!o||p(h,u,a,f)?t.get(h,function(n){t.finishLoad(e,s.strip,n,r)},function(e){r.error&&r.error(e)}):n([l],function(e){t.finishLoad(s.moduleName+"."+s.ext,s.strip,e,r)})},write:function(e,n,r,i){if(l.hasOwnProperty(n)){var s=t.jsEscape(l[n]);r.asModule(e+"!"+n,"define(function () { return '"+s+"';});\n")}},writeFile:function(e,n,r,i,s){var o=t.parseName(n),u=o.ext?"."+o.ext:"",a=o.moduleName+u,f=r.toUrl(o.moduleName+u)+".js";t.load(a,r,function(n){var r=function(e){return i(f,e)};r.asModule=function(e,t){return i.asModule(e,f,t)},t.write(e,a,r,s)},s)}};if(c.env==="node"||!c.env&&typeof process!="undefined"&&process.versions&&!!process.versions.node)n=require.nodeRequire("fs"),t.get=function(e,t){var r=n.readFileSync(e,"utf8");r.indexOf("\ufeff")===0&&(r=r.substring(1)),t(r)};else if(c.env==="xhr"||!c.env&&t.createXhr())t.get=function(e,n,r,i){var s=t.createXhr(),o;s.open("GET",e,!0);if(i)for(o in i)i.hasOwnProperty(o)&&s.setRequestHeader(o.toLowerCase(),i[o]);c.onXhr&&c.onXhr(s,e),s.onreadystatechange=function(t){var i,o;s.readyState===4&&(i=s.status,i>399&&i<600?(o=new Error(e+" HTTP status: "+i),o.xhr=s,r(o)):n(s.responseText))},s.send(null)};else if(c.env==="rhino"||!c.env&&typeof Packages!="undefined"&&typeof java!="undefined")t.get=function(e,t){var n,r,i="utf-8",s=new java.io.File(e),o=java.lang.System.getProperty("line.separator"),u=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(s),i)),a="";try{n=new java.lang.StringBuffer,r=u.readLine(),r&&r.length()&&r.charAt(0)===65279&&(r=r.substring(1)),n.append(r);while((r=u.readLine())!==null)n.append(o),n.append(r);a=String(n.toString())}finally{u.close()}t(a)};return t}),define("text!orion/webui/dropdowntriggerbutton.html",[],function(){return'<button class="dropdownTrigger">${ButtonText}<span class="dropdownArrowDown core-sprite-downarrow"></span></button><ul class="dropdownMenu"></ul>'}),define("text!orion/webui/submenutriggerbutton.html",[],function(){return'<li class="dropdownSubMenu"><span class="dropdownTrigger dropdownMenuItem" role="menuitem" tabindex="0">${ButtonText}<span class="dropdownArrowRight core-sprite-closedarrow"></span></span><ul class="dropdownMenu"></ul></li>'}),define("text!orion/webui/checkedmenuitem.html",[],function(){return'<li><label class="dropdownMenuItem"><input class="checkedMenuItem" role="menuitem" type="checkbox" />${ItemText}</label></li>'}),define("orion/webui/tooltip",["require","orion/webui/littlelib"],function(e,t){function n(e){this._init(e)}return n.prototype={_init:function(e){this._node=t.node(e.node);if(!this._node)throw"no dom node for tooltip found";this._position=e.position||["right","above","below","left"],this._text=e.text,this._hideDelay=e.hideDelay===undefined?200:e.hideDelay,this._tailSize=e.tailSize||10,this._trigger=e.trigger||"mouseover",this._afterShowing=e.afterShowing,this._afterHiding=e.afterHiding;var n=this;if(this._trigger==="click")this._showDelay=0,this._node.addEventListener("click",function(e){e.target===n._node&&(n.show(),t.stop(e))},!1);else if(this._trigger==="mouseover"){this._showDelay=e.showDelay===undefined?500:e.showDelay;var r=["mouseout","click"];this._node.addEventListener("mouseover",function(e){t.contains(n._node,e.target)&&(n.show(),t.stop(e))},!1);for(var i=0;i<r.length;i++)this._node.addEventListener(r[i],function(e){t.contains(n._node,e.target)&&n.hide()},!1)}},_makeTipNode:function(){if(!this._tip){this._tip=document.createElement("span"),this._tip.classList.add("tooltipContainer"),this._tipInner=document.createElement("div"),this._tipInner.classList.add("tooltip");if(this._text){this._tipTextContent=document.createElement("div"),this._tipTextContent.classList.add("textContent"),this._tipInner.appendChild(this._tipTextContent);var e=document.createTextNode(this._text);this._tipTextContent.appendChild(e)}this._tip.appendChild(this._tipInner),document.body.appendChild(this._tip);var n=this;t.addAutoDismiss([this._tip,this._node],function(){n.hide()}),this._trigger==="mouseover"&&(this._tipInner.role="tooltip",this._tipInner.id="tooltip"+(new Date).getTime().toString(),this._node.setAttribute("aria-describedby",this._tipInner.id),this._tip.addEventListener("mouseover",function(e){n._timeout&&(window.clearTimeout(n._timeout),n._timeout=null),n._tip.addEventListener("mouseout",function(e){t.contains(n._tip,e.target)&&(n.hide(),t.stop(e))},!1)},!1))}return this._tip},_positionTip:function(e,n){this._makeTipNode(),e==="left"?this._tipInner.classList.add("left"):this._tipInner.classList.remove("left");var r=this._node,i;for(i=t.bounds(r);r&&!i.width&&!i.height;r=r.parentNode)i=t.bounds(r);var s=t.bounds(this._tipInner),o,u;switch(e){case"above":o=i.top-s.height-this._tailSize-1,u=i.left-this._tailSize;break;case"below":o=i.top+i.height+this._tailSize+1,u=i.left-this._tailSize;break;case"left":o=i.top-this._tailSize/2,u=i.left-s.width-this._tailSize-1;break;default:o=i.top-this._tailSize/2,u=i.left+i.width+this._tailSize+1}var a=t.bounds(document.documentElement);if(o+s.height>a.height){if(!n)return!1;o=a.height-s.height-1}if(u+s.width>a.width){if(!n)return!1;u=a.width-s.width-1}if(u<0){if(!n)return!1;u=4}if(o<0){if(!n)return!1;o=4}return this._tail||(this._tail=document.createElement("span"),this._tail.classList.add("tooltipTailFrom"+e),e==="above"||e==="left"?this._tip.appendChild(this._tail):this._tip.insertBefore(this._tail,this._tipInner),e==="left"&&(this._tail.style.left=s.width+"px")),this._tip.style.top=o+"px",this._tip.style.left=u+"px",!0},contentContainer:function(){return this._makeTipNode(),this._tipInner},show:function(){if(this._tip&&this._tip.classList.contains("tooltipShowing"))return;var e=this;this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null),this._timeout=window.setTimeout(function(){var t=!1,n=0;while(!t&&n<e._position.length)t=e._positionTip(e._position[n]),n++;t||e._positionTip(e._position[0],!0),e._tip.classList.add("tooltipShowing"),e._afterShowing&&e._afterShowing()},this._showDelay)},hide:function(e){this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null);if(!this._tip||!this._tip.classList.contains("tooltipShowing"))return;e===undefined&&(e=this._hideDelay);var t=this;this._timeout=window.setTimeout(function(){t._tip.classList.remove("tooltipShowing"),t._tip.removeAttribute("style"),t._afterHiding&&t._afterHiding()},e)},destroy:function(){this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null),this._tip&&(document.body.removeChild(this._tip),this._tip=null,this._tipInner=null,this._tipTextContent=null,this._tail=null)}},n.prototype.constructor=n,{Tooltip:n}}),define("orion/commands",["require","orion/util","orion/webui/littlelib","orion/webui/dropdown","text!orion/webui/dropdowntriggerbutton.html","text!orion/webui/submenutriggerbutton.html","text!orion/webui/checkedmenuitem.html","orion/webui/tooltip"],function(e,t,n,r,i,s,o,u){function l(e){a=e}function c(e){var t=e.invocation;if(t){var n=e.command;if(n.hrefCallback){var r=n.hrefCallback.call(t.handler||window,t);return r.then?r.then(function(e){window.open(e)}):window.open(r),!0}if(t.commandRegistry)return t.commandRegistry._invoke(t),!0;if(n.onClick||n.callback)return window.setTimeout(function(){(n.onClick||n.callback).call(t.handler||window,t)},0),!0}return!1}function h(e,t){for(var r in t)if(t[r]&&t[r].keyBinding&&t[r].command&&t[r].keyBinding.match(e)){var i=t[r],s=i.keyBinding;if(!s.domScope||n.contains(n.node(s.domScope),e.target))if(c(i)){n.stop(e);return}}}function p(e,t,n){t.classList.add("commandImage");var r;return e.imageClass?e.addImageClassToElement?t.classList.add(e.imageClass):(r=document.createElement("span"),t.appendChild(r),r.classList.add(e.spriteClass),r.classList.add(e.imageClass)):(r=new Image,r.alt=e.name,r.name=n,r.id=n,r.src=e.image,t.appendChild(r)),r}function d(e,t,s,o,u,a,f){e=n.node(e);if(!e)throw"no parent node was specified";var l=document.createRange();l.selectNode(e);var c=l.createContextualFragment(i);n.processTextNodes(c,{ButtonText:t}),e.appendChild(c);var h=e.lastChild,d=h.previousSibling;return o?d.classList.add(o):(d.classList.add("orionButton"),d.classList.add("commandButton")),u&&(a||(d.textContent="",d.setAttribute("aria-label",t)),p({spriteClass:"commandSprite",imageClass:u},d,t),d.classList.add("orionButton")),d.dropdown=new r.Dropdown({dropdown:h,populate:s,selectionClass:f}),h.dropdown=d.dropdown,{menuButton:d,menu:h,dropdown:d.dropdown}}function v(e,t,r,i){e=n.node(e);if(!e)throw"no parent node was specified";var s=document.createRange();s.selectNode(e);var u=s.createContextualFragment(o);n.processTextNodes(u,{ItemText:t}),e.appendChild(u);var a=e.lastChild,f=n.$(".checkedMenuItem",a);return f.checked=r,f.addEventListener("change",i,!1),f}function m(e,t,n,r,i,s,o){var a;s=s||!t.name&&t.hasImage();if(t.hrefCallback){a=document.createElement("a"),a.id=r,s&&t.hasImage()?p(t,a,r):(a.className="commandLink",a.appendChild(document.createTextNode(t.name)));var l=t.hrefCallback.call(n.handler,n);l.then?l.then(function(e){a.href=e}):l?a.href=l:a.href="#"}else{a=document.createElement("button"),a.className="orionButton";if(s)t.hasImage()?(p(t,a,r),t.name&&a.setAttribute("aria-label",t.name)):(a.classList.add("commandButton"),a.classList.add("commandMissingImageButton"),a.appendChild(document.createTextNode(t.name)));else{a.classList.add("commandButton");var c=document.createTextNode(t.name);a.appendChild(c)}var h=o||t.callback;h&&(t.onClick=h,a.addEventListener("click",function(e){h.call(n.handler,n)},!1))}if(e.nodeName.toLowerCase()==="ul"){var d=document.createElement("li");e.appendChild(d),e=d}else a.classList.add("commandMargins");return e.appendChild(a),t.tooltip&&(a.commandTooltip=new u.Tooltip({node:a,text:t.tooltip,position:["above","below","right","left"]})),i&&(f[t.id]={keyBinding:i,command:t,invocation:n}),a}function g(e,t,r,i,s){var o,a=e.dropdown;if(t.hrefCallback){o=document.createElement("a"),o.appendChild(document.createTextNode(t.name));var l=t.hrefCallback.call(r.handler,r);l.then?l.then(function(e){o.href=e}):l?o.href=l:o.href="#",o.addEventListener("keydown",function(e){(e.keyCode===n.KEY.ENTER||e.keyCode===n.KEY.SPACE)&&o.click()},!1)}else{o=document.createElement("span"),o.tabIndex=0,o.appendChild(document.createTextNode(t.name));var c=s||t.callback;c&&(t.onClick=c,o.addEventListener("click",function(e){a.close(!0),c.call(r.handler,r)},!1),o.addEventListener("keydown",function(e){if(e.keyCode===n.KEY.ENTER||e.keyCode===n.KEY.SPACE)e.preventDefault(),o.click()},!1))}t.tooltip&&(o.commandTooltip=new u.Tooltip({node:o,text:t.tooltip,position:["right","left","above","below"]})),o.className="dropdownMenuItem",o.role="menuitem";var h=document.createElement("li");return e.appendChild(h),h.appendChild(o),i&&(f[t.id]={keyBinding:i,command:t,invocation:r}),o}function y(e,t,n,r,i){this.commandRegistry=i,this.handler=e,this.items=t,this.userData=n,this.command=r,r.parameters&&(this.parameters=r.parameters.makeCopy()),this.id=r.id}function b(e){this._init(e)}var a=null,f={};return window.document.addEventListener("keydown",function(e){function n(e){if(t.isMac){if(e.metaKey&&!e.altKey)return!e.shiftKey&&!e.ctrlKey&&(e.keyCode===65||e.keyCode===67||e.keyCode===86||e.keyCode===88||e.keyCode===90)?!0:!1}else{if(e.ctrlKey&&!e.altKey)return!!e.shiftKey||e.keyCode!==65&&e.keyCode!==67&&e.keyCode!==86&&e.keyCode!==88&&e.keyCode!==90?!1:!0;if(e.altKey&&!e.ctrlKey)return!1}if(e["char"])return e["char"].length>0;if(e.charCode||e.keyCode){var n=e.charCode||e.keyCode;switch(n){case 8:case 9:case 13:case 46:return!0;default:return n>=32&&n<112||n>123}}return!1}e=e||window.event;if(n(e)){if(e.target.contentEditable==="true")return;var r=e.target.nodeName.toLowerCase();if(r==="input"){var i=e.target.type.toLowerCase();switch(i){case"text":case"password":case"search":case"color":case"date":case"datetime":case"datetime-local":case"email":case"month":case"number":case"range":case"tel":case"time":case"url":case"week":return}}else if(r==="textarea")return}var s={};if(a){var o,u,l;u=Object.keys(f);for(o=0;o<u.length;o++)l=u[o],s[l]=f[l];var c=a();u=Object.keys(c);for(o=0;o<u.length;o++)l=u[o],s[l]=c[l]}else s=f;h(e,s)},!1),y.prototype={collectsParameters:function(){return this.commandRegistry&&this.commandRegistry.collectsParameters()},makeCopy:function(e){var t=new y(this.handler,this.items,this.userData,this.command,this.commandRegistry);return t.domNode=this.domNode,t.domParent=this.domParent,e?t.parameters=e.makeCopy():this.parameters&&(t.parameters=this.parameters.makeCopy()),t}},y.prototype.constructor=y,b.prototype={_init:function(t){this.id=t.id,this.name=t.name,this.tooltip=t.tooltip||t.name,this.callback=t.callback,this.hrefCallback=t.hrefCallback,this.choiceCallback=t.choiceCallback,this.image=t.image||e.toUrl("images/none.png"),this.imageClass=t.imageClass,this.addImageClassToElement=t.addImageClassToElement,this.selectionClass=t.selectionClass,this.spriteClass=t.spriteClass||"commandSprite",this.visibleWhen=t.visibleWhen,this.parameters=t.parameters},populateChoicesMenu:function(e,t,r,i,s){var o=this.getChoices(t,r,i);o.forEach(function(r){if(r.name){var i=document.createElement("li");e.appendChild(i);var o=document.createElement("span");o.tabIndex=0,o.role="menuitem",o.classList.add("dropdownMenuItem");var u=document.createTextNode(r.name);o.appendChild(u),i.appendChild(o),o.choice=r,o.addEventListener("click",function(e){e.target.choice&&e.target.choice.callback.call(e.target.choice,t)},!1),o.addEventListener("keydown",function(e){(e.keyCode===n.KEY.ENTER||e.keyCode===n.KEY.SPACE)&&e.target.choice&&e.target.choice.callback.call(e.target.choice,t)},!1)}else s._generateMenuSeparator(e)})},getChoices:function(e,t,n){return this.choiceCallback?this.choiceCallback.call(t,e,n):null},makeChoiceCallback:function(e,t){return function(n){e.callback&&e.callback.call(e,t,n)}},hasImage:function(){return this.imageClass||this.image!==e.toUrl("images/none.png")}},b.prototype.constructor=b,{Command:b,CommandInvocation:y,createDropdownMenu:d,createCheckedMenuItem:v,createCommandItem:m,createCommandMenuItem:g,executeBinding:c,setKeyBindingProvider:l,localKeyBindings:f,_testMethodProcessKey:h}}),define("orion/explorers/navigationUtils",[],function(){function n(e,n,r,i){if(t)return;if(!e)return;e.push({domNode:n}),n.tabIndex=-1,n.style.outline="none"}function r(e,t,r){if(!e)return;var i=e.getGridNavHolder(t,!0);i&&n(i,r)}function i(e,t){if(!e)return;for(var n=0;n<e.length;n++)if(e[n].domNode===t){e.splice(n,1);return}}var e=navigator.userAgent,t=e.indexOf("iPad")!==-1;return{addNavGrid:r,generateNavGrid:n,removeNavGrid:i}}),define("orion/PageUtil",[],function(){function t(){var e=window.location.href.split("#")[1];return e=e?"#"+e:"",e}function n(t){t=t||window.location.toString();var n={resource:""},r=t.indexOf("#");if(r!==-1){var i=t.substring(r+1);if(i.length!==0){var s=i.split(",");Object.defineProperty(n,"resourceRaw",{value:s[0]}),n.resource=decodeURIComponent(s[0]),n.resource.match(e)||(n.resource=encodeURI(n.resource).replace(/%5B/g,"[").replace(/%5D/g,"]"));for(var o=1;o<s.length;o++){var u=s[o],a=/([^=]*)(=?)(.*)/.exec(u),f=decodeURIComponent(a[1]||""),l=decodeURIComponent(a[3]||"");f!==""&&f!=="resource"&&(n[f]=l)}}}return n}function i(e,t){var n=e;if(e.indexOf("://")===-1){var i=document.createElement("a");i.href=e,n=i.href}var s=!1;return t?s=t.some(function(e){return(new RegExp("^"+e+":","i")).test(n)}):s=r.test(n),s?e:(console.log("Illegal URL Scheme: '"+e+"'"),"")}var e=/^(?:[a-zA-Z0-9-_.!~*'()#;,\/?:@&=+$\[\]]|%[0-9A-F][0-9A-F])*$/,r=new RegExp("^http[s]?","i");return{hash:t,matchResourceParameters:n,validateURLScheme:i}}),function(){function t(e,t,n,r,i,s){t[e]&&(n.push(e),(t[e]===!0||t[e]===1)&&r.push(i+e+"/"+s))}function n(e,t,n,r,i){var s=r+t+"/"+i;require._fileExists(e.toUrl(s+".js"))&&n.push(s)}function r(e,t,n){var i;for(i in t)t.hasOwnProperty(i)&&(!e.hasOwnProperty(i)||n)?e[i]=t[i]:typeof t[i]=="object"&&r(e[i],t[i],n)}var e=/(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/;define("i18n",["module"],function(i){var s=i.config?i.config():{};return{version:"2.0.1+",load:function(i,o,u,a){a=a||{},a.locale&&(s.locale=a.locale);var f,l=e.exec(i),c=l[1],h=l[4],p=l[5],d=h.split("-"),v=[],m={},g,y,b="";l[5]?(c=l[1],f=c+p):(f=i,p=l[4],h=s.locale,h||(h=s.locale=typeof navigator=="undefined"?"root":(navigator.language||navigator.userLanguage||"root").toLowerCase()),d=h.split("-"));if(a.isBuild){v.push(f),n(o,"root",v,c,p);for(g=0;g<d.length;g++)y=d[g],b+=(b?"-":"")+y,n(o,b,v,c,p);o(v,function(){u()})}else o([f],function(e){var n=[],i;t("root",e,n,v,c,p);for(g=0;g<d.length;g++)i=d[g],b+=(b?"-":"")+i,t(b,e,n,v,c,p);o(v,function(){var t,i,s;for(t=n.length-1;t>-1&&n[t];t--){s=n[t],i=e[s];if(i===!0||i===1)i=o(c+s+"/"+p);r(m,i)}u(m)})})}}})}(),define("orion/i18n",{load:function(e,t,n,r){t.specified&&t.specified("orion/bootstrap")?t(["orion/i18n!"+e],function(e){n(e)}):n({})}}),define("orion/nls/root/messages",{Navigator:"Navigator",Sites:"Sites",Shell:"Shell","Get Plugins":"Get Plugins",Global:"Global",Editor:"Editor","Filter bindings":"Filter bindings","Orion Editor":"Orion Editor","View on Site":"View on Site","View this file or folder on a web site hosted by Orion":"View this file or folder on a web site hosted by Orion","Show a list of all the keybindings on this page":"Show a list of all the keybindings on this page","Show Keys":"Show Keys","Hide or show the page banner and footer":"Hide or show the page banner and footer","Toggle banner and footer":"Toggle banner and footer","Choose a file by name and open an editor on it":"Choose a file by name and open an editor on it","Find File Named...":"Find File Named...","System Configuration Details":"System Configuration Details","System Config Tooltip":"Go to the System Configuration Details page","Background Operations":"Background Operations","Background Operations Tooltip":"Go to the Background Operations page","Operation status is unknown":"Operation status is unknown","Unknown item":"Unknown item","Can't search: no search service is available":"Can't search: no search service is available","could not find banner parent, id was ":"could not find banner parent, id was ",Related:"Related",Options:"Options",FAQ:"FAQ","Report a Bug":"Bugs","Privacy Policy":"Privacy","Terms of Use":"Terms","Copyright Agent":"Copyright","Orion Logo":"Orion Logo","Orion is in Beta. Please try it out but BEWARE your data may be lost.":"@buildLabel@","LOG: ":"LOG: ",View:"View","no parent":"no parent","no tree model":"no tree model","no renderer":"no renderer","could not find table row ":"could not find table row ","Resource is out of sync with the server. Do you want to save it anyway?":"Resource is out of sync with the server. Do you want to save it anyway?",Operations:"Operations","Operations running":"Operations running","Some operations finished with warning":"Some operations finished with warning","Some operations finished with error":"Some operations finished with error","no service registry":"no service registry",Tasks:"Tasks",Close:"Close","Expand all":"Expand all","Collapse all":"Collapse all",Search:"Search","Advanced search":"Advanced search",Submit:"Submit",More:"More","Saved searches":"Saved searches","Recent searches":"Recent searches","Regular expression":"Regular expression","Search options":"Search options","Global search":"Global search","Orion Home":"Orion Home","Close notification":"Close notification","Operations - Press spacebar to show current operations":"Operations - Press spacebar to show current operations","Type a keyword or wild card to search in root":"Type a keyword or wild card to search in root","Toggle side panel":"Toggle side panel","Open or close the side panel":"Open or close the side panel",Projects:"Projects","Toggle Sidebar":"Toggle Sidebar","Sample HTML5 Site":"Sample HTML5 Site","Generate an HTML5 'Hello World' website, including JavaScript, HTML, and CSS files.":"Generate an HTML5 'Hello World' website, including JavaScript, HTML, and CSS files.","Sample Orion Plugin":"Sample Orion Plugin","Generate a sample plugin for integrating with Orion.":"Generate a sample plugin for integrating with Orion.",Raw:"Raw","Open the raw file or folder in the browser":"Open the raw file or folder in the browser",OutlineProgress:"Getting outline for ${0} from ${1}",UnknownError:"An unknown error occurred.",UnknownWarning:"An unknown warning occurred."}),define("orion/nls/messages",["orion/i18n!orion/nls/messages","orion/nls/root/messages"],function(e,t){var n={root:t};return Object.keys(e).forEach(function(t){typeof n[t]=="undefined"&&(n[t]=e[t])}),n}),define("orion/uiUtils",["i18n!orion/nls/messages","orion/webui/littlelib"],function(e,t){function n(e){var n="",r=navigator.platform.indexOf("Mac")!==-1;e.mod1&&(r?n+="Cmd+":n+="Ctrl+"),e.mod2&&(n+="Shift+"),e.mod3&&(n+="Alt+"),e.mod4&&r&&(n+="Ctrl+");if(e.alphaKey)return n+e.alphaKey;if(e.type==="keypress")return n+e.keyCode;for(var i in t.KEY)if(typeof (t.KEY[i]==="number")&&t.KEY[i]===e.keyCode)return n+i;var s;switch(e.keyCode){case 59:s=e.mod2?":":";";break;case 61:s=e.mod2?"+":"=";break;case 188:s=e.mod2?"<":",";break;case 190:s=e.mod2?">":".";break;case 191:s=e.mod2?"?":"/";break;case 192:s=e.mod2?"~":"`";break;case 219:s=e.mod2?"{":"[";break;case 220:s=e.mod2?"|":"\\";break;case 221:s=e.mod2?"}":"]";break;case 222:s=e.mod2?'"':"'"}return s?n+s:e.keyCode>=112&&e.keyCode<=123?n+"F"+(e.keyCode-111):n+String.fromCharCode(e.keyCode)}function r(e){var t="",r=e.getKeys();for(var i=0;i<r.length;i++)i!==0&&(t+=" "),t+=n(r[i]);return t}function i(e,n,r,i,s,o,u,a,f){var l=!1,c=function(u){return function(a){if(l)return;var c=t.node(e),h=c.value;if(!c)return;if(u&&a.keyCode===t.KEY.ESCAPE){r&&(n.style.display="inline"),l=!0,c.parentNode.removeChild(c),o&&o();return}if(u&&a.keyCode!==t.KEY.ENTER)return;h.length===0||!f&&h===i?(r&&(n.style.display="inline"),l=!0):(s(h),r&&n.parentNode&&(n.style.display="inline"),l=!0),c.parentNode&&c.parentNode.removeChild(c),o&&o()}},h=document.createElement("input");h.id=e,h.value=i||"",n.parentNode.insertBefore(h,n.nextSibling),h.classList.add("userEditBoxPrompt"),r&&(n.style.display="none"),h.addEventListener("keydown",c(!0),!1),h.addEventListener("blur",c(!1),!1),window.setTimeout(function(){h.focus();if(i){var n=t.node(e),r=a?i.indexOf(a):-1;if(r>0)if(n.createTextRange){var s=n.createTextRange();s.collapse(!0),s.moveStart("character",0),s.moveEnd("character",r),s.select()}else n.setSelectionRange?n.setSelectionRange(0,r):n.selectionStart!==undefined&&(n.selectionStart=0,n.selectionEnd=r);else n.select()}},0)}function s(e){var t=window.navigator.platform.indexOf("Mac")!==-1;return t&&e.metaKey||!t&&e.ctrlKey}function o(e,t){t&&s(t)?window.open(e):window.location=e}function u(e,n){var r=document.createElement("button");return r.className="orionButton commandButton commandMargins",r.addEventListener("click",function(e){n(),t.stop(e)},!1),e&&r.appendChild(document.createTextNode(e)),r}function a(e,t,n){}function f(e){switch(e.tagName.toLowerCase()){case"button":case"fieldset":case"form":case"input":case"keygen":case"label":case"legend":case"meter":case"optgroup":case"output":case"progress":case"select":case"textarea":return!0}return!1}return{getUserKeyString:r,getUserText:i,openInNewWindow:s,followLink:o,createButton:u,createDropdownButton:a,isFormElement:f}}),define("orion/commandRegistry",["require","orion/commands","orion/explorers/navigationUtils","orion/PageUtil","orion/uiUtils","orion/webui/littlelib","orion/webui/dropdown","orion/webui/tooltip","text!orion/webui/checkedmenuitem.html","text!orion/webui/dropdowntriggerbutton.html","text!orion/webui/submenutriggerbutton.html"],function(e,t,n,r,i,s,o,u,a,f,l){function c(e){this._commandList={},this._contributionsByScopeId={},this._activeBindings={},this._urlBindings={},this._pendingBindings={},this._init(e),this._parameterCollector=null}function h(e,t){this.token=e,this.parameterName=t}function p(e,t,n,r,i){this.name=e,this.type=t,this.label=n,this.value=r,this.lines=i||1}function d(e,t,n){this._storeParameters(e),this._hasOptionalParameters=t&&t.hasOptionalParameters,this._options=t,this.optionsRequested=!1,this.getParameters=n,this.clientCollect=t&&t.clientCollect}return c.prototype={_init:function(e){this._selectionService=e.selection;var n=this;t.setKeyBindingProvider(function(){return n._activeBindings})},processURL:function(e){for(var t in this._urlBindings)if(this._urlBindings[t]&&this._urlBindings[t].urlBinding&&this._urlBindings[t].command){var n=this._urlBindings[t].urlBinding.match(e);if(n){var r=this._urlBindings[t],i=r.command,s=r.invocation;if(s&&s.parameters&&i.callback){s.parameters.setValue(n.parameterName,n.parameterValue);var o=this;window.setTimeout(function(){o._invoke(s)},0);return}}}},findCommand:function(e){return this._commandList[e]},runCommand:function(e,n,r,i){var s=this;if(n){var o=this._commandList[e],u=o&&(o.visibleWhen?o.visibleWhen(n):!0);u&&o.callback&&s._invoke(new t.CommandInvocation(r,n,null,o,s),i)}else{var a=this._urlBindings[e];a&&a.command&&a.command.callback&&s._invoke(a.invocation,i)}},getSelectionService:function(){return this._selectionService},setParameterCollector:function(e){this._parameterCollector=e},openParameterCollector:function(e,t,n){this._parameterCollector&&(this._parameterCollector.close(),this._parameterCollector.open(e,t,n))},confirm:function(e,t,n,r,i,s){var o=!1;if(this._parameterCollector&&!i){var u=this;this._parameterCollector.close();var a=this._parameterCollector.open(e,function(e,i){var s=document.createElement("span");s.classList.add("parameterPrompt"),s.textContent=t,e.appendChild(s);var a=document.createElement("button");a.addEventListener("click",function(e){o=!0,u._parameterCollector.close()},!1),i.appendChild(a),a.appendChild(document.createTextNode(n)),a.className="dismissButton";var f=document.createElement("button");return f.addEventListener("click",function(e){o=!1,u._parameterCollector.close()},!1),i.appendChild(f),f.appendChild(document.createTextNode(r)),f.className="dismissButton",a},function(){s(o)});if(a)return}o=window.confirm(t),s(o)},closeParameterCollector:function(){this._parameterCollector&&this._parameterCollector.close()},collectsParameters:function(){return this._parameterCollector},_invoke:function(e,t){return this._collectAndInvoke(e.makeCopy(t),!1)},_collectAndInvoke:function(e,t){if(e)if(this._parameterCollector&&e.parameters&&e.parameters.hasParameters()&&(t||e.parameters.shouldCollectParameters())){var n=!1;e.parameters.updateParameters(e);if(e.parameters.shouldCollectParameters()){n=this._parameterCollector.collectParameters(e);if(!n){var r=new u.Tooltip({node:e.domNode,trigger:"click",position:["below","right","above","left"]}),i=r.contentContainer();i.classList.add("parameterPopup");var s=window.document.activeElement,o=this._parameterCollector.getFillFunction(e,function(){s&&s.focus(),r.destroy()})(i);r.show(),window.setTimeout(function(){o.focus(),o.select()},0),n=!0}}n||e.command.callback.call(e.handler||window,e)}else e.command.callback.call(e.handler||window,e);else window.console.log("Client attempted to invoke command without an available (rendered) command invocation")},collectParameters:function(e){this._collectAndInvoke(e,!0)},showKeyBindings:function(e){function o(e){return function(){t.executeBinding(e)}}var n={},r,s,u=[];for(var a in this._activeBindings)s=this._activeBindings[a],s&&s.keyBinding&&s.command&&(s.command.name||s.command.tooltip)&&u.push(s);u.sort(function(e,t){var n=e.command.name||e.command.tooltip,r=t.command.name||t.command.tooltip;return n.localeCompare(r)});for(var f=0;f<u.length;f++)s=u[f],s.keyBinding.scopeName?(n[s.keyBinding.scopeName]||(n[s.keyBinding.scopeName]=[]),n[s.keyBinding.scopeName].push(s)):(r=i.getUserKeyString(s.keyBinding),e.createItem(r,s.command.name||s.command.tooltip,o(s)));for(var l in n)n[l].length&&n[l].length>0&&(e.createHeader(l),n[l].forEach(function(t){r=i.getUserKeyString(t.keyBinding),e.createItem(r,t.command.name||t.command.tooltip,o(t))}))},addCommand:function(e){this._commandList[e.id]=e;var t=this._pendingBindings[e.id];if(t){var n=this;t.forEach(function(t){n._addBinding(e,t.type,t.binding,t.bindingOnly)}),delete this._pendingBindings[e.id]}},addCommandGroup:function(e,t,n,r,i,s,o,u,a){this._contributionsByScopeId[e]||(this._contributionsByScopeId[e]={});var f=this._contributionsByScopeId[e];i&&(f=this._createEntryForPath(f,i)),f[t]?(r&&(f[t].title=r),n&&(f[t].position=n),o&&(f[t].imageClass=o),u&&(f[t].tooltip=u),a&&(f[t].selectionClass=a),f[t].emptyGroupMessage=s):(f[t]={title:r,position:n,emptyGroupMessage:s,imageClass:o,tooltip:u,selectionClass:a,children:{}},f.sortedContributions=null)},_createEntryForPath:function(e,t){if(t){var n=t.split("/");n.forEach(function(t){t.length>1&&(e[t]||(e[t]={position:0,children:{}}),e=e[t].children)})}return e},registerSelectionService:function(e,t){this._contributionsByScopeId[e]||(this._contributionsByScopeId[e]={}),this._contributionsByScopeId[e].localSelectionService=t},registerCommandContribution:function(e,t,n,r,i,s,o){this._contributionsByScopeId[e]||(this._contributionsByScopeId[e]={});var u=this._contributionsByScopeId[e];r&&(u=this._createEntryForPath(u,r)),u[t]={position:n};var a;s&&(a=this._commandList[t],a?this._addBinding(a,"key",s,i):this._addPendingBinding(t,"key",s,i)),o&&(a=this._commandList[t],a?this._addBinding(a,"url",o,i):this._addPendingBinding(t,"url",o,i)),u.sortedContributions=null},_addBinding:function(e,t,n,r){if(!e.id)throw new Error("No command id: "+e);t==="key"?this._activeBindings[e.id]={command:e,keyBinding:n,bindingOnly:r}:t==="url"&&(this._urlBindings[e.id]={command:e,urlBinding:n,bindingOnly:r})},_addPendingBinding:function(e,t,n,r){this._pendingBindings[e]=this._pendingBindings[e]||[],this._pendingBindings[e].push({type:t,binding:n,bindingOnly:r})},_checkForTrailingSeparator:function(e,t,n){var r;if(t==="tool"||t==="button"){r=e.childNodes.length>0?e.childNodes[e.childNodes.length-1]:null;if(r&&r.classList.contains("commandSeparator"))return n?(e.removeChild(r),!1):!0}if(t==="menu"){var i=s.$$array("li > *",e);if(i.length>0&&i[i.length-1].classList.contains("dropdownSeparator"))return r=i[i.length-1],n?(r.parentNode.parentNode.removeChild(r.parentNode),!1):!0}return!1},renderCommands:function(e,t,n,r,i,o,u){if(typeof e!="string")throw"a scope id for rendering must be specified";t=s.node(t);if(!t)throw"no parent";var a=this._contributionsByScopeId[e];if(!n&&a){var f=a.localSelectionService||this._selectionService,l=this;f&&f.getSelections(function(n){l.renderCommands(e,t,n,r,i,o)});return}a&&(this._render(this._contributionsByScopeId[e],t,n,r,i||"button",o,u),this._checkForTrailingSeparator(t,i,!0))},destroy:function(e){e=s.node(e);if(!e)throw"no parent";while(e.hasChildNodes()){var t=e.firstChild;t.commandTooltip&&t.commandTooltip.destroy(),t.emptyGroupTooltip&&t.emptyGroupTooltip.destroy(),this.destroy(t),e.removeChild(t)}},_render:function(e,r,i,s,o,a,f){var l=e.sortedContributions;if(!l){l=[];var c=!1;for(var h in e)if(Object.prototype.hasOwnProperty.call(e,h)){var p=e[h];p&&typeof p.position=="number"&&(p.id=h,l.push(p),c=!0)}c&&(l.sort(function(e,t){return e.position-t.position}),e.sortedContributions=l)}var d=0,v=this;l.forEach(function(e){var l,c;e.imageClass||(e.imageClass=null);if(e.children&&Object.getOwnPropertyNames(e.children).length>0){var h=e.children,p;if(o==="tool"||o==="button")if(e.title)p=v._createDropdownMenu(r,e.title,null,null,e.imageClass,e.tooltip,e.selectionClass),f&&n.generateNavGrid(f,p.menuButton),window.setTimeout(function(){v._render(e.children,p.menu,i,s,"menu",a,f),v._checkForTrailingSeparator(p.menu,"menu",!0),p.menu.childNodes.length===0?e.emptyGroupMessage?p.menuButton.emptyGroupTooltip||(p.menuButton.emptyGroupTooltip=new u.Tooltip({node:p.menuButton,text:e.emptyGroupMessage,trigger:"click",position:["below","right","above","left"]})):(f&&n.removeNavGrid(f,p.menuButton),p.menu.parentNode&&p.menu.parentNode.removeChild(p.menu),p.destroyButton&&p.destroyButton.parentNode&&p.destroyButton.parentNode.removeChild(p.destroyButton)):p.menuButton.style.visibility="visible"},0);else{var m;r.childNodes.length>0&&!v._checkForTrailingSeparator(r,o)&&(m=v.generateSeparatorImage(r)),v._render(h,r,i,s,o,a,f);if(r.childNodes.length>0){var g=r.childNodes[r.childNodes.length-1];g!==m&&(m=v.generateSeparatorImage(r))}}else if(e.title){var y=v._createDropdownMenu(r,e.title,!0,null,null,e.imageClass);y&&(v._render(h,y.menu,i,s,"menu",a,f),y.menu.childNodes.length===0&&y.destroyButton&&r.removeChild(y.destroyButton))}else r.childNodes.length>0&&v._generateMenuSeparator(r),v._render(h,r,i,s,o,a,f),v._generateMenuSeparator(r)}else{var b=v._commandList[e.id],w=b?!0:!1,E=null,S=null;if(b){c=new t.CommandInvocation(s,i,a,b,v),c.domParent=r;var x=w&&(b.visibleWhen?b.visibleWhen(i):!0);v._activeBindings[b.id]&&v._activeBindings[b.id].keyBinding&&(E=v._activeBindings[b.id],x?E.invocation=c:E.invocation=null,E.bindingOnly&&(w=!1)),v._urlBindings[b.id]&&v._urlBindings[b.id].urlBinding&&(S=v._urlBindings[b.id],x?S.invocation=c:S.invocation=null,S.bindingOnly&&(w=!1)),w=w&&x}if(w)if(b.choiceCallback){var T,N,C;o==="tool"||o==="button"?(T=r,C=!1,r.nodeName.toLowerCase()==="ul"?(T=document.createElement("li"),r.appendChild(T)):N="commandMargins"):(T=r,C=!0);var k=function(e){b.populateChoicesMenu(e,i,s,a,v)};v._createDropdownMenu(T,b.name,C,k.bind(b),b.imageClass,b.tooltip||b.title,b.selectionClass)}else{c.handler=c.handler||this,c.domParent=r;var L,A=function(e){v._invoke(c)};o==="menu"?L=t.createCommandMenuItem(r,b,c,null,A):(l=o+b.id+d,L=t.createCommandItem(r,b,c,l,null,o==="tool",A)),n.generateNavGrid(f,L),c.domNode=L,d++}}})},_createDropdownMenu:function(e,n,r,i,a,f,c){e=s.node(e);if(!e||!s.contains(document.body,e))return null;var h,p,d,v=e;if(r){var m=document.createRange();m.selectNode(e);var g=m.createContextualFragment(l);s.processTextNodes(g,{ButtonText:n}),e.appendChild(g),d=e.lastChild,p=d.lastChild,h=p.previousSibling,h.dropdown=new o.Dropdown({dropdown:p,populate:i}),p.dropdown=h.dropdown}else{e.nodeName.toLowerCase()==="ul"&&(v=document.createElement("li"),e.appendChild(v),d=v);var y=null;a&&(y="dropdownButtonWithIcon",f=f||n),f=a?f||n:f;var b=t.createDropdownMenu(v,n,i,y,a,!1,c);h=b.menuButton,p=b.menu,f&&(h.commandTooltip=new u.Tooltip({node:h,text:f,position:["above","below","right","left"]}))}return{menuButton:h,menu:p,dropdown:h.dropdown,destroyButton:d}},_generateMenuSeparator:function(e){if(!this._checkForTrailingSeparator(e,"menu")){var t=document.createElement("li");t.classList.add("dropdownSeparator");var n=document.createElement("span");n.classList.add("dropdownSeparator"),t.appendChild(n),e.appendChild(t)}},generateSeparatorImage:function(e){var t;return e.nodeName.toLowerCase()==="ul"?(t=document.createElement("li"),e.appendChild(t)):(t=document.createElement("span"),e.appendChild(t)),t.classList.add("core-sprite-sep"),t.classList.add("imageSprite"),t.classList.add("commandSeparator"),t}},c.prototype.constructor=c,h.prototype={match:function(e){var t=r.matchResourceParameters(e);return typeof t[this.token]!="undefined"?(this.parameterValue=t[this.token],this):null}},h.prototype.constructor=h,p.prototype={optionsRequested:function(){return this.optionsRequested}},p.prototype.constructor=p,d.prototype={_storeParameters:function(e){this.parameterTable=null;if(e){var t=this.parameterTable={};e.forEach(function(e){t[e.name]=e})}},updateParameters:function(e){typeof this.getParameters=="function"&&this._storeParameters(this.getParameters(e))},hasParameters:function(){return this.parameterTable!==null},shouldCollectParameters:function(){return!this.clientCollect&&this.hasParameters()},parameterNamed:function(e){return this.parameterTable[e]},valueFor:function(e){var t=this.parameterTable[e];return t?t.value:null},setValue:function(e,t){var n=this.parameterTable[e];n&&(n.value=t)},forEach:function(e){for(var t in this.parameterTable)this.parameterTable[t].type&&this.parameterTable[t].name&&e(this.parameterTable[t])},makeCopy:function(){var e=[];this.forEach(function(t){var n=new p(t.name,t.type,t.label,t.value,t.lines);e.push(n)});var t=new d(e,this._options,this.getParameters);return t.clientCollect=this.clientCollect,t},hasOptionalParameters:function(){return this._hasOptionalParameters}},d.prototype.constructor=d,{CommandRegistry:c,URLBinding:h,ParametersDescription:d,CommandParameter:p}}),function(e,t){typeof define=="function"&&define.amd?define("orion/Deferred",t):typeof exports=="object"?module.exports=t():(e.orion=e.orion||{},e.orion.Deferred=t())}(this,function(){function n(){var n;while(n=e.shift())n();t=!1}function r(r){e.push(r),t||(t=!0,setTimeout(n,0))}function i(e){return function(){e.apply(undefined,arguments)}}function s(){function f(){var r;while(r=o.shift()){var s=r.deferred,u=n==="fulfilled"?"resolve":"reject";if(typeof r[u]=="function")try{var a=r[u],f=a(t),l=f&&(typeof f=="object"||typeof f=="function")&&f.then;if(typeof l=="function")if(f===s.promise)s.reject(new TypeError);else{var c=f.cancel;typeof c=="function"?s._protected(e).parentCancel=c.bind(f):delete s._protected(e).parentCancel,l.call(f,i(s.resolve),i(s.reject),i(s.progress))}else s.resolve(f)}catch(h){s.reject(h)}else s[u](t)}}function l(e){delete a.parentCancel,n="rejected",t=e,o.length&&r(f)}function c(e){function h(e){return function(t){i||(i=!0,e(t))}}var i=!1;delete a.parentCancel;try{var p=e&&(typeof e=="object"||typeof e=="function")&&e.then;if(typeof p=="function")if(e===u)l(new TypeError);else{n="assumed";var d=e&&e.cancel;if(typeof d!="function"){var v=new s;e=v.promise;try{p(v.resolve,v.reject,v.progress)}catch(m){v.reject(m)}d=e.cancel,p=e.then}t=e,p.call(e,h(c),h(l)),a.parentCancel=d.bind(e)}else n="fulfilled",t=e,o.length&&r(f)}catch(g){h(l)(g)}}function h(){var e=a.parentCancel;if(e)delete a.parentCancel,e();else if(!n){var t=new Error("Cancel");t.name="Cancel",l(t)}}var t,n,o=[],u=this,a={};Object.defineProperty(this,"_protected",{value:function(t){if(t!==e)throw new Error("protected");return a}}),this.resolve=function(e){return n||c(e),u},this.reject=function(e){return n||l(e),u},this.progress=function(e){return n||o.forEach(function(t){if(t.progress)try{t.progress(e)}catch(n){}}),u.promise},this.cancel=function(){return a.parentCancel?setTimeout(h,0):h(),u},this.then=function(t,i,a){var l={resolve:t,reject:i,progress:a,deferred:new s};return o.push(l),l.deferred._protected(e).parentCancel=u.promise.cancel.bind(u),(n==="fulfilled"||n==="rejected")&&r(f),l.deferred.promise},this.promise={then:u.then,cancel:u.cancel}}var e=[],t=!1;return s.all=function(e,t){function u(e,t){i||(r[e]=t,--n===0&&o.resolve(r))}function a(e,n){if(!i){if(t)try{u(e,t(n));return}catch(r){n=r}o.reject(n)}}var n=e.length,r=[],i=!1,o=new s;return o.then(undefined,function(){i=!0,e.forEach(function(e){e.cancel&&e.cancel()})}),n===0?o.resolve(r):e.forEach(function(e,t){e.then(u.bind(undefined,t),a.bind(undefined,t))}),o.promise},s.when=function(e,t,n,r){var i,o;return e&&typeof e.then=="function"?i=e:(o=new s,o.resolve(e),i=o.promise),i.then(t,n,r)},s}),define("orion/compare/nls/root/messages",{"Copy current change from right to left":"Copy current change from right to left","Copy current change from left to right":"Copy current change from left to right","Switch to unified diff":"Switch to unified diff",Unified:"Unified","Switch to side by side diff":"Switch to side by side diff","Side by side":"Side by side","Generate link of the current diff":"Generate link of the current diff","Generate Link":"Generate Link","Next diff block":"Next diff block","Previous diff block":"Previous diff block","Next diff change":"Next diff change","Previous diff change":"Previous diff change","Copy the link URL:":"Copy the link URL:",Compare:"Compare","Open the compare page":"Open the compare page","fetching...":"fetching...","There are unsaved changes.":"There are unsaved changes.","ERROR: ":"ERROR: ","Compare...":"Compare...","files changed":" files changed",Location:"Location",Options:"Options","Sort by folders":"Sort by folders","Line 0 : Col 0":"Line 0 : Col 0","No Matching DiffService for location:":"No Matching DiffService for location:","${0} files compared. The two folders are identical.":"${0} files compared. The two folders are identical."}),define("orion/compare/nls/messages",["orion/i18n!orion/compare/nls/messages","orion/compare/nls/root/messages"],function(e,t){var n={root:t};return Object.keys(e).forEach(function(t){typeof n[t]=="undefined"&&(n[t]=e[t])}),n}),define("orion/compare/diffParser",[],function(){var e=e||{};return e.DiffParser=function(){function n(t,n){this._lineDelimiter=t?t:e?"\r\n":"\n",this._diffLineDelimiter=n?n:this._lineDelimiter,this._DEBUG=!1}var e=window.navigator.platform.indexOf("Win")!==-1,t="\\ No newline at end of file";return n.prototype={_init:function(){this._oFileContents=[],this._diffContents=[],this._oBlocks=[],this._nBlocks=[],this._hunkRanges=[],this._lastToken=" ",this._deltaMap=[],this._nFileContents=[],this._oNewLineAtEnd=!0,this._nNewLineAtEnd=!0,this._diffContentIndex=1},setLineDelim:function(e){this._lineDelimiter=e,this._diffLineDelimiter=e},getDiffArray:function(){return{array:this._diffContents,index:this._diffContentIndex}},parse:function(e,t,n,r){this._init();if(t==="")return{outPutFile:e,mapper:[]};this._oFileContents=e===""?[]:e.split(this._lineDelimiter),this._diffContents=t.split(this._diffLineDelimiter);var i=this._diffContents.length;this._hunkRanges=[];for(var s=0;s<i;s++){var o=this._parseHunkRange(s);o&&this._hunkRanges.push(o)}if(0===this._hunkRanges.length)return{outPutFile:e,mapper:[]};this._DEBUG&&(console.log("***Diff contents: \n"),this._diffContents.forEach(function(e){console.log(e)}),console.log("***Hunk ranges: \n"),console.log(JSON.stringify(this._hunkRanges)));for(var u=0;u<this._hunkRanges.length;u++)this._parseHunkBlock(u);return this._DEBUG&&(console.log("***Original Hunk range blocks: \n"),console.log(JSON.stringify(this._oBlocks)),console.log("***New Hunk range blocks: \n"),console.log(JSON.stringify(this._nBlocks))),this._buildMap(n),this._DEBUG&&(console.log("***New Line at end of file(original): \n"),console.log(JSON.stringify(this._oNewLineAtEnd)),console.log("***New Line at end of file(new): \n"),console.log(JSON.stringify(this._nNewLineAtEnd)),console.log("***Mapper: \n"),this._logMap(),console.log("***Total line number in original file: "+this._oFileContents.length)),r||this._buildNewFile(),this._DEBUG,{outPutFile:this._nFileContents.join(this._diffLineDelimiter),mapper:this._deltaMap}},_logMap:function(){for(var e=0;e<this._deltaMap.length;e++){console.log(JSON.stringify(this._deltaMap[e]));if(this._deltaMap[e][2]>0){console.log(" **Diff content on change/add: \n");for(var t=0;t<this._deltaMap[e][0];t++)console.log(" "+this._diffContents[this._deltaMap[e][2]+t-1])}}},_logNewFile:function(){for(var e=0;e<this._nFileContents.length;e++)console.log(this._nFileContents[e])},_createBlock:function(e,t,n,r){if(r===n&&e===" ")return;var i=[n,r-n,"s"];e==="-"?i[2]="r":e==="+"?i[2]="a":e==="c"&&(i[2]="c"),t.push(i)},_createMinusBlock:function(e,t,n){var r=this._oBlocks.length;r===0||e!==this._oBlocks[r-1][0]?(this._oBlocks.push([e===0?1:e,n]),this._nBlocks.push([t,0,-2])):this._oBlocks[r-1][1]=this._oBlocks[r-1][1]+n},_createPlusBlock:function(e,t,n,r){var i=this._nBlocks.length;i===0||t!==this._nBlocks[i-1][0]?(this._oBlocks.push([e===0?1:e,0]),this._nBlocks.push([t,n,r])):(this._nBlocks[i-1][1]=this._nBlocks[i-1][1]+n,this._nBlocks[i-1][2]=r)},_parseHunkBlock:function(e){var n=" ",r=this._hunkRanges[e][0]+1,i=e===this._hunkRanges.length-1?this._diffContents.length:this._hunkRanges[e+1][0],s=0,o=0,u=this._hunkRanges[e][1],a=this._hunkRanges[e][3],f=r;for(var l=r;l<i;l++){if(0===this._diffContents[l].length)continue;var c=this._diffContents[l][0];if(c==="\\")if(t===this._diffContents[l].substring(0,this._diffContents[l].length-1)||t===this._diffContents[l]){n==="-"?this._oNewLineAtEnd=!1:n===" "?(this._nNewLineAtEnd=!1,this._oNewLineAtEnd=!1):this._nNewLineAtEnd=!1,l>r&&this._diffContents[l-1][this._diffContents[l-1].length-1]==="\r"&&(this._diffContents[l-1]=this._diffContents[l-1].substring(0,this._diffContents[l-1].length-1));continue}switch(c){case"-":case"+":case" ":break;default:continue}if(n!==c){c==="+"&&(f=l);switch(n){case" ":u=this._hunkRanges[e][1]+s,a=this._hunkRanges[e][3]+o;break;case"-":this._createMinusBlock(u,a,this._hunkRanges[e][1]+s-u);break;case"+":this._createPlusBlock(u,a,this._hunkRanges[e][3]+o-a,f);break;default:}n=c}switch(c){case"-":s++;break;case"+":o++;break;case" ":s++,o++}}switch(n){case"-":this._createMinusBlock(u,a,this._hunkRanges[e][1]+s-u);break;case"+":this._createPlusBlock(u,a,this._hunkRanges[e][3]+o-a,f)}},_detectConflictes:function(e,t){if(e<0)return!1;var n=e+t;for(var r=e;r<n;r++){var i=this._diffContents[r];if(i.indexOf("<<<<<")>-1||i.indexOf(">>>>>")>-1)return!0}return!1},_buildMap:function(e){var t=this._oBlocks.length,n=this._oFileContents.length,r=0,i,s=1;for(var o=0;o<t;o++)i=this._oBlocks[o][0]-s,i>0&&(this._deltaMap.push([i,i,0]),r+=i),e&&this._detectConflictes(this._nBlocks[o][2],this._nBlocks[o][1])?this._deltaMap.push([this._nBlocks[o][1],this._oBlocks[o][1],this._nBlocks[o][2]+1,1]):this._deltaMap.push([this._nBlocks[o][1],this._oBlocks[o][1],this._nBlocks[o][2]+1]),r+=this._oBlocks[o][1],s=this._oBlocks[o][0]+this._oBlocks[o][1];0<n-s&&(this._deltaMap.push([n-s+1,n-s+1,0]),r+=n-s+1);if(r<n){i=n-r;var u=this._deltaMap[this._deltaMap.length-1];u[2]===0?(u[0]+=i,u[1]+=i):u[2]===-1?this._deltaMap.push([i,i,0]):this._nNewLineAtEnd===this._oNewLineAtEnd?this._deltaMap.push([i,i,0]):(this._nNewLineAtEnd&&(u[0]+=i),this._oNewLineAtEnd&&(u[1]+=i))}},_buildNewFile:function(){var e=1,t=!1,n=this._deltaMap.length,r,i;for(r=0;r<n;r++){t=!1;if(this._deltaMap[r][2]===0){for(i=0;i<this._deltaMap[r][0];i++)this._nFileContents.push(this._oFileContents[e+i-1]);t=!0}else if(this._deltaMap[r][2]>0)for(i=0;i<this._deltaMap[r][0];i++)this._nFileContents.push(this._diffContents[this._deltaMap[r][2]+i-1].substring(1));e+=this._deltaMap[r][1]}this._nNewLineAtEnd&&!t&&this._nFileContents.push("")},_parseHRangeBody:function(e,t){if(0<e.indexOf(",")){var n=e.split(","),r=parseInt(n[0],10),i=parseInt(n[1],10);t.push(r>=0?r:1),t.push(i>=0?i:1)}else{var s=parseInt(e,10);t.push(s>=0?s:1),t.push(1)}},_parseHunkRange:function(e){var t=this._diffContents[e];if(8>t.length)return null;var n=t.substring(0,2);if("@@"!==n)return null;var r=t.substring(2),i=r.indexOf("@@");if(i<0)return null;var s=r.substring(0,i),o=s.indexOf("-"),u=s.indexOf("+");if(o<0||u<0)return null;var a,f=[e];return o<u?(a=s.substring(o+1).split("+"),this._parseHRangeBody(a[0],f),this._parseHRangeBody(a[1],f)):(a=s.substring(u+1).split("-"),this._parseHRangeBody(a[1],f),this._parseHRangeBody(a[0],f)),f}},n}(),e}),define("orion/URITemplate",[],function(){function r(e){this._text=e}function i(e){return e.replace("%25","%")}function s(e,t){if(t==="U")return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()});if(t==="U+R")return encodeURI(e).replace(/%5B/g,"[").replace(/%5D/g,"]").replace(n,i);if(t==="U+R-,")return encodeURI(e).replace(/%5B/g,"[").replace(/%5D/g,"]").replace(/,/g,"%2C");throw new Error("Unknown allowed character set: "+t)}function o(e,t,n){var r=[];for(var i=0;i<e.length;i++)typeof e[i]!="undefined"&&r.push(s(e[i],t));return r.join(n)}function u(e,t,n,r){var i=Object.keys(e),o=[];for(var u=0;u<i.length;u++)typeof e[i[u]]!="undefined"&&o.push(s(i[u],t)+n+s(e[i[u]],t));return o.join(r)}function a(e){var n=[],r=e.split(",");for(var i=0;i<r.length;i++){var s=r[i].match(t);if(s===null)throw new Error("Bad VarSpec: "+e);n.push({name:s[1],explode:!!s[2],prefix:s[3]?parseInt(s[3],10):-1})}return n}function f(t){if(t.length===0)throw new Error("Invalid Expression: 0 length expression");this._operator=e[t[0]],this._operator?t=t.substring(1):this._operator=e.NUL,this._varSpecList=a(t)}function l(e){var t=[],n=0,i=e.indexOf("{",n);while(i!==-1){t.push(new r(e.substring(n,i)));var s=e.indexOf("}",i+1);if(s===-1)throw new Error("Invalid template: "+e);t.push(new f(e.substring(i+1,s))),n=s+1,i=e.indexOf("{",n)}return t.push(new r(e.substring(n))),t}function c(e){this._templateComponents=l(e)}var e={NUL:{first:"",sep:",",named:!1,ifemp:"",allow:"U"},"+":{first:"",sep:",",named:!1,ifemp:"",allow:"U+R"},".":{first:".",sep:",",named:!1,ifemp:"",allow:"U"},"/":{first:"/",sep:"/",named:!1,ifemp:"",allow:"U"},";":{first:";",sep:";",named:!0,ifemp:"",allow:"U"},"?":{first:"?",sep:"&",named:!0,ifemp:"=",allow:"U"},"&":{first:"&",sep:"&",named:!0,ifemp:"=",allow:"U"},"#":{first:"#",sep:",",named:!1,ifemp:"",allow:"U+R"},",":{first:"",sep:",",named:!1,ifemp:"",allow:"U+R-,"}},t=/^((?:(?:[a-zA-Z0-9_])|(?:%[0-9A-F][0-9A-F]))(?:(?:[a-zA-Z0-9_.])|(?:%[0-9A-F][0-9A-F]))*)(?:(\*)|:([0-9]+))?$/,n=/%25[0-9A-F][0-9A-F]/g;return r.prototype={expand:function(e){return encodeURI(this._text)}},f.prototype={expand:function(e){var t=[];for(var n=0;n<this._varSpecList.length;n++){var r=this._varSpecList[n],i=r.name,a=e[i],f=typeof a;if(f!=="undefined"&&a!==null){var l=t.length===0?this._operator.first:this._operator.sep;if(f==="string")this._operator.named&&(l+=s(i,"U+R"),l+=a.length===0?this._operator.ifemp:"="),r.prefix!==-1&&r.prefix<a.length&&(a=a.substring(0,r.prefix)),l+=s(a,this._operator.allow);else if(Array.isArray(a))r.explode?l+=o(a,this._operator.allow,this._operator.sep):(this._operator.named&&(l+=s(i,"U+R"),l+=a.length===0?this._operator.ifemp:"="),l+=o(a,this._operator.allow,","));else{if(f!=="object")throw new Error("bad param type: "+i+" : "+f);r.explode?l+=u(a,this._operator.allow,"=",this._operator.sep):(this._operator.named&&(l+=s(i,"U+R"),l+=Object.keys(a).length===0?this._operator.ifemp:"="),l+=u(a,this._operator.allow,",",","))}t.push(l)}}return t.join("")}},c.prototype={expand:function(e){var t=[];for(var n=0;n<this._templateComponents.length;n++)t.push(this._templateComponents[n].expand(e));return t.join("")}},c}),define("orion/compare/compareUtils",["orion/URITemplate"],function(e){var t=t||{};return t.compareUtils=t.compareUtils||{},t.compareUtils.lookUpMapper=function(e,t,n){var r=0;for(var i=0;i<e.length;i++){var s=e[i][t];s===0&&(s=1);if(n>=r&&n<r+s)return{mapperIndex:i,startFrom:r};if(i===e.length-1)break;r+=e[i][t]}return{mapperIndex:e.length-1,startFrom:r}},t.compareUtils.lookUpLineIndex=function(e,t,n){if(n===0)return 0;var r=0;for(var i=0;i<n;i++)r+=e[i][t];return r},t.compareUtils.updateMapper=function(e,n,r,i,s){if(i===s)return;if(i>0||s>0){var o=t.compareUtils.lookUpMapper(e,n,r);if(o.mapperIndex<0)return;if(i>0){var u=i,a=r-o.startFrom;for(var f=o.mapperIndex;f<e.length;f++){var l=e[f][n]-a;if(u<=l){e[f][n]-=u;break}e[f][n]-=l,u-=l,a=0}}s>0&&(e[o.mapperIndex][n]+=s)}},t.compareUtils.overlapMapper=function(e,t,n,r,i){var s=n+e[t]-1;return s<n&&(s=n),i<r&&(i=r),s<r||i<n?!1:!0},t.compareUtils.findFirstDiff=function(e,n,r,i){var s=0,o=null;for(var u=0;u<e.length;u++){if(s>i)break;if(t.compareUtils.overlapMapper(e[u],n,s,r,i)){o={mapperIndex:u,startFrom:s};if(e[u][2]!==0)break}s+=e[u][n]}return o},t.compareUtils.matchMapper=function(e,n,r,i){if(e.length===0)return r;var s=r+Math.round((i-r)/3),o=t.compareUtils.findFirstDiff(e,n,r,i),u=e[o.mapperIndex][n]===0?o.startFrom:o.startFrom+e[o.mapperIndex][n]-1,a=t.compareUtils.lookUpLineIndex(e,1-n,o.mapperIndex),f=o.startFrom-r;if(e[o.mapperIndex][2]===0)return a-f;if(s>=o.startFrom&&s<=u)return a-Math.round((i-r)/3);if(s<o.startFrom)return a-f;var l=e[o.mapperIndex][1-n]===0?a:a+e[o.mapperIndex][1-n]-1;return l-(u-r)},t.compareUtils.getMapperLineCount=function(e){var t=0;for(var n=0;n<e.length;n++)t+=Math.max(e[n][0],e[n][1]);return t},t.compareUtils.getAnnotationIndex=function(e,t){for(var n=0;n<e.length;n++)if(e[n][0]===t)return n;return-1},t.compareUtils.getAnnotationMapperIndex=function(e,t){return e[t][1]},t.compareUtils.getAnnotationIndexByMapper=function(e,t){for(var n=0;n<e.length;n++)if(e[n][1]===t)return{current:n,prev:n-1,next:n+1};return{current:-1,prev:-1,next:-1}},t.compareUtils.isMapperConflict=function(e,t){return t<0?!1:e[t][3]?e[t][3]===1:!1},t.compareUtils.mergeDiffBlocks=function(e,t,n,r,i,s){for(var o=0;o<t.length;o++){var u=t[o][0],a=t[o][1],f=n[a];if(f[0]>0){var l="";for(var c=0;c<f[0];c++){var h=r[f[2]-1+c];l=l+h.substring(i)+s}var p=e.getLineCount();u>=p&&(u=p-1);var d=e.getLineStart(u);e.setText(l,d,d)}}},t.compareUtils.generateCompareHref=function(t,n){var r=require.toUrl("compare/compare.html");n.conflict||(n.conflict=undefined),n.readonly||(n.readonly=undefined);var i=(new e(r+"#{,resource,params*}")).expand({resource:t,params:n});return i},t.compareUtils.generateCompareTreeHref=function(t,n){var r=require.toUrl("compare-tree/compare-tree.html"),i=(new e(r+"#{,resource,params*}")).expand({resource:t,params:n});return i},t.compareUtils}),define("orion/compare/compareRulers",["orion/compare/compareUtils"],function(e){var t=t||{};return t.CompareRuler=function(){function e(e,t,n){this._location=e||"left",this._overview=t||"page",this._rulerStyle=n,this._editor=null;var r=this;this._listener={onModelChanged:function(e){r._onModelChanged(e)}}}return e.prototype={setView:function(e){this._onModelChanged&&this._editor&&this._editor.removeEventListener("ModelChanged",this._listener.onModelChanged),this._editor=e,this._onModelChanged&&this._editor&&this._editor.addEventListener("ModelChanged",this._listener.onModelChanged)},getLocation:function(){return this._location},getOverview:function(e){return this._overview},getAnnotationModel:function(){return null},addAnnotationType:function(e){},isAnnotationTypeVisible:function(e){return!1},removeAnnotationType:function(e){},setAnnotationModel:function(e){},getAnnotations:function(e,t){var n=[];for(var r=e;r<t;r++){var i=this.getStyle(r);i&&(n[r]={html:this.getHTML(r),style:i})}return n},getWidestAnnotation:function(){return{html:this.getHTML(-1),style:this.getStyle(-1)}},getRulerStyle:function(){return this.getStyle(undefined)}},e}(),t.LineNumberCompareRuler=function(){function e(e,n,r,i,s,o){t.CompareRuler.call(this,r,"page",i),this._diffNavigator=e,this._oddStyle=s||{style:{backgroundColor:"white"}},this._evenStyle=o||{style:{backgroundColor:"white"}},this._numOfDigits=0,this._mapperColumnIndex=n}return e.prototype=new t.CompareRuler,e.prototype.getStyle=function(e){return e===undefined?this._rulerStyle:this._evenStyle},e.prototype.getHTML=function(e){var t=this._editor.getModel(),n=this._diffNavigator.getFeeder(this._mapperColumnIndex===0);if(!n)return"";if(e===-1)return t.getLineCount();if(n.getLineNumber){var r=n.getLineNumber(e);return r===-1?"":r+1}return e+1},e.prototype._onModelChanged=function(e){var t=e.start,n=this._editor.getModel(),r=n.getLineCount(),i=(r+"").length;if(this._numOfDigits!==i){this._numOfDigits=i;var s=n.getLineAtOffset(t);this._editor.redrawLines(s,r,this)}},e}(),t.CompareOverviewRuler=function(){function n(e,n,r,i){this._diffNavigator=r,this._onClick=i,t.CompareRuler.call(this,e,"document",n)}return n.prototype=new t.CompareRuler,n.prototype.getStyle=function(t){var n,r;if(t===undefined)n=this._rulerStyle||{},r=n.style||(n.style={}),r.lineHeight="1px",r.fontSize="1px",r.width="14px";else{t!==-1?n={styleClass:"annotationOverview breakpoint"}||{}:n={},r=n.style||(n.style={}),r.cursor="pointer",r.width="8px",r.left="2px";if(!(t>=0))return null;var i;if(!this._diffNavigator||!this._diffNavigator.getFeeder())return null;i=this._diffNavigator.getFeeder().getDiffBlocks();var s=e.getAnnotationIndex(i,t);if(s===-1)return null;var o=e.getAnnotationMapperIndex(i,s),u;u=this._diffNavigator.getMapper();var a=e.isMapperConflict(u,o);a&&(r.border="1px #FF0000 solid"),s===this._diffNavigator.getCurrentBlockIndex()&&(r.backgroundColor=a?"red":"blue");var f=this._diffNavigator.getFeeder().getDiffBlockH(s),l=this._diffNavigator.getFeeder().getOverviewLineCount();if(f<0)return null;var c=this._editor.getClientArea(),h=Math.floor(c.height*f/l);h<2&&(h=2),r.height=h+"px"}return n},n.prototype.setDiffNavigator=function(e){this._diffNavigator=e},n.prototype.getHTML=function(e){return" "},n.prototype.onClick=function(e,t){if(e===undefined)return;this._onClick(e,this)},n.prototype._onModelChanged=function(e){var t=this._editor.getModel(),n=t.getLineCount();n>0&&this._editor.redrawLines(0,1,this)},n}(),t.CompareCurveRuler=function(){function t(e){this._canvasDiv=e,this._mapper=undefined}return t.prototype={init:function(e,t,n,r){this._leftIniting=!0,this._rightIniting=!0,this._rightIniting=!0,this._mapper=e,this._leftEditor=t,this._rightEditor=n,this._leftTextView=t.getTextView(),this._rightTextView=n.getTextView(),this._diffNavigator=r,this.render()},matchPositionFrom:function(t){var n=t?this._leftTextView:this._rightTextView,r=t?this._rightTextView:this._leftTextView,i=n.getTopIndex(),s=n.getBottomIndex(),o=e.matchMapper(this._mapper,t?0:1,i,s);r.setTopIndex(o)},copyTo:function(e){if(!this._diffNavigator.iterator)return;var t=this._diffNavigator.iterator.cursor();if(t){var n;t.type==="word"?n=!t.copied&&!t.parent.copied:n=!t.copied;if(!n)return;var r=e?this._rightTextView.getText(t.oldA.start,t.oldA.end):this._leftTextView.getText(t.newA.start,t.newA.end),i=e?t.newA:t.oldA,s=e?this._leftTextView:this._rightTextView;s.setText(r,i.start,i.end),t.copied=!0}},render:function(){if(!this._mapper)return;var t=this._canvasDiv.getContext("2d");t.clearRect(0,0,this._canvasDiv.width,this._canvasDiv.height),t.strokeStyle="#AAAAAA",t.lineWidth=1,t.beginPath();var n=this._leftTextView.getTopIndex(),r=this._leftTextView.getBottomIndex(),i=this._rightTextView.getTopIndex(),s=this._rightTextView.getBottomIndex();this._leftLineH=this._leftTextView.getLineHeight(),this._rightLineH=this._rightTextView.getLineHeight();var o=0,u=0,a=!1;for(var f=0;f<this._mapper.length;f++){if(this._mapper[f][2]!==0)if(e.overlapMapper(this._mapper[f],0,o,n,r)||e.overlapMapper(this._mapper[f],1,u,i,s))this._renderCurve(f,o,u,this._canvasDiv,t,n,r,i,s),a=!0;else if(a)break;o+=this._mapper[f][0],u+=this._mapper[f][1]}t.stroke()},_renderCurve:function(e,t,n,r,i,s,o,u,a){var f=this._mapper[e],l=this._leftTextView.getLinePixel(t+f[0]/2)+f[0]%2*this._leftLineH/3-this._leftTextView.getTopPixel(),c=this._rightTextView.getLinePixel(n+f[1]/2)+f[1]%2*this._rightLineH/3-this._rightTextView.getTopPixel(),h=r.parentNode.clientWidth;if(e===this._diffNavigator.getCurrentMapperIndex()){i.stroke(),i.strokeStyle="#000",i.lineWidth=1,i.beginPath(),i.moveTo(0,l),i.bezierCurveTo(h/3,l,h*.666,c,h,c),i.stroke(),i.strokeStyle="#AAAAAA",i.lineWidth=1,i.beginPath();return}i.moveTo(0,l),i.bezierCurveTo(h/3,l,h*.666,c,h,c),i.stroke()},onChanged:function(t,n){var r=n?this._rightIniting:this._leftIniting;if(t.removedLineCount!==t.addedLineCount){var i=n?this._rightTextView:this._leftTextView;r||e.updateMapper(this._mapper,n?1:0,i.getModel().getLineAtOffset(t.start),t.removedLineCount,t.addedLineCount),(t.removedLineCount>0||t.addedLineCount>0)&&this.render()}return n?this._rightIniting=!1:this._leftIniting=!1,r}},t}(),t}),define("orion/editor/i18n",{load:function(e,t,n,r){t.specified&&t.specified("orion/bootstrap")?t(["orion/i18n!"+e],function(e){n(e)}):n({})}}),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",lineUp:"Line Up",lineDown:"Line Down",lineStart:"Line Start",lineEnd:"Line End",charPrevious:"Previous Character",charNext:"Next Character",pageUp:"Page Up",pageDown:"Page Down",scrollPageUp:"Scroll Page Up",scrollPageDown:"Scroll Page Down",scrollLineUp:"Scroll Line Up",scrollLineDown:"Scroll Line Down",wordPrevious:"Previous Word",wordNext:"Next Word",textStart:"Document Start",textEnd:"Document End",scrollTextStart:"Scroll Document Start",scrollTextEnd:"Scroll Document End",centerLine:"Center Line",selectLineUp:"Select Line Up",selectLineDown:"Select Line Down",selectWholeLineUp:" Select Whole Line Up",selectWholeLineDown:"Select Whole Line Down",selectLineStart:"Select Line Start",selectLineEnd:"Select Line End",selectCharPrevious:"Select Previous Character",selectCharNext:"Select Next Character",selectPageUp:"Select Page Up",selectPageDown:"Select Page Down",selectWordPrevious:"Select Previous Word",selectWordNext:"Select Next Word",selectTextStart:"Select Document Start",selectTextEnd:"Select Document End",deletePrevious:"Delete Previous Character",deleteNext:"Delete Next Character",deleteWordPrevious:"Delete Previous Word",deleteWordNext:"Delete Next Word",deleteLineStart:"Delete Line Start",deleteLineEnd:"Delete Line End",tab:"Insert Tab",enter:"Insert Line Delimiter",enterNoCursor:"Insert Line Delimiter",selectAll:"Select All",copy:"Copy",cut:"Cut",paste:"Paste",uppercase:"To Upper Case",lowercase:"To Lower Case",capitalize:"Capitalize",reversecase:"Reverse Case",toggleWrapMode:"Toggle Wrap Mode",toggleTabMode:"Toggle Tab Mode",toggleOverwriteMode:"Toggle Overwrite Mode",committerOnTime:"${0} on ${1}",emacs:"Emacs",exchangeMarkPoint:"Exchange Mark and Point",setMarkCommand:"Set Mark",clearMark:"Clear Mark",digitArgument:"Digit Argument ${0}",negativeArgument:"Negative Argument",Comment:"Comment","Flat outline":"Flat outline",incrementalFindStr:"Incremental find: ${0}",incrementalFindStrNotFound:"Incremental find: ${0} (not found)",incrementalFindReverseStr:"Reverse Incremental find: ${0}",incrementalFindReverseStrNotFound:"Reverse Incremental find: ${0} (not found)",find:"Find...",undo:"Undo",redo:"Redo",cancelMode:"Cancel Current Mode",findNext:"Find Next Occurrence",findPrevious:"Find Previous Occurrence",incrementalFind:"Incremental Find",incrementalFindReverse:"Incremental Find Reverse",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",trimTrailingWhitespaces:"Trim Trailing Whitespaces",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}",vi:"vi",vimove:"(Move)",viyank:"(Yank)",videlete:"(Delete)",vichange:"(Change)",viLeft:"${0} Left",viRight:"${0} Right",viUp:"${0} Up",viDown:"${0} Down",viw:"${0} Next Word",vib:"${0} Beginning of Word",viW:"${0} Next Word (ws stop)",viB:"${0} Beginning of Word (ws stop)",vie:"${0} End of Word",viE:"${0} End of Word (ws stop)",vi$:"${0} End of the line","vi^_":"${0} First non-blank Char Current Line","vi+":"${0} First Char Next Line","vi-":"${0} First Char Previous Line","vi|":"${0} nth Column in Line",viH:"${0} Top of Page",viM:"${0} Middle of Page",viL:"${0} Bottom of Page","vi/":"${0} Search Forward","vi?":"${0} Search Backward",vin:"${0} Next Search",viN:"${0} Previous Search",vif:"${0} Search Char Fwd",viF:"${0} Search Char Bckwd",vit:"${0} Search Before Char Fwd",viT:"${0} Search Before Char Bckwd","vi,":"${0} Repeat Reverse Char Search","vi;":"${0} Repeat Char Search",viG:"${0} Go to Line",viycd:"${0} Current Line",via:"Append After Cursor",viA:"Append to End of Line",vii:"Insert Before Cursor",viI:"Insert at Beginning of Line",viO:"Insert Line Above",vio:"Insert Line Below",viR:"Begin Overwriting Text",vis:"Substitute a Character",viS:"Substitute Entire Line",viC:"Change Text Until Line End",vip:"Paste After Char or Line",viP:"Paste Before Char or Line",viStar:"Search Word Under Cursor",replaceAll:"Replacing all...",replacedMatches:"Replaced ${0} matches",nothingReplaced:"Nothing replaced",notFound:"Not found"}),define("orion/editor/nls/messages",["orion/editor/i18n!orion/editor/nls/messages","orion/editor/nls/root/messages"],function(e,t){var n={root:t};for(var r in e)e.hasOwnProperty(r)&&typeof n[r]=="undefined"&&(n[r]=e[r]);return n}),define("orion/editor/eventTarget",[],function(){function e(){}return e.addMixin=function(t){var n=e.prototype;for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])},e.prototype={addEventListener:function(e,t,n){this._eventTypes||(this._eventTypes={});var r=this._eventTypes[e];r||(r=this._eventTypes[e]={level:0,listeners:[]});var i=r.listeners;i.push({listener:t,useCapture:n})},dispatchEvent:function(e){var t=e.type;this._dispatchEvent("pre"+t,e),this._dispatchEvent(t,e),this._dispatchEvent("post"+t,e)},_dispatchEvent:function(e,t){var n=this._eventTypes?this._eventTypes[e]:null;if(n){var r=n.listeners;try{n.level++;if(r)for(var i=0,s=r.length;i<s;i++)if(r[i]){var o=r[i].listener;typeof o=="function"?o.call(this,t):o.handleEvent&&typeof o.handleEvent=="function"&&o.handleEvent(t)}}finally{n.level--;if(n.compact&&n.level===0){for(var u=r.length-1;u>=0;u--)r[u]||r.splice(u,1);r.length===0&&delete this._eventTypes[e],n.compact=!1}}}},isListening:function(e){return this._eventTypes?this._eventTypes[e]!==undefined:!1},removeEventListener:function(e,t,n){if(!this._eventTypes)return;var r=this._eventTypes[e];if(r){var i=r.listeners;for(var s=0,o=i.length;s<o;s++){var u=i[s];if(u&&u.listener===t&&u.useCapture===n){r.level!==0?(i[s]=null,r.compact=!0):i.splice(s,1);break}}i.length===0&&delete this._eventTypes[e]}}},{EventTarget:e}}),define("orion/editor/textModel",["orion/editor/eventTarget","orion/util"],function(e,t){function n(e,t){this._lastLineIndex=-1,this._text=[""],this._lineOffsets=[0],this.setText(e),this.setLineDelimiter(t)}return n.prototype={find:function(e){this._text.length>1&&(this._text=[this._text.join("")]);var t=e.string,n=e.regex,r=t,i=e.caseInsensitive;!n&&t&&(r=t.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&"),i&&(r=r.replace(/[iI\u0130\u0131]/g,"[Ii\u0130\u0131]")));var s=null,o;if(r){var u=e.reverse,a=e.wrap,f=e.wholeWord,l=e.start||0,c=e.end,h=c!==null&&c!==undefined,p="";p.indexOf("g")===-1&&(p+="g"),i&&p.indexOf("i")===-1&&(p+="i"),f&&(r="\\b"+r+"\\b");var d=this._text[0],v,m,g=0;if(h){var y=l<c?l:c,b=l<c?c:l;d=d.substring(y,b),g=y}var w=new RegExp(r,p);u?o=function(){var e=null;w.lastIndex=0;for(;;){m=w.lastIndex,v=w.exec(d);if(m===w.lastIndex)return null;if(!v)break;if(v.index+g<l)e={start:v.index+g,end:w.lastIndex+g};else{if(!a||e)break;l=d.length+g,e={start:v.index+g,end:w.lastIndex+g}}}return e&&(l=e.start),e}:(h||(w.lastIndex=l),o=function(){for(;;){m=w.lastIndex,v=w.exec(d);if(m===w.lastIndex)return null;if(v)return{start:v.index+g,end:w.lastIndex+g};if(m!==0&&a)continue;break}return null}),s=o()}return{next:function(){var e=s;return e&&(s=o()),e},hasNext:function(){return s!==null}}},getCharCount:function(){var e=0;for(var t=0;t<this._text.length;t++)e+=this._text[t].length;return e},getLine:function(e,t){var n=this.getLineCount();if(0<=e&&e<n){var r=this._lineOffsets[e];if(e+1<n){var i=this.getText(r,this._lineOffsets[e+1]);if(t)return i;var s=i.length,o;while((o=i.charCodeAt(s-1))===10||o===13)s--;return i.substring(0,s)}return this.getText(r)}return null},getLineAtOffset:function(e){var t=this.getCharCount();if(0<=e&&e<=t){var n=this.getLineCount();if(e===t)return n-1;var r,i,s=this._lastLineIndex;if(0<=s&&s<n){r=this._lineOffsets[s],i=s+1<n?this._lineOffsets[s+1]:t;if(r<=e&&e<i)return s}var o=n,u=-1;while(o-u>1){s=Math.floor((o+u)/2),r=this._lineOffsets[s],i=s+1<n?this._lineOffsets[s+1]:t;if(e<=r)o=s;else{if(e<i){o=s;break}u=s}}return this._lastLineIndex=o,o}return-1},getLineCount:function(){return this._lineOffsets.length},getLineDelimiter:function(){return this._lineDelimiter},getLineEnd:function(e,t){var n=this.getLineCount();if(0<=e&&e<n){if(e+1<n){var r=this._lineOffsets[e+1];if(t)return r;var i=this.getText(Math.max(this._lineOffsets[e],r-2),r),s=i.length,o;while((o=i.charCodeAt(s-1))===10||o===13)s--;return r-(i.length-s)}return this.getCharCount()}return-1},getLineStart:function(e){return 0<=e&&e<this.getLineCount()?this._lineOffsets[e]:-1},getText:function(e,t){e===undefined&&(e=0),t===undefined&&(t=this.getCharCount());if(e===t)return"";var n=0,r=0,i;while(r<this._text.length){i=this._text[r].length;if(e<=n+i)break;n+=i,r++}var s=n,o=r;while(r<this._text.length){i=this._text[r].length;if(t<=n+i)break;n+=i,r++}var u=n,a=r;if(o===a)return this._text[o].substring(e-s,t-u);var f=this._text[o].substring(e-s),l=this._text[a].substring(0,t-u);return f+this._text.slice(o+1,a).join("")+l},onChanging:function(e){return this.dispatchEvent(e)},onChanged:function(e){return this.dispatchEvent(e)},setLineDelimiter:function(e,n){e==="auto"&&(e=undefined,this.getLineCount()>1&&(e=this.getText(this.getLineEnd(0),this.getLineEnd(0,!0)))),this._lineDelimiter=e?e:t.platformDelimiter;if(n){var r=this.getLineCount();if(r>1){var i=new Array(r);for(var s=0;s<r;s++)i[s]=this.getLine(s);this.setText(i.join(this._lineDelimiter))}}},setText:function(e,t,n){e===undefined&&(e=""),t===undefined&&(t=0),n===undefined&&(n=this.getCharCount());if(t===n&&e==="")return;var r=this.getLineAtOffset(t),i=this.getLineAtOffset(n),s=t,o=n-t,u=i-r,a=e.length,f=0,l=this.getLineCount(),c=0,h=0,p=0,d=[];for(;;){c!==-1&&c<=p&&(c=e.indexOf("\r",p)),h!==-1&&h<=p&&(h=e.indexOf("\n",p));if(h===-1&&c===-1)break;c!==-1&&h!==-1?c+1===h?p=h+1:p=(c<h?c:h)+1:c!==-1?p=c+1:p=h+1,d.push(t+p),f++}var v={type:"Changing",text:e,start:s,removedCharCount:o,addedCharCount:a,removedLineCount:u,addedLineCount:f};this.onChanging(v);if(d.length===0){var m=this.getLineStart(r),g;i+1<l?g=this.getLineStart(i+1):g=this.getCharCount(),t!==m&&(e=this.getText(m,t)+e,t=m),n!==g&&(e+=this.getText(n,g),n=g)}var y=a-o;for(var b=r+u+1;b<l;b++)this._lineOffsets[b]+=y;var w=5e4,E=w,S;if(d.length<E)S=[r+1,u].concat(d),Array.prototype.splice.apply(this._lineOffsets,S);else{p=r+1,this._lineOffsets.splice(p,u);for(var x=0;x<d.length;x+=E)S=[p,0].concat(d.slice(x,Math.min(d.length,x+E))),Array.prototype.splice.apply(this._lineOffsets,S),p+=E}var T=0,N=0,C;while(N<this._text.length){C=this._text[N].length;if(t<=T+C)break;T+=C,N++}var k=T,L=N;while(N<this._text.length){C=this._text[N].length;if(n<=T+C)break;T+=C,N++}var A=T,O=N,M=this._text[L],_=this._text[O],D=M.substring(0,t-k),P=_.substring(n-A),H=[L,O-L+1];D&&H.push(D),e&&H.push(e),P&&H.push(P),Array.prototype.splice.apply(this._text,H),this._text.length===0&&(this._text=[""]);var B={type:"Changed",start:s,removedCharCount:o,addedCharCount:a,removedLineCount:u,addedLineCount:f};this.onChanged(B)}},e.EventTarget.addMixin(n.prototype),{TextModel:n}}),define("orion/keyBinding",["orion/util"],function(e){function t(e,t,n,r,i,s){this.type=s||"keydown",typeof e=="string"&&this.type==="keydown"?this.keyCode=e.toUpperCase().charCodeAt(0):this.keyCode=e,this.mod1=t!==undefined&&t!==null?t:!1,this.mod2=n!==undefined&&n!==null?n:!1,this.mod3=r!==undefined&&r!==null?r:!1,this.mod4=i!==undefined&&i!==null?i:!1}function n(e){this.keys=e}return t.prototype={getKeys:function(){return[this]},match:function(t,n){if(n!==undefined){if(n!==0)return!1}else if(t instanceof Array){if(t.length>1)return!1;t=t[0]}if(t.type!==this.type)return!1;if(this.keyCode===t.keyCode||this.keyCode===String.fromCharCode(e.isOpera?t.which:t.charCode!==undefined?t.charCode:t.keyCode)){var r=e.isMac?t.metaKey:t.ctrlKey;return this.mod1!==r?!1:this.type==="keydown"&&this.mod2!==t.shiftKey?!1:this.mod3!==t.altKey?!1:e.isMac&&this.mod4!==t.ctrlKey?!1:!0}return!1},equals:function(e){return e?this.keyCode!==e.keyCode?!1:this.mod1!==e.mod1?!1:this.mod2!==e.mod2?!1:this.mod3!==e.mod3?!1:this.mod4!==e.mod4?!1:this.type!==e.type?!1:!0:!1}},n.prototype={getKeys:function(){return this.keys.slice(0)},match:function(e,t){var n=this.keys;if(t!==undefined)return t>n.length?!1:n[t].match(e)?t===n.length-1?!0:t+1:!1;e instanceof Array||(e=[e]);if(e.length>n.length)return!1;var r;for(r=0;r<e.length;r++)if(!n[r].match(e[r]))return!1;return r===n.length?!0:r},equals:function(e){if(!e.keys)return!1;if(e.keys.length!==this.keys.length)return!1;for(var t=0;t<e.keys.length;t++)if(!e.keys[t].equals(this.keys[t]))return!1;return!0}},{KeyBinding:t,KeyStroke:t,KeySequence:n}}),define("orion/editor/keyModes",["orion/keyBinding","orion/util"],function(e,t){function n(e){if(!e)return;this._view=e,this._keyBindings=this.createKeyBindings(),this._keyBindingIndex=0}function r(e){n.call(this,e)}return n.prototype={createKeyBindings:function(){return[]},getKeyBindings:function(e){var t=[],n=this._keyBindings;for(var r=0;r<n.length;r++)n[r].actionID===e&&t.push(n[r].keyBinding);return t},getView:function(){return this._view},isActive:function(){return this._view.getKeyModes().indexOf(this)!==-1},match:function(e){if(e.type==="keydown")switch(e.keyCode){case 16:case 17:case 18:case 91:return undefined}var t=this._keyBindingIndex,n=this._matchingKeyBindings||this._keyBindings,r=[];for(var i=0;i<n.length;i++){var s=n[i],o=s.keyBinding,u=o.match(e,t);if(u===!0)return this._keyBindingIndex=0,this._matchingKeyBindings=null,s.actionID;typeof u=="number"&&r.push(s)}return r.length!==0?(this._keyBindingIndex++,this._matchingKeyBindings=r,"noop"):(this._keyBindingIndex=0,this._matchingKeyBindings=null,undefined)},setKeyBinding:function(e,t){var n=this._keyBindings;for(var r=0;r<n.length;r++){var i=n[r];if(i.keyBinding.equals(e)){t?i.actionID=t:i.predefined?i.actionID="noop":n.splice(r,1);return}}t&&n.push({keyBinding:e,actionID:t})},setView:function(e){this._view=e}},r.prototype=new n,r.prototype.createKeyBindings=function(){var n=e.KeyBinding,r=[];r.push({actionID:"lineUp",keyBinding:new n(38),predefined:!0}),r.push({actionID:"lineDown",keyBinding:new n(40),predefined:!0}),r.push({actionID:"charPrevious",keyBinding:new n(37),predefined:!0}),r.push({actionID:"charNext",keyBinding:new n(39),predefined:!0}),t.isMac?(r.push({actionID:"scrollPageUp",keyBinding:new n(33),predefined:!0}),r.push({actionID:"scrollPageDown",keyBinding:new n(34),predefined:!0}),r.push({actionID:"pageUp",keyBinding:new n(33,null,null,!0),predefined:!0}),r.push({actionID:"pageDown",keyBinding:new n(34,null,null,!0),predefined:!0}),r.push({actionID:"lineStart",keyBinding:new n(37,!0),predefined:!0}),r.push({actionID:"lineEnd",keyBinding:new n(39,!0),predefined:!0}),r.push({actionID:"wordPrevious",keyBinding:new n(37,null,null,!0),predefined:!0}),r.push({actionID:"wordNext",keyBinding:new n(39,null,null,!0),predefined:!0}),r.push({actionID:"scrollTextStart",keyBinding:new n(36),predefined:!0}),r.push({actionID:"scrollTextEnd",keyBinding:new n(35),predefined:!0}),r.push({actionID:"textStart",keyBinding:new n(38,!0),predefined:!0}),r.push({actionID:"textEnd",keyBinding:new n(40,!0),predefined:!0}),r.push({actionID:"scrollPageUp",keyBinding:new n(38,null,null,null,!0),predefined:!0}),r.push({actionID:"scrollPageDown",keyBinding:new n(40,null,null,null,!0),predefined:!0}),r.push({actionID:"lineStart",keyBinding:new n(37,null,null,null,!0),predefined:!0}),r.push({actionID:"lineEnd",keyBinding:new n(39,null,null,null,!0),predefined:!0}),r.push({actionID:"lineStart",keyBinding:new n(38,null,null,!0),predefined:!0}),r.push({actionID:"lineEnd",keyBinding:new n(40,null,null,!0),predefined:!0})):(r.push({actionID:"pageUp",keyBinding:new n(33),predefined:!0}),r.push({actionID:"pageDown",keyBinding:new n(34),predefined:!0}),r.push({actionID:"lineStart",keyBinding:new n(36),predefined:!0}),r.push({actionID:"lineEnd",keyBinding:new n(35),predefined:!0}),r.push({actionID:"wordPrevious",keyBinding:new n(37,!0),predefined:!0}),r.push({actionID:"wordNext",keyBinding:new n(39,!0),predefined:!0}),r.push({actionID:"textStart",keyBinding:new n(36,!0),predefined:!0}),r.push({actionID:"textEnd",keyBinding:new n(35,!0),predefined:!0})),t.isFirefox&&t.isLinux&&(r.push({actionID:"lineUp",keyBinding:new n(38,!0),predefined:!0}),r.push({actionID:"lineDown",keyBinding:new n(40,!0),predefined:!0})),t.isWindows&&(r.push({actionID:"scrollLineUp",keyBinding:new n(38,!0),predefined:!0}),r.push({actionID:"scrollLineDown",keyBinding:new n(40,!0),predefined:!0})),r.push({actionID:"selectLineUp",keyBinding:new n(38,null,!0),predefined:!0}),r.push({actionID:"selectLineDown",keyBinding:new n(40,null,!0),predefined:!0}),r.push({actionID:"selectCharPrevious",keyBinding:new n(37,null,!0),predefined:!0}),r.push({actionID:"selectCharNext",keyBinding:new n(39,null,!0),predefined:!0}),r.push({actionID:"selectPageUp",keyBinding:new n(33,null,!0),predefined:!0}),r.push({actionID:"selectPageDown",keyBinding:new n(34,null,!0),predefined:!0}),t.isMac?(r.push({actionID:"selectLineStart",keyBinding:new n(37,!0,!0),predefined:!0}),r.push({actionID:"selectLineEnd",keyBinding:new n(39,!0,!0),predefined:!0}),r.push({actionID:"selectWordPrevious",keyBinding:new n(37,null,!0,!0),predefined:!0}),r.push({actionID:"selectWordNext",keyBinding:new n(39,null,!0,!0),predefined:!0}),r.push({actionID:"selectTextStart",keyBinding:new n(36,null,!0),predefined:!0}),r.push({actionID:"selectTextEnd",keyBinding:new n(35,null,!0),predefined:!0}),r.push({actionID:"selectTextStart",keyBinding:new n(38,!0,!0),predefined:!0}),r.push({actionID:"selectTextEnd",keyBinding:new n(40,!0,!0),predefined:!0}),r.push({actionID:"selectLineStart",keyBinding:new n(37,null,!0,null,!0),predefined:!0}),r.push({actionID:"selectLineEnd",keyBinding:new n(39,null,!0,null,!0),predefined:!0}),r.push({actionID:"selectLineStart",keyBinding:new n(38,null,!0,!0),predefined:!0}),r.push({actionID:"selectLineEnd",keyBinding:new n(40,null,!0,!0),predefined:!0})):(t.isLinux&&(r.push({actionID:"selectWholeLineUp",keyBinding:new n(38,!0,!0),predefined:!0}),r.push({actionID:"selectWholeLineDown",keyBinding:new n(40,!0,!0),predefined:!0})),r.push({actionID:"selectLineStart",keyBinding:new n(36,null,!0),predefined:!0}),r.push({actionID:"selectLineEnd",keyBinding:new n(35,null,!0),predefined:!0}),r.push({actionID:"selectWordPrevious",keyBinding:new n(37,!0,!0),predefined:!0}),r.push({actionID:"selectWordNext",keyBinding:new n(39,!0,!0),predefined:!0}),r.push({actionID:"selectTextStart",keyBinding:new n(36,!0,!0),predefined:!0}),r.push({actionID:"selectTextEnd",keyBinding:new n(35,!0,!0),predefined:!0})),r.push({actionID:"undo",keyBinding:new e.KeyBinding("z",!0),predefined:!0}),t.isMac?r.push({actionID:"redo",keyBinding:new e.KeyBinding("z",!0,!0),predefined:!0}):r.push({actionID:"redo",keyBinding:new e.KeyBinding("y",!0),predefined:!0}),r.push({actionID:"deletePrevious",keyBinding:new n(8),predefined:!0}),r.push({actionID:"deletePrevious",keyBinding:new n(8,null,!0),predefined:!0}),r.push({actionID:"deleteNext",keyBinding:new n(46),predefined:!0}),r.push({actionID:"deleteWordPrevious",keyBinding:new n(8,!0),predefined:!0}),r.push({actionID:"deleteWordPrevious",keyBinding:new n(8,!0,!0),predefined:!0}),r.push({actionID:"deleteWordNext",keyBinding:new n(46,!0),predefined:!0}),r.push({actionID:"tab",keyBinding:new n(9),predefined:!0}),r.push({actionID:"shiftTab",keyBinding:new n(9,null,!0),predefined:!0}),r.push({actionID:"enter",keyBinding:new n(13),predefined:!0}),r.push({actionID:"enter",keyBinding:new n(13,null,!0),predefined:!0}),r.push({actionID:"selectAll",keyBinding:new n("a",!0),predefined:!0}),r.push({actionID:"toggleTabMode",keyBinding:new n("m",!0),predefined:!0}),t.isMac&&(r.push({actionID:"deleteNext",keyBinding:new n(46,null,!0),predefined:!0}),r.push({actionID:"deleteWordPrevious",keyBinding:new n(8,null,null,!0),predefined:!0}),r.push({actionID:"deleteWordNext",keyBinding:new n(46,null,null,!0),predefined:!0})),r.push({actionID:"toggleWrapMode",keyBinding:new e.KeyBinding("w",!0,!1,!0)}),r.push({actionID:"toggleOverwriteMode",keyBinding:new e.KeyBinding(45)});if(!t.isFirefox){var i=t.isMac&&t.isChrome;r.push({actionID:"noop",keyBinding:new n("u",!i,!1,!1,i),predefined:!0}),r.push({actionID:"noop",keyBinding:new n("i",!i,!1,!1,i),predefined:!0}),r.push({actionID:"noop",keyBinding:new n("b",!i,!1,!1,i),predefined:!0})}return t.isFirefox&&(r.push({actionID:"copy",keyBinding:new n(45,!0),predefined:!0}),r.push({actionID:"paste",keyBinding:new n(45,null,!0),predefined:!0}),r.push({actionID:"cut",keyBinding:new n(46,null,!0),predefined:!0})),t.isMac&&(r.push({actionID:"lineStart",keyBinding:new n("a",!1,!1,!1,!0),predefined:!0}),r.push({actionID:"lineEnd",keyBinding:new n("e",!1,!1,!1,!0),predefined:!0}),r.push({actionID:"lineUp",keyBinding:new n("p",!1,!1,!1,!0),predefined:!0}),r.push({actionID:"lineDown",keyBinding:new n("n",!1,!1,!1,!0),predefined:!0}),r.push({actionID:"charPrevious",keyBinding:new n("b",!1,!1,!1,!0),predefined:!0}),r.push({actionID:"charNext",keyBinding:new n("f",!1,!1,!1,!0),predefined:!0}),r.push({actionID:"deletePrevious",keyBinding:new n("h",!1,!1,!1,!0),predefined:!0}),r.push({actionID:"deleteNext",keyBinding:new n("d",!1,!1,!1,!0),predefined:!0}),r.push({actionID:"deleteLineEnd",keyBinding:new n("k",!1,!1,!1,!0),predefined:!0}),t.isFirefox?(r.push({actionID:"scrollPageDown",keyBinding:new n("v",!1,!1,!1,!0),predefined:!0}),r.push({actionID:"deleteLineStart",keyBinding:new n("u",!1,!1,!1,!0),predefined:!0}),r.push({actionID:"deleteWordPrevious",keyBinding:new n("w",!1,!1,!1,!0),predefined:!0})):(r.push({actionID:"pageDown",keyBinding:new n("v",!1,!1,!1,!0),predefined:!0}),r.push({actionID:"centerLine",keyBinding:new n("l",!1,!1,!1,!0),predefined:!0}),r.push({actionID:"enterNoCursor",keyBinding:new n("o",!1,!1,!1,!0),predefined:!0}))),r},{KeyMode:n,DefaultKeyMode:r}}),define("orion/editor/textTheme",["require","orion/editor/eventTarget","orion/util"],function(e,t,n){function s(e){e=e||{},this._document=e.document||document}var r="orion-theme-",i={};return s.getTheme=function(e){e=e||"default";var t=i[e];return t||(t=i[e]=new s),t},s.prototype={getThemeClass:function(){return this._themeClass},setThemeClass:function(e,t){var n=this,r=n._themeClass;n._themeClass=e,this._load(e,t,function(){n.onThemeChanged({type:"ThemeChanged",oldValue:r,newValue:n.getThemeClass()})})},onThemeChanged:function(e){return this.dispatchEvent(e)},buildStyleSheet:function(e,t){function r(t,r,i){r&&(n.push("."+e+" ."+t+" {"),n.push(" "+(i?"background-color":"color")+": "+r+";"),n.push("}"))}var n=[];return n.push(""),n.push("."+e+" {"),t.fontFamily&&n.push(" font-family: "+t.fontFamily+";"),t.fontSize&&n.push(" font-size: "+t.fontSize+";"),t.fontSize&&n.push(" color: "+t.text+";"),n.push("}"),n.push("."+e+".textview {"),t.background&&n.push(" background-color: "+t.background+";"),n.push("}"),r("ruler.annotations",t.annotationRuler,!0),r("ruler.lines",t.annotationRuler,!0),r("ruler.folding",t.annotationRuler,!0),r("ruler.overview",t.overviewRuler,!0),r("rulerLines",t.lineNumber,!1),r("rulerLines.even",t.lineNumberEven,!1),r("rulerLines.odd",t.lineNumberOdd,!1),r("annotationLine.currentLine",t.currentLine,!0),r("entity-name-tag",t.keyword,!1),r("entity-other-attribute-name",t.attribute,!1),r("string-quoted",t.string,!1),r("line_caret",t.currentLine,!0),r("token_keyword",t.keyword,!1),r("token_string",t.string,!1),r("token_singleline_comment",t.comment,!1),r("token_multiline_comment",t.comment,!1),r("token_doc_comment",t.comment,!1),r("token_doc_html_markup",t.comment,!1),n.join("\n")},_createStyle:function(e,t,i,s){var o=this._document,u=r+e,a=o.getElementById(u);if(a){if(s||a.firstChild.data===t)return;a.removeChild(a.firstChild),a.appendChild(o.createTextNode(t))}else{s?(a=n.createElement(o,"link"),a.rel="stylesheet",a.type="text/css",a.href=t,a.addEventListener("load",function(){i()})):(a=n.createElement(o,"style"),a.appendChild(o.createTextNode(t))),a.id=u;var f=o.getElementsByTagName("head")[0]||o.documentElement;f.appendChild(a)}s||i()},_load:function(t,n,r){if(!t){r();return}if(typeof n=="string"){this._createStyle(t,n,r);return}var i=n.href,s=".css";i.substring(i.length-s.length)!==s&&(i+=s);if(/^\//.test(i)||/[a-zA-Z0-9]+:\/\//i.test(i)||!e.toUrl)this._createStyle(t,i,r,!0);else{var o=this;e(["text!"+i],function(e){o._createStyle(t,e,r,!1)})}}},t.EventTarget.addMixin(s.prototype),{TextTheme:s}}),define("orion/editor/util",[],function(){function e(e,t,n,r){typeof e.addEventListener=="function"?e.addEventListener(t,n,r===!0):e.attachEvent("on"+t,n)}function t(e,t,n,r){typeof e.removeEventListener=="function"?e.removeEventListener(t,n,r===!0):e.detachEvent("on"+t,n)}function n(e,t){if(!t)return!1;if(!e.compareDocumentPosition){var n=t;while(n){if(e===n)return!0;n=n.parentNode}return!1}return e===t||(e.compareDocumentPosition(t)&16)!==0}return{contains:n,addEventListener:e,removeEventListener:t}}),define("orion/editor/textView",["i18n!orion/editor/nls/messages","orion/editor/textModel","orion/editor/keyModes","orion/editor/eventTarget","orion/editor/textTheme","orion/editor/util","orion/util"],function(e,t,n,r,i,s,o){function u(e){return e.defaultView||e.parentWindow}function l(e,t,n){if(n){t.className="";var r=t.attributes;for(var i=r.length;i-->0;)(!o.isIE||o.isIE>=9||o.isIE<9&&r[i].specified)&&t.removeAttribute(r[i].name)}if(!e)return;e.styleClass&&(t.className=e.styleClass);var s=e.style;if(s)for(var u in s)s.hasOwnProperty(u)&&(t.style[u]=s[u]);var a=e.attributes;if(a)for(var f in a)a.hasOwnProperty(f)&&t.setAttribute(f,a[f])}function c(e){return e instanceof Array?e.slice(0):e}function h(e,t){if(!e)return t;if(!t)return e;for(var n in t)t.hasOwnProperty(n)&&(e.hasOwnProperty(n)||(e[n]=t[n]));return e}function p(e,t){if(e===t)return!0;if(e&&!t||!e&&t)return!1;if(e&&e.constructor===String||t&&t.constructor===String)return!1;if(e instanceof Array||t instanceof Array){if(e instanceof Array&&t instanceof Array){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!p(e[n],t[n]))return!1;return!0}return!1}if(e instanceof Object&&t instanceof Object){var r;for(r in e)if(e.hasOwnProperty(r)){if(!t.hasOwnProperty(r))return!1;if(!p(e[r],t[r]))return!1}for(r in t)if(!e.hasOwnProperty(r))return!1;return!0}return!1}function d(e,t,n){var r=0,i=0,s=0,o=e.length;while(s<o){r!==-1&&r<=s&&(r=e.indexOf("\r",s)),i!==-1&&i<=s&&(i=e.indexOf("\n",s));var u=s,a;if(i===-1&&r===-1){t(e.substring(s));break}r!==-1&&i!==-1?r+1===i?(a=r,s=i+1):(a=r<i?r:i,s=(r<i?r:i)+1):r!==-1?(a=r,s=r+1):(a=i,s=i+1),t(e.substring(u,a)),n()}}function v(e){var t,n,r,i,s=u(e.ownerDocument);if(s.getComputedStyle){var o=s.getComputedStyle(e,null);t=o.getPropertyValue("border-left-width"),n=o.getPropertyValue("border-top-width"),r=o.getPropertyValue("border-right-width"),i=o.getPropertyValue("border-bottom-width")}else e.currentStyle&&(t=e.currentStyle.borderLeftWidth,n=e.currentStyle.borderTopWidth,r=e.currentStyle.borderRightWidth,i=e.currentStyle.borderBottomWidth);return{left:parseInt(t,10)||0,top:parseInt(n,10)||0,right:parseInt(r,10)||0,bottom:parseInt(i,10)||0}}function m(e){var t,n,r,i,s=u(e.ownerDocument);if(s.getComputedStyle){var o=s.getComputedStyle(e,null);t=o.getPropertyValue("padding-left"),n=o.getPropertyValue("padding-top"),r=o.getPropertyValue("padding-right"),i=o.getPropertyValue("padding-bottom")}else e.currentStyle&&(t=e.currentStyle.paddingLeft,n=e.currentStyle.paddingTop,r=e.currentStyle.paddingRight,i=e.currentStyle.paddingBottom);return{left:parseInt(t,10)||0,top:parseInt(n,10)||0,right:parseInt(r,10)||0,bottom:parseInt(i,10)||0}}function g(e){var t=e._trim;if(!t){t=m(e);var n=v(e);t.left+=n.left,t.top+=n.top,t.right+=n.right,t.bottom+=n.bottom,e._trim=t}return t}function b(e,t,n){this.start=e,this.end=t,this.caret=n}function w(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom}function E(e,t,n){this.view=e,this.lineIndex=t,this._lineDiv=n}function S(e){this._init(e||{})}var a=s.addEventListener,f=s.removeEventListener,y=function(){function e(e){this.options=e}return e.prototype.play=function(){function l(){u=u===-1?(new Date).getTime():u;var t=(new Date).getTime(),l=(t-u)/e;if(l<1){var c=n(l);a=i+c*o,r(a)}else r(s),f.stop()}var e=typeof this.options.duration=="number"?this.options.duration:350,t=typeof this.options.rate=="number"?this.options.rate:20,n=this.options.easing||this.defaultEasing,r=this.options.onAnimate||function(){},i=this.options.curve[0],s=this.options.curve[1],o=s-i,u=-1,a,f=this;this.interval=this.options.window.setInterval(l,t)},e.prototype.stop=function(){this.options.window.clearInterval(this.interval);var e=this.options.onEnd||function(){};e()},e.prototype.defaultEasing=function(e){return Math.sin(e*(Math.PI/2))},e}();return b.prototype={clone:function(){return new b(this.start,this.end,this.caret)},collapse:function(){this.caret?this.end=this.start:this.start=this.end},extend:function(e){this.caret?this.start=e:this.end=e;if(this.start>this.end){var t=this.start;this.start=this.end,this.end=t,this.caret=!this.caret}},setCaret:function(e){this.start=e,this.end=e,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(e){return this.caret===e.caret&&this.start===e.start&&this.end===e.end}},w.prototype={toString:function(){return"{l="+this.left+", t="+this.top+", r="+this.right+", b="+this.bottom+"}"}},E.prototype={create:function(e,t){if(this._lineDiv)return;var n=this._lineDiv=this._createLine(e,t,this.lineIndex);return n._line=this,n},_createLine:function(e,t,n){var r=this.view,i=r._model,s=i.getLine(n),u=i.getLineStart(n),a={type:"LineStyle",textView:r,lineIndex:n,lineText:s,lineStart:u};s.length<2e3&&r.onLineStyle(a);var f=t||o.createElement(e.ownerDocument,"div");if(!t||!p(t.viewStyle,a.style))l(a.style,f,t),t&&(t._trim=null),f.viewStyle=a.style,f.setAttribute("role","presentation");f.lineIndex=n;var c=[],h={tabOffset:0,ranges:c};this._createRanges(a.ranges,s,0,s.length,u,h);var d=" ";!r._fullSelection&&o.isIE<9&&(d="\ufeff"),o.isWebkit&&(d="\u200c");var v={text:d,style:r._metrics.largestFontStyle,ignoreChars:1};c.length===0||!c[c.length-1].style||c[c.length-1].style.tagName!=="div"?c.push(v):c.splice(c.length-1,0,v);var m,g,y,b,w,E,S=0,x=0,T,N,C;if(t){var k=t.modelChangedEvent;k&&(k.removedLineCount===0&&k.addedLineCount===0?(C=k.start-u,N=k.addedCharCount-k.removedCharCount):C=-1,t.modelChangedEvent=undefined),y=t.firstChild}for(var L=0;L<c.length;L++){v=c[L],w=v.text,S+=w.length,g=v.style;if(y){E=y.firstChild.data,b=y.viewStyle;if(E===w&&p(g,b)){x+=E.length,y._rectsCache=undefined,m=y=y.nextSibling;continue}while(y){if(C!==-1){var A=S;A>=C&&(A-=N);var O=y.firstChild.data,M=O?O.length:0;if(x+M>A)break;x+=M}T=y.nextSibling,f.removeChild(y),y=T}}m=this._createSpan(f,w,g,v.ignoreChars),y?f.insertBefore(m,y):f.appendChild(m),t&&(t.lineWidth=undefined)}if(t){var _=m?m.nextSibling:null;while(_)T=_.nextSibling,t.removeChild(_),_=T}else e.appendChild(f);return f},_createRanges:function(e,t,n,r,i,s){if(n>r)return;if(e)for(var o=0;o<e.length;o++){var u=e[o];if(u.end<i+n)continue;var a=Math.max(i+n,u.start)-i;if(a>r)break;var f=Math.min(i+r,u.end)-i;if(a<=f){a=Math.max(n,a),f=Math.min(r,f),n<a&&this._createRange(t,n,a,null,s);if(!u.style||!u.style.unmergeable)while(o+1<e.length&&e[o+1].start-i===f&&p(u.style,e[o+1].style))u=e[o+1],f=Math.min(i+r,u.end)-i,o++;this._createRange(t,a,f,u.style,s),n=f}}n<r&&this._createRange(t,n,r,null,s)},_createRange:function(e,t,n,r,i){if(t>n)return;var s=this.view._customTabSize,o;if(s&&s!==8){var u=e.indexOf(" ",t);while(u!==-1&&u<n){t<u&&(o={text:e.substring(t,u),style:r},i.ranges.push(o),i.tabOffset+=o.text.length);var a=s-i.tabOffset%s;if(a>0){var f="\u00a0";for(var l=1;l<a;l++)f+=" ";o={text:f,style:r,ignoreChars:a-1},i.ranges.push(o),i.tabOffset+=o.text.length}t=u+1;if(t===n)return;u=e.indexOf(" ",t)}}t<=n&&(o={text:e.substring(t,n),style:r},i.ranges.push(o),i.tabOffset+=o.text.length)},_createSpan:function(e,t,n,r){var i=this.view,s="span";n&&n.tagName&&(s=n.tagName.toLowerCase());var u=s==="a";u&&(e.hasLink=!0),u&&!i._linksVisible&&(s="span");var f=e.ownerDocument,c=o.createElement(e.ownerDocument,s);n&&n.html?(c.innerHTML=n.html,c.ignore=!0):n&&n.node?(c.appendChild(n.node),c.ignore=!0):c.appendChild(f.createTextNode(n&&n.text?n.text:t)),l(n,c);if(s==="a"){var h=i._getWindow();a(c,"click",function(e){return i._handleLinkClick(e?e:h.event)},!1)}return c.viewStyle=n,r&&(c.ignoreChars=r),c},_ensureCreated:function(){return this._lineDiv?this._lineDiv:this._createdDiv=this.create(this.view._clientDiv,null)},getBoundingClientRect:function(e,t){var n=this._ensureCreated(),r=this.view;if(e===undefined)return this._getLineBoundingClientRect(n,!0);var i=r._model,s=n.ownerDocument,a=this.lineIndex,f=null;if(e<i.getLineEnd(a)){var l=i.getLineStart(a),c=n.firstChild;while(c){if(c.ignore){c=c.nextSibling;continue}var h=c.firstChild,p=h.length;c.ignoreChars&&(p-=c.ignoreChars);if(l+p>e){var d=e-l,v;if(h.length===1)f=new w(c.getBoundingClientRect());else if(r._isRangeRects)v=s.createRange(),v.setStart(h,d),v.setEnd(h,d+1),f=new w(v.getBoundingClientRect());else if(o.isIE){v=s.body.createTextRange(),v.moveToElementText(c),v.collapse();var m=d===0&&o.isIE===8;m&&(d=1),v.moveEnd("character",d+1),v.moveStart("character",d),f=new w(v.getBoundingClientRect()),m&&(f.left=c.getClientRects()[0].left)}else{var g=h.data;c.removeChild(h),c.appendChild(s.createTextNode(g.substring(0,d)));var y=o.createElement(s,"span");y.appendChild(s.createTextNode(g.substring(d,d+1))),c.appendChild(y),c.appendChild(s.createTextNode(g.substring(d+1))),f=new w(y.getBoundingClientRect()),c.innerHTML="",c.appendChild(h);if(!this._createdDiv){var b=r._getSelection();(l<=b.start&&b.start<l+p||l<=b.end&&b.end<l+p)&&r._updateDOMSelection()}}if(o.isIE){var E=u(n.ownerDocument),S=E.screen.logicalXDPI/E.screen.deviceXDPI,x=E.screen.logicalYDPI/E.screen.deviceYDPI;f.left=f.left*S,f.right=f.right*S,f.top=f.top*x,f.bottom=f.bottom*x}break}l+=p,c=c.nextSibling}}var T=this.getBoundingClientRect();if(!f)if(r._wrapMode){var N=this.getClientRects();f=N[N.length-1],f.left=f.right,f.left+=T.left,f.top+=T.top,f.right+=T.left,f.bottom+=T.top}else f=new w(T),f.left=f.right;if(t||t===undefined)f.left-=T.left,f.top-=T.top,f.right-=T.left,f.bottom-=T.top;return f},_getClientRects:function(e,t){var n,r,i,s;if(!e._rectsCache){n=e.getClientRects(),r=new Array(n.length);for(s=0;s<n.length;s++)i=r[s]=new w(n[s]),i.left-=t.left,i.top-=t.top,i.right-=t.left,i.bottom-=t.top;e._rectsCache=r}n=e._rectsCache,r=[n.length];for(s=0;s<n.length;s++)r[s]=new w(n[s]);return r},getClientRects:function(e){if(!this.view._wrapMode)return[this.getBoundingClientRect()];var t=this._ensureCreated(),n=[],r=t.firstChild,i,s,o=t.getBoundingClientRect();while(r){if(r.ignore){r=r.nextSibling;continue}var u=this._getClientRects(r,o);for(i=0;i<u.length;i++){var a=u[i],f;if(a.top===a.bottom)continue;var l=a.top+(a.bottom-a.top)/2;for(f=0;f<n.length;f++){s=n[f];if(s.top<=l&&l<s.bottom)break}f===n.length?n.push(a):(a.left<s.left&&(s.left=a.left),a.top<s.top&&(s.top=a.top),a.right>s.right&&(s.right=a.right),a.bottom>s.bottom&&(s.bottom=a.bottom))}r=r.nextSibling}return e!==undefined?n[e]:n},_getLineBoundingClientRect:function(e,t){var n=new w(e.getBoundingClientRect());if(!this.view._wrapMode){n.right=n.left;var r=e.lastChild;while(r&&r.ignoreChars===r.firstChild.length)r=r.previousSibling;if(r){var i=r.getBoundingClientRect();n.right=i.right+g(e).right}}if(t){var s=g(e);n.left=n.left+s.left,n.right=n.right-s.right}return n},getLineCount:function(){return this.view._wrapMode?this.getClientRects().length:1},getLineIndex:function(e){if(!this.view._wrapMode)return 0;var t=this.getClientRects(),n=this.getBoundingClientRect(e),r=n.top+(n.bottom-n.top)/2;for(var i=0;i<t.length;i++)if(t[i].top<=r&&r<t[i].bottom)return i;return t.length-1},getLineStart:function(e){if(!this.view._wrapMode||e===0)return this.view._model.getLineStart(e);var t=this.getClientRects();return this.getOffset(t[e].left+1,t[e].top+1)},getOffset:function(e,t){var n=this.view,r=n._model,i=this.lineIndex,s=r.getLineStart(i),a=r.getLineEnd(i);if(s===a)return s;var f=this._ensureCreated(),l=this.getBoundingClientRect(),c,h;if(n._wrapMode){c=this.getClientRects(),t<c[0].top&&(t=c[0].top);for(var p=0;p<c.length;p++){h=c[p];if(h.top<=t&&t<h.bottom)break}e<h.left&&(e=h.left),e>h.right&&(e=h.right-1)}else e<0&&(e=0),e>l.right-l.left&&(e=l.right-l.left);var d=f.ownerDocument,v=u(d),m=o.isIE?v.screen.logicalXDPI/v.screen.deviceXDPI:1,g=o.isIE?v.screen.logicalYDPI/v.screen.deviceYDPI:1,y=s,b=f.firstChild;e:while(b){if(b.ignore){b=b.nextSibling;continue}var w=b.firstChild,E=w.length;b.ignoreChars&&(E-=b.ignoreChars);var S,x,T,N;c=this._getClientRects(b,l);for(var C=0;C<c.length;C++){h=c[C];if(h.left<=e&&e<h.right&&(!n._wrapMode||h.top<=t&&t<h.bottom)){var k,L,A,O=h.left+l.left,M;if(o.isIE||n._isRangeRects){k=n._isRangeRects?d.createRange():d.body.createTextRange();var _=E,D=-1;while(_-D>1){var P=Math.floor((_+D)/2);L=D+1,A=P===E-1&&b.ignoreChars?w.length:P+1,M=L===0&&o.isIE===8,n._isRangeRects?(k.setStart(w,L),k.setEnd(w,A)):(M&&(L=1),k.moveToElementText(b),k.move("character",L),k.moveEnd("character",A-L)),c=k.getClientRects();var H=!1;for(var B=0;B<c.length;B++){h=c[B],S=(M?O:h.left)*m-l.left,T=h.right*m-l.left,x=h.top*g-l.top,N=h.bottom*g-l.top;if(S<=e&&e<T&&(!n._wrapMode||x<=t&&t<N)){H=!0;break}}H?_=P:D=P}y+=_,L=_,A=_===E-1&&b.ignoreChars?w.length:Math.min(_+1,w.length),n._isRangeRects?(k.setStart(w,L),k.setEnd(w,A)):(k.moveToElementText(b),k.move("character",L),k.moveEnd("character",A-L)),c=k.getClientRects();var j=!1;c.length>0&&(h=c[0],S=(M?O:h.left)*m-l.left,T=h.right*m-l.left,j=e>S+(T-S)/2);var F=y-s,I=r.getLine(i),q=I.charCodeAt(F);55296<=q&&q<=56319&&j?F<I.length&&(q=I.charCodeAt(F+1),56320<=q&&q<=57343&&(y+=1)):56320<=q&&q<=57343&&!j&&F>0&&(q=I.charCodeAt(F-1),55296<=q&&q<=56319&&(y-=1)),j&&y++}else{var R=[];for(var U=0;U<E;U++)R.push("<span>"),U===E-1?R.push(w.data.substring(U)):R.push(w.data.substring(U,U+1)),R.push("</span>");b.innerHTML=R.join("");var z=b.firstChild;while(z){h=z.getBoundingClientRect(),S=h.left-l.left,T=h.right-l.left;if(S<=e&&e<T){e>S+(T-S)/2&&y++;break}y++,z=z.nextSibling}if(!this._createdDiv){b.innerHTML="",b.appendChild(w);var W=n._getSelection();(y<=W.start&&W.start<y+E||y<=W.end&&W.end<y+E)&&n._updateDOMSelection()}}break e}}y+=E,b=b.nextSibling}return Math.min(a,Math.max(s,y))},getNextOffset:function(e,t){if(t.unit==="line"){var n=this.view,r=n._model,i=r.getLineAtOffset(e);return t.count>0?(t.count--,r.getLineEnd(i)):(t.count++,r.getLineStart(i))}return t.unit==="wordend"||t.unit==="wordWS"||t.unit==="wordendWS"?this._getNextOffset_W3C(e,t):o.isIE?this._getNextOffset_IE(e,t):this._getNextOffset_W3C(e,t)},_getNextOffset_W3C:function(e,t){function n(e){return 33<=e&&e<=47||58<=e&&e<=64||91<=e&&e<=94||e===96||123<=e&&e<=126}function r(e){return e===32||e===9}var i=this.view,s=i._model,o=s.getLineAtOffset(e),u=s.getLine(o),a=s.getLineStart(o),f=s.getLineEnd(o),l=u.length,c=e-a,h,p=t.count<0?-1:1;if(t.unit==="word"||t.unit==="wordend"||t.unit==="wordWS"||t.unit==="wordendWS"){var d,v,m,g;while(t.count!==0){if(t.count>0){if(c===l)return f;h=u.charCodeAt(c),d=n(h),v=!d&&!r(h),c++;while(c<l){h=u.charCodeAt(c);if(t.unit!=="wordWS"&&t.unit!=="wordendWS"){m=n(h);if(t.unit==="wordend"){if(!m&&d)break}else if(m&&!d)break;g=!m&&!r(h)}else g=!r(h);if(t.unit==="wordend"||t.unit==="wordendWS"){if(!g&&v)break}else if(g&&!v)break;v=g,d=m,c++}}else{if(c===0)return a;c--,h=u.charCodeAt(c),d=n(h),v=!d&&!r(h);while(0<c){h=u.charCodeAt(c-1);if(t.unit!=="wordWS"&&t.unit!=="wordendWS"){m=n(h);if(t.unit==="wordend"){if(m&&!d)break}else if(!m&&d)break;g=!m&&!r(h)}else g=!r(h);if(t.unit==="wordend"||t.unit==="wordendWS"){if(g&&!v)break}else if(!g&&v)break;v=g,d=m,c--}c===0}t.count-=p}}else while(t.count!==0&&0<=c+p&&c+p<=l)c+=p,h=u.charCodeAt(c),56320<=h&&h<=57343&&c>0&&(h=u.charCodeAt(c-1),55296<=h&&h<=56319&&(c+=p)),t.count-=p;return a+c},_getNextOffset_IE:function(e,t){var n=this._ensureCreated(),r=this.view,i=r._model,s=this.lineIndex,o=0,u,a,f=i.getLineStart(s),l=n.ownerDocument,c,h=t.count<0?-1:1;if(e===i.getLineEnd(s)){c=n.lastChild;while(c&&c.ignoreChars===c.firstChild.length)c=c.previousSibling;if(!c)return f;u=l.body.createTextRange(),u.moveToElementText(c),a=u.text.length,u.moveEnd(t.unit,h),o=e+u.text.length-a}else if(e===f&&t.count<0)o=f;else{c=n.firstChild;while(c){var p=c.firstChild,d=p.length;c.ignoreChars&&(d-=c.ignoreChars);if(f+d>e){u=l.body.createTextRange(),e===f&&t.count<0?u.moveToElementText(c.previousSibling):(u.moveToElementText(c),u.collapse(),u.moveEnd("character",e-f)),a=u.text.length,u.moveEnd(t.unit,h),o=e+u.text.length-a;break}f=d+f,c=c.nextSibling}}return t.count-=h,o},destroy:function(){var e=this._createdDiv;e&&(e.parentNode.removeChild(e),this._createdDiv=null)}},S.prototype={addKeyMode:function(e,t){var n=this._keyModes;t!==undefined?n.splice(t,0,e):n.push(e),e._modeAdded&&e._modeAdded()},addRuler:function(e,t){e.setView(this);var n=this._rulers;if(t!==undefined){var r,i;for(r=0,i=0;r<n.length&&i<t;r++)e.getLocation()===n[r].getLocation()&&i++;n.splice(i,0,e),t=i}else n.push(e);this._createRuler(e,t),this._update()},computeSize:function(){var e=0,t=0,n=this._model,r=this._clientDiv;if(!r)return{width:e,height:t};var i=r.style.width;o.isWebkit&&(r.style.width="0x7fffffffpx");var s=n.getLineCount();for(var u=0;u<s;u++){var a=this._getLine(u),f=a.getBoundingClientRect();e=Math.max(e,f.right-f.left),t+=f.bottom-f.top,a.destroy()}o.isWebkit&&(r.style.width=i);var l=this._getViewPadding();return e+=l.right+l.left+this._metrics.scrollWidth,t+=l.bottom+l.top+this._metrics.scrollWidth,{width:e,height:t}},convert:function(e,t,n){if(!this._clientDiv)return;var r=this._getScroll(),i=this._getViewPadding(),s=this._viewDiv.getBoundingClientRect();return t==="document"&&(e.x!==undefined&&(e.x+=-r.x+s.left+i.left),e.y!==undefined&&(e.y+=-r.y+s.top+i.top)),n==="document"&&(e.x!==undefined&&(e.x+=r.x-s.left-i.left),e.y!==undefined&&(e.y+=r.y-s.top-i.top)),e},destroy:function(){for(var e=0;e<this._rulers.length;e++)this._rulers[e].setView(null);this.rulers=null,this._destroyView();var t={type:"Destroy"};this.onDestroy(t),this._parent=null,this._model=null,this._theme=null,this._selection=null,this._doubleClickSelection=null,this._keyModes=null,this._actions=null},focus:function(){if(!this._clientDiv)return;this._updateDOMSelection(),this._clientDiv.focus(),this._updateDOMSelection()},hasFocus:function(){return this._hasFocus},getActionDescription:function(e){var t=this._actions[e];return t?t.actionDescription:undefined},getActions:function(e){var t=[],n=this._actions;for(var r in n)if(n.hasOwnProperty(r)){if(!e&&n[r].defaultHandler)continue;t.push(r)}return t},getBottomIndex:function(e){return this._clientDiv?this._getBottomIndex(e):0},getBottomPixel:function(){return this._clientDiv?this._getScroll().y+this._getClientHeight():0},getCaretOffset:function(){var e=this._getSelection();return e.getCaret()},getClientArea:function(){if(!this._clientDiv)return{x:0,y:0,width:0,height:0};var e=this._getScroll();return{x:e.x,y:e.y,width:this._getClientWidth(),height:this._getClientHeight()}},getHorizontalPixel:function(){return this._clientDiv?this._getScroll().x:0},getKeyBindings:function(e){var t=[],n=this._keyModes;for(var r=0;r<n.length;r++)t=t.concat(n[r].getKeyBindings(e));return t},getKeyModes:function(){return this._keyModes.slice(0)},getLineHeight:function(e){return this._clientDiv?this._getLineHeight(e):0},getLineIndex:function(e){return this._clientDiv?this._getLineIndex(e):0},getLinePixel:function(e){return this._clientDiv?this._getLinePixel(e):0},getLocationAtOffset:function(e){if(!this._clientDiv)return{x:0,y:0};var t=this._model;e=Math.min(Math.max(0,e),t.getCharCount());var n=t.getLineAtOffset(e),r=this._getLine(n),i=r.getBoundingClientRect(e);r.destroy();var s=i.left,o=this._getLinePixel(n)+i.top;return{x:s,y:o}},getNextOffset:function(e,t){var n=new b(e,e,!1);return this._doMove(t,n),n.getCaret()},getOptions:function(){var e;if(arguments.length===0)e=this._defaultOptions();else if(arguments.length===1){var t=arguments[0];if(typeof t=="string")return c(this["_"+t]);e=t}else{e={};for(var n in arguments)arguments.hasOwnProperty(n)&&(e[arguments[n]]=undefined)}for(var r in e)e.hasOwnProperty(r)&&(e[r]=c(this["_"+r]));return e},getModel:function(){return this._model},getOffsetAtLocation:function(e,t){if(!this._clientDiv)return 0;var n=this._getLineIndex(t),r=this._getLine(n),i=r.getOffset(e,t-this._getLinePixel(n));return r.destroy(),i},getRulers:function(){return this._rulers.slice(0)},getSelection:function(){var e=this._getSelection();return{start:e.start,end:e.end}},getText:function(e,t){var n=this._model;return n.getText(e,t)},getTopIndex:function(e){return this._clientDiv?this._getTopIndex(e):0},getTopPixel:function(){return this._clientDiv?this._getScroll().y:0},invokeAction:function(e,t,n){if(!this._clientDiv)return;var r=this._actions[e];if(r){if(!t&&r.handler&&r.handler(n))return!0;if(r.defaultHandler)return typeof r.defaultHandler(n)=="boolean"}return!1},isDestroyed:function(){return!this._clientDiv},onContextMenu:function(e){return this.dispatchEvent(e)},onDragStart:function(e){return this.dispatchEvent(e)},onDrag:function(e){return this.dispatchEvent(e)},onDragEnd:function(e){return this.dispatchEvent(e)},onDragEnter:function(e){return this.dispatchEvent(e)},onDragOver:function(e){return this.dispatchEvent(e)},onDragLeave:function(e){return this.dispatchEvent(e)},onDrop:function(e){return this.dispatchEvent(e)},onDestroy:function(e){return this.dispatchEvent(e)},onLineStyle:function(e){return this.dispatchEvent(e)},onKeyDown:function(e){return this.dispatchEvent(e)},onKeyPress:function(e){return this.dispatchEvent(e)},onKeyUp:function(e){return this.dispatchEvent(e)},onModelChanged:function(e){return this.dispatchEvent(e)},onModelChanging:function(e){return this.dispatchEvent(e)},onModify:function(e){return this.dispatchEvent(e)},onMouseDown:function(e){return this.dispatchEvent(e)},onMouseUp:function(e){return this.dispatchEvent(e)},onMouseMove:function(e){return this.dispatchEvent(e)},onMouseOver:function(e){return this.dispatchEvent(e)},onMouseOut:function(e){return this.dispatchEvent(e)},onSelection:function(e){return this.dispatchEvent(e)},onScroll:function(e){return this.dispatchEvent(e)},onVerify:function(e){return this.dispatchEvent(e)},onFocus:function(e){return this.dispatchEvent(e)},onBlur:function(e){return this.dispatchEvent(e)},redraw:function(){if(this._redrawCount>0)return;var e=this._model.getLineCount();this.redrawRulers(0,e),this.redrawLines(0,e)},redrawRulers:function(e,t){if(this._redrawCount>0)return;var n=this.getRulers();for(var r=0;r<n.length;r++)this.redrawLines(e,t,n[r])},redrawLines:function(e,t,n){if(this._redrawCount>0)return;e===undefined&&(e=0),t===undefined&&(t=this._model.getLineCount());if(e===t)return;var r=this._clientDiv;if(!r)return;if(n){var i=this._getRulerParent(n);r=i.firstChild;while(r){if(r._ruler===n)break;r=r.nextSibling}}n?r.rulerChanged=!0:this._lineHeight&&this._resetLineHeight(e,t);if(!n||n.getOverview()==="page"){var s=r.firstChild;while(s){var o=s.lineIndex;e<=o&&o<t&&(s.lineChanged=!0),s=s.nextSibling}}n||this._wrapMode||e<=this._maxLineIndex&&this._maxLineIndex<t&&(this._checkMaxLineIndex=this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0),this._queueUpdate()},redrawRange:function(e,t){if(this._redrawCount>0)return;var n=this._model;e===undefined&&(e=0),t===undefined&&(t=n.getCharCount());var r=n.getLineAtOffset(e),i=n.getLineAtOffset(Math.max(e,t-1))+1;this.redrawLines(r,i)},removeKeyMode:function(e){var t=this._keyModes;for(var n=0;n<t.length;n++)if(t[n]===e){t.splice(n,1);break}e._modeRemoved&&e._modeRemoved()},removeRuler:function(e){var t=this._rulers;for(var n=0;n<t.length;n++)if(t[n]===e){t.splice(n,1),e.setView(null),this._destroyRuler(e),this._update();break}},resize:function(){if(!this._clientDiv)return;this._handleResize(null)},setAction:function(e,t,n){if(!e)return;var r=this._actions,i=r[e];i||(i=r[e]={}),i.handler=t,n!==undefined&&(i.actionDescription=n)},setKeyBinding:function(e,t){this._keyModes[0].setKeyBinding(e,t)},setCaretOffset:function(e,t,n){var r=this._model.getCharCount();e=Math.max(0,Math.min(e,r));var i=new b(e,e,!1);this._setSelection(i,t===undefined||t,!0,n)},setHorizontalPixel:function(e){if(!this._clientDiv)return;e=Math.max(0,e),this._scrollView(e-this._getScroll().x,0)},setRedraw:function(e){e?--this._redrawCount===0&&this.redraw():this._redrawCount++},setModel:function(e){if(!e)return;if(e===this._model)return;this._model.removeEventListener("preChanging",this._modelListener.onChanging),this._model.removeEventListener("postChanged",this._modelListener.onChanged);var t=this._model.getLineCount(),n=this._model.getCharCount(),r=e.getLineCount(),i=e.getCharCount(),s=e.getText(),o={type:"ModelChanging",text:s,start:0,removedCharCount:n,addedCharCount:i,removedLineCount:t,addedLineCount:r};this.onModelChanging(o),this._model=e,o={type:"ModelChanged",start:0,removedCharCount:n,addedCharCount:i,removedLineCount:t,addedLineCount:r},this.onModelChanged(o),this._model.addEventListener("preChanging",this._modelListener.onChanging),this._model.addEventListener("postChanged",this._modelListener.onChanged),this._reset(),this._update()},setOptions:function(e){var t=this._defaultOptions();for(var n in e)if(e.hasOwnProperty(n)){var r=e[n],i=this["_"+n];if(p(i,r))continue;var s=t[n]?t[n].update:null;if(s){s.call(this,r);continue}this["_"+n]=c(r)}},setSelection:function(e,t,n,r){var i=e>t;if(i){var s=e;e=t,t=s}var o=this._model.getCharCount();e=Math.max(0,Math.min(e,o)),t=Math.max(0,Math.min(t,o));var u=new b(e,t,i);this._setSelection(u,n===undefined||n,!0,r)},setText:function(e,t,n){var r=t===undefined&&n===undefined;t===undefined&&(t=0),n===undefined&&(n=this._model.getCharCount()),r&&(this._variableLineHeight=!1),this._modifyContent({text:e,start:t,end:n,_code:!0},!r),r&&(this._columnX=-1,this._setSelection(new b(0,0,!1),!0),o.isFirefox&&this._fixCaret())},setTopIndex:function(e){if(!this._clientDiv)return;this._scrollView(0,this._getLinePixel(Math.max(0,e))-this._getScroll().y)},setTopPixel:function(e){if(!this._clientDiv)return;this._scrollView(0,Math.max(0,e)-this._getScroll().y)},showSelection:function(){return this._showCaret(!0)},update:function(e,t){if(!this._clientDiv)return;e&&this._updateStyle(),t===undefined||t?this._update():this._queueUpdate()},_handleRootMouseDown:function(e){if(this._ignoreEvent(e))return;o.isFirefox&&e.which===1&&(this._clientDiv.contentEditable=!1,(this._overlayDiv||this._clientDiv).draggable=!0,this._ignoreBlur=!0);var t=this._overlayDiv||this._clientDiv;o.isIE<9&&(t=this._viewDiv);var n=e.target?e.target:e.srcElement;while(n){if(t===n)return;n=n.parentNode}e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation();if(!this._isW3CEvents){var r=this,i=this._getWindow();i.setTimeout(function(){r._clientDiv.focus()},0)}},_handleRootMouseUp:function(e){if(this._ignoreEvent(e))return;o.isFirefox&&e.which===1&&(this._clientDiv.contentEditable=!0,(this._overlayDiv||this._clientDiv).draggable=!1,this._fixCaret(),this._ignoreBlur=!1)},_handleBlur:function(e){if(this._ignoreBlur)return;this._hasFocus=!1;if(o.isIE<9&&!this._getSelection().isEmpty()){var t=this._rootDiv,n=o.createElement(t.ownerDocument,"div");t.appendChild(n),t.removeChild(n)}this._cursorDiv&&(this._cursorDiv.style.display="none");if(this._selDiv1){var r="lightgray";this._selDiv1.style.background=r,this._selDiv2.style.background=r,this._selDiv3.style.background=r;var i,s=this._getWindow(),u=this._selDiv1.ownerDocument;if(s.getSelection){var a=s.getSelection();i=a.anchorNode;while(i){if(i===this._clientDiv){a.rangeCount>0&&a.removeAllRanges();break}i=i.parentNode}}else if(u.selection){this._ignoreSelect=!1,i=u.selection.createRange().parentElement();while(i){if(i===this._clientDiv){u.selection.empty();break}i=i.parentNode}this._ignoreSelect=!0}}this._ignoreFocus||this.onBlur({type:"Blur"})},_handleContextMenu:function(e){if(this._ignoreEvent(e))return;o.isIE&&this._lastMouseButton===3&&this._updateDOMSelection();var t=!1;if(this.isListening("ContextMenu")){var n=this._createMouseEvent("ContextMenu",e);n.screenX=e.screenX,n.screenY=e.screenY,this.onContextMenu(n),t=n.defaultPrevented}else o.isMac&&o.isFirefox&&e.button===0&&(t=!0);if(t)return e.preventDefault&&e.preventDefault(),!1},_handleCopy:function(e){if(this._ignoreEvent(e))return;if(this._ignoreCopy)return;if(this._doCopy(e))return e.preventDefault&&e.preventDefault(),!1},_handleCut:function(e){if(this._ignoreEvent(e))return;if(this._doCut(e))return e.preventDefault&&e.preventDefault(),!1},_handleDataModified:function(e){if(this._ignoreEvent(e))return;this._startIME()},_handleDblclick:function(e){if(this._ignoreEvent(e))return;var t=e.timeStamp?e.timeStamp:(new Date).getTime();this._lastMouseTime=t,this._clickCount!==2&&(this._clickCount=2,this._handleMouse(e))},_handleDragStart:function(e){if(this._ignoreEvent(e))return;if(o.isFirefox){var t=this,n=this._getWindow();n.setTimeout(function(){t._clientDiv.contentEditable=!0,t._clientDiv.draggable=!1,t._ignoreBlur=!1},0)}if(!this.isListening("DragStart")||this._dragOffset===-1)return e.preventDefault&&e.preventDefault(),!1;this._isMouseDown=!1,this.onDragStart(this._createMouseEvent("DragStart",e)),this._dragOffset=-1},_handleDrag:function(e){if(this._ignoreEvent(e))return;this.isListening("Drag")&&this.onDrag(this._createMouseEvent("Drag",e))},_handleDragEnd:function(e){if(this._ignoreEvent(e))return;this._dropTarget=!1,this._dragOffset=-1,this.isListening("DragEnd")&&this.onDragEnd(this._createMouseEvent("DragEnd",e)),o.isFirefox&&(this._fixCaret(),e.dataTransfer.dropEffect==="none"&&!e.dataTransfer.mozUserCancelled&&this._fixCaret())},_handleDragEnter:function(e){if(this._ignoreEvent(e))return;var t=!0;this._dropTarget=!0,this.isListening("DragEnter")&&(t=!1,this.onDragEnter(this._createMouseEvent("DragEnter",e)));if(o.isWebkit||t)return e.preventDefault&&e.preventDefault(),!1},_handleDragOver:function(e){if(this._ignoreEvent(e))return;var t=!0;this.isListening("DragOver")&&(t=!1,this.onDragOver(this._createMouseEvent("DragOver",e)));if(o.isWebkit||t)return t&&(e.dataTransfer.dropEffect="none"),e.preventDefault&&e.preventDefault(),!1},_handleDragLeave:function(e){if(this._ignoreEvent(e))return;this._dropTarget=!1,this.isListening("DragLeave")&&this.onDragLeave(this._createMouseEvent("DragLeave",e))},_handleDrop:function(e){if(this._ignoreEvent(e))return;return this._dropTarget=!1,this.isListening("Drop")&&this.onDrop(this._createMouseEvent("Drop",e)),e.preventDefault&&e.preventDefault(),!1},_handleFocus:function(e){this._hasFocus=!0,o.isIOS&&this._lastTouchOffset!==undefined?(this.setCaretOffset(this._lastTouchOffset,!0),this._lastTouchOffset=undefined):this._updateDOMSelection(),this._cursorDiv&&(this._cursorDiv.style.display="block");if(this._selDiv1){var t=this._highlightRGB;this._selDiv1.style.background=t,this._selDiv2.style.background=t,this._selDiv3.style.background=t}this._ignoreFocus||this.onFocus({type:"Focus"})},_handleKeyDown:function(e){if(this._ignoreEvent(e))return;if(this.isListening("KeyDown")){var t=this._createKeyEvent("KeyDown",e);this.onKeyDown(t);if(t.defaultPrevented){o.isFirefox&&(this._keyDownPrevented=!0),e.preventDefault();return}}var n=!1;switch(e.keyCode){case 16:case 17:case 18:case 91:n=!0;break;default:this._setLinksVisible(!1)}if(e.keyCode===229){if(this._readonly)return e.preventDefault&&e.preventDefault(),!1;var r=!0;o.isSafari&&o.isMac&&e.ctrlKey&&(r=!1,e.keyCode=129),r&&this._startIME()}else n||this._commitIME();if((o.isMac||o.isLinux)&&o.isFirefox<4||o.isOpera)return this._keyDownEvent=e,!0;if(this._doAction(e))return e.preventDefault?(e.preventDefault(),e.stopPropagation()):(e.cancelBubble=!0,e.returnValue=!1,e.keyCode=0),!1},_handleKeyPress:function(e){if(this._ignoreEvent(e))return;if(this._keyDownPrevented){e.preventDefault&&(e.preventDefault(),e.stopPropagation()),this._keyDownPrevented=undefined;return}if(o.isMac&&o.isWebkit)if(63232<=e.keyCode&&e.keyCode<=63487||e.keyCode===13||e.keyCode===8)return e.preventDefault&&e.preventDefault(),!1;if((o.isMac||o.isLinux)&&o.isFirefox<4||o.isOpera)if(this._doAction(this._keyDownEvent))return e.preventDefault&&e.preventDefault(),!1;var t=o.isMac?e.metaKey:e.ctrlKey;if(e.charCode!==undefined&&t)switch(e.charCode){case 99:case 118:case 120:return!0}if(this.isListening("KeyPress")){var n=this._createKeyEvent("KeyPress",e);this.onKeyPress(n);if(n.defaultPrevented){e.preventDefault();return}}if(this._doAction(e))return e.preventDefault?(e.preventDefault(),e.stopPropagation()):(e.cancelBubble=!0,e.returnValue=!1,e.keyCode=0),!1;var r=!1;if(o.isMac){if(e.ctrlKey||e.metaKey)r=!0}else if(o.isFirefox){if(e.ctrlKey||e.altKey)r=!0}else e.ctrlKey^e.altKey&&(r=!0);if(!r){var i=o.isOpera?e.which:e.charCode!==undefined?e.charCode:e.keyCode;if(i>31)return this._doContent(String.fromCharCode(i)),e.preventDefault&&e.preventDefault(),!1}},_handleDocKeyUp:function(e){var t=o.isMac?e.metaKey:e.ctrlKey;t||this._setLinksVisible(!1)},_handleKeyUp:function(e){if(this._ignoreEvent(e))return;if(this.isListening("KeyUp")){var t=this._createKeyEvent("KeyUp",e);this.onKeyUp(t);if(t.defaultPrevented){e.preventDefault();return}}this._handleDocKeyUp(e),e.keyCode===13&&this._commitIME()},_handleLinkClick:function(e){var t=o.isMac?e.metaKey:e.ctrlKey;if(!t)return e.preventDefault&&e.preventDefault(),!1},_handleMouse:function(e){var t=this._getWindow(),n=!0,r=t;if(o.isIE||o.isFirefox&&!this._overlayDiv)r=this._clientDiv;if(this._overlayDiv){this._hasFocus&&(this._ignoreFocus=!0);var i=this;t.setTimeout(function(){i.focus(),i._ignoreFocus=!1},0)}return this._clickCount===1?(n=this._setSelectionTo(e.clientX,e.clientY,e.shiftKey,!o.isOpera&&this._hasFocus&&this.isListening("DragStart")),n&&this._setGrab(r)):(this._isW3CEvents&&this._setGrab(r),this._doubleClickSelection=null,this._setSelectionTo(e.clientX,e.clientY,e.shiftKey),this._doubleClickSelection=this._getSelection()),n},_handleMouseDown:function(e){if(this._ignoreEvent(e))return;if(this._linksVisible){var t=e.target||e.srcElement;if(t.tagName==="A")return;this._setLinksVisible(!1)}this._commitIME();var n=e.which;n||(e.button===4&&(n=2),e.button===2&&(n=3),e.button===1&&(n=1));var r=n!==2&&e.timeStamp?e.timeStamp:(new Date).getTime(),i=r-this._lastMouseTime,s=Math.abs(this._lastMouseX-e.clientX),u=Math.abs(this._lastMouseY-e.clientY),a=this._lastMouseButton===n;this._lastMouseX=e.clientX,this._lastMouseY=e.clientY,this._lastMouseTime=r,this._lastMouseButton=n,n===1&&(this._isMouseDown=!0,a&&i<=this._clickTime&&s<=this._clickDist&&u<=this._clickDist?this._clickCount++:this._clickCount=1);if(this.isListening("MouseDown")){var f=this._createMouseEvent("MouseDown",e);this.onMouseDown(f);if(f.defaultPrevented){e.preventDefault();return}}n===1&&this._handleMouse(e)&&(o.isIE>=9||o.isOpera||o.isChrome||o.isSafari||o.isFirefox&&!this._overlayDiv)&&(this._hasFocus||this.focus(),e.preventDefault()),o.isFirefox&&this._lastMouseButton===3&&this._updateDOMSelection()},_handleMouseOver:function(e){if(this._ignoreEvent(e))return;if(this._animation)return;this.isListening("MouseOver")&&this.onMouseOver(this._createMouseEvent("MouseOver",e))},_handleMouseOut:function(e){if(this._ignoreEvent(e))return;if(this._animation)return;this.isListening("MouseOut")&&this.onMouseOut(this._createMouseEvent("MouseOut",e))},_handleMouseMove:function(e){if(this._animation)return;var t=this._isClientDiv(e);this.isListening("MouseMove")&&t&&this.onMouseMove(this._createMouseEvent("MouseMove",e));if(this._dropTarget)return;var n=this._linksVisible||this._lastMouseMoveX!==e.clientX||this._lastMouseMoveY!==e.clientY;this._lastMouseMoveX=e.clientX,this._lastMouseMoveY=e.clientY,this._setLinksVisible(n&&!this._isMouseDown&&(o.isMac?e.metaKey:e.ctrlKey));if(!this._isW3CEvents){if(e.button===0)return this._setGrab(null),!0;if(!this._isMouseDown&&e.button===1&&(this._clickCount&1)!==0&&t)return this._clickCount=2,this._handleMouse(e,this._clickCount)}if(!this._isMouseDown||this._dragOffset!==-1)return;var r=e.clientX,i=e.clientY,s=this._getViewPadding(),u=this._viewDiv.getBoundingClientRect(),a=this._getClientWidth(),f=this._getClientHeight(),l=u.left+s.left,c=u.top+s.top,h=u.left+s.left+a,p=u.top+s.top+f;i<c?this._doAutoScroll("up",r,i-c):i>p?this._doAutoScroll("down",r,i-p):r<l&&!this._wrapMode?this._doAutoScroll("left",r-l,i):r>h&&!this._wrapMode?this._doAutoScroll("right",r-h,i):(this._endAutoScroll(),this._setSelectionTo(r,i,!0))},_isClientDiv:function(e){var t=this._overlayDiv||this._clientDiv,n=e.target?e.target:e.srcElement;while(n){if(t===n)return!0;n=n.parentNode}return!1},_createKeyEvent:function(e,t){return{type:e,event:t,preventDefault:function(){this.defaultPrevented=!0}}},_createMouseEvent:function(e,t){var n=this.convert({x:t.clientX,y:t.clientY},"page","document");return{type:e,event:t,clickCount:this._clickCount,x:n.x,y:n.y,preventDefault:function(){this.defaultPrevented=!0}}},_handleMouseUp:function(e){var t=e.which?e.button===0:e.button===1;this.isListening("MouseUp")&&(this._isClientDiv(e)||t&&this._isMouseDown)&&this.onMouseUp(this._createMouseEvent("MouseUp",e));if(this._linksVisible)return;if(t&&this._isMouseDown){if(this._dragOffset!==-1){var n=this._getSelection();n.extend(this._dragOffset),n.collapse(),this._setSelection(n,!0,!0),this._dragOffset=-1}this._isMouseDown=!1,this._endAutoScroll(),this._isW3CEvents&&this._setGrab(null),o.isFirefox&&e.preventDefault()}},_handleMouseWheel:function(e){var t=this._getLineHeight(),n=0,r=0;if(o.isIE||o.isOpera)r=-e.wheelDelta/40*t;else if(o.isFirefox){var i;if(o.isMac)i=e.detail*3;else{var s=256;i=Math.max(-s,Math.min(s,e.detail))*t}e.axis===e.HORIZONTAL_AXIS?n=i:r=i}else if(o.isMac){var u,a,f=e.timeStamp-this._wheelTimeStamp;this._wheelTimeStamp=e.timeStamp,e.wheelDeltaX%120!==0?u=1:u=f<40?40/(40-f):40,e.wheelDeltaY%120!==0?a=1:a=f<40?40/(40-f):40,n=Math.ceil(-e.wheelDeltaX/u),-1<n&&n<0&&(n=-1),0<n&&n<1&&(n=1),r=Math.ceil(-e.wheelDeltaY/a),-1<r&&r<0&&(r=-1),0<r&&r<1&&(r=1)}else{n=-e.wheelDeltaX;var l=8;r=-e.wheelDeltaY/120*l*t}if(o.isSafari){var c=e.target;while(c&&c.lineIndex===undefined)c=c.parentNode;this._mouseWheelLine=c}var h=this._getScroll();this._scrollView(n,r);var p=this._getScroll();if(h.x!==p.x||h.y!==p.y)return e.preventDefault&&e.preventDefault(),!1},_handlePaste:function(e){if(this._ignoreEvent(e))return;if(this._ignorePaste)return;if(this._doPaste(e)){if(o.isIE){var t=this;this._ignoreFocus=!0;var n=this._getWindow();n.setTimeout(function(){t._updateDOMSelection(),t._ignoreFocus=!1},0)}return e.preventDefault&&e.preventDefault(),!1}},_handleResize:function(e){var t=this._parent.clientWidth,n=this._parent.clientHeight;if(this._parentWidth!==t||this._parentHeight!==n){this._parentWidth!==t&&this._wrapMode&&this._resetLineHeight(),this._parentWidth=t,this._parentHeight=n;var r=o.isIE<9,i=this._calculateMetrics();p(i,this._metrics)||(this._variableLineHeight&&(this._variableLineHeight=!1,this._resetLineHeight()),this._metrics=i,r=!0),r?this._queueUpdate():this._update()}},_handleRulerEvent:function(e){var t=e.target?e.target:e.srcElement,n=t.lineIndex,r=t;while(r&&!r._ruler)n===undefined&&r.lineIndex!==undefined&&(n=r.lineIndex),r=r.parentNode;var i=r?r._ruler:null;if(n===undefined&&i&&i.getOverview()==="document"){var s=this._getClientHeight(),o=this._model.getLineCount(),u=this._getViewPadding(),a=this._viewDiv.getBoundingClientRect(),f=s+u.top+u.bottom-2*this._metrics.scrollWidth;n=Math.floor((e.clientY-a.top-this._metrics.scrollWidth)*o/f),0<=n&&n<o||(n=undefined)}if(i)switch(e.type){case"click":i.onClick&&i.onClick(n,e);break;case"dblclick":i.onDblClick&&i.onDblClick(n,e);break;case"mousemove":i.onMouseMove&&i.onMouseMove(n,e);break;case"mouseover":i.onMouseOver&&i.onMouseOver(n,e);break;case"mouseout":if(i.onMouseOut){var l=e.relatedTarget;while(l&&l!==this._rootDiv){if(l===r)return;l=l.parentNode}i.onMouseOut(n,e)}}},_handleScroll:function(){var e=this._getScroll(!1),t=this._hScroll,n=this._vScroll;if(t!==e.x||n!==e.y){this._hScroll=e.x,this._vScroll=e.y,this._commitIME(),this._update(n===e.y);var r={type:"Scroll",oldValue:{x:t,y:n},newValue:e};this.onScroll(r)}},_handleSelectStart:function(e){if(this._ignoreSelect)return e&&e.preventDefault&&e.preventDefault(),!1},_getModelOffset:function(e,t){if(!e)return;var n;e.tagName==="DIV"?n=e:n=e.parentNode.parentNode;var r=0,i=n.lineIndex;if(e.tagName!=="DIV"){var s=n.firstChild;while(s){var o=s.firstChild;if(o===e){s.ignoreChars&&(r-=s.ignoreChars),r+=t;break}s.ignoreChars&&(r-=s.ignoreChars),r+=o.data.length,s=s.nextSibling}}return Math.max(0,r)+this._model.getLineStart(i)},_updateSelectionFromDOM:function(){var e=this._getWindow(),t=e.getSelection(),n=this._getModelOffset(t.anchorNode,t.anchorOffset),r=this._getModelOffset(t.focusNode,t.focusOffset);if(n===undefined||r===undefined)return;this._setSelection(new b(n,r),!1,!1)},_handleSelectionChange:function(e){if(this._imeOffset!==-1)return;if(o.isAndroid){var t=this._getWindow();this._selTimer&&t.clearTimeout(this._selTimer);var n=this;this._selTimer=t.setTimeout(function(){if(!n._clientDiv)return;n._selTimer=null,n._updateSelectionFromDOM()},250)}else this._updateSelectionFromDOM()},_handleTextInput:function(e){if(this._ignoreEvent(e))return;this._imeOffset=-1;if(o.isAndroid){var t=this._getWindow().getSelection(),n=t.anchorNode;while(n){if(n.lineIndex!==undefined)break;n=n.parentNode}if(n){var r=this._model,i=n.lineIndex,s=r.getLine(i),u=s,a=0,f=r.getLineStart(i);if(t.rangeCount>0){t.getRangeAt(0).deleteContents();var l=n.ownerDocument.createTextNode(e.data);t.getRangeAt(0).insertNode(l);var c=this._getDOMText(n,l);u=c.text,a=c.offset,l.parentNode.removeChild(l)}n.lineRemoved=!0;var h=0;while(s.charCodeAt(h)===u.charCodeAt(h)&&h<a)h++;var p=s.length-1,d=u.length-s.length;while(s.charCodeAt(p)===u.charCodeAt(p+d)&&p+d>=a+e.data.length)p--;p++;var v=u.substring(h,p+d);h+=f,p+=f,this._modifyContent({text:v,start:h,end:p,_ignoreDOMSelection:!0},!0)}}else this._doContent(e.data);e.preventDefault()},_handleTouchStart:function(e){this._commitIME();var t=this._getWindow();this._touchScrollTimer&&(this._vScrollDiv.style.display="none",this._hScrollDiv.style.display="none",t.clearInterval(this._touchScrollTimer),this._touchScrollTimer=null);var n=e.touches;if(n.length===1){var r=n[0],i=r.clientX,s=r.clientY;this._touchStartX=i,this._touchStartY=s,o.isAndroid&&(s<r.pageY-t.pageYOffset||i<r.pageX-t.pageXOffset)&&(i=r.pageX-t.pageXOffset,s=r.pageY-t.pageYOffset);var u=this.convert({x:i,y:s},"page","document");this._lastTouchOffset=this.getOffsetAtLocation(u.x,u.y),this._touchStartTime=e.timeStamp,this._touching=!0}},_handleTouchMove:function(e){var t=e.touches;if(t.length===1){var n=t[0];this._touchCurrentX=n.clientX,this._touchCurrentY=n.clientY;var r=10;if(!this._touchScrollTimer&&e.timeStamp-this._touchStartTime<r*20){this._vScrollDiv.style.display="block",this._wrapMode||(this._hScrollDiv.style.display="block");var i=this,s=this._getWindow();this._touchScrollTimer=s.setInterval(function(){var e=0,t=0;if(i._touching)e=i._touchStartX-i._touchCurrentX,t=i._touchStartY-i._touchCurrentY,i._touchSpeedX=e/r,i._touchSpeedY=t/r,i._touchStartX=i._touchCurrentX,i._touchStartY=i._touchCurrentY;else{if(Math.abs(i._touchSpeedX)<.1&&Math.abs(i._touchSpeedY)<.1){i._vScrollDiv.style.display="none",i._hScrollDiv.style.display="none",s.clearInterval(i._touchScrollTimer),i._touchScrollTimer=null;return}e=i._touchSpeedX*r,t=i._touchSpeedY*r,i._touchSpeedX*=.95,i._touchSpeedY*=.95}i._scrollView(e,t)},r)}this._touchScrollTimer&&e.preventDefault()}},_handleTouchEnd:function(e){var t=e.touches;t.length===0&&(this._touching=!1)},_doAction:function(e){var t,n,r=this._keyModes;for(n=r.length-1;n>=0;n--){t=r[n];if(typeof t.match=="function"){var i=t.match(e);if(i!==undefined)return this.invokeAction(i)}}return!1},_doMove:function(e,t){var n=this._model,r=t.getCaret(),i=n.getLineAtOffset(r);e.count||(e.count=1);while(e.count!==0){var s=n.getLineStart(i);if(e.count<0&&r===s){if(!(i>0))break;e.unit==="character"&&e.count++,i--,t.extend(n.getLineEnd(i))}else if(e.count>0&&r===n.getLineEnd(i)){if(!(i+1<n.getLineCount()))break;e.unit==="character"&&e.count--,i++,t.extend(n.getLineStart(i))}else{var o=!1;if(e.expandTab&&e.unit==="character"&&(r-s)%this._tabSize===0){var u=n.getText(s,r);o=!/[^ ]/.test(u)}if(o)t.extend(r-this._tabSize),e.count+=e.count<0?1:-1;else{var a=this._getLine(i);t.extend(a.getNextOffset(r,e)),a.destroy()}}r=t.getCaret()}return t},_doBackspace:function(e){var t=this._getSelection();return t.isEmpty()&&(e.count||(e.count=1),e.count*=-1,e.expandTab=this._expandTab,this._doMove(e,t)),this._modifyContent({text:"",start:t.start,end:t.end},!0),!0},_doCase:function(e){var t=this._getSelection();this._doMove(e,t);var n=this.getText(t.start,t.end);this._setSelection(t,!0);switch(e.type){case"lower":n=n.toLowerCase();break;case"capitalize":n=n.replace(/(?:^|\s)\S/g,function(e){return e.toUpperCase()});break;case"reverse":var r="";for(var i=0;i<n.length;i++){var s=n[i],o=s.toLowerCase();o!==s?s=o:s=s.toUpperCase(),r+=s}n=r;break;default:n=n.toUpperCase()}return this._doContent(n),!0},_doContent:function(e){var t=this._getSelection();if(this._overwriteMode&&t.isEmpty()){var n=this._model,r=n.getLineAtOffset(t.end);if(t.end<n.getLineEnd(r)){var i=this._getLine(r);t.extend(i.getNextOffset(t.getCaret(),{unit:"character",count:1})),i.destroy()}}this._modifyContent({text:e,start:t.start,end:t.end,_ignoreDOMSelection:!0},!0)},_doCopy:function(e){var t=this._getSelection();if(!t.isEmpty()){var n=this._getBaseText(t.start,t.end);return this._setClipboardText(n,e)}return!0},_doCursorNext:function(e){var t=this._getSelection();return!t.isEmpty()&&!e.select?t.start=t.end:this._doMove(e,t),e.select||t.collapse(),this._setSelection(t,!0),!0},_doCursorPrevious:function(e){var t=this._getSelection();return!t.isEmpty()&&!e.select?t.end=t.start:(e.count||(e.count=1),e.count*=-1,this._doMove(e,t)),e.select||t.collapse(),this._setSelection(t,!0),!0},_doCut:function(e){var t=this._getSelection();if(!t.isEmpty()){var n=this._getBaseText(t.start,t.end);return this._doContent(""),this._setClipboardText(n,e)}return!0},_doDelete:function(e){var t=this._getSelection();return t.isEmpty()&&this._doMove(e,t),this._modifyContent({text:"",start:t.start,end:t.end},!0),!0},_doEnd:function(e){var t=this._getSelection(),n=this._model,r;if(e.ctrl)t.extend(n.getCharCount()),r=function(){};else{var i=t.getCaret(),s=n.getLineAtOffset(i);if(this._wrapMode){var o=this._getLine(s),u=o.getLineIndex(i);u===o.getLineCount()-1?i=n.getLineEnd(s):i=o.getLineStart(u+1)-1,o.destroy()}else e.count&&e.count>0&&(s=Math.min(s+e.count-1,n.getLineCount()-1)),i=n.getLineEnd(s);t.extend(i)}return e.select||t.collapse(),this._setSelection(t,!0,!0,r),!0},_doEnter:function(e){var t=this._model,n=this._getSelection();return this._doContent(t.getLineDelimiter()),e&&e.noCursor&&(n.end=n.start,this._setSelection(n,!0)),!0},_doHome:function(e){var t=this._getSelection(),n=this._model,r;if(e.ctrl)t.extend(0),r=function(){};else{var i=t.getCaret(),s=n.getLineAtOffset(i);if(this._wrapMode){var o=this._getLine(s),u=o.getLineIndex(i);i=o.getLineStart(u),o.destroy()}else i=n.getLineStart(s);t.extend(i)}return e.select||t.collapse(),this._setSelection(t,!0,!0,r),!0},_doLineDown:function(e){var t=this._model,n=this._getSelection(),r=n.getCaret(),i=t.getLineAtOffset(r),s,u=this._getLine(i),a=this._columnX,f=1,l=!1;if(a===-1||e.wholeLine||e.select&&o.isIE){var c=e.wholeLine?t.getLineEnd(i+1):r;a=u.getBoundingClientRect(c).left}if((s=u.getLineIndex(r))<u.getLineCount()-1)f=u.getClientRects(s+1).top+1;else{var h=t.getLineCount()-1;l=i===h,e.count&&e.count>0?i=Math.min(i+e.count,h):i++}var p=!1;if(l){if(e.select||o.isMac||o.isLinux)n.extend(t.getCharCount()),p=!0}else u.lineIndex!==i&&(u.destroy(),u=this._getLine(i)),n.extend(u.getOffset(a,f)),p=!0;return p&&(e.select||n.collapse(),this._setSelection(n,!0,!0)),this._columnX=a,u.destroy(),!0},_doLineUp:function(e){var t=this._model,n=this._getSelection(),r=n.getCaret(),i=t.getLineAtOffset(r),s,u=this._getLine(i),a=this._columnX,f=!1,l;if(a===-1||e.wholeLine||e.select&&o.isIE){var c=e.wholeLine?t.getLineStart(i-1):r;a=u.getBoundingClientRect(c).left}(s=u.getLineIndex(r))>0?l=u.getClientRects(s-1).top+1:(f=i===0,f||(e.count&&e.count>0?i=Math.max(i-e.count,0):i--,l=this._getLineHeight(i)-1));var h=!1;if(f){if(e.select||o.isMac||o.isLinux)n.extend(0),h=!0}else u.lineIndex!==i&&(u.destroy(),u=this._getLine(i)),n.extend(u.getOffset(a,l)),h=!0;return h&&(e.select||n.collapse(),this._setSelection(n,!0,!0)),this._columnX=a,u.destroy(),!0},_doNoop:function(){return!0},_doPageDown:function(e){var t=this,n=this._model,r=this._getSelection(),i=r.getCaret(),s=n.getLineAtOffset(i),u=n.getLineCount(),a=this._getScroll(),f=this._getClientHeight(),l,c;if(this._lineHeight){l=this._columnX;var h=this._getBoundsAtOffset(i);if(l===-1||e.select&&o.isIE)l=h.left;var p=this._getLineIndex(h.top+f);c=this._getLine(p);var d=this._getLinePixel(p),v=h.top+f-d;i=c.getOffset(l,v);var m=c.getBoundingClientRect(i);return c.destroy(),r.extend(i),e.select||r.collapse(),this._setSelection(r,!0,!0,function(){t._columnX=l},m.top+d-h.top),!0}if(s<u-1){var g=this._getLineHeight(),y=Math.floor(f/g),b=Math.min(u-s-1,y);b=Math.max(1,b),l=this._columnX;if(l===-1||e.select&&o.isIE)c=this._getLine(s),l=c.getBoundingClientRect(i).left,c.destroy();c=this._getLine(s+b),r.extend(c.getOffset(l,0)),c.destroy(),e.select||r.collapse();var w=u*g,E=a.y+b*g;E+f>w&&(E=w-f),this._setSelection(r,!0,!0,function(){t._columnX=l},E-a.y)}return!0},_doPageUp:function(e){var t=this,n=this._model,r=this._getSelection(),i=r.getCaret(),s=n.getLineAtOffset(i),u=this._getScroll(),a=this._getClientHeight(),f,l;if(this._lineHeight){f=this._columnX;var c=this._getBoundsAtOffset(i);if(f===-1||e.select&&o.isIE)f=c.left;var h=this._getLineIndex(c.bottom-a);l=this._getLine(h);var p=this._getLinePixel(h),d=c.bottom-a-p;i=l.getOffset(f,d);var v=l.getBoundingClientRect(i);return l.destroy(),r.extend(i),e.select||r.collapse(),this._setSelection(r,!0,!0,function(){t._columnX=f},v.top+p-c.top),!0}if(s>0){var m=this._getLineHeight(),g=Math.floor(a/m),y=Math.max(1,Math.min(s,g));f=this._columnX;if(f===-1||e.select&&o.isIE)l=this._getLine(s),f=l.getBoundingClientRect(i).left,l.destroy();l=this._getLine(s-y),r.extend(l.getOffset(f,this._getLineHeight(s-y)-1)),l.destroy(),e.select||r.collapse();var b=Math.max(0,u.y-y*m);this._setSelection(r,!0,!0,function(){t._columnX=f},b-u.y)}return!0},_doPaste:function(e){var t=this,n=this._getClipboardText(e,function(e){if(e){if(o.isLinux&&t._lastMouseButton===2){var n=(new Date).getTime()-t._lastMouseTime;n<=t._clickTime&&t._setSelectionTo(t._lastMouseX,t._lastMouseY)}t._doContent(e)}});return n!==null},_doScroll:function(e){var t=e.type,n=this._model,r=n.getLineCount(),i=this._getClientHeight(),s=this._getLineHeight(),o=r*s,u=this._getScroll().y,a;switch(t){case"textStart":a=0;break;case"textEnd":a=o-i;break;case"pageDown":a=u+i;break;case"pageUp":a=u-i;break;case"lineDown":a=u+s;break;case"lineUp":a=u-s;break;case"centerLine":var f=this._getSelection(),l=n.getLineAtOffset(f.start),c=n.getLineAtOffset(f.end),h=(c-l+1)*s;a=l*s-i/2+h/2}return a!==undefined&&(a=Math.min(Math.max(0,a),o-i),this._scrollViewAnimated(0,a-u,function(){})),!0},_doSelectAll:function(e){var t=this._model,n=this._getSelection();return n.setCaret(0),n.extend(t.getCharCount()),this._setSelection(n,!1),!0},_doTab:function(e){if(!this._tabMode||this._readonly)return;var t=" ";if(this._expandTab){var n=this._model,r=this._getSelection().getCaret(),i=n.getLineAtOffset(r),s=n.getLineStart(i),o=this._tabSize-(r-s)%this._tabSize;t=(new Array(o+1)).join(" ")}return this._doContent(t),!0},_doShiftTab:function(e){if(!this._tabMode||this._readonly)return;return!0},_doOverwriteMode:function(e){if(this._readonly)return;return this.setOptions({overwriteMode:!this.getOptions("overwriteMode")}),!0},_doTabMode:function(e){return this._tabMode=!this._tabMode,!0},_doWrapMode:function(e){return this.setOptions({wrapMode:!this.getOptions("wrapMode")}),!0},_autoScroll:function(){var e=this._model,t=this._getSelection(),n=this.convert({x:this._autoScrollX,y:this._autoScrollY},"page","document"),r=t.getCaret(),i=e.getLineCount(),s=e.getLineAtOffset(r),u,a;if(this._autoScrollDir==="up"||this._autoScrollDir==="down"){var f=this._autoScrollY/this._getLineHeight();f=f<0?Math.floor(f):Math.ceil(f),u=s,u=Math.max(0,Math.min(i-1,u+f))}else if(this._autoScrollDir==="left"||this._autoScrollDir==="right")u=this._getLineIndex(n.y),a=this._getLine(s),n.x+=a.getBoundingClientRect(r,!1).left,a.destroy();u===0&&(o.isMac||o.isLinux)?t.extend(0):u===i-1&&(o.isMac||o.isLinux)?t.extend(e.getCharCount()):(a=this._getLine(u),t.extend(a.getOffset(n.x,n.y-this._getLinePixel(u))),a.destroy()),this._setSelection(t,!0)},_autoScrollTimer:function(){this._autoScroll();var e=this,t=this._getWindow();this._autoScrollTimerID=t.setTimeout(function(){e._autoScrollTimer()},this._AUTO_SCROLL_RATE)},_calculateLineHeightTimer:function(e){if(!this._lineHeight)return;if(this._calculateLHTimer)return;var t=this._model.getLineCount(),n=0;if(e){var r=0,i=100,s=(new Date).getTime(),o=0;while(n<t){this._lineHeight[n]||(r++,o||(o=n),this._lineHeight[n]=this._calculateLineHeight(n)),n++;if((new Date).getTime()-s>i)break}this.redrawRulers(0,t),this._queueUpdate()}var u=this._getWindow();if(n!==t){var a=this;this._calculateLHTimer=u.setTimeout(function(){a._calculateLHTimer=null,a._calculateLineHeightTimer(!0)},0);return}this._calculateLHTimer&&(u.clearTimeout(this._calculateLHTimer),this._calculateLHTimer=undefined)},_calculateLineHeight:function(e){var t=this._getLine(e),n=t.getBoundingClientRect();return t.destroy(),Math.max(1,n.bottom-n.top)},_calculateMetrics:function(){var e=this._clientDiv,t=e.ownerDocument,n=" ",r=o.createElement(t,"div");r.style.lineHeight="normal";var i=this._model,s=i.getLine(0),u={type:"LineStyle",textView:this,0:0,lineText:s,lineStart:0};this.onLineStyle(u),l(u.style,r),r.style.position="fixed",r.style.left="-1000px";var a=o.createElement(t,"span");a.appendChild(t.createTextNode(n)),r.appendChild(a);var f=o.createElement(t,"span");f.style.fontStyle="italic",f.appendChild(t.createTextNode(n)),r.appendChild(f);var c=o.createElement(t,"span");c.style.fontWeight="bold",c.appendChild(t.createTextNode(n)),r.appendChild(c);var h=o.createElement(t,"span");h.style.fontWeight="bold",h.style.fontStyle="italic",h.appendChild(t.createTextNode(n)),r.appendChild(h),e.appendChild(r);var p=r.getBoundingClientRect(),d=a.getBoundingClientRect(),v=f.getBoundingClientRect(),y=c.getBoundingClientRect(),b=h.getBoundingClientRect(),w=d.bottom-d.top,E=v.bottom-v.top,S=y.bottom-y.top,x=b.bottom-b.top,T=0,N=p.bottom-p.top<=0,C=Math.max(1,p.bottom-p.top);E>w&&(T=1),S>E&&(T=2),x>S&&(T=3);var k;T!==0&&(k={style:{}},(T&1)!==0&&(k.style.fontStyle="italic"),(T&2)!==0&&(k.style.fontWeight="bold"));var L=g(r);e.removeChild(r);var A=m(this._viewDiv),O=o.createElement(t,"div");O.style.position="fixed",O.style.left="-1000px",O.style.paddingLeft=A.left+"px",O.style.paddingTop=A.top+"px",O.style.paddingRight=A.right+"px",O.style.paddingBottom=A.bottom+"px",O.style.width="100px",O.style.height="100px";var M=o.createElement(t,"div");M.style.width="100%",M.style.height="100%",O.appendChild(M),e.appendChild(O);var _=O.getBoundingClientRect(),D=M.getBoundingClientRect(),P=0;if(!this._singleMode){O.style.overflow="hidden",M.style.height="200px";var H=O.clientWidth;O.style.overflow="scroll";var B=O.clientWidth;P=H-B}e.removeChild(O),A={left:D.left-_.left,top:D.top-_.top,right:_.right-D.right,bottom:_.bottom-D.bottom};var j=0,F=0;return!N&&(this._wrapOffset||this._marginOffset)&&(O=o.createElement(t,"div"),O.style.position="fixed",O.style.left="-1000px",O.innerHTML=(new Array(this._wrapOffset+1)).join(" "),e.appendChild(O),_=O.getBoundingClientRect(),j=Math.ceil(_.right-_.left),O.innerHTML=(new Array(this._marginOffset+1)).join(" "),D=O.getBoundingClientRect(),F=Math.ceil(D.right-D.left),e.removeChild(O)),{lineHeight:C,largestFontStyle:k,lineTrim:L,viewPadding:A,scrollWidth:P,wrapWidth:j,marginWidth:F,invalid:N}},_cancelAnimation:function(){this._animation&&(this._animation.stop(),this._animation=null)},_clearSelection:function(e){var t=this._getSelection();return t.isEmpty()?!1:(e==="next"?t.start=t.end:t.end=t.start,this._setSelection(t,!0),!0)},_commitIME:function(){if(this._imeOffset===-1)return;this._scrollDiv.focus(),this._clientDiv.focus();var e=this._model,t=e.getLineAtOffset(this._imeOffset),n=e.getLineStart(t),r=this._getDOMText(this._getLineNode(t)).text,i=e.getLine(t),s=this._imeOffset-n,o=s+r.length-i.length;if(s!==o){var u=r.substring(s,o);this._doContent(u)}this._imeOffset=-1},_createActions:function(){this.addKeyMode(new n.DefaultKeyMode(this));var t=this;this._actions={noop:{defaultHandler:function(){return t._doNoop()}},lineUp:{defaultHandler:function(e){return t._doLineUp(h(e,{select:!1}))},actionDescription:{name:e.lineUp}},lineDown:{defaultHandler:function(e){return t._doLineDown(h(e,{select:!1}))},actionDescription:{name:e.lineDown}},lineStart:{defaultHandler:function(e){return t._doHome(h(e,{select:!1,ctrl:!1}))},actionDescription:{name:e.lineStart}},lineEnd:{defaultHandler:function(e){return t._doEnd(h(e,{select:!1,ctrl:!1}))},actionDescription:{name:e.lineEnd}},charPrevious:{defaultHandler:function(e){return t._doCursorPrevious(h(e,{select:!1,unit:"character"}))},actionDescription:{name:e.charPrevious}},charNext:{defaultHandler:function(e){return t._doCursorNext(h(e,{select:!1,unit:"character"}))},actionDescription:{name:e.charNext}},pageUp:{defaultHandler:function(e){return t._doPageUp(h(e,{select:!1}))},actionDescription:{name:e.pageUp}},pageDown:{defaultHandler:function(e){return t._doPageDown(h(e,{select:!1}))},actionDescription:{name:e.pageDown}},scrollPageUp:{defaultHandler:function(e){return t._doScroll(h(e,{type:"pageUp"}))},actionDescription:{name:e.scrollPageUp}},scrollPageDown:{defaultHandler:function(e){return t._doScroll(h(e,{type:"pageDown"}))},actionDescription:{name:e.scrollPageDown}},scrollLineUp:{defaultHandler:function(e){return t._doScroll(h(e,{type:"lineUp"}))},actionDescription:{name:e.scrollLineUp}},scrollLineDown:{defaultHandler:function(e){return t._doScroll(h(e,{type:"lineDown"}))},actionDescription:{name:e.scrollLineDown}},wordPrevious:{defaultHandler:function(e){return t._doCursorPrevious(h(e,{select:!1,unit:"word"}))},actionDescription:{name:e.wordPrevious}},wordNext:{defaultHandler:function(e){return t._doCursorNext(h(e,{select:!1,unit:"word"}))},actionDescription:{name:e.wordNext}},textStart:{defaultHandler:function(e){return t._doHome(h(e,{select:!1,ctrl:!0}))},actionDescription:{name:e.textStart}},textEnd:{defaultHandler:function(e){return t._doEnd(h(e,{select:!1,ctrl:!0}))},actionDescription:{name:e.textEnd}},scrollTextStart:{defaultHandler:function(e){return t._doScroll(h(e,{type:"textStart"}))},actionDescription:{name:e.scrollTextStart}},scrollTextEnd:{defaultHandler:function(e){return t._doScroll(h(e,{type:"textEnd"}))},actionDescription:{name:e.scrollTextEnd}},centerLine:{defaultHandler:function(e){return t._doScroll(h(e,{type:"centerLine"}))},actionDescription:{name:e.centerLine}},selectLineUp:{defaultHandler:function(e){return t._doLineUp(h(e,{select:!0}))},actionDescription:{name:e.selectLineUp}},selectLineDown:{defaultHandler:function(e){return t._doLineDown(h(e,{select:!0}))},actionDescription:{name:e.selectLineDown}},selectWholeLineUp:{defaultHandler:function(e){return t._doLineUp(h(e,{select:!0,wholeLine:!0}))},actionDescription:{name:e.selectWholeLineUp}},selectWholeLineDown:{defaultHandler:function(e){return t._doLineDown(h(e,{select:!0,wholeLine:!0}))},actionDescription:{name:e.selectWholeLineDown}},selectLineStart:{defaultHandler:function(e){return t._doHome(h(e,{select:!0,ctrl:!1}))},actionDescription:{name:e.selectLineStart}},selectLineEnd:{defaultHandler:function(e){return t._doEnd(h(e,{select:!0,ctrl:!1}))},actionDescription:{name:e.selectLineEnd}},selectCharPrevious:{defaultHandler:function(e){return t._doCursorPrevious(h(e,{select:!0,unit:"character"}))},actionDescription:{name:e.selectCharPrevious}},selectCharNext:{defaultHandler:function(e){return t._doCursorNext(h(e,{select:!0,unit:"character"}))},actionDescription:{name:e.selectCharNext}},selectPageUp:{defaultHandler:function(e){return t._doPageUp(h(e,{select:!0}))},actionDescription:{name:e.selectPageUp}},selectPageDown:{defaultHandler:function(e){return t._doPageDown(h(e,{select:!0}))},actionDescription:{name:e.selectPageDown}},selectWordPrevious:{defaultHandler:function(e){return t._doCursorPrevious(h(e,{select:!0,unit:"word"}))},actionDescription:{name:e.selectWordPrevious}},selectWordNext:{defaultHandler:function(e){return t._doCursorNext(h(e,{select:!0,unit:"word"}))},actionDescription:{name:e.selectWordNext}},selectTextStart:{defaultHandler:function(e){return t._doHome(h(e,{select:!0,ctrl:!0}))},actionDescription:{name:e.selectTextStart}},selectTextEnd:{defaultHandler:function(e){return t._doEnd(h(e,{select:!0,ctrl:!0}))},actionDescription:{name:e.selectTextEnd}},deletePrevious:{defaultHandler:function(e){return t._doBackspace(h(e,{unit:"character"}))},actionDescription:{name:e.deletePrevious}},deleteNext:{defaultHandler:function(e){return t._doDelete(h(e,{unit:"character"}))},actionDescription:{name:e.deleteNext}},deleteWordPrevious:{defaultHandler:function(e){return t._doBackspace(h(e,{unit:"word"}))},actionDescription:{name:e.deleteWordPrevious}},deleteWordNext:{defaultHandler:function(e){return t._doDelete(h(e,{unit:"word"}))},actionDescription:{name:e.deleteWordNext}},deleteLineStart:{defaultHandler:function(e){return t._doBackspace(h(e,{unit:"line"}))},actionDescription:{name:e.deleteLineStart}},deleteLineEnd:{defaultHandler:function(e){return t._doDelete(h(e,{unit:"line"}))},actionDescription:{name:e.deleteLineEnd}},tab:{defaultHandler:function(e){return t._doTab()},actionDescription:{name:e.tab}},shiftTab:{defaultHandler:function(e){return t._doShiftTab()},actionDescription:{name:e.shiftTab}},enter:{defaultHandler:function(e){return t._doEnter()},actionDescription:{name:e.enter}},enterNoCursor:{defaultHandler:function(e){return t._doEnter(h(e,{noCursor:!0}))},actionDescription:{name:e.enterNoCursor}},selectAll:{defaultHandler:function(e){return t._doSelectAll()},actionDescription:{name:e.selectAll}},copy:{defaultHandler:function(e){return t._doCopy()},actionDescription:{name:e.copy}},cut:{defaultHandler:function(e){return t._doCut()},actionDescription:{name:e.cut}},paste:{defaultHandler:function(e){return t._doPaste()},actionDescription:{name:e.paste}},uppercase:{defaultHandler:function(e){return t._doCase(h(e,{type:"upper"}))},actionDescription:{name:e.uppercase}},lowercase:{defaultHandler:function(e){return t._doCase(h(e,{type:"lower"}))},actionDescription:{name:e.lowercase}},capitalize:{defaultHandler:function(e){return t._doCase(h(e,{unit:"word",type:"capitalize"}))},actionDescription:{name:e.capitalize}},reversecase:{defaultHandler:function(e){return t._doCase(h(e,{type:"reverse"}))},actionDescription:{name:e.reversecase}},toggleOverwriteMode:{defaultHandler:function(e){return t._doOverwriteMode()},actionDescription:{name:e.toggleOverwriteMode}},toggleTabMode:{defaultHandler:function(e){return t._doTabMode()},actionDescription:{name:e.toggleTabMode}},toggleWrapMode:{defaultHandler:function(e){return t._doWrapMode()},actionDescription:{name:e.toggleWrapMode}}}},_createRulerParent:function(e){var t=o.createElement(document,"div");return t.className=e,t.tabIndex=-1,t.style.overflow="hidden",t.style.MozUserSelect="none",t.style.WebkitUserSelect="none",t.style.position="absolute",t.style.top="0px",t.style.bottom="0px",t.style.cursor="default",t.style.display="none",t.setAttribute("aria-hidden","true"),this._rootDiv.appendChild(t),t},_createRuler:function(e,t){if(!this._clientDiv)return;var n=this._getRulerParent(e);if(!n)return;if(n!==this._marginDiv||this._marginOffset)n.style.display="block";var r=o.createElement(n.ownerDocument,"div");r._ruler=e,r.rulerChanged=!0,r.style.position="relative",r.style.cssFloat="left",r.style.styleFloat="left",r.style.outline="none";if(t===undefined||t<0||t>=n.children.length)n.appendChild(r);else{var i=n.firstChild;while(i&&t-->0)i=i.nextSibling;n.insertBefore(r,i)}},_createView:function(){if(this._clientDiv)return;var e=this._parent;while(e.hasChildNodes())e.removeChild(e.lastChild);var t=e.ownerDocument,n=o.createElement(t,"div");this._rootDiv=n,n.tabIndex=-1,n.style.position="relative",n.style.overflow="hidden",n.style.width="100%",n.style.height="100%",n.style.overflow="hidden",n.style.WebkitTextSizeAdjust="100%",n.setAttribute("role","application"),e.appendChild(n);var r=this._leftDiv=this._createRulerParent("textviewLeftRuler"),i=o.createElement(t,"div");i.className="textviewScroll",this._viewDiv=i,i.tabIndex=-1,i.style.position="absolute",i.style.top="0px",i.style.bottom="0px",i.style.borderWidth="0px",i.style.margin="0px",i.style.outline="none",i.style.background="transparent",o.isMac&&o.isWebkit&&(i.style.pointerEvents="none",i.style.zIndex="2"),n.appendChild(i);var s=this._rightDiv=this._createRulerParent("textviewRightRuler");s.style.right="0px";var u=o.createElement(t,"div");this._scrollDiv=u,u.style.margin="0px",u.style.borderWidth="0px",u.style.padding="0px",i.appendChild(u);var a=this._marginDiv=this._createRulerParent("textviewMarginRuler");a.style.zIndex="4";if(!o.isIE&&!o.isIOS){var f=o.createElement(t,"div");this._clipDiv=f,f.style.position="absolute",f.style.overflow="hidden",f.style.margin="0px",f.style.borderWidth="0px",f.style.padding="0px",f.style.background="transparent",n.appendChild(f);var l=o.createElement(t,"div");this._clipScrollDiv=l,l.style.position="absolute",l.style.height="1px",l.style.top="-1000px",l.style.background="transparent",f.appendChild(l)}this._setFullSelection(this._fullSelection,!0);var c=o.createElement(t,"div");c.className="textviewContent",this._clientDiv=c,c.tabIndex=0,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(o.isIOS||o.isAndroid)c.style.WebkitTapHighlightColor="transparent";(this._clipDiv||n).appendChild(c);if(o.isIOS||o.isAndroid){var h=o.createElement(t,"div");this._vScrollDiv=h,h.style.position="absolute",h.style.borderWidth="1px",h.style.borderColor="white",h.style.borderStyle="solid",h.style.borderRadius="4px",h.style.backgroundColor="black",h.style.opacity="0.5",h.style.margin="0px",h.style.padding="0px",h.style.outline="none",h.style.zIndex="3",h.style.width="8px",h.style.display="none",n.appendChild(h);var p=o.createElement(t,"div");this._hScrollDiv=p,p.style.position="absolute",p.style.borderWidth="1px",p.style.borderColor="white",p.style.borderStyle="solid",p.style.borderRadius="4px",p.style.backgroundColor="black",p.style.opacity="0.5",p.style.margin="0px",p.style.padding="0px",p.style.outline="none",p.style.zIndex="3",p.style.height="8px",p.style.display="none",n.appendChild(p)}if(o.isFirefox&&!c.setCapture){var d=o.createElement(t,"div");this._overlayDiv=d,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||n).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),this._setMarginOffset(this._marginOffset,!0),this._hookEvents();var v=this._rulers;for(var m=0;m<v.length;m++)this._createRuler(v[m]);this._update()},_defaultOptions:function(){return{parent:{value:undefined,update:null},model:{value:undefined,update:this.setModel},scrollAnimation:{value:0,update:null},readonly:{value:!1,update:this._setReadOnly},fullSelection:{value:!0,update:this._setFullSelection},tabMode:{value:!0,update:null},tabSize:{value:8,update:this._setTabSize},expandTab:{value:!1,update:null},singleMode:{value:!1,update:this._setSingleMode},overwriteMode:{value:!1,update:this._setOverwriteMode},blockCursorVisible:{value:!1,update:this._setBlockCursor},marginOffset:{value:0,update:this._setMarginOffset},wrapOffset:{value:0,update:this._setWrapOffset},wrapMode:{value:!1,update:this._setWrapMode},wrappable:{value:!1,update:null},theme:{value:i.TextTheme.getTheme(),update:this._setTheme},themeClass:{value:undefined,update:this._setThemeClass}}},_destroyRuler:function(e){var t=this._getRulerParent(e);if(t){var n=t.firstChild;while(n){if(n._ruler===e){n._ruler=undefined,t.removeChild(n),t.children.length===0&&(t!==this._marginDiv||!this._marginOffset)&&(t.style.display="none");break}n=n.nextSibling}}},_destroyView:function(){var e=this._clientDiv;if(!e)return;this._setGrab(null),this._unhookEvents();var t=this._getWindow();this._autoScrollTimerID&&(t.clearTimeout(this._autoScrollTimerID),this._autoScrollTimerID=null),this._updateTimer&&(t.clearTimeout(this._updateTimer),this._updateTimer=null);var n=this._rootDiv;n.parentNode.removeChild(n),this._selDiv1=null,this._selDiv2=null,this._selDiv3=null,this._clipboardDiv=null,this._rootDiv=null,this._scrollDiv=null,this._viewDiv=null,this._clipDiv=null,this._clipScrollDiv=null,this._clientDiv=null,this._overlayDiv=null,this._leftDiv=null,this._rightDiv=null,this._marginDiv=null,this._cursorDiv=null,this._vScrollDiv=null,this._hScrollDiv=null},_doAutoScroll:function(e,t,n){this._autoScrollDir=e,this._autoScrollX=t,this._autoScrollY=n,this._autoScrollTimerID||this._autoScrollTimer()},_endAutoScroll:function(){if(this._autoScrollTimerID){var e=this._getWindow();e.clearTimeout(this._autoScrollTimerID)}this._autoScrollDir=undefined,this._autoScrollTimerID=undefined},_fixCaret:function(){var e=this._clientDiv;if(e){var t=this._hasFocus;this._ignoreFocus=!0,t&&e.blur(),e.contentEditable=!1,e.contentEditable=!0,t&&e.focus(),this._ignoreFocus=!1}},_getBaseText:function(e,t){var n=this._model;return n.getBaseModel&&(e=n.mapOffset(e),t=n.mapOffset(t),n=n.getBaseModel()),n.getText(e,t)},_getBottomIndex:function(e){var t=this._bottomChild;if(e&&this._getClientHeight()>this._getLineHeight()){var n=t.getBoundingClientRect(),r=this._clientDiv.getBoundingClientRect();n.bottom>r.bottom&&(t=this._getLinePrevious(t)||t)}return t.lineIndex},_getBoundsAtOffset:function(e){var t=this._model,n=this._getLine(t.getLineAtOffset(e)),r=n.getBoundingClientRect(e),i=this._getLinePixel(n.lineIndex);return r.top+=i,r.bottom+=i,n.destroy(),r},_getClientHeight:function(){var e=this._getViewPadding();return Math.max(0,this._viewDiv.clientHeight-e.top-e.bottom)},_getClientWidth:function(){var e=this._getViewPadding();return Math.max(0,this._viewDiv.clientWidth-e.left-e.right)},_getClipboardText:function(e,t){var n=this._model.getLineDelimiter(),r,i,s=this._getWindow(),u=s.clipboardData;!u&&e&&(u=e.clipboardData);if(u)return r=[],i=u.getData(o.isIE?"Text":"text/plain"),d(i,function(e){r.push(e)},function(){r.push(n)}),i=r.join(""),t&&t(i),i;if(o.isFirefox){this._ignoreFocus=!0;var a=this._clipboardDiv,f=this._rootDiv.ownerDocument;a||(a=o.createElement(f,"div"),this._clipboardDiv=a,a.style.position="fixed",a.style.whiteSpace="pre",a.style.left="-1000px",this._rootDiv.appendChild(a)),a.innerHTML="<pre contenteditable=''></pre>",a.firstChild.focus();var l=this,c=function(){var e=l._getTextFromElement(a);return a.innerHTML="",r=[],d(e,function(e){r.push(e)},function(){r.push(n)}),r.join("")},h=!1;this._ignorePaste=!0;if(!o.isLinux||this._lastMouseButton!==2)try{h=f.execCommand("paste",!1,null)}catch(p){h=a.childNodes.length>1||a.firstChild&&a.firstChild.childNodes.length>0}return this._ignorePaste=!1,h?(this.focus(),this._ignoreFocus=!1,i=c(),i&&t&&t(i),i):e?(s.setTimeout(function(){l.focus(),i=c(),i&&t&&t(i),l._ignoreFocus=!1},0),null):(this.focus(),this._ignoreFocus=!1,"")}return""},_getDOMText:function(e,t){var n=e.firstChild,r="",i=0;while(n){var s;if(n.ignore){n=n.nextSibling;continue}if(n.ignoreChars){s=n.lastChild;var o=0,u=[],a=-1;while(s){var f=s.data;for(var l=f.length-1;l>=0;l--){var c=f.substring(l,l+1);o<n.ignoreChars&&(c===" "||c==="\u200c"||c==="\ufeff")?o++:u.push(c==="\u00a0"?" ":c)}t===s&&(a=u.length),s=s.previousSibling}u=u.reverse().join(""),a!==-1&&(i=r.length+u.length-a),r+=u}else{s=n.firstChild;while(s)t===s&&(i=r.length),r+=s.data,s=s.nextSibling}n=n.nextSibling}return{text:r,offset:i}},_getTextFromElement:function(e){var t=e.ownerDocument,n=t.defaultView;if(!n.getSelection)return e.innerText||e.textContent;var r=t.createRange();r.selectNode(e);var i=n.getSelection(),s=[],o;for(o=0;o<i.rangeCount;o++)s.push(i.getRangeAt(o));this._ignoreSelect=!0,i.removeAllRanges(),i.addRange(r);var u=i.toString();i.removeAllRanges();for(o=0;o<s.length;o++)i.addRange(s[o]);return this._ignoreSelect=!1,u},_getViewPadding:function(){return this._metrics.viewPadding},_getLine:function(e){var t=this._getLineNode(e);return t&&!t.lineChanged&&!t.lineRemoved?t._line:new E(this,e)},_getLineHeight:function(e,t){if(e!==undefined&&this._lineHeight){var n=this._lineHeight[e];if(n)return n;if(t||t===undefined){var r=this._lineHeight[e]=this._calculateLineHeight(e);return r}}return this._metrics.lineHeight},_getLineNode:function(e){var t=this._clientDiv,n=t.firstChild;while(n){if(e===n.lineIndex)return n;n=n.nextSibling}return undefined},_getLineNext:function(e){var t=e?e.nextSibling:this._clientDiv.firstChild;while(t&&t.lineIndex===-1)t=t.nextSibling;return t},_getLinePrevious:function(e){var t=e?e.previousSibling:this._clientDiv.lastChild;while(t&&t.lineIndex===-1)t=t.previousSibling;return t},_getLinePixel:function(e){e=Math.min(Math.max(0,e),this._model.getLineCount());if(this._lineHeight){var t=this._getTopIndex(),n=-this._topIndexY+this._getScroll().y,r;if(e>t)for(r=t;r<e;r++)n+=this._getLineHeight(r);else for(r=t-1;r>=e;r--)n-=this._getLineHeight(r);return n}var i=this._getLineHeight();return i*e},_getLineIndex:function(e){var t,n=0,r=this._model.getLineCount();if(this._lineHeight){n=this._getTopIndex();var i=-this._topIndexY+this._getScroll().y;if(e!==i)if(e<i)while(e<i&&n>0)e+=this._getLineHeight(--n);else{t=this._getLineHeight(n);while(e-t>=i&&n<r-1)e-=t,t=this._getLineHeight(++n)}}else t=this._getLineHeight(),n=Math.floor(e/t);return Math.max(0,Math.min(r-1,n))},_getRulerParent:function(e){switch(e.getLocation()){case"left":return this._leftDiv;case"right":return this._rightDiv;case"margin":return this._marginDiv}return null},_getScroll:function(e){(e===undefined||e)&&this._cancelAnimation();var t=this._viewDiv;return{x:t.scrollLeft,y:t.scrollTop}},_getSelection:function(){return this._selection.clone()},_getTopIndex:function(e){var t=this._topChild;if(e&&this._getClientHeight()>this._getLineHeight()){var n=t.getBoundingClientRect(),r=this._getViewPadding(),i=this._viewDiv.getBoundingClientRect();n.top<i.top+r.top&&(t=this._getLineNext(t)||t)}return t.lineIndex},_hookEvents:function(){var e=this;this._modelListener={onChanging:function(t){e._onModelChanging(t)},onChanged:function(t){e._onModelChanged(t)}},this._model.addEventListener("preChanging",this._modelListener.onChanging),this._model.addEventListener("postChanged",this._modelListener.onChanged),this._themeListener={onChanged:function(t){e._setThemeClass(e._themeClass)}},this._theme.addEventListener("ThemeChanged",this._themeListener.onChanged);var t=this._handlers=[],n=this._clientDiv,r=this._viewDiv,i=this._rootDiv,s=this._overlayDiv||n,u=n.ownerDocument,f=this._getWindow(),l=o.isIE?u:f;t.push({target:f,type:"resize",handler:function(t){return e._handleResize(t?t:f.event)}}),t.push({target:n,type:"blur",handler:function(t){return e._handleBlur(t?t:f.event)}}),t.push({target:n,type:"focus",handler:function(t){return e._handleFocus(t?t:f.event)}}),t.push({target:r,type:"focus",handler:function(e){n.focus()}}),t.push({target:r,type:"scroll",handler:function(t){return e._handleScroll(t?t:f.event)}}),t.push({target:n,type:"textInput",handler:function(t){return e._handleTextInput(t?t:f.event)}}),t.push({target:n,type:"keydown",handler:function(t){return e._handleKeyDown(t?t:f.event)}}),t.push({target:n,type:"keypress",handler:function(t){return e._handleKeyPress(t?t:f.event)}}),t.push({target:n,type:"keyup",handler:function(t){return e._handleKeyUp(t?t:f.event)}}),o.isIE&&t.push({target:u,type:"keyup",handler:function(t){return e._handleDocKeyUp(t?t:f.event)}}),t.push({target:n,type:"contextmenu",handler:function(t){return e._handleContextMenu(t?t:f.event)}}),t.push({target:n,type:"copy",handler:function(t){return e._handleCopy(t?t:f.event)}}),t.push({target:n,type:"cut",handler:function(t){return e._handleCut(t?t:f.event)}}),t.push({target:n,type:"paste",handler:function(t){return e._handlePaste(t?t:f.event)}});if(o.isIOS||o.isAndroid)t.push({target:u,type:"selectionchange",handler:function(t){return e._handleSelectionChange(t?t:f.event)}}),t.push({target:n,type:"touchstart",handler:function(t){return e._handleTouchStart(t?t:f.event)}}),t.push({target:n,type:"touchmove",handler:function(t){return e._handleTouchMove(t?t:f.event)}}),t.push({target:n,type:"touchend",handler:function(t){return e._handleTouchEnd(t?t:f.event)}});else{t.push({target:n,type:"selectstart",handler:function(t){return e._handleSelectStart(t?t:f.event)}}),t.push({target:n,type:"mousedown",handler:function(t){return e._handleMouseDown(t?t:f.event)}}),t.push({target:n,type:"mouseover",handler:function(t){return e._handleMouseOver(t?t:f.event)}}),t.push({target:n,type:"mouseout",handler:function(t){return e._handleMouseOut(t?t:f.event)}}),t.push({target:l,type:"mouseup",handler:function(t){return e._handleMouseUp(t?t:f.event)}}),t.push({target:l,type:"mousemove",handler:function(t){return e._handleMouseMove(t?t:f.event)}}),t.push({target:i,type:"mousedown",handler:function(t){return e._handleRootMouseDown(t?t:f.event)}}),t.push({target:i,type:"mouseup",handler:function(t){return e._handleRootMouseUp(t?t:f.event)}}),t.push({target:s,type:"dragstart",handler:function(t){return e._handleDragStart(t?t:f.event)}}),t.push({target:s,type:"drag",handler:function(t){return e._handleDrag(t?t:f.event)}}),t.push({target:s,type:"dragend",handler:function(t){return e._handleDragEnd(t?t:f.event)}}),t.push({target:s,type:"dragenter",handler:function(t){return e._handleDragEnter(t?t:f.event)}}),t.push({target:s,type:"dragover",handler:function(t){return e._handleDragOver(t?t:f.event)}}),t.push({target:s,type:"dragleave",handler:function(t){return e._handleDragLeave(t?t:f.event)}}),t.push({target:s,type:"drop",handler:function(t){return e._handleDrop(t?t:f.event)}}),t.push({target:this._clientDiv,type:o.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(t){return e._handleMouseWheel(t?t:f.event)}}),this._clipDiv&&t.push({target:this._clipDiv,type:o.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(t){return e._handleMouseWheel(t?t:f.event)}});if(o.isFirefox&&(!o.isWindows||o.isFirefox>=15)){var c=f.MutationObserver||f.MozMutationObserver;c?(this._mutationObserver=new c(function(t){e._handleDataModified(t)}),this._mutationObserver.observe(n,{subtree:!0,characterData:!0})):t.push({target:this._clientDiv,type:"DOMCharacterDataModified",handler:function(t){return e._handleDataModified(t?t:f.event)}})}this._overlayDiv&&(t.push({target:this._overlayDiv,type:"mousedown",handler:function(t){return e._handleMouseDown(t?t:f.event)}}),t.push({target:this._overlayDiv,type:"mouseover",handler:function(t){return e._handleMouseOver(t?t:f.event)}}),t.push({target:this._overlayDiv,type:"mouseout",handler:function(t){return e._handleMouseOut(t?t:f.event)}}),t.push({target:this._overlayDiv,type:"contextmenu",handler:function(t){return e._handleContextMenu(t?t:f.event)}})),this._isW3CEvents||t.push({target:this._clientDiv,type:"dblclick",handler:function(t){return e._handleDblclick(t?t:f.event)}})}this._hookRulerEvents(this._leftDiv,t),this._hookRulerEvents(this._rightDiv,t),this._hookRulerEvents(this._marginDiv,t);for(var h=0;h<t.length;h++){var p=t[h];a(p.target,p.type,p.handler,p.capture)}},_hookRulerEvents:function(e,t){if(!e)return;var n=this,r=this._getWindow();o.isIE&&t.push({target:e,type:"selectstart",handler:function(){return!1}}),t.push({target:e,type:o.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(e){return n._handleMouseWheel(e?e:r.event)}}),t.push({target:e,type:"click",handler:function(e){n._handleRulerEvent(e?e:r.event)}}),t.push({target:e,type:"dblclick",handler:function(e){n._handleRulerEvent(e?e:r.event)}}),t.push({target:e,type:"mousemove",handler:function(e){n._handleRulerEvent(e?e:r.event)}}),t.push({target:e,type:"mouseover",handler:function(e){n._handleRulerEvent(e?e:r.event)}}),t.push({target:e,type:"mouseout",handler:function(e){n._handleRulerEvent(e?e:r.event)}})},_getWindow:function(){return u(this._parent.ownerDocument)},_ignoreEvent:function(e){var t=e.target;while(t&&t!==this._clientDiv){if(t.ignore)return!0;t=t.parentNode}return!1},_init:function(e){var n=e.parent;typeof n=="string"&&(n=(e.document||document).getElementById(n));if(!n)throw"no parent";e.parent=n,e.model=e.model||new t.TextModel;var r=this._defaultOptions();for(var i in r)if(r.hasOwnProperty(i)){var s;e[i]!==undefined?s=e[i]:s=r[i].value,this["_"+i]=s}this._keyModes=[],this._rulers=[],this._selection=new b(0,0,!1),this._linksVisible=!1,this._redrawCount=0,this._maxLineWidth=0,this._maxLineIndex=-1,this._ignoreSelect=!0,this._ignoreFocus=!1,this._hasFocus=!1,this._columnX=-1,this._dragOffset=-1,this._isRangeRects=(!o.isIE||o.isIE>=9)&&typeof n.ownerDocument.createRange().getBoundingClientRect=="function",this._isW3CEvents=n.addEventListener,this._autoScrollX=null,this._autoScrollY=null,this._autoScrollTimerID=null,this._AUTO_SCROLL_RATE=50,this._grabControl=null,this._moseMoveClosure=null,this._mouseUpClosure=null,this._lastMouseX=0,this._lastMouseY=0,this._lastMouseTime=0,this._clickCount=0,this._clickTime=250,this._clickDist=5,this._isMouseDown=!1,this._doubleClickSelection=null,this._hScroll=0,this._vScroll=0,this._imeOffset=-1,this._createActions(),this._createView()},_modifyContent:function(e,t){if(this._readonly&&!e._code)return;e.type="Verify",this.onVerify(e);if(e.text===null||e.text===undefined)return;var n=this._model;try{e._ignoreDOMSelection&&(this._ignoreDOMSelection=!0),n.setText(e.text,e.start,e.end)}finally{e._ignoreDOMSelection&&(this._ignoreDOMSelection=!1)}if(t){var r=this._getSelection();r.setCaret(e.start+e.text.length),this._setSelection(r,!0)}this.onModify({type:"Modify"})},_onModelChanged:function(e){e.type="ModelChanged",this.onModelChanged(e),e.type="Changed";var t=e.start,n=e.addedCharCount,r=e.removedCharCount,i=e.addedLineCount,s=e.removedLineCount,o=this._getSelection();o.end>t&&(o.end>t&&o.start<t+r?o.setCaret(t+n):(o.start+=n-r,o.end+=n-r),this._setSelection(o,!1,!1));var u=this._model,a=u.getLineAtOffset(t),f=this._getLineNext();while(f){var l=f.lineIndex;a<=l&&l<=a+s&&(a===l&&!f.modelChangedEvent&&!f.lineRemoved?(f.modelChangedEvent=e,f.lineChanged=!0):(f.lineRemoved=!0,f.lineChanged=!1,f.modelChangedEvent=null)),l>a+s&&(f.lineIndex=l+i-s,f._line.lineIndex=f.lineIndex),f=this._getLineNext(f)}if(this._lineHeight){var c=[a,s].concat(new Array(i));Array.prototype.splice.apply(this._lineHeight,c)}this._wrapMode||a<=this._maxLineIndex&&this._maxLineIndex<=a+s&&(this._checkMaxLineIndex=this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0),this._update()},_onModelChanging:function(e){e.type="ModelChanging",this.onModelChanging(e),e.type="Changing"},_queueUpdate:function(){if(this._updateTimer||this._ignoreQueueUpdate)return;var e=this,t=this._getWindow();this._updateTimer=t.setTimeout(function(){e._updateTimer=null,e._update()},0)},_resetLineHeight:function(e,t){if(this._wrapMode||this._variableLineHeight){if(e!==undefined&&t!==undefined)for(var n=e;n<t;n++)this._lineHeight[n]=undefined;else this._lineHeight=new Array(this._model.getLineCount());this._calculateLineHeightTimer()}else this._lineHeight=null},_resetLineWidth:function(){var e=this._clientDiv;if(e){var t=e.firstChild;while(t)t.lineWidth=undefined,t=t.nextSibling}},_reset:function(){this._maxLineIndex=-1,this._maxLineWidth=0,this._columnX=-1,this._topChild=null,this._bottomChild=null,this._topIndexY=0,this._variableLineHeight=!1,this._resetLineHeight(),this._setSelection(new b(0,0,!1),!1,!1),this._viewDiv&&(this._viewDiv.scrollLeft=0,this._viewDiv.scrollTop=0);var e=this._clientDiv;if(e){var t=e.firstChild;while(t)t.lineRemoved=!0,t=t.nextSibling;if(o.isFirefox){this._ignoreFocus=!1;var n=this._hasFocus;n&&e.blur(),e.contentEditable=!1,e.contentEditable=!0,n&&e.focus(),this._ignoreFocus=!1}}},_scrollViewAnimated:function(e,t,n){var r=this._getWindow();if(n&&this._scrollAnimation){var i=this;this._animation=new y({window:r,duration:this._scrollAnimation,curve:[t,0],onAnimate:function(e){var n=t-Math.floor(e);i._scrollView(0,n),t-=n},onEnd:function(){i._animation=null,i._scrollView(e,t),n&&r.setTimeout(n,0)}}),this._animation.play()}else this._scrollView(e,t),n&&r.setTimeout(n,0)},_scrollView:function(e,t){this._ensureCaretVisible=!1;var n=this._viewDiv;e&&(n.scrollLeft+=e),t&&(n.scrollTop+=t)},_setClipboardText:function(e,t){var n,r=this._getWindow(),i=r.clipboardData;!i&&t&&(i=t.clipboardData);if(i){n=[],d(e,function(e){n.push(e)},function(){n.push(o.platformDelimiter)});if(i.setData(o.isIE?"Text":"text/plain",n.join("")))return!0}var s=this._parent.ownerDocument,u=o.createElement(s,"pre");u.style.position="fixed",u.style.left="-1000px",d(e,function(e){u.appendChild(s.createTextNode(e))},function(){u.appendChild(o.createElement(s,"br"))}),u.appendChild(s.createTextNode(" ")),this._clientDiv.appendChild(u);var a=s.createRange();a.setStart(u.firstChild,0),a.setEndBefore(u.lastChild);var f=r.getSelection();f.rangeCount>0&&f.removeAllRanges(),f.addRange(a);var l=this,c=function(){u&&u.parentNode===l._clientDiv&&l._clientDiv.removeChild(u),l._updateDOMSelection()},h=!1;this._ignoreCopy=!0;try{h=s.execCommand("copy",!1,null)}catch(p){}return this._ignoreCopy=!1,!h&&t?(r.setTimeout(c,0),!1):(c(),!0)},_setDOMSelection:function(e,t,n,r,i){var s,u,a,f,l=0,c=e.firstChild,h,p,d=this._model,v=d.getLine(e.lineIndex).length;while(c){if(c.ignore){c=c.nextSibling;continue}h=c.firstChild,p=h.length,c.ignoreChars&&(p-=c.ignoreChars);if(l+p>t||l+p>=v){s=h,u=t-l,c.ignoreChars&&p>0&&u===p&&(u+=c.ignoreChars);break}l+=p,c=c.nextSibling}l=0,c=n.firstChild;var m=this._model.getLine(n.lineIndex).length;while(c){if(c.ignore){c=c.nextSibling;continue}h=c.firstChild,p=h.length,c.ignoreChars&&(p-=c.ignoreChars);if(p+l>r||l+p>=m){a=h,f=r-l,c.ignoreChars&&p>0&&f===p&&(f+=c.ignoreChars);break}l+=p,c=c.nextSibling}this._setDOMFullSelection(e,t,v,n,r,m);var g,y=this._getWindow(),b=this._parent.ownerDocument;if(y.getSelection){var w=y.getSelection();g=b.createRange(),g.setStart(s,u),g.setEnd(a,f),this._hasFocus&&(w.anchorNode!==s||w.anchorOffset!==u||w.focusNode!==a||w.focusOffset!==f||w.anchorNode!==a||w.anchorOffset!==f||w.focusNode!==s||w.focusOffset!==u)&&(this._ignoreSelect=!1,w.rangeCount>0&&w.removeAllRanges(),w.addRange(g),this._ignoreSelect=!0);if(this._cursorDiv){g=b.createRange(),i?(g.setStart(s,u),g.setEnd(s,u)):(g.setStart(a,f),g.setEnd(a,f));var E=g.getClientRects()[0],S=this._cursorDiv.parentNode,x=S.getBoundingClientRect();E&&x&&(this._cursorDiv.style.top=E.top-x.top+S.scrollTop+"px",this._cursorDiv.style.left=E.left-x.left+S.scrollLeft+"px")}}else if(b.selection){if(!this._hasFocus)return;var T=b.body,N=o.createElement(b,"div");T.appendChild(N),T.removeChild(N),g=T.createTextRange(),g.moveToElementText(s.parentNode),g.moveStart("character",u);var C=T.createTextRange();C.moveToElementText(a.parentNode),C.moveStart("character",f),g.setEndPoint("EndToStart",C),this._ignoreSelect=!1,g.select(),this._ignoreSelect=!0}},_setDOMFullSelection:function(e,t,n,r,i,s){if(!this._selDiv1)return;var o=this._selDiv1;o.style.width="0px",o.style.height="0px",o=this._selDiv2,o.style.width="0px",o.style.height="0px",o=this._selDiv3,o.style.width="0px",o.style.height="0px";if(e===r&&t===i)return;var u=this._model,a=this._getViewPadding(),f=this._clientDiv.getBoundingClientRect(),l=this._viewDiv.getBoundingClientRect(),c=l.left+a.left,h=f.right,p=l.top+a.top,d=f.bottom,v=0,m=0;if(this._clipDiv){var g=this._clipDiv.getBoundingClientRect();v=g.left-this._clipDiv.scrollLeft,m=g.top}else{var y=this._rootDiv.getBoundingClientRect();v=y.left,m=y.top}this._ignoreDOMSelection=!0;var b=new E(this,e.lineIndex,e),w=b.getBoundingClientRect(u.getLineStart(e.lineIndex)+t,!1),S=w.left,x=new E(this,r.lineIndex,r),T=x.getBoundingClientRect(u.getLineStart(r.lineIndex)+i,!1),N=T.left;this._ignoreDOMSelection=!1;var C=this._selDiv1,k=Math.min(h,Math.max(c,S)),L=Math.min(d,Math.max(p,w.top)),A=h,O=Math.min(d,Math.max(p,w.bottom));C.style.left=k-v+"px",C.style.top=L-m+"px",C.style.width=Math.max(0,A-k)+"px",C.style.height=Math.max(0,O-L)+"px";if(e.lineIndex===r.lineIndex)A=Math.min(N,h),C.style.width=Math.max(0,A-k)+"px";else{var M=c,_=Math.min(d,Math.max(p,T.top)),D=Math.min(h,Math.max(c,N)),P=Math.min(d,Math.max(p,T.bottom)),H=this._selDiv3;H.style.left=M-v+"px",H.style.top=_-m+"px",H.style.width=Math.max(0,D-M)+"px",H.style.height=Math.max(0,P-_)+"px";if(Math.abs(e.lineIndex-r.lineIndex)>1){var B=this._selDiv2;B.style.left=c-v+"px",B.style.top=O-m+"px",B.style.width=Math.max(0,h-c)+"px",B.style.height=Math.max(0,_-O)+"px"}}},_setGrab:function(e){if(e===this._grabControl)return;e?(e.setCapture&&e.setCapture(),this._grabControl=e):(this._grabControl.releaseCapture&&this._grabControl.releaseCapture(),this._grabControl=null)},_setLinksVisible:function(e){if(this._linksVisible===e)return;this._linksVisible=e,o.isIE&&e&&(this._hadFocus=this._hasFocus);var t=this._clientDiv;t.contentEditable=!e,this._hadFocus&&!e&&t.focus(),this._overlayDiv&&(this._overlayDiv.style.zIndex=e?"-1":"1");var n=this._getLineNext();while(n){if(n.hasLink){var r=n.firstChild;while(r){if(r.ignore){r=r.nextSibling;continue}var i=r.nextSibling,s=r.viewStyle;s&&s.tagName&&s.tagName.toLowerCase()==="a"&&n.replaceChild(n._line._createSpan(n,r.firstChild.data,s),r),r=i}}n=this._getLineNext(n)}this._updateDOMSelection()},_setSelection:function(e,t,n,r,i){if(e){this._columnX=-1,n===undefined&&(n=!0);var s=this._selection;this._selection=e,t!==!1&&this._showCaret(!1,r,t,i),n&&this._updateDOMSelection();if(!s.equals(e)){var o={type:"Selection",oldValue:{start:s.start,end:s.end},newValue:{start:e.start,end:e.end}};this.onSelection(o)}}},_setSelectionTo:function(e,t,n,r){var i=this._model,s,o=this._getSelection(),u=this.convert({x:e,y:t},"page","document"),a=this._getLineIndex(u.y),f;if(this._clickCount===1){f=this._getLine(a),s=f.getOffset(u.x,u.y-this._getLinePixel(a)),f.destroy();if(r&&!n&&o.start<=s&&s<o.end)return this._dragOffset=s,!1;o.extend(s),n||o.collapse()}else{var l=(this._clickCount&1)===0,c,h;if(l)f=this._getLine(a),s=f.getOffset(u.x,u.y-this._getLinePixel(a)),this._doubleClickSelection?s>=this._doubleClickSelection.start?(c=this._doubleClickSelection.start,h=f.getNextOffset(s,{unit:"wordend",count:1})):(c=f.getNextOffset(s,{unit:"word",count:-1}),h=this._doubleClickSelection.end):(c=f.getNextOffset(s,{unit:"word",count:-1}),h=f.getNextOffset(c,{unit:"wordend",count:1})),f.destroy();else if(this._doubleClickSelection){var p=i.getLineAtOffset(this._doubleClickSelection.start);a>=p?(c=i.getLineStart(p),h=i.getLineEnd(a)):(c=i.getLineStart(a),h=i.getLineEnd(p))}else c=i.getLineStart(a),h=i.getLineEnd(a);o.setCaret(c),o.extend(h)}return this._setSelection(o,!0,!0),!0},_setFullSelection:function(e,t){this._fullSelection=e,o.isWebkit&&(this._fullSelection=!0);var n=this._clipDiv||this._rootDiv;if(!n)return;if(!this._fullSelection){this._selDiv1&&(n.removeChild(this._selDiv1),this._selDiv1=null),this._selDiv2&&(n.removeChild(this._selDiv2),this._selDiv2=null),this._selDiv3&&(n.removeChild(this._selDiv3),this._selDiv3=null);return}if(!this._selDiv1&&this._fullSelection&&!o.isIOS){var r=n.ownerDocument;this._highlightRGB=o.isWebkit?"transparent":"Highlight";var i=o.createElement(r,"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",n.appendChild(i);var s=o.createElement(r,"div");this._selDiv2=s,s.style.position="absolute",s.style.borderWidth="0px",s.style.margin="0px",s.style.padding="0px",s.style.outline="none",s.style.background=this._highlightRGB,s.style.width="0px",s.style.height="0px",s.style.zIndex="0",n.appendChild(s);var u=o.createElement(r,"div");this._selDiv3=u,u.style.position="absolute",u.style.borderWidth="0px",u.style.margin="0px",u.style.padding="0px",u.style.outline="none",u.style.background=this._highlightRGB,u.style.width="0px",u.style.height="0px",u.style.zIndex="0",n.appendChild(u);if(o.isFirefox&&o.isMac){var a=this._getWindow(),f=a.getComputedStyle(u,null),l=f.getPropertyValue("background-color");switch(l){case"rgb(119, 141, 168)":l="rgb(199, 208, 218)";break;case"rgb(127, 127, 127)":l="rgb(198, 198, 198)";break;case"rgb(255, 193, 31)":l="rgb(250, 236, 115)";break;case"rgb(243, 70, 72)":l="rgb(255, 176, 139)";break;case"rgb(255, 138, 34)":l="rgb(255, 209, 129)";break;case"rgb(102, 197, 71)":l="rgb(194, 249, 144)";break;case"rgb(140, 78, 184)":l="rgb(232, 184, 255)";break;default:l="rgb(180, 213, 255)"}this._highlightRGB=l,i.style.background=l,s.style.background=l,u.style.background=l}t||this._updateDOMSelection()}},_setBlockCursor:function(e){this._blockCursorVisible=e,this._updateBlockCursorVisible()},_setOverwriteMode:function(e){this._overwriteMode=e,this._updateBlockCursorVisible()},_updateBlockCursorVisible:function(){if(this._blockCursorVisible||this._overwriteMode){if(!this._cursorDiv){var e=o.createElement(document,"div");e.className="textviewBlockCursor",this._cursorDiv=e,e.tabIndex=-1,e.style.zIndex="2",e.style.color="transparent",e.style.position="absolute",e.style.pointerEvents="none",e.innerHTML=" ",this._viewDiv.appendChild(e),this._updateDOMSelection()}}else this._cursorDiv&&(this._cursorDiv.parentNode.removeChild(this._cursorDiv),this._cursorDiv=null)},_setMarginOffset:function(e,t){this._marginOffset=e,this._marginDiv.style.display=e?"block":"none",t||(this._metrics=this._calculateMetrics(),this._queueUpdate())},_setWrapOffset:function(e,t){this._wrapOffset=e,t||(this._metrics=this._calculateMetrics(),this._queueUpdate())},_setReadOnly:function(e){this._readonly=e,this._clientDiv.setAttribute("aria-readonly",e?"true":"false")},_setSingleMode:function(e,t){this._singleMode=e,this._updateOverflow(),this._updateStyle(t)},_setTabSize:function(e,t){this._tabSize=e,this._customTabSize=undefined;var n=this._clientDiv;o.isOpera?n&&(n.style.OTabSize=this._tabSize+""):o.isWebkit>=537.1?n&&(n.style.tabSize=this._tabSize+""):o.isFirefox>=4?n&&(n.style.MozTabSize=this._tabSize+""):this._tabSize!==8&&(this._customTabSize=this._tabSize),t||(this.redrawLines(),this._resetLineWidth())},_setTheme:function(e){this._theme&&this._theme.removeEventListener("ThemeChanged",this._themeListener.onChanged),this._theme=e,this._theme&&this._theme.addEventListener("ThemeChanged",this._themeListener.onChanged),this._setThemeClass(this._themeClass)},_setThemeClass:function(e,t){this._themeClass=e;var n="textview",r=this._theme.getThemeClass();r&&(n+=" "+r),this._themeClass&&r!==this._themeClass&&(n+=" "+this._themeClass),this._rootDiv.className=n,this._updateStyle(t)},_setWrapMode:function(e,t){this._wrapMode=e&&this._wrappable;var n=this._clientDiv;this._wrapMode?(n.style.whiteSpace="pre-wrap",n.style.wordWrap="break-word"):(n.style.whiteSpace="pre",n.style.wordWrap="normal"),this._updateOverflow(),t||(this.redraw(),this._resetLineWidth()),this._resetLineHeight()},_showCaret:function(e,t,n,r){if(!this._clientDiv)return;var i=this._model,s=this._getSelection(),o=this._getScroll(),u=s.getCaret(),a=s.start,f=s.end,l=i.getLineAtOffset(f),c=Math.max(Math.max(a,i.getLineStart(l)),f-1),h=this._getClientWidth(),p=this._getClientHeight(),d=h/4,v=this._getBoundsAtOffset(u===a?a:c),m=v.left,g=v.right,y=v.top,b=v.bottom;e&&!s.isEmpty()&&(v=this._getBoundsAtOffset(u===f?a:c),v.top===y?u===a?g=m+Math.min(v.right-m,h):m=g-Math.min(g-v.left,h):u===a?b=y+Math.min(v.bottom-y,p):y=b-Math.min(b-v.top,p));var w=0;m<o.x&&(w=Math.min(m-o.x,-d)),g>o.x+h&&(w=Math.max(g-o.x-h,d));var E=0;return y<o.y?E=y-o.y:b>o.y+p&&(E=b-o.y-p),r&&(r>0?E>0&&(E=Math.max(E,r)):E<0&&(E=Math.min(E,r))),w!==0||E!==0?(E!==0&&typeof n=="number"&&(n<0&&(n=0),n>1&&(n=1),E+=Math.floor(E>0?n*p:-n*p)),this._scrollViewAnimated(w,E,t),p!==this._getClientHeight()||h!==this._getClientWidth()?this._showCaret():this._ensureCaretVisible=!0,!0):(t&&t(),!1)},_startIME:function(){if(this._imeOffset!==-1)return;var e=this._getSelection();e.isEmpty()||this._modifyContent({text:"",start:e.start,end:e.end},!0),this._imeOffset=e.start},_unhookEvents:function(){this._model.removeEventListener("preChanging",this._modelListener.onChanging),this._model.removeEventListener("postChanged",this._modelListener.onChanged),this._theme.removeEventListener("ThemeChanged",this._themeListener.onChanged),this._modelListener=null;for(var e=0;e<this._handlers.length;e++){var t=this._handlers[e];f(t.target,t.type,t.handler)}this._handlers=null,this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)},_updateDOMSelection:function(){if(this._redrawCount>0)return;if(this._ignoreDOMSelection)return;if(!this._clientDiv)return;var e=this._getSelection(),t=this._model,n=t.getLineAtOffset(e.start),r=t.getLineAtOffset(e.end),i=this._getLineNext();if(!i)return;var s=this._getLinePrevious(),o,u,a,f;n<i.lineIndex?(o=i,a=0):n>s.lineIndex?(o=s,a=0):(o=this._getLineNode(n),a=e.start-t.getLineStart(n)),r<i.lineIndex?(u=i,f=0):r>s.lineIndex?(u=s,f=0):(u=this._getLineNode(r),f=e.end-t.getLineStart(r)),this._setDOMSelection(o,a,u,f,e.caret)},_update:function(e){if(this._redrawCount>0)return;if(this._updateTimer){var t=this._getWindow();t.clearTimeout(this._updateTimer),this._updateTimer=null,e=!1}var n=this._clientDiv,r=this._viewDiv;if(!n)return;this._metrics.invalid&&(this._ignoreQueueUpdate=!0,this._updateStyle(),this._ignoreQueueUpdate=!1);var i=this._model,s=this._getScroll(!1),u=this._getViewPadding(),a=i.getLineCount(),f=this._getLineHeight(),l=!1,c=!1,h=!1,p=this._metrics.scrollWidth;this._wrapMode&&(n.style.width=(this._metrics.wrapWidth||this._getClientWidth())+"px");var d,v,m,g,y,b,w,S,x,T,N=0,C=0,k;if(this._lineHeight){while(C<a){k=this._getLineHeight(C);if(N+k>s.y)break;N+=k,C++}d=C,v=Math.max(0,d-1),g=m=s.y-N,d>0&&(m+=this._getLineHeight(d-1))}else{var L=Math.max(0,s.y)/f;d=Math.floor(L),v=Math.max(0,d-1),m=Math.round((L-v)*f),g=Math.round((L-d)*f),T=a*f}this._topIndexY=g;var A=this._parent,O=A.clientWidth,M=A.clientHeight;if(e){y=0,this._leftDiv&&(b=this._leftDiv.getBoundingClientRect(),y=b.right-b.left),w=this._getClientWidth(),S=this._getClientHeight(),x=w,this._wrapMode?this._metrics.wrapWidth&&(x=this._metrics.wrapWidth):x=Math.max(this._maxLineWidth,x);while(C<a)k=this._getLineHeight(C,!1),N+=k,C++;T=N}else{S=this._getClientHeight();var _=Math.floor((S+g)/f),D=Math.min(d+_,a-1),P=Math.min(D+1,a-1),H,B,j=n.firstChild;while(j){H=j.lineIndex;var F=j.nextSibling;if(!(v<=H&&H<=P)||j.lineRemoved||j.lineIndex===-1)this._mouseWheelLine===j?(j.style.display="none",j.lineIndex=-1):n.removeChild(j);j=F}j=this._getLineNext();var I=r.ownerDocument,q=I.createDocumentFragment();for(H=v;H<=P;H++)!j||j.lineIndex>H?(new E(this,H)).create(q,null):(q.firstChild&&(n.insertBefore(q,j),q=I.createDocumentFragment()),j&&j.lineChanged&&(j=(new E(this,H)).create(q,j),j.lineChanged=!1),j=this._getLineNext(j));q.firstChild&&n.insertBefore(q,j),o.isWebkit&&!this._wrapMode&&(n.style.width="0x7fffffffpx");var R;j=this._getLineNext();var U=S+m,z=!1;while(j){B=j.lineWidth;if(B===undefined){R=j._line.getBoundingClientRect(),B=j.lineWidth=Math.ceil(R.right-R.left);var W=R.bottom-R.top;this._lineHeight?this._lineHeight[j.lineIndex]=W:f!==0&&W!==0&&Math.ceil(f)!==Math.ceil(W)&&(this._variableLineHeight=!0,this._lineHeight=[],this._lineHeight[j.lineIndex]=W)}this._lineHeight&&!z&&(U-=this._lineHeight[j.lineIndex],U<0&&(D=j.lineIndex,z=!0)),this._wrapMode||(B>=this._maxLineWidth&&(this._maxLineWidth=B,this._maxLineIndex=j.lineIndex),this._checkMaxLineIndex===j.lineIndex&&(this._checkMaxLineIndex=-1)),j.lineIndex===d&&(this._topChild=j),j.lineIndex===D&&(this._bottomChild=j),j=this._getLineNext(j)}if(this._checkMaxLineIndex!==-1){H=this._checkMaxLineIndex,this._checkMaxLineIndex=-1;if(0<=H&&H<a){var X=new E(this,H);R=X.getBoundingClientRect(),B=R.right-R.left,B>=this._maxLineWidth&&(this._maxLineWidth=B,this._maxLineIndex=H),X.destroy()}}while(C<a)k=this._getLineHeight(C,C<=D),N+=k,C++;T=N,this._updateRuler(this._leftDiv,d,P,M),this._updateRuler(this._rightDiv,d,P,M),this._updateRuler(this._marginDiv,d,P,M),y=0,this._leftDiv&&(b=this._leftDiv.getBoundingClientRect(),y=b.right-b.left);var V=0;if(this._rightDiv){var $=this._rightDiv.getBoundingClientRect();V=$.right-$.left}r.style.left=y+"px",r.style.right=V+"px";var J=this._scrollDiv;J.style.height=T+"px",w=this._getClientWidth();if(!this._singleMode&&!this._wrapMode){var K=S,Q=S,G=r.style.overflowX==="scroll";G?K+=p:Q-=p;var Y=w,Z=w,et=r.style.overflowY==="scroll";et?Y+=p:Z-=p,S=K,w=Y,T>S&&(h=!0,w=Z),this._maxLineWidth>w&&(c=!0,S=Q,T>S&&(h=!0,w=Z)),G!==c&&(r.style.overflowX=c?"scroll":"hidden"),et!==h&&(r.style.overflowY=h?"scroll":"hidden"),l=G!==c||et!==h}var tt=w;this._wrapMode?this._metrics.wrapWidth&&(tt=this._metrics.wrapWidth):tt=Math.max(this._maxLineWidth,tt),x=tt,(!o.isIE||o.isIE>=9)&&this._maxLineWidth>w&&(tt+=u.right+u.left),J.style.width=tt+"px",this._clipScrollDiv&&(this._clipScrollDiv.style.width=tt+"px"),s=this._getScroll(!1)}if(this._vScrollDiv){var nt=S-8,rt=Math.max(15,Math.ceil(Math.min(1,nt/(T+u.top+u.bottom))*nt));this._vScrollDiv.style.left=y+w-8+"px",this._vScrollDiv.style.top=Math.floor(Math.max(0,s.y*nt/T))+"px",this._vScrollDiv.style.height=rt+"px"}if(!this._wrapMode&&this._hScrollDiv){var it=w-8,st=Math.max(15,Math.ceil(Math.min(1,it/(this._maxLineWidth+u.left+u.right))*it));this._hScrollDiv.style.left=y+Math.floor(Math.max(0,Math.floor(s.x*it/this._maxLineWidth)))+"px",this._hScrollDiv.style.top=S-9+"px",this._hScrollDiv.style.width=st+"px"}var ot=s.x,ut=this._clipDiv,at=this._overlayDiv,ft=this._marginDiv,lt,ct;ft&&(ft.style.left=-ot+y+this._metrics.marginWidth+u.left+"px",ft.style.bottom=(r.style.overflowX==="scroll"?p:0)+"px");if(ut){ut.scrollLeft=ot,ut.scrollTop=0,lt=y+u.left,ct=u.top;var ht=w,pt=S,dt=0,vt=-m;s.x===0&&(lt-=u.left,ht+=u.left,dt=u.left),s.x+w===x&&(ht+=u.right),s.y===0&&(ct-=u.top,pt+=u.top,vt+=u.top),s.y+S===T&&(pt+=u.bottom),ut.style.left=lt+"px",ut.style.top=ct+"px",ut.style.right=O-ht-lt+"px",ut.style.bottom=M-pt-ct+"px",n.style.left=dt+"px",n.style.top=vt+"px",n.style.width=x+"px",n.style.height=S+m+"px",at&&(at.style.left=n.style.left,at.style.top=n.style.top,at.style.width=n.style.width,at.style.height=n.style.height)}else{lt=ot,ct=m;var mt=ot+w,gt=m+S;lt===0&&(lt-=u.left),ct===0&&(ct-=u.top),mt===x&&(mt+=u.right),s.y+S===T&&(gt+=u.bottom),n.style.clip="rect("+ct+"px,"+mt+"px,"+gt+"px,"+lt+"px)",n.style.left=-ot+y+u.left+"px",n.style.width=(this._wrapMode||o.isWebkit?x:w+ot)+"px",e||(n.style.top=-m+u.top+"px",n.style.height=S+m+"px"),at&&(at.style.clip=n.style.clip,at.style.left=n.style.left,at.style.width=n.style.width,e||(at.style.top=n.style.top,at.style.height=n.style.height))}this._updateDOMSelection();if(l){var yt=this._ensureCaretVisible;this._ensureCaretVisible=!1,yt&&this._showCaret(),this._queueUpdate()}},_updateOverflow:function(){var e=this._viewDiv;this._wrapMode?(e.style.overflowX="hidden",e.style.overflowY="scroll"):e.style.overflow="hidden"},_updateRuler:function(e,t,n,r){if(!e)return;var i=this._parent.ownerDocument,s=this._getLineHeight(),u=this._getViewPadding(),a=e.firstChild;while(a){var f=a._ruler,c=s,h=f.getOverview();h==="page"&&(c+=this._topIndexY),a.style.top=-c+"px",a.style.height=r+c+"px",a.rulerChanged&&l(f.getRulerStyle(),a);var p,d=a.firstChild;d?(p=d,d=d.nextSibling):(p=o.createElement(i,"div"),p.style.visibility="hidden",a.appendChild(p));var v,m;a.rulerChanged&&p&&(v=-1,m=f.getWidestAnnotation(),m&&(l(m.style,p),m.html&&(p.innerHTML=m.html)),p.lineIndex=v,p.style.height=s+u.top+"px");var g,y,b;if(h==="page"){b=f.getAnnotations(t,n+1);while(d){v=d.lineIndex;var w=d.nextSibling;(!(t<=v&&v<=n)||d.lineChanged)&&a.removeChild(d),d=w}d=a.firstChild.nextSibling,y=i.createDocumentFragment();for(v=t;v<=n;v++)!d||d.lineIndex>v?(g=o.createElement(i,"div"),m=b[v],m&&(l(m.style,g),m.html&&(g.innerHTML=m.html),g.annotation=m),g.lineIndex=v,g.style.height=this._getLineHeight(v)+"px",y.appendChild(g)):(y.firstChild&&(a.insertBefore(y,d),y=i.createDocumentFragment()),d&&(d=d.nextSibling));y.firstChild&&a.insertBefore(y,d)}else{var E=this._getClientHeight(),S=this._model.getLineCount(),x=s*S,T=E+u.top+u.bottom-2*this._metrics.scrollWidth,N;x<T?N=s:N=T/S;if(a.rulerChanged){var C=a.childNodes.length;while(C>1)a.removeChild(a.lastChild),C--;b=f.getAnnotations(0,S),y=i.createDocumentFragment();for(var k in b){v=k>>>0;if(v<0)continue;g=o.createElement(i,"div"),m=b[k],l(m.style,g),g.style.position="absolute",g.style.top=this._metrics.scrollWidth+s+Math.floor(v*N)+"px",m.html&&(g.innerHTML=m.html),g.annotation=m,g.lineIndex=v,y.appendChild(g)}a.appendChild(y)}else if(a._oldTrackHeight!==T){g=a.firstChild?a.firstChild.nextSibling:null;while(g)g.style.top=this._metrics.scrollWidth+s+Math.floor(g.lineIndex*N)+"px",g=g.nextSibling}a._oldTrackHeight=T}a.rulerChanged=!1,a=a.nextSibling}},_updateStyleSheet:function(){var e="";o.isWebkit&&this._metrics.scrollWidth>0&&(e+="\n.textview ::-webkit-scrollbar-corner {background: #eeeeee;}"),o.isFirefox&&o.isMac&&this._highlightRGB&&this._highlightRGB!=="Highlight"&&(e+="\n.textview ::-moz-selection {background: "+this._highlightRGB+";}");if(e){var t=document.getElementById("_textviewStyle");if(!t){t=o.createElement(document,"style"),t.id="_textviewStyle";var n=document.getElementsByTagName("head")[0]||document.documentElement;t.appendChild(document.createTextNode(e)),n.insertBefore(t,n.firstChild)}else t.removeChild(t.firstChild),t.appendChild(document.createTextNode(e))}},_updateStyle:function(e){!e&&o.isIE&&(this._rootDiv.style.lineHeight="normal");var t=this._metrics=this._calculateMetrics();o.isIE?this._rootDiv.style.lineHeight=t.lineHeight-(t.lineTrim.top+t.lineTrim.bottom)+"px":this._rootDiv.style.lineHeight="normal",this._updateStyleSheet(),e||(this.redraw(),this._resetLineWidth())}},r.EventTarget.addMixin(S.prototype),{TextView:S}}),define("orion/editor/projectionTextModel",["orion/editor/textModel","orion/editor/eventTarget"],function(e,t){function n(e){this._model=e,this._projections=[]}return n.prototype={addProjection:function(t){if(!t)return;var n=this._model,r=this._projections;t._lineIndex=n.getLineAtOffset(t.start),t._lineCount=n.getLineAtOffset(t.end)-t._lineIndex;var i=t.text;i||(i=""),typeof i=="string"?t._model=new e.TextModel(i,n.getLineDelimiter()):t._model=i;var s=this.mapOffset(t.start,!0),o=t.end-t.start,u=t._lineCount,a=t._model.getCharCount(),f=t._model.getLineCount()-1,l={type:"Changing",text:t._model.getText(),start:s,removedCharCount:o,addedCharCount:a,removedLineCount:u,addedLineCount:f};this.onChanging(l);var c=this._binarySearch(r,t.start);r.splice(c,0,t);var h={type:"Changed",start:s,removedCharCount:o,addedCharCount:a,removedLineCount:u,addedLineCount:f};this.onChanged(h)},getProjections:function(){return this._projections.slice(0)},getBaseModel:function(){return this._model},mapOffset:function(e,t){var n=this._projections,r=0,i,s;if(t){for(i=0;i<n.length;i++){s=n[i];if(s.start>e)break;if(s.end>e)return-1;r+=s._model.getCharCount()-(s.end-s.start)}return e+r}for(i=0;i<n.length;i++){s=n[i];if(s.start>e-r)break;var o=s._model.getCharCount();if(s.start+o>e-r)return-1;r+=o-(s.end-s.start)}return e-r},removeProjection:function(e){var t,n=0;for(t=0;t<this._projections.length;t++){var r=this._projections[t];if(r===e){e=r;break}n+=r._model.getCharCount()-(r.end-r.start)}if(t<this._projections.length){var i=this._model,s=e.start+n,o=e.end-e.start,u=e._lineCount,a=e._model.getCharCount(),f=e._model.getLineCount()-1,l={type:"Changing",text:i.getText(e.start,e.end),start:s,removedCharCount:a,addedCharCount:o,removedLineCount:f,addedLineCount:u};this.onChanging(l),this._projections.splice(t,1);var c={type:"Changed",start:s,removedCharCount:a,addedCharCount:o,removedLineCount:f,addedLineCount:u};this.onChanged(c)}},_binarySearch:function(e,t){var n=e.length,r=-1,i;while(n-r>1)i=Math.floor((n+r)/2),t<=e[i].start?n=i:r=i;return n},getCharCount:function(){var e=this._model.getCharCount(),t=this._projections;for(var n=0;n<t.length;n++){var r=t[n];e+=r._model.getCharCount()-(r.end-r.start)}return e},getLine:function(e,t){if(e<0)return null;var n=this._model,r=this._projections,i=0,s=[],o=0,u,a,f;for(u=0;u<r.length;u++){f=r[u];if(f._lineIndex>=e-i)break;a=f._model.getLineCount()-1;if(f._lineIndex+a>=e-i){var l=e-(f._lineIndex+i);if(l<a)return f._model.getLine(l,t);s.push(f._model.getLine(a))}o=f.end,i+=a-f._lineCount}o=Math.max(o,n.getLineStart(e-i));for(;u<r.length;u++){f=r[u];if(f._lineIndex>e-i)break;s.push(n.getText(o,f.start)),a=f._model.getLineCount()-1;if(f._lineIndex+a>e-i)return s.push(f._model.getLine(0,t)),s.join("");s.push(f._model.getText()),o=f.end,i+=a-f._lineCount}var c=n.getLineEnd(e-i,t);return o<c&&s.push(n.getText(o,c)),s.join("")},getLineAtOffset:function(e){var t=this._model,n=this._projections,r=0,i=0;for(var s=0;s<n.length;s++){var o=n[s];if(o.start>e-r)break;var u=o._model.getCharCount();if(o.start+u>e-r){var a=e-(o.start+r);i+=o._model.getLineAtOffset(a),r+=a;break}i+=o._model.getLineCount()-1-o._lineCount,r+=u-(o.end-o.start)}return t.getLineAtOffset(e-r)+i},getLineCount:function(){var e=this._model,t=this._projections,n=e.getLineCount();for(var r=0;r<t.length;r++){var i=t[r];n+=i._model.getLineCount()-1-i._lineCount}return n},getLineDelimiter:function(){return this._model.getLineDelimiter()},getLineEnd:function(e,t){if(e<0)return-1;var n=this._model,r=this._projections,i=0,s=0;for(var o=0;o<r.length;o++){var u=r[o];if(u._lineIndex>e-i)break;var a=u._model.getLineCount()-1;if(u._lineIndex+a>e-i){var f=e-(u._lineIndex+i);return u._model.getLineEnd(f,t)+u.start+s}s+=u._model.getCharCount()-(u.end-u.start),i+=a-u._lineCount}return n.getLineEnd(e-i,t)+s},getLineStart:function(e){if(e<0)return-1;var t=this._model,n=this._projections,r=0,i=0;for(var s=0;s<n.length;s++){var o=n[s];if(o._lineIndex>=e-r)break;var u=o._model.getLineCount()-1;if(o._lineIndex+u>=e-r){var a=e-(o._lineIndex+r);return o._model.getLineStart(a)+o.start+i}i+=o._model.getCharCount()-(o.end-o.start),r+=u-o._lineCount}return t.getLineStart(e-r)+i},getText:function(e,t){e===undefined&&(e=0);var n=this._model,r=this._projections,i=0,s=[],o,u,a;for(o=0;o<r.length;o++){u=r[o];if(u.start>e-i)break;a=u._model.getCharCount();if(u.start+a>e-i){if(t!==undefined&&u.start+a>t-i)return u._model.getText(e-(u.start+i),t-(u.start+i));s.push(u._model.getText(e-(u.start+i))),e=u.end+i+a-(u.end-u.start)}i+=a-(u.end-u.start)}var f=e-i;if(t!==undefined){for(;o<r.length;o++){u=r[o];if(u.start>t-i)break;s.push(n.getText(f,u.start)),a=u._model.getCharCount();if(u.start+a>t-i)return s.push(u._model.getText(0,t-(u.start+i))),s.join("");s.push(u._model.getText()),f=u.end,i+=a-(u.end-u.start)}s.push(n.getText(f,t-i))}else{for(;o<r.length;o++)u=r[o],s.push(n.getText(f,u.start)),s.push(u._model.getText()),f=u.end;s.push(n.getText(f))}return s.join("")},_onChanging:function(e,t,n,r,i,s){var o=this._model,u=this._projections,a,f,l=0,c,h=t+n;for(;a<u.length;a++){f=u[a];if(f.start>t)break;l+=f._model.getCharCount()-(f.end-f.start)}var p=t+l,d=a;for(;a<u.length;a++){f=u[a];if(f.start>h)break;l+=f._model.getCharCount()-(f.end-f.start),c+=f._model.getLineCount()-1-f._lineCount}var v=h+l,m=a;this.onChanging(p,v-p,r,i+c,s),u.splice(u,m-d);var g=e.length-(v-p);for(;a<u.length;a++)f=u[a],f.start+=g,f.end+=g,f._lineIndex=o.getLineAtOffset(f.start)},onChanging:function(e){return this.dispatchEvent(e)},onChanged:function(e){return this.dispatchEvent(e)},setLineDelimiter:function(e){this._model.setLineDelimiter(e)},setText:function(e,t,n){e===undefined&&(e=""),t===undefined&&(t=0);var r=t,i=n,s=this._model,o=this._projections,u=0,a=0,f,l,c,h,p,d=0;for(f=0;f<o.length;f++){l=o[f];if(l.start>t-u)break;c=l._model.getCharCount();if(l.start+c>t-u){if(n!==undefined&&l.start+c>n-u){l._model.setText(e,t-(l.start+u),n-(l.start+u));return}d=l._model.getLineCount()-1-l._model.getLineAtOffset(t-(l.start+u)),h={projection:l,start:t-(l.start+u)},t=l.end+u+c-(l.end-l.start)}a+=l._model.getLineCount()-1-l._lineCount,u+=c-(l.end-l.start)}var v=t-u,m=f,g=s.getLineAtOffset(v)+a-d;if(n!==undefined)for(;f<o.length;f++){l=o[f];if(l.start>n-u)break;c=l._model.getCharCount();if(l.start+c>n-u){a+=l._model.getLineAtOffset(n-(l.start+u)),c=n-(l.start+u),n=l.end+u,p={projection:l,end:c};break}a+=l._model.getLineCount()-1-l._lineCount,u+=c-(l.end-l.start)}else{for(;f<o.length;f++)l=o[f],a+=l._model.getLineCount()-1-l._lineCount,u+=l._model.getCharCount()-(l.end-l.start);n=i=s.getCharCount()+u}var y=n-u,b=f,w=s.getLineAtOffset(y)+a,E=i-r,S=w-g,x=e.length,T=0,N=0,C=0,k=0;for(;;){N!==-1&&N<=k&&(N=e.indexOf("\r",k)),C!==-1&&C<=k&&(C=e.indexOf("\n",k));if(C===-1&&N===-1)break;N!==-1&&C!==-1?N+1===C?k=C+1:k=(N<C?N:C)+1:N!==-1?k=N+1:k=C+1,T++}var L={type:"Changing",text:e,start:r,removedCharCount:E,addedCharCount:x,removedLineCount:S,addedLineCount:T};this.onChanging(L),s.setText(e,v,y),h&&(l=h.projection,l._model.setText("",h.start)),p&&(l=p.projection,l._model.setText("",0,p.end),l.start=l.end,l._lineCount=0),o.splice(m,b-m);var A=e.length-(y-v);for(f=b;f<o.length;f++)l=o[f],l.start+=A,l.end+=A,l._lineIndex=s.getLineAtOffset(l.start);var O={type:"Changed",start:r,removedCharCount:E,addedCharCount:x,removedLineCount:S,addedLineCount:T};this.onChanged(O)}},t.EventTarget.addMixin(n.prototype),{ProjectionTextModel:n}}),define("orion/editor/tooltip",["i18n!orion/editor/nls/messages","orion/editor/textView","orion/editor/textModel","orion/editor/projectionTextModel","orion/editor/util","orion/util"],function(e,t,n,r,i,s){function o(e){this._view=e,this._fadeDelay=500,this._hideDelay=200,this._showDelay=500,this._autoHideDelay=5e3,this._create(e.getOptions("parent").ownerDocument)}return o.getTooltip=function(e){return e._tooltip||(e._tooltip=new o(e)),e._tooltip},o.prototype={_create:function(e){if(this._tooltipDiv)return;var t=this._tooltipDiv=s.createElement(e,"div");t.tabIndex=0,t.className="textviewTooltip",t.setAttribute("aria-live","assertive"),t.setAttribute("aria-atomic","true");var n=this._tooltipContents=s.createElement(e,"div");t.appendChild(n),e.body.appendChild(t);var r=this;i.addEventListener(t,"mouseover",function(e){if(!r._hideDelay)return;var t=r._getWindow();r._delayedHideTimeout&&(t.clearTimeout(r._delayedHideTimeout),r._delayedHideTimeout=null),r._hideTimeout&&(t.clearTimeout(r._hideTimeout),r._hideTimeout=null),r._nextTarget=null},!1),i.addEventListener(t,"mouseout",function(e){var n=e.relatedTarget||e.toElement;if(n===t||r._hasFocus())return;if(n&&i.contains(t,n))return;r._hide()},!1),i.addEventListener(t,"keydown",function(e){e.keyCode===27&&r._hide()},!1),i.addEventListener(e,"mousedown",this._mouseDownHandler=function(e){if(!r.isVisible())return;if(i.contains(t,e.target||e.srcElement))return;r._hide()},!0),this._view.addEventListener("Destroy",function(){r.destroy()}),this._hide()},_getWindow:function(){var e=this._tooltipDiv.ownerDocument;return e.defaultView||e.parentWindow},destroy:function(){if(!this._tooltipDiv)return;this._hide();var e=this._tooltipDiv.parentNode;e&&e.removeChild(this._tooltipDiv);var t=this._tooltipDiv.ownerDocument;i.removeEventListener(t,"mousedown",this._mouseDownHandler,!0),this._tooltipDiv=null},_hasFocus:function(){var e=this._tooltipDiv;if(!e)return!1;var t=e.ownerDocument;return i.contains(e,t.activeElement)},hide:function(e){e===undefined&&(e=this._hideDelay);var t=this._getWindow();this._delayedHideTimeout&&(t.clearTimeout(this._delayedHideTimeout),this._delayedHideTimeout=null);var n=this;e?n._delayedHideTimeout=t.setTimeout(function(){n._delayedHideTimeout=null,n._hide(),n.setTarget(n._nextTarget,0)},e):(n._hide(),n.setTarget(n._nextTarget,0))},_hide:function(){var e=this._tooltipDiv;if(!e)return;this._hasFocus()&&this._view.focus(),this._contentsView&&(this._contentsView.destroy(),this._contentsView=null),this._tooltipContents&&(this._tooltipContents.innerHTML=""),e.style.visibility="hidden";var t=this._getWindow();this._showTimeout&&(t.clearTimeout(this._showTimeout),this._showTimeout=null),this._delayedHideTimeout&&(t.clearTimeout(this._delayedHideTimeout),this._delayedHideTimeout=null),this._hideTimeout&&(t.clearTimeout(this._hideTimeout),this._hideTimeout=null),this._fadeTimeout&&(t.clearInterval(this._fadeTimeout),this._fadeTimeout=null)},isVisible:function(){return this._tooltipDiv&&this._tooltipDiv.style.visibility==="visible"},setTarget:function(e,t,n){var r=this.isVisible();if(r){if(this._hasFocus())return;this._nextTarget=e,this.hide(n)}else{this._target=e;if(e){var i=this,s=i._getWindow();i._showTimeout&&(s.clearTimeout(i._showTimeout),i._showTimeout=null),t===0?i.show(!0):i._showTimeout=s.setTimeout(function(){i._showTimeout=null,i.show(!0)},t?t:i._showDelay)}}},show:function(e){if(!this._target)return;var n=this._target.getTooltipInfo();if(!n)return;var i=this._tooltipDiv,s=this._tooltipContents;i.style.left=i.style.right=i.style.width=i.style.height=s.style.width=s.style.height="auto";var o=n.contents;o instanceof Array&&(o=this._getAnnotationContents(o));if(typeof o=="string")s.innerHTML=o;else if(this._isNode(o))s.appendChild(o);else{if(!(o instanceof r.ProjectionTextModel))return;var u=this._view,a=u.getOptions();a.wrapMode=!1,a.parent=s;var f="tooltipTheme",l=a.themeClass;l?(l=l.replace(f,""),l&&(l=" "+l),l=f+l):l=f,a.themeClass=l;var c=this._contentsView=new t.TextView(a),h={onLineStyle:function(e){u.onLineStyle(e)}};c.addEventListener("LineStyle",h.onLineStyle),c.setModel(o);var p=c.computeSize();s.style.width=p.width+"px",s.style.height=p.height+"px",c.resize()}var d=i.ownerDocument.documentElement;if(n.anchor==="right"){var v=d.clientWidth-n.x;i.style.right=v+"px",i.style.maxWidth=d.clientWidth-v-10+"px"}else{var m=parseInt(this._getNodeStyle(i,"padding-left","0"),10);m+=parseInt(this._getNodeStyle(i,"border-left-width","0"),10),m=n.x-m,i.style.left=m+"px",i.style.maxWidth=d.clientWidth-m-10+"px"}var g=parseInt(this._getNodeStyle(i,"padding-top","0"),10);g+=parseInt(this._getNodeStyle(i,"border-top-width","0"),10),g=n.y-g,i.style.top=g+"px",i.style.maxHeight=d.clientHeight-g-10+"px",i.style.opacity="1",i.style.visibility="visible";if(e){var y=this,b=this._getWindow();y._hideTimeout=b.setTimeout(function(){y._hideTimeout=null;var e=parseFloat(y._getNodeStyle(i,"opacity","1"));y._fadeTimeout=b.setInterval(function(){if(i.style.visibility==="visible"&&e>0){e-=.1,i.style.opacity=e;return}y._hide()},y._fadeDelay/10)},y._autoHideDelay)}},_getAnnotationContents:function(t){function d(e,t){var n=p.getLineStart(p.getLineAtOffset(e)),r=p.getLineEnd(p.getLineAtOffset(t),!0);return p.getText(n,r)}function v(e){var t=e.title,n=s.createElement(l,"div");n.className="tooltipRow",e.html&&(n.innerHTML=e.html,n.lastChild&&i.addEventListener(n.lastChild,"click",function(t){var n=e.start,r=e.end;h.getBaseModel&&(n=h.mapOffset(n,!0),r=h.mapOffset(r,!0)),c.setSelection(n,r,1/3,function(){a._hide()})},!1),n.appendChild(l.createTextNode("\u00a0"))),t||(t=d(e.start,e.end)),typeof t=="function"&&(t=e.title());if(typeof t=="string"){var r=s.createElement(l,"span");r.appendChild(l.createTextNode(t)),t=r}return n.appendChild(t),n}var n,o=[];for(var u=0;u<t.length;u++)n=t[u],n.title!==""&&!n.groupAnnotation&&o.push(n);t=o;if(t.length===0)return null;var a=this,f,l=this._tooltipDiv.ownerDocument,c=this._view,h=c.getModel(),p=h.getBaseModel?h.getBaseModel():h;if(t.length===1){n=t[0];if(n.title!==undefined){f=v(n);if(f.firstChild){var m=f.firstChild.className;m&&(m+=" "),m+="single",f.firstChild.className=m}return f}var g=new r.ProjectionTextModel(p),y=p.getLineStart(p.getLineAtOffset(n.start)),b=p.getCharCount();return n.end!==b&&g.addProjection({start:n.end,end:b}),y>0&&g.addProjection({start:0,end:y}),g}var w=s.createElement(l,"div"),E=s.createElement(l,"em");E.appendChild(l.createTextNode(e.multipleAnnotations)),w.appendChild(E);for(var S=0;S<t.length;S++)n=t[S],f=v(n),f&&w.appendChild(f);return w},_getNodeStyle:function(e,t,n){var r;if(e){r=e.style[t];if(!r)if(e.currentStyle){var i=0,s=t;while((i=s.indexOf("-",i))!==-1)s=s.substring(0,i)+s.substring(i+1,i+2).toUpperCase()+s.substring(i+2);r=e.currentStyle[s]}else{var o=e.ownerDocument.defaultView.getComputedStyle(e,null);r=o?o.getPropertyValue(t):null}}return r||n},_isNode:function(e){return typeof Node=="object"?e instanceof Node:e&&typeof e=="object"&&typeof e.nodeType=="number"&&typeof e.nodeName=="string"}},{Tooltip:o}}),define("orion/editor/annotations",["i18n!orion/editor/nls/messages","orion/editor/eventTarget"],function(e,t){function n(e,t,n){this.start=e,this.end=t,this._projectionModel=n,this.html=this._expandedHTML,this.style=this._expandedStyle,this.expanded=!0}function r(){}function s(t,n){var i=t.lastIndexOf("."),s=t.substring(i+1),o={title:e[s],style:{styleClass:"annotation "+s},html:"<div class='annotationHTML "+s+"'></div>",overviewStyle:{styleClass:"annotationOverview "+s}};n?o.lineStyle={styleClass:"annotationLine "+s}:o.rangeStyle={styleClass:"annotationRange "+s},r.registerType(t,o)}function o(){}function u(e){this._annotations=[];var t=this;this._listener={onChanged:function(e){t._onChanged(e)}},this.setTextModel(e)}function a(e,t){this._view=e,this._annotationModel=t;var n=this;this._listener={onDestroy:function(e){n._onDestroy(e)},onLineStyle:function(e){n._onLineStyle(e)},onChanged:function(e){n._onAnnotationModelChanged(e)}},e.addEventListener("Destroy",this._listener.onDestroy),e.addEventListener("postLineStyle",this._listener.onLineStyle),t.addEventListener("Changed",this._listener.onChanged)}n.prototype={_expandedHTML:"<div class='annotationHTML expanded'></div>",_expandedStyle:{styleClass:"annotation expanded"},_collapsedHTML:"<div class='annotationHTML collapsed'></div>",_collapsedStyle:{styleClass:"annotation collapsed"},collapse:function(){if(!this.expanded)return;this.expanded=!1,this.html=this._collapsedHTML,this.style=this._collapsedStyle;var e=this._projectionModel,t=e.getBaseModel();this._projection={start:t.getLineStart(t.getLineAtOffset(this.start)+1),end:t.getLineEnd(t.getLineAtOffset(this.end),!0)},e.addProjection(this._projection)},expand:function(){if(this.expanded)return;this.expanded=!0,this.html=this._expandedHTML,this.style=this._expandedStyle,this._projectionModel.removeProjection(this._projection)}},r.ANNOTATION_ERROR="orion.annotation.error",r.ANNOTATION_WARNING="orion.annotation.warning",r.ANNOTATION_TASK="orion.annotation.task",r.ANNOTATION_BREAKPOINT="orion.annotation.breakpoint",r.ANNOTATION_BOOKMARK="orion.annotation.bookmark",r.ANNOTATION_FOLDING="orion.annotation.folding",r.ANNOTATION_CURRENT_BRACKET="orion.annotation.currentBracket",r.ANNOTATION_MATCHING_BRACKET="orion.annotation.matchingBracket",r.ANNOTATION_CURRENT_LINE="orion.annotation.currentLine",r.ANNOTATION_CURRENT_SEARCH="orion.annotation.currentSearch",r.ANNOTATION_MATCHING_SEARCH="orion.annotation.matchingSearch",r.ANNOTATION_READ_OCCURRENCE="orion.annotation.readOccurrence",r.ANNOTATION_WRITE_OCCURRENCE="orion.annotation.writeOccurrence",r.ANNOTATION_SELECTED_LINKED_GROUP="orion.annotation.selectedLinkedGroup",r.ANNOTATION_CURRENT_LINKED_GROUP="orion.annotation.currentLinkedGroup",r.ANNOTATION_LINKED_GROUP="orion.annotation.linkedGroup",r.ANNOTATION_BLAME="orion.annotation.blame",r.ANNOTATION_CURRENT_BLAME="orion.annotation.currentBlame";var i={};return r.registerType=function(e,t){var n=t;return typeof n!="function"&&(n=function(e,t,n){this.start=e,this.end=t,n!==undefined&&(this.title=n)},n.prototype=t),n.prototype.type=e,i[e]=n,e},r.createAnnotation=function(e,t,n,r){return new(this.getType(e))(t,n,r)},r.getType=function(e){return i[e]},s(r.ANNOTATION_ERROR),s(r.ANNOTATION_WARNING),s(r.ANNOTATION_TASK),s(r.ANNOTATION_BREAKPOINT),s(r.ANNOTATION_BOOKMARK),s(r.ANNOTATION_CURRENT_BRACKET),s(r.ANNOTATION_MATCHING_BRACKET),s(r.ANNOTATION_CURRENT_SEARCH),s(r.ANNOTATION_MATCHING_SEARCH),s(r.ANNOTATION_READ_OCCURRENCE),s(r.ANNOTATION_WRITE_OCCURRENCE),s(r.ANNOTATION_SELECTED_LINKED_GROUP),s(r.ANNOTATION_CURRENT_LINKED_GROUP),s(r.ANNOTATION_LINKED_GROUP),s(r.ANNOTATION_CURRENT_LINE,!0),s(r.ANNOTATION_BLAME,!0),s(r.ANNOTATION_CURRENT_BLAME,!0),r.registerType(r.ANNOTATION_FOLDING,n),o.addMixin=function(e){var t=o.prototype;for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},o.prototype={addAnnotationType:function(e){this._annotationTypes||(this._annotationTypes=[]),this._annotationTypes.push(e)},getAnnotationTypePriority:function(e){if(this._annotationTypes)for(var t=0;t<this._annotationTypes.length;t++)if(this._annotationTypes[t]===e)return t+1;return 0},getAnnotationsByType:function(e,t,n){var r=e.getAnnotations(t,n),i,s=[];while(r.hasNext()){i=r.next();var o=this.getAnnotationTypePriority(i.type);if(o===0)continue;s.push(i)}var u=this;return s.sort(function(e,t){return u.getAnnotationTypePriority(e.type)-u.getAnnotationTypePriority(t.type)}),s},isAnnotationTypeVisible:function(e){return this.getAnnotationTypePriority(e)!==0},removeAnnotationType:function(e){if(!this._annotationTypes)return;for(var t=0;t<this._annotationTypes.length;t++)if(this._annotationTypes[t]===e){this._annotationTypes.splice(t,1);break}}},u.prototype={addAnnotation:function(e){if(!e)return;var t=this._annotations,n=this._binarySearch(t,e.start);t.splice(n,0,e);var r={type:"Changed",added:[e],removed:[],changed:[]};this.onChanged(r)},getTextModel:function(){return this._model},getAnnotations:function(e,t){var n=this._annotations,r,i=0,s=function(){while(i<n.length){var r=n[i++];if(e===r.start||(e>r.start?e<r.end:r.start<t))return r;if(r.start>=t)break}return null};return r=s(),{next:function(){var e=r;return e&&(r=s()),e},hasNext:function(){return r!==null}}},modifyAnnotation:function(e){if(!e)return;var t=this._getAnnotationIndex(e);if(t<0)return;var n={type:"Changed",added:[],removed:[],changed:[e]};this.onChanged(n)},onChanged:function(e){return this.dispatchEvent(e)},removeAnnotations:function(e){var t=this._annotations,n,r;if(e){n=[];for(r=t.length-1;r>=0;r--){var i=t[r];i.type===e&&(t.splice(r,1),n.splice(0,0,i))}}else n=t,t=[];var s={type:"Changed",removed:n,added:[],changed:[]};this.onChanged(s)},removeAnnotation:function(e){if(!e)return;var t=this._getAnnotationIndex(e);if(t<0)return;var n={type:"Changed",removed:this._annotations.splice(t,1),added:[],changed:[]};this.onChanged(n)},replaceAnnotations:function(e,t){var n=this._annotations,r,i,s,o=[];if(e)for(r=e.length-1;r>=0;r--){s=e[r],i=this._getAnnotationIndex(s);if(i<0)continue;n.splice(i,1),o.splice(0,0,s)}t||(t=[]);for(r=0;r<t.length;r++)s=t[r],i=this._binarySearch(n,s.start),n.splice(i,0,s);var u={type:"Changed",removed:o,added:t,changed:[]};this.onChanged(u)},setTextModel:function(e){this._model&&this._model.removeEventListener("Changed",this._listener.onChanged),this._model=e,this._model&&this._model.addEventListener("Changed",this._listener.onChanged)},_binarySearch:function(e,t){var n=e.length,r=-1,i;while(n-r>1)i=Math.floor((n+r)/2),t<=e[i].start?n=i:r=i;return n},_getAnnotationIndex:function(e){var t=this._annotations,n=this._binarySearch(t,e.start);while(n<t.length&&t[n].start===e.start){if(t[n]===e)return n;n++}return-1},_onChanged:function(e){var t=e.start,n=e.addedCharCount,r=e.removedCharCount,i=this._annotations,s=t+r,o=0;if(!(0<=o&&o<i.length))return;var u={type:"Changed",added:[],removed:[],changed:[],textModelChangedEvent:e},a=n-r,f;for(f=o;f<i.length;f++){var l=i[f];l.start>=s?(l.start+=a,l.end+=a,u.changed.push(l)):l.end<=t||(l.start<t&&s<l.end?(l.end+=a,u.changed.push(l)):(i.splice(f,1),u.removed.push(l),f--))}(u.added.length>0||u.removed.length>0||u.changed.length>0)&&this.onChanged(u)}},t.EventTarget.addMixin(u.prototype),a.prototype={destroy:function(){var e=this._view;e&&(e.removeEventListener("Destroy",this._listener.onDestroy),e.removeEventListener("LineStyle",this._listener.onLineStyle),this.view=null);var t=this._annotationModel;t&&(t.removeEventListener("Changed",this._listener.onChanged),t=null)},_mergeStyle:function(e,t){if(t){e||(e={}),e.styleClass&&t.styleClass&&e.styleClass!==t.styleClass?e.styleClass+=" "+t.styleClass:e.styleClass=t.styleClass;var n;t.tagName&&(e.tagName||(e.tagName=t.tagName));if(t.style){e.style||(e.style={});for(n in t.style)e.style[n]||(e.style[n]=t.style[n])}if(t.attributes){e.attributes||(e.attributes={});for(n in t.attributes)e.attributes[n]||(e.attributes[n]=t.attributes[n])}}return e},_mergeStyleRanges:function(e,t){e||(e=[]);var n,r;for(r=0;r<e.length&&t;r++){var i=e[r];if(t.end<=i.start)break;if(t.start>=i.end)continue;n=this._mergeStyle({},i.style),n=this._mergeStyle(n,t.style);var s=[];s.push(r,1),t.start<i.start&&s.push({start:t.start,end:i.start,style:t.style}),t.start>i.start&&s.push({start:i.start,end:t.start,style:i.style}),s.push({start:Math.max(i.start,t.start),end:Math.min(i.end,t.end),style:n}),t.end<i.end&&s.push({start:t.end,end:i.end,style:i.style}),t.end>i.end?t={start:i.end,end:t.end,style:t.style}:t=null,Array.prototype.splice.apply(e,s)}return t&&(n=this._mergeStyle({},t.style),e.splice(r,0,{start:t.start,end:t.end,style:n})),e},_onAnnotationModelChanged:function(e){function i(e){for(var i=0;i<e.length;i++){if(!n.isAnnotationTypeVisible(e[i].type))continue;var s=e[i].start,o=e[i].end;r.getBaseModel&&(s=r.mapOffset(s,!0),o=r.mapOffset(o,!0)),s!==-1&&o!==-1&&t.redrawRange(s,o)}}if(e.textModelChangedEvent)return;var t=this._view;if(!t)return;var n=this,r=t.getModel();i(e.added),i(e.removed),i(e.changed)},_onDestroy:function(e){this.destroy()},_onLineStyle:function(e){var t=this._annotationModel,n=e.textView.getModel(),r=t.getTextModel(),i=e.lineStart,s=e.lineStart+e.lineText.length;r!==n&&(i=n.mapOffset(i),s=n.mapOffset(s));var o=t.getAnnotations(i,s);while(o.hasNext()){var u=o.next();if(!this.isAnnotationTypeVisible(u.type))continue;if(u.rangeStyle){var a=u.start,f=u.end;r!==n&&(a=n.mapOffset(a,!0),f=n.mapOffset(f,!0)),e.ranges=this._mergeStyleRanges(e.ranges,{start:a,end:f,style:u.rangeStyle})}u.lineStyle&&(e.style=this._mergeStyle({},e.style),e.style=this._mergeStyle(e.style,u.lineStyle))}}},o.addMixin(a.prototype),{FoldingAnnotation:n,AnnotationType:r,AnnotationTypeList:o,AnnotationModel:u,AnnotationStyler:a}}),define("orion/objects",[],function(){function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}return{clone:function(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var n=Object.create(Object.getPrototypeOf(t));return e(n,t),n},mixin:e,toArray:function(e){return Array.isArray(e)?e:[e]}}}),define("orion/editor/editor",["i18n!orion/editor/nls/messages","orion/editor/eventTarget","orion/editor/tooltip","orion/editor/annotations","orion/objects","orion/util"],function(e,t,n,r,i,s){function a(e){e=e||{},this._domNode=e.domNode,this._statusReporter=e.statusReporter,this._dirty=!1,this._title=null}function f(e){e=e||{},a.call(this,e),this._textViewFactory=e.textViewFactory,this._undoStackFactory=e.undoStackFactory,this._textDNDFactory=e.textDNDFactory,this._annotationFactory=e.annotationFactory,this._foldingRulerFactory=e.foldingRulerFactory,this._lineNumberRulerFactory=e.lineNumberRulerFactory,this._contentAssistFactory=e.contentAssistFactory,this._keyBindingFactory=e.keyBindingFactory,this._annotationStyler=null,this._annotationModel=null,this._annotationRuler=null,this._lineNumberRuler=null,this._overviewRuler=null,this._foldingRuler=null,this._contentAssist=null}var o=r.AnnotationType,u="orion.annotation.highlightError";return a.prototype={destroy:function(){this.uninstall(),this._statusReporter=this._domNode=null},focus:function(){},getModel:function(){return this._model},getText:function(e,t){return this.getModel().getText(e,t)},getTitle:function(){return this._title},install:function(){},isDirty:function(){return this._dirty},markClean:function(){this.setDirty(!1)},onDirtyChanged:function(e){return this.dispatchEvent(e)},onInputChanged:function(e){return this.dispatchEvent(e)},reportStatus:function(e,t,n){this._statusReporter&&this._statusReporter(e,t,n)},resize:function(){},setDirty:function(e){if(this._dirty===e)return;this._dirty=e,this.onDirtyChanged({type:"DirtyChanged"})},setInput:function(e,t,n,r){this._title=e,this.onInputChanged({type:"InputChanged",title:e,message:t,contents:n,contentsSaved:r})},uninstall:function(){}},t.EventTarget.addMixin(a.prototype),f.prototype=new a,i.mixin(f.prototype,{destroy:function(){a.prototype.destroy.call(this),this._textViewFactory=this._undoStackFactory=this._textDNDFactory=this._annotationFactory=this._foldingRulerFactory=this._lineNumberRulerFactory=this._contentAssistFactory=this._keyBindingFactory=null},getAnnotationModel:function(){return this._annotationModel},getAnnotationRuler:function(){return this._annotationRuler},getAnnotationStyler:function(){return this._annotationStyler},getContentAssist:function(){return this._contentAssist},getFoldingRuler:function(){return this._foldingRuler},getLineNumberRuler:function(){return this._lineNumberRuler},getModel:function(){var e=this._textView.getModel();return e.getBaseModel&&(e=e.getBaseModel()),e},getOverviewRuler:function(){return this._overviewRuler},getTextView:function(){return this._textView},getUndoStack:function(){return this._undoStack},getKeyModes:function(){return this._textView.getKeyModes()},getSourceCodeActions:function(){return this._sourceCodeActions},getLinkedMode:function(){return this._linkedMode},getTextActions:function(){return this._textActions},focus:function(){this._textView&&this._textView.focus()},markClean:function(){this.getUndoStack().markClean()},resize:function(){this._textView&&this._textView.resize()},setAnnotationRulerVisible:function(e,t){if(this._annotationRulerVisible===e&&!t)return;this._annotationRulerVisible=e;if(!this._annotationRuler)return;var n=this._textView;e?n.addRuler(this._annotationRuler,0):n.removeRuler(this._annotationRuler)},setFoldingRulerVisible:function(e,t){if(this._foldingRulerVisible===e&&!t)return;this._foldingRulerVisible=e;if(!this._foldingRuler)return;var n=this._textView;if(!n.getModel().getBaseModel)return;e?n.addRuler(this._foldingRuler):n.removeRuler(this._foldingRuler)},setLineNumberRulerVisible:function(e,t){if(this._lineNumberRulerVisible===e&&!t)return;this._lineNumberRulerVisible=e;if(!this._lineNumberRuler)return;var n=this._textView;e?n.addRuler(this._lineNumberRuler,this._annotationRulerVisible?1:0):n.removeRuler(this._lineNumberRuler)},setOverviewRulerVisible:function(e,t){if(this._overviewRulerVisible===e&&!t)return;this._overviewRulerVisible=e;if(!this._overviewRuler)return;var n=this._textView;e?n.addRuler(this._overviewRuler):n.removeRuler(this._overviewRuler)},mapOffset:function(e,t){var n=this._textView,r=n.getModel();return r.getBaseModel&&(e=r.mapOffset(e,t)),e},getCaretOffset:function(){return this.mapOffset(this._textView.getCaretOffset())},getSelection:function(){var e=this._textView,t=e.getSelection(),n=e.getModel();return n.getBaseModel&&(t.start=n.mapOffset(t.start),t.end=n.mapOffset(t.end)),t},_expandOffset:function(e){var t=this._textView.getModel(),n=this._annotationModel;if(!n||!t.getBaseModel)return;var r=n.getAnnotations(e,e+1);while(r.hasNext()){var i=r.next();i.type===o.ANNOTATION_FOLDING&&i.expand&&(i.expand(),n.modifyAnnotation(i))}},setCaretOffset:function(e,t,n){var r=this._textView,i=r.getModel();i.getBaseModel&&(this._expandOffset(e),e=i.mapOffset(e,!0)),r.setCaretOffset(e,t,n)},setText:function(e,t,n){var r=this._textView,i=r.getModel();i.getBaseModel&&(t!==undefined&&(this._expandOffset(t),t=i.mapOffset(t,!0)),n!==undefined&&(this._expandOffset(n),n=i.mapOffset(n,!0))),r.setText(e,t,n)},setSelection:function(e,t,n,r){var i=this._textView,s=i.getModel();s.getBaseModel&&(this._expandOffset(e),this._expandOffset(t),e=s.mapOffset(e,!0),t=s.mapOffset(t,!0)),i.setSelection(e,t,n,r)},moveSelection:function(e,t,n,r){t=t||e;var i=this._textView;this.setSelection(e,t,1/3,function(){(r===undefined||r)&&i.focus(),n&&n()})},checkDirty:function(){this.setDirty(!this._undoStack.isClean())},_getTooltipInfo:function(e,t){var n=this._textView,r=this.getAnnotationModel();if(!r)return null;var i=this._annotationStyler;if(!i)return null;var s=n.getOffsetAtLocation(e,t);if(s===-1)return null;s=this.mapOffset(s);var o=i.getAnnotationsByType(r,s,s+1),u=[];for(var a=0;a<o.length;a++)o[a].rangeStyle&&u.push(o[a]);if(u.length===0)return null;var f=n.convert({x:e,y:t},"document","page"),l={contents:u,anchor:"left",x:f.x+10,y:f.y+20};return l},_highlightCurrentLine:function(e,t){var n=this._annotationModel;if(!n)return;var r=this._textView;if(r.getOptions("singleMode"))return;var i=r.getModel(),s=t?i.getLineAtOffset(t.start):-1,u=i.getLineAtOffset(e.start),a=e.start===e.end,f=!t||t.start===t.end,l=i.getLineStart(u),c=i.getLineEnd(u);i.getBaseModel&&(l=i.mapOffset(l),c=i.mapOffset(c));var h=this._currentLineAnnotation;if(s===u&&f&&a&&h&&h.start===l&&h.end===c)return;var p=h?[h]:null,d;if(a){var v=o.ANNOTATION_CURRENT_LINE;h=o.createAnnotation(v,l,c),d=[h]}this._currentLineAnnotation=h,n.replaceAnnotations(p,d)},install:function(){this.installTextView()},installTextView:function(){if(this._textView)return;this._textView=this._textViewFactory(),this._undoStackFactory&&(this._undoStack=this._undoStackFactory.createUndoStack(this)),this._textDNDFactory&&(this._textDND=this._textDNDFactory.createTextDND(this,this._undoStack));if(this._contentAssistFactory){var e=this._contentAssistFactory.createContentAssistMode(this);this._contentAssist=e.getContentAssist()}var t=this,r=this._textView,i=this;this._listener={onModelChanged:function(e){i.checkDirty()},onMouseOver:function(e){i._listener.onMouseMove(e)},onMouseMove:function(e){var t=n.Tooltip.getTooltip(r);if(!t)return;if(i._listener.lastMouseX===e.event.clientX&&i._listener.lastMouseY===e.event.clientY)return;i._listener.lastMouseX=e.event.clientX,i._listener.lastMouseY=e.event.clientY,t.setTarget({x:e.x,y:e.y,getTooltipInfo:function(){return i._getTooltipInfo(this.x,this.y)}})},onMouseOut:function(e){var t=n.Tooltip.getTooltip(r);if(!t)return;if(i._listener.lastMouseX===e.event.clientX&&i._listener.lastMouseY===e.event.clientY)return;i._listener.lastMouseX=e.event.clientX,i._listener.lastMouseY=e.event.clientY,t.setTarget(null)},onScroll:function(e){var t=n.Tooltip.getTooltip(r);if(!t)return;t.setTarget(null,0,0)},onSelection:function(e){i._updateCursorStatus(),i._highlightCurrentLine(e.newValue,e.oldValue)}},r.addEventListener("ModelChanged",this._listener.onModelChanged),r.addEventListener("Selection",this._listener.onSelection),r.addEventListener("MouseOver",this._listener.onMouseOver),r.addEventListener("MouseOut",this._listener.onMouseOut),r.addEventListener("MouseMove",this._listener.onMouseMove),r.addEventListener("Scroll",this._listener.onScroll);if(this._keyBindingFactory){var s;typeof this._keyBindingFactory=="function"?s=this._keyBindingFactory(this,this.getKeyModes(),this._undoStack,this._contentAssist):s=this._keyBindingFactory.createKeyBindings(t,this._undoStack,this._contentAssist),s&&(this._textActions=s.textActions,this._linkedMode=s.linkedMode,this._sourceCodeActions=s.sourceCodeActions)}var a=function(e,n){if(e===undefined)return;if(e===-1)return;var r=this.getView(),i=r.getModel(),s=this.getAnnotationModel(),u=t.mapOffset(i.getLineStart(e)),a=t.mapOffset(i.getLineEnd(e)),f=s.getAnnotations(u,a),l=null;while(f.hasNext()){var c=f.next();if(c.type===o.ANNOTATION_BOOKMARK){l=c;break}}l?s.removeAnnotation(l):(l=o.createAnnotation(o.ANNOTATION_BOOKMARK,u,a),l.title=undefined,s.addAnnotation(l))};if(this._annotationFactory){var f=r.getModel();f.getBaseModel&&(f=f.getBaseModel()),this._annotationModel=this._annotationFactory.createAnnotationModel(f);if(this._annotationModel){var l=this._annotationStyler=this._annotationFactory.createAnnotationStyler(r,this._annotationModel);l&&(l.addAnnotationType(o.ANNOTATION_CURRENT_SEARCH),l.addAnnotationType(o.ANNOTATION_MATCHING_SEARCH),l.addAnnotationType(o.ANNOTATION_ERROR),l.addAnnotationType(o.ANNOTATION_WARNING),l.addAnnotationType(o.ANNOTATION_MATCHING_BRACKET),l.addAnnotationType(o.ANNOTATION_CURRENT_BRACKET),l.addAnnotationType(o.ANNOTATION_CURRENT_LINE),l.addAnnotationType(o.ANNOTATION_READ_OCCURRENCE),l.addAnnotationType(o.ANNOTATION_WRITE_OCCURRENCE),l.addAnnotationType(o.ANNOTATION_SELECTED_LINKED_GROUP),l.addAnnotationType(o.ANNOTATION_CURRENT_LINKED_GROUP),l.addAnnotationType(o.ANNOTATION_LINKED_GROUP),l.addAnnotationType(u))}r.annotationModel=this._annotationModel;var c=this._annotationFactory.createAnnotationRulers(this._annotationModel),h=this._annotationRuler=c.annotationRuler;h&&(h.onDblClick=a,h.setMultiAnnotationOverlay({html:"<div class='annotationHTML overlay'></div>"}),h.addAnnotationType(o.ANNOTATION_ERROR),h.addAnnotationType(o.ANNOTATION_WARNING),h.addAnnotationType(o.ANNOTATION_TASK),h.addAnnotationType(o.ANNOTATION_BOOKMARK)),this.setAnnotationRulerVisible(this._annotationRulerVisible||this._annotationRulerVisible===undefined,!0),h=this._overviewRuler=c.overviewRuler,h&&(h.addAnnotationType(o.ANNOTATION_CURRENT_SEARCH),h.addAnnotationType(o.ANNOTATION_MATCHING_SEARCH),h.addAnnotationType(o.ANNOTATION_READ_OCCURRENCE),h.addAnnotationType(o.ANNOTATION_WRITE_OCCURRENCE),h.addAnnotationType(o.ANNOTATION_CURRENT_BLAME),h.addAnnotationType(o.ANNOTATION_ERROR),h.addAnnotationType(o.ANNOTATION_WARNING),h.addAnnotationType(o.ANNOTATION_TASK),h.addAnnotationType(o.ANNOTATION_BOOKMARK),h.addAnnotationType(o.ANNOTATION_MATCHING_BRACKET),h.addAnnotationType(o.ANNOTATION_CURRENT_BRACKET),h.addAnnotationType(o.ANNOTATION_CURRENT_LINE)),this.setOverviewRulerVisible(this._overviewRulerVisible||this._overviewRulerVisible===undefined,!0)}this._lineNumberRulerFactory&&(this._lineNumberRuler=this._lineNumberRulerFactory.createLineNumberRuler(this._annotationModel),this._lineNumberRuler.addAnnotationType(o.ANNOTATION_CURRENT_BLAME),this._lineNumberRuler.addAnnotationType(o.ANNOTATION_BLAME),this._lineNumberRuler.onDblClick=a,this.setLineNumberRulerVisible(this._lineNumberRulerVisible||this._lineNumberRulerVisible===undefined,!0)),this._foldingRulerFactory&&(this._foldingRuler=this._foldingRulerFactory.createFoldingRuler(this._annotationModel),this._foldingRuler.addAnnotationType(o.ANNOTATION_FOLDING),this.setFoldingRulerVisible(this._foldingRulerVisible||this._foldingRulerVisible===undefined,!0));var p={type:"TextViewInstalled",textView:r};this.dispatchEvent(p)},uninstall:function(){this.uninstallTextView()},uninstallTextView:function(){var e=this._textView;if(!e)return;e.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._foldingRulerVisible=this._overviewRulerVisible=this._lineNumberRulerVisible=this._annotationRulerVisible=undefined;var t={type:"TextViewUninstalled",textView:e};this.dispatchEvent(t)},_updateCursorStatus:function(){var t=this.getModel(),n=this.getCaretOffset(),r=t.getLineAtOffset(n),i=t.getLineStart(r),o=n-i,u=this.getKeyModes();for(var a=0;a<u.length;a++){var f=u[a];if(f.isActive()&&f.isStatusActive&&f.isStatusActive())return}this.reportStatus(s.formatMessage(e.lineColumn,r+1,o+1))},showAnnotations:function(e,t,n,r){var i=this._annotationModel;if(!i)return;var s=[],u=[],a=i.getTextModel(),f=i.getAnnotations(0,a.getCharCount()),l;while(f.hasNext())l=f.next(),t.indexOf(l.type)!==-1&&l.creatorID===this&&s.push(l);if(e)for(var c=0;c<e.length;c++){l=e[c];if(!l)continue;if(n)l=n(l);else{var h,p;if(typeof l.line=="number"){var d=l.line-1,v=a.getLineStart(d);h=v+l.start-1,p=v+l.end}else h=l.start,p=l.end;var m=r(l);if(!m)continue;l=o.createAnnotation(m,h,p,l.description)}l.creatorID=this,u.push(l)}i.replaceAnnotations(s,u)},showProblems:function(e){this.showAnnotations(e,[o.ANNOTATION_ERROR,o.ANNOTATION_WARNING,o.ANNOTATION_TASK],null,function(e){switch(e.severity){case"error":return o.ANNOTATION_ERROR;case"warning":return o.ANNOTATION_WARNING;case"task":return o.ANNOTATION_TASK}return null})},showOccurrences:function(e){this.showAnnotations(e,[o.ANNOTATION_READ_OCCURRENCE,o.ANNOTATION_WRITE_OCCURRENCE],null,function(e){return e.readAccess?o.ANNOTATION_READ_OCCURRENCE:o.ANNOTATION_WRITE_OCCURRENCE})},showBlame:function(t){var n=this._blameRGB,u=this.getTextView().getOptions("parent").ownerDocument;if(!n){var a=s.createElement(u,"div");a.className="annotation blame",u.body.appendChild(a);var f=u.defaultView||u.parentWindow,l=f.getComputedStyle(a),c=l.getPropertyValue("background-color");a.parentNode.removeChild(a);var h=c.indexOf("("),p=c.indexOf(")");c=c.substring(h+1,p),this._blameRGB=n=c.split(",").slice(0,3)}var d=function(){var e=r.AnnotationType.createAnnotation(this.groupType,this.start,this.end,this.title);return e.style=i.mixin({},e.style),e.style.style=i.mixin({},e.style.style),e.style.style.backgroundColor="",this.groupAnnotation=e,e.blame=this.blame,e.html=this.html,e},v=function(){var t=s.createElement(u,"div");t.className="tooltipTitle";var n=this.blame.Message.indexOf("\n");n===-1&&(n=this.blame.Message.length);var r=s.createElement(u,"a");return r.href=this.blame.CommitLink,r.appendChild(u.createTextNode(this.blame.Message.substring(0,n))),t.appendChild(r),t.appendChild(s.createElement(u,"br")),t.appendChild(u.createTextNode(s.formatMessage(e.committerOnTime,this.blame.AuthorName,this.blame.Time))),t},m=this.getModel();this.showAnnotations(t,[o.ANNOTATION_BLAME,o.ANNOTATION_CURRENT_BLAME],function(e){var t=m.getLineStart(e.Start-1),s=m.getLineEnd(e.End-1,!0),u=r.AnnotationType.createAnnotation(o.ANNOTATION_BLAME,t,s,v),a=n.slice(0);return a.push(e.Shade),u.style=i.mixin({},u.style),u.style.style=i.mixin({},u.style.style),u.style.style.backgroundColor="rgba("+a.join()+")",u.groupId=e.Name,u.groupType=o.ANNOTATION_CURRENT_BLAME,u.createGroupAnnotation=d,u.html='<img class="annotationHTML blame" src="'+e.AuthorImage+'"/>',u.blame=e,u})},showSelection:function(e,t,n,r,i){if(typeof e=="number")typeof t!="number"&&(t=e),this.moveSelection(e,t);else if(typeof n=="number"){var s=this.getModel(),o=s.getLineStart(n-1);typeof r=="number"&&(o+=r),typeof i!="number"&&(i=0),this.moveSelection(o,o+i)}},setInput:function(e,t,n,r){this._textView&&(r||(t?this._textView.setText(t):n!==null&&n!==undefined&&(this._textView.setText(n),this._textView.getModel().setLineDelimiter("auto"),this._highlightCurrentLine(this._textView.getSelection())),this._undoStack.reset(),this._textView.focus()),this.checkDirty()),a.prototype.setInput.call(this,e,t,n,r)},onGotoLine:function(e,t,n,r){if(this._textView){var i=this.getModel();e=Math.max(0,Math.min(e,i.getLineCount()-1));var s=i.getLineStart(e),o=0;n===undefined&&(n=0);if(typeof t=="string"){var u=i.getLine(e).indexOf(t);u!==-1&&(o=u,n=o+t.length)}else{o=t;var a=i.getLineEnd(e)-s;o=Math.min(o,a),n=Math.min(n,a)}this.moveSelection(s+o,s+n,r)}}}),{BaseEditor:a,Editor:f}}),define("orion/regex",[],function(){function e(e){return e.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&")}function t(e){var t=/^\s*\/(.+)\/([gim]{0,3})\s*$/.exec(e);return t?{pattern:t[1],flags:t[2]}:null}return{escape:e,parse:t}}),define("orion/editor/find",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/keyModes","orion/editor/annotations","orion/regex","orion/objects","orion/util"],function(e,t,n,r,i,s,o){function a(e){var t=e.getTextView();n.KeyMode.call(this,t),this.editor=e,this._active=!1,this._success=!0,this._ignoreSelection=!1,this._prefix="",t.setAction("incrementalFindCancel",function(){return this.setActive(!1),!0}.bind(this)),t.setAction("incrementalFindBackspace",function(){return this._backspace()}.bind(this));var r=this;this._listener={onVerify:function(e){var t=r.editor,n=t.getModel(),s=t.mapOffset(e.start),o=t.mapOffset(e.end),u=n.getText(s,o),a=r._prefix,f=a.match(new RegExp("^"+i.escape(u),"i"));f&&f.length>0&&(a=r._prefix+=e.text,r._success=!0,r._status(),r.find(r._forward,!0),e.text=null)},onSelection:function(){r._ignoreSelection||r.setActive(!1)}}}function f(e,t,n){if(!e)return;this._editor=e,this._undoStack=t,this._showAll=!0,this._visible=!1,this._caseInsensitive=!0,this._wrap=!0,this._wholeWord=!1,this._incremental=!0,this._regex=!1,this._findAfterReplace=!0,this._hideAfterFind=!1,this._reverse=!1,this._start=undefined,this._end=undefined,this._timer=undefined,this._lastString="";var r=this;this._listeners={onEditorFocus:function(e){r._removeCurrentAnnotation(e)}},this.setOptions(n)}var u={};return a.prototype=new n.KeyMode,s.mixin(a.prototype,{createKeyBindings:function(){var e=t.KeyBinding,n=[];return n.push({actionID:"incrementalFindBackspace",keyBinding:new e(8)}),n.push({actionID:"incrementalFindCancel",keyBinding:new e(13)}),n.push({actionID:"incrementalFindCancel",keyBinding:new e(27)}),n.push({actionID:"incrementalFindReverse",keyBinding:new e(38)}),n.push({actionID:"incrementalFind",keyBinding:new e(40)}),n.push({actionID:"incrementalFindReverse",keyBinding:new e("k",!0,!0)}),n.push({actionID:"incrementalFind",keyBinding:new e("k",!0)}),n},find:function(e,t){this._forward=e;if(!this.isActive())return this.setActive(!0),!1;var n=this._prefix;if(n.length===0)return!1;var r=this.editor,i=r.getModel(),s;e?this._success?s=t?this._start:r.getCaretOffset()+1:s=0:this._success?s=t?this._start:r.getCaretOffset():s=i.getCharCount()-1;var o=r.getModel().find({string:n,start:s,reverse:!e,caseInsensitive:n.toLowerCase()===n}).next();return o?(t||(this._start=s),this._success=!0,this._ignoreSelection=!0,r.moveSelection(e?o.start:o.end,e?o.end:o.start),this._ignoreSelection=!1):this._success=!1,this._status(),!0},isActive:function(){return this._active},isStatusActive:function(){return this.isActive()},setActive:function(e){if(this._active===e)return;this._active=e,this._prefix="",this._success=!0;var t=this.editor,n=t.getTextView();this._start=this.editor.getCaretOffset(),this.editor.setCaretOffset(this._start),this._active?(n.addEventListener("Verify",this._listener.onVerify),n.addEventListener("Selection",this._listener.onSelection),n.addKeyMode(this)):(n.removeEventListener("Verify",this._listener.onVerify),n.removeEventListener("Selection",this._listener.onSelection),n.removeKeyMode(this)),this._status()},_backspace:function(){var e=this._prefix;return e=this._prefix=e.substring(0,e.length-1),e.length===0?(this._success=!0,this._ignoreSelection=!0,this.editor.setCaretOffset(this.editor.getSelection().start),this._ignoreSelection=!1,this._status(),!0):this.find(this._forward,!0)},_status:function(){if(!this.isActive()){this.editor.reportStatus("");return}var t;this._forward?t=this._success?e.incrementalFindStr:e.incrementalFindStrNotFound:t=this._success?e.incrementalFindReverseStr:e.incrementalFindReverseStrNotFound,t=o.formatMessage(t,this._prefix),this.editor.reportStatus(t,this._success?"":"error")}}),u.IncrementalFind=a,f.prototype={find:function(e,t,n){this.setOptions({reverse:!e});var r=this.getFindString(),i;t&&(r=t.findString||r,i=t.count);var s=this.getOptions();this.setOptions(t);var o=n?this._startOffset:this.getStartOffset(),u=this._doFind(r,o,i);return u&&(n||(this._startOffset=u.start)),this.setOptions(s),this._hideAfterFind&&this.hide(),u},getStartOffset:function(){return this._start!==undefined?this._start:this._reverse?this._editor.getSelection().start-1:this._editor.getCaretOffset()},getFindString:function(){var e=this._editor.getSelection(),t=this._editor.getText(e.start,e.end);return this._regex&&(t=i.escape(t)),t||this._lastString},getOptions:function(){return{showAll:this._showAll,caseInsensitive:this._caseInsensitive,wrap:this._wrap,wholeWord:this._wholeWord,incremental:this._incremental,regex:this._regex,findAfterReplace:this._findAfterReplace,hideAfterFind:this._hideAfterFind,reverse:this._reverse,findCallback:this._findCallback,start:this._start,end:this._end}},getReplaceString:function(){return""},hide:function(){this._visible=!1,this._savedOptions&&(this.setOptions(this._savedOptions.pop()),this._savedOptions.length===0&&(this._savedOptions=null)),this._removeAllAnnotations();var e=this._editor.getTextView();e&&(e.removeEventListener("Focus",this._listeners.onEditorFocus),e.focus())},_processReplaceString:function(e){var t=e;if(this._regex){t="";var n=!1,r=this._editor.getModel().getLineDelimiter();for(var i=0;i<e.length;i++){var s=e.substring(i,i+1);if(n){switch(s){case"R":t+=r;break;case"r":t+="\r";break;case"n":t+="\n";break;case"t":t+=" ";break;case"\\":t+="\\";break;default:t+="\\"+s}n=!1}else s==="\\"?n=!0:t+=s}n&&(t+="\\")}return t},isVisible:function(){return this._visible},replace:function(){var e=this.getFindString();if(e){var t=this._editor,n=this._processReplaceString(this.getReplaceString()),r=t.getSelection(),i=r.start,s=t.getModel().find({string:e,start:i,reverse:!1,wrap:this._wrap,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive}).next();s&&(this.startUndo(),this._doReplace(s.start,s.end,e,n),this.endUndo())}this._findAfterReplace&&e&&this._doFind(e,this.getStartOffset())},replaceAll:function(){var t=this.getFindString();if(t){this._replacingAll=!0;var n=this._editor,r=n.getTextView();n.reportStatus(e.replaceAll);var i=this._processReplaceString(this.getReplaceString()),s=this;window.setTimeout(function(){var u=0,a=0,f;for(;;){var l=s._doFind(t,u,null,!0);if(!l)break;f=l,a++,a===1&&(r.setRedraw(!1),s.startUndo()),s._doReplace(l.start,l.end,t,i),u=s.getStartOffset()}a>0&&(s.endUndo(),r.setRedraw(!0)),u>0?n.reportStatus(o.formatMessage(e.replacedMatches,a)):n.reportStatus(e.nothingReplaced,"error"),s._replacingAll=!1},100)}},setOptions:function(e){if(e){if((e.showAll===!0||e.showAll===!1)&&this._showAll!==e.showAll){this._showAll=e.showAll;if(this.isVisible())if(this._showAll)this._markAllOccurrences();else{var t=this._editor.getAnnotationModel();t&&t.removeAnnotations(r.AnnotationType.ANNOTATION_MATCHING_SEARCH)}}if(e.caseInsensitive===!0||e.caseInsensitive===!1)this._caseInsensitive=e.caseInsensitive;if(e.wrap===!0||e.wrap===!1)this._wrap=e.wrap;if(e.wholeWord===!0||e.wholeWord===!1)this._wholeWord=e.wholeWord;if(e.incremental===!0||e.incremental===!1)this._incremental=e.incremental;if(e.regex===!0||e.regex===!1)this._regex=e.regex;if(e.findAfterReplace===!0||e.findAfterReplace===!1)this._findAfterReplace=e.findAfterReplace;if(e.hideAfterFind===!0||e.hideAfterFind===!1)this._hideAfterFind=e.hideAfterFind;if(e.reverse===!0||e.reverse===!1)this._reverse=e.reverse;e.hasOwnProperty("findCallback")&&(this._findCallback=e.findCallback),e.hasOwnProperty("start")&&(this._start=e.start),e.hasOwnProperty("end")&&(this._end=e.end)}},show:function(e){this._visible=!0,e&&(this._savedOptions||(this._savedOptions=[]),this._savedOptions.push(this.getOptions()),this.setOptions(e)),this._startOffset=this._editor.getSelection().start,this._editor.getTextView().addEventListener("Focus",this._listeners.onEditorFocus);var t=this;window.setTimeout(function(){t._incremental&&t.find(!0,null,!0)},0)},startUndo:function(){this._undoStack&&this._undoStack.startCompoundChange()},endUndo:function(){this._undoStack&&this._undoStack.endCompoundChange()},_find:function(e,t,n){return this._editor.getModel().find({string:e,start:t,end:this._end,reverse:this._reverse,wrap:n?!1:this._wrap,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive})},_doFind:function(t,n,i,s){i=i||1;var o=this._editor;if(!t)return this._removeAllAnnotations(),null;this._lastString=t;var u,a;if(this._regex)try{a=this._find(t,n,s)}catch(f){o.reportStatus(f.message,"error");return}else a=this._find(t,n,s);for(var l=0;l<i&&a.hasNext();l++)u=a.next();if(!this._replacingAll){u?this._editor.reportStatus(""):this._editor.reportStatus(e.notFound,"error");if(this.isVisible()){var c=r.AnnotationType.ANNOTATION_CURRENT_SEARCH,h=o.getAnnotationModel();h&&(h.removeAnnotations(c),u&&h.addAnnotation(r.AnnotationType.createAnnotation(c,u.start,u.end)));if(this._showAll){this._timer&&window.clearTimeout(this._timer);var p=this;this._timer=window.setTimeout(function(){p._markAllOccurrences(),p._timer=null},500)}}this._findCallback?this._findCallback(u):u&&o.moveSelection(u.start,u.end,null,!1)}return u},_doReplace:function(e,t,n,r){var i=this._editor;if(this._regex){r=i.getText(e,t).replace(new RegExp(n,this._caseInsensitive?"i":""),r);if(!r)return}i.setText(r,e,t),i.setSelection(e,e+r.length,!0)},_markAllOccurrences:function(){var e=this._editor.getAnnotationModel();if(!e)return;var t=r.AnnotationType.ANNOTATION_MATCHING_SEARCH,n=e.getAnnotations(0,e.getTextModel().getCharCount()),i=[],s;while(n.hasNext()){var o=n.next();o.type===t&&i.push(o)}if(this.isVisible()){var u=this.getFindString();n=this._editor.getModel().find({string:u,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive}),s=[];while(n.hasNext()){var a=n.next();s.push(r.AnnotationType.createAnnotation(t,a.start,a.end))}}e.replaceAnnotations(i,s)},_removeAllAnnotations:function(){var e=this._editor.getAnnotationModel();e&&(e.removeAnnotations(r.AnnotationType.ANNOTATION_CURRENT_SEARCH),e.removeAnnotations(r.AnnotationType.ANNOTATION_MATCHING_SEARCH))},_removeCurrentAnnotation:function(e){var t=this._editor.getAnnotationModel();t&&t.removeAnnotations(r.AnnotationType.ANNOTATION_CURRENT_SEARCH)}},u.Find=f,u}),define("orion/editor/actions",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/annotations","orion/editor/tooltip","orion/editor/find","orion/util"],function(e,t,n,r,i,s){function a(e,t,n){this.editor=e,this.undoStack=t,this._incrementalFind=new i.IncrementalFind(e),this._find=n?n:new i.Find(e,t),this._lastEditLocation=null,this.init()}function f(e,t,n,r){this.editor=e,this.undoStack=t,this.contentAssist=n,this.linkedMode=r,this.contentAssist&&this.contentAssist.addEventListener("ProposalApplied",this.contentAssistProposalApplied.bind(this)),this.init()}var o=n.AnnotationType,u={};return a.prototype={init:function(){var n=this.editor.getTextView();this._lastEditListener={onModelChanged:function(e){this.editor.isDirty()&&(this._lastEditLocation=e.start+e.addedCharCount)}.bind(this)},n.addEventListener("ModelChanged",this._lastEditListener.onModelChanged),n.setAction("undo",function(){return this.undoStack?(this.undoStack.undo(),!0):!1}.bind(this),{name:e.undo}),n.setAction("redo",function(){return this.undoStack?(this.undoStack.redo(),!0):!1}.bind(this),{name:e.redo}),n.setKeyBinding(new t.KeyBinding("f",!0),"find"),n.setAction("find",function(){if(this._find){var t=this.editor.getSelection(),n=prompt(e.find,this.editor.getText(t.start,t.end));n&&this._find.find(!0,{findString:n})}}.bind(this),{name:e.find}),n.setKeyBinding(new t.KeyBinding("k",!0),"findNext"),n.setAction("findNext",function(e){return this._find?(this._find.find(!0,e),!0):!1}.bind(this),{name:e.findNext}),n.setKeyBinding(new t.KeyBinding("k",!0,!0),"findPrevious"),n.setAction("findPrevious",function(e){return this._find?(this._find.find(!1,e),!0):!1}.bind(this),{name:e.findPrevious}),n.setKeyBinding(new t.KeyBinding("j",!0),"incrementalFind"),n.setAction("incrementalFind",function(){return this._incrementalFind&&this._incrementalFind.find(!0),!0}.bind(this),{name:e.incrementalFind}),n.setKeyBinding(new t.KeyBinding("j",!0,!0),"incrementalFindReverse"),n.setAction("incrementalFindReverse",function(){return this._incrementalFind&&this._incrementalFind.find(!1),!0}.bind(this),{name:e.incrementalFindReverse}),n.setAction("tab",function(){return this.indentLines()}.bind(this)),n.setAction("shiftTab",function(){return this.unindentLines()}.bind(this),{name:e.unindentLines}),n.setKeyBinding(new t.KeyBinding(38,!1,!1,!0),"moveLinesUp"),n.setAction("moveLinesUp",function(){return this.moveLinesUp()}.bind(this),{name:e.moveLinesUp}),n.setKeyBinding(new t.KeyBinding(40,!1,!1,!0),"moveLinesDown"),n.setAction("moveLinesDown",function(){return this.moveLinesDown()}.bind(this),{name:e.moveLinesDown}),n.setKeyBinding(new t.KeyBinding(38,!0,!1,!0),"copyLinesUp"),n.setAction("copyLinesUp",function(){return this.copyLinesUp()}.bind(this),{name:e.copyLinesUp}),n.setKeyBinding(new t.KeyBinding(40,!0,!1,!0),"copyLinesDown"),n.setAction("copyLinesDown",function(){return this.copyLinesDown()}.bind(this),{name:e.copyLinesDown}),n.setKeyBinding(new t.KeyBinding("d",!0,!1,!1),"deleteLines"),n.setAction("deleteLines",function(e){return this.deleteLines(e)}.bind(this),{name:e.deleteLines}),n.setKeyBinding(new t.KeyBinding("l",!s.isMac,!1,!1,s.isMac),"gotoLine"),n.setAction("gotoLine",function(){return this.gotoLine()}.bind(this),{name:e.gotoLine}),n.setKeyBinding(new t.KeyBinding(190,!0),"nextAnnotation"),n.setAction("nextAnnotation",function(){return this.nextAnnotation(!0)}.bind(this),{name:e.nextAnnotation}),n.setKeyBinding(new t.KeyBinding(188,!0),"previousAnnotation"),n.setAction("previousAnnotation",function(){return this.nextAnnotation(!1)}.bind(this),{name:e.prevAnnotation}),n.setKeyBinding(new t.KeyBinding("e",!0,!1,!0,!1),"expand"),n.setAction("expand",function(){return this.expandAnnotation(!0)}.bind(this),{name:e.expand}),n.setKeyBinding(new t.KeyBinding("c",!0,!1,!0,!1),"collapse"),n.setAction("collapse",function(){return this.expandAnnotation(!1)}.bind(this),{name:e.collapse}),n.setKeyBinding(new t.KeyBinding("e",!0,!0,!0,!1),"expandAll"),n.setAction("expandAll",function(){return this.expandAnnotations(!0)}.bind(this),{name:e.expandAll}),n.setKeyBinding(new t.KeyBinding("c",!0,!0,!0,!1),"collapseAll"),n.setAction("collapseAll",function(){return this.expandAnnotations(!1)}.bind(this),{name:e.collapseAll}),n.setKeyBinding(new t.KeyBinding("q",!s.isMac,!1,!1,s.isMac),"lastEdit"),n.setAction("lastEdit",function(){return this.gotoLastEdit()}.bind(this),{name:e.lastEdit})},copyLinesDown:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel(),r=e.getSelection(),i=n.getLineAtOffset(r.start),s=n.getLineAtOffset(r.end>r.start?r.end-1:r.end),o=n.getLineStart(i),u=n.getLineEnd(s,!0),a=n.getLineCount(),f="",l=n.getText(o,u);s===a-1&&(l=(f=n.getLineDelimiter())+l);var c=u;return e.setText(l,c,c),e.setSelection(c+f.length,c+l.length),!0},copyLinesUp:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel(),r=e.getSelection(),i=n.getLineAtOffset(r.start),s=n.getLineAtOffset(r.end>r.start?r.end-1:r.end),o=n.getLineStart(i),u=n.getLineEnd(s,!0),a=n.getLineCount(),f="",l=n.getText(o,u);s===a-1&&(l+=f=n.getLineDelimiter());var c=o;return e.setText(l,c,c),e.setSelection(c,c+l.length-f.length),!0},deleteLines:function(e){var t=this.editor,n=t.getTextView();if(n.getOptions("readonly"))return!1;var r=1;e&&e.count&&(r=e.count);var i=t.getSelection(),s=t.getModel(),o=s.getLineAtOffset(i.start),u=s.getLineStart(o),a;i.start!==i.end||r===1?a=s.getLineAtOffset(i.end>i.start?i.end-1:i.end):a=Math.min(o+r-1,s.getLineCount()-1);var f=s.getLineEnd(a,!0);return t.setText("",u,f),!0},expandAnnotation:function(e){var t=this.editor,r=t.getAnnotationModel();if(!r)return!0;var i=t.getModel(),s=t.getCaretOffset(),o=i.getLineAtOffset(s),u=i.getLineStart(o),a=i.getLineEnd(o,!0);i.getBaseModel&&(u=i.mapOffset(u),a=i.mapOffset(a),i=i.getBaseModel());var f,l=r.getAnnotations(u,a);while(!f&&l.hasNext()){var c=l.next();if(c.type!==n.AnnotationType.ANNOTATION_FOLDING)continue;f=c}return f&&e!==f.expanded&&(e?f.expand():(t.setCaretOffset(f.start),f.collapse()),r.modifyAnnotation(f)),!0},expandAnnotations:function(e){var t=this.editor,r=t.getTextView(),i=t.getAnnotationModel();if(!i)return!0;var s=t.getModel(),o,u=i.getAnnotations(0,s.getCharCount());r.setRedraw(!1);while(u.hasNext()){o=u.next();if(o.type!==n.AnnotationType.ANNOTATION_FOLDING)continue;e!==o.expanded&&(e?o.expand():o.collapse(),i.modifyAnnotation(o))}return r.setRedraw(!0),!0},indentLines:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;if(!t.getOptions("tabMode"))return;var n=e.getModel(),r=e.getSelection(),i=n.getLineAtOffset(r.start),s=n.getLineAtOffset(r.end>r.start?r.end-1:r.end);if(i!==s){var o=[];o.push("");for(var u=i;u<=s;u++)o.push(n.getLine(u,!0));var a=n.getLineStart(i),f=n.getLineEnd(s,!0),l=t.getOptions("tabSize","expandTab"),c=l.expandTab?(new Array(l.tabSize+1)).join(" "):" ";return e.setText(o.join(c),a,f),e.setSelection(a===r.start?r.start:r.start+c.length,r.end+(s-i+1)*c.length),!0}return!1},gotoLastEdit:function(){return typeof this._lastEditLocation=="number"&&this.editor.showSelection(this._lastEditLocation),!0},gotoLine:function(){var t=this.editor,n=t.getModel(),r=n.getLineAtOffset(t.getCaretOffset());return r=prompt(e.gotoLinePrompty,r+1),r&&(r=parseInt(r,10),t.onGotoLine(r-1,0)),!0},moveLinesDown:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel(),r=e.getSelection(),i=n.getLineAtOffset(r.start),s=n.getLineAtOffset(r.end>r.start?r.end-1:r.end),o=n.getLineCount();if(s===o-1)return!0;var u=n.getLineStart(i),a=n.getLineEnd(s,!0),f=n.getLineEnd(s+1,!0)-(a-u),l,c=0;if(s!==o-2)l=n.getText(u,a);else{var h=n.getLineEnd(s);l=n.getText(h,a)+n.getText(u,h),c+=a-h}return this.startUndo(),e.setText("",u,a),e.setText(l,f,f),e.setSelection(f+c,f+c+l.length),this.endUndo(),!0},moveLinesUp:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel(),r=e.getSelection(),i=n.getLineAtOffset(r.start);if(i===0)return!0;var s=n.getLineAtOffset(r.end>r.start?r.end-1:r.end),o=n.getLineCount(),u=n.getLineStart(i-1),a=n.getLineStart(i),f=n.getLineEnd(s,!0),l=n.getText(a,f),c=0;if(s===o-1){var h=n.getLineEnd(i-1),p=n.getLineEnd(i-1,!0);l+=n.getText(h,p),a=h,c=p-h}return this.startUndo(),e.setText("",a,f),e.setText(l,u,u),e.setSelection(u,u+l.length-c),this.endUndo(),!0},nextAnnotation:function(e){var t=this.editor,n=t.getAnnotationModel();if(!n)return!0;var i=t.getOverviewRuler()||t.getAnnotationStyler();if(!i)return!0;var s=t.getModel(),u=t.getCaretOffset(),a=n.getAnnotations(e?u:0,e?s.getCharCount():u),f=null;while(a.hasNext()){var l=a.next();if(e){if(l.start<=u)continue}else if(l.start>=u)continue;if(l.lineStyle||l.type===o.ANNOTATION_MATCHING_BRACKET||l.type===o.ANNOTATION_CURRENT_BRACKET||!i.isAnnotationTypeVisible(l.type))continue;f=l;if(e)break}if(f){var c=t.getTextView(),h=s.getLineAtOffset(f.start),p=r.Tooltip.getTooltip(c);if(!p)return t.moveSelection(f.start),!0;t.moveSelection(f.start,f.start,function(){p.setTarget({getTooltipInfo:function(){var e=c.convert({x:c.getLocationAtOffset(f.start).x,y:c.getLocationAtOffset(s.getLineStart(h)).y},"document","page");return{contents:[f],x:e.x,y:e.y+Math.floor(c.getLineHeight(h)*1.33)}}},0)})}return!0},unindentLines:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;if(!t.getOptions("tabMode"))return;var n=e.getModel(),r=e.getSelection(),i=n.getLineAtOffset(r.start),s=n.getLineAtOffset(r.end>r.start?r.end-1:r.end),o=t.getOptions("tabSize"),u=(new Array(o+1)).join(" "),a=[],f=0,l=0;for(var c=i;c<=s;c++){var h=n.getLine(c,!0);if(n.getLineStart(c)!==n.getLineEnd(c))if(h.indexOf(" ")===0)h=h.substring(1),f++;else{if(h.indexOf(u)!==0)return!0;h=h.substring(o),f+=o}c===i&&(l=f),a.push(h)}var p=n.getLineStart(i),d=n.getLineEnd(s,!0),v=n.getLineStart(s);e.setText(a.join(""),p,d);var m=p===r.start?r.start:r.start-l,g=Math.max(m,r.end-f+(r.end===v+1&&r.start!==r.end?1:0));return e.setSelection(m,g),!0},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()}},u.TextActions=a,f.prototype={init:function(){var n=this.editor.getTextView();n.setAction("lineStart",function(){return this.lineStart()}.bind(this)),n.setAction("enter",function(){return this.autoIndent()}.bind(this)),n.setKeyBinding(new t.KeyBinding("t",!0,!1,!0),"trimTrailingWhitespaces"),n.setAction("trimTrailingWhitespaces",function(){return this.trimTrailingWhitespaces()}.bind(this),{name:e.trimTrailingWhitespaces}),n.setKeyBinding(new t.KeyBinding(191,!0),"toggleLineComment"),n.setAction("toggleLineComment",function(){return this.toggleLineComment()}.bind(this),{name:e.toggleLineComment}),n.setKeyBinding(new t.KeyBinding(191,!0,!s.isMac,!1,s.isMac),"addBlockComment"),n.setAction("addBlockComment",function(){return this.addBlockComment()}.bind(this),{name:e.addBlockComment}),n.setKeyBinding(new t.KeyBinding(220,!0,!s.isMac,!1,s.isMac),"removeBlockComment"),n.setAction("removeBlockComment",function(){return this.removeBlockComment()}.bind(this),{name:e.removeBlockComment}),n.setKeyBinding(new t.KeyBinding("[",!1,!1,!1,!1,"keypress"),"autoPairSquareBracket"),n.setAction("autoPairSquareBracket",function(){return this.autoPairBrackets("[","]")}.bind(this)),n.setKeyBinding(new t.KeyBinding("]",!1,!1,!1,!1,"keypress"),"skipClosingSquareBracket"),n.setAction("skipClosingSquareBracket",function(){return this.skipClosingBracket("]")}.bind(this)),n.setKeyBinding(new t.KeyBinding("<",!1,!1,!1,!1,"keypress"),"autoPairAngleBracket"),n.setAction("autoPairAngleBracket",function(){return this.autoPairBrackets("<",">")}.bind(this)),n.setKeyBinding(new t.KeyBinding(">",!1,!1,!1,!1,"keypress"),"skipClosingAngleBracket"),n.setAction("skipClosingAngleBracket",function(){return this.skipClosingBracket(">")}.bind(this)),n.setKeyBinding(new t.KeyBinding("(",!1,!1,!1,!1,"keypress"),"autoPairParentheses"),n.setAction("autoPairParentheses",function(){return this.autoPairBrackets("(",")")}.bind(this)),n.setKeyBinding(new t.KeyBinding(")",!1,!1,!1,!1,"keypress"),"skipClosingParenthesis"),n.setAction("skipClosingParenthesis",function(){return this.skipClosingBracket(")")}.bind(this)),n.setKeyBinding(new t.KeyBinding("{",!1,!1,!1,!1,"keypress"),"autoPairBraces"),n.setAction("autoPairBraces",function(){return this.autoPairBrackets("{","}")}.bind(this)),n.setKeyBinding(new t.KeyBinding("}",!1,!1,!1,!1,"keypress"),"skipClosingBrace"),n.setAction("skipClosingBrace",function(){return this.skipClosingBracket("}")}.bind(this)),n.setKeyBinding(new t.KeyBinding("'",!1,!1,!1,!1,"keypress"),"autoPairSingleQuotation"),n.setAction("autoPairSingleQuotation",function(){return this.autoPairQuotations("'")}.bind(this)),n.setKeyBinding(new t.KeyBinding('"',!1,!1,!1,!1,"keypress"),"autoPairDblQuotation"),n.setAction("autoPairDblQuotation",function(){return this.autoPairQuotations('"')}.bind(this)),n.setAction("deletePrevious",function(){return this.deletePrevious()}.bind(this))},autoIndent:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getSelection();if(n.start===n.end){var r=e.getModel(),i=r.getLineAtOffset(n.start),s=r.getLine(i,!1),o=r.getLineStart(i),u=0,a=n.start-o,f;while(u<a&&((f=s.charCodeAt(u))===32||f===9))u++;var l=s.substring(0,u),c=t.getOptions("tabSize","expandTab"),h=c.expandTab?(new Array(c.tabSize+1)).join(" "):" ",p=r.getLineDelimiter(),d=/^[\s]*\/\*[\*]*[\s]*$/,v=/^[\s]*\*/,m=/\*\/[\s]*$/,g=s.substring(0,a),y=s.substring(a),b,w;if(this.smartIndentation&&s.charCodeAt(w=g.trimRight().length-1)===123){var E=a-w-1,S=y.length-y.trimLeft().length;return b=s.charCodeAt(a+S)===125?p+l+h+p+l:p+l+h,e.setText(b,n.start-E,n.end+S),e.setCaretOffset(n.start+p.length+l.length+h.length-E),!0}if(this.autoCompleteComments&&!m.test(g)&&(d.test(g)||v.test(g))){var x,T=d.exec(g);if(T){b=p+l+" * ",m.test(y)?b+=y.substring(0,y.length-2).trim():b+=y.trim();if(r.getLineCount()===i+1||!v.test(r.getLine(i+1)))b+=p+l+" */";return e.setText(b,n.start,n.end+y.length),e.setCaretOffset(n.start+p.length+l.length+3),!0}T=v.exec(g);if(T)for(var N=i-1;N>=0;N--){var C=r.getLine(N,!1);if(d.test(C))return m.test(y)||s.charCodeAt(a)===47?(b=p+l+"*"+y,x=n.start+p.length+l.length+1):(b=p+l+"* "+y,x=n.start+p.length+l.length+2),e.setText(b,n.start,n.end+y.length),e.setCaretOffset(x),!0;if(!v.test(C))return!1}return!1}if(m.test(g))return b=s.substring(n.start)+p+l.substring(0,l.length-1),e.setText(b,n.start,n.end),e.setCaretOffset(n.start+b.length),!0;if(u>0){u=a;while(u<s.length&&((f=s.charCodeAt(u++))===32||f===9))n.end++;return e.setText(r.getLineDelimiter()+l,n.start,n.end),!0}}return!1},addBlockComment:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel(),r=e.getSelection(),i="/*",s="*/",o=new RegExp("/\\*|\\*/","g"),u=this._findEnclosingComment(n,r.start,r.end);if(u.commentStart!==undefined&&u.commentEnd!==undefined)return!0;var a=n.getText(r.start,r.end);if(a.length===0)return!0;var f=a.length;a=a.replace(o,"");var l=a.length;return e.setText(i+a+s,r.start,r.end),e.setSelection(r.start+i.length,r.end+i.length+(l-f)),!0},autoPairBrackets:function(e,t){if(e==="["&&!this.autoPairSquareBrackets)return!1;if(e==="{"&&!this.autoPairBraces)return!1;if(e==="("&&!this.autoPairParentheses)return!1;if(e==="<"&&!this.autoPairAngleBrackets)return!1;var n=this.editor,r=n.getTextView();if(r.getOptions("readonly"))return!1;var i=n.getSelection(),s=n.getModel(),o=n.getCaretOffset(),u=o===s.getCharCount()?"":s.getText(i.start,i.start+1).trim(),a=new RegExp("^$|[)}\\]>]");if(i.start===i.end&&a.test(u))return n.setText(e+t,i.start,i.start),n.setCaretOffset(i.start+1),!0;if(i.start!==i.end){var f=s.getText(i.start,i.end);return n.setText(e+f+t,i.start,i.end),n.setSelection(i.start+1,i.end+1),!0}return!1},autoPairQuotations:function(e){if(!this.autoPairQuotation)return!1;var t=this.editor,n=t.getTextView();if(n.getOptions("readonly"))return!1;var r=t.getSelection(),i=t.getModel(),s=t.getCaretOffset(),o=s===0?"":i.getText(r.start-1,r.start).trim(),u=s===i.getCharCount()?"":i.getText(r.start,r.start+1).trim(),a=new RegExp("^\"$|^'$"),f=new RegExp("\\w"),l=new RegExp("^$|[)}\\]>]");if(r.start!==r.end){var c=i.getText(r.start,r.end);if(a.test(c))return!1;t.setText(e+c+e,r.start,r.end),t.setSelection(r.start+1,r.end+1)}else if(u===e)t.setCaretOffset(r.start+1);else{if(o===e||a.test(u)||f.test(o)||!l.test(u))return!1;t.setText(e+e,r.start,r.start),t.setCaretOffset(r.start+1)}return!0},contentAssistProposalApplied:function(e){var t=e.data.proposal;if(t.positions&&t.positions.length>0&&this.linkedMode){var n=[];for(var r=0;r<t.positions.length;++r)n[r]={positions:[{offset:t.positions[r].offset,length:t.positions[r].length}]};this.linkedMode.enterLinkedMode({groups:n,escapePosition:t.escapePosition})}else if(t.groups&&t.groups.length>0&&this.linkedMode)this.linkedMode.enterLinkedMode({groups:t.groups,escapePosition:t.escapePosition});else if(t.escapePosition){var i=this.editor.getTextView();i.setCaretOffset(t.escapePosition)}return!0},deletePrevious:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getSelection(),r=e.getModel(),i=e.getCaretOffset(),s=i===0?"":r.getText(n.start-1,n.start),o=i===r.getCharCount()?"":r.getText(n.start,n.start+1);return(s==="("&&o===")"||s==="["&&o==="]"||s==="{"&&o==="}"||s==="<"&&o===">"||s==='"'&&o==='"'||s==="'"&&o==="'")&&e.setText("",n.start,n.start+1),!1},_findEnclosingComment:function(e,t,n){var r="/*",i="*/",s=e.getLineAtOffset(t),o=e.getLineAtOffset(n),u,a,f,l,c,h,p;for(u=s;u>=0;u--){a=e.getLine(u),f=u===s?t-e.getLineStart(s):a.length,l=a.lastIndexOf(r,f),c=a.lastIndexOf(i,f);if(c>l)break;if(l!==-1){h=e.getLineStart(u)+l;break}}for(u=o;u<e.getLineCount();u++){a=e.getLine(u),f=u===o?n-e.getLineStart(o):0,l=a.indexOf(r,f),c=a.indexOf(i,f);if(l!==-1&&l<c)break;if(c!==-1){p=e.getLineStart(u)+c;break}}return{commentStart:h,commentEnd:p}},lineStart:function(){var e=this.editor,t=e.getModel(),n=e.getCaretOffset(),r=t.getLineAtOffset(n),i=t.getLineStart(r),s=t.getLine(r),o;for(o=0;o<s.length;o++){var u=s.charCodeAt(o);if(u!==32&&u!==9)break}return o+=i,n!==o?(e.setSelection(o,o),!0):!1},removeBlockComment:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel(),r=e.getSelection(),i="/*",s="*/",o=n.getText(r.start,r.end),u,a,f;for(f=0;f<o.length;f++)if(o.substring(f,f+i.length)===i){u=r.start+f;break}for(;f<o.length;f++)if(o.substring(f,f+s.length)===s){a=r.start+f;break}if(u!==undefined&&a!==undefined)e.setText(n.getText(u+i.length,a),u,a+s.length),e.setSelection(u,a);else{var l=this._findEnclosingComment(n,r.start,r.end);if(l.commentStart===undefined||l.commentEnd===undefined)return!0;var c=n.getText(l.commentStart+i.length,l.commentEnd);e.setText(c,l.commentStart,l.commentEnd+s.length),e.setSelection(r.start-i.length,r.end-s.length)}return!0},toggleLineComment:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel(),r=e.getSelection(),i=n.getLineAtOffset(r.start),s=n.getLineAtOffset(r.end>r.start?r.end-1:r.end),o=!0,u=[],a,f;for(var l=i;l<=s;l++){a=n.getLine(l,!0),u.push(a);if(!o||(f=a.indexOf("//"))===-1)o=!1;else if(f!==0){var c;for(c=0;c<f;c++){var h=a.charCodeAt(c);if(h!==32&&h!==9)break}o=c===f}}var p,d,v,m=n.getLineStart(i),g=n.getLineEnd(s,!0);if(o){for(var y=0;y<u.length;y++)a=u[y],f=a.indexOf("//"),u[y]=a.substring(0,f)+a.substring(f+2);p=u.join("");var b=n.getLineStart(s);d=m===r.start?r.start:r.start-2,v=r.end-2*(s-i+1)+(r.end===b+1?2:0)}else u.splice(0,0,""),p=u.join("//"),d=m===r.start?r.start:r.start+2,v=r.end+2*(s-i+1);return e.setText(p,m,g),e.setSelection(d,v),!0},trimTrailingWhitespaces:function(){var e=this.editor,t=e.getModel(),n=e.getSelection();e.getTextView().setRedraw(!1),e.getUndoStack().startCompoundChange();var r=/(\s+$)/,i=t.getLineCount();for(var s=0;s<i;s++){var o=t.getLine(s),u=r.exec(o);if(u){var a=t.getLineStart(s),f=u[0].length,l=a+u.index;t.setText("",l,l+f),n.start>l&&(n.start=Math.max(l,n.start-f)),n.start!==n.end&&n.end>l&&(n.end=Math.max(l,n.end-f))}}e.getUndoStack().endCompoundChange(),e.getTextView().setRedraw(!0),e.setSelection(n.start,n.end,!1)},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},skipClosingBracket:function(e){var t=this.editor,n=t.getTextView();if(n.getOptions("readonly"))return!1;var r=t.getSelection(),i=t.getModel(),s=t.getCaretOffset(),o=s===i.getCharCount()?"":i.getText(r.start,r.start+1);return o===e?(t.setCaretOffset(r.start+1),!0):!1},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},setAutoPairParentheses:function(e){this.autoPairParentheses=e},setAutoPairBraces:function(e){this.autoPairBraces=e},setAutoPairSquareBrackets:function(e){this.autoPairSquareBrackets=e},setAutoPairAngleBrackets:function(e){this.autoPairAngleBrackets=e},setAutoPairQuotations:function(e){this.autoPairQuotation=e},setAutoCompleteComments:function(e){this.autoCompleteComments=e},setSmartIndentation:function(e){this.smartIndentation=e}},u.SourceCodeActions=f,String.prototype.trimLeft||(String.prototype.trimLeft=function(){return this.replace(/^\s+/g,"")}),String.prototype.trimRight||(String.prototype.trimRight=function(){return this.replace(/\s+$/g,"")}),u}),define("orion/editor/undoStack",[],function(){function e(e,t,n,r){this.offset=e,this.text=t,this.previousText=n,this.type=r}function t(e){this.owner=e,this.changes=[]}function n(e,t){this.view=e,this.size=t!==undefined?t:100,this.reset();var n=e.getModel();n.getBaseModel&&(n=n.getBaseModel()),this.model=n;var r=this;this._listener={onChanging:function(e){r._onChanging(e)},onDestroy:function(e){r._onDestroy(e)}},n.addEventListener("Changing",this._listener.onChanging),e.addEventListener("Destroy",this._listener.onDestroy)}return e.prototype={getRedoChanges:function(){return[{start:this.offset,end:this.offset+this.previousText.length,text:this.text}]},getUndoChanges:function(){return[{start:this.offset,end:this.offset+this.text.length,text:this.previousText}]},undo:function(e,t){return this._doUndoRedo(this.offset,this.previousText,this.text,e,t),!0},redo:function(e,t){return this._doUndoRedo(this.offset,this.text,this.previousText,e,t),!0},merge:function(e,t,n,r,i){if(r===this.type){if(r===1&&e===this.offset+this.text.length)return this.text+=t,!0;if(r===-1&&i===this.offset)return this.offset=e,this.previousText=n+this.previousText,!0;if(r===-1&&e===this.offset)return this.previousText=this.previousText+n,!0}return!1},_doUndoRedo:function(e,t,n,r,i){var s=r.getModel();if(s.mapOffset&&r.annotationModel){var o=s.mapOffset(e,!0);if(o<0){var u=r.annotationModel,a=u.getAnnotations(e,e+1);while(a.hasNext()){var f=a.next();if(f.type==="orion.annotation.folding"){f.expand(),o=s.mapOffset(e,!0);break}}}if(o<0)return;e=o}s.setText(t,e,e+n.length),i&&r.setSelection(e,e+t.length)}},t.prototype={getRedoChanges:function(){var e=[];for(var t=0;t<this.changes.length;t++)e=e.concat(this.changes[t].getRedoChanges());return e},getUndoChanges:function(){var e=[];for(var t=this.changes.length-1;t>=0;t--)e=e.concat(this.changes[t].getUndoChanges());return e},add:function(e){this.changes.push(e)},end:function(e){this.endSelection=e.getSelection(),this.endCaret=e.getCaretOffset();var t=this.owner;t&&t.end&&t.end()},undo:function(e,t){this.changes.length>1&&e.setRedraw(!1);for(var n=this.changes.length-1;n>=0;n--)this.changes[n].undo(e,!1);this.changes.length>1&&e.setRedraw(!0);if(t){var r=this.startSelection.start,i=this.startSelection.end;e.setSelection(this.startCaret?r:i,this.startCaret?i:r)}var s=this.owner;return s&&s.undo&&s.undo(),this.changes.length>0},redo:function(e,t){this.changes.length>1&&e.setRedraw(!1);for(var n=0;n<this.changes.length;n++)this.changes[n].redo(e,!1);this.changes.length>1&&e.setRedraw(!0);if(t){var r=this.endSelection.start,i=this.endSelection.end;e.setSelection(this.endCaret?r:i,this.endCaret?i:r)}var s=this.owner;return s&&s.redo&&s.redo(),this.changes.length>0},merge:function(e,t,n,r,i){var s=this.changes.length;return s>0?this.changes[s-1].merge(e,t,n,r,i):!1},start:function(e){this.startSelection=e.getSelection(),this.startCaret=e.getCaretOffset();var t=this.owner;t&&t.start&&t.start()}},n.prototype={add:function(e){if(this.compoundChange)this.compoundChange.add(e);else{var t=this.stack.length;this.stack.splice(this.index,t-this.index,e),this.index++,this.stack.length>this.size&&(this.stack.shift(),this.index--)}},markClean:function(){this._commitUndo(),this.cleanChange=this.stack[this.index-1],this.cleanChange&&(this.cleanChange.type=2)},isClean:function(){return this.cleanChange===this.stack[this.index-1]},canUndo:function(){return this.index>0},canRedo:function(){return this.stack.length-this.index>0},endCompoundChange:function(){this.compoundChange&&this.compoundChange.end(this.view),this.compoundChange=undefined},getSize:function(){return{undo:this.index,redo:this.stack.length-this.index}},getRedoChanges:function(){this._commitUndo();var e=[];for(var t=this.index;t<this.stack.length;t++)e=e.concat(this.stack[t].getRedoChanges());return e},getUndoChanges:function(){this._commitUndo();var e=[];for(var t=this.index;t>=0;t--)e=e.concat(this.stack[t].getUndoChanges());return e},undo:function(){this._commitUndo();var e,t=!1;this._ignoreUndo=!0;do{if(this.index<=0)break;e=this.stack[--this.index]}while(!(t=e.undo(this.view,!0)));return this._ignoreUndo=!1,t},redo:function(){this._commitUndo();var e,t=!1;this._ignoreUndo=!0;do{if(this.index>=this.stack.length)break;e=this.stack[this.index++]}while(!(t=e.redo(this.view,!0)));return this._ignoreUndo=!1,!0},reset:function(){this.index=0,this.cleanChange=undefined,this.stack=[],this._ignoreUndo=!1,this._compoundChange=undefined},startCompoundChange:function(e){this._commitUndo();var n=new t(e);return this.add(n),this.compoundChange=n,this.compoundChange.start(this.view),this.compoundChange},_commitUndo:function(){this.endCompoundChange()},_onDestroy:function(e){this.model.removeEventListener("Changing",this._listener.onChanging),this.view.removeEventListener("Destroy",this._listener.onDestroy)},_onChanging:function(t){if(this._ignoreUndo)return;var n=t.text,r=t.start,i=t.addedCharCount,s=t.removedCharCount,o=r+s,u=0;i===0&&s===1?u=-1:i===1&&s===0&&(u=1);var a=this.stack.length,f=this.model.getText(r,o);if(a>0&&this.index===a){var l=this.stack[a-1];if(l.merge(r,n,f,u,o))return}this.add(new e(r,n,f,u))}},{UndoStack:n}}),define("orion/editor/rulers",["i18n!orion/editor/nls/messages","orion/editor/annotations","orion/editor/tooltip","orion/util"],function(e,t,n,r){function i(e,t,n,r){this._location=t||"left",this._overview=n||"page",this._rulerStyle=r,this._view=null;var i=this;this._listener={onTextModelChanged:function(e){i._onTextModelChanged(e)},onAnnotationModelChanged:function(e){i._onAnnotationModelChanged(e)}},this.setAnnotationModel(e)}function s(e,t,n,r,s){i.call(this,e,t,"page",n),this._oddStyle=r||{style:{backgroundColor:"white"}},this._evenStyle=s||{style:{backgroundColor:"white"}},this._numOfDigits=0,this._firstLine=1}function o(e,t,n){i.call(this,e,t,"page",n)}function u(e,t,n){i.call(this,e,t,"document",n)}function a(e,t,n){o.call(this,e,t,n)}return i.prototype={getAnnotations:function(e,t){var n=this._annotationModel;if(!n)return[];var r=this._view.getModel(),i=r.getLineStart(e),s=r.getLineEnd(t-1),o=r;r.getBaseModel&&(o=r.getBaseModel(),i=r.mapOffset(i),s=r.mapOffset(s));var u=[],a=this.getAnnotationsByType(n,i,s);for(var f=0;f<a.length;f++){var l=a[f],c=o.getLineAtOffset(l.start),h=o.getLineAtOffset(Math.max(l.start,l.end-1));for(var p=c;p<=h;p++){var d=p;if(r!==o){var v=o.getLineStart(p);v=r.mapOffset(v,!0);if(v===-1)continue;d=r.getLineAtOffset(v)}if(!(e<=d&&d<t))continue;var m=this._mergeAnnotation(u[d],l,p-c,h-c+1);m&&(u[d]=m)}}if(!this._multiAnnotation&&this._multiAnnotationOverlay)for(var g in u)u[g]._multiple&&(u[g].html=u[g].html+this._multiAnnotationOverlay.html);return u},getAnnotationModel:function(){return this._annotationModel},getLocation:function(){return this._location},getOverview:function(){return this._overview},getRulerStyle:function(){return this._rulerStyle},getView:function(){return this._view},getWidestAnnotation:function(){return null},setAnnotationModel:function(e){this._annotationModel&&this._annotationModel.removEventListener("Changed",this._listener.onAnnotationModelChanged),this._annotationModel=e,this._annotationModel&&this._annotationModel.addEventListener("Changed",this._listener.onAnnotationModelChanged)},setMultiAnnotation:function(e){this._multiAnnotation=e},setMultiAnnotationOverlay:function(e){this._multiAnnotationOverlay=e},setView:function(e){this._onTextModelChanged&&this._view&&this._view.removeEventListener("ModelChanged",this._listener.onTextModelChanged),this._view=e,this._onTextModelChanged&&this._view&&this._view.addEventListener("ModelChanged",this._listener.onTextModelChanged)},onClick:function(e,t){if(e===undefined)return;var r=this._view,i=r.getModel(),s=i,o=i.getLineStart(e),u=o,a=o,f=this._annotationModel;if(f){var l=r.getSelection();a=i.getLineEnd(e,!0),o<=l.start&&l.start<a&&(o=l.start),i.getBaseModel&&(o=i.mapOffset(o),a=i.mapOffset(a),s=i.getBaseModel());var c,h=f.getAnnotations(o,a),p=null;while(!c&&h.hasNext()){var d=h.next();if(!this.isAnnotationTypeVisible(d.type))continue;p=d;if(d.start<=o)continue;c=d}p&&p.groupId!==undefined&&(this._currentClickGroup===p.groupId?this._currentClickGroup=null:this._currentClickGroup=p.groupId,this._setCurrentGroup(e)),c&&s.getLineAtOffset(c.start)===s.getLineAtOffset(o)?(o=c.start,a=c.end):a=o=u,i.getBaseModel&&(o=i.mapOffset(o,!0),a=i.mapOffset(a,!0))}var v=n.Tooltip.getTooltip(this._view);v&&v.setTarget(null),this._view.setSelection(a,o,1/3,function(){})},onDblClick:function(e,t){},onMouseMove:function(e,t){var r=n.Tooltip.getTooltip(this._view);if(!r)return;if(r.isVisible()&&this._tooltipLineIndex===e)return;this._tooltipLineIndex=e;var i=this;r.setTarget({y:t.clientY,getTooltipInfo:function(){return i._getTooltipInfo(i._tooltipLineIndex,this.y)}})},onMouseOver:function(e,t){this.onMouseMove(e,t),this._currentClickGroup||this._setCurrentGroup(e)},onMouseOut:function(e,t){this._currentClickGroup||this._setCurrentGroup(-1);var r=n.Tooltip.getTooltip(this._view);if(!r)return;r.setTarget(null)},_getTooltipInfo:function(e,t){if(e===undefined)return;var n=this._view,r=n.getModel(),i=this._annotationModel,s=[];if(i){var o=r.getLineStart(e),u=r.getLineEnd(e);r.getBaseModel&&(o=r.mapOffset(o),u=r.mapOffset(u)),s=this.getAnnotationsByType(i,o,u)}var a=this._getTooltipContents(e,s);if(!a)return null;var f={contents:a,anchor:this.getLocation()},l=n.getClientArea();return this.getOverview()==="document"?l.y=n.convert({y:t},"view","document").y:l.y=n.getLocationAtOffset(r.getLineStart(e)).y,n.convert(l,"document","page"),f.x=l.x,f.y=l.y,f.anchor==="right"&&(f.x+=l.width),f},_getTooltipContents:function(e,t){return t},_onAnnotationModelChanged:function(e){function u(e){for(var i=0;i<e.length;i++){if(!r.isAnnotationTypeVisible(e[i].type))continue;var s=e[i].start,o=e[i].end;n.getBaseModel&&(s=n.mapOffset(s,!0),o=n.mapOffset(o,!0)),s!==-1&&o!==-1&&t.redrawLines(n.getLineAtOffset(s),n.getLineAtOffset(Math.max(s,o-1))+1,r)}}var t=this._view;if(!t)return;var n=t.getModel(),r=this,i=n.getLineCount();if(e.textModelChangedEvent){var s=e.textModelChangedEvent.start;n.getBaseModel&&(s=n.mapOffset(s,!0));var o=n.getLineAtOffset(s);t.redrawLines(o,i,r);return}u(e.added),u(e.removed),u(e.changed)},_mergeAnnotation:function(e,t,n,r){return e||(e={}),n===0&&(e.html&&t.html?(t.html!==e.html&&!e._multiple&&this._multiAnnotation&&(e.html=this._multiAnnotation.html),e._multiple=!0):e.html=t.html),e.style=this._mergeStyle(e.style,t.style),e},_mergeStyle:function(e,t){if(t){e||(e={}),e.styleClass&&t.styleClass&&e.styleClass!==t.styleClass?e.styleClass+=" "+t.styleClass:e.styleClass=t.styleClass;var n;if(t.style){e.style||(e.style={});for(n in t.style)e.style[n]===undefined&&(e.style[n]=t.style[n])}if(t.attributes){e.attributes||(e.attributes={});for(n in t.attributes)e.attributes[n]===undefined&&(e.attributes[n]=t.attributes[n])}}return e},_setCurrentGroup:function(e){var t=this._annotationModel,n=null,r=t.getTextModel(),i,s,o=this._currentGroupAnnotation;if(e!==-1){var u=r.getLineStart(e),a=r.getLineEnd(e);r.getBaseModel&&(u=r.mapOffset(u),a=r.mapOffset(a)),s=t.getAnnotations(u,a);while(s.hasNext()){i=s.next();if(!this.isAnnotationTypeVisible(i.type))continue;if(i.start<=u&&i.end>=a&&i.groupId!==undefined){n=i;break}}if(o&&n&&o.groupId===n.groupId)return}this._currentGroupAnnotation=null,o&&t.removeAnnotations(o.groupType);if(!n)return;if(e===-1)return;this._currentGroupAnnotation=n,s=t.getAnnotations(0,r.getCharCount());var f=[];while(s.hasNext())i=s.next(),delete i.groupAnnotation,i.groupId===n.groupId&&(i=i.createGroupAnnotation(),f.push(i));t.replaceAnnotations(null,f)}},t.AnnotationTypeList.addMixin(i.prototype),s.prototype=new i,s.prototype.getAnnotations=function(e,t){var n=i.prototype.getAnnotations.call(this,e,t),r=this._view.getModel();for(var s=e;s<t;s++){var o=s&1?this._oddStyle:this._evenStyle,u=s;if(r.getBaseModel){var a=r.getLineStart(u);u=r.getBaseModel().getLineAtOffset(r.mapOffset(a))}n[s]||(n[s]={}),n[s].html=this._firstLine+u+"",n[s].style||(n[s].style=o)}return n},s.prototype.getWidestAnnotation=function(){var e=this._view.getModel().getLineCount();return this.getAnnotations(e-1,e)[e-1]},s.prototype.setFirstLine=function(e){this._firstLine=e!==undefined?e:1},s.prototype._onTextModelChanged=function(e){var t=e.start,n=this._view.getModel(),r=n.getBaseModel?n.getBaseModel().getLineCount():n.getLineCount(),i=(this._firstLine+r-1+"").length;if(this._numOfDigits!==i){this._numOfDigits=i;var s=n.getLineAtOffset(t);this._view.redrawLines(s,n.getLineCount(),this)}},o.prototype=new i,u.prototype=new i,u.prototype.getRulerStyle=function(){var e={style:{lineHeight:"1px",fontSize:"1px"}};return e=this._mergeStyle(e,this._rulerStyle),e},u.prototype._getTooltipContents=function(t,n){if(n.length===0){var s=this._view.getModel(),o=t;if(s.getBaseModel){var u=s.getLineStart(o);o=s.getBaseModel().getLineAtOffset(s.mapOffset(u))}return r.formatMessage(e.line,o+1)}return i.prototype._getTooltipContents.call(this,t,n)},u.prototype._mergeAnnotation=function(e,t,n,r){if(n!==0)return undefined;var i=e;if(!i){var s=3*r;i={html:" ",style:{style:{height:s+"px"}}},i.style=this._mergeStyle(i.style,t.overviewStyle)}return i},a.prototype=new o,a.prototype.onClick=function(e,t){if(e===undefined)return;var r=this._annotationModel;if(!r)return;var i=this._view,s=i.getModel(),o=s.getLineStart(e),u=s.getLineEnd(e,!0);s.getBaseModel&&(o=s.mapOffset(o),u=s.mapOffset(u),s=s.getBaseModel());var a,f=r.getAnnotations(o,u);while(!a&&f.hasNext()){var l=f.next();if(!this.isAnnotationTypeVisible(l.type))continue;a=l}if(a&&s.getLineAtOffset(a.start)===s.getLineAtOffset(o)){var c=n.Tooltip.getTooltip(this._view);c&&c.setTarget(null),a.expanded?a.collapse():a.expand(),this._annotationModel.modifyAnnotation(a)}},a.prototype._getTooltipContents=function(e,t){return t.length===1&&t[0].expanded?null:o.prototype._getTooltipContents.call(this,e,t)},a.prototype._onAnnotationModelChanged=function(e){function a(e){for(i=0;i<e.length;i++){if(!r.isAnnotationTypeVisible(e[i].type))continue;var t=e[i].start;n.getBaseModel&&(t=n.mapOffset(t,!0)),t!==-1&&(u=Math.min(u,n.getLineAtOffset(t)))}}if(e.textModelChangedEvent){o.prototype._onAnnotationModelChanged.call(this,e);return}var t=this._view;if(!t)return;var n=t.getModel(),r=this,i,s=n.getLineCount(),u=s;a(e.added),a(e.removed),a(e.changed);var f=t.getRulers();for(i=0;i<f.length;i++)t.redrawLines(u,s,f[i])},{Ruler:i,AnnotationRuler:o,LineNumberRuler:s,OverviewRuler:u,FoldingRuler:a}}),define("orion/editor/textDND",["orion/util"],function(e){function t(e,t){this._view=e,this._undoStack=t,this._dragSelection=null,this._dropOffset=-1,this._dropText=null;var n=this;this._listener={onDragStart:function(e){n._onDragStart(e)},onDragEnd:function(e){n._onDragEnd(e)},onDragEnter:function(e){n._onDragEnter(e)},onDragOver:function(e){n._onDragOver(e)},onDrop:function(e){n._onDrop(e)},onDestroy:function(e){n._onDestroy(e)}},e.addEventListener("DragStart",this._listener.onDragStart),e.addEventListener("DragEnd",this._listener.onDragEnd),e.addEventListener("DragEnter",this._listener.onDragEnter),e.addEventListener("DragOver",this._listener.onDragOver),e.addEventListener("Drop",this._listener.onDrop),e.addEventListener("Destroy",this._listener.onDestroy)}return t.prototype={destroy:function(){var e=this._view;if(!e)return;e.removeEventListener("DragStart",this._listener.onDragStart),e.removeEventListener("DragEnd",this._listener.onDragEnd),e.removeEventListener("DragEnter",this._listener.onDragEnter),e.removeEventListener("DragOver",this._listener.onDragOver),e.removeEventListener("Drop",this._listener.onDrop),e.removeEventListener("Destroy",this._listener.onDestroy),this._view=null},_onDestroy:function(e){this.destroy()},_onDragStart:function(e){var t=this._view,n=t.getSelection(),r=t.getModel();r.getBaseModel&&(n.start=r.mapOffset(n.start),n.end=r.mapOffset(n.end),r=r.getBaseModel());var i=r.getText(n.start,n.end);i&&(this._dragSelection=n,e.event.dataTransfer.effectAllowed="copyMove",e.event.dataTransfer.setData("Text",i))},_onDragEnd:function(t){if(this._dragSelection){var n=this._view,r=t.event.dataTransfer.dropEffect;!e.isFirefox&&(r!=="none"||this._dropText)&&(r=t.event.dataTransfer.dropEffect=this._dropEffect),this._undoStack&&this._undoStack.startCompoundChange();var i=r==="move";i&&n.setText("",this._dragSelection.start,this._dragSelection.end);if(this._dropText){var s=this._dropText,o=this._dropOffset;i&&(o>=this._dragSelection.end?o-=this._dragSelection.end-this._dragSelection.start:o>=this._dragSelection.start&&(o=this._dragSelection.start)),n.setText(s,o,o),n.setSelection(o,o+s.length),this._dropText=null,this._dropOffset=-1}this._undoStack&&this._undoStack.endCompoundChange()}this._dragSelection=null},_onDragEnter:function(e){this._onDragOver(e)},_onDragOver:function(t){var n=t.event.dataTransfer.types,r=!this._view.getOptions("readonly");r&&n&&(r=n.contains?n.contains("text/plain")||n.contains("Text"):n.indexOf("text/plain")!==-1||n.indexOf("Text")!==-1);if(!r)t.event.dataTransfer.dropEffect="none";else if(!e.isFirefox){var i=e.isMac?t.event.altKey:t.event.ctrlKey;this._dropEffect=t.event.dataTransfer.dropEffect=i?"copy":"move"}},_onDrop:function(t){var n=this._view,r=t.event.dataTransfer.getData("Text");if(r){e.isFirefox||(t.event.dataTransfer.dropEffect=this._dropEffect);var i=n.getOffsetAtLocation(t.x,t.y);this._dragSelection?(this._dropOffset=i,this._dropText=r):(n.setText(r,i,i),n.setSelection(i,i+r.length))}}},{TextDND:t}}),define("orion/editor/templates",[],function(){function e(e,t){return t.substring(e.length)}function i(e,t,n){this.prefix=e,this.description=t,this.template=n,this._parse()}function s(e,t){this._keywords=e||[],this._templates=[],this.addTemplates(t||[])}var t="${tab}",n="${delimiter}",r="${cursor}";return i.prototype={getProposal:function(e,i,s){var o=i-e.length,u={},a,f=s.delimiter!==undefined?s.delimiter:"\n";s.indentation&&(f+=s.indentation);var l=s.tab!==undefined?s.tab:" ",c=0,h=this.variables,p=this.segments,d=[];for(var v=0;v<p.length;v++){var m=p[v],g=h[m];if(g!==undefined)switch(m){case t:m=l;break;case n:m=f;break;case r:m="",a=c;break;default:var y=u[m];y||(y=u[m]={data:g.data,positions:[]}),m=g.substitution,y.data&&y.data.values&&(m=y.data.values[0]),y.positions.push({offset:o+c,length:m.length})}d.push(m),c+=m.length}var b=[];for(var w in u)u.hasOwnProperty(w)&&b.push(u[w]);return d=d.join(""),a===undefined&&(a=d.length),{proposal:d,description:this.description,groups:b,escapePosition:o+a}},match:function(e){return this.prefix.indexOf(e)===0},_parse:function(){var e=this.template,r=[],i={},s,o=0;e=e.replace(/\n/g,n),e=e.replace(/\t/g,t),e.replace(/\$\{((?:[^\\}]+|\\.))*\}/g,function(t,n,u){var a=t.substring(2,t.length-1),f=t,l=a,c=null,h=l.indexOf(":");h!==-1&&(l=l.substring(0,h),f="${"+l+"}",c=JSON.parse(a.substring(h+1).replace("\\}","}").trim()));var p=i[f];return p||(p=i[f]={}),p.substitution=l,c&&(p.data=c),s=e.substring(o,u),s&&r.push(s),r.push(f),o=u+t.length,l}),s=e.substring(o,e.length),s&&r.push(s),this.segments=r,this.variables=i}},s.prototype={addTemplates:function(e){var t=this.getTemplates();for(var n=0;n<e.length;n++)t.push(new i(e[n].prefix,e[n].description,e[n].template))},computeProposals:function(e,t,n){var r=this.getPrefix(e,t,n),i=[];return this.isValid(r,e,t,n)?(i=i.concat(this.getTemplateProposals(r,t,n)),i=i.concat(this.getKeywordProposals(r)),i):i},getKeywords:function(){return this._keywords},getKeywordProposals:function(t){var n=[],r=this.getKeywords();if(r)for(var i=0;i<r.length;i++)r[i].indexOf(t)===0&&n.push({proposal:e(t,r[i]),description:r[i]});return n},getPrefix:function(e,t,n){return n.prefix},getTemplates:function(){return this._templates},getTemplateProposals:function(e,t,n){var r=[],i=this.getTemplates();for(var s=0;s<i.length;s++){var o=i[s];if(o.match(e)){var u=o.getProposal(e,t,n);this.removePrefix(e,u),r.push(u)}}return r},removePrefix:function(t,n){var r=n.overwrite=n.proposal.substring(0,t.length)!==t;r||(n.proposal=e(t,n.proposal))},isValid:function(e,t,n,r){return!0}},{Template:i,TemplateContentAssist:s}}),define("orion/editor/linkedMode",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/keyModes","orion/editor/annotations","orion/editor/templates","orion/objects","orion/util"],function(e,t,n,r,i,s){function u(e,t,r){var i=e.getTextView();n.KeyMode.call(this,i),this.editor=e,this.undoStack=t,this.contentAssist=r,this.linkedModeModel=null,i.setAction("linkedModeEnter",function(){return this.exitLinkedMode(!0),!0}.bind(this)),i.setAction("linkedModeCancel",function(){return this.exitLinkedMode(!1),!0}.bind(this)),i.setAction("linkedModeNextGroup",function(){var e=this.linkedModeModel;return this.selectLinkedGroup((e.selectedGroupIndex+1)%e.groups.length),!0}.bind(this)),i.setAction("linkedModePreviousGroup",function(){var e=this.linkedModeModel;return this.selectLinkedGroup(e.selectedGroupIndex>0?e.selectedGroupIndex-1:e.groups.length-1),!0}.bind(this)),this.linkedModeListener={onActivating:function(e){this._groupContentAssistProvider&&(this.contentAssist.setProviders([this._groupContentAssistProvider]),this.contentAssist.setProgress(null))}.bind(this),onModelChanged:function(e){if(this.ignoreVerify)return;var t=this.editor.mapOffset(e.start),n=this.linkedModeModel,r,i;while(n){r=this._getPositionChanged(n,t,t+e.removedCharCount),i=r.position;if(i!==undefined&&i.model===n)break;this.exitLinkedMode(!1),n=this.linkedModeModel}if(!n)return;var s=0,o=e.addedCharCount-e.removedCharCount,u=r.positions,a,f;for(var l=0;l<u.length;++l){f=u[l],a=f.position;var c=a.offset<=t&&t<=a.offset+a.length;c&&!f.ansestor?(a.offset+=s,a.length+=o,s+=o):(a.offset+=s,f.ansestor&&c&&(a.length+=o)),f.escape&&(f.model.escapePosition=a.offset)}this._updateAnnotations(u)}.bind(this),onVerify:function(e){if(this.ignoreVerify)return;var t=this.editor,n=t.mapOffset(e.start),r=this.editor.mapOffset(e.end),i=this.linkedModeModel,s,o;while(i){s=this._getPositionChanged(i,n,r),o=s.position;if(o!==undefined&&o.model===i)break;this.exitLinkedMode(!1),i=this.linkedModeModel}if(!i)return;var u=this._compoundChange;if(u){if(u.owner.model!==i||u.owner.group!==o.group)this.endUndo(),this.startUndo()}else this.startUndo();i.selectedGroupIndex=o.group;var a=0,f=e.text.length-(r-n),l=s.positions,c,h,p=n-o.position.offset,d=r-o.position.offset;for(var v=0;v<l.length;++v)h=l[v],c=h.position,h.oldOffset=c.offset,h.model===i&&h.group===o.group?(c.offset+=a,c.length+=f,a+=f):(c.offset+=a,h.ansestor&&(c.length+=o.count*f)),h.escape&&(h.model.escapePosition=c.offset);this.ignoreVerify=!0;for(v=l.length-1;v>=0;v--)h=l[v],h.model===i&&h.group===o.group&&t.setText(e.text,h.oldOffset+p,h.oldOffset+d);this.ignoreVerify=!1,e.text=null,this._updateAnnotations(l)}.bind(this)}}var o={};return u.prototype=new n.KeyMode,s.mixin(u.prototype,{createKeyBindings:function(){var e=t.KeyBinding,n=[];return n.push({actionID:"linkedModeEnter",keyBinding:new e(13)}),n.push({actionID:"linkedModeCancel",keyBinding:new e(27)}),n.push({actionID:"linkedModeNextGroup",keyBinding:new e(9)}),n.push({actionID:"linkedModePreviousGroup",keyBinding:new e(9,!1,!0)}),n},enterLinkedMode:function(t){if(!this.linkedModeModel){var n=this.editor.getTextView();n.addKeyMode(this),n.addEventListener("Verify",this.linkedModeListener.onVerify),n.addEventListener("ModelChanged",this.linkedModeListener.onModelChanged);var r=this.contentAssist;r.addEventListener("Activating",this.linkedModeListener.onActivating),this.editor.reportStatus(e.linkedModeEntered,null,!0)}this._sortedPositions=null,this.linkedModeModel&&(t.previousModel=this.linkedModeModel,t.parentGroup=this.linkedModeModel.selectedGroupIndex,this.linkedModeModel.nextModel=t),this.linkedModeModel=t,this.selectLinkedGroup(0)},exitLinkedMode:function(t){if(!this.isActive())return;this._compoundChange&&(this.endUndo(),this._compoundChange=null),this._sortedPositions=null;var n=this.linkedModeModel;this.linkedModeModel=n.previousModel,n.parentGroup=n.previousModel=undefined,this.linkedModeModel&&(this.linkedModeModel.nextModel=undefined);if(!this.linkedModeModel){var r=this.editor,i=r.getTextView();i.removeKeyMode(this),i.removeEventListener("Verify",this.linkedModeListener.onVerify),i.removeEventListener("ModelChanged",this.linkedModeListener.onModelChanged);var s=this.contentAssist;s.removeEventListener("Activating",this.linkedModeListener.onActivating),s.offset=undefined,this.editor.reportStatus(e.linkedModeExited,null,!0),t&&r.setCaretOffset(n.escapePosition,!1)}this.selectLinkedGroup(0)},startUndo:function(){if(this.undoStack){var e=this,t=this.linkedModeModel;this._compoundChange=this.undoStack.startCompoundChange({model:t,group:t.selectedGroupIndex,end:function(){e._compoundChange=null}})}},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},isActive:function(){return!!this.linkedModeModel},isStatusActive:function(){return!!this.linkedModeModel},selectLinkedGroup:function(e){var t=this.linkedModeModel;if(t){t.selectedGroupIndex=e;var n=t.groups[e],r=n.positions[0],s=this.editor;s.setSelection(r.offset,r.offset+r.length);var o=this.contentAssist;if(o){o.offset=undefined;if(n.data&&n.data.type==="link"&&n.data.values){var u=this._groupContentAssistProvider=new i.TemplateContentAssist(n.data.values);u.getPrefix=function(){var e=s.getSelection();if(e.start===e.end){var t=s.getCaretOffset();if(r.offset<=t&&t<=r.offset+r.length)return s.getText(r.offset,t)}return""},o.offset=r.offset,o.deactivate(),o.activate()}else this._groupContentAssistProvider&&(this._groupContentAssistProvider=null,o.deactivate())}}this._updateAnnotations()},_getModelPositions:function(e,t,n){var r=t.groups;for(var i=0;i<r.length;i++){var s=r[i].positions;for(var o=0;o<s.length;o++){var u=s[o];n&&(u={offset:u.offset+n,length:u.length});var a={index:o,group:i,count:s.length,model:t,position:u};e.push(a),t.nextModel&&t.nextModel.parentGroup===i&&(a.ansestor=!0,this._getModelPositions(e,t.nextModel,(n||0)+s[o].offset-s[0].offset))}}},_getSortedPositions:function(e){var t=this._sortedPositions;if(!t){t=[];while(e.previousModel)e=e.previousModel;this._getModelPositions(t,e);while(e)e.escapePosition!==undefined&&t.push({escape:!0,model:e,position:{offset:e.escapePosition,length:0}}),e=e.nextModel;t.sort(function(e,t){return e.position.offset-t.position.offset}),this._sortedPositions=t}return t},_getPositionChanged:function(e,t,n){var r,i=this._getSortedPositions(e);for(var s=i.length-1;s>=0;s--){var o=i[s].position;if(o.offset<=t&&n<=o.offset+o.length){r=i[s];break}}return{position:r,positions:i}},_updateAnnotations:function(e){var t=this.editor.getAnnotationModel();if(!t)return;var n=[],i=[],s=t.getTextModel(),o=t.getAnnotations(0,s.getCharCount()),u;while(o.hasNext()){u=o.next();switch(u.type){case r.AnnotationType.ANNOTATION_LINKED_GROUP:case r.AnnotationType.ANNOTATION_CURRENT_LINKED_GROUP:case r.AnnotationType.ANNOTATION_SELECTED_LINKED_GROUP:n.push(u)}}var a=this.linkedModeModel;if(a){e=e||this._getSortedPositions(a);for(var f=0;f<e.length;f++){var l=e[f];if(l.model!==a)continue;var c=r.AnnotationType.ANNOTATION_LINKED_GROUP;l.group===a.selectedGroupIndex&&(l.index===0?c=r.AnnotationType.ANNOTATION_SELECTED_LINKED_GROUP:c=r.AnnotationType.ANNOTATION_CURRENT_LINKED_GROUP),l=l.position,u=r.AnnotationType.createAnnotation(c,l.offset,l.offset+l.length,""),i.push(u)}}t.replaceAnnotations(n,i)}}),o.LinkedMode=u,o}),define("orion/editor/factories",["orion/editor/actions","orion/editor/undoStack","orion/editor/rulers","orion/editor/annotations","orion/editor/textDND","orion/editor/linkedMode"],function(e,t,n,r,i,s){function u(){}function a(){}function f(){}function l(){}function c(){}function h(){}var o={};return u.prototype={createKeyBindings:function(t,n,r,i){var o=new e.TextActions(t,n,i),u=new s.LinkedMode(t,n,r),a=new e.SourceCodeActions(t,n,r,u);return{textActions:o,linkedMode:u,sourceCodeActions:a}}},o.KeyBindingsFactory=u,a.prototype={createUndoStack:function(e){var n=e.getTextView();return new t.UndoStack(n,200)}},o.UndoFactory=a,f.prototype={createLineNumberRuler:function(e){return new n.LineNumberRuler(e,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"})}},o.LineNumberRulerFactory=f,l.prototype={createFoldingRuler:function(e){return new n.FoldingRuler(e,"left",{styleClass:"ruler folding"})}},o.FoldingRulerFactory=l,c.prototype={createAnnotationModel:function(e){return new r.AnnotationModel(e)},createAnnotationStyler:function(e,t){return new r.AnnotationStyler(e,t)},createAnnotationRulers:function(e){var t=new n.AnnotationRuler(e,"left",{styleClass:"ruler annotations"}),r=new n.OverviewRuler(e,"right",{styleClass:"ruler overview"});return{annotationRuler:t,overviewRuler:r}}},o.AnnotationFactory=c,h.prototype={createTextDND:function(e,t){return new i.TextDND(e.getTextView(),t)}},o.TextDNDFactory=h,o}),define("orion/editor/editorFeatures",["orion/editor/factories","orion/editor/actions","orion/editor/linkedMode","orion/objects"],function(e,t,n,r){return r.mixin({},e,t,n)}),define("orion/EventTarget",[],function(){function e(){this._namedListeners={}}return e.prototype={dispatchEvent:function(e){if(!e.type)throw new Error("unspecified type");var t=this._namedListeners[e.type];return t&&t.forEach(function(t){try{typeof t=="function"?t(e):t.handleEvent(e)}catch(n){typeof console!="undefined"&&console.log(n)}}),!e.defaultPrevented},addEventListener:function(e,t){if(typeof t=="function"||t.handleEvent)this._namedListeners[e]=this._namedListeners[e]||[],this._namedListeners[e].push(t)},removeEventListener:function(e,t){var n=this._namedListeners[e];if(n)for(var r=0;r<n.length;r++)if(n[r]===t){n.length===1?delete this._namedListeners[e]:n.splice(r,1);break}}},e.prototype.constructor=e,e.attach=function(t){var n=new e;t.dispatchEvent=n.dispatchEvent.bind(n),t.addEventListener=n.addEventListener.bind(n),t.removeEventListener=n.removeEventListener.bind(n)},e}),define("orion/webui/splitter",["require","orion/EventTarget","orion/webui/littlelib"],function(e,t,n){function i(e){t.attach(this),this._init(e)}var r=5;return i.prototype={_init:function(e){this._tracking=null,this._animationDelay=501,this.$node=n.node(e.node);if(!this.$node)throw"no dom node for splitter found";this.$sideNode=n.node(e.sidePanel);if(!this.$sideNode)throw"no dom node for side panel found";this.$mainNode=n.node(e.mainPanel);if(!this.$mainNode)throw"no dom node for main panel found";this._vertical=e.vertical,this._prefix="/orion/splitter/"+(this.$node.id||document.body.id||""),e.toggle&&(this._thumb=document.createElement("div"),this.$node.appendChild(this._thumb),this._thumb.classList.add("splitThumb"),this._thumb.classList.add(this._vertical?"splitVerticalThumbLayout":"splitThumbLayout")),this._closeByDefault=this.$node.getAttribute("data-initial-state")==="closed",typeof e.closeByDefault!="undefined"&&(this._closeByDefault=e.closeByDefault),this._initializeFromStoredSettings(),this._closed?(this._closed=!1,this._thumbDown(!0,!0)):this._adjustToSplitPosition(),this.$node.style.visibility="visible",this.$mainNode.style.display="block",this.$sideNode.style.display="block",this.$node.addEventListener("mousedown",this._mouseDown.bind(this),!1),window.addEventListener("mouseup",this._mouseUp.bind(this),!1),window.addEventListener("resize",this._resize.bind(this),!1)},isClosed:function(){return this._closed},toggleSidePanel:function(){this._thumbDown()},openSidePanel:function(){this._closed||this._thumbDown()},addResizeListener:function(e){this.addEventListener("resize",function(t){e(t.node)})},_initializeFromStoredSettings:function(){var e=localStorage.getItem(this._prefix+"/toggleState");typeof e=="string"?this._closed=e==="closed":this._closed=this._closeByDefault;var t;this._vertical?(t=localStorage.getItem(this._prefix+"/yPosition"),t?this._splitTop=parseInt(t,10):this._closeByDefault&&(this._initialSplit=this._getSplitPosition(),this._splitTop=0)):(t=localStorage.getItem(this._prefix+"/xPosition"),t?this._splitLeft=parseInt(t,10):this._closeByDefault&&(this._initialSplit=this._getSplitPosition(),this._splitLeft=0))},_getSplitPosition:function(){var e=n.bounds(this.$node),t=n.bounds(this.$node.parentNode);return this.vertical?e.top-t.top:e.left-t.left},_adjustToSplitPosition:function(e){var t=n.bounds(this.$node),r=n.bounds(this.$node.parentNode);if(this._vertical){this._splitHeight=t.height;if(e||!this._splitTop)this._splitTop=t.top,localStorage.setItem(this._prefix+"/yPosition",this._splitTop);var i=this._splitTop;this.$node.parentNode.style.position==="relative"&&(i=this._splitTop-r.top),this.$sideNode.style.height=i+"px",this.$sideNode.style.display="block",this.$node.style.top=i+"px",this._resize()}else{this._splitWidth=t.width;if(e||!this._splitLeft)this._splitLeft=t.left,localStorage.setItem(this._prefix+"/xPosition",this._splitLeft);var s=this._splitLeft;this.$node.parentNode.style.position==="relative"&&(s=this._splitLeft-r.left),this.$sideNode.style.width=s+"px",this.$sideNode.style.display="block",this.$node.style.left=s+"px",this._resize()}},_resize:function(e,t,r){e=e||0;var i=n.bounds(this.$node.parentNode),s=n.bounds(this.$node);this._vertical?(r===undefined&&(r=s.top,this.$node.parentNode.style.position==="relative"&&(r-=i.top)),r+=s.height,this.$mainNode.style.top=r+"px"):(t===undefined&&(t=s.left,this.$node.parentNode.style.position==="relative"&&(t-=i.left)),t+=s.width,this.$mainNode.style.left=t+"px");var o=this;window.setTimeout(function(){o._notifyResizeListeners(o.$mainNode),o._notifyResizeListeners(o.$sideNode)},e)},_notifyResizeListeners:function(e){this.dispatchEvent({type:"resize",node:e})},_notifyToggleListeners:function(){this.dispatchEvent({type:"toggle",closed:this._closed})},_thumbDown:function(e,t){e||this._addAnimation();var n=this._splitTop,r=this._splitLeft;this._closed?(this._closed=!1,!this._splitLeft&&!this._splitTop&&typeof this._initialSplit=="number"&&(n=r=this._initialSplit)):(this._closed=!0,n=r=0),this._vertical?(this.$sideNode.style.height=n+"px",this.$node.style.top=n+"px"):(this.$sideNode.style.width=r+"px",this.$node.style.left=r+"px"),this._resize(this._animationDelay,r,n),e||this._removeAnimation(),t||localStorage.setItem(this._prefix+"/toggleState",this._closed?"closed":null);var i=this;window.setTimeout(function(){i._notifyToggleListeners()},this._animationDelay)},_removeAnimation:function(){var e=this;window.setTimeout(function(){e.$sideNode.classList.remove(e._vertical?"sidePanelVerticalLayoutAnimation":"sidePanelLayoutAnimation"),e.$mainNode.classList.remove(e._vertical?"mainPanelVerticalLayoutAnimation":"mainPanelLayoutAnimation"),e.$node.classList.remove(e._vertical?"splitVerticalLayoutAnimation":"splitLayoutAnimation")},this._animationDelay)},_addAnimation:function(){this.$sideNode.classList.add(this._vertical?"sidePanelVerticalLayoutAnimation":"sidePanelLayoutAnimation"),this.$mainNode.classList.add(this._vertical?"mainPanelVerticalLayoutAnimation":"mainPanelLayoutAnimation"),this.$node.classList.add(this._vertical?"splitVerticalLayoutAnimation":"splitLayoutAnimation")},_mouseDown:function(e){if(e.target===this._thumb)return n.stop(e),this._thumbDown();if(this._tracking)return;this.$node.classList.add("splitTracking"),this.$mainNode.classList.add("panelTracking"),this.$sideNode.classList.add("panelTracking"),this._tracking=this._mouseMove.bind(this),window.addEventListener("mousemove",this._tracking),n.stop(e)},_mouseMove:function(e){if(this._tracking){var t=n.bounds(this.$node.parentNode);if(this._vertical){this._splitTop=e.clientY,this._splitTop<t.top+r?this._splitTop=t.top+r:this._splitTop>t.top+t.height-r&&(this._splitTop=t.top+t.height-r);var i=this._splitTop;this.$node.parentNode.style.position==="relative"&&(i=this._splitTop-t.top),this.$node.style.top=i+"px"}else{this._splitLeft=e.clientX,this._splitLeft<t.left+r?this._splitLeft=t.left+r:this._splitLeft>t.left+t.width-r&&(this._splitLeft=t.left+t.width-r);var s=this._splitLeft;this.$node.parentNode.style.position==="relative"&&(s=this._splitLeft-t.left),this.$node.style.left=s+"px"}this._adjustToSplitPosition(!0),n.stop(e)}},_mouseUp:function(e){this._tracking&&(window.removeEventListener("mousemove",this._tracking),this._tracking=null,this.$node.classList.remove("splitTracking"),this.$mainNode.classList.remove("panelTracking"),this.$sideNode.classList.remove("panelTracking"),n.stop(e))}},i.prototype.constructor=i,{Splitter:i}}),define("text!orion/compare/sideBySideTemplate.html",[],function(){return'<div id="topWidget_id" style="height:100%;width:100%;position:relative">\r\n <div class="leftPanelLayout ">\r\n <div class="titleContainer" id="left_title_id"></div>\r\n <div class="compareEditorParent" id="left_editor_id"></div>\r\n <div class="statusContainer" id="left_status_id"></div>\r\n </div>\r\n <div class="split compareSplitLayout"></div>\r\n <div class="rightPanelLayout">\r\n <div class="titleContainer" id="right_title_id"></div>\r\n <div class="compareEditorParent" id="right_editor_wrapper_id">\r\n <div class="canvasContainer">\r\n <canvas id="diff_canvas_id" class="compareCanvas" width="46" height="3000"></canvas>\r\n </div>\r\n <div class="compareEditorParentWithCanvas" id="right_editor_id"></div>\r\n </div>\r\n <div class="statusContainer" id="right_status_id"></div>\r\n </div>\r\n</div>\r\n'}),define("orion/compare/compareUIFactory",["orion/webui/littlelib","orion/webui/splitter","text!orion/compare/sideBySideTemplate.html"],function(e,t,n){var r=r||{};return r.TwoWayCompareUIFactory=function(){function r(e){this._parentDivID=e.parentDivID,this._commandSpanId=e.commandSpanId,this._showTitle=e.showTitle,this._leftTitle=e.leftTitle,this._rightTitle=e.rightTitle,this._showLineStatus=e.showLineStatus}return r.prototype={_init:function(){var t=this._parentDivID+"_";this._topWidgetDiv=e.node("topWidget_id"),this._topWidgetDiv.id=t+"topWidget_id",this._leftEditorParentDiv=e.node("left_editor_id"),this._leftEditorParentDiv.id=t+"left_editor_id",this._rightEditorParentDiv=e.node("right_editor_id"),this._rightEditorParentDiv.id=t+"right_editor_id",this._rightEditorWrapperDiv=e.node("right_editor_wrapper_id"),this._rightEditorWrapperDiv.id=t+"right_editor_wrapper_id",this._leftTitleDiv=e.node("left_title_id"),this._leftTitleDiv.id=t+"left_title_id",this._rightTitleDiv=e.node("right_title_id"),this._rightTitleDiv.id=t+"right_title_id",this._leftStatusDiv=e.node("left_status_id"),this._leftStatusDiv.id=t+"left_status_id",this._rightStatusDiv=e.node("right_status_id"),this._rightStatusDiv.id=t+"right_status_id",this._diffCanvasDiv=e.node("diff_canvas_id"),this._diffCanvasDiv.id=t+"diff_canvas_id",this._splitterId=t+"orion_splitter",this._showTitle||(this._leftEditorParentDiv.style.top="0px",this._rightEditorWrapperDiv.style.top="0px",this._leftTitleDiv.style.height="0px",this._rightTitleDiv.style.height="0px"),this._showLineStatus||(this._leftEditorParentDiv.style.marginBottom="0px",this._rightEditorWrapperDiv.style.marginBottom="0px",this._leftStatusDiv.style.height="0px",this._rightStatusDiv.style.height="0px")},_createSplitter:function(){var n=e.$(".split",this._topWidgetDiv);n.id=this._splitterId;var r=e.$(".leftPanelLayout",this._topWidgetDiv),i=e.$(".rightPanelLayout",this._topWidgetDiv);n&&r&&i&&(this._splitter=new t.Splitter({node:n,sidePanel:r,mainPanel:i}))},buildUI:function(){e.node(this._parentDivID).innerHTML=n,this._init(),this._createSplitter()},destroy:function(){},getSplitter:function(){return this._splitter},isLeftPane:function(t){var n=e.$(".leftPanelLayout",this._topWidgetDiv);return n===t},getEditorParentDiv:function(e){return e?this._leftEditorParentDiv:this._rightEditorParentDiv},getTitleDiv:function(e){return e?this._leftTitleDiv:this._rightTitleDiv},getStatusDiv:function(e){return e?this._leftStatusDiv:this._rightStatusDiv},getCommandSpanId:function(){return this._commandSpanId},getDiffCanvasDiv:function(){return this._diffCanvasDiv}},r}(),r});var JsDiff=function(){function e(e){return{newPos:e.newPos,components:e.components.slice(0)}}function t(e){var t=[];for(var n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}function n(e){var t=e;return t=t.replace(/&/g,"&"),t=t.replace(/</g,"<"),t=t.replace(/>/g,">"),t=t.replace(/"/g,"""),t}var r=function(e){this.ignoreWhitespace=e};r.prototype={diff:function(t,n){if(n==t)return[{value:n}];if(!n)return[{value:t,removed:!0}];if(!t)return[{value:n,added:!0}];n=this.tokenize(n),t=this.tokenize(t);var r=n.length,i=t.length,s=r+i,o=[{newPos:-1,components:[]}],u=this.extractCommon(o[0],n,t,0);if(o[0].newPos+1>=r&&u+1>=i)return o[0].components;for(var a=1;a<=s;a++)for(var f=-1*a;f<=a;f+=2){var l,c=o[f-1],h=o[f+1];u=(h?h.newPos:0)-f,c&&(o[f-1]=undefined);var p=c&&c.newPos+1<r,d=h&&0<=u&&u<i;if(!p&&!d){o[f]=undefined;continue}!p||d&&c.newPos<h.newPos?(l=e(h),this.pushComponent(l.components,t[u],undefined,!0)):(l=e(c),l.newPos++,this.pushComponent(l.components,n[l.newPos],!0,undefined));var u=this.extractCommon(l,n,t,f);if(l.newPos+1>=r&&u+1>=i)return l.components;o[f]=l}},pushComponent:function(e,t,n,r){var i=e[e.length-1];i&&i.added===n&&i.removed===r?e[e.length-1]={value:this.join(i.value,t),added:n,removed:r}:e.push({value:t,added:n,removed:r})},extractCommon:function(e,t,n,r){var i=t.length,s=n.length,o=e.newPos,u=o-r;while(o+1<i&&u+1<s&&this.equals(t[o+1],n[u+1]))o++,u++,this.pushComponent(e.components,t[o],undefined,undefined);return e.newPos=o,u},equals:function(e,t){var n=/\S/;return this.ignoreWhitespace&&!n.test(e)&&!n.test(t)?!0:e==t},join:function(e,t){return e+t},tokenize:function(e){return e}};var i=new r,s=new r(!1);s.tokenize=function(e){return t(e.split(/(\s+|\b)/))};var o=new r(!0);o.tokenize=function(e){return t(e.split(/([{}:;,]|\s+)/))};var u=new r;return u.tokenize=function(e){return e.split(/^/m)},{diffChars:function(e,t){return i.diff(e,t)},diffWords:function(e,t){return s.diff(e,t)},diffLines:function(e,t){return u.diff(e,t)},diffCss:function(e,t){return o.diff(e,t)},createPatch:function(e,t,n,r,i){var s=[];s.push("Index: "+e),s.push("==================================================================="),s.push("--- "+e+" "+r),s.push("+++ "+e+" "+i);var o=u.diff(t,n);o.push({value:"",lines:[]});var a=0,f=0,l=[],c=1,h=1;for(var p=0;p<o.length;p++){var d=o[p],v=d.lines||d.value.replace(/\n$/,"").split("\n");d.lines=v;if(d.added||d.removed){if(!a){var m=o[p-1];a=c,f=h,m&&(l.push.apply(l,m.lines.slice(-4).map(function(e){return" "+e})),a-=4,f-=4)}l.push.apply(l,v.map(function(e){return(d.added?"+":"-")+e})),d.added?h+=v.length:c+=v.length}else{if(a)if(v.length<=8&&p<o.length-1)l.push.apply(l,v.map(function(e){return" "+e}));else{var g=Math.min(v.length,4);s.push("@@ -"+a+","+(c-a+g)+" +"+f+","+(h-f+g)+" @@"),s.push.apply(s,l),s.push.apply(s,v.slice(0,g).map(function(e){return" "+e})),a=0,f=0,l=[]}c+=v.length,h+=v.length}}return o.length>1&&!/\n$/.test(o[o.length-2].value)&&s.push("\\ No newline at end of file\n"),s.join("\n")},convertChangesToXML:function(e){var t=[];for(var r=0;r<e.length;r++){var i=e[r];i.added?t.push("<ins>"):i.removed&&t.push("<del>"),t.push(n(i.value)),i.added?t.push("</ins>"):i.removed&&t.push("</del>")}return t.join("")}}}();typeof module!="undefined"&&(module.exports=JsDiff),typeof define=="function"&&define.amd&&define("jsdiff/diff",[],function(){return JsDiff}),define("orion/compare/jsdiffAdapter",["jsdiff/diff"],function(e){var t=t||{};return t.JSDiffAdapter=function(){function t(){}return t.prototype={_specialLine:function(e,t,n){return t.value===e&&n!==e},adapt:function(t,n,r){r||(r="\n");var i=t.split(r),s=n.split(r),o=i[i.length-1]==="",u=s[s.length-1]==="",a=e.diffLines(t,n),f=[],l=[],c=0,h=0,p=-1,d=0,v=!0,m=r;for(var g=0;g<a.length;g++){var y=a[g],b=y.lines||y.value.split(r),w=b.length,E=0;b.length>1&&b[b.length-1]===""&&w--,w>1&&!v&&b[0]===""&&(w--,E++),y.lines=b;if(!y.added&&!y.removed){if(!this._specialLine(r,y,m)){if(c||h)f.push([c,h,p]),c=0,h=0,p=-1,d+=h;f.push([w,w,0]),d+=w}}else if(y.added){p===-1&&(p=l.length+1),c+=w;for(var S=E;S<w+E;S++)l.push(y.lines[S])}else h+=w;v=!1,b.length>1&&b[b.length-1]===""&&(v=!0),y.value?m=y.value[y.value.length-1]:m=r}if(c||h)f.push([c,h,p]),d+=h;if(d<i.length&&i.length>1){var x=f[f.length-1];x[2]===0?(x[0]+=1,x[1]+=1):x[2]===-1?f.push([1,1,0]):o===u?f.push([1,1,0]):(u&&(x[0]+=1),o&&(x[1]+=1))}return{mapper:f,changContents:{array:l,index:0}}},adaptCharDiff:function(t,n,r){var i=r?e.diffWords(t,n):e.diffChars(t,n),s=[],o=0,u=0,a=0,f=0;for(var l=0;l<i.length;l++){var c=i[l];if(!c.added&&!c.removed){if(a>0||f>0)s.push([u,u+a,o,o+f]),u+=a,o+=f,a=0,f=0;u+=c.value.length,o+=c.value.length}else c.added?a+=c.value.length:f+=c.value.length}return(a>0||f>0)&&s.push([u,u+a,o,o+f]),s}},t}(),t}),define("orion/treeModelIterator",[],function(){var e={};return e.TreeModelIterator=function(){function e(e,t){this.firstLevelChildren=e,this.reset(),this._init(t)}return e.prototype={_init:function(e){if(!e)return;this.isExpanded=e.isExpanded,this.isExpandable=e.isExpandable,this.forceExpandFunc=e.forceExpandFunc,this.getChildrenFunc=e.getChildrenFunc},topLevel:function(e){return e.parent?e.parent===this.root:!0},_getChildren:function(e){return typeof this.getChildrenFunc=="function"?this.getChildrenFunc(e):e?e.children:null},_expanded:function(e){if(!e)return!0;var t=this._getChildren(e),n=t&&t.length>0;return this.isExpanded&&n&&(n=this.isExpanded(e)),n},_expandable:function(e){return e?this.isExpandable?this.isExpandable(e):!1:!0},_diveIn:function(e){if(this._expanded(e)){var t=this._getChildren(e);return this.setCursor(t[0]),this.cursor()}return null},_drillToLast:function(e){if(this._expanded(e)){var t=this._getChildren(e);return this._drillToLast(t[t.length-1])}return e},_forward:function(e){if(!this._cursor)return null;var t=this._diveIn(this._cursor);if(!t){if(e&&this._expandable(this._cursor)&&this.forceExpandFunc){var n=this;return this.forceExpandFunc(this._cursor,"first",function(e){e&&n.setCursor(e)})}t=this._findSibling(this._cursor,!0),t&&this.setCursor(t)}return t},_backward:function(e){if(!this._cursor)return null;var t=this._findSibling(this._cursor,!1);t&&t!==this._cursor.parent&&(t=this._drillToLast(t));if(e&&t&&this._expandable(t)&&this.forceExpandFunc&&t!==this._cursor.parent){var n=this;return this.forceExpandFunc(t,"last",function(e){e&&n.setCursor(e)})}return t&&this.setCursor(t),t},_findSibling:function(e,t){var n=this.topLevel(e),r=this._getChildren(e.parent),i=n?this.firstLevelChildren:r;for(var s=0;s<i.length;s++)if(i[s]===e)return s===0&&!t?n?null:e.parent:s===i.length-1&&t?n?null:this._findSibling(e.parent,t):t?i[s+1]:i[s-1];return null},_inParentChain:function(e,t){var n=e.parent;while(n){if(n===t)return!0;n=n.parent}return!1},_getTopLevelParent:function(e){if(this.topLevel(e))return e;var t=e.parent;while(t){if(this.topLevel(t))return t;t=t.parent}return null},_onCollapse:function(e){return this._expanded(e.parent)?e:this._onCollapse(e.parent)},_scan:function(e,t,n){this.setCursor(t);var r=[];r.push(t);for(;;){if(!this.iterate(e))break;r.push(this.cursor());if(n===this.cursor())return r}return r=[],null},setCursor:function(e){this._prevCursor=this._cursor,this._cursor=e},setTree:function(e){this.firstLevelChildren=e,this.firstLevelChildren.length>0&&(this.root=this.firstLevelChildren[0].parent)},scan:function(e,t){var n=this.cursor(),r=this._scan(!0,e,t);return r||(r=this._scan(!1,e,t)),this.setCursor(n),r},iterate:function(e,t){return e?this._forward(t):this._backward(t)},iterateOnTop:function(e,t){var n=this._findSibling(this._getTopLevelParent(this.cursor()),e);n?this.setCursor(n):t&&this.firstLevelChildren.length>0&&this.setCursor(e?this.firstLevelChildren[0]:this.firstLevelChildren[this.firstLevelChildren.length-1])},collapse:function(e){return this._cursor?this._inParentChain(this._cursor,e)?(this.setCursor(e),this._cursor):null:null},reset:function(){this._cursor=null,this._prevCursor=null,this.root=null,this.firstLevelChildren.length>0&&(this._cursor=this.firstLevelChildren[0],this.root=this.firstLevelChildren[0].parent)},cursorMoved:function(){return this._cursor!==this._prevCursor},cursor:function(){return this._cursor},prevCursor:function(){return this._prevCursor}},e}(),e}),define("orion/compare/diffTreeNavigator",["orion/treeModelIterator","orion/compare/compareUtils","orion/editor/annotations","orion/compare/jsdiffAdapter"],function(e,t,n,r){var i={},s={};return i.DiffTreeNavigator=function(){function i(e,t,n,r,i,s){this._root={type:"root",children:[]},this._initialized=!1,this.initAll(e,t,n,r,i,s)}s.ANNO_DIFF_ADDED_BLOCK="orion.annotation.diff.addedBlock",s.ANNO_DIFF_CURRENT_ADDED_BLOCK="orion.annotation.diff.currentAddedBlock",s.ANNO_DIFF_DELETED_BLOCK="orion.annotation.diff.deletedBlock",s.ANNO_DIFF_CURRENT_DELETED_BLOCK="orion.annotation.diff.currentDeletedBlock",s.ANNO_DIFF_BLOCK_TOPONLY="orion.annotation.diff.blockTop",s.ANNO_DIFF_CURRENT_BLOCK_TOPONLY="orion.annotation.diff.currentBlockTop",s.ANNO_DIFF_BLOCK_CONFLICT="orion.annotation.diff.blockConflict",s.ANNO_DIFF_CURRENT_BLOCK_CONFLICT="orion.annotation.diff.currentBlockConflict",s.ANNO_DIFF_ADDED_WORD="orion.annotation.diff.addedWord",s.ANNO_DIFF_CURRENT_ADDED_WORD="orion.annotation.diff.currentAddedWord",s.ANNO_DIFF_DELETED_WORD="orion.annotation.diff.deletedWord",s.ANNO_DIFF_CURRENT_DELETED_WORD="orion.annotation.diff.currentDeletedWord",s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT="orion.annotation.diff.emptyDeletedWordLeft",s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT="orion.annotation.diff.emptyDeletedWordRight",s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT="orion.annotation.diff.emptyAddedWordLeft",s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT="orion.annotation.diff.emptyAddedWordRight",n.AnnotationType.registerType(s.ANNO_DIFF_ADDED_BLOCK,{title:"",html:"",lineStyle:{styleClass:"annotationLine addedBlockDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_ADDED_BLOCK,{title:"",html:"",lineStyle:{styleClass:"annotationLine currentAddedBlockDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_DELETED_BLOCK,{title:"",html:"",lineStyle:{styleClass:"annotationLine deletedBlockDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_DELETED_BLOCK,{title:"",html:"",lineStyle:{styleClass:"annotationLine currentDeletedBlockDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_BLOCK_TOPONLY,{title:"",html:"",lineStyle:{styleClass:"annotationLine blockDiffTopOnly"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_BLOCK_TOPONLY,{title:"",html:"",lineStyle:{styleClass:"annotationLine currentBlockDiffTopOnly"}}),n.AnnotationType.registerType(s.ANNO_DIFF_BLOCK_CONFLICT,{title:"",html:"",lineStyle:{styleClass:"annotationLine blockDiffConflict"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_BLOCK_CONFLICT,{title:"",html:"",lineStyle:{styleClass:"annotationLine currentBlockDiffConflict"}}),n.AnnotationType.registerType(s.ANNO_DIFF_ADDED_WORD,{title:"word added",html:"",rangeStyle:{styleClass:"annotationRange addedWordDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_ADDED_WORD,{title:"",html:"",rangeStyle:{styleClass:"annotationRange currentAddedWordDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_DELETED_WORD,{title:"word deleted",html:"",rangeStyle:{styleClass:"annotationRange deletedWordDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_DELETED_WORD,{title:"",html:"",rangeStyle:{styleClass:"annotationRange currentDeletedWordDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT,{title:"",html:"",rangeStyle:{styleClass:"annotationRange emptyDeletedWordDiffLeft"}}),n.AnnotationType.registerType(s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT,{title:"",html:"",rangeStyle:{styleClass:"annotationRange emptyDeletedWordDiffRight"}}),n.AnnotationType.registerType(s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT,{title:"",html:"",rangeStyle:{styleClass:"annotationRange emptyAddedWordDiffLeft"}}),n.AnnotationType.registerType(s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT,{title:"",html:"",rangeStyle:{styleClass:"annotationRange emptyAddedWordDiffRight"}});var o=5e3;return i.prototype={initAll:function(e,t,n,r,i,s,o){e?this._charOrWordDiff=e:this._charOrWordDiff="word",t&&(this._initialized=!0),this.editorWrapper=[{editor:t,diffFeeder:r},{editor:n,diffFeeder:i}],this._curveRuler=o,this._overviewRuler=s,this._overviewRuler&&this._overviewRuler.setDiffNavigator(this)},initMapper:function(e){if(e)for(var t=0;t<this.editorWrapper.length;t++)this.editorWrapper[t].diffFeeder.init(this.editorWrapper[t].editor.getTextView().getModel(),e)},destroy:function(){this.initAll(this._charOrWordDiff)},renderAnnotations:function(){var t;for(t=0;t<this.editorWrapper.length;t++){this.editorWrapper[t].annoTypes=[],this.editorWrapper[t].diffFeeder.getBlockAnnoTypes(this.editorWrapper[t].annoTypes),this.editorWrapper[t].diffFeeder.getWordAnnoTypes(this.editorWrapper[t].annoTypes);for(var n=0;n<this.editorWrapper[t].annoTypes.length;n++)this.editorWrapper[t].annoTypes[n].current&&this.editorWrapper[t].editor.getAnnotationStyler().addAnnotationType(this.editorWrapper[t].annoTypes[n].current),this.editorWrapper[t].annoTypes[n].normal&&this.editorWrapper[t].editor.getAnnotationStyler().addAnnotationType(this.editorWrapper[t].annoTypes[n].normal)}this._root.children=[];var i=this.editorWrapper[0].diffFeeder.getDiffBlocks();if(!i||i.length===0){this.replaceAllAnnotations(!0,0,"block",!1,[]),this.replaceAllAnnotations(!0,1,"block",!1,[]),this.replaceAllAnnotations(!0,0,"word",!1,[]),this.replaceAllAnnotations(!0,1,"word",!1,[]),this.replaceAllAnnotations(!0,0,"block",!0,[]),this.replaceAllAnnotations(!0,1,"block",!0,[]),this.replaceAllAnnotations(!0,0,"word",!0,[]),this.replaceAllAnnotations(!0,1,"word",!0,[]);return}var s=new r.JSDiffAdapter;for(t=0;t<i.length;t++){var o=this.generatePairBlockAnnotations(this._root,t);this._root.children.push(o);var u=this.generatePairWordAnnotations(o,t,s);u&&(o.children=u)}this.replaceAllAnnotations(!1,0,"block",!0),this.replaceAllAnnotations(!1,1,"block",!0),this.replaceAllAnnotations(!1,0,"word",!0),this.replaceAllAnnotations(!1,1,"word",!0),this.iterator=new e.TreeModelIterator(this._root.children)},replaceAllAnnotations:function(e,t,n,r,i){if(!this.editorWrapper[t].annoTypes)return;for(var s=0;s<this.editorWrapper[t].annoTypes.length;s++)this.editorWrapper[t].annoTypes[s].type===n&&this.replaceDiffAnnotations(this.editorWrapper[t].editor,i?i:this.editorWrapper[t].annoTypes[s].list,r?this.editorWrapper[t].annoTypes[s].normal:this.editorWrapper[t].annoTypes[s].current,e)},getMapper:function(){return this.editorWrapper[0].diffFeeder.getMapper()},getFeeder:function(e){return e?this.editorWrapper[1].diffFeeder:this.editorWrapper[0].diffFeeder},iterateOnBlock:function(e,t){if(!this.iterator)return;this.iterator.iterateOnTop(e,t),this.updateCurrentAnnotation(!0)},iterateOnChange:function(e){if(!this.iterator)return null;var t=this.iterator.iterate(e);if(t){var n=this.iterator.cursor();n.type==="block"&&n.children&&n.children.length>0&&this.iterator.iterate(e),this.updateCurrentAnnotation(!0)}return t},gotoBlock:function(e,t){if(!this.iterator)return;if(e<0||e>=this._root.children.length||this._root.children.length===0)e=0;t!==undefined&&t>=0&&this._root.children[e].children&&t<this._root.children[e].children.length?this.iterator.setCursor(this._root.children[e].children[t]):this.iterator.setCursor(this._root.children[e]),this.updateCurrentAnnotation(!1),this._positionDiffBlock()},_hitDiffAnnotation:function(e,t,n){if(n!==this.editorWrapper[e].editor.getTextView())return;for(var r=0;r<this._root.children.length;r++){var i=this._root.children[r],s=e===0?i.oldA:i.newA;if(t>=s.start&&t<=s.end){var o=i;if(i.children&&i.children.length>0)for(var u=0;u<i.children.length;u++){var a=i.children[u],f=e===0?a.oldA:a.newA;if(t>=f.start&&t<=f.end){o=a;break}}return o}}return null},gotoChange:function(e,t){for(var n=0;n<this.editorWrapper.length;n++){var r=this._hitDiffAnnotation(n,e,t);if(r)return this.iterator.setCursor(r),this.updateCurrentAnnotation(!1,t),!0}return!1},getCurrentBlockIndex:function(){if(!this.iterator)return-1;var e=this.iterator.cursor();return e?e.type==="block"?e.index:e.parent.index:-1},getCurrentPosition:function(){if(!this.iterator)return{};var e=this.iterator.cursor();return e.type==="block"?{block:e.index+1}:{block:e.parent.index+1,change:e.index+1}},getCurrentMapperIndex:function(){var e=this.getCurrentBlockIndex();e<0&&(e=0);var t=this.getFeeder().getDiffBlocks();return!t||t.length===0?-1:(e>t.length-1&&(e=0),t[e][1])},replaceDiffAnnotations:function(e,t,n,r){if(!t||!n)return;var i=e.getAnnotationModel();if(!i)return;var s=i.getAnnotations(0,i.getTextModel().getCharCount()),o=[];while(r&&s.hasNext()){var u=s.next();u.type===n&&o.push(u)}i.replaceAnnotations(o,t)},updateCurrentAnnotation:function(e,t){this.replaceAllAnnotations(!0,0,"block",!1,[]),this.replaceAllAnnotations(!0,1,"block",!1,[]),this.replaceAllAnnotations(!0,0,"word",!1,[]),this.replaceAllAnnotations(!0,1,"word",!1,[]);if(!this.iterator)return;var r=this.iterator.cursor();if(!r)return;var i,s,o={start:r.oldA.start,end:r.oldA.end},u={start:r.newA.start,end:r.newA.end};r.type==="word"?(i=this.editorWrapper[0].diffFeeder.getCurrentWordAnnoType(o,this.editorWrapper[0].editor.getTextView().getModel()),s=this.editorWrapper[1].diffFeeder.getCurrentWordAnnoType(u,this.editorWrapper[1].editor.getTextView().getModel())):(i=this.editorWrapper[0].diffFeeder.getCurrentBlockAnnoType(r.index),s=this.editorWrapper[1].diffFeeder.getCurrentBlockAnnoType(r.index)),i&&this.replaceDiffAnnotations(this.editorWrapper[0].editor,[new(n.AnnotationType.getType(i.current))(o.start,o.end)],i,!0),s&&this.replaceDiffAnnotations(this.editorWrapper[1].editor,[new(n.AnnotationType.getType(s.current))(u.start,u.end)],s,!0),e?(this.autoSelecting=!0,this.editorWrapper[0].editor.setSelection(r.oldA.start,r.oldA.end,!0),this.editorWrapper[1].editor.setSelection(r.newA.start,r.newA.end,!0),this.autoSelecting=!1):t&&(this.autoSelecting=!0,t!==this.editorWrapper[0].editor.getTextView()&&this.editorWrapper[0].editor.setSelection(r.oldA.start,r.oldA.end,!0),t!==this.editorWrapper[1].editor.getTextView()&&this.editorWrapper[1].editor.setSelection(r.newA.start,r.newA.end,!0),this.autoSelecting=!1)},generatePairBlockAnnotations:function(e,t){var n=this.generateBlockDiffAnnotations(0,t),r=this.generateBlockDiffAnnotations(1,t);return{parent:e,index:t,type:"block",oldA:n,newA:r}},generatePairWordAnnotations:function(e,t,n){var r=this.editorWrapper[0].diffFeeder.getTextOnBlock(t),i=this.editorWrapper[1].diffFeeder.getTextOnBlock(t),s=null,u=0,a=0;if(!(r&&i&&r.text&&i.text&&r.text.length<=o&&i.text.length<=o))return null;s=n.adaptCharDiff(r.text,i.text,this._charOrWordDiff==="word"),a=i.start,u=r.start;var f=[],l=[];this.generateWordDiffAnnotations(0,f,u,s,2,3),this.generateWordDiffAnnotations(1,l,a,s,0,1);var c=[];for(var h=0;h<f.length;h++)c.push({parent:e,index:h,type:"word",oldA:f[h],newA:l[h]});return c},getAnnoModelList:function(e,t,n){for(var r=0;r<this.editorWrapper[e].annoTypes.length;r++)if(this.editorWrapper[e].annoTypes[r].type===t&&this.editorWrapper[e].annoTypes[r].normal===n)return this.editorWrapper[e].annoTypes[r].list;return null},generateBlockDiffAnnotations:function(e,t){var r=this.editorWrapper[e].diffFeeder.getCurrentBlockAnnoType(t),i=this.getAnnoModelList(e,"block",r.normal),s=this.editorWrapper[e].diffFeeder.getCharRange(t),o=n.AnnotationType.createAnnotation(r.normal,s.start,s.end);return i&&i.push(o),o},generateWordDiffAnnotations:function(e,t,r,i,s,o){if(i){var u=this.editorWrapper[e].diffFeeder.getCurrentWordAnnoType({start:-1,end:-1}),a=this.getAnnoModelList(e,"word",u.normal);for(var f=0;f<i.length;f++){var l=i[f][s]+r,c=i[f][o]+r,h=n.AnnotationType.createAnnotation(u.normal,l,c);a.push(h),t.push(h)}}},_updateOverviewRuler:function(){if(this._overviewRuler){var e=this.editorWrapper[0].editor.getTextView().getTopIndex();this.editorWrapper[0].editor.getTextView().redrawLines(e,e+1,this._overviewRuler)}},_updateCurveRuler:function(){this._curveRuler&&this._curveRuler.render()},_setTextViewPosition:function(e,t){var n=e.getLineHeight(),r=e.getClientArea(),i=Math.floor(r.height/n/3);e.setTopIndex(t-i>0?t-i:0)},_positionDiffBlock:function(){var e=this.getCurrentBlockIndex();e<0&&(e=0);var n=this.getFeeder().getDiffBlocks();if(n.length===0)return;this._setTextViewPosition(this.editorWrapper[0].editor.getTextView(),n[e][0]);if(this.editorWrapper[0].editor!==this.editorWrapper[1].editor){var r=t.lookUpLineIndex(this.getMapper(),0,n[e][1]);this._setTextViewPosition(this.editorWrapper[1].editor.getTextView(),r)}this._updateOverviewRuler(),this._updateCurveRuler()},matchPositionFromOverview:function(e){if(!this._initialized)return;var n;e<0?n=0:n=t.getAnnotationIndex(this.getFeeder().getDiffBlocks(),e),this.gotoBlock(n)},gotoDiff:function(e,t){this.gotoChange(e,t)&&(this._updateOverviewRuler(),this._updateCurveRuler())},nextDiff:function(){this.iterateOnBlock(!0,!0),this._positionDiffBlock()},prevDiff:function(){this.iterateOnBlock(!1,!0),this._positionDiffBlock()},nextChange:function(){var e=this.iterateOnChange(!0);return this._positionDiffBlock(),e},prevChange:function(){this.iterateOnChange(!1),this._positionDiffBlock()}},i}(),i.DiffBlockFeeder=function(){function e(){}return e.prototype={getWordAnnoTypes:function(e){this._mapperColumnIndex===0?e.push({type:"word",current:s.ANNO_DIFF_CURRENT_ADDED_WORD,normal:s.ANNO_DIFF_ADDED_WORD,list:[]}):e.push({type:"word",current:s.ANNO_DIFF_CURRENT_DELETED_WORD,normal:s.ANNO_DIFF_DELETED_WORD,list:[]}),e.push({type:"word",current:s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT}),e.push({type:"word",current:s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT}),e.push({type:"word",current:s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT}),e.push({type:"word",current:s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT})},getCurrentWordAnnoType:function(e,t){return e.start===e.end&&t?this._mapperColumnIndex===0?{current:this._repositionEmptyWord(e,t),normal:s.ANNO_DIFF_ADDED_WORD}:{current:this._repositionEmptyWord(e,t),normal:s.ANNO_DIFF_DELETED_WORD}:this._mapperColumnIndex===0?{current:s.ANNO_DIFF_CURRENT_ADDED_WORD,normal:s.ANNO_DIFF_ADDED_WORD}:{current:s.ANNO_DIFF_CURRENT_DELETED_WORD,normal:s.ANNO_DIFF_DELETED_WORD}},_repositionEmptyWord:function(e,t){var n=t.getLineAtOffset(e.start),r=t.getLineStart(n),i=t.getLineEnd(n);if(r!==i)return e.start===i?(e.start--,this._mapperColumnIndex===0?s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT:s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT):(e.end++,this._mapperColumnIndex===0?s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT:s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT);if(n>0){n--,r=t.getLineStart(n),i=t.getLineEnd(n);if(r!==i)return e.start=i-1,e.end=i,this._mapperColumnIndex===0?s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT:s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT}return this._mapperColumnIndex===0?s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT:s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT},getMapper:function(){return this._mapper},getDiffBlocks:function(){return this._diffBlocks},getDiffBlockH:function(e){if(!this._diffBlocks||this._diffBlocks.length===0)return-1;var t=this._diffBlocks[e][1];return t===-1?0:this._mapper[t][this._mapperColumnIndex]},getOverviewLineCount:function(){return this._textModel.getLineCount()},getLineNumber:function(e){return e},getCharRange:function(e){if(!this._diffBlocks||this._diffBlocks.length===0)return null;var t=this._diffBlocks[e][1],n=this._diffBlocks[e][0],r=n+this._mapper[t][this._mapperColumnIndex]-1,i=this._textModel.getLineStart(n);if(r<n)return{start:i,end:i};var s=this._textModel.getLineEnd(r,!0);return{start:i,end:s}},getTextOnBlock:function(e){if(!this._diffBlocks||this._diffBlocks.length===0)return null;var t=this._diffBlocks[e][1];this._mapper[t][0]===0||this._mapper[t][1]===0||this._mapper[t][2]===0;var n=this.getCharRange(e);return{start:n.start,text:this._textModel.getText(n.start,n.end)}},isMapperEmpty:function(){return this._mapper.length===0}},e}(),i.TwoWayDiffBlockFeeder=function(){function e(e,t,n){this._mapperColumnIndex=n,this.init(e,t)}return e.prototype=new i.DiffBlockFeeder,e.prototype.init=function(e,t){this._textModel=e,this._diffBlocks=undefined;if(t){this._mapper=t,this._diffBlocks=[];var n=0;for(var r=0;r<this._mapper.length;r++)this._mapper[r][2]!==0&&this._diffBlocks.push([n,r]),n+=this._mapper[r][this._mapperColumnIndex]}},e.prototype.getBlockAnnoTypes=function(e){this._mapperColumnIndex===0?e.push({type:"block",normal:s.ANNO_DIFF_ADDED_BLOCK,current:s.ANNO_DIFF_CURRENT_ADDED_BLOCK,list:[]}):e.push({type:"block",normal:s.ANNO_DIFF_DELETED_BLOCK,current:s.ANNO_DIFF_CURRENT_DELETED_BLOCK,list:[]}),e.push({type:"block",normal:s.ANNO_DIFF_BLOCK_TOPONLY,current:s.ANNO_DIFF_CURRENT_BLOCK_TOPONLY,list:[]}),e.push({type:"block",normal:s.ANNO_DIFF_BLOCK_CONFLICT,current:s.ANNO_DIFF_CURRENT_BLOCK_CONFLICT,list:[]})},e.prototype.getCurrentBlockAnnoType=function(e){if(!this._diffBlocks||this._diffBlocks.length===0||this._diffBlocks.length<=e)return null;var n=this._diffBlocks[e][1];return this._mapper[n][this._mapperColumnIndex]===0?{normal:s.ANNO_DIFF_BLOCK_TOPONLY,current:s.ANNO_DIFF_CURRENT_BLOCK_TOPONLY}:t.isMapperConflict(this.getMapper(),n)?{normal:s.ANNO_DIFF_BLOCK_CONFLICT,current:s.ANNO_DIFF_CURRENT_BLOCK_CONFLICT}:this._mapperColumnIndex===0?{type:"block",normal:s.ANNO_DIFF_ADDED_BLOCK,current:s.ANNO_DIFF_CURRENT_ADDED_BLOCK,list:[]}:{type:"block",normal:s.ANNO_DIFF_DELETED_BLOCK,current:s.ANNO_DIFF_CURRENT_DELETED_BLOCK,list:[]}},e}(),i.inlineDiffBlockFeeder=function(){function e(e,t){this._mapperColumnIndex=t,this.init(e)}return e.prototype=new i.DiffBlockFeeder,e.prototype.setModel=function(e){this._textModel=e},e.prototype.init=function(e){this._diffBlocks=undefined;if(e){this._mapper=e,this._diffBlocks=[],this._gapBlocks=[];var t=0,n=0;for(var r=0;r<this._mapper.length;r++){if(this._mapper[r][2]!==0){if(this._mapperColumnIndex===0){var i=t+this._mapper[r][1];this._diffBlocks.push([i,r]),this._gapBlocks.push([i,i+this._mapper[r][0],n])}else this._diffBlocks.push([t,r]),this._gapBlocks.push([t,t+this._mapper[r][1],n]);t+=this._mapper[r][0]+this._mapper[r][1]}else this._gapBlocks.push([t,t+this._mapper[r][this._mapperColumnIndex],n]),t+=this._mapper[r][this._mapperColumnIndex];n+=this._mapper[r][this._mapperColumnIndex]}}},e.prototype.getBlockAnnoTypes=function(e){this._mapperColumnIndex===0?e.push({type:"block",normal:s.ANNO_DIFF_ADDED_BLOCK,current:s.ANNO_DIFF_CURRENT_ADDED_BLOCK,list:[]}):e.push({type:"block",normal:s.ANNO_DIFF_DELETED_BLOCK,current:s.ANNO_DIFF_CURRENT_DELETED_BLOCK,list:[]}),e.push({type:"block",normal:s.ANNO_DIFF_BLOCK_CONFLICT,current:s.ANNO_DIFF_CURRENT_BLOCK_CONFLICT,list:[]})},e.prototype.getCurrentBlockAnnoType=function(e){if(!this._diffBlocks||this._diffBlocks.length===0)return null;var n=this._diffBlocks[e][1];return this._mapper[n][this._mapperColumnIndex]===0?{current:s.ANNO_DIFF_CURRENT_ADDED_WORD,normal:s.ANNO_DIFF_ADDED_WORD}:t.isMapperConflict(this.getMapper(),n)?{normal:s.ANNO_DIFF_BLOCK_CONFLICT,current:s.ANNO_DIFF_CURRENT_BLOCK_CONFLICT}:this._mapperColumnIndex===0?{type:"block",normal:s.ANNO_DIFF_ADDED_BLOCK,current:s.ANNO_DIFF_CURRENT_ADDED_BLOCK,list:[]}:{type:"block",normal:s.ANNO_DIFF_DELETED_BLOCK,current:s.ANNO_DIFF_CURRENT_DELETED_BLOCK,list:[]}},e.prototype.getDiffBlockH=function(e){if(!this._diffBlocks||this._diffBlocks.length===0)return-1;var t=this._diffBlocks[e][1];return this._mapper[t][0]+this._mapper[t][1]},e.prototype.getLineNumber=function(e){for(var t=0;t<this._gapBlocks.length;t++)if(this._gapBlocks[t][0]!==this._gapBlocks[t][1]&&e>=this._gapBlocks[t][0]&&e<this._gapBlocks[t][1]){var n=e-this._gapBlocks[t][0];return n+this._gapBlocks[t][2]}return-1},e}(),i}),define("orion/compare/compareView",["i18n!orion/compare/nls/messages","orion/Deferred","orion/webui/littlelib","orion/compare/diffParser","orion/compare/compareRulers","orion/editor/editor","orion/editor/editorFeatures","orion/keyBinding","orion/editor/textView","orion/compare/compareUIFactory","orion/compare/compareUtils","orion/compare/jsdiffAdapter","orion/compare/diffTreeNavigator"],function(e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v){var m={};return m.CompareView=function(){function e(){this._diffParser=new r.DiffParser}return e.prototype={_clearOptions:function(){this.options={},this.options.blockNumber=1,this.options.changeNumber=0},_getLineDelim:function(e,t){var n="\n";return n},_generateMapper:function(e,t,n,r,i){var s=this._getLineDelim(e,n);this._diffParser.setLineDelim(s);if(this.options.mapper&&this.options.toggler)return{delim:s,mapper:this.options.mapper,output:this.options.newFile.Content,diffArray:this.options.diffArray};if(typeof t=="string"&&typeof e=="string"){var o=new c.JSDiffAdapter,u=o.adapt(e,t,s);return this.options.toggler&&(this.options.mapper=u.mapper,this.options.newFile.Content=t,this.options.diffArray=u.changContents),{delim:s,mapper:u.mapper,output:t,diffArray:u.changContents}}var a=this._diffParser.parse(e,n,r,i),f=this._diffParser.getDiffArray();return this.options.toggler&&(this.options.mapper=a.mapper,this.options.newFile.Content=a.outPutFile,this.options.diffArray=f),{delim:s,mapper:a.mapper,output:a.outPutFile,diffArray:f}},_initSyntaxHighlighter:function(e){this._syntaxHighlighters=null;if(this.options.highlighters&&this.options.highlighters.length>0){if(e.length<1||e.length>2)return;this._syntaxHighlighters=[{highlighter:this.options.highlighters[0],target:e[0]}],e.length===2&&this.options.highlighters.length===2&&this._syntaxHighlighters.push({highlighter:this.options.highlighters[1],target:e[1]})}},_highlightSyntax:function(){if(this._syntaxHighlighters){var e=[];this._syntaxHighlighters.forEach(function(t){e.push(t.highlighter.highlight(t.target.fileName,t.target.contentType,t.target.editor))}.bind(this)),t.all(e,function(e){return{_error:e}}).then(function(e){this._diffNavigator.renderAnnotations(),this._diffNavigator.gotoBlock(this.options.blockNumber-1,this.options.changeNumber-1)}.bind(this))}else window.setTimeout(function(){this._diffNavigator.renderAnnotations(),this._diffNavigator.gotoBlock(this.options.blockNumber-1,this.options.changeNumber-1)}.bind(this),50)},setOptions:function(e,t){t&&this._clearOptions(),this.options||(this.options={}),e&&Object.keys(e).forEach(function(t){this.options[t]=e[t]}.bind(this))},getOptions:function(){return this.options},getCurrentDiffPos:function(){return this._diffNavigator.getCurrentPosition()},initDiffNav:function(){this._diffNavigator.gotoBlock(0,0)},nextDiff:function(){this._diffNavigator.nextDiff()},prevDiff:function(){this._diffNavigator.prevDiff()},nextChange:function(){return this._diffNavigator.nextChange()},prevChange:function(){this._diffNavigator.prevChange()},getWidget:function(){return this},startup:function(){this.initEditors(),this.refresh(!0)},initEditors:function(e){}},e}(),m.TwoWayCompareView=function(){function t(e){this.setOptions(e,!0),this._diffNavigator=new h.DiffTreeNavigator("word"),this.type="twoWay",this._uiFactory=this.options.uiFactory,this._uiFactory||(this._uiFactory=new f.TwoWayCompareUIFactory({parentDivID:this.options.parentDivId,showTitle:this.options.showTitle?this.options.showTitle:!1,showLineStatus:this.options.showLineStatus?this.options.showLineStatus:!1}),this._uiFactory.buildUI()),this._viewLoadedCounter=0,this.options.commandProvider&&this.options.commandProvider.initCommands(this),this._curveRuler=new i.CompareCurveRuler(this._uiFactory.getDiffCanvasDiv())}return t.prototype=new m.CompareView,t.prototype.initEditors=function(t){this._editors=[],this._editors.push(this._createEditor(t,this._uiFactory.getEditorParentDiv(!1),this._uiFactory.getStatusDiv(!1),this.options.oldFile)),this._editors.push(this._createEditor(t,this._uiFactory.getEditorParentDiv(!0),this._uiFactory.getStatusDiv(!0),this.options.newFile,!0)),this._overviewRuler=new i.CompareOverviewRuler("right",{styleClass:"ruler overview"},null,function(e,t){this._diffNavigator.matchPositionFromOverview(e)}.bind(this)),window.onbeforeunload=function(){if(this._editors){var t=this._editors.some(function(e){return e.isDirty()});if(t)return e["There are unsaved changes."]}}.bind(this)},t.prototype.getEditors=function(){return this._editors},t.prototype.gotoDiff=function(e,t,n){var r=n?this._editors[1].getTextView():this._editors[0].getTextView(),i=r.getModel().getLineStart(e)+t;this._diffNavigator.gotoDiff(i,r)},t.prototype.copyToLeft=function(){this._curveRuler.copyTo(!0)},t.prototype.copyToRight=function(){this._curveRuler.copyTo(!1)},t.prototype.resizeEditors=function(){this._editors.forEach(function(e){e.getTextView().resize()})},t.prototype.getSplitter=function(){return this._uiFactory.getSplitter()},t.prototype._createEditor=function(t,n,r,i,u){var f=typeof i.readonly=="undefined"?!0:i.readonly,l=function(){var e=new a.TextView({parent:n,readonly:f,tabSize:4});this._viewLoadedCounter++,this._viewLoadedCounter===2&&this._diffNavigator.matchPositionFromOverview(-1),this.onLoad&&this.onLoad();var t=this.getSplitter();return t&&t.addResizeListener(function(t){if(t){var n=!1;this._uiFactory.isLeftPane(t)?n=u:n=!u,n&&e.resize()}}.bind(this)),e}.bind(this),c=i.keyBindingFactory;c||(c=new o.KeyBindingsFactory);var h=null;if(r){var p="",d="";h=function(t,n){if(!r)return;n?d=e["ERROR: "]+t:d=t,r.textContent=p+d}}var v=new s.Editor({textViewFactory:l,undoStackFactory:new o.UndoFactory,annotationFactory:new o.AnnotationFactory,keyBindingFactory:c,statusReporter:h,domNode:n});v.installTextView(),v.setInput(null,null,i.Content?i.Content:t),v.setOverviewRulerVisible(!1);var m=v.getTextView();return m.addEventListener("Selection",function(e){if(e.newValue&&e.newValue.start!==e.newValue.end)return;if(this._diffNavigator.autoSelecting||!this._diffNavigator.editorWrapper[0].diffFeeder)return;var t=m.getCaretOffset();this._diffNavigator.gotoDiff(t,m)}.bind(this)),m.getModel().addEventListener("Changed",function(e){this._curveRuler.onChanged(e,!u)||(this.options.mapper=null)}.bind(this)),u?m.addEventListener("Scroll",function(e){this._curveRuler&&(this._curveRuler.matchPositionFrom(!0),this._curveRuler.render()),this.onScroll&&this.onScroll()}.bind(this)):m.addEventListener("Scroll",function(e){this._curveRuler&&this._curveRuler.render()}.bind(this)),v},t.prototype.destroy=function(){this._editors&&(this._diffNavigator.destroy(),this._editors.forEach(function(e){e.destroy()}),this._uiFactory.destroy())},t.prototype.addRulers=function(){if(this._editors&&!this._hasRuler){var e=new i.LineNumberCompareRuler(this._diffNavigator,0,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"}),t=new i.LineNumberCompareRuler(this._diffNavigator,0,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"});this._editors[1].getTextView().addRuler(e),this._editors[0].getTextView().addRuler(t),this._editors[0].getTextView().addRuler(this._overviewRuler),this._hasRuler=!0}},t.prototype.refresh=function(e){var t=this.options.oldFile.Content,r=this.options.newFile.Content,i=this.options.diffContent,s;typeof r=="string"?s=this._generateMapper(t,r,i,this.options.hasConflicts):(s=this._generateMapper(t,r,i,this.options.hasConflicts),r=s.output);var o=new h.TwoWayDiffBlockFeeder(this._editors[0].getTextView().getModel(),s.mapper,1),u=new h.TwoWayDiffBlockFeeder(this._editors[1].getTextView().getModel(),s.mapper,0);this._diffNavigator.initAll(this.options.charDiff?"char":"word",this._editors[0],this._editors[1],o,u,this._overviewRuler,this._curveRuler),this._curveRuler.init(s.mapper,this._editors[1],this._editors[0],this._diffNavigator),e&&(this._editors[1].setInput(this.options.newFile.Name,null,r),this._editors[0].setInput(this.options.oldFile.Name,null,t)),this._initSyntaxHighlighter([{fileName:this.options.newFile.Name,contentType:this.options.newFile.Type,editor:this._editors[1]},{fileName:this.options.oldFile.Name,contentType:this.options.oldFile.Type,editor:this._editors[0]}]),this._highlightSyntax(),this.options.commandProvider&&this.options.commandProvider.renderCommands(this),this.addRulers(),this._viewLoadedCounter===2&&this._diffNavigator.gotoBlock(this.options.blockNumber-1,this.options.changeNumber-1);var a=this._uiFactory.getTitleDiv(!0),f=this._uiFactory.getTitleDiv(!1);f&&a&&(n.empty(f),n.empty(a),f.appendChild(document.createTextNode(this.options.oldFile.Name)),a.appendChild(document.createTextNode(this.options.newFile.Name)));var l=this._editors[1].getTextView().getModel().getLineCount()*this._editors[1].getTextView().getLineHeight()+5,c=this._editors[0].getTextView().getModel().getLineCount()*this._editors[0].getTextView().getLineHeight()+5;return l>c?l:c},t}(),m.InlineCompareView=function(){function e(e){this.setOptions(e,!0),this._diffNavigator=new h.DiffTreeNavigator("word"),this.type="inline",this.options.commandProvider&&this.options.commandProvider.initCommands(this),this._editorDiv=this.options.parentDivId}return e.prototype=new m.CompareView,e.prototype.addRulers=function(){this._textView&&!this._hasRuler&&(this._textView.addRuler(this._rulerOrigin),this._textView.addRuler(this._rulerNew),this._textView.addRuler(this._overviewRuler),this._hasRuler=!0)},e.prototype.removeRulers=function(){this._textView&&this._hasRuler&&(this._textView.removeRuler(this._rulerOrigin),this._textView.removeRuler(this._rulerNew),this._textView.removeRuler(this._overviewRuler),this._hasRuler=!1)},e.prototype.destroyEditor=function(){this._textView&&(this._diffNavigator.destroy(),this._textView.setText(""),this.removeRulers())},e.prototype.destroy=function(){this._textView&&(this._diffNavigator.destroy(),this._textView.destroy())},e.prototype.initEditors=function(e){var t=n.node(this._editorDiv),r=function(){var e=new a.TextView({parent:t,readonly:!0,tabSize:4});return e}.bind(this);this._editor=new s.Editor({textViewFactory:r,undoStackFactory:new o.UndoFactory,annotationFactory:new o.AnnotationFactory,domNode:t}),this._editor.installTextView(),this._editor.setInput(null,null,e),this._editor.setOverviewRulerVisible(!1),this._editor.setAnnotationRulerVisible(!1),this._textView=this._editor.getTextView(),this._rulerOrigin=new i.LineNumberCompareRuler(this._diffNavigator,1,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"}),this._rulerNew=new i.LineNumberCompareRuler(this._diffNavigator,0,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"}),this._overviewRuler=new i.CompareOverviewRuler("right",{styleClass:"ruler overview"},null,function(e,t){this._diffNavigator.matchPositionFromOverview(e)}.bind(this)),this._textView.addEventListener("Selection",function(e){if(e.newValue&&e.newValue.start!==e.newValue.end)return;if(this._diffNavigator.autoSelecting||!this._diffNavigator.editorWrapper[0].diffFeeder)return;var t=this._textView.getCaretOffset();this._diffNavigator.gotoDiff(t,this._textView)}.bind(this))},e.prototype._initDiffPosition=function(e){var t=e.getModel();if(t&&t.getAnnotations){var n=t.getAnnotations();if(n.length>0){var r=n[0][0],i=e.getLineHeight(),s=e.getClientArea(),o=Math.floor(s.height/i/3);e.setTopIndex(r-o>0?r-o:0)}}},e.prototype.refresh=function(){var e=this.options.oldFile.Content,t=this.options.newFile.Content,n=this.options.diffContent,r=this._generateMapper(e,t,n,this.options.hasConflicts,!this.options.toggler);typeof t!="string"&&(t=r.output),this._textView.getModel().setText(e);var i=new h.inlineDiffBlockFeeder(r.mapper,1),s=new h.inlineDiffBlockFeeder(r.mapper,0);l.mergeDiffBlocks(this._textView.getModel(),s.getDiffBlocks(),r.mapper,r.diffArray.array,r.diffArray.index,this._diffParser._lineDelimiter),i.setModel(this._textView.getModel()),s.setModel(this._textView.getModel()),this._diffNavigator.initAll(this.options.charDiff?"char":"word",this._editor,this._editor,i,s,this._overviewRuler),this._initSyntaxHighlighter([{fileName:this.options.oldFile.Name,contentType:this.options.oldFile.Type,editor:this._editor}]),this._highlightSyntax(),this.options.commandProvider&&this.options.commandProvider.renderCommands(this),this.addRulers();var o=this._textView.getTopIndex();return this._textView.redrawLines(o,o+1,this._overviewRuler),this._textView.redrawLines(o,o+1,this._rulerOrigin),this._textView.redrawLines(o,o+1,this._rulerNew),this._diffNavigator.gotoBlock(this.options.blockNumber-1,this.options.changeNumber-1),this._textView.getLineHeight()*this._textView.getModel().getLineCount()+5},e.prototype.setConflicting=function(e){this._conflcit=e},e}(),m.toggleableCompareView=function(){function e(e,t){t&&(t.toggler=this),e==="inline"?this._widget=new m.InlineCompareView(t):this._widget=new m.TwoWayCompareView(t)}return e.prototype={startup:function(){this._widget.startup()},toggle:function(){var e=this._widget.options,t=this._widget.getCurrentDiffPos();e.blockNumber=t.block,e.changeNumber=t.change,this._widget.destroy(),n.empty(n.node(e.parentDivId)),this._widget.type==="inline"?this._widget=new m.TwoWayCompareView(e):this._widget=new m.InlineCompareView(e),this._widget.initEditors(),this._widget.refresh(!0)},getWidget:function(){return this._widget}},e}(),m}),define("orion/compare/compareCommands",["i18n!orion/compare/nls/messages","orion/commands","orion/keyBinding","orion/webui/littlelib"],function(e,t,n,r){var i={};return i.CompareCommandFactory=function(){function i(e){this.setOptions(e,!0)}return i.prototype={setOptions:function(e,t){t&&(this.options={}),this.options||(this.options={}),e&&Object.keys(e).forEach(function(t){this.options[t]=e[t]}.bind(this))},getOptions:function(){return this.options},initCommands:function(r){var i=this.options.commandSpanId,s=this.options.commandService;if(!s||!i)return;var o=new t.Command({name:e["Copy current change from right to left"],tooltip:e["Copy current change from right to left"],imageClass:"core-sprite-leftarrow",id:"orion.compare.copyToLeft",groupId:"orion.compareGroup",visibleWhen:function(e){return r.type==="twoWay"&&r.options.newFile&&!r.options.newFile.readonly}.bind(this),callback:function(e){e.items.copyToLeft()}}),u=new t.Command({name:e["Copy current change from left to right"],tooltip:e["Copy current change from left to right"],imageClass:"core-sprite-rightarrow",id:"orion.compare.copyToRight",groupId:"orion.compareGroup",visibleWhen:function(e){return r.type==="twoWay"&&r.options.oldFile&&!r.options.oldFile.readonly}.bind(this),callback:function(e){e.items.copyToRight()}}),a=new t.Command({tooltip:e["Switch to unified diff"],name:e.Unified,id:"orion.compare.toggle2Inline",groupId:"orion.compareGroup",visibleWhen:function(e){return e.options.toggler&&e.options.toggler.getWidget().type==="twoWay"},callback:function(e){e.items.options.toggler.toggle()}}),f=new t.Command({tooltip:e["Switch to side by side diff"],name:e["Side by side"],id:"orion.compare.toggle2TwoWay",groupId:"orion.compareGroup",visibleWhen:function(e){return e.options.toggler&&e.options.toggler.getWidget().type==="inline"},callback:function(e){e.items.options.toggler.toggle()}}),l=new t.Command({name:e["Next diff block"],tooltip:e["Next diff block"],imageClass:"core-sprite-move-down",id:"orion.compare.nextDiff",groupId:"orion.compareGroup",callback:function(e){e.items.nextDiff()}}),c=new t.Command({name:e["Previous diff block"],tooltip:e["Previous diff block"],imageClass:"core-sprite-move-up",id:"orion.compare.prevDiff",groupId:"orion.compareGroup",callback:function(e){e.items.prevDiff()}}),h=new t.Command({name:e["Next diff change"],tooltip:e["Next diff change"],imageClass:"core-sprite-move-down",id:"orion.compare.nextChange",groupId:"orion.compareGroup",callback:function(e){e.items.nextChange()}}),p=new t.Command({name:e["Previous diff change"],tooltip:e["Previous diff change"],imageClass:"core-sprite-move-up",id:"orion.compare.prevChange",groupId:"orion.compareGroup",callback:function(e){e.items.prevChange(e)}});s.addCommand(o),s.addCommand(u),s.addCommand(f),s.addCommand(a),s.addCommand(l),s.addCommand(c),s.addCommand(h),s.addCommand(p),s.registerCommandContribution(i,"orion.compare.toggle2Inline",108),s.registerCommandContribution(i,"orion.compare.toggle2TwoWay",109),s.registerCommandContribution(i,"orion.compare.copyToLeft",110,null,!1,new n.KeyBinding(37,!0,!1,!0)),s.registerCommandContribution(i,"orion.compare.copyToRight",111,null,!1,new n.KeyBinding(39,!0,!1,!0)),s.registerCommandContribution(i,"orion.compare.nextDiff",112,null,!1,new n.KeyBinding(40,!0)),s.registerCommandContribution(i,"orion.compare.prevDiff",113,null,!1,new n.KeyBinding(38,!0)),r.options.wordLevelNav?(s.registerCommandContribution(i,"orion.compare.nextChange",114,null,!1,new n.KeyBinding(40,!0,!0)),s.registerCommandContribution(i,"orion.compare.prevChange",115,null,!1,new n.KeyBinding(38,!0,!0))):(s.registerCommandContribution(i,"orion.compare.nextChange",114,null,!0,new n.KeyBinding(40,!0,!0)),s.registerCommandContribution(i,"orion.compare.prevChange",115,null,!0,new n.KeyBinding(38,!0,!0)))},renderCommands:function(e){var t=this.options.commandSpanId,n=this.options.commandService;if(!n||!t)return;r.empty(r.node(t)),this.options.gridRenderer&&this.options.gridRenderer.navGridHolder?(this.options.gridRenderer.navGridHolder.splice(0,this.options.gridRenderer.navGridHolder.length),this.options.gridRenderer.additionalCmdRender?this.options.gridRenderer.before?(this.options.gridRenderer.additionalCmdRender(this.options.gridRenderer.navGridHolder),n.renderCommands(t,t,e,e,"tool",null,this.options.gridRenderer.navGridHolder)):(n.renderCommands(t,t,e,e,"tool",null,this.options.gridRenderer.navGridHolder),this.options.gridRenderer.additionalCmdRender(this.options.gridRenderer.navGridHolder)):n.renderCommands(t,t,e,e,"tool",null,this.options.gridRenderer.navGridHolder)):n.renderCommands(t,t,e,e,"tool",null)}},i}(),i}),define("orion/editor/textMateStyler",["orion/regex"],function(e){function n(e){var t;if(e instanceof Array){t=new Array(e.length);for(var r=0;r<e.length;r++)t[r]=n(e[r])}else{t={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var s=e[i];typeof s=="object"&&s!==null?t[i]=n(s):t[i]=s}}return t}function r(e,t,r){this.initialize(e),this.grammar=n(t),this.externalGrammars=r?n(r):[],this._styles={},this._tree=null,this._allGrammars={},this.preprocess(this.grammar)}var t={unsupported:[{regex:/\(\?[ims\-]:/,func:function(e){return"option on/off for subexp"}},{regex:/\(\?<([=!])/,func:function(e){return e[1]==="="?"lookbehind":"negative lookbehind"}},{regex:/\(\?>/,func:function(e){return"atomic group"}}],toRegExp:function(e){function n(e,t){throw new Error('Unsupported regex feature "'+e+'": "'+t[0]+'" at index: '+t.index+" in "+t.input)}function r(e){var t="",n=!1,r=e.length;for(var i=0;i<r;){var s=e.charAt(i);if(!n&&s==="#")while(i<r&&s!=="\r"&&s!=="\n")s=e.charAt(++i);else if(!n&&/\s/.test(s))while(i<r&&/\s/.test(s))s=e.charAt(++i);else s==="\\"?(t+=s,/\s/.test(e.charAt(i+1))||(t+=e.charAt(i+1),i+=1),i+=1):s==="["?(n=!0,t+=s,i+=1):s==="]"?(n=!1,t+=s,i+=1):(t+=s,i+=1)}return t}var i="",s;e=t.processGlobalFlag("x",e,function(e){return r(e)}),e=t.processGlobalFlag("i",e,function(e){return i+="i",e});for(s=0;s<this.unsupported.length;s++){var o;(o=this.unsupported[s].regex.exec(e))&&n(this.unsupported[s].func(o),o)}return new RegExp(e,i)},processGlobalFlag:function(e,t,n){function r(e,t){var n=0,r=e.length,i=-1;for(var s=t;s<r&&i===-1;s++)switch(e.charAt(s)){case"\\":s++;break;case"(":n++;break;case")":n--,n===0&&(i=s)}return i}var i="(?"+e+")",s="(?"+e+":";if(t.substring(0,i.length)===i)return n(t.substring(i.length));if(t.substring(0,s.length)===s){var o=r(t,0);if(o<t.length-1)throw new Error("Only a "+s+") group that encloses the entire regex is supported in: "+t);return n(t.substring(s.length,o))}return t},hasBackReference:function(e){return/\\\d+/.test(e.source)},getSubstitutedRegex:function(t,n,r){r=typeof r=="undefined"?!0:!1;var i=t.source.split(/(\\\d+)/g),s=[];for(var o=0;o<i.length;o++){var u=i[o],a=/\\(\d+)/.exec(u);if(a){var f=n[a[1]]||"";s.push(r?e.escape(f):f)}else s.push(u)}return new RegExp(s.join(""))},groupify:function(e,t){var n=1,r=2,i=3,s=4,o=e.source,u=o.length,a=[],f=0,l=[],c=1,h=1,p=[],d={},v={};for(var m=0;m<u;m++){var g=a[a.length-1],y=o.charAt(m);switch(y){case"(":g===s&&(a.pop(),p.push(")"),l[l.length-1].end=m);var b=m+2<u?o.charAt(m+1)+""+o.charAt(m+2):null;if(b==="?:"||b==="?="||b==="?!"){var w;b==="?:"?w=n:(w=i,f++),a.push(w),l.push({start:m,end:-1,type:w}),p.push(y),p.push(b),m+=b.length}else a.push(r),l.push({start:m,end:-1,type:r,oldNum:c,num:h}),p.push(y),f===0&&(v[h]=null),d[c]=h,c++,h++;break;case")":var E=a.pop();E===i&&f--,l[l.length-1].end=m,p.push(y);break;case"*":case"+":case"?":case"}":var S=y,x=o.charAt(m-1),T=m-1;if(y==="}"){for(var N=m-1;o.charAt(N)!=="{"&&N>=0;N--);x=o.charAt(N-1),T=N-1,S=o.substring(N,m+1)}var C=l[l.length-1];if(x===")"&&(C.type===r||C.type===s)){p.splice(C.start,0,"("),p.push(S),p.push(")");var k={start:C.start,end:p.length-1,type:s,num:C.num};for(var L=0;L<l.length;L++)E=l[L],(E.type===r||E.type===s)&&E.start>=C.start&&E.end<=T&&(E.start+=1,E.end+=1,E.num=E.num+1,E.type===r&&(d[E.oldNum]=E.num));l.push(k),h++;break};default:y!=="|"&&g!==r&&g!==s&&f===0&&(a.push(s),l.push({start:m,end:-1,type:s,num:h}),p.push("("),v[h]=null,h++),p.push(y);if(y==="\\"){var A=o.charAt(m+1);p.push(A),m+=1}}}while(a.length)a.pop(),p.push(")");var O=new RegExp(p.join("")),M={};t=t||d;for(var _ in t)t.hasOwnProperty(_)&&(M[_]="\\"+t[_]);return O=this.getSubstitutedRegex(O,M,!1),[O,d,v]},complexCaptures:function(e){if(!e)return!1;for(var t in e)if(e.hasOwnProperty(t)&&t!=="0")return!0;return!1}};return r.prototype={initialize:function(e){this.textView=e,this.textView.stylerOptions=this;var t=this;this._listener={onModelChanged:function(e){t.onModelChanged(e)},onDestroy:function(e){t.onDestroy(e)},onLineStyle:function(e){t.onLineStyle(e)},onStorage:function(e){t.onStorage(e)}},e.addEventListener("ModelChanged",this._listener.onModelChanged),e.addEventListener("Destroy",this._listener.onDestroy),e.addEventListener("LineStyle",this._listener.onLineStyle),e.redrawLines()},onDestroy:function(e){this.destroy()},destroy:function(){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.grammar=null,this._styles=null,this._tree=null,this._listener=null},preprocess:function(e){var t=[e];for(;t.length!==0;){var n=t.pop();if(n._resolvedRule&&n._typedRule)continue;n._resolvedRule=this._resolve(n),n._typedRule=this._createTypedRule(n),this.addStyles(n.name),this.addStyles(n.contentName),this.addStylesForCaptures(n.captures),this.addStylesForCaptures(n.beginCaptures),this.addStylesForCaptures(n.endCaptures),n._resolvedRule!==n&&t.push(n._resolvedRule);if(n.patterns)for(var r=0;r<n.patterns.length;r++)t.push(n.patterns[r])}},addStyles:function(e){if(e&&!this._styles[e]){this._styles[e]=[];var t=e.split(".");for(var n=0;n<t.length;n++)this._styles[e].push(t.slice(0,n+1).join("-"))}},addStylesForCaptures:function(e){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t].name;this.addStyles(n)}},ContainerRule:function(){function e(e){this.rule=e,this.subrules=e.patterns}return e.prototype.valueOf=function(){return"aa"},e}(),BeginEndRule:function(){function e(e){this.rule=e,this.beginRegex=t.toRegExp(e.begin),this.endRegex=t.toRegExp(e.end),this.subrules=e.patterns||[],this.endRegexHasBackRef=t.hasBackReference(this.endRegex);var n=t.complexCaptures(e.captures),r=t.complexCaptures(e.beginCaptures)||t.complexCaptures(e.endCaptures);this.isComplex=n||r;if(this.isComplex){var i=t.groupify(this.beginRegex);this.beginRegex=i[0],this.beginOld2New=i[1],this.beginConsuming=i[2];var s=t.groupify(this.endRegex,this.beginOld2New);this.endRegex=s[0],this.endOld2New=s[1],this.endConsuming=s[2]}}return e.prototype.valueOf=function(){return this.beginRegex},e}(),MatchRule:function(){function e(e){this.rule=e,this.matchRegex=t.toRegExp(e.match),this.isComplex=t.complexCaptures(e.captures);if(this.isComplex){var n=t.groupify(this.matchRegex);this.matchRegex=n[0],this.matchOld2New=n[1],this.matchConsuming=n[2]}}return e.prototype.valueOf=function(){return this.matchRegex},e}(),_createTypedRule:function(e){return e.match?new this.MatchRule(e):e.begin?new this.BeginEndRule(e):new this.ContainerRule(e)},_resolve:function(e){var t=e;if(e.include){if(e.begin||e.end||e.match)throw new Error('Unexpected regex pattern in "include" rule '+e.include);var n=e.include;if(n.charAt(0)==="#"){t=this.grammar.repository&&this.grammar.repository[n.substring(1)];if(!t)throw new Error("Couldn't find included rule "+n+" in grammar repository")}else if(n==="$self")t=this.grammar;else{if(n==="$base")throw new Error('Include "$base" is not supported');t=this._allGrammars[n];if(!t)for(var r=0;r<this.externalGrammars.length;r++){var i=this.externalGrammars[r];if(i.scopeName===n){this.preprocess(i),this._allGrammars[n]=i,t=i;break}}}}return t},ContainerNode:function(){function e(e,t){this.parent=e,this.rule=t,this.children=[],this.start=null,this.end=null}return e.prototype.addChild=function(e){this.children.push(e)},e.prototype.valueOf=function(){var e=this.rule;return"ContainerNode { "+(e.include||"")+" "+(e.name||"")+(e.comment||"")+"}"},e}(),BeginEndNode:function(){function e(e,n,r){this.parent=e,this.rule=n,this.children=[],this.setStart(r),this.end=null,this.endMatch=null,n.endRegexHasBackRef?this.endRegexSubstituted=t.getSubstitutedRegex(n.endRegex,r):this.endRegexSubstituted=null}return e.prototype.addChild=function(e){this.children.push(e)},e.prototype.getIndexInParent=function(e){return this.parent?this.parent.children.indexOf(this):-1},e.prototype.setStart=function(e){this.start=e.index,this.beginMatch=e},e.prototype.setEnd=function(e){if(e&&typeof e=="object"){var t=e;this.endMatch=t,this.end=t.index+t[0].length}else{var n=e;this.endMatch=null,this.end=n}},e.prototype.shiftStart=function(e){this.start+=e,this.beginMatch.index+=e},e.prototype.shiftEnd=function(e){this.end+=e,this.endMatch&&(this.endMatch.index+=e)},e.prototype.valueOf=function(){return"{"+this.rule.beginRegex+" range="+this.start+".."+this.end+"}"},e}(),push:function(e,t){if(!t)return;for(var n=t.length;n>0;)e.push(t[--n])},exec:function(e,t,n){var r=e.exec(t);return r&&(r.index+=n),e.lastIndex=0,r},afterMatch:function(e){return e.index+e[0].length},getEndMatch:function(e,t,n){if(e instanceof this.BeginEndNode){var r=e.rule,i=e.endRegexSubstituted||r.endRegex;return i?this.exec(i,t,n):null}return null},initialParse:function(){var e=this.textView.getModel().getCharCount(),t=new this.ContainerNode(null,this.grammar._typedRule);this._tree=t,this.parse(this._tree,!1,0)},onModelChanged:function(e){var t=e.addedCharCount,n=e.addedLineCount,r=e.removedCharCount,i=e.removedLineCount,s=e.start;if(!this._tree)this.initialParse();else{var o=this.textView.getModel(),u=o.getCharCount(),a=o.getLineEnd(o.getLineAtOffset(s)-1),f=this.getFirstDamaged(a,a);a=a===-1?0:a;var l;f?l=this.parse(f,!0,a,s,t,r):l=u,this.textView.redrawRange(a,l)}},getFirstDamaged:function(e,t){if(e<0)return this._tree;var n=[this._tree],r=null;while(n.length){var i=n.pop();if(!i.parent||this.isDamaged(i,e,t)){i instanceof this.BeginEndNode&&(r=i);for(var s=0;s<i.children.length;s++)n.push(i.children[s])}}return r||this._tree},isDamaged:function(e,t,n){return e.start<=n&&e.end>t},parse:function(e,t,n,r,i,s){var o=this.textView.getModel(),u=o.getLineStart(o.getLineCount()-1),a=o.getCharCount(),f=this.getInitialExpected(e,n),l=-1;if(t){e.repaired=!0,e.endNeedsUpdate=!0;var c=e.children[e.children.length-1],h=i-s,p=c?o.getLineEnd(o.getLineAtOffset(c.end+h)):-1,d=o.getLineEnd(o.getLineAtOffset(r+s));l=Math.max(p,d)}l=l===-1?a:l;var v=f,m=e,g=!1,y=n,b=-1;while(m&&(!t||y<l)){var w=this.getNextMatch(o,m,y);w||(y=y>=u?a:o.getLineStart(o.getLineAtOffset(y)+1));var E=w&&w.match,S=w&&w.rule,x=w&&w.isSub,T=w&&w.isEnd;if(x){y=this.afterMatch(E);if(S instanceof this.BeginEndRule){g=!0;if(t&&S===v.rule&&m===v.parent){var N=v;N.setStart(E),N.repaired=!0,N.endNeedsUpdate=!0,m=N,v=this.getNextExpected(v,"begin")}else{t&&(this.prune(m,v),t=!1);var C=new this.BeginEndNode(m,S,E);m.addChild(C),m=C}}}else if(T||y===a)m instanceof this.BeginEndNode&&(E?(g=!0,b=Math.max(b,m.end),m.setEnd(E),y=this.afterMatch(E),t&&m===v&&m.parent===v.parent?(m.repaired=!0,delete m.endNeedsUpdate,v=this.getNextExpected(v,"end")):t&&(this.prune(m,v),t=!1)):(m.setEnd(a),delete m.endNeedsUpdate)),m=m.parent;t&&y>=l&&!g&&(this.prune(e,f),t=!1)}return this.removeUnrepairedChildren(e,t,n),this.cleanup(t,e,n,l,a,i,s),t?Math.max(b,y):y},removeUnrepairedChildren:function(e,t,n){if(t){var r=e.children,i=-1;for(var s=0;s<r.length;s++){var o=r[s];if(!o.repaired&&this.isDamaged(o,n,Number.MAX_VALUE)){i=s;break}}i!==-1&&(e.children.length=i)}},cleanup:function(e,t,n,r,i,s,o){var u,a,f;if(e){var l=s-o,c=this.getIntersecting(r-l+1,i);f=this.getIntersecting(n,r);for(u=0;u<c.length;u++)a=c[u],!a.repaired&&a instanceof this.BeginEndNode&&(a.shiftEnd(l),a.shiftStart(l));for(u=0;u<f.length;u++)a=f[u],a.repaired&&a.endNeedsUpdate&&a.shiftEnd(l),delete a.endNeedsUpdate,delete a.repaired}else{f=this.getIntersecting(n,r);for(u=0;u<f.length;u++)delete f[u].repaired}},getNextMatch:function(e,t,n,r){var i=e.getLineAtOffset(n),s=e.getLineEnd(i),o=e.getText(n,s),u=[],a=[],f=[],l=[];this.push(u,t.rule.subrules);while(u.length){var c=u.length?u.pop():null,h=c&&c._resolvedRule._typedRule;if(h instanceof this.ContainerRule&&a.indexOf(h)===-1){a.push(h),this.push(u,h.subrules);continue}if(h&&r&&!h.matchRegex)continue;var p=h&&this.exec(h.matchRegex||h.beginRegex,o,n);p&&(f.push(p),l.push(h))}var d=Number.MAX_VALUE,v=-1;for(var m=0;m<f.length;m++){var g=f[m];g.index<d&&(d=g.index,v=m)}if(!r){var y=t,b=this.getEndMatch(t,o,n);if(b){var w=y.rule.applyEndPatternLast,E=v===-1||b.index<d||!w&&b.index===d;if(E)return{isEnd:!0,rule:y.rule,match:b}}}return v===-1?null:{isSub:!0,rule:l[v],match:f[v]}},getInitialExpected:function(e,t){var n,r;if(e===this._tree)for(n=0;n<e.children.length;n++){r=e.children[n];if(r.start>=t)return r}else if(e instanceof this.BeginEndNode&&e.endMatch){var i=e.endMatch.index;for(n=0;n<e.children.length;n++){r=e.children[n];if(r.start>=t)break}if(r&&r.start<i)return r}return e},getNextExpected:function(e,t){var n=e;if(t==="begin"){var r=n.children[0];return r?r:n}if(t==="end"){var i=n.parent;if(i){var s=i.children[i.children.indexOf(n)+1];return s?s:i}}return null},prune:function(e,t){var n=t.parent===e;n?e.children.length=t.getIndexInParent():e instanceof this.BeginEndNode&&(e.endMatch=null,e.end=null),e.parent&&(e.parent.children.length=e.getIndexInParent()+1)},onLineStyle:function(e){function t(e,t){return e.start-t.start}this._tree||this.initialParse();var n=e.lineStart,r=this.textView.getModel(),i=r.getLineEnd(e.lineIndex),s=r.getLineEnd(r.getLineAtOffset(n)-1),o=this.getFirstDamaged(s,s),u=this.getLineScope(r,o,n,i);e.ranges=this.toStyleRanges(u),e.ranges.sort(t)},getLineScope:function(e,t,n,r){var i=n,s=this.getInitialExpected(t,n),o=[],u=[];while(t&&i<r){var a=this.getNextMatch(e,t,i);if(!a)break;var f=a&&a.match,l=a&&a.rule,c=a&&a.isSub,h=a&&a.isEnd;f.index!==i&&u.push({start:i,end:f.index,node:t}),c?(i=this.afterMatch(f),l instanceof this.BeginEndRule?(this.addBeginScope(o,f,l),t=s,s=this.getNextExpected(s,"begin")):this.addMatchScope(o,f,l)):h&&(i=this.afterMatch(f),this.addEndScope(o,f,l),s=this.getNextExpected(s,"end"),t=t.parent)}i<r&&u.push({start:i,end:r,node:t});var p=this.getInheritedLineScope(u,n,r);return o.concat(p)},getInheritedLineScope:function(e,t,n){var r=[];for(var i=0;i<e.length;i++){var s=e[i],o=s.node;while(o){var u=o.rule.rule,a=u.name,f=u.contentName,l=f||a;if(l){this.addScopeRange(r,s.start,s.end,l);break}o=o.parent}}return r},addBeginScope:function(e,t,n){var r=n.rule;this.addCapturesScope(e,t,r.beginCaptures||r.captures,n.isComplex,n.beginOld2New,n.beginConsuming)},addEndScope:function(e,t,n){var r=n.rule;this.addCapturesScope(e,t,r.endCaptures||r.captures,n.isComplex,n.endOld2New,n.endConsuming)},addMatchScope:function(e,t,n){var r=n.rule,i=r.name,s=r.captures;s?this.addCapturesScope(e,t,s,n.isComplex,n.matchOld2New,n.matchConsuming):this.addScope(e,t,i)},addScope:function(e,t,n){if(!n)return;e.push({start:t.index,end:this.afterMatch(t),scope:n})},addScopeRange:function(e,t,n,r){if(!r)return;e.push({start:t,end:n,scope:r})},addCapturesScope:function(e,t,n,r,i,s){if(!n)return;if(!r)this.addScope(e,t,n[0]&&n[0].name);else{var o={1:0},u=0;for(var a=1;t[a]!==undefined;a++)s[a]!==undefined&&(u+=t[a].length),t[a+1]!==undefined&&(o[a+1]=u);var f=t.index;for(var l=1;n[l];l++){var c=n[l].name,h=i[l],p=f+o[h];if(typeof t[h]!="undefined"){var d=p+t[h].length;this.addScopeRange(e,p,d,c)}}}},getIntersecting:function(e,t){var n=[],r=this._tree?[this._tree]:[];while(r.length){var i=r.pop(),s=!1;i instanceof this.ContainerNode?s=!0:this.isDamaged(i,e,t)&&(s=!0,n.push(i));if(s){var o=i.children.length;for(var u=0;u<o;u++)r.push(i.children[u])}}return n.reverse()},toStyleRanges:function(e){var t=[];for(var n=0;n<e.length;n++){var r=e[n],i=this._styles[r.scope];if(!i)throw new Error("styles not found for "+r.scope);var s=i.join(" ");t.push({start:r.start,end:r.end,style:{styleClass:s}})}return t}},{RegexUtil:t,TextMateStyler:r}}),define("orion/editor/htmlGrammar",[],function(){function e(){return{scopeName:"source.html",uuid:"3B5C76FB-EBB5-D930-F40C-047D082CE99B",patterns:[{begin:"<!(doctype|DOCTYPE)",end:">",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:"</[A-Za-z0-9_\\-:]+>",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:"string.quoted.double.html"},qString:{match:"(')[^']+(')",name:"string.quoted.single.html"},entity:{match:"&[A-Za-z0-9]+;",name:"constant.character.entity.html"}}}}return{HtmlGrammar:e}}),define("orion/editor/keywords",[],function(){var e=["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"],t=["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"],n=["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"];return{JSKeywords:e,CSSKeywords:t,JAVAKeywords:n}}),define("examples/editor/textStyler",["orion/editor/annotations","orion/editor/keywords"],function(e,t){function _(e,t){this.keywords=e,this.whitespacesVisible=t,this.setText("")}function D(){_.call(this,null,!0)}function P(e){_.call(this,null,e)}function H(){_.call(this,null,!1)}function B(e,t,s){this.commentStart="/*",this.commentEnd="*/";var o=[];switch(t){case"java":o=r;break;case"js":o=n;break;case"css":o=i}this.whitespacesVisible=this.spacesVisible=this.tabsVisible=!1,this.detectHyperlinks=!0,this.highlightCaretLine=!1,this.foldingEnabled=!0,this.detectTasks=!0,this._scanner=new _(o,this.whitespacesVisible),this._firstScanner=new H,this._commentScanner=new P(this.whitespacesVisible),this._whitespaceScanner=new D,t==="css"&&(this._scanner.isCSS=!0,this._firstScanner.isCSS=!0),this.view=e,this.annotationModel=s,this._bracketAnnotations=undefined;var u=this;this._listener={onChanged:function(e){u._onModelChanged(e)},onDestroy:function(e){u._onDestroy(e)},onLineStyle:function(e){u._onLineStyle(e)},onMouseDown:function(e){u._onMouseDown(e)},onSelection:function(e){u._onSelection(e)}};var a=e.getModel();a.getBaseModel&&(a=a.getBaseModel()),a.addEventListener("Changed",this._listener.onChanged),e.addEventListener("MouseDown",this._listener.onMouseDown),e.addEventListener("Selection",this._listener.onSelection),e.addEventListener("Destroy",this._listener.onDestroy),e.addEventListener("LineStyle",this._listener.onLineStyle),this._computeComments(),this._computeFolding(),e.redrawLines()}var n=t.JSKeywords,r=t.JAVAKeywords,i=t.CSSKeywords,s=1,o=2,u=3,a=4,f=5,l=6,c=7,h=8,p=9,d=10,v=11,m=12,g=13,y=14,b="{}()[]<>",w={styleClass:"token_singleline_comment"},E={styleClass:"token_multiline_comment"},S={styleClass:"token_doc_comment"},x={styleClass:"token_doc_html_markup"},T={styleClass:"token_task_tag"},N={styleClass:"token_doc_tag"},C={styleClass:"token_string"},k={styleClass:"token_number"},L={styleClass:"token_keyword"},A={styleClass:"token_space",unmergeable:!0},O={styleClass:"token_tab",unmergeable:!0},M={styleClass:"line_caret"};return _.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(e){switch(e){case 32:case 9:if(this.whitespacesVisible)return e===32?v:d;do e=this._read();while(e===32||e===9);return this._unread(e),p;case 123:case 125:case 40:case 41:case 91:case 93:case 60:case 62:return e;default:var t=this.isCSS,n=this.offset-1;if(!t&&48<=e&&e<=57){var r=!1,i=!1,a=!1,f=e;do{e=this._read();if(e===46&&!r)r=!0;else if(e===101&&!i)r=i=!0,e=this._read(),e!==45&&this._unread(e);else if(e===120&&f===48&&this.offset-n===2)r=i=a=!0;else if(!(48<=e&&e<=57||a&&(65<=e&&e<=70||97<=e&&e<=102)))break}while(!0);return this._unread(e),u}if(97<=e&&e<=122||65<=e&&e<=90||e===95||45===e&&t){do e=this._read();while(97<=e&&e<=122||65<=e&&e<=90||e===95||48<=e&&e<=57||45===e&&t);this._unread(e);var l=this.keywords;if(l.length>0){var c=this.text.substring(n,this.offset);for(var h=0;h<l.length;h++)if(this.keywords[h]===c)return o}}return s}},_read:function(){return this.offset<this.text.length?this.text.charCodeAt(this.offset++):-1},_unread:function(e){e!==-1&&this.offset--},nextToken:function(){this.startOffset=this.offset;for(;;){var e=this._read(),t;switch(e){case-1:return null;case 47:e=this._read();if(!this.isCSS&&e===47)for(;;){e=this._read();if(e===-1||e===10||e===13)return this._unread(e),l}if(e===42){e=this._read();var n=c;e===42&&(n=h);for(;;){while(e===42){e=this._read();if(e===47)return n}if(e===-1)return this._unread(e),n;e=this._read()}}return this._unread(e),s;case 39:t=a;for(;;){e=this._read();switch(e){case 39:return t;case 13:case 10:case-1:return this._unread(e),t;case 92:e=this._read();switch(e){case 10:t=f;break;case 13:t=f,e=this._read(),e!==10&&this._unread(e)}}}break;case 34:t=a;for(;;){e=this._read();switch(e){case 34:return t;case 13:case 10:case-1:return this._unread(e),t;case 92:e=this._read();switch(e){case 10:t=f;break;case 13:t=f,e=this._read(),e!==10&&this._unread(e)}}}break;default:return this._default(e)}}},setText:function(e){this.text=e,this.offset=0,this.startOffset=0}},D.prototype=new _(null),D.prototype.nextToken=function(){this.startOffset=this.offset;for(;;){var e=this._read();switch(e){case-1:return null;case 32:return v;case 9:return d;default:do e=this._read();while(e!==32&&e!==9&&e!==-1);return this._unread(e),s}}},P.prototype=new _(null),P.prototype.setType=function(e){this._type=e},P.prototype.nextToken=function(){this.startOffset=this.offset;for(;;){var e=this._read();switch(e){case-1:return null;case 32:case 9:if(this.whitespacesVisible)return e===32?v:d;do e=this._read();while(e===32||e===9);return this._unread(e),p;case 60:if(this._type===h){do e=this._read();while(e!==62&&e!==-1);if(e===62)return m}return s;case 64:if(this._type===h){do e=this._read();while(97<=e&&e<=122||65<=e&&e<=90||e===95||48<=e&&e<=57);return this._unread(e),g}return s;case 84:if((e=this._read())===79)if((e=this._read())===68)if((e=this._read())===79){e=this._read();if(!(97<=e&&e<=122||65<=e&&e<=90||e===95||48<=e&&e<=57))return this._unread(e),y;this._unread(e)}else this._unread(e);else this._unread(e);else this._unread(e);default:do e=this._read();while(e!==32&&e!==9&&e!==-1&&e!==60&&e!==64&&e!==84);return this._unread(e),s}}},H.prototype=new _(null),H.prototype._default=function(e){for(;;){e=this._read();switch(e){case 47:case 34:case 39:case-1:return this._unread(e),s}}},B.prototype={destroy:function(){var e=this.view;if(e){var t=e.getModel();t.getBaseModel&&(t=t.getBaseModel()),t.removeEventListener("Changed",this._listener.onChanged),e.removeEventListener("MouseDown",this._listener.onMouseDown),e.removeEventListener("Selection",this._listener.onSelection),e.removeEventListener("Destroy",this._listener.onDestroy),e.removeEventListener("LineStyle",this._listener.onLineStyle),this.view=null}},setHighlightCaretLine:function(e){this.highlightCaretLine=e},setWhitespacesVisible:function(e,t){if(this.whitespacesVisible===e)return;this.whitespacesVisible=e,this._scanner.whitespacesVisible=e,this._commentScanner.whitespacesVisible=e,t&&this.view.redraw()},setTabsVisible:function(e){if(this.tabsVisible===e)return;this.tabsVisible=e,this.setWhitespacesVisible(this.tabsVisible||this.spacesVisible,!1),this.view.redraw()},setSpacesVisible:function(e){if(this.spacesVisible===e)return;this.spacesVisible=e,this.setWhitespacesVisible(this.tabsVisible||this.spacesVisible,!1),this.view.redraw()},setDetectHyperlinks:function(e){this.detectHyperlinks=e},setFoldingEnabled:function(e){this.foldingEnabled=e},setDetectTasks:function(e){this.detectTasks=e},_binarySearch:function(e,t,n,r,i){var s;r===undefined&&(r=-1),i===undefined&&(i=e.length);while(i-r>1){s=Math.floor((i+r)/2);if(t<=e[s].start)i=s;else{if(n&&t<e[s].end){i=s;break}r=s}}return i},_computeComments:function(){var e=this.view.getModel();e.getBaseModel&&(e=e.getBaseModel()),this.comments=this._findComments(e.getText())},_computeFolding:function(){if(!this.foldingEnabled)return;var t=this.view,n=t.getModel();if(!n.getBaseModel)return;var r=this.annotationModel;if(!r)return;r.removeAnnotations(e.AnnotationType.ANNOTATION_FOLDING);var i=[],s=n.getBaseModel(),o=this.comments;for(var u=0;u<o.length;u++){var a=o[u],f=this._createFoldingAnnotation(n,s,a.start,a.end);f&&i.push(f)}r.replaceAnnotations(null,i)},_createFoldingAnnotation:function(t,n,r,i){var s=n.getLineAtOffset(r),o=n.getLineAtOffset(i);return s===o?null:new(e.AnnotationType.getType(e.AnnotationType.ANNOTATION_FOLDING))(r,i,t)},_computeTasks:function(t,n,r){if(!this.detectTasks)return;var i=this.annotationModel;if(!i)return;var s=this.view,o=s.getModel(),u=o;o.getBaseModel&&(u=o.getBaseModel());var a=i.getAnnotations(n,r),f=[],c=e.AnnotationType.ANNOTATION_TASK;while(a.hasNext()){var h=a.next();h.type===c&&f.push(h)}var p=[],d=this._commentScanner;d.setText(u.getText(n,r));var v;while(v=d.nextToken()){var m=d.getStartOffset()+n;if(v===y){var g=u.getLineEnd(u.getLineAtOffset(m));t!==l&&(g=Math.min(g,r-this.commentEnd.length)),p.push(e.AnnotationType.createAnnotation(c,m,g,u.getText(m,g)))}}i.replaceAnnotations(f,p)},_getLineStyle:function(e){if(this.highlightCaretLine){var t=this.view,n=t.getModel(),r=t.getSelection();if(r.start===r.end&&n.getLineAtOffset(r.start)===e)return M}return null},_getStyles:function(e,t,n){e.getBaseModel&&(n=e.mapOffset(n));var r=n+t.length,i=[],s=n,o=this.comments,u=this._binarySearch(o,n,!0);for(var a=u;a<o.length;a++){if(o[a].start>=r)break;var l=o[a].start,p=o[a].end;s<l&&this._parse(t.substring(s-n,l-n),s,i);var d=o[a].type,v;switch(d){case h:v=S;break;case c:v=E;break;case f:v=C}var m=Math.max(s,l),g=Math.min(r,p);d!==h&&d!==c||!this.whitespacesVisible&&!this.detectHyperlinks?d===f&&this.whitespacesVisible?this._parseString(t.substring(m-n,g-n),m,i,C):i.push({start:m,end:g,style:v}):this._parseComment(t.substring(m-n,g-n),m,i,v,d),s=p}s<r&&this._parse(t.substring(s-n,r-n),s,i);if(e.getBaseModel)for(var y=0;y<i.length;y++){var b=i[y].end-i[y].start;i[y].start=e.mapOffset(i[y].start,!0),i[y].end=i[y].start+b}return i},_parse:function(e,t,n){var r=this._scanner;r.setText(e);var i;while(i=r.nextToken()){var s=r.getStartOffset()+t,p=null;switch(i){case o:p=L;break;case u:p=k;break;case f:case a:if(this.whitespacesVisible){this._parseString(r.getData(),s,n,C);continue}p=C;break;case h:this._parseComment(r.getData(),s,n,S,i);continue;case l:this._parseComment(r.getData(),s,n,w,i);continue;case c:this._parseComment(r.getData(),s,n,E,i);continue;case d:this.whitespacesVisible&&this.tabsVisible&&(p=O);break;case v:this.whitespacesVisible&&this.spacesVisible&&(p=A)}n.push({start:s,end:r.getOffset()+t,style:p})}},_parseComment:function(e,t,n,r,i){var s=this._commentScanner;s.setText(e),s.setType(i);var o;while(o=s.nextToken()){var u=s.getStartOffset()+t,a=r;switch(o){case d:this.whitespacesVisible&&this.tabsVisible&&(a=O);break;case v:this.whitespacesVisible&&this.spacesVisible&&(a=A);break;case m:a=x;break;case g:a=N;break;case y:a=T;break;default:this.detectHyperlinks&&(a=this._detectHyperlinks(s.getData(),u,n,a))}a&&n.push({start:u,end:s.getOffset()+t,style:a})}},_parseString:function(e,t,n,r){var i=this._whitespaceScanner;i.setText(e);var s;while(s=i.nextToken()){var o=i.getStartOffset()+t,u=r;switch(s){case d:this.whitespacesVisible&&this.tabsVisible&&(u=O);break;case v:this.whitespacesVisible&&this.spacesVisible&&(u=A)}u&&n.push({start:o,end:i.getOffset()+t,style:u})}},_detectHyperlinks:function(e,t,n,r){var i=null,s,o;if((s=e.indexOf("://"))>0){i=e;var u=s;while(u>0){var a=i.charCodeAt(u-1);if(!(97<=a&&a<=122||65<=a&&a<=90||45===a||48<=a&&a<=57))break;u--}if(u>0){var f="\"\"''(){}[]<>";s=f.indexOf(i.substring(u-1,u));if(s!==-1&&(s&1)===0&&(s=i.lastIndexOf(f.substring(s+1,s+2)))!==-1){var l=s;return o=this._clone(r),o.tagName="a",o.attributes={href:i.substring(u,l)},n.push({start:t,end:t+u,style:r}),n.push({start:t+u,end:t+l,style:o}),n.push({start:t+l,end:t+e.length,style:r}),null}}}else e.toLowerCase().indexOf("bug#")===0&&(i="https://bugs.eclipse.org/bugs/show_bug.cgi?id="+parseInt(e.substring(4),10));return i?(o=this._clone(r),o.tagName="a",o.attributes={href:i},o):r},_clone:function(e){if(!e)return e;var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];t[n]=r}return t},_findComments:function(e,t){t=t||0;var n=this._firstScanner,r;n.setText(e);var i=[];while(r=n.nextToken())(r===c||r===h||r===f)&&i.push({start:n.getStartOffset()+t,end:n.getOffset()+t,type:r}),(r===l||r===c||r===h)&&this._computeTasks(r,n.getStartOffset()+t,n.getOffset()+t);return i},_findMatchingBracket:function(e,t){var n=b,r=e.getText(t,t+1),i=n.indexOf(r,0);if(i===-1)return-1;var s;i&1?s=n.substring(i-1,i):s=n.substring(i+1,i+2);var o=e.getLineAtOffset(t),u=e.getLine(o),a=e.getLineStart(o),f=e.getLineEnd(o);n=this._findBrackets(r,s,u,a,a,f);for(var l=0;l<n.length;l++){var c=n[l]>=0?1:-1;if(n[l]*c-1===t){var h=1;if(i&1){l--;for(;l>=0;l--){c=n[l]>=0?1:-1,h+=c;if(h===0)return n[l]*c-1}o-=1;while(o>=0){u=e.getLine(o),a=e.getLineStart(o),f=e.getLineEnd(o),n=this._findBrackets(r,s,u,a,a,f);for(var p=n.length-1;p>=0;p--){c=n[p]>=0?1:-1,h+=c;if(h===0)return n[p]*c-1}o--}}else{l++;for(;l<n.length;l++){c=n[l]>=0?1:-1,h+=c;if(h===0)return n[l]*c-1}o+=1;var d=e.getLineCount();while(o<d){u=e.getLine(o),a=e.getLineStart(o),f=e.getLineEnd(o),n=this._findBrackets(r,s,u,a,a,f);for(var v=0;v<n.length;v++){c=n[v]>=0?1:-1,h+=c;if(h===0)return n[v]*c-1}o++}}break}}return-1},_findBrackets:function(e,t,n,r,i,s){var o=[],u=e.charCodeAt(0),a=t.charCodeAt(0),f=i,l=this._scanner,c,h=this.comments,p=this._binarySearch(h,i,!0);for(var d=p;d<h.length;d++){if(h[d].start>=s)break;var v=h[d].start,m=h[d].end;if(f<v){l.setText(n.substring(f-i,v-i));while(c=l.nextToken())c===u?o.push(l.getStartOffset()+f-i+r+1):c===a&&o.push(-(l.getStartOffset()+f-i+r+1))}f=m}if(f<s){l.setText(n.substring(f-i,s-i));while(c=l.nextToken())c===u?o.push(l.getStartOffset()+f-i+r+1):c===a&&o.push(-(l.getStartOffset()+f-i+r+1))}return o},_onDestroy:function(e){this.destroy()},_onLineStyle:function(e){e.textView===this.view&&(e.style=this._getLineStyle(e.lineIndex)),e.ranges=this._getStyles(e.textView.getModel(),e.lineText,e.lineStart)},_onSelection:function(t){var n=t.oldValue,r=t.newValue,i=this.view,s=i.getModel(),o;if(this.highlightCaretLine){var u=s.getLineAtOffset(n.start);o=s.getLineAtOffset(r.start);var a=r.start===r.end,f=n.start===n.end;if(u!==o||!f||!a)f&&i.redrawLines(u,u+1),(u!==o||!f)&&a&&i.redrawLines(o,o+1)}if(!this.annotationModel)return;var l=this._bracketAnnotations,c,h;if(r.start===r.end&&(h=i.getCaretOffset())>0){var p=h-1;s.getBaseModel&&(p=s.mapOffset(p),s=s.getBaseModel());var d=this._findMatchingBracket(s,p);d!==-1&&(c=[e.AnnotationType.createAnnotation(e.AnnotationType.ANNOTATION_MATCHING_BRACKET,d,d+1),e.AnnotationType.createAnnotation(e.AnnotationType.ANNOTATION_CURRENT_BRACKET,p,p+1)])}this._bracketAnnotations=c,this.annotationModel.replaceAnnotations(l,c)},_onMouseDown:function(e){if(e.clickCount!==2)return;var t=this.view,n=t.getModel(),r=t.getOffsetAtLocation(e.x,e.y);if(r>0){var i=r-1,s=n;n.getBaseModel&&(i=n.mapOffset(i),s=n.getBaseModel());var o=this._findMatchingBracket(s,i);if(o!==-1){e.preventDefault();var u=o;n.getBaseModel&&(u=n.mapOffset(u,!0)),r>u&&(r--,u++),t.setSelection(u,r)}}},_onModelChanged:function(t){var n=t.start,r=t.removedCharCount,i=t.addedCharCount,s=i-r,o=this.view,u=o.getModel(),a=u.getBaseModel?u.getBaseModel():u,f=n+r,l=a.getCharCount(),c=this.comments.length,h=a.getLineStart(a.getLineAtOffset(n)),p=this._binarySearch(this.comments,h,!0),d=this._binarySearch(this.comments,f,!1,p-1,c),v;p<c&&this.comments[p].start<=h&&h<this.comments[p].end?(v=this.comments[p].start,v>n&&(v+=s)):p===c&&c>0&&l-s===this.comments[c-1].end?v=this.comments[c-1].start:v=h;var m;d<c?(m=this.comments[d].end,m>n&&(m+=s),d+=1):(d=c,m=l);var g=a.getText(v,m),y,b=this._findComments(g,v),w;for(w=p;w<this.comments.length;w++)y=this.comments[w],y.start>n&&(y.start+=s),y.start>n&&(y.end+=s);var E=d-p!==b.length;if(!E)for(w=0;w<b.length;w++){y=this.comments[p+w];var S=b[w];if(y.start!==S.start||y.end!==S.end||y.type!==S.type){E=!0;break}}var x=[p,d-p].concat(b);Array.prototype.splice.apply(this.comments,x);if(E){var T=v,N=m;u!==a&&(T=u.mapOffset(T,!0),N=u.mapOffset(N,!0)),o.redrawRange(T,N)}if(this.foldingEnabled&&a!==u&&this.annotationModel){var C=this.annotationModel,k=C.getAnnotations(v,m),L=[],A=[],O;while(k.hasNext()){O=k.next();if(O.type===e.AnnotationType.ANNOTATION_FOLDING){A.push(O);for(w=0;w<b.length;w++)if(O.start===b[w].start&&O.end===b[w].end)break;if(w===b.length)L.push(O),O.expand();else{var M=O.start,_=O.end;M>n&&(M-=s),_>n&&(_-=s);if(M<=n&&n<_&&M<=f&&f<_){var D=a.getLineAtOffset(O.start),P=a.getLineAtOffset(O.end);D!==P?O.expanded||(O.expand(),C.modifyAnnotation(O)):C.removeAnnotation(O)}}}}var H=[];for(w=0;w<b.length;w++){y=b[w];for(var B=0;B<A.length;B++)if(A[B].start===y.start&&A[B].end===y.end)break;B===A.length&&(O=this._createFoldingAnnotation(u,a,y.start,y.end),O&&H.push(O))}C.replaceAnnotations(L,H)}}},{TextStyler:B}}),define("orion/compare/compareHighlighter",["orion/Deferred","orion/editor/textMateStyler","orion/editor/htmlGrammar","examples/editor/textStyler"],function(e,t,n,r){function s(e){var t=e.split("."),n="js";return t.length>1&&(n=t[t.length-1]),n}var i={};return i.DefaultHighlighter=function(){function i(){this.styler=null}return i.prototype={highlight:function(i,o,u){this.styler&&(this.styler.destroy(),this.styler=null);var a=s(i);if(a){var f=u.getTextView(),l=u.getAnnotationModel();switch(a){case"js":case"java":case"css":this.styler=new r.TextStyler(f,a,l);break;case"html":this.styler=new t.TextMateStyler(f,new n.HtmlGrammar)}return(new e).resolve(u)}return null}},i}(),i}),define("orion/compare/builder/compare",["orion/commandRegistry","orion/Deferred","orion/compare/compareView","orion/compare/compareCommands","orion/compare/compareHighlighter"],function(e,t,n,r,i){function o(e){var t=e.split("."),n="js";return t.length>1&&(n=t[t.length-1]),n}function u(e){var t=o(e),n={id:"application/javascript"};switch(t){case"java":n.id="text/x-java-source";break;case"css":n.id="text/css"}return n}function a(e){var n=new t,r=new XMLHttpRequest;return r.open("GET",e,!0),r.onreadystatechange=function(){if(r.readyState===4){var e=typeof r.response!="undefined"?r.response:r.responseText,t=typeof e=="string"?e:null,i=r.status;200<=i&&i<400?n.resolve(t):n.reject(t)}},r.send(),n}function f(e,t,o,a){var f=e;!f.highlighters&&f.oldFile&&f.oldFile.Name&&f.newFile&&f.newFile.Name&&(f.highlighters=[new i.DefaultHighlighter,new i.DefaultHighlighter]),f.oldFile&&f.oldFile.Name&&(f.oldFile.Type=u(f.oldFile.Name)),f.newFile&&f.newFile.Name&&(f.newFile.Type=u(f.newFile.Name));if(t){var l=new r.CompareCommandFactory({commandService:s,commandSpanId:t});f.commandProvider=l}var c=o==="inline"?"inline":"twoWay";a?this.compareView=new n.toggleableCompareView(c,f):c==="inline"?this.compareView=new n.inlineCompareView(f):this.compareView=new n.TwoWayCompareView(f),this.compareView.startup()}var s=new e.CommandRegistry({});return f.prototype={getCompareView:function(){return this.compareView},refresh:function(){var e=this.getCompareView().getWidget().options;if(e.oldFile.URL&&e.newFile.URL){var n=[];n.push(a(e.oldFile.URL)),n.push(a(e.newFile.URL)),t.all(n,function(e){return{_error:e}}).then(function(e){this.getCompareView().getWidget().options.oldFile.Content=e[0],this.getCompareView().getWidget().options.newFile.Content=e[1],this.getCompareView().getWidget().refresh(!0)}.bind(this))}else this.getCompareView().getWidget().refresh(!0)}},f}),define(["orion/compare/builder/compare"],function(e){return e});