(function(d){"object"==typeof exports&&"object"==typeof module?d(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],d):d(CodeMirror)})(function(d){d.registerHelper("fold","brace",function(e,l){function h(c){for(var b=l.ch,g=0;;)if(b=0>=b?-1:k.lastIndexOf(c,b-1),-1==b){if(1==g)break;g=1;b=k.length}else{if(1==g&&b<l.ch)break;f=e.getTokenTypeAt(d.Pos(a,b+1));if(!/^(comment|string)/.test(f))return b+1;--b}}var a=l.line,k=e.getLine(a),f,n="{",c="}",b=
h("{");null==b&&(n="[",c="]",b=h("["));if(null!=b){var u=1,v=e.lastLine(),q,t,m=a;a:for(;m<=v;++m)for(var p=e.getLine(m),g=m==a?b:0;;){var r=p.indexOf(n,g),g=p.indexOf(c,g);0>r&&(r=p.length);0>g&&(g=p.length);g=Math.min(r,g);if(g==p.length)break;if(e.getTokenTypeAt(d.Pos(m,g+1))==f)if(g==r)++u;else if(!--u){q=m;t=g;break a}++g}if(null!=q&&(a!=q||t!=b))return{from:d.Pos(a,b),to:d.Pos(q,t)}}});d.registerHelper("fold","import",function(e,l){function h(c){if(c<e.firstLine()||c>e.lastLine())return null;
var b=e.getTokenAt(d.Pos(c,1));/\S/.test(b.string)||(b=e.getTokenAt(d.Pos(c,b.end+1)));if("keyword"!=b.type||"import"!=b.string)return null;var a=c;for(c=Math.min(e.lastLine(),c+10);a<=c;++a){var f=e.getLine(a).indexOf(";");if(-1!=f)return{startCh:b.end,end:d.Pos(a,f)}}}var a=l.line,k=h(a),f;if(!k||h(a-1)||(f=h(a-2))&&f.end.line==a-1)return null;for(f=k.end;;){var n=h(f.line+1);if(null==n)break;f=n.end}return{from:e.clipPos(d.Pos(a,k.startCh+1)),to:f}});d.registerHelper("fold","include",function(e,
l){function h(a){if(a<e.firstLine()||a>e.lastLine())return null;var c=e.getTokenAt(d.Pos(a,1));/\S/.test(c.string)||(c=e.getTokenAt(d.Pos(a,c.end+1)));if("meta"==c.type&&"#include"==c.string.slice(0,8))return c.start+8}var a=l.line,k=h(a);if(null==k||null!=h(a-1))return null;for(var f=a;null!=h(f+1);)++f;return{from:d.Pos(a,k+1),to:e.clipPos(d.Pos(f))}})});