vendor: 15,934 bytes, lines 1-4
1// @codemirror/[email protected] downloaded from https://ga.jspm.io/npm:@codemirror/[email protected]/dist/index.js 2 3import{getDialog as e,showDialog as t,EditorView as n,Decoration as r,ViewPlugin as i,showPanel as a,getPanel as o,runScopeHandlers as s}from"@codemirror/view";import{codePointAt as c,fromCodePoint as l,codePointSize as u,EditorSelection as d,Facet as f,combineConfig as p,CharCategory as m,EditorState as h,findClusterBreak as g,StateEffect as _,StateField as ee,RangeSetBuilder as te,Prec as ne}from"@codemirror/state";import v from"crelt";const y=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(y(e)):y,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 c(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=l(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=u(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 b={from:-1,to:-1,match:/* @__PURE__ */ /.*/.exec(``),precise:!0},x=`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=b,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new MultilineRegExpCursor(e,t,n,r,i);this.re=new RegExp(t,x+(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 S=/* @__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=S.get(e);if(!r||r.from>=n||r.to<=t){let r=new FlattenedDoc(t,e.sliceString(t,n));return S.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)),S.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=b,this.matchPos=C(e,r),this.re=new RegExp(t,x+(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 re(e){try{return new RegExp(e,x),!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=r=>{let i=e(r,`cm-goto-line`);if(i){let e=i.dom.querySelector(`input[type=text]`);return e&&e.select(),!0}let{state:a}=r,o=String(a.doc.lineAt(r.state.selection.main.head).number),{close:s,result:c}=t(r,{class:`cm-goto-line`,label:a.phrase(`Go to line`),input:{type:`text`,name:`line`,value:o},focus:!0,submitLabel:a.phrase(`go`)});return c.then(e=>{let t=e&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.elements.line.value);if(!t){r.dispatch({effects:s});return}let i=a.doc.lineAt(a.selection.main.head),[,o,c,l,u]=t,f=l?+l.slice(1):0,p=c?+c:i.number;if(c&&u){let e=p/100;o&&(e=e*(o==`-`?-1:1)+i.number/a.doc.lines),p=Math.round(a.doc.lines*e)}else c&&o&&(p=p*(o==`-`?-1:1)+i.number);let m=a.doc.line(Math.max(1,Math.min(a.doc.lines,p))),h=d.cursor(m.from+Math.max(0,Math.min(f,m.length)));r.dispatch({effects:[s,n.scrollIntoView(h.from,{y:`center`})],selection:h})}),!0},ie={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},T=/* @__PURE__ */ f.define({combine(e){return p(e,ie,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function ae(e){let t=[ue,le];return e&&t.push(T.of(e)),t}const oe=/* @__PURE__ */ r.mark({class:`cm-selectionMatch`}),se=/* @__PURE__ */ r.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function E(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=m.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=m.Word)}function ce(e,t,n,r){return e(t.sliceDoc(n,n+1))==m.Word&&e(t.sliceDoc(r-1,r))==m.Word}const le=/* @__PURE__ */ i.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:n}=e,i=n.selection;if(i.ranges.length>1)return r.none;let a=i.main,o,s=null;if(a.empty){if(!t.highlightWordAroundCursor)return r.none;let e=n.wordAt(a.head);if(!e)return r.none;s=n.charCategorizer(a.head),o=n.sliceDoc(e.from,e.to)}else{let e=a.to-a.from;if(e<t.minSelectionLength||e>200)return r.none;if(t.wholeWords){if(o=n.sliceDoc(a.from,a.to),s=n.charCategorizer(a.head),!(E(s,n,a.from,a.to)&&ce(s,n,a.from,a.to)))return r.none}else if(o=n.sliceDoc(a.from,a.to),!o)return r.none}let c=[];for(let i of e.visibleRanges){let e=new SearchCursor(n.doc,o,i.from,i.to);for(;!e.next().done;){let{from:i,to:o}=e.value;if((!s||E(s,n,i,o))&&(a.empty&&i<=a.from&&o>=a.to?c.push(se.range(i,o)):(i>=a.to||o<=a.from)&&c.push(oe.range(i,o)),c.length>t.maxMatches))return r.none}}return r.set(c)}},{decorations:e=>e.decorations}),ue=/* @__PURE__ */ n.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),de=({state:e,dispatch:t})=>{let{selection:n}=e,r=d.create(n.ranges.map(t=>e.wordAt(t.head)||d.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function fe(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 D=({state:e,dispatch:t})=>{let{ranges:r}=e.selection;if(r.some(e=>e.from===e.to))return de({state:e,dispatch:t});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=fe(e,i);return a?(t(e.update({selection:e.selection.addRange(d.range(a.from,a.to),!1),effects:n.scrollIntoView(a.to)})),!0):!1},O=/* @__PURE__ */ f.define({combine(e){return p(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new SearchPanel(e),scrollToMatch:e=>n.scrollIntoView(e)})}});function pe(e){return e?[O.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||re(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:h.create({doc:e});return n==null&&(n=r.doc.length),this.regexp?A(this,r,t,n):k(this,r,t,n)}}class QueryType{constructor(e){this.spec=e}}function me(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 k(e,t,n,r){let i;return e.wholeWord&&(i=he(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=me(e.test,t,i)),new SearchCursor(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function he(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(j(i,n-a))!=m.Word||t(M(i,n-a))!=m.Word)&&(t(M(i,r-a))!=m.Word||t(j(i,r-a))!=m.Word))}class StringQuery extends QueryType{constructor(e){super(e)}nextMatch(e,t,n){let r=k(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=k(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=k(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=k(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=k(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 ge(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function A(e,t,n,r){let i;return e.wholeWord&&(i=_e(t.charCategorizer(t.selection.main.head))),e.test&&(i=ge(e.test,t,i)),new RegExpCursor(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function j(e,t){return e.slice(g(e,t,!1),t)}function M(e,t){return e.slice(t,g(e,t))}function _e(e){return(t,n,r)=>!r[0].length||(e(j(r.input,r.index))!=m.Word||e(M(r.input,r.index))!=m.Word)&&(e(M(r.input,r.index+r[0].length))!=m.Word||e(j(r.input,r.index+r[0].length))!=m.Word)}class RegExpQuery extends QueryType{nextMatch(e,t,n){let r=A(this.spec,e,n,e.doc.length).next();return r.done&&(r=A(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=A(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=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-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}const N=/* @__PURE__ */ _.define(),P=/* @__PURE__ */ _.define(),F=/* @__PURE__ */ ee.define({create(e){return new SearchState(G(e).create(),null)},update(e,t){for(let n of t.effects)n.is(N)?e=new SearchState(n.value.create(),e.panel):n.is(P)&&(e=new SearchState(e.query,n.value?W:null));return e},provide:e=>a.from(e,e=>e.panel)});function ve(e){let t=e.field(F,!1);return t?t.query.spec:G(e)}function I(e){var t;return((t=e.field(F,!1))==null?void 0:t.panel)!=null}class SearchState{constructor(e,t){this.query=e,this.panel=t}}const ye=/* @__PURE__ */ r.mark({class:`cm-searchMatch`}),be=/* @__PURE__ */ r.mark({class:`cm-searchMatch cm-searchMatch-selected`}),xe=/* @__PURE__ */ i.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(F))}update(e){let t=e.state.field(F);(t!=e.startState.field(F)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return r.none;let{view:n}=this,i=new te;for(let t=0,r=n.visibleRanges,a=r.length;t<a;t++){let{from:o,to:s}=r[t];for(;t<a-1&&s>r[t+1].from-500;)s=r[++t].to;e.highlight(n.state,o,s,(e,t)=>{let r=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);i.add(e,t,r?be:ye)})}return i.finish()}},{decorations:e=>e.decorations});function L(e){return t=>{let n=t.state.field(F,!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=d.single(r.from,r.to),a=e.state.facet(O);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=d.single(i.from,i.to),o=e.state.facet(O);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:d.create(n.map(e=>d.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(d.range(t.value.from,t.value.to))}return t(e.update({selection:d.create(a,o),userEvent:`select.search.matches`})),!0},H=/* @__PURE__ */ L((e,{query:t})=>{let{state:r}=e,{from:i,to:a}=r.selection.main;if(r.readOnly)return!1;let o=t.nextMatch(r,i,i);if(!o)return!1;let s=o,c=[],l,u,f=[];s.precise?s.from==i&&s.to==a&&(u=r.toText(t.getReplacement(s)),c.push({from:s.from,to:s.to,insert:u}),s=t.nextMatch(r,s.from,s.to),f.push(n.announce.of(r.phrase(`replaced match on line $`,r.doc.lineAt(i).number)+`.`))):s=t.nextMatch(r,s.from,s.to);let p=e.state.changes(c);
4return s&&(l=d.single(s.from,s.to).map(p),f.push(Q(e,s)),f.push(r.facet(O).scrollToMatch(l.main,e))),e.dispatch({changes:p,selection:l,effects:f,userEvent:`input.replace`}),!0}),U=/* @__PURE__ */ L((e,{query:t})=>{if(e.state.readOnly)return!1;let r=[];for(let n of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=n;a&&r.push({from:e,to:i,insert:t.getReplacement(n)})}if(!r.length)return!1;let i=e.state.phrase(`replaced $ matches`,r.length)+`.`;return e.dispatch({changes:r,effects:n.announce.of(i),userEvent:`input.replace.all`}),!0});function W(e){return e.state.facet(O).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(O);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=o(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(F,!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:N.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[P.of(!0),t?N.of(G(e.state,t.query.spec)):_.appendConfig.of($)]});return!0},Y=e=>{let t=e.state.field(F,!1);if(!t||!t.panel)return!1;let n=o(e,W);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:P.of(!1)}),!0},Se=[{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:D,preventDefault:!0}];class SearchPanel{constructor(e){this.view=e;let t=this.query=e.state.field(F).query.spec;this.commit=this.commit.bind(this),this.searchField=v(`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=v(`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=v(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=v(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=v(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return v(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=v(`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`)]),v(`label`,null,[this.caseField,X(e,`match case`)]),v(`label`,null,[this.reField,X(e,`regexp`)]),v(`label`,null,[this.wordField,X(e,`by word`)]),...e.state.readOnly?[]:[v(`br`),this.replaceField,n(`replace`,()=>H(e),[X(e,`replace`)]),n(`replaceAll`,()=>U(e),[X(e,`replace all`)])],v(`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:N.of(e)}))}keydown(e){s(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(N)&&!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(O).top}}function X(e,t){return e.state.phrase(t)}const Ce=30,Z=/[\s\.,:;?!]/;function Q(e,{from:t,to:r}){let i=e.state.doc.lineAt(t),a=e.state.doc.lineAt(r).to,o=Math.max(i.from,t-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 n.announce.of(`${e.state.phrase(`current match`)}. ${c} ${e.state.phrase(`on line`)} ${i.number}.`)}const we=/* @__PURE__ */ n.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`}}),$=[F,/* @__PURE__ */ ne.low(xe),we];export{RegExpCursor,SearchCursor,SearchQuery,Y as closeSearchPanel,R as findNext,z as findPrevious,ve as getSearchQuery,w as gotoLine,ae as highlightSelectionMatches,J as openSearchPanel,U as replaceAll,H as replaceNext,pe as search,Se as searchKeymap,I as searchPanelOpen,B as selectMatches,D as selectNextOccurrence,V as selectSelectionMatches,N 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.