(function(){"use strict";function t(e,t){return e.line-t.line||e.ch-t.ch}function s(e,t,n,r){this.line=t,this.ch=n,this.cm=e,this.text=e.getLine(t),this.min=r?r.from:e.firstLine(),this.max=r?r.to-1:e.lastLine()}function o(t,n){var r=t.cm.getTokenTypeAt(e(t.line,n));return r&&/\btag\b/.test(r)}function u(e){if(e.line>=e.max)return;return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function a(e){if(e.line<=e.min)return;return e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0}function f(e){for(;;){var t=e.text.indexOf(">",e.ch);if(t==-1){if(u(e))continue;return}if(!o(e,t+1)){e.ch=t+1;continue}var n=e.text.lastIndexOf("/",t),r=n>-1&&!/\S/.test(e.text.slice(n+1,t));return e.ch=t+1,r?"selfClose":"regular"}}function l(e){for(;;){var t=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(t==-1){if(a(e))continue;return}if(!o(e,t+1)){e.ch=t;continue}i.lastIndex=t,e.ch=t;var n=i.exec(e.text);if(n&&n.index==t)return n}}function c(e){for(;;){i.lastIndex=e.ch;var t=i.exec(e.text);if(!t){if(u(e))continue;return}if(!o(e,t.index+1)){e.ch=t.index+1;continue}return e.ch=t.index+t[0].length,t}}function h(e){for(;;){var t=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(t==-1){if(a(e))continue;return}if(!o(e,t+1)){e.ch=t;continue}var n=e.text.lastIndexOf("/",t),r=n>-1&&!/\S/.test(e.text.slice(n+1,t));return e.ch=t+1,r?"selfClose":"regular"}}function p(t,n){var r=[];for(;;){var i=c(t),s,o=t.line,u=t.ch-(i?i[0].length:0);if(!i||!(s=f(t)))return;if(s=="selfClose")continue;if(i[1]){for(var a=r.length-1;a>=0;--a)if(r[a]==i[2]){r.length=a;break}if(a<0&&(!n||n==i[2]))return{tag:i[2],from:e(o,u),to:e(t.line,t.ch)}}else r.push(i[2])}}function d(t,n){var r=[];for(;;){var i=h(t);if(!i)return;if(i=="selfClose"){l(t);continue}var s=t.line,o=t.ch,u=l(t);if(!u)return;if(u[1])r.push(u[2]);else{for(var a=r.length-1;a>=0;--a)if(r[a]==u[2]){r.length=a;break}if(a<0&&(!n||n==u[2]))return{tag:u[2],from:e(t.line,t.ch),to:e(s,o)}}}}var e=CodeMirror.Pos,n="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",r=n+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",i=new RegExp("<(/?)(["+n+"]["+r+"]*)","g");CodeMirror.registerHelper("fold","xml",function(t,n){var r=new s(t,n.line,0);for(;;){var i=c(r),o;if(!i||r.line!=n.line||!(o=f(r)))return;if(!i[1]&&o!="selfClose"){var n=e(r.line,r.ch),u=p(r,i[2]);return u&&{from:n,to:u.from}}}}),CodeMirror.tagRangeFinder=CodeMirror.fold.xml,CodeMirror.findMatchingTag=function(n,r,i){var o=new s(n,r.line,r.ch,i);if(o.text.indexOf(">")==-1&&o.text.indexOf("<")==-1)return;var u=f(o),a=u&&e(o.line,o.ch),c=u&&l(o);if(!u||u=="selfClose"||!c||t(o,r)>0)return;var h={from:e(o.line,o.ch),to:a,tag:c[2]};return c[1]?{open:d(o,c[2]),close:h,at:"close"}:(o=new s(n,a.line,a.ch,i),{open:h,close:p(o,c[2]),at:"open"})},CodeMirror.findEnclosingTag=function(e,t,n){var r=new s(e,t.line,t.ch,n);for(;;){var i=d(r);if(!i)break;var o=new s(e,t.line,t.ch,n),u=p(o,i.tag);if(u)return{open:i,close:u}}}})();