'use strict';(function(h){"object"==typeof exports&&"object"==typeof module?h(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],h):h(CodeMirror)})(function(h){function p(f){return new RegExp("^(("+f.join(")|(")+"))\\b")}function f(f){return f.scopes[f.scopes.length-1]}var C=p(["and","or","not","is"]),v="as assert break class continue def del elif else except finally for from global if import lambda pass raise return try while with yield in".split(" "),
w="abs all any bin bool bytearray callable chr classmethod compile complex delattr dict dir divmod enumerate eval filter float format frozenset getattr globals hasattr hash help hex id input int isinstance issubclass iter len list locals map max memoryview min next object oct open ord pow property range repr reversed round set setattr slice sorted staticmethod str sum super tuple type vars zip __import__ NotImplemented Ellipsis __debug__".split(" ");h.registerHelper("hintWords","python",v.concat(w));
h.defineMode("python",function(u,e){function x(a,b){var d=a.sol()&&"\\"!=b.lastToken;d&&(b.indent=a.indentation());if(d&&"py"==f(b).type){d=f(b).offset;if(a.eatSpace()){var c=a.indentation();c>d?y(b):c<d&&z(a,b)&&"#"!=a.peek()&&(b.errorToken=!0);return null}c=q(a,b);0<d&&z(a,b)&&(c+=" error");return c}return q(a,b)}function q(a,b){if(a.eatSpace())return null;if(a.match(/^#.*/))return"comment";if(a.match(/^[0-9\.]/,!1)){var d=!1;a.match(/^[\d_]*\.\d+(e[\+\-]?\d+)?/i)&&(d=!0);a.match(/^[\d_]+\.\d*/)&&
(d=!0);a.match(/^\.\d+/)&&(d=!0);if(d)return a.eat(/J/i),"number";d=!1;a.match(/^0x[0-9a-f_]+/i)&&(d=!0);a.match(/^0b[01_]+/i)&&(d=!0);a.match(/^0o[0-7_]+/i)&&(d=!0);a.match(/^[1-9][\d_]*(e[\+\-]?[\d_]+)?/)&&(a.eat(/J/i),d=!0);a.match(/^0(?![\dx])/i)&&(d=!0);if(d)return a.eat(/L/i),"number"}if(a.match(A))return-1===a.current().toLowerCase().indexOf("f")?b.tokenize=D(a.current(),b.tokenize):b.tokenize=E(a.current(),b.tokenize),b.tokenize(a,b);for(d=0;d<l.length;d++)if(a.match(l[d]))return"operator";
if(a.match(F))return"punctuation";if("."==b.lastToken&&a.match(n))return"property";if(a.match(G)||a.match(C))return"keyword";if(a.match(H))return"builtin";if(a.match(/^(self|cls)\b/))return"variable-2";if(a.match(n))return"def"==b.lastToken||"class"==b.lastToken?"def":"variable";a.next();return"error"}function E(a,b){function d(a){return function(b,r){var m=q(b,r);"punctuation"==m&&("{"==b.current()?r.tokenize=d(a+1):"}"==b.current()&&(r.tokenize=1<a?d(a-1):c));return m}}function c(c,f){for(;!c.eol();)if(c.eatWhile(/[^'"\{\}\\]/),
c.eat("\\")){if(c.next(),m&&c.eol())return"string"}else{if(c.match(a))return f.tokenize=b,"string";if(c.match("{{"))return"string";if(c.match("{",!1))return f.tokenize=d(0),c.current()?"string":f.tokenize(c,f);if(c.match("}}"))return"string";if(c.match("}"))return"error";c.eat(/['"]/)}if(m){if(e.singleLineStringErrors)return"error";f.tokenize=b}return"string"}for(;0<="rubf".indexOf(a.charAt(0).toLowerCase());)a=a.substr(1);var m=1==a.length;c.isString=!0;return c}function D(a,b){function d(d,f){for(;!d.eol();)if(d.eatWhile(/[^'"\\]/),
d.eat("\\")){if(d.next(),c&&d.eol())return"string"}else{if(d.match(a))return f.tokenize=b,"string";d.eat(/['"]/)}if(c){if(e.singleLineStringErrors)return"error";f.tokenize=b}return"string"}for(;0<="rubf".indexOf(a.charAt(0).toLowerCase());)a=a.substr(1);var c=1==a.length;d.isString=!0;return d}function y(a){for(;"py"!=f(a).type;)a.scopes.pop();a.scopes.push({offset:f(a).offset+u.indentUnit,type:"py",align:null})}function z(a,b){for(a=a.indentation();1<b.scopes.length&&f(b).offset>a;){if("py"!=f(b).type)return!0;
b.scopes.pop()}return f(b).offset!=a}for(var F=e.delimiters||e.singleDelimiters||/^[\(\)\[\]\{\}@,:`=;\.\\]/,l=[e.singleOperators,e.doubleOperators,e.doubleDelimiters,e.tripleDelimiters,e.operators||/^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@]|\.\.\.)/],g=0;g<l.length;g++)l[g]||l.splice(g--,1);var t=e.hangingIndent||u.indentUnit;g=v;var k=w;void 0!=e.extra_keywords&&(g=g.concat(e.extra_keywords));void 0!=e.extra_builtins&&(k=k.concat(e.extra_builtins));var B=!(e.version&&3>Number(e.version));if(B){var n=
e.identifiers||/^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/;g=g.concat("nonlocal False True None async await".split(" "));k=k.concat(["ascii","bytes","exec","print"]);var A=/^(([rbuf]|(br)|(fr))?('{3}|"{3}|['"]))/i}else n=e.identifiers||/^[_A-Za-z][_A-Za-z0-9]*/,g=g.concat(["exec","print"]),k=k.concat("apply basestring buffer cmp coerce execfile file intern long raw_input reduce reload unichr unicode xrange False True None".split(" ")),A=/^(([rubf]|(ur)|(br))?('{3}|"{3}|['"]))/i;var G=p(g),
H=p(k);return{startState:function(a){return{tokenize:x,scopes:[{offset:a||0,type:"py",align:null}],indent:a||0,lastToken:null,lambda:!1,dedent:0}},token:function(a,b){var d=b.errorToken;d&&(b.errorToken=!1);a:{a.sol()&&(b.beginningOfLine=!0);var c=b.tokenize(a,b);var e=a.current();if(b.beginningOfLine&&"@"==e)c=a.match(n,!1)?"meta":B?"operator":"error";else{/\S/.test(e)&&(b.beginningOfLine=!1);"variable"!=c&&"builtin"!=c||"meta"!=b.lastToken||(c="meta");if("pass"==e||"return"==e)b.dedent+=1;"lambda"==
e&&(b.lambda=!0);":"!=e||b.lambda||"py"!=f(b).type||y(b);if(1==e.length&&!/string|comment/.test(c)){var g="[({".indexOf(e);if(-1!=g){g="])}".slice(g,g+1);var h=a.match(/^([\s\[\{\(]|#.*)*$/,!1)?null:a.column()+1;b.scopes.push({offset:b.indent+t,type:g,align:h})}g="])}".indexOf(e);if(-1!=g)if(f(b).type==e)b.indent=b.scopes.pop().offset-t;else{c="error";break a}}0<b.dedent&&a.eol()&&"py"==f(b).type&&(1<b.scopes.length&&b.scopes.pop(),--b.dedent)}}c&&"comment"!=c&&(b.lastToken="keyword"==c||"punctuation"==
c?a.current():c);"punctuation"==c&&(c=null);a.eol()&&b.lambda&&(b.lambda=!1);return d?c+" error":c},indent:function(a,b){if(a.tokenize!=x)return a.tokenize.isString?h.Pass:0;a=f(a);b=a.type==b.charAt(0);return null!=a.align?a.align-(b?1:0):a.offset-(b?t:0)},electricInput:/^\s*[\}\]\)]$/,closeBrackets:{triples:"'\""},lineComment:"#",fold:"indent"}});h.defineMIME("text/x-python","python");h.defineMIME("text/x-cython",{name:"python",extra_keywords:"by cdef cimport cpdef ctypedef enum except extern gil include nogil property public readonly struct union DEF IF ELIF ELSE".split(" ")})});
