!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 i,r=t.indentUnit;function u(t,e){return i=e,t}function a(t,e){var n=t.next();if("<"==n&&t.eat("!"))return t.eatWhile(/[\-]/)?(e.tokenize=o)(t,e):t.eatWhile(/[\w]/)?u("keyword","doindent"):void 0;if("<"==n&&t.eat("?"))return e.tokenize=function(n,r){return function(t,e){for(;!t.eol();){if(t.match(r)){e.tokenize=a;break}t.next()}return n}}("meta","?>"),u("meta",n);if("#"==n&&t.eatWhile(/[\w]/))return u("atom","tag");if("|"==n)return u("keyword","seperator");if(n.match(/[\(\)\[\]\-\.,\+\?>]/))return u(null,n);if(n.match(/[\[\]]/))return u("rule",n);if('"'==n||"'"==n)return e.tokenize=function(i){return function(t,e){for(var n,r=!1;null!=(n=t.next());){if(n==i&&!r){e.tokenize=a;break}r=!r&&"\\"==n}return u("string","tag")}}(n),e.tokenize(t,e);if(t.eatWhile(/[a-zA-Z\?\+\d]/)){var r=t.current();return null!==r.substr(r.length-1,r.length).match(/\?|\+/)&&t.backUp(1),u("tag","tag")}return"%"==n||"*"==n?u("number","number"):(t.eatWhile(/[\w\\\-_%.{,]/),u(null,null))}function o(t,e){for(var n,r=0;null!=(n=t.next());){if(2<=r&&">"==n){e.tokenize=a;break}r="-"==n?r+1:0}return u("comment","comment")}return{startState:function(t){return{tokenize:a,baseIndent:t||0,stack:[]}},token:function(t,e){if(t.eatSpace())return null;var n=e.tokenize(t,e),r=e.stack[e.stack.length-1];return"["==t.current()||"doindent"===i||"["==i?e.stack.push("rule"):"endtag"===i?e.stack[e.stack.length-1]="endtag":"]"==t.current()||"]"==i||">"==i&&"rule"==r?e.stack.pop():"["==i&&e.stack.push("["),n},indent:function(t,e){var n=t.stack.length;return e.match(/\]\s+|\]/)?n-=1:">"===e.substr(e.length-1,e.length)&&("<"===e.substr(0,1)||"doindent"==i&&1<e.length||("doindent"==i?n--:">"==i&&1<e.length||"tag"==i&&">"!==e||("tag"==i&&"rule"==t.stack[t.stack.length-1]?n--:"tag"==i?n++:">"===e&&"rule"==t.stack[t.stack.length-1]&&">"===i?n--:">"===e&&"rule"==t.stack[t.stack.length-1]||("<"!==e.substr(0,1)&&">"===e.substr(0,1)?n-=1:">"===e||(n-=1)))),null!=i&&"]"!=i||n--),t.baseIndent+n*r},electricChars:"]>"}}),t.defineMIME("application/xml-dtd","dtd")});