'use strict';(function(d){"object"==typeof exports&&"object"==typeof module?d(require("../../lib/codemirror"),require("../htmlmixed/htmlmixed"),require("../ruby/ruby")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../htmlmixed/htmlmixed","../ruby/ruby"],d):d(CodeMirror)})(function(d){d.defineMode("haml",function(k){function l(b){return function(a,c){return a.peek()==b&&1==c.rubyState.tokenize.length?(a.next(),c.tokenize=f,"closeAttributeTag"):e(a,c)}}function e(b,a){return b.match("-#")?
(b.skipToEnd(),"comment"):g.token(b,a.rubyState)}function f(b,a){var c=b.peek();if("comment"==a.previousToken.style&&a.indented>a.previousToken.indented)return b.skipToEnd(),"commentLine";if(a.startOfLine){if("!"==c&&b.match("!!"))return b.skipToEnd(),"tag";if(b.match(/^%[\w:#\.]+=/))return a.tokenize=e,"hamlTag";if(b.match(/^%[\w:]+/))return"hamlTag";if("/"==c)return b.skipToEnd(),"comment"}if(a.startOfLine||"hamlTag"==a.previousToken.style)if("#"==c||"."==c)return b.match(/[\w-#\.]*/),"hamlAttribute";
if(a.startOfLine&&!b.match("--\x3e",!1)&&("="==c||"-"==c))return a.tokenize=e,a.tokenize(b,a);if("hamlTag"==a.previousToken.style||"closeAttributeTag"==a.previousToken.style||"hamlAttribute"==a.previousToken.style){if("("==c)return a.tokenize=l(")"),a.tokenize(b,a);if("{"==c&&!b.match(/^\{%.*/))return a.tokenize=l("}"),a.tokenize(b,a)}return h.token(b,a.htmlState)}var h=d.getMode(k,{name:"htmlmixed"}),g=d.getMode(k,"ruby");return{startState:function(){var b=d.startState(h),a=d.startState(g);return{htmlState:b,
rubyState:a,indented:0,previousToken:{style:null,indented:0},tokenize:f}},copyState:function(b){return{htmlState:d.copyState(h,b.htmlState),rubyState:d.copyState(g,b.rubyState),indented:b.indented,previousToken:b.previousToken,tokenize:b.tokenize}},token:function(b,a){b.sol()&&(a.indented=b.indentation(),a.startOfLine=!0);if(b.eatSpace())return null;var c=a.tokenize(b,a);a.startOfLine=!1;c&&"commentLine"!=c&&(a.previousToken={style:c,indented:a.indented});if(b.eol()&&a.tokenize==e){b.backUp(1);var d=
b.peek();b.next();d&&","!=d&&(a.tokenize=f)}"hamlTag"==c?c="tag":"commentLine"==c?c="comment":"hamlAttribute"==c?c="attribute":"closeAttributeTag"==c&&(c=null);return c}}},"htmlmixed","ruby");d.defineMIME("text/x-haml","haml")});
