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

ide-orion.editorBuild.code_edit.built-codeEdit.min.js Maven / Gradle / Ivy

!function(e,t){"function"==typeof define&&define.amd?define([],t):(e.orion=e.orion||{},e.orion.codeEdit=t())}(this,function(){var e,t,n;!function(i){function r(e,t){return C.call(e,t)}function o(e,t){var n,i,r,o,s,a,l,d,c,h,u=t&&t.split("/"),f=_.map,p=f&&f["*"]||{};if(e&&"."===e.charAt(0))if(t){for(u=u.slice(0,u.length-1),e=u.concat(e.split("/")),d=0;d0&&(e.splice(d-1,2),d-=2)}e=e.join("/")}else 0===e.indexOf("./")&&(e=e.substring(2));if((u||p)&&f){for(n=e.split("/"),d=n.length;d>0;d-=1){if(i=n.slice(0,d).join("/"),u)for(c=u.length;c>0;c-=1)if(r=f[u.slice(0,c).join("/")],r&&(r=r[i])){o=r,s=d;break}if(o)break;!a&&p&&p[i]&&(a=p[i],l=d)}!o&&a&&(o=a,s=l),o&&(n.splice(0,s,o),e=n.join("/"))}return e}function s(e,t){return function(){return f.apply(i,w.call(arguments,0).concat([e,t]))}}function a(e){return function(t){return o(t,e)}}function l(e){return function(t){v[e]=t}}function d(e){if(r(m,e)){var t=m[e];delete m[e],y[e]=!0,u.apply(i,t)}if(!r(v,e)&&!r(y,e))throw new Error("No "+e);return v[e]}function c(e){var t,n=e?e.indexOf("!"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function h(e){return function(){return _&&_.config&&_.config[e]||{}}}var u,f,p,g,v={},m={},_={},y={},C=Object.prototype.hasOwnProperty,w=[].slice;p=function(e,t){var n,i=c(e),r=i[0];return e=i[1],r&&(r=o(r,t),n=d(r)),r?e=n&&n.normalize?n.normalize(e,a(t)):o(e,t):(e=o(e,t),i=c(e),r=i[0],e=i[1],r&&(n=d(r))),{f:r?r+"!"+e:e,n:e,pr:r,p:n}},g={require:function(e){return s(e)},exports:function(e){var t=v[e];return"undefined"!=typeof t?t:v[e]={}},module:function(e){return{id:e,uri:"",exports:v[e],config:h(e)}}},u=function(e,t,n,o){var a,c,h,u,f,_,C=[];if(o=o||e,"function"==typeof n){for(t=!t.length&&n.length?["require","exports","module"]:t,f=0;f-1&&i[e];e--)o=i[e],n=t[o],(n===!0||1===n)&&(n=s(f+o+"/"+g)),r(_,n);a(_)})})}}})}(),n("orion/nls/messages",["module"],function(e){var t=e.config();return t&&t.root?t:{root:!0}}),n("orion/nls/root/messages",{Navigator:"Navigator",Sites:"Sites",Shell:"Shell","Get Plugins":"Get Plug-ins",Global:"Global",Editor:"Editor",EditorRelatedLink:"Show Current Folder",EditorRelatedLinkParent:"Show Enclosing Folder",EditorLinkWorkspace:"Edit",EditorRelatedLinkProj:"Show Project",sidebar:"Sidebar",toolbar:"Toolbar","Filter bindings:":"Filter bindings:","Filter bindings":"Type characters to filter by name or key combination",BindingPrompt:"Enter the new binding",NoBinding:"---",orionClientLabel:"Orion client repository","Orion Editor":"Text Editor","Orion Image Viewer":"Image Viewer","Orion Markdown Editor":"Markdown Editor","Orion Markdown Viewer":"Markdown Viewer","Orion JSON Editor":"JSON Editor","Orion System Editor":"System Editor","View on Site":"View on Site","View this file or folder on a web site hosted by Orion":"View this file or folder on a web site hosted by Orion.",ShowAllKeyBindings:"Show a list of all the keybindings on this page","Show Keys":"Show Keys",HideShowBannerFooter:"Hide or show the page banner and footer","Toggle Banner and Footer":"Toggle Banner and Footer",ChooseFileOpenEditor:"Choose a file by name and open an editor on it",FindFile:"Open File...","System Configuration Details":"System Configuration Details","System Config Tooltip":"Go to the System Configuration Details page","System Editor Tooltip":"Open this file type in the desktop's default manner","Background Operations":"Background Operations","Background Operations Tooltip":"Go to the Background Operations page","Operation status is unknown":"Operation status is unknown","Unknown item":"Unknown item",NoSearchAvailableErr:"Can't search: no search service is available",Related:"Related",Options:"Options","LOG: ":"LOG: ",View:"View",SplashTitle:"Setting up Workspace",SplashTitleSettings:"Loading Settings",SplashTitleGit:"Loading Git Repositories",LoadingPage:"Loading Page",LoadingPlugins:"Loading Plugins",AuthenticatingUser:"Authenticating user...",AuthenticatedUser:"Authenticated user",LoadingResources:"Loading Resources",plugin_started:'"${0}" started',"plugin_lazy activation":'"${0}" lazily activated',plugin_starting:'"${0}" starting',"no parent":"no parent","no tree model":"no tree model","no renderer":"no renderer","could not find table row ":"could not find table row ",Operations:"Operations","Operations running":"Operations running",SomeOpWarning:"Some operations finished with warning",SomeOpErr:"Some operations finished with error","no service registry":"no service registry",Tasks:"Tasks",Close:"Close","Expand all":"Expand all","Collapse all":"Collapse all",Search:"Search","Advanced search":"Advanced search",Submit:"Submit",More:"More","Recent searches":"Recent searches","Regular expression":"Regular expression","Search options":"Search options","Global search":"Global search","Orion Home":"Home","Close notification":"Close notification","Toggle Side Panel":"Toggle Side Panel","Open or close the side panel":"Open or close the side panel",Projects:"Projects","Toggle Sidebar":"Toggle Sidebar","Sample HTML5 Site":"Sample HTML5 Site","Generate an HTML5 'Hello World' website, including JavaScript, HTML, and CSS files.":"Generate an HTML5 'Hello World' website, including JavaScript, HTML, and CSS files.","Sample Orion Plugin":"Sample Orion Plug-in","Generate a sample plugin for integrating with Orion.":"Generate a sample plug-in for integrating with Orion.",Browser:"Web Browser",OutlineProgress:"Getting outline for ${0} from ${1}",FormatProgress:"Formatting ${0} from ${1}",outlineTimeout:"Outline service timed out. Try reloading the page and opening the outline again.",UnknownError:"An unknown error occurred.","Filter outline:":"Filter outline:",Filter:"Type characters (* = any string, ? = any character)",TemplateExplorerLabel:"Templates",OpenTemplateExplorer:"Open Template Explorer",Edit:"Edit",CentralNavTooltip:"Toggle Navigation Menu","Wrote: ${0}":"Wrote: ${0}",GenerateHTML:"Generate HTML file",GenerateHTMLTooltip:"Write an HTML file generated from the current Markdown editor content","alt text":"alt text",blockquote:"blockquote",code:"code","code (block)":"code (block)","code (span)":"code (span)",emphasis:"emphasis","fenced code (${0})":"fenced code (${0})","header (${0})":"header (${0})","horizontal rule":"horizontal rule",label:"label","link (auto)":"link (auto)","link (image)":"link (image)","link (inline)":"link (inline)","link label":"link label","link label (optional)":"link label (optional)","link (ref)":"link (ref)","list item (bullet)":"list item (bullet)","list item (numbered)":"list item (numbered)","strikethrough (${0})":"strikethrough (${0})",strong:"strong","table (${0})":"table (${0})",text:"text","title (optional)":"title (optional)",url:"url",workedProgress:"${0} (${1}/${2})",ConfirmLogout:"Do you want to logout?",VerticalPaneOrientation:"Vertical pane orientation",TogglePaneOrientationTooltip:"Toggle split pane orientation",WarningDuplicateLinkId:"Duplicate link ID: ${0} (link IDs are not case-sensitive)",WarningHeaderTooDeep:"Header level cannot exceed 6",WarningLinkHasNoText:"Link has no text",WarningLinkHasNoURL:"Link has no URL",WarningOrderedListItem:"Ordered list item within unordered list",WarningOrderedListShouldStartAt1:"The first item in an ordered list should have index 1",WarningUndefinedLinkId:"Undefined link ID: ${0}",WarningUnorderedListItem:"Unordered list item within ordered list",PageTitleFormat:"${0} - ${1}",KeyCTRL:"Ctrl",KeySHIFT:"Shift",KeyALT:"Alt",KeyBKSPC:"Backspace",KeyDEL:"Del",KeyEND:"End",KeyENTER:"Enter",KeyESCAPE:"Esc",KeyHOME:"Home",KeyINSERT:"Ins",KeyPAGEDOWN:"Page Down",KeyPAGEUP:"Page Up",KeySPACE:"Space",KeyTAB:"Tab","a year":"a year",years:"${0} years","a month":"a month",months:"${0} months","a day":"a day",days:"${0} days","an hour":"an hour",hours:"${0} hours","a minute":"a minute",minutes:"${0} minutes",timeAgo:"${0} ago",justNow:"just now",fixAll:"Fix all",nextSplitter:"Next Splitter",nextSplitterTooltip:"Move focus through the available splitters",Confirm:"Confirm"}),n("orion/i18nUtil",[],function(){function e(e){var t=/\$\{([^\}]+)\}/g,n=arguments;return 2===n.length&&n[1]&&"object"==typeof n[1]?e.replace(t,function(e,t){return n[1][t]}):e.replace(t,function(e,t){return n[(t<<0)+1]})}return{formatMessage:e}}),n("orion/util",[],function(){function e(e){var t=arguments;return e.replace(/\$\{([^\}]+)\}/g,function(e,n){return t[(n<<0)+1]})}function t(e,t){return e.createElementNS?e.createElementNS(C,t):e.createElement(t)}function n(e,t){t.addEventListener("keydown",function(t){9!==t.keyCode||t.shiftKey||(t.preventDefault(),e.focus())}),e.addEventListener("keydown",function(e){9===e.keyCode&&e.shiftKey&&(e.preventDefault(),t.focus())})}var i=navigator.userAgent,r=-1!==i.indexOf("MSIE")||-1!==i.indexOf("Trident")?document.documentMode:void 0,o=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,d=parseFloat(i.split("WebKit/")[1])||void 0,c=-1!==i.indexOf("Android"),h=-1!==i.indexOf("iPad"),u=-1!==i.indexOf("iPhone"),f=h||u,p=-1!==i.indexOf("Electron"),g=-1!==navigator.platform.indexOf("Mac"),v=-1!==navigator.platform.indexOf("Win"),m=-1!==navigator.platform.indexOf("Linux"),_="undefined"!=typeof document&&"ontouchstart"in document.createElement("input"),y=v?"\r\n":"\n",C="http://www.w3.org/1999/xhtml";return{formatMessage:e,createElement:t,confineDialogTab:n,isIE:r,isFirefox:o,isOpera:s,isChrome:a,isSafari:l,isWebkit:d,isAndroid:c,isIPad:h,isIPhone:u,isIOS:f,isElectron:p,isMac:g,isWindows:v,isLinux:m,isTouch:_,platformDelimiter:y}}),n("orion/webui/littlelib",["orion/util"],function(e){function t(e,t){return t||(t=document),t.querySelector(e)}function n(e,t){return t||(t=document),t.querySelectorAll(e)}function i(e,t){return Array.prototype.slice.call(n(e,t))}function r(e){var t=e;return"string"==typeof e&&(t=document.getElementById(e)),t}function o(e,t){if(!e||!t)return!1;if(e===t)return!0;var n=e.compareDocumentPosition(t);return Boolean(16&n)}function s(e){var t=e.getBoundingClientRect(),n=Math.max(document.documentElement.scrollLeft,document.body.scrollLeft),i=Math.max(document.documentElement.scrollTop,document.body.scrollTop);return{left:t.left+n,top:t.top+i,width:t.width,height:t.height}}function a(e){for(;e.hasChildNodes();){var t=e.firstChild;e.removeChild(t)}}function l(t){var n=t.tabIndex;if(0===n&&e.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[t.nodeName.toLowerCase()]||t.attributes.tabIndex||(n=-1)}return n}function d(e){if(l(e)>=0&&!e.disabled&&e.offsetParent)return e;if(e.hasChildNodes())for(var t=0;t=0;t--){var n=c(e.childNodes[t]);if(n)return n}return l(e)>=0&&!e.disabled&&e.offsetParent?e:null}function h(){e.isMac&&document.addEventListener("keydown",function(e){if(121===e.keyCode&&e.shiftKey){var t,n,i,r=document.activeElement;if("true"===r.contentEditable){var o=window.getSelection(),a=o.getRangeAt(0);t=a.getBoundingClientRect(),n=t.left,i=t.top+t.height}else t=s(r),n=t.left+t.width/2,i=t.top+t.height/2;var l=r.ownerDocument.createEvent("MouseEvents");return l.initMouseEvent("contextmenu",!0,!0,r.ownerDocument.defaultView,1,0,0,n,i,!1,!1,!1,!1,2,null),!r.dispatchEvent(l)}},!0)}function u(e){e.tabTrapInstalled||(e.addEventListener("keydown",function(t){if(t.keyCode===E.TAB){var n=d(e),i=c(e);n&&i&&(t.target!==i||t.shiftKey?t.target===n&&t.shiftKey&&(i.focus(),w(t)):(n.focus(),w(t)))}},!0),e.tabTrapInstalled=!0)}function f(e,t){if(3===e.nodeType){var n=A.exec(e.nodeValue);n&&n.length>1&&t(e,n)}else 1===e.nodeType&&(p(e,t,"alt"),p(e,t,"aria-label"));if(e.hasChildNodes())for(var i=0;i1&&t(e,r,n)}}function g(e,t){if(!e||!t)return 0;var n=e.ownerDocument,i=n.defaultView||n.parentWindow;if(i.getComputedStyle){var r=i.getComputedStyle(e,null),o=r.getPropertyValue(t);if(o.length>2&&-1!==o.indexOf("px",o.length-2)){o=o.slice(0,-2);var s=parseInt(o,10);return s!==s?0:s}}return 0}function v(e,t){f(e,function(e,n,i){var r=t[n[1]]||n[1];3===e.nodeType?e.parentNode.replaceChild(document.createTextNode(r),e):1===e.nodeType&&i&&e.setAttribute(i,r)})}function m(e,t){f(e,function(e,n){var i=t[n[1]];if(i){var r=document.createRange(),o=n.index;r.setStart(e,o),r.setEnd(e,o+n[0].length),r.deleteContents(),r.insertNode(i)}})}function _(t,n){function i(e){L.forEach(function(t){var n=!1,i=t.excludeNodes.some(function(t){return document.body.contains(t)?(n=!0,t.contains(e.target)):!1});if(n&&!i)try{t.dismiss(e)}catch(r){"undefined"!=typeof console&&console&&console.error(r&&r.message)}}),L=L.filter(function(e){return e.excludeNodes.some(function(e){return document.body.contains(e)})})}null===L&&(L=[],document.addEventListener("click",i,!0),e.isIOS&&document.addEventListener("touchend",function(e){function t(){e.target.removeEventListener("click",t)}0===e.touches.length&&e.target.addEventListener("click",t)},!1)),L.push({excludeNodes:t,dismiss:n})}function y(e){L=L.filter(function(t){return e!==t.dismiss})}function C(e){for(var t=e.parentNode,n=document.documentElement;t&&t!==n;){var i=window.getComputedStyle(t,null);if(!i)break;var r=i.getPropertyValue("overflow-y");if("auto"===r||"scroll"===r)break;t=t.parentNode}return t}function w(e){window.document.all&&(e.keyCode=0),e.preventDefault&&(e.preventDefault(),e.stopPropagation())}function x(e){for(var t=document.getElementsByTagName("iframe"),n=0;n1?n.children:n.firstChild}var E={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};h();var A=/\$\{([^\}]+)\}/,L=null,k=Object.create(null);return Object.keys(E).forEach(function(e){k[E[e]]=e}),{$:t,$$:n,$$array:i,node:r,contains:o,bounds:s,empty:a,firstTabbable:d,lastTabbable:c,trapTabs:u,pixelValueOf:g,stop:w,processTextNodes:v,processDOMNodes:m,addAutoDismiss:_,setFramesEnabled:x,validId:b,getOffsetParent:C,removeAutoDismiss:y,keyName:S,KEY:E,createNodes:T}}),n("orion/commandsProxy",["orion/util","orion/webui/littlelib"],function(e,t){function n(t,n){function i(t){if(e.isMac){if(t.metaKey&&!t.altKey)return t.shiftKey||t.ctrlKey||65!==t.keyCode&&67!==t.keyCode&&86!==t.keyCode&&88!==t.keyCode&&90!==t.keyCode?!1:!0;if(t.ctrlKey)return!1}else{if(t.ctrlKey&&!t.altKey)return t.shiftKey||65!==t.keyCode&&67!==t.keyCode&&86!==t.keyCode&&88!==t.keyCode&&90!==t.keyCode?!1:!0;if(t.altKey&&!t.ctrlKey)return!1;if(t.ctrlKey&&t.altKey)return!1}if(t["char"])return t["char"].length>0;if(t.charCode||t.keyCode){var n=t.charCode||t.keyCode;switch(n){case 8:case 9:case 13:case 46:return!0;default:return n>=32&&112>n||n>123}}return!1}if(t=t||window.event,i(t)){if("true"===t.target.contentEditable)return;var r=t.target.nodeName.toLowerCase();if("input"===r){var o=t.target.type.toLowerCase();switch(o){case"text":case"password":case"search":case"color":case"date":case"datetime":case"datetime-local":case"email":case"month":case"number":case"range":case"tel":case"time":case"url":case"week":return}}else if("textarea"===r)return}n(t)}function i(){this._init()}return i.prototype={destroy:function(){this._listener&&(document.removeEventListener("keydown",this._listener),this._listener=null)},setProxy:function(e){this.proxy=e},setKeyBindings:function(e){this.bindings=e},_init:function(){var e=this;document.addEventListener("keydown",this._listener=function(i){return n(i,function(n){var i=e.proxy,r=e.bindings;if(r&&i)for(var o=0;o0?"block":"none",this._bottomScrollButton.style.display=this._dropdownNode.scrollHeight>this._dropdownNode.scrollTop+this._dropdownNode.offsetHeight?"block":"none")}function l(){this._topScrollButton.style.width=this._dropdownNode.clientWidth+1+"px",this._bottomScrollButton.style.width=this._dropdownNode.clientWidth+1+"px",this._topScrollButton.style.top=this._dropdownNode.style.top,this._topScrollButton.style.left=this._topScrollButton.parentNode.clientWidth+"px",this._bottomScrollButton.style.top=Number(this._dropdownNode.style.top.replace("px",""))+(this._dropdownNode.clientHeight-this._bottomScrollButton.clientHeight+1)+"px",this._bottomScrollButton.style.left=this._bottomScrollButton.parentNode.clientWidth+"px"}return n.prototype={_init:function(t){if(this._dropdownNode=e.node(t.dropdown),!this._dropdownNode)throw"no dom node for dropdown found";if(t.name&&this._dropdownNode.setAttribute("aria-label",t.name),this._populate=t.populate,this._selectionClass=t.selectionClass,this._parentDropdown=t.parentDropdown,this._positioningNode=t.positioningNode,!this._parentDropdown)for(var n=this._dropdownNode.parentNode;n&&document!==n;){if(n.classList&&n.classList.contains("dropdownMenu")){this._parentDropdown=n.dropdown;break}n=n.parentNode}if(this._dropdownNode.tabIndex=-1,this._triggerNode=t.triggerNode?t.triggerNode:e.$(".dropdownTrigger",this._dropdownNode.parentNode),!this._triggerNode)throw"no dom node for dropdown trigger found";var i=function(t){var n=!1;n=this._triggerNode.classList.contains("dropdownMenuItem")?this.open(t):this.toggle(t),n&&e.stop(t)}.bind(this);t.skipTriggerEventListeners||(this._triggerNode.addEventListener("click",i,!1),"span"===this._triggerNode.tagName.toLowerCase()?this._triggerNode.addEventListener("keydown",function(t){(t.keyCode===e.KEY.ENTER||t.keyCode===e.KEY.SPACE)&&i(t)}.bind(this),!1):this._triggerNode.addEventListener("keydown",function(t){t.keyCode===e.KEY.DOWN&&i(t)}.bind(this),!1));var r=this;this._dropdownNode.addEventListener("mouseover",function(t){if(t.target!==t.currentTarget){for(var n=t.target;n!==t.currentTarget&&"li"!==n.tagName.toLowerCase();)n=n.parentNode;var i="menubar"===n.parentNode.getAttribute("role");if(n=n.childNodes[0])if(i){for(var o=null,s=n.parentNode.parentNode,a=s.dropdown.getItems(),l=0;l0){e.setFramesEnabled(!1),this._boundAutoDismiss&&e.removeAutoDismiss(this._boundAutoDismiss),this._boundAutoDismiss=this._autoDismiss.bind(this),this._triggerNode.classList.add("dropdownTriggerOpen"),this._triggerNode.setAttribute("aria-expanded","true"),this._selectionClass&&this._triggerNode.classList.add(this._selectionClass),this._dropdownNode.classList.add("dropdownMenuOpen"),this._isVisible=!0,this._dropdownNode.scrollHeight>this._dropdownNode.offsetHeight&&(this._buttonsAdded=s.call(this));var r=e.$$array(".dropdownSubMenu",this._dropdownNode),o=[this._triggerNode].concat(r);this._buttonsAdded&&(o.push(this._topScrollButton),o.push(this._bottomScrollButton)),e.addAutoDismiss(o,this._boundAutoDismiss),this._positionDropdown(t),this._buttonsAdded&&l.call(this),this._focusDropdownNode(),n=!0,this._parentDropdown&&this._parentDropdown.submenuOpen(this)}}return n},_focusDropdownNode:function(){this._dropdownNode.focus()},_autoDismiss:function(e){if(this.close(!1)&&this._dropdownNode.contains(e.target))for(var t=this._parentDropdown;t;)t.close(!1),t=t._parentDropdown},_positionDropdown:function(){if(this._dropdownNode.style.left="",this._dropdownNode.style.top="",this._positioningNode)return void(this._dropdownNode.style.left=this._positioningNode.offsetLeft+"px");var t=e.bounds(this._dropdownNode),n=e.bounds(document.body);if(t.left+t.width>n.left+n.width)if(this._triggerNode.classList.contains("dropdownMenuItem"))this._dropdownNode.style.left=-t.width+"px";else{var i=e.bounds(this._boundingNode(this._triggerNode)),r=e.bounds(this._triggerNode);this._dropdownNode.style.left=r.left-i.left-t.width+r.width+"px"}var o=t.top+t.height-(n.top+n.height);o>0&&(this._dropdownNode.style.top=Math.floor(this._dropdownNode.style.top-o)+"px")},_boundingNode:function(e){var t=window.getComputedStyle(e,null);if(null===t)return e;var n=t.getPropertyValue("position");return"absolute"!==n&&e.parentNode&&e!==document.body?this._boundingNode(e.parentNode):e},close:function(t){var n=!1;return this.isVisible()&&(this._triggerNode.classList.remove("dropdownTriggerOpen"),this._triggerNode.setAttribute("aria-expanded","false"),this._selectionClass&&this._triggerNode.classList.remove(this._selectionClass),this._dropdownNode.classList.remove("dropdownMenuOpen"),e.setFramesEnabled(!0),t&&this._triggerNode.focus(),this._isVisible=!1,this._selectedItem&&(this._selectedItem.classList.remove("dropdownMenuItemSelected"),this._selectedItem=null),this._boundAutoDismiss&&(e.removeAutoDismiss(this._boundAutoDismiss),this._boundAutoDismiss=null),a.call(this,!0),n=!0),n},getItems:function(){var t=e.$$array("li:not(.dropdownSeparator) [role^='menuitem']",this._dropdownNode,!0),n=[],i=this;return t.forEach(function(e){var t=e;"label"===t.parentNode.tagName.toLowerCase()&&(t=e.parentNode),t.parentNode.parentNode===i._dropdownNode&&n.push(t)}),n},empty:function(){var t=e.$$array("li",this._dropdownNode),n=this;t.forEach(function(e){e.parentNode===n._dropdownNode&&e.parentNode.removeChild(e)})},_dropdownKeyDown:function(t){if(t.keyCode!==e.KEY.TAB)if(t.keyCode===e.KEY.UP||t.keyCode===e.KEY.DOWN||t.keyCode===e.KEY.RIGHT||t.keyCode===e.KEY.LEFT||t.keyCode===e.KEY.ENTER||t.keyCode===e.KEY.SPACE){var n=this.getItems(),i="menubar"===this._dropdownNode.getAttribute("role");if(n.length&&n.length>0){if(this._selectedItem){var r=n.indexOf(this._selectedItem);if(0>r&&(r=n.indexOf(this._selectedItem.parentNode)),r>=0)if(t.keyCode===e.KEY.UP)if(i){if(this._selectedItem.classList.contains("dropdownTrigger")&&this._selectedItem.dropdown){var o=this._selectedItem.dropdown;o.open();var s=o.getItems();o._selectItem(s[s.length-1])}}else this._selectItem(n[r>0?r-1:n.length-1]);else t.keyCode===e.KEY.DOWN?i?this._selectedItem.classList.contains("dropdownTrigger")&&this._selectedItem.dropdown&&(this._selectedItem.dropdown.open(),this._selectedItem.dropdown._selectItem()):this._selectItem(n[r0?r-1:n.length-1]):this._parentDropdown?(this.close(!0),this._parentDropdown._dropdownNode.focus()):this._closeThenOpen(this._selectedItem,t.keyCode,!0):(t.keyCode===e.KEY.ENTER||t.keyCode===e.KEY.SPACE)&&(this._selectedItem.classList.contains("dropdownTrigger")&&this._selectedItem.dropdown?(this._selectedItem.dropdown.open(),this._selectedItem.dropdown._selectItem()):(this._selectedItem.click(),this._triggerNode.focus()))}else t.keyCode===e.KEY.UP?this._selectItem(n[n.length-1]):t.keyCode===e.KEY.RIGHT||t.keyCode===e.KEY.LEFT?this._closeThenOpen(this._triggerNode,t.keyCode,!1):this._selectItem(n[0]);e.stop(t)}}else t.keyCode===e.KEY.ESCAPE&&(this.close(!0),this._parentDropdown&&this._parentDropdown._dropdownNode.focus(),e.stop(t));else if(this._selectedItem||this._isVisible)for(var a=!0;a;)a=this.close(!0),this._parentDropdown&&a&&this._parentDropdown._dropdownNode.focus()},_closeThenOpen:function(t,n,i){for(;t.parentNode&&document!==t.parentNode&&"menubar"!==t.parentNode.getAttribute("role");)t=t.parentNode;if(t.parentNode&&document!==t.parentNode){for(var r=t.childNodes[0],o=t.parentNode,s=o.dropdown.getItems(),a=null,l=0;l0?s[l-1]:s[s.length-1]:li.bottom&&(this._selectedItem.scrollIntoView(!1),this._dropdownNode.scrollHeight-this._dropdownNode.scrollTop-this._dropdownNode.clientHeight<5&&(this._dropdownNode.scrollTop=this._dropdownNode.scrollHeight-this._dropdownNode.clientHeight)),a.call(this)}},submenuOpen:function(e){e!==this._selectedSubmenu&&(this._closeSelectedSubmenu(),this._selectedSubmenu=e)},_closeSelectedSubmenu:function(){for(var e=this._selectedSubmenu;e;)e.close(),e=e._selectedSubmenu},destroy:function(){this.empty(),this._boundAutoDismiss&&(e.removeAutoDismiss(this._boundAutoDismiss),this._boundAutoDismiss=null)},appendMenuItem:function(e,t){var n=i(e,t);return this._dropdownNode.appendChild(n),n},appendSeparator:function(){var e=r();return this._dropdownNode.appendChild(e),e}},n.prototype.constructor=n,{Dropdown:n,appendKeyBindingString:o,createMenuItem:i,createSeparator:r}}),n("text",["module"],function(e){"use strict";
function n(e,t){return void 0===e||""===e?t:e}function i(e,t,i,r){if(t===r)return!0;if(e===i){if("http"===e)return n(t,"80")===n(r,"80");if("https"===e)return n(t,"443")===n(r,"443")}return!1}var r,o,s,a,l,d=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],c=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,h=/]*>\s*([\s\S]+)\s*<\/body>/im,u="undefined"!=typeof location&&location.href,f=u&&location.protocol&&location.protocol.replace(/\:/,""),p=u&&location.hostname,g=u&&(location.port||void 0),v={},m=e.config&&e.config()||{};return r={version:"2.0.15",strip:function(e){if(e){e=e.replace(c,"");var t=e.match(h);t&&(e=t[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")},createXhr:m.createXhr||function(){var e,t,n;if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;if("undefined"!=typeof ActiveXObject)for(t=0;3>t;t+=1){n=d[t];try{e=new ActiveXObject(n)}catch(i){}if(e){d=[n];break}}return e},parseName:function(e){var t,n,i,r=!1,o=e.lastIndexOf("."),s=0===e.indexOf("./")||0===e.indexOf("../");return-1!==o&&(!s||o>1)?(t=e.substring(0,o),n=e.substring(o+1)):t=e,i=n||t,o=i.indexOf("!"),-1!==o&&(r="strip"===i.substring(o+1),i=i.substring(0,o),n?n=i:t=i),{moduleName:t,ext:n,strip:r}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(e,t,n,o){var s,a,l,d=r.xdRegExp.exec(e);return d?(s=d[2],a=d[3],a=a.split(":"),l=a[1],a=a[0],!(s&&s!==t||a&&a.toLowerCase()!==n.toLowerCase()||(l||a)&&!i(s,l,t,o))):!0},finishLoad:function(e,t,n,i){n=t?r.strip(n):n,m.isBuild&&(v[e]=n),i(n)},load:function(e,t,n,i){if(i&&i.isBuild&&!i.inlineText)return void n();m.isBuild=i&&i.isBuild;var o=r.parseName(e),s=o.moduleName+(o.ext?"."+o.ext:""),a=t.toUrl(s),l=m.useXhr||r.useXhr;return 0===a.indexOf("empty:")?void n():void(!u||l(a,f,p,g)?r.get(a,function(t){r.finishLoad(e,o.strip,t,n)},function(e){n.error&&n.error(e)}):t([s],function(e){r.finishLoad(o.moduleName+"."+o.ext,o.strip,e,n)}))},write:function(e,t,n){if(v.hasOwnProperty(t)){var i=r.jsEscape(v[t]);n.asModule(e+"!"+t,"define(function () { return '"+i+"';});\n")}},writeFile:function(e,t,n,i,o){var s=r.parseName(t),a=s.ext?"."+s.ext:"",l=s.moduleName+a,d=n.toUrl(s.moduleName+a)+".js";r.load(l,n,function(){var t=function(e){return i(d,e)};t.asModule=function(e,t){return i.asModule(e,d,t)},r.write(e,l,t,o)},o)}},"node"===m.env||!m.env&&"undefined"!=typeof process&&process.versions&&process.versions.node&&!process.versions["node-webkit"]&&!process.versions["atom-shell"]?(o=t.nodeRequire("fs"),r.get=function(e,t,n){try{var i=o.readFileSync(e,"utf8");""===i[0]&&(i=i.substring(1)),t(i)}catch(r){n&&n(r)}}):"xhr"===m.env||!m.env&&r.createXhr()?r.get=function(e,t,n,i){var o,s=r.createXhr();if(s.open("GET",e,!0),i)for(o in i)i.hasOwnProperty(o)&&s.setRequestHeader(o.toLowerCase(),i[o]);m.onXhr&&m.onXhr(s,e),s.onreadystatechange=function(){var i,r;4===s.readyState&&(i=s.status||0,i>399&&600>i?(r=new Error(e+" HTTP status: "+i),r.xhr=s,n&&n(r)):t(s.responseText),m.onXhrComplete&&m.onXhrComplete(s,e))},s.send(null)}:"rhino"===m.env||!m.env&&"undefined"!=typeof Packages&&"undefined"!=typeof java?r.get=function(e,t){var n,i,r="utf-8",o=new java.io.File(e),s=java.lang.System.getProperty("line.separator"),a=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(o),r)),l="";try{for(n=new java.lang.StringBuffer,i=a.readLine(),i&&i.length()&&65279===i.charAt(0)&&(i=i.substring(1)),null!==i&&n.append(i);null!==(i=a.readLine());)n.append(s),n.append(i);l=String(n.toString())}finally{a.close()}t(l)}:("xpconnect"===m.env||!m.env&&"undefined"!=typeof Components&&Components.classes&&Components.interfaces)&&(s=Components.classes,a=Components.interfaces,Components.utils["import"]("resource://gre/modules/FileUtils.jsm"),l="@mozilla.org/windows-registry-key;1"in s,r.get=function(e,t){var n,i,r,o={};l&&(e=e.replace(/\//g,"\\")),r=new FileUtils.File(e);try{n=s["@mozilla.org/network/file-input-stream;1"].createInstance(a.nsIFileInputStream),n.init(r,1,0,!1),i=s["@mozilla.org/intl/converter-input-stream;1"].createInstance(a.nsIConverterInputStream),i.init(n,"utf-8",n.available(),a.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER),i.readString(n.available(),o),i.close(),n.close(),t(o.value)}catch(d){throw new Error((r&&r.path||"")+": "+d)}}),r}),n("text!orion/webui/dropdowntriggerbutton.html",[],function(){return''}),n("text!orion/webui/dropdowntriggerbuttonwitharrow.html",[],function(){return''}),n("text!orion/webui/checkedmenuitem.html",[],function(){return'
  • '}),n("orion/webui/tooltip",["orion/webui/littlelib"],function(e){function t(e){this._init(e)}return t.prototype={_init:function(t){if(this._node=e.node(t.node),!this._node)throw"no dom node for tooltip found";this._position=t.position||["right","above","below","left"],this._text=t.text,this._hideDelay=void 0===t.hideDelay?200:t.hideDelay,this._tailSize=t.tailSize||10,this._trigger=t.trigger||"mouseover",this._afterShowing=t.afterShowing,this._afterHiding=t.afterHiding;var n=this;if("click"===this._trigger)this._showDelay=0,this._node.addEventListener("click",this._clickHandler=function(t){t.target===n._node&&(n.show(),e.stop(t))},!1);else if("mouseover"===this._trigger){this._showDelay=void 0===t.showDelay?500:t.showDelay;var i=["mouseout","click"];this._node.addEventListener("mouseover",this._mouseoverHandler=function(t){e.contains(n._node,t.target)&&n.show()},!1),this._leaveHandler=function(t){e.contains(n._node,t.target)&&n.hide()};for(var r=0;rg){if(!i&&(!n||"left"!==t&&"right"!==t))return!1;s=g-l.height-1,d=!0}if(a+l.width>p){if(!i&&(!n||"above"!==t&&"below"!==t))return!1;a=p-l.width-1,d=!0}if(u>a){if(!i)return!1;a=u+4,d=!0}if(f>s){if(!i)return!1;s=f+4,d=!0}return this._tail&&(this._tail.previousPosition!==t||d)&&(this._tip.removeChild(this._tail),this._tail=null),this._tail||(this._tail=document.createElement("span"),this._tail.classList.add("tooltipTailFrom"+t),"above"===t||"left"===t?this._tip.appendChild(this._tail):this._tip.insertBefore(this._tail,this._tipInner),d?("above"===t||"below"===t?this._tail.style.left=r.left-a+this._tailSize+"px":this._tail.style.top=r.top-s+this._tailSize+"px",this._tail.previousPosition=null):this._tail.previousPosition=t),this._tip.style.top=s+"px",this._tip.style.left=a+"px",!0},contentContainer:function(){return this._makeTipNode(),this._tipInner},isShowing:function(){return this._tip&&this._tip.classList.contains("tooltipShowing")},turnOff:function(){this.isTurnedOff=!0},turnOn:function(){this.isTurnedOff=!1},show:function(){this.isTurnedOff||this.isShowing()||(this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null),this._showDelay?this._timeout=window.setTimeout(this._showImmediately.bind(this),this._showDelay):this._showImmediately())},_showImmediately:function(){for(var t=!1,n=0;!t&&n"+i.name),i.callback.call(i,t)}.bind(this),!1),s.addEventListener("keydown",function(e){(e.keyCode===n.KEY.ENTER||e.keyCode===n.KEY.SPACE)&&(d.logEvent("command","invoke",this.id+">"+i.name),i.callback.call(i,t))}.bind(this),!1)}else o._generateMenuSeparator(e)}.bind(this))},getChoices:function(e,t,n){return this.choiceCallback?this.choiceCallback.call(t,e,n):null},makeChoiceCallback:function(e,t){return function(n){e.callback&&e.callback.call(e,t,n)}},hasImage:function(){return this.imageClass||this.image!==T}},S.prototype.constructor=S,{Command:S,CommandInvocation:b,createDropdownMenu:m,createCheckedMenuItem:_,createQuickfixItem:y,createCommandItem:C,createCommandMenuItem:x,executeBinding:u,setKeyBindingProvider:h,localKeyBindings:A,getKeyBindings:p,processKey:g,NO_IMAGE:T,_testMethodProcessKey:f}}),n("orion/keyBinding",["orion/util"],function(e){function t(e,t,n,i,r,o){this.type=o||"keydown",this.keyCode="string"==typeof e&&"keydown"===this.type?e.toUpperCase().charCodeAt(0):e,this.mod1=void 0!==t&&null!==t?t:!1,this.mod2=void 0!==n&&null!==n?n:!1,this.mod3=void 0!==i&&null!==i?i:!1,this.mod4=void 0!==r&&null!==r?r:!1}function n(e){this.keys=e}return t.prototype={getKeys:function(){return[this]},match:function(t,n){if(void 0!==n){if(0!==n)return!1}else if(t instanceof Array){if(t.length>1)return!1;t=t[0]}if(t.type!==this.type)return!1;if(this.keyCode===t.keyCode||this.keyCode===String.fromCharCode(e.isOpera?t.which:void 0!==t.charCode?t.charCode:t.keyCode)){var i=e.isMac?t.metaKey:t.ctrlKey;return this.mod1!==i?!1:"keydown"===this.type&&this.mod2!==t.shiftKey?!1:this.mod3!==t.altKey?!1:e.isMac&&this.mod4!==t.ctrlKey?!1:!0}return!1},equals:function(e){return e?this.keyCode!==e.keyCode?!1:this.mod1!==e.mod1?!1:this.mod2!==e.mod2?!1:this.mod3!==e.mod3?!1:this.mod4!==e.mod4?!1:this.type!==e.type?!1:!0:!1}},n.prototype={getKeys:function(){return this.keys.slice(0)},match:function(e,t){var n=this.keys;if(void 0!==t)return t>n.length?!1:n[t].match(e)?t===n.length-1?!0:t+1:!1;if(e instanceof Array||(e=[e]),e.length>n.length)return!1;var i;for(i=0;i=0||t.indexOf("Trident")>=0||t.indexOf("Edge")>=0)return!1;var n=document.createElement(e.tagName);n.contentEditable=!0;var i="oninput"in n;return i||(n.setAttribute("oninput","return;"),i="function"==typeof n.oninput),n=null,i}function n(e,n,r,o,s){if(!e||1!=e.nodeType)return!1;C||(C=document.createEvent("Event"),C.initEvent("TF",!0,!0)),e.setAttribute("data-tf-type",n);var l="undefined"===r?"{}":JSON.stringify(Array.isArray(r)?r[0]:r);e.setAttribute("data-tf-args",l);var d="ltr";if("undefined"===o&&(e.dir?d=e.dir:e.style&&e.style.direction&&(d=e.style.direction),o="rtl"===d.toLowerCase()),e.setAttribute("data-tf-dir",o),e.setAttribute("data-tf-locale",a.getLocaleDetails(s).lang),t(e)){{e.oninput}e.oninput=function(e){i(e.target)}}else e.onkeyup=function(t){i(t.target),e.dispatchEvent(C)},e.onmouseup=function(t){i(t.target),e.dispatchEvent(C)};return i(e),!0}function i(t){var n=t.textContent||"",i=document.getSelection();if(0===n.length||!i||i.rangeCount<=0)return void t.dispatchEvent(C);var r,o,s=i.getRangeAt(0),a=s.cloneRange();r=s.startContainer,o=s.startOffset;var l=0;3===r.nodeType&&(l+=o),a.setStart(t,0),a.setEndBefore(r);var d=document.createElement("div");d.appendChild(a.cloneContents()),l+=d.textContent.length,t.innerHTML=e(t.getAttribute("data-tf-type")).format(n,JSON.parse(t.getAttribute("data-tf-args")),"true"===t.getAttribute("data-tf-dir")?!0:!1,!0,t.getAttribute("data-tf-locale"));var c=t,h=t,u=0,f=!1;for(i.removeAllRanges(),s.setStart(t,0),s.setEnd(t,0);h;){if(3===h.nodeType){if(u+h.nodeValue.length>=l){s.setStart(h,l-u);break}u+=h.nodeValue.length,h=h.nextSibling}else{if(h.hasChildNodes()){c=h,h=c.firstChild;continue}h=h.nextSibling}for(;!h;){if(c===t){f=!0;break}h=c.nextSibling,c=c.parentNode}if(f)break}i.addRange(s),t.dispatchEvent(C)}var r=function(){var e=function(e){this.content="",this.actual="",this.textDirection="",this.localGui="",this.isVisible=!0,this.isSeparator=!1,this.isParsed=!1,this.keep=!1,this.inBounds=!1,this.inPoints=!1;var t="";for(t in e)e.hasOwnProperty(t)&&(this[t]=e[t])};return e}(),o=function(){function e(e){if(!e)return!1;"undefined"==typeof e.start&&(e.start=""),"undefined"==typeof e.end&&(e.end=""),"undefined"!=typeof e.startAfter?(e.start=e.startAfter,e.after=!0):e.after=!1,"undefined"!=typeof e.endBefore?(e.end=e.endBefore,e.before=!0):e.before=!1;var t=parseInt(e.startPos,10);e.usePos=isNaN(t)?!1:!0;var n=parseInt(e.length,10);return e.useLength=isNaN(n)?!1:!0,e.loops="undefined"!=typeof e.loops?!!e.loops:!0,!0}function t(e,t){var n={};for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);var r=e.content,o=n.usePos&&n.startPos0?r.indexOf(n.start):0;var s=n.useLength&&n.length>0&&n.bStart+n.length0?r.indexOf(n.end,n.bStart+n.start.length)+1:r.length,n.after||(n.start=""),n.before||(n.end=""),n}return{handleSubcontents:function(e,t,n){if(!n.content||"string"!=typeof n.content||0===n.content.length)return e;var i=!0;"undefined"!=typeof n.loops&&(i=!!n.loops);for(var o=0;!0&&!(o>=e.length);o++)if(!(e[o].isParsed||e.keep||e[o].isSeparator)){var s=e[o].content,a=s.indexOf(n.content);if(!(0>a)){var l,d=0;if(n.continued){do d++,l=s.indexOf(n.content,a+d*n.content.length);while(0===l)}else d=1;if(l=a+d*n.content.length,e.splice(o,1),a>0&&(e.splice(o,0,new r({content:s.substring(0,a),localGui:t.dir,keep:!0})),o++),e.splice(o,0,new r({content:s.substring(a,l),textDirection:n.subDir,localGui:t.dir})),l=n.length);a++)if(!(n[a].isParsed||n[a].inBounds||n.keep||n[a].isSeparator)){var l=t(n[a],o[s]),d=l.bStart,c=l.bEnd;if(!(0>d||0>c)){var h=n[a].content;if(n.splice(a,1),d>0&&(n.splice(a,0,new r({content:h.substring(0,d),localGui:i.dir,keep:!0})),a++),l.start&&(n.splice(a,0,new r({content:l.start,localGui:i.dir,isSeparator:!0})),a++),n.splice(a,0,new r({content:h.substring(d+l.start.length,c-l.end.length),textDirection:l.subDir,localGui:i.dir,inBounds:!0})),l.end&&(a++,n.splice(a,0,new r({content:l.end,localGui:i.dir,isSeparator:!0}))),c+l.end.length=e.length);o++)if(!(e[o].isParsed||e[o].keep||e[o].isSeparator)){var s=e[o].content,a=s.indexOf(n[i]);a>=0&&(e.splice(o,1),a>0&&(e.splice(o,0,new r({content:s.substring(0,a),textDirection:t.subDir,localGui:t.dir,inPoints:!0})),o++),e.splice(o,0,new r({content:n[i],localGui:t.dir,isSeparator:!0})),a+n[i].length+1<=s.length&&e.splice(o+1,0,new r({content:s.substring(a+n[i].length),textDirection:t.subDir,localGui:t.dir,inPoints:!0})))}for(i=0;i/g,""):e},getDirection:function(e,t,n,i){if("auto"!==t&&/^(rtl|ltr)$/i.test(t))return t;n=/^(rtl|ltr)$/i.test(n)?n:"ltr";var r=i?e.split("").reverse().join(""):e,o=/[A-Za-z\u05d0-\u065f\u066a-\u06ef\u06fa-\u07ff\ufb1d-\ufdff\ufe70-\ufefc]/.exec(r);return o?o[0]<="z"?"ltr":"rtl":n},hasArabicChar:function(e){var t=/[\u0600-\u065f\u066a-\u06ef\u06fa-\u07ff\ufb1d-\ufdff\ufe70-\ufefc]/.exec(e);return!!t},showMarks:function(e,l){for(var d="",c=0;c/g,this.LRM).replace(//g,this.RLM).replace(//g,this.LRE);return t.replace(//g,this.RLE).replace(//g,this.LRO).replace(//g,this.RLO).replace(//g,this.PDF)},showTags:function(e){return""+e+""},hideTags:function(e){return e.replace(//g,"").replace(/<\/xmp>/g,"")}}}(),l=function(){function e(e,t,r,o){return e&&t?i(n(e,t,o),t,r):e}function t(e,t){var n=Array.isArray(e)?e[0]:e;return n.guiDir||(n.guiDir="ltr"),n.dir||(n.dir=n.guiDir),t?("undefined"==typeof n.points&&(n.points=[]),n.cases||(n.cases=[]),n.bounds||(n.bounds=[]),n.commonHandler=s,n):n}function n(e,n,i){if(!e||!n)return new r({content:""});var o=t(n,!0),a=[new r({content:e,actual:e,localGui:o.dir})],l=s.handle;return o.handler&&"function"==typeof o.handler&&(l=o.handler.handle),l(e,a,o,i),a}function i(e,n,i){var r=t(n,!1);return i?l(e,r):o(e,r)}function o(e,t){for(var n="",i="",r="",o=!1,s=0;s<e.length;s++)if(e[s].isVisible){var l=e[s].textDirection,d=e[s].localGui;if(""!==d&&""===r?n+="rtl"===d?a.RLE:a.LRE:""===r||""!==d&&d===r&&!o||(n+=a.PDF+(s==e.length-1&&""!==d?"":"rtl"===t.dir?a.RLM:a.LRM),""!==d&&(n+="rtl"===d?a.RLE:a.LRE)),"auto"===l&&(l=a.getDirection(e[s].content,l,t.guiDir)),/^(rtl|ltr)$/i.test(l)?(n+=("rtl"===l?a.RLE:a.LRE)+e[s].content+a.PDF,i=l):(n+=e[s].content,i=a.getDirection(e[s].content,l,t.guiDir,!0)),s<e.length-1){var c=d&&e[s+1].localGui?d:t.dir;n+="rtl"===c?a.RLM:a.LRM}else""!==r&&(n+=a.PDF);r=d,o=!1}else o=!0;var h="auto"===t.dir?a.getDirection(e[0].actual,t.dir,t.guiDir):t.dir;return h!==t.guiDir&&(n=("rtl"===h?a.RLE:a.LRE)+n+a.PDF),n}function l(e,t){for(var n="",i="",r="",o=0;o<e.length;o++)if(e[o].isVisible){var s=e[o].textDirection,l=e[o].localGui;if(""!==l&&""===r?n+="<bdi dir='"+("rtl"===l?"rtl":"ltr")+"'>":""===r||""!==l&&l===r&&!stop||(n+="</bdi>"+(o==e.length-1&&""!==l?"":"<span style='unicode-bidi: embed; direction: "+("rtl"===t.dir?"rtl":"ltr")+";'></span>"),""!==l&&(n+="<bdi dir='"+("rtl"===l?"rtl":"ltr")+"'>")),"auto"===s&&(s=a.getDirection(e[o].content,s,t.guiDir)),/^(rtl|ltr)$/i.test(s)?(n+="<bdi dir='"+("rtl"===s?"rtl":"ltr")+"'>"+e[o].content+"</bdi>",i=s):(n+=e[o].content,i=a.getDirection(e[o].content,s,t.guiDir,!0)),o<e.length-1){var d=l&&e[o+1].localGui?l:t.dir;n+="<span style='unicode-bidi: embed; direction: "+("rtl"===d?"rtl":"ltr")+";'></span>"}else""!==r&&(n+="</bdi>");r=l,stop=!1}else stop=!0;var c="auto"===t.dir?a.getDirection(e[0].actual,t.dir,t.guiDir):t.dir;return c!==t.guiDir&&(n="<bdi dir='"+("rtl"===c?"rtl":"ltr")+"'>"+n+"</bdi>"),n}function d(e){return e}var c={};return c.parseAndDisplayStructure=e,c.parseStructure=n,c.displayStructure=i,c.restore=d,c}(),d=function(){return{format:function(e,t,n,i,r,o){var s={guiDir:n?"rtl":"ltr",dir:t.dir?t.dir:n?"rtl":"ltr",subs:{content:">",continued:!0,subDir:n?"rtl":"ltr"},cases:[{args:{subs:{content:"<",continued:!0,subDir:n?"ltr":"rtl"}}}]};return o?l.parseStructure(e,s,!!i,r):l.parseAndDisplayStructure(e,s,!!i,r)}}}(),c=function(){return{format:function(e,t,n,i,r,o){var s={guiDir:n?"rtl":"ltr",dir:"ltr",points:","};return o?l.parseStructure(e,s,!!i,r):l.parseAndDisplayStructure(e,s,!!i,r)}}}(),h=function(){function e(e,t){if("ar"!==a.getLocaleDetails(t).lang)return"ltr";var n=e.indexOf("@");return n>0&&n<e.length-1&&a.hasArabicChar(e.substring(n+1))?"rtl":"ltr"}return{format:function(t,n,i,r,o,a){var d={guiDir:i?"rtl":"ltr",dir:e(t,o),points:"<>.:,;@",cases:[{handler:s,args:{bounds:[{startAfter:'"',endBefore:'"'},{startAfter:"(",endBefore:")"}],points:""}}]};return a?l.parseStructure(t,d,!!r,o):l.parseAndDisplayStructure(t,d,!!r,o)}}}(),u=function(){return{format:function(e,t,n,i,r,o){var s={guiDir:n?"rtl":"ltr",dir:"ltr",subDir:t.subDir,points:"/\\:.&<>"};return o?l.parseStructure(e,s,!!i,r):l.parseAndDisplayStructure(e,s,!!i,r)}}}(),f=function(){return{format:function(e,t,n,i,r,o){var s={guiDir:n?"rtl":"ltr",dir:"ltr",points:" /%^&[]<>=!?~:.,|()+-*{}"};return o?l.parseStructure(e,s,!!i,r):l.parseAndDisplayStructure(e,s,!!i,r)}}}(),p=function(){return{format:function(e,t,n,i,r,o){var a={guiDir:n?"rtl":"ltr",dir:"ltr",points:" !#%&()*+,-./:;<=>?|[]{}",cases:[{handler:s,args:{bounds:[{startAfter:"/*",endBefore:"*/"},{startAfter:"--",end:"\n"},{startAfter:"--"}]}},{handler:s,args:{subs:{content:" ",continued:!0}}},{handler:s,args:{bounds:[{startAfter:"'",endBefore:"'"},{startAfter:'"',endBefore:'"'}]}}]};return o?l.parseStructure(e,a,!!i,r):l.parseAndDisplayStructure(e,a,!!i,r)}}}(),g=function(){return{format:function(e,t,n,i,r,o){var s={guiDir:n?"rtl":"ltr",dir:"ltr",points:"_"};return o?l.parseStructure(e,s,!!i,r):l.parseAndDisplayStructure(e,s,!!i,r)}}}(),v=function(){return{format:function(e,t,n,i,r,o){var s={guiDir:n?"rtl":"ltr",dir:"ltr",points:":?#/@.[]=&<>"};return o?l.parseStructure(e,s,!!i,r):l.parseAndDisplayStructure(e,s,!!i,r)}}}(),m=function(){return{format:function(e,t,n,i,r,o){var s={guiDir:n?"rtl":"ltr",dir:t.dir?t.dir:n?"rtl":"ltr",points:" ,.!?;:"};return o?l.parseStructure(e,s,!!i,r):l.parseAndDisplayStructure(e,s,!!i,r)}}}(),_=function(){return{format:function(e,t,n,i,r,o){var a={guiDir:n?"rtl":"ltr",dir:"ltr",points:" /[]<>=!:@.|()+-*",cases:[{handler:s,args:{bounds:[{startAfter:'"',endBefore:'"'},{startAfter:"'",endBefore:"'"}],points:""}}]};return o?l.parseStructure(e,a,!!i,r):l.parseAndDisplayStructure(e,a,!!i,r)}}}(),y=function(){return{format:function(e,t,n,i,r,o){var s={},a="",d=Array.isArray(t)?t[0]:t;for(a in d)d.hasOwnProperty(a)&&(s[a]=d[a]);return s.guiDir=n?"rtl":"ltr",s.dir=s.dir?s.dir:s.guiDir,o?l.parseStructure(e,s,!!i,r):l.parseAndDisplayStructure(e,s,!!i,r)}}}(),C=(function(){function t(e){return"he"===e||"iw"===e||"ar"===e?"rtl":"ltr"}function n(e){0===e.msgDir.length&&(e.msgDir=t(e.msgLang)),e.msgDir="ltr"!==e.msgDir&&"rtl"!==e.msgDir&&"auto"!=e.msgDir?"ltr":e.msgDir,0===e.guiDir.length&&(e.guiDir=e.msgDir),e.guiDir="rtl"!==e.guiDir?"ltr":"rtl",0===e.phDir.length&&(e.phDir=0===e.phLang.length?e.msgDir:t(e.phLang)),e.phDir="ltr"!==e.phDir&&"rtl"!==e.phDir&&"auto"!=e.phDir?"ltr":e.phDir,"string"==typeof e.phPacking&&(e.phPacking=e.phPacking.split("")),e.phPacking.length<2&&(e.phPacking=["{","}"])}var i={msgLang:"en",msgDir:"",phLang:"",phDir:"",phPacking:["{","}"],phStt:{type:"none",args:{}},guiDir:""},o=!1;return{setDefaults:function(e){for(var t in e)i.hasOwnProperty(t)&&(i[t]=e[t]);n(i),o=!0},format:function(t){o||(n(i),o=!0);var s=!1,a=!1,d=i.phPacking[0].length,c=i.phPacking[1].length;if(arguments.length>0){var h=arguments[arguments.length-1];"boolean"==typeof h&&(s=h,a=!0)}for(var u,f=new RegExp(i.phPacking[0]+"\\d+"+i.phPacking[1]),p=[],g=0,v=t;null!=(u=f.exec(v));){var m=v.indexOf(u[0])+u[0].length;m>u[0].length&&p.push({text:v.substring(0,m-u[0].length),ph:!1}),p.push({text:u[0],ph:!0}),g+=m,v=v.substring(m,v.length)}g<t.length&&p.push({text:t.substring(g,t.length),ph:!1});for(var _=[],y=1;y<arguments.length-(a?1:0);y++){var C=arguments[y],w=C,x=!1,b=0;if(Array.isArray(w)){if(C=w[0],"undefined"==typeof C)continue;x=!0}do"string"==typeof C?_.push({text:C,dir:i.phDir,stt:i.stt}):"boolean"==typeof C?s=C:"object"==typeof C?(_.push(C),C.hasOwnProperty("text")||(_[_.length-1].text="{???}"),C.hasOwnProperty("dir")&&0!==C.dir.length||(_[_.length-1].dir=i.phDir),(!C.hasOwnProperty("stt")||"string"==typeof C.stt&&0===C.stt.length||"object"==typeof C.stt&&0===Object.keys(C.stt).length)&&(_[_.length-1].stt=i.phStt)):_.push({text:""+C,dir:i.phDir,stt:i.phStt}),x&&(b++,b==w.length?x=!1:C=w[b]);while(x)}var S=[];for(y=0;y<p.length;y++){var T=p[y];if(T.ph){var E=parseInt(T.text.substring(d,T.text.length-c));if(isNaN(E)||E>=_.length){S.push(new r({content:T.text,textDirection:i.msgDir}));continue}var A="none";if(_[E].stt||(_[E].stt=i.phStt),_[E].stt&&("string"==typeof _[E].stt?A=_[E].stt:_[E].stt.hasOwnProperty("type")&&(A=_[E].stt.type)),"none"!==A.toLowerCase()){for(var L=e(A).format(_[E].text,_[E].stt.args||{},"rtl"===i.msgDir,!1,i.msgLang,!0),k=0;k<L.length;k++)S.push(L[k]);S.push(new r({isVisible:!1}))}else S.push(new r({content:_[E].text,textDirection:_[E].dir?_[E].dir:i.phDir}))}else S.push(new r({content:T.text,textDirection:i.msgDir}))}var M=l.displayStructure(S,{guiDir:i.guiDir,dir:i.msgDir},s);return M}}}(),null);return{getHtml:function(t,n,i,r,o){return e(n).format(t,i,r,!0,o)},attach:function(e,t,i,r,o){return n(e,t,i,r,o)},getString:function(t,n,i,r,o){return e(n).format(t,i,r,!1,o)}}}),n("orion/bidiUtils",["orion/util","orion/bidiFormat"],function(e,t){function n(){var e;window.dojoConfig&&(e=window.dojoConfig.locale),e||(e=navigator.languages?navigator.languages[0]:navigator.language||navigator.userLanguage);var t=e&&-1!=="ar iw he".indexOf(e.substring(0,2));if(t&&i()){var n=document.getElementsByTagName("html")[0];n&&n.setAttribute("dir","rtl")}}function i(){var e=localStorage.getItem(f);return e&&"true"===e?!0:!1}function r(){var e=localStorage.getItem(p);return!e||"rtl"!==e&&"ltr"!==e&&"auto"!==e?"ltr":e}function o(t){return _=r(),i()?"auto"===_&&e.isIE?a(t):_:""}function s(e){if(i()&&e.trim()){_=r();var t="auto"===_?a(e):_;return("ltr"===t?g:m)+e+v}return e}function a(e){var t=/[A-Za-z\u05d0-\u065f\u066a-\u06ef\u06fa-\u07ff\ufb1d-\ufdff\ufe70-\ufefc]/.exec(e);return t?t[0]<="z"?"ltr":"rtl":"ltr"}function l(e){if(!e._hasBidiEventListeners){e._hasBidiEventListeners=!0;for(var t=["keyup","cut","paste"],n=0;n<t.length;++n)e.addEventListener(t[n],d.bind(this),!1)}}function d(e){var t=e.target;t&&(t.dir=o(t.value||t.textContent))}function c(t){i()&&t&&(t.dir=o(t.value||t.textContent),e.isIE&&l(t))}function h(e){var t=[{name:"comment block"},{name:"comment line double-slash"},{name:"comment block documentation"},{name:"comment line double-slash jade"},{name:"comment line"},{name:"comment line number-sign php"},{name:"comment block xml"}],n=e.text,r=e.style;if(i()&&r&&r.styleClass&&r.styleClass.startsWith("comment")&&n.length>0)for(var s=0;s<t.length;s++)if(r.styleClass===t[s].name){var a=r;return"undefined"==typeof a.attributes&&(a.attributes={}),a.attributes.dir=o(n),e.style=a,e}return e}function u(e,n){return i()&&e&&n?t.getString(e,n,{subDir:r()},!1,"en"):e}var f="/orion/preferences/bidi/bidiEnabled",p="/orion/preferences/bidi/bidiLayout",g="‪",v="‬",m="‫";n();var _=r();return{isBidiEnabled:i,getTextDirection:o,enforceTextDirWithUcc:s,initInputField:c,enforceTextDir:h,enforceSTT:u}}),n("orion/PageUtil",[],function(){function e(){var e=window.location.href.split("#")[1];return e=e?"#"+e:""}function t(e){e=e||window.location.toString();var t={resource:""},n=e.indexOf("#");if(-1!==n){var i=e.substring(n+1);if(0!==i.length){var r=i.split(",");t.resource=decodeURIComponent(r[0]);for(var o=1;o<r.length;o++){var s=r[o],a=/([^=]*)(=?)(.*)/.exec(s),l=decodeURIComponent(a[1]||""),d=decodeURIComponent(a[3]||"");""!==l&&"resource"!==l&&(t[l]=d)}}}return t}function n(e,t){var n=e;if(-1===e.indexOf("://")){var r=document.createElement("a");r.href=e,n=r.href}var o=!1;return o=t?t.some(function(e){return new RegExp("^"+e+":","i").test(n)}):i.test(n),o?e:(console.log("Illegal URL Scheme: '"+e+"'"),"")}var i=new RegExp("^http[s]?","i");return{hash:e,matchResourceParameters:t,validateURLScheme:n}}),n("orion/uiUtils",["i18n!orion/nls/messages","orion/webui/littlelib","orion/i18nUtil","orion/bidiUtils","orion/urlModifier"],function(e,t,n,i,r){function o(n){var i="";if(y)n.mod4&&(i+="⌃"),n.mod3&&(i+="⌥"),n.mod2&&(i+="⇧"),n.mod1&&(i+="⌘");else{var r="+";n.mod1&&(i+=e.KeyCTRL+r),n.mod2&&(i+=e.KeySHIFT+r),n.mod3&&(i+=e.KeyALT+r)}if(n.alphaKey)return i+n.alphaKey;if("keypress"===n.type)return i+n.keyCode;var o=n.keyCode,s=C[o];if(s)return i+s;var a=t.keyName(o);if(a)return a=e["Key"+a]||a,i+a;var l;switch(n.keyCode){case 59:l=n.mod2?":":";";break;case 61:l=n.mod2?"+":"=";break;case 188:l=n.mod2?"<":",";break;case 190:l=n.mod2?">":".";break;case 191:l=n.mod2?"?":"/";break;case 192:l=n.mod2?"~":"`";break;case 219:l=n.mod2?"{":"[";break;case 220:l=n.mod2?"|":"\\";break;case 221:l=n.mod2?"}":"]";break;case 222:l=n.mod2?'"':"'"}return l?i+l:n.keyCode>=112&&n.keyCode<=123?i+"F"+(n.keyCode-111):i+String.fromCharCode(n.keyCode)}function s(e){for(var t="",n=e.getKeys(),i=0;i<n.length;i++)0!==i&&(t+=" "),t+=o(n[i]);return t}function a(e){var n=e.id,r=e.refNode,o=e.hideRefNode,s=e.initialText,a=e.onComplete,l=e.onEditDestroy,d=e.selectTo,c=e.isInitialValid,h=e.insertAsChild,u=!1,f=function(e){return function(i){if(!u){var d=t.node(n),h=d.value;if(d)return e&&i.keyCode===t.KEY.ESCAPE?(o&&(r.style.display=""),u=!0,d.parentNode.removeChild(d),void(l&&l())):void(e&&i.keyCode!==t.KEY.ENTER||(0===h.length||!c&&h===s?(o&&(r.style.display=""),u=!0):(a(h),o&&r.parentNode&&(r.style.display=""),u=!0),d.parentNode&&d.parentNode.removeChild(d),l&&l()))}}},p=document.createElement("input");p.id=n,p.value=s||"",h?r.appendChild(p):r.parentNode.insertBefore(p,r.nextSibling),p.classList.add("userEditBoxPrompt"),o&&(r.style.display="none"),i.initInputField(p),p.addEventListener("keydown",f(!0),!1),p.addEventListener("blur",f(!1),!1),window.setTimeout(function(){if(p.focus(),s){var e=t.node(n),i=d?s.indexOf(d):-1;if(i>0)if(e.createTextRange){var r=e.createTextRange();r.collapse(!0),r.moveStart("character",0),r.moveEnd("character",i),r.select()}else e.setSelectionRange?e.setSelectionRange(0,i):void 0!==e.selectionStart&&(e.selectionStart=0,e.selectionEnd=i);else e.select()}},0)}function l(e){var t=-1!==window.navigator.platform.indexOf("Mac");return t&&e.metaKey||!t&&e.ctrlKey}function d(e,t){t&&l(t)?window.open(r(e)):window.location=r(e)}function c(e,n){var i=document.createElement("button");return i.className="orionButton commandButton commandMargins",i.addEventListener("click",function(e){n(),t.stop(e)},!1),e&&i.appendChild(document.createTextNode(e)),i}function h(){}function u(e,t){if(!e||!e.tagName)return!1;switch(e.tagName.toLowerCase()){case"button":case"fieldset":case"form":case"input":case"keygen":case"label":case"legend":case"meter":case"optgroup":case"output":case"progress":case"select":case"textarea":return!0}return e.parentNode===t?!1:e.parentNode&&u(e.parentNode,t)}function f(e,t){var n=e.split("/");return n.splice(n.length-1,1),t?n.join("/")+"/":n.join("/")}function p(e){var t=new Date(e),n=Date.now()-t.getTime(),i=Math.floor(n/1e3/60/60/24/365);n-=1e3*i*60*60*24*365;var r=Math.floor(n/1e3/60/60/24/30);n-=1e3*r*60*60*24*30;var o=Math.floor(n/1e3/60/60/24);n-=1e3*o*60*60*24;var s=Math.floor(n/1e3/60/60);n-=1e3*s*60*60;var a=Math.floor(n/1e3/60);n-=1e3*a*60;var l=Math.floor(n/1e3);return{year:i,month:r,day:o,hour:s,minute:a,second:l}}function g(t,i,r){return t>0?1===t?e[i]:n.formatMessage(e[r],t):""}function v(e){var t=p(e),n=g(t.year,"a year","years"),i=g(t.month,"a month","months"),r=g(t.day,"a day","days"),o=g(t.hour,"an hour","hours"),s=g(t.minute,"a minute","minutes"),a="";return n?a=t.year>0?n:n+i:i?a=t.month>0?i:i+r:r?a=t.day>0?r:r+o:o?a=t.hour>0?o:o+s:s&&(a=s),a}function m(t){var i=v(t);return i?n.formatMessage(e.timeAgo,i):e.justNow}function _(e){var t=e.split(" ");return t.length>=2?(t[0].charAt(0)+t[t.length-1].charAt(0)).toUpperCase():e.substr(0,2)}var y=-1!==navigator.platform.indexOf("Mac"),C=Object.create(null);return C[t.KEY.DOWN]="↓",C[t.KEY.UP]="↑",C[t.KEY.RIGHT]="→",C[t.KEY.LEFT]="←",y&&(C[t.KEY.BKSPC]="⌫",C[t.KEY.DEL]="⌦",C[t.KEY.END]="⇲",C[t.KEY.ENTER]="⏎",C[t.KEY.ESCAPE]="⎋",C[t.KEY.HOME]="⇱",C[t.KEY.PAGEDOWN]="⇟",C[t.KEY.PAGEUP]="⇞",C[t.KEY.SPACE]="␣",C[t.KEY.TAB]="⇥"),{getUserKeyString:s,getUserText:a,openInNewWindow:l,followLink:d,createButton:c,createDropdownButton:h,isFormElement:u,path2FolderName:f,timeElapsed:v,displayableTimeElapsed:m,getNameInitial:_}}),n("text!orion/webui/submenutriggerbutton.html",[],function(){return'<li class="dropdownSubMenu" role="none"><span class="dropdownTrigger dropdownMenuItem" aria-expanded = "false" aria-haspopup="true" role="menuitem" tabindex="-1" style="outline:none"><span class="dropdownCommandName">${ButtonText}</span><span class="dropdownArrowRight core-sprite-closedarrow" aria-hidden="true"></span></span><ul class="dropdownMenu" role="menu"></ul></li>'}),function(e,t){"function"==typeof n&&n.amd?n("orion/Deferred",t):"object"==typeof exports?module.exports=t():(e.orion=e.orion||{},e.orion.Deferred=t())}(this,function(){function e(){for(var e;e=o.shift();)e();s=!1}function t(e){o.push(e),s||(s=!0,a())}function n(e){return function(t){e(t)}}function i(e,t,i){try{var r=e(t),o=r&&("object"==typeof r||"function"==typeof r)&&r.then;if("function"==typeof o)if(r===i.promise)i.reject(new TypeError);else{var s=r.cancel;"function"==typeof s?i._parentCancel=s.bind(r):delete i._parentCancel,o.call(r,n(i.resolve),n(i.reject),n(i.progress))}else i.resolve(r)}catch(a){i.reject(a)}}function r(){function e(){for(var e;e=d.shift();){var t=e.deferred,n="fulfilled"===l?"resolve":"reject",r=e[n];"function"==typeof r?i(r,a,t):t[n](a)}}function n(n){delete c._parentCancel,l="rejected",a=n,d.length&&t(e)}function o(i){function s(e){return function(t){l&&"assumed"!==l||e(t)}}delete c._parentCancel;try{var h=i&&("object"==typeof i||"function"==typeof i)&&i.then;if("function"==typeof h)if(i===c)n(new TypeError);else{l="assumed";var u=i&&i.cancel;if("function"!=typeof u){var f=new r;i=f.promise;try{h(f.resolve,f.reject,f.progress)}catch(p){f.reject(p)}u=i.cancel,h=i.then}a=i,h.call(i,s(o),s(n)),c._parentCancel=u.bind(i)}else l="fulfilled",a=i,d.length&&t(e)}catch(g){s(n)(g)}}function s(){var e=c._parentCancel;if(e)delete c._parentCancel,e();else if(!l){var t=new Error("Cancel");t.name="Cancel",n(t)}}var a,l,d=[],c=this;this.resolve=function(e){return l||o(e),c},this.reject=function(e){return l||n(e),c},this.progress=function(e){return l||d.forEach(function(t){if(t.progress)try{t.progress(e)}catch(n){}}),c.promise},this.cancel=function(){return c._parentCancel?setTimeout(s,0):s(),c},this.then=function(n,i,o){var s=new r;return s._parentCancel=c.promise.cancel,d.push({resolve:n,reject:i,progress:o,deferred:s}),("fulfilled"===l||"rejected"===l)&&t(e),s.promise},this.promise={then:c.then,cancel:c.cancel}}var o=[],s=!1,a=function(){if("undefined"!=typeof process&&"function"==typeof process.nextTick){var t=process.nextTick;return function(){t(e)}}if("function"==typeof MutationObserver){var n=document.createElement("div"),i=new MutationObserver(e);return i.observe(n,{attributes:!0}),function(){n.setAttribute("class","_tick")}}return function(){setTimeout(e,0)}}();return r.all=function(e,t){function n(e,t){a||(s[e]=t,0===--o&&l.resolve(s))}function i(e,i){if(!a){if(t)try{return void n(e,t(i))}catch(r){i=r}l.reject(i)}}var o=e.length,s=[],a=!1,l=new r;return l.then(void 0,function(){a=!0,e.forEach(function(e){e.cancel&&e.cancel()})}),0===o?l.resolve(s):e.forEach(function(e,t){e.then(n.bind(void 0,t),i.bind(void 0,t))}),l.promise},r.when=function(e,t,n,i){var o,s;return e&&"function"==typeof e.then?o=e:(s=new r,s.resolve(e),o=s.promise),o.then(t,n,i)},r}),n("orion/commandRegistry",["orion/commands","orion/keyBinding","orion/explorers/navigationUtils","orion/bidiUtils","orion/PageUtil","orion/uiUtils","orion/webui/littlelib","orion/webui/dropdown","orion/webui/tooltip","text!orion/webui/submenutriggerbutton.html","orion/metrics","orion/Deferred","orion/EventTarget"],function(e,t,n,i,r,o,s,a,l,d,c,h,u){function f(e){this._commandList={},this._contributionsByScopeId={},this._activeBindings={},this._urlBindings={},this._pendingBindings={},this._parameterCollector=null,this._init(e||{})}function p(e,t){this.token=e,this.parameterName=t}function g(e,t,n){this.event=e,this.handler=t,this.capture=n||!1}function v(e,t,n,i,r,o,s){this.name=e,this.type=t,this.label=n,this.value=i,this.lines=r||1,this.validator=s,this.eventListeners=Array.isArray(o)?o:o?[o]:[]}function m(e,t,n){this._storeParameters(e),this._hasOptionalParameters=t&&t.hasOptionalParameters,this._options=t,this.optionsRequested=!1,this.getParameters=n,this.clientCollect=t&&t.clientCollect,this.getParameterElement=t&&t.getParameterElement,this.getSubmitName=t&&t.getSubmitName,this.getCancelName=t&&t.getCancelName,this.message=t&&t.message}return f.prototype={_init:function(t){this._selectionService=t.selection;var n=this;e.setKeyBindingProvider(function(){return n._activeBindings}),u.attach(f.prototype),this.addEventListener("bindingChanged",function(e){this._handleBindingChanges(e)}.bind(this)),this.addEventListener=function(e,t){this._bindingOverrides&&"bindingChanged"===e&&this._updateBindingOverrides(t),f.prototype.addEventListener.call(this,e,t)}},processURL:function(e){for(var t in this._urlBindings)if(this._urlBindings[t]&&this._urlBindings[t].urlBinding&&this._urlBindings[t].command){var n=this._urlBindings[t].urlBinding.match(e);if(n){var i=this._urlBindings[t],r=i.command,o=i.invocation;if(o&&o.parameters&&r.callback){o.parameters.setValue(n.parameterName,n.parameterValue);var s=this;return void window.setTimeout(function(){s._invoke(o)},0)}}}},findCommand:function(e){return this._commandList[e]},runCommand:function(t,n,i,r,o,s){var a=this;if(n){var l=this._commandList[t],d=l&&(l.visibleWhen?l.visibleWhen(n):!0);if(d&&l.callback){var c=new e.CommandInvocation(i,n,o,l,a);return c.domParent=s,a._invoke(c,r)}}else{var h=this._urlBindings[t];if(h&&h.command&&h.command.callback)return a._invoke(h.invocation,r)}},getSelectionService:function(){return this._selectionService},setParameterCollector:function(e){this._parameterCollector=e},openParameterCollector:function(e,t,n){this._parameterCollector&&(this._parameterCollector.close(),this._parameterCollector.open(e,t,n))},confirm:function(e,t,n,i,r,o){this._popupDialog(r,"CONFIRM",e,t,[{label:n,callback:o,type:"ok"},{label:i,callback:null,type:"cancel"}])},alert:function(e,t,n,i){this._popupDialog(!1,"ALERT",e,t,[{label:n,callback:i,type:"ok"}])},_popupDialog:function(e,t,n,r,o,a,d){var c;if(this._parameterCollector&&!e){var h=this,u=function(){h._parameterCollector.close()},f=function(e,n){var l=document.createElement("span");if(l.classList.add("parameterPrompt"),l.textContent=r,e.appendChild(l),"PROMPT"===t){var d=document.createElement("input");d.setAttribute("value",a),d.classList.add("parameterInput"),i.initInputField(d),e.appendChild(d),d.addEventListener("keydown",function(e){s.KEY.ENTER===e.keyCode?(o[0].callback&&o[0].callback(d.value),u()):s.KEY.ESCAPE===e.keyCode&&(o[1].callback&&o[1].callback(""),u())},!1)}var h=Object.keys(o).map(function(e){var i=document.createElement("button");return i.addEventListener("click",function(){c="ok"===o[e].type?"PROMPT"===t?d.value:!0:"cancel"===o[e].type?"PROMPT"===t?"":!1:!0,o[e].callback&&o[e].callback(c),u()},!1),n.appendChild(i),i.appendChild(document.createTextNode(o[e].label)),i.className="dismissButton",i});return"PROMPT"===t?d:h[0]};if(this._parameterCollector.close(),!n)var p=this._parameterCollector.open(n,f,function(){});if(!p){var g=new l.Tooltip({node:n,afterHiding:function(){this.destroy()},trigger:"click",position:d?d:"PROMPT"!==t?["below","right","above","left"]:["right","above","below","left"]}),v=g.contentContainer();v.classList.add("parameterPopup");var m=window.document.activeElement;u=function(){m&&m.focus(),g.destroy()};var _=document.createElement("div");_.classList.add("parameterMessage"),v.appendChild(_);var y=document.createElement("div");v.appendChild(y),y.classList.add("layoutRight"),y.classList.add("parametersDismiss");var C=f(_,y);g.show(),C&&window.setTimeout(function(){C.focus(),C.select&&C.select()},0)}}else c=window.confirm(r),o[0].callback(c)},prompt:function(e,t,n,i,r,o,s,a){var l=null;"below"===a?l=["below","right","above","left"]:"right"===a&&(l=["right","above","below","left"]),this._popupDialog(o,"PROMPT",e,t,[{label:n,callback:s,type:"ok"},{label:i,callback:null,type:"cancel"}],r,l)},confirmWithButtons:function(e,t,n){this._popupDialog(!1,"CONFIRM",e,t,n)},closeParameterCollector:function(){this._parameterCollector&&this._parameterCollector.close()},collectsParameters:function(){return this._parameterCollector},_invoke:function(e,t){return this._collectAndInvoke(e.makeCopy(t),!1)},_collectAndInvoke:function(e,t,n){if(e){if(!(this._parameterCollector&&e.parameters&&e.parameters.hasParameters()&&(t||e.parameters.shouldCollectParameters())))return c.logEvent("command","invoke",e.command.id),e.command.callback.call(e.handler||window,e);var i=!1;if(e.parameters.updateParameters(e),e.parameters.shouldCollectParameters()&&(i=this._parameterCollector.collectParameters(e,n),!i)){var r=new l.Tooltip({node:e.domNode||e.domParent,afterHiding:function(){this.destroy(),e.domParent&&e.domParent.classList.remove("parameterPopupOpen")},trigger:"click",position:["below","right","above","left"]}),o=r.contentContainer();o.classList.add("parameterPopup");var s=window.document.activeElement,a=this._parameterCollector.getFillFunction(e,function(){s&&s.focus(),r.destroy(),e.domParent&&e.domParent.classList.remove("parameterPopupOpen")},n)(o);r.show(),e.domParent&&e.domParent.classList.add("parameterPopupOpen"),a&&window.setTimeout(function(){a.focus(),a.select&&a.select()},0),i=!0}if(!i)return c.logEvent("command","invoke",e.command.id),e.command.callback.call(e.handler||window,e)}else window.console.log("Client attempted to invoke command without an available (rendered) command invocation")},collectParameters:function(e,t){this._collectAndInvoke(e,!0,t)},showKeyBindings:function(t){function n(t){return function(){e.executeBinding(t)}}var i,r={},o=[];for(var s in this._activeBindings)i=this._activeBindings[s],i&&i.keyBinding&&i.command&&(i.command.name||i.command.tooltip)&&o.push(i);o.sort(function(e,t){var n=e.command.name||e.command.tooltip,i=t.command.name||t.command.tooltip;return n.localeCompare(i)});for(var a=0;a<o.length;a++)i=o[a],i.keyBinding.scopeName?(r[i.keyBinding.scopeName]||(r[i.keyBinding.scopeName]=[]),r[i.keyBinding.scopeName].push(i)):t.createItem(i.keyBinding,i.command.name||i.command.tooltip,i.command.id,n(i));for(var l in r)r[l].length&&r[l].length>0&&(t.createHeader(l),r[l].forEach(function(e){t.createItem(e.keyBinding,e.command.name||e.command.tooltip,e.command.id,n(e))}))},_handleBindingChanges:function(t){var n=this.findCommand(t.id);if(n){var i=this._activeBindings[t.id];i?i.keyBinding=t.newBinding:this._addBinding(n,"key",t.newBinding)}if(this._renderedCommands&&this._renderedCommands[t.id])for(var r=this._renderedCommands[t.id],s=Object.keys(r),a=0;a<s.length;a++){var l=r[s[a]],d=o.getUserKeyString(t.newBinding),c=e.createCommandMenuItem(l.domParent,l.command,l,null,l.onClick,d);l.domNode.parentNode.replaceChild(c,l.domNode),l.domNode=c}},createBindingOverride:function(e,t,n){if(this._bindingOverrides||(this._bindingOverrides=[]),this._bindingOverrides.push({id:e,newBinding:t,prevBinding:n}),this._prefService){var i=JSON.stringify(this._bindingOverrides);this._prefService.put("/KeyBindings",{overridesJSON:i})}var r={type:"bindingChanged",id:e,newBinding:t,prevBinding:n};this.dispatchEvent(r)},_registerRenderedCommand:function(e,t,n){this._renderedCommands||(this._renderedCommands={});var i=this._renderedCommands[e];i||(i=this._renderedCommands[e]={}),i[t]=n},_getBindingOverrides:function(){return this._prefService.get("/KeyBindings").then(function(e){var n=[],i=e.overridesJSON;i&&(n="string"==typeof i?JSON.parse(i):i);for(var r=0;r<n.length;r++){var o=n[r];if(o.newBinding){var s=o.newBinding;n[r].newBinding=new t.KeyStroke(s.keyCode,s.mod1,s.mod2,s.mod3,s.mod4,s.type)}if(o.prevBinding){var a=o.prevBinding;n[r].prevBinding=new t.KeyStroke(a.keyCode,a.mod1,a.mod2,a.mod3,a.mod4,a.type)}}return(new h).resolve(n)}.bind(this))},getBindingOverride:function(e){if(!this._bindingOverrides)return null;for(var t=this._bindingOverrides.length-1;t>=0;t--){var n=this._bindingOverrides[t];if(n.id===e)return n.newBinding}return null},addCommand:function(e){this._commandList[e.id]=e;var t=this._pendingBindings[e.id];if(t){var n=this;t.forEach(function(t){n._addBinding(e,t.type,t.binding,t.bindingOnly)}),delete this._pendingBindings[e.id]}},addCommandGroup:function(e,t,n,i,r,o,s,a,l,d,c){this._contributionsByScopeId[e]||(this._contributionsByScopeId[e]={});var h=this._contributionsByScopeId[e];r&&(h=this._createEntryForPath(h,r)),h[t]?(i&&(h[t].title=i),n&&(h[t].position=n),s&&(h[t].imageClass=s),a&&(h[t].tooltip=a),l&&(h[t].selectionClass=l),c&&(h[t].extraClass=c),d===!0?h[t].pretendDefaultActionId=!0:h[t].defaultActionId=d,h[t].emptyGroupMessage=o):(h[t]={title:i,position:n,emptyGroupMessage:o,imageClass:s,tooltip:a,selectionClass:l,defaultActionId:d===!0?null:d,pretendDefaultActionId:d===!0,children:{},extraClasses:c},h.sortedContributions=null)},_createEntryForPath:function(e,t){if(t){var n=t.split("/");n.forEach(function(t){t.length>1&&(e[t]||(e[t]={position:0,children:{}},e.sortedContributions=null),e=e[t].children)})}return e},registerSelectionService:function(e,t){this._contributionsByScopeId[e]||(this._contributionsByScopeId[e]={}),this._contributionsByScopeId[e].localSelectionService=t},setServiceRegistry:function(e){this._serviceRegistry=e,this._prefService=e.getService("orion.core.preference"),this._prefService&&(this._getBindingOverrides().then(function(e){this._bindingOverrides=e,this._updateBindingOverrides()}.bind(this)),this._prefService.addEventListener("changed",function(e){"/KeyBindings"===e.namespace&&this._getBindingOverrides().then(function(e){if(e.length>this._bindingOverrides.length)for(var t=this._bindingOverrides.length;t<e.length;t++){var n=e[t],i={type:"bindingChanged",id:n.id,newBinding:n.newBinding,prevBinding:n.prevBinding};this.dispatchEvent(i)}this._bindingOverrides=e}.bind(this))}.bind(this)))},_updateBindingOverrides:function(e){for(var t=0;t<this._bindingOverrides.length;t++){var n=this._bindingOverrides[t],i={type:"bindingChanged",id:n.id,newBinding:n.newBinding,prevBinding:n.prevBinding};e?e(i):this.dispatchEvent(i)}},registerCommandContribution:function(e,t,n,i,r,o,s,a){this._contributionsByScopeId[e]||(this._contributionsByScopeId[e]={});var l=this._contributionsByScopeId[e];i&&(l=this._createEntryForPath(l,i)),l[t]={position:n,handler:a};var d;if(this._bindingOverrides){var c=this.getBindingOverride(t,o);c&&(o=c)}o&&(d=this._commandList[t],d?this._addBinding(d,"key",o,r):this._addPendingBinding(t,"key",o,r)),s&&(d=this._commandList[t],d?this._addBinding(d,"url",s,r):this._addPendingBinding(t,"url",s,r)),l.sortedContributions=null},unregisterCommandContribution:function(e,t,n){if(this._contributionsByScopeId[e]){delete this._commandList[t],delete this._activeBindings[t],delete this._urlBindings[t],delete this._pendingBindings[t];var i=this._contributionsByScopeId[e];if(n){var r=n.split("/");r.forEach(function(e){if(e.length>1){if(!i[e])return;i=i[e].children }})}delete i[t],i.sortedContributions=null}},_addBinding:function(e,t,n,i){if(!e.id)throw new Error("No command id: "+e);"key"===t?this._activeBindings[e.id]={command:e,keyBinding:n,bindingOnly:i}:"url"===t&&(this._urlBindings[e.id]={command:e,urlBinding:n,bindingOnly:i})},_addPendingBinding:function(e,t,n,i){this._pendingBindings[e]=this._pendingBindings[e]||[],this._pendingBindings[e].push({type:t,binding:n,bindingOnly:i})},_checkForTrailingSeparator:function(e,t,n){var i;if(("tool"===t||"button"===t)&&(i=e.childNodes.length>0?e.childNodes[e.childNodes.length-1]:null,i&&i.classList.contains("commandSeparator")))return n?(e.removeChild(i),!1):!0;if("menu"===t){var r=s.$$array("li > *",e);if(r.length>0&&r[r.length-1].classList.contains("dropdownSeparator"))return i=r[r.length-1],n?(i.parentNode.parentNode.removeChild(i.parentNode),!1):!0}return!1},renderCommands:function(e,t,n,i,r,o,a){if("string"!=typeof e)throw"a scope id for rendering must be specified";if(t=s.node(t),!t)throw"no parent";var l=this._contributionsByScopeId[e];if(!n&&l){var d=l.localSelectionService||this._selectionService,c=this;return void(d&&d.getSelections(function(n){c.renderCommands(e,t,n,i,r,o)}))}l&&(this._render(e,l,t,n,i,r||"button",o,a),this._checkForTrailingSeparator(t,r,!0))},destroy:function(e){if(e=s.node(e),!e)throw"no parent";for(;e.hasChildNodes();){var t=e.firstChild;t.commandTooltip&&t.commandTooltip.destroy(),t.emptyGroupTooltip&&t.emptyGroupTooltip.destroy(),this.destroy(t),e.removeChild(t)}},_render:function(t,i,r,s,a,d,c,h){var u=i.sortedContributions;if(!u){u=[];var f=!1;for(var p in i)if(Object.prototype.hasOwnProperty.call(i,p)){var g=i[p];g&&"number"==typeof g.position&&(g.id=p,u.push(g),f=!0)}f&&(u.sort(function(e,t){return e.position-t.position}),i.sortedContributions=u)}var v=0,m=this;u.forEach(function(i){function u(e){e&&e.parentNode&&e.parentNode.removeChild(e)}var f,p;if(i.imageClass||(i.imageClass=null),i.children&&Object.getOwnPropertyNames(i.children).length>0){var g,_=i.children;if("tool"===d||"button"===d||"menubar"===d)if(i.title){var y;if(i.defaultActionId){i.pretendDefaultActionId=i.defaultActionId===!0;var C=m._commandList[i.defaultActionId];C&&(C.visibleWhen?C.visibleWhen(s):!0)?(y=new e.CommandInvocation(a,s,c,C,m),y.domParent=r):i.pretendDefaultActionId=!0}g=m._createDropdownMenu(r,i.title,null,null,i.imageClass,i.tooltip,i.selectionClass,null,y,i.pretendDefaultActionId,i.extraClasses),h&&n.generateNavGrid(h,g.menuButton),g&&("menubar"===d&&(g.menuButton.tabIndex=1===r.childElementCount?"0":"-1",g.menuButton.addEventListener("focus",function(e){var t=e.currentTarget,n=t.parentNode.parentNode.dropdown;n._selectItem(t)},!0)),m._render(t,i.children,g.menu,s,a,"menu",c,h),m._checkForTrailingSeparator(g.menu,"menu",!0),0===g.menu.childNodes.length?i.emptyGroupMessage?g.menuButton.emptyGroupTooltip||(g.menuButton.emptyGroupTooltip=new l.Tooltip({node:g.menuButton,text:i.emptyGroupMessage,trigger:"click",position:["below","right","above","left"]})):(h&&n.removeNavGrid(h,g.menuButton),u(g.menu),u(g.menuButton),u(g.destroyButton)):g.menuButton.style.visibility="visible")}else{var w;if(r.childNodes.length>0&&!m._checkForTrailingSeparator(r,d)&&(w=m.generateSeparatorImage(r)),m._render(t,_,r,s,a,d,c,h),r.childNodes.length>0){var x=r.childNodes[r.childNodes.length-1];x!==w&&(w=m.generateSeparatorImage(r))}}else if(i.title){var b=m._createDropdownMenu(r,i.title,!0,null,null,i.imageClass);b&&(m._render(t,_,b.menu,s,a,"menu",c,h),m._checkForTrailingSeparator(b.menu,"menu",!0),0===b.menu.childNodes.length&&b.destroyButton&&r.removeChild(b.destroyButton))}else r.childNodes.length>0&&m._generateMenuSeparator(r),m._render(t,_,r,s,a,d,c,h),r.childNodes.length>0&&m._generateMenuSeparator(r)}else{var S=m._commandList[i.id],T=S?!0:!1,E=null,A=null;if(S){p=new e.CommandInvocation(i.handler||a,s,c,S,m),p.domParent=r;var L=!1;try{L=T&&(S.visibleWhen?S.visibleWhen(s,p):!0)}catch(k){throw console.log(k),k}m._activeBindings[S.id]&&m._activeBindings[S.id].keyBinding&&(E=m._activeBindings[S.id],E.invocation=L?p:null,E.bindingOnly&&(T=!1)),m._urlBindings[S.id]&&m._urlBindings[S.id].urlBinding&&(A=m._urlBindings[S.id],A.invocation=L?p:null,A.bindingOnly&&(T=!1)),T=T&&L}if(T)if(S.choiceCallback){var M,O;"tool"===d||"button"===d?(M=r,O=!1,"ul"===r.nodeName.toLowerCase()&&(M=document.createElement("li"),M.setAttribute("role","none"),r.appendChild(M))):(M=r,O=!0);var D=function(e){S.populateChoicesMenu(e,s,a,c,m)};m._createDropdownMenu(M,S.name,O,D.bind(S),S.imageClass,S.tooltip||S.title,S.selectionClass,S.positioningNode)}else{p.handler=p.handler||this,p.domParent=r;var N,I=function(){m._invoke(p)};if("menu"===d){var R=null;E&&E.keyBinding&&(R=o.getUserKeyString(E.keyBinding)),N=e.createCommandMenuItem(r,S,p,null,I,R),p.onClick=I,m._registerRenderedCommand(S.id,t,p)}else if("quickfix"===d){f=d+S.id+v,r.classList.add("quickFixList");var B="quickfixDetails",P=r.childNodes.item(B);if("ignore.in.file.fix"===S.id||"css.ignore.on-line.fix"===S.id)P||(P=document.createElement("div"),P.id=B,r.appendChild(P)),N=e.createQuickfixItem(P,S,p,I,m._prefService);else{var F=document.createElement("div");P?r.insertBefore(F,P):r.appendChild(F),N=e.createQuickfixItem(F,S,p,I,m._prefService)}}else f=d+S.id+v,N=e.createCommandItem(r,S,p,f,null,"tool"===d,I);n.generateNavGrid(h,N,null,null,!0),p.domNode=N,v++}}})},_createDropdownMenu:function(t,n,i,r,o,c,h,u,f,p,g){if(t=s.node(t),!t||!s.contains(document.body,t))return null;var v,m,_,y,C=t;if(i){var w=document.createRange();w.selectNode(t);var x=w.createContextualFragment(d);s.processTextNodes(x,{ButtonText:n}),t.appendChild(x),y=t.lastChild,m=y.lastChild,v=m.previousSibling,v.dropdown=new a.Dropdown({dropdown:m,name:n,populate:r,parentDropdown:t.dropdown}),m.dropdown=v.dropdown}else{"ul"===t.nodeName.toLowerCase()&&(C=document.createElement("li"),C.setAttribute("role","none"),t.appendChild(C),y=C);var b=null;o&&(b="dropdownButtonWithIcon",c=c||n),c=o?c||n:c;var S=e.createDropdownMenu(C,n,r,b,o,!1,h,u,f||p,g);if(_=S.dropdownArrow,v=S.menuButton,_){f&&(f.domNode=S.menuButton);var T=this;v.onclick=function(e){var t=s.bounds(_);(e.clientX>=t.left||p===!0)&&S.dropdown?S.dropdown.toggle(e):T._invoke(f)},S.dropdown&&(v.onkeydown=function(e){s.KEY.DOWN===e.keyCode&&(S.dropdown.toggle(e),s.stop(e))})}m=S.menu;var E,A=f&&f.command&&(f.command.tooltip||f.command.name);E=A?f.command.tooltip||f.command.name:c,E&&(v.commandTooltip=new l.Tooltip({node:v,text:E,position:["above","below","right","left"]}))}return{menuButton:v,menu:m,dropdown:v.dropdown,destroyButton:y,dropdownArrow:_}},_generateMenuSeparator:function(e){if(!this._checkForTrailingSeparator(e,"menu")){var t=document.createElement("li");t.classList.add("dropdownSeparator"),t.setAttribute("role","none");var n=document.createElement("span");n.classList.add("dropdownSeparator"),n.setAttribute("role","separator"),t.appendChild(n),e.appendChild(t)}},generateSeparatorImage:function(e){var t;return"ul"===e.nodeName.toLowerCase()?(t=document.createElement("li"),t.setAttribute("role","none"),e.appendChild(t)):(t=document.createElement("span"),e.appendChild(t)),t.classList.add("core-sprite-sep"),t.classList.add("imageSprite"),t.classList.add("commandSeparator"),t}},f.prototype.constructor=f,p.prototype={match:function(e){var t=r.matchResourceParameters(e);return"undefined"!=typeof t[this.token]?(this.parameterValue=t[this.token],this):null}},p.prototype.constructor=p,g.prototype.constructor=g,v.prototype={optionsRequested:function(){return this.optionsRequested}},v.prototype.constructor=v,m.prototype={_storeParameters:function(e){if(this.parameterTable=null,e){var t=this.parameterTable={};e.forEach(function(e){t[e.name]=e})}},updateParameters:function(e){"function"==typeof this.getParameters&&this._storeParameters(this.getParameters(e))},hasParameters:function(){return null!==this.parameterTable},shouldCollectParameters:function(){return!this.clientCollect&&this.hasParameters()},parameterNamed:function(e){return this.parameterTable[e]},valueFor:function(e){var t=this.parameterTable[e];return t?t.value:null},setValue:function(e,t){var n=this.parameterTable[e];n&&(n.value=t)},forEach:function(e){for(var t in this.parameterTable)this.parameterTable[t].type&&this.parameterTable[t].name&&e(this.parameterTable[t])},validate:function(e,t){var n=this.parameterTable[e];return n&&n.validator?n.validator(t):!0},makeCopy:function(){var e=[];this.forEach(function(t){var n=new v(t.name,t.type,t.label,t.value,t.lines,t.eventListeners,t.validator);e.push(n)});var t=new m(e,this._options,this.getParameters);return t.clientCollect=this.clientCollect,t.message=this.message,t},hasOptionalParameters:function(){return this._hasOptionalParameters}},m.prototype.constructor=m,{CommandRegistry:f,URLBinding:p,ParametersDescription:m,CommandParameter:v,CommandEventListener:g}}),n("orion/keyAssist",["i18n!orion/nls/messages","orion/webui/littlelib","orion/keyBinding","orion/commands","orion/metrics","orion/uiUtils","orion/util"],function(e,t,n,i,r,o,s){function a(e){this.commandRegistry=e.commandRegistry,this.create(),this._filterString="",this._providers=[]}function l(t,r,o){var a=new i.Command({name:e["Show Keys"],tooltip:e.ShowAllKeyBindings,id:"orion.keyAssist",callback:function(){return t.isVisible()?t.hide():t.show(),!0}});return o.addCommand(a),o.registerCommandContribution(r,"orion.keyAssist",100,null,!0,new n.KeyBinding(191,!1,!0,!s.isMac,s.isMac)),a}return a.prototype={addProvider:function(e){-1===this._providers.indexOf(e)&&this._providers.push(e)},create:function(){var n=this._keyAssistDiv=document.createElement("div");n.id="keyAssist",n.style.display="none",n.classList.add("keyAssistFloat"),n.setAttribute("role","menu");var i=this._keyAssistInput=document.createElement("input");i.classList.add("keyAssistInput"),i.type="text",i.setAttribute("aria-label","Filter bindings:"),i.placeholder=e["Filter bindings"],i.setAttribute("aria-autocomplete","list"),n.appendChild(i);var r=this._keyAssistContents=document.createElement("div");r.classList.add("keyAssistContents"),(s.isIOS||s.isAndroid)&&(r.style.overflowY="auto"),n.appendChild(r);var o=this._keyAssistTable=document.createElement("table");o.tabIndex=0,o.classList.add("keyAssistList"),r.appendChild(o),document.body.appendChild(n),i.addEventListener("keydown",function(e){this._keyDown(e)}.bind(this)),o.addEventListener("keydown",function(e){this._keyDown(e)}.bind(this)),i.addEventListener("input",function(){this.filterChanged()}.bind(this)),r.addEventListener(s.isFirefox?"DOMMouseScroll":"mousewheel",function(e){this._scrollWheel(e)}.bind(this)),document.addEventListener("keydown",function(e){e.keyCode===t.KEY.ESCAPE&&this.hide()}.bind(this)),t.addAutoDismiss([n],function(){this.hide()}.bind(this)),this.commandRegistry&&this.commandRegistry.addEventListener("bindingChanged",function(e){this.handleBindingChange(e)}.bind(this))},handleBindingChange:function(e){if(this.isVisible())for(var t,n=this._keyAssistTable.querySelectorAll(".keyAssistItem"),i=0;i<n.length;i++){var t=n[i];if(t.cmdID===e.id&&JSON.stringify(e.prevBinding)===JSON.stringify(t.curBinding)){var r=e.newBinding?o.getUserKeyString(e.newBinding):"---";t.childNodes[2].firstChild.textContent=r,t.curBinding=e.newBinding}}},createContents:function(){var n=this._keyAssistTable;t.empty(n),this._selectedIndex=-1,this._selectedRow=null,this._keyAssistContents.scrollTop=0,this._idCount=0;for(var i=0;i<this._providers.length;i++)this._providers[i].showKeyBindings(this);this.createHeader(e.Global),this.commandRegistry.showKeyBindings(this)},createItem:function(n,i,r,s){var a=n?o.getUserKeyString(n):e.NoBinding;if(this._filterString){var l,d=this._filterString.toLowerCase();if(d!==this._filterString?(d=this._filterString,l=function(e){return e}):l=function(e){return e.toLowerCase()},-1===l(i).indexOf(d)&&-1===l(a).indexOf(d)&&-1===l(this._lastHeader).indexOf(d))return}var c=this._keyAssistTable.insertRow(-1);c.id="keyAssist-keyBinding-"+this._idCount++,c.setAttribute("role","menuitem"),c.cmdID=r,c._execute=s,c.curBinding=n,c.classList.add("keyAssistItem"),c.addEventListener("click",function(e){this._selectedRow=c,this.execute(),e.preventDefault()}.bind(this));var h=c.insertCell(-1);h.classList.add("keyAssistSpacer"),h.appendChild(document.createElement("div"));var h=c.insertCell(-1);h.classList.add("keyAssistName"),h.appendChild(document.createTextNode(i)),h=c.insertCell(-1),h.classList.add("keyAssistAccel");var u=document.createElement("span");u.textContent=a,h.appendChild(u),h=c.insertCell(-1),h.classList.add("keyAssistActions");var f=document.createElement("button");f.classList.add("keyAssistEditButton"),f.classList.add("core-sprite-edit"),f.setAttribute("aria-label",e.Edit),f.addEventListener("click",function(e){t.stop(e),this.editBinding(c)}.bind(this)),h.appendChild(f)},editBinding:function(i){var a=function(e){this._keyCode=e.keyCode,this._altDown=e.altKey,this._ctrlDown=s.isMac?e.metaKey:e.ctrlKey,this._shiftDown=e.shiftKey,this._commandDown=s.isMac?e.ctrlKey:e.metaKey;var t=new n.KeyStroke(this._keyCode,this._ctrlDown,this._shiftDown,this._altDown,this._commandDown),i=o.getUserKeyString(t);this.keyAssistKBEdit.value=i}.bind(this),l=function(){this.keyAssistKBEdit.value="",this.bindingField.removeChild(this.keyAssistKBEdit),this.bindingField.firstChild.style.display="block",delete this.keyAssistKBEdit,delete this.bindingField,delete this._keyCode,this._editingABinding=!1}.bind(this);this._editingABinding&&l();for(var d=this._keyAssistTable.querySelectorAll(".keyAssistItem"),c=0;c<d.length;c++)if(d[c]===i){this.selectRow(c,d);break}var h=this.keyAssistKBEdit=document.createElement("input");h.id="keyAssistInput",h.type="text",h.placeholder=e.BindingPrompt,h.classList.add("keyAssistBindingInput"),h.addEventListener("click",function(e){e.stopPropagation()}.bind(this)),h.addEventListener("keydown",function(e){if(e.keyCode===t.KEY.ALT||e.keyCode===t.KEY.SHIFT||e.keyCode===t.KEY.CONTROL||e.keyCode===t.KEY.COMMAND);else if(e.keyCode===t.KEY.ENTER){if(this._keyCode&&this._keyCode){var o=new n.KeyStroke(this._keyCode,this._ctrlDown,this._shiftDown,this._altDown,this._commandDown);this.commandRegistry.createBindingOverride(i.cmdID,o,i.curBinding),r.logEvent("KeyBinding","Changed",i.cmdID,JSON.stringify(o)),l(),this._keyAssistTable.focus()}}else e.keyCode===t.KEY.ESCAPE?(l(),this._keyAssistInput.focus()):a(e);t.stop(e)}.bind(this));var u=this.bindingField=i.childNodes[2];u.firstChild.style.display="none";var f=t.pixelValueOf(u,"padding-left"),p=t.pixelValueOf(u,"padding-right"),g=t.pixelValueOf(u,"border-left"),v=t.pixelValueOf(u,"border-right"),m=t.bounds(u),_=m.width-(f+p+g+v);_=135>_?135:_,h.style.width=_+"px",u.appendChild(h),h.focus(),this._editingABinding=!0},createHeader:function(e){this._lastHeader=e;var t=this._keyAssistTable.insertRow(-1);t.classList.add("keyAssistSection");var n=t.insertCell(-1);n.colSpan=4;var i=document.createElement("h2");i.appendChild(document.createTextNode(e)),n.appendChild(i)},execute:function(){window.setTimeout(function(){this.hide();var e=this._selectedRow;this._selectedRow=null,e&&e._execute&&e._execute()}.bind(this),0)},filterChanged:function(){this._timeout&&window.clearTimeout(this._timeout),this._timeout=window.setTimeout(function(){this._timeout=null;var e=this._keyAssistInput.value;this._filterString!==e&&(this._filterString=e,this.createContents())}.bind(this),100)},hide:function(){if(this.isVisible()){var e=document.activeElement,t=this._keyAssistDiv,n=t===e||0!==(16&t.compareDocumentPosition(e));t.style.display="none",n&&1!==document.compareDocumentPosition(this._previousActiveElement)&&this._previousActiveElement.focus(),this._previousActiveElement=null}},isVisible:function(){return"block"===this._keyAssistDiv.style.display},removeProvider:function(e){var t=this._providers.indexOf(e);-1!==t&&this._providers.splice(t,1)},select:function(e){var t=this._keyAssistTable.querySelectorAll(".keyAssistItem");if(0===t.length)return void(this._selectedIndex=-1);var n=this._selectedIndex;n+=e?1:-1,n%=t.length,0>n&&(n=t.length-1),this.selectRow(n,t)},selectRow:function(e,t){if(-1!==this._selectedIndex&&(n=t[this._selectedIndex],n.classList.remove("selected"),n.childNodes[3].firstChild.classList.remove("keyAssistEditButtonVisible"),this._selectedRow=null),e>=0&&e<t.length){this._selectedIndex=e,this._selectedRow=t[this._selectedIndex];var n=this._selectedRow;n.classList.add("selected"),n.childNodes[3].firstChild.classList.add("keyAssistEditButtonVisible"),this._keyAssistTable.setAttribute("aria-activedescendant",n.id),this._keyAssistTable.focus();var i=n.getBoundingClientRect(),r=this._keyAssistContents,o=r.getBoundingClientRect();n.offsetTop<r.scrollTop?0===this._selectedIndex?r.scrollTop=0:n.scrollIntoView(!0):i.bottom>o.bottom&&n.scrollIntoView(!1)}},show:function(){this.isVisible()||(this._previousActiveElement=document.activeElement,this.createContents(),this._keyAssistContents.style.height=Math.floor(.75*this._keyAssistDiv.parentNode.clientHeight)+"px",this._keyAssistDiv.style.display="block",this._keyAssistInput.value=this._filterString,this._keyAssistInput.focus(),this._keyAssistInput.select(),r.logEvent("KeyBinding","Panel","Opened"))},_keyDown:function(e){if(e.keyCode===t.KEY.DOWN)this.select(!0);else if(e.keyCode===t.KEY.UP)this.select(!1);else if(e.keyCode===t.KEY.ENTER)this.execute();else{if(e.keyCode!==t.KEY.SPACE||!this._selectedRow)return;this._editingABinding||this.editBinding(this._selectedRow)}e.preventDefault()},_scrollWheel:function(e){var t=0;t=s.isIE||s.isOpera?-e.wheelDelta:s.isFirefox?40*e.detail:-e.wheelDeltaY;var n=this._keyAssistContents,i=n.scrollTop;return n.scrollTop+=t,i!==n.scrollTop?(e.preventDefault&&e.preventDefault(),!1):void 0}},{KeyAssistPanel:a,createCommand:l}}),n("orion/navigate/nls/messages",{root:!0}),n("orion/navigate/nls/root/messages",{Navigator:"Navigator","Strings Xtrnalizr":"Strings Xtrnalizr","Externalize strings":"Externalize strings from JavaScript files in this folder.",NotSupportFileSystem:"${0} is not supported in this file system",SrcNotSupportBinRead:"Source file service does not support binary read",TargetNotSupportBinWrite:"Target file service does not support binary write",NoFileSrv:"No matching file service for location: ${0}","Choose a Folder":"Choose a Folder","Copy of ${0}":"Copy of ${0}",EnterName:"Enter a new name for '${0}'",ChooseFolder:"Choose folder...",Rename:"Rename",Refresh:"Refresh",RenameFilesFolders:"Rename the selected files or folders",CompareEach:"Compare with each other","Compare 2 files":"Compare the selected 2 files with each other","Compare with...":"Compare With...",CompareFolders:"Compare the selected folder with a specified folder",Delete:"Delete","Unknown item":"Unknown item","delete item msg":"Are you sure you want to delete these ${0} items?",DeleteTrg:"Are you sure you want to delete '${0}'?",Zip:"Zip",ZipDL:"Create a zip file of the folder contents and download it","New File":"File","Create a new file":"Create a new file",FailedToCreateProject:"Failed to create project: ${0}",FailedToCreateFile:"Failed to create file: ${0}",CopyFailed:"Copy operation failed",MoveFailed:"Move operation failed","Name:":"Name:","New Folder":"Folder","Folder name:":"Folder name:","Create a new folder":"Create a new folder","Creating folder":"Creating folder",Folder:"Folder","Create an empty folder":"Create an empty folder",CreateEmptyMsg:"Create an empty folder on the Orion server. You can import, upload, or create content in the editor.","Sample HTML5 Site":"Sample HTML5 Site","Generate a sample":"Generate a sample",'Generate an HTML5 "Hello World" website, including JavaScript, HTML, and CSS files.':'Generate an HTML5 "Hello World" website, including JavaScript, HTML, and CSS files.',"Creating a folder for ${0}":"Creating a folder for ${0}","SFTP Import":"SFTP Import","Import content from SFTP":"Import content from SFTP","Imported Content":"Imported Content","Upload a Zip":"Upload a Zip","Upload content from a local zip file":"Upload content from a local zip file","Uploaded Content":"Uploaded Content","Clone Git Repository":"Clone Git Repository","Clone a git repository":"Clone a git repository",LinkContent:"Link to existing content on the server",CreateLinkedFolder:"Create a folder that links to an existing folder on the server.","Server path:":"Server path:",NameLocationNotClear:"The name and server location were not specified.","Go Up":"Go Up",GoUpToParent:"Move up to the parent folder","Go Into":"Go Into",GoSelectedFolder:"Move into the selected folder","File or zip archive":"File or Zip Archive",ImportLcFile:"Import a file or zip archive from your local file system","SFTP from...":"SFTP",CpyFrmSftp:"Copy files and folders from a specified SFTP connection","Importing from ${0}":"Importing from ${0}","SFTP to...":"SFTP",CpyToSftp:"Copy files and folders to a specified SFTP location",Exporting:"Exporting to ${0}","Pasting ${0}":"Pasting ${0}","Copy to":"Copy to","Move to":"Move to","Copying ${0}":"Copying ${0}","Moving ${0}":"Moving ${0}","Renaming ${0}":"Renaming ${0}","Deleting ${0}":"Deleting ${0}","Creating ${0}":"Creating ${0}","Linking to ${0}":"Linking to ${0}",MvToLocation:"Move files and folders to a new location",Cut:"Cut",Copy:"Copy","Fetching children of ":"Fetching children of ",Paste:"Paste","Open With":"Open With","Loading ":"Loading ",New:"New",File:"File",Actions:"Actions","Orion Content":"Orion Content","File System":"File System",Root:"Root","Create new content":"Create new content","Import from HTTP...":"HTTP","File URL:":"File URL:",ImportURL:"Import a file from a URL and optionally unzip it","Unzip *.zip files:":"Unzip *.zip files:","Extracted from:":"Extracted from:",FolderDropNotSupported:"Did not drop ${0}. Folder drop is not supported in this browser.",CreateFolderErr:"You cannot copy files directly into the workspace. Create a folder first.","Unzip ${0}?":"Unzip ${0}?","Upload progress: ":"Upload progress: ","Uploading ":"Uploading ","Cancel upload":"Cancel upload",UploadingFileErr:"Uploading the following file failed: ","Enter project name:":"Enter project name:","Create new project":"Create new project","Creating project ${0}":"Creating project ${0}",NoFile:"Use the ${0} menu to create new files and folders. Click a file to start coding.",Download:"Download",Download_tooltips:"Download the file contents as the displayed name","Downloading...":"Reading file contents...","Download not supported":"Contents download is not supported in this browser.",gettingContentFrom:"Getting content from ",confirmLaunchDelete:'Delete Launch Configuration "${0}" ?',deletingLaunchConfiguration:"Deleting launch configuration...",deployTo:"Deploy to ",deployItem:'Deploy "${0}"',deploy:"Deploy",connect:"Connect",fetchContent:"Fetch content",fetchContentOf:"Fetch content of ",disconnectFromProject:"Disconnect from project",doNotTreatThisFolder:"Do not treat this folder as a part of the project",checkStatus:"Check status",checkApplicationStatus:"Check application status",checkApplicationState:"Check application state",stop:"Stop",start:"Start",stopApplication:"Stop the App",startApplication:"Start the application",manage:"Manage",manageThisApplicationOnRemote:"Manage this application on remote server",deleteLaunchConfiguration:"Delete this launch configuration",editLaunchConfiguration:"Edit this launch configuration",deployThisApplication:"Deploy the App from the Workspace",associatedFolder:"Associated Folder",associateAFolderFromThe:"Associate a folder from the workspace with this project.",convertToProject:"Convert to project",convertThisFolderIntoA:"Convert this folder into a project",thisFolderIsAProject:"This folder is a project already.",basic:"Basic","createAnEmptyProject.":"Create an empty project.",sFTP:"SFTP",createAProjectFromAn:"Create a project from an SFTP site.",readMeCommandName:"Readme File",readMeCommandTooltip:"Create a README.md file in this project",zipArchiveCommandName:"Zip Archive",zipArchiveCommandTooltip:"Create a project from a local zip archive.","Url:":"Url:",notZip:"The following files are not zip files: ${0}. Would you like to continue the import?",notZipMultiple:"There are multiple non-zip files being uploaded. Would you like to continue the import?",Cancel:"Cancel",Ok:"Ok",missingCredentials:"Enter the ${0} authentication credentials associated with ${1} to check its status.",deploying:"deploying",starting:"restarting",stopping:"stopping",checkingStateShortMessage:"checking status"}),n("orion/fileClient",["i18n!orion/navigate/nls/messages","orion/Deferred","orion/i18nUtil","orion/EventTarget"],function(e,t,n,i){function r(t,i,r){if(!t[i])throw new Error(n.formatMessage(e.NotSupportFileSystem,i));return t[i].apply(t,r)}function o(n,i,s,a){if(!n.readBlob)throw new Error(e.SrcNotSupportBinRead);if(!s.writeBlob)throw new Error(e.TargetNotSupportBinWrite);if("/"!==i[i.length-1])return r(n,"readBlob",[i]).then(function(e){return r(s,"writeBlob",[a,e])});var l=a.substring(0,a.length-1),d=decodeURIComponent(l.substring(l.lastIndexOf("/")+1)),c=l.substring(0,l.lastIndexOf("/")+1);return r(s,"createFolder",[c,d]).then(function(){},function(){}).then(function(){return r(n,"fetchChildren",[i]).then(function(e){for(var i=[],r=0;r<e.length;++r){var l=e[r].Location,d=l;e[r].Directory&&(d=l.substring(0,l.length-1));var c=decodeURIComponent(d.substring(d.lastIndexOf("/")+1)),h=a+encodeURIComponent(c);e[r].Directory&&(h+="/"),i[r]=o(n,l,s,h)}return t.all(i)})})}function s(r,o){function s(n){var i=new t;return i.reject(e["No Matching FileService for location:"]+n),i}function a(){if(!d){l=[],d=[],c=[];var e=r.getServiceReferences("orion.core.file"),t=e;if(o){t=[];for(var n=0;n<e.length;++n)o(e[n])&&t.push(e[n])}t.sort(function(e,t){var n=e.getProperty("ranking")||0,i=t.getProperty("ranking")||0;return n-i});for(var i=0;i<t.length;++i){h[i]={Directory:!0,Length:0,LocalTimeStamp:0,Location:t[i].getProperty("top"),ChildrenLocation:t[i].getProperty("top"),Name:t[i].getProperty("Name")||t[i].getProperty("NameKey")};var s=t[i].getProperty("top"),a=t[i].getProperty("pattern")||(s?s.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"):"");Array.isArray(a)||(a=[a]);for(var u=[],f=0;f<a.length;f++){var p=a[f];"^"!==p[0]&&(p="^"+p),u.push(new RegExp(p))}l[i]=u,d[i]=r.getService(t[i]),c[i]=t[i].getProperty("Name")||t[i].getProperty("NameKey")}}}var l,d,c;i.attach(this);var h=[],u={fetchChildren:function(){var e=new t;return e.resolve(h),e},createWorkspace:function(){var n=new t;return n.reject(e["no file service"]),n},loadWorkspaces:function(){var n=new t;return n.reject(e["no file service"]),n},loadWorkspace:function(){var n=new t;return window.setTimeout(function(){n.resolve({Directory:!0,Length:0,LocalTimeStamp:0,Name:e["File Servers"],Location:"/",Children:h,ChildrenLocation:"/"})},100),n},read:function(e){return"/"===e?this.loadWorkspace(e):s(e)},getProject:s,search:s,createProject:s,createFolder:s,createFile:s,deleteFile:s,moveFile:s,copyFile:s,write:s};this._getServiceIndex=function(t){if(a(),"/"===t)return-1;if(!t||t.length&&0===t.length)return d[0]?0:-1;for(var i=0;i<l.length;++i)for(var r=0;r<l[i].length;r++)if(l[i][r].test(t))return i;throw new Error(n.formatMessage(e.NoFileSrv,t))},this._getService=function(e){var t=this._getServiceIndex(e);return-1===t?u:d[t]},this._getServiceName=function(e){var t=this._getServiceIndex(e);return-1===t?u.Name:c[t]},this._getServiceRootURL=function(e){var t=this._getServiceIndex(e);return-1===t?u.Location:h[t].Location},this._frozenEvent={type:"Changed"},this._eventFrozenMode=!1,r.registerService("orion.core.file.client",this)}return s.prototype={freezeChangeEvents:function(){this._frozenEvent={type:"Changed"},this._eventFrozenMode=!0},thawChangeEvents:function(){this._eventFrozenMode=!1,this.dispatchEvent(this._frozenEvent)},isEventFrozen:function(){return this._eventFrozenMode},getService:function(e){return this._getService(e)},fileServiceName:function(e){return this._getServiceName(e)},fileServiceRootURL:function(e){return this._getServiceRootURL(e)},fetchChildren:function(e){return r(this._getService(e),"fetchChildren",arguments)},createWorkspace:function(){return r(this._getService(),"createWorkspace",arguments)},loadWorkspaces:function(e){return r(this._getService(e),"loadWorkspaces",arguments)},loadWorkspace:function(e){return r(this._getService(e),"loadWorkspace",arguments)},getWorkspace:function(e){return r(this._getService(e),"getWorkspace",arguments)},changeWorkspace:function(){return r(this._getService(),"changeWorkspace",arguments)},getProject:function(e){return r(this._getService(e),"getProject",arguments)},_createArtifact:function(e,t,n,i){return r(this._getService(e),t,i).then(function(t){return this.isEventFrozen()?(this._frozenEvent.created||(this._frozenEvent.created=[]),this._frozenEvent.created.push({parent:e,result:t,eventData:n})):this.dispatchEvent({type:"Changed",created:[{parent:e,result:t,eventData:n}]}),t}.bind(this))},createProject:function(e){return r(this._getService(e),"createProject",arguments)},createFolder:function(e,t,n){return this._createArtifact(e,"createFolder",n,arguments)},createFile:function(e,t,n){return this._createArtifact(e,"createFile",n,arguments)},deleteFile:function(e,t){return r(this._getService(e),"deleteFile",arguments).then(function(n){return this.isEventFrozen()?(this._frozenEvent.deleted||(this._frozenEvent.deleted=[]),this._frozenEvent.deleted.push({deleteLocation:e,eventData:t})):this.dispatchEvent({type:"Changed",deleted:[{deleteLocation:e,eventData:t}]}),n}.bind(this))},moveFile:function(e,t,n){var i=this._getService(e),s=this._getService(t);if(i===s)return r(i,"moveFile",arguments).then(function(n){return this.isEventFrozen()?(this._frozenEvent.moved||(this._frozenEvent.moved=[]),this._frozenEvent.moved.push({source:e,target:t,result:n})):this.dispatchEvent({type:"Changed",moved:[{source:e,target:t,result:n}]}),n}.bind(this));var a="/"===e[e.length-1],l=t;if("/"!==l[l.length-1]&&(l+="/"),n)l+=encodeURIComponent(n);else{var d=e;a&&(d=d.substring(0,d.length-1)),l+=d.substring(d.lastIndexOf("/")+1)}return a&&"/"!==l[l.length-1]&&(l+="/"),o(i,e,s,l).then(function(){return r(i,"deleteFile",[e])})},copyFile:function(e,t,n){var i=this._getService(e),s=this._getService(t);if(i===s)return r(i,"copyFile",arguments).then(function(n){return this.isEventFrozen()?(this._frozenEvent.copied||(this._frozenEvent.copied=[]),this._frozenEvent.copied.push({source:e,target:t,result:n})):this.dispatchEvent({type:"Changed",copied:[{source:e,target:t,result:n}]}),n}.bind(this));var a="/"===e[e.length-1],l=t;if("/"!==l[l.length-1]&&(l+="/"),n)l+=encodeURIComponent(n);else{var d=e;a&&(d=d.substring(0,d.length-1)),l+=d.substring(d.lastIndexOf("/")+1)}return a&&"/"!==l[l.length-1]&&(l+="/"),o(i,e,s,l)},read:function(e){return r(this._getService(e),"read",arguments)},readBlob:function(e){return r(this._getService(e),"readBlob",arguments)},write:function(e){return r(this._getService(e),"write",arguments).then(function(t){return this.isEventFrozen()?(this._frozenEvent.modified||(this._frozenEvent.modified=[]),this._frozenEvent.modified.push(e)):this.dispatchEvent({type:"Changed",modified:[e]}),t}.bind(this))},remoteImport:function(e,t,n){return r(this._getService(e),"remoteImport",arguments).then(function(e){return this.isEventFrozen()?(this._frozenEvent.copied||(this._frozenEvent.copied=[]),this._frozenEvent.copied.push({target:n})):this.dispatchEvent({type:"Changed",copied:[{target:n}]}),e}.bind(this))},remoteExport:function(e){return r(this._getService(e),"remoteExport",arguments)},find:function(){return r(this._getService(location),"find",arguments)},search:function(e){return r(this._getService(e.resource),"search",arguments)}},s.prototype.constructor=s,{FileClient:s}}),n("orion/serviceTracker",[],function(){function e(e,i){function r(e){var t=e.getProperty("service.id"),n=this.addingService(e);n&&(d[t]=e,c[t]=n)}function o(e){var t=e.getProperty("service.id"),n=c[t];delete d[t],delete c[t],this.removedService(e,n) }function s(e){return-1!==e.getProperty("objectClass").indexOf(i)}this.serviceRegistry=e;var a,l,d={},c={},h=t;this.close=function(){if(h!==n)throw new Error("Already closed");h=t,e.removeEventListener("registered",a),e.removeEventListener("unregistering",l),a=null,l=null;var i=this;this.getServiceReferences().forEach(function(e){o.call(i,e)}),"function"==typeof this.onClose&&this.onClose()},this.getServiceReferences=function(){var e=Object.keys(d);return e.length?e.map(function(e){return d[e]}):null},this.open=function(d){if("undefined"==typeof d&&(d=!0),h!==t)throw new Error("Already open");h=n;var c=this;a=function(e){return s(e.serviceReference)&&(r.call(c,e.serviceReference),"function"==typeof c.onServiceAdded)?c.onServiceAdded(e.serviceReference,c.serviceRegistry.getService(e.serviceReference)):void 0},l=function(e){s(e.serviceReference)&&o.call(c,e.serviceReference)},e.addEventListener("registered",a),e.addEventListener("unregistering",l),d&&e.getServiceReferences(i).forEach(function(t){return r.call(c,t),"function"==typeof c.onServiceAdded?c.onServiceAdded(t,e.getService(t)):void 0}),"function"==typeof this.onOpen&&this.onOpen()}}var t=0,n=1;return e.prototype={addingService:function(e){return this.serviceRegistry.getService(e)},onOpen:null,onClose:null,onServiceAdded:null,removedService:function(){}},e}),n("orion/contentTypes",["orion/serviceTracker"],function(e){function t(e,t){return-1!==e.indexOf(t)}function n(e){switch(e&&e.id){case"image/jpeg":case"image/png":case"image/gif":case"image/ico":case"image/tiff":case"image/svg":return!0}return!1}function i(e){return e?"application/octet-stream"===e.id||"application/octet-stream"===e["extends"]:!1}function r(e,n){if("string"!=typeof e)return null;var i,r=null,o=e.indexOf(".");o++;for(var s=e.substring(o).toLowerCase(),a=0;a<n.length;a++){if(i=n[a],i.filename.indexOf(e)>=0){r=i;break}if(t(i.extension,s))r=i;else if("string"==typeof i.filenamePattern)try{new RegExp(i.filenamePattern,"i").test(e)&&(r=i)}catch(l){}}if(!r)for(o=s.indexOf(".");!r&&o>=0;){for(o++,s=s.substring(o),a=0;a<n.length;a++)if(i=n[a],t(i.extension,s)){r=i;break}o=s.indexOf(".")}return r}function o(e){return null===e||"undefined"==typeof e?[]:Array.isArray(e)?e:[e]}function s(e){return o(e).map(function(e){return String.prototype.toLowerCase.call(e)})}function a(e){return{id:e.id,name:e.name,image:e.image,imageClass:e.imageClass,"extends":e["extends"],extension:s(e.extension),filename:o(e.filename),filenamePattern:e.filenamePattern}}function l(e,t){t.map(a).forEach(function(t){Object.prototype.hasOwnProperty.call(e,t.id)||(e[t.id]=t)})}function d(e,t){t.map(a).forEach(function(t){Object.prototype.hasOwnProperty.call(e,t.id)&&delete e[t.id]})}function c(e,t){for(var n=o(e.getProperty("contentTypes")),i=0;i<n.length;i++)t.push(n[i])}function h(e){var t=Object.create(null);return l(t,e),t}function u(e){for(var t=e.getServiceReferences(g).concat(e.getServiceReferences(v)),n=[],i=0;i<t.length;i++){var r=t[i];c(r,n)}return h(n)}function f(t){if(t&&t.registerService){this.serviceRegistry=t;var n=new e(this.serviceRegistry,"orion.core.contenttype"),i=this;n.onServiceAdded=function(e){var t=[];c(e,t),l(i.map,t)},n.removedService=function(e){var t=[];c(e,t),d(i.map,t)},n.open(!1),this.map=u(t),t.registerService(p,this)}else{if(!Array.isArray(t))throw new Error("Invalid parameter");this.serviceRegistry=null,this.map=h(t)}}var p="orion.core.contentTypeRegistry",g="orion.core.contenttype",v="orion.file.contenttype";return f.prototype={getContentTypes:function(){var e=this.getContentTypesMap(),t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(e[n]);return t},getContentTypesMap:function(){return this.map},getFileContentType:function(e){return r(e.Name,this.getContentTypes())},getFilenameContentType:function(e){return r(e,this.getContentTypes())},getContentType:function(e){return this.map[e]||null},isExtensionOf:function(e,t){if(e="string"==typeof e?this.getContentType(e):e,t="string"==typeof t?this.getContentType(t):t,!e||!t)return!1;if(e.id===t.id)return!0;for(var n=e,i={};n&&(n=this.getContentType(n["extends"]));){if(n.id===t.id)return!0;if(i[n.id])throw new Error("Cycle: "+n.id);i[n.id]=!0}return!1},isSomeExtensionOf:function(e,t){for(var n=0;n<t.length;n++)if(this.isExtensionOf(e,t[n]))return!0;return!1}},{ContentTypeRegistry:f,isImage:n,isBinary:i,getFilenameContentType:r}}),n("orion/edit/nls/messages",["module"],function(e){var t=e.config();return t&&t.root?t:{root:!0}}),n("orion/edit/nls/root/messages",{Editor:"Editor",switchEditor:"Switch Editor",Fetching:"Fetching: ${0}",confirmUnsavedChanges:"This file contains unsaved changes. If you navigate away, will lose them. \n\nDo you want to save your changes?",searchFiles:"Quick Search in ${0}",searchTerm:"Enter search term:",unsavedChanges:"There are unsaved changes in current file, you can't navigate away without saving it.",unsavedAutoSaveChanges:"Please stay on the page until Auto Save is complete.",Save:"Save",Saved:"Saved",Blame:"Blame",BlameTooltip:"Show blame annotations",Diff:"Diff",DiffTooltip:"Show diff annotations",saveOutOfSync:"Resource is out of sync with the server. Do you want to save it anyway?",loadOutOfSync:"Resource is out of sync with the server. Do you want to load it anyway? This will overwrite your local changes.",ReadingMetadata:"Reading metadata of ${0}",ReadingMetadataError:"Cannot get metadata of ${0}",Reading:"Reading ${0}",ReloadWith:"Reload With","Convert Line Delimiters":"Convert Line Delimiters","Windows (CR/LF)":"Windows (CR/LF)","Unix (LF)":"Unix (LF)",ConversionCompleteCRLF:"Line delimiters have been converted to CR/LF",ConversionCompleteLF:"Line delimiters have been converted to LF",readonly:"Read Only.",saveFile:"Save this file",toggleZoomRuler:"Toggle Zoom Ruler",gotoLine:"Go to Line...",gotoLineTooltip:"Go to specified line number",gotoLinePrompt:"Go to line:",Undo:"Undo",Redo:"Redo",Cut:"Cut",Copy:"Copy",Paste:"Paste",Find:"Find...",noResponse:"No response from server. Check your internet connection and try again.",noResponseTimeout:"No response from server (timed out after ${0} seconds). Check your internet connection and try again.",savingFile:"Saving file ${0}",running:"Running ${0}","Saving...":"Saving...",View:"View",SplitSinglePage:"Single Page",SplitVertical:"Split Vertical",SplitHorizontal:"Split Horizontal",SplitPipInPip:"Picture in Picture",SplitModeTooltip:"Change split editor mode",AllTabsDropDown:"Open Tabs (Ctrl + Shift + E)",AllTabsDropDownMac:"Open Tabs (Cmd + Shift + E)",SidePanel:"Side Panel",SidePanelTooltip:"Choose what to show in the side panel.",Slideout:"Slideout",Actions:"Actions",Navigator:"Navigator",FolderNavigator:"Folder Navigator",Project:"Project",New:"New",File:"File",Edit:"Edit",Tools:"Tools",Add:"Add",noActions:"There are no actions for the current selection.",NoFile:"Use the ${0} to create new files and folders. Click a file to start coding.",LocalEditorSettings:"Local Editor Settings",EditorSettings:"Editor Settings",NoProject:"${0} is not a project. To convert it to a project use ${1}.",NoProjects:"There are no projects in your workspace. Use the ${0} menu to create projects.",Disconnected:"${0} (disconnected)",ChooseFS:"Choose Filesystem",ChooseFSTooltip:"Choose the filesystem you want to view.",FSTitle:"${0} (${1})",EnterCondition:"Please enter a condition:",Deploy:"Deploy","Deploy As":"Deploy As",Import:"Import",Export:"Export",OpenWith:"Open With",OpenRelated:"Open Related",OpenFolder:"Open Folder",SwitchWorkspace:"Switch To",SwitchWorkspaceTip:"Switch workspaces",OpenRecent:"Open Recent",OpenFolderTip:"Change the root folder",Dependency:"Dependency",UnnamedCommand:"Unnamed",Search:"Search...","Show Debug":"Debug...",ClickEditLabel:"Click to edit",ProjectInfo:"Project Information",Name:"Name",Description:"Description",Site:"Site",projectsSectionTitle:"Projects",listingProjects:"Listing projects...",gettingWorkspaceInfo:"Getting workspace information...",showProblems:"Show Problems...",showTooltip:"Show Tooltip",showTooltipTooltip:"Shows the tooltip immediately based on the caret position",emptyDeploymentInfoMessage:"Use the Launch Configurations dropdown to deploy this project",Orion:"Orion",OK:"Ok",Format:"Format Code",FormatTooltip:"Format editor contents",References:"References",ReferencesTooltip:"Find references in project",FindReferences:"Finding references",OpenDeclaration:"Open Declaration",OpenDeclarationTooltip:"Open the declaration for the current selection",FindDeclaration:"Finding declaration",Cancel:"Cancel",Yes:"Yes",No:"No",selectNextTab:"Select Next Editor Tab",selectPreviousTab:"Select Previous Editor Tab",showTabDropdown:"Display Open Editor Tabs",Collaborate:"Collaborate",CollaborateToolTip:"Start a Collaboration session on the current file",closeOthers:"Close Other Tabs",closeTotheRight:"Close Tabs To The Right",keepOpen:"Keep Open",closeSelf:"Close"}),function(){function e(e){if("string"!=typeof e)throw new TypeError}function t(e){return e?e.split("&"):[]}function n(e){return 0===e.length?"":e.join("&")}function i(e){var t=/([^=]*)(?:=?)(.*)/.exec(e),n=t[1]?decodeURIComponent(t[1]):"",i=t[2]?decodeURIComponent(t[2]):"";return[n,i]}function r(e){var t=encodeURIComponent(e[0]);return e[1]&&(t+="="+encodeURIComponent(e[1])),t}function o(e,n){var r="",o=[],s=0;return{next:function(){if(r!==e.query&&(r=e.query,o=t(r)),s<o.length){var a=i(o[s++]);switch(n){case"keys":return a[0];case"values":return a[1];case"keys+values":return[a[0],a[1]];default:throw new TypeError}}throw k}}}function s(e){Object.defineProperty(this,"_url",{get:function(){return e._url}})}function a(e,t){if(!e.scheme&&t&&(e.scheme=t.scheme,!e.host&&t.host&&(e.userinfo=t.userinfo,e.host=t.host,e.port=t.port,e.pathRelative=!0)),e.pathRelative)if(e.path){if("/"!==e.path[0]){var n=/^(.*\/)[^\/]*$/.exec(t.path)[1]||"/";e.path=n+e.path}}else e.path=t.path}function l(e){return e.toLowerCase()}function d(e){return e?/[1-9]\d*$/.exec(e)[0]:""}function c(e){var t=[];return e.split("/").forEach(function(e){".."===e?t.length>1&&t.pop():"."!==e&&t.push(e)}),t.join("/")}function h(e){e.scheme&&(e.scheme=l(e.scheme)),e.port&&(e.port=d(e.port)),e.host&&e.path&&(e.path=c(e.path))}function u(e){return e.replace(/\s/g,function(e){return"%"+e.charCodeAt(0).toString(16)})}function f(e,t){if("string"!=typeof e)throw new TypeError;e=u(e);var n=_.exec(e);if(!n)return null;var i={};if(i.scheme=n[1]||"",i.scheme&&!w.test(i.scheme))return null;var r=n[2];if(r){var o=y.exec(r);if(i.userinfo=o[1],i.host=o[2],i.port=o[3],i.port&&!x.test(i.port))return null}return i.path=n[3],i.query=n[4],i.fragment=n[5],a(i,t),h(i),i}function p(e){var t=e.scheme?e.scheme+":":"";return e.host&&(t+="//",e.userinfo&&(t+=e.userinfo+"@"),t+=e.host,e.port&&(t+=":"+e.port)),t+=e.path,e.query&&(t+="?"+e.query),e.fragment&&(t+="#"+e.fragment),t}function g(e,t){var n;if(t){if(t=t.href||t,n=f(t),!n||!n.scheme)throw new SyntaxError;Object.defineProperty(this,"_baseURL",{value:n})}var i=f(e,n);if(!i)throw new SyntaxError;Object.defineProperty(this,"_input",{value:e,writable:!0}),Object.defineProperty(this,"_url",{value:i,writable:!0});var r=new s(this);Object.defineProperty(this,"query",{get:function(){return this._url?r:null},enumerable:!0})}try{var v;if("function"==typeof self.URL&&0!==self.URL.length&&"http:"===(v=new self.URL("http://www.w3.org?q")).protocol&&v.query)return}catch(m){}var _=/^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/,y=/^(?:(.*)@)?(\[[^\]]*\]|[^:]*)(?::(.*))?$/,C=/^\S*$/,w=/^([a-zA-Z](?:[a-zA-Z0-9+-.])*)$/,x=/^\d*$/,b=/^(\[[^\]\/?#\s]*\]|[^:\/?#\s]*)$/,S=/^(\[[^\]\/?#\s]*\]|[^:\/?#\s]*)(?::(\d*))?$/,T=/^([^?#\s]*)$/,E=/^([^\s]*)$/,A=C,L=/([^:]*):?(.*)/,k="undefined"!=typeof StopIteration?StopIteration:new Error("Stop Iteration"),M={"ftp:":"21","gopher:":"70","http:":"80","https:":"443","ws:":"80","wss:":"443"};Object.defineProperties(s.prototype,{get:{value:function(n){e(n);var r,o=t(this._url.query);return o.some(function(e){var t=i(e);return t[0]===n?(r=t[1],!0):void 0}),r},enumerable:!0},set:{value:function(o,s){e(o),e(s);var a=t(this._url.query),l=a.some(function(e,t){var n=i(e);return n[0]===o?(n[1]=s,a[t]=r(n),!0):void 0});l||a.push(r([o,s])),this._url.query=n(a)},enumerable:!0},has:{value:function(n){e(n);var r=t(this._url.query);return r.some(function(e){var t=i(e);return t[0]===n?!0:void 0})},enumerable:!0},"delete":{value:function(r){e(r);var o=t(this._url.query),s=o.filter(function(e){var t=i(e);return t[0]!==r});return s.length!==o.length?(this._url.query=n(s),!0):!1},enumerable:!0},clear:{value:function(){this._url.query=""},enumerable:!0},forEach:{value:function(e,t){if("function"!=typeof e)throw new TypeError;var n=o(this._url,"keys+values");try{for(;;){var i=n.next();e.call(t,i[1],i[0],this)}}catch(r){if(r!==k)throw r}},enumerable:!0},keys:{value:function(){return o(this._url,"keys")},enumerable:!0},values:{value:function(){return o(this._url,"values")},enumerable:!0},items:{value:function(){return o(this._url,"keys+values")}},size:{get:function(){return t(this._url.query).length},enumerable:!0},getAll:{value:function(n){e(n);var r=[],o=t(this._url.query);return o.forEach(function(e){var t=i(e);t[0]===n&&r.push(t[1])}),r},enumerable:!0},append:{value:function(i,o){e(i),e(o);var s=t(this._url.query);s.push(r([i,o])),this._url.query=n(s)},enumerable:!0}}),Object.defineProperties(g.prototype,{toString:{value:function(){return this.href}},href:{get:function(){return this._url?p(this._url):this._input},set:function(t){e(t),this._input=t,this._url=f(this._input,this._baseURL)},enumerable:!0},origin:{get:function(){return this._url&&this._url.host?this.protocol+"//"+this.host:""},enumerable:!0},protocol:{get:function(){return this._url?this._url.scheme+":":":"},set:function(t){if(e(t),this._url){var n=":"===t.slice(-1)?t.substring(0,t.length-1):t;(""===n||w.test(n))&&(this._url.scheme=l(n))}},enumerable:!0},_userinfo:{get:function(){return this._url?this._url.userinfo:""},set:function(t){e(t),this._url&&(this._url.userinfo=t)}},username:{get:function(){if(!this._url)return"";var e=L.exec(this._userinfo),t=decodeURIComponent(e[1]||"");return t},set:function(t){if(e(t),this._url){var n=L.exec(this._userinfo),i=[encodeURIComponent(t||"")];n[2]&&i.push(n[2]),this._userinfo=i.join(":")}},enumerable:!0},password:{get:function(){if(!this._url)return"";var e=L.exec(this._userinfo),t=decodeURIComponent(e[2]||"");return t},set:function(t){if(e(t),this._url){var n=L.exec(this._userinfo),i=[n[1]||""];t&&i.push(encodeURIComponent(t)),this._userinfo=i.join(":")}},enumerable:!0},host:{get:function(){var e="";return this._url&&this._url.host&&(e+=this._url.host,this._url.port&&(e+=":"+this._url.port)),e},set:function(t){if(e(t),this._url){var n=S.exec(t);n&&(this._url.host=n[1],this._url.port=d(n[2]))}},enumerable:!0},hostname:{get:function(){return this._url?this._url.host:""},set:function(t){if(e(t),this._url){var n=b.exec(t);n&&(this._url.host=t)}},enumerable:!0},port:{get:function(){var e=this._url?this._url.port||"":"";return e&&e===M[this.protocol]&&(e=""),e},set:function(t){if(e(t),this._url){var n=x.exec(t);n&&(this._url.port=d(t))}},enumerable:!0},pathname:{get:function(){return this._url?this._url.path:""},set:function(t){if(e(t),this._url){var n=T.exec(t);n&&(this._url.host&&t&&"/"!==t[0]&&(t="/"+t),this._url.path=t?c(t):"")}},enumerable:!0},search:{get:function(){return this._url&&this._url.query?"?"+this._url.query:""},set:function(t){if(e(t),this._url){t&&"?"===t[0]&&(t=t.substring(1));var n=E.exec(t);n&&(this._url.query=t)}},enumerable:!0},hash:{get:function(){return this._url&&this._url.fragment?"#"+this._url.fragment:""},set:function(t){if(e(t),this._url){t&&"#"===t[0]&&(t=t.substring(1));var n=A.exec(t);n&&(this._url.fragment=t)}},enumerable:!0}});var O=self.URL||self.webkitURL;O&&O.createObjectURL&&(Object.defineProperty(g,"createObjectURL",{value:O.createObjectURL.bind(O),enumerable:!1}),Object.defineProperty(g,"revokeObjectURL",{value:O.revokeObjectURL.bind(O),enumerable:!1})),self.URL=g}(),n("orion/URL-shim",function(){}),n("orion/fileUtils",["require","orion/URL-shim"],function(e){function t(e){var t=document.createElement("a");if(t.href=e,e=t.href,o)try{if(window.location.host===parent.location.host&&window.location.protocol===parent.location.protocol)return e.substring(parent.location.href.indexOf(parent.location.host)+parent.location.host.length);o=!1}catch(n){o=!1}return e}function n(e){if(!e)return e;var t=window.location.protocol+"//"+window.location.host;return 0===e.indexOf(t)?e.substring(t.length):e}function i(e){if(!e)return!1;if("/workspace"===e)return!0;var t=new URL(e,window.location.href);return 0===t.href.indexOf(r)}var r,o=!0;return r=e.toUrl?new URL(e.toUrl("workspace"),window.location.href).href:new URL("/",window.location.href).href,{makeParentRelative:t,makeRelative:n,isAtRoot:i}}),n("orion/objects",[],function(){function e(e){for(var t=Object.prototype.hasOwnProperty,n=1,i=arguments.length;i>n;n++){var r=arguments[n];for(var o in r)t.call(r,o)&&(e[o]=r[o])}return e}return{clone:function(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var n=Object.create(Object.getPrototypeOf(t));return e(n,t),n},mixin:e,toArray:function(e){return Array.isArray(e)?e:[e]}}}),n("orion/widgets/input/DropDownMenu",["orion/objects","orion/webui/littlelib"],function(e,t){function n(e,n,i){var r=t.node(e);if(!r)throw new Error("Parent node of dropdown menu not found");this._parent=r,i=i||{},this.options=i,this.navDropDownId=this._parent.id+"_navdropdown",this.selectionClass=i.selectionClass;var o=document.createElement("div");if(o.classList.add("dropdownMenu"),o.classList.add("dropdownMenuOpen"),o.id=this.navDropDownId,o.style.display="none",this._parent.appendChild(o),this._dropdownMenu=o,n=t.node(n),!n)throw"Trigger node of dropdown menu not found";this._triggerNode=n,"hidden"===this._triggerNode.style.visibility&&(this._triggerNode.style.visibility="visible"),i.noClick||(this._triggerNode.onclick=this.click.bind(this)),this._dropdownMenu.addEventListener("keydown",function(e){e.keyCode===t.KEY.ESCAPE&&this.clearPanel()}.bind(this))}return e.mixin(n.prototype,{click:function(){"none"===this._dropdownMenu.style.display?this.updateContent(this.getContentNode(),function(){t.setFramesEnabled(!1),this._dropdownMenu.style.display="",this._positionDropdown(),this.selectionClass&&this._triggerNode.classList.add(this.selectionClass),this.handle=t.addAutoDismiss([this._triggerNode,this._dropdownMenu],this.clearPanel.bind(this)),this.options.onShow&&this.options.onShow()}.bind(this)):this.clearPanel()},clearPanel:function(){this.isVisible()&&(this._dropdownMenu.style.display="none",t.setFramesEnabled(!0),this.selectionClass&&this._triggerNode.classList.remove(this.selectionClass),this.options.onHide&&this.options.onHide())},addContent:function(e){this._dropdownMenu.innerHTML=e},getContentNode:function(){return this._dropdownMenu},updateContent:function(e,t){t()},_positionDropdown:function(){this._dropdownMenu.style.right="";var e=t.bounds(this._dropdownMenu),n=t.bounds(document.body);if(e.left+e.width>n.left+n.width){var i=t.bounds(this._boundingNode(this._triggerNode)),r=t.bounds(this._triggerNode);this._dropdownMenu.style.right=i.width-(r.left-i.left+r.width)+"px"}},_boundingNode:function(e){var t=window.getComputedStyle(e,null);if(null===t)return e;var n=t.getPropertyValue("position");return"absolute"!==n&&e.parentNode&&e!==document.body?this._boundingNode(e.parentNode):e},isDestroyed:function(){return!this._dropdownMenu.parentNode},isVisible:function(){return"none"!==this._dropdownMenu.style.display&&!this.isDestroyed()},focus:function(){this._dropdownMenu.focus()},destroy:function(){this._parent&&(t.setFramesEnabled(!0),t.empty(this._parent),this._parent=this.select=null)}}),n}),n("orion/URITemplate",[],function(){function e(e){this._text=e}function t(e){return e.replace("%25","%")}function n(e,n){if("U"===n)return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()});if("U+R"===n)return encodeURI(e).replace(/%5B/g,"[").replace(/%5D/g,"]").replace(h,t);if("U+R-,"===n)return encodeURI(e).replace(/%5B/g,"[").replace(/%5D/g,"]").replace(/,/g,"%2C");throw new Error("Unknown allowed character set: "+n)}function i(e,t,i){for(var r=[],o=0;o<e.length;o++)"undefined"!=typeof e[o]&&r.push(n(e[o],t));return r.join(i)}function r(e,t,i,r){for(var o=Object.keys(e),s=[],a=0;a<o.length;a++)"undefined"!=typeof e[o[a]]&&s.push(n(o[a],t)+i+n(e[o[a]],t));return s.join(r)}function o(e){for(var t=[],n=e.split(","),i=0;i<n.length;i++){var r=n[i].match(c);if(null===r)throw new Error("Bad VarSpec: "+e);t.push({name:r[1],explode:!!r[2],prefix:r[3]?parseInt(r[3],10):-1})}return t}function s(e){if(0===e.length)throw new Error("Invalid Expression: 0 length expression");this._operator=d[e[0]],this._operator?e=e.substring(1):this._operator=d.NUL,this._varSpecList=o(e)}function a(t){for(var n=[],i=0,r=t.indexOf("{",i);-1!==r;){n.push(new e(t.substring(i,r)));var o=t.indexOf("}",r+1);if(-1===o)throw new Error("Invalid template: "+t);n.push(new s(t.substring(r+1,o))),i=o+1,r=t.indexOf("{",i)}return n.push(new e(t.substring(i))),n}function l(e){this._templateComponents=a(e)}var d={NUL:{first:"",sep:",",named:!1,ifemp:"",allow:"U"},"+":{first:"",sep:",",named:!1,ifemp:"",allow:"U+R"},".":{first:".",sep:",",named:!1,ifemp:"",allow:"U"},"/":{first:"/",sep:"/",named:!1,ifemp:"",allow:"U"},";":{first:";",sep:";",named:!0,ifemp:"",allow:"U"},"?":{first:"?",sep:"&",named:!0,ifemp:"=",allow:"U"},"&":{first:"&",sep:"&",named:!0,ifemp:"=",allow:"U"},"#":{first:"#",sep:",",named:!1,ifemp:"",allow:"U+R"},",":{first:"",sep:",",named:!1,ifemp:"",allow:"U+R-,"}},c=/^((?:(?:[a-zA-Z0-9_])|(?:%[0-9A-F][0-9A-F]))(?:(?:[a-zA-Z0-9_.])|(?:%[0-9A-F][0-9A-F]))*)(?:(\*)|:([0-9]+))?$/,h=/%25[0-9A-F][0-9A-F]/g;return e.prototype={expand:function(){return encodeURI(this._text)}},s.prototype={expand:function(e){for(var t=[],o=0;o<this._varSpecList.length;o++){var s=this._varSpecList[o],a=s.name,l=e[a],d=typeof l;if("undefined"!==d&&null!==l){var c=0===t.length?this._operator.first:this._operator.sep;if("string"===d)this._operator.named&&(c+=n(a,"U+R"),c+=0===l.length?this._operator.ifemp:"="),-1!==s.prefix&&s.prefix<l.length&&(l=l.substring(0,s.prefix)),c+=n(l,this._operator.allow);else if(Array.isArray(l)){if(0===l.length)continue;if(s.explode)c+=i(l,this._operator.allow,this._operator.sep);else{var h=i(l,this._operator.allow,",");this._operator.named&&(c+=n(a,"U+R"),c+=0===h.length?this._operator.ifemp:"="),c+=h}}else{if("object"!==d)throw new Error("bad param type: "+a+" : "+d);if(0===Object.keys(l).length)continue;if(s.explode)c+=r(l,this._operator.allow,"=",this._operator.sep);else{var u=r(l,this._operator.allow,",",",");this._operator.named&&(c+=n(a,"U+R"),c+=0===u.length?this._operator.ifemp:"="),c+=u}}t.push(c)}}return t.join("")}},l.prototype={expand:function(e){for(var t=[],n=0;n<this._templateComponents.length;n++)t.push(this._templateComponents[n].expand(e));return t.join("")}},l}),n("orion/PageLinks",["require","orion/Deferred","orion/PageUtil","orion/URITemplate","orion/i18nUtil","orion/objects","orion/URL-shim"],function(e,t,n,i,r,o){function s(){if(e.toUrl){var t=new URL(e.toUrl("orion/"),self.location.href);return new URL("../",t).href.slice(0,-1)}return new URL("/",self.location.href).href.slice(0,-1)}function a(e,t){return d(e,t).then(function(e){return new u(e)})}function l(e){var t={};return e.getPropertyKeys().forEach(function(n){"objectClass"!==n&&"service.names"!==n&&"service.id"!==n&&"__plugin__"!==n&&(t[n]=e.getProperty(n))}),t}function d(e,r){r=r||"orion.page.link";var o=e.getServiceReferences(r),a=n.matchResourceParameters(window.location.href),d=s(),c={OrionHome:d,Location:a.resource},h=[];return o.forEach(function(e){var r=l(e);if(r.uriTemplate&&(r.nls||r.name)){var o=new i(r.uriTemplate),s=o.expand(c);s=n.validateURLScheme(s),r.href=s,r.textContent=r.name||r.nameKey,h.push((new t).resolve(r))}}),t.all(h)}function c(e){var n;if(!g){n=[];var i=e.getServiceReferences("orion.page.link.category");return i.forEach(function(i){var r=l(i);r.id&&(r.name||r.nameKey)&&(r.service=e.getService(i),r.textContent=r.name,n.push((new t).resolve(r)))}),t.all(n).then(function(e){return g=new h(e)})}return(new t).resolve(g)}function h(e){var t=this.categories=Object.create(null);e.forEach(function(e){t[e.id]=e})}function u(e){this.allPageLinks=e,this.allPageLinks.sort(f)}function f(e,t){var n=e.textContent&&e.textContent.toLowerCase(),i=t.textContent&&t.textContent.toLowerCase();return i>n?-1:n>i?1:0}function p(e,t,n){var i=document.createElement("a");return i.href=e,i.target=t,i.classList.add("targetSelector"),i.textContent=n,i}var g;return o.mixin(h.prototype,{getCategoryIDs:function(){return Object.keys(this.categories)},getCategory:function(e){return this.categories[e]||null}}),o.mixin(u.prototype,{createLinkElements:function(){return this.allPageLinks.map(function(e){return p(e.href,"_self",e.textContent)})},getAllLinks:function(){return this.allPageLinks}}),{getCategoriesInfo:c,getPageLinksInfo:a,getOrionHome:s}}),n("orion/extensionCommands",["orion/Deferred","orion/commands","orion/PageUtil","orion/contentTypes","orion/URITemplate","orion/i18nUtil","orion/PageLinks","i18n!orion/edit/nls/messages","orion/util","orion/URL-shim"],function(e,t,n,i,r,o,s,a,l){function d(e){var t={},n=e.getPropertyKeys();return n.forEach(function(n){t[n]=e.getProperty(n)}),t}function c(e){return e.id||e.name}var h={},u=s.getOrionHome();h._cloneItemWithoutChildren=function v(e){if(null===e||"object"!=typeof e)return e;var t=e.constructor();for(var n in e)"children"!==n&&"Children"!==n&&"parent"!==n&&"Project"!==n&&(t[n]=v(e[n]));return t},h._getOpenWithNavCommandExtensions=function(e){function t(){for(var t=e.getServiceReferences("orion.edit.editor"),n=[],i=0;i<t.length;i++){var r=t[i],o=r.getProperty("id");n.push({id:o,"default":r.getProperty("default")||!1,name:r.getProperty("name"),nameKey:r.getProperty("nameKey"),nls:r.getProperty("nls"),uriTemplate:r.getProperty("orionTemplate")||r.getProperty("uriTemplate"),validationProperties:r.getProperty("validationProperties")||[]})}return n}function n(e,t){for(var n=e.getServiceReferences("orion.navigate.openWith"),i=[],r=[],o=0;o<n.length;o++){var s=n[o];if(s.getProperty("editor")===t.id){var a=s.getProperty("contentType");a instanceof Array?i=i.concat(a):i.push(a||"*/*");var l=s.getProperty("excludedContentTypes");l instanceof Array?r=r.concat(l):null!==l&&"undefined"!=typeof l&&r.push(l)}}return 0===i.length&&(i=null),0===r.length&&(r=null),{contentTypes:i,excludedContentTypes:r}}for(var i,r=t(),o=[],s="orion.editor",a=0;a<r.length;a++){var l=r[a],d=n(e,l),c=d.contentTypes,h=d.excludedContentTypes,u={name:l.name||l.id,nameKey:l.nameKey,id:"eclipse.openWithCommand."+l.id,contentType:c,excludedContentTypes:h,uriTemplate:l.uriTemplate,nls:l.nls,forceSingleItem:!0,isEditor:l["default"]?"default":"editor",validationProperties:l.validationProperties},f={properties:u,service:{}};l.id===s?i=f:o.push(f)}return i&&o.push(i),o},h._makeValidator=function(e,t,n,o){function s(e,t,n,i,r){var o,s=!1;if("!"===t.charAt(0))return"undefined"==typeof e[t.substring(1)];if("undefined"!=typeof e[t]){if("undefined"==typeof n)o=e[t],s=!0;else if("string"==typeof n){if(!i.variableName)return new RegExp(n).test(e[t]);var a=new RegExp(n).exec(e[t]);if(a){var l=a[0];o="before"===i.variableMatchPosition?e[t].substring(0,a.index):"after"===i.variableMatchPosition?e[t].substring(a.index+l.length):"only"===i.variableMatchPosition?l:e[t],s=!0}}else e[t]===n&&(o=e[t],s=!0);var d=i.variableName,c=i.replacements;if(s&&d&&(r[d]=o,r.itemCached=e,c)){if("string"!=typeof o)return window.console.log("Cannot replace "+d+", value is not a string: "+o),s;for(var h=0;h<c.length;h++){var u=!1;if(c[h].pattern){var f=c[h].pattern,p=c[h].replacement||"";r[d]=r[d].replace(new RegExp(f),p).replace(new RegExp(f),p)}else u=!0;u&&window.console.log("Invalid replacements specified in validation property. "+c[h])}}return s}return!1}function a(e,t,n,i){var r,o,l,d,c=n.match;if((l=t.indexOf("["))>=0){if((d=t.indexOf("]"))<0)return!1;var h,u,f=t.substring(0,l);if(!(h=e[f])||!Array.isArray(h))return!1;if(r=t.substring(l+1,d),u=parseInt(r,10),isNaN(u))return!1;0>u&&(u+=h.length),o=t.substring(d+1),t=f+":"+String(u)+o}return t.indexOf("|")>=0?(r=t.substring(0,t.indexOf("|")),o=t.substring(t.indexOf("|")+1),a(e,r,n,i)?!0:a(e,o,n,i)):t.indexOf(":")>=0?(r=t.substring(0,t.indexOf(":")),o=t.substring(t.indexOf(":")+1),e[r]?a(e[r],o,n,i):!1):s(e,t,c,n,i)}function l(t,n,r){if(r.info.validationProperties)for(var o=0;o<r.info.validationProperties.length;o++){var s=r.info.validationProperties[o];if("undefined"==typeof s.source)return window.console.log("Invalid validationProperties in "+e.id+". No source property specified."),!1;var l=a(t,s.source,s,r);if(!l)return!1}if(!r.info.contentType&&!r.info.excludedContentTypes)return!0;if(t.Directory)return r.info.contentType&&r.info.contentType.indexOf("*/*")>=0?!0:!1;var d=!0,c=n?i.getFilenameContentType(t.Name||t.Location,n):null;return c=c||{id:"application/octet-stream"},r.info.excludedContentTypes&&n&&(d=r.info.excludedContentTypes.every(function(e){var t=e.replace(/([*?])/g,".$1");return-1!==c.id.search(t)?!1:!0})),d&&r.info.contentType&&n&&(d=r.info.contentType.some(function(e){var t=e.replace(/([*?])/g,".$1");return-1!==c.id.search(t)?!0:!1})),d}var d={info:e};return d.validationFunction=function(e){if("function"==typeof o&&(e=o.call(this,e)),e){if(Array.isArray(e)){if((this.info.forceSingleItem||this.info.uriTemplate)&&1!==e.length)return!1;if(e.length<1)return!1}else e=[e];for(var t=0;t<e.length;t++)if(!l(e[t],n,this))return!1;return!0}return!1},d.generatesURI=function(){return!!this.info.uriTemplate},d.getURI=function(e){if(this.info.uriTemplate){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);if(this.info.validationProperties)for(var i=0;i<this.info.validationProperties.length;i++){var o=this.info.validationProperties[i];if(o.source&&o.variableName){var s=this.itemCached===e&&this[o.variableName];s||a(e,o.source,o,this),e[o.variableName]?window.console.log("Variable name "+o.variableName+" in the extension "+this.info.id+" conflicts with an existing property in the item metadata."):t[o.variableName]=this[o.variableName]}}t.OrionHome=u;var l=new r(this.info.uriTemplate);return l.expand(t)}return null},d};var f=a.UnnamedCommand,p="";h._createCommandOptions=function(t,i,r,o,s,a){function d(e,d){var c=h._makeValidator(t,r,o,a);if(e.visibleWhen=c.validationFunction.bind(c),s)if(c.generatesURI.bind(c)())e.hrefCallback=function(e){var t=Array.isArray(e.items)?e.items[0]:e.items,i=c.getURI.bind(c)(t),r=new URL(i);return r.search||(r.search=window.location.search),i=r.href,e.command&&e.command.isEditor&&e.domNode.addEventListener("click",function(){if(t.Location){var r=n.matchResourceParameters();if(r.resource!==t.Location)return void(e.domNode.target="_blank");var o=n.matchResourceParameters(i);if(o&&o.editor===r.editor)return void(e.domNode.target="_blank")}e.domNode.target=""}),i},l.isElectron&&t.uriTemplate&&(e.hrefTarget="_blank");else{var u=t;e.callback=function(t){var n;if(u.forceSingleItem){var o=Array.isArray(t.items)?t.items[0]:t.items;n=h._cloneItemWithoutChildren(o)}else if(Array.isArray(t.items)){n=[];for(var s=0;s<t.items.length;s++)n.push(h._cloneItemWithoutChildren(t.items[s]))}else n=h._cloneItemWithoutChildren(t.items);if(r)var a=r.getService("orion.page.progress");i.run?a?a.progress(i.run(n),"Running command: "+e.name):i.run(n):r&&(a?a.progress(r.getService(i).run(n),"Running command: "+e.name):r.getService(i).run(n))}}d.resolve(e)}var u=new e,g={name:t.name||t.nameKey||f,image:t.image,id:c(t),tooltip:t.tooltip||t.tooltipKey||p,isEditor:t.isEditor,showGlobally:t.showGlobally};return t.fixAllEnabled&&(g.fixAllEnabled=!0),d(g,u),u},h.getOpenWithCommand=function(e,t,n){for(var i,r=n||h.getOpenWithCommands(e),o=0;o<r.length;o++)if(r[o].visibleWhen(t)){var s="default"===r[o].isEditor; if((!i||s)&&(i=r[o],s))break}return i},h.getOpenWithCommands=function(e){var t=[];for(var n in e._commandList){var i=e._commandList[n];i.isEditor&&t.push(i)}return t};var g;return h.createAndPlaceFileCommandsExtension=function(e,t,n,i,r,o){var s=o?"all":void 0,l=!!o;return h.createFileCommands(e,null,s,l,t).then(function(e){return r&&0<e.length&&(t.addCommandGroup(n,"eclipse.openWith",1e3,a.OpenWith,r,null,null,null,"dropdownSelection"),t.addCommandGroup(n,"eclipse.fileCommandExtensions",1e3,a.OpenRelated,r)),e.forEach(function(e){var o=null;r&&(o=e.isEditor?r+"/eclipse.openWith":r+"/eclipse.fileCommandExtensions"),t.registerCommandContribution(n,e.id,i,o)}),{}})},h.createFileCommands=function(n,i,r,o,s){function a(){var t=n.getService("orion.core.contentTypeRegistry")||i;return g||e.when(t.getContentTypes(),function(e){return g=e})}r=void 0===r?"global":r,o=void 0===o?!0:o;var l=[];return h._cachedFileCommands||h._createCachedFileCommands(n),("all"===r||"global"===r)&&h._cachedFileCommands.forEach(function(e){var t=e.properties;("all"===r||t.forceSingleItem&&t.showGlobally)&&l.push(e)}),e.when(a(),function(){o&&(h._cachedOpenWithExtensions||(h._cachedOpenWithExtensions=h._getOpenWithNavCommandExtensions(n,g)),l=l.concat(h._cachedOpenWithExtensions),s._addedOpenWithCommands=o);var i=l.map(function(i){var r=i.properties,o=i.service,a=s.findCommand(c(r));return a?(new e).resolve(a):h._createCommandOptions(r,o,n,g,!0).then(function(e){var n=new t.Command(e);return s.addCommand(n),n})});return e.all(i,function(e){return{_error:e}}).then(function(e){return e})})},h._createCachedFileCommands=function(e){var t=e.getServiceReferences("orion.navigate.command");h._cachedFileCommands=[];for(var n=0;n<t.length;n++){var i=t[n].getProperty("id");if("orion.navigateFromMetadata"!==i){var r=e.getService(t[n]),o=d(t[n]);h._cachedFileCommands.push({properties:o,service:r})}}},h.getFileCommandIds=function(){var e=[];if(!h._cachedFileCommands)throw"extensionCommandUtils._cachedFileCommands is not initialized";return h._cachedFileCommands.length&&(e=h._cachedFileCommands.map(function(e){return e.properties.id})),e},h.createOpenWithCommands=function(t,n,i){return i&&i._addedOpenWithCommands?(new e).resolve(h.getOpenWithCommands(i)):h.createFileCommands(t,n,"none",!0,i)},h}),n("orion/regex",[],function(){function e(e){return e.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&")}function t(e){var t=/^\s*\/(.+)\/([gim]{0,3})\s*$/.exec(e);return t?{pattern:t[1],flags:t[2]}:null}return{escape:e,parse:t}}),n("orion/editor/eventTarget",[],function(){function e(){}return e.addMixin=function(t){var n=e.prototype;for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])},e.prototype={addEventListener:function(e,t,n){this._eventTypes||(this._eventTypes={});var i=this._eventTypes[e];i||(i=this._eventTypes[e]={level:0,listeners:[]});var r=i.listeners;r.push({listener:t,useCapture:n})},dispatchEvent:function(e){var t=e.type;this._dispatchEvent("pre"+t,e),this._dispatchEvent(t,e),this._dispatchEvent("post"+t,e)},_dispatchEvent:function(e,t){var n=this._eventTypes?this._eventTypes[e]:null;if(n){var i=n.listeners;try{if(n.level++,i)for(var r=0,o=i.length;o>r;r++)if(i[r]){var s=i[r].listener;"function"==typeof s?s.call(this,t):s.handleEvent&&"function"==typeof s.handleEvent&&s.handleEvent(t)}}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[e],n.compact=!1}}}},isListening:function(e){return this._eventTypes?void 0!==this._eventTypes[e]:!1},removeEventListener:function(e,t,n){if(this._eventTypes){var i=this._eventTypes[e];if(i){for(var r=i.listeners,o=0,s=r.length;s>o;o++){var a=r[o];if(a&&a.listener===t&&a.useCapture===n){0!==i.level?(r[o]=null,i.compact=!0):r.splice(o,1);break}}0===r.length&&delete this._eventTypes[e]}}}},{EventTarget:e}}),n("orion/editor/textModel",["orion/editor/eventTarget","orion/regex","orion/util"],function(e,t,n){function i(e,t){this._lastLineIndex=-1,this._text=[""],this._lineOffsets=[0],this.setText(e),this.setLineDelimiter(t)}function r(e,t){var n=e.getLineAtOffset(t.start),i=e.getLineAtOffset(t.start+t.removedCharCount);t.range={start:{line:n,character:t.start-e.getLineStart(n)},end:{line:i,character:t.start+t.removedCharCount-e.getLineStart(i)}}}return i.prototype={destroy:function(){},find:function(e){this._text.length>1&&(this._text=[this._text.join("")]);var n=e.string,i=e.regex,r=n,o="",s=e.caseInsensitive;if(r)if(i){var a=t.parse(r);a&&(r=a.pattern,o=a.flags)}else r=n.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&"),s&&(r=r.replace(/[iI\u0130\u0131]/g,"[Iiİı]"));var l,d=null;if(r){var c=e.reverse,h=e.wrap,u=e.wholeWord,f=e.start||0,p=e.rangeStart,g=e.rangeEnd,v=null!==p&&void 0!==p&&null!==g&&void 0!==g;-1===o.indexOf("g")&&(o+="g"),-1===o.indexOf("m")&&(o+="m"),s&&-1===o.indexOf("i")&&(o+="i"),u&&(r="\\b"+r+"\\b");var m,_,y=this._text[0],C=0;if(v){var w=g>p?p:g,x=g>p?g:p;y=y.substring(w,x),C=w}var b=new RegExp(r,o);c?l=function(){var e=null;for(b.lastIndex=0;;){if(_=b.lastIndex,m=b.exec(y),_===b.lastIndex)return null;if(!m)break;if(m.index+C<f)e={start:m.index+C,end:b.lastIndex+C};else{if(!h||e)break;f=y.length+C,e={start:m.index+C,end:b.lastIndex+C}}}return e&&(f=e.start),e}:(b.lastIndex=f-C,l=function(){for(;;){if(_=b.lastIndex,m=b.exec(y),_===b.lastIndex)return null;if(m)return{start:m.index+C,end:b.lastIndex+C};if(0===_||!h)break}return null}),d=l()}return{next:function(){var e=d;return e&&(d=l()),e},hasNext:function(){return null!==d}}},getCharCount:function(){for(var e=0,t=0;t<this._text.length;t++)e+=this._text[t].length;return e},getLine:function(e,t){var n=this.getLineCount();if(!(e>=0&&n>e))return null;var i=this._lineOffsets[e];if(n>e+1){var r=this.getText(i,this._lineOffsets[e+1]);if(t)return r;for(var o,s=r.length;10===(o=r.charCodeAt(s-1))||13===o;)s--;return r.substring(0,s)}return this.getText(i)},getLineAtOffset:function(e){var t=this.getCharCount();if(!(e>=0&&t>=e))return-1;var n=this.getLineCount();if(e===t)return n-1;var i,r,o=this._lastLineIndex;if(o>=0&&n>o&&(i=this._lineOffsets[o],r=n>o+1?this._lineOffsets[o+1]:t,e>=i&&r>e))return o;for(var s=n,a=-1;s-a>1;)if(o=Math.floor((s+a)/2),i=this._lineOffsets[o],r=n>o+1?this._lineOffsets[o+1]:t,i>=e)s=o;else{if(r>e){s=o;break}a=o}return this._lastLineIndex=s,s},getLineCount:function(){return this._lineOffsets.length},getLineDelimiter:function(){return this._lineDelimiter},getLineEnd:function(e,t){var n=this.getLineCount();if(!(e>=0&&n>e))return-1;if(n>e+1){var i=this._lineOffsets[e+1];if(t)return i;for(var r,o=this.getText(Math.max(this._lineOffsets[e],i-2),i),s=o.length;10===(r=o.charCodeAt(s-1))||13===r;)s--;return i-(o.length-s)}return this.getCharCount()},getLineStart:function(e){return e>=0&&e<this.getLineCount()?this._lineOffsets[e]:-1},getText:function(e,t){if(void 0===e&&(e=0),void 0===t&&(t=this.getCharCount()),e===t)return"";for(var n,i=0,r=0;r<this._text.length&&(n=this._text[r].length,!(i+n>=e));)i+=n,r++;for(var o=i,s=r;r<this._text.length&&(n=this._text[r].length,!(i+n>=t));)i+=n,r++;var a=i,l=r;if(s>=this._text.length||l>=this._text.length||s>l)return"";if(s===l)return this._text[s].substring(e-o,t-a);var d=this._text[s].substring(e-o),c=this._text[l].substring(0,t-a);return d+this._text.slice(s+1,l).join("")+c},onChanging:function(e){return r(this,e),this.dispatchEvent(e)},onChanged:function(e){return r(this,e),this.dispatchEvent(e)},setLineDelimiter:function(e,t){if("auto"===e&&(e=void 0,this.getLineCount()>1&&(e=this.getText(this.getLineEnd(0),this.getLineEnd(0,!0)))),this._lineDelimiter=e?e:n.platformDelimiter,t){var i=this.getLineCount();if(i>1){for(var r=new Array(i),o=0;i>o;o++)r[o]=this.getLine(o);this.setText(r.join(this._lineDelimiter))}}},setText:function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=0),void 0===n&&(n=this.getCharCount()),t!==n||""!==e){for(var i=this.getLineAtOffset(t),r=this.getLineAtOffset(n),o=t,s=n-t,a=r-i,l=e.length,d=0,c=this.getLineCount(),h=0,u=0,f=0,p=[];;){if(-1!==h&&f>=h&&(h=e.indexOf("\r",f)),-1!==u&&f>=u&&(u=e.indexOf("\n",f)),-1===u&&-1===h)break;f=-1!==h&&-1!==u?h+1===u?u+1:(u>h?h:u)+1:-1!==h?h+1:u+1,p.push(t+f),d++}var g={type:"Changing",text:e,start:o,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:d};this.onChanging(g);var v=e;if(0===p.length){var m,_=this.getLineStart(i);m=c>r+1?this.getLineStart(r+1):this.getCharCount(),t!==_&&(e=this.getText(_,t)+e,t=_),n!==m&&(e+=this.getText(n,m),n=m)}for(var y=l-s,C=i+a+1;c>C;C++)this._lineOffsets[C]+=y;var w,x=5e4,b=x;if(p.length<b)w=[i+1,a].concat(p),Array.prototype.splice.apply(this._lineOffsets,w);else{f=i+1,this._lineOffsets.splice(f,a);for(var S=0;S<p.length;S+=b)w=[f,0].concat(p.slice(S,Math.min(p.length,S+b))),Array.prototype.splice.apply(this._lineOffsets,w),f+=b}for(var T,E=0,A=0;A<this._text.length&&(T=this._text[A].length,!(E+T>=t));)E+=T,A++;for(var L=E,k=A;A<this._text.length&&(T=this._text[A].length,!(E+T>=n));)E+=T,A++;var M=E,O=A,D=this._text[k],N=this._text[O],I=D.substring(0,t-L),R=N.substring(n-M),B=[k,O-k+1];I&&B.push(I),e&&B.push(e),R&&B.push(R),Array.prototype.splice.apply(this._text,B),0===this._text.length&&(this._text=[""]);var P={type:"Changed",start:o,text:v,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:d};this.onChanged(P)}}},e.EventTarget.addMixin(i.prototype),{TextModel:i}}),n("orion/searchUtils",["i18n!orion/nls/messages","orion/regex","orion/editor/textModel","orion/URITemplate"],function(e,t,n,i){function r(e,n,i){var r="";i&&(r="^");var o=n.wholeWord?"\\b"+e.searchStr+"\\b":e.searchStr,s=t.parse("/"+r+o+"/");if(s){var a=s.pattern,l=s.flags;-1!==l.indexOf("i")||n.caseSensitive||(l+="i"),e.regExp={pattern:a,flags:l},e.wildCard=!0}}var o={};return o.ALL_FILE_TYPE="*.*",o.getSearchParams=function(t,n,i,r){if(t){var s=n,a=!0;if("*"===s&&(s=""),""===s&&(a=i&&i.type!==o.ALL_FILE_TYPE),a){var l=t.createSearchParams(s,!1,!1,i,r);return l}}else window.alert(e.NoSearchAvailableErr);return null},o.generateSearchHelper=function(e,t){var n=e.keyword,i=n,s={};if(e.fileType&&e.fileType!==o.ALL_FILE_TYPE&&""===n&&(i="*."+e.fileType),e.regEx)s.searchStr=n,r(s,e,t);else{var a=n.indexOf("*")>-1,l=n.indexOf("?")>-1;a&&(n=n.split("*").join(".*")),l&&(n=n.split("?").join(".")),e.wholeWord&&(n=a||l?n.replace(/[-[\]{}()+,\\^$|#\s]/g,"\\$&"):n.replace(/[-[\]{}()+.,\\^$|#\s]/g,"\\$&")),a||l||e.nameSearch||e.wholeWord?(s.searchStr=e.caseSensitive?n:n.toLowerCase(),r(s,e,t),s.wildCard=!0):(s.searchStr=e.caseSensitive?n.split("\\").join(""):n.split("\\").join("").toLowerCase(),s.wildCard=!1)}return s.searchStrLength=s.searchStr.length,{params:e,inFileQuery:s,displayedSearchTerm:i}},o.convertSearchParams=function(e){void 0!==e.rows&&(e.rows=parseInt(e.rows,10)),void 0!==e.start&&(e.start=parseInt(e.start,10)),"string"==typeof e.regEx&&(e.regEx="true"===e.regEx.toLowerCase()),"string"==typeof e.caseSensitive&&(e.caseSensitive="true"===e.caseSensitive.toLowerCase()),"string"==typeof e.nameSearch&&(e.nameSearch="true"===e.nameSearch.toLowerCase()),void 0!==e.fileNamePatterns&&(e.fileNamePatterns=o.getFileNamePatternsArray(e.fileNamePatterns))},o.getFileNamePatternsArray=function(e){var t=void 0;if(e){var n=e.trim();n=n.replace(/^(\s*,\s*)+/g,""),n=n.replace(/([^\\]),(\s*,\s*)*/g,"$1/"),n=n.replace(/(\s*\/\s*)/g,"/"),n=n.replace(/\/\/+/g,"/"),n=n.replace(/\/+$/g,""),t=n.split("/")}return t},o.copySearchParams=function(e,t){var n={};for(var i in e)if(void 0!==e[i]&&null!==e[i]){if(!t&&"replace"===i)continue;n[i]=e[i]}return n},o.generateFindURLBinding=function(e,t,n,r,o){var s={find:t.searchStr,regEx:t.wildCard?!0:void 0,caseSensitive:e.caseSensitive?!0:void 0,wholeWord:e.wholeWord?!0:void 0,replaceWith:"string"==typeof r?r:void 0,atLine:"number"==typeof n?n:void 0};if(o)return s;var a=new i("{,params*}").expand({params:s});return","+a},o.convertFindURLBinding=function(e){"string"==typeof e.regEx&&(e.regEx="true"===e.regEx.toLowerCase()),"string"==typeof e.caseSensitive&&(e.caseSensitive="true"===e.caseSensitive.toLowerCase()),"string"==typeof e.wholeWord&&(e.wholeWord="true"===e.wholeWord.toLowerCase()),"string"==typeof e.atLine&&(e.atLine=parseInt(e.atLine,10))},o.replaceRegEx=function(e,t,n){var i=new RegExp(t.pattern,t.flags);return e.replace(i,n)},o.replaceStringLiteral=function(e,n,i){var r=t.parse("/"+n+"/gim");return o.replaceRegEx(e,r,i)},o.searchOnelineLiteral=function(e,t,n,i,r){for(var o,s=0,a=!1,l=[];;){if(o=t.indexOf(e.searchStr,s),0>o)break;if(i){var d=i.getLineStart(r)+o;l.push({startIndex:o,length:e.searchStrLength,start:d,end:d+e.searchStrLength})}else l.push({startIndex:o,length:e.searchStrLength});if(a=!0,n)break;s=o+e.searchStrLength}return a?l:null},o.findRegExp=function(e,t,n,i){if(!t)return null;n=n||"",n+=(-1===n.indexOf("g")?"g":"")+(-1===n.indexOf("m")?"m":"");var r=new RegExp(t,n),o=null;return o=r.exec(e.substring(i)),o&&{startIndex:o.index+i,length:o[0].length}},o.searchOnelineRegEx=function(e,t,n,i,r){for(var s=0,a=!1,l=[];;){var d=o.findRegExp(t,e.regExp.pattern,e.regExp.flags,s);if(!d)break;if(i){var c=i.getLineStart(r)+d.startIndex;d.start=c,d.end=c+d.length}if(l.push(d),a=!0,n)break;s=d.startIndex+d.length}return a?l:null},o.generateNewContents=function(e,t,n,i,r,s){if(i&&t){e||(n.contents=[]);for(var a=0;a<t.length;a++){for(var l,d,c=t[a],h=!1,u=!1,f=[],p=0,g=0;g<i.children.length;g++){var v=i.children[g].lineNumber-1;if(v===a){for(p=g,d=0;d<i.children[g].matches.length;d++)i.children[g+d].checked!==!1&&f.push(d);u=f.length>0,l=i.children[g].matches,h=!0;break}}if(h){var m;if(u){var _=o.replaceCheckedMatches(c,r,l,f,s);for(m=_.replacedStr,d=0;d<i.children[p].matches.length;d++)i.children[p+d].newMatches=_.newMatches}else for(m=c,d=0;d<i.children[p].matches.length;d++)i.children[p+d].newMatches=i.children[p+d].matches;e?n.contents[a]=m:n.contents.push(m)}else e||n.contents.push(c)}}},o.generateMatchContext=function(e,t,n){var i,r,o=[],s=2*e+1;t.length<=s?(i=0,r=t.length-1):(i=n-e,0>i?(i=0,r=i+s-1):(r=n+e,r>t.length-1&&(r=t.length-1,i=r-s+1)));for(var a=i;r>=a;a++)o.push({context:t[a],current:a===n});return o},o.splitFile=function(e){for(var t=0,n=0,i=0,r=0,o=[];;){if(-1!==t&&i>=t&&(t=e.indexOf("\r",i)),-1!==n&&i>=n&&(n=e.indexOf("\n",i)),-1===n&&-1===t){o.push(e.substring(r));break}var s=1;-1!==t&&-1!==n?t+1===n?(s=2,i=n+1):i=(n>t?t:n)+1:i=-1!==t?t+1:n+1,o.push(e.substring(r,i)),r=i}return o},o.searchWithinFile=function(e,t,i,r,s,a,l){var d;(a||l)&&(d=new n.TextModel(i));var c=o.splitFile(i);if((r||a)&&(t.contents=c),t){t.children=[];for(var h=0,u=0;u<c.length;u++){var f=c[u];if(f&&f.length>0){var p,g=s?f:f.toLowerCase();if(p=e.wildCard?o.searchOnelineRegEx(e,g,!1,d,u):o.searchOnelineLiteral(e,g,!1,d,u)){var v,m=u+1;if(r)for(var _=0;_<p.length;_++){var y=_+1;v={parent:t,checked:t.checked,type:"detail",matches:p,lineNumber:m,matchNumber:y,name:f,location:t.location},t.children.push(v)}else v=a?{lineNumber:m,matches:p,name:f}:{parent:t,context:o.generateMatchContext(2,c,u),checked:t.checked,type:"detail",matches:p,lineNumber:m,name:f,location:t.location},t.children.push(v);h+=p.length}}}t.totalMatches=h}},o.replaceCheckedMatches=function(e,t,n,i,r){for(var o=r,s=0,a="",l=[],d=0;d<n.length;d++){s!==n[d].startIndex&&(a+=e.substring(s,n[d].startIndex)),n[d].length&&(o=n[d].length);for(var c=!1,h=0;h<i.length;h++)if(i[h]===d){c=!0;break}c?(l.push({startIndex:a.length,length:t.length}),a+=t):(l.push({startIndex:a.length,length:o}),a+=e.substring(n[d].startIndex,n[d].startIndex+o)),s=n[d].startIndex+o}return s<e.length&&(a+=e.substring(s)),{replacedStr:a,newMatches:l}},o.fullPathNameByMeta=function(e){var t=e.length,n="";if(t>0)for(var i=t-1;i>-1;i--){var r=""===n?"":"/";n=n+r+e[i].Name}return n},o}),n("orion/editor/nls/messages",["module"],function(e){var t=e.config();return t&&t.root?t:{root:!0}}),n("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",collabLineChanged:"Collab Line Changed",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",selectedLines:"Sel",regex:"/.*/",wholeWord:"\\b",caseInsensitiveTooltip:"Toggle Case Insensitive",selectedLinesTooltip:"Toggle Search Scope On Selected Lines",regexTooltip:"Toggle Regular Expression",wholeWordTooltip:"Toggle Whole Word",closeTooltip:"Close",replacingAll:"Replacing all...",replacedMatches:"Replaced ${0} matches",nothingReplaced:"Nothing replaced",notFound:"Not found"}),n("orion/editor/annotations",["i18n!orion/editor/nls/messages","orion/editor/eventTarget"],function(e,t){function n(){}function i(e,t,n){this.start=e,this.end=t,this._projectionModel=n,this.html=this._expandedHTML,this.style=this._expandedStyle,this.expanded=!0}function r(t,i){var r=t.lastIndexOf("."),o=t.substring(r+1),s={title:e[o],style:{styleClass:"annotation "+o},html:"<div class='annotationHTML "+o+"'></div>",overviewStyle:{styleClass:"annotationOverview "+o}};i?s.lineStyle={styleClass:"annotationLine "+o}:s.rangeStyle={styleClass:"annotationRange "+o},n.registerType(t,s)}function o(){}function s(e,t,n,i,r){var o;for(void 0===i&&(i=-1),void 0===r&&(r=e.length);r-i>1;)if(o=Math.floor((r+i)/2),t<=e[o].start)r=o;else{if(n&&t<e[o].end){r=o;break}i=o}return r}function a(e){this._annotations=[];var t=this;this._listener={onChanged:function(e){t._onChanged(e)}},this.setTextModel(e)}function l(e,t){this._view=e,this._annotationModel=t;var n=this;this._listener={onDestroy:function(e){n._onDestroy(e)},onLineStyle:function(e){n._onLineStyle(e)},onChanged:function(e){n._onAnnotationModelChanged(e)}},e.addEventListener("Destroy",this._listener.onDestroy),e.addEventListener("postLineStyle",this._listener.onLineStyle),t.addEventListener("Changed",this._listener.onChanged)}i.prototype={_expandedHTML:"<div class='annotationHTML expanded'></div>",_expandedStyle:{styleClass:"annotation expanded"},_collapsedHTML:"<div class='annotationHTML collapsed'></div>",_collapsedStyle:{styleClass:"annotation collapsed"},_collapse:function(){return this.expanded?(this.expanded=!1,this.html=this._collapsedHTML,this.style=this._collapsedStyle,this._annotationModel&&this._annotationModel.modifyAnnotation(this),!0):!1},_expand:function(){return this.expanded?!1:(this.expanded=!0,this.html=this._expandedHTML,this.style=this._expandedStyle,this._annotationModel&&this._annotationModel.modifyAnnotation(this),!0)},_collapseImpl:function(e){if(this._collapse()){e&&this._forEachOverlaping(function(e){e.expanded||(e._expandImpl(!1),e._recollapse=!0)});var t=this._projectionModel,n=t.getBaseModel();this._projection={annotation:this,start:n.getLineStart(n.getLineAtOffset(this.start)+1),end:n.getLineEnd(n.getLineAtOffset(this.end),!0)},t.addProjection(this._projection)}},_expandImpl:function(e){this._expand()&&(this._projectionModel._removeProjection(this._projection,!this._annotationModel),e&&this._forEachOverlaping(function(e){e._recollapse&&(e._collapseImpl(!1),e._recollapse=!1)}))},_forEachOverlaping:function(e){if(this._annotationModel)for(var t=this._annotationModel.getAnnotations(this.start,this.end);t.hasNext();){var i=t.next();i!==this&&i.type===n.ANNOTATION_FOLDING&&e.call(this,i)}},collapse:function(){this._recollapse=!1,this._collapseImpl(!0)},expand:function(){this._recollapse=!1,this._expandImpl(!0)}},n.ANNOTATION_ERROR="orion.annotation.error",n.ANNOTATION_WARNING="orion.annotation.warning",n.ANNOTATION_INFO="orion.annotation.info",n.ANNOTATION_TASK="orion.annotation.task",n.ANNOTATION_BREAKPOINT="orion.annotation.breakpoint",n.ANNOTATION_CONDITIONAL_BREAKPOINT="orion.annotation.conditionalBreakpoint",n.ANNOTATION_BOOKMARK="orion.annotation.bookmark",n.ANNOTATION_FOLDING="orion.annotation.folding",n.ANNOTATION_CURRENT_BRACKET="orion.annotation.currentBracket",n.ANNOTATION_MATCHING_BRACKET="orion.annotation.matchingBracket",n.ANNOTATION_CURRENT_LINE="orion.annotation.currentLine",n.ANNOTATION_HIGHLIGHTED_LINE="orion.annotation.highlightedLine",n.ANNOTATION_CURRENT_SEARCH="orion.annotation.currentSearch",n.ANNOTATION_MATCHING_SEARCH="orion.annotation.matchingSearch",n.ANNOTATION_SEARCH_RANGE="orion.annotation.searchRange",n.ANNOTATION_READ_OCCURRENCE="orion.annotation.readOccurrence",n.ANNOTATION_WRITE_OCCURRENCE="orion.annotation.writeOccurrence",n.ANNOTATION_SELECTED_LINKED_GROUP="orion.annotation.selectedLinkedGroup",n.ANNOTATION_CURRENT_LINKED_GROUP="orion.annotation.currentLinkedGroup",n.ANNOTATION_LINKED_GROUP="orion.annotation.linkedGroup",n.ANNOTATION_BLAME="orion.annotation.blame",n.ANNOTATION_CURRENT_BLAME="orion.annotation.currentBlame",n.ANNOTATION_DIFF_ADDED="orion.annotation.diffAdded",n.ANNOTATION_DIFF_DELETED="orion.annotation.diffDeleted",n.ANNOTATION_DIFF_MODIFIED="orion.annotation.diffModified",n.ANNOTATION_COLLAB_LINE_CHANGED="orion.annotation.collabLineChanged";var d={};return n.registerType=function(e,t){var n=t;return"function"!=typeof n&&(n=function(e,t,n){this.start=e,this.end=t,void 0!==n&&(this.title=n)},n.prototype=t),n.prototype.type=e,d[e]=n,e},n.createAnnotation=function(e,t,n,i){return new(this.getType(e))(t,n,i)},n.getType=function(e){return d[e]},r(n.ANNOTATION_ERROR),r(n.ANNOTATION_WARNING),r(n.ANNOTATION_INFO),r(n.ANNOTATION_TASK),r(n.ANNOTATION_BREAKPOINT),r(n.ANNOTATION_CONDITIONAL_BREAKPOINT),r(n.ANNOTATION_BOOKMARK),r(n.ANNOTATION_CURRENT_BRACKET),r(n.ANNOTATION_MATCHING_BRACKET),r(n.ANNOTATION_CURRENT_SEARCH),r(n.ANNOTATION_MATCHING_SEARCH),r(n.ANNOTATION_SEARCH_RANGE,!0),r(n.ANNOTATION_READ_OCCURRENCE),r(n.ANNOTATION_WRITE_OCCURRENCE),r(n.ANNOTATION_SELECTED_LINKED_GROUP),r(n.ANNOTATION_CURRENT_LINKED_GROUP),r(n.ANNOTATION_LINKED_GROUP),r(n.ANNOTATION_CURRENT_LINE,!0),r(n.ANNOTATION_HIGHLIGHTED_LINE,!0),r(n.ANNOTATION_BLAME,!0),r(n.ANNOTATION_CURRENT_BLAME,!0),r(n.ANNOTATION_DIFF_ADDED),r(n.ANNOTATION_DIFF_DELETED),r(n.ANNOTATION_DIFF_MODIFIED),r(n.ANNOTATION_COLLAB_LINE_CHANGED,!0),n.registerType(n.ANNOTATION_FOLDING,i),o.addMixin=function(e){var t=o.prototype;for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},o.prototype={addAnnotationType:function(e,t){this._annotationTypes||(this._annotationTypes=[]);var n=t-1;void 0!=t&&n>=0&&n<this._annotationTypes.length?this._annotationTypes.splice(n,0,e):this._annotationTypes.push(e)},getAnnotationTypePriority:function(e){if(this._annotationTypes)for(var t=0;t<this._annotationTypes.length;t++)if(this._annotationTypes[t]===e)return t+1;return 0},getAnnotationsByType:function(e,t,n){for(var i,r=e.getAnnotations(t,n),o=[];r.hasNext();)i=r.next(),this.isAnnotationTypeVisible(i.type)&&o.push(i);var s=this;return o.sort(function(e,t){return s.getAnnotationTypePriority(e.type)-s.getAnnotationTypePriority(t.type)}),o},isAnnotationTypeVisible:function(e){return 0===this.getAnnotationTypePriority(e)?!1:!this._visibleAnnotationTypes||void 0===this._visibleAnnotationTypes[e]||this._visibleAnnotationTypes[e]===!0},setAnnotationTypeVisible:function(e,t){"object"==typeof e?this._visibleAnnotationTypes=e:(this._visibleAnnotationTypes||(this._visibleAnnotationTypes={}),this._visibleAnnotationTypes[e]=t)},removeAnnotationType:function(e){if(this._annotationTypes)for(var t=0;t<this._annotationTypes.length;t++)if(this._annotationTypes[t]===e){this._annotationTypes.splice(t,1);break}}},a.prototype={addAnnotation:function(e){if(e){var t=this._annotations,n=s(t,e.start);t.splice(n,0,e),e._annotationModel=this;var i={type:"Changed",added:[e],removed:[],changed:[]};this.onChanged(i)}},getTextModel:function(){return this._model},getAnnotations:function(e,t){var n,i,r=this._annotations,o=0;return i=void 0===e&&void 0===t?function(){return o<r.length?r[o++]:null}:function(){for(;o<r.length;){var n=r[o++];if(e===n.start||n.start===n.end&&n.end===t||(e>n.start?e<n.end:n.start<t))return n;if(n.start>=t)break}return null},n=i(),{next:function(){var e=n;return e&&(n=i()),e},hasNext:function(){return null!==n}}},modifyAnnotation:function(e){if(e){var t=this._getAnnotationIndex(e);if(!(0>t)){var n={type:"Changed",added:[],removed:[],changed:[e]};this.onChanged(n)}}},onChanged:function(e){return this.dispatchEvent(e)},removeAnnotations:function(e){var t,n,i=this._annotations;if(e)for(t=[],n=i.length-1;n>=0;n--){var r=i[n];r.type===e&&(i.splice(n,1),t.splice(0,0,r),r._annotationModel=null)}else t=i,i=[];var o={type:"Changed",removed:t,added:[],changed:[]};this.onChanged(o)},removeAnnotation:function(e){if(e){var t=this._getAnnotationIndex(e);if(!(0>t)){e._annotationModel=null;var n={type:"Changed",removed:this._annotations.splice(t,1),added:[],changed:[]};this.onChanged(n)}}},replaceAnnotations:function(e,t){var n,i,r,o=this._annotations,a=[];if(e)for(n=e.length-1;n>=0;n--)r=e[n],i=this._getAnnotationIndex(r),0>i||(r._annotationModel=null,o.splice(i,1),a.splice(0,0,r));for(t||(t=[]),n=0;n<t.length;n++)r=t[n],i=s(o,r.start),r._annotationModel=this,o.splice(i,0,r);var l={type:"Changed",removed:a,added:t,changed:[]};this.onChanged(l)},setTextModel:function(e){this._model&&this._model.removeEventListener("Changed",this._listener.onChanged),this._model=e,this._model&&this._model.addEventListener("Changed",this._listener.onChanged)},_getAnnotationIndex:function(e){for(var t=this._annotations,n=s(t,e.start);n<t.length&&t[n].start===e.start;){if(t[n]===e)return n;n++}return-1},_onChanged:function(e){var t=e.start,n=e.addedCharCount,i=e.removedCharCount,r=this._annotations,o=t+i,s=0;if(s>=0&&s<r.length){var a,l={type:"Changed",added:[],removed:[],changed:[],textModelChangedEvent:e},d=n-i;for(a=s;a<r.length;a++){var c=r[a];c.start>=o?(c._oldStart=c.start,c._oldEnd=c.end,c.start+=d,c.end+=d,l.changed.push(c)):c.end<=t||(c.start<=t&&o<c.end?(c._oldStart=c.start,c._oldEnd=c.end,c.end+=d,l.changed.push(c)):(r.splice(a,1),l.removed.push(c),c._annotationModel=null,c.expand&&c.expand(),a--))}(l.added.length>0||l.removed.length>0||l.changed.length>0)&&this.onChanged(l)}}},t.EventTarget.addMixin(a.prototype),l.prototype={destroy:function(){var e=this._view;e&&(e.removeEventListener("Destroy",this._listener.onDestroy),e.removeEventListener("LineStyle",this._listener.onLineStyle),this.view=null);var t=this._annotationModel;t&&(t.removeEventListener("Changed",this._listener.onChanged),t=null)},_mergeStyle:function(e,t){if(t){e||(e={}),e.styleClass&&t.styleClass&&e.styleClass!==t.styleClass?e.styleClass+=" "+t.styleClass:e.styleClass=t.styleClass;var n;if(t.tagName&&(e.tagName||(e.tagName=t.tagName)),t.style){e.style||(e.style={});for(n in t.style)e.style[n]||(e.style[n]=t.style[n])}if(t.attributes){e.attributes||(e.attributes={});for(n in t.attributes)e.attributes[n]||(e.attributes[n]=t.attributes[n])}t.html&&(e.html=t.html),t.node&&(e.node=t.node)}return e},_mergeStyleRanges:function(e,t){e||(e=[]);for(var n,i=s(e,t.start,!0);i<e.length&&t;i++){var r=e[i];if(t.end<=r.start)break;if(!(t.start>=r.end)){n=this._mergeStyle({},r.style),n=this._mergeStyle(n,t.style);var o=[];o.push(i,1),t.start<r.start&&o.push({start:t.start,end:r.start,style:t.style}),t.start>r.start&&o.push({start:r.start,end:t.start,style:r.style}),o.push({start:Math.max(r.start,t.start),end:Math.min(r.end,t.end),style:n}),t.end<r.end&&o.push({start:t.end,end:r.end,style:r.style}),t=t.end>r.end?{start:r.end,end:t.end,style:t.style}:null,Array.prototype.splice.apply(e,o) }}return t&&(n=this._mergeStyle({},t.style),e.splice(i,0,{start:t.start,end:t.end,style:n})),e},_onAnnotationModelChanged:function(e){function t(e,t){o.getBaseModel&&(e=o.mapOffset(e,!0),t=o.mapOffset(t,!0)),-1!==e&&-1!==t&&i.redrawRange(e,t)}function n(e,n){for(var i=0;i<e.length;i++)if(r.isAnnotationTypeVisible(e[i].type)){var o=e[i];t(o.start,o.end),n&&void 0!==o._oldStart&&o._oldEnd&&t(o._oldStart,o._oldEnd)}}var i=this._view;if(i){var r=this,o=i.getModel();n(e.added),n(e.removed),n(e.changed,!0)}},_onDestroy:function(){this.destroy()},_onLineStyle:function(e){var t=this._annotationModel,n=e.textView.getModel(),i=t.getTextModel(),r=e.lineStart,o=e.lineStart+e.lineText.length;i!==n&&(r=n.mapOffset(r),o=n.mapOffset(o));for(var s=t.getAnnotations(r,o);s.hasNext();){var a=s.next();if(this.isAnnotationTypeVisible(a.type)){if(a.rangeStyle){var l=a.start,d=a.end;i!==n&&(l=n.mapOffset(l,!0),d=n.mapOffset(d,!0)),e.ranges=this._mergeStyleRanges(e.ranges,{start:l,end:d,style:a.rangeStyle})}a.lineStyle&&(e.style=this._mergeStyle({},e.style),e.style=this._mergeStyle(e.style,a.lineStyle))}}}},o.addMixin(l.prototype),{FoldingAnnotation:i,AnnotationType:n,AnnotationTypeList:o,AnnotationModel:a,AnnotationStyler:l}}),n("orion/editorCommands",["i18n!orion/edit/nls/messages","orion/i18nUtil","orion/webui/littlelib","orion/fileUtils","orion/widgets/input/DropDownMenu","orion/Deferred","orion/URITemplate","orion/commands","orion/keyBinding","orion/commandRegistry","orion/extensionCommands","orion/contentTypes","orion/searchUtils","orion/objects","orion/PageUtil","orion/PageLinks","orion/editor/annotations","orion/regex","orion/PageUtil","orion/uiUtils","orion/util","orion/urlModifier"],function(e,t,n,i,r,o,s,a,l,d,c,h,u,f,p,g,v,m,_,y,C,w){function x(e){var t=new s(e.uriTemplate),n=e.params||{};n.OrionHome=n.OrionHome||g.getOrionHome();var i=t.expand(n),r=document.createElement("div"),o=document.createElement("iframe");return o.id=e.id,o.name=e.id,o.type="text/html",o.sandbox="allow-scripts allow-same-origin allow-forms allow-popups",o.frameborder=void 0!==e.border?e.border:1,o.src=w(i),o.className="delegatedUI",e.width&&(r.style.width=e.width,o.style.width=e.width),e.height&&(r.style.height=e.height,o.style.height=e.height),o.style.visibility="hidden",null!==e.parent&&(e.parent||window.document.body).appendChild(r),r.appendChild(o),o.style.left=e.left||(window.innerWidth-parseInt(o.clientWidth,10))/2+"px",o.style.top=e.top||(window.innerHeight-parseInt(o.clientHeight,10))/2+"px",o.style.visibility="",window.addEventListener("message",function a(t){if(t.source===o.contentWindow&&"string"==typeof t.data){var n=JSON.parse(t.data);"orion.page.delegatedUI"===n.pageService&&n.source===e.id&&(n.cancelled?e.cancelled&&e.cancelled():n.result?e.done&&e.done(n.result):(n.Status||n.status)&&e.status&&e.status(n.Status||n.status),window.removeEventListener("message",a,!1),r.parentNode&&r.parentNode.removeChild(r))}},!1),r}function b(e,t){t&&"undefined"!=typeof t.HTML&&delete t.HTML;var n=e.getService("orion.page.message");return n?n.setProgressResult(t).then(null,function(e){throw console.log(e),e}):(console.log(t),(new o).resolve(t))}function S(e){return{_error:e}}function T(e){this.serviceRegistry=e.serviceRegistry,this.commandService=e.commandRegistry,this.fileClient=e.fileClient,this.preferences=e.preferences,this.inputManager=e.inputManager,this.renderToolbars=e.renderToolbars,this.toolbarId=e.toolbarId,this.saveToolbarId=e.saveToolbarId,this.editToolbarId=e.editToolbarId,this.pageNavId=e.navToolbarId,this.editorContextMenuId=e.editorContextMenuId,this.isReadOnly=e.readonly,this.textSearcher=e.textSearcher,this.searcher=e.searcher,this.localSettings=e.localSettings,this.editorPreferences=e.editorPreferences,this.differ=e.differ,this.blamer=e.blamer,this.formatter=e.formatter,this.references=e.references,this.openDecl=e.openDecl;var t=this;this.listener={onServiceAdded:function(e){t._onServiceAdded(e.serviceReference)},onServiceRemoved:function(e){t._onServiceRemoved(e.serviceReference)}},this.serviceRegistry.addEventListener("registered",this.listener.onServiceAdded),this.serviceRegistry.addEventListener("unregistering",this.listener.onServiceRemoved)}var E={},A=null;return E.createDelegatedUI=x,T.prototype={createCommands:function(){return this._createSettingsCommand(),this._createGotoLineCommnand(),this._createFindCommnand(),this._createBlameCommand(),this._createDiffCommand(),this._createUndoStackCommands(),this._createClipboardCommands(),this._createDelimiterCommands(),this._createEncodingCommand(),this._createFormatterCommand(),this._createSaveCommand(),this._createOpenFolderCommand(),this._createOpenRecentCommand(),this._createSwitchWorkspaceCommand(),this._createReferencesCommand(),this._createOpenDeclCommand(),this._createEditCommands()},setSideBar:function(e){this.sideBar=e},getEditCommands:function(){var e=[],t=this.commandService;for(var n in t._commandList){var i=t._commandList[n];i.editInfo&&e.push(i)}return e},updateCommands:function(e){e=e||{},this.editor=e.editor,this.inputManager=e.inputManager||e.editorInputManager,this.localSettings=e.localSettings,this.differ=e.differ,this.blamer=e.blamer,this.formatter=e.formatter,this.references=e.references,this.openDecl=e.openDecl,this.textSearcher=e.textSearcher,this._recreateEditCommands&&this._createEditCommands().then(function(){this.registerCommands(),this.registerContextMenuCommands(),this.renderToolbars&&this.renderToolbars()}.bind(this))},_registerCommandGroups:function(e,t){var n,i=this.commandService,r=this.serviceRegistry,o=r.getServiceReferences("orion.edit.command.category");o.forEach(function(r){for(var o={},s=r.getPropertyKeys(),a=0;a<s.length;a++)o[s[a]]=r.getProperty(s[a]);n=t,o.parentPath&&(n+="/"+o.parentPath),i.addCommandGroup(e,o.id,o.position||101,o.name,n,null,o.imageClass)}.bind(this))},registerCommands:function(){function t(e){if(!e)return null;var t=new l.KeyBinding;return l.KeyBinding.apply(t,e),t}var n=this.commandService;this.preferences&&this.preferences.get("/editorSettingsActions").then(function(e){Boolean(e)&&Boolean(e.disabled)||n.registerCommandContribution("settingsActions","orion.edit.settings",1,null,!1,new l.KeyBinding("s",!0,!0),null,this)}.bind(this)),n.registerCommandContribution(this.editToolbarId||this.toolbarId,"orion.edit.undo",400,this.editToolbarId?"orion.menuBarEditGroup/orion.edit.undoGroup":null,!this.editToolbarId,new l.KeyBinding("z",!0),null,this),n.registerCommandContribution(this.editToolbarId||this.toolbarId,"orion.edit.redo",401,this.editToolbarId?"orion.menuBarEditGroup/orion.edit.undoGroup":null,!this.editToolbarId,C.isMac?new l.KeyBinding("z",!0,!0):new l.KeyBinding("y",!0),null,this),n.registerCommandContribution(this.saveToolbarId||this.toolbarId,"orion.edit.openFolder",1,this.saveToolbarId?"orion.menuBarFileGroup/orion.edit.saveGroup":null,!1,new l.KeyBinding("o",!0)),n.registerCommandContribution(this.saveToolbarId||this.toolbarId,"orion.edit.openRecent",3,this.saveToolbarId?"orion.menuBarFileGroup/orion.edit.saveGroup":null,!1,null),n.registerCommandContribution(this.saveToolbarId||this.toolbarId,"orion.edit.switchWorkspace",0,this.saveToolbarId?"orion.menuBarFileGroup/orion.edit.workspaceGroup":null,!1,null),n.registerCommandContribution(this.saveToolbarId||this.toolbarId,"orion.openResource",1,this.saveToolbarId?"orion.menuBarFileGroup/orion.edit.saveGroup":null,!1,new l.KeyBinding("f",!0,!0)),n.registerCommandContribution(this.saveToolbarId||this.toolbarId,"orion.edit.save",2,this.saveToolbarId?"orion.menuBarFileGroup/orion.edit.saveGroup":null,!1,new l.KeyBinding("s",!0),null,this),n.registerCommandContribution(this.saveToolbarId||this.toolbarId,"eclipse.file.refresh",3,this.saveToolbarId?"orion.menuBarFileGroup/orion.edit.saveGroup":null,!1,null,null,this),n.registerCommandContribution(this.editToolbarId||this.pageNavId,"orion.edit.gotoLine",3,this.editToolbarId?"orion.menuBarEditGroup/orion.findGroup":null,!this.editToolbarId,new l.KeyBinding("l",!C.isMac,!1,!1,C.isMac),new d.URLBinding("gotoLine","line"),this),n.registerCommandContribution(this.editToolbarId||this.pageNavId,"orion.edit.find",0,this.editToolbarId?"orion.menuBarEditGroup/orion.findGroup":null,!this.editToolbarId,new l.KeyBinding("f",!0),new d.URLBinding("find","find"),this),n.registerCommandContribution(this.editToolbarId||this.pageNavId,"orion.edit.format",2,this.editToolbarId?"orion.menuBarEditGroup/orion.edit.formatGroup":null,!this.editToolbarId,new l.KeyBinding("f",!1,!0,!0),new d.URLBinding("format","format"),this),n.registerCommandContribution(this.toolbarId,"orion.keyAssist",0,"orion.menuBarToolsGroup",!1,new l.KeyBinding(191,!1,!0,!C.isMac,C.isMac)),n.registerCommandContribution(this.toolbarId,"orion.edit.showTooltip",1,"orion.menuBarToolsGroup",!1,null,null,this),n.registerCommandContribution(this.toolbarId,"orion.edit.blame",2,"orion.menuBarToolsGroup",!1,new l.KeyBinding("b",!0,!0),new d.URLBinding("blame","blame"),this),n.registerCommandContribution(this.toolbarId,"orion.edit.diff",3,"orion.menuBarToolsGroup",!1,new l.KeyBinding("d",!0,!0),new d.URLBinding("diff","diff"),this),n.registerCommandContribution(this.toolbarId,"orion.edit.references",5,"orion.menuBarToolsGroup",!1,new l.KeyBinding("y",!0,!0),null,this),n.registerCommandContribution(this.toolbarId,"orion.edit.open.declaration",5,"orion.menuBarToolsGroup",!1,new l.KeyBinding(114,!1,!1),null,this);var i=0;n.addCommandGroup(this.toolbarId,"orion.editorMenuBarMenuDelimitersGroup",999,e["Convert Line Delimiters"],"orion.menuBarToolsGroup"),n.registerCommandContribution(this.toolbarId,"orion.edit.convert.crlf",i++,"orion.menuBarToolsGroup/orion.editorMenuBarMenuDelimitersGroup",!1,null,null,this),n.registerCommandContribution(this.toolbarId,"orion.edit.convert.lf",i++,"orion.menuBarToolsGroup/orion.editorMenuBarMenuDelimitersGroup",!1,null,null,this),n.registerCommandContribution(this.toolbarId,"orion.edit.reloadWithEncoding",1e3,"orion.menuBarToolsGroup"),this._registerCommandGroups(this.toolbarId,"orion.menuBarToolsGroup");for(var r=this.getEditCommands(),o=0,s=100;o<r.length;o++,s++){var a=r[o],c=a.editInfo;if(c.scopeId)n.registerCommandContribution(c.scopeId,a.id,s,c.scopeId+"Group",c.bindingOnly,t(c.key),null,this);else{var h="orion.menuBarToolsGroup";c.parentPath&&(h+="/"+c.parentPath),n.registerCommandContribution(this.toolbarId,a.id,s,h,c.bindingOnly,t(c.key),null,this)}}},registerContextMenuCommands:function(){var t=this.commandService;t.addCommandGroup(this.editorContextMenuId,"orion.editorContextMenuGroup",100,null,null,null,null,null,"dropdownSelection");var n=1;t.registerCommandContribution(this.editorContextMenuId,"orion.edit.copy",n++,"orion.editorContextMenuGroup/orion.edit.copyGroup",!1,new l.KeyBinding("c",!0)),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.cut",n++,"orion.editorContextMenuGroup/orion.edit.copyGroup",!1,new l.KeyBinding("x",!0)),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.paste",n++,"orion.editorContextMenuGroup/orion.edit.copyGroup",!1,new l.KeyBinding("v",!0)),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.undo",n++,"orion.editorContextMenuGroup/orion.edit.undoGroup",!1),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.redo",n++,"orion.editorContextMenuGroup/orion.edit.undoGroup",!1),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.find",n++,"orion.editorContextMenuGroup/orion.findGroup",!1),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.gotoLine",n++,"orion.editorContextMenuGroup/orion.findGroup",!1),t.registerCommandContribution(this.editorContextMenuId,"orion.quickSearch",n++,"orion.editorContextMenuGroup/orion.findGroup",!1),t.registerCommandContribution(this.editorContextMenuId,"orion.openSearch",n++,"orion.editorContextMenuGroup/orion.findGroup",!1),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.format",n++,"orion.editorContextMenuGroup/orion.edit.formatGroup",!1),t.addCommandGroup(this.editorContextMenuId,"orion.editorContextMenuToolsGroup",400,e.Tools,"orion.editorContextMenuGroup"),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.reloadWithEncoding",1e3,"orion.editorContextMenuGroup/orion.editorContextMenuToolsGroup"),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.blame",1,"orion.editorContextMenuGroup/orion.editorContextMenuToolsGroup",!1),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.diff",2,"orion.editorContextMenuGroup/orion.editorContextMenuToolsGroup",!1),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.references",5,"orion.editorContextMenuGroup/orion.editorContextMenuToolsGroup",!1),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.open.declaration",4,"orion.editorContextMenuGroup/orion.editorContextMenuToolsGroup",!1),t.addCommandGroup(this.editorContextMenuId,"orion.editorContextMenuDelimitersGroup",999,e["Convert Line Delimiters"],"orion.editorContextMenuGroup/orion.editorContextMenuToolsGroup"),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.convert.crlf",n++,"orion.editorContextMenuGroup/orion.editorContextMenuToolsGroup/orion.editorContextMenuDelimitersGroup"),t.registerCommandContribution(this.editorContextMenuId,"orion.edit.convert.lf",n++,"orion.editorContextMenuGroup/orion.editorContextMenuToolsGroup/orion.editorContextMenuDelimitersGroup"),this._registerCommandGroups(this.editorContextMenuId,"orion.editorContextMenuGroup/orion.editorContextMenuToolsGroup");for(var i=this.getEditCommands(),r=0,o=100;r<i.length;r++,o++){var s=i[r],a=s.editInfo,d="orion.editorContextMenuGroup/orion.editorContextMenuToolsGroup";a.parentPath&&(d+="/"+a.parentPath),this.commandService.registerCommandContribution(this.editorContextMenuId,s.id,o,d)}},overwriteKeyBindings:function(e){var t=this;if(this.editor=e,e.getTextView&&e.getTextView()){var n=e.getTextView();n.setKeyBinding(new l.KeyBinding("s",!0),"save");var i=t.commandService.findCommand("orion.edit.save");i&&n.setAction("save",function(){return i.callback.call({inputManager:t.inputManager}),!0},i),n.setAction("gotoLine",function(n){return n?(e.onGotoLine(n.line-1,0,void 0,n.callback),!0):(t.commandService.runCommand("orion.edit.gotoLine"),!0)},t.commandService.findCommand("orion.edit.gotoLine")),this.textSearcher&&n.setAction("find",function(e){return e?(t.textSearcher.show(e),!0):(t.commandService.runCommand("orion.edit.find"),!0)},t.commandService.findCommand("orion.edit.find")),this.bindingChangeListener=function(e){this._handleBindingChanges(n,e)}.bind(this),this.commandService.addEventListener("bindingChanged",this.bindingChangeListener)}},_handleBindingChanges:function(e,t){var n=e.getActions(!0);-1!==n.indexOf(t.id)&&(t.prevBinding&&e.setKeyBinding(t.prevBinding,null),e.setKeyBinding(t.newBinding,t.id))},showKeyBindings:function(t){var n=this.editor;if(n&&n.getTextView&&n.getTextView()){var i=n.getTextView(),r=i.getActions(!0).filter(function(e){var t=i.getActionDescription(e);return t&&t.name});r.sort(function(e,t){return i.getActionDescription(e).name.localeCompare(i.getActionDescription(t).name)}),t.createHeader(e.Editor);for(var o,s=function(e){return function(){return i.focus(),i.invokeAction(e)}},a={},l=0;l<r.length;l++){var d=r[l],c=i.getActionDescription(d),h=i.getKeyBindings(d);if(h.length>0)for(var u=0;u<h.length;u++)o=h[u],o.scopeName?(a[o.scopeName]||(a[o.scopeName]=[]),a[o.scopeName].push({binding:o,name:c.name,execute:s(d)})):t.createItem(o,c.name,d,s(d));else t.createItem(null,c.name,d,s(d))}for(var f in a)if(a[f].length){t.createHeader(f);for(var p=0;p<a[f].length;p++)o=a[f][p],t.createItem(o.binding,o.name,o.name,o.execute)}}},_createSettingsCommand:function(){var t=this,n=new a.Command({imageClass:"core-sprite-wrench",name:e.EditorSettings,tooltip:e.LocalEditorSettings,id:"orion.edit.settings",visibleWhen:function(e,n){var i=n.handler.editor||t.editor;return i&&i.installed&&n.handler.localSettings},callback:function(e){var i=this.localSettings||t.localSettings,o=n.settingsDropDown;if(!o||o.isDestroyed()){o=n.settingsDropDown=new r(e.domNode.parentNode,e.domNode,{noClick:!0,selectionClass:"dropdownSelection",onShow:function(){o.focus()},onHide:function(){t.editor.focus()}}),o.updateContent=i.show.bind(i);var s=o.getContentNode();s.tabIndex=s.style.marginTop=0}o.click()}});this.commandService.addCommand(n)},_createDelimiterCommands:function(){var t=this,n=function(n){var i=t.editor;if(i&&i.getModel()){var r=i.getModel();r.setLineDelimiter(n,!0);var o=t.serviceRegistry.getService("orion.page.progress");if(o){var s=e["\r\n"===n?"ConversionCompleteCRLF":"ConversionCompleteLF"];o.setProgressResult({Message:s})}i.focus()}},i=new a.Command({name:e["Windows (CR/LF)"],id:"orion.edit.convert.crlf",visibleWhen:function(e,n){var i=n.handler.editor||t.editor;return i&&i.installed},callback:function(){n("\r\n")}});this.commandService.addCommand(i);var r=new a.Command({name:e["Unix (LF)"],id:"orion.edit.convert.lf",visibleWhen:function(e,n){var i=n.handler.editor||t.editor;return i&&i.installed},callback:function(){n("\n")}});this.commandService.addCommand(r)},_createClipboardCommands:function(){if(C.isIE||C.isElectron){var t=this,n=new a.Command({name:e.Copy,id:"orion.edit.copy",visibleWhen:function(e,n){var i=n.handler.editor||t.editor;return i&&i.installed},callback:function(){var e=this.editor||t.editor;if(e&&e.getTextView&&e.getTextView()){var n=e.getTextView();n.copy(),e.focus()}}});this.commandService.addCommand(n);var i=new a.Command({name:e.Cut,id:"orion.edit.cut",visibleWhen:function(e,n){var i=n.handler.editor||t.editor;return i&&i.installed},callback:function(){var e=this.editor||t.editor;if(e&&e.getTextView&&e.getTextView()){var n=e.getTextView();n.cut(),e.focus()}}});this.commandService.addCommand(i);var r=new a.Command({name:e.Paste,id:"orion.edit.paste",visibleWhen:function(e,n){var i=n.handler.editor||t.editor;return i&&i.installed},callback:function(){var e=this.editor||t.editor;if(e&&e.getTextView&&e.getTextView()){var n=e.getTextView();n.paste(),e.focus()}}});this.commandService.addCommand(r)}},_createUndoStackCommands:function(){var t=this,n=new a.Command({name:e.Undo,id:"orion.edit.undo",visibleWhen:function(e,n){var i=n.handler.editor||t.editor;return i&&i.installed},callback:function(){var e=this.editor||t.editor;e.getUndoStack().undo()}});this.commandService.addCommand(n);var i=new a.Command({name:e.Redo,id:"orion.edit.redo",visibleWhen:function(e,n){var i=n.handler.editor||t.editor;return i&&i.installed},callback:function(){var e=this.editor||t.editor;e.getUndoStack().redo()}});this.commandService.addCommand(i)},_createSaveCommand:function(){var t=this,n=new a.Command({name:e.Save,tooltip:e.saveFile,imageClass:"core-sprite-save",id:"orion.edit.save",visibleWhen:function(e,n){var i=n.handler.inputManager||t.inputManager,r=n.handler.editor||t.editor||i&&i.getEditor();return r&&r.installed&&i&&i.isSaveEnabled()?!0:!1},callback:function(){var e=this.inputManager||t.inputManager;e.save()}});this.commandService.addCommand(n)},_createSwitchWorkspaceCommand:function(){var t=this,n=this.fileClient.fileServiceRootURL(window.location.hash.substring(1));this.fileClient.loadWorkspaces(n).then(function(r){this.sideBar&&this.sideBar.sidebarNavInputManager.addEventListener("filesystemChanged",function(e){n=e.newInput,this.fileClient.loadWorkspaces(n).then(function(e){r=e})}.bind(this)),this.fileClient.addEventListener("Changed",function(e){e.deleted&&e.deleted.some(function(e){return i.isAtRoot(e.deleteLocation)})&&this.fileClient.loadWorkspaces(n).then(function(e){r=e})}.bind(this));var o=new s("#{,resource,params*}"),l=new a.Command({name:e.SwitchWorkspace,tooltip:e.SwitchWorkspaceTip,id:"orion.edit.switchWorkspace",visibleWhen:function(){return r&&r.length>1},choiceCallback:function(){var e=this.inputManager||t.inputManager,n=e&&e.getFileMetadata();return r.map(function(e){return{name:e.Name,checked:n&&(n.WorkspaceLocation||n.Location)===e.Location,callback:function(){window.location=o.expand({resource:e.Location})}}})}});t.commandService.addCommand(l)}.bind(this))},_createOpenFolderCommand:function(){var t=this,n=new a.Command({name:e.OpenFolder,tooltip:e.OpenFolderTip,id:"orion.edit.openFolder",visibleWhen:function(){return C.isElectron},callback:function(){window.__electron.remote.dialog.showOpenDialog({properties:["openDirectory"]},function(e){e&&t.fileClient.changeWorkspace(e[0]).then(function(){localStorage.removeItem("/inlineSearchOtherScope");var e=t.serviceRegistry.getService("orion.core.search.client");e&&e.setLocationOther(null),delete sessionStorage.lastFile})})}});this.commandService.addCommand(n)},_createOpenRecentCommand:function(){var t=this;this.preferences&&this.preferences.get("/workspace",void 0,{noCache:!0}).then(function(e){return e.recentWorkspaces}).then(function(n){var i=new a.Command({name:e.OpenRecent,selectionClass:"dropdownSelection",id:"orion.edit.openRecent",visibleWhen:function(){return C.isElectron&&!!n},choiceCallback:function(){return n.map(function(e){return{name:e,callback:function(){t.fileClient.changeWorkspace(e).then(function(){localStorage.removeItem("/inlineSearchOtherScope");var e=t.serviceRegistry.getService("orion.core.search.client");e&&e.setLocationOther(null),delete sessionStorage.lastFile})}}})}});t.commandService.addCommand(i)})},_createEncodingCommand:function(){var t=this,n=["UTF-8","UTF-16LE","iso-8859-1","iso-8859-2","iso-8859-3","iso-8859-4","iso-8859-5","iso-8859-6","iso-8859-7","iso-8859-8","iso-8859-9","iso-8859-10","iso-8859-11","iso-8859-12","iso-8859-13","iso-8859-14","iso-8859-15","iso-8859-16","windows-1250","windows-1251","windows-1252","windows-1253","windows-1254","windows-1255","windows-1256","windows-1258","gb18030","gb2312","gbk","Big5","Big5-HKSCS","koi8-r","koi8-u","euc-jp","euc-tw","shift-jis","iso-2022-jp","iso-2022-kr","iso-2022-cn","hz","MacRoman"],i=new s("#{,resource,params*}"),r=new a.Command({name:e.ReloadWith,selectionClass:"dropdownSelection",id:"orion.edit.reloadWithEncoding",visibleWhen:function(){var e=t.editor;return e&&e.installed},choiceCallback:function(){return n.map(function(e){return{name:e,callback:function(){var e=_.matchResourceParameters(),t=e.resource;delete e.resource,delete e.encoding,"UTF-8"!==this.name&&(e.encoding=this.name),window.location.href=i.expand({resource:t,params:e})}}})}});this.commandService.addCommand(r)},_createGotoLineCommnand:function(){var t=this,n=new d.ParametersDescription([new d.CommandParameter("line","number",e.gotoLinePrompt)],{hasOptionalParameters:!1},function(n){var i=n.handler.editor||t.editor,r=i.getModel().getLineAtOffset(i.getCaretOffset())+1;return[new d.CommandParameter("line","number",e.gotoLinePrompt,r.toString())]}),i=new a.Command({name:e.gotoLine,tooltip:e.gotoLineTooltip,id:"orion.edit.gotoLine",visibleWhen:function(e,n){var i=n.handler.editor||t.editor;return i&&i.installed},parameters:n,callback:function(n){var i,r=this.editor||t.editor,o=r.getModel();n.parameters&&n.parameters.valueFor("line")?i=n.parameters.valueFor("line"):C.isElectron||(i=o.getLineAtOffset(r.getCaretOffset()),i=prompt(e.gotoLinePrompt,i+1),i&&(i=parseInt(i,10))),i&&r.onGotoLine(i-1,0)}});this.commandService.addCommand(i)},_createFindCommnand:function(){var t=this,i=new d.ParametersDescription([new d.CommandParameter("find","text","Find:")],{clientCollect:!0},function(e){var n=e.handler.editor||t.editor,i=e.handler.textSearcher||t.textSearcher,r=n.getSelection(),o="";if(r.end>r.start){var s=n.getModel();o=s.getText(r.start,r.end),i&&i.getOptions().regex&&(o=m.escape(o))}return[new d.CommandParameter("find","text","Find:",o)]}),r=new a.Command({name:e.Find,tooltip:e.Find,id:"orion.edit.find",visibleWhen:function(e,n){var i=n.handler.editor||t.editor,r=n.handler.textSearcher||t.textSearcher;return i&&i.installed&&r},parameters:i,callback:function(e){var i=n.node("replaceCompareDiv");if(i&&i.classList.contains("replaceCompareDivVisible"))return!1;var o=this.editor||t.editor,s=this.textSearcher||t.textSearcher;r.textSearcher&&r.textSearcher!==s&&r.textSearcher.hide(),r.textSearcher=s;var a="",l=null,d=o.getSelection();if(e.parameters&&e.parameters.valueFor("find"))a=e.parameters.valueFor("find"),l=p.matchResourceParameters(),u.convertFindURLBinding(l);else if(d.end>d.start){var c=o.getModel();a=c.getText(d.start,d.end),s.getOptions().regex&&(a=m.escape(a))}if(l){var h=(this.inputManager||t.inputManager).getFileMetadata();if(!h||l.resource!==h.Location)return;s.setOptions({regex:l.regEx,caseInsensitive:!l.caseSensitive,wholeWord:l.wholeWord});var f={};l.atLine&&(f.start=o.getModel().getLineStart(l.atLine-1)),s.show({findString:a,replaceString:l.replaceWith}),s.find(!0,f),t.commandService.closeParameterCollector()}else s.show({findString:a})}});this.commandService.addCommand(r)},_createBlameCommand:function(){var t=this,n=new a.Command({name:e.Blame,tooltip:e.BlameTooltip,id:"orion.edit.blame",parameters:new d.ParametersDescription([new d.CommandParameter("blame","boolean")],{clientCollect:!0}),visibleWhen:function(e,n){var i=n.handler.editor||t.editor,r=n.handler.blamer||t.blamer;return i&&i.installed&&r&&r.isVisible()},callback:function(e){for(var n=!1,i=this.editor||t.editor,r=this.blamer||t.blamer,o=i.getAnnotationModel().getAnnotations();o.hasNext();){var s=o.next();if(s.type===v.AnnotationType.ANNOTATION_BLAME){n=!0;break}}n=!n,e.parameters&&e.parameters.valueFor("blame")&&(n="true"===e.parameters.valueFor("blame")),n?r.doBlame():i.showBlame([]),i.focus()}});this.commandService.addCommand(n)},_createFormatterCommand:function(){var t=this,n=new a.Command({name:e.Format,tooltip:e.FormatTooltip,id:"orion.edit.format",parameters:new d.ParametersDescription([new d.CommandParameter("formatter","boolean")],{clientCollect:!0}),visibleWhen:function(e,n){var i=n.handler.inputManager||t.inputManager;if(i&&i.getReadOnly())return!1;var r=n.handler.editor||t.editor,o=n.handler.formatter||t.formatter;return r&&r.installed&&o&&o.isVisible()},callback:function(){var e=this.editor||t.editor,n=this.formatter||t.formatter;n.doFormat(),e.focus()}});this.commandService.addCommand(n)},_createReferencesCommand:function(){var n=new a.Command({name:e.References,tooltip:e.ReferencesTooltip,id:"orion.edit.references",parameters:new d.ParametersDescription([new d.CommandParameter("references","boolean")],{clientCollect:!0}),visibleWhen:function(e,t){var n=t.handler.inputManager||this.inputManager;if(n&&n.getReadOnly())return!1;var i=t.handler.editor||this.editor,r=t.handler.references||this.references;return i&&i.installed&&r&&r.isVisible()}.bind(this),callback:function(n){var i=this.serviceRegistry.getService("orion.page.message"),r=this.serviceRegistry.getService("orion.page.progress"),o=t.formatMessage(e.running,e.FindReferences),s=this.references.findReferences(n);i&&i.createProgressMonitor(s,o),r.showWhile(s,o).then(function(e){this.sideBar&&this.sideBar.fillSearchPane(e.searchParams,e.refResult?e:null)}.bind(this)),this.editor.focus()}.bind(this)});this.commandService.addCommand(n)},_createOpenDeclCommand:function(){var n=new a.Command({name:e.OpenDeclaration,tooltip:e.OpenDeclarationTooltip,id:"orion.edit.open.declaration",parameters:new d.ParametersDescription([new d.CommandParameter("declaration","boolean")],{clientCollect:!0}),visibleWhen:function(e,t){var n=t.handler.inputManager||this.inputManager;if(n&&n.getReadOnly())return!1;var i=t.handler.editor||this.editor,r=t.handler.openDecl||this.openDecl;return i&&i.installed&&r&&r.isVisible()}.bind(this),callback:function(n){var i=this.serviceRegistry.getService("orion.page.message"),r=this.serviceRegistry.getService("orion.page.progress"),o=t.formatMessage(e.running,e.FindDeclaration),s=this.openDecl.findDeclaration(n);i&&i.createProgressMonitor(s,o),r.showWhile(s,o).then(function(e){return this.editor.getEditorContext().openEditor(e.file,e)}.bind(this)),this.editor.focus()}.bind(this)});this.commandService.addCommand(n)},_createDiffCommand:function(){var t=this,n=new a.Command({name:e.Diff,tooltip:e.DiffTooltip,id:"orion.edit.diff",visibleWhen:function(e,n){var i=n.handler.editor||t.editor,r=n.handler.differ||t.differ;return i&&i.installed&&r&&r.isVisible()},callback:function(){var e=this.editor||t.editor,n=this.differ||t.differ;n.toggleEnabled();var i=this.editorPreferences;i.getPrefs(function(e){e.diffService=n.isEnabled(),i.setPrefs(e)}),e.focus()}});this.commandService.addCommand(n)},_onServiceRemoved:function(e){-1!==e.getProperty("objectClass").indexOf("orion.edit.command")&&(this._recreateEditCommands=!0)},_onServiceAdded:function(e){-1!==e.getProperty("objectClass").indexOf("orion.edit.command")&&(this._recreateEditCommands=!0),-1!==e.getProperty("objectClass").indexOf("orion.core.contenttype")&&(A=null)},_createEditCommands:function(){function n(e){if(A)return A;var t=e.getService("orion.core.contentTypeRegistry");return t||(t=new h.ContentTypeRegistry(e),t=e.getService("orion.core.contentTypeRegistry")),t.getContentTypes().then(function(e){return A=e})}var i=this;this._recreateEditCommands=!1;var r=this.serviceRegistry,s=this.commandService,l=r.getServiceReferences("orion.edit.command"),d=r.getService("orion.page.progress"),u=r.getService("orion.page.message"),p=b.bind(null,r),g=function(n,r,o){var s=o.visibleWhen;return o.visibleWhen=function(e,t){var r=t.handler.editor||i.editor,o=t.handler.inputManager||i.inputManager;return r&&r.installed&&o?n.editor&&r.id&&n.editor!==r.id?!1:i.inputManager.getReadOnly()?!1:!s||s(o.getFileMetadata()):!1},o.callback=function(s){var a=this.editor||i.editor,l=this.inputManager||i.inputManager;"orion.edit.quickfix"===n.scopeId&&s.userData.annotation.creatorID&&(a=s.userData.annotation.creatorID);var c,h,g=a.getSelection?a.getSelection():{start:0,end:0},v=a.getModel(),m=function(e){"object"==typeof e&&e?(e.text&&a.setText(e.text),e.selection&&(a.setSelection&&a.setSelection(e.selection.start,e.selection.end,!0),a.focus())):"string"==typeof e&&(a.setText(e,g.start,g.end,!0),a.setSelection&&a.setSelection(g.start,g.start+e.length),a.focus())};if(r.execute){var _={contentType:l.getContentType(),input:l.getInput(),offset:a.getCaretOffset(),readonly:l.getReadOnly()};if("orion.edit.quickfix"===n.scopeId&&(_.annotation={start:s.userData.annotation.start,end:s.userData.annotation.end,title:s.userData.annotation.title,id:s.userData.annotation.id,data:s.userData.annotation.data},s.userData.annotation.doFixAll&&s.userData.annotation._annotationModel)){_.doFixAll=!0,_.annotations=[];for(var y=s.userData.annotation._annotationModel._annotations,C=0;C<y.length;C++)y[C].id===s.userData.annotation.id&&_.annotations.push({start:y[C].start,end:y[C].end,title:y[C].title,id:y[C].id,data:y[C].data})}var w=a.getEditorContext();w.openDelegatedUI=function(){var e=arguments[0];e=e||{},e.done=m,e.status=p,e.params=e.params||{},f.mixin(e.params,l.getFileMetadata()),x.apply(null,Array.prototype.slice.call(arguments))},w.setStatus=p,a.focus(),c=r.execute(w,_)}else c=r.run(v.getText(g.start,g.end),v.getText(),g,l.getInput());h=function(e){if(e&&e.uriTemplate){var t={};t.uriTemplate=e.uriTemplate,t.params=l.getFileMetadata(),t.id=n.id,t.width=e.width,t.height=e.height,t.done=m,t.status=p,x(t)}else e&&e.searchParams?i.sideBar&&i.sideBar.fillSearchPane(e.searchParams,e.refResult?e:null):e&&(e.Status||e.status)?p(e.Status||e.status):m(e)};var b=t.formatMessage(e.running,o.name);return u&&u.createProgressMonitor(c,b),d.showWhile(c,b).then(h),!0},new a.Command(o)};return o.when(n(this.serviceRegistry),function(){var e=[];return l.forEach(function(t){for(var n=i.serviceRegistry.getService(t),r={},o=t.getPropertyKeys(),a=0;a<o.length;a++)r[o[a]]=t.getProperty(o[a]);r.forceSingleItem=!0;var l=c._createCommandOptions(r,t,i.serviceRegistry,A,!1,function(e){return"orion.edit.quickfix"===r.scopeId&&void 0!==e.annotation&&void 0!==e.readonly?e:i.inputManager.getFileMetadata()}).then(function(e){var t=g(r,n,e);return t.editInfo=r,s.addCommand(t),t });e.push(l)}),o.all(e,S)})}},E.EditorCommandFactory=T,E.handleStatusMessage=b,E}),n("embeddedEditor/helper/memoryFileSysConst",[],function(){var e="/in_memory_fs/project/",t="/in_memory_fs/project/";return{MEMORY_FILE_PATTERN:e,MEMORY_FILE_PROJECT_PATTERN:t}}),function(e){function t(){Error.apply(this,arguments)}function n(e,t,n){return e>=t&&n>=e}function i(e,t){var n=e||"utf-8";if("utf-8"!==n&&"utf8"!==n&&"unicode-1-1-utf-8"!==n)throw new TypeError("only utf-8 supported");Object.defineProperties(this,{encoding:{value:n,enumerable:!0},_fatal:{value:t&&t.fatal},_saved:{value:[],writable:!0},_checkBOM:{value:!0,writable:!0}})}function r(e){var t=e||"utf-8";if("utf-8"!==t&&"utf8"!==t&&"unicode-1-1-utf-8"!==t)throw new TypeError("only utf-8 supported");Object.defineProperties(this,{encoding:{value:t,enumerable:!0},_saved:{value:null,writable:!0}})}t.prototype=new Error,t.prototype.constructor=t,t.prototype.name="EncodingError",i.prototype.decode=function(e,i){function r(){if(this._fatal)throw this._saved.length=h=0,p=f,this._checkBOM=this._checkBOM||!c,new t;g[v++]=65533}e=e instanceof Uint8Array?e:new Uint8Array(e);var o,s,a,l,d,c=i&&i.stream,h=this._saved.length,u=e.length,f=0,p=0,g=new Uint16Array(u+h),v=0;if(this._checkBOM&&u)if(h+u>2){for(var m=h;3>m;m++)this._saved.push(e[f++]);239!==this._saved[0]||187!==this._saved[1]||191!==this._saved[2]?(f=0,this._saved.length=h):h=this._saved.length-=3,this._checkBOM=!1}else if(c)for(;u>f;)this._saved.push(e[f++]);for(;u>f;){if(o=h>0?this._saved[0]:e[f++],128>o)g[v++]=o;else if(n(o,194,223)){if(f===u)break;if(s=h>1?this._saved[1]:e[f++],!n(s,128,191)){r();continue}g[v++]=(31&o)<<6|63&s}else if(n(o,224,239)){if(f===u)break;if(s=h>1?this._saved[1]:e[f++],224===o&&!n(s,160,191)||237===o&&!n(s,128,159)||!n(s,128,191)){r();continue}if(f===u)break;if(a=h>2?this._saved[2]:e[f++],!n(a,128,191)){r();continue}g[v++]=(15&o)<<12|(63&s)<<6|63&a}else if(n(o,240,244)){if(f===u)break;if(s=h>1?this._saved[1]:e[f++],240===o&&!n(s,144,191)||244===o&&!n(s,128,143)||!n(s,128,191)){r();continue}if(f===u)break;if(a=h>2?this._saved[2]:e[f++],!n(a,128,191)){r();continue}if(f===u)break;if(l=e[f++],!n(l,128,191)){r();continue}d=65535&((7&o)<<18|(63&s)<<12|(63&a)<<6|63&l),g[v++]=d>>10|55296,g[v++]=1023&d|56320}else r();p=f,h&&(this._saved.length=h=0)}for(;p!==f;)this._saved.push(e[p++]);if(this._checkBOM=this._checkBOM||!c,!c&&0!==this._saved.length)throw new t;for(var _=[],y=0;v>y;y+=65536)_.push(String.fromCharCode.apply(null,g.subarray(y,Math.min(v,y+65536))));return _.join("")},r.prototype.encode=function(e,i){e=String(void 0!==e?e:"");for(var r,o,s,a=i&&i.stream,l=e.length,d=0,c=new Uint8Array(3*(l+(null===this._saved?0:1))),h=0;l>d;)if(null===this._saved?r=e.charCodeAt(d++):(r=this._saved,this._saved=null),128>r)c[h++]=r;else if(2048>r)c[h++]=192|r>>6,c[h++]=128|63&r;else if(55296>r||r>56319)c[h++]=224|r>>12,c[h++]=128|r>>6&63,c[h++]=128|63&r;else{if(!(l>d)){if(a){this._saved=r;break}throw new t}if(o=e.charCodeAt(d++),!n(o,56320,57343))throw new t;s=65536|(1023&r)<<10|1023&o,c[h++]=240|s>>18,c[h++]=128|s>>12&63,c[h++]=128|s>>6&63,c[h++]=128|63&s}if(!a&&null!==this._saved)throw new t;return c.buffer.slice?new Uint8Array(c.buffer.slice(0,h)):c.subarray(0,h)},e.TextDecoder=e.TextDecoder||i,e.TextEncoder=e.TextEncoder||r}("undefined"==typeof global?this||self:global),n("orion/encoding-shim",function(){}),n("embeddedEditor/helper/embeddedFileImpl",["orion/Deferred","embeddedEditor/helper/memoryFileSysConst","orion/encoding-shim","orion/URL-shim"],function(e,t){function n(e){this.fileBase=e,this.fileRoot={},this.fileRoot[t.MEMORY_FILE_PROJECT_PATTERN]={Location:t.MEMORY_FILE_PROJECT_PATTERN,Directory:!0}}return n.prototype={fetchChildren:function(){return(new e).resolve([])},loadWorkspaces:function(){return(new e).resolve([])},loadWorkspace:function(){return(new e).resolve([])},createProject:function(){throw new Error("Not supported")},createFolder:function(){throw new Error("Not supported")},createFile:function(e,t){var n=e+t;return this._getFile(n,!0),this.read(n,!0)},moveFile:function(){throw new Error("Not supported")},copyFile:function(){throw new Error("Not supported")},remoteImport:function(){throw new Error("Not supported")},remoteExport:function(){throw new Error("Not supported")},readBlob:function(){throw new Error("Not supported")},writeBlob:function(){throw new Error("Not supported")},getProject:function(){return this.fileRoot[t.MEMORY_FILE_PROJECT_PATTERN]},_getFile:function(e,t){var n=new URL(e),i=n.pathname;return void 0===this.fileRoot[i]&&t&&(this.fileRoot[i]={Name:n.pathname.split("/").pop(),Location:i,LocalTimeStamp:Date.now(),ETag:0}),this.fileRoot[i]},read:function(n,i,r,o){var s=this._getFile(n),a=o?o:Object.create(null);if(void 0===s)return(new e).resolve(a.readIfExists?null:i?{}:"");if(i){var l=n===t.MEMORY_FILE_PROJECT_PATTERN?[]:[this.fileRoot[t.MEMORY_FILE_PROJECT_PATTERN]],d={Length:s.length,Directory:Boolean(s.Directory),LocalTimeStamp:s.LocalTimeStamp,ETag:s.ETag,Location:s.Location,Name:s.Name,Parents:l};return(new e).resolve(d)}return(new e).resolve(s.contents)},write:function(e,t){var n=this._getFile(e,!0);return"string"==typeof t&&(n.ETag++,n.LocalTimeStamp=Date.now(),n.contents=t),this.read(e,!0)},deleteFile:function(t){var n=new URL(t),i=n.pathname;return delete this.fileRoot[i],(new e).resolve()}},n.prototype.constructor=n,n}),n("orion/pluginregistry",["orion/Deferred","orion/EventTarget","orion/urlModifier","orion/URL-shim"],function(e,t,n){function i(e,t){var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;n.sort(),i.sort();for(var r=0,o=n.length;o>r;r++){var s=n[r];if(s!==i[r])return!1;var a=e[s],l=t[s];if(a!==l&&JSON.stringify(a)!==JSON.stringify(l))return!1}return!0}function r(e){for(var t=Object.prototype.hasOwnProperty,n=1,i=arguments.length;i>n;n++){var r=arguments[n];for(var o in r)t.call(r,o)&&(e[o]=r[o])}return e}function o(e){if(-1===e.indexOf("://"))try{return new URL(e,location.href).href}catch(t){}return e}function s(e){function t(){return n=n||Object.keys(e)}var n=null,i={key:function(e){return t()[e]},getItem:function(t){return e[t]},setItem:function(t,i){e[t]=i,n=null},removeItem:function(t){delete e[t],n=null},clear:function(){t().forEach(function(t){delete e[t]}.bind(this)),n=null}};return Object.defineProperty(i,"length",{get:function(){return t().length}}),i}function a(e,t){if(t&&t instanceof XMLHttpRequest){var n,i;try{n=t.status,i=t.statusText}catch(r){n=0,i=""}return{status:n||0,statusText:i}}return t}function l(e){var t=e?JSON.parse(JSON.stringify(e,a)):e;return e instanceof Error&&(t.__isError=!0,t.message=t.message||e.message,t.name=t.name||e.name),t}function d(e,t){this.type=e,this.plugin=t}function c(e,t){this.__objectId=e,this.__methods=t}function h(n,r,o){function s(e){E&&o.postMessage(e,E)}function a(t){if(!E)return(new e).reject(new Error("plugin not connected"));t.id=String(K++);var n=new e;j[t.id]=n,n.then(null,function(e){"active"===V&&e instanceof Error&&"Cancel"===e.name&&s({requestId:t.id,method:"cancel",params:e.message?[e.message]:[]})});var i=Object.prototype.toString;return t.params.forEach(function(e,r){if("[object Object]"===i.call(e)&&!(e instanceof c)){var o,s;for(o in e)"[object Function]"===i.call(e[o])&&(s=s||[],s.push(o));if(s){var a=W++;G[a]=e;var l=function(){delete G[a]};n.then(l,l),t.params[r]=new c(a,s)}}}),o.postMessage(t,E),n.promise}function h(e,t){e||0===e?s({id:e,result:null,error:t}):console.log(t)}function u(e,t,n,i){i.forEach(function(e,t){if(e&&"undefined"!=typeof e.__objectId){var n={};e.__methods.forEach(function(t){n[t]=function(){return a({objectId:e.__objectId,method:t,params:Array.prototype.slice.call(arguments)})}}),i[t]=n}});var r="undefined"==typeof e?null:{id:e,result:null,error:null};try{var o=n.apply(t,i);if(!r)return;o&&"function"==typeof o.then?(H[e]=o,o.then(function(t){delete H[e],r.result=t,s(r)},function(t){H[e]&&(delete H[e],r.error=l(t),s(r))},function(){s({responseId:e,method:"progress",params:Array.prototype.slice.call(arguments)})})):(r.result=o,s(r))}catch(d){r&&(r.error=l(d),s(r))}}function f(e){try{if(e.method){var t=e.method,n=e.params||[];if("serviceId"in e){var i=L[e.serviceId];if(i)if(y(i)){var r=o.serviceRegistry;i=r.getService(i),t in i?u(e.id,i,i[t],n):h(e.id,"method not found")}else h(e.id,"not trusted");else h(e.id,"service not found")}else if("objectId"in e){var s=G[e.objectId];s?t in s?u(e.id,s,s[t],n):h(e.id,"method not found"):h(e.id,"object not found")}else if("requestId"in e){var a=H[e.requestId];a&&"cancel"===t&&a.cancel&&a.cancel.apply(a,n)}else if("responseId"in e){var l=j[e.responseId];l&&"progress"===t&&l.progress&&l.progress.apply(l,n)}else if("loading"===e.method)E.loading();else if("plugin"===e.method){E.connected();var d=e.params[0];k({headers:d.headers,services:d.services}).then(function(){T&&T.resolve(b)}),d.updateRegistry&&C()}else{if("timeout"!==e.method&&"error"!==e.method)throw new Error("Bad method: "+e.method);T&&T.reject(e.error)}}else if(e.id){var c=j[String(e.id)];if(c)if(delete j[String(e.id)],e.error){var f=o.handleServiceError(b,e.error);c.reject(f)}else c.resolve(e.result)}}catch(p){console.log("Plugin._messageHandler "+p)}}function g(e){var n={};if(e.methods&&(e.methods.forEach(function(t){n[t]=function(){var n={serviceId:e.serviceId,method:t,params:Array.prototype.slice.call(arguments)};return"active"===V?a(n):b.start({"transient":!0}).then(function(){return a(n)})}}),n.addEventListener&&n.removeEventListener)){var i=new t,r=W++;G[r]={handleEvent:i.dispatchEvent.bind(i)};var o=new c(r,["handleEvent"]),s=n.addEventListener;n.addEventListener=function(e,t){i._namedListeners[e]||s(e,o),i.addEventListener(e,t)};var l=n.removeEventListener;n.removeEventListener=function(e,t){i.removeEventListener(e,t),i._namedListeners[e]||l(e,o)}}return n}function v(e){var t=JSON.parse(JSON.stringify(e.properties));t.__plugin__=n;var i=e.names||e.type||[];return Array.isArray(i)||(i=[i]),t.objectClass=i,t}function m(e){var t=g(e),n=v(e),i=o.registerService(e.names||e.type,t,n);U[e.serviceId]={registration:i,proxy:t}}function _(){var e=[];return Object.keys(L).forEach(function(t){var n=L[t],i={};n.getPropertyKeys().forEach(function(e){i[e]=n.getProperty(e)}),["service.id","service.names","objectClass","__plugin__"].forEach(function(e){delete i[e]});var r=[],s=o.serviceRegistry,a=s.getService(n);for(var l in a)"function"==typeof a[l]&&r.push(l);e.push({serviceId:String(n.getProperty("service.id")),names:n.getProperty("service.names"),methods:r,properties:i})}),{services:e}}function y(e){var t=new URL(n);if(t.origin===location.origin)return!0;var i=e.getProperty("__plugin__");return t.origin===(i?new URL(i):location).origin}function C(){function e(e,t,n){var i=n.serviceReference,r=i.getProperty("service.id");!L[r]&&y(i)&&(e&&(L[r]=i),t&&delete L[r],C())}if(!L){L={};var t=o.serviceRegistry;t.getServiceReferences().forEach(function(e){y(e)&&(L[e.getProperty("service.id")]=e)}),t.addEventListener("registered",M=e.bind(null,!0,!1)),t.addEventListener("unregistered",O=e.bind(null,!1,!0)),t.addEventListener("modified",D=e.bind(null,!1,!1))}a({method:"plugin",params:[_()]})}function w(){var e=o.serviceRegistry;M&&e.removeEventListener("registered",M),O&&e.removeEventListener("unregistered",O),D&&e.removeEventListener("modified",D),M=O=D=null}function x(){o.persist(n,{created:N,headers:I,services:R,autostart:B,metadataVersion:p,lastModified:P})}var b=this;r=r||{};var S,T,E,A,L,k,M,O,D,N=r.created||Date.now(),I=r.headers||{},R=r.services||[],B=r.autostart,P=r.lastModified||0,F=r.metadataVersion,V="installed",U={},K=0,W=0,H={},j={},G={};this._default=!1,this._persist=x,this._resolve=function(){V="resolved",o.dispatchEvent(new d("resolved",b))},this._getAutostart=function(){return B},this._getCreated=function(){return N},this.getLocation=function(){return n},this.getHeaders=function(){return JSON.parse(JSON.stringify(I))},this.getName=function(){var e=this.getHeaders();return e?e.name||"":null},this.getVersion=function(){var e=this.getHeaders();return e?e.version||"0.0.0":null},this.getLastModified=function(){return P},this.getServiceReferences=function(){var e=[];return Object.keys(U).forEach(function(t){e.push(U[t].registration.getReference())}),e},this.setParent=function(t){return A!==t?(A=t,b.stop({"transient":!0}).then(function(){return"started"===B?b.start({"transient":!0}):"lazy"===B?b.start({lazy:!0,"transient":!0}):void 0})):(new e).resolve()},this.getState=function(){return V},this.getProblemLoading=function(){return b._problemLoading?!0:!1},this.start=function(t){if("uninstalled"===V)return(new e).reject(new Error("Plugin is uninstalled"));if(S)return S.promise.then(this.start.bind(this,t));if("active"===V)return(new e).resolve();if(!t||!t["transient"]){var i=t&&t.lazy?"lazy":"started";i!==B&&(B=i,x())}var r=o.getState();if("starting"!==r&&"active"!==r)return t["transient"]?(new e).reject(new Error("start transient error")):(new e).resolve();if("installed"===V)try{this._resolve()}catch(s){return(new e).reject(s)}if("resolved"===V&&R.forEach(function(e){m(e)}),t&&t.lazy){"starting"!==V&&(V="starting",o.dispatchEvent(new d("lazy activation",b)));var a=Date.now();return!this.getLastModified()||a>this.getLastModified()+864e5||F!==p?this.update():(new e).resolve()}var l=new e;return S=l,V="starting",b._problemLoading=null,o.dispatchEvent(new d("starting",b)),T=new e,E=o.connect(n,f,A),T.then(function(){T=null,V="active",o.dispatchEvent(new d("started",b)),S=null,l.resolve()},function(e){T=null,V="stopping",o.dispatchEvent(new d("stopping",b)),Object.keys(U).forEach(function(e){U[e].registration.unregister(),delete U[e]}),o.disconnect(E),E=null,V="resolved",S=null,o.dispatchEvent(new d("stopped",b)),b._problemLoading=!0,l.reject(new Error("Failed to load plugin: "+n+(e&&e.message?"\n Reason: "+e.message:""))),b._default&&(P=0,x())}),l.promise},this.stop=function(t){if("uninstalled"===V)return(new e).reject(new Error("Plugin is uninstalled"));if(S)return S.promise.then(this.stop.bind(this,t));if(t&&t["transient"]||"stopped"!==B&&(B="stopped",x()),"active"!==V&&"starting"!==V)return(new e).resolve();var n=new e;return S=n,V="stopping",o.dispatchEvent(new d("stopping",b)),Object.keys(U).forEach(function(e){U[e].registration.unregister(),delete U[e]}),E&&(o.disconnect(E),E=null,w()),V="resolved",S=null,o.dispatchEvent(new d("stopped",b)),n.resolve(),n.promise},k=function(t){if(b.problemLoading=null,"uninstalled"===V)return(new e).reject(new Error("Plugin is uninstalled"));if(!t)return 0===P&&(P=Date.now(),x()),o.loadManifest(n).then(k,function(){b._problemLoading=!0,b._default&&(P=0,x()),console.log("Failed to load plugin: "+n)});var r=I,s=R,a=B;if(I=t.headers||{},R=t.services||[],B=t.autostart||B,t.lastModified?P=t.lastModified:(P=Date.now(),x()),i(I,r)&&i(R,s)&&B===a)return(new e).resolve();if("active"===V||"starting"===V){var l=[];Object.keys(R).forEach(function(e){var t=R[e];l.push(e);var n=U[e];if(n){if(i(t.methods,Object.keys(n.proxy))){var r=v(t),o=n.registration.getReference(),s={};return o.getPropertyKeys().forEach(function(e){s[e]=o.getProperty(e)}),void(i(r,s)||n.registration.setProperties(r))}n.registration.unregister(),delete U[e]}m(t)}),Object.keys(U).forEach(function(e){-1===l.indexOf(e)&&(U[e].registration.unregister(),delete U[e])})}return"active"===V&&(o.disconnect(E),T=new e,E=o.connect(n,f,A),T.then(function(){T=null},function(){T=null,V="stopping",o.dispatchEvent(new d("stopping"),b),Object.keys(U).forEach(function(e){U[e].registration.unregister(),delete U[e]}),o.disconnect(E),E=null,V="resolved",o.dispatchEvent(new d("stopped",b))})),(new e).resolve()},this.update=function(e){return k(e).then(function(){o.dispatchEvent(new d("updated",b))})},this.uninstall=function(){return"uninstalled"===V?(new e).reject(new Error("Plugin is uninstalled")):"active"===V||"starting"===V||"stopping"===V?this.stop().then(this.uninstall.bind(this),this.uninstall.bind(this)):(o.removePlugin(this),V="uninstalled",o.dispatchEvent(new d("uninstalled",b)),(new e).resolve())}}function u(i,a){function l(e,t){try{var n;if("undefined"==typeof e.useStructuredClone){var i="string"!=typeof t.data;n=i?t.data:JSON.parse(t.data),e.useStructuredClone=i}else n=e.useStructuredClone?t.data:JSON.parse(t.data);e.handler(n)}catch(r){}}function c(e){var t=e.source;x.some(function(n){return t===n.target?(l(n,e),!0):void 0})}a=a||{};var u=a.storage||localStorage;u.getItem||(u=s(u));var p,y=parseInt(u.getItem("pluginregistry.default.timeout"),10)||void 0,C="installed",w=[],x=[],b=new t,S={},T={serviceRegistry:i,registerService:i.registerService.bind(i),connect:function(e,t,i,r){function o(t){localStorage.pluginLogging&&console.log(t+"("+(Date.now()-a._startTime)+"ms)="+e)}function s(e){o("timeout");var n=new Error(e);n.name="timeout",t({method:"timeout",error:n})}var a={handler:t,url:e};r=r||y,a._updateTimeout=function(){var t,n;if(!this._connected&&!this._closed)if(this._handshake){var i=0;x.forEach(function(e){e._connected||e._closed||(i+=1e3)}),t="Plugin handshake timeout for: "+e,n=this._loading?5e3:(r||6e4)+i}else t="Plugin load timeout for: "+e,n=r||15e3;this._loadTimeout&&clearTimeout(this._loadTimeout),this._loadTimeout=0,n&&(this._loadTimeout=setTimeout(s.bind(null,t),n))};var d=!(!e.match(g)||"undefined"==typeof Worker),c=!(!e.match(v)||"undefined"==typeof SharedWorker);if(localStorage.useSharedWorkers&&c||!e.match(v)||(e=e.replace(v,_),c=!1),localStorage.useWorkers&&d||!e.match(g)||(e=e.replace(g,m),d=c=!1),a.url=e,a._updateTimeout(),a._startTime=Date.now(),d){var h;c?(h=new SharedWorker(e),a.target=h.port,h.port.start(),a._close=function(){h.port.close()}):(h=new Worker(e),a.target=h,a._close=function(){h.terminate()}),a.postMessage=function(e){this.target.postMessage(this.useStructuredClone?e:JSON.stringify(e),[])},a.target.addEventListener("message",function(e){l(a,e)})}else{var u=document.createElement("iframe");u.name=e+"_"+a._startTime,u.src=n(e),u.onload=function(){o("handshake"),a._handshake=!0,a._updateTimeout()},u.sandbox="allow-scripts allow-same-origin allow-forms allow-popups",u.style.width=u.style.height="100%",u.frameBorder=0,u.title=(i||p).title,(i||p).appendChild(u),a.target=u.contentWindow,a.postMessage=function(e){this.target.postMessage(this.useStructuredClone?e:JSON.stringify(e),this.url)},a._close=function(){if(u){var e=u.parentNode;e&&e.removeChild(u),u=null}}}return a.connected=function(){o("connected"),this._connected=!0,this._updateTimeout()},a.loading=function(){o("loading"),this._loading=!0,this._updateTimeout()},a.close=function(){o("closed"),this._closed=!0,this._updateTimeout(),this._close()},x.push(a),a},disconnect:function(e){for(var t=0;t<x.length;t++)if(e===x[t]){x.splice(t,1);try{e.close()}catch(n){}break}},removePlugin:function(e){for(var t=0;t<w.length;t++)if(e===w[t]){w.splice(t,1);break}u.removeItem("plugin."+e.getLocation())},getPersisted:function(e){var t="plugin."+e,n=u.getItem(t);return n&&(n=JSON.parse(n),n.created)?n:null},persist:function(e,t){return t&&t.services&&t.services.length?void u.setItem("plugin."+e,JSON.stringify(t)):void u.removeItem("plugin."+e)},postMessage:function(e,t){t.postMessage(e)},dispatchEvent:function(e){try{b.dispatchEvent(e)}catch(t){console&&console.log("PluginRegistry.dispatchEvent "+t)}},loadManifest:function(t){var n=new e,i=T.connect(t,function(e){if(i&&e.method)if("manifest"===e.method||"plugin"===e.method){var t=e.params[0];T.disconnect(i),i=null,n.resolve(t)}else"timeout"===e.method||"error"===e.method?(T.disconnect(i),i=null,n.reject(e.error)):"loading"===e.method&&i.loading()});return n.promise},getState:function(){return C},handleServiceError:function(e,t){if(t&&(401===t.status||491===t.status)){var n=e.getHeaders(),i=e.getName()||e.getLocation(),r=document.createElement("span");if(r.appendChild(document.createTextNode("Authentication required for: "+i+".")),n.login){r.appendChild(document.createTextNode(" "));var o=document.createElement("a");o.target="_blank",o.textContent="Login",o.href=n.login,f.test(o.href)?(r.appendChild(o),r.appendChild(document.createTextNode(" and re-try the request."))):console.log("Illegal Login URL: "+n.login)}var s=new XMLSerializer;return{Severity:"Error",HTML:!0,Message:s.serializeToString(r)}}if(t.__isError){var a=t;t=new Error(a.message),Object.keys(a).forEach(function(e){t[e]=a[e]}),delete t.__isError}return t}};this.getLocation=function(){return"System"},this.getHeaders=function(){return{}},this.getName=function(){return"System"},this.getVersion=function(){return"0.0.0"},this.getLastModified=function(){return 0},this.getState=T.getState,this.init=function(){"starting"!==C&&"active"!==C&&"stopping"!==C&&(addEventListener("message",c,!1),a.parent?p=a.parent:(p=document.createElement("div"),a.visible||(p.style.display="none",p.style.visibility="hidden"),document.body.appendChild(p)),a.plugins&&Object.keys(a.plugins).forEach(function(e){var t=o(e),n=this.getPlugin(t);if(n)n._default=!0;else{var i=a.plugins[e];"object"!=typeof i&&(i=T.getPersisted(t)||{}),i.autostart=i.autostart||a.defaultAutostart||"lazy",n=new h(t,i,T),n._default=!0,w.push(n)}}.bind(this)),w.sort(function(e,t){return e._getCreated()<t._getCreated()?-1:1}),C="starting")},this.start=function(){if("starting"!==C&&this.init(),"starting"!==C)return(new e).reject("Cannot start framework. Framework is already "+C+".");var t=[];return w.forEach(function(e){var n=e._getAutostart();"started"===n||"active"===n?t.push(e.start({"transient":!0})):"lazy"===n?t.push(e.start({lazy:!0,"transient":!0})):e._resolve()}),e.all(t,function(e){console.log("PluginRegistry.stop "+e)}).then(function(){C="active"})},this.stop=function(){if("starting"!==C&&"active"!==C)return(new e).reject("Cannot stop registry. Registry is already "+C+".");C="stopping";var t=[];return w.forEach(function(e){t.push(e.stop({"transient":!0}))}),e.all(t,function(e){console.log("PluginRegistry.stop "+e)}).then(function(){if(!a.parent){var e=p.parentNode;e&&e.removeChild(p)}p=null,removeEventListener("message",c),C="resolved"})},this.update=function(){this.stop().then(this.start.bind(this))},this.uninstall=function(){return(new e).reject("Cannot uninstall registry")},this.installPlugin=function(t,n){t=o(t);var i=this.getPlugin(t);if(i)return(new e).resolve(i);if(S[t])return S[t];if(n)return"lazy"===n.autostart&&(n=r({},T.getPersisted(t),n)),i=new h(t,n,T),w.push(i),i._persist(),T.dispatchEvent(new d("installed",i)),(new e).resolve(i);var s=T.loadManifest(t).then(function(e){return i=new h(t,e,T),w.push(i),i._persist(),delete S[t],T.dispatchEvent(new d("installed",i)),i},function(e){throw delete S[t],e});return S[t]=s,s},this.getPlugins=function(){return w.slice()},this.getPlugin=function(e){var t=null;return e=o(e),w.some(function(n){return e===n.getLocation()?(t=n,!0):void 0}),t},this.addEventListener=b.addEventListener.bind(b),this.removeEventListener=b.removeEventListener.bind(b),this.resolvePlugins=function(){var e=!0;return w.forEach(function(t){e=e&&t._resolve()}),e}}var f=new RegExp("^http[s]?","i"),p=15,g=/Worker\.js$/,v=/SharedWorker\.js$/,m="Plugin.html",_="Worker.js";return{Plugin:h,PluginRegistry:u}});var i=null,r=document.getElementsByTagName("script");if(r&&r.length&&r.length>0){for(var o=0;2>o;o++){for(var s=0;s<r.length;s++)if(0===o){if("orion.codeEdit"===r[s].id){i=r[s].src;break}}else{var a=/.*built-codeEdit.*.js/;if(r[s].src&&a.exec(r[s].src)){i=r[s].src;break}}if(i)break}i||(i=r[r.length-1].src)}return n("embeddedEditor/helper/bootstrap",["embeddedEditor/helper/embeddedFileImpl","embeddedEditor/helper/memoryFileSysConst","orion/pluginregistry","orion/Deferred","orion/URL-shim"],function(e,t,n,r){function o(t,o,d){if(s)return s;var c;if(c=d&&d._defaultPlugins?d._defaultPlugins:l,d&&d.defaultPlugins){var h=[];d.defaultPlugins.forEach(function(e){var t=e.split("/").pop();c.some(function(e){return-1!==e.indexOf(t)?(h.push(e),!0):!1})}),c=h}s=new r;var u=new e(a);t.registerService("orion.core.file",u,{Name:"Embedded File System",top:a,pattern:a});var f={};c.forEach(function(e){var t=new URL(e,i);f[t.href]={autostart:"lazy"}}),c=d&&d.userPlugins?d.userPlugins:[],c.forEach(function(e){f[e]={autostart:"lazy"}});var p=new n.PluginRegistry(t,{storage:{},plugins:f});return p.start().then(function(){var e={serviceRegistry:t,pluginRegistry:p};return o.getContentType("text/plain")||t.registerService("orion.core.contenttype",{},{contentTypes:[{id:"text/plain",name:"Text",extension:["txt"]}]}),s.resolve(e),e})}var s,a=t.MEMORY_FILE_PATTERN,l=["../javascript/plugins/javascriptPlugin.html","../webtools/plugins/webToolsPlugin.html","../others/plugins/languages/json/jsonPlugin.html","../plugins/embeddedToolingPlugin.html"];return{startup:o}}),n("orion/editor/undoStack",[],function(){function e(e,t,n,i,r){this.model=e,this.offset=t,this.text=n,this.previousText=i,this.type=r}function t(e){this.owner=e,this.changes=[]}function n(e,t){this.size=void 0!==t?t:100,this.reset();var n=this;if(this._listener={onChanging:function(e){n._onChanging(e)},onDestroy:function(e){n._onDestroy(e)}},e.getModel){var i=e.getModel();i.getBaseModel&&(i=i.getBaseModel()),this.model=i,this.setView(e)}else this.shared=!0,this.model=e;this.model.addEventListener("Changing",this._listener.onChanging)}return e.prototype={getRedoChanges:function(){return[{start:this.offset,end:this.offset+this.previousText.length,text:this.text}]},getUndoChanges:function(){return[{start:this.offset,end:this.offset+this.text.length,text:this.previousText}]},undo:function(e,t){return this._doUndoRedo(this.offset,this.previousText,this.text,e,t),!0},redo:function(e,t){return this._doUndoRedo(this.offset,this.text,this.previousText,e,t),!0},merge:function(e,t,n,i,r){if(i===this.type){if(1===i&&e===this.offset+this.text.length)return this.text+=t,!0;if(-1===i&&r===this.offset)return this.offset=e,this.previousText=n+this.previousText,!0;if(-1===i&&e===this.offset)return this.previousText=this.previousText+n,!0}return!1},_doUndoRedo:function(e,t,n,i,r){if(this.model.setText(t,e,e+n.length),r&&i){var o=i.getModel();o!==this.model&&(e=o.mapOffset(e,!0)),i.setSelection(e,e+t.length)}}},t.prototype={getRedoChanges:function(){for(var e=[],t=0;t<this.changes.length;t++)e=e.concat(this.changes[t].getRedoChanges());return e},getUndoChanges:function(){for(var e=[],t=this.changes.length-1;t>=0;t--)e=e.concat(this.changes[t].getUndoChanges());return e},add:function(e){this.changes.push(e)},end:function(e){e&&(this.endSelection=e.getSelections());var t=this.owner;t&&t.end&&t.end()},undo:function(e,t){this.changes.length>1&&e&&e.setRedraw(!1);for(var n=this.changes.length-1;n>=0;n--)this.changes[n].undo(e,!1);t&&e&&e.setSelections(this.startSelection),this.changes.length>1&&e&&e.setRedraw(!0);var i=this.owner;return i&&i.undo&&i.undo(),this.changes.length>0},redo:function(e,t){this.changes.length>1&&e&&e.setRedraw(!1);for(var n=0;n<this.changes.length;n++)this.changes[n].redo(e,!1);t&&e&&e.setSelections(this.endSelection),this.changes.length>1,e&&e.setRedraw(!0);var i=this.owner;return i&&i.redo&&i.redo(),this.changes.length>0},merge:function(e,t,n,i,r,o){var s=this.changes.length;return s>0&&this===o?this.changes[s-1].merge(e,t,n,i,r):!1},start:function(e){e&&(this.startSelection=e.getSelections());var t=this.owner;t&&t.start&&t.start()}},n.prototype={destroy:function(){this._onDestroy()},add:function(e){if(this.compoundChange)this.compoundChange.add(e);else{var t=this.stack.length;this.stack.splice(this.index,t-this.index,e),this.index++,this.stack.length>this.size&&(this.stack.shift(),this.index--)}},markClean:function(){this._commitUndo(),this.cleanChange=this.stack[this.index-1],this.cleanChange&&(this.cleanChange.type=2)},isClean:function(){return this.cleanChange===this.stack[this.index-1]},canUndo:function(){return this.index>0},canRedo:function(){return this.stack.length-this.index>0},endCompoundChange:function(){this.compoundChange&&this.compoundChange.end(this.view),this.compoundChange=void 0},getSize:function(){return{undo:this.index,redo:this.stack.length-this.index}},getRedoChanges:function(){this._commitUndo();for(var e=[],t=this.index;t<this.stack.length;t++)e=e.concat(this.stack[t].getRedoChanges());return e},getUndoChanges:function(){this._commitUndo();for(var e=[],t=this.index;t>=0;t--)e=e.concat(this.stack[t].getUndoChanges());return e},undo:function(){this._commitUndo();var e,t=!1;this._ignoreUndo=!0;do{if(this.index<=0)break;e=this.stack[--this.index]}while(!(t=e.undo(this.view,!0)));return this._ignoreUndo=!1,t},redo:function(){this._commitUndo();var e,t=!1;this._ignoreUndo=!0;do{if(this.index>=this.stack.length)break;e=this.stack[this.index++]}while(!(t=e.redo(this.view,!0)));return this._ignoreUndo=!1,t},reset:function(){this.index=0,this.cleanChange=void 0,this.stack=[],this._ignoreUndo=!1,this._compoundChange=void 0},setView:function(e){this.view!==e&&(this.view&&e.removeEventListener("Destroy",this._listener.onDestroy),this.view=e,this.view&&e.addEventListener("Destroy",this._listener.onDestroy))},startCompoundChange:function(e){this._commitUndo();var n=new t(e);return this.add(n),this.compoundChange=n,this.compoundChange.start(this.view),this.compoundChange},_commitUndo:function(){this.endCompoundChange()},_onDestroy:function(e){e&&this.shared||this.model.removeEventListener("Changing",this._listener.onChanging),this.view&&(this.view.removeEventListener("Destroy",this._listener.onDestroy),this.view=null)},_trackUnsavedChanges:function(e){if(this._unsavedChanges){var t=this._unsavedChanges.length,n=e.addedCharCount,i=e.removedCharCount,r=e.start,o=e.start+i,s=0;if(0===n?s=-1:0===i&&(s=1),t>0&&s===this._previousChangeType){var a=this._unsavedChanges[t-1];if(0===i&&r===a.end+a.text.length)return void(a.text+=e.text);if(0===e.addedCharCount&&o===a.start)return void(a.start=r)}this._previousChangeType=s,this._unsavedChanges.push({start:r,end:o,text:e.text})}},_onChanging:function(t){if(this._trackUnsavedChanges(t),!this._ignoreUndo){var n=t.text,i=t.start,r=t.addedCharCount,o=t.removedCharCount,s=i+o,a=0;0===r&&1===o?a=-1:1===r&&0===o&&(a=1);var l=this.stack.length,d=this.model.getText(i,s);if(l>0&&this.index===l){var c=this.stack[l-1];if(c.merge(i,n,d,a,s,this.compoundChange))return}this.add(new e(this.model,i,n,d,a))}}},{UndoStack:n}}),n("orion/explorers/navigatorRenderer",[],function(){return{getClickedItem:function(){return null}}}),n("orion/editor/projectionTextModel",["orion/editor/textModel","orion/editor/eventTarget"],function(e,t){function n(e){this._model=e,this._projections=[];var t=this;this._listener={onChanged:function(e){t._onChanged(e)},onChanging:function(e){t._onChanging(e)}},e.addEventListener("postChanged",this._listener.onChanged),e.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(t){if(t){var n=this._model,i=this._projections;t._lineIndex=n.getLineAtOffset(t.start),t._lineCount=n.getLineAtOffset(t.end)-t._lineIndex;var r=t.text;r||(r=""),t._model="string"==typeof r?new e.TextModel(r,n.getLineDelimiter()):r;var o=this.mapOffset(t.start,!0),s=t.end-t.start,a=t._lineCount,l=t._model.getCharCount(),d=t._model.getLineCount()-1,c=t._model.getText(),h={type:"Changing",text:c,start:o,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:d};this.onChanging(h);var u=this._binarySearch(i,t.start);i.splice(u,0,t);var f={type:"Changed",start:o,changedText:r,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:d};this.onChanged(f)}},getProjections:function(){return this._projections.slice(0)},getBaseModel:function(){return this._model},mapOffset:function(e,t){var n,i,r=this._projections,o=0;if(t){for(n=0;n<r.length&&(i=r[n],!(i.start>e));n++){if(i.end>e)return-1;o+=i._model.getCharCount()-(i.end-i.start)}return e+o}for(n=0;n<r.length&&(i=r[n],!(i.start>e-o));n++){var s=i._model.getCharCount(); if(i.start+s>e-o)return-1;o+=s-(i.end-i.start)}return e-o},removeProjection:function(e){this._removeProjection(e)},_removeProjection:function(e,t){var n,i=0;for(n=0;n<this._projections.length;n++){var r=this._projections[n];if(r===e){e=r;break}i+=r._model.getCharCount()-(r.end-r.start)}if(n<this._projections.length){var o=this._model,s=e.start+i,a=e.end-e.start,l=e._lineCount,d=e._model.getCharCount(),c=e._model.getLineCount()-1,h=o.getText(e.start,e.end);if(!t){var u={type:"Changing",text:h,start:s,removedCharCount:d,addedCharCount:a,removedLineCount:c,addedLineCount:l};this.onChanging(u)}if(this._projections.splice(n,1),!t){var f={type:"Changed",start:s,text:h,removedCharCount:d,addedCharCount:a,removedLineCount:c,addedLineCount:l};this.onChanged(f)}}},_binarySearch:function(e,t){for(var n,i=e.length,r=-1;i-r>1;)n=Math.floor((i+r)/2),t<=e[n].start?i=n:r=n;return i},getCharCount:function(){for(var e=this._model.getCharCount(),t=this._projections,n=0;n<t.length;n++){var i=t[n];e+=i._model.getCharCount()-(i.end-i.start)}return e},getLine:function(e,t){if(0>e)return null;var n,i,r,o=this._model,s=this._projections,a=0,l=[],d=0;for(n=0;n<s.length&&(r=s[n],!(r._lineIndex>=e-a));n++){if(i=r._model.getLineCount()-1,r._lineIndex+i>=e-a){var c=e-(r._lineIndex+a);if(i>c)return r._model.getLine(c,t);l.push(r._model.getLine(i))}d=r.end,a+=i-r._lineCount}for(d=Math.max(d,o.getLineStart(e-a));n<s.length&&(r=s[n],!(r._lineIndex>e-a));n++){if(l.push(o.getText(d,r.start)),i=r._model.getLineCount()-1,r._lineIndex+i>e-a)return l.push(r._model.getLine(0,t)),l.join("");l.push(r._model.getText()),d=r.end,a+=i-r._lineCount}var h=o.getLineEnd(e-a,t);return h>d&&l.push(o.getText(d,h)),l.join("")},getLineAtOffset:function(e){for(var t=this._model,n=this._projections,i=0,r=0,o=0;o<n.length;o++){var s=n[o];if(s.start>e-i)break;var a=s._model.getCharCount();if(s.start+a>e-i){var l=e-(s.start+i);r+=s._model.getLineAtOffset(l),i+=l;break}r+=s._model.getLineCount()-1-s._lineCount,i+=a-(s.end-s.start)}return t.getLineAtOffset(e-i)+r},getLineCount:function(){for(var e=this._model,t=this._projections,n=e.getLineCount(),i=0;i<t.length;i++){var r=t[i];n+=r._model.getLineCount()-1-r._lineCount}return n},getLineDelimiter:function(){return this._model.getLineDelimiter()},getLineEnd:function(e,t){if(0>e)return-1;for(var n=this._model,i=this._projections,r=0,o=0,s=0;s<i.length;s++){var a=i[s];if(a._lineIndex>e-r)break;var l=a._model.getLineCount()-1;if(a._lineIndex+l>e-r){var d=e-(a._lineIndex+r);return a._model.getLineEnd(d,t)+a.start+o}o+=a._model.getCharCount()-(a.end-a.start),r+=l-a._lineCount}return n.getLineEnd(e-r,t)+o},getLineStart:function(e){if(0>e)return-1;for(var t=this._model,n=this._projections,i=0,r=0,o=0;o<n.length;o++){var s=n[o];if(s._lineIndex>=e-i)break;var a=s._model.getLineCount()-1;if(s._lineIndex+a>=e-i){var l=e-(s._lineIndex+i);return s._model.getLineStart(l)+s.start+r}r+=s._model.getCharCount()-(s.end-s.start),i+=a-s._lineCount}return t.getLineStart(e-i)+r},getText:function(e,t){void 0===e&&(e=0);var n,i,r,o=this._model,s=this._projections,a=0,l=[];for(n=0;n<s.length&&(i=s[n],!(i.start>e-a));n++){if(r=i._model.getCharCount(),i.start+r>e-a){if(void 0!==t&&i.start+r>t-a)return i._model.getText(e-(i.start+a),t-(i.start+a));l.push(i._model.getText(e-(i.start+a))),e=i.end+a+r-(i.end-i.start)}a+=r-(i.end-i.start)}var d=e-a;if(void 0!==t){for(;n<s.length&&(i=s[n],!(i.start>t-a));n++){if(l.push(o.getText(d,i.start)),r=i._model.getCharCount(),i.start+r>t-a)return l.push(i._model.getText(0,t-(i.start+a))),l.join("");l.push(i._model.getText()),d=i.end,a+=r-(i.end-i.start)}l.push(o.getText(d,t-a))}else{for(;n<s.length;n++)i=s[n],l.push(o.getText(d,i.start)),l.push(i._model.getText()),d=i.end;l.push(o.getText(d))}return l.join("")},_onChanged:function(){var e,t,n=this._change,i=n.baseStart,r=n.baseEnd,o=this._projections;for(e=0;e<o.length&&(t=o[e],!(t.end>i));e++);var s=e;for(e=0;e<o.length&&(t=o[e],!(t.start>=r));e++);var a=e,l=this._model,d=n.baseText.length-(r-i);for(e=a;e<o.length;e++)t=o[e],t.start+=d,t.end+=d,t._lineIndex=l.getLineAtOffset(t.start);var c=o.splice(s,a-s);for(e=0;e<c.length;e++)c[e].annotation&&c[e].annotation._expand();var h={type:"Changed",start:n.start,text:n.text,removedCharCount:n.removedCharCount,addedCharCount:n.addedCharCount,removedLineCount:n.removedLineCount,addedLineCount:n.addedLineCount};this.onChanged(h),this._change=void 0},_onChanging:function(e){function t(e){for(a=0,s=0;a<d.length&&(l=d[a],!(l.start>e));a++){if(l.end>e)return-1;s+=l._model.getCharCount()-(l.end-l.start)}return e+s}var n=!!this._change,i=this._change||{},r=e.start,o=r+e.removedCharCount;if(i.baseStart=r,i.baseEnd=o,i.baseText=e.text,i.addedLineCount=e.addedLineCount,!n){this._change=i,i.text=e.text;var s,a,l,d=this._projections;i.start=t(r),-1===i.start&&(i.text=this._model.getText(l.start,r)+i.text,i.addedLineCount+=this._model.getLineAtOffset(r)-this._model.getLineAtOffset(l.start),i.start=l.start+s),i.end=t(o),-1===i.end&&(i.text+=this._model.getText(o,l.end),i.addedLineCount+=this._model.getLineAtOffset(l.end)-this._model.getLineAtOffset(o),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 c={type:"Changing",text:i.text,start:i.start,removedCharCount:i.removedCharCount,addedCharCount:i.addedCharCount,removedLineCount:i.removedLineCount,addedLineCount:i.addedLineCount};this.onChanging(c)},onChanging:function(e){return this.dispatchEvent(e)},onChanged:function(e){return this.dispatchEvent(e)},setLineDelimiter:function(e){this._model.setLineDelimiter(e)},setText:function(e,t,n){function i(e){for(o=0,r=0;o<d.length&&(s=d[o],!(s.start>e-r));o++){var t=s._model.getCharCount();if(s.start+t>e-r)return-1;r+=t-(s.end-s.start)}return e-r}this._change={text:e||"",start:t||0,end:void 0===n?this.getCharCount():n};var r,o,s,a,l,d=this._projections,c=i(this._change.start);-1===c&&(a={projection:s,start:this._change.start-(s.start+r)},c=s.end);var h=i(this._change.end);-1===h&&(l={projection:s,end:this._change.end-(s.start+r)},h=s.start),a&&l&&a.projection===l.projection?s._model.setText(this._change.text,a.start,l.end):(this._model.setText(this._change.text,c,h),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}},t.EventTarget.addMixin(n.prototype),{ProjectionTextModel:n}}),n("orion/editor/textModelFactory",["orion/editor/textModel","orion/editor/projectionTextModel"],function(e,t){function n(){}return n.prototype={createTextModel:function(){return new e.TextModel},createProjectionTextModel:function(e,n){return new t.ProjectionTextModel(e?e:this.createTextModel(n))}},{TextModelFactory:n}}),n("lsp/utils",["orion/Deferred"],function(e){function t(e,t){var n=e.getLineAtOffset(t),i=e.getLineStart(n);return{line:n,character:t-i}}function n(n,i,r,o){return o.proposal&&"java"===o.proposal.kind?o.proposal.hover:void 0===o.offset?"":n.hover(i.getFileMetadata().Location,t(r,o.offset)).then(function(t){if(t){var n={type:"markdown"};if(Array.isArray(t.contents)){if(0===t.contents.length)return(new e).resolve("");var i=t.contents[0];if("string"==typeof i&&0===i.length)return(new e).resolve("");n.content="object"==typeof t.contents[0]?t.contents[0].value:t.contents[0]}else if("string"==typeof t.contents){if(0===t.contents.length)return(new e).resolve("");n.content=t.contents}else null!==t.contents&&"object"==typeof t.contents&&(n.content=t.contents.value);return(new e).resolve(n)}return(new e).resolve("")},function(){return(new e).resolve("")})}function i(n,i,r,o){var s=r.getSelectionText();return 0===s.trim().length?(new e).resolve([]):n.documentHighlight(i.getFileMetadata().Location,t(r,o.selection.start)).then(function(t){return t&&Array.isArray(t)&&t.length>0?t.map(function(e){var t=r.getLineStart(e.range.start.line);return{start:e.range.start.character+t,end:e.range.end.character+t,readAccess:e.kind===n.ipc.DOCUMENT_HIGHLIGHT_KIND.Read}}):(new e).resolve([])},function(){return(new e).resolve([])})}function r(e,t){var n=e[e.length-1];if(n&&n.label===t)return e.length-1;for(var i=0;i<e.length;i++)if(e[i].label===t)return i;return-1}function o(e){switch(e){case 1:return"File";case 2:return"Module";case 3:return"Namespace";case 4:return"Package";case 5:return"Class";case 6:return"Method";case 7:return"Property";case 8:return"Field";case 9:return"Constructor";case 10:return"Enum";case 11:return"Interface";case 12:return"Function";case 13:return"Variable";case 14:return"Constant";case 15:return"String";case 16:return"Number";case 17:return"Boolean";case 18:return"Array";default:return"Unknown"}}function s(t,n){return t.documentSymbol(n.getFileMetadata().Location).then(function(t){if(Array.isArray(t)&&t.length>0){var n=[];return t.forEach(function(e){var t=e.location.range.start.character,i={label:e.name,labelPost:" ("+o(e.kind)+")",line:e.location.range.start.line+1,offset:t,length:e.location.range.end.character-t,children:[]};if(e.containerName){var s,a=r(n,e.containerName);0>a?(s={label:e.containerName,children:[]},n.push(s)):s=n[a],s.children.push(i)}else n.push(i)}),n}return(new e).resolve([])})}function a(e,n,i){return{start:t(e,n),end:t(e,i)}}function l(e,t){var n=e.getLineStart(t.start.line),i=e.getLineStart(t.end.line);return{start:t.start.character+n,end:t.end.character+i}}function d(e){var t=[];return e.forEach(function(e){var n=c(e.severity);n&&t.push({description:e.message,id:e.code,severity:n,range:e.range})}),t}function c(e){return 3===_[e]?null:_[e]}function h(e,t){return e.getLineAtOffset(t).then(function(n){return e.getLineStart(n).then(function(e){return{line:n,character:t-e}})})}function u(t,n,i){return n.getFileMetadata().then(function(r){return h(n,i.selection.start).then(function(i){return t.completion(r.location,i).then(function(i){var r=i;return i.items&&(r=i.items),Array.isArray(r)&&r.length>0?e.all(p(t,n,r)).then(function(t){return(new e).resolve(t)}):(new e).resolve([])},function(){return(new e).resolve([])})})})}function f(e){switch(e){case 1:return"Text";case 2:return"Method";case 3:return"Function";case 4:return"Constructor";case 5:return"Field";case 6:return"Variable";case 7:return"Class";case 8:return"Interface";case 9:return"Module";case 10:return"Property";case 11:return"Unit";case 12:return"Value";case 13:return"Enum";case 14:return"Keyword";case 15:return"Snippet";case 16:return"Color";case 17:return"File";case 18:return"Reference";default:return"Unknown"}}function p(e,t,n){return n.map(function(n){return e.completionItemResolve(n).then(function(e){var n={name:e.label,description:" ("+f(e.kind)+")",relevance:100,style:"emphasis",overwrite:!0,kind:"java"};if(n.proposal=e.textEdit?e.textEdit.newText:e.insertText?e.insertText:e.label,n.proposal){var i=n.proposal,r=i.indexOf("${");if(n.positions=[],-1===r)n.escapePosition=i.length;else{for(;-1!==r;){i=i.substring(0,r)+i.substring(r+4);var o=i.indexOf("}");i=i.substring(0,o)+i.substring(o+1),n.positions.push({offset:r,length:o-r}),r=i.indexOf("${")}n.proposal=i,n.escapePosition=i.length}}if(e.documentation&&(n.hover={content:e.documentation,type:"markdown"}),Array.isArray(e.additionalTextEdits)&&0!==e.additionalTextEdits.length){var s=[];e.additionalTextEdits.forEach(function(e){var t=Object.create(null);t.text=e.newText,t.range=e.range,s.push(t)}),n.additionalEdits=s}return m(t,e,n)})})}function g(e,t){var n=t.range;return e.getLineStart(n.start.line).then(function(i){return e.getLineStart(n.end.line).then(function(e){return{text:t.newText,start:n.start.character+i,end:n.end.character+e}})})}function v(e,t,n,i){t.getLineStart(n.textEdit.range.start.line).then(function(t){for(var r=n.textEdit.range.start.character+t,o=0;o<i.positions.length;o++)i.positions[o].offset=r+i.positions[o].offset;i.escapePosition=r+i.escapePosition,e.resolve(i)})}function m(t,n,i){var r=new e;if(i.additionalEdits){var o=i.additionalEdits.length;i.additionalEdits.forEach(function(e,s){return g(t,e).then(function(a){e.offset=a.start,e.length=a.end-e.offset,delete e.range,s===o-1&&(n.textEdit?v(r,t,n,i):r.resolve(i))})})}else n.textEdit?v(r,t,n,i):(delete i.escapePosition,r.resolve(i));return r}var _={1:"error",2:"warning",3:"info"};return{getPosition:t,computeHoverInfo:n,computeOccurrences:i,getRange:a,toProblems:d,documentSymbol:s,computeContentAssist:u,convertRange:l}}),n("orion/formatter",["orion/Deferred","lsp/utils"],function(e,t){function n(e,t,n,i){this.serviceRegistry=e,this.inputManager=t,this.editor=n,this.languageServerRegistry=i}return n.prototype={getFormatter:function(){for(var e=this.inputManager.getContentType(),t=this.serviceRegistry.getServiceReferences("orion.edit.format"),n=0;n<t.length;n++){var i=t[n],r=i.getProperty("contentType");if(e&&e.id){var o=e.id;if(Array.isArray(r)){for(var s=0,a=r.length;a>s;s++)if(r[s]===o)return this.serviceRegistry.getService(i)}else if(o===r)return this.serviceRegistry.getService(i)}}return null},getLspFormatter:function(){var e=this.inputManager.getContentType();return this.languageServerRegistry.getServerByContentType(e)},isVisible:function(){if(this.getFormatter())return!0;var e=this.getLspFormatter();return e?e.isFormatDocumentEnabled()||e.isRangeFormatDocumentEnabled():!1},doFormat:function(){var n=this.editor.getSelection(),i=this.getFormatter();if(i){var r={start:n.start,end:n.end};return i.format(this.editor.getEditorContext(),r)}var o=this.getLspFormatter();if(o){var s=this.editor.getTextView(),a={tabSize:s.getOptions("tabSize"),insertSpaces:s.getOptions("expandTab")};if(n.start!==n.end){var l=t.getPosition(this.editor,n.start),d=t.getPosition(this.editor,n.end);return o.rangeFormatting(this.inputManager.getFileMetadata().Location,l,d,a).then(function(e){Array.isArray(e)&&0!==e.length&&this.editor.setText({text:e.map(function(e){return e.newText}),selection:e.map(function(e){var t=e.range;return{start:this.editor.getLineStart(t.start.line)+t.start.character,end:this.editor.getLineStart(t.end.line)+t.end.character}}.bind(this)),preserveSelection:!0})}.bind(this))}return o.formatDocument(this.inputManager.getFileMetadata().Location,a).then(function(e){Array.isArray(e)&&0!==e.length&&this.editor.setText({text:e.map(function(e){return e.newText}),selection:e.map(function(e){var t=e.range;return{start:this.editor.getLineStart(t.start.line)+t.start.character,end:this.editor.getLineStart(t.end.line)+t.end.character}}.bind(this)),preserveSelection:!0})}.bind(this))}return(new e).resolve()}},{Formatter:n}}),n("lsp/ipc",[],function(){function e(e,t,n){this.lspService=e,this.languageId=t,this.serviceRegistry=n,this.id=1}return e.prototype.TEXT_DOCUMENT_SYNC_KIND=Object.freeze({None:0,Full:1,Incremental:2}),e.prototype.DOCUMENT_HIGHLIGHT_KIND=Object.freeze({None:1,Read:2,Write:3}),e.prototype.ERROR_CODES=Object.freeze({ParseError:-32700,InvalidRequest:-32600,MethodNotFound:-32601,InvalidParams:-32602,InternalError:-32603,ServerErrorStart:-32099,ServerErrorEnd:-32e3,ServerNotInitialized:-32002,UnknownErrorCode:-32001}),e.prototype.ERROR_TYPES=Object.freeze({1:"error",2:"warn",3:"info"}),e.prototype.MESSAGE_TYPES=Object.freeze({initialize:"initialize",initialized:"initialized",shutdown:"shutdown",cancelRequest:"$/cancelRequest",status:"language/status",exit:"exit",showMessage:"window/showMessage",showMessageRequest:"window/showMessageRequest",logMessage:"window/logMessage",telemetryEvent:"telemetry/event",registerCapability:"client/registerCapability",unregisterCapability:"client/unregisterCapability",didChangeConfiguration:"workspace/didChangeConfiguration",didChangeWatchedFiles:"workspace/didChangeWatchedFiles",workspaceSymbol:"workspace/symbol",workspaceExecuteCommand:"workspace/executeCommand",workspaceApplyEdit:"workspace/applyEdit",codeAction:"textDocument/codeAction",codeLens:"textDocument/codeLens",completion:"textDocument/completion",definition:"textDocument/definition",didOpen:"textDocument/didOpen",didChange:"textDocument/didChange",didClose:"textDocument/didClose",didSave:"textDocument/didSave",documentHighlight:"textDocument/documentHighlight",documentSymbol:"textDocument/documentSymbol",formatting:"textDocument/formatting",hover:"textDocument/hover",onTypeFormatting:"textDocument/onTypeFormatting",publishDiagnostics:"textDocument/publishDiagnostics",rangeFormatting:"textDocument/rangeFormatting",references:"textDocument/references",rename:"textDocument/rename",signatureHelp:"textDocument/signatureHelp",completionItemResolve:"completionItem/resolve",codeLensResolve:"codeLens/resolve",willSave:"textDocument/willSave",willSaveWaitUntil:"textDocument/willSaveWaitUntil",documentLink:"textDocument/documentLink",documentLinkResolve:"documentLink/resolve"}),e.prototype.sendMessage=function(e,t,n){return this.lspService.sendMessage(e,t,n)},e.prototype.didOpen=function(e,t,n,i){return this.sendMessage(0,this.MESSAGE_TYPES.didOpen,{textDocument:{uri:e,languageId:t,version:n,text:i}})},e.prototype.didClose=function(e){return this.sendMessage(0,this.MESSAGE_TYPES.didClose,{textDocument:{uri:e}})},e.prototype.didSave=function(e,t){return this.sendMessage(0,this.MESSAGE_TYPES.didSave,{textDocument:{uri:e},text:t})},e.prototype.didChange=function(e,t,n){return this.sendMessage(0,this.MESSAGE_TYPES.didChange,{textDocument:{uri:e,version:t},contentChanges:n})},e.prototype.documentHighlight=function(e,t){return this.sendMessage(this.id++,this.MESSAGE_TYPES.documentHighlight,{position:t,textDocument:{uri:e}})},e.prototype.completion=function(e,t){return this.sendMessage(this.id++,this.MESSAGE_TYPES.completion,{position:t,textDocument:{uri:e}})},e.prototype.hover=function(e,t){return this.sendMessage(this.id++,this.MESSAGE_TYPES.hover,{position:t,textDocument:{uri:e}})},e.prototype.documentSymbol=function(e){return this.sendMessage(this.id++,this.MESSAGE_TYPES.documentSymbol,{textDocument:{uri:e}})},e.prototype.formatDocument=function(e,t){return this.sendMessage(this.id++,this.MESSAGE_TYPES.formatting,{textDocument:{uri:e},options:t})},e.prototype.codeLens=function(e){return this.sendMessage(this.id++,this.MESSAGE_TYPES.codeLens,{textDocument:{uri:e}})},e.prototype.references=function(e,t,n){return this.sendMessage(this.id++,this.MESSAGE_TYPES.references,{position:t,context:n,textDocument:{uri:e}})},e.prototype.definition=function(e,t){return this.sendMessage(this.id++,this.MESSAGE_TYPES.definition,{position:t,textDocument:{uri:e}})},e.prototype.shutdown=function(){return this.sendMessage(this.id++,this.MESSAGE_TYPES.shutdown,{})},e.prototype.showMessageRequest=function(e,t,n){return this.sendMessage(this.id++,this.MESSAGE_TYPES.showMessageRequest,{type:e,message:t,actions:n})},e.prototype.workspaceSymbol=function(e){return this.sendMessage(this.id++,this.MESSAGE_TYPES.workspaceSymbol,{query:e})},e.prototype.codeAction=function(e,t,n,i){return this.sendMessage(this.id++,this.MESSAGE_TYPES.codeAction,{textDocument:{uri:e},range:{start:t,end:n},context:{diagnostics:i}})},e.prototype.onTypeFormatting=function(e,t,n,i){return this.sendMessage(this.id++,this.MESSAGE_TYPES.onTypeFormatting,{textDocument:{uri:e},position:t,"char":n,options:i})},e.prototype.rangeFormatting=function(e,t,n,i){return this.sendMessage(this.id++,this.MESSAGE_TYPES.rangeFormatting,{textDocument:{uri:e},range:{start:t,end:n},options:i})},e.prototype.codeLensResolve=function(e){return this.sendMessage(this.id++,this.MESSAGE_TYPES.codeLensResolve,{codeLens:e})},e.prototype.rename=function(e,t,n){return this.sendMessage(this.id++,this.MESSAGE_TYPES.rename,{textDocument:{uri:e},position:t,newName:n})},e.prototype.signatureHelp=function(e,t,n,i,r){return this.sendMessage(this.id++,this.MESSAGE_TYPES.signatureHelp,{textDocument:{uri:e,position:t},signatures:n,activeSignature:i,activeParameter:r})},e.prototype.completionItemResolve=function(e){return this.sendMessage(this.id++,this.MESSAGE_TYPES.completionItemResolve,e)},e}),n("lsp/languageServer",["orion/Deferred","lsp/ipc","lsp/utils"],function(e,t,n){function i(e,i,l,d){this._id=i,this.started=!1,this.serviceRef=e;var c=this.lspService=l.getService(e);this.ipc=new t(c,i,l),Object.keys(t.prototype).forEach(function(e){"function"==typeof t.prototype[e]&&(this[e]=r(e,this.ipc))}.bind(this),this),c.addEventListener(this.ipc.MESSAGE_TYPES.logMessage,function(e){var t=e.data;null!==t&&"object"==typeof t&&(t.params&&o&&1===t.params.type||s&&2===t.params.type||a&&3===t.params.type)&&("object"==typeof t&&null!==t?console.log(JSON.stringify(t)):"string"==typeof t&&console.log(t))}),c.addEventListener(this.ipc.MESSAGE_TYPES.publishDiagnostics,function(e){var t=e.data,i=l.getService(d);i&&i._setProblems(n.toProblems(t.params.diagnostics),t.params.uri),console.log(JSON.stringify(t))}),c.addEventListener(this.ipc.MESSAGE_TYPES.status,function(e){var t=e.data,n=l.getService("orion.page.message");n&&("Started"===t.params.type?n.setProgressResult("Java "+t.params.type+" "+t.params.message):n.setProgressMessage("Java "+t.params.type+" "+t.params.message))})}function r(t,n){return function(){var i;try{var r=n[t].apply(n,Array.prototype.slice.call(arguments));if(r&&"function"==typeof r.then)return r;i=new e,i.resolve(r)}catch(o){i=new e,i.reject(o)}return i.promise}}var o="true"===localStorage.getItem("java.langserver.logmessage.error"),s="true"===localStorage.getItem("java.langserver.logmessage.warn"),a="true"===localStorage.getItem("java.langserver.logmessage.error.info");return i.prototype={getProperty:function(e){return"id"===e?this._id:this.serviceRef.getProperty(e)},start:function(){return this.started?new e(this.capabilities):(this.started=!0,this.lspService.start().then(function(e){return this.capabilities=e}.bind(this)))},getCapabilities:function(){return this.capabilities},getTextDocumentSync:function(){if(this.capabilities&&this.capabilities.textDocumentSync){var e=this.capabilities.textDocumentSync;switch(this.capabilities.textDocumentSync.change&&(e=this.capabilities.textDocumentSync.change),e){case this.ipc.TEXT_DOCUMENT_SYNC_KIND.None:case this.ipc.TEXT_DOCUMENT_SYNC_KIND.Incremental:case this.ipc.TEXT_DOCUMENT_SYNC_KIND.Full:return e}}return this.ipc.TEXT_DOCUMENT_SYNC_KIND.None},includeTextOnSave:function(){return this.capabilities&&this.capabilities.textDocumentSync&&this.capabilities.textDocumentSync.save?this.capabilities.textDocumentSync.save.includeText===!0:!1},isDefinitionEnabled:function(){return this.capabilities&&this.capabilities.definitionProvider},isReferencesEnabled:function(){return this.capabilities&&this.capabilities.referencesProvider},isFormatDocumentEnabled:function(){return this.capabilities&&this.capabilities.documentFormattingProvider},isRangeFormatDocumentEnabled:function(){return this.capabilities&&this.capabilities.documentRangeFormattingProvider},isDocumentSymbolEnabled:function(){return this.capabilities&&this.capabilities.documentSymbolProvider},isDocumentHighlightEnabled:function(){return this.capabilities&&this.capabilities.documentHighlightProvider},isHoverEnabled:function(){return this.capabilities&&this.capabilities.hoverProvider}},i}),n("lsp/languageServerRegistry",["lsp/languageServer"],function(e){function t(e,t){i=e,o=t}var n,i,r,o;return t.prototype={init:function(){if(!n&&!r&&i){var t=i.getServiceReferences("orion.languages.server");t&&(n=new Map,r=new Map,t.forEach(function(t){var s=t.getProperty("languageId"),a=t.getProperty("contentType");if(s&&a){var l=new e(t,s,i,o);if(Array.isArray(a))for(var d=0,c=a.length;c>d;d++)r.set(a[d],l);else r.set(a,l);n.set(s,e)}}))}},getServerById:function(e){this.init();var t=n.get(e);return t?t:null},getServerByContentType:function(e){if(!e)return null;this.init();var t=r.get(e.id);return t?t:null}},{LanguageServerRegistry:t}}),n("orion/inputManager",["i18n!orion/edit/nls/messages","orion/explorers/navigatorRenderer","orion/i18nUtil","orion/Deferred","orion/EventTarget","orion/objects","orion/PageUtil","orion/editor/textModelFactory","orion/formatter","lsp/languageServerRegistry","orion/metrics"],function(e,t,n,i,r,o,s,a,l,d,c){function h(e){this._document=e.document||document,this._timeout=e.timeout;for(var t=["mousedown","keypress","keydown","keyup"],n=function(){this._resetTimer()}.bind(this),i=0;i<t.length;i++){var o=t[i];this._document.addEventListener(o,n,!0)}r.attach(this)}function u(t){var i={Severity:"Error"};if(i.Message=t.args&&t.args.timeout?n.formatMessage(e.noResponseTimeout,t.args.timeout/1e3):e.noResponse,"Cancel"===t.name)return{Severity:"Warning",Message:t.name,Cancel:!0};if(0===t.status)return i.Cancel=!0,i;if(t.responseText){var r=t.responseText;try{var o=JSON.parse(r);i.Severity=o.Severity||i.Severity,i.Message=o.Message||i.Message}catch(s){i.Message=r}}else try{i.Message=JSON.stringify(t)}catch(s){}return i}function f(e,t){return e?(t.Severity||(t=u(t)),e.setProgressResult(t),t):void window.console.log(t)}function p(e,t,n,i){if(window.TextDecoder)n(new TextDecoder(t).decode(e));else{var r="text/plain; charset="+t,o=new Blob([e],{type:r}),s=new FileReader;s.onload=function(){n(s.result)}.bind(this),s.onerror=i,s.readAsText(o,t)}}function g(e){return!e||e===m}function v(e){r.attach(this),this.serviceRegistry=e.serviceRegistry,this.statusService=e.statusService,this.fileClient=e.fileClient,this.progressService=e.progressService,this.contentTypeRegistry=e.contentTypeRegistry,this.selection=e.selection,this.reveal=e.reveal,this.isUnsavedWarningNeeed=e.isUnsavedWarningNeeed,this.confirm=e.confirm,this.generalPreferences=e.generalPreferences||{},this.isEditorTabsEnabled=e.isEditorTabsEnabled||!1,this._input=this._title="",this.languageServerRegistry=new d.LanguageServerRegistry(this.serviceRegistry,e.problemsServiceID||"orion.core.marker"),this.fileClient&&this.fileClient.addEventListener("Changed",function(e){if((!this._fileMetadata||!this._fileMetadata._saving)&&e&&e.modified){var t=this.getFileMetadata();t&&t.Location&&e.modified.some(function(e){return t.Location===e})&&this.load(null,!0)}}.bind(this)),this.syncEnabled=!0}h.prototype={_resetTimer:function(){var e=this._document.defaultView||this._document.parentWindow;this._timer&&(e.clearTimeout(this._timer),this._timer=null),-1!==this._timeout&&(this._timer=e.setTimeout(function(){this.onIdle({type:"Idle"}),this._timer=null,this._resetTimer()}.bind(this),this._timeout))},onIdle:function(e){return this.dispatchEvent(e)},setTimeout:function(e){this._timeout=e,this._resetTimer()}};var m="UTF-8";return o.mixin(v.prototype,{_maybeLoadWorkspace:function(e){var t=this.fileClient,n=e;return n.indexOf("?")&&(n=n.split("?")[0]),n===t.fileServiceRootURL(n)?t.loadWorkspace(n).then(function(e){return e.Location}):(new i).resolve(e)},_read:function(e){var n=this.cachedMetadata||t.getClickedItem();if(n&&n.Location===e&&n.Parents&&n.Attributes&&n.ETag)return(new i).resolve(n);var r=this.fileClient,o=Array.prototype.slice.call(arguments,1);return this._maybeLoadWorkspace(e).then(function(e){return r.read.apply(r,[e].concat(o))})},_isSameParent:function(e){if(this._lastMetadata&&this._lastMetadata.Parents&&this._lastMetadata.Parents.length>0){var t=e.substring(0,e.lastIndexOf("/",e.length-("/"===e[e.length-1]?2:1))+1);return this._lastMetadata.Parents[0].Location===t}return!1},load:function(t,r){var s=this.getInput();if(s){var l=this.fileClient,d=this._parsedLocation.resource,c=this.progressService,h=function(e,t,i){return c?c.progress(e,n.formatMessage(t,i)):e},u=this.getEditor();if(this._fileMetadata)this._fileMetadata._saving||this._fileMetadata.Directory||this.getReadOnly()||h(l.read(d,!0),e.ReadingMetadata,s).then(function(t){if(this._fileMetadata&&!this._fileMetadata._saving&&this._fileMetadata.Location===t.Location&&this._fileMetadata.ETag!==t.ETag){this._fileMetadata=o.mixin(this._fileMetadata,t);var n=function(){h(l.read(d),e.Reading,s).then(function(e){u.setInput(s,null,e,null,r),this._clearUnsavedChanges()}.bind(this))};if(this.syncEnabled&&!u.isDirty())n();else{var i=this.serviceRegistry.getService("orion.page.dialog");i.confirm(e.loadOutOfSync,function(e){this.syncEnabled&&e&&n()})}}}.bind(this));else{var v=window.setTimeout(function(){v=null,this.reportStatus(n.formatMessage(e.Fetching,s))}.bind(this),800),m=function(){this.reportStatus(""),v&&window.clearTimeout(v)}.bind(this),_=d,y=function(e){m();var t=null;this.serviceRegistry?t=this.serviceRegistry.getService("orion.page.message"):this.statusService&&(t=this.statusService),f(t,e),this._setNoInput(_)}.bind(this);if(this._acceptPatch=null,!this._isSameParent(_)){var C=new URL(_);C.query.set("tree",localStorage.useCompressedTree?"compressed":"decorated"),_=C.href}h(this._read(_,!0),e.ReadingMetadata,d).then(function(r){if(r)if(r.Directory)i.when(r.Children||h(l.fetchChildren(r.ChildrenLocation),e.Reading,s),function(e){m(),r.Children=e,this._setInputContents(this._parsedLocation,s,e,r)}.bind(this),y);else{t=t||this._charset;var o=this._isText(r);if(g(t)&&o){var c,u=new a.TextModelFactory;"function"==typeof u.getDefaultReadOptions&&(c=u.getDefaultReadOptions()),h(l.read(d,!1,!0,c),e.Reading,s).then(function(e){m(),"string"!=typeof e&&(this._acceptPatch=e.acceptPatch,e=e.result),this._setInputContents(this._parsedLocation,s,e,r)}.bind(this),y)}else h(l._getService(d).readBlob(d),e.Reading,s).then(function(e){return m(),o?void p(e,t,function(e){this._setInputContents(this._parsedLocation,s,e,r)}.bind(this),y):void this._setInputContents(this._parsedLocation,s,e,r)}.bind(this),y)}else y({responseText:n.formatMessage(e.ReadingMetadataError,d)})}.bind(this),y)}}},processParameters:function(e){var t=this.getEditor();return t&&t.processParameters?t.processParameters(e):!1},getAutoLoadEnabled:function(){return this._autoLoadEnabled},getAutoSaveEnabled:function(){return this._autoSaveEnabled},getFormatOnSaveEnabled:function(){return this._formatOnSaveEnabled},getEditor:function(){return this.editor},getEncodingCharset:function(){return this._charset||m},getInput:function(){return this._input},getLocation:function(){return this._location},getTitle:function(){return this._title},getFileMetadata:function(){return this._fileMetadata},isSaveEnabled:function(){return!this.getReadOnly()},getReadOnly:function(){var e=this._fileMetadata;return this._readonly||!e||e.Attributes&&e.Attributes.ReadOnly?!0:!1},getContentType:function(){return this._contentType},onFocus:function(){return this._autoSaveEnabled&&this._errorSaving&&this.syncEnabled?void this.save():void(this._autoLoadEnabled&&this._fileMetadata&&this.syncEnabled&&this.load())},reportStatus:function(e){this.statusReporter?this.statusReporter(e):this.editor&&this.editor.reportStatus(e)},save:function(t){function r(e){var t=s._savingDeferred;return t.resolve(e),s._savingDeferred=null,s._saving=!1,t}function o(i){function o(n){d===i.getInput()&&(s.ETag=n.ETag,a.setInput(d,null,u,!0)),i.reportStatus(""),l&&b&&b.setProgressResult({Message:e.Saved,Severity:"Normal"}),i.postSave&&i.postSave(t);var o=i.languageServerRegistry.getServerByContentType(i.getContentType());if(o){var c=o.includeTextOnSave()?i.getEditor().getText():void 0;o.didSave(i.getFileMetadata().Location,c)}return r(n)}function h(e){i.reportStatus("");var t=f(b,e);return c.logEvent("status","exception",(i._autoSaveActive?"Auto-save: ":"Save: ")+t.Message),i._errorSaving=!0,r()}a.markClean();var u=a.getText(),p=u;if(i._getSaveDiffsEnabled()&&!i._errorSaving){var g=i._getUnsavedChanges();if(g){for(var v=0,m=0;m<g.length;m++)v+=g[m].text.length;u.length>v&&(p={diff:g})}}i._clearUnsavedChanges(),i._errorSaving=!1;var _=s.ETag,y={ETag:_},C=i._parsedLocation.resource,w=i.fileClient.write(C,p,y),x=i.progressService,b=null;return i.serviceRegistry&&(b=i.serviceRegistry.getService("orion.page.message")),x&&(w=x.progress(w,n.formatMessage(e.savingFile,d))),w.then(o,function(t){if(412===t.status){var s=i.serviceRegistry.getService("orion.page.dialog");s.confirm(e.saveOutOfSync,function(t){if(!t)return r();var s=i.fileClient.write(C,u);x&&(s=x.progress(s,n.formatMessage(e.savingFile,d))),s.then(o,h)})}else h(t)}),s._savingDeferred}var s=this.getFileMetadata(); if(!s)return(new i).reject();if(s._saving)return s._savingDeferred;s._savingDeferred=new i,s._saving=!0;var a=this.getEditor();if(!this.syncEnabled||!a||!a.isDirty()||this.getReadOnly())return r();var l=this._errorSaving,d=this.getInput();return this.reportStatus(e["Saving..."]),this._saveEventLogged||(this._logMetrics("save"),this._saveEventLogged=!0),this.dispatchEvent({type:"Saving",inputManager:this}),this.getFormatOnSaveEnabled()?this._formatter.doFormat().then(function(){return o(this)}.bind(this)):o(this)},setAutoLoadEnabled:function(e){this._autoLoadEnabled=e},setAutoSaveTimeout:function(e){if(this._autoSaveEnabled=-1!==e,this._autoSaveActive=!1,this._idle)this._idle.setTimeout(e);else{var t={document:document,timeout:e};this._idle=new h(t),this._idle.addEventListener("Idle",function(){!this._errorSaving&&this.syncEnabled&&(this._autoSaveActive=!0,this.save().then(function(){this._autoSaveActive=!1}))}.bind(this))}},setAutoSyntaxCheck:function(e,t){var n=t;if(e||(n=-1),this._autoSyntaxEnabled=-1!==n,this._autoSyntaxActive=!1,this._idle2)this._idle2.setTimeout(n);else{var i={document:document,timeout:n};this._idle2=new h(i),this._idle2.addEventListener("Idle",function(){this.editor&&(this._autoSyntaxActive=!0,this.editor._isSyntaxCheckRequired()&&(e(),this.editor._setSyntaxCheckRequired(!1),this._autoSyntaxActive=!1))}.bind(this))}},setFormatOnSave:function(e){this._formatOnSaveEnabled=e},setContentType:function(e){this._contentType=e},setEncodingCharset:function(e){this._charset=e},setInput:function(e,t){if(!this._ignoreInput&&(e||(e=s.hash()),"string"==typeof e)){var n=this.getEditor();n&&n.setNoFocus&&n.setNoFocus(t),e&&"#"!==e[0]&&(e="#"+e);var i=s.matchResourceParameters(e),r=this._parsedLocation||{},o=r.encoding!==i.encoding,a=function(){function t(){a.session&&a.session.save()}var s=n&&r.editor!==i.editor;this._location=e,this._parsedLocation=i,this._ignoreInput=!0,this.selection&&this.selection.setSelections(e),this._ignoreInput=!1;var a={type:"InputChanging",input:i};this.dispatchEvent(a);var l=i.resource;if(a.metadata){t(),this.reportStatus(""),this._input=l;var d=a.metadata;return void this._setInputContents(i,l,null,d,!1,!0)}l?l!==this._input||o?(t(),this._input=l,this._readonly=!1,this._lastMetadata=this._fileMetadata,this._fileMetadata=null,this.load(i.encoding)):s?(this.reportStatus(""),this._setInputContents(i,l,null,this._fileMetadata,this._isText(this._fileMetadata))):this.processParameters(i)||a.session&&a.session.apply(!0):(t(),this._setNoInput(""))}.bind(this);if(n&&n.isDirty()&&!this.isEditorTabsEnabled){var l=this._location,d=r.resource,c=i.resource;if(d!==c||o)if(this._autoSaveEnabled)this.save(),a();else if(this.syncEnabled&&this.isUnsavedWarningNeeed()){var h=function(){window.location.hash=l,this.reveal(this.getFileMetadata())}.bind(this);this.confirmUnsavedChanges(a,h)}else a()}else a()}},confirmUnsavedChanges:function(t,n,i){this.confirm(e.confirmUnsavedChanges,[{label:e.Yes,callback:function(){this.save(),t()}.bind(this),type:"ok"},{label:e.No,callback:function(){t()},type:"ok"},{label:e.Cancel,callback:n,type:"cancel"}],i)},setTitle:function(e){var t=e.lastIndexOf("/"),n=e;-1!==t&&(n=n.substring(t+1)),this._title=n},setSaveDiffsEnabled:function(e){this._saveDiffsEnabled=e;var t=this.editor;t&&!t.isDirty()&&this._clearUnsavedChanges()},_getSaveDiffsEnabled:function(){return this._saveDiffsEnabled&&this._acceptPatch&&-1!==this._acceptPatch.indexOf("application/json-patch")},_logMetrics:function(e){var t="(none)",n=this.getContentType(),i=this.getFileMetadata();if(n)t=n.id;else if(i){var r=i.Name,o=r.lastIndexOf(".");if(o>=0)t="unregistered: "+r.substring(o);else switch(r){case"AUTHORS":case"config":case"LICENSE":case"make":case"Makefile":t="unregistered: "+r}}c.logEvent("editor",e,t,null,{path:i.Location})},_unknownContentTypeAsText:function(){return!0},_isText:function(e){var t=this.contentTypeRegistry.getFileContentType(e);if(!t)return this._unknownContentTypeAsText();var n=this.contentTypeRegistry.getContentType("text/plain");return this.contentTypeRegistry.isExtensionOf(t,n)},_setNoInput:function(e){this.fileClient.getWorkspace(e).then(function(e){this._input=e.ChildrenLocation,this._setInputContents(e.ChildrenLocation,null,e,e)}.bind(this))},_setInputContents:function(e,t,n,i,r,o){var s,a=!1;i?(this._fileMetadata=i,this.setTitle(i.Location||String(i)),this.setContentType(this.contentTypeRegistry.getFileContentType(i)),s=i.Name,a=i.Directory):(this._fileMetadata=null,this.setTitle(t),this.setContentType(this.contentTypeRegistry.getFilenameContentType(this.getTitle())),s=this.getTitle());var d=this.getEditor();this._focusListener&&(d&&d.getTextView&&d.getTextView()&&d.getTextView().removeEventListener("Focus",this._focusListener),this._focusListener=null);var h={type:"InputChanged",input:e,name:s,title:t,contentType:this.getContentType(),metadata:i,location:this._location,contents:n};if(this._logMetrics("open"),this.dispatchEvent(h),this.editor=d=h.editor,this._formatter=new l.Formatter(this.serviceRegistry,this,d,this.languageServerRegistry),!a){if(r||(d.setInput(t,null,n),o&&this.load()),d&&d.getTextView&&d.getTextView()){var u=d.getTextView();u.addEventListener("Focus",this._focusListener=this.onFocus.bind(this)),d.getModel()&&"function"==typeof d.getModel().setModelData&&d.getModel().setModelData({metadata:i})}this.isEditorTabsEnabled||this._clearUnsavedChanges(),this.processParameters(e)||h.session&&h.session.apply(),h={},h.type="InputContentsSet",this.editor.dispatchEvent(h)}this._saveEventLogged=!1,c.logPageLoadTiming("interactive",window.location.pathname)},_getUnsavedChanges:function(){var e=this.editor;return e&&e.getUndoStack&&e.getUndoStack()?e.getUndoStack()._unsavedChanges:null},_clearUnsavedChanges:function(){var e=this.editor;e&&e.getUndoStack&&e.getUndoStack()&&(e.getUndoStack()._unsavedChanges=this._getSaveDiffsEnabled()?[]:null)}}),{handleError:f,InputManager:v}}),n("orion/editor/keyModes",["orion/keyBinding","orion/util"],function(e,t){function n(e){e&&(this._view=e,this._keyBindings=this.createKeyBindings(),this._keyBindingIndex=0)}function i(e){n.call(this,e)}return n.prototype={createKeyBindings:function(){return[]},getKeyBindings:function(e){for(var t=[],n=this._keyBindings,i=0;i<n.length;i++)n[i].actionID===e&&t.push(n[i].keyBinding);return t},getView:function(){return this._view},isActive:function(){return-1!==this._view.getKeyModes().indexOf(this)},match:function(e){if("keydown"===e.type)switch(e.keyCode){case 16:case 17:case 18:case 91:return void 0}for(var t=this._keyBindingIndex,n=this._matchingKeyBindings||this._keyBindings,i=[],r=0;r<n.length;r++){var o=n[r],s=o.keyBinding,a=s.match(e,t);if(a===!0)return this._keyBindingIndex=0,this._matchingKeyBindings=null,o.actionID;"number"==typeof a&&i.push(o)}return 0!==i.length?(this._keyBindingIndex++,this._matchingKeyBindings=i,"noop"):(this._keyBindingIndex=0,void(this._matchingKeyBindings=null))},setKeyBinding:function(e,t){for(var n=this._keyBindings,i=0;i<n.length;i++){var r=n[i];if(r.keyBinding.equals(e))return void(t?r.actionID=t:r.predefined?r.actionID="noop":n.splice(i,1))}t&&n.push({keyBinding:e,actionID:t})},setView:function(e){this._view=e}},i.prototype=new n,i.prototype.createKeyBindings=function(){var n=e.KeyBinding,i=[];if(i.push({actionID:"lineUp",keyBinding:new n(38),predefined:!0}),i.push({actionID:"lineDown",keyBinding:new n(40),predefined:!0}),i.push({actionID:"charPrevious",keyBinding:new n(37),predefined:!0}),i.push({actionID:"charNext",keyBinding:new n(39),predefined:!0}),t.isMac?(i.push({actionID:"scrollPageUp",keyBinding:new n(33),predefined:!0}),i.push({actionID:"scrollPageDown",keyBinding:new n(34),predefined:!0}),i.push({actionID:"pageUp",keyBinding:new n(33,null,null,!0),predefined:!0}),i.push({actionID:"pageDown",keyBinding:new n(34,null,null,!0),predefined:!0}),i.push({actionID:"lineStart",keyBinding:new n(37,!0),predefined:!0}),i.push({actionID:"lineEnd",keyBinding:new n(39,!0),predefined:!0}),i.push({actionID:"wordPrevious",keyBinding:new n(37,null,null,!0),predefined:!0}),i.push({actionID:"wordNext",keyBinding:new n(39,null,null,!0),predefined:!0}),i.push({actionID:"scrollTextStart",keyBinding:new n(36),predefined:!0}),i.push({actionID:"scrollTextEnd",keyBinding:new n(35),predefined:!0}),i.push({actionID:"textStart",keyBinding:new n(38,!0),predefined:!0}),i.push({actionID:"textEnd",keyBinding:new n(40,!0),predefined:!0}),i.push({actionID:"scrollPageUp",keyBinding:new n(38,null,null,null,!0),predefined:!0}),i.push({actionID:"scrollPageDown",keyBinding:new n(40,null,null,null,!0),predefined:!0}),i.push({actionID:"lineStart",keyBinding:new n(37,null,null,null,!0),predefined:!0}),i.push({actionID:"lineEnd",keyBinding:new n(39,null,null,null,!0),predefined:!0}),i.push({actionID:"lineStart",keyBinding:new n(38,null,null,!0),predefined:!0}),i.push({actionID:"lineEnd",keyBinding:new n(40,null,null,!0),predefined:!0})):(i.push({actionID:"pageUp",keyBinding:new n(33),predefined:!0}),i.push({actionID:"pageDown",keyBinding:new n(34),predefined:!0}),i.push({actionID:"lineStart",keyBinding:new n(36),predefined:!0}),i.push({actionID:"lineEnd",keyBinding:new n(35),predefined:!0}),i.push({actionID:"wordPrevious",keyBinding:new n(37,!0),predefined:!0}),i.push({actionID:"wordNext",keyBinding:new n(39,!0),predefined:!0}),i.push({actionID:"textStart",keyBinding:new n(36,!0),predefined:!0}),i.push({actionID:"textEnd",keyBinding:new n(35,!0),predefined:!0})),t.isFirefox&&t.isLinux&&(i.push({actionID:"lineUp",keyBinding:new n(38,!0),predefined:!0}),i.push({actionID:"lineDown",keyBinding:new n(40,!0),predefined:!0})),t.isWindows&&(i.push({actionID:"scrollLineUp",keyBinding:new n(38,!0),predefined:!0}),i.push({actionID:"scrollLineDown",keyBinding:new n(40,!0),predefined:!0})),i.push({actionID:"selectLineUp",keyBinding:new n(38,null,!0),predefined:!0}),i.push({actionID:"selectLineDown",keyBinding:new n(40,null,!0),predefined:!0}),i.push({actionID:"selectCharPrevious",keyBinding:new n(37,null,!0),predefined:!0}),i.push({actionID:"selectCharNext",keyBinding:new n(39,null,!0),predefined:!0}),i.push({actionID:"selectPageUp",keyBinding:new n(33,null,!0),predefined:!0}),i.push({actionID:"selectPageDown",keyBinding:new n(34,null,!0),predefined:!0}),t.isMac?(i.push({actionID:"selectLineStart",keyBinding:new n(37,!0,!0),predefined:!0}),i.push({actionID:"selectLineEnd",keyBinding:new n(39,!0,!0),predefined:!0}),i.push({actionID:"selectWordPrevious",keyBinding:new n(37,null,!0,!0),predefined:!0}),i.push({actionID:"selectWordNext",keyBinding:new n(39,null,!0,!0),predefined:!0}),i.push({actionID:"selectTextStart",keyBinding:new n(36,null,!0),predefined:!0}),i.push({actionID:"selectTextEnd",keyBinding:new n(35,null,!0),predefined:!0}),i.push({actionID:"selectTextStart",keyBinding:new n(38,!0,!0),predefined:!0}),i.push({actionID:"selectTextEnd",keyBinding:new n(40,!0,!0),predefined:!0}),i.push({actionID:"selectLineStart",keyBinding:new n(37,null,!0,null,!0),predefined:!0}),i.push({actionID:"selectLineEnd",keyBinding:new n(39,null,!0,null,!0),predefined:!0}),i.push({actionID:"selectLineStart",keyBinding:new n(38,null,!0,!0),predefined:!0}),i.push({actionID:"selectLineEnd",keyBinding:new n(40,null,!0,!0),predefined:!0})):(t.isLinux&&(i.push({actionID:"selectWholeLineUp",keyBinding:new n(38,!0,!0),predefined:!0}),i.push({actionID:"selectWholeLineDown",keyBinding:new n(40,!0,!0),predefined:!0})),i.push({actionID:"selectLineStart",keyBinding:new n(36,null,!0),predefined:!0}),i.push({actionID:"selectLineEnd",keyBinding:new n(35,null,!0),predefined:!0}),i.push({actionID:"selectWordPrevious",keyBinding:new n(37,!0,!0),predefined:!0}),i.push({actionID:"selectWordNext",keyBinding:new n(39,!0,!0),predefined:!0}),i.push({actionID:"selectTextStart",keyBinding:new n(36,!0,!0),predefined:!0}),i.push({actionID:"selectTextEnd",keyBinding:new n(35,!0,!0),predefined:!0})),i.push({actionID:"undo",keyBinding:new e.KeyBinding("z",!0),predefined:!0}),i.push(t.isMac?{actionID:"redo",keyBinding:new e.KeyBinding("z",!0,!0),predefined:!0}:{actionID:"redo",keyBinding:new e.KeyBinding("y",!0),predefined:!0}),i.push({actionID:"deletePrevious",keyBinding:new n(8),predefined:!0}),i.push({actionID:"deletePrevious",keyBinding:new n(8,null,!0),predefined:!0}),i.push({actionID:"deleteNext",keyBinding:new n(46),predefined:!0}),i.push({actionID:"deleteWordPrevious",keyBinding:new n(8,!0),predefined:!0}),i.push({actionID:"deleteWordPrevious",keyBinding:new n(8,!0,!0),predefined:!0}),i.push({actionID:"deleteWordNext",keyBinding:new n(46,!0),predefined:!0}),i.push({actionID:"tab",keyBinding:new n(9),predefined:!0}),i.push({actionID:"shiftTab",keyBinding:new n(9,null,!0),predefined:!0}),i.push({actionID:"enter",keyBinding:new n(13),predefined:!0}),i.push({actionID:"enter",keyBinding:new n(13,null,!0),predefined:!0}),i.push({actionID:"escape",keyBinding:new n(27),predefined:!0}),i.push({actionID:"selectAll",keyBinding:new n("a",!0),predefined:!0}),i.push({actionID:"toggleTabMode",keyBinding:new n("m",!0),predefined:!0}),t.isMac&&(i.push({actionID:"deleteNext",keyBinding:new n(46,null,!0),predefined:!0}),i.push({actionID:"deleteWordPrevious",keyBinding:new n(8,null,null,!0),predefined:!0}),i.push({actionID:"deleteWordNext",keyBinding:new n(46,null,null,!0),predefined:!0})),i.push({actionID:"toggleWrapMode",keyBinding:new e.KeyBinding("w",!0,!1,!0)}),i.push({actionID:"toggleOverwriteMode",keyBinding:new e.KeyBinding(45)}),!t.isFirefox){var r=t.isMac&&t.isChrome;i.push({actionID:"noop",keyBinding:new n("u",!r,!1,!1,r),predefined:!0}),i.push({actionID:"noop",keyBinding:new n("i",!r,!1,!1,r),predefined:!0}),i.push({actionID:"noop",keyBinding:new n("b",!r,!1,!1,r),predefined:!0})}return t.isFirefox&&(i.push({actionID:"copy",keyBinding:new n(45,!0),predefined:!0}),i.push({actionID:"paste",keyBinding:new n(45,null,!0),predefined:!0}),i.push({actionID:"cut",keyBinding:new n(46,null,!0),predefined:!0})),t.isMac&&(i.push({actionID:"lineStart",keyBinding:new n("a",!1,!1,!1,!0),predefined:!0}),i.push({actionID:"lineEnd",keyBinding:new n("e",!1,!1,!1,!0),predefined:!0}),i.push({actionID:"lineUp",keyBinding:new n("p",!1,!1,!1,!0),predefined:!0}),i.push({actionID:"lineDown",keyBinding:new n("n",!1,!1,!1,!0),predefined:!0}),i.push({actionID:"charPrevious",keyBinding:new n("b",!1,!1,!1,!0),predefined:!0}),i.push({actionID:"charNext",keyBinding:new n("f",!1,!1,!1,!0),predefined:!0}),i.push({actionID:"deletePrevious",keyBinding:new n("h",!1,!1,!1,!0),predefined:!0}),i.push({actionID:"deleteNext",keyBinding:new n("d",!1,!1,!1,!0),predefined:!0}),i.push({actionID:"deleteLineEnd",keyBinding:new n("k",!1,!1,!1,!0),predefined:!0}),t.isFirefox?(i.push({actionID:"scrollPageDown",keyBinding:new n("v",!1,!1,!1,!0),predefined:!0}),i.push({actionID:"deleteLineStart",keyBinding:new n("u",!1,!1,!1,!0),predefined:!0}),i.push({actionID:"deleteWordPrevious",keyBinding:new n("w",!1,!1,!1,!0),predefined:!0})):(i.push({actionID:"pageDown",keyBinding:new n("v",!1,!1,!1,!0),predefined:!0}),i.push({actionID:"centerLine",keyBinding:new n("l",!1,!1,!1,!0),predefined:!0}),i.push({actionID:"enterNoCursor",keyBinding:new n("o",!1,!1,!1,!0),predefined:!0}))),i},{KeyMode:n,DefaultKeyMode:i}}),n("orion/editor/textTheme",["require","orion/editor/eventTarget","orion/util"],function(e,t,n){function i(e){e=e||{},this._document=e.document||document}var r="orion-theme-",o={};return i.getTheme=function(e){e=e||"default";var t=o[e];return t||(t=o[e]=new i),t},i.prototype={getThemeClass:function(){return this._themeClass},setThemeClass:function(e,t){var n=this,i=n._themeClass;n._themeClass=e,this._load(e,t,function(){n.onThemeChanged({type:"ThemeChanged",oldValue:i,newValue:n.getThemeClass()})})},onThemeChanged:function(e){return this.dispatchEvent(e)},buildStyleSheet:function(e,t){var n=function(e){return e.replace(this._capitalRegEx,function(e){return"-"+e}.bind(this)).toLowerCase()}.bind(this),i=function(e,t,r,o,s){var a=[],l=Object.keys(e);l.forEach(function(l){if("isTopLevel"!==l){var d=e[l];"string"==typeof d?a.push(" "+n(l)+": "+d+";"):d.isTopLevel?i(d,r===l?t:t+(o?" .":".")+l,r,!0,s):i(d,r===l?t:t+(o?" .":".")+l,r,!1,s)}}),a.length&&(s.push(t+(o?".textview":"")+" {"),s.push.apply(s,a),s.push("}"))},r=[""];return i(t.styles,"."+e,t.className,!0,r),r.join("\n")},_createStyle:function(e,t,i,o){var s=this._document,a=r+e,l=s.getElementById(a);if(l){if(o||l.firstChild.data===t)return;l.removeChild(l.firstChild),l.appendChild(s.createTextNode(t))}else{o?(l=n.createElement(s,"link"),l.rel="stylesheet",l.type="text/css",l.href=t,l.addEventListener("load",function(){i()})):(l=n.createElement(s,"style"),l.appendChild(s.createTextNode(t))),l.id=a;var d=s.getElementsByTagName("head")[0]||s.documentElement;d.appendChild(l)}o||i()},_load:function(t,n,i){if(!t)return void i();if("string"==typeof n)return void this._createStyle(t,n,i);var r=n.href,o=".css";if(r.substring(r.length-o.length)!==o&&(r+=o),/^\//.test(r)||/[a-zA-Z0-9]+:\/\//i.test(r)||!e.toUrl)this._createStyle(t,r,i,!0);else{var s=this;e(["text!"+r],function(e){s._createStyle(t,e,i,!1)})}},_capitalRegEx:/[A-Z]/g},t.EventTarget.addMixin(i.prototype),{TextTheme:i}}),n("orion/editor/util",[],function(){function e(e,t,n,i){"function"==typeof e.addEventListener?e.addEventListener(t,n,i===!0):e.attachEvent("on"+t,n)}function t(e,t,n,i){"function"==typeof e.removeEventListener?e.removeEventListener(t,n,i===!0):e.detachEvent("on"+t,n)}function n(e,t){if(e===t)return!0;if(e&&!t||!e&&t)return!1;if(e&&e.constructor===String||t&&t.constructor===String)return!1;if(e instanceof Array||t instanceof Array){if(!(e instanceof Array&&t instanceof Array))return!1;if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}if(!(e instanceof Object&&t instanceof Object))return!1;var r;for(r in e)if(e.hasOwnProperty(r)){if(!t.hasOwnProperty(r))return!1;if(!n(e[r],t[r]))return!1}for(r in t)if(!e.hasOwnProperty(r))return!1;return!0}function i(e,t){if(!t)return!1;if(!e.compareDocumentPosition){for(var n=t;n;){if(e===n)return!0;n=n.parentNode}return!1}return e===t||0!==(16&e.compareDocumentPosition(t))}function r(e,t,n){var i;if(e&&(i=e.style[t],!i))if(e.currentStyle){for(var r=0,o=t;-1!==(r=o.indexOf("-",r));)o=o.substring(0,r)+o.substring(r+1,r+2).toUpperCase()+o.substring(r+2);i=e.currentStyle[o]}else{var s=e.ownerDocument.defaultView.getComputedStyle(e,null);i=s?s.getPropertyValue(t):null}return i||n}var o=function(){function e(e){this.options=e}return e.prototype.play=function(){function e(){d=-1===d?Date.now():d;var e=Date.now(),i=(e-d)/n;if(1>i){var h=r(i);t=s+h*l,o(t)}else o(a),c.stop()}var t,n="number"==typeof this.options.duration?this.options.duration:350,i="number"==typeof this.options.rate?this.options.rate:20,r=this.options.easing||this.defaultEasing,o=this.options.onAnimate||function(){},s=this.options.curve[0],a=this.options.curve[1],l=a-s,d=-1,c=this;this.interval=this.options.window.setInterval(e,i)},e.prototype.stop=function(){this.options.window.clearInterval(this.interval);var e=this.options.onEnd||function(){};e()},e.prototype.defaultEasing=function(e){return Math.sin(e*(Math.PI/2))},e}();return{compare:n,contains:i,getNodeStyle:r,addEventListener:e,removeEventListener:t,Animation:o}}),n("orion/editor/textView",["i18n!orion/editor/nls/messages","orion/editor/textModel","orion/editor/keyModes","orion/editor/eventTarget","orion/editor/textTheme","orion/editor/util","orion/util","orion/bidiUtils","orion/metrics"],function(e,t,n,i,r,o,s,a,l){function d(e){return e.defaultView||e.parentWindow}function c(e){return new Array(e)}function h(e,t,n){if(n){t.className="";for(var i=t.attributes,r=i.length;r-->0;)(!s.isIE||s.isIE>=9||s.isIE<9&&i[r].specified)&&t.removeAttribute(i[r].name)}if(e){e.styleClass&&(t.className=e.styleClass);var o=e.style;if(o)for(var a in o)o.hasOwnProperty(a)&&(t.style[a]=o[a]);var l=e.attributes;if(l)for(var d in l)l.hasOwnProperty(d)&&t.setAttribute(d,l[d])}}function u(e){return e instanceof Array?e.slice(0):e}function f(e,t){if(!e)return t;if(!t)return e;for(var n in t)t.hasOwnProperty(n)&&(e.hasOwnProperty(n)||(e[n]=t[n]));return e}function p(e,t,n){for(var i=0,r=0,o=0,s=e.length;s>o;){-1!==i&&o>=i&&(i=e.indexOf("\r",o)),-1!==r&&o>=r&&(r=e.indexOf("\n",o));var a,l=o;if(-1===r&&-1===i){t(e.substring(o));break}-1!==i&&-1!==r?i+1===r?(a=i,o=r+1):(a=r>i?i:r,o=(r>i?i:r)+1):-1!==i?(a=i,o=i+1):(a=r,o=r+1),t(e.substring(l,a)),n?n():o===s&&t("")}}function g(e){var t,n,i,r,o=d(e.ownerDocument);if(o.getComputedStyle){var s=o.getComputedStyle(e,null);t=s.getPropertyValue("border-left-width"),n=s.getPropertyValue("border-top-width"),i=s.getPropertyValue("border-right-width"),r=s.getPropertyValue("border-bottom-width")}else e.currentStyle&&(t=e.currentStyle.borderLeftWidth,n=e.currentStyle.borderTopWidth,i=e.currentStyle.borderRightWidth,r=e.currentStyle.borderBottomWidth);return{left:parseInt(t,10)||0,top:parseInt(n,10)||0,right:parseInt(i,10)||0,bottom:parseInt(r,10)||0}}function v(e){var t,n,i,r,o=d(e.ownerDocument);if(o.getComputedStyle){var s=o.getComputedStyle(e,null);t=s.getPropertyValue("padding-left"),n=s.getPropertyValue("padding-top"),i=s.getPropertyValue("padding-right"),r=s.getPropertyValue("padding-bottom")}else e.currentStyle&&(t=e.currentStyle.paddingLeft,n=e.currentStyle.paddingTop,i=e.currentStyle.paddingRight,r=e.currentStyle.paddingBottom);return{left:parseInt(t,10)||0,top:parseInt(n,10)||0,right:parseInt(i,10)||0,bottom:parseInt(r,10)||0}}function m(e){var t=e._trim;if(!t){t=v(e);var n=g(e);t.left+=n.left,t.top+=n.top,t.right+=n.right,t.bottom+=n.bottom,e._trim=t}return t}function _(e,t,n,i){function r(t){if(t.animationName===a){var n=t.target;"function"==typeof n.__DOMReady&&d(e).setTimeout(function(){n.__DOMReady()},0)}}function o(e,t){for(var n=["","-webkit-","-moz-","-ms-","-o-"],i="",r="body ."+e+" {\n",o=0;o<n.length;o++)i+="@"+n[o]+"keyframes "+t+" {\nfrom { opacity: 0.99; }\nto { opacity: 1; }\n}\n",r+=n[o]+"animation-duration: 0.001s;\n"+n[o]+"animation-name: "+t+";\n";return r+="}",i+r}n="_"+n+"DOMReady",t.className=t.className?t.className+" "+n:n,t.__DOMReady=i;var s=n+"Style";if(!e.getElementById(s)){var a=n+"Animation";S(e,"animationstart",r,!1),S(e,"MSAnimationStart",r,!1),S(e,"webkitAnimationStart",r,!1);var l=e.createElement("style");l.id=s;var c=e.getElementsByTagName("head")[0]||e.documentElement;l.appendChild(e.createTextNode(o(n,a))),c.insertBefore(l,c.firstChild)}}function y(e,t,n){this.start=e,this.end=t,this.caret=n,this._columnX=-1}function C(e){this._view=e,this._divs=[];for(var t=e._clipDiv||e._rootDiv,n=0;3>n;n++){var i=e._createSelectionDiv();t.appendChild(i),this._divs.push(i)}}function w(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom}function x(e,t,n){this.view=e,this.lineIndex=t,this._lineDiv=n}function b(e){this._init(e||{})}var S=o.addEventListener,T=o.removeEventListener,E=o.compare,A=o.Animation;return y.compare=function(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].equals(t[n]))return!1;return!0},y.editing=function(e,t){var n;if(t){for(n=e.length-1;n>=0;n--)if(e[n]._editing)return e[n];return e[e.length-1]}for(n=0;n<e.length;n++)if(e[n]._editing)return e[n];return e[0]},y.convert=function(e){return 1===e.length?e[0]:e},y.contains=function(e,t){return e.some(function(e){return e.contains(t)})},y.merge=function(e){if(e.length<=1)return e;e.sort(function(e,t){return e.start-t.start});for(var t=[],n=e[0],i=1;i<e.length;i++)e[i].start>=n.end||n._editing||e[i]._editing?(t.push(n),n=e[i]):n.end=Math.max(n.end,e[i].end);return t.push(n),t},y.prototype={clone:function(){var e=new y(this.start,this.end,this.caret);return e._columnX=this._columnX,e._editing=this._editing,e._docX=this._docX,e},contains:function(e){return this.start<=e&&e<this.end?!0:!1},collapse:function(){this.caret?this.end=this.start:this.start=this.end},extend:function(e){if(this.caret?this.start=e:this.end=e,this.start>this.end){var t=this.start;this.start=this.end,this.end=t,this.caret=!this.caret}},setCaret:function(e){this.start=e,this.end=e,this.caret=!1},getCaret:function(){return this.caret?this.start:this.end},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(e){return this.caret===e.caret&&this.start===e.start&&this.end===e.end&&this._editing===e._editing}},C.prototype={destroy:function(){this._divs&&(this._divs.forEach(function(e){e.parentNode.removeChild(e)}),this._divs=null)},setPrimary:function(e){this.primary=e},update:function(){var e,t=this._view,n=this.primary,i=t._hasFocus,r=t._cursorVisible,o=!this.primary&&this._selection&&this._selection.isEmpty();e=o?"textviewSelectionCaret":i?"textviewSelection":"textviewSelectionUnfocused",this._divs[0].style.visibility=o&&r&&i||!o?"visible":"hidden",this._divs[0].style.zIndex=r&&o?"2":"0",this._divs.forEach(function(t){t.className=e,s.isWebkit<537.36&&n&&(t.style.background=i?"transparent":"")})},setSelection:function(e){this._selection=e,this.update();var t=this._view,n=t._model,i=n.getLineAtOffset(e.start),r=n.getLineAtOffset(e.end),o=t._getLineNext();if(o){var s,a,l,d,c=t._getLinePrevious();i<o.lineIndex?(s=o,l=n.getLineStart(o.lineIndex)):i>c.lineIndex?(s=c,l=n.getLineStart(c.lineIndex)):(s=t._getLineNode(i),l=e.start),r<o.lineIndex?(a=o,d=n.getLineStart(o.lineIndex)):r>c.lineIndex?(a=c,d=n.getLineStart(c.lineIndex)):(a=t._getLineNode(r),d=e.end),this._setDOMSelection(s,l,a,d,e.caret)}},_setDOMSelection:function(e,t,n,i,r){if(this._setDOMFullSelection(e,t,n,i),this.primary){var o=this._view,a=e._line.getNodeOffset(t),l=n._line.getNodeOffset(i);if(a.node&&l.node){var d,c=o._getWindow(),h=o._parent.ownerDocument;if(c.getSelection){var u=c.getSelection();if(d=h.createRange(),d.setStart(a.node,a.offset),d.setEnd(l.node,l.offset),!o._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||(o._anchorNode=a.node,o._anchorOffset=a.offset,o._focusNode=l.node,o._focusOffset=l.offset,o._ignoreSelect=!1,u.rangeCount>0&&u.removeAllRanges(),u.addRange(d),o._ignoreSelect=!0),o._cursorDiv){d=h.createRange(),r?(d.setStart(a.node,a.offset),d.setEnd(a.node,a.offset)):(d.setStart(l.node,l.offset),d.setEnd(l.node,l.offset));var f=d.getClientRects()[0],p=o._cursorDiv.parentNode,g=p.getBoundingClientRect();f&&g&&(o._cursorDiv.style.top=f.top-g.top+p.scrollTop+"px",o._cursorDiv.style.left=f.left-g.left+p.scrollLeft+"px")}}else if(h.selection){if(!o._hasFocus)return;var v=h.body,m=s.createElement(h,"div");v.appendChild(m),v.removeChild(m),d=v.createTextRange(),d.moveToElementText(a.node.parentNode),d.moveStart("character",a.offset);var _=v.createTextRange();_.moveToElementText(l.node.parentNode),_.moveStart("character",l.offset),d.setEndPoint("EndToStart",_),o._ignoreSelect=!1,d.select(),o._ignoreSelect=!0}}}},_setDOMFullSelection:function(e,t,n,i){this._divs.forEach(function(e){e.style.width=e.style.height="0px"});var r=this._view;if(r._fullSelection&&!(s.isIOS||e===n&&t===i&&this.primary)){var o=r._getViewPadding(),a=r._clientDiv.getBoundingClientRect(),l=r._viewDiv.getBoundingClientRect(),d=l.left+o.left,c=a.right,h=l.top+o.top,u=a.bottom,f=0,p=0;if(r._clipDiv){var g=r._clipDiv.getBoundingClientRect();f=g.left-r._clipDiv.scrollLeft,p=g.top}else{var v=r._rootDiv.getBoundingClientRect();f=v.left,p=v.top}r._ignoreDOMSelection=!0;var m,_,y=new x(r,e.lineIndex,e),C=y.getBoundingClientRect(t,!1),w=C.left;e===n&&t===i?(m=y,_=C):(m=new x(r,n.lineIndex,n),_=m.getBoundingClientRect(i,!1));var b=_.left;r._ignoreDOMSelection=!1;var S=this._divs[0],T=Math.min(c,Math.max(d,w)),E=Math.min(u,Math.max(h,C.top)),A=c,L=Math.min(u,Math.max(h,C.bottom));if(S.style.left=T-f+"px",S.style.top=E-p+"px",S.style.width=Math.max(0,A-T)+"px",S.style.height=Math.max(0,L-E)+"px",e.lineIndex===n.lineIndex)A=Math.min(b,c),S.style.width=Math.max(this.primary?0:1,A-T)+"px";else{var k=d,M=Math.min(u,Math.max(h,_.top)),O=Math.min(c,Math.max(d,b)),D=Math.min(u,Math.max(h,_.bottom)),N=this._divs[2];if(N.style.left=k-f+"px",N.style.top=M-p+"px",N.style.width=Math.max(0,O-k)+"px",N.style.height=Math.max(0,D-M)+"px",Math.abs(e.lineIndex-n.lineIndex)>1){var I=this._divs[1];I.style.left=d-f+"px",I.style.top=L-p+"px",I.style.width=Math.max(0,c-d)+"px",I.style.height=Math.max(0,M-L)+"px"}}}}},w.prototype={toString:function(){return"{l="+this.left+", t="+this.top+", r="+this.right+", b="+this.bottom+"}"}},x.prototype={create:function(e,t,n){if(!this._lineDiv){this.drawing=n;var i=this._lineDiv=this._createLine(e,t,this.lineIndex);return i._line=this,i}},_createLine:function(e,t,n){var i=this.view,r=i._model,o=r.getLine(n),a=r.getLineStart(n),l={type:"LineStyle",textView:i,lineIndex:n,lineText:o,lineStart:a};i.onLineStyle(l);var d=e.ownerDocument,c=t||s.createElement(d,"div");if(t&&E(t.viewStyle,l.style)||(h(l.style,c,t),t&&(t._trim=null),c.viewStyle=l.style),c.lineIndex=n,t&&c.viewLineText===o&&E(l.ranges,c.viewRanges))return c;c.viewRanges=l.ranges,c.viewLineText=o;var u=[],f={tabOffset:0,ranges:u};this._createRanges(l.ranges,o,0,o.length,a,f);var p=" ";!i._fullSelection&&s.isIE<9&&(p="");var g={text:p,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,g):u.push(g);var v,m,_,y,C,w,x,b,S=0,T=0;if(s.isFirefox&&o.length>2e3){t&&(c.innerHTML="",t.lineWidth=void 0);var A=d.createDocumentFragment();for(b=0;b<u.length;b++)g=u[b],C=g.text,m=g.style,v=this._createSpan(c,C,m,g.ignoreChars),A.appendChild(v);c.appendChild(A)}else{var L,k;if(t){var M=t.modelChangedEvent;M&&(0===M.removedLineCount&&0===M.addedLineCount?(k=M.start-a,L=M.addedCharCount-M.removedCharCount):k=-1,t.modelChangedEvent=void 0),_=t.firstChild}for(b=0;b<u.length;b++){if(g=u[b],C=g.text,S+=C.length,m=g.style,_){if(w=_.firstChild?_.firstChild.data:" ",y=_.viewStyle,w===C&&E(m,y)){T+=w.length,_._rectsCache=void 0,v=_=_.nextSibling;continue}for(;_;){if(-1!==k){var O=S;O>=k&&(O-=L);var D=_.firstChild?_.firstChild.data:" ",N=D?D.length:0;if(T+N>O)break;T+=N}x=_.nextSibling,c.removeChild(_),_=x}}v=this._createSpan(c,C,m,g.ignoreChars),_?c.insertBefore(v,_):c.appendChild(v),t&&(t.lineWidth=void 0)}if(t)for(var I=v?v.nextSibling:null;I;)x=I.nextSibling,t.removeChild(I),I=x}return c.parentNode||e.appendChild(c),c},_createRanges:function(e,t,n,i,r,o){if(!(n>i)){if(e)for(var s=0;s<e.length;s++){var a=e[s];if(!(a.end<r+n)){var l=Math.max(r+n,a.start)-r;if(l>i)break;var d=Math.min(r+i,a.end)-r;if(d>=l){if(l=Math.max(n,l),d=Math.min(i,d),l>n&&this._createRange(t,n,l,null,o),!a.style||!a.style.unmergeable)for(;s+1<e.length&&e[s+1].start-r===d&&E(a.style,e[s+1].style);)a=e[s+1],d=Math.min(r+i,a.end)-r,s++;this._createRange(t,l,d,a.style,o),n=d}}}i>n&&this._createRange(t,n,i,null,o)}},_createRange:function(e,t,n,i,r){if(!(t>n)){var o,s=this.view._customTabSize,l={tagName:"span",bidi:!0,style:{unicodeBidi:"embed",direction:"ltr"}},d={text:"‎",style:l};if(s&&8!==s)for(var c=e.indexOf(" ",t);-1!==c&&n>c;){c>t&&(o={text:e.substring(t,c),style:i},o=a.enforceTextDir(o),r.ranges.push(o),a.isBidiEnabled()&&r.ranges.push(d),r.tabOffset+=o.text.length);var h=s-r.tabOffset%s;if(h>0){for(var u=" ",f=1;h>f;f++)u+=" ";o={text:u,style:i,ignoreChars:h-1},r.ranges.push(o),a.isBidiEnabled()&&r.ranges.push(d),r.tabOffset+=o.text.length}if(t=c+1,t===n)return;c=e.indexOf(" ",t)}n>=t&&(o={text:e.substring(t,n),style:i},o=a.enforceTextDir(o),r.ranges.push(o),a.isBidiEnabled()&&r.ranges.push(d),r.tabOffset+=o.text.length)}},_createSpan:function(e,t,n,i){var r=this.view,o="span";n&&n.tagName&&(o=n.tagName.toLowerCase());var a="a"===o;a&&(this.hasLink=!0),a&&!r._linksVisible&&(o="span");var l=e.ownerDocument,d=s.createElement(e.ownerDocument,o); if(d.appendChild(l.createTextNode(n&&n.text?n.text:t)),n&&n.html?(d.innerHTML=n.html,d.ignore=!0):n&&n.node?(d.appendChild(this.drawing?n.node:n.node.cloneNode(!0)),d.ignore=!0):n&&n.bidi&&(d.ignore=!0),h(n,d),"a"===o){var c=r._getWindow();S(d,"click",function(e){return r._handleLinkClick(e?e:c.event)},!1)}return d.viewStyle=n,i&&(d.ignoreChars=i),d},_ensureCreated:function(){return this._lineDiv?this._lineDiv:this._createdDiv=this.create(this.view._clientDiv,null)},getBoundingClientRect:function(e,t){var n=this._ensureCreated(),i=this.view;if(void 0===e)return this._getLineBoundingClientRect(n,!0);var r=i._model,o=n.ownerDocument,a=this.lineIndex,l=null;if(e<r.getLineEnd(a)){var c=r.getLineStart(a);this.forEach(function(t){var r=t.firstChild,a=this._nodeLength(t);if(c+a>e){var h,u=e-c;if(1===r.length)l=new w(t.getBoundingClientRect());else if(i._isRangeRects)h=o.createRange(),h.setStart(r,u),h.setEnd(r,u+1),l=new w(h.getBoundingClientRect());else if(s.isIE){h=o.body.createTextRange(),h.moveToElementText(t),h.collapse();var f=0===u&&8===s.isIE;f&&(u=1),h.moveEnd("character",u+1),h.moveStart("character",u),l=new w(h.getBoundingClientRect()),f&&(l.left=t.getClientRects()[0].left)}else{var p=r.data;t.removeChild(r),t.appendChild(o.createTextNode(p.substring(0,u)));var g=s.createElement(o,"span");if(g.appendChild(o.createTextNode(p.substring(u,u+1))),t.appendChild(g),t.appendChild(o.createTextNode(p.substring(u+1))),l=new w(g.getBoundingClientRect()),t.innerHTML="",t.appendChild(r),!this._createdDiv){var v=i._getSelections()[0];(c<=v.start&&v.start<c+a||c<=v.end&&v.end<c+a)&&i._updateDOMSelection()}}if(s.isIE<11){var m=d(n.ownerDocument),_=m.screen.logicalXDPI/m.screen.deviceXDPI,y=m.screen.logicalYDPI/m.screen.deviceYDPI;l.left=l.left*_,l.right=l.right*_,l.top=l.top*y,l.bottom=l.bottom*y}return!1}return c+=a,!0})}var h=this.getBoundingClientRect();if(!l)if(i._wrapMode){var u=this.getClientRects();l=u[u.length-1],l.left=l.right,l.left+=h.left,l.top+=h.top,l.right+=h.left,l.bottom+=h.top}else l=new w(h),l.left=l.right;return(t||void 0===t)&&(l.left-=h.left,l.top-=h.top,l.right-=h.left,l.bottom-=h.top),l},forEach:function(e){for(var t=this._ensureCreated(),n=t.firstChild;n;){var i=n.nextSibling;if(!n.ignore&&!e.call(this,n))break;n=i}},_getClientRects:function(e,t){var n,i,r,o;if(!e._rectsCache){for(n=e.getClientRects(),i=c(n.length),o=0;o<n.length;o++)r=i[o]=new w(n[o]),r.left-=t.left,r.top-=t.top,r.right-=t.left,r.bottom-=t.top;e._rectsCache=i}for(n=e._rectsCache,i=[n.length],o=0;o<n.length;o++)i[o]=new w(n[o]);return i},getClientRects:function(e){if(!this.view._wrapMode)return[this.getBoundingClientRect()];var t=this._ensureCreated(),n=[],i=t.getBoundingClientRect();return this.forEach(function(e){for(var t=this._getClientRects(e,i),r=0;r<t.length;r++){var o,s,a=t[r];if(a.top!==a.bottom){var l=a.top+(a.bottom-a.top)/2;for(o=0;o<n.length&&(s=n[o],!(s.top<=l&&l<s.bottom));o++);o===n.length?n.push(a):(a.left<s.left&&(s.left=a.left),a.top<s.top&&(s.top=a.top),a.right>s.right&&(s.right=a.right),a.bottom>s.bottom&&(s.bottom=a.bottom))}}return!0}),void 0!==e?n[e]:n},_getLineBoundingClientRect:function(e,t){var n=new w(e.getBoundingClientRect());if(this.view._wrapMode);else{n.right=n.left;for(var i=e.lastChild;i&&i.ignoreChars===i.firstChild.length;)i=i.previousSibling;if(i){var r=i.getBoundingClientRect();n.right=r.right+m(e).right}}if(t){var o=m(e);n.left=n.left+o.left,n.right=n.right-o.right}return n},getLineCount:function(){return this.view._wrapMode?this.getClientRects().length:1},getLineIndex:function(e){if(!this.view._wrapMode)return 0;for(var t=this.getClientRects(),n=this.getBoundingClientRect(e),i=n.top+(n.bottom-n.top)/2,r=0;r<t.length;r++)if(t[r].top<=i&&i<t[r].bottom)return r;return t.length-1},getLineStart:function(e){if(!this.view._wrapMode||0===e)return this.view._model.getLineStart(this.lineIndex);var t=this.getClientRects();return this.getOffset(t[e].left+1,t[e].top+1)},_nodeLength:function(e){if(!e||e.ignore)return 0;var t=e.firstChild.length;return e.ignoreChars&&(t-=e.ignoreChars),t},getModelOffset:function(e,t){if(!e)return 0;var n=0;return this.forEach(function(i){var r=i.firstChild;return r===e?(i.ignoreChars&&(n-=i.ignoreChars),n+=t,!1):(i.ignoreChars&&(n-=i.ignoreChars),n+=r.data.length,!0)}),Math.max(0,n)+this.view._model.getLineStart(this.lineIndex)},getNodeOffset:function(e){var t,n,i=0,r=this.view._model,o=r.getLineStart(this.lineIndex),s=e-o,a=r.getLineEnd(this.lineIndex)-o;return this.forEach(function(e){var r=e.firstChild,o=this._nodeLength(e);return o+i>s||i+o>=a?(t=r,n=s-i,e.ignoreChars&&o>0&&n===o&&(n+=e.ignoreChars),!1):(i+=o,!0)}),{node:t,offset:n}},getText:function(e){var t="",n=0;return this.forEach(function(i){var r;if(i.ignoreChars){r=i.lastChild;for(var o=0,s=[],a=-1;r;){var l=r.data;if(l)for(var d=l.length-1;d>=0;d--){var c=l.substring(d,d+1);o<i.ignoreChars&&(" "===c||""===c)?o++:s.push(" "===c?" ":c)}e===r&&(a=s.length),r=r.previousSibling}s=s.reverse().join(""),-1!==a&&(n=t.length+s.length-a),t+=s}else for(r=i.firstChild;r;)e===r&&(n=t.length),t+=r.data,r=r.nextSibling;return!0}),{text:t,offset:n}},getOffset:function(e,t){function n(n,i,c){var h,u,v,m,_,y,C,w,x,b=n.firstChild,S=g._nodeLength(n),T=f.ownerDocument,E=d(T),A=s.isIE<11?E.screen.logicalXDPI/E.screen.deviceXDPI:1,L=s.isIE<11?E.screen.logicalYDPI/E.screen.deviceYDPI:1,k=c.left+p.left;if(s.isIE||r._isRangeRects){_=r._isRangeRects?T.createRange():T.body.createTextRange();for(var M=S,O=-1;M-O>1;){var D=Math.floor((M+O)/2);y=O+1,C=D===S-1&&n.ignoreChars?b.length:D+1,w=0===y&&8===s.isIE,r._isRangeRects?(_.setStart(b,y),_.setEnd(b,C)):(w&&(y=1),_.moveToElementText(n),_.move("character",y),_.moveEnd("character",C-y)),x=_.getClientRects();for(var N=!1,I=0;I<x.length;I++)if(c=x[I],h=(w?k:c.left)*A-p.left,v=c.right*A-p.left,u=c.top*L-p.top,m=c.bottom*L-p.top,e>=h&&v>e&&(!r._wrapMode||t>=u&&m>=t)){N=!0;break}N?M=D:O=D}i+=M,y=M,C=M===S-1&&n.ignoreChars?b.length:Math.min(M+1,b.length),r._isRangeRects?(_.setStart(b,y),_.setEnd(b,C)):(_.moveToElementText(n),_.move("character",y),_.moveEnd("character",C-y)),x=_.getClientRects();var R=!1;x.length>0&&(c=x[0],h=(w?k:c.left)*A-p.left,v=c.right*A-p.left,R=e>h+(v-h)/2);var B=i-l,P=o.getLine(a),F=P.charCodeAt(B);F>=55296&&56319>=F&&R?B<P.length&&(F=P.charCodeAt(B+1),F>=56320&&57343>=F&&(i+=1)):F>=56320&&57343>=F&&!R&&B>0&&(F=P.charCodeAt(B-1),F>=55296&&56319>=F&&(i-=1)),R&&i++}else{for(var V=[],U=0;S>U;U++)V.push("<span>"),V.push(U===S-1?b.data.substring(U):b.data.substring(U,U+1)),V.push("</span>");n.innerHTML=V.join("");for(var K=n.firstChild;K;){if(c=K.getBoundingClientRect(),h=c.left-p.left,v=c.right-p.left,e>=h&&v>e){e>h+(v-h)/2&&i++;break}i++,K=K.nextSibling}if(!g._createdDiv){n.innerHTML="",n.appendChild(b);var W=r._getSelections()[0];(i<=W.start&&W.start<i+S||i<=W.end&&W.end<i+S)&&r._updateDOMSelection()}}return i}function i(n){if(n.ignore)return null;for(var i=g._getClientRects(n,p),o=0;o<i.length;o++){var s=i[o];if(s.left<=e&&e<s.right&&(!r._wrapMode||s.top<=t&&t<=s.bottom))return s}return null}var r=this.view,o=r._model,a=this.lineIndex,l=o.getLineStart(a),c=o.getLineEnd(a);if(l===c)return l;var h,u,f=this._ensureCreated(),p=this.getBoundingClientRect(),g=this;if(r._wrapMode){h=this.getClientRects(),t<h[0].top&&(t=h[0].top);for(var v=0;v<h.length&&(u=h[v],!(u.top<=t&&t<u.bottom));v++);e<u.left&&(e=u.left),e>u.right&&(e=u.right-1)}else 0>e&&(e=0),e>p.right-p.left&&(e=p.right-p.left);var m,_;if(this._lastHitChild&&this._lastHitChild.parentNode){if(m=this._lastHitOffset,_=this._lastHitChild,u=i(_),!u)for(var y=m,C=m+this._nodeLength(_),w=_.previousSibling,x=_.nextSibling;w||x;){if(w){if(y-=this._nodeLength(w),u=i(w)){_=w,m=y;break}w=w.previousSibling}if(x){if(u=i(x)){_=x,m=C;break}C+=this._nodeLength(x),x=x.nextSibling}}}else m=l,this.forEach(function(e){return _=e,(u=i(_))?!1:(m+=this._nodeLength(_),!0)});return _&&u&&(this._lastHitChild=_,this._lastHitOffset=m,m=n(_,m,u)),Math.min(c,Math.max(l,m))},getNextOffset:function(e,t){if("line"===t.unit){var n=this.view,i=n._model,r=i.getLineAtOffset(e);return t.count>0?(t.count--,i.getLineEnd(r)):(t.count++,i.getLineStart(r))}return"wordend"===t.unit||"wordWS"===t.unit||"wordendWS"===t.unit?this._getNextOffset_W3C(e,t):s.isIE?this._getNextOffset_IE(e,t):this._getNextOffset_W3C(e,t)},_getNextOffset_W3C:function(e,t){function n(e){return e>=33&&47>=e||e>=58&&64>=e||e>=91&&94>=e||96===e||e>=123&&126>=e}function i(e){return 32===e||9===e}var r,o=this.view,s=o._model,a=s.getLineAtOffset(e),l=s.getLine(a),d=s.getLineStart(a),c=s.getLineEnd(a),h=l.length,u=e-d,f=t.count<0?-1:1;if("word"===t.unit||"wordend"===t.unit||"wordWS"===t.unit||"wordendWS"===t.unit)for(var p,g,v,m;0!==t.count;){if(t.count>0){if(u===h)return c;for(r=l.charCodeAt(u),p=n(r),g=!p&&!i(r),u++;h>u;){if(r=l.charCodeAt(u),"wordWS"!==t.unit&&"wordendWS"!==t.unit){if(v=n(r),"wordend"===t.unit){if(!v&&p)break}else if(v&&!p)break;m=!v&&!i(r)}else m=!i(r);if("wordend"===t.unit||"wordendWS"===t.unit){if(!m&&g)break}else if(m&&!g)break;g=m,p=v,u++}}else{if(0===u)return d;for(u--,r=l.charCodeAt(u),p=n(r),g=!p&&!i(r);u>0;){if(r=l.charCodeAt(u-1),"wordWS"!==t.unit&&"wordendWS"!==t.unit){if(v=n(r),"wordend"===t.unit){if(v&&!p)break}else if(!v&&p)break;m=!v&&!i(r)}else m=!i(r);if("wordend"===t.unit||"wordendWS"===t.unit){if(m&&!g)break}else if(!m&&g)break;g=m,p=v,u--}}t.count-=f}else for(;0!==t.count&&u+f>=0&&h>=u+f;){if(u+=f,r=l.charCodeAt(u),u>0)if(r>=57339&&57343>=r){if(r=l.charCodeAt(u-1),55356===r){u+=f;continue}}else{if(r>=65024&&65039>=r)continue;r>=56320&&57343>=r&&(r=l.charCodeAt(u-1),r>=55296&&56319>=r&&(u+=f))}t.count-=f}return d+u},_getNextOffset_IE:function(e,t){var n,i,r,o=this._ensureCreated(),s=this.view,a=s._model,l=this.lineIndex,d=0,c=a.getLineStart(l),h=a.getLine(l),u=a.getLineStart(l),f=o.ownerDocument,p=t.count<0?-1:1;if(e===a.getLineEnd(l)){for(r=o.lastChild;r&&r.ignoreChars===r.firstChild.length;)r=r.previousSibling;if(!r)return c;n=f.body.createTextRange(),n.moveToElementText(r),i=n.text.length,n.moveEnd(t.unit,p),d=e+n.text.length-i}else if(e===c&&t.count<0)d=c;else for(r=o.firstChild;r;){var g=this._nodeLength(r);if(c+g>e){if(n=f.body.createTextRange(),e===c&&t.count<0){for(var v=r.previousSibling;v&&(!v.firstChild||!v.firstChild.length);)v=v.previousSibling;n.moveToElementText(v?v:r.previousSibling)}else n.moveToElementText(r),n.collapse(),n.moveEnd("character",e-c);i=n.text.length,n.moveEnd(t.unit,p),d=e+n.text.length-i;break}c=g+c,r=r.nextSibling}var m=d-u,_=h.charCodeAt(m);return _>=56320&&57343>=_&&m>0&&(_=h.charCodeAt(m-1),_>=55296&&56319>=_&&(m+=p)),d=m+u,t.count-=p,d},updateLinks:function(){var e=this._ensureCreated();if(this.hasLink){var t=this;this.forEach(function(n){var i=n.viewStyle;return i&&i.tagName&&"a"===i.tagName.toLowerCase()&&e.replaceChild(t._createSpan(e,n.firstChild.data,i),n),!0})}},destroy:function(){var e=this._createdDiv;e&&(e.parentNode.removeChild(e),this._createdDiv=null)}},b.prototype={addKeyMode:function(e,t){var n=this._keyModes;void 0!==t?n.splice(t,0,e):n.push(e),e._modeAdded&&e._modeAdded()},addRuler:function(e,t){var n=this._rulers;if(void 0!==t){var i,r;for(i=0,r=0;i<n.length&&t>r;i++)e.getLocation()===n[i].getLocation()&&r++;n.splice(r,0,e),t=r}else n.push(e);this._createRuler(e,t),e.setView(this),this._update()},computeSize:function(){var e=0,t=0,n=this._model,i=this._clientDiv;if(!i)return{width:e,height:t};var r=i.style.width;s.isWebkit&&(i.style.width="0x7fffffffpx");for(var o=n.getLineCount(),a=0;o>a;a++){var l=this._getLine(a),d=l.getBoundingClientRect();e=Math.max(e,d.right-d.left),t+=d.bottom-d.top,l.destroy()}s.isWebkit&&(i.style.width=r);var c=this._getViewPadding();return e+=c.right+c.left+this._metrics.scrollWidth,t+=c.bottom+c.top+this._metrics.scrollWidth,{width:e,height:t}},convert:function(e,t,n){if(!this._clientDiv)return e;var i=this._getScroll(),r=this._getViewPadding(),o=this._viewDiv.getBoundingClientRect();return"document"===t&&(void 0!==e.x&&(e.x+=-i.x+o.left+r.left),void 0!==e.y&&(e.y+=-i.y+o.top+r.top)),"document"===n&&(void 0!==e.x&&(e.x+=i.x-o.left-r.left),void 0!==e.y&&(e.y+=i.y-o.top-r.top)),e},copy:function(){return this._clientDiv?this._doCopy():!1},cut:function(){return this._clientDiv?this._doCut():!1},destroy:function(){for(var e=0;e<this._rulers.length;e++)this._rulers[e].setView(null);this.rulers=null,this._destroyView();var t={type:"Destroy"};this.onDestroy(t),this._parent=null,this._model&&this._model.destroy&&this._model.destroy(),this._model=null,this._theme=null,this._selection=null,this._doubleClickSelection=null,this._keyModes=null,this._actions=null},focus:function(){this._clientDiv&&(this._updateDOMSelection(),this._clientDiv.focus(),this._updateDOMSelection())},hasFocus:function(){return this._hasFocus},getActionDescription:function(e){var t=this._actions[e];return t?t.actionDescription:void 0},getActions:function(e){var t=[],n=this._actions;for(var i in n)if(n.hasOwnProperty(i)){if(!e&&n[i].defaultHandler)continue;t.push(i)}return t},getBottomIndex:function(e){return this._clientDiv?this._getBottomIndex(e):0},getBottomPixel:function(){return this._clientDiv?this._getScroll().y+this._getClientHeight():0},getCaretOffset:function(){var e=this._getSelection();return e.getCaret()},getClientArea:function(){if(!this._clientDiv)return{x:0,y:0,width:0,height:0};var e=this._getScroll();return{x:e.x,y:e.y,width:this._getClientWidth(),height:this._getClientHeight()}},getHorizontalPixel:function(){return this._clientDiv?this._getScroll().x:0},getKeyBindings:function(e){for(var t=[],n=this._keyModes,i=0;i<n.length;i++)t=t.concat(n[i].getKeyBindings(e));return t},getKeyModes:function(){return this._keyModes.slice(0)},getLineHeight:function(e){return this._clientDiv?this._getLineHeight(e):0},getLineIndex:function(e){return this._clientDiv?this._getLineIndex(e):0},isValidTextPosition:function(e,t){if(!this._clientDiv)return!1;var n=this._getLineIndex(t,!0);if(0>n)return!1;var i=this._getLine(n),r=this.getOffsetAtLocation(e,t),o=i.getBoundingClientRect(r);return i.destroy(),e>o.right?!1:!0},getLinePixel:function(e){return this._clientDiv?this._getLinePixel(e):0},getLocationAtOffset:function(e){if(!this._clientDiv)return{x:0,y:0};var t=this._model;e=Math.min(Math.max(0,e),t.getCharCount());var n=t.getLineAtOffset(e),i=this._getLine(n),r=i.getBoundingClientRect(e);i.destroy();var o=r.left,s=this._getLinePixel(n)+r.top;return{x:o,y:s}},getNextOffset:function(e,t){var n=new y(e,e,!1);return this._doMove(t,n),n.getCaret()},getOptions:function(){var e;if(0===arguments.length)e=this._defaultOptions();else if(1===arguments.length){var t=arguments[0];if("string"==typeof t)return u(this["_"+t]);e=t}else{e={};for(var n in arguments)arguments.hasOwnProperty(n)&&(e[arguments[n]]=void 0)}for(var i in e)e.hasOwnProperty(i)&&(e[i]=u(this["_"+i]));return e},getModel:function(){return this._model},getOffsetAtLocation:function(e,t){if(!this._clientDiv)return 0;var n=this._getLineIndex(t),i=this._getLine(n),r=i.getOffset(e,t-this._getLinePixel(n));return i.destroy(),r},getLineAtOffset:function(e){return this.getModel().getLineAtOffset(e)},getLineStart:function(e){return this.getModel().getLineStart(e)},getRulers:function(){return this._rulers.slice(0)},getSelection:function(){return this._getSelection()},getSelections:function(){return this._getSelections()},getSelectionText:function(e){var t=[],n=this,i=this._getSelections();return i.forEach(function(e){e.isEmpty()||t.push(n._getBaseText(e.start,e.end))}),t.join(void 0!==e?e:this._model.getLineDelimiter())},getText:function(e,t){var n=this._model;return n.getText(e,t)},getTopIndex:function(e){return this._clientDiv?this._getTopIndex(e):0},getTopPixel:function(){return this._clientDiv?this._getScroll().y:0},invokeAction:function(e,t,n){if(this._clientDiv){var i=this._actions[e];if(i){if(i.actionDescription&&i.actionDescription.id&&l.logEvent("editor","action",i.actionDescription.id),!t&&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(e){return this.dispatchEvent(e)},onDragStart:function(e){return this.dispatchEvent(e)},onDrag:function(e){return this.dispatchEvent(e)},onDragEnd:function(e){return this.dispatchEvent(e)},onDragEnter:function(e){return this.dispatchEvent(e)},onDragOver:function(e){return this.dispatchEvent(e)},onDragLeave:function(e){return this.dispatchEvent(e)},onDrop:function(e){return this.dispatchEvent(e)},onDestroy:function(e){return this.dispatchEvent(e)},onSaving:function(e){return this.dispatchEvent(e)},onInputChanged:function(e){return this.dispatchEvent(e)},onLineStyle:function(e){return this.dispatchEvent(e)},onKeyDown:function(e){return this.dispatchEvent(e)},onKeyPress:function(e){return this.dispatchEvent(e)},onKeyUp:function(e){return this.dispatchEvent(e)},onModelChanged:function(e){return this.dispatchEvent(e)},onModelChanging:function(e){return this.dispatchEvent(e)},onModify:function(e){return this.dispatchEvent(e)},onMouseDown:function(e){return this.dispatchEvent(e)},onMouseUp:function(e){return this.dispatchEvent(e)},onMouseMove:function(e){return this.dispatchEvent(e)},onMouseOver:function(e){return this.dispatchEvent(e)},onMouseOut:function(e){return this.dispatchEvent(e)},onTouchStart:function(e){return this.dispatchEvent(e)},onTouchMove:function(e){return this.dispatchEvent(e)},onTouchEnd:function(e){return this.dispatchEvent(e)},onOptions:function(e){return this.dispatchEvent(e)},onSelection:function(e){return this.dispatchEvent(e)},onScroll:function(e){return this.dispatchEvent(e)},onVerify:function(e){return this.dispatchEvent(e)},onFocus:function(e){return this.dispatchEvent(e)},onBlur:function(e){return this.dispatchEvent(e)},paste:function(){return this._clientDiv?this._doPaste():!1},redraw:function(){if(!(this._redrawCount>0)){var e=this._model.getLineCount();this.redrawRulers(0,e),this.redrawLines(0,e)}},redrawRulers:function(e,t){if(!(this._redrawCount>0))for(var n=this.getRulers(),i=0;i<n.length;i++)this.redrawLines(e,t,n[i])},redrawLines:function(e,t,n){if(!(this._redrawCount>0)&&(void 0===e&&(e=0),void 0===t&&(t=this._model.getLineCount()),e!==t)){var i=this._clientDiv;if(i){if(n){var r=this._getRulerParent(n);for(i=r.firstChild;i&&i._ruler!==n;)i=i.nextSibling}if(i){n?i.rulerChanged=!0:this._lineHeight&&this._resetLineHeight(e,t);var o=-1;if(n||-1===this._imeOffset||(o=this._model.getLineAtOffset(this._imeOffset)),!n||"page"===n.getOverview())for(var s=i.firstChild;s;){var a=s.lineIndex;a>=e&&t>a&&a!==o&&(s.lineChanged=!0),s=s.nextSibling}n||this._wrapMode||e<=this._maxLineIndex&&this._maxLineIndex<t&&(this._checkMaxLineIndex=this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0),this.dispatchEvent({type:"Redraw",startLine:e,endLine:t,ruler:n}),this._queueUpdate()}}}},redrawRange:function(e,t){if(!(this._redrawCount>0)){var n=this._model;void 0===e&&(e=0),void 0===t&&(t=n.getCharCount());var i=n.getLineAtOffset(e),r=n.getLineAtOffset(Math.max(e,t-1))+1;this.redrawLines(i,r)}},removeKeyMode:function(e){for(var t=this._keyModes,n=0;n<t.length;n++)if(t[n]===e){t.splice(n,1);break}e._modeRemoved&&e._modeRemoved()},removeRuler:function(e){for(var t=this._rulers,n=0;n<t.length;n++)if(t[n]===e){t.splice(n,1),e.setView(null),this._destroyRuler(e),this._update();break}},resize:function(){this._clientDiv&&this._handleResize(null)},setAction:function(e,t,n){if(e){var i=this._actions,r=i[e];r||(r=i[e]={}),r.handler=t,void 0!==n&&(r.actionDescription=n)}},setKeyBinding:function(e,t){this._keyModes[0].setKeyBinding(e,t)},setCaretOffset:function(e,t,n){var i=this._model.getCharCount();e=Math.max(0,Math.min(e,i));var r=new y(e,e,!1);this._setSelection(r,void 0===t||t,!0,n)},setHorizontalPixel:function(e){this._clientDiv&&(e=Math.max(0,e),this._scrollView(e-this._getScroll().x,0))},setRedraw:function(e){e?0===--this._redrawCount&&this.redraw():this._redrawCount++},setModel:function(e){if(e!==this._model){e=e||new t.TextModel,this._model.removeEventListener("preChanging",this._modelListener.onChanging),this._model.removeEventListener("postChanged",this._modelListener.onChanged);var n=this._model.getLineCount(),i=this._model.getCharCount(),r=e.getLineCount(),o=e.getCharCount(),s=e.getText(),a={type:"ModelChanging",text:s,start:0,removedCharCount:i,addedCharCount:o,removedLineCount:n,addedLineCount:r};this.onModelChanging(a),this._model=e,a={type:"ModelChanged",start:0,removedCharCount:i,addedCharCount:o,removedLineCount:n,addedLineCount:r},this.onModelChanged(a),this._model.addEventListener("preChanging",this._modelListener.onChanging),this._model.addEventListener("postChanged",this._modelListener.onChanged),this._reset(),this._update()}},setOptions:function(e){var t=this._defaultOptions();for(var n in e)if(e.hasOwnProperty(n)){var i=e[n],r=this["_"+n];if(E(r,i))continue;var o=t[n]?t[n].update:null;if(o){o.call(this,i);continue}this["_"+n]=u(i)}this.onOptions({type:"Options",options:e})},setSelection:function(e,t,n,i){var r=e>t;if(r){var o=e;e=t,t=o}var s=this._model.getCharCount();e=Math.max(0,Math.min(e,s)),t=Math.max(0,Math.min(t,s));var a=new y(e,t,r);this._setSelection(a,void 0===n||n,!0,i)},setSelections:function(e,t,n){var i=this._rangesToSelections(e);this._setSelection(i,void 0===t||t,!0,n)},setText:function(e,t,n,i,r){var o,a="string"==typeof e,l=void 0===t&&void 0===n&&a;a?(void 0===t&&(t=0),void 0===n&&(n=this._model.getCharCount()),o={text:e,selection:[new y(t,n,!1)]}):(o=e,o.selection=this._rangesToSelections(o.selection)),o._code=!0,l&&(this._variableLineHeight=!1),this._modifyContent(o,!l,void 0===i||i,r),l&&s.isFirefox<13&&this._fixCaret()},setTopIndex:function(e,t){this._clientDiv&&this._scrollViewAnimated(0,this._getLinePixel(Math.max(0,e))-this._getScroll().y,t)},setTopPixel:function(e,t){this._clientDiv&&this._scrollViewAnimated(0,Math.max(0,e)-this._getScroll().y,t)},showSelection:function(e,t){return this._showCaret(e?!1:!0,t,e)},update:function(e,t){this._clientDiv&&((e||this._metrics.invalid)&&this._updateStyle(),void 0===t||t?this._update():this._queueUpdate())},_handleRootMouseDown:function(e){if(this._cancelCheckSelection(),!this._ignoreEvent(e)){s.isFirefox<13&&1===e.which&&(this._clientDiv.contentEditable=!1,(this._overlayDiv||this._clientDiv).draggable=!0,this._ignoreBlur=!0);var t=this._overlayDiv||this._clientDiv;s.isIE<9&&(t=this._viewDiv);for(var n=e.target?e.target:e.srcElement;n;){if(t===n)return;if(n.className&&-1!==n.className.indexOf("textViewFind"))return;n=n.parentNode}if(e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!this._isW3CEvents){var i=this,r=this._getWindow();r.setTimeout(function(){i._clientDiv.focus()},0)}}},_handleRootMouseUp:function(e){this._ignoreEvent(e)||(s.isFirefox<13&&1===e.which&&(this._clientDiv.contentEditable=!0,(this._overlayDiv||this._clientDiv).draggable=!1),s.isFirefox&&1===e.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 e=this._rootDiv,t=s.createElement(e.ownerDocument,"div");e.appendChild(t),e.removeChild(t)}if(this._cursorDiv&&(this._cursorDiv.style.display="none"),this._domSelection){this._domSelection.forEach(function(e){e.update()});var n,i=this._getWindow(),r=this._parent.ownerDocument;if(i.getSelection){var o=i.getSelection();for(n=o.anchorNode;n;){if(n===this._clientDiv){o.rangeCount>0&&o.removeAllRanges();break}n=n.parentNode}}else if(r.selection){for(this._ignoreSelect=!1,n=r.selection.createRange().parentElement();n;){if(n===this._clientDiv){r.selection.empty();break}n=n.parentNode}this._ignoreSelect=!0}}this._ignoreFocus||this.onBlur({type:"Blur"})}},_handleCompositionStart:function(e){if(!this._ignoreEvent(e)){if(this._imeTimeout){var t=this._getWindow();t.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(e){this._ignoreEvent(e)||(this._imeText=e.data)},_handleCompositionEnd:function(e){if(!this._ignoreEvent(e)){this._imeText=e.data;var t=this._getWindow();this._imeTimeout=t.setTimeout(function(){this._commitIME(this._imeText),this._imeText=this._imeTimeout=null}.bind(this),0)}},_handleContextMenu:function(e){if(!this._ignoreEvent(e)){s.isIE&&3===this._lastMouseButton&&this._updateDOMSelection();var t=!1;if(this.isListening("ContextMenu")){var n=this._createMouseEvent("ContextMenu",e);n.screenX=e.screenX,n.screenY=e.screenY,this.onContextMenu(n),t=n.defaultPrevented}else s.isMac&&s.isFirefox&&0===e.button&&(t=!0);return t?(e.preventDefault&&e.preventDefault(),!1):(this._contextMenuOpen=!0,void(s.isFirefox&&(this._checkSelectionChange=!0,this._pollSelectionChange(!0))))}},_handleCopy:function(e){return this._cancelCheckSelection(),this._ignoreEvent(e)||this._ignoreCopy?void 0:this._doCopy(e)?(e.preventDefault&&e.preventDefault(),!1):void 0},_handleCut:function(e){return this._cancelCheckSelection(),this._ignoreEvent(e)?void 0:this._doCut(e)?(e.preventDefault&&e.preventDefault(),!1):void 0},_handleDataModified:function(e){this._ignoreEvent(e)||this._startIME()},_handleDblclick:function(e){if(!this._ignoreEvent(e)){var t=e.timeStamp?e.timeStamp:Date.now();this._lastMouseTime=t,2!==this._clickCount&&(this._clickCount=2,this._handleMouse(e))}},_handleDragStart:function(e){if(!this._ignoreEvent(e)){if(s.isFirefox<13){var t=this,n=this._getWindow();n.setTimeout(function(){t._clientDiv.contentEditable=!0,t._clientDiv.draggable=!1,t._ignoreBlur=!1},0)}return this.isListening("DragStart")&&-1!==this._dragOffset?(this._isMouseDown=!1,this.onDragStart(this._createMouseEvent("DragStart",e)),this._dragOffset=-1,void 0):(e.preventDefault&&e.preventDefault(),!1)}},_handleDrag:function(e){this._ignoreEvent(e)||this.isListening("Drag")&&this.onDrag(this._createMouseEvent("Drag",e))},_handleDragEnd:function(e){this._ignoreEvent(e)||(this._dropTarget=!1,this._dragOffset=-1,this.isListening("DragEnd")&&this.onDragEnd(this._createMouseEvent("DragEnd",e)),s.isFirefox<13&&(this._fixCaret(),"none"!==e.dataTransfer.dropEffect||e.dataTransfer.mozUserCancelled||this._fixCaret()))},_handleDragEnter:function(e){if(!this._ignoreEvent(e)){var t=!0;return this._dropTarget=!0,this.isListening("DragEnter")&&(t=!1,this.onDragEnter(this._createMouseEvent("DragEnter",e))),s.isWebkit||t?(e.preventDefault&&e.preventDefault(),!1):void 0}},_handleDragOver:function(e){if(!this._ignoreEvent(e)){var t=!0;return this.isListening("DragOver")&&(t=!1,this.onDragOver(this._createMouseEvent("DragOver",e))),s.isWebkit||t?(t&&(e.dataTransfer.dropEffect="none"),e.preventDefault&&e.preventDefault(),!1):void 0}},_handleDragLeave:function(e){this._ignoreEvent(e)||(this._dropTarget=!1,this.isListening("DragLeave")&&this.onDragLeave(this._createMouseEvent("DragLeave",e)))},_handleDrop:function(e){return this._ignoreEvent(e)?void 0:(this._dropTarget=!1,this.isListening("Drop")&&this.onDrop(this._createMouseEvent("Drop",e)),e.preventDefault&&e.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(e){e.update()}),this._ignoreFocus||this.onFocus({type:"Focus"})},_handleKeyDown:function(e){if(this._cancelCheckSelection(),!this._ignoreEvent(e)){if(this.isListening("KeyDown")){var t=this._createKeyEvent("KeyDown",e);if(this.onKeyDown(t),t.defaultPrevented)return s.isFirefox&&(this._keyDownPrevented=!0),void e.preventDefault()}var n=!1;switch(e.keyCode){case 16:case 17:case 18:case 91:n=!0;break;default:this._setLinksVisible(!1)}if(229===e.keyCode){if(this._readonly)return e.preventDefault&&e.preventDefault(),!1;var i=!0;s.isSafari&&s.isMac&&e.ctrlKey&&(i=!1,e.keyCode=129),i&&this._startIME()}else n||this._commitIME();return(s.isMac||s.isLinux)&&s.isFirefox<4||s.isOpera<12.16?(this._keyDownEvent=e,!0):this._doAction(e)?(e.preventDefault?(e.preventDefault(),e.stopPropagation()):(e.cancelBubble=!0,e.returnValue=!1,e.keyCode=0),!1):void 0}},_handleKeyPress:function(e){if(!this._ignoreEvent(e)){if(this._keyDownPrevented)return e.preventDefault&&(e.preventDefault(),e.stopPropagation()),void(this._keyDownPrevented=void 0);if(s.isMac&&s.isWebkit&&(63232<=e.keyCode&&e.keyCode<=63487||13===e.keyCode||8===e.keyCode))return e.preventDefault&&e.preventDefault(),!1;if(((s.isMac||s.isLinux)&&s.isFirefox<4||s.isOpera<12.16)&&this._doAction(this._keyDownEvent))return e.preventDefault&&e.preventDefault(),!1;var t=s.isMac?e.metaKey:e.ctrlKey;if(void 0!==e.charCode&&t)switch(e.charCode){case 99:case 118:case 120:return!0}if(this.isListening("KeyPress")){var n=this._createKeyEvent("KeyPress",e);if(this.onKeyPress(n),n.defaultPrevented)return void e.preventDefault()}if(this._doAction(e))return e.preventDefault?(e.preventDefault(),e.stopPropagation()):(e.cancelBubble=!0,e.returnValue=!1,e.keyCode=0),!1;var i=!1;if(s.isMac?(e.ctrlKey||e.metaKey)&&(i=!0):s.isFirefox?(e.ctrlKey||e.altKey)&&(i=!0):e.ctrlKey^e.altKey&&(i=!0),!i){if(e.key)return this._doContent(e.key),e.preventDefault&&e.preventDefault(),!1;var r=s.isOpera?e.which:void 0!==e.charCode?e.charCode:e.keyCode;if(r>31)return this._doContent(String.fromCharCode(r)),e.preventDefault&&e.preventDefault(),!1}}},_handleDocKeyUp:function(e){var t=s.isMac?e.metaKey:e.ctrlKey;t||this._setLinksVisible(!1)},_handleKeyUp:function(e){if(!this._ignoreEvent(e)){if(this.isListening("KeyUp")){var t=this._createKeyEvent("KeyUp",e);if(this.onKeyUp(t),t.defaultPrevented)return void e.preventDefault()}this._handleDocKeyUp(e),13===e.keyCode&&this._commitIME()}},_handleLinkClick:function(e){var t=s.isMac?e.metaKey:e.ctrlKey;return t?void 0:(e.preventDefault&&e.preventDefault(),!1)},_handleMouse:function(e){var t=this._getWindow(),n=!0,i=t;if((s.isIE||s.isFirefox&&!this._overlayDiv)&&(i=this._clientDiv),this._overlayDiv){this._hasFocus&&(this._ignoreFocus=!0);var r=this;t.setTimeout(function(){r.focus(),r._ignoreFocus=!1},0)}var o=e.shiftKey,a=e.altKey,l=s.isMac?e.metaKey:e.ctrlKey;if(this._blockSelection=this._doubleClickSelection=null,1===this._clickCount){var d=(!s.isOpera||s.isOpera>=12.16)&&this._hasFocus&&this.isListening("DragStart");n=this._setSelectionTo(e.clientX,e.clientY,!0,o,l,d),n&&this._setGrab(i)}else this._isW3CEvents&&this._setGrab(i),this._setSelectionTo(e.clientX,e.clientY,!0,o,l,!1),this._doubleClickSelection=y.editing(this._getSelections());return a&&(this._blockSelection=y.editing(this._getSelections())),n},_handleMouseDown:function(e){if(!this._ignoreEvent(e)){if(this._linksVisible){var t=e.target||e.srcElement;if("A"===t.tagName)return;this._setLinksVisible(!1)}this._commitIME();var n=e.which;n||(4===e.button&&(n=2),2===e.button&&(n=3),1===e.button&&(n=1));var i=2!==n&&e.timeStamp?e.timeStamp:Date.now(),r=i-this._lastMouseTime,o=Math.abs(this._lastMouseX-e.clientX),a=Math.abs(this._lastMouseY-e.clientY),l=this._lastMouseButton===n;if(this._lastMouseX=e.clientX,this._lastMouseY=e.clientY,this._lastMouseTime=i,this._lastMouseButton=n,1===n&&(this._isMouseDown=!0,l&&r<=this._clickTime&&o<=this._clickDist&&a<=this._clickDist?this._clickCount++:this._clickCount=1),this.isListening("MouseDown")){var d=this._createMouseEvent("MouseDown",e);if(this.onMouseDown(d),d.defaultPrevented)return void e.preventDefault()}1===n&&this._handleMouse(e)&&(s.isIE>=9||s.isOpera||s.isChrome||s.isSafari||s.isFirefox&&!this._overlayDiv)&&(this._hasFocus||this.focus(),e.preventDefault()),s.isFirefox&&3===this._lastMouseButton&&this._updateDOMSelection()}},_handleMouseOver:function(e){this._ignoreEvent(e)||this._animation||this.isListening("MouseOver")&&this.onMouseOver(this._createMouseEvent("MouseOver",e)) },_handleMouseOut:function(e){this._ignoreEvent(e)||this._animation||this.isListening("MouseOut")&&this.onMouseOut(this._createMouseEvent("MouseOut",e))},_handleMouseMove:function(e){if(!this._animation){var t=this._isClientDiv(e);if(this.isListening("MouseMove")&&(t||this._isMouseDown)){var n=this._createMouseEvent("MouseMove",e);if(this.onMouseMove(n),n.defaultPrevented)return void e.preventDefault()}if(!this._dropTarget){var i=this._linksVisible||this._lastMouseMoveX!==e.clientX||this._lastMouseMoveY!==e.clientY;if(this._lastMouseMoveX=e.clientX,this._lastMouseMoveY=e.clientY,this._setLinksVisible(i&&!this._isMouseDown&&e.altKey&&(s.isMac?e.metaKey:e.ctrlKey)),this._checkOverlayScroll(),!this._isW3CEvents){if(0===e.button)return this._setGrab(null),!0;if(!this._isMouseDown&&1===e.button&&0!==(1&this._clickCount)&&t)return this._clickCount=2,this._handleMouse(e,this._clickCount)}if(this._isMouseDown&&-1===this._dragOffset){var r=e.clientX,o=e.clientY,a=this._getViewPadding(),l=this._viewDiv.getBoundingClientRect(),d=this._getClientWidth(),c=this._getClientHeight(),h=l.left+a.left,u=l.top+a.top,f=l.left+a.left+d,p=l.top+a.top+c;u>o?this._doAutoScroll("up",r,o-u):o>p?this._doAutoScroll("down",r,o-p):h>r&&!this._wrapMode?this._doAutoScroll("left",r-h,o):r>f&&!this._wrapMode?this._doAutoScroll("right",r-f,o):(this._endAutoScroll(),this._setSelectionTo(r,o,!1,!0))}}}},_isClientDiv:function(e){for(var t=this._overlayDiv||this._clientDiv,n=e.target?e.target:e.srcElement;n;){if(t===n)return!0;n=n.parentNode}return!1},_createKeyEvent:function(e,t){return{type:e,event:t,preventDefault:function(){this.defaultPrevented=!0}}},_createMouseEvent:function(e,t){var n=this.convert({x:t.clientX,y:t.clientY},"page","document");return{type:e,event:t,clickCount:this._clickCount,x:n.x,y:n.y,preventDefault:function(){this.defaultPrevented=!0}}},_createTouchEvent:function(e,t){var n=t.touches.length?this.convert({x:t.touches[0].clientX,y:t.touches[0].clientY},"page","document"):{};return{type:e,event:t,touchCount:t.touches.length,x:n.x,y:n.y,preventDefault:function(){this.defaultPrevented=!0}}},_handleMouseUp:function(e){var t=e.which?0===e.button:1===e.button;if(this.isListening("MouseUp")&&(this._isClientDiv(e)||t&&this._isMouseDown)){var n=this._createMouseEvent("MouseUp",e);if(this.onMouseUp(n),n.defaultPrevented)return e.preventDefault(),void(this._isMouseDown=!1)}if(!this._linksVisible){if(t&&this._isMouseDown){var i=this._getSelections(),r=y.editing(i);i.forEach(function(e){e._editing=!1}),-1!==this._dragOffset&&(r.extend(this._dragOffset),r.collapse(),i=r,this._dragOffset=-1),this._setSelection(i,!1),this._isMouseDown=!1,this._endAutoScroll(),this._isW3CEvents&&this._setGrab(null)}t&&this._isMouseDown&&s.isFirefox&&(this._updateDOMSelection(),e.preventDefault())}},_handleMouseWheel:function(e){if(!this._noScroll){var t=this._getLineHeight(),n=0,i=0;if(s.isIE||s.isOpera)i=-e.wheelDelta/40*t;else if(s.isFirefox){var r=256;if("wheel"===e.type)e.deltaMode?(n=Math.max(-r,Math.min(r,e.deltaX))*t,i=Math.max(-r,Math.min(r,e.deltaY))*t):(n=e.deltaX,i=e.deltaY);else{var o;o=s.isMac?3*e.detail:Math.max(-r,Math.min(r,e.detail))*t,e.axis===e.HORIZONTAL_AXIS?n=o:i=o}}else if(s.isMac){var a,l,d=e.timeStamp-this._wheelTimeStamp;this._wheelTimeStamp=e.timeStamp,a=e.wheelDeltaX%120!==0?1:40>d?40/(40-d):40,l=e.wheelDeltaY%120!==0?1:40>d?40/(40-d):40,n=Math.ceil(-e.wheelDeltaX/a),n>-1&&0>n&&(n=-1),n>0&&1>n&&(n=1),i=Math.ceil(-e.wheelDeltaY/l),i>-1&&0>i&&(i=-1),i>0&&1>i&&(i=1)}else{n=-e.wheelDeltaX;var c=8;i=-e.wheelDeltaY/120*c*t}if(s.isSafari||s.isChrome&&s.isMac){for(var h=e.target;h&&void 0===h.lineIndex;)h=h.parentNode;this._mouseWheelLine=h}var u=this._getScroll();this._scrollView(n,i);var f=this._getScroll();return u.x!==f.x||u.y!==f.y?(e.preventDefault&&e.preventDefault(),!1):void 0}},_handlePaste:function(e){if(this._cancelCheckSelection(),!this._ignoreEvent(e)&&!this._ignorePaste&&this._doPaste(e)){if(s.isIE){var t=this;this._ignoreFocus=!0;var n=this._getWindow();n.setTimeout(function(){t._updateDOMSelection(),t._ignoreFocus=!1},0)}return e.preventDefault&&e.preventDefault(),!1}},_handleResize:function(){var e=this._rootDiv.clientWidth,t=this._rootDiv.clientHeight;if(this._rootWidth!==e||this._rootHeight!==t){this._rootWidth!==e&&this._wrapMode&&this._resetLineHeight(),this._rootWidth=e,this._rootHeight=t;var n=s.isIE<9,i=this._calculateMetrics();E(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(e){for(var t=e.target?e.target:e.srcElement,n=t.lineIndex,i=t;i&&!i._ruler;)void 0===n&&void 0!==i.lineIndex&&(n=i.lineIndex),i=i.parentNode;var r=i?i._ruler:null;if(void 0===n&&r&&"document"===r.getOverview()){var o,s,a=this._getClientHeight(),l=this._model.getLineCount(),d=this._getViewPadding(),c=this._viewDiv.getBoundingClientRect(),h=this._getLineHeight(),u=h*l,f=a+d.top+d.bottom-2*this._metrics.scrollWidth;f>u?(o=h,s=d.top):(o=f/l,s=this._metrics.scrollWidth),n=Math.floor((e.clientY-c.top-s)/o),n>=0&&l>n||(n=void 0)}if(r)switch(e.type){case"click":r.onClick&&r.onClick(n,e);break;case"dblclick":r.onDblClick&&r.onDblClick(n,e);break;case"mousemove":r.onMouseMove&&r.onMouseMove(n,e);break;case"mouseover":r.onMouseOver&&r.onMouseOver(n,e);break;case"mouseout":if(r.onMouseOut){for(var p=e.relatedTarget;p&&p!==this._rootDiv;){if(p===i)return;p=p.parentNode}r.onMouseOut(n,e)}}},_handleScroll:function(){this._lastScrollTime=Date.now();var e=this._getScroll(!1),t=this._hScroll,n=this._vScroll;if(t!==e.x||n!==e.y){this._hScroll=e.x,this._vScroll=e.y,this._commitIME(),this._update(n===e.y);var i={type:"Scroll",oldValue:{x:t,y:n},newValue:e};this.onScroll(i)}},_handleSelectStart:function(e){var t=this._contextMenuOpen;return this._contextMenuOpen=!1,t?void(this._checkSelectionChange=!0):this._ignoreSelect?(e&&e.preventDefault&&e.preventDefault(),!1):void 0},_getModelOffset:function(e,t){if(e){var n;return n="DIV"===e.tagName?e:e.parentNode.parentNode,n._line?n._line.getModelOffset(e,t):0}},_updateSelectionFromDOM:function(){if(!(s.isIOS||s.isAndroid||this._checkSelectionChange))return!1;var e=this._getWindow(),t=e.getSelection(),n=this._getModelOffset(t.anchorNode,t.anchorOffset),i=this._getModelOffset(t.focusNode,t.focusOffset),r=this._getSelections()[0];if(void 0===n||void 0===i||r.start===n&&r.end===i)return!1;if(this._checkSelectionChange){var o=this._getLineNext(),a=this._getLinePrevious();if(t.anchorNode===o.firstChild.firstChild&&0===t.anchorOffset&&t.focusNode===a.firstChild.firstChild&&0===t.focusOffset)return!1;(t.anchorNode===o.firstChild.firstChild&&0===t.anchorOffset&&t.focusNode===a.lastChild.firstChild||t.anchorNode===this._clientDiv&&t.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 e=this._getWindow();e.clearTimeout(this._selPollTimer),this._selPollTimer=null}},_pollSelectionChange:function(e){var t=this,n=this._getWindow();this._cancelPollSelectionChange(),this._selPollTimer=n.setTimeout(function(){if(t._selPollTimer=null,t._clientDiv){var n=t._updateSelectionFromDOM();!n&&e&&t._pollSelectionChange(e)}},100)},_handleSelectionChange:function(){-1===this._imeOffset&&(s.isAndroid?this._pollSelectionChange():this._updateSelectionFromDOM())},_handleTextInput:function(e){if(!this._ignoreEvent(e)&&-1===this._imeOffset){var t=this._getWindow().getSelection();if(t.anchorNode!==this._anchorNode||t.focusNode!==this._focusNode||t.anchorOffset!==this._anchorOffset||t.focusOffset!==this._focusOffset){for(var n=t.anchorNode;n&&void 0===n.lineIndex;)n=n.parentNode;if(n){var i=this._model,r=n.lineIndex,o=i.getLine(r),s=o,a=0,l=i.getLineStart(r);if(t.rangeCount>0){t.getRangeAt(0).deleteContents();var d=n.ownerDocument.createTextNode(e.data);t.getRangeAt(0).insertNode(d);var c=this._getDOMText(n,d);s=c.text,a=c.offset,d.parentNode.removeChild(d)}n.lineRemoved=!0;for(var h=0;o.charCodeAt(h)===s.charCodeAt(h)&&a>h;)h++;for(var u=o.length-1,f=s.length-o.length;o.charCodeAt(u)===s.charCodeAt(u+f)&&u+f>=a+e.data.length;)u--;u++;var p=s.substring(h,u+f);h+=l,u+=l;var g=this._getSelections(),v=g[0].start-h,m=g[0].end-u;g[0].start=h,g[0].end=u;for(var _=1;_<g.length;_++)g[_].start-=v,g[_].end-=m;this._modifyContent({text:p,selection:g,_ignoreDOMSelection:!0},!0)}}else this._doContent(e.data);e.preventDefault()}},_handleTouchStart:function(e){if(this.isListening("TouchStart")){var t=this._createTouchEvent("TouchStart",e);if(this.onTouchStart(t),t.defaultPrevented)return void e.preventDefault();if(this._noScroll)return}this._commitIME();var n=this._getWindow();this._touchScrollTimer&&(this._vScrollDiv.style.display="none",this._hScrollDiv.style.display="none",n.clearInterval(this._touchScrollTimer),this._touchScrollTimer=null);var i=e.touches;if(1===i.length){var r=i[0],o=r.clientX,a=r.clientY;this._touchStartX=o,this._touchStartY=a,s.isAndroid&&(a<r.pageY-n.pageYOffset||o<r.pageX-n.pageXOffset)&&(o=r.pageX-n.pageXOffset,a=r.pageY-n.pageYOffset);var l=this.convert({x:o,y:a},"page","document");this._lastTouchOffset=this.getOffsetAtLocation(l.x,l.y),this._touchStartTime=e.timeStamp,this._touching=!0}},_handleTouchMove:function(e){if(this.isListening("TouchMove")){var t=this._createTouchEvent("TouchMove",e);if(this.onTouchMove(t),t.defaultPrevented)return void e.preventDefault();if(this._noScroll)return}var n=e.touches;if(1===n.length){var i=n[0];this._touchCurrentX=i.clientX,this._touchCurrentY=i.clientY;var r=10;if(!this._touchScrollTimer&&e.timeStamp-this._touchStartTime<20*r){this._vScrollDiv.style.display="block",this._wrapMode||(this._hScrollDiv.style.display="block");var o=this,s=this._getWindow();this._touchScrollTimer=s.setInterval(function(){var e=0,t=0;if(o._touching)e=o._touchStartX-o._touchCurrentX,t=o._touchStartY-o._touchCurrentY,o._touchSpeedX=e/r,o._touchSpeedY=t/r,o._touchStartX=o._touchCurrentX,o._touchStartY=o._touchCurrentY;else{if(Math.abs(o._touchSpeedX)<.1&&Math.abs(o._touchSpeedY)<.1)return o._vScrollDiv.style.display="none",o._hScrollDiv.style.display="none",s.clearInterval(o._touchScrollTimer),void(o._touchScrollTimer=null);e=o._touchSpeedX*r,t=o._touchSpeedY*r,o._touchSpeedX*=.95,o._touchSpeedY*=.95}o._scrollView(e,t)},r)}this._touchScrollTimer&&e.preventDefault()}},_handleTouchEnd:function(e){if(this.isListening("TouchEnd")){var t=this._createTouchEvent("TouchEnd",e);if(this.onTouchEnd(t),t.defaultPrevented)return void e.preventDefault();if(this._noScroll)return}var n=e.touches;0===n.length&&(this._touching=!1)},_doAction:function(e){var t,n,i=this._keyModes;for(n=i.length-1;n>=0;n--)if(t=i[n],"function"==typeof t.match){var r=t.match(e);if(void 0!==r)return this.invokeAction(r)}return!1},_doMove:function(e,t){var n=this._model,i=t.getCaret(),r=n.getLineAtOffset(i);for(e.count||(e.count=1);0!==e.count;){var o=n.getLineStart(r);if(e.count<0&&i===o){if(!(r>0))break;"character"===e.unit&&e.count++,r--,t.extend(n.getLineEnd(r))}else if(e.count>0&&i===n.getLineEnd(r)){if(!(r+1<n.getLineCount()))break;"character"===e.unit&&e.count--,r++,t.extend(n.getLineStart(r))}else{var s=!1;if(e.expandTab&&"character"===e.unit&&(i-o)%this._tabSize===0){var a=n.getText(o,i);s=!/[^ ]/.test(a)}if(s)t.extend(i-this._tabSize),e.count+=e.count<0?1:-1;else{var l=this._getLine(r);t.extend(l.getNextOffset(i,e)),l.destroy()}}i=t.getCaret()}return t},_doBackspace:function(e){var t=this,n=this._getSelections();return n.forEach(function(n){n.isEmpty()&&(e.count||(e.count=1),e.count*=-1,e.expandTab=t._expandTab,t._doMove(e,n))}),this._modifyContent({text:"",selection:n},!0),!0},_doCase:function(e){var t=this,n=this._getSelections(),i=[];return n.forEach(function(n){t._doMove(e,n);var r=t.getText(n.start,n.end);switch(e.type){case"lower":r=r.toLowerCase();break;case"capitalize":r=r.replace(/(?:^|\s)\S/g,function(e){return e.toUpperCase()});break;case"reverse":for(var o="",s=0;s<r.length;s++){var a=r[s],l=a.toLowerCase();a=l!==a?l:a.toUpperCase(),o+=a}r=o;break;default:r=r.toUpperCase()}i.push(r)}),this._modifyContent({text:i,selection:n,_ignoreDOMSelection:!0},!0)},_doContent:function(e){var t=this,n=this._getSelections();return n.forEach(function(e){if(t._overwriteMode&&e.isEmpty()){var n=t._model,i=n.getLineAtOffset(e.end);if(e.end<n.getLineEnd(i)){var r=t._getLine(i);e.extend(r.getNextOffset(e.getCaret(),{unit:"character",count:1})),r.destroy()}}}),this._modifyContent({text:e,selection:n,_ignoreDOMSelection:!0},!0)},_doCopy:function(e){var t=this.getSelectionText();return t?this._setClipboardText(t,e):!0},_doCursorNext:function(e){var t=this,n=this._getSelections();return n.forEach(function(n){n.isEmpty()||e.select?t._doMove(e,n):n.start=n.end,e.select||n.collapse()}),this._setSelection(n,!0),!0},_doCursorPrevious:function(e){var t=this,n=this._getSelections();return n.forEach(function(n){n.isEmpty()||e.select?(e.count||(e.count=1),e.count*=-1,t._doMove(e,n)):n.end=n.start,e.select||n.collapse()}),this._setSelection(n,!0),!0},_doCut:function(e){var t=this.getSelectionText();if(t){if(!this._setClipboardText(t,e))return!1;this._doContent("")}return!0},_doDelete:function(e){var t=this,n=this._getSelections();return n.forEach(function(n){n.isEmpty()&&t._doMove(e,n)}),this._modifyContent({text:"",selection:n},!0),!0},_doEnd:function(e){var t=this._model,n=this,i=this._getSelections();return i.forEach(function(i){if(e.ctrl)i.extend(t.getCharCount());else{var r=i.getCaret(),o=t.getLineAtOffset(r);if(n._wrapMode){var s=n._getLine(o),a=s.getLineIndex(r);r=a===s.getLineCount()-1?t.getLineEnd(o):s.getLineStart(a+1)-1,s.destroy()}else e.count&&e.count>0&&(o=Math.min(o+e.count-1,t.getLineCount()-1)),r=t.getLineEnd(o);i.extend(r)}e.select||i.collapse()}),this._setSelection(i,!0,!0,e.ctrl?function(){}:null),!0},_doEnter:function(e){if(this._singleMode)return!0;var t=this._model,n=this._getSelections();return this._doContent(t.getLineDelimiter()),e&&e.noCursor&&(n.forEach(function(e){e.end=e.start}),this._setSelection(n,!0)),!0},_doEscape:function(){var e=this._getSelections();return e.length>1&&this._setSelection(e[0],!0),!0},_doHome:function(e){var t=this._model,n=this,i=this._getSelections();return i.forEach(function(i){if(e.ctrl)i.extend(0);else{var r=i.getCaret(),o=t.getLineAtOffset(r);if(n._wrapMode){var s=n._getLine(o),a=s.getLineIndex(r);r=s.getLineStart(a),s.destroy()}else r=t.getLineStart(o);i.extend(r)}e.select||i.collapse()}),this._setSelection(i,!0,!0,e.ctrl?function(){}:null),!0},_doLineDown:function(e){var t=this._model,n=this,i=this._getSelections();return i.forEach(function(i){var r,o=i.getCaret(),a=t.getLineAtOffset(o),l=n._getLine(a),d=i._columnX,c=1,h=!1;if(-1===d||e.wholeLine||e.select&&s.isIE){var u=e.wholeLine?t.getLineEnd(a+1):o;d=i._columnX=l.getBoundingClientRect(u).left}if((r=l.getLineIndex(o))<l.getLineCount()-1)c=l.getClientRects(r+1).top+1;else{var f=t.getLineCount()-1;h=a===f,e.count&&e.count>0?a=Math.min(a+e.count,f):a++}var p=!1;h?(e.select||s.isMac||s.isLinux)&&(i.extend(t.getCharCount()),p=!0):(l.lineIndex!==a&&(l.destroy(),l=n._getLine(a)),i.extend(l.getOffset(d,c)),p=!0),p&&(e.select||i.collapse()),l.destroy()}),n._setSelection(i,!0,!0,null,0,!1,!0),!0},_doLineUp:function(e){var t=this._model,n=this,i=this._getSelections();return i.forEach(function(i){var r,o,a=i.getCaret(),l=t.getLineAtOffset(a),d=n._getLine(l),c=i._columnX,h=!1;if(-1===c||e.wholeLine||e.select&&s.isIE){var u=e.wholeLine?t.getLineStart(l-1):a;c=i._columnX=d.getBoundingClientRect(u).left}(r=d.getLineIndex(a))>0?o=d.getClientRects(r-1).top+1:(h=0===l,h||(e.count&&e.count>0?l=Math.max(l-e.count,0):l--,o=n._getLineHeight(l)-1));var f=!1;h?(e.select||s.isMac||s.isLinux)&&(i.extend(0),f=!0):(d.lineIndex!==l&&(d.destroy(),d=n._getLine(l)),i.extend(d.getOffset(c,o)),f=!0),f&&(e.select||i.collapse()),d.destroy()}),n._setSelection(i,!0,!0,null,0,!1,!0),!0},_doNoop:function(){return!0},_doPageDown:function(e){var t,n,i,r=this,o=this._model,a=this._getSelections(),l=o.getLineCount(),d=this._getScroll(),c=this._getClientHeight(),h=this._getLineHeight(),u=Math.floor(c/h);return a.forEach(function(a){var f=a.getCaret(),p=o.getLineAtOffset(f);if(r._lineHeight){t=a._columnX;var g=r._getBoundsAtOffset(f);(-1===t||e.select&&s.isIE)&&(t=a._columnX=g.left);var v=r._getLineIndex(g.top+c);n=r._getLine(v);var m=r._getLinePixel(v),_=g.top+c-m;f=n.getOffset(t,_);var y=n.getBoundingClientRect(f);n.destroy(),a.extend(f),e.select||a.collapse(),i=void 0!==i?Math.min(i,y.top+m-g.top):y.top+m-g.top}else if(l-1>p){var C=Math.min(l-p-1,u);C=Math.max(1,C),t=a._columnX,(-1===t||e.select&&s.isIE)&&(n=r._getLine(p),t=a._columnX=n.getBoundingClientRect(f).left,n.destroy()),n=r._getLine(p+C),a.extend(n.getOffset(t,0)),n.destroy(),e.select||a.collapse();var w=l*h,x=d.y+C*h;x+c>w&&(x=w-c),i=void 0!==i?Math.min(i,x-d.y):x-d.y}}),this._setSelection(a,!0,!0,function(){},i,!1,!0),!0},_doPageUp:function(e){var t,n,i,r=this,o=this._model,a=this._getSelections(),l=this._getScroll(),d=this._getClientHeight(),c=this._getLineHeight(),h=Math.floor(d/c);return a.forEach(function(a){var u=a.getCaret(),f=o.getLineAtOffset(u);if(r._lineHeight){t=a._columnX;var p=r._getBoundsAtOffset(u);(-1===t||e.select&&s.isIE)&&(t=a._columnX=p.left);var g=r._getLineIndex(p.bottom-d);n=r._getLine(g);var v=r._getLinePixel(g),m=p.bottom-d-v;u=n.getOffset(t,m);var _=n.getBoundingClientRect(u);n.destroy(),a.extend(u),e.select||a.collapse(),i=void 0!==i?Math.max(i,_.top+v-p.top):_.top+v-p.top}else if(f>0){var y=Math.max(1,Math.min(f,h));t=a._columnX,(-1===t||e.select&&s.isIE)&&(n=r._getLine(f),t=a._columnX=n.getBoundingClientRect(u).left,n.destroy()),n=r._getLine(f-y),a.extend(n.getOffset(t,r._getLineHeight(f-y)-1)),n.destroy(),e.select||a.collapse();var C=Math.max(0,l.y-y*c);i=void 0!==i?Math.max(i,C-l.y):C-l.y}}),this._setSelection(a,!0,!0,function(){},i,!1,!0),!0},_doPaste:function(e){var t=this,n=this._getClipboardText(e,function(e){if(e.length){if(s.isLinux&&2===t._lastMouseButton){var n=Date.now()-t._lastMouseTime;n<=t._clickTime&&t._setSelectionTo(t._lastMouseX,t._lastMouseY,!0)}var i=t._getSelections(),r=t._singleMode?"":t._model.getLineDelimiter();t._doContent(i.length>1&&i.length===e.length?e:e.join(r))}});return null!==n},_doScroll:function(e){var t,n=e.type,i=this._model,r=i.getLineCount(),o=this._getClientHeight(),s=this._getLineHeight(),a=this._lineHeight?this._scrollHeight:r*s,l=this._getScroll().y;switch(n){case"textStart":t=0;break;case"textEnd":t=a-o;break;case"pageDown":t=l+o;break;case"pageUp":t=l-o;break;case"lineDown":t=l+s;break;case"lineUp":t=l-s;break;case"centerLine":var d=this._getSelections()[0],c=i.getLineAtOffset(d.start),h=i.getLineAtOffset(d.end),u=(h-c+1)*s;t=c*s-o/2+u/2}return void 0!==t&&(t=Math.min(Math.max(0,t),a-o),this._scrollViewAnimated(0,t-l,function(){})),!0},_doSelectAll:function(){var e=this._model;return this._setSelection(new y(0,e.getCharCount()),!1),!0},_doTab:function(){if(this._tabMode&&!this._readonly){var e=" ",t=this._getSelections();if(this._expandTab){e=[];var n=this._model,i=this._tabSize;t.forEach(function(t){var r=t.getCaret(),o=n.getLineAtOffset(r),s=n.getLineStart(o),a=i-(r-s)%i;e.push(c(a+1).join(" "))})}return this._modifyContent({text:e,selection:t,_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 e,t,n=this._model,i=this._getSelections(),r=y.editing(i,"down"===this._autoScrollDir),o=this.convert({x:this._autoScrollX,y:this._autoScrollY},"page","document"),a=r.getCaret(),l=n.getLineCount(),d=n.getLineAtOffset(a);if("up"===this._autoScrollDir||"down"===this._autoScrollDir){var c=this._autoScrollY/this._getLineHeight();c=0>c?Math.floor(c):Math.ceil(c),e=d,e=Math.max(0,Math.min(l-1,e+c))}else("left"===this._autoScrollDir||"right"===this._autoScrollDir)&&(e=this._getLineIndex(o.y),t=this._getLine(d),o.x+=t.getBoundingClientRect(a,!1).left,t.destroy());this._blockSelection?i=this._getBlockSelections(i,e,o):0===e&&(s.isMac||s.isLinux)?r.extend(0):e===l-1&&(s.isMac||s.isLinux)?r.extend(n.getCharCount()):(t=this._getLine(e),r.extend(t.getOffset(o.x,o.y-this._getLinePixel(e))),t.destroy()),this._setSelection(i,!0)},_autoScrollTimer:function(){this._autoScroll();var e=this,t=this._getWindow();this._autoScrollTimerID=t.setTimeout(function(){e._autoScrollTimer()},this._AUTO_SCROLL_RATE)},_calculateLineHeightTimer:function(e){if(this._lineHeight&&!this._calculateLHTimer){var t=this._model.getLineCount(),n=0;if(e){for(var i=0,r=100,o=Date.now(),s=0;t>n&&(this._lineHeight[n]||(i++,s||(s=n),this._lineHeight[n]=this._calculateLineHeight(n)),n++,!(Date.now()-o>r)););this.redrawRulers(0,t),this._queueUpdate()}var a=this._getWindow();if(n!==t){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(e){var t=this._getLine(e),n=t.getBoundingClientRect();return t.destroy(),Math.max(1,n.bottom-n.top)},_calculateMetrics:function(){var e=this._clientDiv,t=e.ownerDocument,n=" ",i=s.createElement(t,"div");i.style.lineHeight="normal";var r=this._model,o=r.getLine(0),a={type:"LineStyle",textView:this,0:0,lineText:o,lineStart:0};this.onLineStyle(a),h(a.style,i),i.style.position="fixed",i.style.left="-1000px";var l=s.createElement(t,"span");l.appendChild(t.createTextNode(n)),i.appendChild(l);var d=s.createElement(t,"span");d.style.fontStyle="italic",d.appendChild(t.createTextNode(n)),i.appendChild(d);var u=s.createElement(t,"span");u.style.fontWeight="bold",u.appendChild(t.createTextNode(n)),i.appendChild(u);var f=s.createElement(t,"span");f.style.fontWeight="bold",f.style.fontStyle="italic",f.appendChild(t.createTextNode(n)),i.appendChild(f),e.appendChild(i);var p=i.getBoundingClientRect(),g=l.getBoundingClientRect(),_=d.getBoundingClientRect(),y=u.getBoundingClientRect(),C=f.getBoundingClientRect(),w=g.bottom-g.top,x=_.bottom-_.top,b=y.bottom-y.top,S=C.bottom-C.top,T=0,E=p.bottom-p.top<=0,A=Math.max(1,p.bottom-p.top);x>w&&(T=1),b>x&&(T=2),S>b&&(T=3);var L;0!==T&&(L={style:{}},0!==(1&T)&&(L.style.fontStyle="italic"),0!==(2&T)&&(L.style.fontWeight="bold"));var k=m(i);e.removeChild(i);var M=v(this._viewDiv),O=s.createElement(t,"div");O.style.position="fixed",O.style.left="-1000px",O.style.paddingLeft=M.left+"px",O.style.paddingTop=M.top+"px",O.style.paddingRight=M.right+"px",O.style.paddingBottom=M.bottom+"px",O.style.width="100px",O.style.height="100px";var D=s.createElement(t,"div");D.style.width="100%",D.style.height="100%",O.appendChild(D),e.appendChild(O);var N=O.getBoundingClientRect(),I=D.getBoundingClientRect(),R=0;if(!this._singleMode&&!this._noScroll){O.style.overflow="hidden",D.style.height="200px";var B=O.clientWidth;O.style.overflow="scroll";var P=O.clientWidth;R=B-P}e.removeChild(O),M={left:I.left-N.left,top:I.top-N.top,right:N.right-I.right,bottom:N.bottom-I.bottom};var F=0,V=0,U=0;return E||(O=s.createElement(t,"div"),O.style.position="fixed",O.style.left="-1000px",e.appendChild(O),O.innerHTML=c(2).join("a"),N=O.getBoundingClientRect(),U=Math.ceil(N.right-N.left),(this._wrapOffset||this._marginOffset)&&(O.innerHTML=c(this._wrapOffset+1+(s.isWebkit?0:1)).join(" "),N=O.getBoundingClientRect(),F=Math.ceil(N.right-N.left),O.innerHTML=c(this._marginOffset+1).join(" "),I=O.getBoundingClientRect(),V=Math.ceil(I.right-I.left)),e.removeChild(O)),{lineHeight:A,largestFontStyle:L,lineTrim:k,viewPadding:M,scrollWidth:R,wrapWidth:F,marginWidth:V,charWidth:U,invalid:E}},_cancelAnimation:function(){this._animation&&(this._animation.stop(),this._animation=null)},_clearSelection:function(e){var t=this._getSelections();return t.forEach(function(t){"next"===e?t.start=t.end:t.end=t.start}),this._setSelection(t,!0),!0},_commitIME:function(e){if(-1!==this._imeOffset){var t=this._model,n=t.getLineAtOffset(this._imeOffset),i=t.getLineStart(n),r=this._getLineNode(n);if(!e){this._scrollDiv.focus(),this._clientDiv.focus();var o=this._getDOMText(r).text,a=t.getLine(n),l=this._imeOffset-i,d=l+o.length-a.length;l!==d&&(e=o.substring(l,d))}this._imeOffset=-1,e&&(this._doContent(e)||s.isWebkit||(r.lineRemoved=!0,this._queueUpdate()))}},_createActions:function(){this.addKeyMode(new n.DefaultKeyMode(this));var t=this;this._actions={noop:{defaultHandler:function(){return t._doNoop()}},lineUp:{defaultHandler:function(e){return t._doLineUp(f(e,{select:!1}))},actionDescription:{name:e.lineUp}},lineDown:{defaultHandler:function(e){return t._doLineDown(f(e,{select:!1}))},actionDescription:{name:e.lineDown}},lineStart:{defaultHandler:function(e){return t._doHome(f(e,{select:!1,ctrl:!1}))},actionDescription:{name:e.lineStart}},lineEnd:{defaultHandler:function(e){return t._doEnd(f(e,{select:!1,ctrl:!1}))},actionDescription:{name:e.lineEnd}},charPrevious:{defaultHandler:function(e){return t._doCursorPrevious(f(e,{select:!1,unit:"character"}))},actionDescription:{name:e.charPrevious}},charNext:{defaultHandler:function(e){return t._doCursorNext(f(e,{select:!1,unit:"character"}))},actionDescription:{name:e.charNext}},pageUp:{defaultHandler:function(e){return t._doPageUp(f(e,{select:!1}))},actionDescription:{name:e.pageUp}},pageDown:{defaultHandler:function(e){return t._doPageDown(f(e,{select:!1}))},actionDescription:{name:e.pageDown}},scrollPageUp:{defaultHandler:function(e){return t._doScroll(f(e,{type:"pageUp"}))},actionDescription:{name:e.scrollPageUp}},scrollPageDown:{defaultHandler:function(e){return t._doScroll(f(e,{type:"pageDown"}))},actionDescription:{name:e.scrollPageDown}},scrollLineUp:{defaultHandler:function(e){return t._doScroll(f(e,{type:"lineUp"}))},actionDescription:{name:e.scrollLineUp}},scrollLineDown:{defaultHandler:function(e){return t._doScroll(f(e,{type:"lineDown"}))},actionDescription:{name:e.scrollLineDown}},wordPrevious:{defaultHandler:function(e){return t._doCursorPrevious(f(e,{select:!1,unit:"word"}))},actionDescription:{name:e.wordPrevious}},wordNext:{defaultHandler:function(e){return t._doCursorNext(f(e,{select:!1,unit:"word"}))},actionDescription:{name:e.wordNext}},textStart:{defaultHandler:function(e){return t._doHome(f(e,{select:!1,ctrl:!0}))},actionDescription:{name:e.textStart}},textEnd:{defaultHandler:function(e){return t._doEnd(f(e,{select:!1,ctrl:!0}))},actionDescription:{name:e.textEnd}},scrollTextStart:{defaultHandler:function(e){return t._doScroll(f(e,{type:"textStart"}))},actionDescription:{name:e.scrollTextStart}},scrollTextEnd:{defaultHandler:function(e){return t._doScroll(f(e,{type:"textEnd"}))},actionDescription:{name:e.scrollTextEnd}},centerLine:{defaultHandler:function(e){return t._doScroll(f(e,{type:"centerLine"}))},actionDescription:{name:e.centerLine}},selectLineUp:{defaultHandler:function(e){return t._doLineUp(f(e,{select:!0}))},actionDescription:{name:e.selectLineUp}},selectLineDown:{defaultHandler:function(e){return t._doLineDown(f(e,{select:!0}))},actionDescription:{name:e.selectLineDown}},selectWholeLineUp:{defaultHandler:function(e){return t._doLineUp(f(e,{select:!0,wholeLine:!0}))},actionDescription:{name:e.selectWholeLineUp}},selectWholeLineDown:{defaultHandler:function(e){return t._doLineDown(f(e,{select:!0,wholeLine:!0}))},actionDescription:{name:e.selectWholeLineDown}},selectLineStart:{defaultHandler:function(e){return t._doHome(f(e,{select:!0,ctrl:!1}))},actionDescription:{name:e.selectLineStart}},selectLineEnd:{defaultHandler:function(e){return t._doEnd(f(e,{select:!0,ctrl:!1}))},actionDescription:{name:e.selectLineEnd}},selectCharPrevious:{defaultHandler:function(e){return t._doCursorPrevious(f(e,{select:!0,unit:"character"}))},actionDescription:{name:e.selectCharPrevious}},selectCharNext:{defaultHandler:function(e){return t._doCursorNext(f(e,{select:!0,unit:"character"}))},actionDescription:{name:e.selectCharNext}},selectPageUp:{defaultHandler:function(e){return t._doPageUp(f(e,{select:!0}))},actionDescription:{name:e.selectPageUp}},selectPageDown:{defaultHandler:function(e){return t._doPageDown(f(e,{select:!0}))},actionDescription:{name:e.selectPageDown}},selectWordPrevious:{defaultHandler:function(e){return t._doCursorPrevious(f(e,{select:!0,unit:"word"}))},actionDescription:{name:e.selectWordPrevious}},selectWordNext:{defaultHandler:function(e){return t._doCursorNext(f(e,{select:!0,unit:"word"}))},actionDescription:{name:e.selectWordNext}},selectTextStart:{defaultHandler:function(e){return t._doHome(f(e,{select:!0,ctrl:!0}))},actionDescription:{name:e.selectTextStart}},selectTextEnd:{defaultHandler:function(e){return t._doEnd(f(e,{select:!0,ctrl:!0}))},actionDescription:{name:e.selectTextEnd}},deletePrevious:{defaultHandler:function(e){return t._doBackspace(f(e,{unit:"character"}))},actionDescription:{name:e.deletePrevious}},deleteNext:{defaultHandler:function(e){return t._doDelete(f(e,{unit:"character"}))},actionDescription:{name:e.deleteNext}},deleteWordPrevious:{defaultHandler:function(e){return t._doBackspace(f(e,{unit:"word"}))},actionDescription:{name:e.deleteWordPrevious}},deleteWordNext:{defaultHandler:function(e){return t._doDelete(f(e,{unit:"word"}))},actionDescription:{name:e.deleteWordNext}},deleteLineStart:{defaultHandler:function(e){return t._doBackspace(f(e,{unit:"line"}))},actionDescription:{name:e.deleteLineStart}},deleteLineEnd:{defaultHandler:function(e){return t._doDelete(f(e,{unit:"line"}))},actionDescription:{name:e.deleteLineEnd}},tab:{defaultHandler:function(e){return t._doTab(f(e,{}))},actionDescription:{name:e.tab}},shiftTab:{defaultHandler:function(e){return t._doShiftTab(f(e,{}))},actionDescription:{name:e.shiftTab}},enter:{defaultHandler:function(e){return t._doEnter(f(e,{}))},actionDescription:{name:e.enter}},enterNoCursor:{defaultHandler:function(e){return t._doEnter(f(e,{noCursor:!0}))},actionDescription:{name:e.enterNoCursor}},escape:{defaultHandler:function(e){return t._doEscape(f(e,{}))},actionDescription:{name:e.escape}},selectAll:{defaultHandler:function(e){return t._doSelectAll(f(e,{}))},actionDescription:{name:e.selectAll}},copy:{defaultHandler:function(e){return t._doCopy(f(e,{}))},actionDescription:{name:e.copy}},cut:{defaultHandler:function(e){return t._doCut(f(e,{}))},actionDescription:{name:e.cut}},paste:{defaultHandler:function(e){return t._doPaste(f(e,{}))},actionDescription:{name:e.paste}},uppercase:{defaultHandler:function(e){return t._doCase(f(e,{type:"upper"}))},actionDescription:{name:e.uppercase}},lowercase:{defaultHandler:function(e){return t._doCase(f(e,{type:"lower"}))},actionDescription:{name:e.lowercase}},capitalize:{defaultHandler:function(e){return t._doCase(f(e,{unit:"word",type:"capitalize"}))},actionDescription:{name:e.capitalize}},reversecase:{defaultHandler:function(e){return t._doCase(f(e,{type:"reverse"}))},actionDescription:{name:e.reversecase}},toggleOverwriteMode:{defaultHandler:function(e){return t._doOverwriteMode(f(e,{}))},actionDescription:{name:e.toggleOverwriteMode}},toggleTabMode:{defaultHandler:function(e){return t._doTabMode(f(e,{}))},actionDescription:{name:e.toggleTabMode}},toggleWrapMode:{defaultHandler:function(e){return t._doWrapMode(f(e,{}))},actionDescription:{name:e.toggleWrapMode}}}},_createRulerParent:function(e,t){var n=s.createElement(e,"div");return n.className=t,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(e,t){if(this._clientDiv){var n=this._getRulerParent(e);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=e,e.node=i,i.rulerChanged=!0,i.style.position="relative",i.style.cssFloat="left",i.style.styleFloat="left",i.style.outline="none",void 0===t||0>t||t>=n.children.length)n.appendChild(i);else{for(var r=n.firstChild;r&&t-->0;)r=r.nextSibling;n.insertBefore(i,r)}}}},_createSelectionDiv:function(){var e=s.createElement(this._parent.ownerDocument,"div");return e.className="textviewSelection",e.style.position="absolute",e.style.borderWidth="0px",e.style.margin="0px",e.style.padding="0px",e.style.outline="none",e.style.width="0px",e.style.height="0px",e.style.zIndex="0",e},_createView:function(){function e(){w._rootDiv&&(w.update(!0),w._metrics.invalid&&w._getWindow().setTimeout(function(){e()},100))}if(!this._clientDiv){for(var t=this._parent;t.hasChildNodes();)t.removeChild(t.lastChild);var n=t.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"),t.appendChild(i);var r=this._createRulerParent(n,"textviewLeftRuler");this._leftDiv=r;var o=s.createElement(n,"div");o.className="textviewScroll",this._viewDiv=o,o.tabIndex=-1,o.style.position="absolute",o.style.top="0px",o.style.bottom="0px",o.style.borderWidth="0px",o.style.margin="0px",o.style.outline="none",o.style.background="transparent",i.appendChild(o);var l=this._createRulerParent(n,"textviewRightRuler");this._rightDiv=l,"rtl"==document.dir?l.style.left="0px":l.style.right="0px";var d=this._createRulerParent(n,"textviewInnerRightRuler");this._innerRightDiv=d,d.style.zIndex="1";var c=s.createElement(n,"div");this._scrollDiv=c,c.style.margin="0px",c.style.borderWidth="0px",c.style.padding="0px",o.appendChild(c);var h=this._marginDiv=this._createRulerParent(n,"textviewMarginRuler");if(h.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 p=s.createElement(n,"div");if(p.className="textviewContent",this._clientDiv=p,p.tabIndex=0,p.style.position="absolute",p.style.borderWidth="0px",p.style.margin="0px",p.style.padding="0px",p.style.outline="none",p.style.zIndex="1",p.style.WebkitUserSelect="text",p.setAttribute("spellcheck","false"),(s.isIOS||s.isAndroid)&&(p.style.WebkitTapHighlightColor="transparent"),(this._clipDiv||i).appendChild(p),this._setFullSelection(this._fullSelection,!0),s.isIOS||s.isAndroid){var g=s.createElement(n,"div");this._vScrollDiv=g,g.style.position="absolute",g.style.borderWidth="1px",g.style.borderColor="white",g.style.borderStyle="solid",g.style.borderRadius="4px",g.style.backgroundColor="black",g.style.opacity="0.5",g.style.margin="0px",g.style.padding="0px",g.style.outline="none",g.style.zIndex="3",g.style.width="8px",g.style.display="none",i.appendChild(g);var v=s.createElement(n,"div");this._hScrollDiv=v,v.style.position="absolute",v.style.borderWidth="1px",v.style.borderColor="white",v.style.borderStyle="solid",v.style.borderRadius="4px",v.style.backgroundColor="black",v.style.opacity="0.5",v.style.margin="0px",v.style.padding="0px",v.style.outline="none",v.style.zIndex="3",v.style.height="8px",v.style.display="none",i.appendChild(v)}if(s.isFirefox&&!p.setCapture){var m=s.createElement(n,"div");this._overlayDiv=m,m.style.position=p.style.position,m.style.borderWidth=p.style.borderWidth,m.style.margin=p.style.margin,m.style.padding=p.style.padding,m.style.cursor="text",m.style.zIndex="2",(this._clipDiv||i).appendChild(m)}p.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(p);for(var y=this._rulers,C=0;C<y.length;C++)this._createRuler(y[C]);this._update();var w=this;_(n,i,"textview",e)}},_defaultOptions:function(){return{parent:{value:void 0,update:null},model:{value:void 0,update:this.setModel},scrollAnimation:{value:0,update:null},readonly:{value:!1,update:this._setReadOnly},fullSelection:{value:!0,update:this._setFullSelection},tabMode:{value:!0,update:null},tabSize:{value:8,update:this._setTabSize},expandTab:{value:!1,update:null},singleMode:{value:!1,update:this._setSingleMode},noScroll:{value:!1,update:this._setNoScroll},overwriteMode:{value:!1,update:this._setOverwriteMode},blockCursorVisible:{value:!1,update:this._setBlockCursor},marginOffset:{value:0,update:this._setMarginOffset},wrapOffset:{value:0,update:this._setWrapOffset},wrapMode:{value:!1,update:this._setWrapMode},wrappable:{value:!1,update:null},undoStack:{value:null,update:this._setUndoStack},theme:{value:r.TextTheme.getTheme(),update:this._setTheme},themeClass:{value:void 0,update:this._setThemeClass}}},_destroyRuler:function(e){var t=this._getRulerParent(e);if(t)for(var n=t.firstChild;n;){if(n._ruler===e){n._ruler=void 0,t.removeChild(n),0!==t.children.length||t===this._marginDiv&&this._marginOffset||(t.style.display="none"),t.rulerWidth=void 0;break}n=n.nextSibling}},_destroyView:function(){var e=this._clientDiv;if(e){this._setGrab(null),this._unhookEvents();var t=this._getWindow();this._autoScrollTimerID&&(t.clearTimeout(this._autoScrollTimerID),this._autoScrollTimerID=null),this._updateTimer&&(t.clearTimeout(this._updateTimer),this._updateTimer=null),this._calculateLHTimer&&(t.clearTimeout(this._calculateLHTimer),this._calculateLHTimer=null),this._cursorTimer&&(t.clearInterval(this._cursorTimer),this._cursorTimer=null),this._imeTimeout&&(t.clearInterval(this._imeTimeout),this._imeTimeout=null);var n=this._rootDiv;n.parentNode.removeChild(n),this._domSelection=null,this._clipboardDiv=null,this._rootDiv=null,this._scrollDiv=null,this._viewDiv=null,this._clipDiv=null,this._clipScrollDiv=null,this._clientDiv=null,this._overlayDiv=null,this._leftDiv=null,this._rightDiv=null,this._innerRightDiv=null,this._marginDiv=null,this._cursorDiv=null,this._vScrollDiv=null,this._hScrollDiv=null}},_doAutoScroll:function(e,t,n){this._autoScrollDir=e,this._autoScrollX=t,this._autoScrollY=n,this._autoScrollTimerID||this._autoScrollTimer()},_endAutoScroll:function(){if(this._autoScrollTimerID){var e=this._getWindow();e.clearTimeout(this._autoScrollTimerID)}this._autoScrollDir=void 0,this._autoScrollTimerID=void 0},_fixCaret:function(){var e=this._clientDiv;if(e){var t=this._hasFocus;this._ignoreFocus=!0,t&&e.blur(),e.contentEditable=!1,e.contentEditable=!0,t&&e.focus(),this._ignoreFocus=!1}},_getBaseText:function(e,t){var n=this._model;return n.getBaseModel&&(e=n.mapOffset(e),t=n.mapOffset(t),n=n.getBaseModel()),n.getText(e,t)},_getBottomIndex:function(e){var t=this._bottomChild;if(e&&this._getClientHeight()>this._getLineHeight()){var n=t.getBoundingClientRect(),i=this._clientDiv.getBoundingClientRect();n.bottom>i.bottom&&(t=this._getLinePrevious(t)||t)}return t.lineIndex},_getBlockSelections:function(e,t,n){var i=this._model;e=e.filter(function(e){return!e._editing});var r,o=i.getLineAtOffset(this._blockSelection.getAnchor());t>o?r=t:(r=o,o=t);for(var s=o;r>=s;s++){var a=this._getLine(s),l=a.getOffset(n.x,1),d=a.getOffset(this._blockSelection._docX,1);if(a.destroy(),l!==d||l!==i.getLineEnd(s)){var c=d>l,h=new y(c?l:d,c?d:l,c);h._editing=!0,e.push(h)}}return e},_getBoundsAtOffset:function(e){var t=this._model,n=this._getLine(t.getLineAtOffset(e)),i=n.getBoundingClientRect(e),r=this._getLinePixel(n.lineIndex);return i.top+=r,i.bottom+=r,n.destroy(),i},_getClientHeight:function(){var e=this._getViewPadding();return Math.max(0,this._viewDiv.clientHeight-e.top-e.bottom)},_getInnerRightWidth:function(){var e=this._innerRightDiv.rulerWidth;if(void 0===e){var t=this._innerRightDiv.getBoundingClientRect();this._innerRightDiv.rulerWidth=e=t.right-t.left}return e},_getClientWidth:function(){var e=this._getViewPadding(),t=this._getInnerRightWidth();return Math.max(0,this._viewDiv.clientWidth-e.left-e.right-t)},_getClipboardText:function(e,t){function n(e){var n=[];return p(e,function(e){n.push(e)},null),t&&t(n),n}var i=this._getWindow(),r=i.clipboardData;if(!r&&e&&(r=e.clipboardData),r)return n(r.getData(s.isIE?"Text":"text/plain"));if(s.isElectron&&!e)return n(window.__electron.clipboard.readText());if(s.isFirefox){this._ignoreFocus=!0;var o=this._clipboardDiv,a=this._rootDiv.ownerDocument;o||(o=s.createElement(a,"div"),this._clipboardDiv=o,o.style.position="fixed",o.style.whiteSpace="pre",o.style.left="-1000px",this._rootDiv.appendChild(o)),o.innerHTML="<pre contenteditable=''></pre>",o.firstChild.focus();var l=this,d=function(){var e=l._getTextFromElement(o);return o.innerHTML="",n(e)},c=!1;if(this._ignorePaste=!0,!s.isLinux||2!==this._lastMouseButton)try{c=a.execCommand("paste",!1,null)}catch(h){c=o.childNodes.length>1||o.firstChild&&o.firstChild.childNodes.length>0}return this._ignorePaste=!1,c?(this.focus(),this._ignoreFocus=!1,d()):e?(i.setTimeout(function(){l.focus(),d(),l._ignoreFocus=!1},0),null):(this.focus(),this._ignoreFocus=!1,"")}return""},_getDOMText:function(e,t){return e._line.getText(t)},_getTextFromElement:function(e){var t=e.ownerDocument,n=t.defaultView;if(!n.getSelection)return e.innerText||e.textContent;var i=t.createRange();i.selectNode(e);var r,o=n.getSelection(),s=[];for(r=0;r<o.rangeCount;r++)s.push(o.getRangeAt(r));this._ignoreSelect=!0,o.removeAllRanges(),o.addRange(i);var a=o.toString();for(o.removeAllRanges(),r=0;r<s.length;r++)o.addRange(s[r]);return this._ignoreSelect=!1,a},_getViewPadding:function(){return this._metrics.viewPadding},_getLine:function(e){var t=this._getLineNode(e);return!t||t.lineChanged||t.lineRemoved?new x(this,e):t._line},_getLineHeight:function(e,t){if(void 0!==e&&this._lineHeight){var n=this._lineHeight[e];if(n)return n;if(t||void 0===t){var i=this._lineHeight[e]=this._calculateLineHeight(e);return i}}return this._metrics.lineHeight},_getLineNode:function(e){for(var t=this._clientDiv,n=t.firstChild;n;){if(e===n.lineIndex)return n;n=n.nextSibling}return void 0},_getLineNext:function(e){for(var t=e?e.nextSibling:this._clientDiv.firstChild;t&&(-1===t.lineIndex||!t._line);)t=t.nextSibling;return t},_getLinePrevious:function(e){for(var t=e?e.previousSibling:this._clientDiv.lastChild;t&&(-1===t.lineIndex||!t._line);)t=t.previousSibling;return t},_getLinePixel:function(e){if(e=Math.min(Math.max(0,e),this._model.getLineCount()),this._lineHeight){var t,n=this._getTopIndex(),i=-this._topIndexY+this._getScroll().y;if(e>n)for(t=n;e>t;t++)i+=this._getLineHeight(t);else for(t=n-1;t>=e;t--)i-=this._getLineHeight(t);return i}var r=this._getLineHeight();return r*e},_getLineIndex:function(e,t){var n,i=0,r=this._model.getLineCount();if(this._lineHeight){i=this._getTopIndex();var o=-this._topIndexY+this._getScroll().y;if(e!==o)if(o>e)for(;o>e&&i>0;)e+=this._getLineHeight(--i);else for(n=this._getLineHeight(i);e-n>=o&&r-1>i;)e-=n,n=this._getLineHeight(++i)}else n=this._getLineHeight(),i=Math.floor(e/n);return t&&(0===r||0>i||i>r-1)?-1:Math.max(0,Math.min(r-1,i))},_getRulerParent:function(e){switch(e.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(e){(void 0===e||e)&&this._cancelAnimation();var t=this._viewDiv;return{x:t.scrollLeft,y:t.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(e){return e.clone()})},_getTopIndex:function(e){var t=this._topChild;if(e&&this._getClientHeight()>this._getLineHeight()){var n=t.getBoundingClientRect(),i=this._getViewPadding(),r=this._viewDiv.getBoundingClientRect();n.top<r.top+i.top&&(t=this._getLineNext(t)||t)}return t.lineIndex},_hookEvents:function(){var e=this;this._modelListener={onChanging:function(t){e._onModelChanging(t)},onChanged:function(t){e._onModelChanged(t)}},this._model.addEventListener("preChanging",this._modelListener.onChanging),this._model.addEventListener("postChanged",this._modelListener.onChanged),this._themeListener={onChanged:function(){e._setThemeClass(e._themeClass)}},this._theme.addEventListener("ThemeChanged",this._themeListener.onChanged);var t=this._handlers=[],n=this._clientDiv,i=this._viewDiv,r=this._rootDiv,o=this._overlayDiv||n,a=n.ownerDocument,l=this._getWindow(),d=s.isIE?a:l;t.push({target:l,type:"resize",handler:function(t){return e._handleResize(t?t:l.event)}}),t.push({target:n,type:"blur",handler:function(t){return e._handleBlur(t?t:l.event)}}),t.push({target:n,type:"focus",handler:function(t){return e._handleFocus(t?t:l.event)}}),t.push({target:i,type:"focus",handler:function(){n.focus()}});var c=e.getModel();if(c&&"function"==typeof c.deferScroll){var h=c.deferScroll(e,e._handleScroll.bind(e));t.push({target:i,type:"scroll",handler:function(e){return h(e?e:l.event)}})}else t.push({target:i,type:"scroll",handler:function(t){return e._handleScroll(t?t:l.event)}});if(t.push({target:n,type:"textInput",handler:function(t){return e._handleTextInput(t?t:l.event)}}),t.push({target:n,type:"keydown",handler:function(t){return e._handleKeyDown(t?t:l.event)}}),t.push({target:n,type:"keypress",handler:function(t){return e._handleKeyPress(t?t:l.event)}}),t.push({target:n,type:"keyup",handler:function(t){return e._handleKeyUp(t?t:l.event)}}),s.isIE&&t.push({target:a,type:"keyup",handler:function(t){return e._handleDocKeyUp(t?t:l.event)}}),t.push({target:n,type:"contextmenu",handler:function(t){return e._handleContextMenu(t?t:l.event)}}),t.push({target:n,type:"copy",handler:function(t){return e._handleCopy(t?t:l.event)}}),t.push({target:n,type:"cut",handler:function(t){return e._handleCut(t?t:l.event)}}),t.push({target:n,type:"paste",handler:function(t){return e._handlePaste(t?t:l.event)}}),t.push({target:a,type:"selectionchange",handler:function(t){return e._handleSelectionChange(t?t:l.event)}}),s.isIOS||s.isAndroid)t.push({target:n,type:"touchstart",handler:function(t){return e._handleTouchStart(t?t:l.event)}}),t.push({target:n,type:"touchmove",handler:function(t){return e._handleTouchMove(t?t:l.event)}}),t.push({target:n,type:"touchend",handler:function(t){return e._handleTouchEnd(t?t:l.event)}});else{if(t.push({target:n,type:"selectstart",handler:function(t){return e._handleSelectStart(t?t:l.event)}}),t.push({target:n,type:"mousedown",handler:function(t){return e._handleMouseDown(t?t:l.event)}}),t.push({target:n,type:"mouseover",handler:function(t){return e._handleMouseOver(t?t:l.event)}}),t.push({target:n,type:"mouseout",handler:function(t){return e._handleMouseOut(t?t:l.event)}}),t.push({target:d,type:"mouseup",handler:function(t){return e._handleMouseUp(t?t:l.event)}}),t.push({target:d,type:"mousemove",handler:function(t){return e._handleMouseMove(t?t:l.event)}}),t.push({target:r,type:"mousedown",handler:function(t){return e._handleRootMouseDown(t?t:l.event)}}),t.push({target:r,type:"mouseup",handler:function(t){return e._handleRootMouseUp(t?t:l.event)}}),t.push({target:o,type:"dragstart",handler:function(t){return e._handleDragStart(t?t:l.event)}}),t.push({target:o,type:"drag",handler:function(t){return e._handleDrag(t?t:l.event)}}),t.push({target:o,type:"dragend",handler:function(t){return e._handleDragEnd(t?t:l.event)}}),t.push({target:o,type:"dragenter",handler:function(t){return e._handleDragEnter(t?t:l.event)}}),t.push({target:o,type:"dragover",handler:function(t){return e._handleDragOver(t?t:l.event)}}),t.push({target:o,type:"dragleave",handler:function(t){return e._handleDragLeave(t?t:l.event)}}),t.push({target:o,type:"drop",handler:function(t){return e._handleDrop(t?t:l.event)}}),t.push({target:this._clientDiv,type:s.isFirefox>26?"wheel":s.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(t){return e._handleMouseWheel(t?t:l.event)}}),this._clipDiv&&t.push({target:this._clipDiv,type:s.isFirefox>26?"wheel":s.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(t){return e._handleMouseWheel(t?t:l.event)}}),s.isFirefox&&(!s.isWindows||s.isFirefox>=15)){var u=l.MutationObserver||l.MozMutationObserver;u?(this._mutationObserver=new u(function(t){e._handleDataModified(t)}),this._mutationObserver.observe(n,{subtree:!0,characterData:!0})):t.push({target:this._clientDiv,type:"DOMCharacterDataModified",handler:function(t){return e._handleDataModified(t?t:l.event)}})}(s.isFirefox&&(!s.isWindows||s.isFirefox>=15)||s.isIE||s.isWebkit)&&(t.push({target:this._clientDiv,type:"compositionstart",handler:function(t){return e._handleCompositionStart(t?t:l.event)}}),t.push({target:this._clientDiv,type:"compositionend",handler:function(t){return e._handleCompositionEnd(t?t:l.event)}}),t.push({target:this._clientDiv,type:"compositionupdate",handler:function(t){return e._handleCompositionUpdate(t?t:l.event)}})),this._overlayDiv&&(t.push({target:this._overlayDiv,type:"mousedown",handler:function(t){return e._handleMouseDown(t?t:l.event)}}),t.push({target:this._overlayDiv,type:"mouseover",handler:function(t){return e._handleMouseOver(t?t:l.event)}}),t.push({target:this._overlayDiv,type:"mouseout",handler:function(t){return e._handleMouseOut(t?t:l.event)}}),t.push({target:this._overlayDiv,type:"contextmenu",handler:function(t){return e._handleContextMenu(t?t:l.event)}})),this._isW3CEvents||t.push({target:this._clientDiv,type:"dblclick",handler:function(t){return e._handleDblclick(t?t:l.event)}})}this._hookRulerEvents(this._leftDiv,t),this._hookRulerEvents(this._rightDiv,t),this._hookRulerEvents(this._innerRightDiv,t),this._hookRulerEvents(this._marginDiv,t);for(var f=0;f<t.length;f++){var p=t[f];S(p.target,p.type,p.handler,p.capture)}},_hookRulerEvents:function(e,t){if(e){var n=this,i=this._getWindow();s.isIE&&t.push({target:e,type:"selectstart",handler:function(){return!1}}),t.push({target:e,type:s.isFirefox>26?"wheel":s.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(e){return n._handleMouseWheel(e?e:i.event)}}),t.push({target:e,type:"click",handler:function(e){n._handleRulerEvent(e?e:i.event)}}),t.push({target:e,type:"dblclick",handler:function(e){n._handleRulerEvent(e?e:i.event)}}),t.push({target:e,type:"mousemove",handler:function(e){n._handleRulerEvent(e?e:i.event)}}),t.push({target:e,type:"mouseover",handler:function(e){n._handleRulerEvent(e?e:i.event)}}),t.push({target:e,type:"mouseout",handler:function(e){n._handleRulerEvent(e?e:i.event)}})}},_getWindow:function(){return d(this._parent.ownerDocument)},_ignoreEvent:function(e){for(var t=e.target;t&&t!==this._clientDiv;){if(t.ignore)return!0;t=t.parentNode}return!1},_init:function(e){var n=e.parent;if("string"==typeof n&&(n=(e.document||document).getElementById(n)),!n)throw new Error("no parent");e.parent=n,e.model=e.model||new t.TextModel;var i=this._defaultOptions();for(var r in i)if(i.hasOwnProperty(r)){var o;o=void 0!==e[r]?e[r]:i[r].value,this["_"+r]=o}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 e=this._viewDiv,t=this._isOverOverlayScroll();e.style.pointerEvents=t.vertical||t.horizontal?"":"none"}},_isOverOverlayScroll:function(){var e=Date.now()-this._lastScrollTime<1e3;if(!e)return{};var t=this._viewDiv.getBoundingClientRect(),n=this._lastMouseMoveX,i=this._lastMouseMoveY,r=15;return{vertical:t.top<=i&&i<t.bottom&&t.right-r<=n&&n<t.right,horizontal:t.bottom-r<=i&&i<t.bottom&&t.left<=n&&n<t.right}},_startUndo:function(){if(this._undoStack){var e=this;this._compoundChange=this._undoStack.startCompoundChange({end:function(){e._compoundChange=null}})}},_endUndo:function(){this._undoStack&&this._undoStack.endCompoundChange()},_modifyContent:function(e,t,n,i){if(this._readonly&&!e._code)return!1;e.type="Verify";var r=e.start=e.selection[0].start,o=e.end=e.selection[0].end;if(this.onVerify(e),r!==e.start&&(e.selection[0].start=e.start),o!==e.end&&(e.selection[0].end=e.end),null===e.text||void 0===e.text)return!1;var s;e.preserveSelection&&(s=this._getSelections()),e.selection.length>1&&this.setRedraw(!1);var a=this._compoundChange;a?y.compare(s||this._getSelections(),a.owner.selection)||(this._endUndo(),e.selection.length>1&&this._startUndo()):e.selection.length>1&&this._startUndo();var l=this._model;try{e._ignoreDOMSelection&&(this._ignoreDOMSelection=!0);var d=0;e.selection.forEach(function(n,i){n.start+=d,n.end+=d;var r=Array.isArray(e.text)?e.text[i]:e.text;l.setText(r,n.start,n.end);var o=n.start-n.end+r.length;d+=o,s&&s.forEach(function(e){e.start>n.start&&(e.start+=o),e.end>n.start&&(e.end+=o)}),n.setCaret(t?n.start+r.length:n.start)})}finally{e._ignoreDOMSelection&&(this._ignoreDOMSelection=!1)}return this._setSelection(s||e.selection,n,!0,i),a=this._compoundChange,a&&(a.owner.selection=s||e.selection),e.selection.length>1&&this.setRedraw(!0),this.onModify({type:"Modify"}),!0},_onModelChanged:function(e){e.type="ModelChanged",this.onModelChanged(e),e.type="Changed";var t=e.start,n=e.addedCharCount,i=e.removedCharCount,r=e.addedLineCount,o=e.removedLineCount,s=this._getSelections();s.forEach(function(e){e.end>t&&(e.end>t&&e.start<t+i?e.setCaret(t+n):(e.start+=n-i,e.end+=n-i))}),this._setSelection(s,!1,!1);for(var a=this._model,l=a.getLineAtOffset(t),d=this._getLineNext();d;){var h=d.lineIndex;h>=l&&l+o>=h&&(l!==h||d.modelChangedEvent||d.lineRemoved?(d.lineRemoved=!0,d.lineChanged=!1,d.modelChangedEvent=null):(d.modelChangedEvent=e,d.lineChanged=!0)),h>l+o&&(d.lineIndex=h+r-o,d._line.lineIndex=d.lineIndex),d=this._getLineNext(d)}if(this._lineHeight){var u=[l,o].concat(c(r));Array.prototype.splice.apply(this._lineHeight,u)}this._wrapMode||l<=this._maxLineIndex&&this._maxLineIndex<=l+o&&(this._checkMaxLineIndex=this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0),this._update()},_onModelChanging:function(e){e.type="ModelChanging",this.onModelChanging(e),e.type="Changing"},_queueUpdate:function(){if(!this._updateTimer&&!this._ignoreQueueUpdate){var e=this,t=this._getWindow();this._updateTimer=t.setTimeout(function(){e._updateTimer=null,e._update()},0)}},_rangesToSelections:function(e){var t=[],n=this._model.getCharCount();return e.forEach(function(e){var i;if(e instanceof y)i=e.clone();else{var r=e.start,o=e.end,s=r>o;if(s){var a=r;r=o,o=a}r=Math.max(0,Math.min(r,n)),o=Math.max(0,Math.min(o,n)),i=new y(r,o,s)}t.push(i)}),t},_resetLineHeight:function(e,t){if(this._wrapMode||this._variableLineHeight){if(void 0!==e&&void 0!==t)for(var n=e;t>n;n++)this._lineHeight[n]=void 0;else this._lineHeight=c(this._model.getLineCount());this._calculateLineHeightTimer()}else this._lineHeight=null},_resetLineWidth:function(){var e=this._clientDiv;if(e)for(var t=e.firstChild;t;)t.lineWidth=void 0,t=t.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 e=this._clientDiv;if(e){for(var t=e.firstChild;t;)t.lineRemoved=!0,t=t.nextSibling;s.isFirefox<13&&this._fixCaret()}},_scrollViewAnimated:function(e,t,n){var i=this._getWindow();if(n&&this._scrollAnimation){var r=this;this._animation=new A({window:i,duration:this._scrollAnimation,curve:[t,0],onAnimate:function(e){var n=t-Math.floor(e);r._scrollView(0,n),t-=n},onEnd:function(){r._animation=null,r._scrollView(e,t),n&&i.setTimeout(n,0)}}),this._animation.play()}else this._scrollView(e,t),n&&i.setTimeout(n,0)},_scrollView:function(e,t){this._ensureCaretVisible=!1;var n=this._viewDiv;e&&(n.scrollLeft+=e),t&&(n.scrollTop+=t)},_setClipboardText:function(e,t){if(s.isElectron&&!t)return window.__electron.clipboard.writeText(e),!0;var n,i=this._getWindow(),r=i.clipboardData;if(!r&&t&&(r=t.clipboardData),r){n=[],p(e,function(e){n.push(e)},function(){n.push(s.platformDelimiter)});var o=r.setData(s.isIE?"Text":"text/plain",n.join(""));if(o||t&&(s.isFirefox>21||s.isWebkit))return!0;if(!t)return!1}var a=this._parent.ownerDocument,l=s.createElement(a,"pre");l.style.position="fixed",l.style.left="-1000px",p(e,function(e){l.appendChild(a.createTextNode(e))},function(){l.appendChild(s.createElement(a,"br"))}),l.appendChild(a.createTextNode(" ")),this._clientDiv.appendChild(l);var d=a.createRange();d.setStart(l.firstChild,0),d.setEndBefore(l.lastChild);var c=i.getSelection();c.rangeCount>0&&c.removeAllRanges(),c.addRange(d);var h=this,u=function(){l&&l.parentNode===h._clientDiv&&h._clientDiv.removeChild(l),h._updateDOMSelection()},f=!1;this._ignoreCopy=!0;try{f=a.execCommand("copy",!1,null)}catch(g){}return this._ignoreCopy=!1,!f&&t?(i.setTimeout(u,0),!1):(u(),!0)},_setGrab:function(e){e!==this._grabControl&&(e?(e.setCapture&&e.setCapture(),this._grabControl=e):(this._grabControl.releaseCapture&&this._grabControl.releaseCapture(),this._grabControl=null))},_setLinksVisible:function(e){if(this._linksVisible!==e){this._linksVisible=e,s.isIE&&e&&(this._hadFocus=this._hasFocus);var t=this._clientDiv;t.contentEditable=!e,this._hadFocus&&!e&&t.focus(),this._overlayDiv&&(this._overlayDiv.style.zIndex=e?"-1":"1");for(var n=this._getLineNext();n;)n._line.updateLinks(),n=this._getLineNext(n);this._updateDOMSelection()}},_setSelection:function(e,t,n,i,r,o,s){if(e){void 0===n&&(n=!0);var a,l=this._getSelections();if(a=Array.isArray(e)?e:o?l.concat([e]):[e],this._selection=y.merge(a),s||a.forEach(function(e){e._columnX=-1}),t!==!1&&this._showCaret(!1,i,t,r),n&&this._updateDOMSelection(),!y.compare(l,a)){var d={type:"Selection",oldValue:y.convert(l),newValue:y.convert(a)};this.onSelection(d)}}},_setSelectionTo:function(e,t,n,i,r,o){var s=this._model,a=this._getSelections(),l=this.convert({x:e,y:t},"page","document"),d=this._getLineIndex(l.y),c=this._getLine(d),h=c.getOffset(l.x,l.y-this._getLinePixel(d));if(o&&!i&&y.contains(a,h))return this._dragOffset=h,c.destroy(),!1;if(this._blockSelection)a=this._getBlockSelections(a,d,l);else{var u;if(n?i?(u=a[a.length-1],u._editing=!0):(u=new y(0,0),u._editing=!0,r?a.push(u):a=[u],u._docX=l.x):u=y.editing(a),1===this._clickCount)u.extend(h),i||u.collapse();else{var f,p,g=0===(1&this._clickCount);if(g)this._doubleClickSelection?h>=this._doubleClickSelection.start?(f=this._doubleClickSelection.start,p=c.getNextOffset(h,{unit:"wordend",count:1})):(f=c.getNextOffset(h,{unit:"word",count:-1}),p=this._doubleClickSelection.end):(f=c.getNextOffset(h,{unit:"word",count:-1}),p=c.getNextOffset(f,{unit:"wordend",count:1}));else if(this._doubleClickSelection){var v=s.getLineAtOffset(this._doubleClickSelection.start);d>=v?(f=s.getLineStart(v),p=s.getLineEnd(d)):(f=s.getLineStart(d),p=s.getLineEnd(v))}else f=s.getLineStart(d),p=s.getLineEnd(d);u.setCaret(f),u.extend(p)}}return this._setSelection(a,!0,!0,null,!1),c.destroy(),!0},_setFullSelection:function(e,t){this._fullSelection=e,s.isWebkit<537.36&&(this._fullSelection=e=!0),this._domSelection||(this._domSelection=[],this._cursorVisible=!0),t||this._updateDOMSelection()},_setBlockCursor:function(e){this._blockCursorVisible=e,this._updateBlockCursorVisible()},_setOverwriteMode:function(e){this._overwriteMode=e,this._updateBlockCursorVisible()},_updateBlockCursorVisible:function(){if(this._blockCursorVisible||this._overwriteMode){if(!this._cursorDiv){var e=this._viewDiv,t=s.createElement(e.ownerDocument,"div");t.className="textviewBlockCursor",this._cursorDiv=t,t.tabIndex=-1,t.style.zIndex="2",t.style.color="transparent",t.style.position="absolute",t.style.pointerEvents="none",t.innerHTML="&nbsp;",e.appendChild(t),this._updateDOMSelection()}}else this._cursorDiv&&(this._cursorDiv.parentNode.removeChild(this._cursorDiv),this._cursorDiv=null)},_setMarginOffset:function(e,t){this._marginOffset=e,this._marginDiv.style.display=e?"block":"none",t||(this._metrics=this._calculateMetrics(),this._queueUpdate())},_setWrapOffset:function(e,t){this._wrapOffset=e,t||(this._metrics=this._calculateMetrics(),this._queueUpdate())},_setReadOnly:function(e){this._readonly=e},_setSingleMode:function(e,t){this._singleMode=e,this._updateOverflow(),this._updateStyle(t)},_setNoScroll:function(e,t){this._noScroll=e,this._updateOverflow(),this._updateStyle(t)},_setTabSize:function(e,t){this._tabSize=e,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),t||(this.redrawLines(),this._resetLineWidth())},_setTheme:function(e){this._theme&&this._theme.removeEventListener("ThemeChanged",this._themeListener.onChanged),this._theme=e,this._theme&&this._theme.addEventListener("ThemeChanged",this._themeListener.onChanged),this._setThemeClass(this._themeClass)},_setThemeClass:function(e,t){this._themeClass=e;var n="textview",i=this._theme.getThemeClass();i&&(n+=" "+i),this._themeClass&&i!==this._themeClass&&(n+=" "+this._themeClass),this._rootDiv.className=n,this._updateStyle(t)},_setUndoStack:function(e){this._undoStack=e},_setWrapMode:function(e,t){this._wrapMode=e&&this._wrappable;var n=this._clientDiv;this._wrapMode?(n.style.whiteSpace="pre-wrap",n.style.wordWrap="break-word"):(n.style.whiteSpace="pre",n.style.wordWrap="normal"),this._updateOverflow(),t||(this.redraw(),this._resetLineWidth()),this._resetLineHeight()},_showCaret:function(e,t,n,i){if(this._clientDiv&&!(this._redrawCount>0||this._ignoreDOMSelection||-1!==this._imeOffset)){var r=this._model,o=this._getSelections(),s=y.editing(o,"down"===this._autoScrollDir),a=this._getScroll(),l=s.getCaret(),d=s.start,c=s.end,h=r.getLineAtOffset(d),u=r.getLineAtOffset(c),f=Math.max(Math.max(d,r.getLineStart(u)),c-1),p=this._getClientWidth(),g=this._getClientHeight(),v=p/4,m=this._getBoundsAtOffset(l===d?d:f),_=m.left,C=m.right,w=m.top,x=m.bottom,b=0,S="object"==typeof n;!e&&!S||s.isEmpty()||(m=this._getBoundsAtOffset(l===c?d:f),b=(m.bottom>x?m.bottom:x)-(m.top<w?m.top:w),e&&(m.top===w?l===d?C=_+Math.min(m.right-_,p):_=C-Math.min(C-m.left,p):l===d?x=w+Math.min(m.bottom-w,g):w=x-Math.min(x-m.top,g)));var T=0;_<a.x&&(T=Math.min(_-a.x,-v)),C>a.x+p&&(T=Math.max(C-a.x-p,v));var E=0;w<a.y?E=w-a.y:x>a.y+g&&(E=x-a.y-g),i&&(i>0?E>0&&(E=Math.max(E,i)):0>E&&(E=Math.min(E,i)));var A=S&&"always"===n.scrollPolicy;if(0!==T||0!==E||A){if(S){var L=E>0;0===E&&(E=w-a.y);var k=n.viewAnchor,M=n.selectionAnchor,O=Math.min(Math.max(0,n.viewAnchorOffset||0));E+=Math.floor("top"===k?L?(1-O)*g:-O*g:"bottom"===k?L?O*g:-(1-O)*g:"center"===k?L?g/2+O*g:g/2-(1-O)*g:L?O*g:-O*g),h!==u&&("top"===M&&l!==d?E+=Math.floor(-b):"bottom"===M&&l!==c?E+=Math.floor(b):"center"===M&&(E+=Math.floor(b/2))) }else 0!==E&&"number"==typeof n&&(0>n&&(n=0),n>1&&(n=1),E+=Math.floor(E>0?n*g:-n*g));return this._scrollViewAnimated(T,E,t),g!==this._getClientHeight()||p!==this._getClientWidth()?this._showCaret():this._ensureCaretVisible=!0,!0}return t&&t(),!1}},_startIME:function(){if(-1===this._imeOffset){for(var e=!1,t=this._getSelections(),n=0;n<t.length&&!e;n++)e=!t[n].isEmpty();e&&this._modifyContent({text:"",selection:t},!0),this._imeOffset=t[0].start}},_unhookEvents:function(){this._model.removeEventListener("preChanging",this._modelListener.onChanging),this._model.removeEventListener("postChanged",this._modelListener.onChanged),this._theme.removeEventListener("ThemeChanged",this._themeListener.onChanged),this._modelListener=null;for(var e=0;e<this._handlers.length;e++){var t=this._handlers[e];T(t.target,t.type,t.handler)}this._handlers=null,this._mutationObserver&&this._mutationObserver.disconnect()},_updateDOMSelection:function(){if(!(this._redrawCount>0)&&!this._ignoreDOMSelection&&-1===this._imeOffset&&this._clientDiv){var e,t=this._getSelections(),n=this._domSelection;if(n.length<t.length)for(e=n.length;e<t.length;e++)n.push(new C(this));else n.length>t.length&&n.splice(t.length).forEach(function(e){e.destroy()});for(e=0;e<n.length;e++)n[e].setPrimary(0===e),n[e].setSelection(t[e]);var i=this._getWindow(),r=this;n.length>1?this._cursorTimer||(this._cursorTimer=i.setInterval(function(){r._cursorVisible=!r._cursorVisible,r._domSelection.forEach(function(e){e.update()})},500)):this._cursorTimer&&(i.clearInterval(this._cursorTimer),this._cursorTimer=null)}},_update:function(e){if(!(this._redrawCount>0)){if(this._updateTimer){var t=this._getWindow();t.clearTimeout(this._updateTimer),this._updateTimer=null,e=!1}var n=this._clientDiv,i=this._viewDiv;if(n){this._metrics.invalid&&(this._ignoreQueueUpdate=!0,this._updateStyle(),this._ignoreQueueUpdate=!1);var r=this._model,o=this._getScroll(!1),a=this._getViewPadding(),l=r.getLineCount(),d=this._getLineHeight(),c=!1,h=!1,u=!1,f=this._metrics.scrollWidth;this._wrapMode&&(n.style.width=(this._metrics.wrapWidth||this._getClientWidth())+"px");var p,g,v,m,_,y,C,w,b,S,T,E=0,A=0;if(this._lineHeight){for(;l>A&&(T=this._getLineHeight(A),!(E+T>o.y));)E+=T,A++;p=A,g=Math.max(0,p-1),m=v=o.y-E,p>0&&(v+=this._getLineHeight(p-1))}else{var L=Math.max(0,o.y)/d;p=Math.floor(L),g=Math.max(0,p-1),v=Math.round((L-g)*d),m=Math.round((L-p)*d),S=l*d}this._topIndexY=m;var k=this._rootDiv,M=k.clientWidth,O=k.clientHeight;if(e){for(_=0,this._leftDiv&&(y=this._leftDiv.getBoundingClientRect(),_=y.right-y.left),C=this._getClientWidth(),w=this._getClientHeight(),b=C,this._wrapMode?this._metrics.wrapWidth&&(b=this._metrics.wrapWidth):b=Math.max(this._maxLineWidth,b);l>A;)T=this._getLineHeight(A,!1),E+=T,A++;S=E}else{w=this._getClientHeight();for(var D,N,I=Math.floor((w+m)/d),R=Math.min(p+I,l-1),B=Math.min(R+1,l-1),P=n.firstChild;P;){D=P.lineIndex;var F=P.nextSibling;D>=g&&B>=D&&!P.lineRemoved&&-1!==P.lineIndex||(this._mouseWheelLine===P?(P.style.display="none",P.lineIndex=-1):n.removeChild(P)),P=F}P=this._getLineNext();var V=i.ownerDocument,U=V.createDocumentFragment();for(D=g;B>=D;D++)!P||P.lineIndex>D?new x(this,D).create(U,null,!0):(U.firstChild&&(n.insertBefore(U,P),U=V.createDocumentFragment()),P&&P.lineChanged&&(P=new x(this,D).create(U,P,!0),P.lineChanged=!1),P=this._getLineNext(P));U.firstChild&&n.insertBefore(U,P),s.isWebkit&&!this._wrapMode&&(n.style.width="0x7fffffffpx");var K;P=this._getLineNext();for(var W=w+v,H=!1;P;){if(N=P.lineWidth,void 0===N){K=P._line.getBoundingClientRect(),N=P.lineWidth=Math.ceil(K.right-K.left);var j=K.bottom-K.top;this._lineHeight?this._lineHeight[P.lineIndex]=j:0!==d&&0!==j&&Math.ceil(d)!==Math.ceil(j)&&(this._variableLineHeight=!0,this._lineHeight=[],this._lineHeight[P.lineIndex]=j)}this._lineHeight&&!H&&(W-=this._lineHeight[P.lineIndex],0>W&&(R=P.lineIndex,H=!0)),this._wrapMode||(N>=this._maxLineWidth&&(this._maxLineWidth=N,this._maxLineIndex=P.lineIndex),this._checkMaxLineIndex===P.lineIndex&&(this._checkMaxLineIndex=-1)),P.lineIndex===p&&(this._topChild=P),P.lineIndex===R&&(this._bottomChild=P),P=this._getLineNext(P)}if(-1!==this._checkMaxLineIndex&&(D=this._checkMaxLineIndex,this._checkMaxLineIndex=-1,D>=0&&l>D)){var G=new x(this,D);K=G.getBoundingClientRect(),N=K.right-K.left,N>=this._maxLineWidth&&(this._maxLineWidth=N,this._maxLineIndex=D),G.destroy()}for(;l>A;)T=this._getLineHeight(A,R>=A),E+=T,A++;S=E,this._updateRuler(this._leftDiv,p,B,O),this._updateRuler(this._rightDiv,p,B,O),this._updateRuler(this._innerRightDiv,p,B,O),this._updateRuler(this._marginDiv,p,B,O),_=0,this._leftDiv&&(y=this._leftDiv.getBoundingClientRect(),_=y.right-y.left);var z=0;if(this._rightDiv){var $=this._rightDiv.getBoundingClientRect();z=$.right-$.left}i.style.left=_+"px",i.style.right=z+"px";var Y=this._scrollDiv;if(Y.style.height=S+(s.isWebkit?0:a.bottom)+"px",C=this._getClientWidth(),!this._singleMode&&!this._wrapMode&&!this._noScroll){var q=w,X=w,J="scroll"===i.style.overflowX;J?q+=f:X-=f;var Z=C,Q=C,et="scroll"===i.style.overflowY;et?Z+=f:Q-=f,w=q,C=Z,S>w&&(u=!0,C=Q),this._maxLineWidth>C&&(h=!0,w=X,S>w&&(u=!0,C=Q)),J!==h&&(i.style.overflowX=h?"scroll":"hidden"),et!==u&&(i.style.overflowY=u?"scroll":"hidden"),c=J!==h||et!==u}var tt=C;this._wrapMode?this._metrics.wrapWidth&&(tt=this._metrics.wrapWidth):tt=Math.max(this._maxLineWidth+this._getInnerRightWidth(),tt),b=tt,(!s.isIE||s.isIE>=9)&&this._maxLineWidth>C&&(tt+=a.right+a.left),Y.style.width=tt+"px",this._clipScrollDiv&&(this._clipScrollDiv.style.width=tt+"px"),o=this._getScroll(!1);var nt=this._innerRightDiv;nt&&(nt.style.right=z+("scroll"===i.style.overflowY?this._metrics.scrollWidth:0)+"px",nt.style.bottom=("scroll"===i.style.overflowX?f:0)+"px")}if(this._scrollHeight=S,this._vScrollDiv){var it=w-8,rt=Math.max(15,Math.ceil(Math.min(1,it/(S+a.top+a.bottom))*it));this._vScrollDiv.style.left=_+C-8+"px",this._vScrollDiv.style.top=Math.floor(Math.max(0,o.y*it/S))+"px",this._vScrollDiv.style.height=rt+"px"}if(!this._wrapMode&&this._hScrollDiv){var ot=C-8,st=Math.max(15,Math.ceil(Math.min(1,ot/(this._maxLineWidth+a.left+a.right))*ot));this._hScrollDiv.style.left=_+Math.floor(Math.max(0,Math.floor(o.x*ot/this._maxLineWidth)))+"px",this._hScrollDiv.style.top=w-9+"px",this._hScrollDiv.style.width=st+"px"}var at,lt,dt=o.x,ct=this._clipDiv,ht=this._overlayDiv,ut=this._marginDiv;if(ut&&(ut.style.left=-dt+_+this._metrics.marginWidth+a.left+"px",ut.style.bottom=("scroll"===i.style.overflowX?f:0)+"px"),ct){ct.scrollLeft=dt,ct.scrollTop=0,at=_+a.left,lt=a.top;var ft=C,pt=w,gt=0,vt=-v;0===o.x&&(at-=a.left,ft+=a.left,gt=a.left),o.x+C===b&&(ft+=a.right),0===o.y&&(lt-=a.top,pt+=a.top,vt+=a.top),o.y+w===S&&(pt+=a.bottom),ct.style.left=at+"px",ct.style.top=lt+"px",ct.style.right=M-ft-at+"px",ct.style.bottom=O-pt-lt+"px",n.style.left=gt+"px",n.style.top=vt+"px",n.style.width=b+"px",n.style.height=w+v+"px",ht&&(ht.style.left=n.style.left,ht.style.top=n.style.top,ht.style.width=n.style.width,ht.style.height=n.style.height)}else{at=dt,lt=v;var mt=dt+C,_t=v+w;0===at&&(at-=a.left),0===lt&&(lt-=a.top),mt===b&&(mt+=a.right),o.y+w===S&&(_t+=a.bottom),n.style.clip="rect("+lt+"px,"+mt+"px,"+_t+"px,"+at+"px)","rtl"==document.dir?n.style.right=-dt+_+a.left+"px":n.style.left=-dt+_+a.left+"px",n.style.width=(this._wrapMode||s.isWebkit?b:C+dt)+"px",e||(n.style.top=-v+a.top+"px",n.style.height=w+v+"px"),ht&&(ht.style.clip=n.style.clip,ht.style.left=n.style.left,ht.style.width=n.style.width,e||(ht.style.top=n.style.top,ht.style.height=n.style.height))}if(this._updateDOMSelection(),c){var yt=this._ensureCaretVisible;this._ensureCaretVisible=!1,yt&&this._showCaret(),this._queueUpdate()}}}},_updateOverflow:function(){var e=this._viewDiv;this._noScroll?e.style.overflow="hidden":this._wrapMode?(e.style.overflowX="hidden",e.style.overflowY="scroll"):e.style.overflow="hidden"},_updateRuler:function(e,t,n,i){if(e)for(var r=this._parent.ownerDocument,o=this._getLineHeight(),a=this._getViewPadding(),l=e.firstChild;l;){var d=l._ruler,c=d.getOverview();if(l.rulerChanged&&(h(d.getRulerStyle(),l),e.rulerWidth=void 0),"fixed"!==c){var u=o;"page"===c&&(u+=this._topIndexY),l.style.top=-u+"px",l.style.height=i+u+"px";var f,p=l.firstChild;p?(f=p,p=p.nextSibling):(f=s.createElement(r,"div"),f.style.visibility="hidden",l.appendChild(f));var g,v;l.rulerChanged&&f&&(g=-1,v=d.getWidestAnnotation(),v&&(h(v.style,f),v.html&&(f.innerHTML=v.html)),f.lineIndex=g,f.style.height=o+a.top+"px");var m,_,y;if("page"===c){for(y=d.getAnnotations(t,n+1);p;){g=p.lineIndex;var C=p.nextSibling;g>=t&&n>=g&&!p.lineChanged||l.removeChild(p),p=C}for(p=l.firstChild.nextSibling,_=r.createDocumentFragment(),g=t;n>=g;g++)!p||p.lineIndex>g?(m=s.createElement(r,"div"),v=y[g],v&&(h(v.style,m),v.html&&(m.innerHTML=v.html),m.annotation=v),m.lineIndex=g,m.style.height=this._getLineHeight(g)+"px",_.appendChild(m)):(_.firstChild&&(l.insertBefore(_,p),_=r.createDocumentFragment()),p&&(p=p.nextSibling));_.firstChild&&l.insertBefore(_,p)}else{var w,x,b=this._getClientHeight(),S=this._model.getLineCount(),T=o*S,E=b+a.top+a.bottom-2*this._metrics.scrollWidth;if(E>T?(w=o,x=a.top):(w=E/S,x=this._metrics.scrollWidth),l.rulerChanged){for(var A=l.childNodes.length;A>1;)l.removeChild(l.lastChild),A--;y=d.getAnnotations(0,S),_=r.createDocumentFragment();for(var L in y)g=L>>>0,0>g||(m=s.createElement(r,"div"),v=y[L],h(v.style,m),m.style.position="absolute",m.style.top=x+o+Math.floor(g*w)+"px",v.html&&(m.innerHTML=v.html),m.annotation=v,m.lineIndex=g,_.appendChild(m));l.appendChild(_)}else if(l._oldTrackHeight!==E)for(m=l.firstChild?l.firstChild.nextSibling:null;m;)m.style.top=this._metrics.scrollWidth+o+Math.floor(m.lineIndex*w)+"px",m=m.nextSibling;l._oldTrackHeight=E}l.rulerChanged=!1,l=l.nextSibling}else l.rulerChanged=!1,l=l.nextSibling}},_updateStyleSheet:function(){var e="";if(s.isWebkit&&this._metrics.scrollWidth>0&&(e+="\n.textview ::-webkit-scrollbar-corner {background: #eeeeee;}"),e){var t=this._clientDiv.ownerDocument,n=t.getElementById("_textviewStyle");if(n)n.removeChild(n.firstChild),n.appendChild(t.createTextNode(e));else{n=s.createElement(t,"style"),n.id="_textviewStyle";var i=t.getElementsByTagName("head")[0]||t.documentElement;n.appendChild(t.createTextNode(e)),i.insertBefore(n,i.firstChild)}}},_updateStyle:function(e,t){if(!e&&s.isIE&&(this._rootDiv.style.lineHeight="normal"),t=this._metrics=t||this._calculateMetrics(),this._variableLineHeight&&(this._variableLineHeight=!1,this._resetLineHeight()),this._rootDiv.style.lineHeight=s.isIE?t.lineHeight-(t.lineTrim.top+t.lineTrim.bottom)+"px":"normal",this._updateStyleSheet(),s.isMac&&s.isWebkit){var n=this._viewDiv;t.invalid||0!==t.scrollWidth?(n.style.pointerEvents="",n.style.zIndex=""):(n.style.pointerEvents="none",n.style.zIndex="2")}e||(this.redraw(),this._resetLineWidth())}},i.EventTarget.addMixin(b.prototype),{TextView:b}}),n("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(e,t,n,i,r,o,s){function a(e,t){this._view=e,this._editor=t;var n=e.getOptions("parent");this._create(n?n.ownerDocument:document)}return a.getTooltip=function(e,t){return e._tooltip||(e._tooltip=new a(e,t)),e._tooltip},a.prototype={_create:function(e){if(!this._tooltipDiv){var t=this._tooltipDiv=s.createElement(e,"div");t.tabIndex=0,t.className="textviewTooltip",t.setAttribute("aria-live","assertive"),t.setAttribute("aria-atomic","true"),this._tooltipDiv.style.visibility="hidden",this._tipShowing=!1,e.body.appendChild(t),o.trapTabs(this._tooltipDiv);var n=this;r.addEventListener(e,"mousedown",this._mouseDownHandler=function(e){n.isVisible()&&(r.contains(t,e.target||e.srcElement)||n._locked||n.hide())},!0),r.addEventListener(e,"scroll",this._scrollHandler=function(e){n.isVisible()&&(r.contains(t,e.target||e.srcElement)||(n._topPixel!==n._view.getTopPixel()||n._leftPixel!==n._view.getHorizontalPixel())&&n.hide())},!0),r.addEventListener(e,"mousemove",this._mouseMoveHandler=function(e){n._prevX&&n._prevX===e.clientX&&n._prevY&&n._prevY===e.clientY||(n._prevX=e.clientX,n._prevY=e.clientY,!n.isVisible()||n._locked||n._hasFocus()||n._isInRect(n._outerArea,e.clientX,e.clientY)||n.hide())},!0),r.addEventListener(t,"focus",function(){n._locked||n._tooltipDiv.classList.add("textViewTooltipOnFocus")},!1),r.addEventListener(t,"blur",function(){n._tooltipDiv.classList.remove("textViewTooltipOnFocus")},!1),r.addEventListener(t,"mouseenter",function(){n._locked||n._tooltipDiv.classList.add("textViewTooltipOnHover")},!1),r.addEventListener(t,"mouseleave",function(){n._hasFocus()||n._tooltipDiv.classList.remove("textViewTooltipOnHover")},!1),r.addEventListener(t,"keydown",function(e){27===e.keyCode&&(n._locked||n.hide())},!1),this._view.addEventListener("Destroy",function(){n.destroy()})}},destroy:function(){if(this._tooltipDiv){this.hide();var e=this._tooltipDiv.parentNode;e&&e.removeChild(this._tooltipDiv);var t=this._tooltipDiv.ownerDocument;r.removeEventListener(t,"mousedown",this._mouseDownHandler,!0),r.removeEventListener(t,"scroll",this._scrollHandler,!0),r.removeEventListener(t,"mousemove",this._mouseMoveHandler,!0),this._tooltipDiv=null}},show:function(e,t,n){this._locked=t,this._giveFocus=n,this._topPixel=this._view.getTopPixel(),this._leftPixel=this._view.getHorizontalPixel(),this._processInfo(e.getTooltipInfo())},update:function(e,t){e&&(t?this._showContents(null,e.getTooltipInfo(),!0):this._processInfo(e.getTooltipInfo(),!0))},onHover:function(e,t,n){e&&(this._isInRect(this._anchorArea,t,n)||this._isInRect(this._tooltipArea,t,n)||this._locked||this._hasFocus()||this._processInfo(e.getTooltipInfo()))},hide:function(e){e&&(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(e){e.resolved||e.cancel()}),this._hoverPromises=void 0,this._tipRect=void 0)},isVisible:function(){return this._tipShowing},_processInfo:function(e,t){if(this._tooltipDiv){var n;if(t&&this._tooltipContents?(this._tooltipContents.innerHTML="",n=this._tooltipContents):n=s.createElement(this._tooltipDiv.ownerDocument,"div"),e){if(e.contents&&this._renderImmediateInfo(n,e.contents,e.context))return this._showContents(n,e,t),!0;if(this.hover&&e.context&&(this._hoverPromises=this.hover.computeHoverInfo(e.context),this._hoverPromises)){var r=this,o=this._hoverPromises.slice(0);return o.forEach(function(o){i.when(o,function(i){if(r._hoverPromises){var s=r._hoverPromises.indexOf(o);s>=0&&r._hoverPromises.splice(s,1)}i&&r._renderPluginContent(n,i)&&(i.offsetStart&&(e.context.offsetStart=i.offsetStart),i.offsetEnd&&(e.context.offsetEnd=i.offsetEnd),i.allowFullWidth&&(e.allowFullWidth=i.allowFullWidth),r._showContents(n,e,t))},function(e){console&&e&&"Cancel"!==e.name&&(console.log("Error computing hover tooltip"),console.log(e&&e.stack))})}),!0}}}},_showContents:function(e,t,n){n?this._tooltipArea&&t.tooltipArea&&(this._tooltipArea.left!==t.tooltipArea.left||this._tooltipArea.top!==t.tooltipArea.top||this._tooltipArea.width!==t.tooltipArea.width||this._tooltipArea.height!==t.tooltipArea.height)&&(this._anchorArea=null,this._tooltipArea=null,this._outerArea=null):this.hide(),e&&(this._tooltipContents&&this._tooltipDiv.removeChild(this._tooltipContents),this._tooltipContents=e,this._tooltipDiv.appendChild(e)),this._anchorArea||(this._anchorArea=this._computeAnchorArea(t)),this._tooltipArea||(this._tooltipArea=this._computeTooltipArea(t,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(e){if(e.anchorArea&&e.anchorArea.top&&e.anchorArea.left&&e.anchorArea.height&&e.anchorArea.width)return e.anchorArea;if(e.context){if(e.context.offsetStart&&e.context.offsetEnd){var t=this.mapOffset(e.context.offsetStart,!1),n=this.mapOffset(e.context.offsetEnd,!1);return this._computeRectangleFromOffset(t,n)}if(e.context.offset>=0){var i=this.mapOffset(e.context.offset,!1),r=this._view.getNextOffset(i,{unit:"wordend",count:0}),o=this._view.getNextOffset(r,{unit:"word",count:-1});return this._computeRectangleFromOffset(o,r)}}return{top:0,left:0,height:0,width:0}},_computeTooltipArea:function(e,t,n){var i=n.ownerDocument.documentElement,r=16;if(e.tooltipArea&&e.tooltipArea.top&&e.tooltipArea.left&&e.tooltipArea.height&&e.tooltipArea.width)return n.style.overflowY="auto",n.style.resize="none",n.style.top=e.tooltipArea.top+"px",n.style.left=e.tooltipArea.left+"px",n.style.height=e.tooltipArea.height-r+"px",n.style.width=e.tooltipArea.width-r+"px",e.tooltipArea;var o=n.getBoundingClientRect(),s={width:o.width,height:o.height},a=n.getElementsByTagName("img")[0];a&&!a.complete&&0===a.width&&(s.width+=30);var l=e.position?e.position:"below",d=(this._view._rootDiv?this._view._rootDiv:i).getBoundingClientRect(),c=d.left,h=d.top,u=d.width,f=d.height,p=u,g=f;if(e.allowFullWidth?s.width>u&&(s.width=u):(p=Math.min(u/2,600),g=Math.min(f/2,400),s.width=Math.min(s.width,p),s.height=Math.min(s.height,g)),n.style.width=s.width-r+"px",s.height=Math.min(n.clientHeight,g),n.clientHeight>g){var v=this._tooltipContents.offsetWidth;n.style.overflowY="scroll";var m=v-this._tooltipContents.offsetWidth;m>0&&(s.width+=m,s.width>u&&(s.width=u)),n.style.overflowY=null}25+r>s.height&&s.width>p-r&&(s.height=40+r);var _=f-(t.top+t.height-h),y=t.top-h,C=u-(t.left+t.width-c);"above"===l&&s.height>y&&s.height<=_?l="below":"below"===l&&s.height>_&&s.height<=y&&(l="above");var w=e.tooltipOffsetX?e.tooltipOffsetX:0,x=e.tooltipOffsetY?e.tooltipOffsetY:0;switch(l){case"left":s.top=s.height+x>_+t.height?f+h-s.height:t.top+x,s.top=Math.max(s.top,h),s.left=Math.max(t.left-s.width+w,c);break;case"right":s.top=s.height+x>_+t.height?f+h-s.height:t.top+x,s.top=Math.max(s.top,h),s.left=Math.max(t.left+t.width+w,c);break;case"above":s.left=s.width+w>C+t.width?u+c-s.width:t.left+w,s.left=Math.max(s.left,c),s.top=Math.max(t.top-s.height+x,h);break;case"below":s.left=s.width+w>C+t.width?u+c-s.width:t.left+w,s.left=Math.max(s.left,c),s.top=Math.max(t.top+t.height+x,h)}return s.maxWidth=Math.min(u+c-s.left,u),s.maxHeight=Math.min(f+h-s.top,f),n.style.maxWidth=s.maxWidth-r+"px",n.style.maxHeight=s.maxHeight-r+"px",n.style.width=s.width-r+"px",n.style.height=s.height-r+"px",n.style.left=s.left+"px",n.style.top=s.top+"px",s},_computeOuterArea:function(e,t){var n=Math.min(e.left,t.left),i=Math.min(e.top,t.top),r=e.left+e.width,o=t.left+t.width,s=Math.max(r,o),a=e.top+e.height,l=t.top+t.height,d=Math.max(a,l);return{left:n,top:i,width:s-n,height:d-i}},_hasFocus:function(){var e=this._tooltipDiv;return e?r.contains(e,e.ownerDocument.activeElement):!1},_isNode:function(e){return"object"==typeof Node?e instanceof Node:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},_setInitialFocus:function(e){var t=o.$("button",e);if(t)return void t.focus();var n=o.$("a",e);if(n){n.focus();var i=this;return void n.addEventListener("click",function(){i.hide()})}var r=o.firstTabbable(e);r&&r.focus()},_isInRect:function(e,t,n){if(!e)return!1;var i=t>=e.left&&t<=e.left+e.width,r=n>=e.top&&n<=e.top+e.height;return i&&r},mapOffset:function(e){var t=this._view,n=t.getModel();return n.getBaseModel&&(e=n.mapOffset(e,!0)),e},_computeRectangleFromOffset:function(e,t){var n,i,r=this._view,o=r.getLineAtOffset(e),s=r.getLineAtOffset(t);if(o!==s){var a=r.getLocationAtOffset(e).y;n=0;for(var l=0;s>=o;){n+=r.getLineHeight(o);var d=r.getModel().getLineEnd(o),c=r.getLocationAtOffset(d).x;c>t&&(l=c),o++}var h=r.getModel().getLineStart(s),u=r.getLocationAtOffset(h).x;i={x:u,y:a,width:l-u,height:n}}else{var f=r.getLocationAtOffset(e),p=r.getLocationAtOffset(t);n=r.getLineHeight(o),i={x:f.x,y:f.y,width:p.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(e,t){var n=this._tooltipDiv.ownerDocument;if("string"!=typeof t&&"undefined"==typeof t.content)return!1;var i=s.createElement(n,"div");if(t.title&&!t.hiddenTitle){var r=s.createElement(n,"div");this.hover.renderMarkDown?r.innerHTML=this.hover.renderMarkDown(t.title):r.textContent=t.title,r.classList.add("hoverTooltipTitle"),i.appendChild(r)}var o=s.createElement(n,"div");if("string"==typeof t)o.appendChild(n.createTextNode(t));else switch(t.type){case"delegatedUI":case"html":if(t.content){var a=n.createElement("iframe");a.id="HtmlHover",a.name="HTML Hover",a.type="text/html",a.title=t.title||"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=t.content,t.width&&(a.style.width=t.width),t.height&&(a.style.height=t.height),i.style.height="100%",e.style.height="100%",i.appendChild(a)}break;case"markdown":this.hover.renderMarkDown&&(o.innerHTML=this.hover.renderMarkDown(t.content));break;default:o.appendChild(n.createTextNode(t.content))}return i.appendChild(o),e.appendChild(i),!0},_renderImmediateInfo:function(e,i,r){if(i instanceof Array&&(i=this._getAnnotationContents(i,r),!i))return!1;if("string"==typeof i)return e.textContent=i,!0;if(this._isNode(i))return e.appendChild(i),!0;if(i instanceof n.ProjectionTextModel){var o=this._view,s=o.getOptions();s.wrapMode=!1,s.parent=e;var a="tooltipTheme",l=s.themeClass;l?(l=l.replace(a,""),l&&(l=" "+l),l=a+l):l=a,s.themeClass=l;var d=this._contentsView=new t.TextView(s),c={onLineStyle:function(e){o.onLineStyle(e)}};d.addEventListener("LineStyle",c.onLineStyle),d.setModel(i),this._tooltipDiv.appendChild(e),this._tooltipDiv.classList.add("textviewTooltipCodeProjection");var h=d.computeSize();return e.style.width=h.width+16+"px",e.style.height=h.height+16+"px",d.resize(),this._tooltipDiv.removeChild(e),!0}return!1},_getAnnotationContents:function(t,i){function o(e,t,n){var o=e.title,l=s.createElement(f,"div");if(l.className="tooltipRow",e.html){var d=s.createElement(f,"div");d.className="tooltipImage",d.innerHTML=e.html,d.lastChild&&r.addEventListener(d.lastChild,"click",function(){var t=e.start,n=e.end;g.getBaseModel&&(t=g.mapOffset(t,!0),n=g.mapOffset(n,!0));var i={type:"AnnotationClicked",target:a,targetType:"Tooltip",annotation:e,selection:{start:t,end:n,viewportOffset:1/3}};p.dispatchEvent(i),i.selection&&p.setSelection(i.selection.start,i.selection.end,i.selection.viewportOffset,function(){a.hide()})},!1),l.appendChild(d)}if(!o){var c=v.getLineStart(v.getLineAtOffset(e.start)),h=v.getLineEnd(v.getLineAtOffset(e.end),!0);o=v.getText(c,h)}if("function"==typeof o&&(o=e.title()),"string"==typeof o){var u=s.createElement(f,"span");u.className="tooltipTitle",u.appendChild(f.createTextNode(o)),o=u}return l.appendChild(o),n&&a.hover.renderQuickFixes(e,t,l,function(){a.hide(!0)}),i&&(i.offsetStart=e.start,i.offsetEnd=e.end),l}var a=this,l=a.hover?!0:!1;l&&i&&i.source&&i.source.indexOf("ruler")>=0&&t.length>1&&(l=!1);for(var d,c=[],h=0;h<t.length;h++)d=t[h],""===d.title||d.groupAnnotation||(!l||d.title||"orion.annotation.folding"===d.type)&&c.push(d);if(t=c,0===t.length)return null;var u,f=this._tooltipDiv.ownerDocument,p=this._view,g=p.getModel(),v=g.getBaseModel?g.getBaseModel():g;if(1===t.length&&"orion.annotation.folding"===t[0].type){var m=new n.ProjectionTextModel(v),_=v.getLineStart(v.getLineAtOffset(t[0].start)),y=v.getCharCount();return t[0].end!==y&&m.addProjection({start:t[0].end,end:y}),_>0&&m.addProjection({start:0,end:_}),m}var C;if(t.length>0&&this._editor&&(C=this._editor.getAnnotationModel().getAnnotations()),1===t.length){if(u=o(t[0],C,l),u&&u.firstChild){var w=u.firstChild.className;w&&(w+=" "),w+="single",u.firstChild.className=w}return u}var x=s.createElement(f,"div"),b=s.createElement(f,"multi_anno");b.appendChild(f.createTextNode(e.multipleAnnotations)),x.appendChild(b);for(var S=0;S<t.length;S++)u=o(t[S],C,l),u&&x.appendChild(u);return x}},{Tooltip:a}}),n("orion/editor/editor",["i18n!orion/editor/nls/messages","orion/editor/eventTarget","orion/editor/tooltip","orion/editor/annotations","orion/objects","orion/editor/util","orion/util"],function(e,t,n,i,r,o,s){function a(e){e=e||{},this._domNode=e.domNode,this._model=e.model,this._undoStack=e.undoStack,this._statusReporter=e.statusReporter,this._title=null;var t=this;this._listener={onChanged:function(e){t.onChanged(e)}},this._model&&this._model.addEventListener("Changed",this._listener.onChanged),this.checkDirty()}function l(e){e=e||{},a.call(this,e),this._textViewFactory=e.textViewFactory,this._undoStackFactory=e.undoStackFactory,this._textDNDFactory=e.textDNDFactory,this._annotationFactory=e.annotationFactory,this._zoomRulerFactory=e.zoomRulerFactory,this._foldingRulerFactory=e.foldingRulerFactory,this._lineNumberRulerFactory=e.lineNumberRulerFactory,this._contentAssistFactory=e.contentAssistFactory,this._keyBindingFactory=e.keyBindingFactory,this._hoverFactory=e.hoverFactory,this._syntaxHighlighter=e.syntaxHighlighter,this._annotationStyler=null,this._annotationModel=null,this._annotationRuler=null,this._lineNumberRuler=null,this._overviewRuler=null,this._zoomRuler=null,this._foldingRuler=null,this._contentAssist=null}var d=i.AnnotationType,c="orion.annotation.highlightError";return a.prototype={destroy:function(){this.uninstall(),this._statusReporter=this._domNode=null,this._model&&this._model.removeEventListener("Changed",this._listener.onChanged)},checkDirty:function(){this.setDirty(this._undoStack&&!this._undoStack.isClean())},focus:function(){},getModel:function(){return this._model},getText:function(e,t){return this.getModel().getText(e,t)},getTitle:function(){return this._title},getUndoStack:function(){return this._undoStack},install:function(){this.installed=!0},isDirty:function(){return this._undoStack?!this._undoStack.isClean():this._dirty},markClean:function(){this.getUndoStack().markClean(),this.setDirty(!1)},onDirtyChanged:function(e){return this.dispatchEvent(e)},onInputChanged:function(e){return this.dispatchEvent(e)},onChanged:function(){this.checkDirty()},reportStatus:function(e,t,n){this._statusReporter&&this._statusReporter(e,t,n)},resize:function(){},setDirty:function(e){this._setSyntaxCheckRequired(e),this._dirty!==e&&(this._dirty=e,this.onDirtyChanged({type:"DirtyChanged"}))},_setSyntaxCheckRequired:function(e){this._syntaxCheckRequired=e},_isSyntaxCheckRequired:function(){return this._syntaxCheckRequired},_setModelText:function(e){this._model&&this._model.setText(e)},setInput:function(e,t,n,i){this._title=e,i||(t?this.reportStatus(t,"error"):null!==n&&void 0!==n&&("string"==typeof n&&this._setModelText(n),this._undoStack&&this._undoStack.reset())),this.checkDirty(),this.onInputChanged({type:"InputChanged",title:e,message:t,contents:n,contentsSaved:i})},setText:function(e,t,n){this.getModel().setText(e,t,n)},uninstall:function(){this.installed=!1}},t.EventTarget.addMixin(a.prototype),l.prototype=new a,r.mixin(l.prototype,{destroy:function(){a.prototype.destroy.call(this),this._textViewFactory=this._undoStackFactory=this._textDNDFactory=this._annotationFactory=this._foldingRulerFactory=this._lineNumberRulerFactory=this._contentAssistFactory=this._keyBindingFactory=this._hoverFactory=this._zoomRulerFactory=null},getAnnotationModel:function(){return this._annotationModel},getAnnotationRuler:function(){return this._annotationRuler},getAnnotationRulerVisible:function(){return this._annotationRulerVisible},getAnnotationStyler:function(){return this._annotationStyler},getContentAssist:function(){return this._contentAssist},getFoldingRuler:function(){return this._foldingRuler},getFoldingRulerVisible:function(){return this._foldingRulerVisible},addFoldingAnnotation:function(e,t){var n=this.getAnnotationModel();if(n){var r=new i.FoldingAnnotation(e,t,this.getTextView().getModel());return n.addAnnotation(r),r}return null},getLineNumberRuler:function(){return this._lineNumberRuler},getLineNumberRulerVisible:function(){return this._lineNumberRulerVisible},getTooltip:function(){return n.Tooltip.getTooltip(this._textView,this)},getZoomRuler:function(){return this._zoomRuler},getZoomRulerVisible:function(){return this._zoomRulerVisible},getModel:function(){if(!this._textView)return null;var e=this._textView.getModel();return e.getBaseModel&&(e=e.getBaseModel()),e},getOverviewRuler:function(){return this._overviewRuler},getTextView:function(){return this._textView},getKeyModes:function(){return this._textView.getKeyModes()},getSourceCodeActions:function(){return this._sourceCodeActions},getLinkedMode:function(){return this._linkedMode},getTextActions:function(){return this._textActions},focus:function(){this._textView&&this._textView.focus()},resize:function(){this._textView&&this._textView.resize()},setAnnotationRulerVisible:function(e,t){if((this._annotationRulerVisible!==e||t)&&(this._annotationRulerVisible=e,this._annotationRuler)){var n=this._textView;e?n.addRuler(this._annotationRuler,0):n.removeRuler(this._annotationRuler)}},setFoldingRulerVisible:function(e,t){if(this._foldingRulerVisible!==e||t){if(!e){var n=this.getTextActions();n&&n.expandAnnotations(!0)}if(this._foldingRulerVisible=e,this._foldingRuler){var i=this._textView;i.getModel().getBaseModel&&(e?i.addRuler(this._foldingRuler):i.removeRuler(this._foldingRuler))}}},setLineNumberRulerVisible:function(e,t){if((this._lineNumberRulerVisible!==e||t)&&(this._lineNumberRulerVisible=e,this._lineNumberRuler)){var n=this._textView;e?n.addRuler(this._lineNumberRuler,this._annotationRulerVisible?1:0):n.removeRuler(this._lineNumberRuler)}},setOverviewRulerVisible:function(e,t){if((this._overviewRulerVisible!==e||t)&&(this._overviewRulerVisible=e,this._overviewRuler)){var n=this._textView;e?n.addRuler(this._overviewRuler):n.removeRuler(this._overviewRuler)}},setZoomRulerVisible:function(e,t){if((this._zoomRulerVisible!==e||t)&&(this._zoomRulerVisible=e,this._zoomRuler)){var n=this._textView;e?n.addRuler(this._zoomRuler):n.removeRuler(this._zoomRuler)}},setAnnotationTypesVisible:function(e){o.compare(this._annotationTypesVisible,e)||(this._annotationTypesVisible=e,this._annotationRuler&&this._textView&&this._annotationRulerVisible&&(this._annotationRuler.setAnnotationTypeVisible(e),this._textView.redrawLines(0,void 0,this._annotationRuler)))},setOverviewAnnotationTypesVisible:function(e){o.compare(this._overviewAnnotationTypesVisible,e)||(this._overviewAnnotationTypesVisible=e,this._overviewRuler&&this._textView&&this._overviewRulerVisible&&(this._overviewRuler.setAnnotationTypeVisible(e),this._textView.redrawLines(0,void 0,this._overviewRuler)))},setTextAnnotationTypesVisible:function(e){o.compare(this._textAnnotationTypesVisible,e)||(this._textAnnotationTypesVisible=e,this._annotationStyler&&this._textView&&(this._annotationStyler.setAnnotationTypeVisible(e),this._textView.redrawLines(0,void 0)))},mapOffset:function(e,t){var n=this._textView,i=n.getModel();return i.getBaseModel&&(e=i.mapOffset(e,t)),e},getLineAtOffset:function(e){return this.getModel().getLineAtOffset(this.mapOffset(e)) },getLineStart:function(e){return this.getModel().getLineStart(e)},getCaretOffset:function(){return this.mapOffset(this._textView.getCaretOffset())},getSelectionText:function(e){var t=this._textView;return t.getSelectionText(e)},getSelection:function(){var e=this._textView,t=e.getSelection(),n=e.getModel();return n.getBaseModel&&(t.start=n.mapOffset(t.start),t.end=n.mapOffset(t.end)),t},getSelections:function(){var e=this._textView,t=e.getModel(),n=e.getSelections();return n.forEach(function(e){t.getBaseModel&&(e.start=t.mapOffset(e.start),e.end=t.mapOffset(e.end))}),n},getStyleAccessor:function(){var e=null;if(this._syntaxHighlighter){var t=this._syntaxHighlighter.getStyler();t&&t.getStyleAccessor&&(e=t.getStyleAccessor())}return e},_expandOffset:function(e){var t=this._textView.getModel(),n=this._annotationModel;if(n&&t.getBaseModel)for(var i=n.getAnnotations(e,e+1);i.hasNext();){var r=i.next();r.type===d.ANNOTATION_FOLDING&&r.expand&&r.expand()}},setCaretOffset:function(e,t,n){var i=this._textView,r=i.getModel();r.getBaseModel&&(this._expandOffset(e),e=r.mapOffset(e,!0)),i.setCaretOffset(e,t,n)},setText:function(e,t,n,i,r){var o=this._textView,s=o.getModel();s.getBaseModel&&(void 0!==t&&(this._expandOffset(t),t=s.mapOffset(t,!0)),void 0!==n&&(this._expandOffset(n),n=s.mapOffset(n,!0))),o.setText(e,t,n,i,r)},setSelection:function(e,t,n,i){var r=this._textView,o=r.getModel();o.getBaseModel&&(this._expandOffset(e),this._expandOffset(t),e=o.mapOffset(e,!0),t=o.mapOffset(t,!0)),r.setSelection(e,t,n,i)},setSelections:function(e,t,n){var i=this,r=this._textView,o=r.getModel();e.forEach(function(e){var t=e.start,n=e.end;o.getBaseModel&&(i._expandOffset(t),i._expandOffset(n),t=o.mapOffset(t,!0),n=o.mapOffset(n,!0)),e.start=t,e.end=n}),r.setSelections(e,t,n)},moveSelection:function(e,t,n,i){t=t||e;var r=this._textView;this.setSelection(e,t,1/3,function(){(void 0===i||i)&&r.focus(),n&&n()})},_getTooltipInfo:function(e,t){var n=this._textView,i=this.getAnnotationModel();if(!i)return null;var r=this._annotationStyler;if(!r)return null;if(!n.isValidTextPosition(e,t))return null;var o=n.getOffsetAtLocation(e,t);if(-1===o)return null;o=this.mapOffset(o);for(var s=r.getAnnotationsByType(i,o,o+1),a=[],l=0;l<s.length;l++)s[l].rangeStyle&&a.push(s[l]);var d={contents:a,position:"below",context:{source:"editor",offset:o}};return d},_highlightCurrentLine:function(e,t){function n(e){var t={};return e&&e.some(function(e){return e&&e.isEmpty()?(t[s.getLineAtOffset(e.start).toString()]=!0,!1):!0})?{}:t}function i(e,t){for(var n in e)if(!t[n])return!0;return!1}var r=this._annotationModel;if(r){var o=this._textView;if(!o.getOptions("singleMode")){t=Array.isArray(t)?t:[t],e=Array.isArray(e)?e:[e];var s=o.getModel(),a=n(t),l=n(e);if(i(a,l)||i(l,a)){var c=this._currentLineAnnotations,h=[];for(var u in l){var f=u>>0,p=s.getLineStart(f),g=s.getLineEnd(f);s.getBaseModel&&(p=s.mapOffset(p),g=s.mapOffset(g));var v=d.ANNOTATION_CURRENT_LINE,m=d.createAnnotation(v,p,g);h.push(m)}this._currentLineAnnotations=h,r.replaceAnnotations(c,h)}}}},installTextView:function(){this.install()},highlightLine:function(e){var t=this.getAnnotationModel(),n=this.getModel();n.getBaseModel&&(n=n.getBaseModel());for(var i=d.ANNOTATION_HIGHLIGHTED_LINE,r=t.getAnnotations(0,n.getCharCount()),o=null;r.hasNext();){var s=r.next();if(s.type===i){o=s;break}}var a=n.getLineStart(e),l=n.getLineEnd(e),c=d.createAnnotation(i,a,l);o?t.replaceAnnotations([o],[c]):t.addAnnotation(c)},unhighlightLine:function(){var e=this.getAnnotationModel(),t=this.getModel();t.getBaseModel&&(t=t.getBaseModel());for(var n=d.ANNOTATION_HIGHLIGHTED_LINE,i=e.getAnnotations(0,t.getCharCount()),r=null;i.hasNext();){var o=i.next();if(o.type===n){r=o;break}}r&&e.removeAnnotation(r)},install:function(){function e(e,t,n){if(void 0!==e&&-1!==e){for(var i=this.getView(),o=i.getModel(),s=this.getAnnotationModel(),a=r.mapOffset(o.getLineStart(e)),l=r.mapOffset(o.getLineEnd(e)),c=s.getAnnotations(a,l),h=null;c.hasNext();){var u=c.next();if(u.type===n){h=u;break}}h?r.dispatchEvent({type:"UserAnnotationModified",added:[],removed:[h]}):(h=d.createAnnotation(n,a,l,r.getText(a,l)),r.dispatchEvent({type:"UserAnnotationModified",added:[h],removed:[]}))}}if(!this._textView){if(this._textView=this._textViewFactory(this),this._undoStackFactory&&(this._undoStack=this._undoStackFactory.createUndoStack(this),this._textView.setOptions({undoStack:this._undoStack}),this.checkDirty()),this._textDNDFactory&&(this._textDND=this._textDNDFactory.createTextDND(this,this._undoStack)),this._contentAssistFactory){var t=this._contentAssistFactory.createContentAssistMode(this);this._contentAssist=t.getContentAssist()}var i=n.Tooltip.getTooltip(this._textView,this);this._hoverFactory&&(this._hover=this._hoverFactory.createHover(this),i.hover=this._hover);var r=this,o=this._textView,s=this;if(this._listener={onModelChanged:function(){s.checkDirty()},onMouseOver:function(e){s._listener.onMouseMove(e)},onMouseDown:function(){s._listener.mouseDown=!0},onMouseUp:function(){s._listener.mouseDown=!1},onMouseMove:function(e){i&&!s._listener.mouseDown&&(e.event.clientX!==s._listener.lastMouseX||e.event.clientY!==s._listener.lastMouseY)&&(s._listener.lastMouseX=e.event.clientX,s._listener.lastMouseY=e.event.clientY,s._hoverTimeout&&(window.clearTimeout(s._hoverTimeout),s._hoverTimeout=null),s._hoverTimeout=window.setTimeout(function(){s._hoverTimeout=null,s._listener&&i.onHover({y:e.y,x:e.x,getTooltipInfo:function(){return s._getTooltipInfo(this.x,this.y)}},e.x,e.y)},175))},onMouseOut:function(){s._hoverTimeout&&(window.clearTimeout(s._hoverTimeout),s._hoverTimeout=null)},onSelection:function(e){i&&i.hide(),s._updateCursorStatus(),s._highlightCurrentLine(e.newValue,e.oldValue)}},o.addEventListener("ModelChanged",this._listener.onModelChanged),o.addEventListener("Selection",this._listener.onSelection),o.addEventListener("MouseOver",this._listener.onMouseOver),o.addEventListener("MouseOut",this._listener.onMouseOut),o.addEventListener("MouseDown",this._listener.onMouseDown),o.addEventListener("MouseUp",this._listener.onMouseUp),o.addEventListener("MouseMove",this._listener.onMouseMove),this._keyBindingFactory){var l;l="function"==typeof this._keyBindingFactory?this._keyBindingFactory(this,this.getKeyModes(),this._undoStack,this._contentAssist):this._keyBindingFactory.createKeyBindings(r,this._undoStack,this._contentAssist),l&&(this._textActions=l.textActions,this._linkedMode=l.linkedMode,this._sourceCodeActions=l.sourceCodeActions)}var h=function(e,t){t.shiftKey?u.call(this,e,t):t.altKey?p.call(this,e,t):f.call(this,e,t)},u=function(t,n){e.call(this,t,n,d.ANNOTATION_BOOKMARK)},f=function(t,n){e.call(this,t,n,d.ANNOTATION_BREAKPOINT)},p=function(t,n){e.call(this,t,n,d.ANNOTATION_CONDITIONAL_BREAKPOINT)};if(this._annotationFactory){var g=o.getModel();if(g.getBaseModel&&(g=g.getBaseModel()),this._annotationModel=this._annotationFactory.createAnnotationModel(g),this._annotationModel){var v=this._annotationStyler=this._annotationFactory.createAnnotationStyler(o,this._annotationModel);v&&(v.addAnnotationType(d.ANNOTATION_CURRENT_SEARCH),v.addAnnotationType(d.ANNOTATION_MATCHING_SEARCH),v.addAnnotationType(d.ANNOTATION_SEARCH_RANGE),v.addAnnotationType(d.ANNOTATION_ERROR),v.addAnnotationType(d.ANNOTATION_WARNING),v.addAnnotationType(d.ANNOTATION_INFO),v.addAnnotationType(d.ANNOTATION_MATCHING_BRACKET),v.addAnnotationType(d.ANNOTATION_CURRENT_BRACKET),v.addAnnotationType(d.ANNOTATION_CURRENT_LINE),v.addAnnotationType(d.ANNOTATION_HIGHLIGHTED_LINE),v.addAnnotationType(d.ANNOTATION_READ_OCCURRENCE),v.addAnnotationType(d.ANNOTATION_WRITE_OCCURRENCE),v.addAnnotationType(d.ANNOTATION_SELECTED_LINKED_GROUP),v.addAnnotationType(d.ANNOTATION_CURRENT_LINKED_GROUP),v.addAnnotationType(d.ANNOTATION_LINKED_GROUP),v.addAnnotationType(c),v.setAnnotationTypeVisible(this._textAnnotationTypesVisible))}var m=this._annotationFactory.createAnnotationRulers(this._annotationModel),_=this._annotationRuler=m.annotationRuler;_&&(_.onDblClick=h,_.setMultiAnnotationOverlay({html:"<div class='annotationHTML overlay'></div>"}),_.addAnnotationType(d.ANNOTATION_ERROR),_.addAnnotationType(d.ANNOTATION_WARNING),_.addAnnotationType(d.ANNOTATION_INFO),_.addAnnotationType(d.ANNOTATION_TASK),_.addAnnotationType(d.ANNOTATION_BOOKMARK),_.addAnnotationType(d.ANNOTATION_BREAKPOINT),_.addAnnotationType(d.ANNOTATION_CONDITIONAL_BREAKPOINT),_.addAnnotationType(d.ANNOTATION_DIFF_ADDED),_.addAnnotationType(d.ANNOTATION_DIFF_DELETED),_.addAnnotationType(d.ANNOTATION_DIFF_MODIFIED),_.setAnnotationTypeVisible(this._annotationTypesVisible)),this.setAnnotationRulerVisible(this._annotationRulerVisible||void 0===this._annotationRulerVisible,!0),_=this._overviewRuler=m.overviewRuler,_&&(_.addAnnotationType(d.ANNOTATION_CURRENT_SEARCH),_.addAnnotationType(d.ANNOTATION_MATCHING_SEARCH),_.addAnnotationType(d.ANNOTATION_READ_OCCURRENCE),_.addAnnotationType(d.ANNOTATION_WRITE_OCCURRENCE),_.addAnnotationType(d.ANNOTATION_CURRENT_BLAME),_.addAnnotationType(d.ANNOTATION_ERROR),_.addAnnotationType(d.ANNOTATION_WARNING),_.addAnnotationType(d.ANNOTATION_INFO),_.addAnnotationType(d.ANNOTATION_TASK),_.addAnnotationType(d.ANNOTATION_BOOKMARK),_.addAnnotationType(d.ANNOTATION_BREAKPOINT),_.addAnnotationType(d.ANNOTATION_CONDITIONAL_BREAKPOINT),_.addAnnotationType(d.ANNOTATION_MATCHING_BRACKET),_.addAnnotationType(d.ANNOTATION_CURRENT_BRACKET),_.addAnnotationType(d.ANNOTATION_CURRENT_LINE),_.addAnnotationType(d.ANNOTATION_DIFF_ADDED),_.addAnnotationType(d.ANNOTATION_DIFF_DELETED),_.addAnnotationType(d.ANNOTATION_DIFF_MODIFIED),_.setAnnotationTypeVisible(this._overviewAnnotationTypesVisible)),this.setOverviewRulerVisible(this._overviewRulerVisible||void 0===this._overviewRulerVisible,!0)}this._zoomRulerFactory&&(this._zoomRuler=this._zoomRulerFactory.createZoomRuler(this._annotationModel),this.setZoomRulerVisible(this._zoomRulerVisible,!0)),this._lineNumberRulerFactory&&(this._lineNumberRuler=this._lineNumberRulerFactory.createLineNumberRuler(this._annotationModel),this._lineNumberRuler.addAnnotationType(d.ANNOTATION_CURRENT_BLAME),this._lineNumberRuler.addAnnotationType(d.ANNOTATION_BLAME),this._lineNumberRuler.addAnnotationType(d.ANNOTATION_DIFF_ADDED),this._lineNumberRuler.addAnnotationType(d.ANNOTATION_DIFF_MODIFIED),this._lineNumberRuler.addAnnotationType(d.ANNOTATION_DIFF_DELETED),this._lineNumberRuler.onDblClick=h,this.setLineNumberRulerVisible(this._lineNumberRulerVisible||void 0===this._lineNumberRulerVisible,!0)),this._foldingRulerFactory&&(this._foldingRuler=this._foldingRulerFactory.createFoldingRuler(this._annotationModel),this._foldingRuler.addAnnotationType(d.ANNOTATION_FOLDING),this.setFoldingRulerVisible(this._foldingRulerVisible||void 0===this._foldingRulerVisible,!0));var y={type:"TextViewInstalled",textView:o};this.dispatchEvent(y),a.prototype.install.call(this)}},uninstallTextView:function(){this.uninstall()},uninstall:function(){var e=this._textView;if(e){e.destroy(),this._annotationModel&&this._annotationModel.setTextModel(null),this._textView=this._undoStack=this._textDND=this._contentAssist=this._listener=this._annotationModel=this._annotationStyler=this._annotationRuler=this._overviewRuler=this._zoomRuler=this._lineNumberRuler=this._foldingRuler=this._currentLineAnnotations=this._title=null,this._dirty=!1,this._foldingRulerVisible=this._overviewRulerVisible=this._zoomRulerVisible=this._lineNumberRulerVisible=this._annotationRulerVisible=void 0;var t={type:"TextViewUninstalled",textView:e};this.dispatchEvent(t),a.prototype.uninstall.call(this)}},_updateCursorStatus:function(){for(var t=this.getKeyModes(),n=0;n<t.length;n++){var i=t[n];if(i.isActive()&&i.isStatusActive&&i.isStatusActive())return}var r,o=this.getModel(),a=this.getSelections();if(a.length>1)r=s.formatMessage(e.multiSelections,a.length);else{var l=a[0].getCaret(),d=o.getLineAtOffset(l),c=o.getLineStart(d),h=l-c;r=localStorage.languageTools?s.formatMessage(e.lineColumnOffset,d+1,h+1,l):s.formatMessage(e.lineColumn,d+1,h+1)}this.reportStatus(r)},showAnnotations:function(e,t,n,i){var r=this._annotationModel;if(r){for(var o,s=[],a=[],l=r.getTextModel(),c=r.getAnnotations();c.hasNext();)o=c.next(),-1!==t.indexOf(o.type)&&o.creatorID===this&&s.push(o);if(e)for(var h=0;h<e.length;h++)if(o=e[h]){if(n)o=n(o);else{var u,f,p,g;o.lineStart&&o.lineEnd?(u=l.getLineStart(o.lineStart),f=l.getLineCount()===o.lineEnd?l.getLineEnd(o.lineEnd-1):l.getLineStart(o.lineEnd)):"number"==typeof o.line?(p=o.line-1,g=l.getLineStart(p),u=g+o.start-1,f=g+o.end-1):o.range?(p=o.range.start.line,g=l.getLineStart(p),u=g+o.range.start.character,p=o.range.end.line,g=l.getLineStart(p),f=g+o.range.end.character):(u=o.start,f=o.end);var v=i(o);if(!v)continue;o=d.createAnnotation(v,u,f,o.description)}o.id=e[h].id,e[h].data&&(o.data=e[h].data),o.creatorID=this,a.push(o)}r.replaceAnnotations(s,a)}},showProblems:function(e){this.showAnnotations(e,[d.ANNOTATION_ERROR,d.ANNOTATION_WARNING,d.ANNOTATION_TASK,d.ANNOTATION_INFO],null,function(e){switch(e.severity){case"error":return d.ANNOTATION_ERROR;case"warning":return d.ANNOTATION_WARNING;case"task":return d.ANNOTATION_TASK;case"info":return d.ANNOTATION_INFO}return null})},showOccurrences:function(e){this.showAnnotations(e,[d.ANNOTATION_READ_OCCURRENCE,d.ANNOTATION_WRITE_OCCURRENCE],null,function(e){return e.readAccess?d.ANNOTATION_READ_OCCURRENCE:d.ANNOTATION_WRITE_OCCURRENCE})},showBlame:function(t){var n=this._blameRGB,o=this.getTextView().getOptions("parent").ownerDocument;if(!n){var a=s.createElement(o,"div");a.className="annotation blame",o.body.appendChild(a);var l=o.defaultView||o.parentWindow,c=l.getComputedStyle(a),h=c.getPropertyValue("background-color");a.parentNode.removeChild(a);var u=h.indexOf("("),f=h.indexOf(")");h=h.substring(u+1,f),this._blameRGB=n=h.split(",").slice(0,3)}var p=function(){var e=i.AnnotationType.createAnnotation(this.groupType,this.start,this.end,this.title);return e.style=r.mixin({},e.style),e.style.style=r.mixin({},e.style.style),e.style.style.backgroundColor="",this.groupAnnotation=e,e.blame=this.blame,e.html=this.html,e.creatorID=this.creatorID,e},g=function(){var t=s.createElement(o,"div");t.className="tooltipTitle";var n=this.blame.Message.indexOf("\n");-1===n&&(n=this.blame.Message.length);var i=s.createElement(o,"a");return i.href=this.blame.CommitLink,s.isElectron&&(i.target="_blank"),i.appendChild(o.createTextNode(this.blame.Message.substring(0,n))),t.appendChild(i),t.appendChild(s.createElement(o,"br")),t.appendChild(o.createTextNode(s.formatMessage(e.committerOnTime,this.blame.AuthorName,this.blame.Time))),t},v=this.getModel();this.showAnnotations(t,[d.ANNOTATION_BLAME,d.ANNOTATION_CURRENT_BLAME],function(e){var t=v.getLineStart(e.Start-1),o=v.getLineEnd(e.End-1,!0),s=i.AnnotationType.createAnnotation(d.ANNOTATION_BLAME,t,o,g),a=n.slice(0);return a.push(e.Shade),s.style=r.mixin({},s.style),s.style.style=r.mixin({},s.style.style),s.style.style.backgroundColor="rgba("+a.join()+")",s.groupId=e.Name,s.groupType=d.ANNOTATION_CURRENT_BLAME,s.createGroupAnnotation=p,s.html='<img class="annotationHTML blame" src="'+e.AuthorImage+'"/>',s.blame=e,s})},showDiffAnnotations:function(e){this.showAnnotations(e,[d.ANNOTATION_DIFF_ADDED,d.ANNOTATION_DIFF_MODIFIED,d.ANNOTATION_DIFF_DELETED],null,function(e){return"added"===e.type?d.ANNOTATION_DIFF_ADDED:"modified"===e.type?d.ANNOTATION_DIFF_MODIFIED:d.ANNOTATION_DIFF_DELETED})},showSelection:function(e,t,n,i,r){if("number"==typeof e)return"number"!=typeof t&&(t=e),this.moveSelection(e,t),!0;if("number"==typeof n){var o=this.getModel(),s=o.getLineStart(n-1);return"number"==typeof i&&(s+=i),"number"!=typeof r&&(r=0),this.moveSelection(s,s+r),!0}return!1},_setModelText:function(e){this._textView&&(this._textView.setText(e),this._textView.getModel().setLineDelimiter("auto"),this._highlightCurrentLine(this._textView.getSelections()))},setNoFocus:function(e){this._noFocus=e},setInput:function(e,t,n,i,r){a.prototype.setInput.call(this,e,t,n,i),!this._textView||i||r||this._noFocus||this._textView.focus()},onGotoLine:function(e,t,n,i){if(this._textView){var r=this.getModel();e=Math.max(0,Math.min(e,r.getLineCount()-1));var o=r.getLineStart(e),s=0;if(void 0===n&&(n=0),"string"==typeof t){var a=r.getLine(e).indexOf(t);-1!==a&&(s=a,n=s+t.length)}else{s=t;var l=r.getLineEnd(e)-o;s=Math.min(s,l),n=Math.min(n,l)}this.moveSelection(o+s,o+n,i)}}}),{BaseEditor:a,Editor:l}}),n("orion/editor/find",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/keyModes","orion/editor/annotations","orion/regex","orion/objects","orion/Deferred","orion/util"],function(e,t,n,i,r,o,s,a){function l(e){var t=e.getTextView();n.KeyMode.call(this,t),this.editor=e,this._active=!1,this._success=!0,this._ignoreSelection=!1,this._prefix="",t.setAction("incrementalFindCancel",function(){return this.setActive(!1),!0}.bind(this)),t.setAction("incrementalFindBackspace",function(){return this._backspace()}.bind(this));var i=this;this._listener={onVerify:function(e){var t=i.editor,n=t.getModel(),o=t.mapOffset(e.start),s=t.mapOffset(e.end),a=n.getText(o,s),l=i._prefix,d=l.match(new RegExp("^"+r.escape(a),"i"));d&&d.length>0&&(l=i._prefix+=e.text,i._success=!0,i._status(),i.find(i._forward,!0),e.text=null)},onSelection:function(){i._ignoreSelection||i.setActive(!1)}}}function d(e,t,n){if(e){this._editor=e,this._undoStack=t,this._showAll=!0,this._selectedLines=!1,this._visible=!1,this._caseInsensitive=!0,this._wrap=!0,this._wholeWord=!1,this._incremental=!0,this._regex=!1,this._findAfterReplace=!0,this._hideAfterFind=!1,this._reverse=!1,this._start=void 0,this._end=void 0,this._timer=void 0,this._lastString="";var i=this;this._listeners={onEditorFocus:function(e){i._removeCurrentAnnotation(e),i.setOptions({selectedLines:!1})}},this.setOptions(n)}}var c={};return l.prototype=new n.KeyMode,o.mixin(l.prototype,{createKeyBindings:function(){var e=t.KeyBinding,n=[];return n.push({actionID:"incrementalFindBackspace",keyBinding:new e(8)}),n.push({actionID:"incrementalFindCancel",keyBinding:new e(13)}),n.push({actionID:"incrementalFindCancel",keyBinding:new e(27)}),n.push({actionID:"incrementalFindReverse",keyBinding:new e(38)}),n.push({actionID:"incrementalFind",keyBinding:new e(40)}),n.push({actionID:"incrementalFindReverse",keyBinding:new e("k",!0,!0)}),n.push({actionID:"incrementalFind",keyBinding:new e("k",!0)}),n},find:function(e,t){if(this._forward=e,!this.isActive())return this.setActive(!0),!1;var n=this._prefix;if(0===n.length)return!1;var i,r=this.editor,o=r.getModel();return i=e?this._success?t?this._start:r.getCaretOffset()+1:0:this._success?t?this._start:r.getCaretOffset():o.getCharCount()-1,s.when(r.getModel().find({string:n,start:i,reverse:!e,caseInsensitive:n.toLowerCase()===n}),function(n){var o=n.next();o?(t||(this._start=i),this._success=!0,this._ignoreSelection=!0,r.moveSelection(e?o.start:o.end,e?o.end:o.start),this._ignoreSelection=!1):this._success=!1,this._status()}.bind(this)),!0},isActive:function(){return this._active},isStatusActive:function(){return this.isActive()},setActive:function(e){if(this._active!==e){this._active=e,this._prefix="",this._success=!0;var t=this.editor,n=t.getTextView();this._start=this.editor.getCaretOffset(),this.editor.setCaretOffset(this._start),this._active?(n.addEventListener("Verify",this._listener.onVerify),n.addEventListener("Selection",this._listener.onSelection),n.addKeyMode(this)):(n.removeEventListener("Verify",this._listener.onVerify),n.removeEventListener("Selection",this._listener.onSelection),n.removeKeyMode(this)),this._status()}},_backspace:function(){var e=this._prefix;return e=this._prefix=e.substring(0,e.length-1),0===e.length?(this._success=!0,this._ignoreSelection=!0,this.editor.setCaretOffset(this.editor.getSelection().start),this._ignoreSelection=!1,this._status(),!0):this.find(this._forward,!0)},_status:function(){if(!this.isActive())return void this.editor.reportStatus("");var t;t=this._forward?this._success?e.incrementalFindStr:e.incrementalFindStrNotFound:this._success?e.incrementalFindReverseStr:e.incrementalFindReverseStrNotFound,t=a.formatMessage(t,this._prefix),this.editor.reportStatus(t,this._success?"":"error")}}),c.IncrementalFind=l,d.prototype={find:function(e,t,n){this.setOptions({reverse:!e});var i,r=this.getFindString();t&&(r=t.findString||r,i=t.count);var o=this.getOptions();this.setOptions(t);var s=n?this._startOffset:this.getStartOffset();return this._doFind(r,s,i).then(function(e){return e&&(n||(this._startOffset=e.start)),this.setOptions(o),this._hideAfterFind&&this.hide(),e}.bind(this))},getStartOffset:function(){if(this.isRangeSearch()){var e=this._editor.getCaretOffset();return this._reverse&&(e=this._editor.getSelection().start-1),e>=this._searchRangeModel.start&&e<=this._searchRangeModel.end?e:this._searchRangeModel.start}return this._reverse?this._editor.getSelection().start-1:this._editor.getCaretOffset()},getFindString:function(){var e=this._editor.getSelection(),t=this._editor.getText(e.start,e.end);return this._regex&&(t=r.escape(t)),t||this._lastString},getOptions:function(){return{showAll:this._showAll,caseInsensitive:this._caseInsensitive,wrap:this._wrap,wholeWord:this._wholeWord,incremental:this._incremental,regex:this._regex,findAfterReplace:this._findAfterReplace,hideAfterFind:this._hideAfterFind,reverse:this._reverse,findCallback:this._findCallback,start:this._start,end:this._end}},getReplaceString:function(){return""},hide:function(){this._visible=!1,this._savedOptions&&(this.setOptions(this._savedOptions.pop()),0===this._savedOptions.length&&(this._savedOptions=null)),this._removeAllAnnotations(),this._selectedLines&&this.setOptions({selectedLines:!1});var e=this._editor.getTextView();e&&(e.removeEventListener("Focus",this._listeners.onEditorFocus),e.focus())},_processReplaceString:function(e){var t=e;if(this._regex){t="";for(var n=!1,i=this._editor.getModel().getLineDelimiter(),r=0;r<e.length;r++){var o=e.substring(r,r+1);if(n){switch(o){case"R":t+=i;break;case"r":t+="\r";break;case"n":t+="\n";break;case"t":t+=" ";break;case"\\":t+="\\";break;default:t+="\\"+o}n=!1}else"\\"===o?n=!0:t+=o}n&&(t+="\\")}return t},isVisible:function(){return this._visible},replace:function(){var e=this.getFindString();if(e){var t=this._editor,n=this._processReplaceString(this.getReplaceString()),i=t.getSelection(),r=i.start;s.when(this._editor.getModel().find({string:e,start:r,rangeStart:this._searchRangeModel?this._searchRangeModel.start:void 0,rangeEnd:this._searchRangeModel?this._searchRangeModel.end:void 0,reverse:!1,wrap:this._wrap,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive})).then(function(t){if(t){var i=t.next();i&&(this.startUndo(),this._doReplace(i.start,i.end,e,n),this.endUndo()),this._findAfterReplace&&this._doFind(e,this.getStartOffset())}}.bind(this))}},replaceAll:function(){var t=this.getFindString();if(t){this._replacingAll=!0;var n=this._editor,i=n.getTextView();n.reportStatus(e.replacingAll);var r=this._processReplaceString(this.getReplaceString()),o=this;window.setTimeout(function(){for(var s=0,l=0;;){var d=o._doFindForReplaceAll(t,s,null,!0);if(!d)break;l++,1===l&&(i.setRedraw(!1),o.startUndo()),o._doReplace(d.start,d.end,t,r),s=o.getStartOffset()}l>0&&(o.endUndo(),i.setRedraw(!0)),s>0?n.reportStatus(a.formatMessage(e.replacedMatches,l)):n.reportStatus(e.nothingReplaced,"error"),o._replacingAll=!1},100)}},setOptions:function(e){if(e){if((e.showAll===!0||e.showAll===!1)&&this._showAll!==e.showAll&&(this._showAll=e.showAll,this.isVisible()))if(this._showAll)this._markAllOccurrences();else{var t=this._editor.getAnnotationModel();t&&t.removeAnnotations(i.AnnotationType.ANNOTATION_MATCHING_SEARCH)}e.selectedLines!==!0&&e.selectedLines!==!1||this._selectedLinesl===e.selectedLines||(this._selectedLines=e.selectedLines,this._selectedLines?this.annotateSearchRange(e.multipleLine):this.annotateSearchRange(e.multipleLine,!0),this.postSelectedLines()),(e.caseInsensitive===!0||e.caseInsensitive===!1)&&(this._caseInsensitive=e.caseInsensitive),(e.wrap===!0||e.wrap===!1)&&(this._wrap=e.wrap),(e.wholeWord===!0||e.wholeWord===!1)&&(this._wholeWord=e.wholeWord),(e.incremental===!0||e.incremental===!1||"disabled"===e.incremental)&&("disabled"===e.incremental?(this._incremental=!1,this._incrementalDisabled=!0):this._incremental=e.incremental),(e.regex===!0||e.regex===!1)&&(this._regex=e.regex),(e.findAfterReplace===!0||e.findAfterReplace===!1)&&(this._findAfterReplace=e.findAfterReplace),(e.hideAfterFind===!0||e.hideAfterFind===!1)&&(this._hideAfterFind=e.hideAfterFind),(e.reverse===!0||e.reverse===!1)&&(this._reverse=e.reverse),e.hasOwnProperty("findCallback")&&(this._findCallback=e.findCallback),e.hasOwnProperty("start")&&(this._start=e.start),e.hasOwnProperty("end")&&(this._end=e.end)}},show:function(e){this._visible=!0,e&&(this._savedOptions||(this._savedOptions=[]),this._savedOptions.push(this.getOptions()),this.setOptions(e),e.findString&&this._regex&&(e.findString=r.escape(e.findString),e.findString=e.findString.split("\n").join("\\n"),e.findString=e.findString.split("\r").join("\\r"),e.findString=e.findString.split(" ").join("\\t"))),this._startOffset=this._editor.getSelection().start,this._editor.getTextView().addEventListener("Focus",this._listeners.onEditorFocus);var t=this;window.setTimeout(function(){t._incremental&&t.find(!0,null,!0)},0)},startUndo:function(){this._undoStack&&this._undoStack.startCompoundChange()},endUndo:function(){this._undoStack&&this._undoStack.endCompoundChange()},isRangeSearch:function(){return null!==this._searchRangeModel&&void 0!==this._searchRangeModel},annotateSearchRange:function(e,t){var n=i.AnnotationType.ANNOTATION_SEARCH_RANGE,r=this._editor.getAnnotationModel();if(r){if(r.removeAnnotations(n),this.setOptions({start:void 0,end:void 0}),this._selectedLines=!1,this._searchRangeModel=null,t)return;var o=this._editor.getSelection(),s=this._editor.getModel(),a=0,l=0;if(s&&(l=a=s.getLineAtOffset(o.start),o.start!==o.end&&(l=s.getLineAtOffset(o.end-1))),l>a||!e){this._selectedLines=!0;var d=s.getLineStart(a),c=s.getLineEnd(l,!0);this._editor.setSelection(d,d,!0),r.removeAnnotations(i.AnnotationType.ANNOTATION_CURRENT_LINE),this.setOptions({start:d,end:c}),this._searchRangeModel=i.AnnotationType.createAnnotation(n,d,c),r.addAnnotation(this._searchRangeModel)}}},postSelectedLines:function(){},_findFromModel:function(e,t,n){return this._editor.getModel().find({string:e,start:t,rangeStart:this._searchRangeModel?this._searchRangeModel.start:void 0,rangeEnd:this._searchRangeModel?this._searchRangeModel.end:void 0,reverse:this._reverse,wrap:n?!1:this._wrap,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive})},_find:function(e,t,n,i){var r;if(this._regex)try{r=this._findFromModel(t,n,i)}catch(o){return e.reportStatus(o.message,"error"),null}else r=this._findFromModel(t,n,i);return r},_doFindForReplaceAll:function(e,t,n,i){n=n||1;var r=this._editor;if(!e)return this._removeAllAnnotations(),null;this._lastString=e;var o,s;if(s=this._find(r,e,t,i),!s)return null;if(!s.hasNext||!s.next)return null;for(var a=0;n>a&&s.hasNext();a++)o=s.next();return o},_doFind:function(t,n,r,o){r=r||1;var a=this._editor;if(!t)return this._removeAllAnnotations(),(new s).resolve();this._lastString=t;var l;return s.when(this._find(a,t,n,o)).then(function(t){if(t){for(var n=0;r>n&&t.hasNext();n++)l=t.next();if(!this._replacingAll){if(l?this._editor.reportStatus(""):this._editor.reportStatus(e.notFound,"error"),this.isVisible()){var o=i.AnnotationType.ANNOTATION_CURRENT_SEARCH,s=a.getAnnotationModel();if(s&&(s.removeAnnotations(o),l&&s.addAnnotation(i.AnnotationType.createAnnotation(o,l.start,l.end))),this._showAll){this._timer&&window.clearTimeout(this._timer);var d=this;this._timer=window.setTimeout(function(){d._markAllOccurrences(),d._timer=null},500)}}this._findCallback?this._findCallback(l):l&&a.moveSelection(l.start,l.end,null,!1)}return l}}.bind(this))},_doReplace:function(e,t,n,i){var r=this._editor;this._regex&&(i=r.getText(e,t).replace(new RegExp(n,this._caseInsensitive?"i":""),i)),r.setText(i,e,t),r.setSelection(e,e+i.length,!0)},_markAllOccurrences:function(){var e=this._editor.getAnnotationModel();if(e){for(var t,n=i.AnnotationType.ANNOTATION_MATCHING_SEARCH,r=e.getAnnotations(),o=[];r.hasNext();){var a=r.next();a.type===n&&o.push(a)}if(this.isVisible()){var l=this.getFindString();s.when(this._editor.getModel().find({string:l,start:this._start,rangeStart:this._searchRangeModel?this._searchRangeModel.start:void 0,rangeEnd:this._searchRangeModel?this._searchRangeModel.end:void 0,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive})).then(function(r){if(r){for(t=[];r.hasNext();){var s=r.next();t.push(i.AnnotationType.createAnnotation(n,s.start,s.end))}e.replaceAnnotations(o,t)}}.bind(this))}else e.replaceAnnotations(o,t)}},_removeAllAnnotations:function(){var e=this._editor.getAnnotationModel();e&&(e.removeAnnotations(i.AnnotationType.ANNOTATION_CURRENT_SEARCH),e.removeAnnotations(i.AnnotationType.ANNOTATION_MATCHING_SEARCH))},_removeCurrentAnnotation:function(){var e=this._editor.getAnnotationModel();e&&e.removeAnnotations(i.AnnotationType.ANNOTATION_CURRENT_SEARCH)}},c.Find=d,c}),n("orion/editor/findUI",["i18n!orion/editor/nls/messages","orion/editor/find","orion/objects","orion/editor/util","orion/util"],function(e,t,n,i,r){function o(e,n,i){t.Find.call(this,e,n,i)}return o.prototype=new t.Find,n.mixin(o.prototype,{getFindString:function(){var e=this._findInput;return e?e.value:t.Find.prototype.getFindString.call(this)},getReplaceString:function(){var e=this._replaceInput;return e?e.value:t.Find.prototype.getReplaceString(this)},hide:function(){var e=this.isVisible();t.Find.prototype.hide.call(this),e&&(this._rootDiv.className="textViewFind")},show:function(e){t.Find.prototype.show.call(this,e);var n=e.findString,i=e.replaceString,r=this._findInput;if(r||(this._create(),r=this._findInput),n&&(r.value=n),i){var o=this._replaceInput;o.value=i}var s=this;this.setOptions({selectedLines:!0,multipleLine:!0}),window.setTimeout(function(){s._rootDiv.className="textViewFind show",r.select(),r.focus()},0)},postSelectedLines:function(){this._selectedLinesUI&&this._checked(this._selectedLines,this._selectedLinesUI)},_create:function(){var t=this,n=this._editor.getTextView(),o=n.getOptions("parent"),s=o.ownerDocument,a=r.createElement(s,"div");a.className="textViewFind",i.addEventListener(a,"keydown",function(e){t._handleKeyDown(e)}),this._rootDiv=a,a.setAttribute("role","dialog"),a.setAttribute("aria-label",e.findReplace),this._createContents(s,a),n._rootDiv.insertBefore(a,n._rootDiv.firstChild)},_createContents:function(t,n){var o=this,s=r.createElement(t,"input");s.className="textViewFindInput",this._findInput=s,s.type="text",s.placeholder=e.findWith,i.addEventListener(s,"input",function(e){return o._handleInput(e)}),n.appendChild(s);var a=r.createElement(t,"span");o._createButton(t,a,e.next,function(){o.find(!0)}),o._createButton(t,a,e.previous,function(){o.find(!1)}),n.appendChild(a);var l=o._editor.getTextView().getOptions("readonly");if(!l){var d=r.createElement(t,"input");d.className="textViewReplaceInput",this._replaceInput=d,d.type="text",d.placeholder=e.replaceWith,n.appendChild(d),a=r.createElement(t,"span"),o._createButton(t,a,e.replace,function(){o.replace()}),o._createButton(t,a,e.replaceAll,function(){o.replaceAll()}),n.appendChild(a)}a=r.createElement(t,"span"),o._selectedLinesUI=o._createButton(t,a,e.selectedLines,function(e){o._toggle("selectedLines",e.target)},this._selectedLines,e.selectedLinesTooltip,e.selectedLinesTooltip),o._createButton(t,a,e.regex,function(e){o._toggle("regex",e.target)},this._regex,e.regexTooltip,e.regexTooltip),o._createButton(t,a,e.caseInsensitive,function(e){o._toggle("caseInsensitive",e.target)},this._caseInsensitive,e.caseInsensitiveTooltip,e.caseInsensitiveTooltip),o._createButton(t,a,e.wholeWord,function(e){o._toggle("wholeWord",e.target) },this._wholeWord,e.wholeWordTooltip,e.wholeWordTooltip),n.appendChild(a);var c=o._createButton(t,n,"",function(){o.hide()});c.className="textViewFindCloseButton",c.title=e.closeTooltip,r.confineDialogTab(s,c)},_createButton:function(e,t,n,r,o,s,a){var l=e.createElement("button");return l.type="button",this._checked(o,l),s&&(l.title=s),i.addEventListener(l,"click",function(e){r.call(this,e)},!1),n&&l.appendChild(e.createTextNode(n)),a&&l.setAttribute("aria-label",a),t.appendChild(l),l},_toggle:function(e,t){var n={};n[e]=!this["_"+e],this._checked(n[e],t),this.setOptions(n)},_checked:function(e,t){t.className="textViewFindButton",e&&(t.className+=" checked")},_handleInput:function(){return this._incremental&&this.find(!0,null,!0),!0},_handleKeyDown:function(e){var t,n=(r.isMac?e.metaKey:e.ctrlKey)&&!e.altKey&&!e.shiftKey;return n&&70===e.keyCode&&(t=!0),((r.isMac?e.metaKey:e.ctrlKey)&&!e.altKey&&75===e.keyCode||13===e.keyCode)&&(this.find(13===e.keyCode?this._reverse?e.shiftKey:!e.shiftKey:!e.shiftKey),t=!0),n&&82===e.keyCode&&(this.replace(),t=!0),27===e.keyCode&&(this.hide(),t=!0),t?(e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.cancelBubble=!0,!1):!0}}),{FindUI:o}}),n("orion/editor/actions",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/annotations","orion/editor/tooltip","orion/editor/find","orion/editor/findUI","orion/util"],function(e,t,n,i,r,o,s){function a(e,t,n,i){function r(e,t,n){s.setText(e,t,n),o+=t-n+e.length}var o=0,s=e.editor,a=s.getSelections();!i&&(t||a.length>1)&&e.startUndo(),a.forEach(function(e){e.start+=o,e.end+=o,n(e,r)}),s.setSelections(a),!i&&(t||a.length>1)&&e.endUndo()}function l(e,t,n){this.editor=e,this.undoStack=t,this._incrementalFind=new r.IncrementalFind(e),this._find=n?n:new o.FindUI(e,t),this._lastEditLocation=null,this.init()}function d(e,t,n,i){this.editor=e,this.undoStack=t,this.contentAssist=n,this.linkedMode=i,this.contentAssist&&this.contentAssist.addEventListener("ProposalApplied",this.contentAssistProposalApplied.bind(this)),this.init()}var c=n.AnnotationType,h={};return l.prototype={init:function(){var n=this.editor.getTextView();this._lastEditListener={onModelChanged:function(e){this.editor.isDirty()&&(this._lastEditLocation=e.start+e.addedCharCount)}.bind(this)},n.addEventListener("ModelChanged",this._lastEditListener.onModelChanged),n.setAction("undo",function(e){if(this.undoStack){var t=1;for(e&&e.count&&(t=e.count);t>0;)this.undoStack.undo(),--t;return!0}return!1}.bind(this),{name:e.undo}),n.setAction("redo",function(e){if(this.undoStack){var t=1;for(e&&e.count&&(t=e.count);t>0;)this.undoStack.redo(),--t;return!0}return!1}.bind(this),{name:e.redo}),n.setKeyBinding(new t.KeyBinding("f",!0),"find"),n.setAction("find",function(){if(this._find){var e=this.editor.getSelection();return this._find.show({findString:this.editor.getText(e.start,e.end)}),!0}return!1}.bind(this),{name:e.find}),n.setKeyBinding(new t.KeyBinding("k",!0),"findNext"),n.setAction("findNext",function(e){return this._find?(this._find.find(!0,e),!0):!1}.bind(this),{name:e.findNext}),n.setKeyBinding(new t.KeyBinding("k",!0,!0),"findPrevious"),n.setAction("findPrevious",function(e){return this._find?(this._find.find(!1,e),!0):!1}.bind(this),{name:e.findPrevious}),n.setKeyBinding(new t.KeyBinding("j",!0),"incrementalFind"),n.setAction("incrementalFind",function(){return this._incrementalFind&&this._incrementalFind.find(!0),!0}.bind(this),{name:e.incrementalFind}),n.setKeyBinding(new t.KeyBinding("j",!0,!0),"incrementalFindReverse"),n.setAction("incrementalFindReverse",function(){return this._incrementalFind&&this._incrementalFind.find(!1),!0}.bind(this),{name:e.incrementalFindReverse}),n.setAction("tab",function(){return this.indentLines()}.bind(this)),n.setAction("shiftTab",function(){return this.unindentLines()}.bind(this),{name:e.unindentLines}),n.setKeyBinding(new t.KeyBinding(38,!1,!1,!0),"moveLinesUp"),n.setAction("moveLinesUp",function(){return this.moveLinesUp()}.bind(this),{name:e.moveLinesUp}),n.setKeyBinding(new t.KeyBinding(40,!1,!1,!0),"moveLinesDown"),n.setAction("moveLinesDown",function(){return this.moveLinesDown()}.bind(this),{name:e.moveLinesDown}),n.setKeyBinding(new t.KeyBinding(38,!0,!1,!0),"copyLinesUp"),n.setAction("copyLinesUp",function(){return this.copyLinesUp()}.bind(this),{name:e.copyLinesUp}),n.setKeyBinding(new t.KeyBinding(40,!0,!1,!0),"copyLinesDown"),n.setAction("copyLinesDown",function(){return this.copyLinesDown()}.bind(this),{name:e.copyLinesDown}),n.setKeyBinding(new t.KeyBinding("d",!0,!1,!1),"deleteLines"),n.setAction("deleteLines",function(e){return this.deleteLines(e)}.bind(this),{name:e.deleteLines}),n.setKeyBinding(new t.KeyBinding("l",!s.isMac,!1,!1,s.isMac),"gotoLine"),n.setAction("gotoLine",function(){return this.gotoLine()}.bind(this),{name:e.gotoLine}),n.setKeyBinding(new t.KeyBinding(190,!0),"nextAnnotation"),n.setAction("nextAnnotation",function(){return this.nextAnnotation(!0)}.bind(this),{name:e.nextAnnotation}),n.setKeyBinding(new t.KeyBinding(188,!0),"previousAnnotation"),n.setAction("previousAnnotation",function(){return this.nextAnnotation(!1)}.bind(this),{name:e.prevAnnotation}),n.setKeyBinding(new t.KeyBinding("e",!0,!1,!0,!1),"expand"),n.setAction("expand",function(){return this.expandAnnotation(!0)}.bind(this),{name:e.expand}),n.setKeyBinding(new t.KeyBinding("c",!0,!1,!0,!1),"collapse"),n.setAction("collapse",function(){return this.expandAnnotation(!1)}.bind(this),{name:e.collapse}),n.setKeyBinding(new t.KeyBinding("e",!0,!0,!0,!1),"expandAll"),n.setAction("expandAll",function(){return this.expandAnnotations(!0)}.bind(this),{name:e.expandAll}),n.setKeyBinding(new t.KeyBinding("c",!0,!0,!0,!1),"collapseAll"),n.setAction("collapseAll",function(){return this.expandAnnotations(!1)}.bind(this),{name:e.collapseAll}),n.setKeyBinding(new t.KeyBinding("q",!s.isMac,!1,!1,s.isMac),"lastEdit"),n.setAction("lastEdit",function(){return this.gotoLastEdit()}.bind(this),{name:e.lastEdit})},copyLinesDown:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel();return a(this,!1,function(e,t){var i=n.getLineAtOffset(e.start),r=n.getLineAtOffset(e.end>e.start?e.end-1:e.end),o=n.getLineStart(i),s=n.getLineEnd(r,!0),a=n.getLineCount(),l="",d=n.getText(o,s);r===a-1&&(d=(l=n.getLineDelimiter())+d);var c=s;t(d,c,c),e.start=c+l.length,e.end=c+d.length}),!0},copyLinesUp:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel();return a(this,!1,function(e,t){var i=n.getLineAtOffset(e.start),r=n.getLineAtOffset(e.end>e.start?e.end-1:e.end),o=n.getLineStart(i),s=n.getLineEnd(r,!0),a=n.getLineCount(),l="",d=n.getText(o,s);r===a-1&&(d+=l=n.getLineDelimiter());var c=o;t(d,c,c),e.start=c,e.end=c+d.length-l.length}),!0},deleteLines:function(e){var t=this.editor,n=t.getTextView();if(n.getOptions("readonly"))return!1;var i=1;e&&e.count&&(i=e.count);var r=t.getModel();return a(this,!1,function(e,t){var n,o=r.getLineAtOffset(e.start),s=r.getLineStart(o);n=e.start!==e.end||1===i?r.getLineAtOffset(e.end>e.start?e.end-1:e.end):Math.min(o+i-1,r.getLineCount()-1);var a=r.getLineEnd(n,!0);t("",s,a),e.start=e.end=s}),!0},expandAnnotation:function(e){var t=this.editor;if(!t.getFoldingRulerVisible())return!0;var i=t.getAnnotationModel();if(!i)return!0;var r=t.getModel(),o=t.getCaretOffset(),s=r.getLineAtOffset(o),a=r.getLineStart(s),l=r.getLineEnd(s,!0);r.getBaseModel&&(a=r.mapOffset(a),l=r.mapOffset(l),r=r.getBaseModel());for(var d,c=i.getAnnotations(a,l);!d&&c.hasNext();){var h=c.next();h.type===n.AnnotationType.ANNOTATION_FOLDING&&(d=h)}return d&&e!==d.expanded&&(e?d.expand():(t.setCaretOffset(d.start),d.collapse())),!0},expandAnnotations:function(e){var t=this.editor;if(!t.getFoldingRulerVisible())return!0;var i=t.getTextView(),r=t.getAnnotationModel();if(!r)return!0;var o,s=r.getAnnotations();for(i.setRedraw(!1);s.hasNext();)o=s.next(),o.type===n.AnnotationType.ANNOTATION_FOLDING&&e!==o.expanded&&(e?o.expand():o.collapse());return i.setRedraw(!0),!0},indentLines:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;if(t.getOptions("tabMode")){var n=e.getModel(),i=0,r=e.getSelections();return r.length>1&&this.startUndo(),r.some(function(o){o.start+=i,o.end+=i;var s=n.getLineAtOffset(o.start),a=n.getLineAtOffset(o.end>o.start?o.end-1:o.end);if(!(s!==a||r.length>1))return!0;var l=[];l.push("");for(var d=s;a>=d;d++)l.push(n.getLine(d,!0));var c=n.getLineStart(s),h=n.getLineEnd(a,!0),u=t.getOptions("tabSize","expandTab"),f=u.expandTab?new Array(u.tabSize+1).join(" "):" ",p=l.join(f);e.setText(p,c,h);var g=c===o.start?o.start:o.start+f.length,v=o.end+(a-s+1)*f.length;return i+=c-h+p.length,o.start=g,o.end=v,!1})?!1:(e.setSelections(r),r.length>1&&this.endUndo(),!0)}},gotoLastEdit:function(){return"number"==typeof this._lastEditLocation&&this.editor.showSelection(this._lastEditLocation),!0},gotoLine:function(){var t=this.editor,n=t.getModel(),i=n.getLineAtOffset(t.getCaretOffset());return i=prompt(e.gotoLinePrompty,i+1),i&&(i=parseInt(i,10),t.onGotoLine(i-1,0)),!0},moveLinesDown:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel();return a(this,!0,function(e,t){var i=n.getLineAtOffset(e.start),r=n.getLineAtOffset(e.end>e.start?e.end-1:e.end),o=n.getLineCount();if(r!==o-1){var s,a=n.getLineStart(i),l=n.getLineEnd(r,!0),d=n.getLineEnd(r+1,!0)-(l-a),c=0;if(r!==o-2)s=n.getText(a,l);else{var h=n.getLineEnd(r);s=n.getText(h,l)+n.getText(a,h),c+=l-h}t("",a,l),t(s,d,d),e.start=d+c,e.end=d+c+s.length}}),!0},moveLinesUp:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel();return a(this,!0,function(e,t){var i=n.getLineAtOffset(e.start);if(0!==i){var r=n.getLineAtOffset(e.end>e.start?e.end-1:e.end),o=n.getLineCount(),s=n.getLineStart(i-1),a=n.getLineStart(i),l=n.getLineEnd(r,!0),d=n.getText(a,l),c=0;if(r===o-1){var h=n.getLineEnd(i-1),u=n.getLineEnd(i-1,!0);d+=n.getText(h,u),a=h,c=u-h}t("",a,l),t(d,s,s),e.start=s,e.end=s+d.length-c}}),!0},nextAnnotation:function(e){function t(e,t){switch(t){case c.ANNOTATION_ERROR:return e.type!==c.ANNOTATION_ERROR&&e.type!==c.ANNOTATION_WARNING&&e.type!==c.ANNOTATION_INFO;case c.ANNOTATION_READ_OCCURRENCE:return e.type!==c.ANNOTATION_READ_OCCURRENCE&&e.type!==c.ANNOTATION_WRITE_OCCURRENCE;case c.ANNOTATION_CURRENT_SEARCH:return e.type!==c.ANNOTATION_CURRENT_SEARCH&&e.type!==c.ANNOTATION_MATCHING_SEARCH;case c.ANNOTATION_TASK:return e.type!==c.ANNOTATION_TASK&&e.type!==c.ANNOTATION_BOOKMARK}return!0}var n=this.editor,r=n.getAnnotationModel();if(!r)return!0;var o=n.getOverviewRuler()||n.getAnnotationStyler();if(!o)return!0;var s=n.getModel(),a=n.getCaretOffset();if(!this._lastPosition||this._lastPosition!==a){for(var l=r.getAnnotations(a,a),d=null;l.hasNext();){var h=l.next();if(h.type===c.ANNOTATION_ERROR||h.type===c.ANNOTATION_WARNING||h.type===c.ANNOTATION_INFO){d=c.ANNOTATION_ERROR;break}h.type===c.ANNOTATION_READ_OCCURRENCE||h.type===c.ANNOTATION_WRITE_OCCURRENCE?d=c.ANNOTATION_READ_OCCURRENCE:h.type===c.ANNOTATION_TASK||h.type===c.ANNOTATION_BOOKMARK&&d!==c.ANNOTATION_READ_OCCURRENCE?d=c.ANNOTATION_TASK:(h.type===c.ANNOTATION_CURRENT_SEARCH||h.type===c.ANNOTATION_MATCHING_SEARCH&&!d)&&(d=c.ANNOTATION_CURRENT_SEARCH)}this._iterationMode=d?d:c.ANNOTATION_ERROR}for(var u=r.getAnnotations(e?a:0,e?s.getCharCount():a),f=null;u.hasNext();){var h=u.next();if(e){if(h.start<=a)continue}else if(h.start>=a)continue;if(!t(h,this._iterationMode)&&(f=h,e))break}if(f){var p=[f];for(u=r.getAnnotations(f.start,f.start);u.hasNext();)h=u.next(),h===f||t(h,this._iterationMode)||p.push(h);var g=n.getTextView(),v=i.Tooltip.getTooltip(g,n);if(this._lastPosition=f.start,!v)return n.moveSelection(f.start),!0;n.moveSelection(f.start,f.start,function(){setTimeout(function(){var e=n.getTextView(),t=f.start,i=e.getLocationAtOffset(t);v.show({x:i.x,y:i.y,getTooltipInfo:function(){return n._getTooltipInfo(this.x,this.y)}},!1,!1)},0)})}return!0},unindentLines:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;if(t.getOptions("tabMode")){var n=e.getModel();return a(this,!1,function(e,i){for(var r=n.getLineAtOffset(e.start),o=n.getLineAtOffset(e.end>e.start?e.end-1:e.end),s=t.getOptions("tabSize"),a=new Array(s+1).join(" "),l=[],d=0,c=0,h=r;o>=h;h++){var u=n.getLine(h,!0);if(n.getLineStart(h)!==n.getLineEnd(h))if(0===u.indexOf(" "))u=u.substring(1),d++;else{if(0!==u.indexOf(a))return!0;u=u.substring(s),d+=s}h===r&&(c=d),l.push(u)}var f=n.getLineStart(r),p=n.getLineEnd(o,!0),g=n.getLineStart(o),v=l.join("");i(v,f,p);var m=f===e.start?e.start:e.start-c,_=Math.max(m,e.end-d+(e.end===g+1&&e.start!==e.end?1:0));e.start=m,e.end=_}),!0}},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()}},h.TextActions=l,d.prototype={init:function(){var n=this.editor.getTextView();n.setAction("lineStart",function(){return this.lineStart()}.bind(this)),n.setAction("enter",function(){return this.autoIndent()}.bind(this)),n.setKeyBinding(new t.KeyBinding("t",!0,!1,!0),"trimTrailingWhitespaces"),n.setAction("trimTrailingWhitespaces",function(){return this.trimTrailingWhitespaces()}.bind(this),{name:e.trimTrailingWhitespaces}),n.setKeyBinding(new t.KeyBinding(191,!0),"toggleLineComment"),n.setAction("toggleLineComment",function(){return this.toggleLineComment()}.bind(this),{name:e.toggleLineComment}),n.setKeyBinding(new t.KeyBinding(191,!0,!s.isMac,!1,s.isMac),"addBlockComment"),n.setAction("addBlockComment",function(){return this.addBlockComment()}.bind(this),{name:e.addBlockComment}),n.setKeyBinding(new t.KeyBinding(220,!0,!s.isMac,!1,s.isMac),"removeBlockComment"),n.setAction("removeBlockComment",function(){return this.removeBlockComment()}.bind(this),{name:e.removeBlockComment}),n.setKeyBinding(new t.KeyBinding("[",!1,!1,!1,!1,"keypress"),"autoPairSquareBracket"),n.setAction("autoPairSquareBracket",function(){return this.autoPairBrackets("[","]")}.bind(this)),n.setKeyBinding(new t.KeyBinding("]",!1,!1,!1,!1,"keypress"),"skipClosingSquareBracket"),n.setAction("skipClosingSquareBracket",function(){return this.handleClosingBracket("]")}.bind(this)),n.setKeyBinding(new t.KeyBinding("<",!1,!1,!1,!1,"keypress"),"autoPairAngleBracket"),n.setAction("autoPairAngleBracket",function(){return this.autoPairBrackets("<",">")}.bind(this)),n.setKeyBinding(new t.KeyBinding(">",!1,!1,!1,!1,"keypress"),"skipClosingAngleBracket"),n.setAction("skipClosingAngleBracket",function(){return this.handleClosingBracket(">")}.bind(this)),n.setKeyBinding(new t.KeyBinding("(",!1,!1,!1,!1,"keypress"),"autoPairParentheses"),n.setAction("autoPairParentheses",function(){return this.autoPairBrackets("(",")")}.bind(this)),n.setKeyBinding(new t.KeyBinding(")",!1,!1,!1,!1,"keypress"),"skipClosingParenthesis"),n.setAction("skipClosingParenthesis",function(){return this.handleClosingBracket(")")}.bind(this)),n.setKeyBinding(new t.KeyBinding("{",!1,!1,!1,!1,"keypress"),"autoPairBraces"),n.setAction("autoPairBraces",function(){return this.autoPairBrackets("{","}")}.bind(this)),n.setKeyBinding(new t.KeyBinding("}",!1,!1,!1,!1,"keypress"),"skipClosingBrace"),n.setAction("skipClosingBrace",function(){return this.handleClosingBracket("}")}.bind(this)),n.setKeyBinding(new t.KeyBinding("'",!1,!1,!1,!1,"keypress"),"autoPairSingleQuotation"),n.setAction("autoPairSingleQuotation",function(){return this.autoPairQuotations("'")}.bind(this)),n.setKeyBinding(new t.KeyBinding('"',!1,!1,!1,!1,"keypress"),"autoPairDblQuotation"),n.setAction("autoPairDblQuotation",function(){return this.autoPairQuotations('"')}.bind(this)),n.setAction("deletePrevious",function(){return this.deletePrevious()}.bind(this))},autoIndent:function(){function e(e,t){if(e.start===e.end){for(var n,r=i.getLineAtOffset(e.start),a=i.getLine(r,!1),u=i.getLineStart(r),f=0,p=e.start-u;p>f&&(32===(n=a.charCodeAt(f))||9===n);)f++;var g,v,m=a.substring(0,f),_=a.substring(0,p),y=a.substring(p);if(h.smartIndentation&&123===a.charCodeAt(v=_.trimRight().length-1)){var C=p-v-1,w=y.length-y.trimLeft().length;return g=125===a.charCodeAt(p+w)?s+m+o+s+m:s+m+o,t(g,e.start-C,e.end+w),e.start=e.end=e.start+s.length+m.length+o.length-C,!0}if(h.autoCompleteComments&&!c.test(_)&&(l.test(_)||d.test(_))){var x,b=l.exec(_);if(b)return g=s+m+" * ",g+=c.test(y)?y.substring(0,y.length-2).trim():y.trim(),i.getLineCount()!==r+1&&d.test(i.getLine(r+1))||(g+=s+m+" */"),t(g,e.start,e.end+y.length),e.start=e.end=e.start+s.length+m.length+3,!0;if(b=d.exec(_))for(var S=r-1;S>=0;S--){var T=i.getLine(S,!1);if(l.test(T))return c.test(y)||47===a.charCodeAt(p)?(g=s+m+"*"+y,x=e.start+s.length+m.length+1):(g=s+m+"* "+y,x=e.start+s.length+m.length+2),t(g,e.start,e.end+y.length),e.start=e.end=x,!0;if(!d.test(T))return!1}return!1}if(c.test(_)&&32===m.charCodeAt(m.length-1))return g=s+m.substring(0,m.length-1),t(g,e.start,e.end),e.start=e.end=e.start+g.length,!0;if(f>0){for(f=p;f<a.length&&(32===(n=a.charCodeAt(f++))||9===n);)e.end++;return g=i.getLineDelimiter()+m,t(g,e.start,e.end),e.start=e.end=e.start+g.length,!0}}return!1}var t=this.editor,n=t.getTextView();if(n.getOptions("readonly"))return!1;if(n.getOptions("singleMode"))return!1;var i=t.getModel(),r=n.getOptions("tabSize","expandTab"),o=r.expandTab?new Array(r.tabSize+1).join(" "):" ",s=i.getLineDelimiter(),l=/^[\s]*\/\*[\*]*[\s]*$/,d=/^[\s]*\*/,c=/\*\/[\s]*$/,h=this;return a(this,!0,function(t,n){e(t,n)||(n(s,t.start,t.end),t.start=t.end=t.start+s.length)}),!0},addBlockComment:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel(),i=e.getStyleAccessor();return a(this,!1,function(e,t){var r,o;if(i){var s=i.getBlockCommentDelimiters(e.start);r=s[0],o=s[1]}else r="/*",o="*/";var a=this._findEnclosingComment(n,e.start,e.end,r,o);if(void 0===a.commentStart||void 0===a.commentEnd){var l=n.getText(e.start,e.end);if(0!==l.length){var d=l.length;l=l.replace(r,""),l=l.replace(o,"");var c=l.length;l=r+l+o,t(l,e.start,e.end),e.start+=r.length,e.end+=r.length+(c-d)}}}.bind(this)),!0},autoPairBrackets:function(e,t){if("["===e&&!this.autoPairSquareBrackets)return!1;if("{"===e&&!this.autoPairBraces)return!1;if("("===e&&!this.autoPairParentheses)return!1;if("<"===e&&!this.autoPairAngleBrackets)return!1;var n=this.editor,i=n.getTextView();if(i.getOptions("readonly"))return!1;var r=new RegExp("^$|[)}\\]>]"),o=n.getModel();return a(this,!1,function(n,i){var s,a=n.start===o.getCharCount()?"":o.getText(n.start,n.start+1).trim();n.start===n.end&&r.test(a)?(s=e+t,i(s,n.start,n.start),n.start=n.end=n.start+1):n.start!==n.end?(s=e+o.getText(n.start,n.end)+t,i(s,n.start,n.end),n.start+=1,n.end+=1):(i(e,n.start,n.end),n.start=n.end=n.start+e.length)}),!0},autoPairQuotations:function(e){if(!this.autoPairQuotation)return!1;var t=this.editor,n=t.getTextView();if(n.getOptions("readonly"))return!1;var i=new RegExp("^\"$|^'$"),r=new RegExp("\\w"),o=new RegExp("^$|[)}\\]>]"),s=t.getModel();return a(this,!1,function(t,n){function a(){n(e,t.start,t.end),t.start=t.end=t.start+e.length}var l=0===t.start?"":s.getText(t.start-1,t.start).trim(),d=t.start===s.getCharCount()?"":s.getText(t.start,t.start+1).trim();if(t.start!==t.end){var c=s.getText(t.start,t.end);i.test(c)?a():(n(e+c+e,t.start,t.end),t.start+=1,t.end+=1)}else d===e?t.start=t.end=t.start+1:l===e||i.test(d)||r.test(l)||!o.test(d)?a():(n(e+e,t.start,t.end),t.start=t.end=t.start+e.length)}),!0},contentAssistProposalApplied:function(e){function t(){return"number"==typeof n.escapePosition?n.escapePosition:e.data.start+n.proposal.length}var n=e.data.proposal;if(Array.isArray(n.positions)&&this.linkedMode){var i=[];n.positions.forEach(function(e){"number"==typeof e.offset&&"number"==typeof e.length&&i.push({positions:[{offset:e.offset,length:e.length}]})}),i.length>0?this.linkedMode.enterLinkedMode({groups:i,escapePosition:t()}):this.editor.getTextView().setCaretOffset(t())}else n.groups&&n.groups.length>0&&this.linkedMode?this.linkedMode.enterLinkedMode({groups:n.groups,escapePosition:t()}):"number"==typeof n.escapePosition&&this.editor.getTextView().setCaretOffset(n.escapePosition);return!0},deletePrevious:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel();return a(this,!1,function(e,t){if(e.start===e.end){var i=0===e.start?"":n.getText(e.start-1,e.start),r=e.start===n.getCharCount()?"":n.getText(e.start,e.start+1);("("===i&&")"===r||"["===i&&"]"===r||"{"===i&&"}"===r||"<"===i&&">"===r||'"'===i&&'"'===r||"'"===i&&"'"===r)&&t("",e.start,e.start+1)}},!0),!1},_findEnclosingComment:function(e,t,n,i,r){var o,s,a,l,d,c,h,u=e.getLineAtOffset(t),f=e.getLineAtOffset(n);for(o=u;o>=0&&(s=e.getLine(o),a=o===u?t-e.getLineStart(u):s.length,l=s.lastIndexOf(i,a),d=s.lastIndexOf(r,a),!(d>l));o--)if(-1!==l){c=e.getLineStart(o)+l;break}for(o=f;o<e.getLineCount()&&(s=e.getLine(o),a=o===f?n-e.getLineStart(f):0,l=s.indexOf(i,a),d=s.indexOf(r,a),!(-1!==l&&d>l));o++)if(-1!==d){h=e.getLineStart(o)+d;break}return{commentStart:c,commentEnd:h}},lineStart:function(){var e=this.editor,t=e.getModel();return a(this,!1,function(e){var n,i=e.getCaret(),r=t.getLineAtOffset(i),o=t.getLineStart(r),s=t.getLine(r);for(n=0;n<s.length;n++){var a=s.charCodeAt(n);if(32!==a&&9!==a)break}n+=o,e.setCaret(i!==n?n:o)}),!0},removeBlockComment:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel(),i=e.getStyleAccessor();return a(this,!1,function(e,t){var r,o;if(i){var s=i.getBlockCommentDelimiters(e.start);r=s[0],o=s[1]}else r="/*",o="*/";var a,l,d,c=n.getText(e.start,e.end);for(d=0;d<c.length;d++)if(c.substring(d,d+r.length)===r){a=e.start+d;break}for(;d<c.length;d++)if(c.substring(d,d+o.length)===o){l=e.start+d;break}var h;if(void 0!==a&&void 0!==l)h=n.getText(a+r.length,l),t(h,a,l+o.length),e.start=a,e.end=l;else{var u=this._findEnclosingComment(n,e.start,e.end,r,o);void 0!==u.commentStart&&void 0!==u.commentEnd&&(h=n.getText(u.commentStart+r.length,u.commentEnd),t(h,u.commentStart,u.commentEnd+o.length),e.start=e.start-r.length,e.end=e.end-o.length)}}.bind(this)),!0},toggleLineComment:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var n=e.getModel(),i=e.getStyleAccessor();return t.setRedraw(!1),a(this,!0,function(e,t){var r,o=n.getLineAtOffset(e.start),s=n.getLineAtOffset(e.end>e.start?e.end-1:e.end);r=i?i.getLineCommentDelimiter(n.getLineStart(o)):"//";for(var a,l=!0,d=[],c=o;s>=c;c++){var h=n.getLine(c,!0);if(a=h.indexOf(r),d.push(a),l&&-1!==a){if(0!==a){var u;for(u=0;a>u;u++){var f=h.charCodeAt(u);if(32!==f&&9!==f)break}l=u===a}}else l=!1}var p,g,v,m=r.length,_=n.getLineStart(o);if(l){for(v=d.length-1;v>=0;v--)a=d[v]+n.getLineStart(o+v),t("",a,a+m);var y=n.getLineStart(s);p=_===e.start?e.start:e.start-m,g=e.end-m*(s-o+1)+(e.end===y+1?m:0)}else{for(v=d.length-1;v>=0;v--)a=n.getLineStart(o+v),t(r,a,a);p=_===e.start?e.start:e.start+m,g=e.end+m*(s-o+1)}e.start=p,e.end=g}),t.setRedraw(!0),!0},trimTrailingWhitespaces:function(){var e=this.editor,t=e.getModel(),n=e.getSelections();e.getTextView().setRedraw(!1),this.startUndo();for(var i=/(\s+$)/,r=t.getLineCount(),o=0;r>o;o++){var s=t.getLine(o),a=i.exec(s);if(a){var l=t.getLineStart(o),d=a[0].length,c=l+a.index;t.setText("",c,c+d),n.forEach(function(e){e.start>c&&(e.start=Math.max(c,e.start-d)),e.start!==e.end&&e.end>c&&(e.end=Math.max(c,e.end-d))})}}this.endUndo(),e.setSelections(n,!1),e.getTextView().setRedraw(!0)},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},handleClosingBracket:function(e){var t=this.editor,n=t.getTextView();if(n.getOptions("readonly"))return!1;var i=t.getModel(),r=t.getSelections();if(1===r.length&&r[0].start===r[0].end){var o=r[0].start===i.getCharCount()?"":i.getText(r[0].start,r[0].start+1);if(o===e)return r[0].start=r[0].end=r[0].start+1,t.setSelections(r),!0;var s=i.getLineAtOffset(r[0].start),a=i.getLine(s,!0);if(a.match(/^\s*$/)&&n.getOptions("tabMode")){var l=n.getOptions("tabSize"),d=new Array(l+1).join(" "),c=i.getLineStart(s),h=i.getLineEnd(s);if(c!==h){if(0===a.indexOf(" "))return a=a.substring(1),i.setText(a,c,h),t.setSelection(r[0].start-1,r[0].end-1),!1;if(0===a.indexOf(d))return a=a.substring(l),i.setText(a,c,h),t.setSelection(r[0].start-l,r[0].end-l),!1}}}return!1},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},setAutoPairParentheses:function(e){this.autoPairParentheses=e},setAutoPairBraces:function(e){this.autoPairBraces=e},setAutoPairSquareBrackets:function(e){this.autoPairSquareBrackets=e},setAutoPairAngleBrackets:function(e){this.autoPairAngleBrackets=e},setAutoPairQuotations:function(e){this.autoPairQuotation=e},setAutoCompleteComments:function(e){this.autoCompleteComments=e},setSmartIndentation:function(e){this.smartIndentation=e}},h.SourceCodeActions=d,String.prototype.trimLeft||(String.prototype.trimLeft=function(){return this.replace(/^\s+/g,"")}),String.prototype.trimRight||(String.prototype.trimRight=function(){return this.replace(/\s+$/g,"")}),h}),n("orion/editor/rulers",["i18n!orion/editor/nls/messages","orion/editor/textView","orion/editor/annotations","orion/editor/tooltip","orion/objects","orion/editor/util","orion/util"],function(e,t,n,i,r,o,s){function a(e,t,n){this._location=e||"left",this._overview=t||"page",this._rulerStyle=n,this._view=null}function l(e,t,n,i){a.call(this,t,n,i);var r=this;this._listener={onTextModelChanged:function(e){r._onTextModelChanged(e)},onAnnotationModelChanged:function(e){r._onAnnotationModelChanged(e)}},this.setAnnotationModel(e)}function d(e,t,n,i,r){l.call(this,e,t,"page",n),this._oddStyle=i||{style:{backgroundColor:"white"}},this._evenStyle=r||{style:{backgroundColor:"white"}},this._numOfDigits=0,this._firstLine=1}function c(e,t,n){l.call(this,e,t,"page",n)}function h(e,t,n){l.call(this,e,t,"document",n)}function u(e,t,n){c.call(this,e,t,n)}a.prototype={getLocation:function(){return this._location},getOverview:function(){return this._overview},getRulerStyle:function(){return this._rulerStyle},getView:function(){return this._view},setView:function(e){this._onTextModelChanged&&this._view&&this._view.removeEventListener("ModelChanged",this._listener.onTextModelChanged),this._view=e,this._onTextModelChanged&&this._view&&this._view.addEventListener("ModelChanged",this._listener.onTextModelChanged)}},l.prototype=r.mixin(new a,{getAnnotations:function(e,t){var n=this._annotationModel;if(!n)return[];var i=this._view.getModel(),r=i.getLineStart(e),o=i.getLineEnd(t-1),s=i;i.getBaseModel&&(s=i.getBaseModel(),r=i.mapOffset(r),o=i.mapOffset(o));for(var a=[],l=this.getAnnotationsByType(n,r,o),d=0;d<l.length;d++)for(var c=l[d],h=s.getLineAtOffset(c.start),u=s.getLineAtOffset(Math.max(c.start,c.end-1)),f=h;u>=f;f++){var p=f;if(i!==s){var g=s.getLineStart(f);if(g=i.mapOffset(g,!0),-1===g)continue;p=i.getLineAtOffset(g)}if(p>=e&&t>p){var v=this._mergeAnnotation(a[p],c,f-h,u-h+1);v&&(a[p]=v)}}if(!this._multiAnnotation&&this._multiAnnotationOverlay)for(var m in a)a[m]._multiple&&(a[m].html=a[m].html+this._multiAnnotationOverlay.html);return a},getAnnotationModel:function(){return this._annotationModel},getWidestAnnotation:function(){return null},setAnnotationModel:function(e){this._annotationModel&&this._annotationModel.removeEventListener("Changed",this._listener.onAnnotationModelChanged),this._annotationModel=e,this._annotationModel&&this._annotationModel.addEventListener("Changed",this._listener.onAnnotationModelChanged)},setMultiAnnotation:function(e){this._multiAnnotation=e},setMultiAnnotationOverlay:function(e){this._multiAnnotationOverlay=e},onClick:function(e){if(void 0!==e){var t,n,r,o=this._view,s=o.getModel(),a=s.getLineStart(e),l=s.getLineEnd(e,!0),d=o.getSelection().start,c=o.getSelection().end,h=this._annotationModel;if(h){s.getBaseModel&&(a=s.mapOffset(a),l=s.mapOffset(l),d=s.mapOffset(d),c=s.mapOffset(c));var u=this;t=this._findNextAnnotation(h,a,l,d,c,function(e){return u.isAnnotationTypeVisible(e)}),n=t?t.start:a,r=t?t.end:a,s.getBaseModel&&(n=s.mapOffset(n,!0),r=s.mapOffset(r,!0)),t&&void 0!==t.groupId&&(this._currentClickGroup=this._currentClickGroup===t.groupId?null:t.groupId,this._setCurrentGroup(e))}var f={type:"AnnotationClicked",target:u,targetType:"Ruler",annotation:t,selection:{start:n,end:r,viewportOffset:1/3},showTooltip:!0};if(this._view.dispatchEvent(f),f.selection&&this._view.setSelection(f.selection.start,f.selection.end,f.selection.viewportOffset,function(){}),f.showTooltip){var p=i.Tooltip.getTooltip(this._view);p&&(t&&"left"===this.getLocation()?p.show({getTooltipInfo:function(){return u._getTooltipInfo([t])}},!1,!1):p.hide())}}},onDblClick:function(){},onMouseMove:function(e,t){var n=i.Tooltip.getTooltip(this._view);if(n&&(!n.isVisible()||this._tooltipLineIndex!==e)&&(this._tooltipLineIndex=e,t.clientX!==this._lastMouseX||t.clientY!==this._lastMouseY)){this._lastMouseX=t.clientX,this._lastMouseY=t.clientY,this._hoverTimeout&&(window.clearTimeout(this._hoverTimeout),this._hoverTimeout=null);var r=t.target?t.target:t.srcElement,o=r.getBoundingClientRect();this._curElementBounds=Object.create(null),this._curElementBounds.top=o.top,this._curElementBounds.left=o.left,this._curElementBounds.height=o.height,this._curElementBounds.width=o.width,r===this.node&&(this._curElementBounds.top=t.clientY,this._curElementBounds.height=1);var s=this;s._hoverTimeout=window.setTimeout(function(){s._hoverTimeout=null,n.onHover({getTooltipInfo:function(){var e=s._getAnnotationsAtLineIndex(s._tooltipLineIndex),n=s._getTooltipContents(s._tooltipLineIndex,e);return s._getTooltipInfo(n,t.clientY,{source:"ruler",rulerLocation:s.getLocation()})}},t.clientX,t.clientY)},175)}},onMouseOver:function(e,t){this.onMouseMove(e,t),this._currentClickGroup||this._setCurrentGroup(e)},onMouseOut:function(){this._currentClickGroup||this._setCurrentGroup(-1),this._hoverTimeout&&(window.clearTimeout(this._hoverTimeout),this._hoverTimeout=null)},_findNextAnnotation:function(e,t,n,i,r,o){var s,a=null,l=t;if(i>=0&&r>=0&&i>=t&&n>i){l=i;for(var d=e.getAnnotations(i,r);!s&&d.hasNext();){var c=d.next();(!o||o(c.type))&&c.start===i&&c.end===r&&(s=c)}}for(var h,u=e.getAnnotations(l,n);u.hasNext();)if(c=u.next(),!o||o(c.type)){if(a||(a=c),!s){a=c;break}if(h&&(s.start!==c.start||s.end!==c.end)){h=!1,a=c;break}s&&s===c&&(h=!0)}return h&&(a=null),a},_getAnnotationsAtLineIndex:function(e){if(void 0!==e){var t,n=this._view,i=this._annotationModel,r=[];if(!n)return[];if(t=n.getModel(),i&&t){var o=t.getLineStart(e),s=t.getLineEnd(e);t.getBaseModel&&(o=t.mapOffset(o),s=t.mapOffset(s)),r=this.getAnnotationsByType(i,o,s)}return r}},_getTooltipInfo:function(e,t,n){if(!e)return null;var i=Object.create(null);i.top=this._curElementBounds.top,i.left=this._curElementBounds.left,i.height=this._curElementBounds.height,i.width=this._curElementBounds.width,"string"==typeof e&&t&&(i.top=t,i.height=1);var r=this.getLocation(),o=this.getRulerStyle(),s="left"===r?"right":"left",a=0,l=0;if(this._view){var d=this._view._clientDiv.getBoundingClientRect();a=d.left-(i.left+i.width)}else a=i.width;l=i.height,"left"===s&&(a=-25,1===i.height&&(a+=2)),o.styleClass.indexOf("folding")>=0&&(l-=14);var c={contents:e,position:s,tooltipOffsetX:a,tooltipOffsetY:l,anchorArea:i,context:n};return c},_getTooltipContents:function(e,t){return t},_getOnClickTooltipInfo:function(e){var t=this._view,n=Object.create(null);n.top=this._curElementBounds.top,n.left=this._curElementBounds.left,n.height=this._curElementBounds.height,n.width=this._curElementBounds.width;var i=this.getLocation(),r="left"===i?"right":"left",o={contents:[e],position:r,anchorArea:n};if(t){var s=t._clientDiv.getBoundingClientRect();o.offsetX=s.left-(n.left+n.width)}else o.offsetX=n.width;return o.offsetY=n.height,"left"===o.position&&(o.offsetX=20),o},_onAnnotationModelChanged:function(e){function t(e){for(var t=0;t<e.length;t++)if(r.isAnnotationTypeVisible(e[t].type)){s=e[t].start; var o=e[t].end;i.getBaseModel&&(s=i.mapOffset(s,!0),o=i.mapOffset(o,!0)),-1!==s&&-1!==o&&n.redrawLines(i.getLineAtOffset(s),i.getLineAtOffset(Math.max(s,o-1))+1,r)}}var n=this._view;if(n){var i=n.getModel(),r=this,o=i.getLineCount();if(e.textModelChangedEvent){var s=e.textModelChangedEvent.start;i.getBaseModel&&(s=i.mapOffset(s,!0));var a=i.getLineAtOffset(s);return void n.redrawLines(a,o,r)}t(e.added),t(e.removed),t(e.changed)}},_mergeAnnotation:function(e,t,n){return e||(e={}),0===n&&(e.html&&t.html?(t.html!==e.html&&!e._multiple&&this._multiAnnotation&&(e.html=this._multiAnnotation.html),e._multiple=!0):e.html=t.html),e.style=this._mergeStyle(e.style,t.style),e},_mergeStyle:function(e,t){if(t){e||(e={}),e.styleClass&&t.styleClass&&e.styleClass!==t.styleClass?e.styleClass+=" "+t.styleClass:e.styleClass=t.styleClass;var n;if(t.style){e.style||(e.style={});for(n in t.style)void 0===e.style[n]&&(e.style[n]=t.style[n])}if(t.attributes){e.attributes||(e.attributes={});for(n in t.attributes)void 0===e.attributes[n]&&(e.attributes[n]=t.attributes[n])}}return e},_setCurrentGroup:function(e){var t,n,i=this._annotationModel,r=null,o=i.getTextModel(),s=this._currentGroupAnnotation;if(-1!==e){var a=o.getLineStart(e),l=o.getLineEnd(e);for(o.getBaseModel&&(a=o.mapOffset(a),l=o.mapOffset(l)),n=i.getAnnotations(a,l);n.hasNext();)if(t=n.next(),this.isAnnotationTypeVisible(t.type)&&t.start<=a&&t.end>=l&&void 0!==t.groupId){r=t;break}if(s&&r&&s.groupId===r.groupId)return}if(this._currentGroupAnnotation=null,s&&i.removeAnnotations(s.groupType),r&&-1!==e){this._currentGroupAnnotation=r,n=i.getAnnotations();for(var d=[];n.hasNext();)t=n.next(),delete t.groupAnnotation,t.groupId===r.groupId&&(t=t.createGroupAnnotation(),d.push(t));i.replaceAnnotations(null,d)}}}),n.AnnotationTypeList.addMixin(l.prototype),d.prototype=new l,d.prototype.getAnnotations=function(e,t){for(var n=l.prototype.getAnnotations.call(this,e,t),i=this._view.getModel(),r=e;t>r;r++){var o=r-this._firstLine&1?this._oddStyle:this._evenStyle,s=r;if(i.getBaseModel){var a=i.getLineStart(s);s=i.getBaseModel().getLineAtOffset(i.mapOffset(a))}n[r]||(n[r]={}),n[r].html=this._firstLine+s+"",n[r].style||(n[r].style=o)}return n},d.prototype.getWidestAnnotation=function(){var e=this._view.getModel().getLineCount();return this.getAnnotations(e-1,e)[e-1]},d.prototype.setFirstLine=function(e){this._firstLine=void 0!==e?e:1},d.prototype._onTextModelChanged=function(e){var t=e.start,n=this._view.getModel(),i=n.getBaseModel?n.getBaseModel().getLineCount():n.getLineCount(),r=(this._firstLine+i-1+"").length;if(this._numOfDigits!==r){this._numOfDigits=r;var o=n.getLineAtOffset(t);this._view.redrawLines(o,n.getLineCount(),this)}},c.prototype=new l,h.prototype=new l,h.prototype.getRulerStyle=function(){var e={style:{lineHeight:"1px",fontSize:"1px"}};return e=this._mergeStyle(e,this._rulerStyle)},h.prototype._getTooltipContents=function(t,n){if(n&&0===n.length){var i=this._view.getModel(),r=t;if(i.getBaseModel){var o=i.getLineStart(r);r=i.getBaseModel().getLineAtOffset(i.mapOffset(o))}return s.formatMessage(e.line,r+1)}return l.prototype._getTooltipContents.call(this,t,n)},h.prototype._mergeAnnotation=function(e,t,n,i){if(0!==n)return void 0;var r=e;if(!r){var o=3*i;r={html:"&nbsp;",style:{style:{height:o+"px"}}},r.style=this._mergeStyle(r.style,t.overviewStyle)}return r},u.prototype=new c,u.prototype.onClick=function(e){if(void 0!==e){var t=this._annotationModel;if(t){var n=this._view,r=n.getModel(),o=r.getLineStart(e),s=r.getLineEnd(e,!0);r.getBaseModel&&(o=r.mapOffset(o),s=r.mapOffset(s),r=r.getBaseModel());for(var a,l=t.getAnnotations(o,s);!a&&l.hasNext();){var d=l.next();this.isAnnotationTypeVisible(d.type)&&r.getLineAtOffset(d.start)===r.getLineAtOffset(o)&&(a=d)}if(a){var c=i.Tooltip.getTooltip(this._view);c&&c.hide(),a.expanded?a.collapse():a.expand()}}}},u.prototype._getTooltipContents=function(e,t){if(t&&t.length>0){var n=this._view,i=n.getModel(),r=i.getLineStart(e);i.getBaseModel&&(r=i.mapOffset(r),i=i.getBaseModel());for(var o=i.getLineAtOffset(r),s=0;s<t.length;s++){var a=t[s];if(this.isAnnotationTypeVisible(a.type)&&i.getLineAtOffset(a.start)===o){if(t[s].expanded)break;return c.prototype._getTooltipContents.call(this,e,[a])}}}return null},u.prototype._onAnnotationModelChanged=function(e){function t(e){for(i=0;i<e.length;i++)if(o.isAnnotationTypeVisible(e[i].type)){var t=e[i].start;r.getBaseModel&&(t=r.mapOffset(t,!0)),-1!==t&&(a=Math.min(a,r.getLineAtOffset(t)))}}if(e.textModelChangedEvent)return void c.prototype._onAnnotationModelChanged.call(this,e);var n=this._view;if(n){var i,r=n.getModel(),o=this,s=r.getLineCount(),a=s;t(e.added),t(e.removed),t(e.changed);var l=n.getRulers();for(i=0;i<l.length;i++)n.redrawLines(a,s,l[i])}};var f=function(e,t){a.call(this,e,"fixed",t)};return f.prototype=r.mixin(new a,{setView:function(e){this._destroy(),a.prototype.setView.call(this,e),this._create()},_create:function(){function e(e){var t="textviewZoom",n=e.themeClass;return n?(n=n.replace(t,""),n&&(n=" "+n),n=t+n):n=t,e.themeClass=n,e.noScroll=!0,e.readonly=!0,e}function n(e,t){var n=e.y*t.zoomFactor,i=t.clientHeight*t.zoomFactor;y.top=n,y.bottom=n+i,n=g.convert({y:n},"document","page").y,n-=y.node.getBoundingClientRect().top,m.style.top=n+"px",m.style.height=i-_+"px"}function i(){var e=f._metrics.viewPadding,t=f._metrics.viewPadding,n=f.getLineHeight(),i=g.getLineHeight(),r=f.getModel().getLineCount(),o=f._lineHeight?f._scrollHeight:r*n,s=g._lineHeight?g._scrollHeight:r*i,a=s/o,l=f.getClientArea().height+e.top+e.bottom,d=g.getClientArea().height+t.top+t.bottom,c=l*a,h=f._metrics.scrollWidth;return{zoomFactor:a,documentHeight:o,zoomDocumentHeight:s,clientHeight:l,zoomClientHeight:d,scrollWidth:h,windowHeight:c,padding:e}}function r(e,t){return e.y*(t.zoomFactor+(t.windowHeight-t.clientHeight-t.scrollWidth)/t.documentHeight)}function a(e){e=e||{y:f.getTopPixel()};var t=i(),o=r(e,t);g.setTopPixel(o),n(e,t)}function l(e){var t;if(e.wrapMode&&!e.wrapOffset&&f._metrics.charWidth){var n=s.createElement(v,"div");n.style.position="fixed",n.style.left="-1000px",g._clientDiv.appendChild(n),n.textContent=new Array(Math.ceil(f.getClientArea().width/f._metrics.charWidth)+1).join("a");var i=n.getBoundingClientRect();t=Math.min(150,Math.ceil(i.right-i.left))+"px"}else t="";var r=y.node.style.width;return y.node.style.width=t,r!==t}function d(e,t,n){if(n||y.top<=e.y&&e.y<=y.bottom)y.mouseDown=!0,y.delta=t-m.getBoundingClientRect().top+y.node.getBoundingClientRect().top;else{var i=g.getOffsetAtLocation(e.x,e.y);f.setSelection(i,i,.5,function(){})}}function c(){y.mouseDown=!1}function h(e){if(y.mouseDown){var t=i(),n=Math.min(t.zoomClientHeight-t.windowHeight,Math.max(0,e-y.delta));f.setTopPixel(n*(t.documentHeight-t.clientHeight)/Math.min(t.zoomDocumentHeight,t.zoomClientHeight-t.windowHeight))}}function u(e){e.preventDefault()}var f=this.getView();if(f){var p=e(f.getOptions());p.parent=this.node;var g=this._zoomView=new t.TextView(p);g._clientDiv.contentEditable=!1,g.setModel(f.getModel());var v=f.getOptions("parent").ownerDocument,m=this._windowDiv=s.createElement(v,"div");m.className="rulerZoomWindow",this.node.appendChild(m);var _=parseInt(o.getNodeStyle(m,"border-top-width",0))+parseInt(o.getNodeStyle(m,"border-bottom-width",0)),y=this;f.addEventListener("Scroll",this._scrollListener=function(e){a(e.newValue)}),f.addEventListener("Resize",this._resizeListener=function(){l(g.getOptions()),a()}),f.addEventListener("Redraw",this._redrawListener=function(e){e.ruler||g.redrawLines(e.startLine,e.endLine)}),f.addEventListener("Options",this._optionsListener=function(t){var n=e(t.options);g.setOptions(n),l(g.getOptions())}),g.addEventListener("LineStyle",this._lineListener=function(e){f.onLineStyle(e)}),s.isIOS||s.isAndroid?(m.addEventListener("touchstart",function(e){var t=e.touches;1===t.length&&(d(e,e.touches[0].clientY,!0),e.preventDefault())}),m.addEventListener("touchend",function(e){var t=e.touches;0===t.length&&c()}),m.addEventListener("touchmove",function(e){var t=e.touches;1===t.length&&h(e.touches[0].clientY)}),g.addEventListener("TouchStart",function(e){1===e.touchCount&&(d(e,e.event.touches[0].clientY),u(e))})):(m.style.pointerEvents="none",g.addEventListener("MouseDown",function(e){var t=e.event;(t.which?0===t.button:1===t.button)&&d(e,t.clientY),u(e)}),g.addEventListener("MouseUp",function(e){c(),u(e)}),g.addEventListener("MouseMove",function(e){h(e.event.clientY),u(e)})),(v.defaultView||v.parentWindow).setTimeout(function(){a()},0)}},_destroy:function(){var e=this.getView();e&&(e.removeEventListener("Scroll",this._scrollListener),this._scrollListener=null,e.removeEventListener("Resize",this._resizeListener),this._resizeListener=null,e.removeEventListener("Redraw",this._redrawListener),this._redrawListener=null,e.removeEventListener("Options",this._optionsListener),this._optionsListener=null);var t=this._zoomView;t&&(t.removeEventListener("LineStyle",this._lineListener),t.setModel(null),t.destroy(),this._zoomView=null)}}),{BaseRuler:a,Ruler:l,AnnotationRuler:c,LineNumberRuler:d,OverviewRuler:h,FoldingRuler:u,ZoomRuler:f}}),n("orion/editor/textDND",["orion/util"],function(e){function t(e,t){this._view=e,this._undoStack=t,this._dragSelection=null,this._dropOffset=-1,this._dropText=null;var n=this;this._listener={onDragStart:function(e){n._onDragStart(e)},onDragEnd:function(e){n._onDragEnd(e)},onDragEnter:function(e){n._onDragEnter(e)},onDragOver:function(e){n._onDragOver(e)},onDrop:function(e){n._onDrop(e)},onDestroy:function(e){n._onDestroy(e)}},e.addEventListener("DragStart",this._listener.onDragStart),e.addEventListener("DragEnd",this._listener.onDragEnd),e.addEventListener("DragEnter",this._listener.onDragEnter),e.addEventListener("DragOver",this._listener.onDragOver),e.addEventListener("Drop",this._listener.onDrop),e.addEventListener("Destroy",this._listener.onDestroy)}return t.prototype={destroy:function(){var e=this._view;e&&(e.removeEventListener("DragStart",this._listener.onDragStart),e.removeEventListener("DragEnd",this._listener.onDragEnd),e.removeEventListener("DragEnter",this._listener.onDragEnter),e.removeEventListener("DragOver",this._listener.onDragOver),e.removeEventListener("Drop",this._listener.onDrop),e.removeEventListener("Destroy",this._listener.onDestroy),this._view=null)},_onDestroy:function(){this.destroy()},_onDragStart:function(e){var t=this._view,n=t.getSelectionText();n&&(this._dragSelection=t.getSelections(),e.event.dataTransfer.effectAllowed="copyMove",e.event.dataTransfer.setData("Text",n))},_onDragEnd:function(t){if(this._dragSelection){var n=this._view,i=t.event.dataTransfer.dropEffect;e.isFirefox||("none"!==i||this._dropText)&&(i=t.event.dataTransfer.dropEffect=this._dropEffect),this._undoStack&&this._undoStack.startCompoundChange();var r="move"===i&&this._dropText;if(r&&n.setText({text:"",selection:this._dragSelection}),this._dropText){var o=this._dropText,s=this._dropOffset;r&&this._dragSelection.forEach(function(e){s>=e.end?s-=e.end-e.start:s>=e.start&&(s=e.start)}),n.setText(o,s,s),n.setSelection(s,s+o.length),this._dropText=null,this._dropOffset=-1}this._undoStack&&this._undoStack.endCompoundChange(),this._dragSelection=null}},_onDragEnter:function(e){this._onDragOver(e)},_onDragOver:function(t){var n=t.event.dataTransfer.types,i=!this._view.getOptions("readonly");if(i&&n&&(i=n.contains?n.contains("text/plain")||n.contains("Text"):-1!==n.indexOf("text/plain")||-1!==n.indexOf("Text")),i){if(!e.isFirefox){var r=e.isMac?t.event.altKey:t.event.ctrlKey;this._dropEffect=t.event.dataTransfer.dropEffect=r?"copy":"move"}}else t.event.dataTransfer.dropEffect="none"},_onDrop:function(t){var n=this._view,i=t.event.dataTransfer.getData("Text");if(i){e.isFirefox||(t.event.dataTransfer.dropEffect=this._dropEffect);var r=n.getOffsetAtLocation(t.x,t.y);this._dragSelection?(this._dropOffset=r,this._dropText=i):(n.setText(i,r,r),n.setSelection(r,r+i.length))}}},{TextDND:t}}),n("orion/editor/linkedMode",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/keyModes","orion/editor/annotations","orion/objects","orion/util"],function(e,t,n,i,r){function o(e){this._data=e}function s(e,t,i){var r=e.getTextView();n.KeyMode.call(this,r),this.editor=e,this.undoStack=t,this.contentAssist=i,this.linkedModeModel=null,r.setAction("linkedModeEnter",function(){return this.exitLinkedMode(!0),!0}.bind(this)),r.setAction("linkedModeCancel",function(){return this.exitLinkedMode(!0),!0}.bind(this)),r.setAction("linkedModeNextGroup",function(){var e=this.linkedModeModel;return this.selectLinkedGroup((e.selectedGroupIndex+1)%e.groups.length),!0}.bind(this)),r.setAction("linkedModePreviousGroup",function(){var e=this.linkedModeModel;return this.selectLinkedGroup(e.selectedGroupIndex>0?e.selectedGroupIndex-1:e.groups.length-1),!0}.bind(this)),this.linkedModeListener={onActivating:function(){this._groupContentAssistProvider&&(this.contentAssist.setProviders([this._groupContentAssistProvider]),this.contentAssist.setProgress(null))}.bind(this),onModelChanged:function(e){if(!this.ignoreVerify){for(var t,n,i=this.editor.mapOffset(e.start),r=this.linkedModeModel;r&&(t=this._getPositionChanged(r,i,i+e.removedCharCount),n=t.position,void 0===n||n.model!==r);)this.exitLinkedMode(!1),r=this.linkedModeModel;if(r){for(var o,s,a=0,l=e.addedCharCount-e.removedCharCount,d=t.positions,c=0;c<d.length;++c){s=d[c],o=s.position;var h=o.offset<=i&&i<=o.offset+o.length;h&&!s.ansestor?(o.offset+=a,o.length+=l,a+=l):(o.offset+=a,s.ansestor&&h&&(o.length+=l)),s.escape&&(s.model.escapePosition=o.offset)}this._updateAnnotations(d)}}}.bind(this),onVerify:function(e){if(!this.ignoreVerify){for(var t,n,i=this.editor.mapOffset(e.start),r=this.editor.mapOffset(e.end),o=this.linkedModeModel;o&&(t=this._getPositionChanged(o,i,r),n=t.position,void 0===n||n.model!==o);)this.exitLinkedMode(!1),o=this.linkedModeModel;if(o){var s=this._compoundChange;s?(s.owner.model!==o||s.owner.group!==n.group)&&(this.endUndo(),this.startUndo()):this.startUndo(),o.selectedGroupIndex=n.group;for(var a,l,d=0,c=e.text.length-(r-i),h=t.positions,u=i-n.position.offset,f=r-n.position.offset,p=0;p<h.length;++p)l=h[p],a=l.position,l.oldOffset=a.offset,l.model===o&&l.group===n.group?(a.offset+=d,a.length+=c,d+=c):(a.offset+=d,l.ansestor&&(a.length+=n.count*c)),l.escape&&(l.model.escapePosition=a.offset);this.ignoreVerify=!0;var g=0;for(p=h.length-1;p>=0;p--)if(l=h[p],l.model===o&&l.group===n.group){var v=e.text;Array.isArray(v)&&(v=e.text[p]),this.editor.setText(v,l.oldOffset+u,l.oldOffset+f,!1),g=l.oldOffset<=e.start?g+c:g}this.ignoreVerify=!1,this.editor.setCaretOffset(e.end+g),e.text=null,this._updateAnnotations(h)}}}.bind(this)}}return o.prototype={chop:function(e,t){return t.substring(e.length)},computeProposals:function(e,t,n){var i=n.prefix,r=[],o=this._data.style?this._data.style:null;o=o?o:"emphasis";for(var s=this._data.values,a=0;a<s.length;a++){var l=s[a];"string"==typeof l&&0===l.indexOf(i)?r.push({proposal:this.chop(i,l),description:l,hover:l,style:o}):"object"==typeof l&&l.proposal&&r.push({proposal:this.chop(i,l.proposal),description:l.description?l.description:l.proposal,hover:l.hover?l.hover:l.proposal,style:o})}var d=this._data.title?this._data.title:null;return 0<r.length&&r.splice(0,0,{proposal:"",description:d?d:"Options",style:"noemphasis_title",unselectable:!0}),r}},s.prototype=new n.KeyMode,r.mixin(s.prototype,{createKeyBindings:function(){var e=t.KeyBinding,n=[];return n.push({actionID:"linkedModeEnter",keyBinding:new e(13)}),n.push({actionID:"linkedModeCancel",keyBinding:new e(27)}),n.push({actionID:"linkedModeNextGroup",keyBinding:new e(9)}),n.push({actionID:"linkedModePreviousGroup",keyBinding:new e(9,!1,!0)}),n},enterLinkedMode:function(t){if(!this.linkedModeModel){var n=this.editor.getTextView();n.addKeyMode(this),n.addEventListener("Verify",this.linkedModeListener.onVerify),n.addEventListener("ModelChanged",this.linkedModeListener.onModelChanged);var i=this.contentAssist;i.addEventListener("Activating",this.linkedModeListener.onActivating),this.editor.reportStatus(e.linkedModeEntered,null,!0)}this._sortedPositions=null,this.linkedModeModel&&(t.previousModel=this.linkedModeModel,t.parentGroup=this.linkedModeModel.selectedGroupIndex,this.linkedModeModel.nextModel=t),this.linkedModeModel=t;var r=!0,o=this.editor.getCaretOffset();t.groups[0].positions.some(function(e){return e.offset<=o&&o<=e.offset+e.length?(r=!1,!0):void 0}),this.selectLinkedGroup(0,r)},exitLinkedMode:function(t){if(this.isActive()){this._compoundChange&&(this.endUndo(),this._compoundChange=null),this._sortedPositions=null;var n=this.linkedModeModel;if(this.linkedModeModel=n.previousModel,n.parentGroup=n.previousModel=void 0,this.linkedModeModel&&(this.linkedModeModel.nextModel=void 0),!this.linkedModeModel){var i=this.editor,r=i.getTextView();r.removeKeyMode(this),r.removeEventListener("Verify",this.linkedModeListener.onVerify),r.removeEventListener("ModelChanged",this.linkedModeListener.onModelChanged);var o=this.contentAssist;o.removeEventListener("Activating",this.linkedModeListener.onActivating),o.offset=void 0,this.editor.reportStatus(e.linkedModeExited,null,!0)}t&&"number"==typeof n.escapePosition&&i.setCaretOffset(n.escapePosition,!1),this.selectLinkedGroup(0)}},startUndo:function(){if(this.undoStack){var e=this,t=this.linkedModeModel;this._compoundChange=this.undoStack.startCompoundChange({model:t,group:t.selectedGroupIndex,end:function(){e._compoundChange=null}})}},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},isActive:function(){return Boolean(this.linkedModeModel)},isStatusActive:function(){return Boolean(this.linkedModeModel)},selectLinkedGroup:function(e,t){var n=this.linkedModeModel;if(n){n.selectedGroupIndex=e;var i=n.groups[e],r=i.positions[0],s=this.editor;(void 0===t||t)&&s.setSelection(r.offset,r.offset+r.length);var a=this.contentAssist;if(a)if(a.offset=void 0,i.data&&"link"===i.data.type&&i.data.values){var l=this._groupContentAssistProvider=new o(i.data);l.getPrefix=function(){var e=s.getSelection();if(e.start===e.end){var t=s.getCaretOffset();if(r.offset<=t&&t<=r.offset+r.length)return s.getText(r.offset,t)}return""},a.offset=r.offset,a.deactivate(),a.activate()}else this._groupContentAssistProvider&&(this._groupContentAssistProvider=null,a.deactivate())}this._updateAnnotations()},_getModelPositions:function(e,t,n){for(var i=t.groups,r=0;r<i.length;r++)for(var o=i[r].positions,s=0;s<o.length;s++){var a=o[s];n&&(a={offset:a.offset+n,length:a.length});var l={index:s,group:r,count:o.length,model:t,position:a};e.push(l),t.nextModel&&t.nextModel.parentGroup===r&&(l.ansestor=!0,this._getModelPositions(e,t.nextModel,(n||0)+o[s].offset-o[0].offset))}},_getSortedPositions:function(e){var t=this._sortedPositions;if(!t){for(t=[];e.previousModel;)e=e.previousModel;for(this._getModelPositions(t,e);e;)"number"==typeof e.escapePosition&&t.push({escape:!0,model:e,position:{offset:e.escapePosition,length:0}}),e=e.nextModel;t.sort(function(e,t){return e.position.offset-t.position.offset}),this._sortedPositions=t}return t},_getPositionChanged:function(e,t,n){for(var i,r=this._getSortedPositions(e),o=r.length-1;o>=0;o--)if(!r[o].escape){var s=r[o].position;if(s.offset<=t&&n<=s.offset+s.length){i=r[o];break}}return{position:i,positions:r}},_updateAnnotations:function(e){var t=this.editor.getAnnotationModel();if(t){for(var n,r=[],o=[],s=t.getAnnotations();s.hasNext();)switch(n=s.next(),n.type){case i.AnnotationType.ANNOTATION_LINKED_GROUP:case i.AnnotationType.ANNOTATION_CURRENT_LINKED_GROUP:case i.AnnotationType.ANNOTATION_SELECTED_LINKED_GROUP:r.push(n)}var a=this.linkedModeModel;if(a){e=e||this._getSortedPositions(a);for(var l=0;l<e.length;l++){var d=e[l];if(d.model===a&&!d.escape){var c=i.AnnotationType.ANNOTATION_LINKED_GROUP;d.group===a.selectedGroupIndex&&(c=0===d.index&&d.count>1?i.AnnotationType.ANNOTATION_SELECTED_LINKED_GROUP:i.AnnotationType.ANNOTATION_CURRENT_LINKED_GROUP),d=d.position,n=i.AnnotationType.createAnnotation(c,d.offset,d.offset+d.length,""),o.push(n)}}}t.replaceAnnotations(r,o)}}}),{LinkedMode:s}}),n("orion/editor/factories",["orion/editor/actions","orion/editor/undoStack","orion/editor/rulers","orion/editor/annotations","orion/editor/textDND","orion/editor/linkedMode","orion/util"],function(e,t,n,i,r,o,s){function a(){}function l(){}function d(){}function c(){}function h(){}function u(){}function f(){}var p={};return a.prototype={createKeyBindings:function(t,n,i,r){var s=new e.TextActions(t,n,r),a=new o.LinkedMode(t,n,i),l=new e.SourceCodeActions(t,n,i,a);return{textActions:s,linkedMode:a,sourceCodeActions:l}}},p.KeyBindingsFactory=a,l.prototype={createUndoStack:function(e){var n=e.getTextView();return new t.UndoStack(n,200)}},p.UndoFactory=l,d.prototype={createLineNumberRuler:function(e){return new n.LineNumberRuler(e,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"})}},p.LineNumberRulerFactory=d,c.prototype={createFoldingRuler:function(e){return new n.FoldingRuler(e,"left",{styleClass:"ruler folding"})}},p.FoldingRulerFactory=c,h.prototype={createZoomRuler:function(){return new n.ZoomRuler(s.isIOS||s.isAndroid?"right":"innerRight",{styleClass:"ruler zoom"})}},p.ZoomRulerFactory=h,u.prototype={createAnnotationModel:function(e){return new i.AnnotationModel(e)},createAnnotationStyler:function(e,t){return new i.AnnotationStyler(e,t)},createAnnotationRulers:function(e){var t=new n.AnnotationRuler(e,"left",{styleClass:"ruler annotations"}),i=new n.OverviewRuler(e,"right",{styleClass:"ruler overview"});return{annotationRuler:t,overviewRuler:i}}},p.AnnotationFactory=u,f.prototype={createTextDND:function(e,t){return new r.TextDND(e.getTextView(),t)}},p.TextDNDFactory=f,p}),n("orion/editor/editorFeatures",["orion/editor/factories","orion/editor/actions","orion/editor/linkedMode","orion/objects"],function(e,t,n,i){return i.mixin({},e,t,n)}),function(){function e(e){this.tokens=[],this.tokens.links={},this.options=e||c.defaults,this.rules=h.normal,this.options.gfm&&(this.rules=this.options.tables?h.tables:h.gfm)}function t(e,t){if(this.options=t||c.defaults,this.links=e,this.rules=u.normal,this.renderer=this.options.renderer||new i,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.rules=this.options.breaks?u.breaks:u.gfm:this.options.pedantic&&(this.rules=u.pedantic)}function i(e){this.options=e||{}}function r(e){this.tokens=[],this.token=null,this.options=e||c.defaults,this.options.renderer=this.options.renderer||new i,this.renderer=this.options.renderer,this.renderer.options=this.options}function o(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function s(e){return e.replace(/&([#\w]+);/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?String.fromCharCode("x"===t.charAt(1)?parseInt(t.substring(2),16):+t.substring(1)):""})}function a(e,t){return e=e.source,t=t||"",function n(i,r){return i?(r=r.source||r,r=r.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(i,r),n):new RegExp(e,t)}}function l(){}function d(e){for(var t,n,i=1;i<arguments.length;i++){t=arguments[i];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}function c(t,n,i){if(i||"function"==typeof n){i||(i=n,n=null),n=d({},c.defaults,n||{});var s,a,l=n.highlight,h=0;try{s=e.lex(t,n)}catch(u){return i(u)}a=s.length;var f=function(){var e,t;try{e=r.parse(s,n)}catch(o){t=o}return n.highlight=l,t?i(t):i(null,e)};if(!l||l.length<3)return f();if(delete n.highlight,!a)return f();for(;h<s.length;h++)!function(e){return"code"!==e.type?--a||f():l(e.text,e.lang,function(t,n){return null==n||n===e.text?--a||f():(e.text=n,e.escaped=!0,void(--a||f()))})}(s[h])}else try{return n&&(n=d({},c.defaults,n)),r.parse(e.lex(t,n),n)}catch(u){if(u.message+="\nPlease report this to https://github.com/chjj/marked.",(n||c.defaults).silent)return"<p>An error occured:</p><pre>"+o(u.message+"",!0)+"</pre>";throw u}}var h={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:l,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:l,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:l,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};h.bullet=/(?:[*+-]|\d+\.)/,h.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,h.item=a(h.item,"gm")(/bull/g,h.bullet)(),h.list=a(h.list)(/bull/g,h.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+h.def.source+")")(),h.blockquote=a(h.blockquote)("def",h.def)(),h._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",h.html=a(h.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,h._tag)(),h.paragraph=a(h.paragraph)("hr",h.hr)("heading",h.heading)("lheading",h.lheading)("blockquote",h.blockquote)("tag","<"+h._tag)("def",h.def)(),h.normal=d({},h),h.gfm=d({},h.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/}),h.gfm.paragraph=a(h.paragraph)("(?!","(?!"+h.gfm.fences.source.replace("\\1","\\2")+"|"+h.list.source.replace("\\1","\\3")+"|")(),h.tables=d({},h.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),e.rules=h,e.lex=function(t,n){var i=new e(n);return i.lex(t)},e.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},e.prototype.token=function(e,t,n){for(var i,r,o,s,a,l,d,c,u,e=e.replace(/^ +$/gm,"");e;)if((o=this.rules.newline.exec(e))&&(e=e.substring(o[0].length),o[0].length>1&&this.tokens.push({type:"space"})),o=this.rules.code.exec(e))e=e.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?o:o.replace(/\n+$/,"")});else if(o=this.rules.fences.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"code",lang:o[2],text:o[3]});else if(o=this.rules.heading.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"heading",depth:o[1].length,text:o[2]});else if(t&&(o=this.rules.nptable.exec(e))){for(e=e.substring(o[0].length),l={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/\n$/,"").split("\n")},c=0;c<l.align.length;c++)l.align[c]=/^ *-+: *$/.test(l.align[c])?"right":/^ *:-+: *$/.test(l.align[c])?"center":/^ *:-+ *$/.test(l.align[c])?"left":null;for(c=0;c<l.cells.length;c++)l.cells[c]=l.cells[c].split(/ *\| */);this.tokens.push(l)}else if(o=this.rules.lheading.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"heading",depth:"="===o[2]?1:2,text:o[1]});else if(o=this.rules.hr.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"hr"});else if(o=this.rules.blockquote.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"blockquote_start"}),o=o[0].replace(/^ *> ?/gm,""),this.token(o,t,!0),this.tokens.push({type:"blockquote_end"});else if(o=this.rules.list.exec(e)){for(e=e.substring(o[0].length),s=o[2],this.tokens.push({type:"list_start",ordered:s.length>1}),o=o[0].match(this.rules.item),i=!1,u=o.length,c=0;u>c;c++)l=o[c],d=l.length,l=l.replace(/^ *([*+-]|\d+\.) +/,""),~l.indexOf("\n ")&&(d-=l.length,l=this.options.pedantic?l.replace(/^ {1,4}/gm,""):l.replace(new RegExp("^ {1,"+d+"}","gm"),"")),this.options.smartLists&&c!==u-1&&(a=h.bullet.exec(o[c+1])[0],s===a||s.length>1&&a.length>1||(e=o.slice(c+1).join("\n")+e,c=u-1)),r=i||/\n\n(?!\s*$)/.test(l),c!==u-1&&(i="\n"===l.charAt(l.length-1),r||(r=i)),this.tokens.push({type:r?"loose_item_start":"list_item_start"}),this.token(l,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(o=this.rules.html.exec(e))e=e.substring(o[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:"pre"===o[1]||"script"===o[1]||"style"===o[1],text:o[0],isHTML:!0});else if(!n&&t&&(o=this.rules.def.exec(e)))e=e.substring(o[0].length),this.tokens.links[o[1].toLowerCase()]={href:o[2],title:o[3]},this.tokens.push({type:"def",id:o[1].toLowerCase(),href:o[2],title:o[3]});else if(t&&(o=this.rules.table.exec(e))){for(e=e.substring(o[0].length),l={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/(?: *\| *)?\n$/,"").split("\n")},c=0;c<l.align.length;c++)l.align[c]=/^ *-+: *$/.test(l.align[c])?"right":/^ *:-+: *$/.test(l.align[c])?"center":/^ *:-+ *$/.test(l.align[c])?"left":null;for(c=0;c<l.cells.length;c++)l.cells[c]=l.cells[c].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(l)}else if(t&&(o=this.rules.paragraph.exec(e)))e=e.substring(o[0].length),this.tokens.push({type:"paragraph",text:"\n"===o[1].charAt(o[1].length-1)?o[1].slice(0,-1):o[1]});else if(o=this.rules.text.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"text",text:o[0]});else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0));return this.tokens};var u={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:l,tag:/^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:l,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};u._inside=/(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/,u._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,u.link=a(u.link)("inside",u._inside)("href",u._href)(),u.reflink=a(u.reflink)("inside",u._inside)(),u.normal=d({},u),u.pedantic=d({},u.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),u.gfm=d({},u.normal,{escape:a(u.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:a(u.text)("]|","~]|")("|","|https?://|")()}),u.breaks=d({},u.gfm,{br:a(u.br)("{2,}","*")(),text:a(u.gfm.text)("{2,}","*")()}),t.rules=u,t.output=function(e,n,i){var r=new t(n,i);return r.output(e)},t.prototype.output=function(e){for(var t,n,i,r,s="";e;)if(r=this.rules.escape.exec(e))e=e.substring(r[0].length),s+=r[1];else if(r=this.rules.autolink.exec(e))e=e.substring(r[0].length),"@"===r[2]?(n=this.mangle(":"===r[1].charAt(6)?r[1].substring(7):r[1]),i=this.mangle("mailto:")+n):(n=o(r[1]),i=n),s+=this.renderer.link(i,null,n);else if(this.inLink||!(r=this.rules.url.exec(e))){if(r=this.rules.tag.exec(e))!this.inLink&&/^<a /i.test(r[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(r[0])&&(this.inLink=!1),e=e.substring(r[0].length),s+=this.options.sanitize?o(r[0]):r[0];else if(r=this.rules.link.exec(e))e=e.substring(r[0].length),this.inLink=!0,s+=this.outputLink(r,{href:r[2],title:r[3]}),this.inLink=!1;else if((r=this.rules.reflink.exec(e))||(r=this.rules.nolink.exec(e))){if(e=e.substring(r[0].length),t=(r[2]||r[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){s+=r[0].charAt(0),e=r[0].substring(1)+e;continue}this.inLink=!0,s+=this.outputLink(r,t),this.inLink=!1}else if(r=this.rules.strong.exec(e))e=e.substring(r[0].length),s+=this.renderer.strong(this.output(r[2]||r[1]));else if(r=this.rules.em.exec(e))e=e.substring(r[0].length),s+=this.renderer.em(this.output(r[2]||r[1]));else if(r=this.rules.code.exec(e))e=e.substring(r[0].length),s+=this.renderer.codespan(o(r[2],!0)); else if(r=this.rules.br.exec(e))e=e.substring(r[0].length),s+=this.renderer.br();else if(r=this.rules.del.exec(e))e=e.substring(r[0].length),s+=this.renderer.del(this.output(r[1]));else if(r=this.rules.text.exec(e))e=e.substring(r[0].length),s+=o(this.smartypants(r[0]));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(r[0].length),n=o(r[1]),i=n,s+=this.renderer.link(i,null,n);return s},t.prototype.outputLink=function(e,t){var n=o(t.href),i=t.title?o(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,i,this.output(e[1])):this.renderer.image(n,i,o(e[1]))},t.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/--/g,"—").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},t.prototype.mangle=function(e){for(var t,n="",i=e.length,r=0;i>r;r++)t=e.charCodeAt(r),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},i.prototype.code=function(e,t,n){if(this.options.highlight){var i=this.options.highlight(e,t);null!=i&&i!==e&&(n=!0,e=i)}return t?'<pre><code class="'+this.options.langPrefix+o(t,!0)+'">'+(n?e:o(e,!0))+"\n</code></pre>\n":"<pre><code>"+(n?e:o(e,!0))+"\n</code></pre>"},i.prototype.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},i.prototype.def=function(){return""},i.prototype.html=function(e){return e},i.prototype.heading=function(e,t,n){return"<h"+t+' id="'+this.options.headerPrefix+n.toLowerCase().replace(/[^\w]+/g,"-")+'">'+e+"</h"+t+">\n"},i.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},i.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"</"+n+">\n"},i.prototype.listitem=function(e){return"<li>"+e+"</li>\n"},i.prototype.paragraph=function(e){return"<p>"+e+"</p>\n"},i.prototype.table=function(e,t){return"<table>\n<thead>\n"+e+"</thead>\n<tbody>\n"+t+"</tbody>\n</table>\n"},i.prototype.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},i.prototype.tablecell=function(e,t){var n=t.header?"th":"td",i=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return i+e+"</"+n+">\n"},i.prototype.strong=function(e){return"<strong>"+e+"</strong>"},i.prototype.em=function(e){return"<em>"+e+"</em>"},i.prototype.codespan=function(e){return"<code>"+e+"</code>"},i.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},i.prototype.del=function(e){return"<del>"+e+"</del>"},i.prototype.link=function(e,t,n){if(this.options.sanitize){try{var i=decodeURIComponent(s(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(r){return""}if(0===i.indexOf("javascript:"))return""}var o='<a href="'+e+'"';return t&&(o+=' title="'+t+'"'),o+=">"+n+"</a>"},i.prototype.image=function(e,t,n){var i='<img src="'+e+'" alt="'+n+'"';return t&&(i+=' title="'+t+'"'),i+=this.options.xhtml?"/>":">"},r.parse=function(e,t,n){var i=new r(t,n);return i.parse(e)},r.prototype.parse=function(e){this.inline=new t(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var n="";this.next();)n+=this.tok();return n},r.prototype.next=function(){return this.token=this.tokens.pop()},r.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},r.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},r.prototype.tok=function(){switch(this.token.type){case"space":return"";case"def":return this.renderer.def(this.token.id,this.token.href,this.token.title);case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,i,r,o="",s="";for(n="",e=0;e<this.token.header.length;e++)i={header:!0,align:this.token.align[e]},n+=this.renderer.tablecell(this.inline.output(this.token.header[e]),{header:!0,align:this.token.align[e]});for(o+=this.renderer.tablerow(n),e=0;e<this.token.cells.length;e++){for(t=this.token.cells[e],n="",r=0;r<t.length;r++)n+=this.renderer.tablecell(this.inline.output(t[r]),{header:!1,align:this.token.align[r]});s+=this.renderer.tablerow(n)}return this.renderer.table(o,s);case"blockquote_start":for(var s="";"blockquote_end"!==this.next().type;)s+=this.tok();return this.renderer.blockquote(s);case"list_start":for(var s="",a=this.token.ordered;"list_end"!==this.next().type;)s+=this.tok();return this.renderer.list(s,a);case"list_item_start":for(var s="";"list_item_end"!==this.next().type;)s+="text"===this.token.type?this.parseText():this.tok();return this.renderer.listitem(s);case"loose_item_start":for(var s="";"list_item_end"!==this.next().type;)s+=this.tok();return this.renderer.listitem(s);case"html":var l=this.token.pre||this.options.pedantic?this.token.text:this.inline.output(this.token.text);return this.renderer.html(l);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText())}},l.exec=l,c.options=c.setOptions=function(e){return d(c.defaults,e),c},c.defaults={gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,smartLists:!1,silent:!1,highlight:null,langPrefix:"lang-",smartypants:!1,headerPrefix:"",renderer:new i,xhtml:!1},c.Parser=r,c.parser=r.parse,c.Renderer=i,c.Lexer=e,c.lexer=e.lex,c.InlineLexer=t,c.inlineLexer=t.output,c.parse=c,"function"==typeof n&&n.amd?n("marked/marked",[],function(){return c}):"object"==typeof exports?module.exports=c:this.marked=c}.call(function(){return this||("undefined"!=typeof window?window:global)}()),n("orion/hover",["marked/marked","lsp/utils"],function(e,t){function n(e,t){this.editor=e,this.hoverFactory=t,this.inputManager=t.inputManager,this.serviceRegistry=t.serviceRegistry,this.commandRegistry=t.commandRegistry,this._qfToolbars=[]}function i(e,t,n,i){this.serviceRegistry=e,this.inputManager=t,this.commandRegistry=n,this.languageServerRegistry=i,this.filterHoverPlugins(),this.inputManager.addEventListener("InputChanged",function(){this.filterHoverPlugins()}.bind(this))}return n.prototype={computeHoverInfo:function(e){var n=[];return this.hoverFactory._applicableProviders.forEach(function(i){if(i._id&&i.isHoverEnabled())n.push(t.computeHoverInfo(i,this.inputManager,this.editor,e));else{var r=this.serviceRegistry.getService(i);if(r&&r.computeHoverInfo){var o=this.editor.getEditorContext();n.push(r.computeHoverInfo(o,e))}}}.bind(this)),n},renderMarkDown:function(t){return e(t,{sanitize:!0})},clearQuickFixes:function(){this._qfToolbars.forEach(function(e){e.destroy()}),this._qfToolbars=[]},renderQuickFixes:function(e,t,n,i){if(e&&n){var r=document.createElement("div");r.classList.add("commandList"),n.appendChild(r);var o=[],s=this.inputManager.getFileMetadata();s&&(s.annotation=e,s.readonly=this.inputManager.getReadOnly(),this.commandRegistry.renderCommands("orion.edit.quickfix",r,s,this.editor,"quickfix",{annotation:e,postCallback:i},o),delete s.annotation,delete s.readonly)}}},i.prototype={createHover:function(e){return new n(e,this)},filterHoverPlugins:function(){var e=this.inputManager.getContentType();if(this._applicableProviders=[],e){var t=this.languageServerRegistry.getServerByContentType(e);t&&this._applicableProviders.push(t);for(var n=this.serviceRegistry.getServiceReferences("orion.edit.hover"),i=0;i<n.length;i++){var r=n[i],o=r.getProperty("contentType");o&&-1!==o.indexOf(e.id)&&this._applicableProviders.push(r)}}}},{HoverFactory:i}}),n("orion/editor/contentAssist",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/keyModes","orion/editor/eventTarget","orion/Deferred","orion/objects","orion/editor/tooltip","orion/editor/util","orion/util","orion/webui/littlelib","orion/metrics","lsp/utils"],function(e,t,n,i,r,o,s,a,l,d,c,h){function u(n,i){this.textView=n,i&&(this.pageMessage=i.getService("orion.page.message")),this.state=g.INACTIVE,this.clearProviders();var r=this;this._textViewListeners={onModelChanging:function(e){this._latestModelChangingEvent=e,e&&this._updateFilterText(e)}.bind(this),onSelection:function(e){this.isDeactivatingChange(this._latestModelChangingEvent,e)?this.setState(g.INACTIVE):this.isActive()&&(this.state===g.ACTIVE&&this.setState(g.FILTERING),this.filterProposals()),this._latestModelChangingEvent=null}.bind(this),onScroll:function(){this.setState(g.INACTIVE)}.bind(this)},n.setKeyBinding(l.isMac?new t.KeyBinding(" ",!1,!1,!1,!0):new t.KeyBinding(" ",!0),"contentAssist"),n.setKeyBinding(l.isMac?new t.KeyBinding(" ",!1,!1,!0,!0):new t.KeyBinding(" ",!0,!1,!0),"contentAssist"),n.setAction("contentAssist",function(){return n.getOptions("readonly")||r.activate(),!0},{name:e.contentAssist})}function f(e,t){var i=e.textView;n.KeyMode.call(this,i),this.contentAssist=e,this.widget=t,this.proposals=[];var r=this;this.contentAssist.addEventListener("ProposalsComputed",function(e){if(r.proposals=e.data.proposals,0===r.proposals.length)r.selectedIndex=-1,r.cancel();else{for(r.selectedIndex=0;r.proposals[r.selectedIndex]&&r.proposals[r.selectedIndex].unselectable;)r.selectedIndex++;if(r.proposals[r.selectedIndex]){if(r.widget){var t=!0;if(e.autoApply){for(var n=r.selectedIndex+1;r.proposals[n]&&r.proposals[n].unselectable;)n++;r.proposals[n]||(t=!1,r.contentAssist.apply(r.proposals[r.selectedIndex]))}t&&(r.widget.show(),r.widget.selectNode(r.selectedIndex))}}else r.selectedIndex=-1,r.cancel()}}),i.setAction("contentAssistApply",function(){return this.enter()}.bind(this)),i.setAction("contentAssistCancel",function(){return this.cancel()}.bind(this)),i.setAction("contentAssistNextProposal",function(){return this.lineDown()}.bind(this)),i.setAction("contentAssistPreviousProposal",function(){return this.lineUp()}.bind(this)),i.setAction("contentAssistNextPage",function(){return this.pageDown()}.bind(this)),i.setAction("contentAssistPreviousPage",function(){return this.pageUp()}.bind(this)),i.setAction("contentAssistHome",function(){return this.widget&&this.widget.scrollIndex(0,!0),this.lineDown(0)}.bind(this)),i.setAction("contentAssistEnd",function(){return this.lineUp(this.proposals.length-1)}.bind(this)),i.setAction("contentAssistTab",function(){return this.tab()}.bind(this)),this.widget&&(this.widget.setContentAssistMode(this),this.widget.createAccessible())}function p(e,t){this.contentAssist=e,this.textView=this.contentAssist.getTextView(),this.isShowing=!1,this._useResizeTimer=!1;var n=this.textView.getOptions("parent").ownerDocument;if(this.parentNode="string"==typeof t?n.getElementById(t):t,!this.parentNode){this.parentNode=l.createElement(n,"div"),this.parentNode.className="contentassist";var i=n.getElementsByTagName("body")[0];if(!i)throw new Error("parentNode is required");i.appendChild(this.parentNode)}var r=window.MutationObserver||window.MozMutationObserver;r&&l.isFirefox?this._mutationObserver=new r(function(){this._contentAssistMode._showTooltip(!0,!0)}.bind(this)):this._useResizeTimer=!0,a.addEventListener(this.parentNode,"scroll",this.onScroll.bind(this));var o=this;this.autoDismissFunctionAdded=!1,this.autoDismissFunction=function(){o.contentAssist.deactivate()},this.contentAssist.addEventListener("Deactivating",function(){o.hide()}),this.scrollListener=function(){o.isShowing&&o.position()},a.addEventListener(n,"scroll",this.scrollListener)}var g={INACTIVE:1,ACTIVE:2,FILTERING:3},v={selected:"selected",hr:"proposal-hr",emphasis:"proposal-emphasis",strikethrough:"proposal-strikethrough",noemphasis:"proposal-noemphasis",noemphasis_title:"proposal-noemphasis-title",noemphasis_title_keywords:"proposal-noemphasis-title-keywords",dfault:"proposal-default"};return u.prototype={apply:function(e){if(!e)return!1;var t=this.textView,n=t.getSelection(),i=this._initialCaretOffset,r=i,o=Math.max(n.start,n.end),s=o,a=t.getModel();a.getBaseModel&&(r=a.mapOffset(r),s=a.mapOffset(s),a=a.getBaseModel()),e.overwrite&&(i="string"==typeof e.prefix?r-e.prefix.length:this.getPrefixStart(a,r));var l={proposal:e,start:r,end:s};this.setState(g.INACTIVE);var d="string"==typeof e?e:e.proposal;if(t.setText(d,i,o),e.additionalEdits)for(var h,u=0;u<e.additionalEdits.length;u++)h=e.additionalEdits[u],t.setText(h.text,h.offset,h.offset+h.length);return this.dispatchEvent({type:"ProposalApplied",data:l}),c.logEvent("contentAssist","apply"),!0},activate:function(e,t){this.state===g.INACTIVE&&(c.logEvent("contentAssist","activate",void 0,t?0:1),this._autoTriggered=t?!0:!1,this.setState(g.ACTIVE,e))},deactivate:function(){this.setState(g.INACTIVE)},getTextView:function(){return this.textView},isActive:function(){return this.state===g.ACTIVE||this.state===g.FILTERING},isDeactivatingChange:function(e,t){var n=!1,i=Array.isArray(t.newValue)?t.newValue:[t.newValue],r=i[0].start<this._initialCaretOffset;return r||!e?n=!0:e&&(n=e.removedLineCount>0||e.addedLineCount>0),n},setState:function(e,t){var n;e===g.ACTIVE?(n="Activating",this._mode&&this._mode.setActive(!0)):e===g.INACTIVE&&(n="Deactivating",this._mode&&this._mode.setActive(!1)),n&&this.dispatchEvent({type:n,providers:t}),this.state=e,this.onStateChange(e)},setMode:function(e){this._mode=e},onStateChange:function(e){e===g.INACTIVE?(this._removeTextViewListeners(),this._filterText="",this._initialCaretOffset=-1,this._computedProposals=null):e===g.ACTIVE&&(this._filterText="",this._addTextViewListeners(),this.computeProposals())},computeProposals:function(){var e=this.textView.getCaretOffset(),t=this.textView.getSelection(),n=Math.min(t.start,t.end);this._initialCaretOffset=Math.min(e,n),this._computedProposals=null,delete this._autoApply,this._computeProposals(this._initialCaretOffset).then(function(e){if(this.isActive()){var t=this._flatten(e);t&&Array.isArray(t)&&0<t.length&&(this._computedProposals=e);var n="boolean"==typeof this._autoApply?this._autoApply:!this._autoTriggerEnabled;this.dispatchEvent({type:"ProposalsComputed",data:{proposals:t},autoApply:n}),this._computedProposals&&this._filterText&&this.filterProposals(!0)}}.bind(this))},getPrefixStart:function(e,t){for(var n=t;n>0&&/[A-Za-z0-9_]/.test(e.getText(n-1,n));)n--;return n},handleError:function(e){"undefined"!=typeof console&&(console.log("Error retrieving content assist proposals"),console.log(e&&e.stack))},initialize:function(){this._providers.forEach(function(e){var t=e.provider;"function"==typeof t.initialize&&t.initialize()})},_computeProposals:function(t){var n=this._providers,i=this.textView,s=i.getSelection(),a=i.getModel(),l=t;a.getBaseModel&&(l=a.mapOffset(l),s.start=a.mapOffset(s.start),s.end=a.mapOffset(s.end),a=a.getBaseModel());for(var d=a.getLine(a.getLineAtOffset(l)),c=0;c<d.length&&/\s/.test(d.charAt(c));)c++;var u=d.substring(0,c),f=i.getOptions("tabSize","expandTab"),p=f.expandTab?new Array(f.tabSize+1).join(" "):" ",g=a.getLineDelimiter(),v=this,m=n.map(function(e){var t,n,i,c,f,m,_=e.provider,y=_.computePrefix;if("boolean"==typeof e.autoApply&&(v._autoApply=e.autoApply),y){t=v.editorContextProvider,n=t.getEditorContext();var C=y.apply(_,[n,l]);return C.then(function(e){m={line:d,offset:l,prefix:e,selection:s,delimiter:g,tab:p,indentation:u};try{(c=_.computeContentAssist)?(m=o.mixin(m,t.getOptions()),f=c.apply(_,[n,m])):(c=_.getProposals||_.computeProposals)&&(f=c.apply(_,[a.getText(),l,m])),i=v.progress?v.progress.progress(f,"Generating content assist proposal"):f}catch(h){return(new r).reject(h)}return r.when(i)},function(e){return(new r).reject(e)})}m={line:d,offset:l,prefix:a.getText(v.getPrefixStart(a,l),l),selection:s,delimiter:g,tab:p,indentation:u};try{e.lspServer?(t=v.editorContextProvider,n=t.getEditorContext(),m=o.mixin(m,t.getOptions()),f=h.computeContentAssist(_,n,m)):(c=_.computeContentAssist)?(t=v.editorContextProvider,n=t.getEditorContext(),m=o.mixin(m,t.getOptions()),f=c.apply(_,[n,m])):(c=_.getProposals||_.computeProposals)&&(f=c.apply(_,[a.getText(),l,m])),i=v.progress?v.progress.progress(f,"Generating content assist proposal"):f}catch(w){return(new r).reject(w)}return r.when(i)}),_=r.all(m,this.handleError);return this.pageMessage&&(_=r.when(_,function(t){v.pageMessage.close();var n=!1;if(t&&t.length>0)for(var i=0;i<t.length;i++)if(Array.isArray(t[i])&&t[i].length>0){n=!0;break}return n||v.pageMessage.setErrorMessage(e.noProposals),t}),this.pageMessage.showWhile(_,e.computingProposals)),_},filterProposals:function(e){if(this._computedProposals&&(this._latestModelChangingEvent||e)){var t=this.textView.getModel();t.getBaseModel&&(t=t.getBaseModel());var n=this.getPrefixStart(t,this._initialCaretOffset),i=this.textView.getText(n,this._initialCaretOffset),r=i,o=[];this._computedProposals.forEach(function(e){if(e&&Array.isArray(e)){var t=e.filter(function(e){function t(e,t){var n=t.replace(/([.+^=!:${}()|\[\]\/\\])/g,"\\$1");return n=n.replace(/([*?])/g,".$1"),new RegExp("^"+e+n,"i")}var n;if(!e)return!1;if(r="string"==typeof e.prefix?e.prefix:i,v[e.style]===v.hr||v[e.style]===v.noemphasis_title)return!0;var o="";if(e.overwrite){if(e.name)o=e.name;else{if(!e.proposal)return!1;o=e.proposal}return n=t(r,this._filterText),n.test(o)}if(e.name||e.proposal){var s=!1;return e.name&&(n=t(r,this._filterText),s=n.test(e.name)),!s&&e.proposal&&(n=t("",this._filterText),s=n.test(e.proposal)),s}return"string"==typeof e?(n=t("",this._filterText),n.test(e)):!1},this);t.length>0&&o.push(t)}},this);var s=[];o&&(o=this._removeExtraUnselectableElements(o),s=this._flatten(o)),this.dispatchEvent({type:"ProposalsComputed",data:{proposals:s},autoApply:!1})}},_removeExtraUnselectableElements:function(e){var t=e.map(function(e){var t=e.filter(function(t,n){var i=!0;if(v[t.style]===v.hr)0===n||e.length-1===n?i=!1:v.hr===v[e[n-1].style]&&(i=!1);else if(v[t.style]===v.noemphasis_title){var r=e[n+1];r?v[r.style]===v.noemphasis_title&&(i=!1):i=!1}return i});return t});return t},setEditorContextProvider:function(e){this.editorContextProvider=e},_generateProviderId:function(){return this._idcount?this._idcount++:this._idcount=0,"ContentAssistGeneratedID_"+this._idcount},setAutoTriggerEnabled:function(e){this._autoTriggerEnabled=e,this._updateAutoTriggerListenerState()},setProviders:function(e){var t=this;this.setProviderInfoArray(e.map(function(e){return e.id?e:{provider:e,id:t._generateProviderId()}}))},setProviderInfoArray:function(e){this.clearProviders(),this._providers=e,this._charTriggersInstalled=e.some(function(e){return e.charTriggers||e.lspServer}),this._updateAutoTriggerListenerState()},getProviders:function(){return this._providers.slice()},clearProviders:function(){this._providers=[],this._charTriggersInstalled=!1,this._updateAutoTriggerListenerState()},setProgress:function(e){this.progress=e},setStyleAccessor:function(e){this._styleAccessor=e},_flatten:function(e){return e.reduce(function(e,t){var n=e,i=null;if(t&&Array.isArray(t)&&(i=t.filter(function(e){return e})),i&&Array.isArray(i)&&i.length>0){var r=i,o=e,s=i[0].style;if(s&&v[s]&&0===v[s].indexOf(v.noemphasis)&&(r=e,o=i),r.length>0){var a=r[r.length-1].style;a&&v.hr!==v[a]&&(r=r.concat({proposal:"",name:"",description:"---------------------------------",style:"hr",unselectable:!0}))}n=r.concat(o)}return n},[])},_triggerListener:function(){var e=this.textView.getCaretOffset(),t=null,n=[];if(this._charTriggersInstalled){var i=this.textView.getText(e-1,e);this._providers.forEach(function(r){var o=null;if(r.lspServer){var s=r.provider.capabilities;if(s&&s.completionProvider&&!r.charTriggers){var a=s.completionProvider,l="[";a.triggerCharacters&&a.triggerCharacters.forEach(function(e){l+=e}),l+="]",r.charTriggers=new RegExp(l)}}if(o=r.charTriggers,o&&o.test(i)){var d=!1,c=r.excludedStyles;this._styleAccessor&&c&&(t||(t=this._styleAccessor.getStyles(e-1)),d=t.some(function(e){return c.test(e.style)})),d||n.push(r)}},this),n.length>0&&this.activate(n,!0)}},_updateAutoTriggerListenerState:function(){this._boundTriggerListener||(this._boundTriggerListener=this._triggerListener.bind(this)),this._triggerListenerInstalled?this._autoTriggerEnabled&&this._charTriggersInstalled||(this.textView.removeEventListener("Modify",this._boundTriggerListener),this._triggerListenerInstalled=!1):this._autoTriggerEnabled&&this._charTriggersInstalled&&(this.textView.addEventListener("Modify",this._boundTriggerListener),this._triggerListenerInstalled=!0)},_addTextViewListeners:function(){this._textViewListenersAdded||(this.textView.addEventListener("ModelChanging",this._textViewListeners.onModelChanging),this.textView.addEventListener("Scroll",this._textViewListeners.onScroll),this.textView.addEventListener("Selection",this._textViewListeners.onSelection),this._textViewListenersAdded=!0)},_removeTextViewListeners:function(){this._textViewListenersAdded&&(this._latestModelChangingEvent=null,this.textView.removeEventListener("ModelChanging",this._textViewListeners.onModelChanging),this.textView.removeEventListener("Scroll",this._textViewListeners.onScroll),this.textView.removeEventListener("Selection",this._textViewListeners.onSelection),this._textViewListenersAdded=!1)},_updateFilterText:function(e){var t=e.removedCharCount;if(t){var n=this._filterText.length-t;this._filterText=this._filterText.substring(0,n)}var i=e.text;i&&(this._filterText=this._filterText.concat(i))}},i.EventTarget.addMixin(u.prototype),f.prototype=new n.KeyMode,o.mixin(f.prototype,{createKeyBindings:function(){var e=t.KeyBinding,n=[];return n.push({actionID:"contentAssistApply",keyBinding:new e(13)}),n.push({actionID:"contentAssistCancel",keyBinding:new e(27)}),n.push({actionID:"contentAssistNextProposal",keyBinding:new e(40)}),n.push({actionID:"contentAssistPreviousProposal",keyBinding:new e(38)}),n.push({actionID:"contentAssistNextPage",keyBinding:new e(34)}),n.push({actionID:"contentAssistPreviousPage",keyBinding:new e(33)}),n.push({actionID:"contentAssistHome",keyBinding:new e(d.KEY.HOME)}),n.push({actionID:"contentAssistEnd",keyBinding:new e(d.KEY.END)}),n.push({actionID:"contentAssistTab",keyBinding:new e(9)}),n},cancel:function(){this.getContentAssist().deactivate()},getContentAssist:function(){return this.contentAssist},getProposals:function(){return this.proposals},isActive:function(){return this.getContentAssist().isActive()},setActive:function(e){e?this.contentAssist.textView.addKeyMode(this):this.contentAssist.textView.removeKeyMode(this)},lineUp:function(e,t){return this.selectNew(e,t,!1)},lineDown:function(e,t){return this.selectNew(e,t,!0)},selectNew:function(e,t,n){var i=e;if(n){if(void 0===i&&(i=this.selectedIndex+1),i>=this.proposals.length){if(t)return!0;i=0}}else if(void 0===i&&(i=this.selectedIndex-1),0>i){if(t)return!0;i=this.proposals.length-1}for(var r=i;this.proposals[i]&&this.proposals[i].unselectable;){if(n){if(i++,i>=this.proposals.length){if(t)return!0;i=0}}else if(i--,0>i){if(t)return!0;i=this.proposals.length-1}if(i===r){i=-1;break}}return this.selectedIndex=i,this.widget&&this.widget.selectNode(i),this._showTooltip(!0),!0},_showTooltip:function(e,t){var n=s.Tooltip.getTooltip(this.contentAssist.textView),i=this,r={getTooltipInfo:function(){var e=i.widget.parentNode.getBoundingClientRect(),t={width:350,height:e.height,top:e.top};e.left+e.width>=document.documentElement.clientWidth?(t.left=e.left-t.width,t.left-=10):(t.left=e.left+e.width,t.left+=10);var n={context:{proposal:i.proposals[i.selectedIndex]},anchorArea:e,tooltipArea:t};return n}};e?n.update(r,t):n.show(r,!0,!1)},_hideTooltip:function(){var e=s.Tooltip.getTooltip(this.contentAssist.textView);e.hide(!0)},pageUp:function(){if(this.widget){var e=this.widget.getTopIndex();return e===this.selectedIndex&&(this.widget.scrollIndex(e,!1),e=this.widget.getTopIndex()),0===e?this.lineDown(e,!0):this.lineUp(e,!0)}return this.lineUp()},pageDown:function(){if(this.widget){var e=this.widget.getBottomIndex();return e===this.selectedIndex&&(this.widget.scrollIndex(e,!0),e=this.widget.getBottomIndex()),this.lineDown(e,!0)}return this.lineDown()},enter:function(){var e=this.proposals[this.selectedIndex]||null;return this.contentAssist.apply(e)},tab:function(){return this.widget?(this.widget.parentNode.focus(),!0):!1}}),p.prototype={onClick:function(e){e||(e=window.event),this.contentAssist.apply(this.getProposal(e.target||e.srcElement)),this.textView.focus()},onScroll:function(){this.previousCloneNode&&!this.preserveCloneThroughScroll&&(this._removeCloneNode(),this.previousSelectedNode.classList.add(v.selected)),this.preserveCloneThroughScroll=!1},createDiv:function(e,t,n){var i=t.ownerDocument,r=l.createElement(i,"div");r.id="contentoption"+n,r.setAttribute("role","option"),r.className=v[e.style]?v[e.style]:v.dfault;var o;"hr"===e.style?o=l.createElement(i,"hr"):(o=this._createDisplayNode(e,n),r.contentAssistProposalIndex=n),r.appendChild(o),t.appendChild(r)},createAccessible:function(){var e=this._contentAssistMode,t=this;a.addEventListener(this.parentNode,"keydown",function(n){return n||(n=window.event),n.preventDefault&&n.preventDefault(),n.keyCode===d.KEY.ESCAPE?e.cancel():n.keyCode===d.KEY.UP?e.lineUp():n.keyCode===d.KEY.DOWN?e.lineDown():n.keyCode===d.KEY.ENTER?e.enter():n.keyCode===d.KEY.PAGEDOWN?e.pageDown():n.keyCode===d.KEY.PAGEUP?e.pageUp():n.keyCode===d.KEY.HOME?(t.scrollIndex(0,!0),e.lineDown(0)):n.keyCode===d.KEY.END?e.lineUp(e.getProposals().length-1):!1})},_createDisplayNode:function(e,t){var n=document.createElement("span");if(!e)return n;if("string"==typeof e){var i=this._createNameNode(e);return i.contentAssistProposalIndex=t,i}var r,o;if(e.name&&"string"==typeof e.name)r=this._createNameNode(e.name);else if(e.description&&"string"==typeof e.description)r=this._createNameNode(e.description),o=!0;else{if(!e.proposal||"string"!=typeof e.proposal)return n;r=this._createNameNode(e.proposal)}var s,a=this._createTagsNode(e.tags);return!o&&e.description&&"string"==typeof e.description&&(s=document.createTextNode(e.description)),a&&n.appendChild(a),n.appendChild(r),s&&n.appendChild(s),r.contentAssistProposalIndex=t,n.contentAssistProposalIndex=t,n},_stopResizeTimer:function(){this._resizeTimer&&(window.clearInterval(this._resizeTimer),this._resizeTimer=null)},_startResizeTimer:function(){this._stopResizeTimer(),this._cachedResizeBound=this.parentNode.getBoundingClientRect(),this._resizeTimer=window.setInterval(function(){if(this._contentAssistMode){var e=this.parentNode.getBoundingClientRect();if(e.left===this._cachedResizeBound.left&&e.top===this._cachedResizeBound.top&&e.width===this._cachedResizeBound.width&&e.height===this._cachedResizeBound.height)return;this._cachedResizeBound=e,this._contentAssistMode._showTooltip(!0,!0)}}.bind(this),100)},_createNameNode:function(e){var t=document.createElement("span");return t.classList.add("proposal-name"),t.appendChild(document.createTextNode(e)),t},_createTagsNode:function(e){var t=null;if(e&&e.constructor===Array&&e.length>0){t=document.createElement("span");for(var n=0;n<e.length;n++){var i=e[n];if(i.content||i.cssClass||i.color){var r=document.createElement("span");i.cssClass?r.classList.add(i.cssClass):"string"==typeof i.color&&i.color.match(/^[\w-]*$/)?(r.classList.add("colorTag"),r.style.backgroundColor=i.color):r.classList.add("proposalTag"),i.content&&(r.textContent=i.content),t.appendChild(r)}}}return t},getProposal:function(e){var t=null,n=e.contentAssistProposalIndex;return void 0!==n&&(t=this._contentAssistMode.getProposals()[n]||null),t},getTopIndex:function(){for(var e=this.parentNode.childNodes,t=0;t<e.length;t++){var n=e[t];if(n.offsetTop>=this.parentNode.scrollTop)return t}return 0},getBottomIndex:function(){for(var e=this.parentNode.childNodes,t=0;t<e.length;t++){var n=e[t];if(n.offsetTop+n.offsetHeight>this.parentNode.scrollTop+this.parentNode.clientHeight)return Math.max(0,t-1)}return e.length-1},scrollIndex:function(e,t){var n=this.parentNode.childNodes[e];n&&(n.scrollIntoView(t),this.preserveCloneThroughScroll=!0)},selectNode:function(e){var t=null;if(this._hideTimeout&&(window.clearTimeout(this._hideTimeout),this._hideTimeout=null),this._fadeTimer&&(window.clearTimeout(this._fadeTimer),this._fadeTimer=null),this.previousSelectedNode&&(this.previousSelectedNode.classList.remove(v.selected),this.previousSelectedNode=null,this.previousCloneNode&&this._removeCloneNode()),-1!==e&&(t=this.parentNode.childNodes[e])){t.classList.add(v.selected),this.parentNode.setAttribute("aria-activedescendant",t.id),t.focus(),t.offsetTop<this.parentNode.scrollTop?(t.scrollIntoView(!0),this.preserveCloneThroughScroll=!0):t.offsetTop+t.offsetHeight>this.parentNode.scrollTop+this.parentNode.clientHeight&&(t.scrollIntoView(!1),this.preserveCloneThroughScroll=!0);var n=t.firstChild||t,i=n.getBoundingClientRect(),r=this.parentNode.clientWidth?this.parentNode.clientWidth:this.parentNode.getBoundingClientRect(),o=window.getComputedStyle(this.parentNode),s=window.getComputedStyle(t),a=parseInt(o.paddingLeft)+parseInt(o.paddingRight)+parseInt(s.paddingLeft)+parseInt(s.paddingRight);if(i.width>=r-a){var l=parseInt(o.top),d=t.cloneNode(!0);d.classList.add("cloneProposal"),d.style.top=l+t.offsetTop-this.parentNode.scrollTop+"px",d.style.left=o.left,d.setAttribute("id",d.id+"_clone");var c=document.documentElement.clientWidth,h=i.left+i.width-parseInt(c);if(h>0){var u=parseInt(o.left)-h;0>u&&(u=0),d.style.left=u+"px"}var f=document.createElement("div");f.id="clone_contentassist",f.classList.add("contentassist"),f.classList.add("cloneWrapper"),f.appendChild(d),f.onclick=this.parentNode.onclick,this.parentNode.parentNode.insertBefore(f,this.parentNode);var p=function(e){if(e.contentAssistProposalIndex=t.contentAssistProposalIndex,e.hasChildNodes())for(var n=0;n<e.childNodes.length;n++)p(e.childNodes[n])};p(f);var g=this;this._hideTimeout=window.setTimeout(function(){g._hideTimeout=null,t.classList.add(v.selected);var e=1;g._fadeTimer=window.setInterval(function(){!g.previousCloneNode||.01>=e?(g._removeCloneNode(),window.clearInterval(g._fadeTimer),g._fadeTimer=null):(f.style.opacity=e,f.style.filter="alpha(opacity="+100*e+")",e-=.1*e)},50)},1500),t.classList.remove(v.selected),this.previousCloneNode=f}}this.previousSelectedNode=t},setContentAssistMode:function(e){this._contentAssistMode=e},show:function(){var e=this._contentAssistMode.getProposals();if(0===e.length)this.hide();else{this.parentNode.innerHTML="";for(var t=0;t<e.length;t++)this.createDiv(e[t],this.parentNode,t);if(this.position(),this.parentNode.onclick=this.onClick.bind(this),this.isShowing=!0,this._contentAssistMode._showTooltip(!1),this._useResizeTimer?this._startResizeTimer():this._mutationObserver&&this._mutationObserver.observe(this.parentNode,{attributes:!0}),!this.autoDismissFunctionAdded){var n=s.Tooltip.getTooltip(this.contentAssist.textView);d.addAutoDismiss([this.parentNode,n._tooltipDiv],this.autoDismissFunction),this.autoDismissFunctionAdded=!0}}},hide:function(){this.parentNode.ownerDocument.activeElement===this.parentNode&&this.textView.focus(),this.parentNode.style.display="none",this.parentNode.onclick=null,this.isShowing=!1,this._useResizeTimer?this._stopResizeTimer():this._mutationObserver&&this._mutationObserver.disconnect(),this._contentAssistMode._hideTooltip(),this.autoDismissFunctionAdded&&(d.removeAutoDismiss(this.autoDismissFunction),this.autoDismissFunctionAdded=!1),this.previousSelectedNode&&(this.previousSelectedNode=null,this.previousCloneNode&&this._removeCloneNode())},position:function(){var e,t=this.contentAssist,n=this.textView;if(void 0!==t.offset){e=t.offset;var i=n.getModel();i.getBaseModel&&(e=i.mapOffset(e,!0))}else e=this.textView.getCaretOffset();var r=n.getLocationAtOffset(e);r.y+=n.getLineHeight(),this.textView.convert(r,"document","page"),this.parentNode.style.position="fixed",this.parentNode.style.left=r.x+"px",this.parentNode.style.top=r.y+"px",this.parentNode.style.display="block",this.parentNode.scrollTop=0;var o=this.parentNode.ownerDocument,s=o.documentElement.clientWidth,a=o.documentElement.clientHeight,l=a-r.y;if(this.parentNode.offsetHeight>l){var d=r.y-this.textView.getLineHeight();this.parentNode.offsetHeight>d?l>d?this.parentNode.style.maxHeight=l+"px":(this.parentNode.style.maxHeight=d+"px",this.parentNode.style.top="0"):(this.parentNode.style.top=r.y-this.parentNode.offsetHeight-this.textView.getLineHeight()+"px",this.parentNode.style.maxHeight=d+"px") }else this.parentNode.style.maxHeight=l+"px";if(r.x+this.parentNode.offsetWidth>s){var c=s-this.parentNode.offsetWidth;0>c&&(c=0),this.parentNode.style.left=c+"px",this.parentNode.style.maxWidth=s-c}else this.parentNode.style.maxWidth=s+r.x+"px"},_removeCloneNode:function(){this.parentNode.parentNode.contains(this.previousCloneNode)&&this.parentNode.parentNode.removeChild(this.previousCloneNode),this.previousCloneNode=null}},{ContentAssist:u,ContentAssistMode:f,ContentAssistWidget:p}}),n("orion/editor/emacs",["i18n!orion/editor/nls/messages","orion/editor/keyModes","orion/keyBinding","orion/util"],function(e,t,n,i){function r(e){t.KeyMode.call(this,e)}return r.prototype=new t.KeyMode,r.prototype.createKeyBindings=function(){var e=[];e.push({actionID:"emacs-beginning-of-line",keyBinding:this._createStroke("a",!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-end-of-line",keyBinding:this._createStroke("e",!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-forward-char",keyBinding:this._createStroke("f",!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-backward-char",keyBinding:this._createStroke("b",!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-forward-word",keyBinding:this._createStroke("f",!1,!1,!0)}),e.push({actionID:"emacs-backward-word",keyBinding:this._createStroke("b",!1,!1,!0)}),e.push({actionID:"emacs-next-line",keyBinding:this._createStroke("n",!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-previous-line",keyBinding:this._createStroke("p",!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-beginning-of-buffer",keyBinding:this._createStroke(188,!1,!0,!0)}),e.push({actionID:"emacs-end-of-buffer",keyBinding:this._createStroke(190,!1,!0,!0)}),e.push({actionID:"emacs-delete-backward-char",keyBinding:this._createStroke(46,!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-delete-char",keyBinding:this._createStroke("d",!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-kill-line",keyBinding:this._createStroke("k",!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-kill-word",keyBinding:this._createStroke("d",!1,!1,!0)}),e.push({actionID:"emacs-backward-kill-word",keyBinding:this._createStroke(46,!1,!1,!0)}),e.push({actionID:"undo",keyBinding:this._createSequence([this._createStroke("x",!0),this._createStroke("u")])}),e.push({actionID:"redo",keyBinding:this._createSequence([this._createStroke("x",!0),this._createStroke("r")])}),e.push({actionID:"emacs-scroll-up",keyBinding:this._createStroke("v",!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-scroll-down",keyBinding:this._createStroke("v",!1,!1,!0)}),e.push({actionID:"emacs-set-mark-command",keyBinding:this._createStroke(" ",!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-reset-mark-command",keyBinding:this._createStroke("g",!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-exchange-point-and-mark",keyBinding:this._createSequence([this._createStroke("x",!i.isMac,!1,!1,i.isMac),this._createStroke("x",!i.isMac,!1,!1,i.isMac)])});for(var t=0;9>=t;t++)e.push({actionID:"emacs-digit-argument-"+t,keyBinding:this._createStroke(48+t,!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-digit-argument-"+t,keyBinding:this._createStroke(48+t,!1,!1,!0)}),e.push({actionID:"emacs-digit-argument-"+t,keyBinding:this._createStroke(48+t,!i.isMac,!1,!0,i.isMac)});return e.push({actionID:"emacs-negative-argument",keyBinding:this._createStroke(189,!i.isMac,!1,!1,i.isMac)}),e.push({actionID:"emacs-negative-argument",keyBinding:this._createStroke(189,!1,!1,!0)}),e.push({actionID:"emacs-negative-argument",keyBinding:this._createStroke(189,!i.isMac,!1,!0,i.isMac)}),e.push({actionID:"emacs-uppercase",keyBinding:this._createStroke("u",!1,!1,!0)}),e.push({actionID:"emacs-lowercase",keyBinding:this._createStroke("l",!1,!1,!0)}),e.push({actionID:"emacs-capitalize",keyBinding:this._createStroke("c",!1,!1,!0)}),e.push({actionID:"contentAssist",keyBinding:this._createStroke(191,!1,!1,!0)}),e.push({actionID:"find",keyBinding:this._createStroke("r",!1,!1,!0)}),e.push({actionID:"incrementalFind",keyBinding:this._createStroke("s",!0)}),e.push({actionID:"incrementalFindReverse",keyBinding:this._createStroke("r",!0)}),e.push({actionID:"save",keyBinding:this._createSequence([this._createStroke("x",!i.isMac,!1,!1,i.isMac),this._createStroke("s",!i.isMac,!1,!1,i.isMac)])}),this._createActions(this.getView()),e},r.prototype._createStroke=function(t,i,r,o,s){var a=new n.KeyStroke(t,i,r,o,s);return a.scopeName=e.emacs,a},r.prototype._createSequence=function(t){var i=new n.KeySequence(t);return i.scopeName=e.emacs,i},r.prototype._getData=function(){var e={count:(this._argument||1)*(this._sign||1)};return this._argument=0,this._sign=1,e},r.prototype._moveCursor=function(e){var t=this._getData();this._marker&&(t.select=!0);var n=this.getView();return n.invokeAction(e,!1,t)},r.prototype._digitArgument=function(e){return this._argument=10*(this._argument||0)+e,!0},r.prototype._negativeArgument=function(){return this._sign=-1*(this._sign||1),!0},r.prototype._createActions=function(t){var n=this;t.setAction("emacs-beginning-of-line",function(){return n._moveCursor("lineStart")},{name:e.lineStart}),t.setAction("emacs-end-of-line",function(){return n._moveCursor("lineEnd")},{name:e.lineEnd}),t.setAction("emacs-forward-char",function(){return n._moveCursor("charNext")},{name:e.charNext}),t.setAction("emacs-backward-char",function(){return n._moveCursor("charPrevious")},{name:e.charPrevious}),t.setAction("emacs-forward-word",function(){return n._moveCursor("wordNext")},{name:e.wordNext}),t.setAction("emacs-backward-word",function(){return n._moveCursor("wordPrevious")},{name:e.wordPrevious}),t.setAction("emacs-next-line",function(){return n._moveCursor("lineDown")},{name:e.lineDown}),t.setAction("emacs-previous-line",function(){return n._moveCursor("lineUp")},{name:e.lineUp}),t.setAction("emacs-beginning-of-buffer",function(){return n._moveCursor("textStart")},{name:e.textStart}),t.setAction("emacs-end-of-buffer",function(){return n._moveCursor("textEnd")},{name:e.textEnd}),t.setAction("emacs-delete-backward-char",function(){return t.invokeAction("deletePrevious")},{name:e.deletePrevious}),t.setAction("emacs-delete-char",function(){return t.invokeAction("deletePrevious")},{name:e.deletePrevious}),t.setAction("emacs-kill-line",function(){return t.invokeAction("deleteLineEnd")},{name:e.deleteLineEnd}),t.setAction("emacs-kill-word",function(){return t.invokeAction("deleteWordNext")},{name:e.deleteWordNext}),t.setAction("emacs-backward-kill-word",function(){return t.invokeAction("deleteWordPrevious")},{name:e.deleteWordPrevious}),t.setAction("emacs-scroll-up",function(){return n._moveCursor("pageDown")},{name:e.pageDown}),t.setAction("emacs-scroll-down",function(){return n._moveCursor("pageUp")},{name:e.pageUp}),t.setAction("emacs-set-mark-command",function(){var e=t.getCaretOffset();return t.setCaretOffset(e),n._marker=e,!0},{name:e.setMarkCommand}),t.setAction("emacs-exchange-point-and-mark",function(){if(void 0!==n._marker){var e=t.getCaretOffset(),i=t.getSelection();if(i.end===e){var r=i.start;i.start=i.end,i.end=r}n._marker=e,t.setSelection(i.start,i.end)}return!0},{name:e.exchangeMarkPoint}),t.setAction("emacs-reset-mark-command",function(){var e=t.getCaretOffset();return t.setCaretOffset(e),n._marker=void 0,!0},{name:e.clearMark}),t.setAction("emacs-digit-argument-0",function(){return n._digitArgument(0)},{name:i.formatMessage(e.digitArgument,"0")}),t.setAction("emacs-digit-argument-1",function(){return n._digitArgument(1)},{name:i.formatMessage(e.digitArgument,"1")}),t.setAction("emacs-digit-argument-2",function(){return n._digitArgument(2)},{name:i.formatMessage(e.digitArgument,"2")}),t.setAction("emacs-digit-argument-3",function(){return n._digitArgument(3)},{name:i.formatMessage(e.digitArgument,"3")}),t.setAction("emacs-digit-argument-4",function(){return n._digitArgument(4)},{name:i.formatMessage(e.digitArgument,"4")}),t.setAction("emacs-digit-argument-5",function(){return n._digitArgument(5)},{name:i.formatMessage(e.digitArgument,"5")}),t.setAction("emacs-digit-argument-6",function(){return n._digitArgument(6)},{name:i.formatMessage(e.digitArgument,"6")}),t.setAction("emacs-digit-argument-7",function(){return n._digitArgument(7)},{name:i.formatMessage(e.digitArgument,"7")}),t.setAction("emacs-digit-argument-8",function(){return n._digitArgument(8)},{name:i.formatMessage(e.digitArgument,"8")}),t.setAction("emacs-digit-argument-9",function(){return n._digitArgument(9)},{name:i.formatMessage(e.digitArgument,"9")}),t.setAction("emacs-negative-argument",function(){return n._negativeArgument()},{name:e.negativeArgument}),t.setAction("emacs-uppercase",function(){var e=n._getData();return e.unit="word",t.invokeAction("uppercase",!1,e)},{name:e.uppercase}),t.setAction("emacs-lowercase",function(){var e=n._getData();return e.unit="word",t.invokeAction("lowercase",!1,e)},{name:e.lowercase}),t.setAction("emacs-capitalize",function(){var e=n._getData();return e.unit="word",t.invokeAction("capitalize",!1,e)},{name:e.capitalize})},{EmacsMode:r}}),n("orion/editor/vi",["i18n!orion/editor/nls/messages","orion/editor/keyModes","orion/keyBinding","orion/util"],function(e,t,n,i){function r(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function o(t,i,r,o,s,a,l){var d=new n.KeyStroke(t,i,r,o,s,a);return d.scopeName=l||e.vi,d}function s(t,i){var r=new n.KeySequence(t);return r.scopeName=i||e.vi,r}function a(e,n,i){this.key=n,this.msg=i,this.number="",t.KeyMode.call(this,e),e&&this._createActions(e)}function l(e){var n=e.getView();this.viMode=e,t.KeyMode.call(this,n),this._createActions(n)}function d(e,t,n,i){this.viMode=e,this.nextMode=t,a.call(this,e.getView(),n,i)}function c(e){var n=e.getView();t.KeyMode.call(this,n),this.viMode=e,this._createActions(n)}function h(t,n){a.call(this,t,"",e.vimove),this.insertMode=new c(this),this.changeMode=new d(this,this.insertMode,"c",e.vichange),this.deleteMode=new d(this,this,"d",e.videlete),this.yankMode=new d(this,this,"y",e.viyank),this.statusReporter=n}var u,f;return a.prototype=new t.KeyMode,r(a.prototype,{_msg:function(t){return{name:i.formatMessage(e[t],this.msg)}},createKeyBindings:function(){var e=[],t=this.key;t=t?"-"+t+"-":"-";for(var n=0;9>=n;n++)e.push({actionID:"vi"+t+n,keyBinding:o(n+"",!1,!1,!1,!1,"keypress"),predefined:!0});return e.push({actionID:"vi"+t+"Left",keyBinding:o("h",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"Left",keyBinding:o("h",!0,!1,!1,!1)}),e.push({actionID:"vi"+t+"Left",keyBinding:o(8)}),e.push({actionID:"vi"+t+"Left",keyBinding:o(37)}),e.push({actionID:"vi"+t+"Down",keyBinding:o("j",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"Down",keyBinding:o(40)}),e.push({actionID:"vi"+t+"Up",keyBinding:o("k",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"Up",keyBinding:o(38)}),e.push({actionID:"vi"+t+"Right",keyBinding:o("l",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"Right",keyBinding:o(39)}),e.push({actionID:"vi"+t+"Right",keyBinding:o(32)}),e.push({actionID:"vi"+t+"w",keyBinding:o("w",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"b",keyBinding:o("b",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"W",keyBinding:o("W",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"B",keyBinding:o("B",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"e",keyBinding:o("e",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"E",keyBinding:o("E",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"$",keyBinding:o("$",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"^_",keyBinding:o("^",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"^_",keyBinding:o("_",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"+",keyBinding:o("+",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"+",keyBinding:o(13)}),e.push({actionID:"vi"+t+"-",keyBinding:o("-",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"|",keyBinding:o("|",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"H",keyBinding:o("H",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"M",keyBinding:o("M",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"L",keyBinding:o("L",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"/",keyBinding:o("/",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"?",keyBinding:o("?",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"n",keyBinding:o("n",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"N",keyBinding:o("N",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"f",keyBinding:o("f",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"F",keyBinding:o("F",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"t",keyBinding:o("t",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"T",keyBinding:o("T",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+",",keyBinding:o(",",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+";",keyBinding:o(";",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi"+t+"G",keyBinding:o("G",!1,!1,!1,!1,"keypress")}),e},_createActions:function(e){function t(t){for(var n=e.getModel(),i=n.getLine(t),r=0,o=i.charCodeAt(r);32===o||9===o;)r++,o=i.charCodeAt(r);return r}function n(e,t){e&&r.getView().setCaretOffset(e.start),t.editDone&&t.editDone()}var i=this.key;i=i?"-"+i+"-":"-";var r=this;e.setAction("vi"+i+"0",function(){return r._storeNumber(0)}),e.setAction("vi"+i+"1",function(){return r._storeNumber(1)}),e.setAction("vi"+i+"2",function(){return r._storeNumber(2)}),e.setAction("vi"+i+"3",function(){return r._storeNumber(3)}),e.setAction("vi"+i+"4",function(){return r._storeNumber(4)}),e.setAction("vi"+i+"5",function(){return r._storeNumber(5)}),e.setAction("vi"+i+"6",function(){return r._storeNumber(6)}),e.setAction("vi"+i+"7",function(){return r._storeNumber(7)}),e.setAction("vi"+i+"8",function(){return r._storeNumber(8)}),e.setAction("vi"+i+"9",function(){return r._storeNumber(9)}),e.setAction("vi"+i+"Left",function(){return r._invoke("charPrevious",{unit:"character"})},this._msg("viLeft")),e.setAction("vi"+i+"Right",function(){return r._invoke("charNext",{unit:"character"})},this._msg("viRight")),e.setAction("vi"+i+"Up",function(){return r._invoke("lineUp",{editLine:!0})},this._msg("viUp")),e.setAction("vi"+i+"Down",function(){return r._invoke("lineDown",{editLine:!0})},this._msg("viDown")),e.setAction("vi"+i+"w",function(){return r._invoke("wordNext",{unit:"word"})},this._msg("viw")),e.setAction("vi"+i+"b",function(){return r._invoke("wordPrevious",{unit:"word"})},this._msg("vib")),e.setAction("vi"+i+"W",function(){return r._invoke("wordNext",{unit:"wordWS"})},this._msg("viW")),e.setAction("vi"+i+"B",function(){return r._invoke("wordPrevious",{unit:"wordWS"})},this._msg("viB")),e.setAction("vi"+i+"e",function(){return r._invoke("charNext",{unit:"character"}),r._invoke("wordNext",{unit:"wordend"}),r._invoke("charPrevious",{unit:"character"}),!0},this._msg("vie")),e.setAction("vi"+i+"E",function(){return r._invoke("wordNext",{unit:"wordendWS"})},this._msg("viE")),e.setAction("vi"+i+"$",function(){return r._invoke("lineEnd")},this._msg("vi$")),e.setAction("vi"+i+"^_",function(){return r._invoke(function(){var n=e.getModel(),i=e.getCaretOffset(),r=n.getLineAtOffset(i);e.setCaretOffset(n.getLineStart(r)+t(r))})},this._msg("vi^_")),e.setAction("vi"+i+"+",function(){return r._invoke(function(n){var i=e.getModel(),r=e.getCaretOffset(),o=i.getLineCount()-1,s=Math.min(i.getLineAtOffset(r)+n.count,o);e.setCaretOffset(i.getLineStart(s)+t(s))},{editLine:!0})},this._msg("vi+")),e.setAction("vi"+i+"-",function(){return r._invoke(function(n){var i=e.getModel(),r=e.getCaretOffset(),o=Math.max(i.getLineAtOffset(r)-n.count,0);e.setCaretOffset(i.getLineStart(o)+t(o))},{editLine:!0})},this._msg("vi-")),e.setAction("vi"+i+"|",function(){return r._invoke(function(t){var n=e.getModel(),i=e.getCaretOffset(),r=n.getLineAtOffset(i);e.setCaretOffset(Math.min(n.getLineStart(r)+t.count-1,n.getLineEnd(r)))})},this._msg("vi|")),e.setAction("vi"+i+"H",function(){return r._invoke(function(t){var n=e.getModel().getLineStart(e.getTopIndex(!0)+(t.count-1));e.setCaretOffset(n)},{editLine:!0})},this._msg("viH")),e.setAction("vi"+i+"M",function(){return r._invoke(function(){var t=Math.ceil((e.getBottomIndex(!0)-e.getTopIndex(!0))/2)+e.getTopIndex(!0);e.setCaretOffset(e.getModel().getLineStart(t))},{editLine:!0})},this._msg("viM")),e.setAction("vi"+i+"L",function(){return r._invoke(function(t){e.setCaretOffset(e.getModel().getLineStart(e.getBottomIndex(!0)-(t.count-1)))},{editLine:!0})},this._msg("viL")),e.setAction("vi"+i+"/",function(){var e={hideAfterFind:!0,incremental:!1,reverse:!1,findCallback:function(t){r._searchFwd=!0,n(t,e)}};return r._invoke("find",e)},this._msg("vi/")),e.setAction("vi"+i+"?",function(){var e={hideAfterFind:!0,incremental:!1,reverse:!0,findCallback:function(t){r._searchFwd=!1,n(t,e)}};return r._invoke("find",e)},this._msg("vi?")),e.setAction("vi"+i+"n",function(){var t,i=e.getCaretOffset();r._searchFwd?(t="findNext",i++):t="findPrevious";var o={start:i,findCallback:function(e){n(e,o)}};return r._invoke(t,o)},this._msg("vin")),e.setAction("vi"+i+"N",function(){var t,i=e.getCaretOffset();r._searchFwd?t="findPrevious":(t="findNext",i++);var o={start:i,findCallback:function(e){n(e,o)}};return r._invoke(t,o)},this._msg("viN")),e.setAction("vi"+i+"f",function(){var t=e.getModel(),n=e.getCaretOffset();return r._findChar(n,t.getLineEnd(t.getLineAtOffset(n)),!1,0)},this._msg("vif")),e.setAction("vi"+i+"F",function(){var t=e.getModel(),n=e.getCaretOffset();return r._findChar(t.getLineStart(t.getLineAtOffset(n)),n,!0,0)},this._msg("viF")),e.setAction("vi"+i+"t",function(){var t=e.getModel(),n=e.getCaretOffset();return r._findChar(n,t.getLineEnd(t.getLineAtOffset(n)),!1,-1)},this._msg("vit")),e.setAction("vi"+i+"T",function(){var t=e.getModel(),n=e.getCaretOffset();return r._findChar(t.getLineStart(t.getLineAtOffset(n)),n,!0,1)},this._msg("viT")),e.setAction("vi"+i+",",function(){return r._charTempOptions?r._findNextChar(r._charTempOptions.reverse):void 0},this._msg("vi,")),e.setAction("vi"+i+";",function(){return r._charTempOptions?r._findNextChar(!r._charTempOptions.reverse):void 0},this._msg("vi;")),e.setAction("vi"+i+"G",function(){if(""===r.number){var t=e.getModel();t.getBaseModel&&(t=t.getBaseModel()),r.number=t.getLineCount()}return r._invoke(function(t){t=t||{},t.line=t.count,t.editLine=!0,t.callback=function(){t.editDone&&t.editDone()},e.invokeAction("gotoLine",!1,t)})},this._msg("viG"))},_invoke:function(e,t){var n=this.getView();return t=t||{},t.count=this._getCount(),"function"==typeof e?e(t):n.invokeAction(e,!1,t),!0},_getCount:function(){var e=1;return""!==this.number&&(e=this.number>>0),this.number="",e},_findChar:function(e,t,n,i){this._charTempOptions={},this._charTempOptions.start=e,this._charTempOptions.end=t,this._charTempOptions.hideAfterFind=!0,this._charTempOptions.incremental=!1,this._charTempOptions.reverse=n,this._charTempOptions.offset=i;var r=this._charTempOptions,o=this;return this._charTempOptions.findCallback=function(e){e&&o.getView().setCaretOffset(e.start+i),r.editDone&&r.editDone()},this._invoke("find",this._charTempOptions)},_findNextChar:function(e){if(this._charTempOptions){var t=this.getView(),n={};n.hideAfterFind=this._charTempOptions.hideAfterFind,n.incremental=this._charTempOptions.incremental,n.reverse=this._charTempOptions.reverse,n.wrap=!1;var i=n,r=this;n.findCallback=function(e){e&&r.getView().setCaretOffset(e.start+r._charTempOptions.offset),i.editDone&&i.editDone()};var o=t.getModel();return e?(n.start=t.getCaretOffset()+1-this._charTempOptions.offset,n.end=o.getLineEnd(o.getLineAtOffset(n.start)),n.reverse=!1,this._invoke("findNext",n)):(n.start=t.getCaretOffset()-this._charTempOptions.offset,n.end=o.getLineStart(o.getLineAtOffset(n.start)),n.reverse=!0,this._invoke("findPrevious",n))}return!0},_storeNumber:function(e){var t=this;return 0!==e||this.number?(this.number+=e,!0):this._invoke(function(){t.getView().invokeAction("lineStart",!0)})}}),l.prototype=new t.KeyMode,r(l.prototype,{createKeyBindings:function(){var e=[];return e.push({actionID:"vi-:-ESC",keyBinding:o(27),predefined:!0}),e},_createActions:function(e){var t=this;e.setAction("vi-:-ESC",function(){return e.removeKeyMode(t),e.addKeyMode(t.viMode),!0})},match:function(e){var n=t.KeyMode.prototype.match.call(this,e);return n||(n=this.getView().getKeyModes()[0].match(e)),n},storeNumber:function(e){this.number=e}}),d.prototype=new a,r(d.prototype,{createKeyBindings:function(){var e=a.prototype.createKeyBindings.call(this);return e.push({actionID:"vi-"+this.key+"ESC",keyBinding:o(27),predefined:!0}),e.push({actionID:"vi-"+this.key+"-"+this.key,keyBinding:o(this.key,!1,!1,!1,!1,"keypress")}),e},_invoke:function(e,t){t=t||{};var n=this.getView(),i=n.getCaretOffset(),r=i,o=n.getModel(),s=this;return t.editDone=function(){var e=n.getCaretOffset();if(r>e){var a=r;r=e,e=a}t.editLine&&(r=o.getLineStart(o.getLineAtOffset(r)),e=o.getLineEnd(o.getLineAtOffset(e),"c"===s.key?!1:!0)),"y"===s.key?(u=n.getText(r,e),f=t.editLine,n.setCaretOffset(i)):n.setText("",r,e),n.removeKeyMode(s),n.addKeyMode(s.nextMode)},a.prototype._invoke.call(this,e,t),t.editDone(),!0},_getCount:function(){var e=1;""!==this.firstNumber&&(e=this.firstNumber>>0);var t=1;return""!==this.number&&(t=this.number>>0),e*=t,this.number=this.firstNumber="",e},_createActions:function(e){a.prototype._createActions.call(this,e);var t=this;e.setAction("vi-"+t.key+"ESC",function(){return e.removeKeyMode(t),e.addKeyMode(t.viMode),!0}),e.setAction("vi-"+t.key+"-"+t.key,function(){return t._invoke("lineEnd",{editLine:!0})},this._msg("viycd"))},storeNumber:function(e){this.firstNumber=e},_modeAdded:function(){this.secondNumber=""},_modeRemoved:function(){this.command="",this.firstNumber="",this.number=""}}),c.prototype=new t.KeyMode,r(c.prototype,{createKeyBindings:function(){var e=[];return e.push({actionID:"vi-insert-ESC",keyBinding:o(27),predefined:!0}),e},_createActions:function(e){var t=this;e.setAction("vi-insert-ESC",function(){return e.removeKeyMode(t),e.addKeyMode(t.viMode),!0})},match:function(e){var n=t.KeyMode.prototype.match.call(this,e);return n||(n=this.getView().getKeyModes()[0].match(e)),n},storeNumber:function(){}}),h.prototype=new a,r(h.prototype,{createKeyBindings:function(){var e=a.prototype.createKeyBindings.call(this);return e.push({actionID:"vi-ctrl-f",keyBinding:o("f",!0)}),e.push({actionID:"vi-ctrl-b",keyBinding:o("b",!0)}),e.push({actionID:"vi-ctrl-e",keyBinding:o("e",!0)}),e.push({actionID:"vi-ctrl-y",keyBinding:o("y",!0)}),e.push({actionID:"statusLineMode",keyBinding:o(":",!1,!1,!1,!1,"keypress")}),e.push({actionID:"vi-a",keyBinding:o("a",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-A",keyBinding:o("A",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-i",keyBinding:o("i",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-I",keyBinding:o("I",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-o",keyBinding:o("o",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-O",keyBinding:o("O",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-R",keyBinding:o("R",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-s",keyBinding:o("s",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-S",keyBinding:o("S",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-p",keyBinding:o("p",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-P",keyBinding:o("P",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-u",keyBinding:o("u",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-c",keyBinding:o("c",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-d",keyBinding:o("d",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-y",keyBinding:o("y",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-~",keyBinding:o("~",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-x",keyBinding:o("x",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-X",keyBinding:o("X",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-C",keyBinding:o("C",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-D",keyBinding:o("D",!1,!1,!1,!1,"keypress"),predefined:!0}),e.push({actionID:"vi-*",keyBinding:o("*",!1,!1,!1,!1,"keypress"),predefined:!0}),e},getKeyBindings:function(e){var n=t.KeyMode.prototype.getKeyBindings.call(this,e);n=n||[];var i,r=this.changeMode.getKeyBindings(e);if(!this.changeMode.isActive())for(i=0;i<r.length;i++)r[i]=s([o("c",!1,!1,!1,!1,"keypress"),r[i]]);if(n=n.concat(r),r=this.deleteMode.getKeyBindings(e),!this.deleteMode.isActive())for(i=0;i<r.length;i++)r[i]=s([o("d",!1,!1,!1,!1,"keypress"),r[i]]);if(n=n.concat(r),r=this.yankMode.getKeyBindings(e),!this.yankMode.isActive())for(i=0;i<r.length;i++)r[i]=s([o("y",!1,!1,!1,!1,"keypress"),r[i]]);return n=n.concat(r)},match:function(e){var n=t.KeyMode.prototype.match.call(this,e);return n||"keypress"!==e.type||(n="noop"),n},_createActions:function(t){a.prototype._createActions.call(this,t);var n=this;t.setAction("vi-ctrl-f",function(){return n._invoke("pageDown")},{name:e.pageDown}),t.setAction("vi-ctrl-b",function(){return n._invoke("pageUp")},{name:e.pageUp}),t.setAction("vi-ctrl-e",function(){return n._invoke("scrollLineDown")},{name:e.scrollLineDown}),t.setAction("vi-ctrl-y",function(){return n._invoke("scrollLineUp")},{name:e.scrollLineUp}),t.setAction("vi-a",function(){return n._toInsertMode("charNext")},{name:e.via}),t.setAction("vi-A",function(){return n._toInsertMode("lineEnd")},{name:e.viA}),t.setAction("vi-i",function(){return n._toInsertMode("noop")},{name:e.vii}),t.setAction("vi-I",function(){return n._toInsertMode("lineStart")},{name:e.viI}),t.setAction("vi-O",function(){return n._invoke("lineUp"),n._invoke("lineEnd"),n._toInsertMode("enter"),!0},{name:e.viO}),t.setAction("vi-o",function(){return n._invoke("lineEnd"),n._toInsertMode("enter"),!0},{name:e.vio}),t.setAction("vi-R",function(){return n._toInsertMode("toggleOverwriteMode")},{name:e.viR}),t.setAction("vi-s",function(){return n._toInsertMode("deleteNext",{unit:"char"})},{name:e.vis}),t.setAction("vi-S",function(){return n._toInsertMode("deleteLines",{unit:"line"})},{name:e.viS}),t.setAction("vi-p",function(){return n._invoke(function(){var e=n.getView(),t=e.getSelection();if(t.start===t.end){var i=e.getModel(),r=e.getCaretOffset();f?t.start=t.end=i.getLineEnd(i.getLineAtOffset(r),!0):(t.start++,t.end++)}e.setText(u,t.start,t.end)})},{name:e.vip}),t.setAction("vi-P",function(){return n._invoke(function(){var e=n.getView(),t=e.getSelection();if(t.start===t.end){var i=e.getModel(),r=e.getCaretOffset();f&&(t.start=t.end=i.getLineStart(i.getLineAtOffset(r)))}e.setText(u,t.start,t.end)})},{name:e.viP}),t.setAction("vi-u",function(){return n._invoke("undo")},{name:e.Undo}),t.setAction("vi-c",function(){return t.removeKeyMode(n),t.addKeyMode(n.changeMode),n.changeMode.storeNumber(n.number),n.number="",!0}),t.setAction("vi-d",function(){return t.removeKeyMode(n),t.addKeyMode(n.deleteMode),n.deleteMode.storeNumber(n.number),n.number="",!0}),t.setAction("vi-y",function(){return t.removeKeyMode(n),t.addKeyMode(n.yankMode),n.yankMode.storeNumber(n.number),n.number="",!0}),t.setAction("vi-~",function(){return n._invoke("reversecase")},{name:e.reversecase}),t.setAction("vi-x",function(){return n._invoke("deleteNext")},{name:e.deleteNext}),t.setAction("vi-X",function(){return n._invoke("deletePrevious")},{name:e.deletePrevious}),t.setAction("vi-C",function(){return n._toInsertMode("deleteLineEnd")},{name:e.viC}),t.setAction("vi-D",function(){return n._invoke("deleteLineEnd")},{name:e.deleteLineEnd}),t.setAction("vi-*",function(){var e=n.getView(),t=e.getCaretOffset(),i=e.getNextOffset(t+1,{count:-1,unit:"word"}),r=e.getNextOffset(i,{count:1,unit:"wordend"}),o=e.getText(i,r);n._searchFwd=!0;var s={hideAfterFind:!0,incremental:!1,reverse:!1,findString:o};return n._invoke("find",s)},{name:e.viStar})},_reportStatus:function(e){this.statusReporter&&this.statusReporter(e)},_toInsertMode:function(e,t){t=t||{};var n=1;""!==this.number&&(n=this.number>>0),t.count=n;var i=this.getView();return this.insertMode.storeNumber(this.number),i.invokeAction(e,!1,t),i.removeKeyMode(this),i.addKeyMode(this.insertMode),this.number="",!0},_modeAdded:function(){this.getView().setOptions({blockCursorVisible:!0})},_modeRemoved:function(){var e=this.getView();e.setOptions({blockCursorVisible:!1}),e.removeKeyMode(this.insertMode),e.removeKeyMode(this.changeMode),e.removeKeyMode(this.deleteMode)}}),{VIMode:h}}),n("orion/editorPreferences",[],function(){return{}}),n("orion/widgets/themes/ThemePreferences",[],function(){return{}}),n("orion/widgets/themes/editor/ThemeData",[],function(){return{}}),n("orion/widgets/settings/EditorSettings",[],function(){return null}),n("orion/searchAndReplace/textSearcher",[],function(){return{TextSearcher:null}}),n("orion/globalCommands",[],function(){return{}}),n("orion/edit/dispatcher",[],function(){function e(e,t,n,i){this.serviceRegistry=e,this.editor=n,this.inputManager=i,this.ctRegistry=t,this.serviceReferences={};var r=this;this.inputManager.addEventListener("InputChanged",function(e){r.contentType=e.contentType,r.updateListeners()}.bind(this)),this.listener={onServiceAdded:function(e){r._onServiceAdded(e.serviceReference)},onServiceRemoved:function(e){r._onServiceRemoved(e.serviceReference)}},this.serviceRegistry.addEventListener("registered",this.listener.onServiceAdded),this.serviceRegistry.addEventListener("unregistering",this.listener.onServiceRemoved)}return e.prototype={updateListeners:function(){this._removeAllListeners();for(var e=this.serviceRegistry,t=e.getServiceReferences("orion.edit.model"),n=0;n<t.length;n++)this._wireServiceReference(t[n])},_wireServiceReference:function(e){var t=e.getProperty("contentType");if("undefined"!=typeof t&&null!==t){var n=this,i=this.contentType;this.ctRegistry.isSomeExtensionOf(i,t)&&n._wireService(e,n.serviceRegistry.getService(e))}},_wireService:function(e,t){var n=this.editor.getTextView();if(!n)throw new Error("TextView not installed");for(var i=Object.keys(t),r=0;r<i.length;r++){var o=i[r],s=t[o];if("on"===o.substr(0,2)&&"function"==typeof s){var a=o.substr(2);this._wireServiceMethod(e,t,s,n,a)}}},_wireServiceMethod:function(e,t,n,i,r){var o=this,s=function(e){e.file=o.getServiceFileObject(),n(e).then()},a=e.getProperty("service.id");this.serviceReferences[a]=this.serviceReferences[a]||[],this.serviceReferences[a].push([i,r,s]),i.addEventListener(r,s)},_onServiceRemoved:function(e){var t=e.getProperty("service.id");this._removeListeners(t)},_onServiceAdded:function(e){-1!==e.getProperty("objectClass").indexOf("orion.edit.model")&&this._wireServiceReference(e)},_removeListeners:function(e){var t=this.serviceReferences[e];if(t){for(var n=0;n<t.length;n++){var i=t[n],r=i[0],o=i[1],s=i[2];r.removeEventListener(o,s)}delete this.serviceReferences[e]}},_removeAllListeners:function(){for(var e=Object.keys(this.serviceReferences),t=0;t<e.length;t++)this._removeListeners(e[t])},getServiceFileObject:function(){var t=this.inputManager.getFileMetadata();return t?e.toServiceFileObject(t,this.inputManager.getContentType()):null}},e.toServiceFileObject=function(e,t){var n=Object.create(null);return n.name=e.Name,n.location=e.Location,n.parents=e.Parents,t&&(n.contentType=Object.create(null),n.contentType.id=t.id,n.contentType.name=t.name,n.contentType.imageClass=t.imageClass,n.contentType.extension=t.extension),n},{Dispatcher:e}}),n("orion/edit/editorContext",[],function(){function e(e,t){var i=Object.create(null);return n(e,t).forEach(function(t){var n=e.getService(t);Object.keys(n).forEach(function(e){"function"==typeof n[e]&&(i[e]=n[e].bind(n))})}),i}function t(e,t){var i=Object.create(null);return n(e,t).forEach(function(e){e.getPropertyKeys().forEach(function(t){"service.id"!==t&&"service.names"!==t&&"objectClass"!==t&&(i[t]=e.getProperty(t))})}),i}function n(e,t){return e.getServiceReferences(t||"orion.edit.context")}return{getEditorContext:e,getOptions:t}}),n("examples/editor/textStyler",[],function(){return{}}),n("orion/editor/textStyler",["orion/editor/annotations","orion/editor/eventTarget","orion/metrics"],function(e,t,n){function i(e){return JSON.parse(JSON.stringify(e)) }function r(e,t,n){this._patternManager=new o(e,t),this._contentType=n}function o(e,t){this._unnamedCounter=0,this._patterns=[],this._firstLineMatches={},Array.isArray(t)||(t=[t]),this._rootIds=t,e.forEach(function(e){this._addRepositoryPatterns(e.repository||{},e.id),this._addPatterns(e.patterns||[],e.id),e.firstLineMatch&&(this._firstLineMatches[e.id]=new RegExp(e.firstLineMatch))}.bind(this))}function s(e,t,n,i,r,o,s){this.start=e.start,this.end=e.end,this.contentStart=e.contentStart,this.contentEnd=e.contentEnd,this.name=t,this.typeId=n,this.styler=i,this.parent=o,s&&s(this),this._subBlocks=i.computeBlocks(r,r.getText(this.contentStart,this.end),this,this.contentStart,null,null,null)}function a(e){this._styler=e}function l(e,t,n){this._whitespacesVisible=!1,this._highlightCaretLine=!1,this._foldingEnabled=!0,this._detectTasks=!0,this._annotationProviders=[],this._view=e,this._annotationModel=t,this._stylerAdapter=n,this._stylerAdapter.setStyler(this),this._accessor=new a(this),this._bracketAnnotations;var i=this;this._listener={onChanged:function(e){i._onModelChanged(e)},onDestroy:function(e){i._onDestroy(e)},onLineStyle:function(e){i._onLineStyle(e)},onMouseDown:function(e){i._onMouseDown(e)},onSelection:function(e){i._onSelection(e)}};var r=e.getModel();r.getBaseModel&&(r=r.getBaseModel()),r.addEventListener("Changed",this._listener.onChanged),e.addEventListener("MouseDown",this._listener.onMouseDown),e.addEventListener("Selection",this._listener.onSelection),e.addEventListener("Destroy",this._listener.onDestroy),e.addEventListener("LineStyle",this._listener.onLineStyle),this.computeRootBlock(r)}var d=function(e,t,n,i,r){var o;for(void 0===i&&(i=-1),void 0===r&&(r=e.length);r-i>1;)if(o=Math.floor((r+i)/2),t<=e[o].start)r=o;else{if(n&&t<e[o].end){r=o;break}i=o}return r},c=function(e,t,n){return new r(e,t,n)};return r.prototype={blockSpansBeyondEnd:function(e){return e.pattern.regexEnd===this._eolRegex},computeBlocks:function(e,t,n,i,r,o,s){if(!t)return[];var a,l=[],d=[];if(r=r||0,o=o||1/0,s=s||1/0,n.blockPatterns.forEach(function(e){a=this._findMatch(e.regexBegin||e.regex,t,r),a&&d.push({result:a,pattern:e})}.bind(this)),!d.length)return l;d.sort(function(e,t){return e.result.index<t.result.index?-1:e.result.index>t.result.index?1:e.pattern.pattern.index<t.pattern.pattern.index?-1:1});for(var c=0;d.length>0;){var h=d[0];if(d.splice(0,1),o<h.result.index)break;if(h.result.index<c)this._updateMatch(h,t,d,c,o);else{var u=i+h.result.index,f=h.result.index,p=null,g=h.pattern.regexEnd;if(g){f+=h.result[0].length;var v=h.pattern,m=this._substituteCaptureValues(g,h.result);m!==g&&(v={pattern:v.pattern,regexBegin:v.regexBegin,regexEnd:m},g=m);for(var _=f;!p;){a=this._findMatch(g,t,_),a||(this._eolRegex.lastIndex=0,a=this._eolRegex.exec(t),v={pattern:v.pattern,regexBegin:v.regexBegin,regexEnd:this._eolRegex});var y=this.createBlock({start:u,end:i+a.index+a[0].length,contentStart:i+f,contentEnd:i+a.index},n.styler,e,n,v),C=y.getBlocks();(!C.length||C[C.length-1].end<=a.index+i)&&(p=y),_=a.index+a[0].length}}else p=this.createBlock({start:u,end:u+h.result[0].length,contentStart:u,contentEnd:u+h.result[0].length},n.styler,e,n,h.pattern);if(l.push(p),l.length===s||o<=p.end)break;c=p.end-i,this._updateMatch(h,t,d,c,o)}}return l},computeStyle:function(e,t,n){if(!e.pattern)return null;var i={start:e.start,end:e.end,style:e.pattern.pattern.name};if(e.contentStart<=n&&n<e.contentEnd)return e.pattern.pattern.contentName?{start:e.contentStart,end:e.contentEnd,style:e.pattern.pattern.contentName}:i;var r,o,s,a;if(n<e.contentStart){if(o=e.pattern.pattern.beginCaptures||e.pattern.pattern.captures,!o)return i;r=e.pattern.regexBegin,s=t.getText(e.start,e.contentStart),a=e.start}else{if(o=e.pattern.pattern.endCaptures||e.pattern.pattern.captures,!o)return i;r=e.pattern.regexEnd,s=t.getText(e.contentEnd,e.end),a=e.contentEnd}r.lastIndex=0;var l=r.exec(s);if(l){var c=[];this._getCaptureStyles(l,o,a,c);var h=c[d(c,n,!0)];if(h&&h.start<=n&&n<h.end)return h}return i},createBlock:function(e,t,n,i,r){return new s(e,r?r.pattern.name:null,r?r.pattern.id:null,t,n,i,function(e){e.pattern=r,e.linePatterns=[],e.blockPatterns=[],e.enclosurePatterns={},this._initPatterns(this._patternManager,e)}.bind(this))},destroy:function(){this._textModel.removeEventListener("Changed",this._listener)},getBlockCommentDelimiters:function(e){var t=this._getLanguageBlock(e),n=t.blockPatterns;if(n)for(var i="comment.block",r=0;r<n.length;r++){var o=n[r].pattern,s=o.name||o.contentName;if(s&&-1!==s.indexOf(i)&&o.begin&&o.end&&o.begin.literal&&o.end.literal)return[o.begin.literal,o.end.literal]}return["",""]},getBlockContentStyleName:function(e){return e.pattern.pattern.contentName||e.pattern.pattern.name},getBlockEndStyle:function(e,t,n,i){var r;if(e.pattern.regexEnd&&(r=this._findMatch(e.pattern.regexEnd,t,0))){var o=e.pattern.pattern.endCaptures||e.pattern.pattern.captures;o?this._getCaptureStyles(r,o,n-r[0].length,i):e.pattern.pattern.name&&i.push({start:n-r[0].length,end:n,style:e.pattern.pattern.name})}return r?r[0]:null},getBlockFoldBounds:function(e){return{start:e.start,end:e.end}},getBlockOverrideStyles:function(e,t,n,i){if(e.pattern.regex&&e.pattern.pattern.captures&&this._containsCaptureRegex.test(e.pattern.regex)){var r=this._findMatch(e.pattern.regex,t,0);r&&this._getCaptureStyles(r,e.pattern.pattern.captures,n,i)}},getBlockStartStyle:function(e,t,n,i){var r;if(e.pattern.regexBegin&&(r=this._findMatch(e.pattern.regexBegin,t,0))){var o=e.pattern.pattern.beginCaptures||e.pattern.pattern.captures;o?this._getCaptureStyles(r,o,n,i):i.push({start:n,end:n+r[0].length,style:e.pattern.pattern.name})}return r?r[0]:null},getBracketMatch:function(e,t){for(var n,i=Object.keys(e.enclosurePatterns),r=0;r<i.length;r++){var o=e.enclosurePatterns[i[r]],s=this._findMatch(o.regex,t,0);if(s&&0===s.index){n=o;break}}if(!n)return null;var a,l=!1;-1!==n.pattern.name.indexOf(this._PUNCTUATION_SECTION_BEGIN)?(l=!0,a=n.pattern.name.replace(this._PUNCTUATION_SECTION_BEGIN,this._PUNCTUATION_SECTION_END)):a=n.pattern.name.replace(this._PUNCTUATION_SECTION_END,this._PUNCTUATION_SECTION_BEGIN);var d=e.enclosurePatterns[a];return d?{beginName:n.pattern.name,endName:a,atStart:l}:null},getContentType:function(){return this._contentType},getLineCommentDelimiter:function(e){var t="comment.line",n=this._getLanguageBlock(e),i=n.linePatterns;if(i)for(var r=0;r<i.length;r++){var o=i[r].pattern,s=o.name;if(s&&-1!==s.indexOf(t)&&o.match&&o.match.literal)return o.match.literal}var a=n.blockPatterns;if(a)for(r=0;r<a.length;r++)if(o=a[r].pattern,s=o.name||o.contentName,s&&-1!==s.indexOf(t)&&o.begin&&o.begin.literal)return o.begin.literal;return""},parse:function(e,t,n,i,r,o){if(e){var s=i.linePatterns;if(s){var a,l=[];s.forEach(function(t){var i=t.regex||t.regexBegin;i.oldLastIndex=i.lastIndex,a=this._findMatch(i,e,n),a&&l.push({result:a,pattern:t})}.bind(this)),l.sort(function(e,t){return e.result.index<t.result.index?-1:e.result.index>t.result.index?1:e.pattern.pattern.index<t.pattern.pattern.index?-1:1});for(var d=n;l.length>0;){var c=l[0];if(l.splice(0,1),c.result.index<d)this._updateMatch(c,e,l,d);else{var h,u=c.result.index;if(c.pattern.regex){var f=[];a=c.result,h=u+a[0].length;var p={start:t+u,end:t+h,style:c.pattern.pattern.name};if(!o){c.pattern.pattern.captures&&this._getCaptureStyles(a,c.pattern.pattern.captures,t+u,f),f.sort(function(e,t){return e.start<t.start?-1:e.start>t.start?1:0});for(var g=0;g<f.length-1;g++)if(f[g+1].start<f[g].end){var v={start:f[g+1].end,end:f[g].end,style:f[g].style};f[g].end=f[g+1].start,f.splice(g+2,0,v)}}this._mergeStyles(p,f,r)}else{var m=c.pattern.regexEnd;m=this._substituteCaptureValues(m,c.result),a=this._findMatch(m,e,c.result.index+c.result[0].length),a||(this._eolRegex.lastIndex=0,a=this._eolRegex.exec(e)),h=a.index+a[0].length,r.push({start:t+u,end:t+h,style:c.pattern.pattern.name})}d=a.index+a[0].length,this._updateMatch(c,e,l,d)}}s.forEach(function(e){var t=e.regex||e.regexBegin;t.lastIndex=t.oldLastIndex})}}},setStyler:function(e){this._styler&&this._textModel.removeEventListener("Changed",this._listener),this._styler=e,this._listener=this._onModelChanged.bind(this),this._textModel=this._styler.getTextModel(),this._textModel.addEventListener("Changed",this._listener),this._patternManager.firstLineChanged(this._textModel.getLine(0))},verifyBlock:function(e,t,n,i){var r,o=null,s=[],a=n.parent;if(a.blockPatterns.forEach(function(e){r=this._findMatch(e.regexBegin||e.regex,t,0),r&&s.push({result:r,pattern:e})}.bind(this)),s.sort(function(e,t){return!e.result.index&&t.result.index?-1:e.result.index&&!t.result.index?1:e.result.index||t.result.index?0:e.pattern.pattern.index<t.pattern.pattern.index?-1:1}),s.length&&0===s[0].result.index&&s[0].pattern.pattern.id===n.pattern.pattern.id){r=s[0];var l=r.pattern.regexEnd;if(l){l=this._substituteCaptureValues(l,r.result);for(var d=r.result[0].length,c=this._findMatch(l,t,d);null===o&&c&&n.start+c.index!==n.contentEnd+i;){var h=this.computeBlocks(e,t,n,n.start,d,c.index+1,null);!h.length||h[h.length-1].end<=n.start+c.index?o=!1:h.length?(d=h[h.length-1].end-n.start,c=this._findMatch(l,t,d)):c=null}c||(this._eolRegex.lastIndex=0,c=this._eolRegex.exec(t),o=n.start+c.index===n.end+i)}else o=n.start+r.result[0].length===n.end+i}else o=!1;return null!==o?o:!0},_findMatch:function(e,t,n,i){var r=n,o=e.lastIndex;this._linebreakRegex.lastIndex=n;var s,a,l=this._linebreakRegex.exec(t);if(e.lastIndex=0,l){for(var d=l.index;0<=--d;){var c=t.charAt(d);if(c===this._NEWLINE||c===this._CR)break}s=t.substring(d+1,l.index+l[1].length),e.lastIndex=a=l.index-d-1}for(;l&&l.index<t.length;){var h;if(i){var u=e.lastIndex;e.test(s)&&(e.lastIndex=u,h=e.exec(s))}else h=e.exec(s);if(h)return h.index+=r,h.index-=a,e.lastIndex=o,h;a=0,r+=l[0].length,l=this._linebreakRegex.exec(t),l&&(s=l[1],e.lastIndex=0)}return e.lastIndex=o,null},_getCaptureStyles:function(e,t,n,i){if(t[0])return void i.push({start:n,end:n+e[0].length,style:t[0].name});for(var r=0,o=1;o<e.length;o++)if(e[o]){var s=t[o];if(s){var a=n+r;i.push({start:a,end:a+e[o].length,style:s.name})}r+=e[o].length}},_getLanguageBlock:function(e){for(var t=this._styler.getBlockAtIndex(e),n=/^source\..+\.embedded/;t;){if(t.pattern){var i=t.pattern.pattern;if(n.test(i.name||i.contentName))return t}t=t.parent}return this._styler.getRootBlock()},_initPatterns:function(e,t){if(t.pattern&&t.pattern.pattern.linePatterns)return t.linePatterns=t.pattern.pattern.linePatterns,t.blockPatterns=t.pattern.pattern.blockPatterns,void(t.enclosurePatterns=t.pattern.pattern.enclosurePatterns);var n=e.getPatterns(t.pattern?t.pattern.pattern:null),i=function(e){var t="string"==typeof e?e:e.match,n=this._ignoreCaseRegex.exec(t),i=this._FLAGS;return n&&(t=t.substring(n[0].length),i+="i"),new RegExp(t,i)}.bind(this),r=-1,o=0;n.forEach(function(e){var n;!e.match||e.begin||e.end?!e.match&&e.begin&&e.end&&(r=o,n={regexBegin:i(e.begin),regexEnd:i(e.end),pattern:e},t.linePatterns.push(n)):(n={regex:i(e.match),pattern:e},t.linePatterns.push(n),!e.name||0!==e.name.indexOf("punctuation.section")||-1===e.name.indexOf(this._PUNCTUATION_SECTION_BEGIN)&&-1===e.name.indexOf(this._PUNCTUATION_SECTION_END)||(t.enclosurePatterns[e.name]=n)),o++}.bind(this)),t.blockPatterns=t.linePatterns.slice(0,r+1),t.pattern&&(t.pattern.pattern.enclosurePatterns=t.enclosurePatterns,t.pattern.pattern.linePatterns=t.linePatterns,t.pattern.pattern.blockPatterns=t.blockPatterns)},_mergeStyles:function(e,t,n){var i=e.start;t.forEach(function(t){i<=t.start&&n.push({start:i,end:t.start,style:e.style}),n.push(t),i=t.end}),i<e.end&&n.push({start:i,end:e.end,style:e.style})},_onModelChanged:function(e){var t=this._textModel.getLineAtOffset(e.start);0===t&&this._patternManager.firstLineChanged(this._textModel.getLine(0))&&this._styler.computeRootBlock(this._textModel)},_substituteCaptureValues:function(e,t){var n=e.toString();if(this._captureReferenceRegex.lastIndex=0,!this._captureReferenceRegex.test(n))return e;this._captureReferenceRegex.lastIndex=0;for(var i=this._captureReferenceRegex.exec(n);i;)n=n.replace(i[0],t[i[1]]||""),this._captureReferenceRegex.lastIndex=0,i=this._captureReferenceRegex.exec(n);return new RegExp(n.substring(1,n.length-1-this._FLAGS.length),this._FLAGS)},_updateMatch:function(e,t,n,i,r){var o=e.pattern.regex?e.pattern.regex:e.pattern.regexBegin;r=r||1/0;var s=this._findMatch(o,t,i,!0);if(s&&s.index<r){e.result=s;for(var a=0;a<n.length;a++)if(s.index<n[a].result.index||s.index===n[a].result.index&&e.pattern.pattern.index<n[a].pattern.pattern.index)return void n.splice(a,0,e);n.push(e)}},_captureReferenceRegex:/\\(\d)/g,_containsCaptureRegex:/\((?!\?:)/,_eolRegex:/$/,_ignoreCaseRegex:/^\(\?i\)\s*/,_linebreakRegex:/([\s\S]*?)(?:[\r\n]|$)/g,_CR:"\r",_FLAGS:"g",_NEWLINE:"\n",_PUNCTUATION_SECTION_BEGIN:".begin",_PUNCTUATION_SECTION_END:".end"},o.prototype={firstLineChanged:function(e){var t=this._computeRootId(e),n=this._rootId!==t;return this._rootId=t,n},getPatterns:function(e){var t;if(e)t="string"==typeof e?e:e.qualifiedId,t+="#";else{if(!this._rootId)return[];t=this._rootId+"#"+this._NO_ID}var n=[0],r={},o=new RegExp("^"+t+"[^#]+$");this._patterns.forEach(function(e){if(o.test(e.qualifiedId))if(e.include)this._processInclude(e,n,r);else{var t=i(e);t.index=n[0]++,r[e.qualifiedId]=t}}.bind(this));var s=[],a=Object.keys(r);return a.forEach(function(e){s.push(r[e])}),s},_addPattern:function(e,t,n){e.parentId=n,e.id=t,e.qualifiedId=e.parentId+"#"+e.id,this._patterns.push(e),e.patterns&&!e.include&&this._addPatterns(e.patterns,e.qualifiedId)},_addPatterns:function(e,t){e.forEach(function(e){this._addPattern(e,this._NO_ID+this._unnamedCounter++,t)}.bind(this))},_addRepositoryPatterns:function(e,t){var n=Object.keys(e);n.forEach(function(n){this._addPattern(e[n],n,t)}.bind(this))},_computeRootId:function(e){for(var t=null,n=null,i=0;i<this._rootIds.length;i++){var r=this._firstLineMatches[this._rootIds[i]];r?r.test(e)&&(n=this._rootIds[i]):t=this._rootIds[i]}return n||t},_processInclude:function(e,t,n){var r,o=e.include.indexOf("#");r=new RegExp(0===o?"^"+e.qualifiedId.substring(0,e.qualifiedId.indexOf("#"))+e.include+"$":-1===o?"^"+e.include+"#"+this._NO_ID+"[^#]+$":"^"+e.include+"$"),this._patterns.forEach(function(e){if(r.test(e.qualifiedId))if(e.include)this._processInclude(e,t,n);else if(!n[e.qualifiedId]){var o=i(e);o.index=t[0]++,n[e.qualifiedId]=o}}.bind(this))},_NO_ID:"NoID"},s.prototype={adjustBounds:function(e,t){e<this.start&&(this.start+=t),e<this.contentStart&&(this.contentStart+=t),e<=this.end&&(this.end+=t),e<=this.contentEnd&&(this.contentEnd+=t),this._subBlocks.forEach(function(n){e<=n.end&&n.adjustBounds(e,t)})},getBlocks:function(){return this._subBlocks},getBlockAtIndex:function(e){return d(this.getBlocks(),e,!0)},isRenderingWhitespace:function(){return this.styler._isRenderingWhitespace()}},a.prototype={getBlockCommentDelimiters:function(e){return this._styler.getBlockCommentDelimiters(e)},getLineCommentDelimiter:function(e){return this._styler.getLineCommentDelimiter(e)},getStyles:function(e){return this._styler.getStyles(e)}},l.prototype={addAnnotationProvider:function(e){"function"==typeof e&&this._annotationProviders.push(e)},computeBlocks:function(e,t,n,i,r,o,s){return this._stylerAdapter.computeBlocks(e,t,n,i,r,o,s)},computeRootBlock:function(t){var i=t.getCharCount(),r={start:0,contentStart:0,end:i,contentEnd:i};if(i>=5e4)var o=Date.now();if(this._rootBlock=this._stylerAdapter.createBlock(r,this,t,null),o){var s=Date.now()-o;s>10&&n.logTiming("editor","styler compute blocks (ms/50000 chars)",5e4*s/i,this._stylerAdapter.getContentType())}if(this._annotationModel){var a=[];this._annotationModel.removeAnnotations(e.AnnotationType.ANNOTATION_FOLDING),this._computeFolding(this._rootBlock.getBlocks(),this._view.getModel(),a),this._detectTasks&&(this._annotationModel.removeAnnotations(e.AnnotationType.ANNOTATION_TASK),this._computeTasks(this._rootBlock,t,a)),this._replaceAnnotations([],a)}this._view.redrawLines()},destroy:function(){if(this._stylerAdapter.destroy(),this._view){var e=this._view.getModel();e.getBaseModel&&(e=e.getBaseModel()),e.removeEventListener("Changed",this._listener.onChanged),this._view.removeEventListener("MouseDown",this._listener.onMouseDown),this._view.removeEventListener("Selection",this._listener.onSelection),this._view.removeEventListener("Destroy",this._listener.onDestroy),this._view.removeEventListener("LineStyle",this._listener.onLineStyle),this._view=null}},getAnnotationModel:function(){return this._annotationModel},getBlockAtIndex:function(e){return this._findBlock(this._rootBlock,e)},getBlockCommentDelimiters:function(e){return this._stylerAdapter.getBlockCommentDelimiters(e)},getLineCommentDelimiter:function(e){return this._stylerAdapter.getLineCommentDelimiter(e)},getRootBlock:function(){return this._rootBlock},getStyleAccessor:function(){return this._accessor},getStyles:function(e){var t=[];if(this._view){var n=this._view.getModel();n.getBaseModel&&(n=n.getBaseModel());var i=this._findBlock(this._rootBlock,e),r=n.getLineAtOffset(e),o=n.getLine(r),s=[];this._stylerAdapter.parse(o,n.getLineStart(r),0,i,s);var a=s[d(s,e,!0)];for(a&&a.start<=e&&e<a.end&&t.push(a);i;)a=this._stylerAdapter.computeStyle(i,n,e),a&&t.splice(0,0,a),i=i.parent}return t},getTextModel:function(){var e=this._view.getModel();return e.getBaseModel&&(e=e.getBaseModel()),e},removeAnnotationProvider:function(e){if("function"==typeof e){var t=this._annotationProviders.indexOf(e);-1!==t&&this._annotationProviders.splice(t,1)}},setDetectHyperlinks:function(){},setDetectTasks:function(e){this._detectTasks=e},setFoldingEnabled:function(e){this._foldingEnabled=e},setHighlightCaretLine:function(e){this._highlightCaretLine=e},setWhitespacesVisible:function(e,t){this._whitespacesVisible!==e&&(this._whitespacesVisible=e,t&&this._view.redraw())},_computeFolding:function(e,t,n){if(t.getBaseModel){var i=t.getBaseModel();e.forEach(function(e){var r=this._stylerAdapter.getBlockFoldBounds(e,i),o=this._createFoldingAnnotation(t,i,r.start,r.end);o&&n.push(o),this._computeFolding(e.getBlocks(),t,n)}.bind(this))}},_computeTasks:function(t,n,i,r,o){if(r=r||t.start,o=o||t.end,t.start<=o&&r<=t.end){if(!this._annotationModel)return;if(t.name&&0===t.name.indexOf("comment")){var s=[],a=n.getLineAtOffset(t.contentStart),l=n.getLineStart(a);this._stylerAdapter.parse(n.getText(l,t.end),l,t.contentStart-l,t,s,!0);for(var d=0;d<s.length;d++)"meta.annotation.task.todo"===s[d].style&&r<=s[d].start&&s[d].end<=o&&i.push(this._createAnnotation(e.AnnotationType.ANNOTATION_TASK,s[d].start,s[d].end,n.getText(s[d].start,s[d].end)))}t.getBlocks().forEach(function(e){this._computeTasks(e,n,i,r,o)}.bind(this))}},_createAnnotation:function(t,n,i,r){var o=e.AnnotationType.createAnnotation(t,n,i,r);return o.source=this._TEXTSTYLER,o},_createFoldingAnnotation:function(t,n,i,r){var o=n.getLineAtOffset(i),s=n.getLineAtOffset(r);return o===s?null:o+1===s&&n.getLineStart(s)===n.getLineEnd(s)?null:this._createAnnotation(e.AnnotationType.ANNOTATION_FOLDING,i,r,t)},_findBlock:function(e,t){var n=e.getBlocks();if(!n.length)return e;var i=d(n,t,!0);return i<n.length&&n[i].start<=t&&t<n[i].end?this._findBlock(n[i],t):e},_findBrackets:function(e,t,n,i,r,o){for(var s=[],a=[],l=r,c=n.getBlocks(),h=d(c,r,!0),u=h;u<c.length&&!(c[u].start>=o);u++){var f=c[u].start,p=c[u].end;if(f>l){var g=e.getLineAtOffset(l),v=e.getLineStart(g);this._stylerAdapter.parse(i.substring(v-r,f-r),v,l-v,n,a),a.forEach(function(e){e.style&&(0===e.style.indexOf(t.beginName)?s.push(e.start+1):0===e.style.indexOf(t.endName)&&s.push(-(e.start+1)))}),a=[]}l=p}return o>l&&(g=e.getLineAtOffset(l),v=e.getLineStart(g),this._stylerAdapter.parse(i.substring(v-r,o-r),v,l-v,n,a),a.forEach(function(e){e.style&&(0===e.style.indexOf(t.beginName)?s.push(e.start+1):0===e.style.indexOf(t.endName)&&s.push(-(e.start+1)))})),s},_findMatchingBracket:function(e,t,n){var i=e.getLineAtOffset(n),r=e.getLineEnd(i),o=e.getText(n,r),s=this._stylerAdapter.getBracketMatch(t,o);if(!s)return-1;for(var a=e.getLine(i),l=e.getLineStart(i),d=this._findBrackets(e,s,t,a,l,r),c=0;c<d.length;c++){var h=d[c]>=0?1:-1;if(d[c]*h-1===n){var u=1;if(s.atStart){for(c++;c<d.length;c++)if(h=d[c]>=0?1:-1,u+=h,0===u)return d[c]*h-1;i+=1;for(var f=e.getLineCount();f>i;){a=e.getLine(i),l=e.getLineStart(i),r=e.getLineEnd(i),d=this._findBrackets(e,s,t,a,l,r);for(var p=0;p<d.length;p++)if(h=d[p]>=0?1:-1,u+=h,0===u)return d[p]*h-1;i++}}else{for(c--;c>=0;c--)if(h=d[c]>=0?1:-1,u+=h,0===u)return d[c]*h-1;for(i-=1;i>=0;){a=e.getLine(i),l=e.getLineStart(i),r=e.getLineEnd(i),d=this._findBrackets(e,s,t,a,l,r);for(var g=d.length-1;g>=0;g--)if(h=d[g]>=0?1:-1,u+=h,0===u)return d[g]*h-1;i--}}break}}return-1},_getLineStyle:function(e){if(this._highlightCaretLine){var t=this._view,n=t.getModel(),i=t.getSelections(),r=!1;if(!i.some(function(t){return t.start===t.end?(r=r||n.getLineAtOffset(t.start)===e,!1):!0})&&r)return this._caretLineStyle}return null},_getStyles:function(e,t,n,i,r){for(var o=i+n.length,s=[],a=i+r,l=e.getBlocks(),c=d(l,a,!0),h=c;h<l.length&&!(l[h].start>=o);h++){var u=l[h].start,f=l[h].end;if(u>a){var p=t.getLineAtOffset(a),g=t.getLineStart(p);this._stylerAdapter.parse(n.substring(g-i,u-i),g,a-g,e,s)}var v=Math.max(a,u);if(v===u){var m=this._stylerAdapter.getBlockStartStyle(l[h],n.substring(v-i),v,s);m&&(v+=m.length)}var _=Math.min(o,f),y=[];if(_===f){var C=n.substring(_-a-(l[h].end-l[h].contentEnd)),w=this._stylerAdapter.getBlockEndStyle(l[h],C,_,y);w&&(_-=w.length)}p=t.getLineAtOffset(v),g=t.getLineStart(p);var x=this._getStyles(l[h],t,n.substring(g-i,_-i),g,v-g),b=[];this._stylerAdapter.getBlockOverrideStyles(l[h],n.substring(v-i,_-i),v,b),b.length&&(Array.prototype.push.apply(x,b),x.length!==b.length&&x.sort(function(e,t){return e.start<t.start?-1:e.start>t.start?1:0}));var S=this._stylerAdapter.getBlockContentStyleName(l[h]);if(S){var T=v;x.forEach(function(e){e.start-T&&s.push({start:T,end:e.start,style:S}),e.mergeable&&(e.style+=","+S),s.push(e),T=e.end}),_-T&&s.push({start:T,end:_,style:S})}else s=s.concat(x);s=s.concat(y),a=f}return o>a&&(p=t.getLineAtOffset(a),g=t.getLineStart(p),this._stylerAdapter.parse(n.substring(g-i,o-i),g,a-g,e,s)),s},_isRenderingWhitespace:function(){return this._whitespacesVisible},_onDestroy:function(){this.destroy()},_onLineStyle:function(e){if(this._rootBlock){e.textView===this._view&&(e.style=this._getLineStyle(e.lineIndex));var t=e.lineStart,n=e.textView.getModel();if(n.getBaseModel){t=n.mapOffset(t);var i=n.getBaseModel()}e.ranges=this._getStyles(this._rootBlock,i||n,e.lineText,t,0);for(var r=e.ranges.length-1;r>=0;r--){var o=e.ranges[r];if(o.style){if(o.style={styleClass:o.style.replace(/\./g," ")},i){var s=o.end-o.start;o.start=n.mapOffset(o.start,!0),o.end=o.start+s}}else e.ranges.splice(r,1)}}else e.ranges=[];this._isRenderingWhitespace()&&(this._spliceStyles(this._spacePattern,e.ranges,e.lineText,e.lineStart),this._spliceStyles(this._tabPattern,e.ranges,e.lineText,e.lineStart))},_onModelChanged:function(t){for(var n,i,r,o,s,a,l,c=t.start,h=t.removedCharCount,u=t.addedCharCount,f=u-h,p=this._view.getModel(),g=p.getBaseModel?p.getBaseModel():p,v=c+h,m=g.getCharCount(),_=g.getLineStart(g.getLineAtOffset(c)),y=this._findBlock(this._rootBlock,c);;){if(r=y.parent,!n&&r){if(0>f&&y.end-c<=-f){y=r;continue}if(s=g.getText(y.start,Math.min(m,y.end+f+1)),!this._stylerAdapter.verifyBlock(g,s,y,f)){y=r;continue}}i=y.getBlocks();var C=i.length,w=d(i,_,!0),x=d(i,v,!1,w-1,C);if(n=!1,w&&i.length&&i[w-1].end===c){s=g.getText(i[w-1].start,Math.min(m,c+1));var b=this.computeBlocks(g,s,y,i[w-1].start,null,null,null);b.length&&b[0].end!==i[w-1].end&&(w--,n=!0)}C>w&&i[w].start<=_&&(_<i[w].end||n)?(l=i[w].start,l>c&&(l+=f)):w===C&&C>0&&y.end-f===i[C-1].end?(l=i[--w].start,l>c&&(l+=f)):l=Math.max(_,y.contentStart),a=C>x?i[x].end:y.contentEnd,a>=c&&(a+=f),a=Math.min(a,m-1),s=g.getText(l,a+1);var S=this.computeBlocks(g,s,y,l,null,null,null);if(C>x){if(S.length&&S[S.length-1].end===a&&S[S.length-1].typeId===i[x].typeId)break;if(S.length&&this._stylerAdapter.blockSpansBeyondEnd(S[S.length-1])){x++;for(var T=S[S.length-1].getBlocks(),E=(T.length?T[T.length-1]:S[S.length-1]).typeId;C>x;){if(i[x].typeId===E){var A=i[x].end+f;A=Math.min(A,m-1),s=g.getText(l,A+1);var L=this.computeBlocks(g,s,y,l,null,null,null);if(L.length&&L[L.length-1].end===A){a=A,S=L;break}}x++}if(C>x)break}}else if(!S.length||S[S.length-1].end<=y.contentEnd+f)break;if(!r){a=m,x=C,s=g.getText(l,a),S=this.computeBlocks(g,s,y,l,null,null,null);break}y=r,o=!0}this._rootBlock.adjustBounds(c,f),x=Math.min(x+1,C);var k;if(o||(o=x-w!==S.length),!o)for(var M=0;M<S.length;M++){k=i[w+M];var O=S[M];if(k.start!==O.start||k.end!==O.end||k.typeId!==O.typeId){o=!0;break}}if(i.length||S.length)this.dispatchEvent({type:"BlocksChanged",oldBlocks:i.slice(w,x),newBlocks:S});else{var D=[y],N=[y];this.dispatchEvent({type:"BlocksChanged",oldBlocks:D,newBlocks:N}),y=N[0]}var I=[w,x-w].concat(S);if(Array.prototype.splice.apply(i,I),o){var R=l,B=a;p!==g&&(R=p.mapOffset(R,!0),B=p.mapOffset(B,!0)),this._view.redrawRange(R,B)}if(this._annotationModel){for(var P=[],F=[],V=[],U=this._annotationModel.getAnnotations(l,a),K=this._foldingEnabled&&g!==p,W=y.parent||y;U.hasNext();){var H=U.next();if(K&&H.type===e.AnnotationType.ANNOTATION_FOLDING){for(V.push(H),k=this._findBlock(W,H.start);k;){var j=this._stylerAdapter.getBlockFoldBounds(k,g);if(H.start===j.start&&H.end===j.end)break;k=k.parent}if(k&&H.start===j.start&&H.end===j.end){var G=H.start,z=H.end;if(G>c&&(G-=f),z>c&&(z-=f),c>=G&&z>c&&v>=G&&z>v){var $=g.getLineAtOffset(H.start),Y=g.getLineAtOffset(H.end);$!==Y?H.expanded||H.expand():P.push(H)}}else P.push(H),H.expand()}else H.type===e.AnnotationType.ANNOTATION_TASK&&y.start<=H.start&&H.end<=y.end&&P.push(H)}K&&W.getBlocks().forEach(function(e){this._updateFolding(e,g,p,V,F,l,a)}.bind(this)),this._detectTasks&&this._computeTasks(y,g,F,l,a),this._annotationProviders.forEach(function(e){var t=[],n=[];e(this._annotationModel,g,y,l,a,t,n),P=P.concat(t),F=F.concat(n)}.bind(this)),this._replaceAnnotations(P,F)}},_onMouseDown:function(e){if(2===e.clickCount){var t=this._view.getModel(),n=this._view.getOffsetAtLocation(e.x,e.y);if(n>0){var i=n-1,r=t;t.getBaseModel&&(i=t.mapOffset(i),r=t.getBaseModel());var o=this._findBlock(this._rootBlock,i),s=this._findMatchingBracket(r,o,i);if(-1!==s){e.preventDefault();var a=s;t.getBaseModel&&(a=t.mapOffset(a,!0)),n>a&&(n--,a++),this._view.setSelection(a,n)}}}},_onSelection:function(t){function n(e){var t={};return e.some(function(e){return e.isEmpty()?(t[l.getLineAtOffset(e.start).toString()]=!0,!1):!0})?{}:t}function i(e,t){for(var n in e)t[n]||(r=n>>0,a.redrawLines(r,r+1))}var r,o=Array.isArray(t.oldValue)?t.oldValue:[t.oldValue],s=Array.isArray(t.newValue)?t.newValue:[t.newValue],a=this._view,l=a.getModel();if(this._highlightCaretLine){var d=n(o),c=n(s);i(d,c),i(c,d)}if(this._annotationModel){var h,u,f=this._bracketAnnotations;if(1===s.length&&s[0].isEmpty()&&(u=s[0].getCaret())>0){var p=u-1;l.getBaseModel&&(p=l.mapOffset(p),l=l.getBaseModel());var g=this._findBlock(this._rootBlock,p),v=this._findMatchingBracket(l,g,p);-1!==v&&(h=[this._createAnnotation(e.AnnotationType.ANNOTATION_MATCHING_BRACKET,v,v+1),this._createAnnotation(e.AnnotationType.ANNOTATION_CURRENT_BRACKET,p,p+1)])}this._bracketAnnotations=h,this._replaceAnnotations(f,h)}},_replaceAnnotations:function(t,n){var i;t&&(i=[],t.forEach(function(t){(t.type!==e.AnnotationType.ANNOTATION_FOLDING||t.source===this._TEXTSTYLER)&&i.push(t)}.bind(this))),this._annotationModel.replaceAnnotations(i,n)},_spliceStyles:function(e,t,n,r){var o=e.regex;o.lastIndex=0;for(var s=0,a=o.exec(n);a;){for(var l=r+a.index;s<t.length&&!(l<t[s].end);)s++;var d={start:l,end:l+1,style:i(e.style)};if(s<t.length&&t[s].start<=l){var c={start:l+1,end:t[s].end,style:t[s].style};t[s].end=l,t.splice(s+1,0,c),t.splice(s+1,0,d),s+=2,d.style.styleClass+=" "+t[s].style.styleClass}else t.splice(s,0,d),s++;a=o.exec(n)}},_updateFolding:function(e,t,n,i,r,o,s){o=o||e.start,s=s||e.end;var a=this._stylerAdapter.getBlockFoldBounds(e,t);if(!e.doNotFold&&a.start<=s&&o<=a.end){var l=d(i,a.start,!0);if(!(l<i.length&&i[l].start===a.start&&i[l].end===a.end)){var c=this._createFoldingAnnotation(n,t,a.start,a.end);c&&r.push(c)}e.getBlocks().forEach(function(e){this._updateFolding(e,t,n,i,r,o,s)}.bind(this))}},_caretLineStyle:{styleClass:"meta annotation currentLine"},_spacePattern:{regex:/[ ]/g,style:{styleClass:"punctuation separator space",unmergeable:!0}},_tabPattern:{regex:/\t/g,style:{styleClass:"punctuation separator tab",unmergeable:!0}},_TEXTSTYLER:"textStyler"},t.EventTarget.addMixin(l.prototype),{TextStyler:l,Block:s,createPatternBasedAdapter:c}}),n("orion/editor/textMateStyler",["orion/regex"],function(e){function t(e){var n;if(e instanceof Array){n=new Array(e.length);for(var i=0;i<e.length;i++)n[i]=t(e[i])}else{n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var o=e[r];n[r]="object"==typeof o&&null!==o?t(o):o}}return n}function n(e,n,i){this.initialize(e),this.grammar=t(n),this.externalGrammars=i?t(i):[],this._styles={},this._tree=null,this._allGrammars={},this.preprocess(this.grammar)}var i={unsupported:[{regex:/\(\?[ims\-]:/,func:function(){return"option on/off for subexp"}},{regex:/\(\?<([=!])/,func:function(e){return"="===e[1]?"lookbehind":"negative lookbehind"}},{regex:/\(\?>/,func:function(){return"atomic group"}}],toRegExp:function(e){function t(e,t){throw new Error('Unsupported regex feature "'+e+'": "'+t[0]+'" at index: '+t.index+" in "+t.input)}function n(e){for(var t="",n=!1,i=e.length,r=0;i>r;){var o=e.charAt(r);if(n||"#"!==o)if(!n&&/\s/.test(o))for(;i>r&&/\s/.test(o);)o=e.charAt(++r);else"\\"===o?(t+=o,/\s/.test(e.charAt(r+1))||(t+=e.charAt(r+1),r+=1),r+=1):"["===o?(n=!0,t+=o,r+=1):"]"===o?(n=!1,t+=o,r+=1):(t+=o,r+=1);else for(;i>r&&"\r"!==o&&"\n"!==o;)o=e.charAt(++r)}return t}var r,o="";for(e=i.processGlobalFlag("x",e,function(e){return n(e)}),e=i.processGlobalFlag("i",e,function(e){return o+="i",e}),r=0;r<this.unsupported.length;r++){var s;(s=this.unsupported[r].regex.exec(e))&&t(this.unsupported[r].func(s),s)}return new RegExp(e,o)},processGlobalFlag:function(e,t,n){function i(e,t){for(var n=0,i=e.length,r=-1,o=t;i>o&&-1===r;o++)switch(e.charAt(o)){case"\\":o++;break;case"(":n++;break;case")":n--,0===n&&(r=o)}return r}var r="(?"+e+")",o="(?"+e+":";if(t.substring(0,r.length)===r)return n(t.substring(r.length));if(t.substring(0,o.length)===o){var s=i(t,0);if(s<t.length-1)throw new Error("Only a "+o+") group that encloses the entire regex is supported in: "+t);return n(t.substring(o.length,s))}return t},hasBackReference:function(e){return/\\\d+/.test(e.source)},getSubstitutedRegex:function(t,n,i){i="undefined"==typeof i?!0:!1;for(var r=t.source.split(/(\\\d+)/g),o=[],s=0;s<r.length;s++){var a=r[s],l=/\\(\d+)/.exec(a);if(l){var d=n[l[1]]||"";o.push(i?e.escape(d):d)}else o.push(a)}return new RegExp(o.join(""))},groupify:function(e,t){for(var n=1,i=2,r=3,o=4,s=e.source,a=s.length,l=[],d=0,c=[],h=1,u=1,f=[],p={},g={},v=0;a>v;v++){var m=l[l.length-1],_=s.charAt(v);switch(_){case"(":m===o&&(l.pop(),f.push(")"),c[c.length-1].end=v);var y=a>v+2?s.charAt(v+1)+""+s.charAt(v+2):null;if("?:"===y||"?="===y||"?!"===y){var C;"?:"===y?C=n:(C=r,d++),l.push(C),c.push({start:v,end:-1,type:C}),f.push(_),f.push(y),v+=y.length}else l.push(i),c.push({start:v,end:-1,type:i,oldNum:h,num:u}),f.push(_),0===d&&(g[u]=null),p[h]=u,h++,u++;break;case")":var w=l.pop();w===r&&d--,c[c.length-1].end=v,f.push(_);break;case"*":case"+":case"?":case"}":var x=_,b=s.charAt(v-1),S=v-1;if("}"===_){for(var T=v-1;"{"!==s.charAt(T)&&T>=0;T--);b=s.charAt(T-1),S=T-1,x=s.substring(T,v+1)}var E=c[c.length-1];if(")"===b&&(E.type===i||E.type===o)){f.splice(E.start,0,"("),f.push(x),f.push(")");for(var A={start:E.start,end:f.length-1,type:o,num:E.num},L=0;L<c.length;L++)w=c[L],(w.type===i||w.type===o)&&w.start>=E.start&&w.end<=S&&(w.start+=1,w.end+=1,w.num=w.num+1,w.type===i&&(p[w.oldNum]=w.num)); c.push(A),u++;break}default:if("|"!==_&&m!==i&&m!==o&&0===d&&(l.push(o),c.push({start:v,end:-1,type:o,num:u}),f.push("("),g[u]=null,u++),f.push(_),"\\"===_){var k=s.charAt(v+1);f.push(k),v+=1}}}for(;l.length;)l.pop(),f.push(")");var M=new RegExp(f.join("")),O={};t=t||p;for(var D in t)t.hasOwnProperty(D)&&(O[D]="\\"+t[D]);return M=this.getSubstitutedRegex(M,O,!1),[M,p,g]},complexCaptures:function(e){if(!e)return!1;for(var t in e)if(e.hasOwnProperty(t)&&"0"!==t)return!0;return!1}};return n.prototype={initialize:function(e){this.textView=e,this.textView.stylerOptions=this;var t=this;this._listener={onModelChanged:function(e){t.onModelChanged(e)},onDestroy:function(e){t.onDestroy(e)},onLineStyle:function(e){t.onLineStyle(e)},onStorage:function(e){t.onStorage(e)}},e.addEventListener("ModelChanged",this._listener.onModelChanged),e.addEventListener("Destroy",this._listener.onDestroy),e.addEventListener("LineStyle",this._listener.onLineStyle),e.redrawLines()},onDestroy:function(){this.destroy()},destroy:function(){this.textView&&(this.textView.removeEventListener("ModelChanged",this._listener.onModelChanged),this.textView.removeEventListener("Destroy",this._listener.onDestroy),this.textView.removeEventListener("LineStyle",this._listener.onLineStyle),this.textView=null),this.grammar=null,this._styles=null,this._tree=null,this._listener=null},preprocess:function(e){for(var t=[e];0!==t.length;){var n=t.pop();if((!n._resolvedRule||!n._typedRule)&&(n._resolvedRule=this._resolve(n),n._typedRule=this._createTypedRule(n),this.addStyles(n.name),this.addStyles(n.contentName),this.addStylesForCaptures(n.captures),this.addStylesForCaptures(n.beginCaptures),this.addStylesForCaptures(n.endCaptures),n._resolvedRule!==n&&t.push(n._resolvedRule),n.patterns))for(var i=0;i<n.patterns.length;i++)t.push(n.patterns[i])}},addStyles:function(e){if(e&&!this._styles[e]){this._styles[e]=[];for(var t=e.split("."),n=0;n<t.length;n++)this._styles[e].push(t.slice(0,n+1).join("-"))}},addStylesForCaptures:function(e){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t].name;this.addStyles(n)}},ContainerRule:function(){function e(e){this.rule=e,this.subrules=e.patterns}return e.prototype.valueOf=function(){return"aa"},e}(),BeginEndRule:function(){function e(e){this.rule=e,this.beginRegex=i.toRegExp(e.begin),this.endRegex=i.toRegExp(e.end),this.subrules=e.patterns||[],this.endRegexHasBackRef=i.hasBackReference(this.endRegex);var t=i.complexCaptures(e.captures),n=i.complexCaptures(e.beginCaptures)||i.complexCaptures(e.endCaptures);if(this.isComplex=t||n,this.isComplex){var r=i.groupify(this.beginRegex);this.beginRegex=r[0],this.beginOld2New=r[1],this.beginConsuming=r[2];var o=i.groupify(this.endRegex,this.beginOld2New);this.endRegex=o[0],this.endOld2New=o[1],this.endConsuming=o[2]}}return e.prototype.valueOf=function(){return this.beginRegex},e}(),MatchRule:function(){function e(e){if(this.rule=e,this.matchRegex=i.toRegExp(e.match),this.isComplex=i.complexCaptures(e.captures),this.isComplex){var t=i.groupify(this.matchRegex);this.matchRegex=t[0],this.matchOld2New=t[1],this.matchConsuming=t[2]}}return e.prototype.valueOf=function(){return this.matchRegex},e}(),_createTypedRule:function(e){return e.match?new this.MatchRule(e):e.begin?new this.BeginEndRule(e):new this.ContainerRule(e)},_resolve:function(e){var t=e;if(e.include){if(e.begin||e.end||e.match)throw new Error('Unexpected regex pattern in "include" rule '+e.include);var n=e.include;if("#"===n.charAt(0)){if(t=this.grammar.repository&&this.grammar.repository[n.substring(1)],!t)throw new Error("Couldn't find included rule "+n+" in grammar repository")}else if("$self"===n)t=this.grammar;else{if("$base"===n)throw new Error('Include "$base" is not supported');if(t=this._allGrammars[n],!t)for(var i=0;i<this.externalGrammars.length;i++){var r=this.externalGrammars[i];if(r.scopeName===n){this.preprocess(r),this._allGrammars[n]=r,t=r;break}}}}return t},ContainerNode:function(){function e(e,t){this.parent=e,this.rule=t,this.children=[],this.start=null,this.end=null}return e.prototype.addChild=function(e){this.children.push(e)},e.prototype.valueOf=function(){var e=this.rule;return"ContainerNode { "+(e.include||"")+" "+(e.name||"")+(e.comment||"")+"}"},e}(),BeginEndNode:function(){function e(e,t,n){this.parent=e,this.rule=t,this.children=[],this.setStart(n),this.end=null,this.endMatch=null,this.endRegexSubstituted=t.endRegexHasBackRef?i.getSubstitutedRegex(t.endRegex,n):null}return e.prototype.addChild=function(e){this.children.push(e)},e.prototype.getIndexInParent=function(){return this.parent?this.parent.children.indexOf(this):-1},e.prototype.setStart=function(e){this.start=e.index,this.beginMatch=e},e.prototype.setEnd=function(e){if(e&&"object"==typeof e){var t=e;this.endMatch=t,this.end=t.index+t[0].length}else{var n=e;this.endMatch=null,this.end=n}},e.prototype.shiftStart=function(e){this.start+=e,this.beginMatch.index+=e},e.prototype.shiftEnd=function(e){this.end+=e,this.endMatch&&(this.endMatch.index+=e)},e.prototype.valueOf=function(){return"{"+this.rule.beginRegex+" range="+this.start+".."+this.end+"}"},e}(),push:function(e,t){if(t)for(var n=t.length;n>0;)e.push(t[--n])},exec:function(e,t,n){var i=e.exec(t);return i&&(i.index+=n),e.lastIndex=0,i},afterMatch:function(e){return e.index+e[0].length},getEndMatch:function(e,t,n){if(e instanceof this.BeginEndNode){var i=e.rule,r=e.endRegexSubstituted||i.endRegex;return r?this.exec(r,t,n):null}return null},initialParse:function(){var e=(this.textView.getModel().getCharCount(),new this.ContainerNode(null,this.grammar._typedRule));this._tree=e,this.parse(this._tree,!1,0)},onModelChanged:function(e){var t=e.addedCharCount,n=(e.addedLineCount,e.removedCharCount),i=(e.removedLineCount,e.start);if(this._tree){var r=this.textView.getModel(),o=r.getCharCount(),s=r.getLineEnd(r.getLineAtOffset(i)-1),a=this.getFirstDamaged(s,s);s=-1===s?0:s;var l;l=a?this.parse(a,!0,s,i,t,n):o,this.textView.redrawRange(s,l)}else this.initialParse()},getFirstDamaged:function(e,t){if(0>e)return this._tree;for(var n=[this._tree],i=null;n.length;){var r=n.pop();if(!r.parent||this.isDamaged(r,e,t)){r instanceof this.BeginEndNode&&(i=r);for(var o=0;o<r.children.length;o++)n.push(r.children[o])}}return i||this._tree},isDamaged:function(e,t,n){return e.start<=n&&e.end>t},parse:function(e,t,n,i,r,o){var s=this.textView.getModel(),a=s.getLineStart(s.getLineCount()-1),l=s.getCharCount(),d=this.getInitialExpected(e,n),c=-1;if(t){e.repaired=!0,e.endNeedsUpdate=!0;var h=e.children[e.children.length-1],u=r-o,f=h?s.getLineEnd(s.getLineAtOffset(h.end+u)):-1,p=s.getLineEnd(s.getLineAtOffset(i+o));c=Math.max(f,p)}c=-1===c?l:c;for(var g=d,v=e,m=!1,_=n,y=-1;v&&(!t||c>_);){var C=this.getNextMatch(s,v,_);C||(_=_>=a?l:s.getLineStart(s.getLineAtOffset(_)+1));var w=C&&C.match,x=C&&C.rule,b=C&&C.isSub,S=C&&C.isEnd;if(b){if(_=this.afterMatch(w),x instanceof this.BeginEndRule)if(m=!0,t&&x===g.rule&&v===g.parent){var T=g;T.setStart(w),T.repaired=!0,T.endNeedsUpdate=!0,v=T,g=this.getNextExpected(g,"begin")}else{t&&(this.prune(v,g),t=!1);var E=new this.BeginEndNode(v,x,w);v.addChild(E),v=E}}else(S||_===l)&&(v instanceof this.BeginEndNode&&(w?(m=!0,y=Math.max(y,v.end),v.setEnd(w),_=this.afterMatch(w),t&&v===g&&v.parent===g.parent?(v.repaired=!0,delete v.endNeedsUpdate,g=this.getNextExpected(g,"end")):t&&(this.prune(v,g),t=!1)):(v.setEnd(l),delete v.endNeedsUpdate)),v=v.parent);t&&_>=c&&!m&&(this.prune(e,d),t=!1)}return this.removeUnrepairedChildren(e,t,n),this.cleanup(t,e,n,c,l,r,o),t?Math.max(y,_):_},removeUnrepairedChildren:function(e,t,n){if(t){for(var i=e.children,r=-1,o=0;o<i.length;o++){var s=i[o];if(!s.repaired&&this.isDamaged(s,n,Number.MAX_VALUE)){r=o;break}}-1!==r&&(e.children.length=r)}},cleanup:function(e,t,n,i,r,o,s){var a,l,d;if(e){var c=o-s,h=this.getIntersecting(i-c+1,r);for(d=this.getIntersecting(n,i),a=0;a<h.length;a++)l=h[a],!l.repaired&&l instanceof this.BeginEndNode&&(l.shiftEnd(c),l.shiftStart(c));for(a=0;a<d.length;a++)l=d[a],l.repaired&&l.endNeedsUpdate&&l.shiftEnd(c),delete l.endNeedsUpdate,delete l.repaired}else for(d=this.getIntersecting(n,i),a=0;a<d.length;a++)delete d[a].repaired},getNextMatch:function(e,t,n,i){var r=e.getLineAtOffset(n),o=e.getLineEnd(r),s=e.getText(n,o),a=[],l=[],d=[],c=[];for(this.push(a,t.rule.subrules);a.length;){var h=a.length?a.pop():null,u=h&&h._resolvedRule._typedRule;if(u instanceof this.ContainerRule&&-1===l.indexOf(u))l.push(u),this.push(a,u.subrules);else if(!u||!i||u.matchRegex){var f=u&&this.exec(u.matchRegex||u.beginRegex,s,n);f&&(d.push(f),c.push(u))}}for(var p=Number.MAX_VALUE,g=-1,v=0;v<d.length;v++){var m=d[v];m.index<p&&(p=m.index,g=v)}if(!i){var _=t,y=this.getEndMatch(t,s,n);if(y){var C=_.rule.applyEndPatternLast,w=-1===g||y.index<p||!C&&y.index===p;if(w)return{isEnd:!0,rule:_.rule,match:y}}}return-1===g?null:{isSub:!0,rule:c[g],match:d[g]}},getInitialExpected:function(e,t){var n,i;if(e===this._tree){for(n=0;n<e.children.length;n++)if(i=e.children[n],i.start>=t)return i}else if(e instanceof this.BeginEndNode&&e.endMatch){var r=e.endMatch.index;for(n=0;n<e.children.length&&(i=e.children[n],!(i.start>=t));n++);if(i&&i.start<r)return i}return e},getNextExpected:function(e,t){var n=e;if("begin"===t){var i=n.children[0];return i?i:n}if("end"===t){var r=n.parent;if(r){var o=r.children[r.children.indexOf(n)+1];return o?o:r}}return null},prune:function(e,t){var n=t.parent===e;n?e.children.length=t.getIndexInParent():e instanceof this.BeginEndNode&&(e.endMatch=null,e.end=null),e.parent&&(e.parent.children.length=e.getIndexInParent()+1)},onLineStyle:function(e){function t(e,t){return e.start-t.start}this._tree||this.initialParse();var n=e.lineStart,i=this.textView.getModel(),r=i.getLineEnd(e.lineIndex),o=i.getLineEnd(i.getLineAtOffset(n)-1),s=this.getFirstDamaged(o,o),a=this.getLineScope(i,s,n,r);e.ranges=this.toStyleRanges(a),e.ranges.sort(t)},getLineScope:function(e,t,n,i){for(var r=n,o=this.getInitialExpected(t,n),s=[],a=[];t&&i>r;){var l=this.getNextMatch(e,t,r);if(!l)break;var d=l&&l.match,c=l&&l.rule,h=l&&l.isSub,u=l&&l.isEnd;d.index!==r&&a.push({start:r,end:d.index,node:t}),h?(r=this.afterMatch(d),c instanceof this.BeginEndRule?(this.addBeginScope(s,d,c),t=o,o=this.getNextExpected(o,"begin")):this.addMatchScope(s,d,c)):u&&(r=this.afterMatch(d),this.addEndScope(s,d,c),o=this.getNextExpected(o,"end"),t=t.parent)}i>r&&a.push({start:r,end:i,node:t});var f=this.getInheritedLineScope(a,n,i);return s.concat(f)},getInheritedLineScope:function(e){for(var t=[],n=0;n<e.length;n++)for(var i=e[n],r=i.node;r;){var o=r.rule.rule,s=o.name,a=o.contentName,l=a||s;if(l){this.addScopeRange(t,i.start,i.end,l);break}r=r.parent}return t},addBeginScope:function(e,t,n){var i=n.rule;this.addCapturesScope(e,t,i.beginCaptures||i.captures,n.isComplex,n.beginOld2New,n.beginConsuming)},addEndScope:function(e,t,n){var i=n.rule;this.addCapturesScope(e,t,i.endCaptures||i.captures,n.isComplex,n.endOld2New,n.endConsuming)},addMatchScope:function(e,t,n){var i=n.rule,r=i.name,o=i.captures;o?this.addCapturesScope(e,t,o,n.isComplex,n.matchOld2New,n.matchConsuming):this.addScope(e,t,r)},addScope:function(e,t,n){n&&e.push({start:t.index,end:this.afterMatch(t),scope:n})},addScopeRange:function(e,t,n,i){i&&e.push({start:t,end:n,scope:i})},addCapturesScope:function(e,t,n,i,r,o){if(n)if(i){for(var s={1:0},a=0,l=1;void 0!==t[l];l++)void 0!==o[l]&&(a+=t[l].length),void 0!==t[l+1]&&(s[l+1]=a);for(var d=t.index,c=1;n[c];c++){var h=n[c].name,u=r[c],f=d+s[u];if("undefined"!=typeof t[u]){var p=f+t[u].length;this.addScopeRange(e,f,p,h)}}}else this.addScope(e,t,n[0]&&n[0].name)},getIntersecting:function(e,t){for(var n=[],i=this._tree?[this._tree]:[];i.length;){var r=i.pop(),o=!1;if(r instanceof this.ContainerNode?o=!0:this.isDamaged(r,e,t)&&(o=!0,n.push(r)),o)for(var s=r.children.length,a=0;s>a;a++)i.push(r.children[a])}return n.reverse()},toStyleRanges:function(e){for(var t=[],n=0;n<e.length;n++){var i=e[n],r=this._styles[i.scope];if(!r)throw new Error("styles not found for "+i.scope);var o=r.join(" ");t.push({start:i.start,end:i.end,style:{styleClass:o}})}return t}},{RegexUtil:i,TextMateStyler:n}}),n("orion/editor/AsyncStyler",["i18n!orion/editor/nls/messages","orion/editor/annotations"],function(e,t){function n(e){return-1!==e.getProperty("objectClass").indexOf(r)&&"highlighter"===e.getProperty("type")}function i(e,t,n){this.initialize(e,t,n),this.lineStyles=[]}var r="orion.edit.highlighter",o="orion.annotation.highlightError",s=r+" service must be an event emitter";return t.AnnotationType.registerType(o,{title:e.syntaxError,html:"<div class='annotationHTML error'></div>",rangeStyle:{styleClass:"annotationRange error"}}),i.prototype={initialize:function(e,t,i){this.textView=e,this.serviceRegistry=t,this.annotationModel=i,this.services=[];var o=this;this.listener={onModelChanging:function(e){o.onModelChanging(e)},onModelChanged:function(e){o.onModelChanged(e)},onDestroy:function(e){o.onDestroy(e)},onLineStyle:function(e){o.onLineStyle(e)},onStyleReady:function(e){o.onStyleReady(e)},onServiceAdded:function(e){o.onServiceAdded(e.serviceReference,o.serviceRegistry.getService(e.serviceReference))},onServiceRemoved:function(e){o.onServiceRemoved(e.serviceReference,o.serviceRegistry.getService(e.serviceReference))}},e.addEventListener("ModelChanging",this.listener.onModelChanging),e.addEventListener("ModelChanged",this.listener.onModelChanged),e.addEventListener("Destroy",this.listener.onDestroy),e.addEventListener("LineStyle",this.listener.onLineStyle),t.addEventListener("registered",this.listener.onServiceAdded),t.addEventListener("unregistering",this.listener.onServiceRemoved);for(var s=t.getServiceReferences(r),a=0;a<s.length;a++){var l=s[a];n(l)&&this.addServiceListener(t.getService(l))}},onDestroy:function(){this.destroy()},destroy:function(){if(this.textView&&(this.textView.removeEventListener("ModelChanging",this.listener.onModelChanging),this.textView.removeEventListener("ModelChanged",this.listener.onModelChanged),this.textView.removeEventListener("Destroy",this.listener.onDestroy),this.textView.removeEventListener("LineStyle",this.listener.onLineStyle),this.textView=null),this.services){for(var e=0;e<this.services.length;e++)this.removeServiceListener(this.services[e]);this.services=null}this.serviceRegistry&&(this.serviceRegistry.removeEventListener("registered",this.listener.onServiceAdded),this.serviceRegistry.removeEventListener("unregistering",this.listener.onServiceRemoved),this.serviceRegistry=null),this.listener=null,this.lineStyles=null},onModelChanging:function(e){this.startLine=this.textView.getModel().getLineAtOffset(e.start)},onModelChanged:function(e){var t=this.startLine;(e.addedLineCount||e.removedLineCount)&&Array.prototype.splice.apply(this.lineStyles,[t,e.removedLineCount].concat(this._getEmptyStyle(e.addedLineCount)))},onStyleReady:function(e){var n=e.lineStyles||e.style,i=Number.MAX_VALUE,r=-1,s=this.textView.getModel();for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(this.lineStyles[a]=n[a],i=Math.min(i,a),r=Math.max(r,a));i=Math.max(i,0),r=Math.min(r,s.getLineCount());var l=this.annotationModel;if(l){for(var d=l.getAnnotations(s.getLineStart(i),s.getLineEnd(r)),c=[];d.hasNext();){var h=d.next();h.type===o&&c.push(h)}for(var u=[],f=i;r>=f;f++){a=f;var p=this.lineStyles[a],g=p&&p.errors,v=s.getLineStart(a);if(g)for(var m=0;m<g.length;m++){var _=g[m];u.push(t.AnnotationType.createAnnotation(o,_.start+v,_.end+v))}}l.replaceAnnotations(c,u)}this.textView.redrawLines(i,r+1)},onLineStyle:function(e){function t(e,t){for(var n=e.length,i=[],r=0;n>r;r++){var o=e[r];i.push({start:o.start+t,end:o.end+t,style:o.style})}return i}var n=this.lineStyles[e.lineIndex];n&&(n.ranges?e.ranges=t(n.ranges,e.lineStart):n.style&&(e.style=n.style))},_getEmptyStyle:function(e){for(var t=[],n=0;e>n;n++)t.push(null);return t},setContentType:function(e){if(this.contentType=e,this.services)for(var t=0;t<this.services.length;t++){var n=this.services[t];if(n.setContentType){var i=this.serviceRegistry.getService("orion.page.progress");i?i.progress(n.setContentType(this.contentType),this.contentType.id):n.setContentType(this.contentType)}}},onServiceAdded:function(e,t){n(e)&&this.addServiceListener(t)},onServiceRemoved:function(e,t){-1!==this.services.indexOf(t)&&this.removeServiceListener(t)},addServiceListener:function(e){if("function"==typeof e.addEventListener){if(e.addEventListener("orion.edit.highlighter.styleReady",this.listener.onStyleReady),this.services.push(e),e.setContentType&&this.contentType){var t=this.serviceRegistry.getService("orion.page.progress");t?t.progress(e.setContentType(this.contentType),this.contentType.id):e.setContentType(this.contentType)}}else"undefined"!=typeof console&&console.log(new Error(s))},removeServiceListener:function(e){if("function"==typeof e.removeEventListener){e.removeEventListener("orion.edit.highlighter.styleReady",this.listener.onStyleReady);var t=this.services.indexOf(e);-1!==t&&this.services.splice(t,1)}else"undefined"!=typeof console&&console.log(new Error(s))}},i}),n("orion/highlight",["examples/editor/textStyler","orion/editor/textStyler","orion/editor/textMateStyler","orion/editor/AsyncStyler","orion/Deferred"],function(e,t,n,i,r){function o(o,s,l,d,c,h,u){function f(e,t){var n=e.getProperty("contentType")||e.getProperty("contentTypes"),i=e.getProperty("fileTypes");if(n)return r.when(s.isSomeExtensionOf(l,n)).then(function(t){return t?e:null});if(t&&i&&-1!==i.indexOf(t)){var o=new r;return o.resolve(e),o}return null}function p(e){return u||"highlighter"!==e.getProperty("type")}function g(t){var n=null;switch(t&&t.id){case"application/javascript":case"application/json":n=new e.TextStyler(d,"js",c);break;case"text/x-java-source":n=new e.TextStyler(d,"java",c);break;case"text/css":n=new e.TextStyler(d,"css",c)}return n}if(!a){var v=g(l);if(v){var m=new r;return m.resolve(v),m}}a&&!this.orionGrammars&&(this.orionGrammars={});for(var _=h&&h.split(".").pop().toLowerCase(),y=o.getServiceReferences("orion.edit.highlighter"),C=[],w=[],x=0;x<y.length;x++){var b=y[x],S=b.getProperty("type");if("grammar"===S||!a&&"undefined"==typeof S)C.push(b.getProperty("grammar"));else if("highlighter"!==S){var T=b.getProperty("id");T&&!this.orionGrammars[T]&&(this.orionGrammars[T]={id:T,contentTypes:b.getProperty("contentTypes"),patterns:b.getProperty("patterns"),repository:b.getProperty("repository"),firstLineMatch:b.getProperty("firstLineMatch")})}var E=f(b,_);E&&w.push(E)}return r.all(w,function(e){return{_error:e}}).then(function(e){for(var r=[],s=0;s<e.length;s++){var h=e[s];h&&!h._error&&p(h)&&r.push(h)}var u;if(r.length){var f=r[0].getProperty("type");if("highlighter"===f)u=new i(d,o,c),u.setContentType(l);else if("grammar"===f||!a&&"undefined"==typeof f){var g=r[0].getProperty("grammar");u=new n.TextMateStyler(d,g,C)}else if(a){var v=[];for(var m in this.orionGrammars)v.push(this.orionGrammars[m]);var _=[];r.forEach(function(e){_.push(e.getProperty("id"))});var y=new t.createPatternBasedAdapter(v,_,l.id);u=new t.TextStyler(d,c,y)}}else!a||l&&"text/x-markdown"===l.id||(y=new t.createPatternBasedAdapter([],""),u=new t.TextStyler(d,c,y));return u})}function s(e,t){this.serviceRegistry=e,this.contentTypeService=t,this.styler=null}var a=1;return s.prototype={setup:function(e,t,n,i,r){r="undefined"==typeof r?!0:r,this.styler&&(this.styler.destroy&&this.styler.destroy(),this.styler=null);var s=this;return o(this.serviceRegistry,this.contentTypeService?this.contentTypeService:this.serviceRegistry.getService("orion.core.contentTypeRegistry"),e,t,n,i,r).then(function(e){return s.styler=e,e})},getStyler:function(){return this.styler}},{createStyler:o,SyntaxHighlighter:s}}),n("orion/markOccurrences",["orion/Deferred","lsp/utils"],function(e,t){function n(e,t,n,i){this.registry=e,this.inputManager=t,this.editor=n,this.languageServerRegistry=i,this._languageServer=null}return n.prototype={setOccurrencesVisible:function(e){this.occurrencesVisible!==e&&(this.occurrencesVisible=e,e||this.editor.showOccurrences([]))},findOccurrences:function(){function n(t,n,i){function r(e,t,n){var i=t.getProperty("contentType");return o.isSomeExtensionOf(n,i).then(function(e){return e?t:null})}for(var o=t.getService("orion.core.contentTypeRegistry"),s=t.getServiceReferences("orion.edit.occurrences"),a=[],l=0;l<s.length;l++){var d=s[l],c=d.getProperty("pattern");if(d.getProperty("contentType"))a.push(r(t,d,n));else if(c&&new RegExp(c).test(i)){var h=new e;h.resolve(d),a.push(h)}}return e.all(a,function(e){return{_error:e}}).then(function(e){for(var t=[],n=0;n<e.length;n++){var i=e[n];i&&!i._error&&t.push(i)}return t})}var i,r=this,o=function(){i&&window.clearTimeout(i),r.occurrencesVisible&&(i=window.setTimeout(function(){i=null;var n=r.editor,o=n.getSelections();if(o.length>1)return void r.editor.showOccurrences([]);var s={selection:o[0],contentType:r.inputManager.getContentType().id},a=[],l=[];if(Array.isArray(r.occurrencesServices)&&r.occurrencesServices.length>0)for(var d=0;d<r.occurrencesServices.length;d++){var c=r.occurrencesServices[d];c&&a.push(c.computeOccurrences(n.getEditorContext(),s).then(function(e){l=l.concat(e)}))}r._languageServer&&r._languageServer.isDocumentHighlightEnabled()&&a.push(t.computeOccurrences(r._languageServer,r.inputManager,n,s).then(function(e){l=l.concat(e)})),e.all(a).then(function(){r.editor.showOccurrences(l)})},500))};r.inputManager.addEventListener("InputChanged",function(e){var t=r.editor.getTextView(),s=!1;t&&(t.removeEventListener("Selection",o),n(r.registry,e.contentType,e.title).then(function(e){if(e&&0!==e.length){r.occurrencesServices=[];for(var n=0;n<e.length;n++){var a=r.registry.getService(e[n]);a&&r.occurrencesServices.push(a)}s||(s=!0,t.addEventListener("Selection",o))}else i&&window.clearTimeout(i)}),r._languageServer=r.languageServerRegistry.getServerByContentType(e.contentType),r._languageServer&&!s&&t.addEventListener("Selection",o))})}},{MarkOccurrences:n}}),n("orion/syntaxchecker",["orion/Deferred","orion/edit/editorContext"],function(e,t){function n(e,t,n){var i=e.getProperty("contentType");return n.isSomeExtensionOf(t,i).then(function(t){return t?e:null})}function i(e,t,n){return e=Math.max(e,t),e=Math.min(e,n)}function r(e){e=e||{};var t=e.problems||e.errors||e;return Array.isArray(t)?t:[]}function o(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.description=r.description||r.reason,r.severity=r.severity||"error",r.start="number"==typeof r.start?r.start:r.character,"number"==typeof r.line){var o=t.getLine(r.line-1,!1).length;r.start=i(r.start,1,o),r.end="number"==typeof r.end?r.end:-1,r.end=i(r.end,r.start+1,o+1)}else{var s=t.getCharCount();if(r.start=i(r.start,0,s),r.end="number"==typeof r.end?r.end:-1,r.end=i(r.end,r.start,s),r.end===s&&t.getLineCount()>1&&s===t.getLineStart(t.getLineCount()-1)){var a=t.getLineCount()-2,l=t.getLineStart(a),d=t.getLineEnd(a);l===d?r.start=r.end=d:(r.start=d-1,r.end=d)}}}}function s(e,t){this.registry=e,this.textModel=t}return s.prototype={initialize:function(e,t){return t?void this.getValidators(e,t).then(function(n){Array.isArray(n)&&n.length>0&&n.forEach(function(n){var i=this.registry.getService(n);i&&"function"==typeof i.initialize&&i.initialize(e,t)}.bind(this))}.bind(this)):void this.registry.getServiceReferences("orion.edit.validator").forEach(function(t){var n=this.registry.getService(t);n&&"function"==typeof n.initialize&&n.initialize(e)}.bind(this))},checkSyntax:function(n,i,s,a,l){if(!n||s)return(new e).resolve([]);if(!s){var d=this.registry;return this.getValidators(i,n).then(function(s){if(0===s.length)return(new e).resolve();var c=d.getService("orion.page.progress"),h=s.map(function(e){var o,s=d.getService(e);if(s.computeProblems){var h={contentType:n.id,title:i};o=s.computeProblems(l?l:t.getEditorContext(d),h)}else s.checkSyntax&&(o=s.checkSyntax(i,a));return c.progress(o,"Validating "+i).then(r)});return e.all(h,function(e){return{_error:e}}).then(function(t){for(var n=[],i=0;i<t.length;i++){var r=t[i];r._error||(o(r,this.textModel),n=n.concat(r))}return(new e).resolve(n)}.bind(this))}.bind(this),function(){return(new e).resolve([])})}},setTextModel:function(e){this.textModel=e},getValidators:function(t,i){for(var r=this.registry.getService("orion.core.contentTypeRegistry"),o=this.registry.getServiceReferences("orion.edit.validator"),s=[],a=0;a<o.length;a++){var l=o[a],d=l.getProperty("pattern");if(l.getProperty("contentType"))s.push(n(l,i,r));else if(d&&new RegExp(d).test(t)){var c=new e;c.resolve(l),s.push(c)}}return e.all(s,function(e){return{_error:e}}).then(function(e){var t=[];for(a=0;a<e.length;a++){var n=e[a];n&&!n._error&&t.push(n)}return t})}},{SyntaxChecker:s}}),n("orion/liveEditSession",["orion/Deferred"],function(e){function t(e){return e instanceof Error?e:new Error(e)}function n(e,t){this.registry=e,this.editor=t}var i,r=[];return n.prototype={start:function(n,o){function s(n,i){function r(e,t){var n=e.getProperty("contentType");return o.isSomeExtensionOf(t,n).then(function(t){return t?e:null})}for(var o=n.getService("orion.core.contentTypeRegistry"),s=n.getServiceReferences("orion.edit.live"),a=[],l=0;l<s.length;l++){var d=s[l];d.getProperty("contentType")&&a.push(r(d,i))}return e.all(a,t).then(function(e){for(var t=[],n=0;n<e.length;n++){var i=e[n];!i||i instanceof Error||t.push(i)}return t})}if(i!==o){if(r&&r.forEach(function(e){e.endEdit(i)}),r=[],i=o,!n)return;var a=this.editor,l=this.registry;s(l,n).then(function(i){var s=i.map(function(e){var t=l.getService(e);if(t.startEdit){var i={contentType:n.id,title:o};r.push(t);var s=a.getEditorContext();return t.startEdit(s,i)}});e.all(s,t)})}}},n}),n("orion/problems",["orion/EventTarget"],function(e){function t(t,n){this._serviceRegistry=t,e.attach(this),this._serviceRegistration=t.registerService(n||"orion.core.marker",this)}return t.prototype={_setProblems:function(e,t){this.problems=e,this.dispatchEvent({type:"problemsChanged",uri:t,problems:e})}},t.prototype.constructor=t,{ProblemService:t}}),n("orion/blamer",["orion/extensionCommands","orion/PageLinks","orion/URITemplate"],function(e,t,n){function i(e,t,n){this.serviceRegistry=e,this.inputManager=t,this.editor=n}return i.prototype={getBlamer:function(){for(var t=this.inputManager.getFileMetadata(),n=this.serviceRegistry.getServiceReferences("orion.edit.blamer"),i=0;i<n.length;i++){var r=n[i],o={};o.validationProperties=r.getProperty("validationProperties"),o.forceSingleItem=!0;var s=e._makeValidator(o,this.serviceRegistry);if(s.validationFunction.bind(s)(t))return this.serviceRegistry.getService(r)}return null},isVisible:function(){return!!this.getBlamer()},doBlame:function(){var e=this.getBlamer();if(e){var i=function(e){for(var i=t.getOrionHome(),r=0;r<e.length;r++){var o=e[r],s=new n(o.CommitLink),a={};a.OrionHome=i,o.CommitLink=s.expand(a)}this.editor.showBlame(e)}.bind(this),r=this.inputManager,o={metadata:r.getFileMetadata()};e.computeBlame(this.editor.getEditorContext(),o).then(i)}}},{Blamer:i}}),n("orion/compare/diffParser",[],function(){var e=e||{};return e.DiffParser=function(){function e(e,n){this._lineDelimiter=e?e:t?"\r\n":"\n",this._diffLineDelimiter=n?n:this._lineDelimiter,this._DEBUG=!1}var t=-1!==window.navigator.platform.indexOf("Win"),n="\\ No newline at end of file";return e.prototype={_init:function(){this._oFileContents=[],this._diffContents=[],this._oBlocks=[],this._nBlocks=[],this._hunkRanges=[],this._lastToken=" ",this._deltaMap=[],this._nFileContents=[],this._oNewLineAtEnd=!0,this._nNewLineAtEnd=!0,this._diffContentIndex=1},getOriginalBlocks:function(){return this._oBlocks},getNewBlocks:function(){return this._nBlocks},setLineDelim:function(e){this._lineDelimiter=e,this._diffLineDelimiter=e},getDiffArray:function(){return{array:this._diffContents,index:this._diffContentIndex}},parse:function(e,t,n,i){if(this._init(),""===t)return{outPutFile:e,mapper:[]};this._oFileContents=""===e?[]:e.split(this._lineDelimiter),this._diffContents=t.split(this._diffLineDelimiter);var r={};r.mapper=[];var o=this._diffContents.length;this._hunkRanges=[];for(var s=0;o>s;s++){this._addFileModeProperties(this._diffContents[s],r);var a=this._parseHunkRange(s);a&&this._hunkRanges.push(a)}if(0===this._hunkRanges.length)return r.outPutFile=e,r;this._DEBUG&&(console.log("***Diff contents: \n"),this._diffContents.forEach(function(e){console.log(e)}),console.log("***Hunk ranges: \n"),console.log(JSON.stringify(this._hunkRanges)));for(var l=0;l<this._hunkRanges.length;l++)this._parseHunkBlock(l);return this._DEBUG&&(console.log("***Original Hunk range blocks: \n"),console.log(JSON.stringify(this._oBlocks)),console.log("***New Hunk range blocks: \n"),console.log(JSON.stringify(this._nBlocks))),this._buildMap(n),this._DEBUG&&(console.log("***New Line at end of file(original): \n"),console.log(JSON.stringify(this._oNewLineAtEnd)),console.log("***New Line at end of file(new): \n"),console.log(JSON.stringify(this._nNewLineAtEnd)),console.log("***Mapper: \n"),this._logMap(),console.log("***Total line number in original file: "+this._oFileContents.length)),i||this._buildNewFile(),this._DEBUG,r.outPutFile=this._nFileContents.join(this._diffLineDelimiter),r.mapper=this._deltaMap,r},_addFileModeProperties:function(e,t){function n(e,t){return 0===e.lastIndexOf(t,0)}n(e,"-")||n(e,"+")||n(e,"@")||(n(e,"deleted file mode")&&(t.deletedFileMode=e.split("deleted file mode")[1].match(/[^ ]+/g)[0]),n(e,"new file mode")&&(t.newFileMode=e.split("new file mode")[1].match(/[^ ]+/g)[0]),n(e,"old mode")&&(t.oldMode=e.split("old mode")[1].match(/[^ ]+/g)[0]),n(e,"new mode")&&(t.newMode=e.split("new mode")[1].match(/[^ ]+/g)[0]))},_logMap:function(){for(var e=0;e<this._deltaMap.length;e++)if(console.log(JSON.stringify(this._deltaMap[e])),this._deltaMap[e][2]>0){console.log(" **Diff content on change/add: \n");for(var t=0;t<this._deltaMap[e][0];t++)console.log(" "+this._diffContents[this._deltaMap[e][2]+t-1])}},_logNewFile:function(){for(var e=0;e<this._nFileContents.length;e++)console.log(this._nFileContents[e])},_createBlock:function(e,t,n,i){if(i!==n||" "!==e){var r=[n,i-n,"s"];"-"===e?r[2]="r":"+"===e?r[2]="a":"c"===e&&(r[2]="c"),t.push(r)}},_createMinusBlock:function(e,t,n,i){var r=this._oBlocks.length;0===r||e!==this._oBlocks[r-1][0]?(this._oBlocks.push([0===e?1:e,n,i]),this._nBlocks.push([t,0,-2])):(this._oBlocks[r-1][1]=this._oBlocks[r-1][1]+n,this._oBlocks[r-1][2]=i)},_createPlusBlock:function(e,t,n,i){var r=this._nBlocks.length;0===r||t!==this._nBlocks[r-1][0]?(this._oBlocks.push([0===e?1:e,0]),this._nBlocks.push([t,n,i])):(this._nBlocks[r-1][1]=this._nBlocks[r-1][1]+n,this._nBlocks[r-1][2]=i)},_parseHunkBlock:function(e){for(var t=" ",i=this._hunkRanges[e][0]+1,r=e===this._hunkRanges.length-1?this._diffContents.length:this._hunkRanges[e+1][0],o=0,s=0,a=this._hunkRanges[e][1],l=this._hunkRanges[e][3],d=i,c=i,h=i;r>h;h++)if(0!==this._diffContents[h].length){var u=this._diffContents[h][0];if("\\"!==u||n!==this._diffContents[h].substring(0,this._diffContents[h].length-1)&&n!==this._diffContents[h]){switch(u){case"-":case"+":case" ":break;default:continue}if(t!==u){switch("+"===u&&(d=h),"-"===u&&(c=h),t){case" ":a=this._hunkRanges[e][1]+o,l=this._hunkRanges[e][3]+s;break;case"-":this._createMinusBlock(a,l,this._hunkRanges[e][1]+o-a,c);break;case"+":this._createPlusBlock(a,l,this._hunkRanges[e][3]+s-l,d)}t=u}switch(u){case"-":o++;break;case"+":s++;break;case" ":o++,s++}}else"-"===t?this._oNewLineAtEnd=!1:" "===t?(this._nNewLineAtEnd=!1,this._oNewLineAtEnd=!1):this._nNewLineAtEnd=!1,h>i&&"\r"===this._diffContents[h-1][this._diffContents[h-1].length-1]&&(this._diffContents[h-1]=this._diffContents[h-1].substring(0,this._diffContents[h-1].length-1))}switch(t){case"-":this._createMinusBlock(a,l,this._hunkRanges[e][1]+o-a,c);break;case"+":this._createPlusBlock(a,l,this._hunkRanges[e][3]+s-l,d)}},_detectConflictes:function(e,t){if(0>e)return!1;for(var n=e+t,i=e;n>i;i++){var r=this._diffContents[i];if(r.indexOf("<<<<<")>-1||r.indexOf(">>>>>")>-1)return!0}return!1},_buildMap:function(e){for(var t,n=this._oBlocks.length,i=this._oFileContents.length,r=0,o=1,s=0;n>s;s++)t=this._oBlocks[s][0]-o,t>0&&(this._deltaMap.push([t,t,0]),r+=t),this._deltaMap.push(e&&this._detectConflictes(this._nBlocks[s][2],this._nBlocks[s][1])?[this._nBlocks[s][1],this._oBlocks[s][1],this._nBlocks[s][2]+1,1]:[this._nBlocks[s][1],this._oBlocks[s][1],this._nBlocks[s][2]+1]),r+=this._oBlocks[s][1],o=this._oBlocks[s][0]+this._oBlocks[s][1]; if(i-o>0&&(this._deltaMap.push([i-o+1,i-o+1,0]),r+=i-o+1),i>r){t=i-r;var a=this._deltaMap[this._deltaMap.length-1];0===a[2]?(a[0]+=t,a[1]+=t):-1===a[2]?this._deltaMap.push([t,t,0]):this._nNewLineAtEnd===this._oNewLineAtEnd?this._deltaMap.push([t,t,0]):(this._nNewLineAtEnd&&(a[0]+=t),this._oNewLineAtEnd&&(a[1]+=t))}},_buildNewFile:function(){var e,t,n=1,i=!1,r=this._deltaMap.length;for(e=0;r>e;e++){if(i=!1,0===this._deltaMap[e][2]){for(t=0;t<this._deltaMap[e][0];t++)this._nFileContents.push(this._oFileContents[n+t-1]);i=!0}else if(this._deltaMap[e][2]>0)for(t=0;t<this._deltaMap[e][0];t++)this._nFileContents.push(this._diffContents[this._deltaMap[e][2]+t-1].substring(1));n+=this._deltaMap[e][1]}this._nNewLineAtEnd&&!i&&this._nFileContents.push("")},_converHRangeBody:function(e,t){if(e){var n=parseInt(e,10);t.push(n>=0?n:1)}else t.push(1)},_parseHunkRange:function(e){var t=this._diffContents[e],n=/^@@\s*-([\+|\-]*[\d]+)\s*,*\s*([\d]*)\s*\+([\+|\-]*[\d]+)\s*,*\s*([\d]*)\s*@@+/,i=/^@@\s*\+([\+|\-]*[\d]+)\s*,*\s*([\d]*)\s*-([\+|\-]*[\d]+)\s*,*\s*([\d]*)\s*@@+/,r=n.exec(t),o=null;return r&&5===r.length?(o=[e],this._converHRangeBody(r[1],o),this._converHRangeBody(r[2],o),this._converHRangeBody(r[3],o),this._converHRangeBody(r[4],o)):(r=i.exec(t),r&&5===r.length&&(o=[e],this._converHRangeBody(r[3],o),this._converHRangeBody(r[4],o),this._converHRangeBody(r[1],o),this._converHRangeBody(r[2],o))),o}},e}(),e}),n("orion/differ",["orion/extensionCommands","orion/compare/diffParser"],function(e,t){function n(e,t,n){this._serviceRegistry=e,this._inputManager=t,this._editor=n,this._enabled=!1,this.init()}return n.prototype={init:function(){var e=this;this._changeListener=function(){e._enabled&&(e.occurrenceTimer&&window.clearTimeout(e.occurrenceTimer),e.occurrenceTimer=window.setTimeout(function(){e.occurrenceTimer=null,e.doDiff()},500))},this._inputManager.addEventListener("InputChanged",function(){var t=e._editor.getTextView();t&&t.removeEventListener("ModelChanged",e._changeListener);var n=e.service=e.getDiffer();n&&t&&t.addEventListener("ModelChanged",e._changeListener)})},isVisible:function(){return!!this.getDiffer()},getDiffer:function(){for(var t=this._inputManager.getFileMetadata(),n=this._serviceRegistry.getServiceReferences("orion.edit.diff"),i=0;i<n.length;i++){var r=n[i],o={};o.validationProperties=r.getProperty("validationProperties"),o.forceSingleItem=!0;var s=e._makeValidator(o,this._serviceRegistry);if(s.validationFunction.bind(s)(t))return this._serviceRegistry.getService(r)}return null},showAnnotations:function(e){var n=this,i=new t.DiffParser,r={metadata:this._inputManager.getFileMetadata()};e.computeDiff(this._editor.getEditorContext(),r).then(function(e){i.setLineDelim("\n"),i.parse("",e);var t=i.getOriginalBlocks(),r=i.getNewBlocks(),o=i.getDiffArray(),s=n.getDiffRanges(t,r,o);n._enabled&&n._editor.showDiffAnnotations(s)})},getDiffRanges:function(e,t){for(var n=[],i=0;i<t.length;i++){var r=t[i][0],o=e[i][1],s=t[i][1];n.push(0===s?{lineStart:r-1,lineEnd:r,type:"deleted"}:0===o?{lineStart:r-1,lineEnd:r+s-1,type:"added"}:{lineStart:r-1,lineEnd:r+s-1,type:"modified"})}return n},toggleEnabled:function(){this.setEnabled(!this.isEnabled())},setEnabled:function(e){this._enabled=e,this.doDiff()},isEnabled:function(){return this._enabled},doDiff:function(){if(this._enabled){if(this.service){var e=this;this._inputManager.save().then(function(){e.showAnnotations(e.service)})}}else this._editor.showDiffAnnotations([])}},n.prototype.constructor=n,{Differ:n}}),n("orion/webui/contextmenu",["orion/webui/littlelib","orion/webui/dropdown","orion/objects"],function(e,t,n){function i(e){e.skipTriggerEventListeners=!0,r.call(this,e),this._initialize()}var r=t.Dropdown;return i.prototype=Object.create(r.prototype),i.prototype.constructor=i,n.mixin(i.prototype,{_initialize:function(){this._dropdownNode.dropdown||(this._dropdownNode.dropdown=this),this._boundcontextmenuEventHandler=this._contextmenuEventHandler.bind(this),this._boundContextMenuCloser=this._contextMenuCloser.bind(this),this._triggerNode.addEventListener("contextmenu",this._boundcontextmenuEventHandler,!0),window.addEventListener("contextmenu",this._boundContextMenuCloser,!1)},_contextMenuCloser:function(e){this.close(e)},_contextmenuEventHandler:function(t){this.open(t)?e.stop(t):this.close()}}),i.prototype.open=function(e){return this._triggerNode.addEventListener("click",this._boundContextMenuCloser,!1),r.prototype.open.call(this,e)},i.prototype.close=function(e){return this._triggerNode.removeEventListener("click",this._boundContextMenuCloser,!1),r.prototype.close.call(this,e)},i.prototype._positionDropdown=function(t){if(t){var n=t.clientX,i=t.clientY;this._dropdownNode.style.position="fixed",this._dropdownNode.style.left=n+1+"px",this._dropdownNode.style.top=i+"px";var o=e.bounds(this._dropdownNode),s=o.width,a=o.height,l=e.bounds(document.body),d=n+s-(l.left+l.width);d>0&&(this._dropdownNode.style.left=Math.floor(n-d)+"px");var c=i+a-(l.top+l.height);c>0&&(this._dropdownNode.style.top=Math.floor(i-c)+"px")}else r.prototype._positionDropdown.call(this)},i.prototype.destroy=function(){this._triggerNode.removeEventListener("contextmenu",this._boundcontextmenuEventHandler,!0),this._triggerNode.removeEventListener("click",this._boundContextMenuCloser,!1),window.removeEventListener("contextmenu",this._boundContextMenuCloser,!1),this._dropdownNode.dropdown=null,r.prototype.destroy.call(this)},{ContextMenu:i}}),n("orion/commonPreferences",["orion/EventTarget"],function(e){function t(e,t){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n]);return t}function n(t,n){this._preferences=t,e.attach(this),t.addEventListener("changed",function(e){e.namespace===this.getPrefsSection()&&this.dispatchEvent({type:"Changed"})}.bind(this)),n&&this.addEventListener("Changed",function(e){n(e.preferences)})}return n.prototype={_initialize:function(e){var n=e[this.getPrefsKey()]||{},i=this.getDefaults();return t(i,n)},getDefaults:function(){return{}},getPrefsSection:function(){return"common/settings"},getPrefsKey:function(){return"commonSettings"},getPrefs:function(e){return this._preferences.get(this.getPrefsSection()).then(function(t){var n=this._initialize(t);return"string"==typeof n&&(n=JSON.parse(n)),e&&e(n),n}.bind(this))},setPrefs:function(e,t){var n={};n[this.getPrefsKey()]=e,this._preferences.put(this.getPrefsSection(),n).then(function(){e=this._initialize(n),t&&t(e),this.dispatchEvent({type:"Changed",preferences:e})}.bind(this))}},{CommonPreferences:n,mergeSettings:t}}),n("orion/references",[],function(){function e(e,t,n){this.serviceRegistry=e,this.inputManager=t,this.editor=n}function t(e){for(var t=e.inputManager.getContentType(),n=e.serviceRegistry.getServiceReferences("orion.edit.references"),i=0;i<n.length;i++){var r=n[i],o=r.getProperty("contentType");if(t&&t.id){var s=t.id;if(Array.isArray(o)){for(var a=0,l=o.length;l>a;a++)if(o[a]===s)return e.serviceRegistry.getService(r)}else if(s===o)return e.serviceRegistry.getService(r)}}return null}return e.prototype={isVisible:function(){return!!t(this)},findReferences:function(){var e=t(this);if(e){var n=this.editor.getSelection(),i={start:n.start,end:n.end,offset:n.start};return e.findReferences(this.editor.getEditorContext(),i)}}},{References:e}}),n("orion/openDeclaration",[],function(){function e(e,t,n){this.serviceRegistry=e,this.inputManager=t,this.editor=n}function t(e){for(var t=e.inputManager.getContentType(),n=e.serviceRegistry.getServiceReferences("orion.edit.open.declaration"),i=0;i<n.length;i++){var r=n[i],o=r.getProperty("contentType");if(t&&t.id){var s=t.id;if(Array.isArray(o)){for(var a=0,l=o.length;l>a;a++)if(o[a]===s)return e.serviceRegistry.getService(r)}else if(s===o)return e.serviceRegistry.getService(r)}}return null}return e.prototype={isVisible:function(){return!!t(this)},findDeclaration:function(){var e=t(this);if(e){var n=this.editor.getSelection(),i={start:n.start,end:n.end,offset:n.start,input:this.inputManager.getInput()};return e.findDeclaration(this.editor.getEditorContext(),i)}}},{OpenDeclaration:e}}),n("orion/editorView",["i18n!orion/edit/nls/messages","orion/editor/editor","orion/editor/annotations","orion/editor/eventTarget","orion/editor/textView","orion/editor/textModelFactory","orion/editor/editorFeatures","orion/hover","orion/editor/contentAssist","orion/editor/emacs","orion/editor/vi","orion/editorPreferences","orion/widgets/themes/ThemePreferences","orion/widgets/themes/editor/ThemeData","orion/widgets/settings/EditorSettings","orion/searchAndReplace/textSearcher","orion/editorCommands","orion/globalCommands","orion/edit/dispatcher","orion/edit/editorContext","orion/highlight","orion/markOccurrences","orion/syntaxchecker","orion/liveEditSession","orion/problems","orion/blamer","orion/differ","orion/keyBinding","orion/util","orion/Deferred","orion/webui/contextmenu","orion/metrics","orion/commonPreferences","embeddedEditor/helper/memoryFileSysConst","orion/objects","orion/formatter","orion/references","orion/openDeclaration","lsp/languageServerRegistry","lsp/utils"],function(e,n,i,r,o,s,a,l,d,c,h,u,f,p,g,v,m,_,y,C,w,x,b,S,T,E,A,L,k,M,O,D,N,I,R,B,P,F,V,U){function K(e,t){for(var n=0;n<t.length;n++){var i=t[n];e[i]&&(e[i]=parseInt(e[i],10))}}function W(e){this._parent=e.parent,"string"==typeof this._parent&&(this._parent=document.getElementById(e.parent)),this.id=e.id||"",this.activateContext=e.activateContext,this.renderToolbars=e.renderToolbars,this.serviceRegistry=e.serviceRegistry,this.contentTypeRegistry=e.contentTypeRegistry,this.commandRegistry=e.commandRegistry,this.progress=e.progress,this.statusService=e.statusService,this.editorCommands=e.editorCommands,this.fileClient=e.fileService,this.inputManager=e.inputManager,this.preferences=e.preferences,this.readonly=e.readonly,this.singleMode=e.singleMode,this.searcher=e.searcher,this.statusReporter=e.statusReporter,this.model=e.model,this.undoStack=e.undoStack,this.problemsServiceID=e.problemsServiceID||"orion.core.marker",this.editContextServiceID=e.editContextServiceID||"orion.edit.context",this.syntaxHighlighter=new w.SyntaxHighlighter(this.serviceRegistry);var t=_.getKeyAssist?_.getKeyAssist():null;t&&t.addProvider(this.editorCommands);var n=_.getMainSplitter?_.getMainSplitter():null;n&&n.splitter.addEventListener("resize",function(e){this.editor&&e.node===n.main&&this.editor.resize()}.bind(this)),_.getGlobalEventTarget&&_.getGlobalEventTarget().addEventListener("toggleTrim",function(){this.editor&&this.editor.resize()}.bind(this)),this.settings={},this._editorConfig=e.editorConfig,this._init()}var H=I.MEMORY_FILE_PATTERN,j=y.Dispatcher,G=i.AnnotationType;return W.prototype={updateKeyMode:function(e,t){this.emacs&&t.removeKeyMode(this.emacs),this.vi&&t.removeKeyMode(this.vi),"Emacs"===e.keyBindings?(this.emacs||(this.emacs=new c.EmacsMode(t)),t.addKeyMode(this.emacs)):"vi"===e.keyBindings&&(this.vi||(this.vi=new h.VIMode(t,this.statusReporter)),t.addKeyMode(this.vi))},setContents:function(e,t,n){var i=this.contentTypeRegistry.getContentType(t),r="txt";i&&i.extension&&i.extension.length>0&&(r=i.extension[0]);var o,s=n&&n.fileName||"foo",a=H+this.id+"/"+s+"."+r,l=a===this.lastFileLocation;return o=l||!this.lastFileLocation?(new M).resolve():this.fileClient.deleteFile(this.lastFileLocation),o.then(function(){return this.fileClient.write(a,e).then(function(){this.lastFileLocation=a;var e=n&&n.noFocus?!0:void 0;l?this.inputManager.load(void 0,e):this.inputManager.setInput(a,e)}.bind(this))}.bind(this))},getParent:function(){return this._parent},getSettings:function(){return this.settings},setParent:function(e){this._parent=e},updateSourceCodeActions:function(e,t){t&&(t.setAutoPairParentheses(e.autoPairParentheses),t.setAutoPairBraces(e.autoPairBraces),t.setAutoPairSquareBrackets(e.autoPairSquareBrackets),t.setAutoPairAngleBrackets(e.autoPairAngleBrackets),t.setAutoPairQuotations(e.autoPairQuotations),t.setAutoCompleteComments(e.autoCompleteComments),t.setSmartIndentation(e.smartIndentation))},updateViewOptions:function(e){var t=0;e.showMargin&&(t=e.marginOffset,"number"!=typeof t&&(t=e.marginOffset=parseInt(t,10)));var n=0;return e.wordWrap&&(n=t),{readonly:this.readonly||this.inputManager.getReadOnly(),singleMode:this.singleMode,tabSize:e.tabSize||4,expandTab:e.expandTab,wrapMode:e.wordWrap,wrapOffset:n,marginOffset:t,scrollAnimation:e.scrollAnimation?e.scrollAnimationTimeout:0}},updateSettings:function(e){function t(t){var n={};return n[G.ANNOTATION_CURRENT_SEARCH]=e["show"+t+"CurrentSearchAnnotation"],n[G.ANNOTATION_MATCHING_SEARCH]=e["show"+t+"MatchingSearchAnnotation"],n[G.ANNOTATION_READ_OCCURRENCE]=e["show"+t+"ReadOccurrenceAnnotation"],n[G.ANNOTATION_WRITE_OCCURRENCE]=e["show"+t+"WriteOcurrenceAnnotation"],n[G.ANNOTATION_ERROR]=e["show"+t+"ErrorAnnotation"],n[G.ANNOTATION_WARNING]=e["show"+t+"WarningAnnotation"],n[G.ANNOTATION_INFO]=e["show"+t+"InfoAnnotation"],n[G.ANNOTATION_TASK]=e["show"+t+"TaskAnnotation"],n[G.ANNOTATION_BOOKMARK]=e["show"+t+"BookmarkAnnotation"],n[G.ANNOTATION_MATCHING_BRACKET]=e["show"+t+"MatchingBracketAnnotation"],n[G.ANNOTATION_CURRENT_BRACKET]=e["show"+t+"CurrentBracketAnnotation"],n[G.ANNOTATION_CURRENT_LINE]=e["show"+t+"CurrentLineAnnotation"],n}this.settings=e;var n=this.editor,i=this.inputManager;i.setAutoLoadEnabled(e.autoLoad),i.setAutoSaveTimeout(e.autoSave?e.autoSaveTimeout:-1),i.setAutoSyntaxCheck(this.refreshSyntaxCheck,e.autoSave?-1:250),i.setFormatOnSave(e.formatOnSave?e.formatOnSave:!1),this.differ&&(i.setSaveDiffsEnabled(e.saveDiffs),this.differ.setEnabled(this.settings.diffService)),this.updateStyler(e);var r=n.getTextView();r&&(this.updateKeyMode(e,r),r.setOptions(this.updateViewOptions(e))),this.updateSourceCodeActions(e,n.getSourceCodeActions()),n.setAnnotationRulerVisible(e.annotationRuler),n.setLineNumberRulerVisible(e.lineNumberRuler),n.setFoldingRulerVisible(e.foldingRuler),n.setOverviewRulerVisible(e.overviewRuler),n.setZoomRulerVisible(e.zoomRuler),n.setAnnotationTypesVisible(t("")),n.setOverviewAnnotationTypesVisible(t("Overview")),n.setTextAnnotationTypesVisible(t("Text")),this.renderToolbars&&this.renderToolbars(i.getFileMetadata()),this.markOccurrences.setOccurrencesVisible(e.showOccurrences),n.getContentAssist()&&n.getContentAssist().setAutoTriggerEnabled(e.contentAssistAutoTrigger),this.dispatchEvent({type:"Settings",newSettings:this.settings})},updateStyler:function(e){var t=this.syntaxHighlighter.getStyler();t&&t.setWhitespacesVisible&&t.setWhitespacesVisible(e.showWhitespaces,!0)},createSession:function(e){var t=this.editor,n=t.getTextView(),i=this.inputManager;if(n&&i){var r=i.getFileMetadata(),o=k.isElectron?localStorage:sessionStorage;r&&(e.session={get:function(){return o.editorViewSection?JSON.parse(o.editorViewSection):{}},apply:function(e){if(r.Location){var i=this.get(),s=i[r.Location];s&&s.ETag===r.ETag?(t.setSelections(s.selections),n.setTopIndex(s.topIndex,e?function(){}:void 0)):k.isElectron&&(delete i[r.Location],o.editorViewSection=JSON.stringify(i))}},save:function(){if(r.Location){var e=this.get();e[r.Location]={ETag:r.ETag,topIndex:n.getTopIndex(),selections:t.getSelections().map(function(e){return e.getOrientedSelection()})},o.editorViewSection=JSON.stringify(e)}}})}},_init:function(){function i(e,t){c&&t.didClose(c.location);var n=M.getFileMetadata();c={location:n.Location,version:1},t.didOpen(n.Location,M.getContentType().id,c.version,e.text)}function r(t,n,i){J.setTextModel($.getModel());var r=M.getInput();J.checkSyntax(M.getContentType(),t,n,i,$.getEditorContext()).then(function(e){r===M.getInput()&&e&&w.getService(h.problemsServiceID)._setProblems(e)}),M.getReadOnly()&&$.reportStatus(e.readonly,"error")}this.preferences&&(this.editorCommands.editorPreferences=this.editorPreferences=this.editorCommands.editorPreferences||new u.EditorPreferences(this.preferences),this.editorPreferences.addEventListener("Changed",function(e){var t=e.preferences;t?this.updateSettings(t):this.editorPreferences.getPrefs(this.updateSettings.bind(this))}.bind(this)),this.editorCommands.themePreferences=this.themePreferences=this.editorCommands.themePreferences||new f.ThemePreferences(this.preferences,new p.ThemeData),this.themePreferences.apply());var c,h=this,_=this.readonly,y=this.commandRegistry,w=this.serviceRegistry,k=this.activateContext,M=this.inputManager,O=this.progress,D=this.contentTypeRegistry,N=this.editorCommands,I=new V.LanguageServerRegistry(w,this.problemsServiceID),W=function(){var e=h.updateViewOptions(h.settings);R.mixin(e,{parent:h._parent,model:(new s.TextModelFactory).createProjectionTextModel(h.model,{serviceRegistry:h.serviceRegistry}),wrappable:!0});var t=new o.TextView(e);return t.addEventListener("ModelChanging",function(e){var n=I.getServerByContentType(M.getContentType());if(n){if(h.inputChanged)return delete h.inputChanged,void i(e,n);var r=n.getTextDocumentSync();if(r)if(r===n.ipc.TEXT_DOCUMENT_SYNC_KIND.Full){var o=t.getText();o=o.substring(0,e.start)+e.text+o.substring(e.start+e.removedCharCount),n.didChange(M.getFileMetadata().Location,c.version++,[{text:o}])}else r===n.ipc.TEXT_DOCUMENT_SYNC_KIND.Incremental&&n.didChange(M.getFileMetadata().Location,c.version++,[{range:U.getRange($,e.start,e.start+e.removedCharCount),rangeLength:e.removedCharCount,text:e.text}])}}),t},H=function(t,n,i,r){var o,l=new s.TextModelFactory;"function"==typeof l.getDefaultFindOptions&&(o=l.getDefaultFindOptions());var d=h.textSearcher=v.TextSearcher?new v.TextSearcher(t,w,y,i,o):null,c=(new a.KeyBindingsFactory).createKeyBindings(t,i,r,d);h.updateSourceCodeActions(h.settings,c.sourceCodeActions);var u=t.getTextView();return u.setAction("toggleWrapMode",function(){u.invokeAction("toggleWrapMode",!0);var e=u.getOptions("wrapMode");return h.settings.wordWrap=e,h.editorPreferences&&h.editorPreferences.setPrefs(h.settings),!0}),u.setKeyBinding(new L.KeyStroke("z",!0,!1,!0),"toggleZoomRuler"),u.setAction("toggleZoomRuler",function(){return h.settings.zoomRulerVisible?(h.settings.zoomRuler=!h.settings.zoomRuler,h.editorPreferences&&h.editorPreferences.setPrefs(h.settings),!0):!1},{name:e.toggleZoomRuler}),h.vi=h.emacs=null,h.updateKeyMode(h.settings,u),N.overwriteKeyBindings(t),c},G=function(e,t,n){var i=M.getContentType(),r=e.getTitle(),o=w.getServiceReferences("orion.edit.contentAssist").concat(w.getServiceReferences("orion.edit.contentassist")),s=n&&n.providers;s||(s=o.map(function(e){var t=e.getProperty("contentType"),n=e.getProperty("pattern");if(t&&D.isSomeExtensionOf(i,t)||n&&new RegExp(n).test(r)){var o=w.getService(e),s=e.getProperty("service.id").toString(),a=e.getProperty("charTriggers"),l=e.getProperty("excludedStyles"),d=e.getProperty("autoApply");return a&&(a=new RegExp(a)),l&&(l=new RegExp(l)),{provider:o,id:s,charTriggers:a,excludedStyles:l,autoApply:d}}return null}).filter(function(e){return!!e}));var a=I.getServerByContentType(i);a&&s.push({provider:a,id:a._id,lspServer:!0,excludedStyles:new RegExp("(string.*)")});var l={};Object.keys(C).forEach(function(e){"function"==typeof C[e]&&(l[e]=C[e].bind(null,w,h.editContextServiceID))}),t.setEditorContextProvider(l),t.setProviders(s),t.setAutoTriggerEnabled(h.settings.contentAssistAutoTrigger),t.setProgress(O),t.setStyleAccessor(h.getStyleAccessor())},z=_?null:{createContentAssistMode:function(e){var t=new d.ContentAssist(e.getTextView(),w);t.addEventListener("Activating",G.bind(null,e,t));var n=new d.ContentAssistWidget(t,"contentassist"),i=new d.ContentAssistMode(t,n);return t.setMode(i),G(e,t),t.initialize(),i}},$=this.editor=new n.Editor({textViewFactory:W,undoStackFactory:h.undoStack?{createUndoStack:function(e){return h.undoStack.setView(e.getTextView()),h.undoStack}}:new a.UndoFactory,textDNDFactory:new a.TextDNDFactory,annotationFactory:new a.AnnotationFactory,foldingRulerFactory:new a.FoldingRulerFactory,zoomRulerFactory:new a.ZoomRulerFactory,lineNumberRulerFactory:new a.LineNumberRulerFactory,hoverFactory:new l.HoverFactory(w,M,y,I),contentAssistFactory:z,keyBindingFactory:H,statusReporter:this.statusReporter,domNode:this._parent,syntaxHighlighter:this.syntaxHighlighter});this.preferences&&this.preferences.get("/plugins").then(function(e){e["collab/plugins/collabPlugin.html"]&&t(["orion/collab/collabClient"],function(e){e.init(function(){new e.CollabClient($,h.inputManager,h.fileClient,h.serviceRegistry,h.commandRegistry,h.preferences)})})}),$.id="orion.editor",$.processParameters=function(e){return K(e,["start","end","line","offset","length"]),this.showSelection(e.start,e.end,e.line,e.offset,e.length)},$.getEditorContext=function(){return C.getEditorContext(w,h.editContextServiceID)},this.dispatcher=new j(this.serviceRegistry,this.contentTypeRegistry,$,M),this.themePreferences&&this.editorPreferences&&(this.localSettings=g?new g({local:!0,editor:$,themePreferences:this.themePreferences,preferences:this.editorPreferences}):null);var Y=new S(w,$);M.addEventListener("InputChanging",function(e){h.createSession(e)}),window.addEventListener("beforeunload",function(e){h.createSession(e),e.session&&e.session.save()}),M.addEventListener("InputChanged",function(e){h.createSession(e),h.inputChanged=!0;var t=$.getTextView();if(t){var n=M.getContentType(),i=I.getServerByContentType(n);i&&i.start().then(function(){this.renderToolbars&&this.renderToolbars(M.getFileMetadata())}.bind(this)),Y.start(M.getContentType(),e.title),t.setOptions(this.updateViewOptions(this.settings)),this.markOccurrences.setOccurrencesVisible(this.settings.showOccurrences),this.syntaxHighlighter.setup(e.contentType,$.getTextView(),$.getAnnotationModel(),e.title,!0).then(function(){this.updateStyler(this.settings),$.getContentAssist()&&G($,$.getContentAssist())}.bind(this)),t.onInputChanged&&t.onInputChanged({type:e.type})}else Y.start()}.bind(this)),M.addEventListener("Saving",function(e){h.settings.trimTrailingWhiteSpace&&$.getTextView().invokeAction("trimTrailingWhitespaces");var t=$.getTextView();t&&t.onSaving&&t.onSaving({type:e.type})}),this.blamer=new E.Blamer(w,M,$),this.differ=new A.Differ(w,M,$),this.formatter=new B.Formatter(w,M,$,I),this.references=new P.References(w,M,$),this.openDecl=new F.OpenDeclaration(w,M,$),this.problemService=new T.ProblemService(w,this.problemsServiceID);var q=w.getService(this.problemsServiceID);q&&q.addEventListener("problemsChanged",function(e){if(e.uri){var t=M.getFileMetadata();t&&t.Location===e.uri&&Array.isArray(e.problems)&&$.showProblems(e.problems)}else Array.isArray(e.problems)&&$.showProblems(e.problems)});var X=this.markOccurrences=new x.MarkOccurrences(w,M,$,I);X.setOccurrencesVisible(this.settings.showOccurrences),X.findOccurrences();var J=new b.SyntaxChecker(w,$.getModel());this.refreshSyntaxCheck=function(){r(M.getInput())},$.addEventListener("InputChanged",function(e){r(e.title,e.message,e.contents)});var Z=function(e){var t=$.getTextView();if(t){var n=new d.ContentAssist(t,w);G($,n,e)}};w.addEventListener("registered",Z),w.addEventListener("unregistering",Z);var Q=Object.create(null);["getCaretOffset","setCaretOffset","getSelection","getSelectionText","setSelection","getSelections","setSelections","getText","setText","getLineAtOffset","getLineStart","isDirty","markClean"].forEach(function(e){Q[e]=$[e].bind($)}),Q.showMarkers=function(e){w.getService(h.problemsServiceID)._setProblems(e)},Q.enterLinkedMode=function(e){$.getLinkedMode().enterLinkedMode(e)},Q.exitLinkedMode=function(e){$.getLinkedMode().exitLinkedMode(e)},Q.syntaxCheck=function(e,t,n){r(e,t,n)},Q.openEditor=function(e,t){return k.openEditor(e,t)},Q.getFileMetadata=function(){return h.dispatcher.getServiceFileObject()},Q.setStatus=m.handleStatusMessage.bind(null,w),w.registerService(this.editContextServiceID,Q,null)},create:function(){if(this.editor.install(),this.editorPreferences)this.editorPreferences.getPrefs(this.updateSettings.bind(this));else if(this._editorConfig){var e=N.mergeSettings(this._editorConfig,{});this.updateSettings(e)}this._createContextMenu()},destroy:function(){this.lastFileLocation&&this.fileClient.deleteFile(this.lastFileLocation),this.editor.uninstall()},getStyleAccessor:function(){var e=null,t=this.syntaxHighlighter.getStyler();return t&&t.getStyleAccessor&&(e=t.getStyleAccessor()),e},_createContextMenu:function(){this._editorContextMenuNode=document.createElement("ul"),this._editorContextMenuNode.className="dropdownMenu",this._editorContextMenuNode.setAttribute("role","menu"),this._parent.parentNode.appendChild(this._editorContextMenuNode);var e=this.editor.getTextView(),t=new O.ContextMenu({dropdown:this._editorContextMenuNode,triggerNode:e._clientDiv}),n=function(e){var t=e.event;t.target&&(this.commandRegistry.destroy(this._editorContextMenuNode),this.commandRegistry.renderCommands("editorContextMenuActions",this._editorContextMenuNode,null,this,"menu"),D.logEvent("contextMenu","opened","editor"))}.bind(this);t.addEventListener("triggered",n)}},r.EventTarget.addMixin(W.prototype),{EditorView:W}}),n("embeddedEditor/helper/editorSetup",["orion/editor/textModel","orion/editor/undoStack","orion/inputManager","orion/editorView","orion/Deferred","orion/webui/littlelib","orion/objects"],function(e,t,n,i,r,o,s){function a(e){this._serviceRegistry=e.serviceRegistry,this._pluginRegistry=e.pluginRegistry,this._commandRegistry=e.commandRegistry,this._fileClient=e.fileClient,this._contentTypeRegistry=e.contentTypeRegistry,this._editorCommands=e.editorCommands,this._progressService=e.progressService,this._toolbarId=e.toolbarId,this._editorConfig=e.editorConfig}var l=0;return s.mixin(a.prototype,{destroy:function(){},createInputManager:function(){var e=this._inputManager=new n.InputManager({serviceRegistry:this._serviceRegistry,fileClient:this._fileClient,progressService:this._progressService,selection:this.selection,contentTypeRegistry:this._contentTypeRegistry});e.addEventListener("InputChanged",function(e){e.editor=this.editorView.editor,this.setActiveEditorView(this.editorView)}.bind(this)),e.addEventListener("InputChanging",function(e){e.editor=this.editorView.editor}.bind(this))},defaultOptions:function(n){var i=n.parent,r=new e.TextModel,o=l.toString(),s=Object.create(null);return s.openEditor=function(e,t){this.editorView.editor.setSelection(t.start,t.end)}.bind(this),{activateContext:s,id:o,parent:i,model:r,undoStack:new t.UndoStack(r,500),serviceRegistry:this._serviceRegistry,pluginRegistry:this._pluginRegistry,commandRegistry:this._commandRegistry,contentTypeRegistry:this._contentTypeRegistry,editorCommands:this._editorCommands,editorConfig:n.editorConfig?n.editorConfig:this._editorConfig,statusReporter:n.statusReporter,singleMode:n.singleMode,progressService:this._progressService,inputManager:this._inputManager,fileService:this._fileClient,problemsServiceID:"orion.core.marker"+o,editContextServiceID:"orion.edit.context"+o,editModelContextServiceID:"orion.edit.model.context"+o,readonly:!1}},setActiveEditorView:function(e){this._editorCommands.updateCommands(e),this._commandRegistry.destroy(this._toolbarId),this._commandRegistry.renderCommands(this._toolbarId,this._toolbarId,this._inputManager.getFileMetadata(),e.editor,"tool")},createEditor:function(e){this.createInputManager(),this.editorView=new i.EditorView(this.defaultOptions(e)),l++,this.editorView.create(),this._inputManager.editor=this.editorView.editor;var t=o.node(e.parent);return t.addEventListener("mousedown",function(){this.setActiveEditorView(this.editorView)}.bind(this),!0),t.addEventListener("keyup",function(){this.setActiveEditorView(this.editorView)}.bind(this),!0),e.contentType&&"string"==typeof e.contents&&this.editorView.setContents(e.contents,e.contentType,{noFocus:e.noFocus}),(new r).resolve(this.editorView)}}),{EditorSetupHelper:a}}),n("orion/serviceregistry",["orion/Deferred","orion/EventTarget"],function(e,t){function n(e,t,n){this._properties=n||{},this._properties["service.id"]=e,this._properties.objectClass=t,this._properties["service.names"]=t}function i(e,t,n){this._serviceId=e,this._serviceReference=t,this._internalRegistry=n}function r(t,n){function i(i){return function(){var r;try{if(!n())throw new Error("Service was unregistered");var o=t[i].apply(t,Array.prototype.slice.call(arguments));if(o&&"function"==typeof o.then)return o;r=new e,r.resolve(o)}catch(s){r=new e,r.reject(s)}return r.promise}}var r;for(r in t)"function"==typeof t[r]&&(this[r]=i(r))}function o(e,t){this.type=e,this.serviceReference=t}function s(){this._entries=[],this._namedReferences={},this._serviceEventTarget=new t;var e=this;this._internalRegistry={isRegistered:function(t){return e._entries[t]?!0:!1},unregisterService:function(t){var n=e._entries[t];if(!n)throw new Error("Service has already been unregistered: "+t);var i=n.reference;e._serviceEventTarget.dispatchEvent(new o("unregistering",i)),e._entries[t]=null;var r=i.getProperty("objectClass");r.forEach(function(t){for(var n=e._namedReferences[t],r=0;r<n.length;r++)if(n[r]===i){1===n.length?delete e._namedReferences[t]:n.splice(r,1);break}})},modifyService:function(t){var n=e._entries[t];if(!n)throw new Error("Service not found while trying to send modified event: "+t);var i=n.reference;e._serviceEventTarget.dispatchEvent(new o("modified",i))}}}return n.prototype={getPropertyKeys:function(){var e,t=[];for(e in this._properties)this._properties.hasOwnProperty(e)&&t.push(e);return t},getProperty:function(e){return this._properties[e]}},n.prototype.constructor=n,i.prototype={unregister:function(){this._internalRegistry.unregisterService(this._serviceId)},getReference:function(){if(!this._internalRegistry.isRegistered(this._serviceId))throw new Error("Service has already been unregistered: "+this._serviceId);return this._serviceReference},setProperties:function(e){var t=this._serviceReference._properties;this._serviceReference._properties=e||{},e["service.id"]=this._serviceId,e.objectClass=t.objectClass,e["service.names"]=t["service.names"],this._internalRegistry.modifyService(this._serviceId)}},i.prototype.constructor=i,s.prototype={getService:function(e){var t;if("string"==typeof e){var n=this._namedReferences[e];n&&n.some(function(e){return t=this._entries[e.getProperty("service.id")].service,!!t},this)}else{var i=this._entries[e.getProperty("service.id")];i&&(t=i.service)}return t||null},getServiceReferences:function(e){if(e)return this._namedReferences[e]?this._namedReferences[e]:[];var t=[];return this._entries.forEach(function(e){e&&t.push(e.reference)}),t},registerService:function(e,t,s){if("undefined"==typeof t||null===t)throw new Error("invalid service");"string"==typeof e?e=[e]:Array.isArray(e)||(e=[]);var a=this._entries.length,l=new n(a,e,s),d=this._namedReferences;e.forEach(function(e){d[e]=d[e]||[],d[e].push(l)});var c=new r(t,this._internalRegistry.isRegistered.bind(null,a));this._entries.push({reference:l,service:c});var h=this._internalRegistry;return this._serviceEventTarget.dispatchEvent(new o("registered",l)),new i(a,l,h)},addEventListener:function(e,t){this._serviceEventTarget.addEventListener(e,t)},removeEventListener:function(e,t){this._serviceEventTarget.removeEventListener(e,t)}},s.prototype.constructor=s,{ServiceRegistry:s}}),n("orion/defaultEditorPreferences",["orion/util"],function(e){var t={autoSave:e.isElectron?!1:!0,autoSaveVisible:!0,autoSaveLocalVisible:!0,autoSaveTimeout:250,autoSaveTimeoutVisible:!0,themeVisible:!0,themeLocalVisible:!0,fontSizeVisible:!0,fontSizeLocalVisible:!0,autoLoad:!0,autoLoadVisible:!0,saveDiffs:!0,saveDiffsVisible:!0,contentAssistAutoTrigger:!0,contentAssistAutoTriggerVisible:!0,showOccurrences:!0,showOccurrencesVisible:!0,autoPairParentheses:!0,autoPairParenthesesVisible:!0,autoPairBraces:!0,autoPairBracesVisible:!0,autoPairSquareBrackets:!0,autoPairSquareBracketsVisible:!0,autoPairAngleBrackets:!1,autoPairAngleBracketsVisible:!0,autoPairQuotations:!0,autoPairQuotationsVisible:!0,autoCompleteComments:!0,autoCompleteCommentsVisible:!0,smartIndentation:!0,smartIndentationVisible:!0,trimTrailingWhiteSpace:!1,trimTrailingWhiteSpaceVisible:!0,formatOnSave:!1,formatOnSaveVisible:!0,tabSize:4,tabSizeVisible:!0,expandTab:!1,expandTabVisible:!0,scrollAnimation:!0,scrollAnimationVisible:!0,scrollAnimationTimeout:300,scrollAnimationTimeoutVisible:!0,annotationRuler:!0,annotationRulerVisible:!0,lineNumberRuler:!0,lineNumberRulerVisible:!0,foldingRuler:!0,foldingRulerVisible:!0,overviewRuler:!0,overviewRulerVisible:!0,zoomRuler:!1,zoomRulerVisible:!0,zoomRulerLocalVisible:!0,showWhitespaces:!1,showWhitespacesVisible:!0,wordWrap:!1,wordWrapVisible:!0,showMargin:!1,showMarginVisible:!0,marginOffset:80,marginOffsetVisible:!0,keyBindings:"Default",keyBindingsVisible:!0,keyBindingsLocalVisible:!0,diffService:!1,diffServiceVisible:!1,showCurrentSearchAnnotation:!0,showMatchingSearchAnnotation:!0,showReadOccurrenceAnnotation:!0,showWriteOcurrenceAnnotation:!0,showErrorAnnotation:!0,showWarningAnnotation:!0,showInfoAnnotation:!0,showTaskAnnotation:!0,showBookmarkAnnotation:!0,showMatchingBracketAnnotation:!0,showCurrentBracketAnnotation:!0,showCurrentLineAnnotation:!0,showOverviewCurrentSearchAnnotation:!0,showOverviewMatchingSearchAnnotation:!0,showOverviewReadOccurrenceAnnotation:!0,showOverviewWriteOcurrenceAnnotation:!0,showOverviewErrorAnnotation:!0,showOverviewWarningAnnotation:!0,showOverviewInfoAnnotation:!0,showOverviewTaskAnnotation:!0,showOverviewBookmarkAnnotation:!0,showOverviewMatchingBracketAnnotation:!0,showOverviewCurrentBracketAnnotation:!0,showOverviewCurrentLineAnnotation:!0,showTextCurrentSearchAnnotation:!0,showTextMatchingSearchAnnotation:!0,showTextReadOccurrenceAnnotation:!0,showTextWriteOcurrenceAnnotation:!0,showTextErrorAnnotation:!0,showTextWarningAnnotation:!0,showTextInfoAnnotation:!0,showTextTaskAnnotation:!0,showTextBookmarkAnnotation:!0,showTextMatchingBracketAnnotation:!0,showTextCurrentBracketAnnotation:!0,showTextCurrentLineAnnotation:!0,showCurrentSearchAnnotationVisible:!0,showMatchingSearchAnnotationVisible:!0,showReadOccurrenceAnnotationVisible:!0,showWriteOcurrenceAnnotationVisible:!0,showErrorAnnotationVisible:!0,showWarningAnnotationVisible:!0,showInfoAnnotationVisible:!0,showTaskAnnotationVisible:!0,showWarningAnnotationLocalVisible:!0,showInfoAnnotationLocalVisible:!0,showTaskAnnotationLocalVisible:!0,showBookmarkAnnotationVisible:!0,showMatchingBracketAnnotationVisible:!0,showCurrentBracketAnnotationVisible:!0,showCurrentLineAnnotationVisible:!0,showOverviewCurrentSearchAnnotationVisible:!0,showOverviewMatchingSearchAnnotationVisible:!0,showOverviewReadOccurrenceAnnotationVisible:!0,showOverviewWriteOcurrenceAnnotationVisible:!0,showOverviewErrorAnnotationVisible:!0,showOverviewWarningAnnotationVisible:!0,showOverviewInfoAnnotationVisible:!0,showOverviewTaskAnnotationVisible:!0,showOverviewBookmarkAnnotationVisible:!0,showOverviewMatchingBracketAnnotationVisible:!0,showOverviewCurrentBracketAnnotationVisible:!0,showOverviewCurrentLineAnnotationVisible:!0,showTextCurrentSearchAnnotationVisible:!0,showTextMatchingSearchAnnotationVisible:!0,showTextReadOccurrenceAnnotationVisible:!0,showTextWriteOcurrenceAnnotationVisible:!0,showTextErrorAnnotationVisible:!0,showTextWarningAnnotationVisible:!0,showTextInfoAnnotationVisible:!0,showTextTaskAnnotationVisible:!0,showTextBookmarkAnnotationVisible:!0,showTextMatchingBracketAnnotationVisible:!0,showTextCurrentBracketAnnotationVisible:!0,showTextCurrentLineAnnotationVisible:!0}; return{defaults:t}}),n("embeddedEditor/builder/embeddedEditor",["orion/commandRegistry","orion/keyAssist","orion/fileClient","orion/contentTypes","orion/editorCommands","embeddedEditor/helper/bootstrap","embeddedEditor/helper/editorSetup","embeddedEditor/helper/memoryFileSysConst","orion/serviceregistry","orion/Deferred","orion/commonPreferences","orion/defaultEditorPreferences","orion/objects"],function(e,t,n,i,r,o,s,a,l,d,c,h,u){function f(e){this.serviceRegistry=new l.ServiceRegistry,this.contentTypeRegistry=new i.ContentTypeRegistry(this.serviceRegistry),this._startupOptions=e,this._toolbarId=e&&e.toolbarId?e.toolbarId:"__code__edit__hidden__toolbar",this.Deferred=d}var p;return u.mixin(f.prototype,{_init:function(){if(p)return p;if(!this._startupOptions||!this._startupOptions.toolbarId){var i=document.createElement("div");i.id=this._toolbarId,document.body.appendChild(i),i.style.display="none"}this._commandRegistry=new e.CommandRegistry({}),this._fileClient=new n.FileClient(this.serviceRegistry),this._editorCommands=new r.EditorCommandFactory({serviceRegistry:this.serviceRegistry,commandRegistry:this._commandRegistry,fileClient:this._fileClient,toolbarId:this._toolbarId,navToolbarId:this._toolbarId});var o=new t.KeyAssistPanel({commandRegistry:this._commandRegistry});return t.createCommand(o,"__toolbar__",this._commandRegistry),o.addProvider(this._editorCommands),this._editorConfig=this._startupOptions&&this._startupOptions.editorConfig?this._startupOptions.editorConfig:{},c.mergeSettings(h.defaults,this._editorConfig),this._progressService={progress:function(e){return e},showWhile:function(e){return e}},this.serviceRegistry.registerService("orion.page.progress",this._progressService),p=this._editorCommands.createCommands().then(function(){return this._editorCommands.registerCommands(),(new d).resolve()}.bind(this))},startup:function(e){return o.startup(this.serviceRegistry,this.contentTypeRegistry,this._startupOptions).then(function(t){var n=t.serviceRegistry,i=t.pluginRegistry;return this._init(t).then(function(){if(!e)return(new d).resolve(t);var r=new s.EditorSetupHelper({serviceRegistry:n,pluginRegistry:i,commandRegistry:this._commandRegistry,fileClient:this._fileClient,contentTypeRegistry:this.contentTypeRegistry,editorCommands:this._editorCommands,editorConfig:this._editorConfig,progressService:this._progressService,toolbarId:this._toolbarId});return r.createEditor(e)}.bind(this))}.bind(this))},create:function(e){return this.startup(e)},importFiles:function(e){var t=this.serviceRegistry.getService("orion.core.file.client"),n=[];return t&&e.forEach(function(e){var i=t.createFile(e.parentLocation?e.parentLocation:a.MEMORY_FILE_PROJECT_PATTERN,e.name).then(function(n){return t.write(n.Location,e.contents)});n.push(i)}),d.all(n)},exportFiles:function(e){var t=this.serviceRegistry.getService("orion.core.file.client"),n=[];return t&&e.forEach(function(e){var i;if(e.name||e.location){var r=e.location?e.location:a.MEMORY_FILE_PROJECT_PATTERN+e.name;i=t.read(r)}else i=(new d).resolve("");n.push(i)}),d.all(n)}}),f}),t("embeddedEditor/builder/embeddedEditor")});</code></pre> <br/> <br/> <div class='clear'></div> </main> </div> <br/><br/> <div class="align-center">&copy; 2015 - 2025 <a href="/legal-notice.php">Weber Informatics LLC</a>&nbsp;|&nbsp;<a href="/data-protection.php">Privacy Policy</a></div> <br/><br/><br/><br/><br/><br/> </body> </html>