!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";t.defineMode("dtd",function(t){var e,n=t.indentUnit;function r(t,n){return e=n,t}function a(t,e){var n,u,o,c=t.next();if("<"!=c||!t.eat("!")){if("<"==c&&t.eat("?"))return e.tokenize=(u="meta",o="?>",function(t,e){for(;!t.eol();){if(t.match(o)){e.tokenize=a;break}t.next()}return u}),r("meta",c);if("#"==c&&t.eatWhile(/[\w]/))return r("atom","tag");if("|"==c)return r("keyword","separator");if(c.match(/[\(\)\[\]\-\.,\+\?>]/))return r(null,c);if(c.match(/[\[\]]/))return r("rule",c);if('"'==c||"'"==c)return e.tokenize=(n=c,function(t,e){for(var i,u=!1;null!=(i=t.next());){if(i==n&&!u){e.tokenize=a;break}u=!u&&"\\"==i}return r("string","tag")}),e.tokenize(t,e);if(t.eatWhile(/[a-zA-Z\?\+\d]/)){var l=t.current();return null!==l.substr(l.length-1,l.length).match(/\?|\+/)&&t.backUp(1),r("tag","tag")}return"%"==c||"*"==c?r("number","number"):(t.eatWhile(/[\w\\\-_%.{,]/),r(null,null))}return t.eatWhile(/[\-]/)?(e.tokenize=i,i(t,e)):t.eatWhile(/[\w]/)?r("keyword","doindent"):void 0}function i(t,e){for(var n,i=0;null!=(n=t.next());){if(i>=2&&">"==n){e.tokenize=a;break}i="-"==n?i+1:0}return r("comment","comment")}return{startState:function(t){return{tokenize:a,baseIndent:t||0,stack:[]}},token:function(t,n){if(t.eatSpace())return null;var r=n.tokenize(t,n),a=n.stack[n.stack.length-1];return"["==t.current()||"doindent"===e||"["==e?n.stack.push("rule"):"endtag"===e?n.stack[n.stack.length-1]="endtag":"]"==t.current()||"]"==e||">"==e&&"rule"==a?n.stack.pop():"["==e&&n.stack.push("["),r},indent:function(t,r){var a=t.stack.length;return"]"===r.charAt(0)?a--:">"===r.substr(r.length-1,r.length)&&("<"===r.substr(0,1)||"doindent"==e&&r.length>1||("doindent"==e?a--:">"==e&&r.length>1||"tag"==e&&">"!==r||("tag"==e&&"rule"==t.stack[t.stack.length-1]?a--:"tag"==e?a++:">"===r&&"rule"==t.stack[t.stack.length-1]&&">"===e?a--:">"===r&&"rule"==t.stack[t.stack.length-1]||("<"!==r.substr(0,1)&&">"===r.substr(0,1)?a-=1:">"===r||(a-=1)))),null!=e&&"]"!=e||a--),t.baseIndent+a*n},electricChars:"]>"}}),t.defineMIME("application/xml-dtd","dtd")});