UNPKG

p3x-redis-ui-material

Version:

💿 The p3x-redis-ui-material web interface that connects to the p3x-redis-ui-server via http and socket.io

1 lines • 20.4 kB
"use strict";(self.webpackChunkp3x_redis_ui_material=self.webpackChunkp3x_redis_ui_material||[]).push([[2730],{45106(e,t,i){i.d(t,{highlightSelectionMatches:()=>v,searchKeymap:()=>H});var r=i(43599),n=i(41762),s=i(40662);const o="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class l{constructor(e,t,i=0,r=e.length,n,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,r),this.bufferStart=i,this.normalize=n?e=>n(o(e)):o,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return(0,n.vS)(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=(0,n.MK)(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=(0,n.Fh)(e);let r=this.normalize(t);if(r.length)for(let e=0,n=i;;e++){let s=r.charCodeAt(e),o=this.match(s,n,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}n==i&&e<t.length&&t.charCodeAt(e)==s&&n++}}}match(e,t,i){let r=null;for(let t=0;t<this.matches.length;t+=2){let n=this.matches[t],s=!1;this.query.charCodeAt(n)==e&&(n==this.query.length-1?r={from:this.matches[t+1],to:i}:(this.matches[t]++,s=!0)),s||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?r={from:t,to:i}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}}"undefined"!=typeof Symbol&&(l.prototype[Symbol.iterator]=function(){return this});const a={from:-1,to:-1,match:/.*/.exec("")},h="gm"+(null==/x/.unicode?"":"u");class c{constructor(e,t,i,r=0,n=e.length){if(this.text=e,this.to=n,this.curLine="",this.done=!1,this.value=a,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new d(e,t,i,r,n);this.re=new RegExp(t,h+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=e.iter();let s=e.lineAt(r);this.curLineStart=s.from,this.matchPos=m(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,r=i+t[0].length;if(this.matchPos=m(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<r||i>this.value.to)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const u=new WeakMap;class f{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let r=u.get(e);if(!r||r.from>=i||r.to<=t){let r=new f(t,e.sliceString(t,i));return u.set(e,r),r}if(r.from==t&&r.to==i)return r;let{text:n,from:s}=r;return s>t&&(n=e.sliceString(t,s)+n,s=t),r.to<i&&(n+=e.sliceString(r.to,i)),u.set(e,new f(s,n)),new f(t,n.slice(t-s,i-s))}}class d{constructor(e,t,i,r,n){this.text=e,this.to=n,this.done=!1,this.value=a,this.matchPos=m(e,r),this.re=new RegExp(t,h+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=f.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,i=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,i,t)))return this.value={from:e,to:i,match:t},this.matchPos=m(this.text,i+(e==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=f.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function m(e,t){if(t>=e.length)return t;let i,r=e.lineAt(t);for(;t<r.to&&(i=r.text.charCodeAt(t-r.from))>=56320&&i<57344;)t++;return t}"undefined"!=typeof Symbol&&(c.prototype[Symbol.iterator]=d.prototype[Symbol.iterator]=function(){return this});const p={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},g=n.sj.define({combine:e=>(0,n.QR)(e,p,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});function v(e){let t=[M,y];return e&&t.push(g.of(e)),t}const x=r.NZ.mark({class:"cm-selectionMatch"}),w=r.NZ.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function b(e,t,i,r){return!(0!=i&&e(t.sliceDoc(i-1,i))==n.Je.Word||r!=t.doc.length&&e(t.sliceDoc(r,r+1))==n.Je.Word)}const y=r.Z9.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(g),{state:i}=e,s=i.selection;if(s.ranges.length>1)return r.NZ.none;let o,a=s.main,h=null;if(a.empty){if(!t.highlightWordAroundCursor)return r.NZ.none;let e=i.wordAt(a.head);if(!e)return r.NZ.none;h=i.charCategorizer(a.head),o=i.sliceDoc(e.from,e.to)}else{let e=a.to-a.from;if(e<t.minSelectionLength||e>200)return r.NZ.none;if(t.wholeWords){if(o=i.sliceDoc(a.from,a.to),h=i.charCategorizer(a.head),!b(h,i,a.from,a.to)||!function(e,t,i,r){return e(t.sliceDoc(i,i+1))==n.Je.Word&&e(t.sliceDoc(r-1,r))==n.Je.Word}(h,i,a.from,a.to))return r.NZ.none}else if(o=i.sliceDoc(a.from,a.to),!o)return r.NZ.none}let c=[];for(let n of e.visibleRanges){let e=new l(i.doc,o,n.from,n.to);for(;!e.next().done;){let{from:n,to:s}=e.value;if((!h||b(h,i,n,s))&&(a.empty&&n<=a.from&&s>=a.to?c.push(w.range(n,s)):(n>=a.to||s<=a.from)&&c.push(x.range(n,s)),c.length>t.maxMatches))return r.NZ.none}}return r.NZ.set(c)}},{decorations:e=>e.decorations}),M=r.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const S=n.sj.define({combine:e=>(0,n.QR)(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new X(e),scrollToMatch:e=>r.EditorView.scrollIntoView(e)})});class k{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,h),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,((e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\"))}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new E(this):new A(this)}getCursor(e,t=0,i){let r=e.doc?e:n.EditorState.create({doc:e});return null==i&&(i=r.doc.length),this.regexp?C(this,r,t,i):q(this,r,t,i)}}class F{constructor(e){this.spec=e}}function q(e,t,i,r){let s;var o,a;return e.wholeWord&&(o=t.doc,a=t.charCategorizer(t.selection.main.head),s=(e,t,i,r)=>((r>e||r+i.length<t)&&(r=Math.max(0,e-2),i=o.sliceString(r,Math.min(o.length,t+2))),!(a(L(i,e-r))==n.Je.Word&&a(W(i,e-r))==n.Je.Word||a(W(i,t-r))==n.Je.Word&&a(L(i,t-r))==n.Je.Word))),e.test&&(s=function(e,t,i){return(r,n,s,o)=>{if(i&&!i(r,n,s,o))return!1;let l=r>=o&&n<=o+s.length?s.slice(r-o,n-o):t.doc.sliceString(r,n);return e(l,t,r,n)}}(e.test,t,s)),new l(t.doc,e.unquoted,i,r,e.caseSensitive?void 0:e=>e.toLowerCase(),s)}class A extends F{constructor(e){super(e)}nextMatch(e,t,i){let r=q(this.spec,e,i,e.doc.length).nextOverlapping();if(r.done){let i=Math.min(e.doc.length,t+this.spec.unquoted.length);r=q(this.spec,e,0,i).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==i?null:r.value}prevMatchInRange(e,t,i){for(let r=i;;){let i=Math.max(t,r-1e4-this.spec.unquoted.length),n=q(this.spec,e,i,r),s=null;for(;!n.nextOverlapping().done;)s=n.value;if(s)return s;if(i==t)return null;r-=1e4}}prevMatch(e,t,i){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),!r||r.from==t&&r.to==i?null:r}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=q(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let n=q(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!n.next().done;)r(n.value.from,n.value.to)}}function C(e,t,i,r){let s;var o;return e.wholeWord&&(o=t.charCategorizer(t.selection.main.head),s=(e,t,i)=>!i[0].length||(o(L(i.input,i.index))!=n.Je.Word||o(W(i.input,i.index))!=n.Je.Word)&&(o(W(i.input,i.index+i[0].length))!=n.Je.Word||o(L(i.input,i.index+i[0].length))!=n.Je.Word)),e.test&&(s=function(e,t,i){return(r,n,s)=>(!i||i(r,n,s))&&e(s[0],t,r,n)}(e.test,t,s)),new c(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},i,r)}function L(e,t){return e.slice((0,n.zK)(e,t,!1),t)}function W(e,t){return e.slice(t,(0,n.zK)(e,t))}class E extends F{nextMatch(e,t,i){let r=C(this.spec,e,i,e.doc.length).next();return r.done&&(r=C(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=1;;r++){let n=Math.max(t,i-1e4*r),s=C(this.spec,e,n,i),o=null;for(;!s.next().done;)o=s.value;if(o&&(n==t||o.from>n+10))return o;if(n==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,((t,i)=>{if("&"==i)return e.match[0];if("$"==i)return"$";for(let t=i.length;t>0;t--){let r=+i.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+i.slice(t)}return t}))}matchAll(e,t){let i=C(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let n=C(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!n.next().done;)r(n.value.from,n.value.to)}}const D=n.Pe.define(),R=n.Pe.define(),P=n.sU.define({create:e=>new O(Q(e).create(),null),update(e,t){for(let i of t.effects)i.is(D)?e=new O(i.value.create(),e.panel):i.is(R)&&(e=new O(e.query,i.value?_:null));return e},provide:e=>r.S7.from(e,(e=>e.panel))});class O{constructor(e,t){this.query=e,this.panel=t}}const N=r.NZ.mark({class:"cm-searchMatch"}),Z=r.NZ.mark({class:"cm-searchMatch cm-searchMatch-selected"}),I=r.Z9.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(P))}update(e){let t=e.state.field(P);(t!=e.startState.field(P)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return r.NZ.none;let{view:i}=this,s=new n.vB;for(let t=0,r=i.visibleRanges,n=r.length;t<n;t++){let{from:o,to:l}=r[t];for(;t<n-1&&l>r[t+1].from-500;)l=r[++t].to;e.highlight(i.state,o,l,((e,t)=>{let r=i.state.selection.ranges.some((i=>i.from==e&&i.to==t));s.add(e,t,r?Z:N)}))}return s.finish()}},{decorations:e=>e.decorations});function z(e){return t=>{let i=t.state.field(P,!1);return i&&i.query.spec.valid?e(t,i):G(t)}}const J=z(((e,{query:t})=>{let{to:i}=e.state.selection.main,r=t.nextMatch(e.state,i,i);if(!r)return!1;let s=n.OF.single(r.from,r.to),o=e.state.facet(S);return e.dispatch({selection:s,effects:[te(e,r),o.scrollToMatch(s.main,e)],userEvent:"select.search"}),B(e),!0})),V=z(((e,{query:t})=>{let{state:i}=e,{from:r}=i.selection.main,s=t.prevMatch(i,r,r);if(!s)return!1;let o=n.OF.single(s.from,s.to),l=e.state.facet(S);return e.dispatch({selection:o,effects:[te(e,s),l.scrollToMatch(o.main,e)],userEvent:"select.search"}),B(e),!0})),$=z(((e,{query:t})=>{let i=t.matchAll(e.state,1e3);return!(!i||!i.length)&&(e.dispatch({selection:n.OF.create(i.map((e=>n.OF.range(e.from,e.to)))),userEvent:"select.search.matches"}),!0)})),T=z(((e,{query:t})=>{let{state:i}=e,{from:s,to:o}=i.selection.main;if(i.readOnly)return!1;let l=t.nextMatch(i,s,s);if(!l)return!1;let a,h,c=l,u=[],f=[];c.from==s&&c.to==o&&(h=i.toText(t.getReplacement(c)),u.push({from:c.from,to:c.to,insert:h}),c=t.nextMatch(i,c.from,c.to),f.push(r.EditorView.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(s).number)+".")));let d=e.state.changes(u);return c&&(a=n.OF.single(c.from,c.to).map(d),f.push(te(e,c)),f.push(i.facet(S).scrollToMatch(a.main,e))),e.dispatch({changes:d,selection:a,effects:f,userEvent:"input.replace"}),!0})),K=z(((e,{query:t})=>{if(e.state.readOnly)return!1;let i=t.matchAll(e.state,1e9).map((e=>{let{from:i,to:r}=e;return{from:i,to:r,insert:t.getReplacement(e)}}));if(!i.length)return!1;let n=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:r.EditorView.announce.of(n),userEvent:"input.replace.all"}),!0}));function _(e){return e.state.facet(S).createPanel(e)}function Q(e,t){var i,r,n,s,o;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let h=e.facet(S);return new k({search:(null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!==(r=null==t?void 0:t.caseSensitive)&&void 0!==r?r:h.caseSensitive,literal:null!==(n=null==t?void 0:t.literal)&&void 0!==n?n:h.literal,regexp:null!==(s=null==t?void 0:t.regexp)&&void 0!==s?s:h.regexp,wholeWord:null!==(o=null==t?void 0:t.wholeWord)&&void 0!==o?o:h.wholeWord})}function j(e){let t=(0,r.ld)(e,_);return t&&t.dom.querySelector("[main-field]")}function B(e){let t=j(e);t&&t==e.root.activeElement&&t.select()}const G=e=>{let t=e.state.field(P,!1);if(t&&t.panel){let i=j(e);if(i&&i!=e.root.activeElement){let r=Q(e.state,t.query.spec);r.valid&&e.dispatch({effects:D.of(r)}),i.focus(),i.select()}}else e.dispatch({effects:[R.of(!0),t?D.of(Q(e.state,t.query.spec)):n.Pe.appendConfig.of(re)]});return!0},U=e=>{let t=e.state.field(P,!1);if(!t||!t.panel)return!1;let i=(0,r.ld)(e,_);return i&&i.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:R.of(!1)}),!0},H=[{key:"Mod-f",run:G,scope:"editor search-panel"},{key:"F3",run:J,shift:V,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:J,shift:V,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:U,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let i=e.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:r,to:s}=i.main,o=[],a=0;for(let t=new l(e.doc,e.sliceDoc(r,s));!t.next().done;){if(o.length>1e3)return!1;t.value.from==r&&(a=o.length),o.push(n.OF.range(t.value.from,t.value.to))}return t(e.update({selection:n.OF.create(o,a),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let{state:t}=e,i=String(t.doc.lineAt(e.state.selection.main.head).number),{close:s,result:o}=(0,r.ui)(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:i},focus:!0,submitLabel:t.phrase("go")});return o.then((i=>{let o=i&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(i.elements.line.value);if(!o)return void e.dispatch({effects:s});let l=t.doc.lineAt(t.selection.main.head),[,a,h,c,u]=o,f=c?+c.slice(1):0,d=h?+h:l.number;if(h&&u){let e=d/100;a&&(e=e*("-"==a?-1:1)+l.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else h&&a&&(d=d*("-"==a?-1:1)+l.number);let m=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=n.OF.cursor(m.from+Math.max(0,Math.min(f,m.length)));e.dispatch({effects:[s,r.EditorView.scrollIntoView(p.from,{y:"center"})],selection:p})})),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:i}=e.selection;if(i.some((e=>e.from===e.to)))return(({state:e,dispatch:t})=>{let{selection:i}=e,r=n.OF.create(i.ranges.map((t=>e.wordAt(t.head)||n.OF.cursor(t.head))),i.mainIndex);return!r.eq(i)&&(t(e.update({selection:r})),!0)})({state:e,dispatch:t});let s=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some((t=>e.sliceDoc(t.from,t.to)!=s)))return!1;let o=function(e,t){let{main:i,ranges:r}=e.selection,n=e.wordAt(i.head),s=n&&n.from==i.from&&n.to==i.to;for(let i=!1,n=new l(e.doc,t,r[r.length-1].to);;){if(n.next(),!n.done){if(i&&r.some((e=>e.from==n.value.from)))continue;if(s){let t=e.wordAt(n.value.from);if(!t||t.from!=n.value.from||t.to!=n.value.to)continue}return n.value}if(i)return null;n=new l(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),i=!0}}(e,s);return!!o&&(t(e.update({selection:e.selection.addRange(n.OF.range(o.from,o.to),!1),effects:r.EditorView.scrollIntoView(o.to)})),!0)},preventDefault:!0}];class X{constructor(e){this.view=e;let t=this.query=e.state.field(P).query.spec;function i(e,t,i){return(0,s.A)("button",{class:"cm-button",name:e,onclick:t,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=(0,s.A)("input",{value:t.search,placeholder:Y(e,"Find"),"aria-label":Y(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=(0,s.A)("input",{value:t.replace,placeholder:Y(e,"Replace"),"aria-label":Y(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=(0,s.A)("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=(0,s.A)("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=(0,s.A)("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=(0,s.A)("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,i("next",(()=>J(e)),[Y(e,"next")]),i("prev",(()=>V(e)),[Y(e,"previous")]),i("select",(()=>$(e)),[Y(e,"all")]),(0,s.A)("label",null,[this.caseField,Y(e,"match case")]),(0,s.A)("label",null,[this.reField,Y(e,"regexp")]),(0,s.A)("label",null,[this.wordField,Y(e,"by word")]),...e.state.readOnly?[]:[(0,s.A)("br"),this.replaceField,i("replace",(()=>T(e)),[Y(e,"replace")]),i("replaceAll",(()=>K(e)),[Y(e,"replace all")])],(0,s.A)("button",{name:"close",onclick:()=>U(e),"aria-label":Y(e,"close"),type:"button"},["×"])])}commit(){let e=new k({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:D.of(e)}))}keydown(e){(0,r.TS)(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?V:J)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),T(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(D)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(S).top}}function Y(e,t){return e.state.phrase(t)}const ee=/[\s\.,:;?!]/;function te(e,{from:t,to:i}){let n=e.state.doc.lineAt(t),s=e.state.doc.lineAt(i).to,o=Math.max(n.from,t-30),l=Math.min(s,i+30),a=e.state.sliceDoc(o,l);if(o!=n.from)for(let e=0;e<30;e++)if(!ee.test(a[e+1])&&ee.test(a[e])){a=a.slice(e);break}if(l!=s)for(let e=a.length-1;e>a.length-30;e--)if(!ee.test(a[e-1])&&ee.test(a[e])){a=a.slice(0,e);break}return r.EditorView.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${n.number}.`)}const ie=r.EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),re=[P,n.Nb.low(I),ie]}}]);