mirror of
https://github.com/mindoc-org/mindoc.git
synced 2026-02-27 17:03:57 +08:00
2 lines
46 KiB
Go
2 lines
46 KiB
Go
/*! Editor.md v1.7.17 | addons.min.js | Open source online markdown editor. | MIT License | By: IBM Skills Network | https://github.com/ibm-skills-network/editor.md | 2024-03-27 */
|
|
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(o){o.defineOption("showTrailingSpace",!1,function(e,t,n){(n=n==o.Init?!1:n)&&!t?e.removeOverlay("trailingspace"):!n&&t&&e.addOverlay({token:function(e){for(var t=e.string.length,n=t;n&&/\s/.test(e.string.charAt(n-1));--n);return n>e.pos?(e.pos=n,null):(e.pos=t,"trailingspace")},name:"trailingspace"})})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(u){function d(e,t,n){var e=e.getWrapperElement(),o=e.appendChild(document.createElement("div"));return o.className=n?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof t?o.innerHTML=t:o.appendChild(t),u.addClass(e,"dialog-opened"),o}function h(e,t){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=t}u.defineExtension("openDialog",function(e,t,n){n=n||{},h(this,null);var o=d(this,e,n.bottom),r=!1,i=this;function a(e){"string"==typeof e?l.value=e:r||(r=!0,u.rmClass(o.parentNode,"dialog-opened"),o.parentNode.removeChild(o),i.focus(),n.onClose&&n.onClose(o))}var l=o.getElementsByTagName("input")[0];return l?(l.focus(),n.value&&(l.value=n.value,!1!==n.selectValueOnOpen)&&l.select(),n.onInput&&u.on(l,"input",function(e){n.onInput(e,l.value,a)}),n.onKeyUp&&u.on(l,"keyup",function(e){n.onKeyUp(e,l.value,a)}),u.on(l,"keydown",function(e){n&&n.onKeyDown&&n.onKeyDown(e,l.value,a)||((27==e.keyCode||!1!==n.closeOnEnter&&13==e.keyCode)&&(l.blur(),u.e_stop(e),a()),13==e.keyCode&&t(l.value,e))}),!1!==n.closeOnBlur&&u.on(o,"focusout",function(e){null!==e.relatedTarget&&a()})):(e=o.getElementsByTagName("button")[0])&&(u.on(e,"click",function(){a(),i.focus()}),!1!==n.closeOnBlur&&u.on(e,"blur",a),e.focus()),a}),u.defineExtension("openConfirm",function(e,t,n){h(this,null);var o=d(this,e,n&&n.bottom),r=o.getElementsByTagName("button"),i=!1,a=this,l=1;function s(){i||(i=!0,u.rmClass(o.parentNode,"dialog-opened"),o.parentNode.removeChild(o),a.focus())}r[0].focus();for(var c=0;c<r.length;++c){var f=r[c];!function(t){u.on(f,"click",function(e){u.e_preventDefault(e),s(),t&&t(a)})}(t[c]),u.on(f,"blur",function(){--l,setTimeout(function(){l<=0&&s()},200)}),u.on(f,"focus",function(){++l})}}),u.defineExtension("openNotification",function(e,t){h(this,i);var n,o=d(this,e,t&&t.bottom),r=!1,e=t&&void 0!==t.duration?t.duration:5e3;function i(){r||(r=!0,clearTimeout(n),u.rmClass(o.parentNode,"dialog-opened"),o.parentNode.removeChild(o))}return u.on(o,"click",function(e){u.e_preventDefault(e),i()}),e&&(n=setTimeout(i,e)),i})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(r){"use strict";var m,v,y=r.Pos;function p(e,t){for(var n,o=null!=(o=(n=e).flags)?o:(n.ignoreCase?"i":"")+(n.global?"g":"")+(n.multiline?"m":""),r=o,i=0;i<t.length;i++)-1==r.indexOf(t.charAt(i))&&(r+=t.charAt(i));return o==r?e:new RegExp(e.source,r)}function g(e){return/\\s|\\n|\n|\\W|\\D|\[\^/.test(e.source)}function h(e,t,n){t=p(t,"g");for(var o=n.line,r=n.ch,i=e.lastLine();o<=i;o++,r=0){t.lastIndex=r;var a=e.getLine(o),a=t.exec(a);if(a)return{from:y(o,a.index),to:y(o,a.index+a[0].length),match:a}}}function i(e,t,n){if(!g(t))return h(e,t,n);t=p(t,"gm");for(var o=1,r=n.line,i=e.lastLine();r<=i;){for(var a=0;a<o&&!(i<r);a++)var l=e.getLine(r++),s=null==s?l:s+"\n"+l;o*=2,t.lastIndex=n.ch;var c,f,u,d=t.exec(s);if(d)return u=s.slice(0,d.index).split("\n"),c=d[0].split("\n"),f=n.line+u.length-1,u=u[u.length-1].length,{from:y(f,u),to:y(f+c.length-1,1==c.length?u+c[0].length:c[c.length-1].length),match:d}}}function b(e,t,n){for(var o,r=0;r<=e.length;){t.lastIndex=r;var i=t.exec(e);if(!i)break;var a=i.index+i[0].length;if(a>e.length-n)break;(!o||a>o.index+o[0].length)&&(o=i),r=i.index+1}return o}function C(e,t,n){t=p(t,"g");for(var o=n.line,r=n.ch,i=e.firstLine();i<=o;o--,r=-1){var a=e.getLine(o),a=b(a,t,r<0?0:a.length-r);if(a)return{from:y(o,a.index),to:y(o,a.index+a[0].length),match:a}}}function a(e,t,n){if(!g(t))return C(e,t,n);t=p(t,"gm");for(var o=1,r=e.getLine(n.line).length-n.ch,i=n.line,a=e.firstLine();a<=i;){for(var l=0;l<o&&a<=i;l++)var s=e.getLine(i--),c=null==c?s:s+"\n"+c;o*=2;var f,u,d,h=b(c,t,r);if(h)return d=c.slice(0,h.index).split("\n"),f=h[0].split("\n"),u=i+d.length,d=d[d.length-1].length,{from:y(u,d),to:y(u+f.length-1,1==f.length?d+f[0].length:f[f.length-1].length),match:h}}}function x(e,t,n,o){if(e.length==t.length)return n;for(var r=0,i=n+Math.max(0,e.length-t.length);;){if(r==i)return r;var a=r+i>>1,l=o(e.slice(0,a)).length;if(l==n)return a;n<l?i=a:r=1+a}}function l(e,t,n,o){if(!t.length)return null;var r=o?m:v,i=r(t).split(/\r|\n\r?/);e:for(var a=n.line,l=n.ch,s=e.lastLine()+1-i.length;a<=s;a++,l=0){var c=e.getLine(a).slice(l),f=r(c);if(1==i.length){var u=f.indexOf(i[0]);if(-1!=u)return n=x(c,f,u,r)+l,{from:y(a,x(c,f,u,r)+l),to:y(a,x(c,f,u+i[0].length,r)+l)}}else{u=f.length-i[0].length;if(f.slice(u)==i[0]){for(var d=1;d<i.length-1;d++)if(r(e.getLine(a+d))!=i[d])continue e;var h=e.getLine(a+i.length-1),p=r(h),g=i[i.length-1];if(p.slice(0,g.length)==g)return{from:y(a,x(c,f,u,r)+l),to:y(a+i.length-1,x(h,p,g.length,r))}}}}}function s(e,t,n,o){if(!t.length)return null;var r=o?m:v,i=r(t).split(/\r|\n\r?/);e:for(var a=n.line,l=n.ch,s=e.firstLine()-1+i.length;s<=a;a--,l=-1){var c=e.getLine(a),f=r(c=-1<l?c.slice(0,l):c);if(1==i.length){var u=f.lastIndexOf(i[0]);if(-1!=u)return{from:y(a,x(c,f,u,r)),to:y(a,x(c,f,u+i[0].length,r))}}else{u=i[i.length-1];if(f.slice(0,u.length)==u){for(var d=1,n=a-i.length+1;d<i.length-1;d++)if(r(e.getLine(n+d))!=i[d])continue e;var h=e.getLine(a+1-i.length),p=r(h);if(p.slice(p.length-i[0].length)==i[0])return{from:y(a+1-i.length,x(h,p,h.length-i[0].length,r)),to:y(a,x(c,f,u.length,r))}}}}}function o(n,o,e,t){var r;this.atOccurrence=!1,this.afterEmptyMatch=!1,this.doc=n,e=e?n.clipPos(e):y(0,0),this.pos={from:e,to:e},"object"==typeof t?r=t.caseFold:(r=t,t=null),"string"==typeof o?(null==r&&(r=!1),this.matches=function(e,t){return(e?s:l)(n,o,t,r)}):(o=p(o,"gm"),t&&!1===t.multiline?this.matches=function(e,t){return(e?C:h)(n,o,t)}:this.matches=function(e,t){return(e?a:i)(n,o,t)})}v=String.prototype.normalize?(m=function(e){return e.normalize("NFD").toLowerCase()},function(e){return e.normalize("NFD")}):(m=function(e){return e.toLowerCase()},function(e){return e}),o.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(e){var t=this.doc.clipPos(e?this.pos.from:this.pos.to);return this.afterEmptyMatch&&this.atOccurrence&&(t=y(t.line,t.ch),e?(t.ch--,t.ch<0&&(t.line--,t.ch=(this.doc.getLine(t.line)||"").length)):(t.ch++,t.ch>(this.doc.getLine(t.line)||"").length&&(t.ch=0,t.line++)),0!=r.cmpPos(t,this.doc.clipPos(t)))?this.atOccurrence=!1:(t=this.matches(e,t),this.afterEmptyMatch=t&&0==r.cmpPos(t.from,t.to),t?(this.pos=t,this.atOccurrence=!0,this.pos.match||!0):(t=y(e?this.doc.firstLine():this.doc.lastLine()+1,0),this.pos={from:t,to:t},this.atOccurrence=!1))},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(e,t){this.atOccurrence&&(e=r.splitLines(e),this.doc.replaceRange(e,this.pos.from,this.pos.to,t),this.pos.to=y(this.pos.from.line+e.length-1,e[e.length-1].length+(1==e.length?this.pos.from.ch:0)))}},r.defineExtension("getSearchCursor",function(e,t,n){return new o(this.doc,e,t,n)}),r.defineDocExtension("getSearchCursor",function(e,t,n){return new o(this,e,t,n)}),r.defineExtension("selectMatches",function(e,t){for(var n=[],o=this.getSearchCursor(e,this.getCursor("from"),t);o.findNext()&&!(0<r.cmpPos(o.to(),this.getCursor("to")));)n.push({anchor:o.from(),head:o.to()});n.length&&this.setSelections(n,0)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],e):e(CodeMirror)}(function(u){"use strict";function t(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}function d(e){return e.state.search||(e.state.search=new t)}function r(e){return"string"==typeof e&&e==e.toLowerCase()}function h(e,t,n){return e.getSearchCursor(t,n,{caseFold:r(t),multiline:!0})}function p(e,t,n,o,r){e.openDialog?e.openDialog(t,r,{value:o,selectValueOnOpen:!0,bottom:e.options.search.bottom}):r(prompt(n,o))}function g(e){return e.replace(/\\([nrt\\])/g,function(e,t){return"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\"==t?"\\":e})}function i(e){var t=e.match(/^\/(.*)\/([a-z]*)$/);if(t)try{e=new RegExp(t[1],-1==t[2].indexOf("i")?"":"i")}catch(e){}else e=g(e);return e=("string"==typeof e?""==e:e.test(""))?/x^/:e}function m(e,t,n){var o;t.queryText=n,t.query=i(n),e.removeOverlay(t.overlay,r(t.query)),t.overlay=(o=t.query,n=r(t.query),"string"==typeof o?o=new RegExp(o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),n?"gi":"g"):o.global||(o=new RegExp(o.source,o.ignoreCase?"gi":"g")),{token:function(e){o.lastIndex=e.pos;var t=o.exec(e.string);if(t&&t.index==e.pos)return e.pos+=t[0].length||1,"searching";t?e.pos=t.index:e.skipToEnd()}}),e.addOverlay(t.overlay),e.showMatchesOnScrollbar&&(t.annotate&&(t.annotate.clear(),t.annotate=null),t.annotate=e.showMatchesOnScrollbar(t.query,r(t.query)))}function n(r,t,e,n){var o=d(r);if(o.query)return v(r,t);var i,a,l,s,c,f=r.getSelection()||o.lastQuery;f instanceof RegExp&&"x^"==f.source&&(f=null),e&&r.openDialog?(i=null,a=function(e,t){u.e_stop(t),e&&(e!=o.queryText&&(m(r,o,e),o.posFrom=o.posTo=r.getCursor()),i&&(i.style.opacity=1),v(r,t.shiftKey,function(e,t){var n;t.line<3&&document.querySelector&&(n=r.display.wrapper.querySelector(".CodeMirror-dialog"))&&n.getBoundingClientRect().bottom-4>r.cursorCoords(t,"window").top&&((i=n).style.opacity=.4)}))},e=C(l=r),s=f,c=function(e,t){var n=u.keyName(e),o=r.getOption("extraKeys"),o=o&&o[n]||u.keyMap[r.getOption("keyMap")][n];"findNext"==o||"findPrev"==o||"findPersistentNext"==o||"findPersistentPrev"==o?(u.e_stop(e),m(r,d(r),t),r.execCommand(o)):"find"!=o&&"findPersistent"!=o||(u.e_stop(e),a(t,e))},l.openDialog(e,a,{value:s,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){y(l)},onKeyDown:c,bottom:l.options.search.bottom}),n&&f&&(m(r,o,f),v(r,t))):p(r,C(r),"Search for:",f,function(e){e&&!o.query&&r.operation(function(){m(r,o,e),o.posFrom=o.posTo=r.getCursor(),v(r,t)})})}function v(n,o,r){n.operation(function(){var e=d(n),t=h(n,e.query,o?e.posFrom:e.posTo);(t.find(o)||(t=h(n,e.query,o?u.Pos(n.lastLine()):u.Pos(n.firstLine(),0))).find(o))&&(n.setSelection(t.from(),t.to()),n.scrollIntoView({from:t.from(),to:t.to()},20),e.posFrom=t.from(),e.posTo=t.to(),r)&&r(t.from(),t.to())})}function y(t){t.operation(function(){var e=d(t);e.lastQuery=e.query,e.query&&(e.query=e.queryText=null,t.removeOverlay(e.overlay),e.annotate)&&(e.annotate.clear(),e.annotate=null)})}function b(e,t){var n,o=e?document.createElement(e):document.createDocumentFragment();for(n in t)o[n]=t[n];for(var r=2;r<arguments.length;r++){var i=arguments[r];o.appendChild("string"==typeof i?document.createTextNode(i):i)}return o}function C(e){return b("",null,b("span",{className:"CodeMirror-search-label"},e.phrase("Search:"))," ",b("input",{type:"text",style:"width: 10em",className:"CodeMirror-search-field"})," ",b("span",{style:"color: #888",className:"CodeMirror-search-hint"},e.phrase("(Use /re/ syntax for regexp search)")))}function x(t,o,r){t.operation(function(){for(var n,e=h(t,o);e.findNext();)"string"!=typeof o?(n=t.getRange(e.from(),e.to()).match(o),e.replace(r.replace(/\$(\d)/g,function(e,t){return n[t]}))):e.replace(r)})}function o(f,e){var t,n,o;f.getOption("readOnly")||(t=f.getSelection()||d(f).lastQuery,o=b("",null,b("span",{className:"CodeMirror-search-label"},n=e?f.phrase("Replace all:"):f.phrase("Replace:")),(o=f,b("",null," ",b("input",{type:"text",style:"width: 10em",className:"CodeMirror-search-field"})," ",b("span",{style:"color: #888",className:"CodeMirror-search-hint"},o.phrase("(Use /re/ syntax for regexp search)"))))),p(f,o,n,t,function(c){c&&(c=i(c),p(f,b("",null,b("span",{className:"CodeMirror-search-label"},f.phrase("With:"))," ",b("input",{type:"text",style:"width: 10em",className:"CodeMirror-search-field"})),f.phrase("Replace with:"),"",function(i){var a,l,s;i=g(i),e?x(f,c,i):(y(f),a=h(f,c,f.getCursor("from")),s=function(n){a.replace("string"==typeof c?i:i.replace(/\$(\d)/g,function(e,t){return n[t]})),l()},(l=function(){var e,t,n,o,r=a.from();!(e=a.findNext())&&(a=h(f,c),!(e=a.findNext())||r&&a.from().line==r.line&&a.from().ch==r.ch)||(f.setSelection(a.from(),a.to()),f.scrollIntoView({from:a.from(),to:a.to()}),o=b("",null,b("span",{className:"CodeMirror-search-label"},(o=r=f).phrase("Replace?"))," ",b("button",{},o.phrase("Yes"))," ",b("button",{},o.phrase("No"))," ",b("button",{},o.phrase("All"))," ",b("button",{},o.phrase("Stop"))),t=f.phrase("Replace?"),n=[function(){s(e)},l,function(){x(f,c,i)}],r.openConfirm?r.openConfirm(o,n):confirm(t)&&n[0]())})())}))}))}u.defineOption("search",{bottom:!1}),u.commands.find=function(e){y(e),n(e)},u.commands.findPersistent=function(e){y(e),n(e,!1,!0)},u.commands.findPersistentNext=function(e){n(e,!1,!0,!0)},u.commands.findPersistentPrev=function(e){n(e,!0,!0,!0)},u.commands.findNext=n,u.commands.findPrev=function(e){n(e,!0)},u.commands.clearSearch=y,u.commands.replace=o,u.commands.replaceAll=function(e){o(e,!0)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){function n(e){clearTimeout(o.doRedraw),o.doRedraw=setTimeout(function(){o.redraw()},e)}this.cm=e,this.options=t,this.buttonHeight=t.scrollButtonHeight||e.getOption("scrollButtonHeight"),this.annotations=[],this.doRedraw=this.doUpdate=null,this.div=e.getWrapperElement().appendChild(document.createElement("div")),this.div.style.cssText="position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none",this.computeScale();var o=this;e.on("refresh",this.resizeHandler=function(){clearTimeout(o.doUpdate),o.doUpdate=setTimeout(function(){o.computeScale()&&n(20)},100)}),e.on("markerAdded",this.resizeHandler),e.on("markerCleared",this.resizeHandler),!1!==t.listenForChanges&&e.on("changes",this.changeHandler=function(){n(250)})}e.defineExtension("annotateScrollbar",function(e){return new t(this,e="string"==typeof e?{className:e}:e)}),e.defineOption("scrollButtonHeight",0),t.prototype.computeScale=function(){var e=this.cm,e=(e.getWrapperElement().clientHeight-e.display.barHeight-2*this.buttonHeight)/e.getScrollerElement().scrollHeight;if(e!=this.hScale)return this.hScale=e,!0},t.prototype.update=function(e){this.annotations=e,this.redraw()},t.prototype.redraw=function(e){!1!==e&&this.computeScale();var o=this.cm,t=this.hScale,n=document.createDocumentFragment(),r=this.annotations,i=o.getOption("lineWrapping"),a=i&&1.5*o.defaultTextHeight(),l=null,s=null;function c(e,t){var n;return l!=e.line&&(l=e.line,s=o.getLineHandle(e.line),(n=o.getLineHandleVisualStart(s))!=s)&&(l=o.getLineNumber(n),s=n),s.widgets&&s.widgets.length||i&&s.height>a?o.charCoords(e,"local")[t?"top":"bottom"]:o.heightAtLine(s,"local")+(t?0:s.height)}var f=o.lastLine();if(o.display.barWidth)for(var u,d=0;d<r.length;d++){var h=r[d];if(!(h.to.line>f)){for(var p,g,m=u||c(h.from,!0)*t,v=c(h.to,!1)*t;d<r.length-1&&!(r[d+1].to.line>f)&&!(v+.9<(u=c(r[d+1].from,!0)*t));)v=c((h=r[++d]).to,!1)*t;v!=m&&(p=Math.max(v-m,3),(g=n.appendChild(document.createElement("div"))).style.cssText="position: absolute; right: 0px; width: "+Math.max(o.display.barWidth-1,2)+"px; top: "+(m+this.buttonHeight)+"px; height: "+p+"px",g.className=this.options.className,h.id)&&g.setAttribute("annotation-id",h.id)}}this.div.textContent="",this.div.appendChild(n)},t.prototype.clear=function(){this.cm.off("refresh",this.resizeHandler),this.cm.off("markerAdded",this.resizeHandler),this.cm.off("markerCleared",this.resizeHandler),this.changeHandler&&this.cm.off("changes",this.changeHandler),this.div.parentNode.removeChild(this.div)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],e):e(CodeMirror)}(function(s){"use strict";function o(e,t,n,o){this.cm=e;var r,i={listenForChanges:!1};for(r in this.options=o)i[r]=o[r];i.className||(i.className="CodeMirror-search-match"),this.annotation=e.annotateScrollbar(i),this.query=t,this.caseFold=n,this.gap={from:e.firstLine(),to:e.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var a=this;e.on("change",this.changeHandler=function(e,t){a.onChange(t)})}s.defineExtension("showMatchesOnScrollbar",function(e,t,n){return new o(this,e,t,n=(n="string"==typeof n?{className:n}:n)||{})});function c(e,t,n){return e<=t?e:Math.max(t,e+n)}o.prototype.findMatches=function(){if(this.gap){for(var e=0;e<this.matches.length;e++){if((t=this.matches[e]).from.line>=this.gap.to)break;t.to.line>=this.gap.from&&this.matches.splice(e--,1)}for(var t,n=this.cm.getSearchCursor(this.query,s.Pos(this.gap.from,0),{caseFold:this.caseFold,multiline:this.options.multiline}),o=this.options&&this.options.maxMatches||1e3;n.findNext();){if((t={from:n.from(),to:n.to()}).from.line>=this.gap.to)break;if(this.matches.splice(e++,0,t),this.matches.length>o)break}this.gap=null}},o.prototype.onChange=function(e){var t=e.from.line,n=s.changeEnd(e).line,o=n-e.to.line;if(this.gap?(this.gap.from=Math.min(c(this.gap.from,t,o),e.from.line),this.gap.to=Math.max(c(this.gap.to,t,o),e.from.line)):this.gap={from:e.from.line,to:n+1},o)for(var r=0;r<this.matches.length;r++){var i=this.matches[r],a=c(i.from.line,t,o),a=(a!=i.from.line&&(i.from=s.Pos(a,i.from.ch)),c(i.to.line,t,o));a!=i.to.line&&(i.to=s.Pos(a,i.to.ch))}clearTimeout(this.update);var l=this;this.update=setTimeout(function(){l.updateAfterChange()},250)},o.prototype.updateAfterChange=function(){this.findMatches(),this.annotation.update(this.matches)},o.prototype.clear=function(){this.cm.off("change",this.changeHandler),this.annotation.clear()}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(o){function r(e){e.state.placeholder&&(e.state.placeholder.parentNode.removeChild(e.state.placeholder),e.state.placeholder=null)}function i(e){r(e);var t=e.state.placeholder=document.createElement("pre"),n=(t.style.cssText="height: 0; overflow: visible",t.style.direction=e.getOption("direction"),t.className="CodeMirror-placeholder CodeMirror-line-like",e.getOption("placeholder"));"string"==typeof n&&(n=document.createTextNode(n)),t.appendChild(n),e.display.lineSpace.insertBefore(t,e.display.lineSpace.firstChild)}function a(e){s(e)&&i(e)}function l(e){var t=e.getWrapperElement(),n=s(e);t.className=t.className.replace(" CodeMirror-empty","")+(n?" CodeMirror-empty":""),(n?i:r)(e)}function s(e){return 1===e.lineCount()&&""===e.getLine(0)}o.defineOption("placeholder","",function(e,t,n){var n=n&&n!=o.Init;t&&!n?(e.on("blur",a),e.on("change",l),e.on("swapDoc",l),o.on(e.getInputField(),"compositionupdate",e.state.placeholderCompose=function(){var n;n=e,setTimeout(function(){var e,t=!1;((t=1==n.lineCount()?"TEXTAREA"==(e=n.getInputField()).nodeName?!n.getLine(0).length:!/[^\u200b]/.test(e.querySelector(".CodeMirror-line").textContent):t)?i:r)(n)},20)}),l(e)):!t&&n&&(e.off("blur",a),e.off("change",l),e.off("swapDoc",l),o.off(e.getInputField(),"compositionupdate",e.state.placeholderCompose),r(e),(n=e.getWrapperElement()).className=n.className.replace(" CodeMirror-empty","")),t&&!e.hasFocus()&&a(e)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../fold/xml-fold"],e):e(CodeMirror)}(function(y){y.defineOption("autoCloseTags",!1,function(e,t,n){n!=y.Init&&n&&e.removeKeyMap("autoCloseTags"),t&&(n={name:"autoCloseTags"},"object"==typeof t&&!1===t.whenClosing||(n["'/'"]=function(e){return(e=e).getOption("disableInput")?y.Pass:o(e,!0)}),"object"==typeof t&&!1===t.whenOpening||(n["'>'"]=function(e){var t=e;if(t.getOption("disableInput"))return y.Pass;for(var n=t.listSelections(),o=[],r=t.getOption("autoCloseTags"),i=0;i<n.length;i++){if(!n[i].empty())return y.Pass;var a=n[i].head,l=t.getTokenAt(a),s=y.innerMode(t.getMode(),l.state),c=s.state,f=s.mode.xmlCurrentTag&&s.mode.xmlCurrentTag(c),u=f&&f.name;if(!u)return y.Pass;var d="html"==s.mode.configuration,h="object"==typeof r&&r.dontCloseTags||d&&b,d="object"==typeof r&&r.indentTags||d&&C,p=(u=l.end>a.ch?u.slice(0,u.length-l.end+a.ch):u).toLowerCase();if(!u||"string"==l.type&&(l.end!=a.ch||!/[\"\']/.test(l.string.charAt(l.string.length-1))||1==l.string.length)||"tag"==l.type&&f.close||l.string.indexOf("/")==a.ch-l.start-1||h&&-1<x(h,p)||O(t,s.mode.xmlCurrentContext&&s.mode.xmlCurrentContext(c)||[],u,a,!0))return y.Pass;f="object"==typeof r&&r.emptyTags;f&&-1<x(f,u)?o[i]={text:"/>",newPos:y.Pos(a.line,a.ch+2)}:(l=d&&-1<x(d,p),o[i]={indent:l,text:">"+(l?"\n\n":"")+"</"+u+">",newPos:l?y.Pos(a.line+1,0):y.Pos(a.line,a.ch+1)})}for(var g="object"==typeof r&&r.dontIndentOnAutoClose,i=n.length-1;0<=i;i--){var m=o[i],v=(t.replaceRange(m.text,n[i].head,n[i].anchor,"+insert"),t.listSelections().slice(0));v[i]={head:m.newPos,anchor:m.newPos},t.setSelections(v),!g&&m.indent&&(t.indentLine(m.newPos.line,null,!0),t.indentLine(m.newPos.line+1,null,!0))}}),e.addKeyMap(n))});var b=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],C=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function o(e,t){for(var n=e.listSelections(),o=[],r=t?"/":"</",i=e.getOption("autoCloseTags"),i="object"==typeof i&&i.dontIndentOnSlash,a=0;a<n.length;a++){if(!n[a].empty())return y.Pass;var l=n[a].head,s=e.getTokenAt(l),c=y.innerMode(e.getMode(),s.state),f=c.state;if(t&&("string"==s.type||"<"!=s.string.charAt(0)||s.start!=l.ch-1))return y.Pass;var u,d="xml"!=c.mode.name&&"htmlmixed"==e.getMode().name;if(d&&"javascript"==c.mode.name)u=r+"script";else if(d&&"css"==c.mode.name)u=r+"style";else{d=c.mode.xmlCurrentContext&&c.mode.xmlCurrentContext(f),c=d.length?d[d.length-1]:"";if(!d||d.length&&O(e,d,c,l))return y.Pass;u=r+c}">"!=e.getLine(l.line).charAt(s.end)&&(u+=">"),o[a]=u}if(e.replaceSelections(o),n=e.listSelections(),!i)for(a=0;a<n.length;a++)(a==n.length-1||n[a].head.line<n[a+1].head.line)&&e.indentLine(n[a].head.line)}function x(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,o=e.length;n<o;++n)if(e[n]==t)return n;return-1}function O(e,t,n,o,r){if(y.scanForClosingTag){var i=Math.min(e.lastLine()+1,o.line+500),a=y.scanForClosingTag(e,o,null,i);if(a&&a.tag==n){for(var l=r?1:0,s=t.length-1;0<=s&&t[s]==n;s--)++l;o=a.to;for(s=1;s<l;s++){var c=y.scanForClosingTag(e,o,null,i);if(!c||c.tag!=n)return;o=c.to}return 1}}}y.commands.closeTag=function(e){return o(e)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(f){"use strict";function r(r,i,e,a){e&&e.call?(l=e,e=null):l=u(r,e,"rangeFinder"),"number"==typeof i&&(i=f.Pos(i,0));var l,s=u(r,e,"minFoldSize");function t(e){var t=l(r,i);if(!t||t.to.line-t.from.line<s)return null;if("fold"!==a)for(var n=r.findMarksAt(t.from),o=0;o<n.length;++o)if(n[o].__isFold){if(!e)return null;t.cleared=!0,n[o].clear()}return t}var n,o,c=t(!0);if(u(r,e,"scanUp"))for(;!c&&i.line>r.firstLine();)i=f.Pos(i.line-1,0),c=t(!1);c&&!c.cleared&&"unfold"!==a&&(n=function(e,t,n){e=u(e,t,"widget");"function"==typeof e&&(e=e(n.from,n.to));"string"==typeof e?(t=document.createTextNode(e),(e=document.createElement("span")).appendChild(t),e.className="CodeMirror-foldmarker"):e=e&&e.cloneNode(!0);return e}(r,e,c),f.on(n,"mousedown",function(e){o.clear(),f.e_preventDefault(e)}),(o=r.markText(c.from,c.to,{replacedWith:n,clearOnEnter:u(r,e,"clearOnEnter"),__isFold:!0})).on("clear",function(e,t){f.signal(r,"unfold",r,e,t)}),f.signal(r,"fold",r,c.from,c.to))}f.newFoldFunction=function(n,o){return function(e,t){r(e,t,{rangeFinder:n,widget:o})}},f.defineExtension("foldCode",function(e,t,n){r(this,e,t,n)}),f.defineExtension("isFolded",function(e){for(var t=this.findMarksAt(e),n=0;n<t.length;++n)if(t[n].__isFold)return!0}),f.commands.toggleFold=function(e){e.foldCode(e.getCursor())},f.commands.fold=function(e){e.foldCode(e.getCursor(),null,"fold")},f.commands.unfold=function(e){e.foldCode(e.getCursor(),{scanUp:!1},"unfold")},f.commands.foldAll=function(n){n.operation(function(){for(var e=n.firstLine(),t=n.lastLine();e<=t;e++)n.foldCode(f.Pos(e,0),{scanUp:!1},"fold")})},f.commands.unfoldAll=function(n){n.operation(function(){for(var e=n.firstLine(),t=n.lastLine();e<=t;e++)n.foldCode(f.Pos(e,0),{scanUp:!1},"unfold")})},f.registerHelper("fold","combine",function(){var r=Array.prototype.slice.call(arguments,0);return function(e,t){for(var n=0;n<r.length;++n){var o=r[n](e,t);if(o)return o}}}),f.registerHelper("fold","auto",function(e,t){for(var n=e.getHelpers(t,"fold"),o=0;o<n.length;o++){var r=n[o](e,t);if(r)return r}});var o={rangeFinder:f.fold.auto,widget:"↔",minFoldSize:0,scanUp:!1,clearOnEnter:!0};function u(e,t,n){return(t&&void 0!==t[n]||(t=e.options.foldOptions)&&void 0!==t[n]?t:o)[n]}f.defineOption("foldOptions",null),f.defineExtension("foldOption",function(e,t){return u(this,e,t)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./foldcode")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./foldcode"],e):e(CodeMirror)}(function(o){"use strict";o.defineOption("foldGutter",!1,function(e,t,n){n&&n!=o.Init&&(e.clearGutter(e.state.foldGutter.options.gutter),e.state.foldGutter=null,e.off("gutterClick",l),e.off("changes",s),e.off("viewportChange",c),e.off("fold",f),e.off("unfold",f),e.off("swapDoc",s)),t&&(e.state.foldGutter=new r(function(e){!0===e&&(e={});null==e.gutter&&(e.gutter="CodeMirror-foldgutter");null==e.indicatorOpen&&(e.indicatorOpen="CodeMirror-foldgutter-open");null==e.indicatorFolded&&(e.indicatorFolded="CodeMirror-foldgutter-folded");return e}(t)),a(e),e.on("gutterClick",l),e.on("changes",s),e.on("viewportChange",c),e.on("fold",f),e.on("unfold",f),e.on("swapDoc",s))});var u=o.Pos;function r(e){this.options=e,this.from=this.to=0}function d(e,t){for(var n=e.findMarks(u(t,0),u(t+1,0)),o=0;o<n.length;++o)if(n[o].__isFold){var r=n[o].find(-1);if(r&&r.line===t)return n[o]}}function h(e){var t;return"string"==typeof e?((t=document.createElement("div")).className=e+" CodeMirror-guttermarker-subtle",t):e.cloneNode(!0)}function i(r,e,t){var i=r.state.foldGutter.options,a=e-1,l=r.foldOption(i,"minFoldSize"),s=r.foldOption(i,"rangeFinder"),c="string"==typeof i.indicatorFolded&&n(i.indicatorFolded),f="string"==typeof i.indicatorOpen&&n(i.indicatorOpen);r.eachLine(e,t,function(e){++a;var t=null,n=(n=e.gutterMarkers)&&n[i.gutter];if(d(r,a)){if(c&&n&&c.test(n.className))return;t=h(i.indicatorFolded)}else{var o=u(a,0),o=s&&s(r,o);if(o&&o.to.line-o.from.line>=l){if(f&&n&&f.test(n.className))return;t=h(i.indicatorOpen)}}(t||n)&&r.setGutterMarker(e,i.gutter,t)})}function n(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function a(e){var t=e.getViewport(),n=e.state.foldGutter;n&&(e.operation(function(){i(e,t.from,t.to)}),n.from=t.from,n.to=t.to)}function l(e,t,n){var o=e.state.foldGutter;o&&n==(n=o.options).gutter&&((o=d(e,t))?o.clear():e.foldCode(u(t,0),n))}function s(e){var t,n=e.state.foldGutter;n&&(t=n.options,n.from=n.to=0,clearTimeout(n.changeUpdate),n.changeUpdate=setTimeout(function(){a(e)},t.foldOnChangeTimeSpan||600))}function c(t){var e,n=t.state.foldGutter;n&&(e=n.options,clearTimeout(n.changeUpdate),n.changeUpdate=setTimeout(function(){var e=t.getViewport();n.from==n.to||20<e.from-n.to||20<n.from-e.to?a(t):t.operation(function(){e.from<n.from&&(i(t,e.from,n.from),n.from=e.from),e.to>n.to&&(i(t,n.to,e.to),n.to=e.to)})},e.updateViewportTimeSpan||400))}function f(e,t){var n=e.state.foldGutter;n&&(t=t.line)>=n.from&&t<n.to&&i(e,t,t+1)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(l){"use strict";function s(e,t){var n=e.getLine(t),o=n.search(/\S/);return-1==o||/\bcomment\b/.test(e.getTokenTypeAt(l.Pos(t,o+1)))?-1:l.countColumn(n,null,e.getOption("tabSize"))}l.registerHelper("fold","indent",function(e,t){var n=s(e,t.line);if(!(n<0)){for(var o=null,r=t.line+1,i=e.lastLine();r<=i;++r){var a=s(e,r);if(-1!=a){if(!(n<a))break;o=r}}return o?{from:l.Pos(t.line,e.getLine(t.line).length),to:l.Pos(o,e.getLine(o).length)}:void 0}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(h){"use strict";function e(r){return function(u,i){var d=i.line,a=u.getLine(d);for(var e=[],t=0;t<r.length;t++){var n=function(e){for(var t,n=i.ch,o=0;;){var r=n<=0?-1:a.lastIndexOf(e[0],n-1);if(-1==r){if(1==o)break;o=1,n=a.length}else{if(1==o&&r<i.ch)break;if(t=u.getTokenTypeAt(h.Pos(d,r+1)),!/^(comment|string)/.test(t))return{ch:r+1,tokenType:t,pair:e};n=r-1}}}(r[t]);n&&e.push(n)}e.sort(function(e,t){return e.ch-t.ch});for(t=0;t<e.length;t++){var o=function(e){var t,n,o=1,r=u.lastLine(),i=e.ch;e:for(var a=d;a<=r;++a)for(var l=u.getLine(a),s=a==d?i:0;;){var c=l.indexOf(e.pair[0],s),f=l.indexOf(e.pair[1],s);if(c<0&&(c=l.length),f<0&&(f=l.length),(s=Math.min(c,f))==l.length)break;if(u.getTokenTypeAt(h.Pos(a,s+1))==e.tokenType)if(s==c)++o;else if(!--o){t=a,n=s;break e}++s}return null==t||d==t?null:{from:h.Pos(d,i),to:h.Pos(t,n)}}(e[t]);if(o)return o}return null}}h.registerHelper("fold","brace",e([["{","}"],["[","]"]])),h.registerHelper("fold","brace-paren",e([["{","}"],["[","]"],["(",")"]])),h.registerHelper("fold","import",function(i,e){function t(e){if(e<i.firstLine()||e>i.lastLine())return null;var t=i.getTokenAt(h.Pos(e,1));if("keyword"!=(t=/\S/.test(t.string)?t:i.getTokenAt(h.Pos(e,t.end+1))).type||"import"!=t.string)return null;for(var n=e,o=Math.min(i.lastLine(),e+10);n<=o;++n){var r=i.getLine(n).indexOf(";");if(-1!=r)return{startCh:t.end,end:h.Pos(n,r)}}}var n,e=e.line,o=t(e);if(!o||t(e-1)||(n=t(e-2))&&n.end.line==e-1)return null;for(var r=o.end;;){var a=t(r.line+1);if(null==a)break;r=a.end}return{from:i.clipPos(h.Pos(e,o.startCh+1)),to:r}}),h.registerHelper("fold","include",function(n,e){function t(e){var t;return e<n.firstLine()||e>n.lastLine()?null:(t=n.getTokenAt(h.Pos(e,1)),"meta"==(t=/\S/.test(t.string)?t:n.getTokenAt(h.Pos(e,t.end+1))).type&&"#include"==t.string.slice(0,8)?t.start+8:void 0)}var e=e.line,o=t(e);if(null==o||null!=t(e-1))return null;for(var r=e;;){if(null==t(r+1))break;++r}return{from:h.Pos(e,o+1),to:n.clipPos(h.Pos(r))}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var s=e.Pos;function l(e,t){return e.line-t.line||e.ch-t.ch}var t="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",o=new RegExp("<(/?)(["+t+"][A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*)","g");function c(e,t,n,o){this.line=t,this.ch=n,this.cm=e,this.text=e.getLine(t),this.min=o?Math.max(o.from,e.firstLine()):e.firstLine(),this.max=o?Math.min(o.to-1,e.lastLine()):e.lastLine()}function f(e,t){e=e.cm.getTokenTypeAt(s(e.line,t));return e&&/\btag\b/.test(e)}function r(e){return!(e.line>=e.max)&&(e.ch=0,e.text=e.cm.getLine(++e.line),1)}function u(e){return!(e.line<=e.min)&&(e.text=e.cm.getLine(--e.line),e.ch=e.text.length,1)}function d(e){for(;;){var t,n=e.text.indexOf(">",e.ch);if(-1==n){if(r(e))continue;return}if(f(e,n+1))return t=-1<(t=e.text.lastIndexOf("/",n))&&!/\S/.test(e.text.slice(t+1,n)),e.ch=n+1,t?"selfClose":"regular";e.ch=n+1}}function h(e){for(;;){var t=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(-1==t){if(u(e))continue;return}if(f(e,t+1)){o.lastIndex=t,e.ch=t;var n=o.exec(e.text);if(n&&n.index==t)return n}else e.ch=t}}function p(e){for(;;){o.lastIndex=e.ch;var t=o.exec(e.text);if(!t){if(r(e))continue;return}if(f(e,t.index+1))return e.ch=t.index+t[0].length,t;e.ch=t.index+1}}function g(e,t){for(var n=[];;){var o,r=p(e),i=e.line,a=e.ch-(r?r[0].length:0);if(!r||!(o=d(e)))return;if("selfClose"!=o)if(r[1]){for(var l=n.length-1;0<=l;--l)if(n[l]==r[2]){n.length=l;break}if(l<0&&(!t||t==r[2]))return{tag:r[2],from:s(i,a),to:s(e.line,e.ch)}}else n.push(r[2])}}function m(e,t){for(var n=[];;){var o=function(e){for(;;){var t,n=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(-1==n){if(u(e))continue;return}if(f(e,n+1))return t=-1<(t=e.text.lastIndexOf("/",n))&&!/\S/.test(e.text.slice(t+1,n)),e.ch=n+1,t?"selfClose":"regular";e.ch=n}}(e);if(!o)return;if("selfClose"==o)h(e);else{var o=e.line,r=e.ch,i=h(e);if(!i)return;if(i[1])n.push(i[2]);else{for(var a=n.length-1;0<=a;--a)if(n[a]==i[2]){n.length=a;break}if(a<0&&(!t||t==i[2]))return{tag:i[2],from:s(e.line,e.ch),to:s(o,r)}}}}}e.registerHelper("fold","xml",function(e,t){for(var n=new c(e,t.line,0);;){var o=p(n);if(!o||n.line!=t.line)return;var r=d(n);if(!r)return;if(!o[1]&&"selfClose"!=r)return r=s(n.line,n.ch),(o=g(n,o[2]))&&0<l(o.from,r)?{from:r,to:o.from}:null}}),e.findMatchingTag=function(e,t,n){var o=new c(e,t.line,t.ch,n);if(-1!=o.text.indexOf(">")||-1!=o.text.indexOf("<")){var r=d(o),i=r&&s(o.line,o.ch),a=r&&h(o);if(r&&a&&!(0<l(o,t)))return t={from:s(o.line,o.ch),to:i,tag:a[2]},"selfClose"==r?{open:t,close:null,at:"open"}:a[1]?{open:m(o,a[2]),close:t,at:"close"}:{open:t,close:g(o=new c(e,i.line,i.ch,n),a[2]),at:"open"}}},e.findEnclosingTag=function(e,t,n,o){for(var r=new c(e,t.line,t.ch,n);;){var i=m(r,o);if(!i)break;var a=g(new c(e,t.line,t.ch,n),i.tag);if(a)return{open:i,close:a}}},e.scanForClosingTag=function(e,t,n,o){return g(new c(e,t.line,t.ch,o?{from:0,to:o}:null),n)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(f){"use strict";f.registerHelper("fold","markdown",function(t,e){function o(e){e=t.getTokenTypeAt(f.Pos(e,0));return e&&/\bheader\b/.test(e)}function n(e,t,n){t=t&&t.match(/^#+/);return t&&o(e)?t[0].length:n&&n.match(/^[=\-]+\s*$/)&&o(e+1)?"="==n[0]?1:2:100}var r=t.getLine(e.line),i=t.getLine(e.line+1),a=n(e.line,r,i);if(100!==a){for(var l=t.lastLine(),s=e.line,c=t.getLine(s+2);s<l&&!(n(s+1,i,c)<=a);)i=c,c=t.getLine(++s+2);return{from:f.Pos(e.line,r.length),to:f.Pos(s,t.getLine(s).length)}}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(C){"use strict";C.registerGlobalHelper("fold","comment",function(e){return e.blockCommentStart&&e.blockCommentEnd},function(e,t){var n=e.getModeAt(t),o=n.blockCommentStart,r=n.blockCommentEnd;if(o&&r){for(var i,a=t.line,l=e.getLine(a),s=t.ch,c=0;;){var f=s<=0?-1:l.lastIndexOf(o,s-1);if(-1==f){if(1==c)return;c=1,s=l.length}else{if(1==c&&f<t.ch)return;if(/comment/.test(e.getTokenTypeAt(C.Pos(a,f+1)))&&(0==f||l.slice(f-r.length,f)==r||!/comment/.test(e.getTokenTypeAt(C.Pos(a,f))))){i=f+o.length;break}s=f-1}}var u,d,h=1,p=e.lastLine();e:for(var g=a;g<=p;++g)for(var m=e.getLine(g),v=g==a?i:0;;){var y=m.indexOf(o,v),b=m.indexOf(r,v);if(y<0&&(y=m.length),b<0&&(b=m.length),(v=Math.min(y,b))==m.length)break;if(v==y)++h;else if(!--h){u=g,d=v;break e}++v}if(null!=u&&(a!=u||d!=i))return{from:C.Pos(a,i),to:C.Pos(u,d)}}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(t){"use strict";t.overlayMode=function(o,r,i){return{startState:function(){return{base:t.startState(o),overlay:t.startState(r),basePos:0,baseCur:null,overlayPos:0,overlayCur:null,streamSeen:null}},copyState:function(e){return{base:t.copyState(o,e.base),overlay:t.copyState(r,e.overlay),basePos:e.basePos,baseCur:null,overlayPos:e.overlayPos,overlayCur:null}},token:function(e,t){return(e!=t.streamSeen||Math.min(t.basePos,t.overlayPos)<e.start)&&(t.streamSeen=e,t.basePos=t.overlayPos=e.start),e.start==t.basePos&&(t.baseCur=o.token(e,t.base),t.basePos=e.pos),e.start==t.overlayPos&&(e.pos=e.start,t.overlayCur=r.token(e,t.overlay),t.overlayPos=e.pos),e.pos=Math.min(t.basePos,t.overlayPos),null==t.overlayCur?t.baseCur:null!=t.baseCur&&t.overlay.combineTokens||i&&null==t.overlay.combineTokens?t.baseCur+" "+t.overlayCur:t.overlayCur},indent:o.indent&&function(e,t,n){return o.indent(e.base,t,n)},electricChars:o.electricChars,innerMode:function(e){return{state:e.base,mode:o}},blankLine:function(e){var t,n;return o.blankLine&&(t=o.blankLine(e.base)),null==(n=r.blankLine?r.blankLine(e.overlay):n)?t:i&&null!=t?t+" "+n:n}}}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(o){"use strict";var a="CodeMirror-activeline",l="CodeMirror-activeline-background",s="CodeMirror-activeline-gutter";function c(e){for(var t=0;t<e.state.activeLines.length;t++)e.removeLineClass(e.state.activeLines[t],"wrap",a),e.removeLineClass(e.state.activeLines[t],"background",l),e.removeLineClass(e.state.activeLines[t],"gutter",s)}function r(t,e){for(var n=[],o=0;o<e.length;o++){var r=e[o],i=t.getOption("styleActiveLine");("object"==typeof i&&i.nonEmpty?r.anchor.line==r.head.line:r.empty())&&(i=t.getLineHandleVisualStart(r.head.line),n[n.length-1]!=i)&&n.push(i)}!function(e,t){if(e.length==t.length){for(var n=0;n<e.length;n++)if(e[n]!=t[n])return;return 1}}(t.state.activeLines,n)&&t.operation(function(){c(t);for(var e=0;e<n.length;e++)t.addLineClass(n[e],"wrap",a),t.addLineClass(n[e],"background",l),t.addLineClass(n[e],"gutter",s);t.state.activeLines=n})}function i(e,t){r(e,t.ranges)}o.defineOption("styleActiveLine",!1,function(e,t,n){n=n!=o.Init&&n;t!=n&&(n&&(e.off("beforeSelectionChange",i),c(e),delete e.state.activeLines),t)&&(e.state.activeLines=[],r(e,e.listSelections()),e.on("beforeSelectionChange",i))})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(b){var n={pairs:"()[]{}''\"\"",closeBefore:")]}'\":;>",triples:"",explode:"[]{}"},C=b.Pos;function x(e,t){return"pairs"==t&&"string"==typeof e?e:("object"==typeof e&&null!=e[t]?e:n)[t]}b.defineOption("autoCloseBrackets",!1,function(e,t,n){n&&n!=b.Init&&(e.removeKeyMap(r),e.state.closeBrackets=null),t&&(o(x(t,"pairs")),e.state.closeBrackets=t,e.addKeyMap(r))});var r={Backspace:function(e){var t=O(e);if(!t||e.getOption("disableInput"))return b.Pass;for(var n=x(t,"pairs"),o=e.listSelections(),r=0;r<o.length;r++){if(!o[r].empty())return b.Pass;var i=l(e,o[r].head);if(!i||n.indexOf(i)%2!=0)return b.Pass}for(r=o.length-1;0<=r;r--){var a=o[r].head;e.replaceRange("",C(a.line,a.ch-1),C(a.line,a.ch+1),"+delete")}},Enter:function(o){var e=O(o),t=e&&x(e,"explode");if(!t||o.getOption("disableInput"))return b.Pass;for(var r=o.listSelections(),n=0;n<r.length;n++){if(!r[n].empty())return b.Pass;var i=l(o,r[n].head);if(!i||t.indexOf(i)%2!=0)return b.Pass}o.operation(function(){var e=o.lineSeparator()||"\n";o.replaceSelection(e+e,null),w(o,-1),r=o.listSelections();for(var t=0;t<r.length;t++){var n=r[t].head.line;o.indentLine(n,null,!0),o.indentLine(n+1,null,!0)}})}};function o(e){for(var t=0;t<e.length;t++){var n=e.charAt(t),o="'"+n+"'";r[o]||(r[o]=function(y){return function(e){var r=e,t=y,e=O(r);if(!e||r.getOption("disableInput"))return b.Pass;var n=x(e,"pairs"),o=n.indexOf(t);if(-1==o)return b.Pass;for(var i,a=x(e,"closeBefore"),l=x(e,"triples"),s=n.charAt(o+1)==t,c=r.listSelections(),f=o%2==0,u=0;u<c.length;u++){var d,h=c[u],p=h.head,g=r.getRange(p,C(p.line,p.ch+1));if(f&&!h.empty())d="surround";else if(!s&&f||g!=t)if(s&&1<p.ch&&0<=l.indexOf(t)&&r.getRange(C(p.line,p.ch-2),p)==t+t){if(2<p.ch&&/\bstring/.test(r.getTokenTypeAt(C(p.line,p.ch-2))))return b.Pass;d="addFour"}else{if(s){h=0==p.ch?" ":r.getRange(C(p.line,p.ch-1),p);if(b.isWordChar(g)||h==t||b.isWordChar(h))return b.Pass}else if(!f||!(0===g.length||/\s/.test(g)||-1<a.indexOf(g)))return b.Pass;d="both"}else d=s&&function(e,t){var n=e.getTokenAt(C(t.line,t.ch+1));return/\bstring/.test(n.type)&&n.start==t.ch&&(0==t.ch||!/\bstring/.test(e.getTokenTypeAt(t)))}(r,p)?"both":0<=l.indexOf(t)&&r.getRange(p,C(p.line,p.ch+3))==t+t+t?"skipThree":"skip";if(i){if(i!=d)return b.Pass}else i=d}var m=o%2?n.charAt(o-1):t,v=o%2?t:n.charAt(o+1);r.operation(function(){if("skip"==i)w(r,1);else if("skipThree"==i)w(r,3);else if("surround"==i){for(var e=r.getSelections(),t=0;t<e.length;t++)e[t]=m+e[t]+v;r.replaceSelections(e,"around");for(e=r.listSelections().slice(),t=0;t<e.length;t++)e[t]=(n=e[t],o=void 0,o=0<b.cmpPos(n.anchor,n.head),{anchor:new C(n.anchor.line,n.anchor.ch+(o?-1:1)),head:new C(n.head.line,n.head.ch+(o?1:-1))});r.setSelections(e)}else"both"==i?(r.replaceSelection(m+v,null),r.triggerElectric(m+v),w(r,-1)):"addFour"==i&&(r.replaceSelection(m+m+m+m,"before"),w(r,1));var n,o})}}(n))}}function O(e){var t=e.state.closeBrackets;return t&&!t.override&&e.getModeAt(e.getCursor()).closeBrackets||t}function w(e,t){for(var n=[],o=e.listSelections(),r=0,i=0;i<o.length;i++){var a=o[i],a=(a.head==e.getCursor()&&(r=i),a.head.ch||0<t?{line:a.head.line,ch:a.head.ch+t}:{line:a.head.line-1});n.push({anchor:a,head:a})}e.setSelections(n,r)}function l(e,t){e=e.getRange(C(t.line,t.ch-1),C(t.line,t.ch+1));return 2==e.length?e:null}o(n.pairs+"`")}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(o){"use strict";o.defineOption("fullScreen",!1,function(e,t,n){!(n=n==o.Init?!1:n)!=!t&&(t?(t=(n=e).getWrapperElement(),n.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:t.style.width,height:t.style.height},t.style.width="",t.style.height="auto",t.className+=" CodeMirror-fullscreen",document.documentElement.style.overflow="hidden",n):((n=(t=e).getWrapperElement()).className=n.className.replace(/\s*CodeMirror-fullscreen\b/,""),document.documentElement.style.overflow="",e=t.state.fullScreenRestore,n.style.width=e.width,n.style.height=e.height,window.scrollTo(e.scrollLeft,e.scrollTop),t)).refresh()})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./matchesonscrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./matchesonscrollbar"],e):e(CodeMirror)}(function(o){"use strict";var n={style:"matchhighlight",minChars:2,delay:100,wordsOnly:!1,annotateScrollbar:!1,showToken:!1,trim:!0};function r(e){for(var t in this.options={},n)this.options[t]=(e&&e.hasOwnProperty(t)?e:n)[t];this.overlay=this.timeout=null,this.matchesonscroll=null,this.active=!1}function i(e){var t=e.state.matchHighlighter;(t.active||e.hasFocus())&&l(e,t)}function a(e){var t=e.state.matchHighlighter;t.active||(t.active=!0,l(e,t))}function l(e,t){clearTimeout(t.timeout),t.timeout=setTimeout(function(){f(e)},t.options.delay)}function s(e,t,n,o){var r,i,a,l=e.state.matchHighlighter;e.addOverlay(l.overlay=(r=t,i=n,a=o,{token:function(e){if(e.match(r)&&(!i||(n=i,!((t=e).start&&n.test(t.string.charAt(t.start-1))||t.pos!=t.string.length&&n.test(t.string.charAt(t.pos))))))return a;var t,n;e.next(),e.skipTo(r.charAt(0))||e.skipToEnd()}})),l.options.annotateScrollbar&&e.showMatchesOnScrollbar&&(o=n?new RegExp((/\w/.test(t.charAt(0))?"\\b":"")+t.replace(/[\\\[.+*?(){|^$]/g,"\\$&")+(/\w/.test(t.charAt(t.length-1))?"\\b":"")):t,l.matchesonscroll=e.showMatchesOnScrollbar(o,!1,{className:"CodeMirror-selection-highlight-scrollbar"}))}function c(e){var t=e.state.matchHighlighter;t.overlay&&(e.removeOverlay(t.overlay),t.overlay=null,t.matchesonscroll)&&(t.matchesonscroll.clear(),t.matchesonscroll=null)}function f(l){l.operation(function(){var e=l.state.matchHighlighter;if(c(l),!l.somethingSelected()&&e.options.showToken){for(var t=!0===e.options.showToken?/[\w$]/:e.options.showToken,n=l.getCursor(),o=l.getLine(n.line),r=n.ch,i=r;r&&t.test(o.charAt(r-1));)--r;for(;i<o.length&&t.test(o.charAt(i));)++i;r<i&&s(l,o.slice(r,i),t,e.options.style)}else{var n=l.getCursor("from"),a=l.getCursor("to");n.line!=a.line||e.options.wordsOnly&&!function(e,t,n){if(null!==e.getRange(t,n).match(/^\w+$/)){if(0<t.ch){var o={line:t.line,ch:t.ch-1};if(null===e.getRange(o,t).match(/\W/))return}if(n.ch<e.getLine(t.line).length){o={line:n.line,ch:n.ch+1};if(null===e.getRange(n,o).match(/\W/))return}return 1}}(l,n,a)||(n=l.getRange(n,a),(n=e.options.trim?n.replace(/^\s+|\s+$/g,""):n).length>=e.options.minChars&&s(l,n,!1,e.options.style))}})}o.defineOption("highlightSelectionMatches",!1,function(e,t,n){n&&n!=o.Init&&(c(e),clearTimeout(e.state.matchHighlighter.timeout),e.state.matchHighlighter=null,e.off("cursorActivity",i),e.off("focus",a)),t&&(n=e.state.matchHighlighter=new r(t),e.hasFocus()?(n.active=!0,f(e)):e.on("focus",a),e.on("cursorActivity",i))})}); |