This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0
wcui/js/lib/codemirror/codemirror.js

6 lines
158 KiB
JavaScript
Raw Normal View History

2017-03-30 02:06:15 +08:00
define(function(){"use strict";function e(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function t(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function r(e,r){return t(e).appendChild(r)}function n(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function i(e,t,r,i){var o=n(e,t,r,i);return o.setAttribute("role","presentation"),o}function o(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function l(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function s(t,r){var n=t.className;e(r).test(n)||(t.className+=(n?" ":"")+r)}function a(t,r){for(var n=t.split(" "),i=0;i<n.length;i++)n[i]&&!e(n[i]).test(r)&&(r+=" "+n[i]);return r}function u(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function c(e,t,r){t||(t={});for(var n in e)!e.hasOwnProperty(n)||r===!1&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function f(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/),-1==t&&(t=e.length));for(var o=n||0,l=i||0;;){var s=e.indexOf(" ",o);if(0>s||s>=t)return l+(t-o);l+=s-o,l+=r-l%r,o=s+1}}function h(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function d(e,t,r){for(var n=0,i=0;;){var o=e.indexOf(" ",n);-1==o&&(o=e.length);var l=o-n;if(o==e.length||i+l>=t)return n+Math.min(l,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}}function p(e){for(;Os.length<=e;)Os.push(g(Os)+" ");return Os[e]}function g(e){return e[e.length-1]}function v(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function m(e,t,r){for(var n=0,i=r(t);n<e.length&&r(e[n])<=i;)n++;e.splice(n,0,t)}function y(){}function b(e,t){var r;return Object.create?r=Object.create(e):(y.prototype=e,r=new y),t&&c(t,r),r}function w(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||Ws.test(e))}function x(e,t){return t?t.source.indexOf("\\w")>-1&&w(e)?!0:t.test(e):w(e)}function C(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function S(e){return e.charCodeAt(0)>=768&&As.test(e)}function L(e,t,r){for(;(0>r?t>0:t<e.length)&&S(e.charAt(t));)t+=r;return t}function T(e,t,r){for(;;){if(Math.abs(t-r)<=1)return e(t)?t:r;var n=Math.floor((t+r)/2);e(n)?r=n:t=n}}function k(e,t,r){var o=this;this.input=r,o.scrollbarFiller=n("div",null,"CodeMirror-scrollbar-filler"),o.scrollbarFiller.setAttribute("cm-not-content","true"),o.gutterFiller=n("div",null,"CodeMirror-gutter-filler"),o.gutterFiller.setAttribute("cm-not-content","true"),o.lineDiv=i("div",null,"CodeMirror-code"),o.selectionDiv=n("div",null,null,"position: relative; z-index: 1"),o.cursorDiv=n("div",null,"CodeMirror-cursors"),o.measure=n("div",null,"CodeMirror-measure"),o.lineMeasure=n("div",null,"CodeMirror-measure"),o.lineSpace=i("div",[o.measure,o.lineMeasure,o.selectionDiv,o.cursorDiv,o.lineDiv],null,"position: relative; outline: none");var l=i("div",[o.lineSpace],"CodeMirror-lines");o.mover=n("div",[l],null,"position: relative"),o.sizer=n("div",[o.mover],"CodeMirror-sizer"),o.sizerWidth=null,o.heightForcer=n("div",null,null,"position: absolute; height: "+Ls+"px; width: 1px;"),o.gutters=n("div",null,"CodeMirror-gutters"),o.lineGutter=null,o.scroller=n("div",[o.sizer,o.heightForcer,o.gutters],"CodeMirror-scroll"),o.scroller.setAttribute("tabIndex","-1"),o.wrapper=n("div",[o.scrollbarFiller,o.gutterFiller,o.scroller],"CodeMirror"),es&&8>ts&&(o.gutters.style.zIndex=-1,o.scroller.style.paddingRight=0),rs||ql&&fs||(o.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(o.wrapper):e(o.wrapper)),o.viewFrom=o.viewTo=t.first,o.reportedViewFrom=o.reportedViewTo=t.first,o.view=[],o.renderedView=null,o.externalMeasured=null,o.viewOffset=0,o.lastWrapHeight=o.lastWrapWidth=0,o.updateLineNumbers=null,o.nativeBarWidth=o.barHeight=o.barWidth=0,o.scrollbarsClipped=!1,o.
}function Qr(e,t,r){for(var n,i,o,l,s,a,u=0;u<e.length;u+=3)if(s=e[u],a=e[u+1],s>t?(i=0,o=1,l="left"):a>t?(i=t-s,o=i+1):(u==e.length-3||t==a&&e[u+3]>t)&&(o=a-s,i=o-1,t>=a&&(l="right")),null!=i){if(n=e[u+2],s==a&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)n=e[(u-=3)+2],l="left";if("right"==r&&i==a-s)for(;u<e.length-3&&e[u+3]==e[u+4]&&!e[u+5].insertLeft;)n=e[(u+=3)+2],l="right";break}return{node:n,start:i,end:o,collapse:l,coverStart:s,coverEnd:a}}function Jr(e,t){var r=Js;if("left"==t)for(var n=0;n<e.length&&(r=e[n]).left==r.right;n++);else for(var i=e.length-1;i>=0&&(r=e[i]).left==r.right;i--);return r}function en(e,t,r,n){var i,o=Qr(t.map,r,n),l=o.node,s=o.start,a=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;4>c;c++){for(;s&&S(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+a<o.coverEnd&&S(t.line.text.charAt(o.coverStart+a));)++a;if(i=es&&9>ts&&0==s&&a==o.coverEnd-o.coverStart?l.parentNode.getBoundingClientRect():Jr(vs(l,s,a).getClientRects(),n),i.left||i.right||0==s)break;a=s,s-=1,u="right"}es&&11>ts&&(i=tn(e.display.measure,i))}else{s>0&&(u=n="right");var f;i=e.options.lineWrapping&&(f=l.getClientRects()).length>1?f["right"==n?f.length-1:0]:l.getBoundingClientRect()}if(es&&9>ts&&!s&&(!i||!i.left&&!i.right)){var h=l.parentNode.getClientRects()[0];i=h?{left:h.left,right:h.left+bn(e.display),top:h.top,bottom:h.bottom}:Js}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+p)/2,v=t.view.measure.heights,m=0;m<v.length-1&&!(g<v[m]);m++);var y=m?v[m-1]:0,b=v[m],w={left:("right"==u?i.right:i.left)-t.rect.left,right:("left"==u?i.left:i.right)-t.rect.left,top:y,bottom:b};return i.left||i.right||(w.bogus=!0),e.options.singleCursorHeightPerLine||(w.rtop=d,w.rbottom=p),w}function tn(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Vt(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}function rn(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function nn(e){e.display.externalMeasure=null,t(e.display.lineMeasure);for(var r=0;r<e.display.view.length;r++)rn(e.display.view[r])}function on(e){nn(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function ln(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function sn(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function an(e,t,r,n,i){if(!i&&t.widgets)for(var o=0;o<t.widgets.length;++o)if(t.widgets[o].above){var l=Ir(t.widgets[o]);r.top+=l,r.bottom+=l}if("line"==n)return r;n||(n="local");var s=yt(t);if("local"==n?s+=Rr(e.display):s-=e.display.viewOffset,"page"==n||"window"==n){var a=e.display.lineSpace.getBoundingClientRect();s+=a.top+("window"==n?0:sn());var u=a.left+("window"==n?0:ln());r.left+=u,r.right+=u}return r.top+=s,r.bottom+=s,r}function un(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=ln(),i-=sn();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var l=e.display.lineSpace.getBoundingClientRect();return{left:n-l.left,top:i-l.top}}function cn(e,t,r,n,i){return n||(n=M(e.doc,t.line)),an(e,n,_r(e,n,t.ch,i),r)}function fn(e,t,r,n,i,o){function l(t,l){var s=Zr(e,i,t,l?"right":"left",o);return l?s.left=s.right:s.right=s.left,an(e,n,s,r)}function s(e,t,r){var n=a[t],i=n.level%2!=0;return l(r?e-1:e,i!=r)}n=n||M(e.doc,t.line),i||(i=qr(e,n));var a=St(n,e.doc.direction),u=t.ch,c=t.sticky;if(u>=n.text.length?(u=n.text.length,c="before"):0>=u&&(u=0,c="after"),!a)return l("before"==c?u-1:u,"before"==c);var f=Ct(a,u,c),h=Ps,d=s(u,f,"before"==c);return null!=h&&(d.other=s(u,h,"before"!=c)),d}function hn(e,t){var r=0;t=U(e.doc,t),e.options.lineWrapping||(r=bn(e.display)*t.ch);var n=M(e.doc,t.line),i=yt(n)+Rr(e.display);return{left:r,right:r,top:i,bottom:i+n.he
}Sr(e,"change",e,t)}function Ui(e,t,r){function n(e,i,o){if(e.linked)for(var l=0;l<e.linked.length;++l){var s=e.linked[l];if(s.doc!=i){var a=o&&s.sharedHist;(!r||a)&&(t(s.doc,a),n(s.doc,e,a))}}}n(e,null,!0)}function Vi(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Sn(e),zi(e),Ki(e),e.options.lineWrapping||wt(e),e.options.mode=t.modeOption,pi(e)}function Ki(e){("rtl"==e.doc.direction?s:bs)(e.display.lineDiv,"CodeMirror-rtl")}function ji(e){ci(e,function(){Ki(e),pi(e)})}function Xi(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Yi(e,t){var r={from:z(t.from),to:Hi(t),text:N(e,t.from,t.to)};return eo(e,r,t.from.line,t.to.line+1),Ui(e,function(e){return eo(e,r,t.from.line,t.to.line+1)},!0),r}function _i(e){for(;e.length;){var t=g(e);if(!t.ranges)break;e.pop()}}function $i(e,t){return t?(_i(e.done),g(e.done)):e.done.length&&!g(e.done).ranges?g(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),g(e.done)):void 0}function qi(e,t,r,n){var i=e.history;i.undone.length=0;var o,l,s=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>s-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=$i(i,i.lastOp==n)))l=g(o.changes),0==F(t.from,t.to)&&0==F(t.from,l.to)?l.to=Hi(t):o.changes.push(Yi(e,t));else{var a=g(i.done);for(a&&a.ranges||Ji(e.sel,i.done),o={changes:[Yi(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=s,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,l||Wt(e,"historyAdded")}function Zi(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function Qi(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||Zi(e,o,g(i.done),t))?i.done[i.done.length-1]=t:Ji(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&_i(i.undone)}function Ji(e,t){var r=g(t);r&&r.ranges&&r.equals(e)||t.push(e)}function eo(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function to(e){if(!e)return null;for(var t,r=0;r<e.length;++r)e[r].marker.explicitlyCleared?t||(t=e.slice(0,r)):t&&t.push(e[r]);return t?t.length?t:null:e}function ro(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=[],i=0;i<t.text.length;++i)n.push(to(r[i]));return n}function no(e,t){var r=ro(e,t),n=J(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],l=n[i];if(o&&l)e:for(var s=0;s<l.length;++s){for(var a=l[s],u=0;u<o.length;++u)if(o[u].marker==a.marker)continue e;o.push(a)}else l&&(r[i]=l)}return r}function io(e,t,r){for(var n=[],i=0;i<e.length;++i){var o=e[i];if(o.ranges)n.push(r?sa.prototype.deepCopy.call(o):o);else{var l=o.changes,s=[];n.push({changes:s});for(var a=0;a<l.length;++a){var u=l[a],c=void 0;if(s.push({from:u.from,to:u.to,text:u.text}),t)for(var f in u)(c=f.match(/^spans_(\d+)$/))&&h(t,Number(c[1]))>-1&&(g(s)[f]=u[f],delete u[f])}}}return n}function oo(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=F(r,i)<0;o!=F(n,i)<0?(i=r,r=n):o!=F(r,n)<0&&(r=n)}return new aa(i,r)}return new aa(n||r,r)}function lo(e,t,r,n){ho(e,new sa([oo(e,e.sel.primary(),t,r)],0),n)}function so(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=oo(e,e.sel.ranges[i],t[i],null);var o=Ai(n,e.sel.primIndex);ho(e,o,r)}function ao(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,ho(e,Ai(i,e.sel.primIndex),n)}function uo(e,t,r,n){ho(e,Di(t,r),n)}function co(e,t,r){var n={ranges:t.ranges,update:function(t){var r=this;this.ranges=[];for(var n=0;n<t.length;n++)
if(u>d&&(h+=p(u-d)),h!=c)return Oo(o,h,E(t,0),E(t,c.length),"+input"),s.stateAfter=null,!0;for(var v=0;v<o.sel.ranges.length;v++){var m=o.sel.ranges[v];if(m.head.line==t&&m.head.ch<c.length){var y=E(t,c.length);ao(o,v,new aa(y,y));break}}}function Wl(e){Ha=e}function Al(e,t,r,n,i){var o=e.doc;e.display.shift=!1,n||(n=o.sel);var l=e.state.pasteIncoming||"paste"==i,s=Rs(t),a=null;if(l&&n.ranges.length>1)if(Ha&&Ha.text.join("\n")==t){if(n.ranges.length%Ha.text.length==0){a=[];for(var u=0;u<Ha.text.length;u++)a.push(o.splitLines(Ha.text[u]))}}else s.length==n.ranges.length&&(a=v(s,function(e){return[e]}));for(var c,f=n.ranges.length-1;f>=0;f--){var h=n.ranges[f],d=h.from(),p=h.to();h.empty()&&(r&&r>0?d=E(d.line,d.ch-r):e.state.overwrite&&!l?p=E(p.line,Math.min(M(o,p.line).text.length,p.ch+g(s).length)):Ha&&Ha.lineWise&&Ha.text.join("\n")==t&&(d=p=E(d.line,0))),c=e.curOp.updateInput;var m={from:d,to:p,text:a?a[f%a.length]:s,origin:i||(l?"paste":e.state.cutIncoming?"cut":"+input")};So(e.doc,m),Sr(e,"inputRead",e,m)}t&&!l&&Hl(e,t),ei(e),e.curOp.updateInput=c,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function Dl(e,t){var r=e.clipboardData&&e.clipboardData.getData("Text");return r?(e.preventDefault(),t.isReadOnly()||t.options.disableInput||ci(t,function(){return Al(t,r,0,null,"paste")}),!0):void 0}function Hl(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var r=e.doc.sel,n=r.ranges.length-1;n>=0;n--){var i=r.ranges[n];if(!(i.head.ch>100||n&&r.ranges[n-1].head.line==i.head.line)){var o=e.getModeAt(i.head),l=!1;if(o.electricChars){for(var s=0;s<o.electricChars.length;s++)if(t.indexOf(o.electricChars.charAt(s))>-1){l=Ol(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(M(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=Ol(e,i.head.line,"smart"));l&&Sr(e,"electricInput",e,i.head.line)}}}function Pl(e){for(var t=[],r=[],n=0;n<e.doc.sel.ranges.length;n++){var i=e.doc.sel.ranges[n].head.line,o={anchor:E(i,0),head:E(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function El(e,t){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck",!!t)}function Fl(){var e=n("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=n("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return rs?e.style.width="1000px":e.setAttribute("wrap","off"),us&&(e.style.border="1px solid black"),El(e),t}function Il(e){var t=e.optionHandlers,r=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,r){var n=this.options,i=n[e];(n[e]!=r||"mode"==e)&&(n[e]=r,t.hasOwnProperty(e)&&fi(this,t[e])(this,r,i),Wt(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](el(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;r<t.length;++r)if(t[r]==e||t[r].name==e)return t.splice(r,1),!0},addOverlay:hi(function(t,r){var n=t.token?t:e.getMode(this.options,t);if(n.startState)throw new Error("Overlays may not be stateful.");m(this.state.overlays,{mode:n,modeSpec:t,opaque:r&&r.opaque,priority:r&&r.priority||0},function(e){return e.priority}),this.state.modeGen++,pi(this)}),removeOverlay:hi(function(e){for(var t=this,r=this.state.overlays,n=0;n<r.length;++n){var i=r[n].modeSpec;if(i==e||"string"==typeof e&&i.name==e)return r.splice(n,1),t.state.modeGen++,void pi(t)}}),indentLine:hi(function(e,t,r){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),H(this.doc,e)&&Ol(this,e,t,r)}),indentSelection:hi(function(e){for(var t=this,r=this.doc.sel.ranges,n=-1,i=0;i<r.length;i++){var o=r[i];if(o.empty())o.head.line>n&&(Ol(t,o.head.line,e,!0),n=o.head.line,i==t.doc.sel.primIndex&&ei(t));else{var l=o.from(),s=o.to(),a=Math.max(n,l.line);n=Math.min(t.lastLine(),s.line-(s.ch?0:1))+1;for(var u=a;n>u;++u)Ol(t,u,e);var c=t.doc.sel.ranges;
if(null!=i&&r){for(var o=0;o<r.length;++o)r[o]==e&&r.splice(o--,1);r.length||(n.widgets=null);var l=Ir(this);W(n,Math.max(0,n.height-l)),t&&(ci(t,function(){Po(t,n,-l),gi(t,i,"widget")}),Sr(t,"lineWidgetCleared",t,this,i))}},fa.prototype.changed=function(){var e=this,t=this.height,r=this.doc.cm,n=this.line;this.height=null;var i=Ir(this)-t;i&&(W(n,n.height+i),r&&ci(r,function(){r.curOp.forceUpdate=!0,Po(r,n,i),Sr(r,"lineWidgetChanged",r,e,A(n))}))},Pt(fa);var ha=0,da=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ha};da.prototype.clear=function(){var e=this;if(!this.explicitlyCleared){var t=this.doc.cm,r=t&&!t.curOp;if(r&&ri(t),Ht(this,"clear")){var n=this.find();n&&Sr(this,"clear",n.from,n.to)}for(var i=null,o=null,l=0;l<this.lines.length;++l){var s=e.lines[l],a=_(s.markedSpans,e);t&&!e.collapsed?gi(t,A(s),"text"):t&&(null!=a.to&&(o=A(s)),null!=a.from&&(i=A(s))),s.markedSpans=$(s.markedSpans,a),null==a.from&&e.collapsed&&!vt(e.doc,s)&&t&&W(s,yn(t.display))}if(t&&this.collapsed&&!t.options.lineWrapping)for(var u=0;u<this.lines.length;++u){var c=ft(e.lines[u]),f=bt(c);f>t.display.maxLineLength&&(t.display.maxLine=c,t.display.maxLineLength=f,t.display.maxLineChanged=!0)}null!=i&&t&&this.collapsed&&pi(t,i,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&vo(t.doc)),t&&Sr(t,"markerCleared",t,this,i,o),r&&ni(t),this.parent&&this.parent.clear()}},da.prototype.find=function(e,t){var r=this;null==e&&"bookmark"==this.type&&(e=1);for(var n,i,o=0;o<this.lines.length;++o){var l=r.lines[o],s=_(l.markedSpans,r);if(null!=s.from&&(n=E(t?l:A(l),s.from),-1==e))return n;if(null!=s.to&&(i=E(t?l:A(l),s.to),1==e))return i}return n&&{from:n,to:i}},da.prototype.changed=function(){var e=this,t=this.find(-1,!0),r=this,n=this.doc.cm;t&&n&&ci(n,function(){var i=t.line,o=A(t.line),l=$r(n,o);if(l&&(rn(l),n.curOp.selectionChanged=n.curOp.forceUpdate=!0),n.curOp.updateMaxLine=!0,!vt(r.doc,i)&&null!=r.height){var s=r.height;r.height=null;var a=Ir(r)-s;a&&W(i,i.height+a)}Sr(n,"markerChanged",n,e)})},da.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&-1!=h(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},da.prototype.detachLine=function(e){if(this.lines.splice(h(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},Pt(da);var pa=function(e,t){var r=this;this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=r};pa.prototype.clear=function(){var e=this;if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var t=0;t<this.markers.length;++t)e.markers[t].clear();Sr(this,"clear")}},pa.prototype.find=function(e,t){return this.primary.find(e,t)},Pt(pa);var ga=0,va=function(e,t,r,n,i){if(!(this instanceof va))return new va(e,t,r,n,i);null==r&&(r=0),ca.call(this,[new ua([new Ys("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var o=E(r,0);this.sel=Di(o),this.history=new Xi(null),this.id=++ga,this.modeOption=t,this.lineSep=n,this.direction="rtl"==i?"rtl":"ltr",this.extend=!1,"string"==typeof e&&(e=this.splitLines(e)),Gi(this,{from:o,to:o,text:e}),ho(this,Di(o),ks)};va.prototype=b(ca.prototype,{constructor:va,iter:function(e,t,r){r?this.iterN(e-this.first,t-e,r):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var r=0,n=0;n<t.length;++n)r+=t[n].height;this.insertInner(e-this.first,t,r)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=O(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:di(function(e){var t=E(this.first,0),r=this.first+this.size-1;So(this,{from:t,to:E(r,M(this,r).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),ho(this,Di(t))}),replaceRange:function(e,t,r,n){t=U(this,t),r=r?U(this,r):t,Oo(this,e,t,r,n)},getRange:function(e,t,r){var n=N(this,U(this,e),U(this,t));return
var h=n.wrapper.getBoundingClientRect();l.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-h.top-5)+"px; left: "+(e.clientX-h.left-5)+"px;\n z-index: 1000; background: "+(es?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var d;if(rs&&(d=window.scrollY),o.input.focus(),rs&&window.scrollTo(null,d),o.input.reset(),i.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),es&&ts>=9&&t(),ys){zt(e);var p=function(){Ot(window,"mouseup",p),setTimeout(r,20)};Is(window,"mouseup",p)}else setTimeout(r,50)}},Ea.prototype.readOnlyChanged=function(e){e||this.reset()},Ea.prototype.setUneditable=function(){},Ea.prototype.needsContentAttribute=!1,Sl(Ml),Il(Ml);var Fa="iter insert remove copy getEditor constructor".split(" ");for(var Ia in va.prototype)va.prototype.hasOwnProperty(Ia)&&h(Fa,Ia)<0&&(Ml.prototype[Ia]=function(e){return function(){return e.apply(this.doc,arguments)}}(va.prototype[Ia]));return Pt(va),Ml.inputStyles={textarea:Ea,contenteditable:Pa},Ml.defineMode=function(e){Ml.defaults.mode||"null"==e||(Ml.defaults.mode=e),Kt.apply(this,arguments)},Ml.defineMIME=jt,Ml.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Ml.defineMIME("text/plain","null"),Ml.defineExtension=function(e,t){Ml.prototype[e]=t},Ml.defineDocExtension=function(e,t){va.prototype[e]=t},Ml.fromTextArea=Xl,Yl(Ml),Ml.version="5.25.1",Ml});