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