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