| 1 |
- "use strict";(self["webpackChunk_jupyterlab_application_top"]=self["webpackChunk_jupyterlab_application_top"]||[]).push([[2491],{62491:(e,t,i)=>{i.r(t);i.d(t,{RegExpCursor:()=>f,SearchCursor:()=>c,SearchQuery:()=>F,closeSearchPanel:()=>fe,findNext:()=>te,findPrevious:()=>ie,getSearchQuery:()=>H,gotoLine:()=>x,highlightSelectionMatches:()=>b,openSearchPanel:()=>ue,replaceAll:()=>oe,replaceNext:()=>se,search:()=>P,searchKeymap:()=>de,searchPanelOpen:()=>U,selectMatches:()=>re,selectNextOccurrence:()=>L,selectSelectionMatches:()=>ne,setSearchQuery:()=>B});var r=i(22819);var n=i.n(r);var s=i(71674);var o=i.n(s);var l=i(41107);const a=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e;class c{constructor(e,t,i=0,r=e.length,n,s){this.test=s;this.value={from:0,to:0};this.done=false;this.matches=[];this.buffer="";this.bufferPos=0;this.iter=e.iterRange(i,r);this.bufferStart=i;this.normalize=n?e=>n(a(e)):a;this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){this.bufferStart+=this.buffer.length;this.iter.next();if(this.iter.done)return-1;this.bufferPos=0;this.buffer=this.iter.value}return(0,s.codePointAt)(this.buffer,this.bufferPos)}next(){while(this.matches.length)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0){this.done=true;return this}let t=(0,s.fromCodePoint)(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=(0,s.codePointSize)(e);let r=this.normalize(t);if(r.length)for(let n=0,s=i;;n++){let e=r.charCodeAt(n);let o=this.match(e,s,this.bufferPos+this.bufferStart);if(n==r.length-1){if(o){this.value=o;return this}break}if(s==i&&n<t.length&&t.charCodeAt(n)==e)s++}}}match(e,t,i){let r=null;for(let n=0;n<this.matches.length;n+=2){let t=this.matches[n],s=false;if(this.query.charCodeAt(t)==e){if(t==this.query.length-1){r={from:this.matches[n+1],to:i}}else{this.matches[n]++;s=true}}if(!s){this.matches.splice(n,2);n-=2}}if(this.query.charCodeAt(0)==e){if(this.query.length==1)r={from:t,to:i};else this.matches.push(1,t)}if(r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart))r=null;return r}}if(typeof Symbol!="undefined")c.prototype[Symbol.iterator]=function(){return this};const h={from:-1,to:-1,match:/.*/.exec("")};const u="gm"+(/x/.unicode==null?"":"u");class f{constructor(e,t,i,r=0,n=e.length){this.text=e;this.to=n;this.curLine="";this.done=false;this.value=h;if(/\\[sWDnr]|\n|\r|\[\^/.test(t))return new p(e,t,i,r,n);this.re=new RegExp(t,u+((i===null||i===void 0?void 0:i.ignoreCase)?"i":""));this.test=i===null||i===void 0?void 0:i.test;this.iter=e.iter();let s=e.lineAt(r);this.curLineStart=s.from;this.matchPos=v(e,r);this.getLine(this.curLineStart)}getLine(e){this.iter.next(e);if(this.iter.lineBreak){this.curLine=""}else{this.curLine=this.iter.value;if(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;if(this.curLineStart>this.to)this.curLine="";else 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;this.matchPos=v(this.text,r+(i==r?1:0));if(i==this.curLineStart+this.curLine.length)this.nextLine();if((i<r||i>this.value.to)&&(!this.test||this.test(i,r,t))){this.value={from:i,to:r,match:t};return this}e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to){this.nextLine();e=0}else{this.done=true;return this}}}}const d=new WeakMap;class m{constructor(e,t){this.from=e;this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let r=d.get(e);if(!r||r.from>=i||r.to<=t){let r=new m(t,e.sliceString(t,i));d.set(e,r);return r}if(r.from==t&&r.to==i)return r;let{text:n,from:s}=r;if(s>t){n=e.sliceString(t,s)+n;s=t}if(r.to<i)n+=e.sliceString(r.to,i);d.set(e,new m(s,n));return new m(t,n.slice(t-s,i-s))}}class p{constructor(e,t,i,r,n){this.text=e;this.to=n;this.done=false;this.value=h;this.matchPos=v(e,r);this.re=new RegExp(t,u+((i===null||i===void 0?void 0:i.ignoreCase)?"i":""));this.test=i===null||i===void 0?void 0:i.test;this.flat=m.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;let 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)}if(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))){this.value={from:e,to:i,match:t};this.matchPos=v(this.text,i+(e==i?1:0));return this}}if(this.flat.to==this.to){this.done=true;return this}this.flat=m.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}if(typeof Symbol!="undefined"){f.prototype[Symbol.iterator]=p.prototype[Symbol.iterator]=function(){return this}}function g(e){try{new RegExp(e,u);return true}catch(t){return false}}function v(e,t){if(t>=e.length)return t;let i=e.lineAt(t),r;while(t<i.to&&(r=i.text.charCodeAt(t-i.from))>=56320&&r<57344)t++;return t}const x=e=>{let{state:t}=e;let i=String(t.doc.lineAt(e.state.selection.main.head).number);let{close:n,result:o}=(0,r.showDialog)(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:i},focus:true,submitLabel:t.phrase("go")});o.then((i=>{let o=i&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(i.elements["line"].value);if(!o){e.dispatch({effects:n});return}let l=t.doc.lineAt(t.selection.main.head);let[,a,c,h,u]=o;let f=h?+h.slice(1):0;let d=c?+c:l.number;if(c&&u){let e=d/100;if(a)e=e*(a=="-"?-1:1)+l.number/t.doc.lines;d=Math.round(t.doc.lines*e)}else if(c&&a){d=d*(a=="-"?-1:1)+l.number}let m=t.doc.line(Math.max(1,Math.min(t.doc.lines,d)));let p=s.EditorSelection.cursor(m.from+Math.max(0,Math.min(f,m.length)));e.dispatch({effects:[n,r.EditorView.scrollIntoView(p.from,{y:"center"})],selection:p})}));return true};const y={highlightWordAroundCursor:false,minSelectionLength:1,maxMatches:100,wholeWords:false};const w=s.Facet.define({combine(e){return(0,s.combineConfig)(e,y,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function b(e){let t=[E,A];if(e)t.push(w.of(e));return t}const S=r.Decoration.mark({class:"cm-selectionMatch"});const C=r.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function M(e,t,i,r){return(i==0||e(t.sliceDoc(i-1,i))!=s.CharCategory.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=s.CharCategory.Word)}function k(e,t,i,r){return e(t.sliceDoc(i,i+1))==s.CharCategory.Word&&e(t.sliceDoc(r-1,r))==s.CharCategory.Word}const A=r.ViewPlugin.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){if(e.selectionSet||e.docChanged||e.viewportChanged)this.decorations=this.getDeco(e.view)}getDeco(e){let t=e.state.facet(w);let{state:i}=e,n=i.selection;if(n.ranges.length>1)return r.Decoration.none;let s=n.main,o,l=null;if(s.empty){if(!t.highlightWordAroundCursor)return r.Decoration.none;let e=i.wordAt(s.head);if(!e)return r.Decoration.none;l=i.charCategorizer(s.head);o=i.sliceDoc(e.from,e.to)}else{let e=s.to-s.from;if(e<t.minSelectionLength||e>200)return r.Decoration.none;if(t.wholeWords){o=i.sliceDoc(s.from,s.to);l=i.charCategorizer(s.head);if(!(M(l,i,s.from,s.to)&&k(l,i,s.from,s.to)))return r.Decoration.none}else{o=i.sliceDoc(s.from,s.to);if(!o)return r.Decoration.none}}let a=[];for(let h of e.visibleRanges){let e=new c(i.doc,o,h.from,h.to);while(!e.next().done){let{from:n,to:o}=e.value;if(!l||M(l,i,n,o)){if(s.empty&&n<=s.from&&o>=s.to)a.push(C.range(n,o));else if(n>=s.to||o<=s.from)a.push(S.range(n,o));if(a.length>t.maxMatches)return r.Decoration.none}}}return r.Decoration.set(a)}},{decorations:e=>e.decorations});const E=r.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const q=({state:e,dispatch:t})=>{let{selection:i}=e;let r=s.EditorSelection.create(i.ranges.map((t=>e.wordAt(t.head)||s.EditorSelection.cursor(t.head))),i.mainIndex);if(r.eq(i))return false;t(e.update({selection:r}));return true};function D(e,t){let{main:i,ranges:r}=e.selection;let n=e.wordAt(i.head),s=n&&n.from==i.from&&n.to==i.to;for(let o=false,l=new c(e.doc,t,r[r.length-1].to);;){l.next();if(l.done){if(o)return null;l=new c(e.doc,t,0,Math.max(0,r[r.length-1].from-1));o=true}else{if(o&&r.some((e=>e.from==l.value.from)))continue;if(s){let t=e.wordAt(l.value.from);if(!t||t.from!=l.value.from||t.to!=l.value.to)continue}return l.value}}}const L=({state:e,dispatch:t})=>{let{ranges:i}=e.selection;if(i.some((e=>e.from===e.to)))return q({state:e,dispatch:t});let n=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some((t=>e.sliceDoc(t.from,t.to)!=n)))return false;let o=D(e,n);if(!o)return false;t(e.update({selection:e.selection.addRange(s.EditorSelection.range(o.from,o.to),false),effects:r.EditorView.scrollIntoView(o.to)}));return true};const W=s.Facet.define({combine(e){return(0,s.combineConfig)(e,{top:false,caseSensitive:false,literal:false,regexp:false,wholeWord:false,createPanel:e=>new me(e),scrollToMatch:e=>r.EditorView.scrollIntoView(e)})}});function P(e){return e?[W.of(e),we]:we}class F{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||g(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)=>t=="n"?"\n":t=="r"?"\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 j(this):new z(this)}getCursor(e,t=0,i){let r=e.doc?e:s.EditorState.create({doc:e});if(i==null)i=r.doc.length;return this.regexp?T(this,r,t,i):V(this,r,t,i)}}class R{constructor(e){this.spec=e}}function I(e,t,i){return(r,n,s,o)=>{if(i&&!i(r,n,s,o))return false;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)}}function V(e,t,i,r){let n;if(e.wholeWord)n=O(t.doc,t.charCategorizer(t.selection.main.head));if(e.test)n=I(e.test,t,n);return new c(t.doc,e.unquoted,i,r,e.caseSensitive?undefined:e=>e.toLowerCase(),n)}function O(e,t){return(i,r,n,o)=>{if(o>i||o+n.length<r){o=Math.max(0,i-2);n=e.sliceString(o,Math.min(e.length,r+2))}return(t(_(n,i-o))!=s.CharCategory.Word||t(N(n,i-o))!=s.CharCategory.Word)&&(t(N(n,r-o))!=s.CharCategory.Word||t(_(n,r-o))!=s.CharCategory.Word)}}class z extends R{constructor(e){super(e)}nextMatch(e,t,i){let r=V(this.spec,e,i,e.doc.length).nextOverlapping();if(r.done){let i=Math.min(e.doc.length,t+this.spec.unquoted.length);r=V(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);let n=V(this.spec,e,i,r),s=null;while(!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);if(!r)r=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length);return r&&(r.from!=t||r.to!=i)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=V(this.spec,e,0,e.doc.length),r=[];while(!i.next().done){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let n=V(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));while(!n.next().done)r(n.value.from,n.value.to)}}function $(e,t,i){return(r,n,s)=>(!i||i(r,n,s))&&e(s[0],t,r,n)}function T(e,t,i,r){let n;if(e.wholeWord)n=Q(t.charCategorizer(t.selection.main.head));if(e.test)n=$(e.test,t,n);return new f(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:n},i,r)}function _(e,t){return e.slice((0,s.findClusterBreak)(e,t,false),t)}function N(e,t){return e.slice(t,(0,s.findClusterBreak)(e,t))}function Q(e){return(t,i,r)=>!r[0].length||(e(_(r.input,r.index))!=s.CharCategory.Word||e(N(r.input,r.index))!=s.CharCategory.Word)&&(e(N(r.input,r.index+r[0].length))!=s.CharCategory.Word||e(_(r.input,r.index+r[0].length))!=s.CharCategory.Word)}class j extends R{nextMatch(e,t,i){let r=T(this.spec,e,i,e.doc.length).next();if(r.done)r=T(this.spec,e,0,t).next();return r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=1;;r++){let n=Math.max(t,i-r*1e4);let s=T(this.spec,e,n,i),o=null;while(!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 r=i.length;r>0;r--){let t=+i.slice(0,r);if(t>0&&t<e.match.length)return e.match[t]+i.slice(r)}return t}))}matchAll(e,t){let i=T(this.spec,e,0,e.doc.length),r=[];while(!i.next().done){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let n=T(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));while(!n.next().done)r(n.value.from,n.value.to)}}const B=s.StateEffect.define();const K=s.StateEffect.define();const G=s.StateField.define({create(e){return new J(ae(e).create(),null)},update(e,t){for(let i of t.effects){if(i.is(B))e=new J(i.value.create(),e.panel);else if(i.is(K))e=new J(e.query,i.value?le:null)}return e},provide:e=>r.showPanel.from(e,(e=>e.panel))});function H(e){let t=e.field(G,false);return t?t.query.spec:ae(e)}function U(e){var t;return((t=e.field(G,false))===null||t===void 0?void 0:t.panel)!=null}class J{constructor(e,t){this.query=e;this.panel=t}}const X=r.Decoration.mark({class:"cm-searchMatch"}),Y=r.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"});const Z=r.ViewPlugin.fromClass(class{constructor(e){this.view=e;this.decorations=this.highlight(e.state.field(G))}update(e){let t=e.state.field(G);if(t!=e.startState.field(G)||e.docChanged||e.selectionSet||e.viewportChanged)this.decorations=this.highlight(t)}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return r.Decoration.none;let{view:i}=this;let n=new s.RangeSetBuilder;for(let r=0,s=i.visibleRanges,o=s.length;r<o;r++){let{from:t,to:l}=s[r];while(r<o-1&&l>s[r+1].from-2*250)l=s[++r].to;e.highlight(i.state,t,l,((e,t)=>{let r=i.state.selection.ranges.some((i=>i.from==e&&i.to==t));n.add(e,t,r?Y:X)}))}return n.finish()}},{decorations:e=>e.decorations});function ee(e){return t=>{let i=t.state.field(G,false);return i&&i.query.spec.valid?e(t,i):ue(t)}}const te=ee(((e,{query:t})=>{let{to:i}=e.state.selection.main;let r=t.nextMatch(e.state,i,i);if(!r)return false;let n=s.EditorSelection.single(r.from,r.to);let o=e.state.facet(W);e.dispatch({selection:n,effects:[xe(e,r),o.scrollToMatch(n.main,e)],userEvent:"select.search"});he(e);return true}));const ie=ee(((e,{query:t})=>{let{state:i}=e,{from:r}=i.selection.main;let n=t.prevMatch(i,r,r);if(!n)return false;let o=s.EditorSelection.single(n.from,n.to);let l=e.state.facet(W);e.dispatch({selection:o,effects:[xe(e,n),l.scrollToMatch(o.main,e)],userEvent:"select.search"});he(e);return true}));const re=ee(((e,{query:t})=>{let i=t.matchAll(e.state,1e3);if(!i||!i.length)return false;e.dispatch({selection:s.EditorSelection.create(i.map((e=>s.EditorSelection.range(e.from,e.to)))),userEvent:"select.search.matches"});return true}));const ne=({state:e,dispatch:t})=>{let i=e.selection;if(i.ranges.length>1||i.main.empty)return false;let{from:r,to:n}=i.main;let o=[],l=0;for(let a=new c(e.doc,e.sliceDoc(r,n));!a.next().done;){if(o.length>1e3)return false;if(a.value.from==r)l=o.length;o.push(s.EditorSelection.range(a.value.from,a.value.to))}t(e.update({selection:s.EditorSelection.create(o,l),userEvent:"select.search.matches"}));return true};const se=ee(((e,{query:t})=>{let{state:i}=e,{from:n,to:o}=i.selection.main;if(i.readOnly)return false;let l=t.nextMatch(i,n,n);if(!l)return false;let a=l;let c=[],h,u;let f=[];if(a.from==n&&a.to==o){u=i.toText(t.getReplacement(a));c.push({from:a.from,to:a.to,insert:u});a=t.nextMatch(i,a.from,a.to);f.push(r.EditorView.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+"."))}let d=e.state.changes(c);if(a){h=s.EditorSelection.single(a.from,a.to).map(d);f.push(xe(e,a));f.push(i.facet(W).scrollToMatch(h.main,e))}e.dispatch({changes:d,selection:h,effects:f,userEvent:"input.replace"});return true}));const oe=ee(((e,{query:t})=>{if(e.state.readOnly)return false;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 false;let n=e.state.phrase("replaced $ matches",i.length)+".";e.dispatch({changes:i,effects:r.EditorView.announce.of(n),userEvent:"input.replace.all"});return true}));function le(e){return e.state.facet(W).createPanel(e)}function ae(e,t){var i,r,n,s,o;let l=e.selection.main;let a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let c=e.facet(W);return new F({search:((i=t===null||t===void 0?void 0:t.literal)!==null&&i!==void 0?i:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(r=t===null||t===void 0?void 0:t.caseSensitive)!==null&&r!==void 0?r:c.caseSensitive,literal:(n=t===null||t===void 0?void 0:t.literal)!==null&&n!==void 0?n:c.literal,regexp:(s=t===null||t===void 0?void 0:t.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(o=t===null||t===void 0?void 0:t.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function ce(e){let t=(0,r.getPanel)(e,le);return t&&t.dom.querySelector("[main-field]")}function he(e){let t=ce(e);if(t&&t==e.root.activeElement)t.select()}const ue=e=>{let t=e.state.field(G,false);if(t&&t.panel){let i=ce(e);if(i&&i!=e.root.activeElement){let r=ae(e.state,t.query.spec);if(r.valid)e.dispatch({effects:B.of(r)});i.focus();i.select()}}else{e.dispatch({effects:[K.of(true),t?B.of(ae(e.state,t.query.spec)):s.StateEffect.appendConfig.of(we)]})}return true};const fe=e=>{let t=e.state.field(G,false);if(!t||!t.panel)return false;let i=(0,r.getPanel)(e,le);if(i&&i.dom.contains(e.root.activeElement))e.focus();e.dispatch({effects:K.of(false)});return true};const de=[{key:"Mod-f",run:ue,scope:"editor search-panel"},{key:"F3",run:te,shift:ie,scope:"editor search-panel",preventDefault:true},{key:"Mod-g",run:te,shift:ie,scope:"editor search-panel",preventDefault:true},{key:"Escape",run:fe,scope:"editor search-panel"},{key:"Mod-Shift-l",run:ne},{key:"Mod-Alt-g",run:x},{key:"Mod-d",run:L,preventDefault:true}];class me{constructor(e){this.view=e;let t=this.query=e.state.field(G).query.spec;this.commit=this.commit.bind(this);this.searchField=(0,l.A)("input",{value:t.search,placeholder:pe(e,"Find"),"aria-label":pe(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit});this.replaceField=(0,l.A)("input",{value:t.replace,placeholder:pe(e,"Replace"),"aria-label":pe(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit});this.caseField=(0,l.A)("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit});this.reField=(0,l.A)("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit});this.wordField=(0,l.A)("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(e,t,i){return(0,l.A)("button",{class:"cm-button",name:e,onclick:t,type:"button"},i)}this.dom=(0,l.A)("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,i("next",(()=>te(e)),[pe(e,"next")]),i("prev",(()=>ie(e)),[pe(e,"previous")]),i("select",(()=>re(e)),[pe(e,"all")]),(0,l.A)("label",null,[this.caseField,pe(e,"match case")]),(0,l.A)("label",null,[this.reField,pe(e,"regexp")]),(0,l.A)("label",null,[this.wordField,pe(e,"by word")]),...e.state.readOnly?[]:[(0,l.A)("br"),this.replaceField,i("replace",(()=>se(e)),[pe(e,"replace")]),i("replaceAll",(()=>oe(e)),[pe(e,"replace all")])],(0,l.A)("button",{name:"close",onclick:()=>fe(e),"aria-label":pe(e,"close"),type:"button"},["×"])])}commit(){let e=new F({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});if(!e.eq(this.query)){this.query=e;this.view.dispatch({effects:B.of(e)})}}keydown(e){if((0,r.runScopeHandlers)(this.view,e,"search-panel")){e.preventDefault()}else if(e.keyCode==13&&e.target==this.searchField){e.preventDefault();(e.shiftKey?ie:te)(this.view)}else if(e.keyCode==13&&e.target==this.replaceField){e.preventDefault();se(this.view)}}update(e){for(let t of e.transactions)for(let e of t.effects){if(e.is(B)&&!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(W).top}}function pe(e,t){return e.state.phrase(t)}const ge=30;const ve=/[\s\.,:;?!]/;function xe(e,{from:t,to:i}){let n=e.state.doc.lineAt(t),s=e.state.doc.lineAt(i).to;let o=Math.max(n.from,t-ge),l=Math.min(s,i+ge);let a=e.state.sliceDoc(o,l);if(o!=n.from){for(let e=0;e<ge;e++)if(!ve.test(a[e+1])&&ve.test(a[e])){a=a.slice(e);break}}if(l!=s){for(let e=a.length-1;e>a.length-ge;e--)if(!ve.test(a[e-1])&&ve.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 ye=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"}});const we=[G,s.Prec.low(Z),ye]},41107:(e,t,i)=>{i.d(t,{A:()=>r});function r(){var e=arguments[0];if(typeof e=="string")e=document.createElement(e);var t=1,i=arguments[1];if(i&&typeof i=="object"&&i.nodeType==null&&!Array.isArray(i)){for(var r in i)if(Object.prototype.hasOwnProperty.call(i,r)){var s=i[r];if(typeof s=="string")e.setAttribute(r,s);else if(s!=null)e[r]=s}t++}for(;t<arguments.length;t++)n(e,arguments[t]);return e}function n(e,t){if(typeof t=="string"){e.appendChild(document.createTextNode(t))}else if(t==null){}else if(t.nodeType!=null){e.appendChild(t)}else if(Array.isArray(t)){for(var i=0;i<t.length;i++)n(e,t[i])}else{throw new RangeError("Unsupported child node: "+t)}}}}]);
|