import{t as e}from"./chunk-D9Tnb9aB.js";import{t}from"./codemirror-DtW92bSi.js";var n=e(((e,n)=>{(function(r){typeof e==`object`&&typeof n==`object`?r(t()):typeof define==`function`&&define.amd?define([`../../lib/codemirror`],r):r(CodeMirror)})(function(e){function t(t){return function(n,r){var i=r.line,a=n.getLine(i);function o(t){for(var o,s=r.ch,c=0;;){var l=s<=0?-1:a.lastIndexOf(t[0],s-1);if(l==-1){if(c==1)break;c=1,s=a.length;continue}if(c==1&&l<r.ch)break;if(o=n.getTokenTypeAt(e.Pos(i,l+1)),!/^(comment|string)/.test(o))return{ch:l+1,tokenType:o,pair:t};s=l-1}}function s(t){var r=1,a=n.lastLine(),o,s=t.ch,c;outer:for(var l=i;l<=a;++l)for(var u=n.getLine(l),d=l==i?s:0;;){var f=u.indexOf(t.pair[0],d),p=u.indexOf(t.pair[1],d);if(f<0&&(f=u.length),p<0&&(p=u.length),d=Math.min(f,p),d==u.length)break;if(n.getTokenTypeAt(e.Pos(l,d+1))==t.tokenType){if(d==f)++r;else if(!--r){o=l,c=d;break outer}}++d}return o==null||i==o?null:{from:e.Pos(i,s),to:e.Pos(o,c)}}for(var c=[],l=0;l<t.length;l++){var u=o(t[l]);u&&c.push(u)}c.sort(function(e,t){return e.ch-t.ch});for(var l=0;l<c.length;l++){var d=s(c[l]);if(d)return d}return null}}e.registerHelper(`fold`,`brace`,t([[`{`,`}`],[`[`,`]`]])),e.registerHelper(`fold`,`brace-paren`,t([[`{`,`}`],[`[`,`]`],[`(`,`)`]])),e.registerHelper(`fold`,`import`,function(t,n){function r(n){if(n<t.firstLine()||n>t.lastLine())return null;var r=t.getTokenAt(e.Pos(n,1));if(/\S/.test(r.string)||(r=t.getTokenAt(e.Pos(n,r.end+1))),r.type!=`keyword`||r.string!=`import`)return null;for(var i=n,a=Math.min(t.lastLine(),n+10);i<=a;++i){var o=t.getLine(i).indexOf(`;`);if(o!=-1)return{startCh:r.end,end:e.Pos(i,o)}}}var i=n.line,a=r(i),o;if(!a||r(i-1)||(o=r(i-2))&&o.end.line==i-1)return null;for(var s=a.end;;){var c=r(s.line+1);if(c==null)break;s=c.end}return{from:t.clipPos(e.Pos(i,a.startCh+1)),to:s}}),e.registerHelper(`fold`,`include`,function(t,n){function r(n){if(n<t.firstLine()||n>t.lastLine())return null;var r=t.getTokenAt(e.Pos(n,1));if(/\S/.test(r.string)||(r=t.getTokenAt(e.Pos(n,r.end+1))),r.type==`meta`&&r.string.slice(0,8)==`#include`)return r.start+8}var i=n.line,a=r(i);if(a==null||r(i-1)!=null)return null;for(var o=i;r(o+1)!=null;)++o;return{from:e.Pos(i,a+1),to:t.clipPos(e.Pos(o))}})})}));export default n();
//# sourceMappingURL=brace-fold-Cf7nESMu.js.map