!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("tiki",function(e){function o(n,r,i){return function(e,t){for(;!e.eol();){if(e.match(r)){t.tokenize=a;break}e.next()}return i&&(t.tokenize=i),n}}function u(n){return function(e,t){for(;!e.eol();)e.next();return t.tokenize=a,n}}function a(t,n){function e(e){return(n.tokenize=e)(t,n)}var r=t.sol(),i=t.next();switch(i){case"{":return t.eat("/"),t.eatSpace(),t.eatWhile(/[^\s\u00a0=\"\'\/?(}]/),n.tokenize=l,"tag";case"_":if(t.eat("_"))return e(o("strong","__",a));break;case"'":if(t.eat("'"))return e(o("em","''",a));break;case"(":if(t.eat("("))return e(o("variable-2","))",a));break;case"[":return e(o("variable-3","]",a));case"|":if(t.eat("|"))return e(o("comment","||"));break;case"-":if(t.eat("="))return e(o("header string","=-",a));if(t.eat("-"))return e(o("error tw-deleted","--",a));break;case"=":if(t.match("=="))return e(o("tw-underline","===",a));break;case":":if(t.eat(":"))return e(o("comment","::"));break;case"^":return e(o("tw-box","^"));case"~":if(t.match("np~"))return e(o("meta","~/np~"))}if(r)switch(i){case"!":return t.match("!!!!!")||t.match("!!!!")||t.match("!!!")||t.match("!!"),e(u("header string"));case"*":case"#":case"+":return e(u("tw-listitem bracket"))}return null}var r,i,c,f,s=e.indentUnit;function l(e,t){var n=e.next(),r=e.peek();return"}"==n?(t.tokenize=a,"tag"):"("==n||")"==n?"bracket":"="==n?(i="equals",">"==r&&(e.next(),r=e.peek()),/[\'\"]/.test(r)||(t.tokenize=function(e,t){for(;!e.eol();){var n=e.next(),r=e.peek();if(" "==n||","==n||/[ )}]/.test(r)){t.tokenize=l;break}}return"string"}),"operator"):/[\'\"]/.test(n)?(t.tokenize=function(n){return function(e,t){for(;!e.eol();)if(e.next()==n){t.tokenize=l;break}return"string"}}(n),t.tokenize(e,t)):(e.eatWhile(/[^\s\u00a0=\"\'\/?]/),"keyword")}function n(){for(var e=arguments.length-1;0<=e;e--)c.cc.push(arguments[e])}function d(){return n.apply(null,arguments),!0}function k(e,t){var n=c.context&&c.context.noIndent;c.context={prev:c.context,pluginName:e,indent:c.indented,startOfLine:t,noIndent:n}}function p(){c.context&&(c.context=c.context.prev)}function m(e){if("openPlugin"==e)return c.pluginName=r,d(g,function(t){return function(e){return"selfclosePlugin"==e||"endPlugin"==e||"endPlugin"==e&&k(c.pluginName,t),d()}}(c.startOfLine));if("closePlugin"!=e)return"string"==e&&(c.context&&"!cdata"==c.context.name||k("!cdata"),c.tokenize==a&&p()),d();var t=!1;return c.context?(t=c.context.pluginName!=r,p()):t=!0,t&&(f="error"),d(function(t){return function(e){return t&&(f="error"),"endPlugin"==e?d():n()}}(t))}function g(e){return"keyword"==e?(f="attribute",d(g)):"equals"==e?d(t,g):n()}function t(e){return"keyword"==e?(f="string",d()):"string"==e?d(x):n()}function x(e){return"string"==e?d(x):n()}return{startState:function(){return{tokenize:a,cc:[],indented:0,startOfLine:!0,pluginName:null,context:null}},token:function(e,t){if(e.sol()&&(t.startOfLine=!0,t.indented=e.indentation()),e.eatSpace())return null;f=i=r=null;var n=t.tokenize(e,t);if((n||i)&&"comment"!=n)for(c=t;;){if((t.cc.pop()||m)(i||n))break}return t.startOfLine=!1,f||n},indent:function(e,t){var n=e.context;if(n&&n.noIndent)return 0;for(n&&/^{\//.test(t)&&(n=n.prev);n&&!n.startOfLine;)n=n.prev;return n?n.indent+s:0},electricChars:"/"}}),e.defineMIME("text/tiki","tiki")});