import{r as A}from"./codemirror-DpyRu-EA.js";var I={exports:{}},z;function $(){return z||(z=1,(function(y,C){(function(v){v(A())})(function(v){var s=v.Pos;function D(e){var t=e.flags;return t??(e.ignoreCase?"i":"")+(e.global?"g":"")+(e.multiline?"m":"")}function O(e,t){for(var n=D(e),r=n,l=0;l<t.length;l++)r.indexOf(t.charAt(l))==-1&&(r+=t.charAt(l));return n==r?e:new RegExp(e.source,r)}function S(e){return/\\s|\\n|\n|\\W|\\D|\[\^/.test(e.source)}function d(e,t,n){t=O(t,"g");for(var r=n.line,l=n.ch,i=e.lastLine();r<=i;r++,l=0){t.lastIndex=l;var h=e.getLine(r),f=t.exec(h);if(f)return{from:s(r,f.index),to:s(r,f.index+f[0].length),match:f}}}function N(e,t,n){if(!S(t))return d(e,t,n);t=O(t,"gm");for(var r,l=1,i=n.line,h=e.lastLine();i<=h;){for(var f=0;f<l&&!(i>h);f++){var L=e.getLine(i++);r=r==null?L:r+`
`+L}l=l*2,t.lastIndex=n.ch;var u=t.exec(r);if(u){var a=r.slice(0,u.index).split(`
`),c=u[0].split(`
`),o=n.line+a.length-1,g=a[a.length-1].length;return{from:s(o,g),to:s(o+c.length-1,c.length==1?g+c[0].length:c[c.length-1].length),match:u}}}}function E(e,t,n){for(var r,l=0;l<=e.length;){t.lastIndex=l;var i=t.exec(e);if(!i)break;var h=i.index+i[0].length;if(h>e.length-n)break;(!r||h>r.index+r[0].length)&&(r=i),l=i.index+1}return r}function R(e,t,n){t=O(t,"g");for(var r=n.line,l=n.ch,i=e.firstLine();r>=i;r--,l=-1){var h=e.getLine(r),f=E(h,t,l<0?0:h.length-l);if(f)return{from:s(r,f.index),to:s(r,f.index+f[0].length),match:f}}}function b(e,t,n){if(!S(t))return R(e,t,n);t=O(t,"gm");for(var r,l=1,i=e.getLine(n.line).length-n.ch,h=n.line,f=e.firstLine();h>=f;){for(var L=0;L<l&&h>=f;L++){var u=e.getLine(h--);r=r==null?u:u+`
`+r}l*=2;var a=E(r,t,i);if(a){var c=r.slice(0,a.index).split(`
`),o=a[0].split(`
`),g=h+c.length,p=c[c.length-1].length;return{from:s(g,p),to:s(g+o.length-1,o.length==1?p+o[0].length:o[o.length-1].length),match:a}}}}var F,P;String.prototype.normalize?(F=function(e){return e.normalize("NFD").toLowerCase()},P=function(e){return e.normalize("NFD")}):(F=function(e){return e.toLowerCase()},P=function(e){return e});function m(e,t,n,r){if(e.length==t.length)return n;for(var l=0,i=n+Math.max(0,e.length-t.length);;){if(l==i)return l;var h=l+i>>1,f=r(e.slice(0,h)).length;if(f==n)return h;f>n?i=h:l=h+1}}function B(e,t,n,r){if(!t.length)return null;var l=r?F:P,i=l(t).split(/\r|\n\r?/);t:for(var h=n.line,f=n.ch,L=e.lastLine()+1-i.length;h<=L;h++,f=0){var u=e.getLine(h).slice(f),a=l(u);if(i.length==1){var c=a.indexOf(i[0]);if(c==-1)continue t;var n=m(u,a,c,l)+f;return{from:s(h,m(u,a,c,l)+f),to:s(h,m(u,a,c+i[0].length,l)+f)}}else{var o=a.length-i[0].length;if(a.slice(o)!=i[0])continue t;for(var g=1;g<i.length-1;g++)if(l(e.getLine(h+g))!=i[g])continue t;var p=e.getLine(h+i.length-1),x=l(p),w=i[i.length-1];if(x.slice(0,w.length)!=w)continue t;return{from:s(h,m(u,a,o,l)+f),to:s(h+i.length-1,m(p,x,w.length,l))}}}}function j(e,t,n,r){if(!t.length)return null;var l=r?F:P,i=l(t).split(/\r|\n\r?/);t:for(var h=n.line,f=n.ch,L=e.firstLine()-1+i.length;h>=L;h--,f=-1){var u=e.getLine(h);f>-1&&(u=u.slice(0,f));var a=l(u);if(i.length==1){var c=a.lastIndexOf(i[0]);if(c==-1)continue t;return{from:s(h,m(u,a,c,l)),to:s(h,m(u,a,c+i[0].length,l))}}else{var o=i[i.length-1];if(a.slice(0,o.length)!=o)continue t;for(var g=1,n=h-i.length+1;g<i.length-1;g++)if(l(e.getLine(n+g))!=i[g])continue t;var p=e.getLine(h+1-i.length),x=l(p);if(x.slice(x.length-i[0].length)!=i[0])continue t;return{from:s(h+1-i.length,m(p,x,p.length-i[0].length,l)),to:s(h,m(u,a,o.length,l))}}}}function k(e,t,n,r){this.atOccurrence=!1,this.afterEmptyMatch=!1,this.doc=e,n=n?e.clipPos(n):s(0,0),this.pos={from:n,to:n};var l;typeof r=="object"?l=r.caseFold:(l=r,r=null),typeof t=="string"?(l==null&&(l=!1),this.matches=function(i,h){return(i?j:B)(e,t,h,l)}):(t=O(t,"gm"),!r||r.multiline!==!1?this.matches=function(i,h){return(i?b:N)(e,t,h)}:this.matches=function(i,h){return(i?R:d)(e,t,h)})}k.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);if(this.afterEmptyMatch&&this.atOccurrence&&(t=s(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++)),v.cmpPos(t,this.doc.clipPos(t))!=0))return this.atOccurrence=!1;var n=this.matches(e,t);if(this.afterEmptyMatch=n&&v.cmpPos(n.from,n.to)==0,n)return this.pos=n,this.atOccurrence=!0,this.pos.match||!0;var r=s(e?this.doc.firstLine():this.doc.lastLine()+1,0);return this.pos={from:r,to:r},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){if(this.atOccurrence){var n=v.splitLines(e);this.doc.replaceRange(n,this.pos.from,this.pos.to,t),this.pos.to=s(this.pos.from.line+n.length-1,n[n.length-1].length+(n.length==1?this.pos.from.ch:0))}}},v.defineExtension("getSearchCursor",function(e,t,n){return new k(this.doc,e,t,n)}),v.defineDocExtension("getSearchCursor",function(e,t,n){return new k(this,e,t,n)}),v.defineExtension("selectMatches",function(e,t){for(var n=[],r=this.getSearchCursor(e,this.getCursor("from"),t);r.findNext()&&!(v.cmpPos(r.to(),this.getCursor("to"))>0);)n.push({anchor:r.from(),head:r.to()});n.length&&this.setSelections(n,0)})})})()),I.exports}export{$ as r};
//# sourceMappingURL=searchcursor-BkXLGAQH.js.map
