toserve.orion.built-editor-amd.min.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of net.enilink.platform.lift Show documentation
Show all versions of net.enilink.platform.lift Show documentation
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