(function(){"use strict";function e(e,n,r){function o(t){var r=i(e,n);if(!r||r.to.line-r.from.line<s)return null;var o=e.findMarksAt(r.from);for(var u=0;u<o.length;++u)if(o[u].__isFold){if(!t)return null;r.cleared=!0,o[u].clear()}return r}var i=r&&(r.call?r:r.rangeFinder);i||(i=e.getHelper(n,"fold"));if(!i)return;typeof n=="number"&&(n=CodeMirror.Pos(n,0));var s=r&&r.minFoldSize||0,u=o(!0);if(r&&r.scanUp)while(!u&&n.line>e.firstLine())n=CodeMirror.Pos(n.line-1,0),u=o(!1);if(!u||u.cleared)return;var a=t(r);CodeMirror.on(a,"mousedown",function(){f.clear()});var f=e.markText(u.from,u.to,{replacedWith:a,clearOnEnter:!0,__isFold:!0});f.on("clear",function(t,n){CodeMirror.signal(e,"unfold",e,t,n)}),CodeMirror.signal(e,"fold",e,u.from,u.to)}function t(e){var t=e&&e.widget||"↔";if(typeof t=="string"){var n=document.createTextNode(t);t=document.createElement("span"),t.appendChild(n),t.className="CodeMirror-foldmarker"}return t}CodeMirror.newFoldFunction=function(t,n){return function(r,i){e(r,i,{rangeFinder:t,widget:n})}},CodeMirror.defineExtension("foldCode",function(t,n){e(this,t,n)}),CodeMirror.registerHelper("fold","combine",function(){var e=Array.prototype.slice.call(arguments,0);return function(t,n){for(var r=0;r<e.length;++r){var i=e[r](t,n);if(i)return i}}})})();