vendor: 15,793 bytes, lines 1-4
1// @codemirror/[email protected] downloaded from https://ga.jspm.io/npm:@codemirror/[email protected]/dist/index.js 2 3import{showDialog as e,EditorView as t,Decoration as n,ViewPlugin as r,showPanel as i,getPanel as a,runScopeHandlers as o}from"@codemirror/view";import{codePointAt as s,fromCodePoint as c,codePointSize as l,EditorSelection as u,Facet as d,combineConfig as f,CharCategory as p,EditorState as m,findClusterBreak as h,StateEffect as g,StateField as ee,RangeSetBuilder as te,Prec as ne}from"@codemirror/state";import _ from"crelt";const v=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e;class SearchCursor{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(v(e)):v,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 s(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=c(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=l(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}}typeof Symbol<`u`&&(SearchCursor.prototype[Symbol.iterator]=function(){return this});const y={from:-1,to:-1,match:/* @__PURE__ */ /.*/.exec(``),precise:!0},b=`gm`+(/x/.unicode==null?``:`u`);class RegExpCursor{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=y,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new MultilineRegExpCursor(e,t,n,r,i);this.re=new RegExp(t,b+(n!=null&&n.ignoreCase?`i`:``)),this.test=n==null?void 0:n.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=C(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 n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=C(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const x=/* @__PURE__ */ new WeakMap;class FlattenedDoc{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=x.get(e);if(!r||r.from>=n||r.to<=t){let r=new FlattenedDoc(t,e.sliceString(t,n));return x.set(e,r),r}if(r.from==t&&r.to==n)return r;let{text:i,from:a}=r;return a>t&&(i=e.sliceString(t,a)+i,a=t),r.to<n&&(i+=e.sliceString(r.to,n)),x.set(e,new FlattenedDoc(a,i)),new FlattenedDoc(t,i.slice(t-a,n-a))}}class MultilineRegExpCursor{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=y,this.matchPos=C(e,r),this.re=new RegExp(t,b+(n!=null&&n.ignoreCase?`i`:``)),this.test=n==null?void 0:n.test,this.flat=FlattenedDoc.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,n=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,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=C(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=FlattenedDoc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<`u`&&(RegExpCursor.prototype[Symbol.iterator]=MultilineRegExpCursor.prototype[Symbol.iterator]=function(){return this});function S(e){try{return new RegExp(e,b),!0}catch(e){return!1}}function C(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}const w=n=>{let{state:r}=n,i=String(r.doc.lineAt(n.state.selection.main.head).number),{close:a,result:o}=e(n,{label:r.phrase(`Go to line`),input:{type:`text`,name:`line`,value:i},focus:!0,submitLabel:r.phrase(`go`)});return o.then(e=>{let i=e&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.elements.line.value);if(!i){n.dispatch({effects:a});return}let o=r.doc.lineAt(r.selection.main.head),[,s,c,l,d]=i,f=l?+l.slice(1):0,p=c?+c:o.number;if(c&&d){let e=p/100;s&&(e=e*(s==`-`?-1:1)+o.number/r.doc.lines),p=Math.round(r.doc.lines*e)}else c&&s&&(p=p*(s==`-`?-1:1)+o.number);let m=r.doc.line(Math.max(1,Math.min(r.doc.lines,p))),h=u.cursor(m.from+Math.max(0,Math.min(f,m.length)));n.dispatch({effects:[a,t.scrollIntoView(h.from,{y:`center`})],selection:h})}),!0},re={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},T=/* @__PURE__ */ d.define({combine(e){return f(e,re,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function ie(e){let t=[ce,se];return e&&t.push(T.of(e)),t}const ae=/* @__PURE__ */ n.mark({class:`cm-selectionMatch`}),E=/* @__PURE__ */ n.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function D(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=p.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=p.Word)}function oe(e,t,n,r){return e(t.sliceDoc(n,n+1))==p.Word&&e(t.sliceDoc(r-1,r))==p.Word}const se=/* @__PURE__ */ r.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(T),{state:r}=e,i=r.selection;if(i.ranges.length>1)return n.none;let a=i.main,o,s=null;if(a.empty){if(!t.highlightWordAroundCursor)return n.none;let e=r.wordAt(a.head);if(!e)return n.none;s=r.charCategorizer(a.head),o=r.sliceDoc(e.from,e.to)}else{let e=a.to-a.from;if(e<t.minSelectionLength||e>200)return n.none;if(t.wholeWords){if(o=r.sliceDoc(a.from,a.to),s=r.charCategorizer(a.head),!(D(s,r,a.from,a.to)&&oe(s,r,a.from,a.to)))return n.none}else if(o=r.sliceDoc(a.from,a.to),!o)return n.none}let c=[];for(let i of e.visibleRanges){let e=new SearchCursor(r.doc,o,i.from,i.to);for(;!e.next().done;){let{from:i,to:o}=e.value;if((!s||D(s,r,i,o))&&(a.empty&&i<=a.from&&o>=a.to?c.push(E.range(i,o)):(i>=a.to||o<=a.from)&&c.push(ae.range(i,o)),c.length>t.maxMatches))return n.none}}return n.set(c)}},{decorations:e=>e.decorations}),ce=/* @__PURE__ */ t.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),le=({state:e,dispatch:t})=>{let{selection:n}=e,r=u.create(n.ranges.map(t=>e.wordAt(t.head)||u.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function ue(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new SearchCursor(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new SearchCursor(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}const O=({state:e,dispatch:n})=>{let{ranges:r}=e.selection;if(r.some(e=>e.from===e.to))return le({state:e,dispatch:n});let i=e.sliceDoc(r[0].from,r[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=i))return!1;let a=ue(e,i);return a?(n(e.update({selection:e.selection.addRange(u.range(a.from,a.to),!1),effects:t.scrollIntoView(a.to)})),!0):!1},k=/* @__PURE__ */ d.define({combine(e){return f(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new SearchPanel(e),scrollToMatch:e=>t.scrollIntoView(e)})}});function de(e){return e?[k.of(e),$]:$}class SearchQuery{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||S(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`?` 4`:t==`r`?`\r`: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 RegExpQuery(this):new StringQuery(this)}getCursor(e,t=0,n){let r=e.doc?e:m.create({doc:e});return n==null&&(n=r.doc.length),this.regexp?j(this,r,t,n):A(this,r,t,n)}}class QueryType{constructor(e){this.spec=e}}function fe(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function A(e,t,n,r){let i;return e.wholeWord&&(i=pe(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=fe(e.test,t,i)),new SearchCursor(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function pe(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(M(i,n-a))!=p.Word||t(N(i,n-a))!=p.Word)&&(t(N(i,r-a))!=p.Word||t(M(i,r-a))!=p.Word))}class StringQuery extends QueryType{constructor(e){super(e)}nextMatch(e,t,n){let r=A(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=A(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=A(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=A(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=A(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}function me(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function j(e,t,n,r){let i;return e.wholeWord&&(i=he(t.charCategorizer(t.selection.main.head))),e.test&&(i=me(e.test,t,i)),new RegExpCursor(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function M(e,t){return e.slice(h(e,t,!1),t)}function N(e,t){return e.slice(t,h(e,t))}function he(e){return(t,n,r)=>!r[0].length||(e(M(r.input,r.index))!=p.Word||e(N(r.input,r.index))!=p.Word)&&(e(N(r.input,r.index+r[0].length))!=p.Word||e(M(r.input,r.index+r[0].length))!=p.Word)}class RegExpQuery extends QueryType{nextMatch(e,t,n){let r=j(this.spec,e,n,e.doc.length).next();return r.done&&(r=j(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=j(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=j(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=j(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}const P=/* @__PURE__ */ g.define(),F=/* @__PURE__ */ g.define(),I=/* @__PURE__ */ ee.define({create(e){return new SearchState(G(e).create(),null)},update(e,t){for(let n of t.effects)n.is(P)?e=new SearchState(n.value.create(),e.panel):n.is(F)&&(e=new SearchState(e.query,n.value?W:null));return e},provide:e=>i.from(e,e=>e.panel)});function ge(e){let t=e.field(I,!1);return t?t.query.spec:G(e)}function _e(e){var t;return((t=e.field(I,!1))==null?void 0:t.panel)!=null}class SearchState{constructor(e,t){this.query=e,this.panel=t}}const ve=/* @__PURE__ */ n.mark({class:`cm-searchMatch`}),ye=/* @__PURE__ */ n.mark({class:`cm-searchMatch cm-searchMatch-selected`}),be=/* @__PURE__ */ r.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(I))}update(e){let t=e.state.field(I);(t!=e.startState.field(I)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return n.none;let{view:r}=this,i=new te;for(let t=0,n=r.visibleRanges,a=n.length;t<a;t++){let{from:o,to:s}=n[t];for(;t<a-1&&s>n[t+1].from-500;)s=n[++t].to;e.highlight(r.state,o,s,(e,t)=>{let n=r.state.selection.ranges.some(n=>n.from==e&&n.to==t);i.add(e,t,n?ye:ve)})}return i.finish()}},{decorations:e=>e.decorations});function L(e){return t=>{let n=t.state.field(I,!1);return n&&n.query.spec.valid?e(t,n):J(t)}}const R=/* @__PURE__ */ L((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=u.single(r.from,r.to),a=e.state.facet(k);return e.dispatch({selection:i,effects:[Q(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),q(e),!0}),z=/* @__PURE__ */ L((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=u.single(i.from,i.to),o=e.state.facet(k);return e.dispatch({selection:a,effects:[Q(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),q(e),!0}),B=/* @__PURE__ */ L((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:u.create(n.map(e=>u.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),V=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new SearchCursor(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(u.range(t.value.from,t.value.to))}return t(e.update({selection:u.create(a,o),userEvent:`select.search.matches`})),!0},H=/* @__PURE__ */ L((e,{query:n})=>{let{state:r}=e,{from:i,to:a}=r.selection.main;if(r.readOnly)return!1;let o=n.nextMatch(r,i,i);if(!o)return!1;let s=o,c=[],l,d,f=[];s.precise?s.from==i&&s.to==a&&(d=r.toText(n.getReplacement(s)),c.push({from:s.from,to:s.to,insert:d}),s=n.nextMatch(r,s.from,s.to),f.push(t.announce.of(r.phrase(`replaced match on line $`,r.doc.lineAt(i).number)+`.`))):s=n.nextMatch(r,s.from,s.to);let p=e.state.changes(c);
4return s&&(l=u.single(s.from,s.to).map(p),f.push(Q(e,s)),f.push(r.facet(k).scrollToMatch(l.main,e))),e.dispatch({changes:p,selection:l,effects:f,userEvent:`input.replace`}),!0}),U=/* @__PURE__ */ L((e,{query:n})=>{if(e.state.readOnly)return!1;let r=[];for(let t of n.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=t;a&&r.push({from:e,to:i,insert:n.getReplacement(t)})}if(!r.length)return!1;let i=e.state.phrase(`replaced $ matches`,r.length)+`.`;return e.dispatch({changes:r,effects:t.announce.of(i),userEvent:`input.replace.all`}),!0});function W(e){return e.state.facet(k).createPanel(e)}function G(e,t){var n,r,i,a,o;let s=e.selection.main,c=s.empty||s.to>s.from+100?``:e.sliceDoc(s.from,s.to);if(t&&!c)return t;let l=e.facet(k);return new SearchQuery({search:((n=t==null?void 0:t.literal)==null?l.literal:n)?c:c.replace(/\n/g,`\\n`),caseSensitive:(r=t==null?void 0:t.caseSensitive)==null?l.caseSensitive:r,literal:(i=t==null?void 0:t.literal)==null?l.literal:i,regexp:(a=t==null?void 0:t.regexp)==null?l.regexp:a,wholeWord:(o=t==null?void 0:t.wholeWord)==null?l.wholeWord:o})}function K(e){let t=a(e,W);return t&&t.dom.querySelector(`[main-field]`)}function q(e){let t=K(e);t&&t==e.root.activeElement&&t.select()}const J=e=>{let t=e.state.field(I,!1);if(t&&t.panel){let n=K(e);if(n&&n!=e.root.activeElement){let r=G(e.state,t.query.spec);r.valid&&e.dispatch({effects:P.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[F.of(!0),t?P.of(G(e.state,t.query.spec)):g.appendConfig.of($)]});return!0},Y=e=>{let t=e.state.field(I,!1);if(!t||!t.panel)return!1;let n=a(e,W);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:F.of(!1)}),!0},xe=[{key:`Mod-f`,run:J,scope:`editor search-panel`},{key:`F3`,run:R,shift:z,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:R,shift:z,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:Y,scope:`editor search-panel`}
vendor: 1,507 bytes, line 4
4,{key:`Mod-Shift-l`,run:V},{key:`Mod-Alt-g`,run:w},{key:`Mod-d`,run:O,preventDefault:!0}];class SearchPanel{constructor(e){this.view=e;let t=this.query=e.state.field(I).query.spec;this.commit=this.commit.bind(this),this.searchField=_(`input`,{value:t.search,placeholder:X(e,`Find`),"aria-label":X(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=_(`input`,{value:t.replace,placeholder:X(e,`Replace`),"aria-label":X(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=_(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=_(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=_(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return _(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=_(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>R(e),[X(e,`next`)]),n(`prev`,()=>z(e),[X(e,`previous`)]),n(`select`,()=>B(e),[X(e,`all`)]),_(`label`,null,[this.caseField,X(e,`match case`)]),_(`label`,null,[this.reField,X(e,`regexp`)]),_(`label`,null,[this.wordField,X(e,`by word`)]),...e.state.readOnly?[]:[_(`br`),this.replaceField,n(`replace`,()=>H(e),[X(e,`replace`)]),n(`replaceAll`,()=>U(e),[X(e,`replace all`)])],_(`button`,{name:`close`,onclick:()=>
4Y(e),"aria-label":X(e,`close`),type:`button`},[`Ã`])])}commit(){let e=new SearchQuery({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:P.of(e)}))}keydown(e){o(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?z:R)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),H(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(P)&&!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(k).top}}function X(e,t){return e.state.phrase(t)}const Se=30,Z=/[\s\.,:;?!]/;function Q(e,{from:n,to:r}){let i=e.state.doc.lineAt(n),a=e.state.doc.lineAt(r).to,o=Math.max(i.from,n-30),s=Math.min(a,r+30),c=e.state.sliceDoc(o,s);if(o!=i.from){for(let e=0;e<30;e++)if(!Z.test(c[e+1])&&Z.test(c[e])){c=c.slice(e);break}}if(s!=a){for(let e=c.length-1;e>c.length-30;e--)if(!Z.test(c[e-1])&&Z.test(c[e])){c=c.slice(0,e);break}}return t.announce.of(`${e.state.phrase(`current match`)}. ${c} ${e.state.phrase(`on line`)} ${i.number}.`)}const Ce=/* @__PURE__ */ t.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`}}),$=[I,/* @__PURE__ */ ne.low(be),Ce];export{RegExpCursor,SearchCursor,SearchQuery,Y as closeSearchPanel,R as findNext,z as findPrevious,ge as getSearchQuery,w as gotoLine,ie as highlightSelectionMatches,J as openSearchPanel,U as replaceAll,H as replaceNext,de as search,xe as searchKeymap,_e as searchPanelOpen,B as selectMatches,O as selectNextOccurrence,V as selectSelectionMatches,P as setSearchQuery}; 5
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.