2 lines
32 KiB
JavaScript
2 lines
32 KiB
JavaScript
|
!function(){"use strict";let e={};const t={exports:e};var n;n=function(e){var t,n,r=e.Pos;function o(e,t){for(var n=function(e){var t=e.flags;return null!=t?t:(e.ignoreCase?"i":"")+(e.global?"g":"")+(e.multiline?"m":"")}(e),r=n,o=0;o<t.length;o++)-1==r.indexOf(t.charAt(o))&&(r+=t.charAt(o));return n==r?e:new RegExp(e.source,r)}function i(e){return/\\s|\\n|\n|\\W|\\D|\[\^/.test(e.source)}function l(e,t,n){t=o(t,"g");for(var i=n.line,l=n.ch,a=e.lastLine();i<=a;i++,l=0){t.lastIndex=l;var s=e.getLine(i),f=t.exec(s);if(f)return{from:r(i,f.index),to:r(i,f.index+f[0].length),match:f}}}function a(e,t,n){if(!i(t))return l(e,t,n);t=o(t,"gm");for(var a,s=1,f=n.line,c=e.lastLine();f<=c;){for(var u=0;u<s&&!(f>c);u++){var d=e.getLine(f++);a=null==a?d:a+"\n"+d}s*=2,t.lastIndex=n.ch;var h=t.exec(a);if(h){var m=a.slice(0,h.index).split("\n"),g=h[0].split("\n"),p=n.line+m.length-1,v=m[m.length-1].length;return{from:r(p,v),to:r(p+g.length-1,1==g.length?v+g[0].length:g[g.length-1].length),match:h}}}}function s(e,t,n){for(var r,o=0;o<=e.length;){t.lastIndex=o;var i=t.exec(e);if(!i)break;var l=i.index+i[0].length;if(l>e.length-n)break;(!r||l>r.index+r[0].length)&&(r=i),o=i.index+1}return r}function f(e,t,n){t=o(t,"g");for(var i=n.line,l=n.ch,a=e.firstLine();i>=a;i--,l=-1){var f=e.getLine(i),c=s(f,t,l<0?0:f.length-l);if(c)return{from:r(i,c.index),to:r(i,c.index+c[0].length),match:c}}}function c(e,t,n){if(!i(t))return f(e,t,n);t=o(t,"gm");for(var l,a=1,c=e.getLine(n.line).length-n.ch,u=n.line,d=e.firstLine();u>=d;){for(var h=0;h<a&&u>=d;h++){var m=e.getLine(u--);l=null==l?m:m+"\n"+l}a*=2;var g=s(l,t,c);if(g){var p=l.slice(0,g.index).split("\n"),v=g[0].split("\n"),C=u+p.length,L=p[p.length-1].length;return{from:r(C,L),to:r(C+v.length-1,1==v.length?L+v[0].length:v[v.length-1].length),match:g}}}}function u(e,t,n,r){if(e.length==t.length)return n;for(var o=0,i=n+Math.max(0,e.length-t.length);;){if(o==i)return o;var l=o+i>>1,a=r(e.slice(0,l)).length;if(a==n)return l;a>n?i=l:o=l+1}}function d(e,o,i,l){if(!o.length)return null;var a=l?t:n,s=a(o).split(/\r|\n\r?/);e:for(var f=i.line,c=i.ch,d=e.lastLine()+1-s.length;f<=d;f++,c=0){var h=e.getLine(f).slice(c),m=a(h);if(1==s.length){var g=m.indexOf(s[0]);if(-1==g)continue e;return i=u(h,m,g,a)+c,{from:r(f,u(h,m,g,a)+c),to:r(f,u(h,m,g+s[0].length,a)+c)}}var p=m.length-s[0].length;if(m.slice(p)==s[0]){for(var v=1;v<s.length-1;v++)if(a(e.getLine(f+v))!=s[v])continue e;var C=e.getLine(f+s.length-1),L=a(C),S=s[s.length-1];if(L.slice(0,S.length)==S)return{from:r(f,u(h,m,p,a)+c),to:r(f+s.length-1,u(C,L,S.length,a))}}}}function h(e,o,i,l){if(!o.length)return null;var a=l?t:n,s=a(o).split(/\r|\n\r?/);e:for(var f=i.line,c=i.ch,d=e.firstLine()-1+s.length;f>=d;f--,c=-1){var h=e.getLine(f);c>-1&&(h=h.slice(0,c));var m=a(h);if(1==s.length){var g=m.lastIndexOf(s[0]);if(-1==g)continue e;return{from:r(f,u(h,m,g,a)),to:r(f,u(h,m,g+s[0].length,a))}}var p=s[s.length-1];if(m.slice(0,p.length)==p){var v=1;for(i=f-s.length+1;v<s.length-1;v++)if(a(e.getLine(i+v))!=s[v])continue e;var C=e.getLine(f+1-s.length),L=a(C);if(L.slice(L.length-s[0].length)==s[0])return{from:r(f+1-s.length,u(C,L,C.length-s[0].length,a)),to:r(f,u(h,m,p.length,a))}}}}function m(e,t,n,i){var s;this.atOccurrence=!1,this.afterEmptyMatch=!1,this.doc=e,n=n?e.clipPos(n):r(0,0),this.pos={from:n,to:n},"object"==typeof i?s=i.caseFold:(s=i,i=null),"string"==typeof t?(null==s&&(s=!1),this.matches=function(n,r){return(n?h:d)(e,t,r,s)}):(t=o(t,"gm"),i&&!1===i.multiline?this.matches=function(n,r){return(n?f:l)(e,t,r)}:this.matches=function(n,r){return(n?c:a)(e,t,r)})}String.prototype.normalize?(t=function(e){return e.normalize("NFD").toLowerCase()},n=function(e){return e.normalize("NFD")}):(t=function(e){return e.toLowerCase()},n=function(e){return e}),m.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(t){var n=this.doc.clipPos(t?this.pos.from:this.pos.to);if(this.afterEmptyMatch&&this.atOccurrence&&(n=r(n.line,n.ch),t?(n.ch--,n.ch<0&&(n.line--,n.ch=(this.doc.getLine(n.line)||"").length)):(n.ch++,n.ch>(this
|