All Downloads are FREE. Search and download functionalities are using the official Maven repository.

toserve.orion.built-editor-amd.min.js Maven / Gradle / Ivy

Go to download

eniLINK is a web platform for linked data applications based on the KOMMA framework and Lift.

The newest version!
!function(){"use strict";function t(t,e,n,i,o,r){e[t]&&(n.push(t),(e[t]===!0||1===e[t])&&i.push(o+t+"/"+r))}function e(t,e,n,i,o){var r=i+e+"/"+o;require._fileExists(t.toUrl(r+".js"))&&n.push(r)}function n(t,e,i){var o;for(o in e)!e.hasOwnProperty(o)||t.hasOwnProperty(o)&&!i?"object"==typeof e[o]&&(!t[o]&&e[o]&&(t[o]={}),n(t[o],e[o],i)):t[o]=e[o]}var i=/(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/;define("i18n",["module"],function(o){var r=o.config?o.config():{};return r=r||{},{version:"2.0.4",load:function(o,s,a,l){l=l||{},l.locale&&(r.locale=l.locale);var h,d,c,u=i.exec(o),f=u[1],g=u[4],p=u[5],_=g.split("-"),v=[],m={},y="";if(u[5]?(f=u[1],h=f+p):(h=o,p=u[4],g=r.locale,g||(g=r.locale="undefined"==typeof navigator?"root":(navigator.language||navigator.userLanguage||"root").toLowerCase()),_=g.split("-")),l.isBuild){for(v.push(h),e(s,"root",v,f,p),d=0;d<_.length;d++)c=_[d],y+=(y?"-":"")+c,e(s,y,v,f,p);if(l.locales){var x,C;for(x=0;x-1&&o[t];t--)r=o[t],i=e[r],(i===!0||1===i)&&(i=s(f+r+"/"+p)),n(m,i);a(m)})})}}})}(),define("orion/editor/nls/messages",["module"],function(t){var e=t.config();return e&&e.root?e:{root:!0}}),define("orion/editor/nls/root/messages",{multipleAnnotations:"Multiple annotations:",line:"Line: ${0}",breakpoint:"Breakpoint",bookmark:"Bookmark",task:"Task",error:"Error",warning:"Warning",info:"Info",currentSearch:"Current Search",currentLine:"Current Line",matchingBracket:"Matching Bracket",currentBracket:"Current Bracket",diffAdded:"Diff Added Lines",diffDeleted:"Diff Deleted Lines",diffModified:"Diff Modified Lines",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",escape:"Escape",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)",findReplace:"Find/Replace",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: Enter or ESC to exit",linkedModeExited:"Linked Mode exited",syntaxError:"Syntax Error",contentAssist:"Content Assist",noProposals:"No proposals found",computingProposals:"Computing content assist proposals...",lineColumn:"Line ${0} : Column ${1}",lineColumnOffset:"Line ${0} : Column ${1} : Offset ${2}",multiSelections:"${0} selection regions",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",next:"Next",previous:"Previous",replace:"Replace",replaceAll:"Replace All",findWith:"Find With",replaceWith:"Replace With",caseInsensitive:"Aa",regex:"/.*/",wholeWord:"\\b",caseInsensitiveTooltip:"Toggle Case Insensitive",regexTooltip:"Toggle Regular Expression",wholeWordTooltip:"Toggle Whole Word",closeTooltip:"Close",replacingAll:"Replacing all...",replacedMatches:"Replaced ${0} matches",nothingReplaced:"Nothing replaced",notFound:"Not found"}),define("orion/editor/eventTarget",[],function(){function t(){}return t.addMixin=function(e){var n=t.prototype;for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])},t.prototype={addEventListener:function(t,e,n){this._eventTypes||(this._eventTypes={});var i=this._eventTypes[t];i||(i=this._eventTypes[t]={level:0,listeners:[]});var o=i.listeners;o.push({listener:e,useCapture:n})},dispatchEvent:function(t){var e=t.type;this._dispatchEvent("pre"+e,t),this._dispatchEvent(e,t),this._dispatchEvent("post"+e,t)},_dispatchEvent:function(t,e){var n=this._eventTypes?this._eventTypes[t]:null;if(n){var i=n.listeners;try{if(n.level++,i)for(var o=0,r=i.length;r>o;o++)if(i[o]){var s=i[o].listener;"function"==typeof s?s.call(this,e):s.handleEvent&&"function"==typeof s.handleEvent&&s.handleEvent(e)}}finally{if(n.level--,n.compact&&0===n.level){for(var a=i.length-1;a>=0;a--)i[a]||i.splice(a,1);0===i.length&&delete this._eventTypes[t],n.compact=!1}}}},isListening:function(t){return this._eventTypes?void 0!==this._eventTypes[t]:!1},removeEventListener:function(t,e,n){if(this._eventTypes){var i=this._eventTypes[t];if(i){for(var o=i.listeners,r=0,s=o.length;s>r;r++){var a=o[r];if(a&&a.listener===e&&a.useCapture===n){0!==i.level?(o[r]=null,i.compact=!0):o.splice(r,1);break}}0===o.length&&delete this._eventTypes[t]}}}},{EventTarget:t}}),define("orion/regex",[],function(){function t(t){return t.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&")}function e(t){var e=/^\s*\/(.+)\/([gim]{0,3})\s*$/.exec(t);return e?{pattern:e[1],flags:e[2]}:null}return{escape:t,parse:e}}),define("orion/util",[],function(){function t(t){var e=arguments;return t.replace(/\$\{([^\}]+)\}/g,function(t,n){return e[(n<<0)+1]})}function e(t,e){return t.createElementNS?t.createElementNS(x,e):t.createElement(e)}function n(t,e){e.addEventListener("keydown",function(e){9!==e.keyCode||e.shiftKey||(e.preventDefault(),t.focus())}),t.addEventListener("keydown",function(t){9===t.keyCode&&t.shiftKey&&(t.preventDefault(),e.focus())})}var i=navigator.userAgent,o=-1!==i.indexOf("MSIE")||-1!==i.indexOf("Trident")?document.documentMode:void 0,r=parseFloat(i.split("Firefox/")[1]||i.split("Minefield/")[1])||void 0,s=-1!==i.indexOf("Opera")?parseFloat(i.split("Version/")[1]):void 0,a=parseFloat(i.split("Chrome/")[1])||void 0,l=-1!==i.indexOf("Safari")&&!a,h=parseFloat(i.split("WebKit/")[1])||void 0,d=-1!==i.indexOf("Android"),c=-1!==i.indexOf("iPad"),u=-1!==i.indexOf("iPhone"),f=c||u,g=-1!==i.indexOf("Electron"),p=-1!==navigator.platform.indexOf("Mac"),_=-1!==navigator.platform.indexOf("Win"),v=-1!==navigator.platform.indexOf("Linux"),m="undefined"!=typeof document&&"ontouchstart"in document.createElement("input"),y=_?"\r\n":"\n",x="http://www.w3.org/1999/xhtml";return{formatMessage:t,createElement:e,confineDialogTab:n,isIE:o,isFirefox:r,isOpera:s,isChrome:a,isSafari:l,isWebkit:h,isAndroid:d,isIPad:c,isIPhone:u,isIOS:f,isElectron:g,isMac:p,isWindows:_,isLinux:v,isTouch:m,platformDelimiter:y}}),define("orion/editor/textModel",["orion/editor/eventTarget","orion/regex","orion/util"],function(t,e,n){function i(t,e){this._lastLineIndex=-1,this._text=[""],this._lineOffsets=[0],this.setText(t),this.setLineDelimiter(e)}return i.prototype={destroy:function(){},find:function(t){this._text.length>1&&(this._text=[this._text.join("")]);var n=t.string,i=t.regex,o=n,r="",s=t.caseInsensitive;if(o)if(i){var a=e.parse(o);a&&(o=a.pattern,r=a.flags)}else o=n.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&"),s&&(o=o.replace(/[iI\u0130\u0131]/g,"[Iiİı]"));var l,h=null;if(o){var d=t.reverse,c=t.wrap,u=t.wholeWord,f=t.start||0,g=t.end,p=null!==g&&void 0!==g;-1===r.indexOf("g")&&(r+="g"),-1===r.indexOf("m")&&(r+="m"),s&&-1===r.indexOf("i")&&(r+="i"),u&&(o="\\b"+o+"\\b");var _,v,m=this._text[0],y=0;if(p){var x=g>f?f:g,C=g>f?g:f;m=m.substring(x,C),y=x}var w=new RegExp(o,r);d?l=function(){var t=null;for(w.lastIndex=0;;){if(v=w.lastIndex,_=w.exec(m),v===w.lastIndex)return null;if(!_)break;if(_.index+y=0&&n>t))return null;var i=this._lineOffsets[t];if(n>t+1){var o=this.getText(i,this._lineOffsets[t+1]);if(e)return o;for(var r,s=o.length;10===(r=o.charCodeAt(s-1))||13===r;)s--;return o.substring(0,s)}return this.getText(i)},getLineAtOffset:function(t){var e=this.getCharCount();if(!(t>=0&&e>=t))return-1;var n=this.getLineCount();if(t===e)return n-1;var i,o,r=this._lastLineIndex;if(r>=0&&n>r&&(i=this._lineOffsets[r],o=n>r+1?this._lineOffsets[r+1]:e,t>=i&&o>t))return r;for(var s=n,a=-1;s-a>1;)if(r=Math.floor((s+a)/2),i=this._lineOffsets[r],o=n>r+1?this._lineOffsets[r+1]:e,i>=t)s=r;else{if(o>t){s=r;break}a=r}return this._lastLineIndex=s,s},getLineCount:function(){return this._lineOffsets.length},getLineDelimiter:function(){return this._lineDelimiter},getLineEnd:function(t,e){var n=this.getLineCount();if(!(t>=0&&n>t))return-1;if(n>t+1){var i=this._lineOffsets[t+1];if(e)return i;for(var o,r=this.getText(Math.max(this._lineOffsets[t],i-2),i),s=r.length;10===(o=r.charCodeAt(s-1))||13===o;)s--;return i-(r.length-s)}return this.getCharCount()},getLineStart:function(t){return t>=0&&t=t));)i+=n,o++;for(var r=i,s=o;o=e));)i+=n,o++;var a=i,l=o;if(s>=this._text.length||l>=this._text.length||s>l)return"";if(s===l)return this._text[s].substring(t-r,e-a);var h=this._text[s].substring(t-r),d=this._text[l].substring(0,e-a);return h+this._text.slice(s+1,l).join("")+d},onChanging:function(t){return this.dispatchEvent(t)},onChanged:function(t){return this.dispatchEvent(t)},setLineDelimiter:function(t,e){if("auto"===t&&(t=void 0,this.getLineCount()>1&&(t=this.getText(this.getLineEnd(0),this.getLineEnd(0,!0)))),this._lineDelimiter=t?t:n.platformDelimiter,e){var i=this.getLineCount();if(i>1){for(var o=new Array(i),r=0;i>r;r++)o[r]=this.getLine(r);this.setText(o.join(this._lineDelimiter))}}},setText:function(t,e,n){if(void 0===t&&(t=""),void 0===e&&(e=0),void 0===n&&(n=this.getCharCount()),e!==n||""!==t){for(var i=this.getLineAtOffset(e),o=this.getLineAtOffset(n),r=e,s=n-e,a=o-i,l=t.length,h=0,d=this.getLineCount(),c=0,u=0,f=0,g=[];;){if(-1!==c&&f>=c&&(c=t.indexOf("\r",f)),-1!==u&&f>=u&&(u=t.indexOf("\n",f)),-1===u&&-1===c)break;f=-1!==c&&-1!==u?c+1===u?u+1:(u>c?c:u)+1:-1!==c?c+1:u+1,g.push(e+f),h++}var p={type:"Changing",text:t,start:r,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:h};if(this.onChanging(p),0===g.length){var _,v=this.getLineStart(i);_=d>o+1?this.getLineStart(o+1):this.getCharCount(),e!==v&&(t=this.getText(v,e)+t,e=v),n!==_&&(t+=this.getText(n,_),n=_)}for(var m=l-s,y=i+a+1;d>y;y++)this._lineOffsets[y]+=m;var x,C=5e4,w=C;if(g.length=e));)L+=T,S++;for(var M=L,D=S;S=n));)L+=T,S++;var E=L,O=S,N=this._text[D],b=this._text[O],I=N.substring(0,e-M),k=b.substring(n-E),R=[D,O-D+1];I&&R.push(I),t&&R.push(t),k&&R.push(k),Array.prototype.splice.apply(this._text,R),0===this._text.length&&(this._text=[""]);var B={type:"Changed",start:r,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:h};this.onChanged(B)}}},t.EventTarget.addMixin(i.prototype),{TextModel:i}}),define("orion/keyBinding",["orion/util"],function(t){function e(t,e,n,i,o,r){this.type=r||"keydown",this.keyCode="string"==typeof t&&"keydown"===this.type?t.toUpperCase().charCodeAt(0):t,this.mod1=void 0!==e&&null!==e?e:!1,this.mod2=void 0!==n&&null!==n?n:!1,this.mod3=void 0!==i&&null!==i?i:!1,this.mod4=void 0!==o&&null!==o?o:!1}function n(t){this.keys=t}return e.prototype={getKeys:function(){return[this]},match:function(e,n){if(void 0!==n){if(0!==n)return!1}else if(e instanceof Array){if(e.length>1)return!1;e=e[0]}if(e.type!==this.type)return!1;if(this.keyCode===e.keyCode||this.keyCode===String.fromCharCode(t.isOpera?e.which:void 0!==e.charCode?e.charCode:e.keyCode)){var i=t.isMac?e.metaKey:e.ctrlKey;return this.mod1!==i?!1:"keydown"===this.type&&this.mod2!==e.shiftKey?!1:this.mod3!==e.altKey?!1:t.isMac&&this.mod4!==e.ctrlKey?!1:!0}return!1},equals:function(t){return t?this.keyCode!==t.keyCode?!1:this.mod1!==t.mod1?!1:this.mod2!==t.mod2?!1:this.mod3!==t.mod3?!1:this.mod4!==t.mod4?!1:this.type!==t.type?!1:!0:!1}},n.prototype={getKeys:function(){return this.keys.slice(0)},match:function(t,e){var n=this.keys;if(void 0!==e)return e>n.length?!1:n[e].match(t)?e===n.length-1?!0:e+1:!1;if(t instanceof Array||(t=[t]),t.length>n.length)return!1;var i;for(i=0;ii){var c=o(i);e=s+c*l,r(e)}else r(a),d.stop()}var e,n="number"==typeof this.options.duration?this.options.duration:350,i="number"==typeof this.options.rate?this.options.rate:20,o=this.options.easing||this.defaultEasing,r=this.options.onAnimate||function(){},s=this.options.curve[0],a=this.options.curve[1],l=a-s,h=-1,d=this;this.interval=this.options.window.setInterval(t,i)},t.prototype.stop=function(){this.options.window.clearInterval(this.interval);var t=this.options.onEnd||function(){};t()},t.prototype.defaultEasing=function(t){return Math.sin(t*(Math.PI/2))},t}();return{compare:n,contains:i,getNodeStyle:o,addEventListener:t,removeEventListener:e,Animation:r}}),define("orion/bidiUtils",["orion/util"],function(t){function e(){var t;window.dojoConfig&&(t=window.dojoConfig.locale),t||(t=navigator.languages?navigator.languages[0]:navigator.language||navigator.userLanguage);var e=t&&-1!=="ar iw he".indexOf(t.substring(0,2));if(e&&n()){var i=document.getElementsByTagName("html")[0];i&&i.setAttribute("dir","rtl")}}function n(){var t=localStorage.getItem(c);return t&&"true"===t?!0:!1}function i(){var t=localStorage.getItem(u);return!t||"rtl"!==t&&"ltr"!==t&&"auto"!==t?"ltr":t}function o(e){return _=i(),n()?"auto"===_&&t.isIE?s(e):_:""}function r(t){if(n()&&t.trim()){_=i();var e="auto"===_?s(t):_;return("ltr"===e?f:p)+t+g}return t}function s(t){var e=/[A-Za-z\u05d0-\u065f\u066a-\u06ef\u06fa-\u07ff\ufb1d-\ufdff\ufe70-\ufefc]/.exec(t);return e?e[0]<="z"?"ltr":"rtl":"ltr"}function a(t){if(!t._hasBidiEventListeners){t._hasBidiEventListeners=!0;for(var e=["keyup","cut","paste"],n=0;n0)for(var s=0;s0;)(!s.isIE||s.isIE>=9||s.isIE<9&&i[o].specified)&&e.removeAttribute(i[o].name)}if(t){t.styleClass&&(e.className=t.styleClass);var r=t.style;if(r)for(var a in r)r.hasOwnProperty(a)&&(e.style[a]=r[a]);var l=t.attributes;if(l)for(var h in l)l.hasOwnProperty(h)&&e.setAttribute(h,l[h])}}function u(t){return t instanceof Array?t.slice(0):t}function f(t,e){if(!t)return e;if(!e)return t;for(var n in e)e.hasOwnProperty(n)&&(t.hasOwnProperty(n)||(t[n]=e[n]));return t}function g(t,e,n){for(var i=0,o=0,r=0,s=t.length;s>r;){-1!==i&&r>=i&&(i=t.indexOf("\r",r)),-1!==o&&r>=o&&(o=t.indexOf("\n",r));var a,l=r;if(-1===o&&-1===i){e(t.substring(r));break}-1!==i&&-1!==o?i+1===o?(a=i,r=o+1):(a=o>i?i:o,r=(o>i?i:o)+1):-1!==i?(a=i,r=i+1):(a=o,r=o+1),e(t.substring(l,a)),n?n():r===s&&e("")}}function p(t){var e,n,i,o,r=h(t.ownerDocument);if(r.getComputedStyle){var s=r.getComputedStyle(t,null);e=s.getPropertyValue("border-left-width"),n=s.getPropertyValue("border-top-width"),i=s.getPropertyValue("border-right-width"),o=s.getPropertyValue("border-bottom-width")}else t.currentStyle&&(e=t.currentStyle.borderLeftWidth,n=t.currentStyle.borderTopWidth,i=t.currentStyle.borderRightWidth,o=t.currentStyle.borderBottomWidth);return{left:parseInt(e,10)||0,top:parseInt(n,10)||0,right:parseInt(i,10)||0,bottom:parseInt(o,10)||0}}function _(t){var e,n,i,o,r=h(t.ownerDocument);if(r.getComputedStyle){var s=r.getComputedStyle(t,null);e=s.getPropertyValue("padding-left"),n=s.getPropertyValue("padding-top"),i=s.getPropertyValue("padding-right"),o=s.getPropertyValue("padding-bottom")}else t.currentStyle&&(e=t.currentStyle.paddingLeft,n=t.currentStyle.paddingTop,i=t.currentStyle.paddingRight,o=t.currentStyle.paddingBottom);return{left:parseInt(e,10)||0,top:parseInt(n,10)||0,right:parseInt(i,10)||0,bottom:parseInt(o,10)||0}}function v(t){var e=t._trim;if(!e){e=_(t);var n=p(t);e.left+=n.left,e.top+=n.top,e.right+=n.right,e.bottom+=n.bottom,t._trim=e}return e}function m(t,e,n,i){function o(e){if(e.animationName===a){var n=e.target;"function"==typeof n.__DOMReady&&h(t).setTimeout(function(){n.__DOMReady()},0)}}function r(t,e){for(var n=["","-webkit-","-moz-","-ms-","-o-"],i="",o="body ."+t+" {\n",r=0;rn;n++){var i=t._createSelectionDiv();e.appendChild(i),this._divs.push(i)}}function C(t){this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom}function w(t,e,n){this.view=t,this.lineIndex=e,this._lineDiv=n}function A(t){this._init(t||{})}var T=r.addEventListener,L=r.removeEventListener,S=r.compare,M=r.Animation;return y.compare=function(t,e){if(t.length!==e.length)return!1;for(var n=0;n=0;n--)if(t[n]._editing)return t[n];return t[t.length-1]}for(n=0;n=n.end||n._editing||t[i]._editing?(e.push(n),n=t[i]):n.end=Math.max(n.end,t[i].end);return e.push(n),e},y.prototype={clone:function(){var t=new y(this.start,this.end,this.caret);return t._columnX=this._columnX,t._editing=this._editing,t._docX=this._docX,t},contains:function(t){return this.start<=t&&tthis.end){var e=this.start;this.start=this.end,this.end=e,this.caret=!this.caret}},setCaret:function(t){this.start=t,this.end=t,this.caret=!1},getCaret:function(){return this.caret?this.start:this.end},getAnchor:function(){return this.caret?this.end:this.start},getOrientedSelection:function(){return{start:this.getAnchor(),end:this.getCaret()}},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(t){return this.caret===t.caret&&this.start===t.start&&this.end===t.end&&this._editing===t._editing}},x.prototype={destroy:function(){this._divs&&(this._divs.forEach(function(t){t.parentNode.removeChild(t)}),this._divs=null)},setPrimary:function(t){this.primary=t},update:function(){var t,e=this._view,n=this.primary,i=e._hasFocus,o=e._cursorVisible,r=!this.primary&&this._selection&&this._selection.isEmpty();t=r?"textviewSelectionCaret":i?"textviewSelection":"textviewSelectionUnfocused",this._divs[0].style.visibility=r&&o&&i||!r?"visible":"hidden",this._divs[0].style.zIndex=o&&r?"2":"0",this._divs.forEach(function(e){e.className=t,s.isWebkit<537.36&&n&&(e.style.background=i?"transparent":"")})},setSelection:function(t){this._selection=t,this.update();var e=this._view,n=e._model,i=n.getLineAtOffset(t.start),o=n.getLineAtOffset(t.end),r=e._getLineNext();if(r){var s,a,l,h,d=e._getLinePrevious();id.lineIndex?(s=d,l=n.getLineStart(d.lineIndex)):(s=e._getLineNode(i),l=t.start),od.lineIndex?(a=d,h=n.getLineStart(d.lineIndex)):(a=e._getLineNode(o),h=t.end),this._setDOMSelection(s,l,a,h,t.caret)}},_setDOMSelection:function(t,e,n,i,o){if(this._setDOMFullSelection(t,e,n,i),this.primary){var r=this._view,a=t._line.getNodeOffset(e),l=n._line.getNodeOffset(i);if(a.node&&l.node){var h,d=r._getWindow(),c=r._parent.ownerDocument;if(d.getSelection){var u=d.getSelection();if(h=c.createRange(),h.setStart(a.node,a.offset),h.setEnd(l.node,l.offset),!r._hasFocus||u.anchorNode===a.node&&u.anchorOffset===a.offset&&u.focusNode===l.node&&u.focusOffset===l.offset&&u.anchorNode===l.node&&u.anchorOffset===l.offset&&u.focusNode===a.node&&u.focusOffset===a.offset||(r._anchorNode=a.node,r._anchorOffset=a.offset,r._focusNode=l.node,r._focusOffset=l.offset,r._ignoreSelect=!1,u.rangeCount>0&&u.removeAllRanges(),u.addRange(h),r._ignoreSelect=!0),r._cursorDiv){h=c.createRange(),o?(h.setStart(a.node,a.offset),h.setEnd(a.node,a.offset)):(h.setStart(l.node,l.offset),h.setEnd(l.node,l.offset));var f=h.getClientRects()[0],g=r._cursorDiv.parentNode,p=g.getBoundingClientRect();f&&p&&(r._cursorDiv.style.top=f.top-p.top+g.scrollTop+"px",r._cursorDiv.style.left=f.left-p.left+g.scrollLeft+"px")}}else if(c.selection){if(!r._hasFocus)return;var _=c.body,v=s.createElement(c,"div");_.appendChild(v),_.removeChild(v),h=_.createTextRange(),h.moveToElementText(a.node.parentNode),h.moveStart("character",a.offset);var m=_.createTextRange();m.moveToElementText(l.node.parentNode),m.moveStart("character",l.offset),h.setEndPoint("EndToStart",m),r._ignoreSelect=!1,h.select(),r._ignoreSelect=!0}}}},_setDOMFullSelection:function(t,e,n,i){this._divs.forEach(function(t){t.style.width=t.style.height="0px"});var o=this._view;if(o._fullSelection&&!(s.isIOS||t===n&&e===i&&this.primary)){var r=o._getViewPadding(),a=o._clientDiv.getBoundingClientRect(),l=o._viewDiv.getBoundingClientRect(),h=l.left+r.left,d=a.right,c=l.top+r.top,u=a.bottom,f=0,g=0;if(o._clipDiv){var p=o._clipDiv.getBoundingClientRect();f=p.left-o._clipDiv.scrollLeft,g=p.top}else{var _=o._rootDiv.getBoundingClientRect();f=_.left,g=_.top}o._ignoreDOMSelection=!0;var v,m,y=new w(o,t.lineIndex,t),x=y.getBoundingClientRect(e,!1),C=x.left;t===n&&e===i?(v=y,m=x):(v=new w(o,n.lineIndex,n),m=v.getBoundingClientRect(i,!1));var A=m.left;o._ignoreDOMSelection=!1;var T=this._divs[0],L=Math.min(d,Math.max(h,C)),S=Math.min(u,Math.max(c,x.top)),M=d,D=Math.min(u,Math.max(c,x.bottom));if(T.style.left=L-f+"px",T.style.top=S-g+"px",T.style.width=Math.max(0,M-L)+"px",T.style.height=Math.max(0,D-S)+"px",t.lineIndex===n.lineIndex)M=Math.min(A,d),T.style.width=Math.max(this.primary?0:1,M-L)+"px";else{var E=h,O=Math.min(u,Math.max(c,m.top)),N=Math.min(d,Math.max(h,A)),b=Math.min(u,Math.max(c,m.bottom)),I=this._divs[2];if(I.style.left=E-f+"px",I.style.top=O-g+"px",I.style.width=Math.max(0,N-E)+"px",I.style.height=Math.max(0,b-O)+"px",Math.abs(t.lineIndex-n.lineIndex)>1){var k=this._divs[1];k.style.left=h-f+"px",k.style.top=D-g+"px",k.style.width=Math.max(0,d-h)+"px",k.style.height=Math.max(0,O-D)+"px"}}}}},C.prototype={toString:function(){return"{l="+this.left+", t="+this.top+", r="+this.right+", b="+this.bottom+"}"}},w.prototype={create:function(t,e){if(!this._lineDiv){var n=this._lineDiv=this._createLine(t,e,this.lineIndex);return n._line=this,n}},_createLine:function(t,e,n){var i=this.view,o=i._model,r=o.getLine(n),a=o.getLineStart(n),l={type:"LineStyle",textView:i,lineIndex:n,lineText:r,lineStart:a};i.onLineStyle(l);var h=t.ownerDocument,d=e||s.createElement(h,"div");if(e&&S(e.viewStyle,l.style)||(c(l.style,d,e),e&&(e._trim=null),d.viewStyle=l.style),d.lineIndex=n,e&&d.viewLineText===r&&S(l.ranges,d.viewRanges))return d;d.viewRanges=l.ranges,d.viewLineText=r;var u=[],f={tabOffset:0,ranges:u};this._createRanges(l.ranges,r,0,r.length,a,f);var g=" ";!i._fullSelection&&s.isIE<9&&(g="");var p={text:g,style:i._metrics.largestFontStyle,ignoreChars:1};0!==u.length&&u[u.length-1].style&&"div"===u[u.length-1].style.tagName?u.splice(u.length-1,0,p):u.push(p);var _,v,m,y,x,C,w,A,T=0,L=0;if(s.isFirefox&&r.length>2e3){e&&(d.innerHTML="",e.lineWidth=void 0);var M=h.createDocumentFragment();for(A=0;A=E&&(N-=D);var b=m.firstChild.data,I=b?b.length:0;if(L+I>N)break;L+=I}w=m.nextSibling,d.removeChild(m),m=w}}_=this._createSpan(d,x,v,p.ignoreChars),m?d.insertBefore(_,m):d.appendChild(_),e&&(e.lineWidth=void 0)}if(e)for(var k=_?_.nextSibling:null;k;)w=k.nextSibling,e.removeChild(k),k=w}return d.parentNode||t.appendChild(d),d},_createRanges:function(t,e,n,i,o,r){if(!(n>i)){if(t)for(var s=0;si)break;var h=Math.min(o+i,a.end)-o;if(h>=l){if(l=Math.max(n,l),h=Math.min(i,h),l>n&&this._createRange(e,n,l,null,r),!a.style||!a.style.unmergeable)for(;s+1n&&this._createRange(e,n,i,null,r)}},_createRange:function(t,e,n,i,o){if(!(e>n)){var r,s=this.view._customTabSize,l={tagName:"span",bidi:!0,style:{unicodeBidi:"embed",direction:"ltr"}},h={text:"‎",style:l};if(s&&8!==s)for(var d=t.indexOf("	",e);-1!==d&&n>d;){d>e&&(r={text:t.substring(e,d),style:i},r=a.enforceTextDir(r),o.ranges.push(r),a.isBidiEnabled()&&o.ranges.push(h),o.tabOffset+=r.text.length);var c=s-o.tabOffset%s;if(c>0){for(var u=" ",f=1;c>f;f++)u+=" ";r={text:u,style:i,ignoreChars:c-1},o.ranges.push(r),a.isBidiEnabled()&&o.ranges.push(h),o.tabOffset+=r.text.length}if(e=d+1,e===n)return;d=t.indexOf("	",e)}n>=e&&(r={text:t.substring(e,n),style:i},r=a.enforceTextDir(r),o.ranges.push(r),a.isBidiEnabled()&&o.ranges.push(h),o.tabOffset+=r.text.length)}},_createSpan:function(t,e,n,i){var o=this.view,r="span";n&&n.tagName&&(r=n.tagName.toLowerCase());var a="a"===r;a&&(this.hasLink=!0),a&&!o._linksVisible&&(r="span");var l=t.ownerDocument,h=s.createElement(t.ownerDocument,r);if(h.appendChild(l.createTextNode(n&&n.text?n.text:e)),n&&n.html?(h.innerHTML=n.html,h.ignore=!0):n&&n.node?(h.appendChild(n.node),h.ignore=!0):n&&n.bidi&&(h.ignore=!0),c(n,h),"a"===r){var d=o._getWindow();T(h,"click",function(t){return o._handleLinkClick(t?t:d.event)},!1)}return h.viewStyle=n,i&&(h.ignoreChars=i),h},_ensureCreated:function(){return this._lineDiv?this._lineDiv:this._createdDiv=this.create(this.view._clientDiv,null)},getBoundingClientRect:function(t,e){var n=this._ensureCreated(),i=this.view;if(void 0===t)return this._getLineBoundingClientRect(n,!0);var o=i._model,r=n.ownerDocument,a=this.lineIndex,l=null;if(tt){var c,u=t-d;if(1===o.length)l=new C(e.getBoundingClientRect());else if(i._isRangeRects)c=r.createRange(),c.setStart(o,u),c.setEnd(o,u+1),l=new C(c.getBoundingClientRect());else if(s.isIE){c=r.body.createTextRange(),c.moveToElementText(e),c.collapse();var f=0===u&&8===s.isIE;f&&(u=1),c.moveEnd("character",u+1),c.moveStart("character",u),l=new C(c.getBoundingClientRect()),f&&(l.left=e.getClientRects()[0].left)}else{var g=o.data;e.removeChild(o),e.appendChild(r.createTextNode(g.substring(0,u)));var p=s.createElement(r,"span");if(p.appendChild(r.createTextNode(g.substring(u,u+1))),e.appendChild(p),e.appendChild(r.createTextNode(g.substring(u+1))),l=new C(p.getBoundingClientRect()),e.innerHTML="",e.appendChild(o),!this._createdDiv){var _=i._getSelections()[0];(d<=_.start&&_.starts.right&&(s.right=a.right),a.bottom>s.bottom&&(s.bottom=a.bottom))}}return!0}),void 0!==t?n[t]:n},_getLineBoundingClientRect:function(t,e){var n=new C(t.getBoundingClientRect());if(this.view._wrapMode);else{n.right=n.left;for(var i=t.lastChild;i&&i.ignoreChars===i.firstChild.length;)i=i.previousSibling;if(i){var o=i.getBoundingClientRect();n.right=o.right+v(t).right}}if(e){var r=v(t);n.left=n.left+r.left,n.right=n.right-r.right}return n},getLineCount:function(){return this.view._wrapMode?this.getClientRects().length:1},getLineIndex:function(t){if(!this.view._wrapMode)return 0;for(var e=this.getClientRects(),n=this.getBoundingClientRect(t),i=n.top+(n.bottom-n.top)/2,o=0;os||i+r>=a?(e=o,n=s-i,t.ignoreChars&&r>0&&n===r&&(n+=t.ignoreChars),!1):(i+=r,!0)}),{node:e,offset:n}},getText:function(t){var e="",n=0;return this.forEach(function(i){var o;if(i.ignoreChars){o=i.lastChild;for(var r=0,s=[],a=-1;o;){var l=o.data;if(l)for(var h=l.length-1;h>=0;h--){var d=l.substring(h,h+1);r1;){var b=Math.floor((O+N)/2);y=N+1,x=b===T-1&&n.ignoreChars?A.length:b+1,C=0===y&&8===s.isIE,o._isRangeRects?(m.setStart(A,y),m.setEnd(A,x)):(C&&(y=1),m.moveToElementText(n),m.move("character",y),m.moveEnd("character",x-y)),w=m.getClientRects();for(var I=!1,k=0;k=c&&_>t&&(!o._wrapMode||e>=u&&v>=e)){I=!0;break}I?O=b:N=b}i+=O,y=O,x=O===T-1&&n.ignoreChars?A.length:Math.min(O+1,A.length),o._isRangeRects?(m.setStart(A,y),m.setEnd(A,x)):(m.moveToElementText(n),m.move("character",y),m.moveEnd("character",x-y)),w=m.getClientRects();var R=!1;w.length>0&&(d=w[0],c=(C?E:d.left)*M-g.left,_=d.right*M-g.left,R=t>c+(_-c)/2);var B=i-l,P=r.getLine(a),V=P.charCodeAt(B);V>=55296&&56319>=V&&R?B=56320&&57343>=V&&(i+=1)):V>=56320&&57343>=V&&!R&&B>0&&(V=P.charCodeAt(B-1),V>=55296&&56319>=V&&(i-=1)),R&&i++}else{for(var F=[],W=0;T>W;W++)F.push(""),F.push(W===T-1?A.data.substring(W):A.data.substring(W,W+1)),F.push("");n.innerHTML=F.join("");for(var H=n.firstChild;H;){if(d=H.getBoundingClientRect(),c=d.left-g.left,_=d.right-g.left,t>=c&&_>t){t>c+(_-c)/2&&i++;break}i++,H=H.nextSibling}if(!p._createdDiv){n.innerHTML="",n.appendChild(A);var U=o._getSelections()[0];(i<=U.start&&U.startu.right&&(t=u.right-1)}else 0>t&&(t=0),t>g.right-g.left&&(t=g.right-g.left);var v,m;if(this._lastHitChild&&this._lastHitChild.parentNode){if(v=this._lastHitOffset,m=this._lastHitChild,u=i(m),!u)for(var y=v,x=v+this._nodeLength(m),C=m.previousSibling,w=m.nextSibling;C||w;){if(C){if(y-=this._nodeLength(C),u=i(C)){m=C,v=y;break}C=C.previousSibling}if(w){if(u=i(w)){m=w,v=x;break}x+=this._nodeLength(w),w=w.nextSibling}}}else v=l,this.forEach(function(t){return m=t,(u=i(m))?!1:(v+=this._nodeLength(m),!0)});return m&&u&&(this._lastHitChild=m,this._lastHitOffset=v,v=n(m,v,u)),Math.min(d,Math.max(l,v))},getNextOffset:function(t,e){if("line"===e.unit){var n=this.view,i=n._model,o=i.getLineAtOffset(t);return e.count>0?(e.count--,i.getLineEnd(o)):(e.count++,i.getLineStart(o))}return"wordend"===e.unit||"wordWS"===e.unit||"wordendWS"===e.unit?this._getNextOffset_W3C(t,e):s.isIE?this._getNextOffset_IE(t,e):this._getNextOffset_W3C(t,e)},_getNextOffset_W3C:function(t,e){function n(t){return t>=33&&47>=t||t>=58&&64>=t||t>=91&&94>=t||96===t||t>=123&&126>=t}function i(t){return 32===t||9===t}var o,r=this.view,s=r._model,a=s.getLineAtOffset(t),l=s.getLine(a),h=s.getLineStart(a),d=s.getLineEnd(a),c=l.length,u=t-h,f=e.count<0?-1:1;if("word"===e.unit||"wordend"===e.unit||"wordWS"===e.unit||"wordendWS"===e.unit)for(var g,p,_,v;0!==e.count;){if(e.count>0){if(u===c)return d;for(o=l.charCodeAt(u),g=n(o),p=!g&&!i(o),u++;c>u;){if(o=l.charCodeAt(u),"wordWS"!==e.unit&&"wordendWS"!==e.unit){if(_=n(o),"wordend"===e.unit){if(!_&&g)break}else if(_&&!g)break;v=!_&&!i(o)}else v=!i(o);if("wordend"===e.unit||"wordendWS"===e.unit){if(!v&&p)break}else if(v&&!p)break;p=v,g=_,u++}}else{if(0===u)return h;for(u--,o=l.charCodeAt(u),g=n(o),p=!g&&!i(o);u>0;){if(o=l.charCodeAt(u-1),"wordWS"!==e.unit&&"wordendWS"!==e.unit){if(_=n(o),"wordend"===e.unit){if(_&&!g)break}else if(!_&&g)break;v=!_&&!i(o)}else v=!i(o);if("wordend"===e.unit||"wordendWS"===e.unit){if(v&&!p)break}else if(!v&&p)break;p=v,g=_,u--}}e.count-=f}else for(;0!==e.count&&u+f>=0&&c>=u+f;){if(u+=f,o=l.charCodeAt(u),u>0)if(o>=57339&&57343>=o){if(o=l.charCodeAt(u-1),55356===o){u+=f;continue}}else{if(o>=65024&&65039>=o)continue;o>=56320&&57343>=o&&(o=l.charCodeAt(u-1),o>=55296&&56319>=o&&(u+=f))}e.count-=f}return h+u},_getNextOffset_IE:function(t,e){var n,i,o,r=this._ensureCreated(),s=this.view,a=s._model,l=this.lineIndex,h=0,d=a.getLineStart(l),c=a.getLine(l),u=a.getLineStart(l),f=r.ownerDocument,g=e.count<0?-1:1;if(t===a.getLineEnd(l)){for(o=r.lastChild;o&&o.ignoreChars===o.firstChild.length;)o=o.previousSibling;if(!o)return d;n=f.body.createTextRange(),n.moveToElementText(o),i=n.text.length,n.moveEnd(e.unit,g),h=t+n.text.length-i}else if(t===d&&e.count<0)h=d;else for(o=r.firstChild;o;){var p=this._nodeLength(o);if(d+p>t){if(n=f.body.createTextRange(),t===d&&e.count<0){for(var _=o.previousSibling;_&&(!_.firstChild||!_.firstChild.length);)_=_.previousSibling;n.moveToElementText(_?_:o.previousSibling)}else n.moveToElementText(o),n.collapse(),n.moveEnd("character",t-d);i=n.text.length,n.moveEnd(e.unit,g),h=t+n.text.length-i;break}d=p+d,o=o.nextSibling}var v=h-u,m=c.charCodeAt(v);return m>=56320&&57343>=m&&v>0&&(m=c.charCodeAt(v-1),m>=55296&&56319>=m&&(v+=g)),h=v+u,e.count-=g,h},updateLinks:function(){var t=this._ensureCreated();if(this.hasLink){var e=this;this.forEach(function(n){var i=n.viewStyle;return i&&i.tagName&&"a"===i.tagName.toLowerCase()&&t.replaceChild(e._createSpan(t,n.firstChild.data,i),n),!0})}},destroy:function(){var t=this._createdDiv;t&&(t.parentNode.removeChild(t),this._createdDiv=null)}},A.prototype={addKeyMode:function(t,e){var n=this._keyModes;void 0!==e?n.splice(e,0,t):n.push(t),t._modeAdded&&t._modeAdded()},addRuler:function(t,e){var n=this._rulers;if(void 0!==e){var i,o;for(i=0,o=0;io;i++)t.getLocation()===n[i].getLocation()&&o++;n.splice(o,0,t),e=o}else n.push(t);this._createRuler(t,e),t.setView(this),this._update()},computeSize:function(){var t=0,e=0,n=this._model,i=this._clientDiv;if(!i)return{width:t,height:e};var o=i.style.width;s.isWebkit&&(i.style.width="0x7fffffffpx");for(var r=n.getLineCount(),a=0;r>a;a++){var l=this._getLine(a),h=l.getBoundingClientRect();t=Math.max(t,h.right-h.left),e+=h.bottom-h.top,l.destroy()}s.isWebkit&&(i.style.width=o);var d=this._getViewPadding();return t+=d.right+d.left+this._metrics.scrollWidth,e+=d.bottom+d.top+this._metrics.scrollWidth,{width:t,height:e}},convert:function(t,e,n){if(!this._clientDiv)return t;var i=this._getScroll(),o=this._getViewPadding(),r=this._viewDiv.getBoundingClientRect();return"document"===e&&(void 0!==t.x&&(t.x+=-i.x+r.left+o.left),void 0!==t.y&&(t.y+=-i.y+r.top+o.top)),"document"===n&&(void 0!==t.x&&(t.x+=i.x-r.left-o.left),void 0!==t.y&&(t.y+=i.y-r.top-o.top)),t},copy:function(){return this._clientDiv?this._doCopy():!1},cut:function(){return this._clientDiv?this._doCut():!1},destroy:function(){for(var t=0;tn)return!1;var i=this._getLine(n),o=this.getOffsetAtLocation(t,e),r=i.getBoundingClientRect(o);return i.destroy(),t>r.right?!1:!0},getLinePixel:function(t){return this._clientDiv?this._getLinePixel(t):0},getLocationAtOffset:function(t){if(!this._clientDiv)return{x:0,y:0};var e=this._model;t=Math.min(Math.max(0,t),e.getCharCount());var n=e.getLineAtOffset(t),i=this._getLine(n),o=i.getBoundingClientRect(t);i.destroy();var r=o.left,s=this._getLinePixel(n)+o.top;return{x:r,y:s}},getNextOffset:function(t,e){var n=new y(t,t,!1);return this._doMove(e,n),n.getCaret()},getOptions:function(){var t;if(0===arguments.length)t=this._defaultOptions();else if(1===arguments.length){var e=arguments[0];if("string"==typeof e)return u(this["_"+e]);t=e}else{t={};for(var n in arguments)arguments.hasOwnProperty(n)&&(t[arguments[n]]=void 0)}for(var i in t)t.hasOwnProperty(i)&&(t[i]=u(this["_"+i]));return t},getModel:function(){return this._model},getOffsetAtLocation:function(t,e){if(!this._clientDiv)return 0;var n=this._getLineIndex(e),i=this._getLine(n),o=i.getOffset(t,e-this._getLinePixel(n));return i.destroy(),o},getLineAtOffset:function(t){return this.getModel().getLineAtOffset(t)},getLineStart:function(t){return this.getModel().getLineStart(t)},getRulers:function(){return this._rulers.slice(0)},getSelection:function(){return this._getSelection()},getSelections:function(){return this._getSelections()},getSelectionText:function(t){var e=[],n=this,i=this._getSelections();return i.forEach(function(t){t.isEmpty()||e.push(n._getBaseText(t.start,t.end))}),e.join(void 0!==t?t:this._model.getLineDelimiter())},getText:function(t,e){var n=this._model;return n.getText(t,e)},getTopIndex:function(t){return this._clientDiv?this._getTopIndex(t):0},getTopPixel:function(){return this._clientDiv?this._getScroll().y:0},invokeAction:function(t,e,n){if(this._clientDiv){var i=this._actions[t];if(i){if(i.actionDescription&&i.actionDescription.id&&l.logEvent("editor","action",i.actionDescription.id),!e&&i.handler&&i.handler(n))return!0;if(i.defaultHandler)return"boolean"==typeof i.defaultHandler(n)}return!1}},isDestroyed:function(){return!this._clientDiv},onContextMenu:function(t){return this.dispatchEvent(t)},onDragStart:function(t){return this.dispatchEvent(t)},onDrag:function(t){return this.dispatchEvent(t)},onDragEnd:function(t){return this.dispatchEvent(t)},onDragEnter:function(t){return this.dispatchEvent(t)},onDragOver:function(t){return this.dispatchEvent(t)},onDragLeave:function(t){return this.dispatchEvent(t)},onDrop:function(t){return this.dispatchEvent(t)},onDestroy:function(t){return this.dispatchEvent(t)},onSaving:function(t){return this.dispatchEvent(t)},onInputChanged:function(t){return this.dispatchEvent(t)},onLineStyle:function(t){return this.dispatchEvent(t)},onKeyDown:function(t){return this.dispatchEvent(t)},onKeyPress:function(t){return this.dispatchEvent(t)},onKeyUp:function(t){return this.dispatchEvent(t)},onModelChanged:function(t){return this.dispatchEvent(t)},onModelChanging:function(t){return this.dispatchEvent(t)},onModify:function(t){return this.dispatchEvent(t)},onMouseDown:function(t){return this.dispatchEvent(t)},onMouseUp:function(t){return this.dispatchEvent(t)},onMouseMove:function(t){return this.dispatchEvent(t)},onMouseOver:function(t){return this.dispatchEvent(t)},onMouseOut:function(t){return this.dispatchEvent(t)},onTouchStart:function(t){return this.dispatchEvent(t)},onTouchMove:function(t){return this.dispatchEvent(t)},onTouchEnd:function(t){return this.dispatchEvent(t)},onOptions:function(t){return this.dispatchEvent(t)},onSelection:function(t){return this.dispatchEvent(t)},onScroll:function(t){return this.dispatchEvent(t)},onVerify:function(t){return this.dispatchEvent(t)},onFocus:function(t){return this.dispatchEvent(t)},onBlur:function(t){return this.dispatchEvent(t)},paste:function(){return this._clientDiv?this._doPaste():!1},redraw:function(){if(!(this._redrawCount>0)){var t=this._model.getLineCount();this.redrawRulers(0,t),this.redrawLines(0,t)}},redrawRulers:function(t,e){if(!(this._redrawCount>0))for(var n=this.getRulers(),i=0;i0)&&(void 0===t&&(t=0),void 0===e&&(e=this._model.getLineCount()),t!==e)){var i=this._clientDiv;if(i){if(n){var o=this._getRulerParent(n);for(i=o.firstChild;i&&i._ruler!==n;)i=i.nextSibling}n?i.rulerChanged=!0:this._lineHeight&&this._resetLineHeight(t,e);var r=-1;if(n||-1===this._imeOffset||(r=this._model.getLineAtOffset(this._imeOffset)),!n||"page"===n.getOverview())for(var s=i.firstChild;s;){var a=s.lineIndex;
a>=t&&e>a&&a!==r&&(s.lineChanged=!0),s=s.nextSibling}n||this._wrapMode||t<=this._maxLineIndex&&this._maxLineIndex0)){var n=this._model;void 0===t&&(t=0),void 0===e&&(e=n.getCharCount());var i=n.getLineAtOffset(t),o=n.getLineAtOffset(Math.max(t,e-1))+1;this.redrawLines(i,o)}},removeKeyMode:function(t){for(var e=this._keyModes,n=0;ne;if(o){var r=t;t=e,e=r}var s=this._model.getCharCount();t=Math.max(0,Math.min(t,s)),e=Math.max(0,Math.min(e,s));var a=new y(t,e,o);this._setSelection(a,void 0===n||n,!0,i)},setSelections:function(t,e,n){var i=this._rangesToSelections(t);this._setSelection(i,void 0===e||e,!0,n)},setText:function(t,e,n,i,o){var r,a="string"==typeof t,l=void 0===e&&void 0===n&&a;a?(void 0===e&&(e=0),void 0===n&&(n=this._model.getCharCount()),r={text:t,selection:[new y(e,n,!1)]}):(r=t,r.selection=this._rangesToSelections(r.selection)),r._code=!0,l&&(this._variableLineHeight=!1),this._modifyContent(r,!l,void 0===i||i,o),l&&s.isFirefox<13&&this._fixCaret()},setTopIndex:function(t,e){this._clientDiv&&this._scrollViewAnimated(0,this._getLinePixel(Math.max(0,t))-this._getScroll().y,e)},setTopPixel:function(t,e){this._clientDiv&&this._scrollViewAnimated(0,Math.max(0,t)-this._getScroll().y,e)},showSelection:function(t,e){return this._showCaret(t?!1:!0,e,t)},update:function(t,e){this._clientDiv&&((t||this._metrics.invalid)&&this._updateStyle(),void 0===e||e?this._update():this._queueUpdate())},_handleRootMouseDown:function(t){if(this._cancelCheckSelection(),!this._ignoreEvent(t)){s.isFirefox<13&&1===t.which&&(this._clientDiv.contentEditable=!1,(this._overlayDiv||this._clientDiv).draggable=!0,this._ignoreBlur=!0);var e=this._overlayDiv||this._clientDiv;s.isIE<9&&(e=this._viewDiv);for(var n=t.target?t.target:t.srcElement;n;){if(e===n)return;if(n.className&&-1!==n.className.indexOf("textViewFind"))return;n=n.parentNode}if(t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),!this._isW3CEvents){var i=this,o=this._getWindow();o.setTimeout(function(){i._clientDiv.focus()},0)}}},_handleRootMouseUp:function(t){this._ignoreEvent(t)||(s.isFirefox<13&&1===t.which&&(this._clientDiv.contentEditable=!0,(this._overlayDiv||this._clientDiv).draggable=!1),s.isFirefox&&1===t.which&&(this._fixCaret(),this._ignoreBlur=!1))},_handleBlur:function(){if(this._cancelCheckSelection(),!this._ignoreBlur){if(this._commitIME(),this._hasFocus=!1,s.isIE<9&&!this._getSelections()[0].isEmpty()){var t=this._rootDiv,e=s.createElement(t.ownerDocument,"div");t.appendChild(e),t.removeChild(e)}if(this._cursorDiv&&(this._cursorDiv.style.display="none"),this._domSelection){this._domSelection.forEach(function(t){t.update()});var n,i=this._getWindow(),o=this._parent.ownerDocument;if(i.getSelection){var r=i.getSelection();for(n=r.anchorNode;n;){if(n===this._clientDiv){r.rangeCount>0&&r.removeAllRanges();break}n=n.parentNode}}else if(o.selection){for(this._ignoreSelect=!1,n=o.selection.createRange().parentElement();n;){if(n===this._clientDiv){o.selection.empty();break}n=n.parentNode}this._ignoreSelect=!0}}this._ignoreFocus||this.onBlur({type:"Blur"})}},_handleCompositionStart:function(t){if(!this._ignoreEvent(t)){if(this._imeTimeout){var e=this._getWindow();e.clearTimeout(this._imeTimeout),this._imeTimeout=null}this._imeText&&(this._commitIME(this._imeText),this._imeText=null),this._startIME(),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)}},_handleCompositionUpdate:function(t){this._ignoreEvent(t)||(this._imeText=t.data)},_handleCompositionEnd:function(t){if(!this._ignoreEvent(t)){this._imeText=t.data;var e=this._getWindow();this._imeTimeout=e.setTimeout(function(){this._commitIME(this._imeText),this._imeText=this._imeTimeout=null}.bind(this),0)}},_handleContextMenu:function(t){if(!this._ignoreEvent(t)){s.isIE&&3===this._lastMouseButton&&this._updateDOMSelection();var e=!1;if(this.isListening("ContextMenu")){var n=this._createMouseEvent("ContextMenu",t);n.screenX=t.screenX,n.screenY=t.screenY,this.onContextMenu(n),e=n.defaultPrevented}else s.isMac&&s.isFirefox&&0===t.button&&(e=!0);return e?(t.preventDefault&&t.preventDefault(),!1):(this._contextMenuOpen=!0,void(s.isFirefox&&(this._checkSelectionChange=!0,this._pollSelectionChange(!0))))}},_handleCopy:function(t){return this._cancelCheckSelection(),this._ignoreEvent(t)||this._ignoreCopy?void 0:this._doCopy(t)?(t.preventDefault&&t.preventDefault(),!1):void 0},_handleCut:function(t){return this._cancelCheckSelection(),this._ignoreEvent(t)?void 0:this._doCut(t)?(t.preventDefault&&t.preventDefault(),!1):void 0},_handleDataModified:function(t){this._ignoreEvent(t)||this._startIME()},_handleDblclick:function(t){if(!this._ignoreEvent(t)){var e=t.timeStamp?t.timeStamp:Date.now();this._lastMouseTime=e,2!==this._clickCount&&(this._clickCount=2,this._handleMouse(t))}},_handleDragStart:function(t){if(!this._ignoreEvent(t)){if(s.isFirefox<13){var e=this,n=this._getWindow();n.setTimeout(function(){e._clientDiv.contentEditable=!0,e._clientDiv.draggable=!1,e._ignoreBlur=!1},0)}return this.isListening("DragStart")&&-1!==this._dragOffset?(this._isMouseDown=!1,this.onDragStart(this._createMouseEvent("DragStart",t)),this._dragOffset=-1,void 0):(t.preventDefault&&t.preventDefault(),!1)}},_handleDrag:function(t){this._ignoreEvent(t)||this.isListening("Drag")&&this.onDrag(this._createMouseEvent("Drag",t))},_handleDragEnd:function(t){this._ignoreEvent(t)||(this._dropTarget=!1,this._dragOffset=-1,this.isListening("DragEnd")&&this.onDragEnd(this._createMouseEvent("DragEnd",t)),s.isFirefox<13&&(this._fixCaret(),"none"!==t.dataTransfer.dropEffect||t.dataTransfer.mozUserCancelled||this._fixCaret()))},_handleDragEnter:function(t){if(!this._ignoreEvent(t)){var e=!0;return this._dropTarget=!0,this.isListening("DragEnter")&&(e=!1,this.onDragEnter(this._createMouseEvent("DragEnter",t))),s.isWebkit||e?(t.preventDefault&&t.preventDefault(),!1):void 0}},_handleDragOver:function(t){if(!this._ignoreEvent(t)){var e=!0;return this.isListening("DragOver")&&(e=!1,this.onDragOver(this._createMouseEvent("DragOver",t))),s.isWebkit||e?(e&&(t.dataTransfer.dropEffect="none"),t.preventDefault&&t.preventDefault(),!1):void 0}},_handleDragLeave:function(t){this._ignoreEvent(t)||(this._dropTarget=!1,this.isListening("DragLeave")&&this.onDragLeave(this._createMouseEvent("DragLeave",t)))},_handleDrop:function(t){return this._ignoreEvent(t)?void 0:(this._dropTarget=!1,this.isListening("Drop")&&this.onDrop(this._createMouseEvent("Drop",t)),t.preventDefault&&t.preventDefault(),!1)},_handleFocus:function(){this._hasFocus=!0,s.isIOS&&void 0!==this._lastTouchOffset?(this.setCaretOffset(this._lastTouchOffset,!0),this._lastTouchOffset=void 0):this._updateDOMSelection(),this._cursorDiv&&(this._cursorDiv.style.display="block"),this._domSelection&&this._domSelection.forEach(function(t){t.update()}),this._ignoreFocus||this.onFocus({type:"Focus"})},_handleKeyDown:function(t){if(this._cancelCheckSelection(),!this._ignoreEvent(t)){if(this.isListening("KeyDown")){var e=this._createKeyEvent("KeyDown",t);if(this.onKeyDown(e),e.defaultPrevented)return s.isFirefox&&(this._keyDownPrevented=!0),void t.preventDefault()}var n=!1;switch(t.keyCode){case 16:case 17:case 18:case 91:n=!0;break;default:this._setLinksVisible(!1)}if(229===t.keyCode){if(this._readonly)return t.preventDefault&&t.preventDefault(),!1;var i=!0;s.isSafari&&s.isMac&&t.ctrlKey&&(i=!1,t.keyCode=129),i&&this._startIME()}else n||this._commitIME();return(s.isMac||s.isLinux)&&s.isFirefox<4||s.isOpera<12.16?(this._keyDownEvent=t,!0):this._doAction(t)?(t.preventDefault?(t.preventDefault(),t.stopPropagation()):(t.cancelBubble=!0,t.returnValue=!1,t.keyCode=0),!1):void 0}},_handleKeyPress:function(t){if(!this._ignoreEvent(t)){if(this._keyDownPrevented)return t.preventDefault&&(t.preventDefault(),t.stopPropagation()),void(this._keyDownPrevented=void 0);if(s.isMac&&s.isWebkit&&(63232<=t.keyCode&&t.keyCode<=63487||13===t.keyCode||8===t.keyCode))return t.preventDefault&&t.preventDefault(),!1;if(((s.isMac||s.isLinux)&&s.isFirefox<4||s.isOpera<12.16)&&this._doAction(this._keyDownEvent))return t.preventDefault&&t.preventDefault(),!1;var e=s.isMac?t.metaKey:t.ctrlKey;if(void 0!==t.charCode&&e)switch(t.charCode){case 99:case 118:case 120:return!0}if(this.isListening("KeyPress")){var n=this._createKeyEvent("KeyPress",t);if(this.onKeyPress(n),n.defaultPrevented)return void t.preventDefault()}if(this._doAction(t))return t.preventDefault?(t.preventDefault(),t.stopPropagation()):(t.cancelBubble=!0,t.returnValue=!1,t.keyCode=0),!1;var i=!1;if(s.isMac?(t.ctrlKey||t.metaKey)&&(i=!0):s.isFirefox?(t.ctrlKey||t.altKey)&&(i=!0):t.ctrlKey^t.altKey&&(i=!0),!i){var o=s.isOpera?t.which:void 0!==t.charCode?t.charCode:t.keyCode;if(o>31)return this._doContent(String.fromCharCode(o)),t.preventDefault&&t.preventDefault(),!1}}},_handleDocKeyUp:function(t){var e=s.isMac?t.metaKey:t.ctrlKey;e||this._setLinksVisible(!1)},_handleKeyUp:function(t){if(!this._ignoreEvent(t)){if(this.isListening("KeyUp")){var e=this._createKeyEvent("KeyUp",t);if(this.onKeyUp(e),e.defaultPrevented)return void t.preventDefault()}this._handleDocKeyUp(t),13===t.keyCode&&this._commitIME()}},_handleLinkClick:function(t){var e=s.isMac?t.metaKey:t.ctrlKey;return e?void 0:(t.preventDefault&&t.preventDefault(),!1)},_handleMouse:function(t){var e=this._getWindow(),n=!0,i=e;if((s.isIE||s.isFirefox&&!this._overlayDiv)&&(i=this._clientDiv),this._overlayDiv){this._hasFocus&&(this._ignoreFocus=!0);var o=this;e.setTimeout(function(){o.focus(),o._ignoreFocus=!1},0)}var r=t.shiftKey,a=t.altKey,l=s.isMac?t.metaKey:t.ctrlKey;if(this._blockSelection=this._doubleClickSelection=null,1===this._clickCount){var h=(!s.isOpera||s.isOpera>=12.16)&&this._hasFocus&&this.isListening("DragStart");n=this._setSelectionTo(t.clientX,t.clientY,!0,r,l,h),n&&this._setGrab(i)}else this._isW3CEvents&&this._setGrab(i),this._setSelectionTo(t.clientX,t.clientY,!0,r,l,!1),this._doubleClickSelection=y.editing(this._getSelections());return a&&(this._blockSelection=y.editing(this._getSelections())),n},_handleMouseDown:function(t){if(!this._ignoreEvent(t)){if(this._linksVisible){var e=t.target||t.srcElement;if("A"===e.tagName)return;this._setLinksVisible(!1)}this._commitIME();var n=t.which;n||(4===t.button&&(n=2),2===t.button&&(n=3),1===t.button&&(n=1));var i=2!==n&&t.timeStamp?t.timeStamp:Date.now(),o=i-this._lastMouseTime,r=Math.abs(this._lastMouseX-t.clientX),a=Math.abs(this._lastMouseY-t.clientY),l=this._lastMouseButton===n;if(this._lastMouseX=t.clientX,this._lastMouseY=t.clientY,this._lastMouseTime=i,this._lastMouseButton=n,1===n&&(this._isMouseDown=!0,l&&o<=this._clickTime&&r<=this._clickDist&&a<=this._clickDist?this._clickCount++:this._clickCount=1),this.isListening("MouseDown")){var h=this._createMouseEvent("MouseDown",t);if(this.onMouseDown(h),h.defaultPrevented)return void t.preventDefault()}1===n&&this._handleMouse(t)&&(s.isIE>=9||s.isOpera||s.isChrome||s.isSafari||s.isFirefox&&!this._overlayDiv)&&(this._hasFocus||this.focus(),t.preventDefault()),s.isFirefox&&3===this._lastMouseButton&&this._updateDOMSelection()}},_handleMouseOver:function(t){this._ignoreEvent(t)||this._animation||this.isListening("MouseOver")&&this.onMouseOver(this._createMouseEvent("MouseOver",t))},_handleMouseOut:function(t){this._ignoreEvent(t)||this._animation||this.isListening("MouseOut")&&this.onMouseOut(this._createMouseEvent("MouseOut",t))},_handleMouseMove:function(t){if(!this._animation){var e=this._isClientDiv(t);if(this.isListening("MouseMove")&&(e||this._isMouseDown)){var n=this._createMouseEvent("MouseMove",t);if(this.onMouseMove(n),n.defaultPrevented)return void t.preventDefault()}if(!this._dropTarget){var i=this._linksVisible||this._lastMouseMoveX!==t.clientX||this._lastMouseMoveY!==t.clientY;if(this._lastMouseMoveX=t.clientX,this._lastMouseMoveY=t.clientY,this._setLinksVisible(i&&!this._isMouseDown&&t.altKey&&(s.isMac?t.metaKey:t.ctrlKey)),this._checkOverlayScroll(),!this._isW3CEvents){if(0===t.button)return this._setGrab(null),!0;if(!this._isMouseDown&&1===t.button&&0!==(1&this._clickCount)&&e)return this._clickCount=2,this._handleMouse(t,this._clickCount)}if(this._isMouseDown&&-1===this._dragOffset){var o=t.clientX,r=t.clientY,a=this._getViewPadding(),l=this._viewDiv.getBoundingClientRect(),h=this._getClientWidth(),d=this._getClientHeight(),c=l.left+a.left,u=l.top+a.top,f=l.left+a.left+h,g=l.top+a.top+d;u>r?this._doAutoScroll("up",o,r-u):r>g?this._doAutoScroll("down",o,r-g):c>o&&!this._wrapMode?this._doAutoScroll("left",o-c,r):o>f&&!this._wrapMode?this._doAutoScroll("right",o-f,r):(this._endAutoScroll(),this._setSelectionTo(o,r,!1,!0))}}}},_isClientDiv:function(t){for(var e=this._overlayDiv||this._clientDiv,n=t.target?t.target:t.srcElement;n;){if(e===n)return!0;n=n.parentNode}return!1},_createKeyEvent:function(t,e){return{type:t,event:e,preventDefault:function(){this.defaultPrevented=!0}}},_createMouseEvent:function(t,e){var n=this.convert({x:e.clientX,y:e.clientY},"page","document");return{type:t,event:e,clickCount:this._clickCount,x:n.x,y:n.y,preventDefault:function(){this.defaultPrevented=!0}}},_createTouchEvent:function(t,e){var n=e.touches.length?this.convert({x:e.touches[0].clientX,y:e.touches[0].clientY},"page","document"):{};return{type:t,event:e,touchCount:e.touches.length,x:n.x,y:n.y,preventDefault:function(){this.defaultPrevented=!0}}},_handleMouseUp:function(t){var e=t.which?0===t.button:1===t.button;if(this.isListening("MouseUp")&&(this._isClientDiv(t)||e&&this._isMouseDown)){var n=this._createMouseEvent("MouseUp",t);if(this.onMouseUp(n),n.defaultPrevented)return t.preventDefault(),void(this._isMouseDown=!1)}if(!this._linksVisible){if(e&&this._isMouseDown){var i=this._getSelections(),o=y.editing(i);i.forEach(function(t){t._editing=!1}),-1!==this._dragOffset&&(o.extend(this._dragOffset),o.collapse(),i=o,this._dragOffset=-1),this._setSelection(i,!1),this._isMouseDown=!1,this._endAutoScroll(),this._isW3CEvents&&this._setGrab(null)}e&&this._isMouseDown&&s.isFirefox&&(this._updateDOMSelection(),t.preventDefault())}},_handleMouseWheel:function(t){if(!this._noScroll){var e=this._getLineHeight(),n=0,i=0;if(s.isIE||s.isOpera)i=-t.wheelDelta/40*e;else if(s.isFirefox){var o=256;if("wheel"===t.type)t.deltaMode?(n=Math.max(-o,Math.min(o,t.deltaX))*e,i=Math.max(-o,Math.min(o,t.deltaY))*e):(n=t.deltaX,i=t.deltaY);else{var r;r=s.isMac?3*t.detail:Math.max(-o,Math.min(o,t.detail))*e,t.axis===t.HORIZONTAL_AXIS?n=r:i=r}}else if(s.isMac){var a,l,h=t.timeStamp-this._wheelTimeStamp;this._wheelTimeStamp=t.timeStamp,a=t.wheelDeltaX%120!==0?1:40>h?40/(40-h):40,l=t.wheelDeltaY%120!==0?1:40>h?40/(40-h):40,n=Math.ceil(-t.wheelDeltaX/a),n>-1&&0>n&&(n=-1),n>0&&1>n&&(n=1),i=Math.ceil(-t.wheelDeltaY/l),i>-1&&0>i&&(i=-1),i>0&&1>i&&(i=1)}else{n=-t.wheelDeltaX;var d=8;i=-t.wheelDeltaY/120*d*e}if(s.isSafari||s.isChrome&&s.isMac){for(var c=t.target;c&&void 0===c.lineIndex;)c=c.parentNode;this._mouseWheelLine=c}var u=this._getScroll();this._scrollView(n,i);var f=this._getScroll();return u.x!==f.x||u.y!==f.y?(t.preventDefault&&t.preventDefault(),!1):void 0}},_handlePaste:function(t){if(this._cancelCheckSelection(),!this._ignoreEvent(t)&&!this._ignorePaste&&this._doPaste(t)){if(s.isIE){var e=this;this._ignoreFocus=!0;var n=this._getWindow();n.setTimeout(function(){e._updateDOMSelection(),e._ignoreFocus=!1},0)}return t.preventDefault&&t.preventDefault(),!1}},_handleResize:function(){var t=this._rootDiv.clientWidth,e=this._rootDiv.clientHeight;if(this._rootWidth!==t||this._rootHeight!==e){this._rootWidth!==t&&this._wrapMode&&this._resetLineHeight(),this._rootWidth=t,this._rootHeight=e;var n=s.isIE<9,i=this._calculateMetrics();S(i,this._metrics)||(this._metrics.invalid&&!i.invalid?this._updateStyle(!1,i):(this._variableLineHeight&&(this._variableLineHeight=!1,this._resetLineHeight()),this._metrics=i),n=!0),n?this._queueUpdate():this._update(),this.dispatchEvent({type:"Resize"})}},_handleRulerEvent:function(t){for(var e=t.target?t.target:t.srcElement,n=e.lineIndex,i=e;i&&!i._ruler;)void 0===n&&void 0!==i.lineIndex&&(n=i.lineIndex),i=i.parentNode;var o=i?i._ruler:null;if(void 0===n&&o&&"document"===o.getOverview()){var r,s,a=this._getClientHeight(),l=this._model.getLineCount(),h=this._getViewPadding(),d=this._viewDiv.getBoundingClientRect(),c=this._getLineHeight(),u=c*l,f=a+h.top+h.bottom-2*this._metrics.scrollWidth;f>u?(r=c,s=h.top):(r=f/l,s=this._metrics.scrollWidth),n=Math.floor((t.clientY-d.top-s)/r),n>=0&&l>n||(n=void 0)}if(o)switch(t.type){case"click":o.onClick&&o.onClick(n,t);break;case"dblclick":o.onDblClick&&o.onDblClick(n,t);break;case"mousemove":o.onMouseMove&&o.onMouseMove(n,t);break;case"mouseover":o.onMouseOver&&o.onMouseOver(n,t);break;case"mouseout":if(o.onMouseOut){for(var g=t.relatedTarget;g&&g!==this._rootDiv;){if(g===i)return;g=g.parentNode}o.onMouseOut(n,t)}}},_handleScroll:function(){this._lastScrollTime=Date.now();var t=this._getScroll(!1),e=this._hScroll,n=this._vScroll;if(e!==t.x||n!==t.y){this._hScroll=t.x,this._vScroll=t.y,this._commitIME(),this._update(n===t.y);var i={type:"Scroll",oldValue:{x:e,y:n},newValue:t};this.onScroll(i)}},_handleSelectStart:function(t){var e=this._contextMenuOpen;return this._contextMenuOpen=!1,e?void(this._checkSelectionChange=!0):this._ignoreSelect?(t&&t.preventDefault&&t.preventDefault(),!1):void 0},_getModelOffset:function(t,e){if(t){var n;return n="DIV"===t.tagName?t:t.parentNode.parentNode,n._line?n._line.getModelOffset(t,e):0}},_updateSelectionFromDOM:function(){if(!(s.isIOS||s.isAndroid||this._checkSelectionChange))return!1;var t=this._getWindow(),e=t.getSelection(),n=this._getModelOffset(e.anchorNode,e.anchorOffset),i=this._getModelOffset(e.focusNode,e.focusOffset),o=this._getSelections()[0];if(void 0===n||void 0===i||o.start===n&&o.end===i)return!1;if(this._checkSelectionChange){var r=this._getLineNext(),a=this._getLinePrevious();if(e.anchorNode===r.firstChild.firstChild&&0===e.anchorOffset&&e.focusNode===a.firstChild.firstChild&&0===e.focusOffset)return!1;(e.anchorNode===r.firstChild.firstChild&&0===e.anchorOffset&&e.focusNode===a.lastChild.firstChild||e.anchorNode===this._clientDiv&&e.focusNode===this._clientDiv)&&(n=0,i=this.getModel().getCharCount())}return this._setSelection(new y(n,i),!1,!1),this._checkSelectionChange=!1,!0},_cancelCheckSelection:function(){this._checkSelectionChange&&(this._checkSelectionChange=!1,this._cancelPollSelectionChange())},_cancelPollSelectionChange:function(){if(this._selPollTimer){var t=this._getWindow();t.clearTimeout(this._selPollTimer),this._selPollTimer=null}},_pollSelectionChange:function(t){var e=this,n=this._getWindow();this._cancelPollSelectionChange(),this._selPollTimer=n.setTimeout(function(){if(e._selPollTimer=null,e._clientDiv){var n=e._updateSelectionFromDOM();!n&&t&&e._pollSelectionChange(t)}},100)},_handleSelectionChange:function(){-1===this._imeOffset&&(s.isAndroid?this._pollSelectionChange():this._updateSelectionFromDOM())},_handleTextInput:function(t){if(!this._ignoreEvent(t)&&-1===this._imeOffset){var e=this._getWindow().getSelection();if(e.anchorNode!==this._anchorNode||e.focusNode!==this._focusNode||e.anchorOffset!==this._anchorOffset||e.focusOffset!==this._focusOffset){for(var n=e.anchorNode;n&&void 0===n.lineIndex;)n=n.parentNode;if(n){var i=this._model,o=n.lineIndex,r=i.getLine(o),s=r,a=0,l=i.getLineStart(o);if(e.rangeCount>0){e.getRangeAt(0).deleteContents();var h=n.ownerDocument.createTextNode(t.data);e.getRangeAt(0).insertNode(h);var d=this._getDOMText(n,h);s=d.text,a=d.offset,h.parentNode.removeChild(h)}n.lineRemoved=!0;for(var c=0;r.charCodeAt(c)===s.charCodeAt(c)&&a>c;)c++;for(var u=r.length-1,f=s.length-r.length;r.charCodeAt(u)===s.charCodeAt(u+f)&&u+f>=a+t.data.length;)u--;u++;var g=s.substring(c,u+f);c+=l,u+=l;var p=this._getSelections(),_=p[0].start-c,v=p[0].end-u;p[0].start=c,p[0].end=u;for(var m=1;m=0;n--)if(e=i[n],"function"==typeof e.match){var o=e.match(t);if(void 0!==o)return this.invokeAction(o)}return!1},_doMove:function(t,e){var n=this._model,i=e.getCaret(),o=n.getLineAtOffset(i);for(t.count||(t.count=1);0!==t.count;){var r=n.getLineStart(o);if(t.count<0&&i===r){if(!(o>0))break;"character"===t.unit&&t.count++,o--,e.extend(n.getLineEnd(o))}else if(t.count>0&&i===n.getLineEnd(o)){if(!(o+10&&(r=Math.min(r+t.count-1,e.getLineCount()-1)),o=e.getLineEnd(r);i.extend(o)}t.select||i.collapse()}),this._setSelection(i,!0,!0,t.ctrl?function(){}:null),!0},_doEnter:function(t){if(this._singleMode)return!0;var e=this._model,n=this._getSelections();return this._doContent(e.getLineDelimiter()),t&&t.noCursor&&(n.forEach(function(t){t.end=t.start}),this._setSelection(n,!0)),!0},_doEscape:function(){var t=this._getSelections();return t.length>1&&this._setSelection(t[0],!0),!0},_doHome:function(t){var e=this._model,n=this,i=this._getSelections();return i.forEach(function(i){if(t.ctrl)i.extend(0);else{var o=i.getCaret(),r=e.getLineAtOffset(o);if(n._wrapMode){var s=n._getLine(r),a=s.getLineIndex(o);o=s.getLineStart(a),s.destroy()}else o=e.getLineStart(r);i.extend(o)}t.select||i.collapse()}),this._setSelection(i,!0,!0,t.ctrl?function(){}:null),!0},_doLineDown:function(t){var e=this._model,n=this,i=this._getSelections();return i.forEach(function(i){var o,r=i.getCaret(),a=e.getLineAtOffset(r),l=n._getLine(a),h=i._columnX,d=1,c=!1;if(-1===h||t.wholeLine||t.select&&s.isIE){var u=t.wholeLine?e.getLineEnd(a+1):r;h=i._columnX=l.getBoundingClientRect(u).left}if((o=l.getLineIndex(r))0?a=Math.min(a+t.count,f):a++}var g=!1;c?(t.select||s.isMac||s.isLinux)&&(i.extend(e.getCharCount()),g=!0):(l.lineIndex!==a&&(l.destroy(),l=n._getLine(a)),i.extend(l.getOffset(h,d)),g=!0),g&&(t.select||i.collapse()),l.destroy()}),n._setSelection(i,!0,!0,null,0,!1,!0),!0},_doLineUp:function(t){var e=this._model,n=this,i=this._getSelections();return i.forEach(function(i){var o,r,a=i.getCaret(),l=e.getLineAtOffset(a),h=n._getLine(l),d=i._columnX,c=!1;if(-1===d||t.wholeLine||t.select&&s.isIE){var u=t.wholeLine?e.getLineStart(l-1):a;d=i._columnX=h.getBoundingClientRect(u).left}(o=h.getLineIndex(a))>0?r=h.getClientRects(o-1).top+1:(c=0===l,c||(t.count&&t.count>0?l=Math.max(l-t.count,0):l--,r=n._getLineHeight(l)-1));var f=!1;c?(t.select||s.isMac||s.isLinux)&&(i.extend(0),f=!0):(h.lineIndex!==l&&(h.destroy(),h=n._getLine(l)),i.extend(h.getOffset(d,r)),f=!0),f&&(t.select||i.collapse()),h.destroy()}),n._setSelection(i,!0,!0,null,0,!1,!0),!0},_doNoop:function(){return!0},_doPageDown:function(t){var e,n,i,o=this,r=this._model,a=this._getSelections(),l=r.getLineCount(),h=this._getScroll(),d=this._getClientHeight(),c=this._getLineHeight(),u=Math.floor(d/c);return a.forEach(function(a){var f=a.getCaret(),g=r.getLineAtOffset(f);if(o._lineHeight){e=a._columnX;var p=o._getBoundsAtOffset(f);(-1===e||t.select&&s.isIE)&&(e=a._columnX=p.left);var _=o._getLineIndex(p.top+d);n=o._getLine(_);var v=o._getLinePixel(_),m=p.top+d-v;f=n.getOffset(e,m);var y=n.getBoundingClientRect(f);n.destroy(),a.extend(f),t.select||a.collapse(),i=void 0!==i?Math.min(i,y.top+v-p.top):y.top+v-p.top}else if(l-1>g){var x=Math.min(l-g-1,u);x=Math.max(1,x),e=a._columnX,(-1===e||t.select&&s.isIE)&&(n=o._getLine(g),e=a._columnX=n.getBoundingClientRect(f).left,n.destroy()),n=o._getLine(g+x),a.extend(n.getOffset(e,0)),n.destroy(),t.select||a.collapse();var C=l*c,w=h.y+x*c;w+d>C&&(w=C-d),i=void 0!==i?Math.min(i,w-h.y):w-h.y}}),this._setSelection(a,!0,!0,function(){},i,!1,!0),!0},_doPageUp:function(t){var e,n,i,o=this,r=this._model,a=this._getSelections(),l=this._getScroll(),h=this._getClientHeight(),d=this._getLineHeight(),c=Math.floor(h/d);return a.forEach(function(a){var u=a.getCaret(),f=r.getLineAtOffset(u);if(o._lineHeight){e=a._columnX;var g=o._getBoundsAtOffset(u);(-1===e||t.select&&s.isIE)&&(e=a._columnX=g.left);var p=o._getLineIndex(g.bottom-h);n=o._getLine(p);var _=o._getLinePixel(p),v=g.bottom-h-_;u=n.getOffset(e,v);var m=n.getBoundingClientRect(u);n.destroy(),a.extend(u),t.select||a.collapse(),i=void 0!==i?Math.max(i,m.top+_-g.top):m.top+_-g.top}else if(f>0){var y=Math.max(1,Math.min(f,c));e=a._columnX,(-1===e||t.select&&s.isIE)&&(n=o._getLine(f),e=a._columnX=n.getBoundingClientRect(u).left,n.destroy()),n=o._getLine(f-y),a.extend(n.getOffset(e,o._getLineHeight(f-y)-1)),n.destroy(),t.select||a.collapse();var x=Math.max(0,l.y-y*d);i=void 0!==i?Math.max(i,x-l.y):x-l.y}}),this._setSelection(a,!0,!0,function(){},i,!1,!0),!0},_doPaste:function(t){var e=this,n=this._getClipboardText(t,function(t){if(t.length){if(s.isLinux&&2===e._lastMouseButton){var n=Date.now()-e._lastMouseTime;n<=e._clickTime&&e._setSelectionTo(e._lastMouseX,e._lastMouseY,!0)}var i=e._getSelections(),o=e._singleMode?"":e._model.getLineDelimiter();e._doContent(i.length>1&&i.length===t.length?t:t.join(o))}});return null!==n},_doScroll:function(t){var e,n=t.type,i=this._model,o=i.getLineCount(),r=this._getClientHeight(),s=this._getLineHeight(),a=this._lineHeight?this._scrollHeight:o*s,l=this._getScroll().y;
switch(n){case"textStart":e=0;break;case"textEnd":e=a-r;break;case"pageDown":e=l+r;break;case"pageUp":e=l-r;break;case"lineDown":e=l+s;break;case"lineUp":e=l-s;break;case"centerLine":var h=this._getSelections()[0],d=i.getLineAtOffset(h.start),c=i.getLineAtOffset(h.end),u=(c-d+1)*s;e=d*s-r/2+u/2}return void 0!==e&&(e=Math.min(Math.max(0,e),a-r),this._scrollViewAnimated(0,e-l,function(){})),!0},_doSelectAll:function(){var t=this._model;return this._setSelection(new y(0,t.getCharCount()),!1),!0},_doTab:function(){if(this._tabMode&&!this._readonly){var t="	",e=this._getSelections();if(this._expandTab){t=[];var n=this._model,i=this._tabSize;e.forEach(function(e){var o=e.getCaret(),r=n.getLineAtOffset(o),s=n.getLineStart(r),a=i-(o-s)%i;t.push(d(a+1).join(" "))})}return this._modifyContent({text:t,selection:e,_ignoreDOMSelection:!0},!0)}},_doShiftTab:function(){return this._tabMode&&!this._readonly?!0:void 0},_doOverwriteMode:function(){return this._readonly?void 0:(this.setOptions({overwriteMode:!this.getOptions("overwriteMode")}),!0)},_doTabMode:function(){return this.setOptions({tabMode:!this.getOptions("tabMode")}),!0},_doWrapMode:function(){return this.setOptions({wrapMode:!this.getOptions("wrapMode")}),!0},_autoScroll:function(){var t,e,n=this._model,i=this._getSelections(),o=y.editing(i,"down"===this._autoScrollDir),r=this.convert({x:this._autoScrollX,y:this._autoScrollY},"page","document"),a=o.getCaret(),l=n.getLineCount(),h=n.getLineAtOffset(a);if("up"===this._autoScrollDir||"down"===this._autoScrollDir){var d=this._autoScrollY/this._getLineHeight();d=0>d?Math.floor(d):Math.ceil(d),t=h,t=Math.max(0,Math.min(l-1,t+d))}else("left"===this._autoScrollDir||"right"===this._autoScrollDir)&&(t=this._getLineIndex(r.y),e=this._getLine(h),r.x+=e.getBoundingClientRect(a,!1).left,e.destroy());this._blockSelection?i=this._getBlockSelections(i,t,r):0===t&&(s.isMac||s.isLinux)?o.extend(0):t===l-1&&(s.isMac||s.isLinux)?o.extend(n.getCharCount()):(e=this._getLine(t),o.extend(e.getOffset(r.x,r.y-this._getLinePixel(t))),e.destroy()),this._setSelection(i,!0)},_autoScrollTimer:function(){this._autoScroll();var t=this,e=this._getWindow();this._autoScrollTimerID=e.setTimeout(function(){t._autoScrollTimer()},this._AUTO_SCROLL_RATE)},_calculateLineHeightTimer:function(t){if(this._lineHeight&&!this._calculateLHTimer){var e=this._model.getLineCount(),n=0;if(t){for(var i=0,o=100,r=Date.now(),s=0;e>n&&(this._lineHeight[n]||(i++,s||(s=n),this._lineHeight[n]=this._calculateLineHeight(n)),n++,!(Date.now()-r>o)););this.redrawRulers(0,e),this._queueUpdate()}var a=this._getWindow();if(n!==e){var l=this;return void(this._calculateLHTimer=a.setTimeout(function(){l._calculateLHTimer=null,l._calculateLineHeightTimer(!0)},0))}this._calculateLHTimer&&(a.clearTimeout(this._calculateLHTimer),this._calculateLHTimer=void 0)}},_calculateLineHeight:function(t){var e=this._getLine(t),n=e.getBoundingClientRect();return e.destroy(),Math.max(1,n.bottom-n.top)},_calculateMetrics:function(){var t=this._clientDiv,e=t.ownerDocument,n=" ",i=s.createElement(e,"div");i.style.lineHeight="normal";var o=this._model,r=o.getLine(0),a={type:"LineStyle",textView:this,0:0,lineText:r,lineStart:0};this.onLineStyle(a),c(a.style,i),i.style.position="fixed",i.style.left="-1000px";var l=s.createElement(e,"span");l.appendChild(e.createTextNode(n)),i.appendChild(l);var h=s.createElement(e,"span");h.style.fontStyle="italic",h.appendChild(e.createTextNode(n)),i.appendChild(h);var u=s.createElement(e,"span");u.style.fontWeight="bold",u.appendChild(e.createTextNode(n)),i.appendChild(u);var f=s.createElement(e,"span");f.style.fontWeight="bold",f.style.fontStyle="italic",f.appendChild(e.createTextNode(n)),i.appendChild(f),t.appendChild(i);var g=i.getBoundingClientRect(),p=l.getBoundingClientRect(),m=h.getBoundingClientRect(),y=u.getBoundingClientRect(),x=f.getBoundingClientRect(),C=p.bottom-p.top,w=m.bottom-m.top,A=y.bottom-y.top,T=x.bottom-x.top,L=0,S=g.bottom-g.top<=0,M=Math.max(1,g.bottom-g.top);w>C&&(L=1),A>w&&(L=2),T>A&&(L=3);var D;0!==L&&(D={style:{}},0!==(1&L)&&(D.style.fontStyle="italic"),0!==(2&L)&&(D.style.fontWeight="bold"));var E=v(i);t.removeChild(i);var O=_(this._viewDiv),N=s.createElement(e,"div");N.style.position="fixed",N.style.left="-1000px",N.style.paddingLeft=O.left+"px",N.style.paddingTop=O.top+"px",N.style.paddingRight=O.right+"px",N.style.paddingBottom=O.bottom+"px",N.style.width="100px",N.style.height="100px";var b=s.createElement(e,"div");b.style.width="100%",b.style.height="100%",N.appendChild(b),t.appendChild(N);var I=N.getBoundingClientRect(),k=b.getBoundingClientRect(),R=0;if(!this._singleMode&&!this._noScroll){N.style.overflow="hidden",b.style.height="200px";var B=N.clientWidth;N.style.overflow="scroll";var P=N.clientWidth;R=B-P}t.removeChild(N),O={left:k.left-I.left,top:k.top-I.top,right:I.right-k.right,bottom:I.bottom-k.bottom};var V=0,F=0,W=0;return S||(N=s.createElement(e,"div"),N.style.position="fixed",N.style.left="-1000px",t.appendChild(N),N.innerHTML=d(2).join("a"),I=N.getBoundingClientRect(),W=Math.ceil(I.right-I.left),(this._wrapOffset||this._marginOffset)&&(N.innerHTML=d(this._wrapOffset+1+(s.isWebkit?0:1)).join(" "),I=N.getBoundingClientRect(),V=Math.ceil(I.right-I.left),N.innerHTML=d(this._marginOffset+1).join(" "),k=N.getBoundingClientRect(),F=Math.ceil(k.right-k.left)),t.removeChild(N)),{lineHeight:M,largestFontStyle:D,lineTrim:E,viewPadding:O,scrollWidth:R,wrapWidth:V,marginWidth:F,charWidth:W,invalid:S}},_cancelAnimation:function(){this._animation&&(this._animation.stop(),this._animation=null)},_clearSelection:function(t){var e=this._getSelections();return e.forEach(function(e){"next"===t?e.start=e.end:e.end=e.start}),this._setSelection(e,!0),!0},_commitIME:function(t){if(-1!==this._imeOffset){var e=this._model,n=e.getLineAtOffset(this._imeOffset),i=e.getLineStart(n),o=this._getLineNode(n);if(!t){this._scrollDiv.focus(),this._clientDiv.focus();var r=this._getDOMText(o).text,a=e.getLine(n),l=this._imeOffset-i,h=l+r.length-a.length;l!==h&&(t=r.substring(l,h))}this._imeOffset=-1,t&&(this._doContent(t)||s.isWebkit||(o.lineRemoved=!0,this._queueUpdate()))}},_createActions:function(){this.addKeyMode(new n.DefaultKeyMode(this));var e=this;this._actions={noop:{defaultHandler:function(){return e._doNoop()}},lineUp:{defaultHandler:function(t){return e._doLineUp(f(t,{select:!1}))},actionDescription:{name:t.lineUp}},lineDown:{defaultHandler:function(t){return e._doLineDown(f(t,{select:!1}))},actionDescription:{name:t.lineDown}},lineStart:{defaultHandler:function(t){return e._doHome(f(t,{select:!1,ctrl:!1}))},actionDescription:{name:t.lineStart}},lineEnd:{defaultHandler:function(t){return e._doEnd(f(t,{select:!1,ctrl:!1}))},actionDescription:{name:t.lineEnd}},charPrevious:{defaultHandler:function(t){return e._doCursorPrevious(f(t,{select:!1,unit:"character"}))},actionDescription:{name:t.charPrevious}},charNext:{defaultHandler:function(t){return e._doCursorNext(f(t,{select:!1,unit:"character"}))},actionDescription:{name:t.charNext}},pageUp:{defaultHandler:function(t){return e._doPageUp(f(t,{select:!1}))},actionDescription:{name:t.pageUp}},pageDown:{defaultHandler:function(t){return e._doPageDown(f(t,{select:!1}))},actionDescription:{name:t.pageDown}},scrollPageUp:{defaultHandler:function(t){return e._doScroll(f(t,{type:"pageUp"}))},actionDescription:{name:t.scrollPageUp}},scrollPageDown:{defaultHandler:function(t){return e._doScroll(f(t,{type:"pageDown"}))},actionDescription:{name:t.scrollPageDown}},scrollLineUp:{defaultHandler:function(t){return e._doScroll(f(t,{type:"lineUp"}))},actionDescription:{name:t.scrollLineUp}},scrollLineDown:{defaultHandler:function(t){return e._doScroll(f(t,{type:"lineDown"}))},actionDescription:{name:t.scrollLineDown}},wordPrevious:{defaultHandler:function(t){return e._doCursorPrevious(f(t,{select:!1,unit:"word"}))},actionDescription:{name:t.wordPrevious}},wordNext:{defaultHandler:function(t){return e._doCursorNext(f(t,{select:!1,unit:"word"}))},actionDescription:{name:t.wordNext}},textStart:{defaultHandler:function(t){return e._doHome(f(t,{select:!1,ctrl:!0}))},actionDescription:{name:t.textStart}},textEnd:{defaultHandler:function(t){return e._doEnd(f(t,{select:!1,ctrl:!0}))},actionDescription:{name:t.textEnd}},scrollTextStart:{defaultHandler:function(t){return e._doScroll(f(t,{type:"textStart"}))},actionDescription:{name:t.scrollTextStart}},scrollTextEnd:{defaultHandler:function(t){return e._doScroll(f(t,{type:"textEnd"}))},actionDescription:{name:t.scrollTextEnd}},centerLine:{defaultHandler:function(t){return e._doScroll(f(t,{type:"centerLine"}))},actionDescription:{name:t.centerLine}},selectLineUp:{defaultHandler:function(t){return e._doLineUp(f(t,{select:!0}))},actionDescription:{name:t.selectLineUp}},selectLineDown:{defaultHandler:function(t){return e._doLineDown(f(t,{select:!0}))},actionDescription:{name:t.selectLineDown}},selectWholeLineUp:{defaultHandler:function(t){return e._doLineUp(f(t,{select:!0,wholeLine:!0}))},actionDescription:{name:t.selectWholeLineUp}},selectWholeLineDown:{defaultHandler:function(t){return e._doLineDown(f(t,{select:!0,wholeLine:!0}))},actionDescription:{name:t.selectWholeLineDown}},selectLineStart:{defaultHandler:function(t){return e._doHome(f(t,{select:!0,ctrl:!1}))},actionDescription:{name:t.selectLineStart}},selectLineEnd:{defaultHandler:function(t){return e._doEnd(f(t,{select:!0,ctrl:!1}))},actionDescription:{name:t.selectLineEnd}},selectCharPrevious:{defaultHandler:function(t){return e._doCursorPrevious(f(t,{select:!0,unit:"character"}))},actionDescription:{name:t.selectCharPrevious}},selectCharNext:{defaultHandler:function(t){return e._doCursorNext(f(t,{select:!0,unit:"character"}))},actionDescription:{name:t.selectCharNext}},selectPageUp:{defaultHandler:function(t){return e._doPageUp(f(t,{select:!0}))},actionDescription:{name:t.selectPageUp}},selectPageDown:{defaultHandler:function(t){return e._doPageDown(f(t,{select:!0}))},actionDescription:{name:t.selectPageDown}},selectWordPrevious:{defaultHandler:function(t){return e._doCursorPrevious(f(t,{select:!0,unit:"word"}))},actionDescription:{name:t.selectWordPrevious}},selectWordNext:{defaultHandler:function(t){return e._doCursorNext(f(t,{select:!0,unit:"word"}))},actionDescription:{name:t.selectWordNext}},selectTextStart:{defaultHandler:function(t){return e._doHome(f(t,{select:!0,ctrl:!0}))},actionDescription:{name:t.selectTextStart}},selectTextEnd:{defaultHandler:function(t){return e._doEnd(f(t,{select:!0,ctrl:!0}))},actionDescription:{name:t.selectTextEnd}},deletePrevious:{defaultHandler:function(t){return e._doBackspace(f(t,{unit:"character"}))},actionDescription:{name:t.deletePrevious}},deleteNext:{defaultHandler:function(t){return e._doDelete(f(t,{unit:"character"}))},actionDescription:{name:t.deleteNext}},deleteWordPrevious:{defaultHandler:function(t){return e._doBackspace(f(t,{unit:"word"}))},actionDescription:{name:t.deleteWordPrevious}},deleteWordNext:{defaultHandler:function(t){return e._doDelete(f(t,{unit:"word"}))},actionDescription:{name:t.deleteWordNext}},deleteLineStart:{defaultHandler:function(t){return e._doBackspace(f(t,{unit:"line"}))},actionDescription:{name:t.deleteLineStart}},deleteLineEnd:{defaultHandler:function(t){return e._doDelete(f(t,{unit:"line"}))},actionDescription:{name:t.deleteLineEnd}},tab:{defaultHandler:function(t){return e._doTab(f(t,{}))},actionDescription:{name:t.tab}},shiftTab:{defaultHandler:function(t){return e._doShiftTab(f(t,{}))},actionDescription:{name:t.shiftTab}},enter:{defaultHandler:function(t){return e._doEnter(f(t,{}))},actionDescription:{name:t.enter}},enterNoCursor:{defaultHandler:function(t){return e._doEnter(f(t,{noCursor:!0}))},actionDescription:{name:t.enterNoCursor}},escape:{defaultHandler:function(t){return e._doEscape(f(t,{}))},actionDescription:{name:t.escape}},selectAll:{defaultHandler:function(t){return e._doSelectAll(f(t,{}))},actionDescription:{name:t.selectAll}},copy:{defaultHandler:function(t){return e._doCopy(f(t,{}))},actionDescription:{name:t.copy}},cut:{defaultHandler:function(t){return e._doCut(f(t,{}))},actionDescription:{name:t.cut}},paste:{defaultHandler:function(t){return e._doPaste(f(t,{}))},actionDescription:{name:t.paste}},uppercase:{defaultHandler:function(t){return e._doCase(f(t,{type:"upper"}))},actionDescription:{name:t.uppercase}},lowercase:{defaultHandler:function(t){return e._doCase(f(t,{type:"lower"}))},actionDescription:{name:t.lowercase}},capitalize:{defaultHandler:function(t){return e._doCase(f(t,{unit:"word",type:"capitalize"}))},actionDescription:{name:t.capitalize}},reversecase:{defaultHandler:function(t){return e._doCase(f(t,{type:"reverse"}))},actionDescription:{name:t.reversecase}},toggleOverwriteMode:{defaultHandler:function(t){return e._doOverwriteMode(f(t,{}))},actionDescription:{name:t.toggleOverwriteMode}},toggleTabMode:{defaultHandler:function(t){return e._doTabMode(f(t,{}))},actionDescription:{name:t.toggleTabMode}},toggleWrapMode:{defaultHandler:function(t){return e._doWrapMode(f(t,{}))},actionDescription:{name:t.toggleWrapMode}}}},_createRulerParent:function(t,e){var n=s.createElement(t,"div");return n.className=e,n.tabIndex=-1,n.style.overflow="hidden",n.style.MozUserSelect="none",n.style.WebkitUserSelect="none",n.style.position="absolute",n.style.top="0px",n.style.bottom="0px",n.style.cursor="default",n.style.display="none",n.setAttribute("aria-hidden","true"),this._rootDiv.appendChild(n),n},_createRuler:function(t,e){if(this._clientDiv){var n=this._getRulerParent(t);if(n){(n!==this._marginDiv||this._marginOffset)&&(n.style.display="block"),n.rulerWidth=void 0;var i=s.createElement(n.ownerDocument,"div");if(i._ruler=t,t.node=i,i.rulerChanged=!0,i.style.position="relative",i.style.cssFloat="left",i.style.styleFloat="left",i.style.outline="none",void 0===e||0>e||e>=n.children.length)n.appendChild(i);else{for(var o=n.firstChild;o&&e-->0;)o=o.nextSibling;n.insertBefore(i,o)}}}},_createSelectionDiv:function(){var t=s.createElement(this._parent.ownerDocument,"div");return t.className="textviewSelection",t.style.position="absolute",t.style.borderWidth="0px",t.style.margin="0px",t.style.padding="0px",t.style.outline="none",t.style.width="0px",t.style.height="0px",t.style.zIndex="0",t},_createView:function(){function t(){C._rootDiv&&(C.update(!0),C._metrics.invalid&&C._getWindow().setTimeout(function(){t()},100))}if(!this._clientDiv){for(var e=this._parent;e.hasChildNodes();)e.removeChild(e.lastChild);var n=e.ownerDocument,i=s.createElement(n,"div");this._rootDiv=i,i.tabIndex=-1,i.style.position="relative",i.style.overflow="hidden",i.style.width="100%",i.style.height="100%",i.style.overflow="hidden",i.style.WebkitTextSizeAdjust="100%",i.setAttribute("role","application"),i.setAttribute("aria-label","Text View"),e.appendChild(i);var o=this._createRulerParent(n,"textviewLeftRuler");this._leftDiv=o;var r=s.createElement(n,"div");r.className="textviewScroll",this._viewDiv=r,r.tabIndex=-1,r.style.position="absolute",r.style.top="0px",r.style.bottom="0px",r.style.borderWidth="0px",r.style.margin="0px",r.style.outline="none",r.style.background="transparent",i.appendChild(r);var l=this._createRulerParent(n,"textviewRightRuler");this._rightDiv=l,"rtl"==document.dir?l.style.left="0px":l.style.right="0px";var h=this._createRulerParent(n,"textviewInnerRightRuler");this._innerRightDiv=h,h.style.zIndex="1";var d=s.createElement(n,"div");this._scrollDiv=d,d.style.margin="0px",d.style.borderWidth="0px",d.style.padding="0px",r.appendChild(d);var c=this._marginDiv=this._createRulerParent(n,"textviewMarginRuler");if(c.style.zIndex="4",!s.isIE&&!s.isIOS){var u=s.createElement(n,"div");this._clipDiv=u,u.style.position="absolute",u.style.overflow="hidden",u.style.margin="0px",u.style.borderWidth="0px",u.style.padding="0px",u.style.background="transparent",i.appendChild(u);var f=s.createElement(n,"div");this._clipScrollDiv=f,f.style.position="absolute",f.style.height="1px",f.style.top="-1000px",f.style.background="transparent",u.appendChild(f)}var g=s.createElement(n,"div");if(g.className="textviewContent",this._clientDiv=g,g.tabIndex=0,g.style.position="absolute",g.style.borderWidth="0px",g.style.margin="0px",g.style.padding="0px",g.style.outline="none",g.style.zIndex="1",g.style.WebkitUserSelect="text",g.setAttribute("spellcheck","false"),(s.isIOS||s.isAndroid)&&(g.style.WebkitTapHighlightColor="transparent"),(this._clipDiv||i).appendChild(g),this._setFullSelection(this._fullSelection,!0),s.isIOS||s.isAndroid){var p=s.createElement(n,"div");this._vScrollDiv=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.width="8px",p.style.display="none",i.appendChild(p);var _=s.createElement(n,"div");this._hScrollDiv=_,_.style.position="absolute",_.style.borderWidth="1px",_.style.borderColor="white",_.style.borderStyle="solid",_.style.borderRadius="4px",_.style.backgroundColor="black",_.style.opacity="0.5",_.style.margin="0px",_.style.padding="0px",_.style.outline="none",_.style.zIndex="3",_.style.height="8px",_.style.display="none",i.appendChild(_)}if(s.isFirefox&&!g.setCapture){var v=s.createElement(n,"div");this._overlayDiv=v,v.style.position=g.style.position,v.style.borderWidth=g.style.borderWidth,v.style.margin=g.style.margin,v.style.padding=g.style.padding,v.style.cursor="text",v.style.zIndex="2",(this._clipDiv||i).appendChild(v)}g.contentEditable="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(),a.initInputField(g);for(var y=this._rulers,x=0;xthis._getLineHeight()){var n=e.getBoundingClientRect(),i=this._clientDiv.getBoundingClientRect();n.bottom>i.bottom&&(e=this._getLinePrevious(e)||e)}return e.lineIndex},_getBlockSelections:function(t,e,n){var i=this._model;t=t.filter(function(t){return!t._editing});var o,r=i.getLineAtOffset(this._blockSelection.getAnchor());e>r?o=e:(o=r,r=e);for(var s=r;o>=s;s++){var a=this._getLine(s),l=a.getOffset(n.x,1),h=a.getOffset(this._blockSelection._docX,1);if(a.destroy(),l!==h||l!==i.getLineEnd(s)){var d=h>l,c=new y(d?l:h,d?h:l,d);c._editing=!0,t.push(c)}}return t},_getBoundsAtOffset:function(t){var e=this._model,n=this._getLine(e.getLineAtOffset(t)),i=n.getBoundingClientRect(t),o=this._getLinePixel(n.lineIndex);return i.top+=o,i.bottom+=o,n.destroy(),i},_getClientHeight:function(){var t=this._getViewPadding();return Math.max(0,this._viewDiv.clientHeight-t.top-t.bottom)},_getInnerRightWidth:function(){var t=this._innerRightDiv.rulerWidth;if(void 0===t){var e=this._innerRightDiv.getBoundingClientRect();this._innerRightDiv.rulerWidth=t=e.right-e.left}return t},_getClientWidth:function(){var t=this._getViewPadding(),e=this._getInnerRightWidth();return Math.max(0,this._viewDiv.clientWidth-t.left-t.right-e)},_getClipboardText:function(t,e){function n(t){var n=[];return g(t,function(t){n.push(t)},null),e&&e(n),n}var i=this._getWindow(),o=i.clipboardData;if(!o&&t&&(o=t.clipboardData),o)return n(o.getData(s.isIE?"Text":"text/plain"));if(s.isElectron&&!t)return n(window.__electron.clipboard.readText());if(s.isFirefox){this._ignoreFocus=!0;var r=this._clipboardDiv,a=this._rootDiv.ownerDocument;r||(r=s.createElement(a,"div"),this._clipboardDiv=r,r.style.position="fixed",r.style.whiteSpace="pre",r.style.left="-1000px",this._rootDiv.appendChild(r)),r.innerHTML="
",r.firstChild.focus();var l=this,h=function(){var t=l._getTextFromElement(r);return r.innerHTML="",n(t)},d=!1;if(this._ignorePaste=!0,!s.isLinux||2!==this._lastMouseButton)try{d=a.execCommand("paste",!1,null)}catch(c){d=r.childNodes.length>1||r.firstChild&&r.firstChild.childNodes.length>0}return this._ignorePaste=!1,d?(this.focus(),this._ignoreFocus=!1,h()):t?(i.setTimeout(function(){l.focus(),h(),l._ignoreFocus=!1},0),null):(this.focus(),this._ignoreFocus=!1,"")}return""},_getDOMText:function(t,e){return t._line.getText(e)},_getTextFromElement:function(t){var e=t.ownerDocument,n=e.defaultView;if(!n.getSelection)return t.innerText||t.textContent;var i=e.createRange();i.selectNode(t);var o,r=n.getSelection(),s=[];for(o=0;on)for(e=n;t>e;e++)i+=this._getLineHeight(e);else for(e=n-1;e>=t;e--)i-=this._getLineHeight(e);return i}var o=this._getLineHeight();return o*t},_getLineIndex:function(t,e){var n,i=0,o=this._model.getLineCount();if(this._lineHeight){i=this._getTopIndex();var r=-this._topIndexY+this._getScroll().y;if(t!==r)if(r>t)for(;r>t&&i>0;)t+=this._getLineHeight(--i);else for(n=this._getLineHeight(i);t-n>=r&&o-1>i;)t-=n,n=this._getLineHeight(++i)}else n=this._getLineHeight(),i=Math.floor(t/n);return e&&(0===o||0>i||i>o-1)?-1:Math.max(0,Math.min(o-1,i))},_getRulerParent:function(t){switch(t.getLocation()){case"left":return this._leftDiv;case"right":return this._rightDiv;case"innerRight":return this._innerRightDiv;case"margin":return this._marginDiv}return null},_getScroll:function(t){(void 0===t||t)&&this._cancelAnimation();var e=this._viewDiv;return{x:e.scrollLeft,y:e.scrollTop}},_getSelection:function(){return(Array.isArray(this._selection)?this._selection[0]:this._selection).clone()},_getSelections:function(){return(Array.isArray(this._selection)?this._selection:[this._selection]).map(function(t){return t.clone()})},_getTopIndex:function(t){var e=this._topChild;if(t&&this._getClientHeight()>this._getLineHeight()){var n=e.getBoundingClientRect(),i=this._getViewPadding(),o=this._viewDiv.getBoundingClientRect();n.top26?"wheel":s.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(e){return t._handleMouseWheel(e?e:l.event)}}),this._clipDiv&&e.push({target:this._clipDiv,type:s.isFirefox>26?"wheel":s.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(e){return t._handleMouseWheel(e?e:l.event)}}),s.isFirefox&&(!s.isWindows||s.isFirefox>=15)){var u=l.MutationObserver||l.MozMutationObserver;u?(this._mutationObserver=new u(function(e){t._handleDataModified(e)}),this._mutationObserver.observe(n,{subtree:!0,characterData:!0})):e.push({target:this._clientDiv,type:"DOMCharacterDataModified",handler:function(e){return t._handleDataModified(e?e:l.event)}})}(s.isFirefox&&(!s.isWindows||s.isFirefox>=15)||s.isIE||s.isWebkit)&&(e.push({target:this._clientDiv,type:"compositionstart",handler:function(e){return t._handleCompositionStart(e?e:l.event)}}),e.push({target:this._clientDiv,type:"compositionend",handler:function(e){return t._handleCompositionEnd(e?e:l.event)}}),e.push({target:this._clientDiv,type:"compositionupdate",handler:function(e){return t._handleCompositionUpdate(e?e:l.event)}})),this._overlayDiv&&(e.push({target:this._overlayDiv,type:"mousedown",handler:function(e){return t._handleMouseDown(e?e:l.event)}}),e.push({target:this._overlayDiv,type:"mouseover",handler:function(e){return t._handleMouseOver(e?e:l.event)}}),e.push({target:this._overlayDiv,type:"mouseout",handler:function(e){return t._handleMouseOut(e?e:l.event)}}),e.push({target:this._overlayDiv,type:"contextmenu",handler:function(e){return t._handleContextMenu(e?e:l.event)}})),this._isW3CEvents||e.push({target:this._clientDiv,type:"dblclick",handler:function(e){return t._handleDblclick(e?e:l.event)}})}this._hookRulerEvents(this._leftDiv,e),this._hookRulerEvents(this._rightDiv,e),this._hookRulerEvents(this._innerRightDiv,e),this._hookRulerEvents(this._marginDiv,e);for(var f=0;f26?"wheel":s.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(t){return n._handleMouseWheel(t?t:i.event)}}),e.push({target:t,type:"click",handler:function(t){n._handleRulerEvent(t?t:i.event)
}}),e.push({target:t,type:"dblclick",handler:function(t){n._handleRulerEvent(t?t:i.event)}}),e.push({target:t,type:"mousemove",handler:function(t){n._handleRulerEvent(t?t:i.event)}}),e.push({target:t,type:"mouseover",handler:function(t){n._handleRulerEvent(t?t:i.event)}}),e.push({target:t,type:"mouseout",handler:function(t){n._handleRulerEvent(t?t:i.event)}})}},_getWindow:function(){return h(this._parent.ownerDocument)},_ignoreEvent:function(t){for(var e=t.target;e&&e!==this._clientDiv;){if(e.ignore)return!0;e=e.parentNode}return!1},_init:function(t){var n=t.parent;if("string"==typeof n&&(n=(t.document||document).getElementById(n)),!n)throw new Error("no parent");t.parent=n,t.model=t.model||new e.TextModel;var i=this._defaultOptions();for(var o in i)if(i.hasOwnProperty(o)){var r;r=void 0!==t[o]?t[o]:i[o].value,this["_"+o]=r}this._keyModes=[],this._rulers=[],this._selection=[new y(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._dragOffset=-1,this._isRangeRects=(!s.isIE||s.isIE>=9)&&"function"==typeof n.ownerDocument.createRange().getBoundingClientRect,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()},_checkOverlayScroll:function(){if(s.isMac&&s.isWebkit&&!this._metrics.invalid&&0===this._metrics.scrollWidth){var t=this._viewDiv,e=this._isOverOverlayScroll();t.style.pointerEvents=e.vertical||e.horizontal?"":"none"}},_isOverOverlayScroll:function(){var t=Date.now()-this._lastScrollTime<200;if(!t)return{};var e=this._viewDiv.getBoundingClientRect(),n=this._lastMouseMoveX,i=this._lastMouseMoveY,o=15;return{vertical:e.top<=i&&i1&&this.setRedraw(!1);var s=this._compoundChange;s?y.compare(this._getSelections(),s.owner.selection)||(this._endUndo(),t.selection.length>1&&this._startUndo()):t.selection.length>1&&this._startUndo();var a=this._model;try{t._ignoreDOMSelection&&(this._ignoreDOMSelection=!0);var l=0,h=0;t.selection.forEach(function(n){n.start+=l,n.end+=l;var i=Array.isArray(t.text)?t.text[h]:t.text;a.setText(i,n.start,n.end),l+=n.start-n.end+i.length,n.setCaret(e?n.start+i.length:n.start),h++})}finally{t._ignoreDOMSelection&&(this._ignoreDOMSelection=!1)}return this._setSelection(t.selection,n,!0,i),s=this._compoundChange,s&&(s.owner.selection=t.selection),t.selection.length>1&&this.setRedraw(!0),this.onModify({type:"Modify"}),!0},_onModelChanged:function(t){t.type="ModelChanged",this.onModelChanged(t),t.type="Changed";var e=t.start,n=t.addedCharCount,i=t.removedCharCount,o=t.addedLineCount,r=t.removedLineCount,s=this._getSelections();s.forEach(function(t){t.end>e&&(t.end>e&&t.start=l&&l+r>=c&&(l!==c||h.modelChangedEvent||h.lineRemoved?(h.lineRemoved=!0,h.lineChanged=!1,h.modelChangedEvent=null):(h.modelChangedEvent=t,h.lineChanged=!0)),c>l+r&&(h.lineIndex=c+o-r,h._line.lineIndex=h.lineIndex),h=this._getLineNext(h)}if(this._lineHeight){var u=[l,r].concat(d(o));Array.prototype.splice.apply(this._lineHeight,u)}this._wrapMode||l<=this._maxLineIndex&&this._maxLineIndex<=l+r&&(this._checkMaxLineIndex=this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0),this._update()},_onModelChanging:function(t){t.type="ModelChanging",this.onModelChanging(t),t.type="Changing"},_queueUpdate:function(){if(!this._updateTimer&&!this._ignoreQueueUpdate){var t=this,e=this._getWindow();this._updateTimer=e.setTimeout(function(){t._updateTimer=null,t._update()},0)}},_rangesToSelections:function(t){var e=[],n=this._model.getCharCount();return t.forEach(function(t){var i;if(t instanceof y)i=t.clone();else{var o=t.start,r=t.end,s=o>r;if(s){var a=o;o=r,r=a}o=Math.max(0,Math.min(o,n)),r=Math.max(0,Math.min(r,n)),i=new y(o,r,s)}e.push(i)}),e},_resetLineHeight:function(t,e){if(this._wrapMode||this._variableLineHeight){if(void 0!==t&&void 0!==e)for(var n=t;e>n;n++)this._lineHeight[n]=void 0;else this._lineHeight=d(this._model.getLineCount());this._calculateLineHeightTimer()}else this._lineHeight=null},_resetLineWidth:function(){var t=this._clientDiv;if(t)for(var e=t.firstChild;e;)e.lineWidth=void 0,e=e.nextSibling},_reset:function(){this._maxLineIndex=-1,this._maxLineWidth=0,this._topChild=null,this._bottomChild=null,this._topIndexY=0,this._variableLineHeight=!1,this._resetLineHeight(),this._setSelection(new y(0,0,!1),!1,!1),this._viewDiv&&(this._viewDiv.scrollLeft=0,this._viewDiv.scrollTop=0);var t=this._clientDiv;if(t){for(var e=t.firstChild;e;)e.lineRemoved=!0,e=e.nextSibling;s.isFirefox<13&&this._fixCaret()}},_scrollViewAnimated:function(t,e,n){var i=this._getWindow();if(n&&this._scrollAnimation){var o=this;this._animation=new M({window:i,duration:this._scrollAnimation,curve:[e,0],onAnimate:function(t){var n=e-Math.floor(t);o._scrollView(0,n),e-=n},onEnd:function(){o._animation=null,o._scrollView(t,e),n&&i.setTimeout(n,0)}}),this._animation.play()}else this._scrollView(t,e),n&&i.setTimeout(n,0)},_scrollView:function(t,e){this._ensureCaretVisible=!1;var n=this._viewDiv;t&&(n.scrollLeft+=t),e&&(n.scrollTop+=e)},_setClipboardText:function(t,e){if(s.isElectron&&!e)return window.__electron.clipboard.writeText(t),!0;var n,i=this._getWindow(),o=i.clipboardData;if(!o&&e&&(o=e.clipboardData),o){n=[],g(t,function(t){n.push(t)},function(){n.push(s.platformDelimiter)});var r=o.setData(s.isIE?"Text":"text/plain",n.join(""));if(r||e&&(s.isFirefox>21||s.isWebkit))return!0;if(!e)return!1}var a=this._parent.ownerDocument,l=s.createElement(a,"pre");l.style.position="fixed",l.style.left="-1000px",g(t,function(t){l.appendChild(a.createTextNode(t))},function(){l.appendChild(s.createElement(a,"br"))}),l.appendChild(a.createTextNode(" ")),this._clientDiv.appendChild(l);var h=a.createRange();h.setStart(l.firstChild,0),h.setEndBefore(l.lastChild);var d=i.getSelection();d.rangeCount>0&&d.removeAllRanges(),d.addRange(h);var c=this,u=function(){l&&l.parentNode===c._clientDiv&&c._clientDiv.removeChild(l),c._updateDOMSelection()},f=!1;this._ignoreCopy=!0;try{f=a.execCommand("copy",!1,null)}catch(p){}return this._ignoreCopy=!1,!f&&e?(i.setTimeout(u,0),!1):(u(),!0)},_setGrab:function(t){t!==this._grabControl&&(t?(t.setCapture&&t.setCapture(),this._grabControl=t):(this._grabControl.releaseCapture&&this._grabControl.releaseCapture(),this._grabControl=null))},_setLinksVisible:function(t){if(this._linksVisible!==t){this._linksVisible=t,s.isIE&&t&&(this._hadFocus=this._hasFocus);var e=this._clientDiv;e.contentEditable=!t,this._hadFocus&&!t&&e.focus(),this._overlayDiv&&(this._overlayDiv.style.zIndex=t?"-1":"1");for(var n=this._getLineNext();n;)n._line.updateLinks(),n=this._getLineNext(n);this._updateDOMSelection()}},_setSelection:function(t,e,n,i,o,r,s){if(t){void 0===n&&(n=!0);var a,l=this._getSelections();if(a=Array.isArray(t)?t:r?l.concat([t]):[t],this._selection=y.merge(a),s||a.forEach(function(t){t._columnX=-1}),e!==!1&&this._showCaret(!1,i,e,o),n&&this._updateDOMSelection(),!y.compare(l,a)){var h={type:"Selection",oldValue:y.convert(l),newValue:y.convert(a)};this.onSelection(h)}}},_setSelectionTo:function(t,e,n,i,o,r){var s=this._model,a=this._getSelections(),l=this.convert({x:t,y:e},"page","document"),h=this._getLineIndex(l.y),d=this._getLine(h),c=d.getOffset(l.x,l.y-this._getLinePixel(h));if(r&&!i&&y.contains(a,c))return this._dragOffset=c,d.destroy(),!1;if(this._blockSelection)a=this._getBlockSelections(a,h,l);else{var u;if(n?i?(u=a[a.length-1],u._editing=!0):(u=new y(0,0),u._editing=!0,o?a.push(u):a=[u],u._docX=l.x):u=y.editing(a),1===this._clickCount)u.extend(c),i||u.collapse();else{var f,g,p=0===(1&this._clickCount);if(p)this._doubleClickSelection?c>=this._doubleClickSelection.start?(f=this._doubleClickSelection.start,g=d.getNextOffset(c,{unit:"wordend",count:1})):(f=d.getNextOffset(c,{unit:"word",count:-1}),g=this._doubleClickSelection.end):(f=d.getNextOffset(c,{unit:"word",count:-1}),g=d.getNextOffset(f,{unit:"wordend",count:1}));else if(this._doubleClickSelection){var _=s.getLineAtOffset(this._doubleClickSelection.start);h>=_?(f=s.getLineStart(_),g=s.getLineEnd(h)):(f=s.getLineStart(h),g=s.getLineEnd(_))}else f=s.getLineStart(h),g=s.getLineEnd(h);u.setCaret(f),u.extend(g)}}return this._setSelection(a,!0,!0,null,!1),d.destroy(),!0},_setFullSelection:function(t,e){this._fullSelection=t,s.isWebkit<537.36&&(this._fullSelection=t=!0),this._domSelection||(this._domSelection=[],this._cursorVisible=!0),e||this._updateDOMSelection()},_setBlockCursor:function(t){this._blockCursorVisible=t,this._updateBlockCursorVisible()},_setOverwriteMode:function(t){this._overwriteMode=t,this._updateBlockCursorVisible()},_updateBlockCursorVisible:function(){if(this._blockCursorVisible||this._overwriteMode){if(!this._cursorDiv){var t=this._viewDiv,e=s.createElement(t.ownerDocument,"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=" ",t.appendChild(e),this._updateDOMSelection()}}else this._cursorDiv&&(this._cursorDiv.parentNode.removeChild(this._cursorDiv),this._cursorDiv=null)},_setMarginOffset:function(t,e){this._marginOffset=t,this._marginDiv.style.display=t?"block":"none",e||(this._metrics=this._calculateMetrics(),this._queueUpdate())},_setWrapOffset:function(t,e){this._wrapOffset=t,e||(this._metrics=this._calculateMetrics(),this._queueUpdate())},_setReadOnly:function(t){this._readonly=t},_setSingleMode:function(t,e){this._singleMode=t,this._updateOverflow(),this._updateStyle(e)},_setNoScroll:function(t,e){this._noScroll=t,this._updateOverflow(),this._updateStyle(e)},_setTabSize:function(t,e){this._tabSize=t,this._customTabSize=void 0;var n=this._clientDiv;s.isOpera?n&&(n.style.OTabSize=this._tabSize+""):s.isWebkit>=537.1?n&&(n.style.tabSize=this._tabSize+""):s.isFirefox>=4?n&&(n.style.MozTabSize=this._tabSize+""):8!==this._tabSize&&(this._customTabSize=this._tabSize),e||(this.redrawLines(),this._resetLineWidth())},_setTheme:function(t){this._theme&&this._theme.removeEventListener("ThemeChanged",this._themeListener.onChanged),this._theme=t,this._theme&&this._theme.addEventListener("ThemeChanged",this._themeListener.onChanged),this._setThemeClass(this._themeClass)},_setThemeClass:function(t,e){this._themeClass=t;var n="textview",i=this._theme.getThemeClass();i&&(n+=" "+i),this._themeClass&&i!==this._themeClass&&(n+=" "+this._themeClass),this._rootDiv.className=n,this._updateStyle(e)},_setUndoStack:function(t){this._undoStack=t},_setWrapMode:function(t,e){this._wrapMode=t&&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(),e||(this.redraw(),this._resetLineWidth()),this._resetLineHeight()},_showCaret:function(t,e,n,i){if(this._clientDiv&&!(this._redrawCount>0||this._ignoreDOMSelection||-1!==this._imeOffset)){var o=this._model,r=this._getSelections(),s=y.editing(r,"down"===this._autoScrollDir),a=this._getScroll(),l=s.getCaret(),h=s.start,d=s.end,c=o.getLineAtOffset(h),u=o.getLineAtOffset(d),f=Math.max(Math.max(h,o.getLineStart(u)),d-1),g=this._getClientWidth(),p=this._getClientHeight(),_=g/4,v=this._getBoundsAtOffset(l===h?h:f),m=v.left,x=v.right,C=v.top,w=v.bottom,A=0,T="object"==typeof n;!t&&!T||s.isEmpty()||(v=this._getBoundsAtOffset(l===d?h:f),A=(v.bottom>w?v.bottom:w)-(v.topa.x+g&&(L=Math.max(x-a.x-g,_));var S=0;Ca.y+p&&(S=w-a.y-p),i&&(i>0?S>0&&(S=Math.max(S,i)):0>S&&(S=Math.min(S,i)));var M=T&&"always"===n.scrollPolicy;if(0!==L||0!==S||M){if(T){var D=S>0;0===S&&(S=C-a.y);var E=n.viewAnchor,O=n.selectionAnchor,N=Math.min(Math.max(0,n.viewAnchorOffset||0));S+=Math.floor("top"===E?D?(1-N)*p:-N*p:"bottom"===E?D?N*p:-(1-N)*p:"center"===E?D?p/2+N*p:p/2-(1-N)*p:D?N*p:-N*p),c!==u&&("top"===O&&l!==h?S+=Math.floor(-A):"bottom"===O&&l!==d?S+=Math.floor(A):"center"===O&&(S+=Math.floor(A/2)))}else 0!==S&&"number"==typeof n&&(0>n&&(n=0),n>1&&(n=1),S+=Math.floor(S>0?n*p:-n*p));return this._scrollViewAnimated(L,S,e),p!==this._getClientHeight()||g!==this._getClientWidth()?this._showCaret():this._ensureCaretVisible=!0,!0}return e&&e(),!1}},_startIME:function(){if(-1===this._imeOffset){for(var t=!1,e=this._getSelections(),n=0;n0)&&!this._ignoreDOMSelection&&-1===this._imeOffset&&this._clientDiv){var t,e=this._getSelections(),n=this._domSelection;if(n.lengthe.length&&n.splice(e.length).forEach(function(t){t.destroy()});for(t=0;t1?this._cursorTimer||(this._cursorTimer=i.setInterval(function(){o._cursorVisible=!o._cursorVisible,o._domSelection.forEach(function(t){t.update()})},500)):this._cursorTimer&&(i.clearInterval(this._cursorTimer),this._cursorTimer=null)}},_update:function(t){if(!(this._redrawCount>0)){if(this._updateTimer){var e=this._getWindow();e.clearTimeout(this._updateTimer),this._updateTimer=null,t=!1}var n=this._clientDiv,i=this._viewDiv;if(n){this._metrics.invalid&&(this._ignoreQueueUpdate=!0,this._updateStyle(),this._ignoreQueueUpdate=!1);var o=this._model,r=this._getScroll(!1),a=this._getViewPadding(),l=o.getLineCount(),h=this._getLineHeight(),d=!1,c=!1,u=!1,f=this._metrics.scrollWidth;this._wrapMode&&(n.style.width=(this._metrics.wrapWidth||this._getClientWidth())+"px");var g,p,_,v,m,y,x,C,A,T,L,S=0,M=0;if(this._lineHeight){for(;l>M&&(L=this._getLineHeight(M),!(S+L>r.y));)S+=L,M++;g=M,p=Math.max(0,g-1),v=_=r.y-S,g>0&&(_+=this._getLineHeight(g-1))}else{var D=Math.max(0,r.y)/h;g=Math.floor(D),p=Math.max(0,g-1),_=Math.round((D-p)*h),v=Math.round((D-g)*h),T=l*h}this._topIndexY=v;var E=this._rootDiv,O=E.clientWidth,N=E.clientHeight;if(t){for(m=0,this._leftDiv&&(y=this._leftDiv.getBoundingClientRect(),m=y.right-y.left),x=this._getClientWidth(),C=this._getClientHeight(),A=x,this._wrapMode?this._metrics.wrapWidth&&(A=this._metrics.wrapWidth):A=Math.max(this._maxLineWidth,A);l>M;)L=this._getLineHeight(M,!1),S+=L,M++;T=S}else{C=this._getClientHeight();for(var b,I,k=Math.floor((C+v)/h),R=Math.min(g+k,l-1),B=Math.min(R+1,l-1),P=n.firstChild;P;){b=P.lineIndex;var V=P.nextSibling;b>=p&&B>=b&&!P.lineRemoved&&-1!==P.lineIndex||(this._mouseWheelLine===P?(P.style.display="none",P.lineIndex=-1):n.removeChild(P)),P=V}P=this._getLineNext();var F=i.ownerDocument,W=F.createDocumentFragment();for(b=p;B>=b;b++)!P||P.lineIndex>b?new w(this,b).create(W,null):(W.firstChild&&(n.insertBefore(W,P),W=F.createDocumentFragment()),P&&P.lineChanged&&(P=new w(this,b).create(W,P),P.lineChanged=!1),P=this._getLineNext(P));W.firstChild&&n.insertBefore(W,P),s.isWebkit&&!this._wrapMode&&(n.style.width="0x7fffffffpx");var H;P=this._getLineNext();for(var U=C+_,K=!1;P;){if(I=P.lineWidth,void 0===I){H=P._line.getBoundingClientRect(),I=P.lineWidth=Math.ceil(H.right-H.left);var z=H.bottom-H.top;this._lineHeight?this._lineHeight[P.lineIndex]=z:0!==h&&0!==z&&Math.ceil(h)!==Math.ceil(z)&&(this._variableLineHeight=!0,this._lineHeight=[],this._lineHeight[P.lineIndex]=z)}this._lineHeight&&!K&&(U-=this._lineHeight[P.lineIndex],0>U&&(R=P.lineIndex,K=!0)),this._wrapMode||(I>=this._maxLineWidth&&(this._maxLineWidth=I,this._maxLineIndex=P.lineIndex),this._checkMaxLineIndex===P.lineIndex&&(this._checkMaxLineIndex=-1)),P.lineIndex===g&&(this._topChild=P),P.lineIndex===R&&(this._bottomChild=P),P=this._getLineNext(P)}if(-1!==this._checkMaxLineIndex&&(b=this._checkMaxLineIndex,this._checkMaxLineIndex=-1,b>=0&&l>b)){var j=new w(this,b);H=j.getBoundingClientRect(),I=H.right-H.left,I>=this._maxLineWidth&&(this._maxLineWidth=I,this._maxLineIndex=b),j.destroy()}for(;l>M;)L=this._getLineHeight(M,R>=M),S+=L,M++;T=S,this._updateRuler(this._leftDiv,g,B,N),this._updateRuler(this._rightDiv,g,B,N),this._updateRuler(this._innerRightDiv,g,B,N),this._updateRuler(this._marginDiv,g,B,N),m=0,this._leftDiv&&(y=this._leftDiv.getBoundingClientRect(),m=y.right-y.left);var G=0;if(this._rightDiv){var Y=this._rightDiv.getBoundingClientRect();G=Y.right-Y.left}i.style.left=m+"px",i.style.right=G+"px";var X=this._scrollDiv;if(X.style.height=T+(s.isWebkit?0:a.bottom)+"px",x=this._getClientWidth(),!this._singleMode&&!this._wrapMode&&!this._noScroll){var $=C,q=C,Z="scroll"===i.style.overflowX;Z?$+=f:q-=f;var Q=x,J=x,te="scroll"===i.style.overflowY;te?Q+=f:J-=f,C=$,x=Q,T>C&&(u=!0,x=J),this._maxLineWidth>x&&(c=!0,C=q,T>C&&(u=!0,x=J)),Z!==c&&(i.style.overflowX=c?"scroll":"hidden"),te!==u&&(i.style.overflowY=u?"scroll":"hidden"),d=Z!==c||te!==u}var ee=x;this._wrapMode?this._metrics.wrapWidth&&(ee=this._metrics.wrapWidth):ee=Math.max(this._maxLineWidth+this._getInnerRightWidth(),ee),A=ee,(!s.isIE||s.isIE>=9)&&this._maxLineWidth>x&&(ee+=a.right+a.left),X.style.width=ee+"px",this._clipScrollDiv&&(this._clipScrollDiv.style.width=ee+"px"),r=this._getScroll(!1);var ne=this._innerRightDiv;ne&&(ne.style.right=G+("scroll"===i.style.overflowY?this._metrics.scrollWidth:0)+"px",ne.style.bottom=("scroll"===i.style.overflowX?f:0)+"px")}if(this._scrollHeight=T,this._vScrollDiv){var ie=C-8,oe=Math.max(15,Math.ceil(Math.min(1,ie/(T+a.top+a.bottom))*ie));this._vScrollDiv.style.left=m+x-8+"px",this._vScrollDiv.style.top=Math.floor(Math.max(0,r.y*ie/T))+"px",this._vScrollDiv.style.height=oe+"px"}if(!this._wrapMode&&this._hScrollDiv){var re=x-8,se=Math.max(15,Math.ceil(Math.min(1,re/(this._maxLineWidth+a.left+a.right))*re));this._hScrollDiv.style.left=m+Math.floor(Math.max(0,Math.floor(r.x*re/this._maxLineWidth)))+"px",this._hScrollDiv.style.top=C-9+"px",this._hScrollDiv.style.width=se+"px"}var ae,le,he=r.x,de=this._clipDiv,ce=this._overlayDiv,ue=this._marginDiv;if(ue&&(ue.style.left=-he+m+this._metrics.marginWidth+a.left+"px",ue.style.bottom=("scroll"===i.style.overflowX?f:0)+"px"),de){de.scrollLeft=he,de.scrollTop=0,ae=m+a.left,le=a.top;var fe=x,ge=C,pe=0,_e=-_;0===r.x&&(ae-=a.left,fe+=a.left,pe=a.left),r.x+x===A&&(fe+=a.right),0===r.y&&(le-=a.top,ge+=a.top,_e+=a.top),r.y+C===T&&(ge+=a.bottom),de.style.left=ae+"px",de.style.top=le+"px",de.style.right=O-fe-ae+"px",de.style.bottom=N-ge-le+"px",n.style.left=pe+"px",n.style.top=_e+"px",n.style.width=A+"px",n.style.height=C+_+"px",ce&&(ce.style.left=n.style.left,ce.style.top=n.style.top,ce.style.width=n.style.width,ce.style.height=n.style.height)}else{ae=he,le=_;var ve=he+x,me=_+C;0===ae&&(ae-=a.left),0===le&&(le-=a.top),ve===A&&(ve+=a.right),r.y+C===T&&(me+=a.bottom),n.style.clip="rect("+le+"px,"+ve+"px,"+me+"px,"+ae+"px)","rtl"==document.dir?n.style.right=-he+m+a.left+"px":n.style.left=-he+m+a.left+"px",n.style.width=(this._wrapMode||s.isWebkit?A:x+he)+"px",t||(n.style.top=-_+a.top+"px",n.style.height=C+_+"px"),ce&&(ce.style.clip=n.style.clip,ce.style.left=n.style.left,ce.style.width=n.style.width,t||(ce.style.top=n.style.top,ce.style.height=n.style.height))}if(this._updateDOMSelection(),d){var ye=this._ensureCaretVisible;this._ensureCaretVisible=!1,ye&&this._showCaret(),this._queueUpdate()}}}},_updateOverflow:function(){var t=this._viewDiv;this._noScroll?t.style.overflow="hidden":this._wrapMode?(t.style.overflowX="hidden",t.style.overflowY="scroll"):t.style.overflow="hidden"},_updateRuler:function(t,e,n,i){if(t)for(var o=this._parent.ownerDocument,r=this._getLineHeight(),a=this._getViewPadding(),l=t.firstChild;l;){var h=l._ruler,d=h.getOverview();if(l.rulerChanged&&(c(h.getRulerStyle(),l),t.rulerWidth=void 0),"fixed"!==d){var u=r;"page"===d&&(u+=this._topIndexY),l.style.top=-u+"px",l.style.height=i+u+"px";var f,g=l.firstChild;g?(f=g,g=g.nextSibling):(f=s.createElement(o,"div"),f.style.visibility="hidden",l.appendChild(f));var p,_;l.rulerChanged&&f&&(p=-1,_=h.getWidestAnnotation(),_&&(c(_.style,f),_.html&&(f.innerHTML=_.html)),f.lineIndex=p,f.style.height=r+a.top+"px");var v,m,y;if("page"===d){for(y=h.getAnnotations(e,n+1);g;){p=g.lineIndex;var x=g.nextSibling;p>=e&&n>=p&&!g.lineChanged||l.removeChild(g),g=x}for(g=l.firstChild.nextSibling,m=o.createDocumentFragment(),p=e;n>=p;p++)!g||g.lineIndex>p?(v=s.createElement(o,"div"),_=y[p],_&&(c(_.style,v),_.html&&(v.innerHTML=_.html),v.annotation=_),v.lineIndex=p,v.style.height=this._getLineHeight(p)+"px",m.appendChild(v)):(m.firstChild&&(l.insertBefore(m,g),m=o.createDocumentFragment()),g&&(g=g.nextSibling));m.firstChild&&l.insertBefore(m,g)}else{var C,w,A=this._getClientHeight(),T=this._model.getLineCount(),L=r*T,S=A+a.top+a.bottom-2*this._metrics.scrollWidth;if(S>L?(C=r,w=a.top):(C=S/T,w=this._metrics.scrollWidth),l.rulerChanged){for(var M=l.childNodes.length;M>1;)l.removeChild(l.lastChild),M--;y=h.getAnnotations(0,T),m=o.createDocumentFragment();for(var D in y)p=D>>>0,0>p||(v=s.createElement(o,"div"),_=y[D],c(_.style,v),v.style.position="absolute",v.style.top=w+r+Math.floor(p*C)+"px",_.html&&(v.innerHTML=_.html),v.annotation=_,v.lineIndex=p,m.appendChild(v));l.appendChild(m)}else if(l._oldTrackHeight!==S)for(v=l.firstChild?l.firstChild.nextSibling:null;v;)v.style.top=this._metrics.scrollWidth+r+Math.floor(v.lineIndex*C)+"px",v=v.nextSibling;l._oldTrackHeight=S}l.rulerChanged=!1,l=l.nextSibling}else l.rulerChanged=!1,l=l.nextSibling}},_updateStyleSheet:function(){var t="";if(s.isWebkit&&this._metrics.scrollWidth>0&&(t+="\n.textview ::-webkit-scrollbar-corner {background: #eeeeee;}"),t){var e=this._clientDiv.ownerDocument,n=e.getElementById("_textviewStyle");if(n)n.removeChild(n.firstChild),n.appendChild(e.createTextNode(t));else{n=s.createElement(e,"style"),n.id="_textviewStyle";var i=e.getElementsByTagName("head")[0]||e.documentElement;n.appendChild(e.createTextNode(t)),i.insertBefore(n,i.firstChild)}}},_updateStyle:function(t,e){if(!t&&s.isIE&&(this._rootDiv.style.lineHeight="normal"),e=this._metrics=e||this._calculateMetrics(),this._variableLineHeight&&(this._variableLineHeight=!1,this._resetLineHeight()),this._rootDiv.style.lineHeight=s.isIE?e.lineHeight-(e.lineTrim.top+e.lineTrim.bottom)+"px":"normal",this._updateStyleSheet(),s.isMac&&s.isWebkit){var n=this._viewDiv;e.invalid||0!==e.scrollWidth?(n.style.pointerEvents="",n.style.zIndex=""):(n.style.pointerEvents="none",n.style.zIndex="2")}t||(this.redraw(),this._resetLineWidth())}},i.EventTarget.addMixin(A.prototype),{TextView:A}}),define("orion/editor/projectionTextModel",["orion/editor/textModel","orion/editor/eventTarget"],function(t,e){function n(t){this._model=t,this._projections=[];var e=this;this._listener={onChanged:function(t){e._onChanged(t)},onChanging:function(t){e._onChanging(t)}},t.addEventListener("postChanged",this._listener.onChanged),t.addEventListener("preChanging",this._listener.onChanging)}return n.prototype={destroy:function(){this._model&&(this._model.removeEventListener("postChanged",this._listener.onChanged),this._model.removeEventListener("preChanging",this._listener.onChanging),this._model=null)},addProjection:function(e){if(e){var n=this._model,i=this._projections;e._lineIndex=n.getLineAtOffset(e.start),e._lineCount=n.getLineAtOffset(e.end)-e._lineIndex;var o=e.text;o||(o=""),e._model="string"==typeof o?new t.TextModel(o,n.getLineDelimiter()):o;var r=this.mapOffset(e.start,!0),s=e.end-e.start,a=e._lineCount,l=e._model.getCharCount(),h=e._model.getLineCount()-1,d={type:"Changing",text:e._model.getText(),start:r,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:h};this.onChanging(d);var c=this._binarySearch(i,e.start);i.splice(c,0,e);var u={type:"Changed",start:r,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:h};this.onChanged(u)}},getProjections:function(){return this._projections.slice(0)},getBaseModel:function(){return this._model},mapOffset:function(t,e){var n,i,o=this._projections,r=0;if(e){for(n=0;nt));n++){if(i.end>t)return-1;r+=i._model.getCharCount()-(i.end-i.start)}return t+r}for(n=0;nt-r));n++){var s=i._model.getCharCount();if(i.start+s>t-r)return-1;r+=s-(i.end-i.start)}return t-r},removeProjection:function(t){this._removeProjection(t)},_removeProjection:function(t,e){var n,i=0;for(n=0;n1;)n=Math.floor((i+o)/2),e<=t[n].start?i=n:o=n;return i},getCharCount:function(){for(var t=this._model.getCharCount(),e=this._projections,n=0;nt)return null;var n,i,o,r=this._model,s=this._projections,a=0,l=[],h=0;for(n=0;n=t-a));n++){if(i=o._model.getLineCount()-1,o._lineIndex+i>=t-a){var d=t-(o._lineIndex+a);if(i>d)return o._model.getLine(d,e);l.push(o._model.getLine(i))}h=o.end,a+=i-o._lineCount}for(h=Math.max(h,r.getLineStart(t-a));nt-a));n++){if(l.push(r.getText(h,o.start)),i=o._model.getLineCount()-1,o._lineIndex+i>t-a)return l.push(o._model.getLine(0,e)),l.join("");l.push(o._model.getText()),h=o.end,a+=i-o._lineCount}var c=r.getLineEnd(t-a,e);return c>h&&l.push(r.getText(h,c)),l.join("")},getLineAtOffset:function(t){for(var e=this._model,n=this._projections,i=0,o=0,r=0;rt-i)break;var a=s._model.getCharCount();if(s.start+a>t-i){var l=t-(s.start+i);o+=s._model.getLineAtOffset(l),i+=l;break}o+=s._model.getLineCount()-1-s._lineCount,i+=a-(s.end-s.start)}return e.getLineAtOffset(t-i)+o},getLineCount:function(){for(var t=this._model,e=this._projections,n=t.getLineCount(),i=0;it)return-1;for(var n=this._model,i=this._projections,o=0,r=0,s=0;st-o)break;var l=a._model.getLineCount()-1;if(a._lineIndex+l>t-o){var h=t-(a._lineIndex+o);return a._model.getLineEnd(h,e)+a.start+r}r+=a._model.getCharCount()-(a.end-a.start),o+=l-a._lineCount}return n.getLineEnd(t-o,e)+r},getLineStart:function(t){if(0>t)return-1;for(var e=this._model,n=this._projections,i=0,o=0,r=0;r=t-i)break;var a=s._model.getLineCount()-1;if(s._lineIndex+a>=t-i){var l=t-(s._lineIndex+i);return s._model.getLineStart(l)+s.start+o}o+=s._model.getCharCount()-(s.end-s.start),i+=a-s._lineCount}return e.getLineStart(t-i)+o},getText:function(t,e){void 0===t&&(t=0);var n,i,o,r=this._model,s=this._projections,a=0,l=[];for(n=0;nt-a));n++){if(o=i._model.getCharCount(),i.start+o>t-a){if(void 0!==e&&i.start+o>e-a)return i._model.getText(t-(i.start+a),e-(i.start+a));l.push(i._model.getText(t-(i.start+a))),t=i.end+a+o-(i.end-i.start)}a+=o-(i.end-i.start)}var h=t-a;if(void 0!==e){for(;ne-a));n++){if(l.push(r.getText(h,i.start)),o=i._model.getCharCount(),i.start+o>e-a)return l.push(i._model.getText(0,e-(i.start+a))),l.join("");l.push(i._model.getText()),h=i.end,a+=o-(i.end-i.start)}l.push(r.getText(h,e-a))}else{for(;ni));t++);var s=t;for(t=0;t=o));t++);var a=t,l=this._model,h=n.baseText.length-(o-i);for(t=a;tt));a++){if(l.end>t)return-1;s+=l._model.getCharCount()-(l.end-l.start)}return t+s}var n=!!this._change,i=this._change||{},o=t.start,r=o+t.removedCharCount;if(i.baseStart=o,i.baseEnd=r,i.baseText=t.text,i.addedLineCount=t.addedLineCount,!n){this._change=i,i.text=t.text;var s,a,l,h=this._projections;i.start=e(o),-1===i.start&&(i.text=this._model.getText(l.start,o)+i.text,i.addedLineCount+=this._model.getLineAtOffset(o)-this._model.getLineAtOffset(l.start),i.start=l.start+s),i.end=e(r),-1===i.end&&(i.text+=this._model.getText(r,l.end),i.addedLineCount+=this._model.getLineAtOffset(l.end)-this._model.getLineAtOffset(r),i.end=l.start+s)}i.addedCharCount=i.text.length,i.removedCharCount=i.end-i.start,i.removedLineCount=this.getLineAtOffset(i.end)-this.getLineAtOffset(i.start);var d={type:"Changing",text:i.text,start:i.start,removedCharCount:i.removedCharCount,addedCharCount:i.addedCharCount,removedLineCount:i.removedLineCount,addedLineCount:i.addedLineCount};this.onChanging(d)},onChanging:function(t){return this.dispatchEvent(t)},onChanged:function(t){return this.dispatchEvent(t)},setLineDelimiter:function(t){this._model.setLineDelimiter(t)},setText:function(t,e,n){function i(t){for(r=0,o=0;rt-o));r++){var e=s._model.getCharCount();if(s.start+e>t-o)return-1;o+=e-(s.end-s.start)}return t-o}this._change={text:t||"",start:e||0,end:void 0===n?this.getCharCount():n};var o,r,s,a,l,h=this._projections,d=i(this._change.start);-1===d&&(a={projection:s,start:this._change.start-(s.start+o)},d=s.end);var c=i(this._change.end);-1===c&&(l={projection:s,end:this._change.end-(s.start+o)},c=s.start),a&&l&&a.projection===l.projection?s._model.setText(this._change.text,a.start,l.end):(this._model.setText(this._change.text,d,c),a&&(s=a.projection,s._model.setText("",a.start)),l&&(s=l.projection,s._model.setText("",0,l.end),s.start=s.end,s._lineCount=0)),this._change=void 0
}},e.EventTarget.addMixin(n.prototype),{ProjectionTextModel:n}}),function(t,e){"function"==typeof define&&define.amd?define("orion/Deferred",e):"object"==typeof exports?module.exports=e():(t.orion=t.orion||{},t.orion.Deferred=e())}(this,function(){function t(){for(var t;t=r.shift();)t();s=!1}function e(t){r.push(t),s||(s=!0,a())}function n(t){return function(e){t(e)}}function i(t,e,i){try{var o=t(e),r=o&&("object"==typeof o||"function"==typeof o)&&o.then;if("function"==typeof r)if(o===i.promise)i.reject(new TypeError);else{var s=o.cancel;"function"==typeof s?i._parentCancel=s.bind(o):delete i._parentCancel,r.call(o,n(i.resolve),n(i.reject),n(i.progress))}else i.resolve(o)}catch(a){i.reject(a)}}function o(){function t(){for(var t;t=h.shift();){var e=t.deferred,n="fulfilled"===l?"resolve":"reject",o=t[n];"function"==typeof o?i(o,a,e):e[n](a)}}function n(n){delete d._parentCancel,l="rejected",a=n,h.length&&e(t)}function r(i){function s(t){return function(e){l&&"assumed"!==l||t(e)}}delete d._parentCancel;try{var c=i&&("object"==typeof i||"function"==typeof i)&&i.then;if("function"==typeof c)if(i===d)n(new TypeError);else{l="assumed";var u=i&&i.cancel;if("function"!=typeof u){var f=new o;i=f.promise;try{c(f.resolve,f.reject,f.progress)}catch(g){f.reject(g)}u=i.cancel,c=i.then}a=i,c.call(i,s(r),s(n)),d._parentCancel=u.bind(i)}else l="fulfilled",a=i,h.length&&e(t)}catch(p){s(n)(p)}}function s(){var t=d._parentCancel;if(t)delete d._parentCancel,t();else if(!l){var e=new Error("Cancel");e.name="Cancel",n(e)}}var a,l,h=[],d=this;this.resolve=function(t){return l||r(t),d},this.reject=function(t){return l||n(t),d},this.progress=function(t){return l||h.forEach(function(e){if(e.progress)try{e.progress(t)}catch(n){}}),d.promise},this.cancel=function(){return d._parentCancel?setTimeout(s,0):s(),d},this.then=function(n,i,r){var s=new o;return s._parentCancel=d.promise.cancel,h.push({resolve:n,reject:i,progress:r,deferred:s}),("fulfilled"===l||"rejected"===l)&&e(t),s.promise},this.promise={then:d.then,cancel:d.cancel}}var r=[],s=!1,a=function(){if("undefined"!=typeof process&&"function"==typeof process.nextTick){var e=process.nextTick;return function(){e(t)}}if("function"==typeof MutationObserver){var n=document.createElement("div"),i=new MutationObserver(t);return i.observe(n,{attributes:!0}),function(){n.setAttribute("class","_tick")}}return function(){setTimeout(t,0)}}();return o.all=function(t,e){function n(t,e){a||(s[t]=e,0===--r&&l.resolve(s))}function i(t,i){if(!a){if(e)try{return void n(t,e(i))}catch(o){i=o}l.reject(i)}}var r=t.length,s=[],a=!1,l=new o;return l.then(void 0,function(){a=!0,t.forEach(function(t){t.cancel&&t.cancel()})}),0===r?l.resolve(s):t.forEach(function(t,e){t.then(n.bind(void 0,e),i.bind(void 0,e))}),l.promise},o.when=function(t,e,n,i){var r,s;return t&&"function"==typeof t.then?r=t:(s=new o,s.resolve(t),r=s.promise),r.then(e,n,i)},o}),define("orion/webui/littlelib",["orion/util"],function(t){function e(t,e){return e||(e=document),e.querySelector(t)}function n(t,e){return e||(e=document),e.querySelectorAll(t)}function i(t,e){return Array.prototype.slice.call(n(t,e))}function o(t){var e=t;return"string"==typeof t&&(e=document.getElementById(t)),e}function r(t,e){if(!t||!e)return!1;if(t===e)return!0;var n=t.compareDocumentPosition(e);return Boolean(16&n)}function s(t){var e=t.getBoundingClientRect(),n=Math.max(document.documentElement.scrollLeft,document.body.scrollLeft),i=Math.max(document.documentElement.scrollTop,document.body.scrollTop);return{left:e.left+n,top:e.top+i,width:e.width,height:e.height}}function a(t){for(;t.hasChildNodes();){var e=t.firstChild;t.removeChild(e)}}function l(e){var n=e.tabIndex;if(0===n&&t.isIE){var i={a:!0,body:!0,button:!0,frame:!0,iframe:!0,img:!0,input:!0,isindex:!0,object:!0,select:!0,textarea:!0};i[e.nodeName.toLowerCase()]||e.attributes.tabIndex||(n=-1)}return n}function h(t){if(l(t)>=0)return t;if(t.hasChildNodes())for(var e=0;e=0)return t;if(t.hasChildNodes())for(var e=t.childNodes.length-1;e>=0;e--){var n=d(t.childNodes[e]);if(n)return n}return null}function c(t,e){if(3===t.nodeType){var n=w.exec(t.nodeValue);n&&n.length>1&&e(t,n)}if(t.hasChildNodes())for(var i=0;i2&&-1!==r.indexOf("px",r.length-2)){r=r.slice(0,-2);var s=parseInt(r,10);return s!==s?0:s}}return 0}function f(t,e){c(t,function(t,n){var i=e[n[1]]||n[1];t.parentNode.replaceChild(document.createTextNode(i),t)})}function g(t,e){c(t,function(t,n){var i=e[n[1]];if(i){var o=document.createRange(),r=n.index;o.setStart(t,r),o.setEnd(t,r+n[0].length),o.deleteContents(),o.insertNode(i)}})}function p(e,n){function i(t){A.forEach(function(e){var n=!1,i=e.excludeNodes.some(function(e){return document.body.contains(e)?(n=!0,e.contains(t.target)):!1});if(n&&!i)try{e.dismiss(t)}catch(o){"undefined"!=typeof console&&console&&console.error(o&&o.message)}}),A=A.filter(function(t){return t.excludeNodes.some(function(t){return document.body.contains(t)})})}null===A&&(A=[],document.addEventListener("click",i,!0),t.isIOS&&document.addEventListener("touchend",function(t){function e(){t.target.removeEventListener("click",e)}0===t.touches.length&&t.target.addEventListener("click",e)},!1)),A.push({excludeNodes:e,dismiss:n})}function _(t){A=A.filter(function(e){return t!==e.dismiss})}function v(t){for(var e=t.parentNode,n=document.documentElement;e&&e!==n;){var i=window.getComputedStyle(e,null);if(!i)break;var o=i.getPropertyValue("overflow-y");if("auto"===o||"scroll"===o)break;e=e.parentNode}return e}function m(t){window.document.all&&(t.keyCode=0),t.preventDefault&&(t.preventDefault(),t.stopPropagation())}function y(t){for(var e=document.getElementsByTagName("iframe"),n=0;n1?n.children:n.firstChild}var w=/\$\{([^\}]+)\}/,A=null,T={BKSPC:8,TAB:9,ENTER:13,SHIFT:16,CONTROL:17,ALT:18,ESCAPE:27,SPACE:32,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DEL:46,COMMAND:91},L=Object.create(null);return Object.keys(T).forEach(function(t){L[T[t]]=t}),{$:e,$$:n,$$array:i,node:o,contains:r,bounds:s,empty:a,firstTabbable:h,lastTabbable:d,pixelValueOf:u,stop:m,processTextNodes:f,processDOMNodes:g,addAutoDismiss:p,setFramesEnabled:y,getOffsetParent:v,removeAutoDismiss:_,keyName:x,KEY:T,createNodes:C}}),define("orion/editor/tooltip",["i18n!orion/editor/nls/messages","orion/editor/textView","orion/editor/projectionTextModel","orion/Deferred","orion/editor/util","orion/webui/littlelib","orion/util"],function(t,e,n,i,o,r,s){function a(t,e){this._view=t,this._editor=e;var n=t.getOptions("parent");this._create(n?n.ownerDocument:document)}return a.getTooltip=function(t,e){return t._tooltip||(t._tooltip=new a(t,e)),t._tooltip},a.prototype={_create:function(t){if(!this._tooltipDiv){var e=this._tooltipDiv=s.createElement(t,"div");e.tabIndex=0,e.className="textviewTooltip",e.setAttribute("aria-live","assertive"),e.setAttribute("aria-atomic","true"),this._tooltipDiv.style.visibility="hidden",this._tipShowing=!1,t.body.appendChild(e);var n=this;o.addEventListener(t,"mousedown",this._mouseDownHandler=function(t){n.isVisible()&&(o.contains(e,t.target||t.srcElement)||n._locked||n.hide())},!0),o.addEventListener(t,"scroll",this._scrollHandler=function(t){n.isVisible()&&(o.contains(e,t.target||t.srcElement)||(n._topPixel!==n._view.getTopPixel()||n._leftPixel!==n._view.getHorizontalPixel())&&n.hide())},!0),o.addEventListener(t,"mousemove",this._mouseMoveHandler=function(t){n._prevX&&n._prevX===t.clientX&&n._prevY&&n._prevY===t.clientY||(n._prevX=t.clientX,n._prevY=t.clientY,!n.isVisible()||n._locked||n._hasFocus()||n._isInRect(n._outerArea,t.clientX,t.clientY)||n.hide())},!0),o.addEventListener(e,"focus",function(){n._locked||n._tooltipDiv.classList.add("textViewTooltipOnFocus")},!1),o.addEventListener(e,"blur",function(){n._tooltipDiv.classList.remove("textViewTooltipOnFocus")},!1),o.addEventListener(e,"mouseenter",function(){n._locked||n._tooltipDiv.classList.add("textViewTooltipOnHover")},!1),o.addEventListener(e,"mouseleave",function(){n._hasFocus()||n._tooltipDiv.classList.remove("textViewTooltipOnHover")},!1),o.addEventListener(e,"keydown",function(t){27===t.keyCode&&(n._locked||n.hide())},!1),this._view.addEventListener("Destroy",function(){n.destroy()})}},destroy:function(){if(this._tooltipDiv){this.hide();var t=this._tooltipDiv.parentNode;t&&t.removeChild(this._tooltipDiv);var e=this._tooltipDiv.ownerDocument;o.removeEventListener(e,"mousedown",this._mouseDownHandler,!0),o.removeEventListener(e,"scroll",this._scrollHandler,!0),o.removeEventListener(e,"mousemove",this._mouseMoveHandler,!0),this._tooltipDiv=null}},show:function(t,e,n){this._locked=e,this._giveFocus=n,this._topPixel=this._view.getTopPixel(),this._leftPixel=this._view.getHorizontalPixel(),this._processInfo(t.getTooltipInfo())},update:function(t,e){t&&(e?this._showContents(null,t.getTooltipInfo(),!0):this._processInfo(t.getTooltipInfo(),!0))},onHover:function(t,e,n){t&&(this._isInRect(this._anchorArea,e,n)||this._isInRect(this._tooltipArea,e,n)||this._locked||this._hasFocus()||this._processInfo(t.getTooltipInfo()))},hide:function(t){t&&(this._locked=void 0),!this._locked&&this.isVisible()&&(this.hover&&this.hover.clearQuickFixes(),this._hasFocus()&&this._view.focus(),this._tooltipContents&&(this._tooltipDiv.removeChild(this._tooltipContents),this._tooltipContents=null),this._tooltipDiv.classList.remove("textviewTooltipCodeProjection"),this._tooltipDiv.classList.remove("textviewTooltipOnHover"),this._tooltipDiv.classList.remove("textviewTooltipOnFocus"),this._tooltipDiv.style.visibility="hidden",this._tipShowing=!1,this._tooltipDiv.style.left="",this._tooltipDiv.style.right="",this._tooltipDiv.style.top="",this._tooltipDiv.style.bottom="",this._tooltipDiv.style.width="auto",this._tooltipDiv.style.maxWidth="",this._tooltipDiv.style.height="auto",this._tooltipDiv.style.maxHeight="",this._tooltipDiv.style.overflowX="",this._tooltipDiv.style.overflowY="",this._anchorArea=void 0,this._tooltipArea=void 0,this._outerArea=void 0,this._hoverPromises&&this._hoverPromises.forEach(function(t){t.resolved||t.cancel()}),this._hoverPromises=void 0,this._tipRect=void 0)},isVisible:function(){return this._tipShowing},_processInfo:function(t,e){if(this._tooltipDiv){var n;if(e&&this._tooltipContents?(this._tooltipContents.innerHTML="",n=this._tooltipContents):n=s.createElement(this._tooltipDiv.ownerDocument,"div"),t){if(t.contents&&this._renderImmediateInfo(n,t.contents,t.context))return this._showContents(n,t,e),!0;if(this.hover&&t.context&&(this._hoverPromises=this.hover.computeHoverInfo(t.context),this._hoverPromises)){var o=this,r=this._hoverPromises.slice(0);return r.forEach(function(r){i.when(r,function(i){if(o._hoverPromises){var s=o._hoverPromises.indexOf(r);s>=0&&o._hoverPromises.splice(s,1)}i&&o._renderPluginContent(n,i)&&(i.offsetStart&&(t.context.offsetStart=i.offsetStart),i.offsetEnd&&(t.context.offsetEnd=i.offsetEnd),i.allowFullWidth&&(t.allowFullWidth=i.allowFullWidth),o._showContents(n,t,e))},function(t){console&&t&&"Cancel"!==t.name&&(console.log("Error computing hover tooltip"),console.log(t&&t.stack))})}),!0}}}},_showContents:function(t,e,n){n?this._tooltipArea&&e.tooltipArea&&(this._tooltipArea.left!==e.tooltipArea.left||this._tooltipArea.top!==e.tooltipArea.top||this._tooltipArea.width!==e.tooltipArea.width||this._tooltipArea.height!==e.tooltipArea.height)&&(this._anchorArea=null,this._tooltipArea=null,this._outerArea=null):this.hide(),t&&(this._tooltipContents&&this._tooltipDiv.removeChild(this._tooltipContents),this._tooltipContents=t,this._tooltipDiv.appendChild(t)),this._anchorArea||(this._anchorArea=this._computeAnchorArea(e)),this._tooltipArea||(this._tooltipArea=this._computeTooltipArea(e,this._anchorArea,this._tooltipDiv)),this._outerArea||(this._outerArea=this._computeOuterArea(this._anchorArea,this._tooltipArea)),this._tooltipDiv.style.visibility="visible",this._tipShowing=!0,this._giveFocus&&(this._setInitialFocus(this._tooltipDiv),this._giveFocus=void 0)},_computeAnchorArea:function(t){if(t.anchorArea&&t.anchorArea.top&&t.anchorArea.left&&t.anchorArea.height&&t.anchorArea.width)return t.anchorArea;if(t.context){if(t.context.offsetStart&&t.context.offsetEnd){var e=this.mapOffset(t.context.offsetStart,!1),n=this.mapOffset(t.context.offsetEnd,!1);return this._computeRectangleFromOffset(e,n)}if(t.context.offset>=0){var i=this.mapOffset(t.context.offset,!1),o=this._view.getNextOffset(i,{unit:"wordend",count:0}),r=this._view.getNextOffset(o,{unit:"word",count:-1});return this._computeRectangleFromOffset(r,o)}}return{top:0,left:0,height:0,width:0}},_computeTooltipArea:function(t,e,n){var i=n.ownerDocument.documentElement,o=16;if(t.tooltipArea&&t.tooltipArea.top&&t.tooltipArea.left&&t.tooltipArea.height&&t.tooltipArea.width)return n.style.overflowY="auto",n.style.resize="none",n.style.top=t.tooltipArea.top+"px",n.style.left=t.tooltipArea.left+"px",n.style.height=t.tooltipArea.height-o+"px",n.style.width=t.tooltipArea.width-o+"px",t.tooltipArea;var r=n.getBoundingClientRect(),s={width:r.width,height:r.height},a=n.getElementsByTagName("img")[0];a&&!a.complete&&0===a.width&&(s.width+=30);var l=t.position?t.position:"below",h=(this._view._rootDiv?this._view._rootDiv:i).getBoundingClientRect(),d=h.left,c=h.top,u=h.width,f=h.height,g=u,p=f;if(t.allowFullWidth?s.width>u&&(s.width=u):(g=Math.min(u/2,600),p=Math.min(f/2,400),s.width=Math.min(s.width,g),s.height=Math.min(s.height,p)),n.style.width=s.width-o+"px",s.height=Math.min(n.clientHeight,p),n.clientHeight>p){var _=this._tooltipContents.offsetWidth;n.style.overflowY="scroll";var v=_-this._tooltipContents.offsetWidth;v>0&&(s.width+=v,s.width>u&&(s.width=u)),n.style.overflowY=null}25+o>s.height&&s.width>g-o&&(s.height=40+o);var m=f-(e.top+e.height-c),y=e.top-c,x=u-(e.left+e.width-d);"above"===l&&s.height>y&&s.height<=m?l="below":"below"===l&&s.height>m&&s.height<=y&&(l="above");var C=t.tooltipOffsetX?t.tooltipOffsetX:0,w=t.tooltipOffsetY?t.tooltipOffsetY:0;switch(l){case"left":s.top=s.height+w>m+e.height?f+c-s.height:e.top+w,s.top=Math.max(s.top,c),s.left=Math.max(e.left-s.width+C,d);break;case"right":s.top=s.height+w>m+e.height?f+c-s.height:e.top+w,s.top=Math.max(s.top,c),s.left=Math.max(e.left+e.width+C,d);break;case"above":s.left=s.width+C>x+e.width?u+d-s.width:e.left+C,s.left=Math.max(s.left,d),s.top=Math.max(e.top-s.height+w,c);break;case"below":s.left=s.width+C>x+e.width?u+d-s.width:e.left+C,s.left=Math.max(s.left,d),s.top=Math.max(e.top+e.height+w,c)}return s.maxWidth=Math.min(u+d-s.left,u),s.maxHeight=Math.min(f+c-s.top,f),n.style.maxWidth=s.maxWidth-o+"px",n.style.maxHeight=s.maxHeight-o+"px",n.style.width=s.width-o+"px",n.style.height=s.height-o+"px",n.style.left=s.left+"px",n.style.top=s.top+"px",s},_computeOuterArea:function(t,e){var n=Math.min(t.left,e.left),i=Math.min(t.top,e.top),o=t.left+t.width,r=e.left+e.width,s=Math.max(o,r),a=t.top+t.height,l=e.top+e.height,h=Math.max(a,l);return{left:n,top:i,width:s-n,height:h-i}},_hasFocus:function(){var t=this._tooltipDiv;return t?o.contains(t,t.ownerDocument.activeElement):!1},_isNode:function(t){return"object"==typeof Node?t instanceof Node:t&&"object"==typeof t&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},_setInitialFocus:function(t){var e=r.$("button",t);if(e)return void e.focus();var n=r.$("a",t);if(n){n.focus();var i=this;return void n.addEventListener("click",function(){i.hide()})}var o=r.firstTabbable(t);o&&o.focus()},_isInRect:function(t,e,n){if(!t)return!1;var i=e>=t.left&&e<=t.left+t.width,o=n>=t.top&&n<=t.top+t.height;return i&&o},mapOffset:function(t){var e=this._view,n=e.getModel();return n.getBaseModel&&(t=n.mapOffset(t,!0)),t},_computeRectangleFromOffset:function(t,e){var n,i,o=this._view,r=o.getLineAtOffset(t),s=o.getLineAtOffset(e);if(r!==s){var a=o.getLocationAtOffset(t).y;n=0;for(var l=0;s>=r;){n+=o.getLineHeight(r);var h=o.getModel().getLineEnd(r),d=o.getLocationAtOffset(h).x;d>e&&(l=d),r++}var c=o.getModel().getLineStart(s),u=o.getLocationAtOffset(c).x;i={x:u,y:a,width:l-u,height:n}}else{var f=o.getLocationAtOffset(t),g=o.getLocationAtOffset(e);n=o.getLineHeight(r),i={x:f.x,y:f.y,width:g.x-f.x,height:n}}return i=this._view.convert(i,"document","page"),{left:i.x,top:i.y,width:i.width,height:i.height}},_renderPluginContent:function(t,e){var n=this._tooltipDiv.ownerDocument;if("string"!=typeof e&&"undefined"==typeof e.content)return!1;var i=s.createElement(n,"div");if(e.title){var o=s.createElement(n,"div");this.hover.renderMarkDown?o.innerHTML=this.hover.renderMarkDown(e.title):o.textContent=e.title,o.classList.add("hoverTooltipTitle"),i.appendChild(o)}var r=s.createElement(n,"div");if("string"==typeof e)r.appendChild(n.createTextNode(e));else switch(e.type){case"delegatedUI":case"html":if(e.content){var a=n.createElement("iframe");a.id="HtmlHover",a.name="HTML Hover",a.type="text/html",a.sandbox="allow-scripts allow-same-origin allow-forms",a.style.border="none",a.style.width="100%",a.style.height="100%",a.style.overflow="auto",this._tooltipDiv.style.paddingBottom="5px",a.srcdoc=e.content,e.width&&(a.style.width=e.width),e.height&&(a.style.height=e.height),i.style.height="100%",t.style.height="100%",i.appendChild(a)}break;case"markdown":this.hover.renderMarkDown&&(r.innerHTML=this.hover.renderMarkDown(e.content));break;default:r.appendChild(n.createTextNode(e.content))}return i.appendChild(r),t.appendChild(i),!0},_renderImmediateInfo:function(t,i,o){if(i instanceof Array&&(i=this._getAnnotationContents(i,o),!i))return!1;if("string"==typeof i)return t.textContent=i,!0;if(this._isNode(i))return t.appendChild(i),!0;if(i instanceof n.ProjectionTextModel){var r=this._view,s=r.getOptions();s.wrapMode=!1,s.parent=t;var a="tooltipTheme",l=s.themeClass;l?(l=l.replace(a,""),l&&(l=" "+l),l=a+l):l=a,s.themeClass=l;var h=this._contentsView=new e.TextView(s),d={onLineStyle:function(t){r.onLineStyle(t)}};h.addEventListener("LineStyle",d.onLineStyle),h.setModel(i),this._tooltipDiv.appendChild(t),this._tooltipDiv.classList.add("textviewTooltipCodeProjection");var c=h.computeSize();return t.style.width=c.width+16+"px",t.style.height=c.height+16+"px",h.resize(),this._tooltipDiv.removeChild(t),!0}return!1},_getAnnotationContents:function(e,i){function r(t,e,n){var r=t.title,l=s.createElement(f,"div");if(l.className="tooltipRow",t.html){var h=s.createElement(f,"div");h.className="tooltipImage",h.innerHTML=t.html,h.lastChild&&o.addEventListener(h.lastChild,"click",function(){var e=t.start,n=t.end;p.getBaseModel&&(e=p.mapOffset(e,!0),n=p.mapOffset(n,!0)),g.setSelection(e,n,1/3,function(){a.hide()})},!1),l.appendChild(h)}if(!r){var d=_.getLineStart(_.getLineAtOffset(t.start)),c=_.getLineEnd(_.getLineAtOffset(t.end),!0);r=_.getText(d,c)}if("function"==typeof r&&(r=t.title()),"string"==typeof r){var u=s.createElement(f,"span");u.className="tooltipTitle",u.appendChild(f.createTextNode(r)),r=u}return l.appendChild(r),n&&a.hover.renderQuickFixes(t,e,l,function(){a.hide(!0)}),i&&(i.offsetStart=t.start,i.offsetEnd=t.end),l}var a=this,l=a.hover?!0:!1;l&&i&&i.source&&i.source.indexOf("ruler")>=0&&e.length>1&&(l=!1);for(var h,d=[],c=0;c0&&v.addProjection({start:0,end:m}),v}var x;if(e.length>0&&this._editor&&(x=this._editor.getAnnotationModel().getAnnotations()),1===e.length){if(u=r(e[0],x,l),u&&u.firstChild){var C=u.firstChild.className;C&&(C+=" "),C+="single",u.firstChild.className=C}return u}var w=s.createElement(f,"div"),A=s.createElement(f,"multi_anno");A.appendChild(f.createTextNode(t.multipleAnnotations)),w.appendChild(A);for(var T=0;T
",overviewStyle:{styleClass:"annotationOverview "+r}};i?s.lineStyle={styleClass:"annotationLine "+r}:s.rangeStyle={styleClass:"annotationRange "+r},n.registerType(e,s)}function r(){}function s(t,e,n,i,o){var r;for(void 0===i&&(i=-1),void 0===o&&(o=t.length);o-i>1;)if(r=Math.floor((o+i)/2),e<=t[r].start)o=r;else{if(n&&e",_expandedStyle:{styleClass:"annotation expanded"},_collapsedHTML:"",_collapsedStyle:{styleClass:"annotation collapsed"},_collapse:function(){return this.expanded?(this.expanded=!1,this.html=this._collapsedHTML,this.style=this._collapsedStyle,this._annotationModel&&this._annotationModel.modifyAnnotation(this),!0):!1},_expand:function(){return this.expanded?!1:(this.expanded=!0,this.html=this._expandedHTML,this.style=this._expandedStyle,this._annotationModel&&this._annotationModel.modifyAnnotation(this),!0)},_collapseImpl:function(t){if(this._collapse()){t&&this._forEachOverlaping(function(t){t.expanded||(t._expandImpl(!1),t._recollapse=!0)});var e=this._projectionModel,n=e.getBaseModel();this._projection={annotation:this,start:n.getLineStart(n.getLineAtOffset(this.start)+1),end:n.getLineEnd(n.getLineAtOffset(this.end),!0)},e.addProjection(this._projection)}},_expandImpl:function(t){this._expand()&&(this._projectionModel._removeProjection(this._projection,!this._annotationModel),t&&this._forEachOverlaping(function(t){t._recollapse&&(t._collapseImpl(!1),t._recollapse=!1)}))},_forEachOverlaping:function(t){if(this._annotationModel)for(var e=this._annotationModel.getAnnotations(this.start,this.end);e.hasNext();){var i=e.next();i!==this&&i.type===n.ANNOTATION_FOLDING&&t.call(this,i)}},collapse:function(){this._recollapse=!1,this._collapseImpl(!0)},expand:function(){this._recollapse=!1,this._expandImpl(!0)}},n.ANNOTATION_ERROR="orion.annotation.error",n.ANNOTATION_WARNING="orion.annotation.warning",n.ANNOTATION_INFO="orion.annotation.info",n.ANNOTATION_TASK="orion.annotation.task",n.ANNOTATION_BREAKPOINT="orion.annotation.breakpoint",n.ANNOTATION_BOOKMARK="orion.annotation.bookmark",n.ANNOTATION_FOLDING="orion.annotation.folding",n.ANNOTATION_CURRENT_BRACKET="orion.annotation.currentBracket",n.ANNOTATION_MATCHING_BRACKET="orion.annotation.matchingBracket",n.ANNOTATION_CURRENT_LINE="orion.annotation.currentLine",n.ANNOTATION_CURRENT_SEARCH="orion.annotation.currentSearch",n.ANNOTATION_MATCHING_SEARCH="orion.annotation.matchingSearch",n.ANNOTATION_READ_OCCURRENCE="orion.annotation.readOccurrence",n.ANNOTATION_WRITE_OCCURRENCE="orion.annotation.writeOccurrence",n.ANNOTATION_SELECTED_LINKED_GROUP="orion.annotation.selectedLinkedGroup",n.ANNOTATION_CURRENT_LINKED_GROUP="orion.annotation.currentLinkedGroup",n.ANNOTATION_LINKED_GROUP="orion.annotation.linkedGroup",n.ANNOTATION_BLAME="orion.annotation.blame",n.ANNOTATION_CURRENT_BLAME="orion.annotation.currentBlame",n.ANNOTATION_DIFF_ADDED="orion.annotation.diffAdded",n.ANNOTATION_DIFF_DELETED="orion.annotation.diffDeleted",n.ANNOTATION_DIFF_MODIFIED="orion.annotation.diffModified";var h={};return n.registerType=function(t,e){var n=e;return"function"!=typeof n&&(n=function(t,e,n){this.start=t,this.end=e,void 0!==n&&(this.title=n)},n.prototype=e),n.prototype.type=t,h[t]=n,t},n.createAnnotation=function(t,e,n,i){return new(this.getType(t))(e,n,i)},n.getType=function(t){return h[t]},o(n.ANNOTATION_ERROR),o(n.ANNOTATION_WARNING),o(n.ANNOTATION_INFO),o(n.ANNOTATION_TASK),o(n.ANNOTATION_BREAKPOINT),o(n.ANNOTATION_BOOKMARK),o(n.ANNOTATION_CURRENT_BRACKET),o(n.ANNOTATION_MATCHING_BRACKET),o(n.ANNOTATION_CURRENT_SEARCH),o(n.ANNOTATION_MATCHING_SEARCH),o(n.ANNOTATION_READ_OCCURRENCE),o(n.ANNOTATION_WRITE_OCCURRENCE),o(n.ANNOTATION_SELECTED_LINKED_GROUP),o(n.ANNOTATION_CURRENT_LINKED_GROUP),o(n.ANNOTATION_LINKED_GROUP),o(n.ANNOTATION_CURRENT_LINE,!0),o(n.ANNOTATION_BLAME,!0),o(n.ANNOTATION_CURRENT_BLAME,!0),o(n.ANNOTATION_DIFF_ADDED),o(n.ANNOTATION_DIFF_DELETED),o(n.ANNOTATION_DIFF_MODIFIED),n.registerType(n.ANNOTATION_FOLDING,i),r.addMixin=function(t){var e=r.prototype;for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},r.prototype={addAnnotationType:function(t,e){this._annotationTypes||(this._annotationTypes=[]);var n=e-1;void 0!=e&&n>=0&&nn.start?t=e)break}return null},n=i(),{next:function(){var t=n;return t&&(n=i()),t},hasNext:function(){return null!==n}}},modifyAnnotation:function(t){if(t){var e=this._getAnnotationIndex(t);if(!(0>e)){var n={type:"Changed",added:[],removed:[],changed:[t]};this.onChanged(n)}}},onChanged:function(t){return this.dispatchEvent(t)},removeAnnotations:function(t){var e,n,i=this._annotations;if(t)for(e=[],n=i.length-1;n>=0;n--){var o=i[n];o.type===t&&(i.splice(n,1),e.splice(0,0,o),o._annotationModel=null)}else e=i,i=[];var r={type:"Changed",removed:e,added:[],changed:[]};this.onChanged(r)},removeAnnotation:function(t){if(t){var e=this._getAnnotationIndex(t);if(!(0>e)){t._annotationModel=null;var n={type:"Changed",removed:this._annotations.splice(e,1),added:[],changed:[]};this.onChanged(n)}}},replaceAnnotations:function(t,e){var n,i,o,r=this._annotations,a=[];if(t)for(n=t.length-1;n>=0;n--)o=t[n],i=this._getAnnotationIndex(o),0>i||(o._annotationModel=null,r.splice(i,1),a.splice(0,0,o));for(e||(e=[]),n=0;n=0&&s=r?(d._oldStart=d.start,d._oldEnd=d.end,d.start+=h,d.end+=h,l.changed.push(d)):d.end<=e||(d.start0||l.removed.length>0||l.changed.length>0)&&this.onChanged(l)}}},e.EventTarget.addMixin(a.prototype),l.prototype={destroy:function(){var t=this._view;t&&(t.removeEventListener("Destroy",this._listener.onDestroy),t.removeEventListener("LineStyle",this._listener.onLineStyle),this.view=null);var e=this._annotationModel;e&&(e.removeEventListener("Changed",this._listener.onChanged),e=null)},_mergeStyle:function(t,e){if(e){t||(t={}),t.styleClass&&e.styleClass&&t.styleClass!==e.styleClass?t.styleClass+=" "+e.styleClass:t.styleClass=e.styleClass;var n;if(e.tagName&&(t.tagName||(t.tagName=e.tagName)),e.style){t.style||(t.style={});for(n in e.style)t.style[n]||(t.style[n]=e.style[n])}if(e.attributes){t.attributes||(t.attributes={});for(n in e.attributes)t.attributes[n]||(t.attributes[n]=e.attributes[n])}}return t},_mergeStyleRanges:function(t,e){t||(t=[]);for(var n,i=s(t,e.start,!0);i=o.end)){n=this._mergeStyle({},o.style),n=this._mergeStyle(n,e.style);var r=[];r.push(i,1),e.starto.start&&r.push({start:o.start,end:e.start,style:o.style}),r.push({start:Math.max(o.start,e.start),end:Math.min(o.end,e.end),style:n}),e.endo.end?{start:o.end,end:e.end,style:e.style}:null,Array.prototype.splice.apply(t,r)}}return e&&(n=this._mergeStyle({},e.style),t.splice(i,0,{start:e.start,end:e.end,style:n})),t},_onAnnotationModelChanged:function(t){function e(t,e){r.getBaseModel&&(t=r.mapOffset(t,!0),e=r.mapOffset(e,!0)),-1!==t&&-1!==e&&i.redrawRange(t,e)}function n(t,n){for(var i=0;in;n++){var o=arguments[n];for(var r in o)e.call(o,r)&&(t[r]=o[r])}return t}return{clone:function(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var n=Object.create(Object.getPrototypeOf(e));return t(n,e),n},mixin:t,toArray:function(t){return Array.isArray(t)?t:[t]}}}),define("orion/editor/editor",["i18n!orion/editor/nls/messages","orion/editor/eventTarget","orion/editor/tooltip","orion/editor/annotations","orion/objects","orion/editor/util","orion/util"],function(t,e,n,i,o,r,s){function a(t){t=t||{},this._domNode=t.domNode,this._model=t.model,this._undoStack=t.undoStack,this._statusReporter=t.statusReporter,this._title=null;var e=this;this._listener={onChanged:function(t){e.onChanged(t)}},this._model&&this._model.addEventListener("Changed",this._listener.onChanged),this.checkDirty()}function l(t){t=t||{},a.call(this,t),this._textViewFactory=t.textViewFactory,this._undoStackFactory=t.undoStackFactory,this._textDNDFactory=t.textDNDFactory,this._annotationFactory=t.annotationFactory,this._zoomRulerFactory=t.zoomRulerFactory,this._foldingRulerFactory=t.foldingRulerFactory,this._lineNumberRulerFactory=t.lineNumberRulerFactory,this._contentAssistFactory=t.contentAssistFactory,this._keyBindingFactory=t.keyBindingFactory,this._hoverFactory=t.hoverFactory,this._syntaxHighlighter=t.syntaxHighlighter,this._annotationStyler=null,this._annotationModel=null,this._annotationRuler=null,this._lineNumberRuler=null,this._overviewRuler=null,this._zoomRuler=null,this._foldingRuler=null,this._contentAssist=null}var h=i.AnnotationType,d="orion.annotation.highlightError";return a.prototype={destroy:function(){this.uninstall(),this._statusReporter=this._domNode=null,this._model&&this._model.removeEventListener("Changed",this._listener.onChanged)},checkDirty:function(){this.setDirty(this._undoStack&&!this._undoStack.isClean())},focus:function(){},getModel:function(){return this._model},getText:function(t,e){return this.getModel().getText(t,e)},getTitle:function(){return this._title},getUndoStack:function(){return this._undoStack},install:function(){this.installed=!0},isDirty:function(){return this._undoStack?!this._undoStack.isClean():this._dirty},markClean:function(){this.getUndoStack().markClean(),this.setDirty(!1)},onDirtyChanged:function(t){return this.dispatchEvent(t)},onInputChanged:function(t){return this.dispatchEvent(t)},onChanged:function(){this.checkDirty()},reportStatus:function(t,e,n){this._statusReporter&&this._statusReporter(t,e,n)},resize:function(){},setDirty:function(t){this._setSyntaxCheckRequired(t),this._dirty!==t&&(this._dirty=t,this.onDirtyChanged({type:"DirtyChanged"}))},_setSyntaxCheckRequired:function(t){this._syntaxCheckRequired=t},_isSyntaxCheckRequired:function(){return this._syntaxCheckRequired},_setModelText:function(t){this._model&&this._model.setText(t)},setInput:function(t,e,n,i){this._title=t,i||(e?this.reportStatus(e,"error"):null!==n&&void 0!==n&&("string"==typeof n&&this._setModelText(n),this._undoStack&&this._undoStack.reset())),this.checkDirty(),this.onInputChanged({type:"InputChanged",title:t,message:e,contents:n,contentsSaved:i})},setText:function(t,e,n){this.getModel().setText(t,e,n)},uninstall:function(){this.installed=!1}},e.EventTarget.addMixin(a.prototype),l.prototype=new a,o.mixin(l.prototype,{destroy:function(){a.prototype.destroy.call(this),this._textViewFactory=this._undoStackFactory=this._textDNDFactory=this._annotationFactory=this._foldingRulerFactory=this._lineNumberRulerFactory=this._contentAssistFactory=this._keyBindingFactory=this._hoverFactory=this._zoomRulerFactory=null},getAnnotationModel:function(){return this._annotationModel},getAnnotationRuler:function(){return this._annotationRuler},getAnnotationRulerVisible:function(){return this._annotationRulerVisible},getAnnotationStyler:function(){return this._annotationStyler},getContentAssist:function(){return this._contentAssist},getFoldingRuler:function(){return this._foldingRuler},getFoldingRulerVisible:function(){return this._foldingRulerVisible},addFoldingAnnotation:function(t,e){var n=this.getAnnotationModel();if(n){var o=new i.FoldingAnnotation(t,e,this.getTextView().getModel());return n.addAnnotation(o),o}return null},getLineNumberRuler:function(){return this._lineNumberRuler},getLineNumberRulerVisible:function(){return this._lineNumberRulerVisible},getTooltip:function(){return n.Tooltip.getTooltip(this._textView,this)},getZoomRuler:function(){return this._zoomRuler},getZoomRulerVisible:function(){return this._zoomRulerVisible},getModel:function(){if(!this._textView)return null;var t=this._textView.getModel();return t.getBaseModel&&(t=t.getBaseModel()),t},getOverviewRuler:function(){return this._overviewRuler},getTextView:function(){return this._textView},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()},resize:function(){this._textView&&this._textView.resize()},setAnnotationRulerVisible:function(t,e){if((this._annotationRulerVisible!==t||e)&&(this._annotationRulerVisible=t,this._annotationRuler)){var n=this._textView;t?n.addRuler(this._annotationRuler,0):n.removeRuler(this._annotationRuler)}},setFoldingRulerVisible:function(t,e){if(this._foldingRulerVisible!==t||e){if(!t){var n=this.getTextActions();n&&n.expandAnnotations(!0)}if(this._foldingRulerVisible=t,this._foldingRuler){var i=this._textView;i.getModel().getBaseModel&&(t?i.addRuler(this._foldingRuler):i.removeRuler(this._foldingRuler))}}},setLineNumberRulerVisible:function(t,e){if((this._lineNumberRulerVisible!==t||e)&&(this._lineNumberRulerVisible=t,this._lineNumberRuler)){var n=this._textView;t?n.addRuler(this._lineNumberRuler,this._annotationRulerVisible?1:0):n.removeRuler(this._lineNumberRuler)}},setOverviewRulerVisible:function(t,e){if((this._overviewRulerVisible!==t||e)&&(this._overviewRulerVisible=t,this._overviewRuler)){var n=this._textView;t?n.addRuler(this._overviewRuler):n.removeRuler(this._overviewRuler)}},setZoomRulerVisible:function(t,e){if((this._zoomRulerVisible!==t||e)&&(this._zoomRulerVisible=t,this._zoomRuler)){var n=this._textView;t?n.addRuler(this._zoomRuler):n.removeRuler(this._zoomRuler)}},setAnnotationTypesVisible:function(t){r.compare(this._annotationTypesVisible,t)||(this._annotationTypesVisible=t,this._annotationRuler&&this._textView&&this._annotationRulerVisible&&(this._annotationRuler.setAnnotationTypeVisible(t),this._textView.redrawLines(0,void 0,this._annotationRuler)))},setOverviewAnnotationTypesVisible:function(t){r.compare(this._overviewAnnotationTypesVisible,t)||(this._overviewAnnotationTypesVisible=t,this._overviewRuler&&this._textView&&this._overviewRulerVisible&&(this._overviewRuler.setAnnotationTypeVisible(t),this._textView.redrawLines(0,void 0,this._overviewRuler)))},setTextAnnotationTypesVisible:function(t){r.compare(this._textAnnotationTypesVisible,t)||(this._textAnnotationTypesVisible=t,this._annotationStyler&&this._textView&&(this._annotationStyler.setAnnotationTypeVisible(t),this._textView.redrawLines(0,void 0)))},mapOffset:function(t,e){var n=this._textView,i=n.getModel();return i.getBaseModel&&(t=i.mapOffset(t,e)),t},getLineAtOffset:function(t){return this.getModel().getLineAtOffset(this.mapOffset(t))},getLineStart:function(t){return this.getModel().getLineStart(t)},getCaretOffset:function(){return this.mapOffset(this._textView.getCaretOffset())},getSelectionText:function(t){var e=this._textView;return e.getSelectionText(t)},getSelection:function(){var t=this._textView,e=t.getSelection(),n=t.getModel();return n.getBaseModel&&(e.start=n.mapOffset(e.start),e.end=n.mapOffset(e.end)),e},getSelections:function(){var t=this._textView,e=t.getModel(),n=t.getSelections();return n.forEach(function(t){e.getBaseModel&&(t.start=e.mapOffset(t.start),t.end=e.mapOffset(t.end))}),n},getStyleAccessor:function(){var t=null;if(this._syntaxHighlighter){var e=this._syntaxHighlighter.getStyler();e&&e.getStyleAccessor&&(t=e.getStyleAccessor())}return t},_expandOffset:function(t){var e=this._textView.getModel(),n=this._annotationModel;if(n&&e.getBaseModel)for(var i=n.getAnnotations(t,t+1);i.hasNext();){var o=i.next();o.type===h.ANNOTATION_FOLDING&&o.expand&&o.expand()}},setCaretOffset:function(t,e,n){var i=this._textView,o=i.getModel();o.getBaseModel&&(this._expandOffset(t),t=o.mapOffset(t,!0)),i.setCaretOffset(t,e,n)},setText:function(t,e,n,i,o){var r=this._textView,s=r.getModel();s.getBaseModel&&(void 0!==e&&(this._expandOffset(e),e=s.mapOffset(e,!0)),void 0!==n&&(this._expandOffset(n),n=s.mapOffset(n,!0))),r.setText(t,e,n,i,o)},setSelection:function(t,e,n,i){var o=this._textView,r=o.getModel();r.getBaseModel&&(this._expandOffset(t),this._expandOffset(e),t=r.mapOffset(t,!0),e=r.mapOffset(e,!0)),o.setSelection(t,e,n,i)},setSelections:function(t,e,n){var i=this,o=this._textView,r=o.getModel();t.forEach(function(t){var e=t.start,n=t.end;r.getBaseModel&&(i._expandOffset(e),i._expandOffset(n),e=r.mapOffset(e,!0),n=r.mapOffset(n,!0)),t.start=e,t.end=n}),o.setSelections(t,e,n)},moveSelection:function(t,e,n,i){e=e||t;var o=this._textView;this.setSelection(t,e,1/3,function(){(void 0===i||i)&&o.focus(),n&&n()})},_getTooltipInfo:function(t,e){var n=this._textView,i=this.getAnnotationModel();if(!i)return null;var o=this._annotationStyler;if(!o)return null;if(!n.isValidTextPosition(t,e))return null;var r=n.getOffsetAtLocation(t,e);if(-1===r)return null;r=this.mapOffset(r);for(var s=o.getAnnotationsByType(i,r,r+1),a=[],l=0;l>0,g=s.getLineStart(f),p=s.getLineEnd(f);s.getBaseModel&&(g=s.mapOffset(g),p=s.mapOffset(p));var _=h.ANNOTATION_CURRENT_LINE,v=h.createAnnotation(_,g,p);c.push(v)}this._currentLineAnnotations=c,o.replaceAnnotations(d,c)}}}},installTextView:function(){this.install()},install:function(){if(!this._textView){if(this._textView=this._textViewFactory(),this._undoStackFactory&&(this._undoStack=this._undoStackFactory.createUndoStack(this),this._textView.setOptions({undoStack:this._undoStack}),this.checkDirty()),this._textDNDFactory&&(this._textDND=this._textDNDFactory.createTextDND(this,this._undoStack)),this._contentAssistFactory){var t=this._contentAssistFactory.createContentAssistMode(this);this._contentAssist=t.getContentAssist()}var e=n.Tooltip.getTooltip(this._textView,this);this._hoverFactory&&(this._hover=this._hoverFactory.createHover(this),e.hover=this._hover);var i=this,o=this._textView,r=this;if(this._listener={onModelChanged:function(){r.checkDirty()},onMouseOver:function(t){r._listener.onMouseMove(t)},onMouseDown:function(){r._listener.mouseDown=!0},onMouseUp:function(){r._listener.mouseDown=!1},onMouseMove:function(t){e&&!r._listener.mouseDown&&(t.event.clientX!==r._listener.lastMouseX||t.event.clientY!==r._listener.lastMouseY)&&(r._listener.lastMouseX=t.event.clientX,r._listener.lastMouseY=t.event.clientY,r._hoverTimeout&&(window.clearTimeout(r._hoverTimeout),r._hoverTimeout=null),r._hoverTimeout=window.setTimeout(function(){r._hoverTimeout=null,r._listener&&e.onHover({y:t.y,x:t.x,getTooltipInfo:function(){return r._getTooltipInfo(this.x,this.y)}},t.x,t.y)},175))},onMouseOut:function(){r._hoverTimeout&&(window.clearTimeout(r._hoverTimeout),r._hoverTimeout=null)},onSelection:function(t){e&&e.hide(),r._updateCursorStatus(),r._highlightCurrentLine(t.newValue,t.oldValue)}},o.addEventListener("ModelChanged",this._listener.onModelChanged),o.addEventListener("Selection",this._listener.onSelection),o.addEventListener("MouseOver",this._listener.onMouseOver),o.addEventListener("MouseOut",this._listener.onMouseOut),o.addEventListener("MouseDown",this._listener.onMouseDown),o.addEventListener("MouseUp",this._listener.onMouseUp),o.addEventListener("MouseMove",this._listener.onMouseMove),this._keyBindingFactory){var s;s="function"==typeof this._keyBindingFactory?this._keyBindingFactory(this,this.getKeyModes(),this._undoStack,this._contentAssist):this._keyBindingFactory.createKeyBindings(i,this._undoStack,this._contentAssist),s&&(this._textActions=s.textActions,this._linkedMode=s.linkedMode,this._sourceCodeActions=s.sourceCodeActions)}var l=function(t){if(void 0!==t&&-1!==t){for(var e=this.getView(),n=e.getModel(),o=this.getAnnotationModel(),r=i.mapOffset(n.getLineStart(t)),s=i.mapOffset(n.getLineEnd(t)),a=o.getAnnotations(r,s),l=null;a.hasNext();){var d=a.next();if(d.type===h.ANNOTATION_BOOKMARK){l=d;break}}l?o.removeAnnotation(l):(l=h.createAnnotation(h.ANNOTATION_BOOKMARK,r,s,i.getText(r,s)),o.addAnnotation(l))}};if(this._annotationFactory){var c=o.getModel();if(c.getBaseModel&&(c=c.getBaseModel()),this._annotationModel=this._annotationFactory.createAnnotationModel(c),this._annotationModel){var u=this._annotationStyler=this._annotationFactory.createAnnotationStyler(o,this._annotationModel);u&&(u.addAnnotationType(h.ANNOTATION_CURRENT_SEARCH),u.addAnnotationType(h.ANNOTATION_MATCHING_SEARCH),u.addAnnotationType(h.ANNOTATION_ERROR),u.addAnnotationType(h.ANNOTATION_WARNING),u.addAnnotationType(h.ANNOTATION_INFO),u.addAnnotationType(h.ANNOTATION_MATCHING_BRACKET),u.addAnnotationType(h.ANNOTATION_CURRENT_BRACKET),u.addAnnotationType(h.ANNOTATION_CURRENT_LINE),u.addAnnotationType(h.ANNOTATION_READ_OCCURRENCE),u.addAnnotationType(h.ANNOTATION_WRITE_OCCURRENCE),u.addAnnotationType(h.ANNOTATION_SELECTED_LINKED_GROUP),u.addAnnotationType(h.ANNOTATION_CURRENT_LINKED_GROUP),u.addAnnotationType(h.ANNOTATION_LINKED_GROUP),u.addAnnotationType(d),u.setAnnotationTypeVisible(this._textAnnotationTypesVisible))}var f=this._annotationFactory.createAnnotationRulers(this._annotationModel),g=this._annotationRuler=f.annotationRuler;g&&(g.onDblClick=l,g.setMultiAnnotationOverlay({html:"
"}),g.addAnnotationType(h.ANNOTATION_ERROR),g.addAnnotationType(h.ANNOTATION_WARNING),g.addAnnotationType(h.ANNOTATION_INFO),g.addAnnotationType(h.ANNOTATION_TASK),g.addAnnotationType(h.ANNOTATION_BOOKMARK),g.addAnnotationType(h.ANNOTATION_DIFF_ADDED),g.addAnnotationType(h.ANNOTATION_DIFF_DELETED),g.addAnnotationType(h.ANNOTATION_DIFF_MODIFIED),g.setAnnotationTypeVisible(this._annotationTypesVisible)),this.setAnnotationRulerVisible(this._annotationRulerVisible||void 0===this._annotationRulerVisible,!0),g=this._overviewRuler=f.overviewRuler,g&&(g.addAnnotationType(h.ANNOTATION_CURRENT_SEARCH),g.addAnnotationType(h.ANNOTATION_MATCHING_SEARCH),g.addAnnotationType(h.ANNOTATION_READ_OCCURRENCE),g.addAnnotationType(h.ANNOTATION_WRITE_OCCURRENCE),g.addAnnotationType(h.ANNOTATION_CURRENT_BLAME),g.addAnnotationType(h.ANNOTATION_ERROR),g.addAnnotationType(h.ANNOTATION_WARNING),g.addAnnotationType(h.ANNOTATION_INFO),g.addAnnotationType(h.ANNOTATION_TASK),g.addAnnotationType(h.ANNOTATION_BOOKMARK),g.addAnnotationType(h.ANNOTATION_MATCHING_BRACKET),g.addAnnotationType(h.ANNOTATION_CURRENT_BRACKET),g.addAnnotationType(h.ANNOTATION_CURRENT_LINE),g.addAnnotationType(h.ANNOTATION_DIFF_ADDED),g.addAnnotationType(h.ANNOTATION_DIFF_DELETED),g.addAnnotationType(h.ANNOTATION_DIFF_MODIFIED),g.setAnnotationTypeVisible(this._overviewAnnotationTypesVisible)),this.setOverviewRulerVisible(this._overviewRulerVisible||void 0===this._overviewRulerVisible,!0)}this._zoomRulerFactory&&(this._zoomRuler=this._zoomRulerFactory.createZoomRuler(this._annotationModel),this.setZoomRulerVisible(this._zoomRulerVisible,!0)),this._lineNumberRulerFactory&&(this._lineNumberRuler=this._lineNumberRulerFactory.createLineNumberRuler(this._annotationModel),this._lineNumberRuler.addAnnotationType(h.ANNOTATION_CURRENT_BLAME),this._lineNumberRuler.addAnnotationType(h.ANNOTATION_BLAME),this._lineNumberRuler.addAnnotationType(h.ANNOTATION_DIFF_ADDED),this._lineNumberRuler.addAnnotationType(h.ANNOTATION_DIFF_MODIFIED),this._lineNumberRuler.addAnnotationType(h.ANNOTATION_DIFF_DELETED),this._lineNumberRuler.onDblClick=l,this.setLineNumberRulerVisible(this._lineNumberRulerVisible||void 0===this._lineNumberRulerVisible,!0)),this._foldingRulerFactory&&(this._foldingRuler=this._foldingRulerFactory.createFoldingRuler(this._annotationModel),this._foldingRuler.addAnnotationType(h.ANNOTATION_FOLDING),this.setFoldingRulerVisible(this._foldingRulerVisible||void 0===this._foldingRulerVisible,!0));var p={type:"TextViewInstalled",textView:o};this.dispatchEvent(p),a.prototype.install.call(this)}},uninstallTextView:function(){this.uninstall()},uninstall:function(){var t=this._textView;if(t){t.destroy(),this._annotationModel&&this._annotationModel.setTextModel(null),this._textView=this._undoStack=this._textDND=this._contentAssist=this._listener=this._annotationModel=this._annotationStyler=this._annotationRuler=this._overviewRuler=this._zoomRuler=this._lineNumberRuler=this._foldingRuler=this._currentLineAnnotations=this._title=null,this._dirty=!1,this._foldingRulerVisible=this._overviewRulerVisible=this._zoomRulerVisible=this._lineNumberRulerVisible=this._annotationRulerVisible=void 0;var e={type:"TextViewUninstalled",textView:t};this.dispatchEvent(e),a.prototype.uninstall.call(this)}},_updateCursorStatus:function(){for(var e=this.getKeyModes(),n=0;n1)o=s.formatMessage(t.multiSelections,a.length);else{var l=a[0].getCaret(),h=r.getLineAtOffset(l),d=r.getLineStart(h),c=l-d;o=localStorage.languageTools?s.formatMessage(t.lineColumnOffset,h+1,c+1,l):s.formatMessage(t.lineColumn,h+1,c+1)}this.reportStatus(o)},showAnnotations:function(t,e,n,i){var o=this._annotationModel;if(o){for(var r,s=[],a=[],l=o.getTextModel(),d=o.getAnnotations();d.hasNext();)r=d.next(),-1!==e.indexOf(r.type)&&r.creatorID===this&&s.push(r);if(t)for(var c=0;c',s.blame=t,s})},showDiffAnnotations:function(t){this.showAnnotations(t,[h.ANNOTATION_DIFF_ADDED,h.ANNOTATION_DIFF_MODIFIED,h.ANNOTATION_DIFF_DELETED],null,function(t){return"added"===t.type?h.ANNOTATION_DIFF_ADDED:"modified"===t.type?h.ANNOTATION_DIFF_MODIFIED:h.ANNOTATION_DIFF_DELETED})},showSelection:function(t,e,n,i,o){if("number"==typeof t)return"number"!=typeof e&&(e=t),this.moveSelection(t,e),!0;if("number"==typeof n){var r=this.getModel(),s=r.getLineStart(n-1);return"number"==typeof i&&(s+=i),"number"!=typeof o&&(o=0),this.moveSelection(s,s+o),!0}return!1},_setModelText:function(t){this._textView&&(this._textView.setText(t),this._textView.getModel().setLineDelimiter("auto"),this._highlightCurrentLine(this._textView.getSelections()))},setNoFocus:function(t){this._noFocus=t},setInput:function(t,e,n,i,o){a.prototype.setInput.call(this,t,e,n,i),!this._textView||i||o||this._noFocus||this._textView.focus()},onGotoLine:function(t,e,n,i){if(this._textView){var o=this.getModel();t=Math.max(0,Math.min(t,o.getLineCount()-1));var r=o.getLineStart(t),s=0;if(void 0===n&&(n=0),"string"==typeof e){var a=o.getLine(t).indexOf(e);-1!==a&&(s=a,n=s+e.length)}else{s=e;var l=o.getLineEnd(t)-r;s=Math.min(s,l),n=Math.min(n,l)}this.moveSelection(r+s,r+n,i)}}}),{BaseEditor:a,Editor:l}}),define("orion/editor/find",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/keyModes","orion/editor/annotations","orion/regex","orion/objects","orion/Deferred","orion/util"],function(t,e,n,i,o,r,s,a){function l(t){var e=t.getTextView();n.KeyMode.call(this,e),this.editor=t,this._active=!1,this._success=!0,this._ignoreSelection=!1,this._prefix="",e.setAction("incrementalFindCancel",function(){return this.setActive(!1),!0}.bind(this)),e.setAction("incrementalFindBackspace",function(){return this._backspace()}.bind(this));var i=this;this._listener={onVerify:function(t){var e=i.editor,n=e.getModel(),r=e.mapOffset(t.start),s=e.mapOffset(t.end),a=n.getText(r,s),l=i._prefix,h=l.match(new RegExp("^"+o.escape(a),"i"));h&&h.length>0&&(l=i._prefix+=t.text,i._success=!0,i._status(),i.find(i._forward,!0),t.text=null)},onSelection:function(){i._ignoreSelection||i.setActive(!1)}}}function h(t,e,n){if(t){this._editor=t,this._undoStack=e,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=void 0,this._end=void 0,this._timer=void 0,this._lastString="";var i=this;this._listeners={onEditorFocus:function(t){i._removeCurrentAnnotation(t)}},this.setOptions(n)}}var d={};return l.prototype=new n.KeyMode,r.mixin(l.prototype,{createKeyBindings:function(){var t=e.KeyBinding,n=[];return n.push({actionID:"incrementalFindBackspace",keyBinding:new t(8)}),n.push({actionID:"incrementalFindCancel",keyBinding:new t(13)}),n.push({actionID:"incrementalFindCancel",keyBinding:new t(27)}),n.push({actionID:"incrementalFindReverse",keyBinding:new t(38)}),n.push({actionID:"incrementalFind",keyBinding:new t(40)}),n.push({actionID:"incrementalFindReverse",keyBinding:new t("k",!0,!0)}),n.push({actionID:"incrementalFind",keyBinding:new t("k",!0)}),n},find:function(t,e){if(this._forward=t,!this.isActive())return this.setActive(!0),!1;var n=this._prefix;if(0===n.length)return!1;var i,o=this.editor,r=o.getModel();return i=t?this._success?e?this._start:o.getCaretOffset()+1:0:this._success?e?this._start:o.getCaretOffset():r.getCharCount()-1,s.when(o.getModel().find({string:n,start:i,reverse:!t,caseInsensitive:n.toLowerCase()===n}),function(n){var r=n.next();r?(e||(this._start=i),this._success=!0,this._ignoreSelection=!0,o.moveSelection(t?r.start:r.end,t?r.end:r.start),this._ignoreSelection=!1):this._success=!1,this._status()}.bind(this)),!0},isActive:function(){return this._active},isStatusActive:function(){return this.isActive()},setActive:function(t){if(this._active!==t){this._active=t,this._prefix="",this._success=!0;var e=this.editor,n=e.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 t=this._prefix;return t=this._prefix=t.substring(0,t.length-1),0===t.length?(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())return void this.editor.reportStatus("");var e;e=this._forward?this._success?t.incrementalFindStr:t.incrementalFindStrNotFound:this._success?t.incrementalFindReverseStr:t.incrementalFindReverseStrNotFound,e=a.formatMessage(e,this._prefix),this.editor.reportStatus(e,this._success?"":"error")}}),d.IncrementalFind=l,h.prototype={find:function(t,e,n){this.setOptions({reverse:!t});var i,o=this.getFindString();e&&(o=e.findString||o,i=e.count);var r=this.getOptions();this.setOptions(e);var s=n?this._startOffset:this.getStartOffset();return this._doFind(o,s,i).then(function(t){return t&&(n||(this._startOffset=t.start)),this.setOptions(r),this._hideAfterFind&&this.hide(),t}.bind(this))},getStartOffset:function(){return void 0!==this._start?this._start:this._reverse?this._editor.getSelection().start-1:this._editor.getCaretOffset()},getFindString:function(){var t=this._editor.getSelection(),e=this._editor.getText(t.start,t.end);return this._regex&&(e=o.escape(e)),e||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()),0===this._savedOptions.length&&(this._savedOptions=null)),this._removeAllAnnotations();var t=this._editor.getTextView();t&&(t.removeEventListener("Focus",this._listeners.onEditorFocus),t.focus())},_processReplaceString:function(t){var e=t;if(this._regex){e="";for(var n=!1,i=this._editor.getModel().getLineDelimiter(),o=0;o0&&(r.endUndo(),i.setRedraw(!0)),s>0?n.reportStatus(a.formatMessage(t.replacedMatches,l)):n.reportStatus(t.nothingReplaced,"error"),r._replacingAll=!1},100)}},setOptions:function(t){if(t){if((t.showAll===!0||t.showAll===!1)&&this._showAll!==t.showAll&&(this._showAll=t.showAll,this.isVisible()))if(this._showAll)this._markAllOccurrences();else{var e=this._editor.getAnnotationModel();e&&e.removeAnnotations(i.AnnotationType.ANNOTATION_MATCHING_SEARCH)}(t.caseInsensitive===!0||t.caseInsensitive===!1)&&(this._caseInsensitive=t.caseInsensitive),(t.wrap===!0||t.wrap===!1)&&(this._wrap=t.wrap),(t.wholeWord===!0||t.wholeWord===!1)&&(this._wholeWord=t.wholeWord),(t.incremental===!0||t.incremental===!1||"disabled"===t.incremental)&&("disabled"===t.incremental?(this._incremental=!1,this._incrementalDisabled=!0):this._incremental=t.incremental),(t.regex===!0||t.regex===!1)&&(this._regex=t.regex),(t.findAfterReplace===!0||t.findAfterReplace===!1)&&(this._findAfterReplace=t.findAfterReplace),(t.hideAfterFind===!0||t.hideAfterFind===!1)&&(this._hideAfterFind=t.hideAfterFind),(t.reverse===!0||t.reverse===!1)&&(this._reverse=t.reverse),t.hasOwnProperty("findCallback")&&(this._findCallback=t.findCallback),t.hasOwnProperty("start")&&(this._start=t.start),t.hasOwnProperty("end")&&(this._end=t.end)}},show:function(t){this._visible=!0,t&&(this._savedOptions||(this._savedOptions=[]),this._savedOptions.push(this.getOptions()),this.setOptions(t)),this._startOffset=this._editor.getSelection().start,this._editor.getTextView().addEventListener("Focus",this._listeners.onEditorFocus);var e=this;window.setTimeout(function(){e._incremental&&e.find(!0,null,!0)},0)},startUndo:function(){this._undoStack&&this._undoStack.startCompoundChange()},endUndo:function(){this._undoStack&&this._undoStack.endCompoundChange()},_findFromModel:function(t,e,n){return this._editor.getModel().find({string:t,start:e,end:this._end,reverse:this._reverse,wrap:n?!1:this._wrap,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive})},_find:function(t,e,n,i){var o;if(this._regex)try{o=this._findFromModel(e,n,i)}catch(r){return t.reportStatus(r.message,"error"),null}else o=this._findFromModel(e,n,i);return o},_doFindForReplaceAll:function(t,e,n,i){n=n||1;var o=this._editor;if(!t)return this._removeAllAnnotations(),null;this._lastString=t;var r,s;if(s=this._find(o,t,e,i),!s)return null;if(!s.hasNext||!s.next)return null;for(var a=0;n>a&&s.hasNext();a++)r=s.next();return r},_doFind:function(e,n,o,r){o=o||1;var a=this._editor;if(!e)return this._removeAllAnnotations(),(new s).resolve();this._lastString=e;var l;return s.when(this._find(a,e,n,r)).then(function(e){if(e){for(var n=0;o>n&&e.hasNext();n++)l=e.next();if(!this._replacingAll){if(l?this._editor.reportStatus(""):this._editor.reportStatus(t.notFound,"error"),this.isVisible()){var r=i.AnnotationType.ANNOTATION_CURRENT_SEARCH,s=a.getAnnotationModel();if(s&&(s.removeAnnotations(r),l&&s.addAnnotation(i.AnnotationType.createAnnotation(r,l.start,l.end))),this._showAll){this._timer&&window.clearTimeout(this._timer);var h=this;this._timer=window.setTimeout(function(){h._markAllOccurrences(),h._timer=null },500)}}this._findCallback?this._findCallback(l):l&&a.moveSelection(l.start,l.end,null,!1)}return l}}.bind(this))},_doReplace:function(t,e,n,i){var o=this._editor;this._regex&&(i=o.getText(t,e).replace(new RegExp(n,this._caseInsensitive?"i":""),i)),o.setText(i,t,e),o.setSelection(t,t+i.length,!0)},_markAllOccurrences:function(){var t=this._editor.getAnnotationModel();if(t){for(var e,n=i.AnnotationType.ANNOTATION_MATCHING_SEARCH,o=t.getAnnotations(),r=[];o.hasNext();){var a=o.next();a.type===n&&r.push(a)}if(this.isVisible()){var l=this.getFindString();s.when(this._editor.getModel().find({string:l,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive})).then(function(o){if(o){for(e=[];o.hasNext();){var s=o.next();e.push(i.AnnotationType.createAnnotation(n,s.start,s.end))}t.replaceAnnotations(r,e)}}.bind(this))}else t.replaceAnnotations(r,e)}},_removeAllAnnotations:function(){var t=this._editor.getAnnotationModel();t&&(t.removeAnnotations(i.AnnotationType.ANNOTATION_CURRENT_SEARCH),t.removeAnnotations(i.AnnotationType.ANNOTATION_MATCHING_SEARCH))},_removeCurrentAnnotation:function(){var t=this._editor.getAnnotationModel();t&&t.removeAnnotations(i.AnnotationType.ANNOTATION_CURRENT_SEARCH)}},d.Find=h,d}),define("orion/editor/findUI",["i18n!orion/editor/nls/messages","orion/editor/find","orion/objects","orion/editor/util","orion/util"],function(t,e,n,i,o){function r(t,n,i){e.Find.call(this,t,n,i)}return r.prototype=new e.Find,n.mixin(r.prototype,{getFindString:function(){var t=this._findInput;return t?t.value:e.Find.prototype.getFindString.call(this)},getReplaceString:function(){var t=this._replaceInput;return t?t.value:e.Find.prototype.getReplaceString(this)},hide:function(){var t=this.isVisible();e.Find.prototype.hide.call(this),t&&(this._rootDiv.className="textViewFind")},show:function(t){e.Find.prototype.show.call(this,t);var n=t.findString,i=t.replaceString,o=this._findInput;if(o||(this._create(),o=this._findInput),n&&(o.value=n),i){var r=this._replaceInput;r.value=i}var s=this;window.setTimeout(function(){s._rootDiv.className="textViewFind show",o.select(),o.focus()},0)},_create:function(){var e=this,n=this._editor.getTextView(),r=n.getOptions("parent"),s=r.ownerDocument,a=o.createElement(s,"div");a.className="textViewFind",i.addEventListener(a,"keydown",function(t){e._handleKeyDown(t)}),this._rootDiv=a,a.setAttribute("role","dialog"),a.setAttribute("aria-label",t.findReplace),this._createContents(s,a),n._rootDiv.insertBefore(a,n._rootDiv.firstChild)},_createContents:function(e,n){var r=this,s=o.createElement(e,"input");s.className="textViewFindInput",this._findInput=s,s.type="text",s.placeholder=t.findWith,i.addEventListener(s,"input",function(t){return r._handleInput(t)}),n.appendChild(s);var a=o.createElement(e,"span");r._createButton(e,a,t.next,function(){r.find(!0)}),r._createButton(e,a,t.previous,function(){r.find(!1)}),n.appendChild(a);var l=r._editor.getTextView().getOptions("readonly");if(!l){var h=o.createElement(e,"input");h.className="textViewReplaceInput",this._replaceInput=h,h.type="text",h.placeholder=t.replaceWith,n.appendChild(h),a=o.createElement(e,"span"),r._createButton(e,a,t.replace,function(){r.replace()}),r._createButton(e,a,t.replaceAll,function(){r.replaceAll()}),n.appendChild(a)}a=o.createElement(e,"span"),r._createButton(e,a,t.regex,function(t){r._toggle("regex",t.target)},this._regex,t.regexTooltip,t.regexTooltip),r._createButton(e,a,t.caseInsensitive,function(t){r._toggle("caseInsensitive",t.target)},this._caseInsensitive,t.caseInsensitiveTooltip,t.caseInsensitiveTooltip),r._createButton(e,a,t.wholeWord,function(t){r._toggle("wholeWord",t.target)},this._wholeWord,t.wholeWordTooltip,t.wholeWordTooltip),n.appendChild(a);var d=r._createButton(e,n,"",function(){r.hide()});d.className="textViewFindCloseButton",d.title=t.closeTooltip,o.confineDialogTab(s,d)},_createButton:function(t,e,n,o,r,s,a){var l=t.createElement("button");return l.type="button",this._checked(r,l),s&&(l.title=s),i.addEventListener(l,"click",function(t){o.call(this,t)},!1),n&&l.appendChild(t.createTextNode(n)),a&&l.setAttribute("aria-label",a),e.appendChild(l),l},_toggle:function(t,e){var n={};n[t]=!this["_"+t],this.setOptions(n),this._checked(n[t],e)},_checked:function(t,e){e.className="textViewFindButton",t&&(e.className+=" checked")},_handleInput:function(){return this._incremental&&this.find(!0,null,!0),!0},_handleKeyDown:function(t){var e,n=(o.isMac?t.metaKey:t.ctrlKey)&&!t.altKey&&!t.shiftKey;return n&&70===t.keyCode&&(e=!0),((o.isMac?t.metaKey:t.ctrlKey)&&!t.altKey&&75===t.keyCode||13===t.keyCode)&&(this.find(13===t.keyCode?this._reverse?t.shiftKey:!t.shiftKey:!t.shiftKey),e=!0),n&&82===t.keyCode&&(this.replace(),e=!0),27===t.keyCode&&(this.hide(),e=!0),e?(t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.cancelBubble=!0,!1):!0}}),{FindUI:r}}),define("orion/editor/actions",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/annotations","orion/editor/tooltip","orion/editor/find","orion/editor/findUI","orion/util"],function(t,e,n,i,o,r,s){function a(t,e,n,i){function o(t,e,n){s.setText(t,e,n),r+=e-n+t.length}var r=0,s=t.editor,a=s.getSelections();!i&&(e||a.length>1)&&t.startUndo(),a.forEach(function(t){t.start+=r,t.end+=r,n(t,o)}),s.setSelections(a),!i&&(e||a.length>1)&&t.endUndo()}function l(t,e,n){this.editor=t,this.undoStack=e,this._incrementalFind=new o.IncrementalFind(t),this._find=n?n:new r.FindUI(t,e),this._lastEditLocation=null,this.init()}function h(t,e,n,i){this.editor=t,this.undoStack=e,this.contentAssist=n,this.linkedMode=i,this.contentAssist&&this.contentAssist.addEventListener("ProposalApplied",this.contentAssistProposalApplied.bind(this)),this.init()}var d=n.AnnotationType,c={};return l.prototype={init:function(){var n=this.editor.getTextView();this._lastEditListener={onModelChanged:function(t){this.editor.isDirty()&&(this._lastEditLocation=t.start+t.addedCharCount)}.bind(this)},n.addEventListener("ModelChanged",this._lastEditListener.onModelChanged),n.setAction("undo",function(t){if(this.undoStack){var e=1;for(t&&t.count&&(e=t.count);e>0;)this.undoStack.undo(),--e;return!0}return!1}.bind(this),{name:t.undo}),n.setAction("redo",function(t){if(this.undoStack){var e=1;for(t&&t.count&&(e=t.count);e>0;)this.undoStack.redo(),--e;return!0}return!1}.bind(this),{name:t.redo}),n.setKeyBinding(new e.KeyBinding("f",!0),"find"),n.setAction("find",function(){if(this._find){var t=this.editor.getSelection();return this._find.show({findString:this.editor.getText(t.start,t.end)}),!0}return!1}.bind(this),{name:t.find}),n.setKeyBinding(new e.KeyBinding("k",!0),"findNext"),n.setAction("findNext",function(t){return this._find?(this._find.find(!0,t),!0):!1}.bind(this),{name:t.findNext}),n.setKeyBinding(new e.KeyBinding("k",!0,!0),"findPrevious"),n.setAction("findPrevious",function(t){return this._find?(this._find.find(!1,t),!0):!1}.bind(this),{name:t.findPrevious}),n.setKeyBinding(new e.KeyBinding("j",!0),"incrementalFind"),n.setAction("incrementalFind",function(){return this._incrementalFind&&this._incrementalFind.find(!0),!0}.bind(this),{name:t.incrementalFind}),n.setKeyBinding(new e.KeyBinding("j",!0,!0),"incrementalFindReverse"),n.setAction("incrementalFindReverse",function(){return this._incrementalFind&&this._incrementalFind.find(!1),!0}.bind(this),{name:t.incrementalFindReverse}),n.setAction("tab",function(){return this.indentLines()}.bind(this)),n.setAction("shiftTab",function(){return this.unindentLines()}.bind(this),{name:t.unindentLines}),n.setKeyBinding(new e.KeyBinding(38,!1,!1,!0),"moveLinesUp"),n.setAction("moveLinesUp",function(){return this.moveLinesUp()}.bind(this),{name:t.moveLinesUp}),n.setKeyBinding(new e.KeyBinding(40,!1,!1,!0),"moveLinesDown"),n.setAction("moveLinesDown",function(){return this.moveLinesDown()}.bind(this),{name:t.moveLinesDown}),n.setKeyBinding(new e.KeyBinding(38,!0,!1,!0),"copyLinesUp"),n.setAction("copyLinesUp",function(){return this.copyLinesUp()}.bind(this),{name:t.copyLinesUp}),n.setKeyBinding(new e.KeyBinding(40,!0,!1,!0),"copyLinesDown"),n.setAction("copyLinesDown",function(){return this.copyLinesDown()}.bind(this),{name:t.copyLinesDown}),n.setKeyBinding(new e.KeyBinding("d",!0,!1,!1),"deleteLines"),n.setAction("deleteLines",function(t){return this.deleteLines(t)}.bind(this),{name:t.deleteLines}),n.setKeyBinding(new e.KeyBinding("l",!s.isMac,!1,!1,s.isMac),"gotoLine"),n.setAction("gotoLine",function(){return this.gotoLine()}.bind(this),{name:t.gotoLine}),n.setKeyBinding(new e.KeyBinding(190,!0),"nextAnnotation"),n.setAction("nextAnnotation",function(){return this.nextAnnotation(!0)}.bind(this),{name:t.nextAnnotation}),n.setKeyBinding(new e.KeyBinding(188,!0),"previousAnnotation"),n.setAction("previousAnnotation",function(){return this.nextAnnotation(!1)}.bind(this),{name:t.prevAnnotation}),n.setKeyBinding(new e.KeyBinding("e",!0,!1,!0,!1),"expand"),n.setAction("expand",function(){return this.expandAnnotation(!0)}.bind(this),{name:t.expand}),n.setKeyBinding(new e.KeyBinding("c",!0,!1,!0,!1),"collapse"),n.setAction("collapse",function(){return this.expandAnnotation(!1)}.bind(this),{name:t.collapse}),n.setKeyBinding(new e.KeyBinding("e",!0,!0,!0,!1),"expandAll"),n.setAction("expandAll",function(){return this.expandAnnotations(!0)}.bind(this),{name:t.expandAll}),n.setKeyBinding(new e.KeyBinding("c",!0,!0,!0,!1),"collapseAll"),n.setAction("collapseAll",function(){return this.expandAnnotations(!1)}.bind(this),{name:t.collapseAll}),n.setKeyBinding(new e.KeyBinding("q",!s.isMac,!1,!1,s.isMac),"lastEdit"),n.setAction("lastEdit",function(){return this.gotoLastEdit()}.bind(this),{name:t.lastEdit})},copyLinesDown:function(){var t=this.editor,e=t.getTextView();if(e.getOptions("readonly"))return!1;var n=t.getModel();return a(this,!1,function(t,e){var i=n.getLineAtOffset(t.start),o=n.getLineAtOffset(t.end>t.start?t.end-1:t.end),r=n.getLineStart(i),s=n.getLineEnd(o,!0),a=n.getLineCount(),l="",h=n.getText(r,s);o===a-1&&(h=(l=n.getLineDelimiter())+h);var d=s;e(h,d,d),t.start=d+l.length,t.end=d+h.length}),!0},copyLinesUp:function(){var t=this.editor,e=t.getTextView();if(e.getOptions("readonly"))return!1;var n=t.getModel();return a(this,!1,function(t,e){var i=n.getLineAtOffset(t.start),o=n.getLineAtOffset(t.end>t.start?t.end-1:t.end),r=n.getLineStart(i),s=n.getLineEnd(o,!0),a=n.getLineCount(),l="",h=n.getText(r,s);o===a-1&&(h+=l=n.getLineDelimiter());var d=r;e(h,d,d),t.start=d,t.end=d+h.length-l.length}),!0},deleteLines:function(t){var e=this.editor,n=e.getTextView();if(n.getOptions("readonly"))return!1;var i=1;t&&t.count&&(i=t.count);var o=e.getModel();return a(this,!1,function(t,e){var n,r=o.getLineAtOffset(t.start),s=o.getLineStart(r);n=t.start!==t.end||1===i?o.getLineAtOffset(t.end>t.start?t.end-1:t.end):Math.min(r+i-1,o.getLineCount()-1);var a=o.getLineEnd(n,!0);e("",s,a),t.start=t.end=s}),!0},expandAnnotation:function(t){var e=this.editor;if(!e.getFoldingRulerVisible())return!0;var i=e.getAnnotationModel();if(!i)return!0;var o=e.getModel(),r=e.getCaretOffset(),s=o.getLineAtOffset(r),a=o.getLineStart(s),l=o.getLineEnd(s,!0);o.getBaseModel&&(a=o.mapOffset(a),l=o.mapOffset(l),o=o.getBaseModel());for(var h,d=i.getAnnotations(a,l);!h&&d.hasNext();){var c=d.next();c.type===n.AnnotationType.ANNOTATION_FOLDING&&(h=c)}return h&&t!==h.expanded&&(t?h.expand():(e.setCaretOffset(h.start),h.collapse())),!0},expandAnnotations:function(t){var e=this.editor;if(!e.getFoldingRulerVisible())return!0;var i=e.getTextView(),o=e.getAnnotationModel();if(!o)return!0;var r,s=o.getAnnotations();for(i.setRedraw(!1);s.hasNext();)r=s.next(),r.type===n.AnnotationType.ANNOTATION_FOLDING&&t!==r.expanded&&(t?r.expand():r.collapse());return i.setRedraw(!0),!0},indentLines:function(){var t=this.editor,e=t.getTextView();if(e.getOptions("readonly"))return!1;if(e.getOptions("tabMode")){var n=t.getModel(),i=0,o=t.getSelections();return o.length>1&&this.startUndo(),o.some(function(r){r.start+=i,r.end+=i;var s=n.getLineAtOffset(r.start),a=n.getLineAtOffset(r.end>r.start?r.end-1:r.end);if(!(s!==a||o.length>1))return!0;var l=[];l.push("");for(var h=s;a>=h;h++)l.push(n.getLine(h,!0));var d=n.getLineStart(s),c=n.getLineEnd(a,!0),u=e.getOptions("tabSize","expandTab"),f=u.expandTab?new Array(u.tabSize+1).join(" "):" ",g=l.join(f);t.setText(g,d,c);var p=d===r.start?r.start:r.start+f.length,_=r.end+(a-s+1)*f.length;return i+=d-c+g.length,r.start=p,r.end=_,!1})?!1:(t.setSelections(o),o.length>1&&this.endUndo(),!0)}},gotoLastEdit:function(){return"number"==typeof this._lastEditLocation&&this.editor.showSelection(this._lastEditLocation),!0},gotoLine:function(){var e=this.editor,n=e.getModel(),i=n.getLineAtOffset(e.getCaretOffset());return i=prompt(t.gotoLinePrompty,i+1),i&&(i=parseInt(i,10),e.onGotoLine(i-1,0)),!0},moveLinesDown:function(){var t=this.editor,e=t.getTextView();if(e.getOptions("readonly"))return!1;var n=t.getModel();return a(this,!0,function(t,e){var i=n.getLineAtOffset(t.start),o=n.getLineAtOffset(t.end>t.start?t.end-1:t.end),r=n.getLineCount();if(o!==r-1){var s,a=n.getLineStart(i),l=n.getLineEnd(o,!0),h=n.getLineEnd(o+1,!0)-(l-a),d=0;if(o!==r-2)s=n.getText(a,l);else{var c=n.getLineEnd(o);s=n.getText(c,l)+n.getText(a,c),d+=l-c}e("",a,l),e(s,h,h),t.start=h+d,t.end=h+d+s.length}}),!0},moveLinesUp:function(){var t=this.editor,e=t.getTextView();if(e.getOptions("readonly"))return!1;var n=t.getModel();return a(this,!0,function(t,e){var i=n.getLineAtOffset(t.start);if(0!==i){var o=n.getLineAtOffset(t.end>t.start?t.end-1:t.end),r=n.getLineCount(),s=n.getLineStart(i-1),a=n.getLineStart(i),l=n.getLineEnd(o,!0),h=n.getText(a,l),d=0;if(o===r-1){var c=n.getLineEnd(i-1),u=n.getLineEnd(i-1,!0);h+=n.getText(c,u),a=c,d=u-c}e("",a,l),e(h,s,s),t.start=s,t.end=s+h.length-d}}),!0},nextAnnotation:function(t){function e(t,e){switch(e){case d.ANNOTATION_ERROR:return t.type!==d.ANNOTATION_ERROR&&t.type!==d.ANNOTATION_WARNING&&t.type!==d.ANNOTATION_INFO;case d.ANNOTATION_READ_OCCURRENCE:return t.type!==d.ANNOTATION_READ_OCCURRENCE&&t.type!==d.ANNOTATION_WRITE_OCCURRENCE;case d.ANNOTATION_CURRENT_SEARCH:return t.type!==d.ANNOTATION_CURRENT_SEARCH&&t.type!==d.ANNOTATION_MATCHING_SEARCH;case d.ANNOTATION_TASK:return t.type!==d.ANNOTATION_TASK&&t.type!==d.ANNOTATION_BOOKMARK}return!0}var n=this.editor,o=n.getAnnotationModel();if(!o)return!0;var r=n.getOverviewRuler()||n.getAnnotationStyler();if(!r)return!0;var s=n.getModel(),a=n.getCaretOffset();if(!this._lastPosition||this._lastPosition!==a){for(var l=o.getAnnotations(a,a),h=null;l.hasNext();){var c=l.next();if(c.type===d.ANNOTATION_ERROR||c.type===d.ANNOTATION_WARNING||c.type===d.ANNOTATION_INFO){h=d.ANNOTATION_ERROR;break}c.type===d.ANNOTATION_READ_OCCURRENCE||c.type===d.ANNOTATION_WRITE_OCCURRENCE?h=d.ANNOTATION_READ_OCCURRENCE:c.type===d.ANNOTATION_TASK||c.type===d.ANNOTATION_BOOKMARK&&h!==d.ANNOTATION_READ_OCCURRENCE?h=d.ANNOTATION_TASK:(c.type===d.ANNOTATION_CURRENT_SEARCH||c.type===d.ANNOTATION_MATCHING_SEARCH&&!h)&&(h=d.ANNOTATION_CURRENT_SEARCH)}this._iterationMode=h?h:d.ANNOTATION_ERROR}for(var u=o.getAnnotations(t?a:0,t?s.getCharCount():a),f=null;u.hasNext();){var c=u.next();if(t){if(c.start<=a)continue}else if(c.start>=a)continue;if(!e(c,this._iterationMode)&&(f=c,t))break}if(f){var g=[f];for(u=o.getAnnotations(f.start,f.start);u.hasNext();)c=u.next(),c===f||e(c,this._iterationMode)||g.push(c);var p=n.getTextView(),_=i.Tooltip.getTooltip(p,n);if(this._lastPosition=f.start,!_)return n.moveSelection(f.start),!0;n.moveSelection(f.start,f.start,function(){setTimeout(function(){var t=n.getTextView(),e=f.start,i=t.getLocationAtOffset(e);_.show({x:i.x,y:i.y,getTooltipInfo:function(){return n._getTooltipInfo(this.x,this.y)}},!1,!1)},0)})}return!0},unindentLines:function(){var t=this.editor,e=t.getTextView();if(e.getOptions("readonly"))return!1;if(e.getOptions("tabMode")){var n=t.getModel();return a(this,!1,function(t,i){for(var o=n.getLineAtOffset(t.start),r=n.getLineAtOffset(t.end>t.start?t.end-1:t.end),s=e.getOptions("tabSize"),a=new Array(s+1).join(" "),l=[],h=0,d=0,c=o;r>=c;c++){var u=n.getLine(c,!0);if(n.getLineStart(c)!==n.getLineEnd(c))if(0===u.indexOf(" "))u=u.substring(1),h++;else{if(0!==u.indexOf(a))return!0;u=u.substring(s),h+=s}c===o&&(d=h),l.push(u)}var f=n.getLineStart(o),g=n.getLineEnd(r,!0),p=n.getLineStart(r),_=l.join("");i(_,f,g);var v=f===t.start?t.start:t.start-d,m=Math.max(v,t.end-h+(t.end===p+1&&t.start!==t.end?1:0));t.start=v,t.end=m}),!0}},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()}},c.TextActions=l,h.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 e.KeyBinding("t",!0,!1,!0),"trimTrailingWhitespaces"),n.setAction("trimTrailingWhitespaces",function(){return this.trimTrailingWhitespaces()}.bind(this),{name:t.trimTrailingWhitespaces}),n.setKeyBinding(new e.KeyBinding(191,!0),"toggleLineComment"),n.setAction("toggleLineComment",function(){return this.toggleLineComment()}.bind(this),{name:t.toggleLineComment}),n.setKeyBinding(new e.KeyBinding(191,!0,!s.isMac,!1,s.isMac),"addBlockComment"),n.setAction("addBlockComment",function(){return this.addBlockComment()}.bind(this),{name:t.addBlockComment}),n.setKeyBinding(new e.KeyBinding(220,!0,!s.isMac,!1,s.isMac),"removeBlockComment"),n.setAction("removeBlockComment",function(){return this.removeBlockComment()}.bind(this),{name:t.removeBlockComment}),n.setKeyBinding(new e.KeyBinding("[",!1,!1,!1,!1,"keypress"),"autoPairSquareBracket"),n.setAction("autoPairSquareBracket",function(){return this.autoPairBrackets("[","]")}.bind(this)),n.setKeyBinding(new e.KeyBinding("]",!1,!1,!1,!1,"keypress"),"skipClosingSquareBracket"),n.setAction("skipClosingSquareBracket",function(){return this.handleClosingBracket("]")}.bind(this)),n.setKeyBinding(new e.KeyBinding("<",!1,!1,!1,!1,"keypress"),"autoPairAngleBracket"),n.setAction("autoPairAngleBracket",function(){return this.autoPairBrackets("<",">")}.bind(this)),n.setKeyBinding(new e.KeyBinding(">",!1,!1,!1,!1,"keypress"),"skipClosingAngleBracket"),n.setAction("skipClosingAngleBracket",function(){return this.handleClosingBracket(">")}.bind(this)),n.setKeyBinding(new e.KeyBinding("(",!1,!1,!1,!1,"keypress"),"autoPairParentheses"),n.setAction("autoPairParentheses",function(){return this.autoPairBrackets("(",")")}.bind(this)),n.setKeyBinding(new e.KeyBinding(")",!1,!1,!1,!1,"keypress"),"skipClosingParenthesis"),n.setAction("skipClosingParenthesis",function(){return this.handleClosingBracket(")")}.bind(this)),n.setKeyBinding(new e.KeyBinding("{",!1,!1,!1,!1,"keypress"),"autoPairBraces"),n.setAction("autoPairBraces",function(){return this.autoPairBrackets("{","}")}.bind(this)),n.setKeyBinding(new e.KeyBinding("}",!1,!1,!1,!1,"keypress"),"skipClosingBrace"),n.setAction("skipClosingBrace",function(){return this.handleClosingBracket("}")}.bind(this)),n.setKeyBinding(new e.KeyBinding("'",!1,!1,!1,!1,"keypress"),"autoPairSingleQuotation"),n.setAction("autoPairSingleQuotation",function(){return this.autoPairQuotations("'")}.bind(this)),n.setKeyBinding(new e.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(){function t(t,e){if(t.start===t.end){for(var n,o=i.getLineAtOffset(t.start),a=i.getLine(o,!1),u=i.getLineStart(o),f=0,g=t.start-u;g>f&&(32===(n=a.charCodeAt(f))||9===n);)f++;var p,_,v=a.substring(0,f),m=a.substring(0,g),y=a.substring(g);if(c.smartIndentation&&123===a.charCodeAt(_=m.trimRight().length-1)){var x=g-_-1,C=y.length-y.trimLeft().length;return p=125===a.charCodeAt(g+C)?s+v+r+s+v:s+v+r,e(p,t.start-x,t.end+C),t.start=t.end=t.start+s.length+v.length+r.length-x,!0}if(c.autoCompleteComments&&!d.test(m)&&(l.test(m)||h.test(m))){var w,A=l.exec(m);if(A)return p=s+v+" * ",p+=d.test(y)?y.substring(0,y.length-2).trim():y.trim(),i.getLineCount()!==o+1&&h.test(i.getLine(o+1))||(p+=s+v+" */"),e(p,t.start,t.end+y.length),t.start=t.end=t.start+s.length+v.length+3,!0;if(A=h.exec(m))for(var T=o-1;T>=0;T--){var L=i.getLine(T,!1);if(l.test(L))return d.test(y)||47===a.charCodeAt(g)?(p=s+v+"*"+y,w=t.start+s.length+v.length+1):(p=s+v+"* "+y,w=t.start+s.length+v.length+2),e(p,t.start,t.end+y.length),t.start=t.end=w,!0;if(!h.test(L))return!1}return!1}if(d.test(m)&&32===v.charCodeAt(v.length-1))return p=s+v.substring(0,v.length-1),e(p,t.start,t.end),t.start=t.end=t.start+p.length,!0;if(f>0){for(f=g;f]"),r=n.getModel();return a(this,!1,function(n,i){var s,a=n.start===r.getCharCount()?"":r.getText(n.start,n.start+1).trim();n.start===n.end&&o.test(a)?(s=t+e,i(s,n.start,n.start),n.start=n.end=n.start+1):n.start!==n.end?(s=t+r.getText(n.start,n.end)+e,i(s,n.start,n.end),n.start+=1,n.end+=1):(i(t,n.start,n.end),n.start=n.end=n.start+t.length)}),!0},autoPairQuotations:function(t){if(!this.autoPairQuotation)return!1;var e=this.editor,n=e.getTextView();if(n.getOptions("readonly"))return!1;var i=new RegExp("^\"$|^'$"),o=new RegExp("\\w"),r=new RegExp("^$|[)}\\]>]"),s=e.getModel();return a(this,!1,function(e,n){function a(){n(t,e.start,e.end),e.start=e.end=e.start+t.length}var l=0===e.start?"":s.getText(e.start-1,e.start).trim(),h=e.start===s.getCharCount()?"":s.getText(e.start,e.start+1).trim();if(e.start!==e.end){var d=s.getText(e.start,e.end);i.test(d)?a():(n(t+d+t,e.start,e.end),e.start+=1,e.end+=1)}else h===t?e.start=e.end=e.start+1:l===t||i.test(h)||o.test(l)||!r.test(h)?a():(n(t+t,e.start,e.end),e.start=e.end=e.start+t.length)}),!0},contentAssistProposalApplied:function(t){function e(){return"number"==typeof n.escapePosition?n.escapePosition:t.data.start+n.proposal.length}var n=t.data.proposal;if(n.positions&&n.positions.length>0&&this.linkedMode){for(var i=[],o=0;o0&&this.linkedMode)this.linkedMode.enterLinkedMode({groups:n.groups,escapePosition:e()});else if("number"==typeof n.escapePosition){var r=this.editor.getTextView();r.setCaretOffset(n.escapePosition)}return!0},deletePrevious:function(){var t=this.editor,e=t.getTextView();if(e.getOptions("readonly"))return!1;var n=t.getModel();return a(this,!1,function(t,e){if(t.start===t.end){var i=0===t.start?"":n.getText(t.start-1,t.start),o=t.start===n.getCharCount()?"":n.getText(t.start,t.start+1);("("===i&&")"===o||"["===i&&"]"===o||"{"===i&&"}"===o||"<"===i&&">"===o||'"'===i&&'"'===o||"'"===i&&"'"===o)&&e("",t.start,t.start+1)}},!0),!1},_findEnclosingComment:function(t,e,n,i,o){var r,s,a,l,h,d,c,u=t.getLineAtOffset(e),f=t.getLineAtOffset(n);for(r=u;r>=0&&(s=t.getLine(r),a=r===u?e-t.getLineStart(u):s.length,l=s.lastIndexOf(i,a),h=s.lastIndexOf(o,a),!(h>l));r--)if(-1!==l){d=t.getLineStart(r)+l;break}for(r=f;rl));r++)if(-1!==h){c=t.getLineStart(r)+h;break}return{commentStart:d,commentEnd:c}},lineStart:function(){var t=this.editor,e=t.getModel();return a(this,!1,function(t){var n,i=t.getCaret(),o=e.getLineAtOffset(i),r=e.getLineStart(o),s=e.getLine(o);for(n=0;nt.start?t.end-1:t.end);o=i?i.getLineCommentDelimiter(n.getLineStart(r)):"//";for(var a,l=!0,h=[],d=r;s>=d;d++){var c=n.getLine(d,!0);if(a=c.indexOf(o),h.push(a),l&&-1!==a){if(0!==a){var u;for(u=0;a>u;u++){var f=c.charCodeAt(u);if(32!==f&&9!==f)break}l=u===a}}else l=!1}var g,p,_,v=o.length,m=n.getLineStart(r);if(l){for(_=h.length-1;_>=0;_--)a=h[_]+n.getLineStart(r+_),e("",a,a+v);var y=n.getLineStart(s);g=m===t.start?t.start:t.start-v,p=t.end-v*(s-r+1)+(t.end===y+1?v:0)}else{for(_=h.length-1;_>=0;_--)a=n.getLineStart(r+_),e(o,a,a);g=m===t.start?t.start:t.start+v,p=t.end+v*(s-r+1)}t.start=g,t.end=p}),e.setRedraw(!0),!0},trimTrailingWhitespaces:function(){var t=this.editor,e=t.getModel(),n=t.getSelections();t.getTextView().setRedraw(!1),this.startUndo();for(var i=/(\s+$)/,o=e.getLineCount(),r=0;o>r;r++){var s=e.getLine(r),a=i.exec(s);if(a){var l=e.getLineStart(r),h=a[0].length,d=l+a.index;e.setText("",d,d+h),n.forEach(function(t){t.start>d&&(t.start=Math.max(d,t.start-h)),t.start!==t.end&&t.end>d&&(t.end=Math.max(d,t.end-h))})}}this.endUndo(),t.setSelections(n,!1),t.getTextView().setRedraw(!0)},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},handleClosingBracket:function(t){var e=this.editor,n=e.getTextView();if(n.getOptions("readonly"))return!1;var i=e.getModel(),o=e.getSelections();if(1===o.length&&o[0].start===o[0].end){var r=o[0].start===i.getCharCount()?"":i.getText(o[0].start,o[0].start+1);if(r===t)return o[0].start=o[0].end=o[0].start+1,e.setSelections(o),!0;var s=i.getLineAtOffset(o[0].start),a=i.getLine(s,!0);if(a.match(/^\s*$/)&&n.getOptions("tabMode")){var l=n.getOptions("tabSize"),h=new Array(l+1).join(" "),d=i.getLineStart(s),c=i.getLineEnd(s);if(d!==c){if(0===a.indexOf(" "))return a=a.substring(1),i.setText(a,d,c),e.setSelection(o[0].start-1,o[0].end-1),!1;if(0===a.indexOf(h))return a=a.substring(l),i.setText(a,d,c),e.setSelection(o[0].start-l,o[0].end-l),!1}}}return!1},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},setAutoPairParentheses:function(t){this.autoPairParentheses=t},setAutoPairBraces:function(t){this.autoPairBraces=t},setAutoPairSquareBrackets:function(t){this.autoPairSquareBrackets=t},setAutoPairAngleBrackets:function(t){this.autoPairAngleBrackets=t},setAutoPairQuotations:function(t){this.autoPairQuotation=t},setAutoCompleteComments:function(t){this.autoCompleteComments=t},setSmartIndentation:function(t){this.smartIndentation=t}},c.SourceCodeActions=h,String.prototype.trimLeft||(String.prototype.trimLeft=function(){return this.replace(/^\s+/g,"")}),String.prototype.trimRight||(String.prototype.trimRight=function(){return this.replace(/\s+$/g,"")}),c}),define("orion/editor/undoStack",[],function(){function t(t,e,n,i,o){this.model=t,this.offset=e,this.text=n,this.previousText=i,this.type=o}function e(t){this.owner=t,this.changes=[]}function n(t,e){this.size=void 0!==e?e:100,this.reset();var n=this;if(this._listener={onChanging:function(t){n._onChanging(t)},onDestroy:function(t){n._onDestroy(t)}},t.getModel){var i=t.getModel();i.getBaseModel&&(i=i.getBaseModel()),this.model=i,this.setView(t)}else this.shared=!0,this.model=t;this.model.addEventListener("Changing",this._listener.onChanging)}return t.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(t,e){return this._doUndoRedo(this.offset,this.previousText,this.text,t,e),!0},redo:function(t,e){return this._doUndoRedo(this.offset,this.text,this.previousText,t,e),!0},merge:function(t,e,n,i,o){if(i===this.type){if(1===i&&t===this.offset+this.text.length)return this.text+=e,!0;if(-1===i&&o===this.offset)return this.offset=t,this.previousText=n+this.previousText,!0;if(-1===i&&t===this.offset)return this.previousText=this.previousText+n,!0}return!1},_doUndoRedo:function(t,e,n,i,o){if(this.model.setText(e,t,t+n.length),o&&i){var r=i.getModel();r!==this.model&&(t=r.mapOffset(t,!0)),i.setSelection(t,t+e.length)}}},e.prototype={getRedoChanges:function(){for(var t=[],e=0;e=0;e--)t=t.concat(this.changes[e].getUndoChanges());return t},add:function(t){this.changes.push(t)},end:function(t){t&&(this.endSelection=t.getSelections());var e=this.owner;e&&e.end&&e.end()},undo:function(t,e){this.changes.length>1&&t&&t.setRedraw(!1);for(var n=this.changes.length-1;n>=0;n--)this.changes[n].undo(t,!1);e&&t&&t.setSelections(this.startSelection),this.changes.length>1&&t&&t.setRedraw(!0);var i=this.owner;return i&&i.undo&&i.undo(),this.changes.length>0},redo:function(t,e){this.changes.length>1&&t&&t.setRedraw(!1);for(var n=0;n1,t&&t.setRedraw(!0);var i=this.owner;return i&&i.redo&&i.redo(),this.changes.length>0},merge:function(t,e,n,i,o,r){var s=this.changes.length;return s>0&&this===r?this.changes[s-1].merge(t,e,n,i,o):!1},start:function(t){t&&(this.startSelection=t.getSelections());var e=this.owner;e&&e.start&&e.start()}},n.prototype={destroy:function(){this._onDestroy()},add:function(t){if(this.compoundChange)this.compoundChange.add(t);else{var e=this.stack.length;this.stack.splice(this.index,e-this.index,t),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=void 0 },getSize:function(){return{undo:this.index,redo:this.stack.length-this.index}},getRedoChanges:function(){this._commitUndo();for(var t=[],e=this.index;e=0;e--)t=t.concat(this.stack[e].getUndoChanges());return t},undo:function(){this._commitUndo();var t,e=!1;this._ignoreUndo=!0;do{if(this.index<=0)break;t=this.stack[--this.index]}while(!(e=t.undo(this.view,!0)));return this._ignoreUndo=!1,e},redo:function(){this._commitUndo();var t,e=!1;this._ignoreUndo=!0;do{if(this.index>=this.stack.length)break;t=this.stack[this.index++]}while(!(e=t.redo(this.view,!0)));return this._ignoreUndo=!1,e},reset:function(){this.index=0,this.cleanChange=void 0,this.stack=[],this._ignoreUndo=!1,this._compoundChange=void 0},setView:function(t){this.view!==t&&(this.view&&t.removeEventListener("Destroy",this._listener.onDestroy),this.view=t,this.view&&t.addEventListener("Destroy",this._listener.onDestroy))},startCompoundChange:function(t){this._commitUndo();var n=new e(t);return this.add(n),this.compoundChange=n,this.compoundChange.start(this.view),this.compoundChange},_commitUndo:function(){this.endCompoundChange()},_onDestroy:function(t){t&&this.shared||this.model.removeEventListener("Changing",this._listener.onChanging),this.view&&(this.view.removeEventListener("Destroy",this._listener.onDestroy),this.view=null)},_trackUnsavedChanges:function(t){if(this._unsavedChanges){var e=this._unsavedChanges.length,n=t.addedCharCount,i=t.removedCharCount,o=t.start,r=t.start+i,s=0;if(0===n?s=-1:0===i&&(s=1),e>0&&s===this._previousChangeType){var a=this._unsavedChanges[e-1];if(0===i&&o===a.end+a.text.length)return void(a.text+=t.text);if(0===t.addedCharCount&&r===a.start)return void(a.start=o)}this._previousChangeType=s,this._unsavedChanges.push({start:o,end:r,text:t.text})}},_onChanging:function(e){if(this._trackUnsavedChanges(e),!this._ignoreUndo){var n=e.text,i=e.start,o=e.addedCharCount,r=e.removedCharCount,s=i+r,a=0;0===o&&1===r?a=-1:1===o&&0===r&&(a=1);var l=this.stack.length,h=this.model.getText(i,s);if(l>0&&this.index===l){var d=this.stack[l-1];if(d.merge(i,n,h,a,s,this.compoundChange))return}this.add(new t(this.model,i,n,h,a))}}},{UndoStack:n}}),define("orion/editor/rulers",["i18n!orion/editor/nls/messages","orion/editor/textView","orion/editor/annotations","orion/editor/tooltip","orion/objects","orion/editor/util","orion/util"],function(t,e,n,i,o,r,s){function a(t,e,n){this._location=t||"left",this._overview=e||"page",this._rulerStyle=n,this._view=null}function l(t,e,n,i){a.call(this,e,n,i);var o=this;this._listener={onTextModelChanged:function(t){o._onTextModelChanged(t)},onAnnotationModelChanged:function(t){o._onAnnotationModelChanged(t)}},this.setAnnotationModel(t)}function h(t,e,n,i,o){l.call(this,t,e,"page",n),this._oddStyle=i||{style:{backgroundColor:"white"}},this._evenStyle=o||{style:{backgroundColor:"white"}},this._numOfDigits=0,this._firstLine=1}function d(t,e,n){l.call(this,t,e,"page",n)}function c(t,e,n){l.call(this,t,e,"document",n)}function u(t,e,n){d.call(this,t,e,n)}a.prototype={getLocation:function(){return this._location},getOverview:function(){return this._overview},getRulerStyle:function(){return this._rulerStyle},getView:function(){return this._view},setView:function(t){this._onTextModelChanged&&this._view&&this._view.removeEventListener("ModelChanged",this._listener.onTextModelChanged),this._view=t,this._onTextModelChanged&&this._view&&this._view.addEventListener("ModelChanged",this._listener.onTextModelChanged)}},l.prototype=o.mixin(new a,{getAnnotations:function(t,e){var n=this._annotationModel;if(!n)return[];var i=this._view.getModel(),o=i.getLineStart(t),r=i.getLineEnd(e-1),s=i;i.getBaseModel&&(s=i.getBaseModel(),o=i.mapOffset(o),r=i.mapOffset(r));for(var a=[],l=this.getAnnotationsByType(n,o,r),h=0;h=f;f++){var g=f;if(i!==s){var p=s.getLineStart(f);if(p=i.mapOffset(p,!0),-1===p)continue;g=i.getLineAtOffset(p)}if(g>=t&&e>g){var _=this._mergeAnnotation(a[g],d,f-c,u-c+1);_&&(a[g]=_)}}if(!this._multiAnnotation&&this._multiAnnotationOverlay)for(var v in a)a[v]._multiple&&(a[v].html=a[v].html+this._multiAnnotationOverlay.html);return a},getAnnotationModel:function(){return this._annotationModel},getWidestAnnotation:function(){return null},setAnnotationModel:function(t){this._annotationModel&&this._annotationModel.removeEventListener("Changed",this._listener.onAnnotationModelChanged),this._annotationModel=t,this._annotationModel&&this._annotationModel.addEventListener("Changed",this._listener.onAnnotationModelChanged)},setMultiAnnotation:function(t){this._multiAnnotation=t},setMultiAnnotationOverlay:function(t){this._multiAnnotationOverlay=t},onClick:function(t){if(void 0!==t){var e,n,o,r=this._view,s=r.getModel(),a=s.getLineStart(t),l=s.getLineEnd(t,!0),h=r.getSelection().start,d=r.getSelection().end,c=this._annotationModel;if(c){s.getBaseModel&&(a=s.mapOffset(a),l=s.mapOffset(l),h=s.mapOffset(h),d=s.mapOffset(d));var u=this;e=this._findNextAnnotation(c,a,l,h,d,function(t){return u.isAnnotationTypeVisible(t)}),n=e?e.start:a,o=e?e.end:a,s.getBaseModel&&(n=s.mapOffset(n,!0),o=s.mapOffset(o,!0)),e&&void 0!==e.groupId&&(this._currentClickGroup=this._currentClickGroup===e.groupId?null:e.groupId,this._setCurrentGroup(t))}this._view.setSelection(o,n,1/3,function(){});var f=i.Tooltip.getTooltip(this._view);f&&(e&&"left"===this.getLocation()?f.show({getTooltipInfo:function(){return u._getTooltipInfo([e])}},!1,!1):f.hide())}},onDblClick:function(){},onMouseMove:function(t,e){var n=i.Tooltip.getTooltip(this._view);if(n&&(!n.isVisible()||this._tooltipLineIndex!==t)&&(this._tooltipLineIndex=t,e.clientX!==this._lastMouseX||e.clientY!==this._lastMouseY)){this._lastMouseX=e.clientX,this._lastMouseY=e.clientY,this._hoverTimeout&&(window.clearTimeout(this._hoverTimeout),this._hoverTimeout=null);var o=e.target?e.target:e.srcElement,r=o.getBoundingClientRect();this._curElementBounds=Object.create(null),this._curElementBounds.top=r.top,this._curElementBounds.left=r.left,this._curElementBounds.height=r.height,this._curElementBounds.width=r.width,o===this.node&&(this._curElementBounds.top=e.clientY,this._curElementBounds.height=1);var s=this;s._hoverTimeout=window.setTimeout(function(){s._hoverTimeout=null,n.onHover({getTooltipInfo:function(){var t=s._getAnnotationsAtLineIndex(s._tooltipLineIndex),n=s._getTooltipContents(s._tooltipLineIndex,t);return s._getTooltipInfo(n,e.clientY,{source:"ruler",rulerLocation:s.getLocation()})}},e.clientX,e.clientY)},175)}},onMouseOver:function(t,e){this.onMouseMove(t,e),this._currentClickGroup||this._setCurrentGroup(t)},onMouseOut:function(){this._currentClickGroup||this._setCurrentGroup(-1),this._hoverTimeout&&(window.clearTimeout(this._hoverTimeout),this._hoverTimeout=null)},_findNextAnnotation:function(t,e,n,i,o,r){var s,a=null,l=e;if(i>=0&&o>=0&&i>=e&&n>i){l=i;for(var h=t.getAnnotations(i,o);!s&&h.hasNext();){var d=h.next();(!r||r(d.type))&&d.start===i&&d.end===o&&(s=d)}}for(var c,u=t.getAnnotations(l,n);u.hasNext();)if(d=u.next(),!r||r(d.type)){if(a||(a=d),!s){a=d;break}if(c&&(s.start!==d.start||s.end!==d.end)){c=!1,a=d;break}s&&s===d&&(c=!0)}return c&&(a=null),a},_getAnnotationsAtLineIndex:function(t){if(void 0!==t){var e,n=this._view,i=this._annotationModel,o=[];if(!n)return[];if(e=n.getModel(),i&&e){var r=e.getLineStart(t),s=e.getLineEnd(t);e.getBaseModel&&(r=e.mapOffset(r),s=e.mapOffset(s)),o=this.getAnnotationsByType(i,r,s)}return o}},_getTooltipInfo:function(t,e,n){if(!t)return null;var i=Object.create(null);i.top=this._curElementBounds.top,i.left=this._curElementBounds.left,i.height=this._curElementBounds.height,i.width=this._curElementBounds.width,"string"==typeof t&&e&&(i.top=e,i.height=1);var o=this.getLocation(),r=this.getRulerStyle(),s="left"===o?"right":"left",a=0,l=0;if(this._view){var h=this._view._clientDiv.getBoundingClientRect();a=h.left-(i.left+i.width)}else a=i.width;l=i.height,"left"===s&&(a=-25,1===i.height&&(a+=2)),r.styleClass.indexOf("folding")>=0&&(l-=14);var d={contents:t,position:s,tooltipOffsetX:a,tooltipOffsetY:l,anchorArea:i,context:n};return d},_getTooltipContents:function(t,e){return e},_getOnClickTooltipInfo:function(t){var e=this._view,n=Object.create(null);n.top=this._curElementBounds.top,n.left=this._curElementBounds.left,n.height=this._curElementBounds.height,n.width=this._curElementBounds.width;var i=this.getLocation(),o="left"===i?"right":"left",r={contents:[t],position:o,anchorArea:n};if(e){var s=e._clientDiv.getBoundingClientRect();r.offsetX=s.left-(n.left+n.width)}else r.offsetX=n.width;return r.offsetY=n.height,"left"===r.position&&(r.offsetX=20),r},_onAnnotationModelChanged:function(t){function e(t){for(var e=0;e=l&&void 0!==e.groupId){o=e;break}if(s&&o&&s.groupId===o.groupId)return}if(this._currentGroupAnnotation=null,s&&i.removeAnnotations(s.groupType),o&&-1!==t){this._currentGroupAnnotation=o,n=i.getAnnotations();for(var h=[];n.hasNext();)e=n.next(),delete e.groupAnnotation,e.groupId===o.groupId&&(e=e.createGroupAnnotation(),h.push(e));i.replaceAnnotations(null,h)}}}),n.AnnotationTypeList.addMixin(l.prototype),h.prototype=new l,h.prototype.getAnnotations=function(t,e){for(var n=l.prototype.getAnnotations.call(this,t,e),i=this._view.getModel(),o=t;e>o;o++){var r=o-this._firstLine&1?this._oddStyle:this._evenStyle,s=o;if(i.getBaseModel){var a=i.getLineStart(s);s=i.getBaseModel().getLineAtOffset(i.mapOffset(a))}n[o]||(n[o]={}),n[o].html=this._firstLine+s+"",n[o].style||(n[o].style=r)}return n},h.prototype.getWidestAnnotation=function(){var t=this._view.getModel().getLineCount();return this.getAnnotations(t-1,t)[t-1]},h.prototype.setFirstLine=function(t){this._firstLine=void 0!==t?t:1},h.prototype._onTextModelChanged=function(t){var e=t.start,n=this._view.getModel(),i=n.getBaseModel?n.getBaseModel().getLineCount():n.getLineCount(),o=(this._firstLine+i-1+"").length;if(this._numOfDigits!==o){this._numOfDigits=o;var r=n.getLineAtOffset(e);this._view.redrawLines(r,n.getLineCount(),this)}},d.prototype=new l,c.prototype=new l,c.prototype.getRulerStyle=function(){var t={style:{lineHeight:"1px",fontSize:"1px"}};return t=this._mergeStyle(t,this._rulerStyle)},c.prototype._getTooltipContents=function(e,n){if(n&&0===n.length){var i=this._view.getModel(),o=e;if(i.getBaseModel){var r=i.getLineStart(o);o=i.getBaseModel().getLineAtOffset(i.mapOffset(r))}return s.formatMessage(t.line,o+1)}return l.prototype._getTooltipContents.call(this,e,n)},c.prototype._mergeAnnotation=function(t,e,n,i){if(0!==n)return void 0;var o=t;if(!o){var r=3*i;o={html:" ",style:{style:{height:r+"px"}}},o.style=this._mergeStyle(o.style,e.overviewStyle)}return o},u.prototype=new d,u.prototype.onClick=function(t){if(void 0!==t){var e=this._annotationModel;if(e){var n=this._view,o=n.getModel(),r=o.getLineStart(t),s=o.getLineEnd(t,!0);o.getBaseModel&&(r=o.mapOffset(r),s=o.mapOffset(s),o=o.getBaseModel());for(var a,l=e.getAnnotations(r,s);!a&&l.hasNext();){var h=l.next();this.isAnnotationTypeVisible(h.type)&&o.getLineAtOffset(h.start)===o.getLineAtOffset(r)&&(a=h)}if(a){var d=i.Tooltip.getTooltip(this._view);d&&d.hide(),a.expanded?a.collapse():a.expand()}}}},u.prototype._getTooltipContents=function(t,e){if(e&&e.length>0){var n=this._view,i=n.getModel(),o=i.getLineStart(t);i.getBaseModel&&(o=i.mapOffset(o),i=i.getBaseModel());for(var r=i.getLineAtOffset(o),s=0;s=t.end?s-=t.end-t.start:s>=t.start&&(s=t.start)}),n.setText(r,s,s),n.setSelection(s,s+r.length),this._dropText=null,this._dropOffset=-1}this._undoStack&&this._undoStack.endCompoundChange(),this._dragSelection=null}},_onDragEnter:function(t){this._onDragOver(t)},_onDragOver:function(e){var n=e.event.dataTransfer.types,i=!this._view.getOptions("readonly");if(i&&n&&(i=n.contains?n.contains("text/plain")||n.contains("Text"):-1!==n.indexOf("text/plain")||-1!==n.indexOf("Text")),i){if(!t.isFirefox){var o=t.isMac?e.event.altKey:e.event.ctrlKey;this._dropEffect=e.event.dataTransfer.dropEffect=o?"copy":"move"}}else e.event.dataTransfer.dropEffect="none"},_onDrop:function(e){var n=this._view,i=e.event.dataTransfer.getData("Text");if(i){t.isFirefox||(e.event.dataTransfer.dropEffect=this._dropEffect);var o=n.getOffsetAtLocation(e.x,e.y);this._dragSelection?(this._dropOffset=o,this._dropText=i):(n.setText(i,o,o),n.setSelection(o,o+i.length))}}},{TextDND:e}}),define("orion/editor/linkedMode",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/keyModes","orion/editor/annotations","orion/objects","orion/util"],function(t,e,n,i,o){function r(t){this._data=t}function s(t,e,i){var o=t.getTextView();n.KeyMode.call(this,o),this.editor=t,this.undoStack=e,this.contentAssist=i,this.linkedModeModel=null,o.setAction("linkedModeEnter",function(){return this.exitLinkedMode(!0),!0}.bind(this)),o.setAction("linkedModeCancel",function(){return this.exitLinkedMode(!0),!0}.bind(this)),o.setAction("linkedModeNextGroup",function(){var t=this.linkedModeModel;return this.selectLinkedGroup((t.selectedGroupIndex+1)%t.groups.length),!0}.bind(this)),o.setAction("linkedModePreviousGroup",function(){var t=this.linkedModeModel;return this.selectLinkedGroup(t.selectedGroupIndex>0?t.selectedGroupIndex-1:t.groups.length-1),!0}.bind(this)),this.linkedModeListener={onActivating:function(){this._groupContentAssistProvider&&(this.contentAssist.setProviders([this._groupContentAssistProvider]),this.contentAssist.setProgress(null))}.bind(this),onModelChanged:function(t){if(!this.ignoreVerify){for(var e,n,i=this.editor.mapOffset(t.start),o=this.linkedModeModel;o&&(e=this._getPositionChanged(o,i,i+t.removedCharCount),n=e.position,void 0===n||n.model!==o);)this.exitLinkedMode(!1),o=this.linkedModeModel;if(o){for(var r,s,a=0,l=t.addedCharCount-t.removedCharCount,h=e.positions,d=0;d=0;g--)l=c[g],l.model===r&&l.group===n.group&&this.editor.setText(t.text,l.oldOffset+u,l.oldOffset+f,!1);this.ignoreVerify=!1,t.text=null,this._updateAnnotations(c)}}}.bind(this)}}var a={};return r.prototype={chop:function(t,e){return e.substring(t.length)},computeProposals:function(t,e,n){var i=n.prefix,o=[],r=this._data.style?this._data.style:null;r=r?r:"emphasis";for(var s=this._data.values,a=0;a=0;r--)if(!o[r].escape){var s=o[r].position;if(s.offset<=e&&n<=s.offset+s.length){i=o[r];break}}return{position:i,positions:o}},_updateAnnotations:function(t){var e=this.editor.getAnnotationModel();if(e){for(var n,o=[],r=[],s=e.getAnnotations();s.hasNext();)switch(n=s.next(),n.type){case i.AnnotationType.ANNOTATION_LINKED_GROUP:case i.AnnotationType.ANNOTATION_CURRENT_LINKED_GROUP:case i.AnnotationType.ANNOTATION_SELECTED_LINKED_GROUP:o.push(n)}var a=this.linkedModeModel;if(a){t=t||this._getSortedPositions(a);for(var l=0;l0||t.addedLineCount>0),n},setState:function(t,e){var n;t===g.ACTIVE?(n="Activating",this._mode&&this._mode.setActive(!0)):t===g.INACTIVE&&(n="Deactivating",this._mode&&this._mode.setActive(!1)),n&&this.dispatchEvent({type:n,providers:e}),this.state=t,this.onStateChange(t)},setMode:function(t){this._mode=t},onStateChange:function(t){t===g.INACTIVE?(this._removeTextViewListeners(),this._filterText="",this._initialCaretOffset=-1,this._computedProposals=null):t===g.ACTIVE&&(this._filterText="",this._addTextViewListeners(),this.computeProposals())},computeProposals:function(){var t=this.textView.getCaretOffset(),e=this.textView.getSelection(),n=Math.min(e.start,e.end);this._initialCaretOffset=Math.min(t,n),this._computedProposals=null,delete this._autoApply,this._computeProposals(this._initialCaretOffset).then(function(t){if(this.isActive()){var e=this._flatten(t);e&&Array.isArray(e)&&00&&/[A-Za-z0-9_]/.test(t.getText(n-1,n));)n--;return n},handleError:function(t){"undefined"!=typeof console&&(console.log("Error retrieving content assist proposals"),console.log(t&&t.stack))},initialize:function(){this._providers.forEach(function(t){var e=t.provider;"function"==typeof e.initialize&&e.initialize()})},_computeProposals:function(e){var n=this._providers,i=this.textView,s=i.getSelection(),a=i.getModel(),l=e;a.getBaseModel&&(l=a.mapOffset(l),s.start=a.mapOffset(s.start),s.end=a.mapOffset(s.end),a=a.getBaseModel());for(var h=a.getLine(a.getLineAtOffset(l)),d=0;d0)for(var i=0;i0){n=!0;break}return n||p.pageMessage.setErrorMessage(t.noProposals),e}),this.pageMessage.showWhile(v,t.computingProposals)),v},filterProposals:function(t){if(this._computedProposals&&(this._latestModelChangingEvent||t)){var e=this.textView.getModel();e.getBaseModel&&(e=e.getBaseModel());var n=this.getPrefixStart(e,this._initialCaretOffset),i=this.textView.getText(n,this._initialCaretOffset),o=i,r=[];this._computedProposals.forEach(function(t){if(t&&Array.isArray(t)){var e=t.filter(function(t){function e(t,e){var n=e.replace(/([.+^=!:${}()|\[\]\/\\])/g,"\\$1");return n=n.replace(/([*?])/g,".$1"),new RegExp("^"+t+n,"i")}var n;if(!t)return!1;if(o="string"==typeof t.prefix?t.prefix:i,p[t.style]===p.hr||p[t.style]===p.noemphasis_title)return!0;var r="";if(t.overwrite){if(t.name)r=t.name;else{if(!t.proposal)return!1;r=t.proposal}return n=e(o,this._filterText),n.test(r)}if(t.name||t.proposal){var s=!1;return t.name&&(n=e(o,this._filterText),s=n.test(t.name)),!s&&t.proposal&&(n=e("",this._filterText),s=n.test(t.proposal)),s}return"string"==typeof t?(n=e("",this._filterText),n.test(t)):!1},this);e.length>0&&r.push(e)}},this);var s=[];r&&(r=this._removeExtraUnselectableElements(r),s=this._flatten(r)),this.dispatchEvent({type:"ProposalsComputed",data:{proposals:s},autoApply:!1})}},_removeExtraUnselectableElements:function(t){var e=t.map(function(t){var e=t.filter(function(e,n){var i=!0;if(p[e.style]===p.hr)0===n||t.length-1===n?i=!1:p.hr===p[t[n-1].style]&&(i=!1);else if(p[e.style]===p.noemphasis_title){var o=t[n+1];o?p[o.style]===p.noemphasis_title&&(i=!1):i=!1}return i});return e});return e},setEditorContextProvider:function(t){this.editorContextProvider=t},_generateProviderId:function(){return this._idcount?this._idcount++:this._idcount=0,"ContentAssistGeneratedID_"+this._idcount},setAutoTriggerEnabled:function(t){this._autoTriggerEnabled=t,this._updateAutoTriggerListenerState()},setProviders:function(t){var e=this;this.setProviderInfoArray(t.map(function(t){return t.id?t:{provider:t,id:e._generateProviderId()}}))},setProviderInfoArray:function(t){this.clearProviders(),this._providers=t,this._charTriggersInstalled=t.some(function(t){return t.charTriggers}),this._updateAutoTriggerListenerState()},getProviders:function(){return this._providers.slice()},clearProviders:function(){this._providers=[],this._charTriggersInstalled=!1,this._updateAutoTriggerListenerState()},setProgress:function(t){this.progress=t},setStyleAccessor:function(t){this._styleAccessor=t},_flatten:function(t){return t.reduce(function(t,e){var n=t,i=null;if(e&&Array.isArray(e)&&(i=e.filter(function(t){return t})),i&&Array.isArray(i)&&i.length>0){var o=i,r=t,s=i[0].style;if(s&&p[s]&&0===p[s].indexOf(p.noemphasis)&&(o=t,r=i),o.length>0){var a=o[o.length-1].style;a&&p.hr!==p[a]&&(o=o.concat({proposal:"",name:"",description:"---------------------------------",style:"hr",unselectable:!0}))}n=o.concat(r)}return n},[])},_triggerListener:function(){var t=this.textView.getCaretOffset(),e=null,n=[];if(this._charTriggersInstalled){var i=this.textView.getText(t-1,t);this._providers.forEach(function(o){var r=o.charTriggers;if(r&&r.test(i)){var s=!1,a=o.excludedStyles;this._styleAccessor&&a&&(e||(e=this._styleAccessor.getStyles(t-1)),s=e.some(function(t){return a.test(t.style)})),s||n.push(o)}},this),n.length>0&&this.activate(n,!0)}},_updateAutoTriggerListenerState:function(){this._boundTriggerListener||(this._boundTriggerListener=this._triggerListener.bind(this)),this._triggerListenerInstalled?this._autoTriggerEnabled&&this._charTriggersInstalled||(this.textView.removeEventListener("Modify",this._boundTriggerListener),this._triggerListenerInstalled=!1):this._autoTriggerEnabled&&this._charTriggersInstalled&&(this.textView.addEventListener("Modify",this._boundTriggerListener),this._triggerListenerInstalled=!0)},_addTextViewListeners:function(){this._textViewListenersAdded||(this.textView.addEventListener("ModelChanging",this._textViewListeners.onModelChanging),this.textView.addEventListener("Scroll",this._textViewListeners.onScroll),this.textView.addEventListener("Selection",this._textViewListeners.onSelection),this._textViewListenersAdded=!0)},_removeTextViewListeners:function(){this._textViewListenersAdded&&(this._latestModelChangingEvent=null,this.textView.removeEventListener("ModelChanging",this._textViewListeners.onModelChanging),this.textView.removeEventListener("Scroll",this._textViewListeners.onScroll),this.textView.removeEventListener("Selection",this._textViewListeners.onSelection),this._textViewListenersAdded=!1)},_updateFilterText:function(t){var e=t.removedCharCount;if(e){var n=this._filterText.length-e;this._filterText=this._filterText.substring(0,n)}var i=t.text;i&&(this._filterText=this._filterText.concat(i))}},i.EventTarget.addMixin(c.prototype),u.prototype=new n.KeyMode,r.mixin(u.prototype,{createKeyBindings:function(){var t=e.KeyBinding,n=[];return n.push({actionID:"contentAssistApply",keyBinding:new t(13)}),n.push({actionID:"contentAssistCancel",keyBinding:new t(27)}),n.push({actionID:"contentAssistNextProposal",keyBinding:new t(40)}),n.push({actionID:"contentAssistPreviousProposal",keyBinding:new t(38)}),n.push({actionID:"contentAssistNextPage",keyBinding:new t(34)}),n.push({actionID:"contentAssistPreviousPage",keyBinding:new t(33)}),n.push({actionID:"contentAssistHome",keyBinding:new t(h.KEY.HOME)}),n.push({actionID:"contentAssistEnd",keyBinding:new t(h.KEY.END)}),n.push({actionID:"contentAssistTab",keyBinding:new t(9)}),n},cancel:function(){this.getContentAssist().deactivate()},getContentAssist:function(){return this.contentAssist},getProposals:function(){return this.proposals},isActive:function(){return this.getContentAssist().isActive()},setActive:function(t){t?this.contentAssist.textView.addKeyMode(this):this.contentAssist.textView.removeKeyMode(this)},lineUp:function(t,e){return this.selectNew(t,e,!1)},lineDown:function(t,e){return this.selectNew(t,e,!0)},selectNew:function(t,e,n){var i=t;if(n){if(void 0===i&&(i=this.selectedIndex+1),i>=this.proposals.length){if(e)return!0;i=0}}else if(void 0===i&&(i=this.selectedIndex-1),0>i){if(e)return!0;i=this.proposals.length-1}for(var o=i;this.proposals[i]&&this.proposals[i].unselectable;){if(n){if(i++,i>=this.proposals.length){if(e)return!0;i=0}}else if(i--,0>i){if(e)return!0;i=this.proposals.length-1}if(i===o){i=-1;break}}return this.selectedIndex=i,this.widget&&this.widget.selectNode(i),this._showTooltip(!0),!0},_showTooltip:function(t,e){var n=s.Tooltip.getTooltip(this.contentAssist.textView),i=this,o={getTooltipInfo:function(){var t=i.widget.parentNode.getBoundingClientRect(),e={width:350,height:t.height,top:t.top};t.left+t.width>=document.documentElement.clientWidth?(e.left=t.left-e.width,e.left-=10):(e.left=t.left+t.width,e.left+=10);var n={context:{proposal:i.proposals[i.selectedIndex]},anchorArea:t,tooltipArea:e};return n}};t?n.update(o,e):n.show(o,!0,!1)},_hideTooltip:function(){var t=s.Tooltip.getTooltip(this.contentAssist.textView);t.hide(!0)},pageUp:function(){if(this.widget){var t=this.widget.getTopIndex();return t===this.selectedIndex&&(this.widget.scrollIndex(t,!1),t=this.widget.getTopIndex()),0===t?this.lineDown(t,!0):this.lineUp(t,!0)}return this.lineUp()},pageDown:function(){if(this.widget){var t=this.widget.getBottomIndex();return t===this.selectedIndex&&(this.widget.scrollIndex(t,!0),t=this.widget.getBottomIndex()),this.lineDown(t,!0)}return this.lineDown()},enter:function(){var t=this.proposals[this.selectedIndex]||null;return this.contentAssist.apply(t)},tab:function(){return this.widget?(this.widget.parentNode.focus(),!0):!1}}),f.prototype={onClick:function(t){t||(t=window.event),this.contentAssist.apply(this.getProposal(t.target||t.srcElement)),this.textView.focus()},onScroll:function(){this.previousCloneNode&&!this.preserveCloneThroughScroll&&(this._removeCloneNode(),this.previousSelectedNode.classList.add(p.selected)),this.preserveCloneThroughScroll=!1},createDiv:function(t,e,n){var i=e.ownerDocument,o=l.createElement(i,"div");o.id="contentoption"+n,o.setAttribute("role","option"),o.className=p[t.style]?p[t.style]:p.dfault;var r;"hr"===t.style?r=l.createElement(i,"hr"):(r=this._createDisplayNode(t,n),o.contentAssistProposalIndex=n),o.appendChild(r),e.appendChild(o)},createAccessible:function(){var t=this._contentAssistMode,e=this;a.addEventListener(this.parentNode,"keydown",function(n){return n||(n=window.event),n.preventDefault&&n.preventDefault(),n.keyCode===h.KEY.ESCAPE?t.cancel():n.keyCode===h.KEY.UP?t.lineUp():n.keyCode===h.KEY.DOWN?t.lineDown():n.keyCode===h.KEY.ENTER?t.enter():n.keyCode===h.KEY.PAGEDOWN?t.pageDown():n.keyCode===h.KEY.PAGEUP?t.pageUp():n.keyCode===h.KEY.HOME?(e.scrollIndex(0,!0),t.lineDown(0)):n.keyCode===h.KEY.END?t.lineUp(t.getProposals().length-1):!1})},_createDisplayNode:function(t,e){var n=document.createElement("span");if(!t)return n;if("string"==typeof t){var i=this._createNameNode(t);return i.contentAssistProposalIndex=e,i}var o,r;if(t.name&&"string"==typeof t.name)o=this._createNameNode(t.name);else if(t.description&&"string"==typeof t.description)o=this._createNameNode(t.description),r=!0;else{if(!t.proposal||"string"!=typeof t.proposal)return n;o=this._createNameNode(t.proposal)}var s,a=this._createTagsNode(t.tags);return!r&&t.description&&"string"==typeof t.description&&(s=document.createTextNode(t.description)),a&&n.appendChild(a),n.appendChild(o),s&&n.appendChild(s),o.contentAssistProposalIndex=e,n.contentAssistProposalIndex=e,n},_stopResizeTimer:function(){this._resizeTimer&&(window.clearInterval(this._resizeTimer),this._resizeTimer=null)},_startResizeTimer:function(){this._stopResizeTimer(),this._cachedResizeBound=this.parentNode.getBoundingClientRect(),this._resizeTimer=window.setInterval(function(){if(this._contentAssistMode){var t=this.parentNode.getBoundingClientRect();if(t.left===this._cachedResizeBound.left&&t.top===this._cachedResizeBound.top&&t.width===this._cachedResizeBound.width&&t.height===this._cachedResizeBound.height)return;this._cachedResizeBound=t,this._contentAssistMode._showTooltip(!0,!0)}}.bind(this),100)},_createNameNode:function(t){var e=document.createElement("span");return e.classList.add("proposal-name"),e.appendChild(document.createTextNode(t)),e},_createTagsNode:function(t){var e=null;if(t&&t.constructor===Array&&t.length>0){e=document.createElement("span");for(var n=0;n=this.parentNode.scrollTop)return e}return 0},getBottomIndex:function(){for(var t=this.parentNode.childNodes,e=0;ethis.parentNode.scrollTop+this.parentNode.clientHeight)return Math.max(0,e-1)}return t.length-1},scrollIndex:function(t,e){var n=this.parentNode.childNodes[t];n&&(n.scrollIntoView(e),this.preserveCloneThroughScroll=!0)},selectNode:function(t){var e=null;if(this._hideTimeout&&(window.clearTimeout(this._hideTimeout),this._hideTimeout=null),this._fadeTimer&&(window.clearTimeout(this._fadeTimer),this._fadeTimer=null),this.previousSelectedNode&&(this.previousSelectedNode.classList.remove(p.selected),this.previousSelectedNode=null,this.previousCloneNode&&this._removeCloneNode()),-1!==t&&(e=this.parentNode.childNodes[t])){e.classList.add(p.selected),this.parentNode.setAttribute("aria-activedescendant",e.id),e.focus(),e.offsetTopthis.parentNode.scrollTop+this.parentNode.clientHeight&&(e.scrollIntoView(!1),this.preserveCloneThroughScroll=!0);var n=e.firstChild||e,i=n.getBoundingClientRect(),o=this.parentNode.clientWidth?this.parentNode.clientWidth:this.parentNode.getBoundingClientRect(),r=window.getComputedStyle(this.parentNode),s=window.getComputedStyle(e),a=parseInt(r.paddingLeft)+parseInt(r.paddingRight)+parseInt(s.paddingLeft)+parseInt(s.paddingRight);if(i.width>=o-a){var l=parseInt(r.top),h=e.cloneNode(!0);h.classList.add("cloneProposal"),h.style.top=l+e.offsetTop-this.parentNode.scrollTop+"px",h.style.left=r.left,h.setAttribute("id",h.id+"_clone");var d=document.documentElement.clientWidth,c=i.left+i.width-parseInt(d);if(c>0){var u=parseInt(r.left)-c;0>u&&(u=0),h.style.left=u+"px"}var f=document.createElement("div");f.id="clone_contentassist",f.classList.add("contentassist"),f.classList.add("cloneWrapper"),f.appendChild(h),f.onclick=this.parentNode.onclick,this.parentNode.parentNode.insertBefore(f,this.parentNode);var g=function(t){if(t.contentAssistProposalIndex=e.contentAssistProposalIndex,t.hasChildNodes())for(var n=0;n=t?(_._removeCloneNode(),window.clearInterval(_._fadeTimer),_._fadeTimer=null):(f.style.opacity=t,f.style.filter="alpha(opacity="+100*t+")",t-=.1*t)},50)},1500),e.classList.remove(p.selected),this.previousCloneNode=f}}this.previousSelectedNode=e},setContentAssistMode:function(t){this._contentAssistMode=t},show:function(){var t=this._contentAssistMode.getProposals();if(0===t.length)this.hide();else{this.parentNode.innerHTML="";for(var e=0;el){var h=o.y-this.textView.getLineHeight();this.parentNode.offsetHeight>h?l>h?this.parentNode.style.maxHeight=l+"px":(this.parentNode.style.maxHeight=h+"px",this.parentNode.style.top="0"):(this.parentNode.style.top=o.y-this.parentNode.offsetHeight-this.textView.getLineHeight()+"px",this.parentNode.style.maxHeight=h+"px")}else this.parentNode.style.maxHeight=l+"px";if(o.x+this.parentNode.offsetWidth>s){var d=s-this.parentNode.offsetWidth;0>d&&(d=0),this.parentNode.style.left=d+"px",this.parentNode.style.maxWidth=s-d}else this.parentNode.style.maxWidth=s+o.x+"px"},_removeCloneNode:function(){this.parentNode.parentNode.contains(this.previousCloneNode)&&this.parentNode.parentNode.removeChild(this.previousCloneNode),this.previousCloneNode=null}},{ContentAssist:c,ContentAssistMode:u,ContentAssistWidget:f}}),define("orion/editor/textStyler",["orion/editor/annotations","orion/editor/eventTarget","orion/metrics"],function(t,e,n){function i(t){return JSON.parse(JSON.stringify(t))}function o(t,e,n){this._patternManager=new r(t,e),this._contentType=n}function r(t,e){this._unnamedCounter=0,this._patterns=[],this._firstLineMatches={},Array.isArray(e)||(e=[e]),this._rootIds=e,t.forEach(function(t){this._addRepositoryPatterns(t.repository||{},t.id),this._addPatterns(t.patterns||[],t.id),t.firstLineMatch&&(this._firstLineMatches[t.id]=new RegExp(t.firstLineMatch))}.bind(this))}function s(t,e,n,i,o,r,s){this.start=t.start,this.end=t.end,this.contentStart=t.contentStart,this.contentEnd=t.contentEnd,this.name=e,this.typeId=n,this.styler=i,this.parent=r,s&&s(this),this._subBlocks=i.computeBlocks(o,o.getText(this.contentStart,this.end),this,this.contentStart,null,null,null)}function a(t){this._styler=t}function l(t,e,n){this._whitespacesVisible=!1,this._highlightCaretLine=!1,this._foldingEnabled=!0,this._detectTasks=!0,this._annotationProviders=[],this._view=t,this._annotationModel=e,this._stylerAdapter=n,this._stylerAdapter.setStyler(this),this._accessor=new a(this),this._bracketAnnotations;var i=this;this._listener={onChanged:function(t){i._onModelChanged(t)},onDestroy:function(t){i._onDestroy(t)},onLineStyle:function(t){i._onLineStyle(t)},onMouseDown:function(t){i._onMouseDown(t)},onSelection:function(t){i._onSelection(t)}};var o=t.getModel();o.getBaseModel&&(o=o.getBaseModel()),o.addEventListener("Changed",this._listener.onChanged),t.addEventListener("MouseDown",this._listener.onMouseDown),t.addEventListener("Selection",this._listener.onSelection),t.addEventListener("Destroy",this._listener.onDestroy),t.addEventListener("LineStyle",this._listener.onLineStyle),this.computeRootBlock(o)}var h=function(t,e,n,i,o){var r;for(void 0===i&&(i=-1),void 0===o&&(o=t.length);o-i>1;)if(r=Math.floor((o+i)/2),e<=t[r].start)o=r;else{if(n&&ee.result.index?1:t.pattern.pattern.index0;){var c=h[0];if(h.splice(0,1),re.result.index?1:t.pattern.pattern.index0;){var d=l[0];if(l.splice(0,1),d.result.indexe.start?1:0});for(var p=0;p=5e4)var r=Date.now();if(this._rootBlock=this._stylerAdapter.createBlock(o,this,e,null),r){var s=Date.now()-r;s>10&&n.logTiming("editor","styler compute blocks (ms/50000 chars)",5e4*s/i,this._stylerAdapter.getContentType())}if(this._annotationModel){var a=[];this._annotationModel.removeAnnotations(t.AnnotationType.ANNOTATION_FOLDING),this._computeFolding(this._rootBlock.getBlocks(),this._view.getModel(),a),this._detectTasks&&(this._annotationModel.removeAnnotations(t.AnnotationType.ANNOTATION_TASK),this._computeTasks(this._rootBlock,e,a)),this._replaceAnnotations([],a)}this._view.redrawLines()},destroy:function(){if(this._stylerAdapter.destroy(),this._view){var t=this._view.getModel();t.getBaseModel&&(t=t.getBaseModel()),t.removeEventListener("Changed",this._listener.onChanged),this._view.removeEventListener("MouseDown",this._listener.onMouseDown),this._view.removeEventListener("Selection",this._listener.onSelection),this._view.removeEventListener("Destroy",this._listener.onDestroy),this._view.removeEventListener("LineStyle",this._listener.onLineStyle),this._view=null}},getAnnotationModel:function(){return this._annotationModel},getBlockAtIndex:function(t){return this._findBlock(this._rootBlock,t)},getBlockCommentDelimiters:function(t){return this._stylerAdapter.getBlockCommentDelimiters(t)},getLineCommentDelimiter:function(t){return this._stylerAdapter.getLineCommentDelimiter(t)},getRootBlock:function(){return this._rootBlock},getStyleAccessor:function(){return this._accessor},getStyles:function(t){var e=[],n=this._view.getModel();n.getBaseModel&&(n=n.getBaseModel());var i=this._findBlock(this._rootBlock,t),o=n.getLineAtOffset(t),r=n.getLine(o),s=[];this._stylerAdapter.parse(r,n.getLineStart(o),0,i,s);var a=s[h(s,t,!0)];for(a&&a.start<=t&&t=r);u++){var f=d[u].start,g=d[u].end;if(f>l){var p=t.getLineAtOffset(l),_=t.getLineStart(p);this._stylerAdapter.parse(i.substring(_-o,f-o),_,l-_,n,a),a.forEach(function(t){t.style&&(0===t.style.indexOf(e.beginName)?s.push(t.start+1):0===t.style.indexOf(e.endName)&&s.push(-(t.start+1)))}),a=[]}l=g}return r>l&&(p=t.getLineAtOffset(l),_=t.getLineStart(p),this._stylerAdapter.parse(i.substring(_-o,r-o),_,l-_,n,a),a.forEach(function(t){t.style&&(0===t.style.indexOf(e.beginName)?s.push(t.start+1):0===t.style.indexOf(e.endName)&&s.push(-(t.start+1)))})),s},_findMatchingBracket:function(t,e,n){var i=t.getLineAtOffset(n),o=t.getLineEnd(i),r=t.getText(n,o),s=this._stylerAdapter.getBracketMatch(e,r);if(!s)return-1;for(var a=t.getLine(i),l=t.getLineStart(i),h=this._findBrackets(t,s,e,a,l,o),d=0;d=0?1:-1;if(h[d]*c-1===n){var u=1;if(s.atStart){for(d++;d=0?1:-1,u+=c,0===u)return h[d]*c-1;i+=1;for(var f=t.getLineCount();f>i;){a=t.getLine(i),l=t.getLineStart(i),o=t.getLineEnd(i),h=this._findBrackets(t,s,e,a,l,o);for(var g=0;g=0?1:-1,u+=c,0===u)return h[g]*c-1;i++}}else{for(d--;d>=0;d--)if(c=h[d]>=0?1:-1,u+=c,0===u)return h[d]*c-1;for(i-=1;i>=0;){a=t.getLine(i),l=t.getLineStart(i),o=t.getLineEnd(i),h=this._findBrackets(t,s,e,a,l,o);for(var p=h.length-1;p>=0;p--)if(c=h[p]>=0?1:-1,u+=c,0===u)return h[p]*c-1;i--}}break}}return-1},_getLineStyle:function(t){if(this._highlightCaretLine){var e=this._view,n=e.getModel(),i=e.getSelections(),o=!1;if(!i.some(function(e){return e.start===e.end?(o=o||n.getLineAtOffset(e.start)===t,!1):!0})&&o)return this._caretLineStyle}return null},_getStyles:function(t,e,n,i,o){for(var r=i+n.length,s=[],a=i+o,l=t.getBlocks(),d=h(l,a,!0),c=d;c=r);c++){var u=l[c].start,f=l[c].end;if(u>a){var g=e.getLineAtOffset(a),p=e.getLineStart(g);this._stylerAdapter.parse(n.substring(p-i,u-i),p,a-p,t,s)}var _=Math.max(a,u);if(_===u){var v=this._stylerAdapter.getBlockStartStyle(l[c],n.substring(_-i),_,s);v&&(_+=v.length)}var m=Math.min(r,f),y=[];if(m===f){var x=n.substring(m-a-(l[c].end-l[c].contentEnd)),C=this._stylerAdapter.getBlockEndStyle(l[c],x,m,y);C&&(m-=C.length)}g=e.getLineAtOffset(_),p=e.getLineStart(g);var w=this._getStyles(l[c],e,n.substring(p-i,m-i),p,_-p),A=[];this._stylerAdapter.getBlockOverrideStyles(l[c],n.substring(_-i,m-i),_,A),A.length&&(Array.prototype.push.apply(w,A),w.length!==A.length&&w.sort(function(t,e){return t.starte.start?1:0}));var T=this._stylerAdapter.getBlockContentStyleName(l[c]);if(T){var L=_;w.forEach(function(t){t.start-L&&s.push({start:L,end:t.start,style:T}),t.mergeable&&(t.style+=","+T),s.push(t),L=t.end}),m-L&&s.push({start:L,end:m,style:T})}else s=s.concat(w);s=s.concat(y),a=f}return r>a&&(g=e.getLineAtOffset(a),p=e.getLineStart(g),this._stylerAdapter.parse(n.substring(p-i,r-i),p,a-p,t,s)),s},_isRenderingWhitespace:function(){return this._whitespacesVisible},_onDestroy:function(){this.destroy()},_onLineStyle:function(t){if(this._rootBlock){t.textView===this._view&&(t.style=this._getLineStyle(t.lineIndex));var e=t.lineStart,n=t.textView.getModel();if(n.getBaseModel){e=n.mapOffset(e);var i=n.getBaseModel()}t.ranges=this._getStyles(this._rootBlock,i||n,t.lineText,e,0);for(var o=t.ranges.length-1;o>=0;o--){var r=t.ranges[o];if(r.style){if(r.style={styleClass:r.style.replace(/\./g," ")},i){var s=r.end-r.start;r.start=n.mapOffset(r.start,!0),r.end=r.start+s}}else t.ranges.splice(o,1)}}else t.ranges=[];this._isRenderingWhitespace()&&(this._spliceStyles(this._spacePattern,t.ranges,t.lineText,t.lineStart),this._spliceStyles(this._tabPattern,t.ranges,t.lineText,t.lineStart))},_onModelChanged:function(e){for(var n,i,o,r,s,a,l,d=e.start,c=e.removedCharCount,u=e.addedCharCount,f=u-c,g=this._view.getModel(),p=g.getBaseModel?g.getBaseModel():g,_=d+c,v=p.getCharCount(),m=p.getLineStart(p.getLineAtOffset(d)),y=this._findBlock(this._rootBlock,d);;){if(o=y.parent,!n&&o){if(0>f&&y.end-d<=-f){y=o;continue}if(s=p.getText(y.start,Math.min(v,y.end+f+1)),!this._stylerAdapter.verifyBlock(p,s,y,f)){y=o;continue}}i=y.getBlocks();var x=i.length,C=h(i,m,!0),w=h(i,_,!1,C-1,x);if(n=!1,C&&i.length&&i[C-1].end===d){s=p.getText(i[C-1].start,Math.min(v,d+1));var A=this.computeBlocks(p,s,y,i[C-1].start,null,null,null);A.length&&A[0].end!==i[C-1].end&&(C--,n=!0)}x>C&&i[C].start<=m&&(md&&(l+=f)):C===x&&x>0&&y.end-f===i[x-1].end?(l=i[--C].start,l>d&&(l+=f)):l=Math.max(m,y.contentStart),a=x>w?i[w].end:y.contentEnd,a>=d&&(a+=f),a=Math.min(a,v-1),s=p.getText(l,a+1);var T=this.computeBlocks(p,s,y,l,null,null,null);if(x>w){if(T.length&&T[T.length-1].end===a&&T[T.length-1].typeId===i[w].typeId)break;if(T.length&&this._stylerAdapter.blockSpansBeyondEnd(T[T.length-1])){w++;for(var L=T[T.length-1].getBlocks(),S=(L.length?L[L.length-1]:T[T.length-1]).typeId;x>w;){if(i[w].typeId===S){var M=i[w].end+f;M=Math.min(M,v-1),s=p.getText(l,M+1);var D=this.computeBlocks(p,s,y,l,null,null,null);if(D.length&&D[D.length-1].end===M){a=M,T=D;break}}w++}if(x>w)break}}else if(!T.length||T[T.length-1].end<=y.contentEnd+f)break;if(!o){a=v,w=x,s=p.getText(l,a),T=this.computeBlocks(p,s,y,l,null,null,null);break}y=o,r=!0}this._rootBlock.adjustBounds(d,f),w=Math.min(w+1,x);var E;if(r||(r=w-C!==T.length),!r)for(var O=0;Od&&(j-=f),G>d&&(G-=f),d>=j&&G>d&&_>=j&&G>_){var Y=p.getLineAtOffset(K.start),X=p.getLineAtOffset(K.end);Y!==X?K.expanded||K.expand():P.push(K)}}else P.push(K),K.expand()}else K.type===t.AnnotationType.ANNOTATION_TASK&&y.start<=K.start&&K.end<=y.end&&P.push(K)}H&&U.getBlocks().forEach(function(t){this._updateFolding(t,p,g,F,V,l,a)}.bind(this)),this._detectTasks&&this._computeTasks(y,p,V,l,a),this._annotationProviders.forEach(function(t){var e=[],n=[];t(this._annotationModel,p,y,l,a,e,n),P=P.concat(e),V=V.concat(n)}.bind(this)),this._replaceAnnotations(P,V)}},_onMouseDown:function(t){if(2===t.clickCount){var e=this._view.getModel(),n=this._view.getOffsetAtLocation(t.x,t.y);if(n>0){var i=n-1,o=e;e.getBaseModel&&(i=e.mapOffset(i),o=e.getBaseModel());var r=this._findBlock(this._rootBlock,i),s=this._findMatchingBracket(o,r,i);if(-1!==s){t.preventDefault();var a=s;e.getBaseModel&&(a=e.mapOffset(a,!0)),n>a&&(n--,a++),this._view.setSelection(a,n)}}}},_onSelection:function(e){function n(t){var e={};return t.some(function(t){return t.isEmpty()?(e[l.getLineAtOffset(t.start).toString()]=!0,!1):!0})?{}:e}function i(t,e){for(var n in t)e[n]||(o=n>>0,a.redrawLines(o,o+1))}var o,r=Array.isArray(e.oldValue)?e.oldValue:[e.oldValue],s=Array.isArray(e.newValue)?e.newValue:[e.newValue],a=this._view,l=a.getModel();if(this._highlightCaretLine){var h=n(r),d=n(s);i(h,d),i(d,h)}if(this._annotationModel){var c,u,f=this._bracketAnnotations;if(1===s.length&&s[0].isEmpty()&&(u=s[0].getCaret())>0){var g=u-1;l.getBaseModel&&(g=l.mapOffset(g),l=l.getBaseModel());var p=this._findBlock(this._rootBlock,g),_=this._findMatchingBracket(l,p,g);-1!==_&&(c=[this._createAnnotation(t.AnnotationType.ANNOTATION_MATCHING_BRACKET,_,_+1),this._createAnnotation(t.AnnotationType.ANNOTATION_CURRENT_BRACKET,g,g+1)])}this._bracketAnnotations=c,this._replaceAnnotations(f,c)}},_replaceAnnotations:function(e,n){var i;e&&(i=[],e.forEach(function(e){(e.type!==t.AnnotationType.ANNOTATION_FOLDING||e.source===this._TEXTSTYLER)&&i.push(e)}.bind(this))),this._annotationModel.replaceAnnotations(i,n)},_spliceStyles:function(t,e,n,o){var r=t.regex;r.lastIndex=0;for(var s=0,a=r.exec(n);a;){for(var l=o+a.index;so;o++){i=r.item(o);var a=c(i.nodeName);if(a){var l=i.nodeValue;("true"===l||"false"===l)&&(l="true"===l),n[a]=l}}return n}function g(t,e){return t.getElementsByClassName?t.getElementsByClassName(e):(e=e.replace(/ *$/,""),t.querySelectorAll?t.querySelectorAll((" "+e).replace(/ +/g,".")):null)}function p(t){return t.clientHeight}function _(c){var u=c.document||document,v=c.parent;if(v||(v="editor"),"string"==typeof v&&(v=u.getElementById(v)),!v&&c.className){var m=g(u,c.className);if(m){c.className=void 0,m.length>1&&void 0===c.noFocus&&(c.noFocus=!0);for(var y=[],x=m.length-1;x>=0;x--)c.parent=m[x],y.push(_(c));return y}}if(!v)throw new Error("no parent");if(c=f(v,c),"string"==typeof c.theme){var C=i.TextTheme.getTheme(c.theme),w=c.theme.lastIndexOf("/"),A=c.theme;-1!==w&&(A=A.substring(w+1));var T=".css";A.substring(A.length-T.length)===T&&(A=A.substring(0,A.length-T.length)),C.setThemeClass(A,{href:c.theme}),c.theme=C}var L,S,M=function(){return new e.TextView({parent:v,model:new o.ProjectionTextModel(c.model?c.model:new n.TextModel("")),tabSize:c.tabSize?c.tabSize:4,readonly:c.readonly,fullSelection:c.fullSelection,tabMode:c.tabMode,expandTab:c.expandTab,singleMode:c.singleMode,themeClass:c.themeClass,theme:c.theme,wrapMode:c.wrapMode,wrappable:c.wrappable})};c.readonly||(S={createContentAssistMode:function(t){L=new a.ContentAssist(t.getTextView());var e=new a.ContentAssistWidget(L),n=new a.ContentAssistMode(L,e);return L.setMode(n),n}});var D={styler:null,highlight:function(e,n,i){this.styler&&this.styler.destroy&&this.styler.destroy(),this.styler=null,"js"===e?e="application/javascript":"css"===e?e="text/css":"html"===e?e="text/html":"java"===e&&(e="text/x-java-source");var o=i.getTextView(),r=i.getAnnotationModel(),s=function(e){var n=e.replace(/[*|:/".<>?+]/g,"_");t(["./stylers/"+n+"/syntax"],function(t){var n=new l.createPatternBasedAdapter(t.grammars,t.id,e);this.styler=new l.TextStyler(o,r,n)},function(){})};e&&(n&&"function"==typeof n?n(e).then(function(t){if(t&&t.grammars&&t.id){var n=new l.createPatternBasedAdapter(t.grammars,t.id,e);this.styler=new l.TextStyler(o,r,n)}}.bind(this),function(){s(e)}):s(e)),"text/css"===e&&i.setFoldingRulerVisible(void 0===c.showFoldingRuler||c.showFoldingRuler)}},E=new r.Editor({textViewFactory:M,undoStackFactory:new s.UndoFactory,annotationFactory:new s.AnnotationFactory,lineNumberRulerFactory:new s.LineNumberRulerFactory,foldingRulerFactory:new s.FoldingRulerFactory,textDNDFactory:new s.TextDNDFactory,contentAssistFactory:S,keyBindingFactory:new s.KeyBindingsFactory,statusReporter:c.statusReporter,hoverFactory:c.hoverFactory,domNode:v});E.addEventListener("TextViewInstalled",function(){var t=E.getLineNumberRuler();t&&void 0!==c.firstLineIndex&&t.setFirstLine(c.firstLineIndex);var e=E.getSourceCodeActions();e&&(e.setAutoPairParentheses(c.autoPairParentheses),e.setAutoPairBraces(c.autoPairBraces),e.setAutoPairSquareBrackets(c.autoPairSquareBrackets),e.setAutoPairAngleBrackets(c.autoPairAngleBrackets),e.setAutoPairQuotations(c.autoPairQuotations),e.setAutoCompleteComments(c.autoCompleteComments),e.setSmartIndentation(c.smartIndentation))});var O=c.contents;void 0===O&&(O=d(v)),O||(O=""),E.installTextView(),E.setLineNumberRulerVisible(void 0===c.showLinesRuler||c.showLinesRuler),E.setAnnotationRulerVisible(void 0===c.showAnnotationRuler||c.showFoldingRuler),E.setOverviewRulerVisible(void 0===c.showOverviewRuler||c.showOverviewRuler),E.setZoomRulerVisible(void 0===c.showZoomRuler||c.showZoomRuler),E.setFoldingRulerVisible(void 0===c.showFoldingRuler||c.showFoldingRuler),E.setInput(c.title,null,O,!1,c.noFocus),D.highlight(c.contentType||c.lang,c.grammarProvider,E);var N=u.defaultView||u.parentWindow;if(!c.noComputeSize&&"none"!==h(N,u,v)&&p(v)<=50){var b=E.getTextView().computeSize().height;v.style.height=b+"px"}return E}var v=window.orion?window.orion.editor:void 0;if(v){for(var m=0;m