'use strict';(function(f){"object"==typeof exports&&"object"==typeof module?f(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],f):f(CodeMirror)})(function(f){function w(a,d){function b(a){if(!e.parentNode)return f.off(document,"mousemove",b);e.style.top=Math.max(0,a.clientY-e.offsetHeight-5)+"px";e.style.left=a.clientX+5+"px"}var e=document.createElement("div");e.className="CodeMirror-lint-tooltip";e.appendChild(d.cloneNode(!0));document.body.appendChild(e);
f.on(document,"mousemove",b);b(a);null!=e.style.opacity&&(e.style.opacity=1);return e}function x(a){a.parentNode&&(null==a.style.opacity&&a.parentNode&&a.parentNode.removeChild(a),a.style.opacity=0,setTimeout(function(){a.parentNode&&a.parentNode.removeChild(a)},600))}function q(a,d,b){function e(){f.off(b,"mouseout",e);c&&(x(c),c=null)}var c=w(a,d),g=setInterval(function(){if(c)for(var a=b;;a=a.parentNode){a&&11==a.nodeType&&(a=a.host);if(a==document.body)return;if(!a){e();break}}if(!c)return clearInterval(g)},
400);f.on(b,"mouseout",e)}function y(a,d,b){this.marked=[];this.options=d;this.timeout=null;this.hasGutter=b;this.onMouseOver=function(b){a:{var c=b.target||b.srcElement;if(/\bCodeMirror-lint-mark-/.test(c.className))for(var c=c.getBoundingClientRect(),d=a.findMarksAt(a.coordsChar({left:(c.left+c.right)/2,top:(c.top+c.bottom)/2},"client")),f=0;f<d.length;++f)if(c=d[f].__annotation){d=b.target||b.srcElement;q(b,r(c),d);break a}}};this.waitingFor=0}function t(a){var d=a.state.lint;d.hasGutter&&a.clearGutter("CodeMirror-lint-markers");
for(a=0;a<d.marked.length;++a)d.marked[a].clear();d.marked.length=0}function z(a,d,b,e){var c=document.createElement("div"),g=c;c.className="CodeMirror-lint-marker-"+d;b&&(g=c.appendChild(document.createElement("div")),g.className="CodeMirror-lint-marker-multiple");if(0!=e)f.on(g,"mouseover",function(c){q(c,a,g)});return c}function r(a){var d=a.severity;d||(d="error");var b=document.createElement("div");b.className="CodeMirror-lint-message-"+d;b.appendChild(document.createTextNode(a.message));return b}
function A(a,d,b){function e(){g=-1;a.off("change",e)}var c=a.state.lint,g=++c.waitingFor;a.on("change",e);d(a.getValue(),function(b,d){a.off("change",e);c.waitingFor==g&&(d&&b instanceof f&&(b=d),u(a,b))},b,a)}function m(a,d){var b=a.state.lint.options,e=b.options||b,c=(d?null:b.getAnnotations)||a.getHelper(f.Pos(0,0),"lint");c&&(d||!b.async&&!c.async?u(a,c(a.getValue(),e,a)):A(a,c,e))}function u(a,d){t(a);for(var b=a.state.lint,e=b.options,c=[],f=0;f<d.length;++f){var k=d[f],l=k.from.line;(c[l]||
(c[l]=[])).push(k)}for(f=0;f<c.length;++f)if(k=c[f]){for(var l=null,m=b.hasGutter&&document.createDocumentFragment(),p=0;p<k.length;++p){var h=k[p],n=h.severity;n||(n="error");"error"!=l&&(l=n);e.formatAnnotation&&(h=e.formatAnnotation(h));b.hasGutter&&m.appendChild(r(h));h.to&&b.marked.push(a.markText(h.from,h.to,{className:"CodeMirror-lint-mark-"+n,__annotation:h}))}b.hasGutter&&a.setGutterMarker(f,"CodeMirror-lint-markers",z(m,l,1<k.length,b.options.tooltips))}if(e.onUpdateLinting)e.onUpdateLinting(d,
c,a)}function v(a){var d=a.state.lint;d&&(clearTimeout(d.timeout),d.timeout=setTimeout(function(){m(a)},d.options.delay||500))}f.defineOption("lint",!1,function(a,d,b){b&&b!=f.Init&&(t(a),!1!==a.state.lint.options.lintOnChange&&a.off("change",v),f.off(a.getWrapperElement(),"mouseover",a.state.lint.onMouseOver),clearTimeout(a.state.lint.timeout),delete a.state.lint);if(d){var e=a.getOption("gutters");b=!1;for(var c=0;c<e.length;++c)"CodeMirror-lint-markers"==e[c]&&(b=!0);e=a.state;c=d;c instanceof
Function?c={getAnnotations:c}:c&&!0!==c||(c={});b=e.lint=new y(a,c,b);if(!1!==b.options.lintOnChange)a.on("change",v);if(0!=b.options.tooltips)f.on(a.getWrapperElement(),"mouseover",b.onMouseOver);!1!==d.lintOnChange&&m(a)}});f.defineExtension("performLint",function(a){this.state.lint&&m(this,a)})});
