@bhsd/codemirror-mediawiki 3.2.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -23
- package/dist/codemirror.d.ts +7 -0
- package/dist/codemirror.js +31 -2
- package/dist/fold.d.ts +2 -1
- package/dist/fold.js +13 -1
- package/dist/hover.d.ts +2 -1
- package/dist/hover.js +40 -18
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -3
- package/dist/inlay.js +8 -0
- package/dist/lintsource.js +2 -2
- package/dist/main.min.js +29 -25
- package/dist/mediawiki.js +145 -1
- package/dist/mw.min.js +32 -28
- package/dist/ref.js +9 -0
- package/dist/statusBar.js +134 -56
- package/dist/theme.d.ts +8 -0
- package/dist/theme.js +108 -0
- package/dist/wiki.min.js +31 -27
- package/i18n/en.json +3 -1
- package/i18n/zh-hans.json +3 -1
- package/i18n/zh-hant.json +3 -1
- package/package.json +7 -7
- package/dist/demo.min.js +0 -37
- package/mediawiki.css +0 -6
package/dist/demo.min.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
var jd=Object.create;var qr=Object.defineProperty;var qd=Object.getOwnPropertyDescriptor;var Cl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Yt=t=>{throw TypeError(t)};var Kd=(t,e,i)=>e in t?qr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var Sl=(t,e)=>qr(t,"name",{value:e,configurable:!0});var Al=t=>{var e;return[,,,jd((e=t==null?void 0:t[Cl("metadata")])!=null?e:null)]},Tl=["class","method","getter","setter","accessor","field","value","get","set"],Ai=t=>t!==void 0&&typeof t!="function"?Yt("Function expected"):t,Ud=(t,e,i,n,r)=>({kind:Tl[t],name:e,metadata:n,addInitializer:s=>i._?Yt("Already initialized"):r.push(Ai(s||null))}),Kr=(t,e)=>Kd(e,Cl("metadata"),t[3]),Ml=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)e&1?s[r].call(i):n=s[r].call(i,n);return n},j=(t,e,i,n,r,s)=>{var o,l,a,c,h,f=e&7,u=!!(e&8),d=!!(e&16),p=f>3?t.length+1:f?u?1:2:0,g=Tl[f+5],m=f>3&&(t[p-1]=[]),v=t[p]||(t[p]=[]),y=f&&(!d&&!u&&(r=r.prototype),f<5&&(f>3||!d)&&qd(f<4?r:{get[i](){return b(this,s)},set[i](k){return $e(this,s,k)}},i));f?d&&f<4&&Sl(s,(f>2?"set ":f>1?"get ":"")+i):Sl(r,i);for(var S=n.length-1;S>=0;S--)c=Ud(f,i,a={},t[3],v),f&&(c.static=u,c.private=d,h=c.access={has:d?k=>Gd(r,k):k=>i in k},f^3&&(h.get=d?k=>(f^1?b:ce)(k,r,f^4?s:y.get):k=>k[i]),f>2&&(h.set=d?(k,E)=>$e(k,r,E,f^4?s:y.set):(k,E)=>k[i]=E)),l=(0,n[S])(f?f<4?d?s:y[g]:f>4?void 0:{get:y.get,set:y.set}:r,c),a._=1,f^4||l===void 0?Ai(l)&&(f>4?m.unshift(l):f?d?s=l:y[g]=l:r=l):typeof l!="object"||l===null?Yt("Object expected"):(Ai(o=l.get)&&(y.get=o),Ai(o=l.set)&&(y.set=o),Ai(o=l.init)&&m.unshift(o));return f||Kr(t,r),y&&qr(r,i,y),d?f^4?s:y:r};var Ur=(t,e,i)=>e.has(t)||Yt("Cannot "+i),Gd=(t,e)=>Object(e)!==e?Yt('Cannot use the "in" operator on this value'):t.has(e),b=(t,e,i)=>(Ur(t,e,"read from private field"),i?i.call(t):e.get(t)),ue=(t,e,i)=>e.has(t)?Yt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),$e=(t,e,i,n)=>(Ur(t,e,"write to private field"),n?n.call(t,i):e.set(t,i),i),ce=(t,e,i)=>(Ur(t,e,"access private method"),i);var Ru,Nu,Iu,Fu,Hu,Vu,Wu,$u,zu,_u,ju,qu,Ku,Uu,Gu,Ju,Yu,Xu,Qu,Zu,ed,td,id,nd,rd,sd,od,ld,ad,hd,_,z,Ut,bl,Wd,cd,Ve,mn,Kt,vn,yn,bn,wn,xn,kn,N,We,Pt,Rt,Ci,Sn,he,wl,mt,jr,_d,fd,Jd=Object.create,Dl=Object.defineProperty,Yd=Object.getOwnPropertyDescriptor,Ol=Object.getOwnPropertyNames,Xd=Object.getPrototypeOf,Qd=Object.prototype.hasOwnProperty,Zd=(t,e)=>function(){return e||(0,t[Ol(t)[0]])((e={exports:{}}).exports,e),e.exports},ep=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ol(e))!Qd.call(t,r)&&r!==i&&Dl(t,r,{get:()=>e[r],enumerable:!(n=Yd(e,r))||n.enumerable});return t},tp=(t,e,i)=>(i=t!=null?Jd(Xd(t)):{},ep(e||!t||!t.__esModule?Dl(i,"default",{value:t,enumerable:!0}):i,t)),ip=Zd({"../node_modules/stylelint-config-recommended/index.js"(t,e){"use strict";e.exports={rules:{"annotation-no-unknown":!0,"at-rule-descriptor-no-unknown":!0,"at-rule-descriptor-value-no-unknown":!0,"at-rule-no-deprecated":!0,"at-rule-no-unknown":!0,"at-rule-prelude-no-invalid":[!0,{ignoreAtRules:["media"]}],"block-no-empty":!0,"comment-no-empty":!0,"custom-property-no-missing-var-function":!0,"declaration-block-no-duplicate-custom-properties":!0,"declaration-block-no-duplicate-properties":[!0,{ignore:["consecutive-duplicates-with-different-syntaxes"]}],"declaration-block-no-shorthand-property-overrides":!0,"declaration-property-value-keyword-no-deprecated":!0,"declaration-property-value-no-unknown":!0,"font-family-no-duplicate-names":!0,"font-family-no-missing-generic-family-keyword":!0,"function-calc-no-unspaced-operator":!0,"keyframe-block-no-duplicate-selectors":!0,"keyframe-declaration-no-important":!0,"media-feature-name-no-unknown":!0,"media-feature-name-value-no-unknown":!0,"media-query-no-invalid":!0,"media-type-no-deprecated":!0,"named-grid-areas-no-invalid":!0,"nesting-selector-no-missing-scoping-root":!0,"no-descending-specificity":!0,"no-duplicate-at-import-rules":!0,"no-duplicate-selectors":!0,"no-empty-source":!0,"no-invalid-double-slash-comments":!0,"no-invalid-position-at-import-rule":!0,"no-invalid-position-declaration":!0,"no-irregular-whitespace":!0,"property-no-deprecated":!0,"property-no-unknown":!0,"selector-anb-no-unmatchable":!0,"selector-pseudo-class-no-unknown":!0,"selector-pseudo-element-no-unknown":!0,"selector-type-no-unknown":[!0,{ignore:["custom-elements"]}],"string-no-newline":[!0,{ignore:["at-rule-preludes","declaration-values"]}],"syntax-string-no-invalid":!0}}}}),Gr=[],El=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,i=0;e<t.length;e++)(e%2?El:Gr).push(i=i+t[e])})();function np(t){if(t<768)return!1;for(let e=0,i=Gr.length;;){let n=e+i>>1;if(t<Gr[n])i=n;else if(t>=El[n])e=n+1;else return!0;if(e==i)return!1}}function Ll(t){return t>=127462&&t<=127487}var Bl=8205;function rp(t,e,i=!0,n=!0){return(i?Pl:sp)(t,e,n)}function Pl(t,e,i){if(e==t.length)return e;e&&Rl(t.charCodeAt(e))&&Nl(t.charCodeAt(e-1))&&e--;let n=Jr(t,e);for(e+=Il(n);e<t.length;){let r=Jr(t,e);if(n==Bl||r==Bl||i&&np(r))e+=Il(r),n=r;else if(Ll(r)){let s=0,o=e-2;for(;o>=0&&Ll(Jr(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function sp(t,e,i){for(;e>0;){let n=Pl(t,e-2,i);if(n<e)return n;e--}return 0}function Jr(t,e){let i=t.charCodeAt(e);if(!Nl(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return Rl(n)?(i-55296<<10)+(n-56320)+65536:i}function Rl(t){return t>=56320&&t<57344}function Nl(t){return t>=55296&&t<56320}function Il(t){return t<65536?1:2}var q=class ud{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,i,n){[e,i]=Xt(this,e,i);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(i,this.length,r,1),An.from(r,this.length-(i-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,i=this.length){[e,i]=Xt(this,e,i);let n=[];return this.decompose(e,i,n,0),An.from(n,i-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let i=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new Ti(this),s=new Ti(e);for(let o=i,l=i;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=n)return!0}}iter(e=1){return new Ti(this,e)}iterRange(e,i=this.length){return new Hl(this,e,i)}iterLines(e,i){let n;if(e==null)n=this.iter();else{i==null&&(i=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,i==this.lines+1?this.length:i<=1?0:this.line(i-1).to))}return new Vl(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?ud.empty:e.length<=32?new ze(e):An.from(ze.split(e,[]))}},ze=class ht extends q{constructor(e,i=op(e)){super(),this.text=e,this.length=i}get lines(){return this.text.length}get children(){return null}lineInner(e,i,n,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((i?n:l)>=e)return new lp(r,l,n,o);r=l+1,n++}}decompose(e,i,n,r){let s=e<=0&&i>=this.length?this:new ht(Fl(this.text,e,i),Math.min(i,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),l=Tn(s.text,o.text.slice(),0,s.length);if(l.length<=32)n.push(new ht(l,o.length+s.length));else{let a=l.length>>1;n.push(new ht(l.slice(0,a)),new ht(l.slice(a)))}}else n.push(s)}replace(e,i,n){if(!(n instanceof ht))return super.replace(e,i,n);[e,i]=Xt(this,e,i);let r=Tn(this.text,Tn(n.text,Fl(this.text,0,e)),i),s=this.length+n.length-(i-e);return r.length<=32?new ht(r,s):An.from(ht.split(r,[]),s)}sliceString(e,i=this.length,n=`
|
|
2
|
-
`){[e,i]=Xt(this,e,i);let r="";for(let s=0,o=0;s<=i&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=n),e<a&&i>s&&(r+=l.slice(Math.max(0,e-s),i-s)),s=a+1}return r}flatten(e){for(let i of this.text)e.push(i)}scanIdentical(){return 0}static split(e,i){let n=[],r=-1;for(let s of e)n.push(s),r+=s.length+1,n.length==32&&(i.push(new ht(n,r)),n=[],r=-1);return r>-1&&i.push(new ht(n,r)),i}},An=class Si extends q{constructor(e,i){super(),this.children=e,this.length=i,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,i,n,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=n+o.lines-1;if((i?a:l)>=e)return o.lineInner(e,i,n,r);r=l+1,n=a+1}}decompose(e,i,n,r){for(let s=0,o=0;o<=i&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&i>=o){let c=r&((o<=e?1:0)|(a>=i?2:0));o>=e&&a<=i&&!c?n.push(l):l.decompose(e-o,i-o,n,c)}o=a+1}}replace(e,i,n){if([e,i]=Xt(this,e,i),n.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&i<=l){let a=o.replace(e-s,i-s,n),c=this.lines-o.lines+a.lines;if(a.lines<c>>4&&a.lines>c>>6){let h=this.children.slice();return h[r]=a,new Si(h,this.length-(i-e)+n.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,i,n)}sliceString(e,i=this.length,n=`
|
|
3
|
-
`){[e,i]=Xt(this,e,i);let r="";for(let s=0,o=0;s<this.children.length&&o<=i;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=n),e<a&&i>o&&(r+=l.sliceString(e-o,i-o,n)),o=a+1}return r}flatten(e){for(let i of this.children)i.flatten(e)}scanIdentical(e,i){if(!(e instanceof Si))return 0;let n=0,[r,s,o,l]=i>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=i,s+=i){if(r==o||s==l)return n;let a=this.children[r],c=e.children[s];if(a!=c)return n+a.scanIdentical(c,i);n+=a.length+1}}static from(e,i=e.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new ze(d,i)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,l=[],a=0,c=-1,h=[];function f(d){let p;if(d.lines>s&&d instanceof Si)for(let g of d.children)f(g);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof ze&&a&&(p=h[h.length-1])instanceof ze&&d.lines+p.lines<=32?(a+=d.lines,c+=d.length+1,h[h.length-1]=new ze(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>r&&u(),a+=d.lines,c+=d.length+1,h.push(d))}function u(){a!=0&&(l.push(h.length==1?h[0]:Si.from(h,c)),c=-1,a=h.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new Si(l,i)}};q.empty=new ze([""],0);function op(t){let e=-1;for(let i of t)e+=i.length+1;return e}function Tn(t,e,i=0,n=1e9){for(let r=0,s=0,o=!0;s<t.length&&r<=n;s++){let l=t[s],a=r+l.length;a>=i&&(a>n&&(l=l.slice(0,n-r)),r<i&&(l=l.slice(i-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function Fl(t,e,i){return Tn(t,[""],e,i)}var Ti=class{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof ze?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],s=r>>1,o=n instanceof ze?n.text.length:n.children.length;if(s==(e>0?o:0)){if(i==0)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(e>0?0:1)){if(this.offsets[i]+=e,t==0)return this.lineBreak=!0,this.value=`
|
|
4
|
-
`,this;t--}else if(n instanceof ze){let l=n.text[s+(e<0?-1:0)];if(this.offsets[i]+=e,l.length>Math.max(0,t))return this.value=t==0?l:e>0?l.slice(t):l.slice(0,l.length-t),this;t-=l.length}else{let l=n.children[s+(e<0?-1:0)];t>l.length?(t-=l.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(l),this.offsets.push(e>0?1:(l instanceof ze?l.text.length:l.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}},Hl=class{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new Ti(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Vl=class{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol!="undefined"&&(q.prototype[Symbol.iterator]=function(){return this.iter()},Ti.prototype[Symbol.iterator]=Hl.prototype[Symbol.iterator]=Vl.prototype[Symbol.iterator]=function(){return this});var lp=class{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}};function Xt(t,e,i){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,i))]}function pe(t,e,i=!0,n=!0){return rp(t,e,i,n)}function ap(t){return t>=56320&&t<57344}function hp(t){return t>=55296&&t<56320}function Wl(t,e){let i=t.charCodeAt(e);if(!hp(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return ap(n)?(i-55296<<10)+(n-56320)+65536:i}function cp(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function $l(t){return t<65536?1:2}var Yr=/\r\n?|\n/,we=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(we||(we={})),Qt=class Hr{constructor(e){this.sections=e}get length(){let e=0;for(let i=0;i<this.sections.length;i+=2)e+=this.sections[i];return e}get newLength(){let e=0;for(let i=0;i<this.sections.length;i+=2){let n=this.sections[i+1];e+=n<0?this.sections[i]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let i=0,n=0,r=0;i<this.sections.length;){let s=this.sections[i++],o=this.sections[i++];o<0?(e(n,r,s),r+=s):r+=o,n+=s}}iterChangedRanges(e,i=!1){Xr(this,e,i)}get invertedDesc(){let e=[];for(let i=0;i<this.sections.length;){let n=this.sections[i++],r=this.sections[i++];r<0?e.push(n,r):e.push(r,n)}return new Hr(e)}composeDesc(e){return this.empty?e:e.empty?this:zl(this,e)}mapDesc(e,i=!1){return e.empty?this:Qr(this,e,i)}mapPos(e,i=-1,n=we.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],c=r+l;if(a<0){if(c>e)return s+(e-r);s+=l}else{if(n!=we.Simple&&c>=e&&(n==we.TrackDel&&r<e&&c>e||n==we.TrackBefore&&r<e||n==we.TrackAfter&&c>e))return null;if(c>e||c==e&&i<0&&!l)return e==r||i<0?s:s+a;s+=a}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,i=e){for(let n=0,r=0;n<this.sections.length&&r<=i;){let s=this.sections[n++],o=this.sections[n++],l=r+s;if(o>=0&&r<=i&&l>=e)return r<e&&l>i?"cover":!0;r=l}return!1}toString(){let e="";for(let i=0;i<this.sections.length;){let n=this.sections[i++],r=this.sections[i++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(i=>typeof i!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Hr(e)}static create(e){return new Hr(e)}},_e=class Bt extends Qt{constructor(e,i){super(e),this.inserted=i}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Xr(this,(i,n,r,s,o)=>e=e.replace(r,r+(n-i),o),!1),e}mapDesc(e,i=!1){return Qr(this,e,i,!0)}invert(e){let i=this.sections.slice(),n=[];for(let r=0,s=0;r<i.length;r+=2){let o=i[r],l=i[r+1];if(l>=0){i[r]=l,i[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(q.empty);n.push(o?e.slice(s,s+o):q.empty)}s+=o}return new Bt(i,n)}compose(e){return this.empty?e:e.empty?this:zl(this,e,!0)}map(e,i=!1){return e.empty?this:Qr(this,e,i,!0)}iterChanges(e,i=!1){Xr(this,e,i)}get desc(){return Qt.create(this.sections)}filter(e){let i=[],n=[],r=[],s=new Mi(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let h=Math.min(s.len,a-l);ve(r,h,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;ve(i,h,f),f>0&&vt(n,i,s.text),s.forward(h),l+=h}let c=e[o++];for(;l<c;){if(s.done)break e;let h=Math.min(s.len,c-l);ve(i,h,-1),ve(r,h,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(h),l+=h}}return{changes:new Bt(i,n),filtered:Qt.create(r)}}toJSON(){let e=[];for(let i=0;i<this.sections.length;i+=2){let n=this.sections[i],r=this.sections[i+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[i>>1].toJSON()))}return e}static of(e,i,n){let r=[],s=[],o=0,l=null;function a(h=!1){if(!h&&!r.length)return;o<i&&ve(r,i-o,-1);let f=new Bt(r,s);l=l?l.compose(f.map(l)):f,r=[],s=[],o=0}function c(h){if(Array.isArray(h))for(let f of h)c(f);else if(h instanceof Bt){if(h.length!=i)throw new RangeError(`Mismatched change set length (got ${h.length}, expected ${i})`);a(),l=l?l.compose(h.map(l)):h}else{let{from:f,to:u=f,insert:d}=h;if(f>u||f<0||u>i)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${i})`);let p=d?typeof d=="string"?q.of(d.split(n||Yr)):d:q.empty,g=p.length;if(f==u&&g==0)return;f<o&&a(),f>o&&ve(r,f-o,-1),ve(r,u-f,g),vt(s,r,p),o=u}}return c(e),a(!l),l}static empty(e){return new Bt(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let i=[],n=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")i.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)i.push(s[0],0);else{for(;n.length<r;)n.push(q.empty);n[r]=q.of(s.slice(1)),i.push(s[0],n[r].length)}}}return new Bt(i,n)}static createSet(e,i){return new Bt(e,i)}};function ve(t,e,i,n=!1){if(e==0&&i<=0)return;let r=t.length-2;r>=0&&i<=0&&i==t[r+1]?t[r]+=e:r>=0&&e==0&&t[r]==0?t[r+1]+=i:n?(t[r]+=e,t[r+1]+=i):t.push(e,i)}function vt(t,e,i){if(i.length==0)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(q.empty);t.push(i)}}function Xr(t,e,i){let n=t.inserted;for(let r=0,s=0,o=0;o<t.sections.length;){let l=t.sections[o++],a=t.sections[o++];if(a<0)r+=l,s+=l;else{let c=r,h=s,f=q.empty;for(;c+=l,h+=a,a&&n&&(f=f.append(n[o-2>>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(r,c,s,h,f),r=c,s=h}}}function Qr(t,e,i,n=!1){let r=[],s=n?[]:null,o=new Mi(t),l=new Mi(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let c=Math.min(o.len,l.len);ve(r,c,-1),o.forward(c),l.forward(c)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!i))){let c=l.len;for(ve(r,l.ins,-1);c;){let h=Math.min(o.len,c);o.ins>=0&&a<o.i&&o.len<=h&&(ve(r,0,o.ins),s&&vt(s,r,o.text),a=o.i),o.forward(h),c-=h}l.next()}else if(o.ins>=0){let c=0,h=o.len;for(;h;)if(l.ins==-1){let f=Math.min(h,l.len);c+=f,h-=f,l.forward(f)}else if(l.ins==0&&l.len<h)h-=l.len,l.next();else break;ve(r,c,a<o.i?o.ins:0),s&&a<o.i&&vt(s,r,o.text),a=o.i,o.forward(o.len-h)}else{if(o.done&&l.done)return s?_e.createSet(r,s):Qt.create(r);throw new Error("Mismatched change set lengths")}}}function zl(t,e,i=!1){let n=[],r=i?[]:null,s=new Mi(t),o=new Mi(e);for(let l=!1;;){if(s.done&&o.done)return r?_e.createSet(n,r):Qt.create(n);if(s.ins==0)ve(n,s.len,0,l),s.next();else if(o.len==0&&!o.done)ve(n,0,o.ins,l),r&&vt(r,n,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),c=n.length;if(s.ins==-1){let h=o.ins==-1?-1:o.off?0:o.ins;ve(n,a,h,l),r&&h&&vt(r,n,o.text)}else o.ins==-1?(ve(n,s.off?0:s.len,a,l),r&&vt(r,n,s.textBit(a))):(ve(n,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&vt(r,n,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||n.length>c),s.forward2(a),o.forward(a)}}}}var Mi=class{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?q.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?q.empty:e[i].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}},Di=class rl{constructor(e,i,n){this.from=e,this.to=i,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,i=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,i):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new rl(n,r,this.flags)}extend(e,i=e){if(e<=this.anchor&&i>=this.anchor)return w.range(e,i);let n=Math.abs(e-this.anchor)>Math.abs(i-this.anchor)?e:i;return w.range(this.anchor,n)}eq(e,i=!1){return this.anchor==e.anchor&&this.head==e.head&&(!i||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return w.range(e.anchor,e.head)}static create(e,i,n){return new rl(e,i,n)}},w=class Me{constructor(e,i){this.ranges=e,this.mainIndex=i}map(e,i=-1){return e.empty?this:Me.create(this.ranges.map(n=>n.map(e,i)),this.mainIndex)}eq(e,i=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],i))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new Me([this.main],0)}addRange(e,i=!0){return Me.create([e].concat(this.ranges),i?0:this.mainIndex+1)}replaceRange(e,i=this.mainIndex){let n=this.ranges.slice();return n[i]=e,Me.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Me(e.ranges.map(i=>Di.fromJSON(i)),e.main)}static single(e,i=e){return new Me([Me.range(e,i)],0)}static create(e,i=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=n:s.from<n)return Me.normalized(e.slice(),i);n=s.to}return new Me(e,i)}static cursor(e,i=0,n,r){return Di.create(e,e,(i==0?0:i<0?8:16)|(n==null?7:Math.min(6,n))|(r!=null?r:16777215)<<6)}static range(e,i,n,r){let s=(n!=null?n:16777215)<<6|(r==null?7:Math.min(6,r));return i<e?Di.create(i,e,48|s):Di.create(e,i,(i>e?8:0)|s)}static normalized(e,i=0){let n=e[i];e.sort((r,s)=>r.from-s.from),i=e.indexOf(n);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=i&&i--,e.splice(--r,2,s.anchor>s.head?Me.range(a,l):Me.range(l,a))}}return new Me(e,i)}};function _l(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}var Zr=0,P=class dd{constructor(e,i,n,r,s){this.combine=e,this.compareInput=i,this.compare=n,this.isStatic=r,this.id=Zr++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new dd(e.combine||(i=>i),e.compareInput||((i,n)=>i===n),e.compare||(e.combine?(i,n)=>i===n:es),!!e.static,e.enables)}of(e){return new Mn([],this,0,e)}compute(e,i){if(this.isStatic)throw new Error("Can't compute a static facet");return new Mn(e,this,1,i)}computeN(e,i){if(this.isStatic)throw new Error("Can't compute a static facet");return new Mn(e,this,2,i)}from(e,i){return i||(i=n=>n),this.compute([e],n=>i(n.field(e)))}};function es(t,e){return t==e||t.length==e.length&&t.every((i,n)=>i===e[n])}var Mn=class{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=Zr++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,r=this.id,s=t[r]>>1,o=this.type==2,l=!1,a=!1,c=[];for(let h of this.dependencies)h=="doc"?l=!0:h=="selection"?a=!0:(((e=t[h.id])!==null&&e!==void 0?e:1)&1)==0&&c.push(t[h.id]);return{create(h){return h.values[s]=i(h),1},update(h,f){if(l&&f.docChanged||a&&(f.docChanged||f.selection)||ts(h,c)){let u=i(h);if(o?!jl(u,h.values[s],n):!n(u,h.values[s]))return h.values[s]=u,1}return 0},reconfigure:(h,f)=>{let u,d=f.config.address[r];if(d!=null){let p=On(f,d);if(this.dependencies.every(g=>g instanceof P?f.facet(g)===h.facet(g):g instanceof Oe?f.field(g,!1)==h.field(g,!1):!0)||(o?jl(u=i(h),p,n):n(u=i(h),p)))return h.values[s]=p,0}else u=i(h);return h.values[s]=u,1}}}};function jl(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function ts(t,e){let i=!1;for(let n of e)Li(t,n)&1&&(i=!0);return i}function fp(t,e,i){let n=i.map(a=>t[a.id]),r=i.map(a=>a.type),s=n.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let c=[];for(let h=0;h<n.length;h++){let f=On(a,n[h]);if(r[h]==2)for(let u of f)c.push(u);else c.push(f)}return e.combine(c)}return{create(a){for(let c of n)Li(a,c);return a.values[o]=l(a),1},update(a,c){if(!ts(a,s))return 0;let h=l(a);return e.compare(h,a.values[o])?0:(a.values[o]=h,1)},reconfigure(a,c){let h=ts(a,n),f=c.config.facets[e.id],u=c.facet(e);if(f&&!h&&es(i,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}var Dn=P.define({static:!0}),Oe=class pd{constructor(e,i,n,r,s){this.id=e,this.createF=i,this.updateF=n,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let i=new pd(Zr++,e.create,e.update,e.compare||((n,r)=>n===r),e);return e.provide&&(i.provides=e.provide(i)),i}create(e){let i=e.facet(Dn).find(n=>n.field==this);return((i==null?void 0:i.create)||this.createF)(e)}slot(e){let i=e[this.id]>>1;return{create:n=>(n.values[i]=this.create(n),1),update:(n,r)=>{let s=n.values[i],o=this.updateF(s,r);return this.compareF(s,o)?0:(n.values[i]=o,1)},reconfigure:(n,r)=>{let s=n.facet(Dn),o=r.facet(Dn),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(n.values[i]=l.create(n),1):r.config.address[this.id]!=null?(n.values[i]=r.field(this),0):(n.values[i]=this.create(n),1)}}}init(e){return[this,Dn.of({field:this,create:e})]}get extension(){return this}},Ht={lowest:4,low:3,default:2,high:1,highest:0};function Oi(t){return e=>new ql(e,t)}var Ei={highest:Oi(Ht.highest),high:Oi(Ht.high),default:Oi(Ht.default),low:Oi(Ht.low),lowest:Oi(Ht.lowest)},ql=class{constructor(t,e){this.inner=t,this.prec=e}},Qe=class gd{of(e){return new is(this,e)}reconfigure(e){return gd.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},is=class{constructor(t,e){this.compartment=t,this.inner=e}},Kl=class md{constructor(e,i,n,r,s,o){for(this.base=e,this.compartments=i,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let i=this.address[e.id];return i==null?e.default:this.staticValues[i>>1]}static resolve(e,i,n){let r=[],s=Object.create(null),o=new Map;for(let u of up(e,i,o))u instanceof Oe?r.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],c=[];for(let u of r)l[u.id]=c.length<<1,c.push(d=>u.slot(d));let h=n==null?void 0:n.config.facets;for(let u in s){let d=s[u],p=d[0].facet,g=h&&h[u]||[];if(d.every(m=>m.type==0))if(l[p.id]=a.length<<1|1,es(g,d))a.push(n.facet(p));else{let m=p.combine(d.map(v=>v.value));a.push(n&&p.compare(m,n.facet(p))?n.facet(p):m)}else{for(let m of d)m.type==0?(l[m.id]=a.length<<1|1,a.push(m.value)):(l[m.id]=c.length<<1,c.push(v=>m.dynamicSlot(v)));l[p.id]=c.length<<1,c.push(m=>fp(m,p,d))}}let f=c.map(u=>u(l));return new md(e,o,f,l,a,s)}};function up(t,e,i){let n=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let c=n[a].indexOf(o);c>-1&&n[a].splice(c,1),o instanceof is&&i.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let c of o)s(c,l);else if(o instanceof is){if(i.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;i.set(o.compartment,c),s(c,l)}else if(o instanceof ql)s(o.inner,o.prec);else if(o instanceof Oe)n[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Mn)n[l].push(o),o.facet.extensions&&s(o.facet.extensions,Ht.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(c,l)}}return s(t,Ht.default),n.reduce((o,l)=>o.concat(l))}function Li(t,e){if(e&1)return 2;let i=e>>1,n=t.status[i];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;t.status[i]=4;let r=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|r}function On(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}var Ul=P.define(),ns=P.define({combine:t=>t.some(e=>e),static:!0}),Gl=P.define({combine:t=>t.length?t[0]:void 0,static:!0}),Jl=P.define(),Yl=P.define(),Xl=P.define(),Ql=P.define({combine:t=>t.length?t[0]:!1}),ft=class{constructor(t,e){this.type=t,this.value=e}static define(){return new dp}},dp=class{of(t){return new ft(this,t)}},pp=class{constructor(t){this.map=t}of(t){return new K(this,t)}},K=class vd{constructor(e,i){this.type=e,this.value=i}map(e){let i=this.type.map(this.value,e);return i===void 0?void 0:i==this.value?this:new vd(this.type,i)}is(e){return this.type==e}static define(e={}){return new pp(e.map||(i=>i))}static mapEffects(e,i){if(!e.length)return e;let n=[];for(let r of e){let s=r.map(i);s&&n.push(s)}return n}};K.reconfigure=K.define(),K.appendConfig=K.define();var xe=class cn{constructor(e,i,n,r,s,o){this.startState=e,this.changes=i,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&_l(n,i.newLength),s.some(l=>l.type==cn.time)||(this.annotations=s.concat(cn.time.of(Date.now())))}static create(e,i,n,r,s,o){return new cn(e,i,n,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let i of this.annotations)if(i.type==e)return i.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let i=this.annotation(cn.userEvent);return!!(i&&(i==e||i.length>e.length&&i.slice(0,e.length)==e&&i[e.length]=="."))}};xe.time=ft.define(),xe.userEvent=ft.define(),xe.addToHistory=ft.define(),xe.remote=ft.define();function gp(t,e){let i=[];for(let n=0,r=0;;){let s,o;if(n<t.length&&(r==e.length||e[r]>=t[n]))s=t[n++],o=t[n++];else if(r<e.length)s=e[r++],o=e[r++];else return i;!i.length||i[i.length-1]<s?i.push(s,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function Zl(t,e,i){var n;let r,s,o;return i?(r=e.changes,s=_e.empty(e.changes.length),o=t.changes.compose(e.changes)):(r=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(n=t.selection)===null||n===void 0?void 0:n.map(r),effects:K.mapEffects(t.effects,r).concat(K.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function rs(t,e,i){let n=e.selection,r=Zt(e.annotations);return e.userEvent&&(r=r.concat(xe.userEvent.of(e.userEvent))),{changes:e.changes instanceof _e?e.changes:_e.of(e.changes||[],i,t.facet(Gl)),selection:n&&(n instanceof w?n:w.single(n.anchor,n.head)),effects:Zt(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function ea(t,e,i){let n=rs(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(i=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(i=!1);let o=!!e[s].sequential;n=Zl(n,rs(t,e[s],o?n.changes.newLength:t.doc.length),o)}let r=xe.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return vp(i?mp(r):r)}function mp(t){let e=t.startState,i=!0;for(let r of e.facet(Jl)){let s=r(t);if(s===!1){i=!1;break}Array.isArray(s)&&(i=i===!0?s:gp(i,s))}if(i!==!0){let r,s;if(i===!1)s=t.changes.invertedDesc,r=_e.empty(e.doc.length);else{let o=t.changes.filter(i);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}t=xe.create(e,r,t.selection&&t.selection.map(s),K.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(Yl);for(let r=n.length-1;r>=0;r--){let s=n[r](t);s instanceof xe?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof xe?t=s[0]:t=ea(e,Zt(s),!1)}return t}function vp(t){let e=t.startState,i=e.facet(Xl),n=t;for(let r=i.length-1;r>=0;r--){let s=i[r](t);s&&Object.keys(s).length&&(n=Zl(n,rs(e,s,t.changes.newLength),!0))}return n==t?t:xe.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}var yp=[];function Zt(t){return t==null?yp:Array.isArray(t)?t:[t]}var ge=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(ge||(ge={})),bp=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,ss;try{ss=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function wp(t){if(ss)return ss.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||bp.test(i)))return!0}return!1}function xp(t){return e=>{if(!/\S/.test(e))return ge.Space;if(wp(e))return ge.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return ge.Word;return ge.Other}}var ie=class Ge{constructor(e,i,n,r,s,o){this.config=e,this.doc=i,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Li(this,l<<1);this.computeSlot=null}field(e,i=!0){let n=this.config.address[e.id];if(n==null){if(i)throw new RangeError("Field is not present in this state");return}return Li(this,n),On(this,n)}update(...e){return ea(this,e,!0)}applyTransaction(e){let i=this.config,{base:n,compartments:r}=i;for(let l of e.effects)l.is(Qe.reconfigure)?(i&&(r=new Map,i.compartments.forEach((a,c)=>r.set(c,a)),i=null),r.set(l.value.compartment,l.value.extension)):l.is(K.reconfigure)?(i=null,n=l.value):l.is(K.appendConfig)&&(i=null,n=Zt(n).concat(l.value));let s;i?s=e.startState.values.slice():(i=Kl.resolve(n,r,this),s=new Ge(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(a,c)=>c.reconfigure(a,this),null).values);let o=e.startState.facet(ns)?e.newSelection:e.newSelection.asSingle();new Ge(i,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:e},range:w.cursor(i.from+e.length)}))}changeByRange(e){let i=this.selection,n=e(i.ranges[0]),r=this.changes(n.changes),s=[n.range],o=Zt(n.effects);for(let l=1;l<i.ranges.length;l++){let a=e(i.ranges[l]),c=this.changes(a.changes),h=c.map(r);for(let u=0;u<l;u++)s[u]=s[u].map(h);let f=r.mapDesc(c,!0);s.push(a.range.map(f)),r=r.compose(h),o=K.mapEffects(o,h).concat(K.mapEffects(Zt(a.effects),f))}return{changes:r,selection:w.create(s,i.mainIndex),effects:o}}changes(e=[]){return e instanceof _e?e:_e.of(e,this.doc.length,this.facet(Ge.lineSeparator))}toText(e){return q.of(e.split(this.facet(Ge.lineSeparator)||Yr))}sliceDoc(e=0,i=this.doc.length){return this.doc.sliceString(e,i,this.lineBreak)}facet(e){let i=this.config.address[e.id];return i==null?e.default:(Li(this,i),On(this,i))}toJSON(e){let i={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Oe&&this.config.address[r.id]!=null&&(i[n]=r.spec.toJSON(this.field(e[n]),this))}return i}static fromJSON(e,i={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(e,s)){let o=n[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return Ge.create({doc:e.doc,selection:w.fromJSON(e.selection),extensions:i.extensions?r.concat([i.extensions]):r})}static create(e={}){let i=Kl.resolve(e.extensions||[],new Map),n=e.doc instanceof q?e.doc:q.of((e.doc||"").split(i.staticFacet(Ge.lineSeparator)||Yr)),r=e.selection?e.selection instanceof w?e.selection:w.single(e.selection.anchor,e.selection.head):w.single(0);return _l(r,n.length),i.staticFacet(ns)||(r=r.asSingle()),new Ge(i,n,r,i.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Ge.tabSize)}get lineBreak(){return this.facet(Ge.lineSeparator)||`
|
|
5
|
-
`}get readOnly(){return this.facet(Ql)}phrase(e,...i){for(let n of this.facet(Ge.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return i.length&&(e=e.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>i.length?n:i[s-1]})),e}languageDataAt(e,i,n=-1){let r=[];for(let s of this.facet(Ul))for(let o of s(this,i,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return xp(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:i,from:n,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-n,l=e-n;for(;o>0;){let a=pe(i,o,!1);if(s(i.slice(a,o))!=ge.Word)break;o=a}for(;l<r;){let a=pe(i,l);if(s(i.slice(l,a))!=ge.Word)break;l=a}return o==l?null:w.range(o+n,l+n)}};ie.allowMultipleSelections=ns,ie.tabSize=P.define({combine:t=>t.length?t[0]:4}),ie.lineSeparator=Gl,ie.readOnly=Ql,ie.phrases=P.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every(r=>t[r]==e[r])}}),ie.languageData=Ul,ie.changeFilter=Jl,ie.transactionFilter=Yl,ie.transactionExtender=Xl,Qe.reconfigure=K.define();function Bi(t,e,i={}){let n={};for(let r of t)for(let s of Object.keys(r)){let o=r[s],l=n[s];if(l===void 0)n[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(i,s))n[s]=i[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)n[r]===void 0&&(n[r]=e[r]);return n}var Vt=class{eq(t){return this==t}range(t,e=t){return os.create(t,e,this)}};Vt.prototype.startSide=Vt.prototype.endSide=0,Vt.prototype.point=!1,Vt.prototype.mapMode=we.TrackDel;var os=class yd{constructor(e,i,n){this.from=e,this.to=i,this.value=n}static create(e,i,n){return new yd(e,i,n)}};function ls(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}var kp=class bd{constructor(e,i,n,r){this.from=e,this.to=i,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,i,n,r=0){let s=n?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,c=s[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-i;if(a==o)return c>=0?o:l;c>=0?l=a:o=a+1}}between(e,i,n,r){for(let s=this.findIndex(i,-1e9,!0),o=this.findIndex(n,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,i){let n=[],r=[],s=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let c=this.value[a],h=this.from[a]+e,f=this.to[a]+e,u,d;if(h==f){let p=i.mapPos(h,c.startSide,c.mapMode);if(p==null||(u=d=p,c.startSide!=c.endSide&&(d=i.mapPos(h,c.endSide),d<u)))continue}else if(u=i.mapPos(h,c.startSide),d=i.mapPos(f,c.endSide),u>d||u==d&&c.startSide>0&&c.endSide<=0)continue;(d-u||c.endSide-c.startSide)<0||(o<0&&(o=u),c.point&&(l=Math.max(l,d-u)),n.push(c),r.push(u-o),s.push(d-o))}return{mapped:n.length?new bd(r,s,n,l):null,pos:o}}},ne=class gt{constructor(e,i,n,r){this.chunkPos=e,this.chunk=i,this.nextLayer=n,this.maxPoint=r}static create(e,i,n,r){return new gt(e,i,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let i of this.chunk)e+=i.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:i=[],sort:n=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(i.length==0&&!o)return this;if(n&&(i=i.slice().sort(ls)),this.isEmpty)return i.length?gt.of(i):this;let l=new ia(this,null,-1).goto(0),a=0,c=[],h=new ei;for(;l.value||a<i.length;)if(a<i.length&&(l.from-i[a].from||l.startSide-i[a].value.startSide)>=0){let f=i[a++];h.addInner(f.from,f.to,f.value)||c.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==i.length||this.chunkEnd(l.chunkIndex)<i[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&h.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(h.addInner(l.from,l.to,l.value)||c.push(os.create(l.from,l.to,l.value))),l.next());return h.finishInner(this.nextLayer.isEmpty&&!c.length?gt.empty:this.nextLayer.update({add:c,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let i=[],n=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],c=e.touchesRange(l,l+a.length);if(c===!1)r=Math.max(r,a.maxPoint),i.push(a),n.push(e.mapPos(l));else if(c===!0){let{mapped:h,pos:f}=a.map(l,e);h&&(r=Math.max(r,h.maxPoint),i.push(h),n.push(f))}}let s=this.nextLayer.map(e);return i.length==0?s:new gt(n,i,s||gt.empty,r)}between(e,i,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(i>=s&&e<=s+o.length&&o.between(s,e-s,i-s,n)===!1)return}this.nextLayer.between(e,i,n)}}iter(e=0){return as.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,i=0){return as.from(e).goto(i)}static compare(e,i,n,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=i.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=ta(o,l,n),c=new Pi(o,a,s),h=new Pi(l,a,s);n.iterGaps((f,u,d)=>na(c,f,h,u,d,r)),n.empty&&n.length==0&&na(c,0,h,0,0,r)}static eq(e,i,n=0,r){r==null&&(r=999999999);let s=e.filter(h=>!h.isEmpty&&i.indexOf(h)<0),o=i.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=ta(s,o),a=new Pi(s,l,0).goto(n),c=new Pi(o,l,0).goto(n);for(;;){if(a.to!=c.to||!cs(a.active,c.active)||a.point&&(!c.point||!a.point.eq(c.point)))return!1;if(a.to>r)return!0;a.next(),c.next()}}static spans(e,i,n,r,s=-1){let o=new Pi(e,null,s).goto(i),l=i,a=o.openStart;for(;;){let c=Math.min(o.to,n);if(o.point){let h=o.activeForPoint(o.to),f=o.pointFrom<i?h.length+1:o.point.startSide<0?h.length:Math.min(h.length,a);r.point(l,c,o.point,h,f,o.pointRank),a=Math.min(o.openEnd(c),h.length)}else c>l&&(r.span(l,c,o.active,a),a=o.openEnd(c));if(o.to>n)return a+(o.point&&o.to>n?1:0);l=o.to,o.next()}}static of(e,i=!1){let n=new ei;for(let r of e instanceof os?[e]:i?Sp(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return gt.empty;let i=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=gt.empty;r=r.nextLayer)i=new gt(r.chunkPos,r.chunk,i,Math.max(r.maxPoint,i.maxPoint));return i}};ne.empty=new ne([],[],null,-1);function Sp(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(ls(e,n)>0)return t.slice().sort(ls);e=n}return t}ne.empty.nextLayer=ne.empty;var ei=class wd{finishChunk(e){this.chunks.push(new kp(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,i,n){this.addInner(e,i,n)||(this.nextLayer||(this.nextLayer=new wd)).add(e,i,n)}addInner(e,i,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(i-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=i,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,i-e)),!0)}addChunk(e,i){if((e-this.lastTo||i.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,i.maxPoint),this.chunks.push(i),this.chunkPos.push(e);let n=i.value.length-1;return this.last=i.value[n],this.lastFrom=i.from[n]+e,this.lastTo=i.to[n]+e,!0}finish(){return this.finishInner(ne.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let i=ne.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,i}};function ta(t,e,i){let n=new Map;for(let s of t)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&n.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=n.get(s.chunk[o]);l!=null&&(i?i.mapPos(l):l)==s.chunkPos[o]&&!(i!=null&&i.touchesRange(l,l+s.chunk[o].length))&&r.add(s.chunk[o])}return r}var ia=class{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let n=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(n)||this.layer.chunkEnd(this.chunkIndex)<t||n.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}},as=class xd{constructor(e){this.heap=e}static from(e,i=null,n=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new ia(o,i,n,s));return r.length==1?r[0]:new xd(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,i=-1e9){for(let n of this.heap)n.goto(e,i);for(let n=this.heap.length>>1;n>=0;n--)hs(this.heap,n);return this.next(),this}forward(e,i){for(let n of this.heap)n.forward(e,i);for(let n=this.heap.length>>1;n>=0;n--)hs(this.heap,n);(this.to-e||this.value.endSide-i)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),hs(this.heap,0)}}};function hs(t,e){for(let i=t[e];;){let n=(e<<1)+1;if(n>=t.length)break;let r=t[n];if(n+1<t.length&&r.compare(t[n+1])>=0&&(r=t[n+1],n++),i.compare(r)<0)break;t[n]=i,t[e]=r,e=n}}var Pi=class{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=as.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){En(this.active,t),En(this.activeTo,t),En(this.activeRank,t),this.minActive=ra(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:r}=this.cursor;for(;e<this.activeRank.length&&(r-this.activeRank[e]||n-this.activeTo[e])>0;)e++;Ln(this.active,e,i),Ln(this.activeTo,e,n),Ln(this.activeRank,e,r),t&&Ln(t,e,this.cursor.from),this.minActive=ra(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&En(i,n)}else if(this.cursor.value)if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=r,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=r.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let n=i.length-1;n>=0&&i[n]<t;n--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}};function na(t,e,i,n,r,s){t.goto(e),i.goto(n);let o=n+r,l=n,a=n-e;for(;;){let c=t.to+a-i.to,h=c||t.endSide-i.endSide,f=h<0?t.to+a:i.to,u=Math.min(f,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&cs(t.activeForPoint(t.to),i.activeForPoint(i.to))||s.comparePoint(l,u,t.point,i.point):u>l&&!cs(t.active,i.active)&&s.compareRange(l,u,t.active,i.active),f>o)break;(c||t.openEnd!=i.openEnd)&&s.boundChange&&s.boundChange(f),l=f,h<=0&&t.next(),h>=0&&i.next()}}function cs(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function En(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function Ln(t,e,i){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=i}function ra(t,e){let i=-1,n=1e9;for(let r=0;r<e.length;r++)(e[r]-n||t[r].endSide-t[i].endSide)<0&&(i=r,n=e[r]);return i}function Bn(t,e,i=t.length){let n=0;for(let r=0;r<i&&r<t.length;)t.charCodeAt(r)==9?(n+=e-n%e,r++):(n++,r=pe(t,r));return n}function Cp(t,e,i,n){for(let r=0,s=0;;){if(s>=e)return r;if(r==t.length)break;s+=t.charCodeAt(r)==9?i-s%i:1,r=pe(t,r)}return n===!0?-1:t.length}var fs="ͼ",sa=typeof Symbol=="undefined"?"__"+fs:Symbol.for(fs),us=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),oa=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},yt=class{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function r(s,o,l,a){let c=[],h=/^@(\w+)\b/.exec(s[0]),f=h&&h[1]=="keyframes";if(h&&o==null)return l.push(s[0]+";");for(let u in o){let d=o[u];if(/&/.test(u))r(u.split(/,\s*/).map(p=>s.map(g=>p.replace(/&/,g))).reduce((p,g)=>p.concat(g)),d,l);else if(d&&typeof d=="object"){if(!h)throw new RangeError("The value of a property ("+u+") should be a primitive value.");r(n(u),d,c,f)}else d!=null&&c.push(u.replace(/_.*/,"").replace(/[A-Z]/g,p=>"-"+p.toLowerCase())+": "+d+";")}(c.length||f)&&l.push((i&&!h&&!a?s.map(i):s).join(", ")+" {"+c.join(" ")+"}")}for(let s in t)r(n(s),t[s],this.rules)}getRules(){return this.rules.join(`
|
|
6
|
-
`)}static newName(){let t=oa[sa]||1;return oa[sa]=t+1,fs+t.toString(36)}static mount(t,e,i){let n=t[us],r=i&&i.nonce;n?r&&n.setNonce(r):n=new Ap(t,r),n.mount(Array.isArray(e)?e:[e],t)}},la=new Map,Ap=class{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let r=la.get(i);if(r)return t[us]=r;this.sheet=new n.CSSStyleSheet,la.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[us]=this}mount(t,e){let i=this.sheet,n=0,r=0;for(let s=0;s<t.length;s++){let o=t[s],l=this.modules.indexOf(o);if(l<r&&l>-1&&(this.modules.splice(l,1),r--,l=-1),l==-1){if(this.modules.splice(r++,0,o),i)for(let a=0;a<o.rules.length;a++)i.insertRule(o.rules[a],n++)}else{for(;r<l;)n+=this.modules[r++].rules.length;n+=o.rules.length,r++}}if(i)e.adoptedStyleSheets.indexOf(this.sheet)<0&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{let s="";for(let l=0;l<this.modules.length;l++)s+=this.modules[l].getRules()+`
|
|
7
|
-
`;this.styleTag.textContent=s;let o=e.head||e;this.styleTag.parentNode!=o&&o.insertBefore(this.styleTag,o.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}},bt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ri={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Tp=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Mp=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ae=0;ae<10;ae++)bt[48+ae]=bt[96+ae]=String(ae);var ae;for(ae=1;ae<=24;ae++)bt[ae+111]="F"+ae;var ae;for(ae=65;ae<=90;ae++)bt[ae]=String.fromCharCode(ae+32),Ri[ae]=String.fromCharCode(ae);var ae;for(Pn in bt)Ri.hasOwnProperty(Pn)||(Ri[Pn]=bt[Pn]);var Pn;function Dp(t){var e=Tp&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Mp&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",i=!e&&t.key||(t.shiftKey?Ri:bt)[t.keyCode]||t.key||"Unidentified";return i=="Esc"&&(i="Escape"),i=="Del"&&(i="Delete"),i=="Left"&&(i="ArrowLeft"),i=="Up"&&(i="ArrowUp"),i=="Right"&&(i="ArrowRight"),i=="Down"&&(i="ArrowDown"),i}function X(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&typeof i=="object"&&i.nodeType==null&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var r=i[n];typeof r=="string"?t.setAttribute(n,r):r!=null&&(t[n]=r)}e++}for(;e<arguments.length;e++)aa(t,arguments[e]);return t}function aa(t,e){if(typeof e=="string")t.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)t.appendChild(e);else if(Array.isArray(e))for(var i=0;i<e.length;i++)aa(t,e[i]);else throw new RangeError("Unsupported child node: "+e)}function Ni(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function ds(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Rn(t,e){if(!e.anchorNode)return!1;try{return ds(t,e.anchorNode)}catch{return!1}}function Ii(t){return t.nodeType==3?$t(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Fi(t,e,i,n){return i?ha(t,e,i,n,-1)||ha(t,e,i,n,1):!1}function Wt(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Nn(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ha(t,e,i,n,r){for(;;){if(t==i&&e==n)return!0;if(e==(r<0?0:Ze(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=Wt(t)+(r<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(r<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=r<0?Ze(t):0}else return!1}}function Ze(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function In(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function Op(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function ca(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}function Ep(t,e,i,n,r,s,o,l){let a=t.ownerDocument,c=a.defaultView||window;for(let h=t,f=!1;h&&!f;)if(h.nodeType==1){let u,d=h==a.body,p=1,g=1;if(d)u=Op(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(f=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let y=h.getBoundingClientRect();({scaleX:p,scaleY:g}=ca(h,y)),u={left:y.left,right:y.left+h.clientWidth*p,top:y.top,bottom:y.top+h.clientHeight*g}}let m=0,v=0;if(r=="nearest")e.top<u.top?(v=e.top-(u.top+o),i>0&&e.bottom>u.bottom+v&&(v=e.bottom-u.bottom+o)):e.bottom>u.bottom&&(v=e.bottom-u.bottom+o,i<0&&e.top-v<u.top&&(v=e.top-(u.top+o)));else{let y=e.bottom-e.top,S=u.bottom-u.top;v=(r=="center"&&y<=S?e.top+y/2-S/2:r=="start"||r=="center"&&i<0?e.top-o:e.bottom-S+o)-u.top}if(n=="nearest"?e.left<u.left?(m=e.left-(u.left+s),i>0&&e.right>u.right+m&&(m=e.right-u.right+s)):e.right>u.right&&(m=e.right-u.right+s,i<0&&e.left<u.left+m&&(m=e.left-(u.left+s))):m=(n=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:n=="start"==l?e.left-s:e.right-(u.right-u.left)+s)-u.left,m||v)if(d)c.scrollBy(m,v);else{let y=0,S=0;if(v){let k=h.scrollTop;h.scrollTop+=v/g,S=(h.scrollTop-k)*g}if(m){let k=h.scrollLeft;h.scrollLeft+=m/p,y=(h.scrollLeft-k)*p}e={left:e.left-y,top:e.top-S,right:e.right-y,bottom:e.bottom-S},y&&Math.abs(y-m)<1&&(n="nearest"),S&&Math.abs(S-v)<1&&(r="nearest")}if(d)break;(e.top<u.top||e.bottom>u.bottom||e.left<u.left||e.right>u.right)&&(e={left:Math.max(e.left,u.left),right:Math.min(e.right,u.right),top:Math.max(e.top,u.top),bottom:Math.min(e.bottom,u.bottom)}),h=h.assignedSlot||h.parentNode}else if(h.nodeType==11)h=h.host;else break}function Lp(t){let e=t.ownerDocument,i,n;for(let r=t.parentNode;r&&!(r==e.body||i&&n);)if(r.nodeType==1)!n&&r.scrollHeight>r.clientHeight&&(n=r),!i&&r.scrollWidth>r.clientWidth&&(i=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:i,y:n}}var Bp=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?Ze(e):0),i,Math.min(t.focusOffset,i?Ze(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}},ti=null;function fa(t){if(t.setActive)return t.setActive();if(ti)return t.focus(ti);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(ti==null?{get preventScroll(){return ti={preventScroll:!0},!0}}:void 0),!ti){ti=!1;for(let i=0;i<e.length;){let n=e[i++],r=e[i++],s=e[i++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=s&&(n.scrollLeft=s)}}}var ua;function $t(t,e,i=e){let n=ua||(ua=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function ii(t,e,i,n){let r={key:e,code:e,keyCode:i,which:i,cancelable:!0};n&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=n);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Pp(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function da(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function Rp(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,Ze(i));;)if(n){if(i.nodeType!=1)return!1;let r=i.childNodes[n-1];r.contentEditable=="false"?n--:(i=r,n=Ze(i))}else{if(i==t)return!0;n=Wt(i),i=i.parentNode}}function pa(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function ga(t,e){for(let i=t,n=e;;){if(i.nodeType==3&&n>0)return{node:i,offset:n};if(i.nodeType==1&&n>0){if(i.contentEditable=="false")return null;i=i.childNodes[n-1],n=Ze(i)}else if(i.parentNode&&!Nn(i))n=Wt(i),i=i.parentNode;else return null}}function ma(t,e){for(let i=t,n=e;;){if(i.nodeType==3&&n<i.nodeValue.length)return{node:i,offset:n};if(i.nodeType==1&&n<i.childNodes.length){if(i.contentEditable=="false")return null;i=i.childNodes[n],n=0}else if(i.parentNode&&!Nn(i))n=Wt(i)+1,i=i.parentNode;else return null}}var Ce=class sl{constructor(e,i,n=!0){this.node=e,this.offset=i,this.precise=n}static before(e,i){return new sl(e.parentNode,Wt(e),i)}static after(e,i){return new sl(e.parentNode,Wt(e)+1,i)}},ps=[],re=class ol{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let i=this.posAtStart;for(let n of this.children){if(n==e)return i;i+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,i){if(this.flags&2){let n=this.dom,r=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=r?r.nextSibling:n.firstChild)){let l=ol.get(s);(!l||!l.parent&&l.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,i),o.flags&=-8}if(s=r?r.nextSibling:n.firstChild,i&&!i.written&&i.node==n&&s!=o.dom&&(i.written=!0),o.dom.parentNode==n)for(;s&&s!=o.dom;)s=va(s);else n.insertBefore(o.dom,s);r=o.dom}for(s=r?r.nextSibling:n.firstChild,s&&i&&i.node==n&&(i.written=!0);s;)s=va(s)}else if(this.flags&1)for(let n of this.children)n.flags&7&&(n.sync(e,i),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,i){let n;if(e==this.dom)n=this.dom.childNodes[i];else{let r=Ze(e)==0?0:i==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;r==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?r=-1:r=1),e=s}r<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!ol.get(n);)n=n.nextSibling;if(!n)return this.length;for(let r=0,s=0;;r++){let o=this.children[r];if(o.dom==n)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,i,n=0){let r=-1,s=-1,o=-1,l=-1;for(let a=0,c=n,h=n;a<this.children.length;a++){let f=this.children[a],u=c+f.length;if(c<e&&u>i)return f.domBoundsAround(e,i,c);if(u>=e&&r==-1&&(r=a,s=c),c>i&&f.dom.parentNode==this.dom){o=a,l=h;break}h=u,c=u+f.breakAfter}return{from:s,to:l<0?n+this.length:l,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let i=this.parent;i;i=i.parent){if(e&&(i.flags|=2),i.flags&1)return;i.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let i=e.parent;if(!i)return e;e=i}}replaceChildren(e,i,n=ps){this.markDirty();for(let r=e;r<i;r++){let s=this.children[r];s.parent==this&&n.indexOf(s)<0&&s.destroy()}n.length<250?this.children.splice(e,i-e,...n):this.children=[].concat(this.children.slice(0,e),n,this.children.slice(i));for(let r=0;r<n.length;r++)n[r].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new ya(this.children,e,this.children.length)}childPos(e,i=1){return this.childCursor().findPos(e,i)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,i,n,r,s,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}};re.prototype.breakAfter=0;function va(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}var ya=class{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}};function ba(t,e,i,n,r,s,o,l,a){let{children:c}=t,h=c.length?c[e]:null,f=s.length?s[s.length-1]:null,u=f?f.breakAfter:o;if(!(e==n&&h&&!o&&!u&&s.length<2&&h.merge(i,r,s.length?f:null,i==0,l,a))){if(n<c.length){let d=c[n];d&&(r<d.length||d.breakAfter&&(f!=null&&f.breakAfter))?(e==n&&(d=d.split(r),r=0),!u&&f&&d.merge(0,r,f,!0,0,a)?s[s.length-1]=d:((r||d.children.length&&!d.children[0].length)&&d.merge(0,r,null,!1,0,a),s.push(d))):d!=null&&d.breakAfter&&(f?f.breakAfter=1:o=1),n++}for(h&&(h.breakAfter=o,i>0&&(!o&&s.length&&h.merge(i,h.length,s[0],!1,l,0)?h.breakAfter=s.shift().breakAfter:(i<h.length||h.children.length&&h.children[h.children.length-1].length==0)&&h.merge(i,h.length,null,!1,l,0),e++));e<n&&s.length;)if(c[n-1].become(s[s.length-1]))n--,s.pop(),a=s.length?0:l;else if(c[e].become(s[0]))e++,s.shift(),l=s.length?0:a;else break;!s.length&&e&&n<c.length&&!c[e-1].breakAfter&&c[n].merge(0,0,c[e-1],!1,l,a)&&e--,(e<n||s.length)&&t.replaceChildren(e,n,s)}}function wa(t,e,i,n,r,s){let o=t.childCursor(),{i:l,off:a}=o.findPos(i,1),{i:c,off:h}=o.findPos(e,-1),f=e-i;for(let u of n)f+=u.length;t.length+=f,ba(t,c,h,l,a,n,0,r,s)}var ke=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""},gs=typeof document!="undefined"?document:{documentElement:{style:{}}},ms=/Edge\/(\d+)/.exec(ke.userAgent),xa=/MSIE \d/.test(ke.userAgent),vs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ke.userAgent),Fn=!!(xa||vs||ms),ka=!Fn&&/gecko\/(\d+)/i.test(ke.userAgent),ys=!Fn&&/Chrome\/(\d+)/.exec(ke.userAgent),Sa="webkitFontSmoothing"in gs.documentElement.style,Ca=!Fn&&/Apple Computer/.test(ke.vendor),Aa=Ca&&(/Mobile\/\w+/.test(ke.userAgent)||ke.maxTouchPoints>2),D={mac:Aa||/Mac/.test(ke.platform),windows:/Win/.test(ke.platform),linux:/Linux|X11/.test(ke.platform),ie:Fn,ie_version:xa?gs.documentMode||6:vs?+vs[1]:ms?+ms[1]:0,gecko:ka,gecko_version:ka?+(/Firefox\/(\d+)/.exec(ke.userAgent)||[0,0])[1]:0,chrome:!!ys,chrome_version:ys?+ys[1]:0,ios:Aa,android:/Android\b/.test(ke.userAgent),webkit:Sa,safari:Ca,webkit_version:Sa?+(/\bAppleWebKit\/(\d+)/.exec(ke.userAgent)||[0,0])[1]:0,tabSize:gs.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},Np=256,wt=class ll extends re{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,i){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(i&&i.node==this.dom&&(i.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,i,n){return this.flags&8||n&&(!(n instanceof ll)||this.length-(i-e)+n.length>Np||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(i),this.markDirty(),!0)}split(e){let i=new ll(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),i.flags|=this.flags&8,i}localPosFromDOM(e,i){return e==this.dom?i:i?this.text.length:0}domAtPos(e){return new Ce(this.dom,e)}domBoundsAround(e,i,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,i){return Ip(this.dom,e,i)}},ni=class al extends re{constructor(e,i=[],n=0){super(),this.mark=e,this.children=i,this.length=n;for(let r of i)r.setParent(this)}setAttrs(e){if(da(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let i in this.mark.attrs)e.setAttribute(i,this.mark.attrs[i]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,i){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,i)}merge(e,i,n,r,s,o){return n&&(!(n instanceof al&&n.mark.eq(this.mark))||e&&s<=0||i<this.length&&o<=0)?!1:(wa(this,e,i,n?n.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(e){let i=[],n=0,r=-1,s=0;for(let l of this.children){let a=n+l.length;a>e&&i.push(n<e?l.split(e-n):l),r<0&&n>=e&&(r=s),n=a,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new al(this.mark,i,o)}domAtPos(e){return Ta(this,e)}coordsAt(e,i){return Da(this,e,i)}};function Ip(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let r=e,s=e,o=0;e==0&&i<0||e==n&&i>=0?D.chrome||D.gecko||(e?(r--,o=1):s<n&&(s++,o=-1)):i<0?r--:s<n&&s++;let l=$t(t,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:i>=0)?0:l.length-1];return D.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,c=>c.width)||a),o?In(a,o<0):a||null}var bs=class fn extends re{static create(e,i,n){return new fn(e,i,n)}constructor(e,i,n){super(),this.widget=e,this.length=i,this.side=n,this.prevWidget=null}split(e){let i=fn.create(this.widget,this.length-e,this.side);return this.length-=e,i}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,i,n,r,s,o){return n&&(!(n instanceof fn)||!this.widget.compare(n.widget)||e>0&&s<=0||i<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-i),!0)}become(e){return e instanceof fn&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return q.empty;let e=this;for(;e.parent;)e=e.parent;let{view:i}=e,n=i&&i.state.doc,r=this.posAtStart;return n?n.slice(r,r+this.length):q.empty}domAtPos(e){return(this.length?e==0:this.side>0)?Ce.before(this.dom):Ce.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,i){let n=this.widget.coordsAt(this.dom,e,i);if(n)return n;let r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?r.length-1:0;s=r[l],!(e>0?l==0:l==r.length-1||s.top<s.bottom);l+=o?-1:1);return In(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},ws=class hl extends re{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof hl&&e.side==this.side}split(){return new hl(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?Ce.before(this.dom):Ce.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return q.empty}get isHidden(){return!0}};wt.prototype.children=bs.prototype.children=ws.prototype.children=ps;function Ta(t,e){let i=t.dom,{children:n}=t,r=0;for(let s=0;r<n.length;r++){let o=n[r],l=s+o.length;if(!(l==s&&o.getSide()<=0)){if(e>s&&e<l&&o.dom.parentNode==i)return o.domAtPos(e-s);if(e<=s)break;s=l}}for(let s=r;s>0;s--){let o=n[s-1];if(o.dom.parentNode==i)return o.domAtPos(o.length)}for(let s=r;s<n.length;s++){let o=n[s];if(o.dom.parentNode==i)return o.domAtPos(0)}return new Ce(i,0)}function Ma(t,e,i){let n,{children:r}=t;i>0&&e instanceof ni&&r.length&&(n=r[r.length-1])instanceof ni&&n.mark.eq(e.mark)?Ma(n,e.children[0],i-1):(r.push(e),e.setParent(t)),t.length+=e.length}function Da(t,e,i){let n=null,r=-1,s=null,o=-1;function l(c,h){for(let f=0,u=0;f<c.children.length&&u<=h;f++){let d=c.children[f],p=u+d.length;p>=h&&(d.children.length?l(d,h-u):(!s||s.isHidden&&(i>0||Hp(s,d)))&&(p>h||u==p&&d.getSide()>0)?(s=d,o=h-u):(u<h||u==p&&d.getSide()<0&&!d.isHidden)&&(n=d,r=h-u)),u=p}}l(t,e);let a=(i<0?n:s)||n||s;return a?a.coordsAt(Math.max(0,a==n?r:o),i):Fp(t)}function Fp(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=Ii(e);return i[i.length-1]||null}function Hp(t,e){let i=t.coordsAt(0,1),n=e.coordsAt(0,1);return i&&n&&n.top<i.bottom}function xs(t,e){for(let i in t)i=="class"&&e.class?e.class+=" "+t.class:i=="style"&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}var Oa=Object.create(null);function Hn(t,e,i){if(t==e)return!0;t||(t=Oa),e||(e=Oa);let n=Object.keys(t),r=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=r.length-(i&&r.indexOf(i)>-1?1:0))return!1;for(let s of n)if(s!=i&&(r.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function ks(t,e,i){let n=!1;if(e)for(let r in e)i&&r in i||(n=!0,r=="style"?t.style.cssText="":t.removeAttribute(r));if(i)for(let r in i)e&&e[r]==i[r]||(n=!0,r=="style"?t.style.cssText=i[r]:t.setAttribute(r,i[r]));return n}function Vp(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}var Vn=class{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}},Ee=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(Ee||(Ee={})),U=class extends Vt{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new Ss(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new ri(t,e,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,i,n;if(t.isBlockGap)i=-5e8,n=4e8;else{let{start:r,end:s}=Ea(t,e);i=(r?e?-3e8:-1:5e8)-1,n=(s?e?2e8:1:-6e8)+1}return new ri(t,i,n,e,t.widget||null,!0)}static line(t){return new Cs(t)}static set(t,e=!1){return ne.of(t,e)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};U.none=ne.empty;var Ss=class kd extends U{constructor(e){let{start:i,end:n}=Ea(e);super(i?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var i,n;return this==e||e instanceof kd&&this.tagName==e.tagName&&(this.class||((i=this.attrs)===null||i===void 0?void 0:i.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&Hn(this.attrs,e.attrs,"class")}range(e,i=e){if(e>=i)throw new RangeError("Mark decorations may not be empty");return super.range(e,i)}};Ss.prototype.point=!1;var Cs=class Sd extends U{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Sd&&this.spec.class==e.spec.class&&Hn(this.spec.attributes,e.spec.attributes)}range(e,i=e){if(i!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,i)}};Cs.prototype.mapMode=we.TrackBefore,Cs.prototype.point=!0;var ri=class Cd extends U{constructor(e,i,n,r,s,o){super(i,n,s,e),this.block=r,this.isReplace=o,this.mapMode=r?i<=0?we.TrackBefore:we.TrackAfter:we.TrackDel}get type(){return this.startSide!=this.endSide?Ee.WidgetRange:this.startSide<=0?Ee.WidgetBefore:Ee.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Cd&&Wp(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,i=e){if(this.isReplace&&(e>i||e==i&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&i!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,i)}};ri.prototype.point=!0;function Ea(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return i==null&&(i=t.inclusive),n==null&&(n=t.inclusive),{start:i!=null?i:e,end:n!=null?n:e}}function Wp(t,e){return t==e||!!(t&&e&&t.compare(e))}function Wn(t,e,i,n=0){let r=i.length-1;r>=0&&i[r]+n>=t?i[r]=Math.max(i[r],e):i.push(t,e)}var be=class un extends re{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,i,n,r,s,o){if(n){if(!(n instanceof un))return!1;this.dom||n.transferDOM(this)}return r&&this.setDeco(n?n.attrs:null),wa(this,e,i,n?n.children.slice():[],s,o),!0}split(e){let i=new un;if(i.breakAfter=this.breakAfter,this.length==0)return i;let{i:n,off:r}=this.childPos(e);r&&(i.append(this.children[n].split(r),0),this.children[n].merge(r,this.children[n].length,null,!1,0,0),n++);for(let s=n;s<this.children.length;s++)i.append(this.children[s],0);for(;n>0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,i}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Hn(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,i){Ma(this,e,i)}addLineDeco(e){let i=e.spec.attributes,n=e.spec.class;i&&(this.attrs=xs(i,this.attrs||{})),n&&(this.attrs=xs({class:n},this.attrs||{}))}domAtPos(e){return Ta(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,i){var n;this.dom?this.flags&4&&(da(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(ks(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,i);let r=this.dom.lastChild;for(;r&&re.get(r)instanceof ni;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((n=re.get(r))===null||n===void 0?void 0:n.isEditable)==!1&&(!D.ios||!this.children.some(s=>s instanceof wt))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,i;for(let n of this.children){if(!(n instanceof wt)||/[^ -~]/.test(n.text))return null;let r=Ii(n.dom);if(r.length!=1)return null;e+=r[0].width,i=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:i}:null}coordsAt(e,i){let n=Da(this,e,i);if(!this.children.length&&n&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=n.bottom-n.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight<s){let o=(s-r.textHeight)/2;return{top:n.top+o,bottom:n.bottom-o,left:n.left,right:n.left}}}return n}become(e){return e instanceof un&&this.children.length==0&&e.children.length==0&&Hn(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,i){for(let n=0,r=0;n<e.children.length;n++){let s=e.children[n],o=r+s.length;if(o>=i){if(s instanceof un)return s;if(o>i)break}r=o+s.breakAfter}return null}},Hi=class Vr extends re{constructor(e,i,n){super(),this.widget=e,this.length=i,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,i,n,r,s,o){return n&&(!(n instanceof Vr)||!this.widget.compare(n.widget)||e>0&&s<=0||i<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-i),!0)}domAtPos(e){return e==0?Ce.before(this.dom):Ce.after(this.dom,e==this.length)}split(e){let i=this.length-e;this.length=e;let n=new Vr(this.widget,i,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return ps}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):q.empty}domBoundsAround(){return null}become(e){return e instanceof Vr&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,i){let n=this.widget.coordsAt(this.dom,e,i);return n||(this.widget instanceof As?null:In(this.dom.getBoundingClientRect(),this.length?e==0:i<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:i,endSide:n}=this.deco;return i==n?!1:e<0?i<0:n>0}},As=class extends Vn{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},Ts=class Ad{constructor(e,i,n,r){this.doc=e,this.pos=i,this.end=n,this.disallowBlockEffectsFor=r,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=i}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof Hi&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new be),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append($n(new ws(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof Hi)&&this.getLine()}buildText(e,i,n){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(i.slice(i.length-n)),this.getLine().append($n(new wt(this.text.slice(this.textOff,this.textOff+r)),i),n),this.atCursorPos=!0,this.textOff+=r,e-=r,n=0}}span(e,i,n,r){this.buildText(i-e,n,r),this.pos=i,this.openStart<0&&(this.openStart=r)}point(e,i,n,r,s,o){if(this.disallowBlockEffectsFor[o]&&n instanceof ri){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(i>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=i-e;if(n instanceof ri)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Hi(n.widget||si.block,l,n));else{let a=bs.create(n.widget||si.inline,l,l?0:n.startSide),c=this.atCursorPos&&!a.isEditable&&s<=r.length&&(e<i||n.startSide>0),h=!a.isEditable&&(e<i||s>r.length||n.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!c&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),c&&(f.append($n(new ws(1),r),s),s=r.length+Math.max(0,s-r.length)),f.append($n(a,r),s),this.atCursorPos=h,this.pendingBuffer=h?e<i||s>r.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=i),this.openStart<0&&(this.openStart=s)}static build(e,i,n,r,s){let o=new Ad(e,i,n,s);return o.openEnd=ne.spans(r,i,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function $n(t,e){for(let i of e)t=new ni(i,[t],t.length);return t}var si=class extends Vn{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};si.inline=new si("span"),si.block=new si("div");var oe=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(oe||(oe={})),zt=oe.LTR,Ms=oe.RTL;function La(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}var $p=La("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),zp=La("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ds=Object.create(null),et=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Ds[e]=i,Ds[i]=-e}function Ba(t){return t<=247?$p[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?zp[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}var _p=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,xt=class{get dir(){return this.level%2?Ms:zt}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let r=-1;for(let s=0;s<t.length;s++){let o=t[s];if(o.from<=e&&o.to>=e){if(o.level==i)return s;(r<0||(n!=0?n<0?o.from<e:o.to>e:t[r].level>o.level))&&(r=s)}}if(r<0)throw new RangeError("Index out of range");return r}};function Pa(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],r=e[i];if(n.from!=r.from||n.to!=r.to||n.direction!=r.direction||!Pa(n.inner,r.inner))return!1}return!0}var Q=[];function jp(t,e,i,n,r){for(let s=0;s<=n.length;s++){let o=s?n[s-1].to:e,l=s<n.length?n[s].from:i,a=s?256:r;for(let c=o,h=a,f=a;c<l;c++){let u=Ba(t.charCodeAt(c));u==512?u=h:u==8&&f==4&&(u=16),Q[c]=u==4?2:u,u&7&&(f=u),h=u}for(let c=o,h=a,f=a;c<l;c++){let u=Q[c];if(u==128)c<l-1&&h==Q[c+1]&&h&24?u=Q[c]=h:Q[c]=256;else if(u==64){let d=c+1;for(;d<l&&Q[d]==64;)d++;let p=c&&h==8||d<i&&Q[d]==8?f==1?1:8:256;for(let g=c;g<d;g++)Q[g]=p;c=d-1}else u==8&&f==1&&(Q[c]=1);h=u,u&7&&(f=u)}}}function qp(t,e,i,n,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=n.length;o++){let c=o?n[o-1].to:e,h=o<n.length?n[o].from:i;for(let f=c,u,d,p;f<h;f++)if(d=Ds[u=t.charCodeAt(f)])if(d<0){for(let g=l-3;g>=0;g-=3)if(et[g+1]==-d){let m=et[g+2],v=m&2?r:m&4?m&1?s:r:0;v&&(Q[f]=Q[et[g]]=v),l=g;break}}else{if(et.length==189)break;et[l++]=f,et[l++]=u,et[l++]=a}else if((p=Q[f])==2||p==1){let g=p==r;a=g?0:1;for(let m=l-3;m>=0;m-=3){let v=et[m+2];if(v&2)break;if(g)et[m+2]|=2;else{if(v&4)break;et[m+2]|=4}}}}}function Kp(t,e,i,n){for(let r=0,s=n;r<=i.length;r++){let o=r?i[r-1].to:t,l=r<i.length?i[r].from:e;for(let a=o;a<l;){let c=Q[a];if(c==256){let h=a+1;for(;;)if(h==l){if(r==i.length)break;h=i[r++].to,l=r<i.length?i[r].from:e}else if(Q[h]==256)h++;else break;let f=s==1,u=(h<e?Q[h]:n)==1,d=f==u?f?1:2:n;for(let p=h,g=r,m=g?i[g-1].to:t;p>a;)p==m&&(p=i[--g].from,m=g?i[g-1].to:t),Q[--p]=d;a=h}else s=c,a++}}}function Os(t,e,i,n,r,s,o){let l=n%2?2:1;if(n%2==r%2)for(let a=e,c=0;a<i;){let h=!0,f=!1;if(c==s.length||a<s[c].from){let g=Q[a];g!=l&&(h=!1,f=g==16)}let u=!h&&l==1?[]:null,d=h?n:n+1,p=a;e:for(;;)if(c<s.length&&p==s[c].from){if(f)break e;let g=s[c];if(!h)for(let m=g.to,v=c+1;;){if(m==i)break e;if(v<s.length&&s[v].from==m)m=s[v++].to;else{if(Q[m]==l)break e;break}}if(c++,u)u.push(g);else{g.from>a&&o.push(new xt(a,g.from,d));let m=g.direction==zt!=!(d%2);Es(t,m?n+1:n,r,g.inner,g.from,g.to,o),a=g.to}p=g.to}else{if(p==i||(h?Q[p]!=l:Q[p]==l))break;p++}u?Os(t,a,p,n+1,r,u,o):a<p&&o.push(new xt(a,p,d)),a=p}else for(let a=i,c=s.length;a>e;){let h=!0,f=!1;if(!c||a>s[c-1].to){let g=Q[a-1];g!=l&&(h=!1,f=g==16)}let u=!h&&l==1?[]:null,d=h?n:n+1,p=a;e:for(;;)if(c&&p==s[c-1].to){if(f)break e;let g=s[--c];if(!h)for(let m=g.from,v=c;;){if(m==e)break e;if(v&&s[v-1].to==m)m=s[--v].from;else{if(Q[m-1]==l)break e;break}}if(u)u.push(g);else{g.to<a&&o.push(new xt(g.to,a,d));let m=g.direction==zt!=!(d%2);Es(t,m?n+1:n,r,g.inner,g.from,g.to,o),a=g.from}p=g.from}else{if(p==e||(h?Q[p-1]!=l:Q[p-1]==l))break;p--}u?Os(t,p,a,n+1,r,u,o):p<a&&o.push(new xt(p,a,d)),a=p}}function Es(t,e,i,n,r,s,o){let l=e%2?2:1;jp(t,r,s,n,l),qp(t,r,s,n,l),Kp(r,s,n,l),Os(t,r,s,e,i,n,o)}function Up(t,e,i){if(!t)return[new xt(0,0,e==Ms?1:0)];if(e==zt&&!i.length&&!_p.test(t))return Ra(t.length);if(i.length)for(;t.length>Q.length;)Q[Q.length]=256;let n=[],r=e==zt?0:1;return Es(t,r,r,i,0,t.length,n),n}function Ra(t){return[new xt(0,t,0)]}var Na="";function Gp(t,e,i,n,r){var s;let o=n.head-t.from,l=xt.find(e,o,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc),a=e[l],c=a.side(r,i);if(o==c){let u=l+=r?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!r,i),c=a.side(r,i)}let h=pe(t.text,o,a.forward(r,i));(h<a.from||h>a.to)&&(h=c),Na=t.text.slice(Math.min(o,h),Math.max(o,h));let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return f&&h==c&&f.level+(r?0:1)<a.level?w.cursor(f.side(!r,i)+t.from,f.forward(r,i)?1:-1,f.level):w.cursor(h+t.from,a.forward(r,i)?-1:1,a.level)}function Jp(t,e,i){for(let n=e;n<i;n++){let r=Ba(t.charCodeAt(n));if(r==1)return zt;if(r==2||r==4)return Ms}return zt}var Ia=P.define(),Fa=P.define(),Ha=P.define(),Va=P.define(),Ls=P.define(),Wa=P.define(),$a=P.define(),Bs=P.define(),Ps=P.define(),za=P.define({combine:t=>t.some(e=>e)}),Yp=P.define({combine:t=>t.some(e=>e)}),_a=P.define(),Rs=class cl{constructor(e,i="nearest",n="nearest",r=5,s=5,o=!1){this.range=e,this.y=i,this.x=n,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new cl(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new cl(w.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},zn=K.define({map:(t,e)=>t.map(e)}),ja=K.define();function Le(t,e,i){let n=t.facet(Va);n.length?n[0](e):window.onerror&&window.onerror(String(e),i,void 0,void 0,e)||(i?console.error(i+":",e):console.error(e))}var ut=P.define({combine:t=>t.length?t[0]:!0}),Xp=0,oi=P.define({combine(t){return t.filter((e,i)=>{for(let n=0;n<i;n++)if(t[n].plugin==e.plugin)return!1;return!0})}}),je=class fl{constructor(e,i,n,r,s){this.id=e,this.create=i,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(oi.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(oi.of({plugin:this,arg:e}))}static define(e,i){const{eventHandlers:n,eventObservers:r,provide:s,decorations:o}=i||{};return new fl(Xp++,e,n,r,l=>{let a=[];return o&&a.push(Vi.of(c=>{let h=c.plugin(l);return h?o(h):U.none})),s&&a.push(s(l)),a})}static fromClass(e,i){return fl.define((n,r)=>new e(n,r),i)}},Ns=class{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(i){if(Le(e.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){Le(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(!((e=this.value)===null||e===void 0)&&e.destroy)try{this.value.destroy()}catch(i){Le(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},qa=P.define(),Is=P.define(),Vi=P.define(),Ka=P.define(),Fs=P.define(),Ua=P.define();function Ga(t,e){let i=t.state.facet(Ua);if(!i.length)return i;let n=i.map(s=>s instanceof Function?s(t):s),r=[];return ne.spans(n,e.from,e.to,{point(){},span(s,o,l,a){let c=s-e.from,h=o-e.from,f=r;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=Jp(e.text,c,h)),a>0&&f.length&&(p=f[f.length-1]).to==c&&p.direction==d)p.to=h,f=p.inner;else{let g={from:c,to:h,direction:d,inner:[]};f.push(g),f=g.inner}}}}),r}var Ja=P.define();function Hs(t){let e=0,i=0,n=0,r=0;for(let s of t.state.facet(Ja)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(i=Math.max(i,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:i,top:n,bottom:r}}var Wi=P.define(),kt=class Wr{constructor(e,i,n,r){this.fromA=e,this.toA=i,this.fromB=n,this.toB=r}join(e){return new Wr(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let i=e.length,n=this;for(;i>0;i--){let r=e[i-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(i-1,1)}}return e.splice(i,0,n),e}static extendWithRanges(e,i){if(i.length==0)return e;let n=[];for(let r=0,s=0,o=0,l=0;;r++){let a=r==e.length?null:e[r],c=o-l,h=a?a.fromB:1e9;for(;s<i.length&&i[s]<h;){let f=i[s],u=i[s+1],d=Math.max(l,f),p=Math.min(h,u);if(d<=p&&new Wr(d+c,p+c,d,p).addToSet(n),u>h)break;s+=2}if(!a)return n;new Wr(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),o=a.toA,l=a.toB}}},Ya=class Td{constructor(e,i,n){this.view=e,this.state=i,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=_e.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new kt(s,o,l,a))),this.changedRanges=r}static create(e,i,n){return new Td(e,i,n)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},Xa=class extends re{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=U.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new be],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new kt(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:a,toA:c})=>c<this.minWidthFrom||a>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((e=this.domChanged)===null||e===void 0)&&e.newSel?n=this.domChanged.newSel.head:!rg(t.changes,this.hasComposition)&&!t.selectionSet&&(n=t.state.selection.main.head));let r=n>-1?Zp(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:a,to:c}=this.hasComposition;i=new kt(a,c,t.changes.mapPos(a,-1),t.changes.mapPos(c,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(D.ie||D.chrome)&&!r&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let s=this.decorations,o=this.updateDeco(),l=ig(s,o,t.changes);return i=kt.extendWithRanges(i,l),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,t.startState.doc.length,r),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=D.chrome||D.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,s),this.flags&=-8,s&&(s.written||n.selectionRange.focusNode!=s.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(s=>s.flags&=-9);let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.children)s instanceof Hi&&s.widget instanceof As&&r.push(s.dom);n.updateGaps(r)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,r=this.childCursor(e);for(let s=n.length-1;;s--){let o=s>=0?n[s]:null;if(!o)break;let{fromA:l,toA:a,fromB:c,toB:h}=o,f,u,d,p;if(i&&i.range.fromB<h&&i.range.toB>c){let S=Ts.build(this.view.state.doc,c,i.range.fromB,this.decorations,this.dynamicDecorationMap),k=Ts.build(this.view.state.doc,i.range.toB,h,this.decorations,this.dynamicDecorationMap);u=S.breakAtStart,d=S.openStart,p=k.openEnd;let E=this.compositionView(i);k.breakAtStart?E.breakAfter=1:k.content.length&&E.merge(E.length,E.length,k.content[0],!1,k.openStart,0)&&(E.breakAfter=k.content[0].breakAfter,k.content.shift()),S.content.length&&E.merge(0,0,S.content[S.content.length-1],!0,0,S.openEnd)&&S.content.pop(),f=S.content.concat(E).concat(k.content)}else({content:f,breakAtStart:u,openStart:d,openEnd:p}=Ts.build(this.view.state.doc,c,h,this.decorations,this.dynamicDecorationMap));let{i:g,off:m}=r.findPos(a,1),{i:v,off:y}=r.findPos(l,-1);ba(this,v,y,g,m,f,u,d,p)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let i of e.effects)i.is(ja)&&(this.editContextFormatting=i.value)}compositionView(t){let e=new wt(t.text.nodeValue);e.flags|=8;for(let{deco:n}of t.marks)e=new ni(n,[e],e.length);let i=new be;return i.append(e,0),i}fixCompositionDOM(t){let e=(r,s)=>{s.flags|=8|(s.children.some(l=>l.flags&7)?1:0),this.markedForComposition.add(s);let o=re.get(r);o&&o!=s&&(o.dom=null),s.setDOM(r)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let r=t.marks.length-1;r>=-1;r--)i=n.childPos(i.off,1),n=n.children[i.i],e(r>=0?t.marks[r].node:t.text,n)}updateSelection(t=!1,e=!1){(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,r=!n&&!(this.view.state.facet(ut)||this.dom.tabIndex>-1)&&Rn(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||r))return;let s=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,l=this.moveToLine(this.domAtPos(o.anchor)),a=o.empty?l:this.moveToLine(this.domAtPos(o.head));if(D.gecko&&o.empty&&!this.hasComposition&&Qp(l)){let h=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(h,l.node.childNodes[l.offset]||null)),l=a=new Ce(h,0),s=!0}let c=this.view.observer.selectionRange;(s||!c.focusNode||(!Fi(l.node,l.offset,c.anchorNode,c.anchorOffset)||!Fi(a.node,a.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,o))&&(this.view.observer.ignore(()=>{D.android&&D.chrome&&this.dom.contains(c.focusNode)&&ng(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let h=Ni(this.view.root);if(h)if(o.empty){if(D.gecko){let f=eg(l.node,l.offset);if(f&&f!=3){let u=(f==1?ga:ma)(l.node,l.offset);u&&(l=new Ce(u.node,u.offset))}}h.collapse(l.node,l.offset),o.bidiLevel!=null&&h.caretBidiLevel!==void 0&&(h.caretBidiLevel=o.bidiLevel)}else if(h.extend){h.collapse(l.node,l.offset);try{h.extend(a.node,a.offset)}catch{}}else{let f=document.createRange();o.anchor>o.head&&([l,a]=[a,l]),f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),h.removeAllRanges(),h.addRange(f)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(l,a)),this.impreciseAnchor=l.precise?null:new Ce(c.anchorNode,c.anchorOffset),this.impreciseHead=a.precise?null:new Ce(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&Fi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=Ni(t.root),{anchorNode:n,anchorOffset:r}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let s=be.find(this,e.head);if(!s)return;let o=s.posAtStart;if(e.head==o||e.head==o+s.length)return;let l=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!l||!a||l.bottom>a.top)return;let c=this.domAtPos(e.head+e.assoc);i.collapse(c.node,c.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let h=t.observer.selectionRange;t.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=e.from&&i.collapse(n,r)}moveToLine(t){let e=this.dom,i;if(t.node!=e)return t;for(let n=t.offset;!i&&n<e.childNodes.length;n++){let r=re.get(e.childNodes[n]);r instanceof be&&(i=r.domAtPos(0))}for(let n=t.offset-1;!i&&n>=0;n--){let r=re.get(e.childNodes[n]);r instanceof be&&(i=r.domAtPos(r.length))}return i?new Ce(i.node,i.offset,!0):t}nearest(t){for(let e=t;e;){let i=re.get(e);if(i&&i.rootView==this)return i;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let n=this.children[e];if(i<n.length||n instanceof be)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let r=this.length,s=this.children.length-1;s>=0;s--){let o=this.children[s],l=r-o.breakAfter,a=l-o.length;if(l<t)break;if(a<=t&&(a<t||o.covers(-1))&&(l>t||o.covers(1))&&(!i||o instanceof be&&!(i instanceof be&&e>=0)))i=o,n=a;else if(i&&a==t&&l==t&&o instanceof Hi&&Math.abs(e)<2){if(o.deco.startSide<0)break;s&&(i=null)}r=a}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof be))return null;for(;n.children.length;){let{i:o,off:l}=n.childPos(i,1);for(;;o++){if(o==n.children.length)return null;if((n=n.children[o]).length)break}i=l}if(!(n instanceof wt))return null;let r=pe(n.text,i);if(r==i)return null;let s=$t(n.dom,i,r).getClientRects();for(let o=0;o<s.length;o++){let l=s[o];if(o==s.length-1||l.top<l.bottom&&l.left<l.right)return l}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,r=this.view.contentDOM.clientWidth,s=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==oe.LTR;for(let a=0,c=0;c<this.children.length;c++){let h=this.children[c],f=a+h.length;if(f>n)break;if(a>=i){let u=h.dom.getBoundingClientRect();if(e.push(u.height),s){let d=h.dom.lastChild,p=d?Ii(d):[];if(p.length){let g=p[p.length-1],m=l?g.right-u.left:u.right-g.left;m>o&&(o=m,this.minWidth=r,this.minWidthFrom=a,this.minWidthTo=f)}}}a=f+h.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return getComputedStyle(this.children[e].dom).direction=="rtl"?oe.RTL:oe.LTR}measureTextSize(){for(let r of this.children)if(r instanceof be){let s=r.measureTextSize();if(s)return s}let t=document.createElement("div"),e,i,n;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(t);let r=Ii(t.firstChild)[0];e=t.getBoundingClientRect().height,i=r?r.width/27:7,n=r?r.height:e,t.remove()}),{lineHeight:e,charWidth:i,textHeight:n}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new ya(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let r=n==e.viewports.length?null:e.viewports[n],s=r?r.from-1:this.length;if(s>i){let o=(e.lineBlockAt(s).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(U.replace({widget:new As(o),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!r)break;i=r.to+1}return U.set(t)}updateDeco(){let t=1,e=this.view.state.facet(Vi).map(r=>(this.dynamicDecorationMap[t++]=typeof r=="function")?r(this.view):r),i=!1,n=this.view.state.facet(Ka).map((r,s)=>{let o=typeof r=="function";return o&&(i=!0),o?r(this.view):r});for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(ne.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let a=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=a.top-t.yMargin,this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let a of this.view.state.facet(_a))try{if(a(this.view,t.range,t))return!0}catch(c){Le(this.view.state,c,"scroll handler")}let{range:e}=t,i=this.coordsAt(e.head,e.empty?e.assoc:e.head>e.anchor?-1:1),n;if(!i)return;!e.empty&&(n=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let r=Hs(this.view),s={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;Ep(this.view.scrollDOM,s,e.head<e.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,l),-l),this.view.textDirection==oe.LTR)}};function Qp(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function Qa(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let n=ga(i.focusNode,i.focusOffset),r=ma(i.focusNode,i.focusOffset),s=n||r;if(r&&n&&r.node!=n.node){let l=re.get(r.node);if(!l||l instanceof wt&&l.text!=r.node.nodeValue)s=r;else if(t.docView.lastCompositionAfterCursor){let a=re.get(n.node);!a||a instanceof wt&&a.text!=n.node.nodeValue||(s=r)}}if(t.docView.lastCompositionAfterCursor=s!=n,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function Zp(t,e,i){let n=Qa(t,i);if(!n)return null;let{node:r,from:s,to:o}=n,l=r.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(n.from,n.to)!=l)return null;let a=e.invertedDesc,c=new kt(a.mapPos(s),a.mapPos(o),s,o),h=[];for(let f=r.parentNode;;f=f.parentNode){let u=re.get(f);if(u instanceof ni)h.push({node:f,deco:u.mark});else{if(u instanceof be||f.nodeName=="DIV"&&f.parentNode==t.contentDOM)return{range:c,text:r,marks:h,line:f};if(f!=t.contentDOM)h.push({node:f,deco:new Ss({inclusive:!0,attributes:Vp(f),tagName:f.tagName.toLowerCase()})});else return null}}}function eg(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e<t.childNodes.length&&t.childNodes[e].contentEditable=="false"?2:0)}var tg=class{constructor(){this.changes=[]}compareRange(e,i){Wn(e,i,this.changes)}comparePoint(e,i){Wn(e,i,this.changes)}boundChange(e){Wn(e,e,this.changes)}};function ig(t,e,i){let n=new tg;return ne.compare(t,e,i,n),n.changes}function ng(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(i.nodeType==1&&i.contentEditable=="false")return!0;return!1}function rg(t,e){let i=!1;return e&&t.iterChangedRanges((n,r)=>{n<e.to&&r>e.from&&(i=!0)}),i}function sg(t,e,i=1){let n=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(r.length==0)return w.cursor(e);s==0?i=1:s==r.length&&(i=-1);let o=s,l=s;i<0?o=pe(r.text,s,!1):l=pe(r.text,s);let a=n(r.text.slice(o,l));for(;o>0;){let c=pe(r.text,o,!1);if(n(r.text.slice(c,o))!=a)break;o=c}for(;l<r.length;){let c=pe(r.text,l);if(n(r.text.slice(l,c))!=a)break;l=c}return w.range(o+r.from,l+r.from)}function og(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function lg(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function Vs(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function Za(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function eh(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Ws(t,e,i){let n,r,s,o,l=!1,a,c,h,f;for(let p=t.firstChild;p;p=p.nextSibling){let g=Ii(p);for(let m=0;m<g.length;m++){let v=g[m];r&&Vs(r,v)&&(v=Za(eh(v,r.bottom),r.top));let y=og(e,v),S=lg(i,v);if(y==0&&S==0)return p.nodeType==3?th(p,e,i):Ws(p,e,i);(!n||o>S||o==S&&s>y)&&(n=p,r=v,s=y,o=S,l=y?e<v.left?m>0:m<g.length-1:!0),y==0?i>v.bottom&&(!h||h.bottom<v.bottom)?(a=p,h=v):i<v.top&&(!f||f.top>v.top)&&(c=p,f=v):h&&Vs(h,v)?h=eh(h,v.bottom):f&&Vs(f,v)&&(f=Za(f,v.top))}}if(h&&h.bottom>=i?(n=a,r=h):f&&f.top<=i&&(n=c,r=f),!n)return{node:t,offset:0};let u=Math.max(r.left,Math.min(r.right,e));if(n.nodeType==3)return th(n,u,i);if(l&&n.contentEditable!="false")return Ws(n,u,i);let d=Array.prototype.indexOf.call(t.childNodes,n)+(e>=(r.left+r.right)/2?1:0);return{node:t,offset:d}}function th(t,e,i){let n=t.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;l<n;l++){let a=$t(t,l,l+1).getClientRects();for(let c=0;c<a.length;c++){let h=a[c];if(h.top==h.bottom)continue;o||(o=e-h.left);let f=(h.top>i?h.top-i:i-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&f<s){let u=e>=(h.left+h.right)/2,d=u;if((D.chrome||D.gecko)&&$t(t,l).getBoundingClientRect().left==h.right&&(d=!u),f<=0)return{node:t,offset:l+(d?1:0)};r=l+(d?1:0),s=f}}}return{node:t,offset:r>-1?r:o>0?t.nodeValue.length:0}}function ih(t,e,i,n=-1){var r,s;let o=t.contentDOM.getBoundingClientRect(),l=o.top+t.viewState.paddingTop,a,{docHeight:c}=t.viewState,{x:h,y:f}=e,u=f-l;if(u<0)return 0;if(u>c)return t.state.doc.length;for(let k=t.viewState.heightOracle.textHeight/2,E=!1;a=t.elementAtHeight(u),a.type!=Ee.Text;)for(;u=n>0?a.bottom+k:a.top-k,!(u>=0&&u<=c);){if(E)return i?null:0;E=!0,n=-n}f=l+u;let d=a.from;if(d<t.viewport.from)return t.viewport.from==0?0:i?null:nh(t,o,a,h,f);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:nh(t,o,a,h,f);let p=t.dom.ownerDocument,g=t.root.elementFromPoint?t.root:p,m=g.elementFromPoint(h,f);m&&!t.contentDOM.contains(m)&&(m=null),m||(h=Math.max(o.left+1,Math.min(o.right-1,h)),m=g.elementFromPoint(h,f),m&&!t.contentDOM.contains(m)&&(m=null));let v,y=-1;if(m&&((r=t.docView.nearest(m))===null||r===void 0?void 0:r.isEditable)!=!1){if(p.caretPositionFromPoint){let k=p.caretPositionFromPoint(h,f);k&&({offsetNode:v,offset:y}=k)}else if(p.caretRangeFromPoint){let k=p.caretRangeFromPoint(h,f);k&&({startContainer:v,startOffset:y}=k,(!t.contentDOM.contains(v)||D.safari&&ag(v,y,h)||D.chrome&&hg(v,y,h))&&(v=void 0))}v&&(y=Math.min(Ze(v),y))}if(!v||!t.docView.dom.contains(v)){let k=be.find(t.docView,d);if(!k)return u>a.top+a.height/2?a.to:a.from;({node:v,offset:y}=Ws(k.dom,h,f))}let S=t.docView.nearest(v);if(!S)return null;if(S.isWidget&&((s=S.dom)===null||s===void 0?void 0:s.nodeType)==1){let k=S.dom.getBoundingClientRect();return e.y<k.top||e.y<=k.bottom&&e.x<=(k.left+k.right)/2?S.posAtStart:S.posAtEnd}else return S.localPosFromDOM(v,y)+S.posAtStart}function nh(t,e,i,n,r){let s=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>t.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,a=Math.floor((r-i.top-(t.defaultLineHeight-l)*.5)/l);s+=a*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+Cp(o,s,t.state.tabSize)}function ag(t,e,i){let n,r=t;if(t.nodeType!=3||e!=(n=t.nodeValue.length))return!1;for(;;){let s=r.nextSibling;if(s){if(s.nodeName=="BR")break;return!1}else{let o=r.parentNode;if(!o||o.nodeName=="DIV")break;r=o}}return $t(t,n-1,n).getBoundingClientRect().right>i}function hg(t,e,i){if(e!=0)return!1;for(let r=t;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let n=t.nodeType==1?t.getBoundingClientRect():$t(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}function cg(t,e,i){let n=t.lineBlockAt(e);if(Array.isArray(n.type)){let r;for(let s of n.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!r||s.type==Ee.Text&&(r.type!=s.type||(i<0?s.from<e:s.to>e)))&&(r=s)}}return r||n}return n}function fg(t,e,i,n){let r=cg(t,e.head,e.assoc||-1),s=!n||r.type!=Ee.Text||!(t.lineWrapping||r.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(r.from),a=t.posAtCoords({x:i==(l==oe.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return w.cursor(a,i?-1:1)}return w.cursor(i?r.to:r.from,i?-1:1)}function rh(t,e,i,n){let r=t.state.doc.lineAt(e.head),s=t.bidiSpans(r),o=t.textDirectionAt(r.from);for(let l=e,a=null;;){let c=Gp(r,s,o,l,i),h=Na;if(!c){if(r.number==(i?t.state.doc.lines:1))return l;h=`
|
|
8
|
-
`,r=t.state.doc.line(r.number+(i?1:-1)),s=t.bidiSpans(r),c=t.visualLineSide(r,!i)}if(a){if(!a(h))return l}else{if(!n)return c;a=n(h)}l=c}}function ug(t,e,i){let n=t.state.charCategorizer(e),r=n(i);return s=>{let o=n(s);return r==ge.Space&&(r=o),r==o}}function dg(t,e,i,n){let r=e.head,s=i?1:-1;if(r==(i?t.state.doc.length:0))return w.cursor(r,e.assoc);let o=e.goalColumn,l,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(r,e.assoc||-1),h=t.documentTop;if(c)o==null&&(o=c.left-a.left),l=s<0?c.top:c.bottom;else{let d=t.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,t.defaultCharacterWidth*(r-d.from))),l=(s<0?d.top:d.bottom)+h}let f=a.left+o,u=n!=null?n:t.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=l+(u+d)*s,g=ih(t,{x:f,y:p},!1,s);if(p<a.top||p>a.bottom||(s<0?g<r:g>r)){let m=t.docView.coordsForChar(g),v=!m||p<m.top?-1:1;return w.cursor(g,v,void 0,o)}}}function _n(t,e,i){for(;;){let n=0;for(let r of t)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=n||i||(e-s<o-e?-1:1);e=a<0?s:o,n=a}});if(!n)return e}}function $s(t,e,i){let n=_n(t.state.facet(Fs).map(r=>r(t)),i.from,e.head>i.from?-1:1);return n==i.from?i:w.cursor(n,n<i.from?1:-1)}var $i="",pg=class{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(ie.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=$i}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let r=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let o=re.get(n),l=re.get(s);(o&&l?o.breakAfter:(o?o.breakAfter:Nn(n))||Nn(s)&&(n.nodeName!="BR"||n.cmIgnore)&&this.text.length>r)&&this.lineBreak(),n=s}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,s=1,o;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),s=this.lineSeparator.length):(o=n.exec(e))&&(r=o.index,s=o[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),s>1)for(let l of this.points)l.node==t&&l.pos>this.text.length&&(l.pos-=s-1);i=r+s}}readNode(t){if(t.cmIgnore)return;let e=re.get(t),i=e&&e.overrideDOMText;if(i!=null){this.findPointInside(t,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(t.nodeType==3?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(gg(t,i.node,i.offset)?e:0))}};function gg(t,e,i){for(;;){if(!e||i<Ze(e))return!1;if(e==t)return!0;i=Wt(e)+1,e=e.parentNode}}var sh=class{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}},mg=class{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:r,impreciseAnchor:s}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let o=r||s?[]:bg(t),l=new pg(o,t.state);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=wg(o,this.bounds.from)}else{let o=t.observer.selectionRange,l=r&&r.node==o.focusNode&&r.offset==o.focusOffset||!ds(t.contentDOM,o.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(o.focusNode,o.focusOffset),a=s&&s.node==o.anchorNode&&s.offset==o.anchorOffset||!ds(t.contentDOM,o.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(o.anchorNode,o.anchorOffset),c=t.viewport;if((D.ios||D.chrome)&&t.state.selection.main.empty&&l!=a&&(c.from>0||c.to<t.state.doc.length)){let h=Math.min(l,a),f=Math.max(l,a),u=c.from-h,d=c.to-f;(u==0||u==1||h==0)&&(d==0||d==-1||f==t.state.doc.length)&&(l=0,a=t.state.doc.length)}this.newSel=w.single(a,l)}}};function oh(t,e){let i,{newSel:n}=e,r=t.state.selection.main,s=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=r.from,c=null;(s===8||D.android&&e.text.length<l-o)&&(a=r.to,c="end");let h=yg(t.state.doc.sliceString(o,l,$i),e.text,a-o,c);h&&(D.chrome&&s==13&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==$i+$i&&h.toB--,i={from:o+h.from,to:o+h.toA,insert:q.of(e.text.slice(h.from,h.toB).split($i))})}else n&&(!t.hasFocus&&t.state.facet(ut)||n.main.eq(r))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!r.empty&&n&&n.main.empty?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,r.to)}:(D.mac||D.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(n&&i.insert.length==2&&(n=w.single(n.main.anchor-1,n.main.head-1)),i={from:i.from,to:i.to,insert:q.of([i.insert.toString().replace("."," ")])}):i&&i.from>=r.from&&i.to<=r.to&&(i.from!=r.from||i.to!=r.to)&&r.to-r.from-(i.to-i.from)<=4?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,r.to))}:D.chrome&&i&&i.from==i.to&&i.from==r.head&&i.insert.toString()==`
|
|
9
|
-
`&&t.lineWrapping&&(n&&(n=w.single(n.main.anchor-1,n.main.head-1)),i={from:r.from,to:r.to,insert:q.of([" "])}),i)return zs(t,i,n,s);if(n&&!n.main.eq(r)){let o=!1,l="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(o=!0),l=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:o,userEvent:l}),!0}else return!1}function zs(t,e,i,n=-1){if(D.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(D.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&t.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ii(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&ii(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&ii(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=vg(t,e,i));return t.state.facet(Wa).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function vg(t,e,i){let n,r=t.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let l=s.from<e.from?r.sliceDoc(s.from,e.from):"",a=s.to>e.to?r.sliceDoc(e.to,s.to):"";n=r.replaceSelection(t.state.toText(l+e.insert.sliceString(0,void 0,t.state.lineBreak)+a))}else{let l=r.changes(e),a=i&&i.main.to<=l.newLength?i.main:void 0;if(r.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let c=t.state.sliceDoc(e.from,e.to),h,f=i&&Qa(t,i.main.head);if(f){let p=e.insert.length-(e.to-e.from);h={from:f.from,to:f.to-p}}else h=t.state.doc.lineAt(s.head);let u=s.to-e.to,d=s.to-s.from;n=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:l,range:a||p.map(l)};let g=p.to-u,m=g-c.length;if(p.to-p.from!=d||t.state.sliceDoc(m,g)!=c||p.to>=h.from&&p.from<=h.to)return{range:p};let v=r.changes({from:m,to:g,insert:e.insert}),y=p.to-s.to;return{changes:v,range:a?w.range(Math.max(0,a.anchor+y),Math.max(0,a.head+y)):p.map(v)}})}else n={changes:l,selection:a&&r.selection.replaceRange(a)}}let o="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,o+=".compose",t.inputState.compositionFirstChange&&(o+=".start",t.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:o,scrollIntoView:!0})}function yg(t,e,i,n){let r=Math.min(t.length,e.length),s=0;for(;s<r&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&t.length==e.length)return null;let o=t.length,l=e.length;for(;o>0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(n=="end"){let a=Math.max(0,s-Math.min(o,l));i-=o+a-s}if(o<s&&t.length<e.length){let a=i<=s&&i>=o?s-i:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=i<=s&&i>=l?s-i:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function bg(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}=t.observer.selectionRange;return i&&(e.push(new sh(i,n)),(r!=i||s!=n)&&e.push(new sh(r,s))),e}function wg(t,e){if(t.length==0)return null;let i=t[0].pos,n=t.length==2?t[1].pos:i;return i>-1&&n>-1?w.single(i+e,n+e):null}var xg=class{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,D.safari&&t.contentDOM.addEventListener("input",()=>null),D.gecko&&Fg(t.contentDOM.ownerDocument)}handleEvent(t){!Og(this.view,t)||this.ignoreDuringComposition(t)||t.type=="keydown"&&this.keydown(t)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let n of i.observers)n(this.view,e);for(let n of i.handlers){if(e.defaultPrevented)break;if(n(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=kg(t),i=this.handlers,n=this.view.contentDOM;for(let r in e)if(r!="scroll"){let s=!e[r].handlers.length,o=i[r];o&&s!=!o.handlers.length&&(n.removeEventListener(r,this.handleEvent),o=null),o||n.addEventListener(r,this.handleEvent,{passive:s})}for(let r in i)r!="scroll"&&!e[r]&&n.removeEventListener(r,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&t.keyCode!=27&&hh.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),D.android&&D.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return D.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((e=ah.find(i=>i.keyCode==t.keyCode))&&!t.ctrlKey||Sg.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0):(t.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(t){let e=this.pendingIOSKey;return!e||e.key=="Enter"&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString())?!1:(this.pendingIOSKey=void 0,ii(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0))}ignoreDuringComposition(t){return/^key/.test(t.type)?this.composing>0?!0:D.safari&&!D.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function lh(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(r){Le(i.state,r)}}}function kg(t){let e=Object.create(null);function i(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of t){let r=n.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&i(l).handlers.push(lh(n.value,a))}if(o)for(let l in o){let a=o[l];a&&i(l).observers.push(lh(n.value,a))}}for(let n in qe)i(n).handlers.push(qe[n]);for(let n in Be)i(n).observers.push(Be[n]);return e}var ah=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Sg="dthko",hh=[16,17,18,20,91,92,224,225],jn=6;function qn(t){return Math.max(0,t)*.7+8}function Cg(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}var Ag=class{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=Lp(t.contentDOM),this.atoms=t.state.facet(Fs).map(s=>s(t));let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(ie.allowMultipleSelections)&&Tg(t,e),this.dragging=Dg(t,e)&&yh(e)==1?null:!1}start(t){this.dragging===!1&&this.select(t)}move(t){if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Cg(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let e=0,i=0,n=0,r=0,s=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:s}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:o}=this.scrollParents.y.getBoundingClientRect());let l=Hs(this.view);t.clientX-l.left<=n+jn?e=-qn(n-t.clientX):t.clientX+l.right>=s-jn&&(e=qn(t.clientX-s)),t.clientY-l.top<=r+jn?i=-qn(r-t.clientY):t.clientY+l.bottom>=o-jn&&(i=qn(t.clientY-o)),this.setScrollSpeed(e,i)}up(t){this.dragging==null&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],r=null;if(n.empty){let s=_n(this.atoms,n.from,0);s!=n.from&&(r=w.cursor(s,-1))}else{let s=_n(this.atoms,n.from,-1),o=_n(this.atoms,n.to,1);(s!=n.from||o!=n.to)&&(r=w.range(n.from==n.anchor?s:o,n.from==n.head?s:o))}r&&(e||(e=t.ranges.slice()),e[i]=r)}return e?w.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));(this.mustSelect||!i.eq(e.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}};function Tg(t,e){let i=t.state.facet(Ia);return i.length?i[0](e):D.mac?e.metaKey:e.ctrlKey}function Mg(t,e){let i=t.state.facet(Fa);return i.length?i[0](e):D.mac?!e.altKey:!e.ctrlKey}function Dg(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=Ni(t.root);if(!n||n.rangeCount==0)return!0;let r=n.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Og(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i=e.target,n;i!=t.contentDOM;i=i.parentNode)if(!i||i.nodeType==11||(n=re.get(i))&&n.ignoreEvent(e))return!1;return!0}var qe=Object.create(null),Be=Object.create(null),ch=D.ie&&D.ie_version<15||D.ios&&D.webkit_version<604;function Eg(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{t.focus(),i.remove(),fh(t,i.value)},50)}function Kn(t,e,i){for(let n of t.facet(e))i=n(i,t);return i}function fh(t,e){e=Kn(t.state,Bs,e);let{state:i}=t,n,r=1,s=i.toText(e),o=s.lines==i.selection.ranges.length;if(_s!=null&&i.selection.ranges.every(a=>a.empty)&&_s==s.toString()){let a=-1;n=i.changeByRange(c=>{let h=i.doc.lineAt(c.from);if(h.from==a)return{range:c};a=h.from;let f=i.toText((o?s.line(r++).text:e)+i.lineBreak);return{changes:{from:h.from,insert:f},range:w.cursor(c.from+f.length)}})}else o?n=i.changeByRange(a=>{let c=s.line(r++);return{changes:{from:a.from,to:a.to,insert:c.text},range:w.cursor(a.from+c.length)}}):n=i.replaceSelection(s);t.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}Be.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},qe.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),Be.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Be.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},qe.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(Ha))if(i=n(t,e),i)break;if(!i&&e.button==0&&(i=Pg(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new Ag(t,e,i,n)),n&&t.observer.ignore(()=>{fa(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let r=t.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}return!1};function uh(t,e,i,n){if(n==1)return w.cursor(e,i);if(n==2)return sg(t.state,e,i);{let r=be.find(t.docView,e),s=t.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<t.state.doc.length&&l==s.to&&l++,w.range(o,l)}}var dh=(t,e,i)=>e>=i.top&&e<=i.bottom&&t>=i.left&&t<=i.right;function Lg(t,e,i,n){let r=be.find(t.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&dh(i,n,o))return-1;let l=r.coordsAt(s,1);return l&&dh(i,n,l)?1:o&&o.bottom>=n?-1:1}function ph(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Lg(t,i,e.clientX,e.clientY)}}var Bg=D.ie&&D.ie_version<=11,gh=null,mh=0,vh=0;function yh(t){if(!Bg)return t.detail;let e=gh,i=vh;return gh=t,vh=Date.now(),mh=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(mh+1)%3:1}function Pg(t,e){let i=ph(t,e),n=yh(e),r=t.state.selection;return{update(s){s.docChanged&&(i.pos=s.changes.mapPos(i.pos),r=r.map(s.changes))},get(s,o,l){let a=ph(t,s),c,h=uh(t,a.pos,a.bias,n);if(i.pos!=a.pos&&!o){let f=uh(t,i.pos,i.bias,n),u=Math.min(f.from,h.from),d=Math.max(f.to,h.to);h=u<h.from?w.range(u,d):w.range(d,u)}return o?r.replaceRange(r.main.extend(h.from,h.to)):l&&n==1&&r.ranges.length>1&&(c=Rg(r,a.pos))?c:l?r.addRange(h):w.create([h])}}}function Rg(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:r}=t.ranges[i];if(n<=e&&r>=e)return w.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}qe.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let r=t.docView.nearest(e.target);if(r&&r.isWidget){let s=r.posAtStart,o=s+r.length;(s>=i.to||o<=i.from)&&(i=w.range(s,o))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",Kn(t.state,Ps,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1},qe.dragend=t=>(t.inputState.draggedContent=null,!1);function bh(t,e,i,n){if(i=Kn(t.state,Bs,i),!i)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=n&&s&&Mg(t,e)?{from:s.from,to:s.to}:null,l={from:r,insert:i},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}qe.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),r=0,s=()=>{++r==i.length&&bh(t,e,n.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o<i.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[o]=l.result),s()},l.readAsText(i[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return bh(t,e,n,!0),!0}return!1},qe.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=ch?null:e.clipboardData;return i?(fh(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(Eg(t),!1)};function Ng(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),t.focus()},50)}function Ig(t){let e=[],i=[],n=!1;for(let r of t.selection.ranges)r.empty||(e.push(t.sliceDoc(r.from,r.to)),i.push(r));if(!e.length){let r=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>r&&(e.push(o.text),i.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),r=o.number}n=!0}return{text:Kn(t,Ps,e.join(t.lineBreak)),ranges:i,linewise:n}}var _s=null;qe.copy=qe.cut=(t,e)=>{let{text:i,ranges:n,linewise:r}=Ig(t.state);if(!i&&!r)return!1;_s=r?i:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=ch?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",i),!0):(Ng(t,i),!1)};var wh=ft.define();function xh(t,e){let i=[];for(let n of t.facet($a)){let r=n(t,e);r&&i.push(r)}return i.length?t.update({effects:i,annotations:wh.of(!0)}):null}function kh(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=xh(t.state,e);i?t.dispatch(i):t.update([])}},10)}Be.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),kh(t)},Be.blur=t=>{t.observer.clearSelectionRange(),kh(t)},Be.compositionstart=Be.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},Be.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,D.chrome&&D.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},Be.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},qe.beforeinput=(t,e)=>{var i,n;if(e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(i=e.dataTransfer)===null||i===void 0?void 0:i.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=t.posAtDOM(l.startContainer,l.startOffset),c=t.posAtDOM(l.endContainer,l.endOffset);return zs(t,{from:a,to:c,insert:t.state.toText(s)},null),!0}}let r;if(D.chrome&&D.android&&(r=ah.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return D.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),D.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>Be.compositionend(t,e),20),!1};var Sh=new Set;function Fg(t){Sh.has(t)||(Sh.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}var Ch=["pre-wrap","normal","pre-line","break-spaces"],li=!1;function Ah(){li=!1}var Hg=class{constructor(t){this.lineWrapping=t,this.doc=q.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Ch.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(n*10)]||(e=!0,this.heightSamples[Math.floor(n*10)]=!0)}return e}refresh(t,e,i,n,r,s){let o=Ch.indexOf(t)>-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=r,l){this.heightSamples={};for(let a=0;a<s.length;a++){let c=s[a];c<0?a++:this.heightSamples[Math.floor(c*10)]=!0}}return l}},Vg=class{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}},St=class Md{constructor(e,i,n,r,s){this.from=e,this.length=i,this.top=n,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Ee.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof ri?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let i=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Md(this.from,this.length+e.length,this.top,this.height+e.height,i)}},Z=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(Z||(Z={})),Un=.001,Ke=class $r{constructor(e,i,n=2){this.length=e,this.height=i,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Un&&(li=!0),this.height=e)}replace(e,i,n){return $r.of(n)}decomposeLeft(e,i){i.push(this)}decomposeRight(e,i){i.push(this)}applyChanges(e,i,n,r){let s=this,o=n.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:c,fromB:h,toB:f}=r[l],u=s.lineAt(a,Z.ByPosNoHeight,n.setDoc(i),0,0),d=u.to>=c?u:s.lineAt(c,Z.ByPosNoHeight,n,0,0);for(f+=d.to-c,c=d.to;l>0&&u.from<=r[l-1].toA;)a=r[l-1].fromA,h=r[l-1].fromB,l--,a<u.from&&(u=s.lineAt(a,Z.ByPosNoHeight,n,0,0));h+=u.from-a,a=u.from;let p=zg.build(n.setDoc(o),e,h,f);s=Gn(s,s.replace(a,c,p))}return s.updateHeight(n,0)}static empty(){return new tt(0,0)}static of(e){if(e.length==1)return e[0];let i=0,n=e.length,r=0,s=0;for(;;)if(i==n)if(r>s*2){let l=e[i-1];l.break?e.splice(--i,1,l.left,null,l.right):e.splice(--i,1,l.left,l.right),n+=1+l.break,r-=l.size}else if(s>r*2){let l=e[n];l.break?e.splice(n,1,l.left,null,l.right):e.splice(n,1,l.left,l.right),n+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[i++];l&&(r+=l.size)}else{let l=e[--n];l&&(s+=l.size)}let o=0;return e[i-1]==null?(o=1,i--):e[i]==null&&(o=1,n++),new Wg($r.of(e.slice(0,i)),o,$r.of(e.slice(n)))}};function Gn(t,e){return t==e?t:(t.constructor!=e.constructor&&(li=!0),e)}Ke.prototype.size=1;var Th=class extends Ke{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new St(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,r){return this.blockAt(0,i,n,r)}forEachLine(t,e,i,n,r,s){t<=r+this.length&&e>=r&&s(this.blockAt(0,i,n,r))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},tt=class ul extends Th{constructor(e,i){super(e,i,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,i,n,r){return new St(r,this.length,n,this.height,this.breaks)}replace(e,i,n){let r=n[0];return n.length==1&&(r instanceof ul||r instanceof ai&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof ai?r=new ul(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Ke.of(n)}updateHeight(e,i=0,n=!1,r){return r&&r.from<=i&&r.more?this.setHeight(r.heights[r.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},ai=class Je extends Ke{constructor(e){super(e,0)}heightMetrics(e,i){let n=e.doc.lineAt(i).number,r=e.doc.lineAt(i+this.length).number,s=r-n+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:r,perLine:o,perChar:l}}blockAt(e,i,n,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(i,r);if(i.lineWrapping){let c=r+(e<i.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),h=i.doc.lineAt(c),f=l+h.length*a,u=Math.max(n,e-f/2);return new St(h.from,h.length,u,f,0)}else{let c=Math.max(0,Math.min(o-s,Math.floor((e-n)/l))),{from:h,length:f}=i.doc.line(s+c);return new St(h,f,n+l*c,l,0)}}lineAt(e,i,n,r,s){if(i==Z.ByHeight)return this.blockAt(e,n,r,s);if(i==Z.ByPosNoHeight){let{from:d,to:p}=n.doc.lineAt(e);return new St(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,s),c=n.doc.lineAt(e),h=l+c.length*a,f=c.number-o,u=r+l*f+a*(c.from-s-f);return new St(c.from,c.length,Math.max(r,Math.min(u,r+this.height-h)),h,0)}forEachLine(e,i,n,r,s,o){e=Math.max(e,s),i=Math.min(i,s+this.length);let{firstLine:l,perLine:a,perChar:c}=this.heightMetrics(n,s);for(let h=e,f=r;h<=i;){let u=n.doc.lineAt(h);if(h==e){let p=u.number-l;f+=a*p+c*(e-s-p)}let d=a+c*u.length;o(new St(u.from,u.length,f,d,0)),f+=d,h=u.to+1}}replace(e,i,n){let r=this.length-i;if(r>0){let s=n[n.length-1];s instanceof Je?n[n.length-1]=new Je(s.length+r):n.push(null,new Je(r-1))}if(e>0){let s=n[0];s instanceof Je?n[0]=new Je(e+s.length):n.unshift(new Je(e-1),null)}return Ke.of(n)}decomposeLeft(e,i){i.push(new Je(e-1),null)}decomposeRight(e,i){i.push(null,new Je(this.length-e-1))}updateHeight(e,i=0,n=!1,r){let s=i+this.length;if(r&&r.from<=i+this.length&&r.more){let o=[],l=Math.max(i,r.from),a=-1;for(r.from>i&&o.push(new Je(r.from-i-1).updateHeight(e,i));l<=s&&r.more;){let h=e.doc.lineAt(l).length;o.length&&o.push(null);let f=r.heights[r.index++];a==-1?a=f:Math.abs(f-a)>=Un&&(a=-2);let u=new tt(h,f);u.outdated=!1,o.push(u),l+=h+1}l<=s&&o.push(null,new Je(s-l).updateHeight(e,l));let c=Ke.of(o);return(a<0||Math.abs(c.height-this.height)>=Un||Math.abs(a-this.heightMetrics(e,i).perLine)>=Un)&&(li=!0),Gn(this,c)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(i,i+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Wg=class extends Ke{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return this.flags&1}blockAt(t,e,i,n){let r=i+this.left.height;return t<r?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,r,n+this.left.length+this.break)}lineAt(t,e,i,n,r){let s=n+this.left.height,o=r+this.left.length+this.break,l=e==Z.ByHeight?t<s:t<o,a=l?this.left.lineAt(t,e,i,n,r):this.right.lineAt(t,e,i,s,o);if(this.break||(l?a.to<o:a.from>o))return a;let c=e==Z.ByPosNoHeight?Z.ByPosNoHeight:Z.ByPos;return l?a.join(this.right.lineAt(o,c,i,s,o)):this.left.lineAt(o,c,i,n,r).join(a)}forEachLine(t,e,i,n,r,s){let o=n+this.left.height,l=r+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,i,n,r,s),e>=l&&this.right.forEachLine(t,e,i,o,l,s);else{let a=this.lineAt(l,Z.ByPos,i,n,r);t<a.from&&this.left.forEachLine(t,a.from-1,i,n,r,s),a.to>=t&&a.from<=e&&s(a),e>a.to&&this.right.forEachLine(a.to+1,e,i,o,l,s)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let r=[];t>0&&this.decomposeLeft(t,r);let s=r.length;for(let o of i)r.push(o);if(t>0&&Mh(r,s-1),e<this.length){let o=r.length;this.decomposeRight(e,r),Mh(r,o)}return Ke.of(r)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?Ke.of(this.break?[t,null,e]:[t,e]):(this.left=Gn(this.left,t),this.right=Gn(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:r,right:s}=this,o=e+r.length+this.break,l=null;return n&&n.from<=e+r.length&&n.more?l=r=r.updateHeight(t,e,i,n):r.updateHeight(t,e,i),n&&n.from<=o+s.length&&n.more?l=s=s.updateHeight(t,o,i,n):s.updateHeight(t,o,i),l?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Mh(t,e){let i,n;t[e]==null&&(i=t[e-1])instanceof ai&&(n=t[e+1])instanceof ai&&t.splice(e-1,3,new ai(i.length+1+n.length))}var $g=5,zg=class Dd{constructor(e,i){this.pos=e,this.oracle=i,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,i){if(this.lineStart>-1){let n=Math.min(i,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof tt?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new tt(n-this.pos,-1)),this.writtenTo=n,i>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=i}point(e,i,n){if(e<i||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=i-e;n.block?this.addBlock(new Th(o,r,n)):(o||s||r>=$g)&&this.addLineDeco(r,s,o)}else i>e&&this.span(e,i);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:i}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=i,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new tt(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,i){let n=new ai(i-e);return this.oracle.doc.lineAt(e).to==i&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof tt)return e;let i=new tt(0,-1);return this.nodes.push(i),i}addBlock(e){this.enterLine();let i=e.deco;i&&i.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,i&&i.endSide>0&&(this.covering=e)}addLineDeco(e,i,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=i,this.writtenTo=this.pos=this.pos+n}finish(e){let i=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(i instanceof tt)&&!this.isCovered?this.nodes.push(new tt(0,-1)):(this.writtenTo<this.pos||i==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let r of this.nodes)r instanceof tt&&r.updateHeight(this.oracle,n),n+=r?r.length:1;return this.nodes}static build(e,i,n,r){let s=new Dd(n,e);return ne.spans(i,n,r,s,0),s.finish(n)}};function _g(t,e,i){let n=new jg;return ne.compare(t,e,i,n,0),n.changes}var jg=class{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Wn(t,e,this.changes,5)}};function qg(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,r=n.defaultView||window,s=Math.max(0,i.left),o=Math.min(r.innerWidth,i.right),l=Math.max(0,i.top),a=Math.min(r.innerHeight,i.bottom);for(let c=t.parentNode;c&&c!=n.body;)if(c.nodeType==1){let h=c,f=window.getComputedStyle(h);if((h.scrollHeight>h.clientHeight||h.scrollWidth>h.clientWidth)&&f.overflow!="visible"){let u=h.getBoundingClientRect();s=Math.max(s,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(c==t.parentNode?r.innerHeight:a,u.bottom)}c=f.position=="absolute"||f.position=="fixed"?h.offsetParent:h.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-i.left,right:Math.max(s,o)-i.left,top:l-(i.top+e),bottom:Math.max(l,a)-(i.top+e)}}function Kg(t){let e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||window;return e.left<i.innerWidth&&e.right>0&&e.top<i.innerHeight&&e.bottom>0}function Ug(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}var js=class{constructor(t,e,i,n){this.from=t,this.to=e,this.size=i,this.displaySize=n}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],r=e[i];if(n.from!=r.from||n.to!=r.to||n.size!=r.size)return!1}return!0}draw(t,e){return U.replace({widget:new Gg(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}},Gg=class extends Vn{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}},Dh=class{constructor(t){this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Oh,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=oe.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Is).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new Hg(e),this.stateDeco=t.facet(Vi).filter(i=>typeof i!="function"),this.heightMap=Ke.empty().applyChanges(this.stateDeco,q.empty,this.heightOracle.setDoc(t.doc),[new kt(0,0,0,t.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=U.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some(({from:r,to:s})=>n>=r&&n<=s)){let{from:r,to:s}=this.lineBlockAt(n);t.push(new Jn(r,s))}}return this.viewports=t.sort((i,n)=>i.from-n.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?Oh:new Xg(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(zi(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Vi).filter(c=>typeof c!="function");let n=t.changedRanges,r=kt.extendWithRanges(n,_g(i,this.stateDeco,t?t.changes:_e.empty(this.state.doc.length))),s=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Ah(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=s||li)&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=s);let l=r.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let a=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,t.flags|=this.updateForViewport(),(a||!t.changes.empty||t.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(Yp)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?oe.RTL:oe.LTR;let s=this.heightOracle.mustRefreshForWrapping(r),o=e.getBoundingClientRect(),l=s||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let a=0,c=0;if(o.width&&o.height){let{scaleX:S,scaleY:k}=ca(e,o);(S>.005&&Math.abs(this.scaleX-S)>.005||k>.005&&Math.abs(this.scaleY-k)>.005)&&(this.scaleX=S,this.scaleY=k,a|=16,s=l=!0)}let h=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=h||this.paddingBottom!=f)&&(this.paddingTop=h,this.paddingBottom=f,a|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=16);let u=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=u&&(this.scrollAnchorHeight=-1,this.scrollTop=u),this.scrolledToBottom=pa(t.scrollDOM);let d=(this.printing?Ug:qg)(e,this.paddingTop),p=d.top-this.pixelViewport.top,g=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(l=!0)),!this.inView&&!this.scrollTarget&&!Kg(t.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=t.scrollDOM.clientHeight,a|=16),l){let S=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(S)&&(s=!0),s||n.lineWrapping&&Math.abs(v-this.contentDOMWidth)>n.charWidth){let{lineHeight:k,charWidth:E,textHeight:H}=t.docView.measureTextSize();s=k>0&&n.refresh(r,k,E,H,v/E,S),s&&(t.docView.minWidth=0,a|=16)}p>0&&g>0?c=Math.max(p,g):p<0&&g<0&&(c=Math.min(p,g)),Ah();for(let k of this.viewports){let E=k.from==this.viewport.from?S:t.docView.measureVisibleLineHeights(k);this.heightMap=(s?Ke.empty().applyChanges(this.stateDeco,q.empty,this.heightOracle,[new kt(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,s,new Vg(k.from,E))}li&&(a|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(a&2&&(a|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),a|=this.updateForViewport()),(a&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:s,visibleBottom:o}=this,l=new Jn(n.lineAt(s-i*1e3,Z.ByHeight,r,0,0).from,n.lineAt(o+(1-i)*1e3,Z.ByHeight,r,0,0).to);if(e){let{head:a}=e.range;if(a<l.from||a>l.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),h=n.lineAt(a,Z.ByPos,r,0,0),f;e.y=="center"?f=(h.top+h.bottom)/2-c/2:e.y=="start"||e.y=="nearest"&&a<l.from?f=h.top:f=h.bottom-c,l=new Jn(n.lineAt(f-1e3/2,Z.ByHeight,r,0,0).from,n.lineAt(f+c+1e3/2,Z.ByHeight,r,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new Jn(this.heightMap.lineAt(i,Z.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,Z.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,Z.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(e,Z.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:o}=this;return(t==0||n<=s-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||r>=o+Math.max(10,Math.min(i,250)))&&n>s-2*1e3&&r<o+2*1e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new js(e.mapPos(n.from),e.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,r=n>>1,s=n<<1;if(this.defaultTextDirection!=oe.LTR&&!i)return[];let o=[],l=(c,h,f,u)=>{if(h-c<r)return;let d=this.state.selection.main,p=[d.from];d.empty||p.push(d.to);for(let m of p)if(m>c&&m<h){l(c,m-10,f,u),l(m+10,h,f,u);return}let g=Yg(t,m=>m.from>=f.from&&m.to<=f.to&&Math.abs(m.from-c)<r&&Math.abs(m.to-h)<r&&!p.some(v=>m.from<v&&m.to>v));if(!g){if(h<f.to&&e&&i&&e.visibleRanges.some(y=>y.from<=h&&y.to>=h)){let y=e.moveToLineBoundary(w.cursor(h),!1,!0).head;y>c&&(h=y)}let m=this.gapSize(f,c,h,u),v=i||m<2e6?m:2e6;g=new js(c,h,m,v)}o.push(g)},a=c=>{if(c.length<s||c.type!=Ee.Text)return;let h=Jg(c.from,c.to,this.stateDeco);if(h.total<s)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,u,d;if(i){let p=n/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,m;if(f!=null){let v=Xn(h,f),y=((this.visibleBottom-this.visibleTop)/2+p)/c.height;g=v-y,m=v+y}else g=(this.visibleTop-c.top-p)/c.height,m=(this.visibleBottom-c.top+p)/c.height;u=Yn(h,g),d=Yn(h,m)}else{let p=h.total*this.heightOracle.charWidth,g=n*this.heightOracle.charWidth,m=0;if(p>2e6)for(let E of t)E.from>=c.from&&E.from<c.to&&E.size!=E.displaySize&&E.from*this.heightOracle.charWidth+m<this.pixelViewport.left&&(m=E.size-E.displaySize);let v=this.pixelViewport.left+m,y=this.pixelViewport.right+m,S,k;if(f!=null){let E=Xn(h,f),H=((y-v)/2+g)/p;S=E-H,k=E+H}else S=(v-g)/p,k=(y+g)/p;u=Yn(h,S),d=Yn(h,k)}u>c.from&&l(c.from,u,c,h),d<c.to&&l(d,c.to,c,h)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(a):a(c);return o}gapSize(t,e,i,n){let r=Xn(n,i)-Xn(n,e);return this.heightOracle.lineWrapping?t.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(t){js.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=U.set(t.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];ne.spans(e,this.viewport.from,this.viewport.to,{span(r,s){i.push({from:r,to:s})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let r=0;r<i.length&&!(n&8);r++){let s=this.visibleRanges[r],o=i[r];(s.from!=o.from||s.to!=o.to)&&(n|=4,t&&t.mapPos(s.from,-1)==o.from&&t.mapPos(s.to,1)==o.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||zi(this.heightMap.lineAt(t,Z.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||zi(this.heightMap.lineAt(this.scaler.fromDOM(t),Z.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return zi(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Jn=class{constructor(t,e){this.from=t,this.to=e}};function Jg(t,e,i){let n=[],r=t,s=0;return ne.spans(i,t,e,{span(){},point(o,l){o>r&&(n.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(n.push({from:r,to:e}),s+=e-r),{total:s,ranges:n}}function Yn({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(n<=l)return s+n;n-=l}}function Xn(t,e){let i=0;for(let{from:n,to:r}of t.ranges){if(e<=r){i+=e-n;break}i+=r-n}return i/t.total}function Yg(t,e){for(let i of t)if(e(i))return i}var Oh={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}},Xg=class Od{constructor(e,i,n){let r=0,s=0,o=0;this.viewports=n.map(({from:l,to:a})=>{let c=i.lineAt(l,Z.ByPos,e,0,0).top,h=i.lineAt(a,Z.ByPos,e,0,0).bottom;return r+=h-c,{from:l,to:a,top:c,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(i.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let i=0,n=0,r=0;;i++){let s=i<this.viewports.length?this.viewports[i]:null;if(!s||e<s.top)return r+(e-n)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);n=s.bottom,r=s.domBottom}}fromDOM(e){for(let i=0,n=0,r=0;;i++){let s=i<this.viewports.length?this.viewports[i]:null;if(!s||e<s.domTop)return n+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);n=s.bottom,r=s.domBottom}}eq(e){return e instanceof Od?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((i,n)=>i.from==e.viewports[n].from&&i.to==e.viewports[n].to):!1}};function zi(t,e){if(e.scale==1)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new St(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map(r=>zi(r,e)):t._content)}var Qn=P.define({combine:t=>t.join(" ")}),qs=P.define({combine:t=>t.indexOf(!0)>-1}),Ks=yt.newName(),Eh=yt.newName(),Lh=yt.newName(),Bh={"&light":"."+Eh,"&dark":"."+Lh};function Us(t,e,i){return new yt(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,r=>{if(r=="&")return t;if(!i||!i[r])throw new RangeError(`Unsupported selector: ${r}`);return i[r]}):t+" "+n}})}var Qg=Us("."+Ks,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Bh),Zg={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Gs=D.ie&&D.ie_version<=11,em=class{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new Bp,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let i of e)this.queue.push(i);(D.ie&&D.ie_version<=11||D.ios&&t.composing)&&e.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&D.android&&t.constructor.EDIT_CONTEXT!==!1&&!(D.chrome&&D.chrome_version<126)&&(this.editContext=new im(t),t.state.facet(ut)&&(t.contentDOM.editContext=this.editContext.editContext)),Gs&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var e;((e=this.view.docView)===null||e===void 0?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){(t.type=="change"||!t.type)&&!t.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(ut)?i.root.activeElement!=this.dom:!Rn(this.dom,n))return;let r=n.anchorNode&&i.docView.nearest(n.anchorNode);if(r&&r.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(D.ie&&D.ie_version<=11||D.android&&D.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Fi(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Ni(t.root);if(!e)return!1;let i=D.safari&&t.root.nodeType==11&&t.root.activeElement==this.dom&&tm(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=Rn(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&Rp(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(i.nodeType==1)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=e)i.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Zg),Gs&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Gs&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let n=()=>{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&ii(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let r of t){let s=this.readMutation(r);s&&(s.typeOver&&(n=!0),e==-1?{from:e,to:i}=s:(e=Math.min(s.from,e),i=Math.max(s.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&Rn(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new mg(this.view,t,e,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=oh(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty(t.type=="attributes"),t.type=="attributes"&&(e.flags|=4),t.type=="childList"){let i=Ph(e,t.previousSibling||t.target.previousSibling,-1),n=Ph(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(ut)!=t.state.facet(ut)&&(t.view.contentDOM.editContext=t.state.facet(ut)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),(t=this.intersection)===null||t===void 0||t.disconnect(),(e=this.gapIntersection)===null||e===void 0||e.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function Ph(t,e,i){for(;e;){let n=re.get(e);if(n&&n.parent==t)return n;let r=e.parentNode;e=r!=t.dom?r:i>0?e.nextSibling:e.previousSibling}return null}function Rh(t,e){let i=e.startContainer,n=e.startOffset,r=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return Fi(o.node,o.offset,r,s)&&([i,n,r,s]=[r,s,i,n]),{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}}function tm(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return Rh(t,r)}let i=null;function n(r){r.preventDefault(),r.stopImmediatePropagation(),i=r.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),i?Rh(t,i):null}var im=class{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=i=>{let n=t.state.selection.main,{anchor:r,head:s}=n,o=this.toEditorPos(i.updateRangeStart),l=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:o,drifted:!1});let a={from:o,to:l,insert:q.of(i.text.split(`
|
|
10
|
-
`))};if(a.from==this.from&&r<this.from?a.from=r:a.to==this.to&&r>this.to&&(a.to=r),a.from==a.to&&!a.insert.length){let c=w.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));c.main.eq(n)||t.dispatch({selection:c,userEvent:"select"});return}if((D.mac||D.android)&&a.from==s-1&&/^\. ?$/.test(i.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(a={from:o,to:l,insert:q.of([i.text.replace("."," ")])}),this.pendingContextChange=a,!t.state.readOnly){let c=this.to-this.from+(a.to-a.from+a.insert.length);zs(t,a,w.single(this.toEditorPos(i.selectionStart,c),this.toEditorPos(i.selectionEnd,c)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=i=>{let n=[],r=null;for(let s=this.toEditorPos(i.rangeStart),o=this.toEditorPos(i.rangeEnd);s<o;s++){let l=t.coordsForChar(s);r=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||r||new DOMRect,n.push(r)}e.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=i=>{let n=[];for(let r of i.getTextFormats()){let s=r.underlineStyle,o=r.underlineThickness;if(s!="None"&&o!="None"){let l=this.toEditorPos(r.rangeStart),a=this.toEditorPos(r.rangeEnd);if(l<a){let c=`text-decoration: underline ${s=="Dashed"?"dashed ":s=="Squiggle"?"wavy ":""}${o=="Thin"?1:2}px`;n.push(U.mark({attributes:{style:c}}).range(l,a))}}}t.dispatch({effects:ja.of(U.set(n))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(t.state)}};for(let i in this.handlers)e.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let n=Ni(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges((r,s,o,l,a)=>{if(i)return;let c=a.length-(s-r);if(n&&s>=n.to)if(n.from==r&&n.to==s&&n.insert.eq(a)){n=this.pendingContextChange=null,e+=c,this.to+=c;return}else n=null,this.revertPending(t.state);if(r+=e,s+=e,s<=this.from)this.from+=c,this.to+=c;else if(r<this.to){if(r<this.from||s>this.to||this.to-this.from+a.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(s),a.toString()),this.to+=c}e+=c}),n&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(n=>!n.isUserEvent("input.type")&&n.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>1e4*3)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}},L=class dl{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var i;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(r=>r.forEach(s=>n(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Pp(e.parent)||document,this.viewState=new Dh(e.state||ie.create(e)),e.scrollTo&&e.scrollTo.is(zn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(oi).map(r=>new Ns(r));for(let r of this.plugins)r.update(this);this.observer=new em(this),this.inputState=new xg(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Xa(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((i=document.fonts)===null||i===void 0)&&i.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let i=e.length==1&&e[0]instanceof xe?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(i,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let i=!1,n=!1,r,s=this.state;for(let u of e){if(u.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=u.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(wh))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=xh(s,o),a||(l=1));let c=this.observer.delayedAndroidKey,h=null;if(c?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(ie.phrases)!=this.state.facet(ie.phrases))return this.setState(s);r=Ya.create(this,s,e),r.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection;f=new Rs(d.empty?d:w.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of u.effects)d.is(zn)&&(f=d.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Ih.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),i=this.docView.update(r),this.state.facet(Wi)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(i,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Qn)!=r.state.facet(Qn)&&(this.viewState.mustMeasureContent=!0),(i||n||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!r.empty)for(let u of this.state.facet(Ls))try{u(r)}catch(d){Le(this.state,d,"update listener")}(a||h)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),h&&!oh(this,h)&&c.force&&ii(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let i=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new Dh(e),this.plugins=e.facet(oi).map(n=>new Ns(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new Xa(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}i&&this.focus(),this.requestMeasure()}updatePlugins(e){let i=e.startState.facet(oi),n=e.state.facet(oi);if(i!=n){let r=[];for(let s of n){let o=i.indexOf(s);if(o<0)r.push(new Ns(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);i!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let i=e.value;if(i&&i.docViewUpdate)try{i.docViewUpdate(this)}catch(n){Le(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let i=null,n=this.scrollDOM,r=n.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(pa(n))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];a&4||([this.measureRequests,c]=[c,this.measureRequests]);let h=c.map(d=>{try{return d.read(this)}catch(p){return Le(this.state,p),Nh}}),f=Ya.create(this,this.state,[]),u=!1;f.flags|=a,i?i.flags|=a:i=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),u=this.docView.update(f),u&&this.docViewUpdate());for(let d=0;d<c.length;d++)if(h[d]!=Nh)try{let p=c[d];p.write&&p.write(h[d],this)}catch(p){Le(this.state,p)}if(u&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(p>1||p<-1){r=r+p,n.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(i&&!i.empty)for(let l of this.state.facet(Ls))l(i)}get themeClasses(){return Ks+" "+(this.state.facet(qs)?Lh:Eh)+" "+this.state.facet(Qn)}updateAttrs(){let e=Fh(this,qa,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),i={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ut)?"true":"false",class:"cm-content",style:`${D.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(i["aria-readonly"]="true"),Fh(this,Is,i);let n=this.observer.ignore(()=>{let r=ks(this.contentDOM,this.contentAttrs,i),s=ks(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=i,n}showAnnouncements(e){let i=!0;for(let n of e)for(let r of n.effects)if(r.is(dl.announce)){i&&(this.announceDOM.textContent=""),i=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Wi);let e=this.state.facet(dl.cspNonce);yt.mount(this.root,this.styleModules.concat(Qg).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let i=0;i<this.measureRequests.length;i++)if(this.measureRequests[i].key===e.key){this.measureRequests[i]=e;return}}this.measureRequests.push(e)}}plugin(e){let i=this.pluginMap.get(e);return(i===void 0||i&&i.plugin!=e)&&this.pluginMap.set(e,i=this.plugins.find(n=>n.plugin==e)||null),i&&i.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,i,n){return $s(this,e,rh(this,e,i,n))}moveByGroup(e,i){return $s(this,e,rh(this,e,i,n=>ug(this,e.head,n)))}visualLineSide(e,i){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=n[i?n.length-1:0];return w.cursor(s.side(i,r)+e.from,s.forward(!i,r)?1:-1)}moveToLineBoundary(e,i,n=!0){return fg(this,e,i,n)}moveVertically(e,i,n){return $s(this,e,dg(this,e,i,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,i=0){return this.docView.posFromDOM(e,i)}posAtCoords(e,i=!0){return this.readMeasured(),ih(this,e,i)}coordsAtPos(e,i=1){this.readMeasured();let n=this.docView.coordsAt(e,i);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[xt.find(s,e-r.from,-1,i)];return In(n,o.dir==oe.LTR==i>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(za)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>nm)return Ra(e.length);let i=this.textDirectionAt(e.from),n;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==i&&(s.fresh||Pa(s.isolates,n=Ga(this,e))))return s.order;n||(n=Ga(this,e));let r=Up(e.text,i,n);return this.bidiCache.push(new Ih(e.from,e.to,i,n,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||D.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{fa(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,i={}){return zn.of(new Rs(typeof e=="number"?w.cursor(e):e,i.y,i.x,i.yMargin,i.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:i}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return zn.of(new Rs(w.cursor(n.from),"start","start",n.top-e,i,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return je.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return je.define(()=>({}),{eventObservers:e})}static theme(e,i){let n=yt.newName(),r=[Qn.of(n),Wi.of(Us(`.${n}`,e))];return i&&i.dark&&r.push(qs.of(!0)),r}static baseTheme(e){return Ei.lowest(Wi.of(Us("."+Ks,e,Bh)))}static findFromDOM(e){var i;let n=e.querySelector(".cm-content"),r=n&&re.get(n)||re.get(e);return((i=r==null?void 0:r.rootView)===null||i===void 0?void 0:i.view)||null}};L.styleModule=Wi,L.inputHandler=Wa,L.clipboardInputFilter=Bs,L.clipboardOutputFilter=Ps,L.scrollHandler=_a,L.focusChangeEffect=$a,L.perLineTextDirection=za,L.exceptionSink=Va,L.updateListener=Ls,L.editable=ut,L.mouseSelectionStyle=Ha,L.dragMovesSelection=Fa,L.clickAddsSelectionRange=Ia,L.decorations=Vi,L.outerDecorations=Ka,L.atomicRanges=Fs,L.bidiIsolatedRanges=Ua,L.scrollMargins=Ja,L.darkTheme=qs,L.cspNonce=P.define({combine:t=>t.length?t[0]:""}),L.contentAttributes=Is,L.editorAttributes=qa,L.lineWrapping=L.contentAttributes.of({class:"cm-lineWrapping"}),L.announce=K.define();var nm=4096,Nh={},Ih=class Ed{constructor(e,i,n,r,s,o){this.from=e,this.to=i,this.dir=n,this.isolates=r,this.fresh=s,this.order=o}static update(e,i){if(i.empty&&!e.some(s=>s.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:oe.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!i.touchesRange(o.from,o.to)&&n.push(new Ed(i.mapPos(o.from,1),i.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}};function Fh(t,e,i){for(let n=t.state.facet(e),r=n.length-1;r>=0;r--){let s=n[r],o=typeof s=="function"?s(t):s;o&&xs(o,i)}return i}var rm=D.mac?"mac":D.windows?"win":D.linux?"linux":"key";function sm(t,e){const i=t.split(/-(?!$)/);let n=i[i.length-1];n=="Space"&&(n=" ");let r,s,o,l;for(let a=0;a<i.length-1;++a){const c=i[a];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),l&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Zn(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),i!==!1&&e.shiftKey&&(t="Shift-"+t),t}var om=Ei.default(L.domEventHandlers({keydown(t,e){return Wh(Vh(e.state),t,e,"editor")}})),hi=P.define({enables:om}),Hh=new WeakMap;function Vh(t){let e=t.facet(hi),i=Hh.get(e);return i||Hh.set(e,i=hm(e.reduce((n,r)=>n.concat(r),[]))),i}function lm(t,e,i){return Wh(Vh(t.state),e,t,i)}var Ct=null,am=4e3;function hm(t,e=rm){let i=Object.create(null),n=Object.create(null),r=(o,l)=>{let a=n[o];if(a==null)n[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,c,h)=>{var f,u;let d=i[o]||(i[o]=Object.create(null)),p=l.split(/ (?!$)/).map(v=>sm(v,e));for(let v=1;v<p.length;v++){let y=p.slice(0,v).join(" ");r(y,!0),d[y]||(d[y]={preventDefault:!0,stopPropagation:!1,run:[S=>{let k=Ct={view:S,prefix:y,scope:o};return setTimeout(()=>{Ct==k&&(Ct=null)},am),!0}]})}let g=p.join(" ");r(g,!1);let m=d[g]||(d[g]={preventDefault:!1,stopPropagation:!1,run:((u=(f=d._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&m.run.push(a),c&&(m.preventDefault=!0),h&&(m.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of l){let h=i[c]||(i[c]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let u in h)h[u].run.push(d=>f(d,Js))}let a=o[e]||o.key;if(a)for(let c of l)s(c,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return i}var Js=null;function Wh(t,e,i,n){Js=e;let r=Dp(e),s=Wl(r,0),o=$l(s)==r.length&&r!=" ",l="",a=!1,c=!1,h=!1;Ct&&Ct.view==i&&Ct.scope==n&&(l=Ct.prefix+" ",hh.indexOf(e.keyCode)<0&&(c=!0,Ct=null));let f=new Set,u=m=>{if(m){for(let v of m.run)if(!f.has(v)&&(f.add(v),v(i)))return m.stopPropagation&&(h=!0),!0;m.preventDefault&&(m.stopPropagation&&(h=!0),c=!0)}return!1},d=t[n],p,g;return d&&(u(d[l+Zn(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(D.windows&&e.ctrlKey&&e.altKey)&&(p=bt[e.keyCode])&&p!=r?(u(d[l+Zn(p,e,!0)])||e.shiftKey&&(g=Ri[e.keyCode])!=r&&g!=p&&u(d[l+Zn(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+Zn(r,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),c&&(a=!0),a&&h&&e.stopPropagation(),Js=null,a}var Kb=/x/.unicode!=null?"gu":"g",_i="-10000px",$h=class{constructor(t,e,i,n){this.facet=e,this.createTooltipView=i,this.removeTooltipView=n,this.input=t.state.facet(e),this.tooltips=this.input.filter(s=>s);let r=null;this.tooltipViews=this.tooltips.map(s=>r=i(s,r))}update(t,e){var i;let n=t.state.facet(this.facet),r=n.filter(l=>l);if(n===this.input){for(let l of this.tooltipViews)l.update&&l.update(t);return!1}let s=[],o=e?[]:null;for(let l=0;l<r.length;l++){let a=r[l],c=-1;if(a){for(let h=0;h<this.tooltips.length;h++){let f=this.tooltips[h];f&&f.create==a.create&&(c=h)}if(c<0)s[l]=this.createTooltipView(a,l?s[l-1]:null),o&&(o[l]=!!a.above);else{let h=s[l]=this.tooltipViews[c];o&&(o[l]=e[c]),h.update&&h.update(t)}}}for(let l of this.tooltipViews)s.indexOf(l)<0&&(this.removeTooltipView(l),(i=l.destroy)===null||i===void 0||i.call(l));return e&&(o.forEach((l,a)=>e[a]=l),e.length=o.length),this.input=n,this.tooltips=r,this.tooltipViews=s,!0}};function cm(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}var Ys=P.define({combine:t=>{var e,i,n;return{position:D.ios?"absolute":((e=t.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((i=t.find(r=>r.parent))===null||i===void 0?void 0:i.parent)||null,tooltipSpace:((n=t.find(r=>r.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||cm}}}),zh=new WeakMap,_h=je.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(Ys);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new $h(t,Xs,(i,n)=>this.createTooltip(i,n),i=>{this.resizeObserver&&this.resizeObserver.unobserve(i.dom),i.dom.remove()}),this.above=this.manager.tooltips.map(i=>!!i.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(i=>{Date.now()>this.lastTransaction-50&&i.length>0&&i[i.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let i=e||t.geometryChanged,n=t.state.facet(Ys);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t,e){let i=t.create(this.view),n=e?e.dom:null;if(i.dom.classList.add("cm-tooltip"),t.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",i.dom.appendChild(r)}return i.dom.style.position=this.position,i.dom.style.top=_i,i.dom.style.left="0px",this.container.insertBefore(i.dom,n),i.mount&&i.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(i.dom),i}destroy(){var t,e,i;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(t=n.destroy)===null||t===void 0||t.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(i=this.intersectionObserver)===null||i===void 0||i.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,i=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(D.gecko)i=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==_i&&s.style.left=="0px"){let o=s.getBoundingClientRect();i=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}}if(i||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),r=Hs(this.view);return{visible:{left:n.left+r.left,top:n.top+r.top,right:n.right-r.right,bottom:n.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Ys).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:i}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:i,space:n,scaleX:r,scaleY:s}=t,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],c=this.manager.tooltipViews[l],{dom:h}=c,f=t.pos[l],u=t.size[l];if(!f||a.clip!==!1&&(f.bottom<=Math.max(i.top,n.top)||f.top>=Math.min(i.bottom,n.bottom)||f.right<Math.max(i.left,n.left)-.1||f.left>Math.min(i.right,n.right)+.1)){h.style.top=_i;continue}let d=a.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,g=u.right-u.left,m=(e=zh.get(c))!==null&&e!==void 0?e:u.bottom-u.top,v=c.offset||um,y=this.view.textDirection==oe.LTR,S=u.width>n.right-n.left?y?n.left:n.right-u.width:y?Math.max(n.left,Math.min(f.left-(d?14:0)+v.x,n.right-g)):Math.min(Math.max(n.left,f.left-g+(d?14:0)-v.x),n.right-g),k=this.above[l];!a.strictSide&&(k?f.top-m-p-v.y<n.top:f.bottom+m+p+v.y>n.bottom)&&k==n.bottom-f.bottom>f.top-n.top&&(k=this.above[l]=!k);let E=(k?f.top-n.top:n.bottom-f.bottom)-p;if(E<m&&c.resize!==!1){if(E<this.view.defaultLineHeight){h.style.top=_i;continue}zh.set(c,m),h.style.height=(m=E)/s+"px"}else h.style.height&&(h.style.height="");let H=k?f.top-m-p-v.y:f.bottom+p+v.y,C=S+g;if(c.overlap!==!0)for(let B of o)B.left<C&&B.right>S&&B.top<H+m&&B.bottom>H&&(H=k?B.top-m-2-p:B.bottom+p+2);if(this.position=="absolute"?(h.style.top=(H-t.parent.top)/s+"px",jh(h,(S-t.parent.left)/r)):(h.style.top=H/s+"px",jh(h,S/r)),d){let B=f.left+(y?v.x:-v.x)-(S+14-7);d.style.left=B/r+"px"}c.overlap!==!0&&o.push({left:S,top:H,right:C,bottom:H+m}),h.classList.toggle("cm-tooltip-above",k),h.classList.toggle("cm-tooltip-below",!k),c.positioned&&c.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=_i}},{eventObservers:{scroll(){this.maybeMeasure()}}});function jh(t,e){let i=parseInt(t.style.left,10);(isNaN(i)||Math.abs(e-i)>1)&&(t.style.left=e+"px")}var fm=L.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),um={x:0,y:0},Xs=P.define({enables:[_h,fm]}),er=P.define({combine:t=>t.reduce((e,i)=>e.concat(i),[])}),qh=class Ld{static create(e){return new Ld(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new $h(e,er,(i,n)=>this.createHostedView(i,n),i=>i.dom.remove())}createHostedView(e,i){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,i?i.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let i of this.manager.tooltipViews)i.mount&&i.mount(e);this.mounted=!0}positioned(e){for(let i of this.manager.tooltipViews)i.positioned&&i.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let i of this.manager.tooltipViews)(e=i.destroy)===null||e===void 0||e.call(i)}passProp(e){let i;for(let n of this.manager.tooltipViews){let r=n[e];if(r!==void 0){if(i===void 0)i=r;else if(i!==r)return}}return i}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},dm=Xs.compute([er],t=>{let e=t.facet(er);return e.length===0?null:{pos:Math.min(...e.map(i=>i.pos)),end:Math.max(...e.map(i=>{var n;return(n=i.end)!==null&&n!==void 0?n:i.pos})),create:qh.create,above:e[0].above,arrow:e.some(i=>i.arrow)}}),pm=class{constructor(t,e,i,n,r){this.view=t,this.source=e,this.field=i,this.setHover=n,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,i=t.docView.nearest(e.target);if(!i)return;let n,r=1;if(i instanceof bs)n=i.posAtStart;else{if(n=t.posAtCoords(e),n==null)return;let o=t.coordsAtPos(n);if(!o||e.y<o.top||e.y>o.bottom||e.x<o.left-t.defaultCharacterWidth||e.x>o.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(n)).find(c=>c.from<=n&&c.to>=n),a=l&&l.dir==oe.RTL?-1:1;r=e.x<o.left?-a:a}let s=this.source(t,n,r);if(s!=null&&s.then){let o=this.pending={pos:n};s.then(l=>{this.pending==o&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Le(t.state,l,"hover tooltip"))}else s&&!(Array.isArray(s)&&!s.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(s)?s:[s])})}get tooltip(){let t=this.view.plugin(_h),e=t?t.manager.tooltips.findIndex(i=>i.create==qh.create):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:r}=this;if(n.length&&r&&!gm(r.dom,t)||this.pending){let{pos:s}=n[0]||this.pending,o=(i=(e=n[0])===null||e===void 0?void 0:e.end)!==null&&i!==void 0?i:s;(s==o?this.view.posAtCoords(this.lastMove)!=s:!mm(this.view,s,o,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e.length){let{tooltip:i}=this;i&&i.dom.contains(t.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},tr=4;function gm(t,e){let{left:i,right:n,top:r,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();r=Math.min(l.top,r),s=Math.max(l.bottom,s)}return e.clientX>=i-tr&&e.clientX<=n+tr&&e.clientY>=r-tr&&e.clientY<=s+tr}function mm(t,e,i,n,r,s){let o=t.scrollDOM.getBoundingClientRect(),l=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>n||o.right<n||o.top>r||Math.min(o.bottom,l)<r)return!1;let a=t.posAtCoords({x:n,y:r},!1);return a>=e&&a<=i}function vm(t,e={}){let i=K.define(),n=Oe.define({create(){return[]},update(r,s){if(r.length&&(e.hideOnChange&&(s.docChanged||s.selection)?r=[]:e.hideOn&&(r=r.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let l of r){let a=s.changes.mapPos(l.pos,-1,we.TrackDel);if(a!=null){let c=Object.assign(Object.create(null),l);c.pos=a,c.end!=null&&(c.end=s.changes.mapPos(c.end)),o.push(c)}}r=o}for(let o of s.effects)o.is(i)&&(r=o.value),o.is(ym)&&(r=[]);return r},provide:r=>er.from(r)});return{active:n,extension:[n,je.define(r=>new pm(r,t,n,i,e.hoverTime||300)),dm]}}var ym=K.define(),Kh=P.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});function ji(t,e){let i=t.plugin(Uh),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}var Uh=je.fromClass(class{constructor(t){this.input=t.state.facet(ci),this.specs=this.input.filter(i=>i),this.panels=this.specs.map(i=>i(t));let e=t.state.facet(Kh);this.top=new ir(t,!0,e.topContainer),this.bottom=new ir(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(i=>i.top)),this.bottom.sync(this.panels.filter(i=>!i.top));for(let i of this.panels)i.dom.classList.add("cm-panel"),i.mount&&i.mount()}update(t){let e=t.state.facet(Kh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new ir(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new ir(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(ci);if(i!=this.input){let n=i.filter(a=>a),r=[],s=[],o=[],l=[];for(let a of n){let c=this.specs.indexOf(a),h;c<0?(h=a(t.view),l.push(h)):(h=this.panels[c],h.update&&h.update(t)),r.push(h),(h.top?s:o).push(h)}this.specs=n,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let n of this.panels)n.update&&n.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>L.scrollMargins.of(e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})}),ir=class{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=Gh(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Gh(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}};function Gh(t){let e=t.nextSibling;return t.remove(),e}var ci=P.define({enables:Uh}),dt=class extends Vt{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}};dt.prototype.elementClass="",dt.prototype.toDOM=void 0,dt.prototype.mapMode=we.TrackBefore,dt.prototype.startSide=dt.prototype.endSide=-1,dt.prototype.point=!0;var nr=P.define(),bm=P.define(),wm={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ne.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},qi=P.define();function xm(t){return[Jh(),qi.of({...wm,...t})]}var Qs=P.define({combine:t=>t.some(e=>e)});function Jh(t){let e=[km];return t&&t.fixed===!1&&e.push(Qs.of(!0)),e}var km=je.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(qi).map(e=>new Xh(t,e)),this.fixed=!t.state.facet(Qs);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,n=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(n<(i.to-i.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Qs)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let i=ne.iter(this.view.state.facet(nr),this.view.viewport.from),n=[],r=this.gutters.map(s=>new Sm(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Ee.Text&&o){Zs(i,n,l.from);for(let a of r)a.line(this.view,l,n);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==Ee.Text){Zs(i,n,s.from);for(let o of r)o.line(this.view,s,n)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(qi),i=t.state.facet(qi),n=t.docChanged||t.heightChanged||t.viewportChanged||!ne.eq(t.startState.facet(nr),t.state.facet(nr),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let r of this.gutters)r.update(t)&&(n=!0);else{n=!0;let r=[];for(let s of i){let o=e.indexOf(s);o<0?r.push(new Xh(this.view,s)):(this.gutters[o].update(t),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>L.scrollMargins.of(e=>{let i=e.plugin(t);if(!i||i.gutters.length==0||!i.fixed)return null;let n=i.dom.offsetWidth*e.scaleX,r=i.domAfter?i.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==oe.LTR?{left:n,right:r}:{right:n,left:r}})});function Yh(t){return Array.isArray(t)?t:[t]}function Zs(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}var Sm=class{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=ne.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,r=(e.top-this.height)/t.scaleY,s=e.height/t.scaleY;if(this.i==n.elements.length){let o=new Qh(t,s,r,i);n.elements.push(o),n.dom.appendChild(o.dom)}else n.elements[this.i].update(t,s,r,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];Zs(this.cursor,n,e.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(t,e,n);r&&n.unshift(r);let s=this.gutter;n.length==0&&!s.config.renderEmptyElements||this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),n=i?[i]:null;for(let r of t.state.facet(bm)){let s=r(t,e.widget,e);s&&(n||(n=[])).push(s)}n&&this.addElement(t,e,n)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}},Xh=class{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,n=>{let r=n.target,s;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let l=r.getBoundingClientRect();s=(l.top+l.bottom)/2}else s=n.clientY;let o=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,o,n)&&n.preventDefault()});this.markers=Yh(e.markers(t)),e.initialSpacer&&(this.spacer=new Qh(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=Yh(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],t);n!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[n])}let i=t.view.viewport;return!ne.eq(this.markers,e,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}},Qh=class{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Cm(this.markers,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let r=0,s=0;;){let o=s,l=r<e.length?e[r++]:null,a=!1;if(l){let c=l.elementClass;c&&(i+=" "+c);for(let h=s;h<this.markers.length;h++)if(this.markers[h].compare(l)){o=h,a=!0;break}}else o=this.markers.length;for(;s<o;){let c=this.markers[s++];if(c.toDOM){c.destroy(n);let h=n.nextSibling;n.remove(),n=h}}if(!l)break;l.toDOM&&(a?n=n.nextSibling:this.dom.insertBefore(l.toDOM(t),n)),a&&s++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}};function Cm(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}var Am=P.define(),Tm=P.define(),fi=P.define({combine(t){return Bi(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,i){let n=Object.assign({},e);for(let r in i){let s=n[r],o=i[r];n[r]=s?(l,a,c)=>s(l,a,c)||o(l,a,c):o}return n}})}}),eo=class extends dt{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}};function to(t,e){return t.state.facet(fi).formatNumber(e,t.state)}var Mm=qi.compute([fi],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Am)},lineMarker(e,i,n){return n.some(r=>r.toDOM)?null:new eo(to(e,e.state.doc.lineAt(i.from).number))},widgetMarker:(e,i,n)=>{for(let r of e.state.facet(Tm)){let s=r(e,i,n);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(fi)!=e.state.facet(fi),initialSpacer(e){return new eo(to(e,Zh(e.state.doc.lines)))},updateSpacer(e,i){let n=to(i.view,Zh(i.view.state.doc.lines));return n==e.number?e:new eo(n)},domEventHandlers:t.facet(fi).domEventHandlers,side:"before"}));function Dm(t={}){return[fi.of(t),Jh(),Mm]}function Zh(t){let e=9;for(;e<t;)e=e*10+9;return e}var Om=new class extends dt{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Em=nr.compute(["selection"],t=>{let e=[],i=-1;for(let n of t.selection.ranges){let r=t.doc.lineAt(n.head).from;r>i&&(i=r,e.push(Om.range(r)))}return ne.of(e)});function Lm(){return Em}var ec=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t,Ki=class{constructor(t,e,i=0,n=t.length,r,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,n),this.bufferStart=i,this.normalize=r?o=>r(ec(o)):ec,this.query=this.normalize(e)}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 Wl(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=cp(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=$l(t);let n=this.normalize(e);if(n.length)for(let r=0,s=i;;r++){let o=n.charCodeAt(r),l=this.match(o,s,this.bufferPos+this.bufferStart);if(r==n.length-1){if(l)return this.value=l,this;break}s==i&&r<e.length&&e.charCodeAt(r)==o&&s++}}}match(t,e,i){let n=null;for(let r=0;r<this.matches.length;r+=2){let s=this.matches[r],o=!1;this.query.charCodeAt(s)==t&&(s==this.query.length-1?n={from:this.matches[r+1],to:i}:(this.matches[r]++,o=!0)),o||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==t&&(this.query.length==1?n={from:e,to:i}:this.matches.push(1,e)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferStart)&&(n=null),n}};typeof Symbol!="undefined"&&(Ki.prototype[Symbol.iterator]=function(){return this});var tc={from:-1,to:-1,match:/.*/.exec("")},io="gm"+(/x/.unicode==null?"":"u"),ic=class{constructor(t,e,i,n=0,r=t.length){if(this.text=t,this.to=r,this.curLine="",this.done=!1,this.value=tc,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new rc(t,e,i,n,r);this.re=new RegExp(e,io+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.iter=t.iter();let s=t.lineAt(n);this.curLineStart=s.from,this.matchPos=rr(t,n),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),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 t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let i=this.curLineStart+e.index,n=i+e[0].length;if(this.matchPos=rr(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,e)))return this.value={from:i,to:n,match:e},this;t=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),t=0;else return this.done=!0,this}}},no=new WeakMap,nc=class zr{constructor(e,i){this.from=e,this.text=i}get to(){return this.from+this.text.length}static get(e,i,n){let r=no.get(e);if(!r||r.from>=n||r.to<=i){let l=new zr(i,e.sliceString(i,n));return no.set(e,l),l}if(r.from==i&&r.to==n)return r;let{text:s,from:o}=r;return o>i&&(s=e.sliceString(i,o)+s,o=i),r.to<n&&(s+=e.sliceString(r.to,n)),no.set(e,new zr(o,s)),new zr(i,s.slice(i-o,n-o))}},rc=class{constructor(t,e,i,n,r){this.text=t,this.to=r,this.done=!1,this.value=tc,this.matchPos=rr(t,n),this.re=new RegExp(e,io+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=nc.get(t,n,this.chunkEnd(n+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let i=this.flat.from+e.index,n=i+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,n,e)))return this.value={from:i,to:n,match:e},this.matchPos=rr(this.text,n+(i==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=nc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol!="undefined"&&(ic.prototype[Symbol.iterator]=rc.prototype[Symbol.iterator]=function(){return this});function Bm(t){try{return new RegExp(t,io),!0}catch{return!1}}function rr(t,e){if(e>=t.length)return e;let i=t.lineAt(e),n;for(;e<i.to&&(n=i.text.charCodeAt(e-i.from))>=56320&&n<57344;)e++;return e}function ro(t){let e=String(t.state.doc.lineAt(t.state.selection.main.head).number),i=X("input",{class:"cm-textfield",name:"line",value:e}),n=X("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),t.dispatch({effects:Ui.of(!1)}),t.focus()):s.keyCode==13&&(s.preventDefault(),r())},onsubmit:s=>{s.preventDefault(),r()}},X("label",t.state.phrase("Go to line"),": ",i)," ",X("button",{class:"cm-button",type:"submit"},t.state.phrase("go")),X("button",{name:"close",onclick:()=>{t.dispatch({effects:Ui.of(!1)}),t.focus()},"aria-label":t.state.phrase("close"),type:"button"},["×"]));function r(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(i.value);if(!s)return;let{state:o}=t,l=o.doc.lineAt(o.selection.main.head),[,a,c,h,f]=s,u=h?+h.slice(1):0,d=c?+c:l.number;if(c&&f){let m=d/100;a&&(m=m*(a=="-"?-1:1)+l.number/o.doc.lines),d=Math.round(o.doc.lines*m)}else c&&a&&(d=d*(a=="-"?-1:1)+l.number);let p=o.doc.line(Math.max(1,Math.min(o.doc.lines,d))),g=w.cursor(p.from+Math.max(0,Math.min(u,p.length)));t.dispatch({effects:[Ui.of(!1),L.scrollIntoView(g.from,{y:"center"})],selection:g}),t.focus()}return{dom:n}}var Ui=K.define(),sc=Oe.define({create(){return!0},update(t,e){for(let i of e.effects)i.is(Ui)&&(t=i.value);return t},provide:t=>ci.from(t,e=>e?ro:null)}),Pm=t=>{let e=ji(t,ro);if(!e){let i=[Ui.of(!0)];t.state.field(sc,!1)==null&&i.push(K.appendConfig.of([sc,Rm])),t.dispatch({effects:i}),e=ji(t,ro)}return e&&e.dom.querySelector("input").select(),!0},Rm=L.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),Nm=({state:t,dispatch:e})=>{let{selection:i}=t,n=w.create(i.ranges.map(r=>t.wordAt(r.head)||w.cursor(r.head)),i.mainIndex);return n.eq(i)?!1:(e(t.update({selection:n})),!0)};function Im(t,e){let{main:i,ranges:n}=t.selection,r=t.wordAt(i.head),s=r&&r.from==i.from&&r.to==i.to;for(let o=!1,l=new Ki(t.doc,e,n[n.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Ki(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),o=!0}else{if(o&&n.some(a=>a.from==l.value.from))continue;if(s){let a=t.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}var Fm=({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some(s=>s.from===s.to))return Nm({state:t,dispatch:e});let n=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some(s=>t.sliceDoc(s.from,s.to)!=n))return!1;let r=Im(t,n);return r?(e(t.update({selection:t.selection.addRange(w.range(r.from,r.to),!1),effects:L.scrollIntoView(r.to)})),!0):!1},ui=P.define({combine(t){return Bi(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Jm(e),scrollToMatch:e=>L.scrollIntoView(e)})}}),oc=class{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||Bm(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(e,i)=>i=="n"?`
|
|
11
|
-
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new $m(this):new Vm(this)}getCursor(t,e=0,i){let n=t.doc?t:ie.create({doc:t});return i==null&&(i=n.doc.length),this.regexp?pi(this,n,e,i):di(this,n,e,i)}},lc=class{constructor(t){this.spec=t}};function di(t,e,i,n){return new Ki(e.doc,t.unquoted,i,n,t.caseSensitive?void 0:r=>r.toLowerCase(),t.wholeWord?Hm(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function Hm(t,e){return(i,n,r,s)=>((s>i||s+r.length<n)&&(s=Math.max(0,i-2),r=t.sliceString(s,Math.min(t.length,n+2))),(e(sr(r,i-s))!=ge.Word||e(or(r,i-s))!=ge.Word)&&(e(or(r,n-s))!=ge.Word||e(sr(r,n-s))!=ge.Word))}var Vm=class extends lc{constructor(t){super(t)}nextMatch(t,e,i){let n=di(this.spec,t,i,t.doc.length).nextOverlapping();if(n.done){let r=Math.min(t.doc.length,e+this.spec.unquoted.length);n=di(this.spec,t,0,r).nextOverlapping()}return n.done||n.value.from==e&&n.value.to==i?null:n.value}prevMatchInRange(t,e,i){for(let n=i;;){let r=Math.max(e,n-1e4-this.spec.unquoted.length),s=di(this.spec,t,r,n),o=null;for(;!s.nextOverlapping().done;)o=s.value;if(o)return o;if(r==e)return null;n-=1e4}}prevMatch(t,e,i){let n=this.prevMatchInRange(t,0,e);return n||(n=this.prevMatchInRange(t,Math.max(0,i-this.spec.unquoted.length),t.doc.length)),n&&(n.from!=e||n.to!=i)?n:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let i=di(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let r=di(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}};function pi(t,e,i,n){return new ic(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?Wm(e.charCategorizer(e.selection.main.head)):void 0},i,n)}function sr(t,e){return t.slice(pe(t,e,!1),e)}function or(t,e){return t.slice(e,pe(t,e))}function Wm(t){return(e,i,n)=>!n[0].length||(t(sr(n.input,n.index))!=ge.Word||t(or(n.input,n.index))!=ge.Word)&&(t(or(n.input,n.index+n[0].length))!=ge.Word||t(sr(n.input,n.index+n[0].length))!=ge.Word)}var $m=class extends lc{nextMatch(t,e,i){let n=pi(this.spec,t,i,t.doc.length).next();return n.done&&(n=pi(this.spec,t,0,e).next()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=1;;n++){let r=Math.max(e,i-n*1e4),s=pi(this.spec,t,r,i),o=null;for(;!s.next().done;)o=s.value;if(o&&(r==e||o.from>r+10))return o;if(r==e)return null}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(e,i)=>{if(i=="&")return t.match[0];if(i=="$")return"$";for(let n=i.length;n>0;n--){let r=+i.slice(0,n);if(r>0&&r<t.match.length)return t.match[r]+i.slice(n)}return e})}matchAll(t,e){let i=pi(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let r=pi(this.spec,t,Math.max(0,e-250),Math.min(i+250,t.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}},Gi=K.define(),so=K.define(),At=Oe.define({create(t){return new oo(ao(t).create(),null)},update(t,e){for(let i of e.effects)i.is(Gi)?t=new oo(i.value.create(),t.panel):i.is(so)&&(t=new oo(t.query,i.value?lo:null));return t},provide:t=>ci.from(t,e=>e.panel)}),oo=class{constructor(t,e){this.query=t,this.panel=e}},zm=U.mark({class:"cm-searchMatch"}),_m=U.mark({class:"cm-searchMatch cm-searchMatch-selected"}),jm=je.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(At))}update(t){let e=t.state.field(At);(e!=t.startState.field(At)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return U.none;let{view:i}=this,n=new ei;for(let r=0,s=i.visibleRanges,o=s.length;r<o;r++){let{from:l,to:a}=s[r];for(;r<o-1&&a>s[r+1].from-2*250;)a=s[++r].to;t.highlight(i.state,l,a,(c,h)=>{let f=i.state.selection.ranges.some(u=>u.from==c&&u.to==h);n.add(c,h,f?_m:zm)})}return n.finish()}},{decorations:t=>t.decorations});function Ji(t){return e=>{let i=e.state.field(At,!1);return i&&i.query.spec.valid?t(e,i):fc(e)}}var lr=Ji((t,{query:e})=>{let{to:i}=t.state.selection.main,n=e.nextMatch(t.state,i,i);if(!n)return!1;let r=w.single(n.from,n.to),s=t.state.facet(ui);return t.dispatch({selection:r,effects:[ho(t,n),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),cc(t),!0}),ar=Ji((t,{query:e})=>{let{state:i}=t,{from:n}=i.selection.main,r=e.prevMatch(i,n,n);if(!r)return!1;let s=w.single(r.from,r.to),o=t.state.facet(ui);return t.dispatch({selection:s,effects:[ho(t,r),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),cc(t),!0}),qm=Ji((t,{query:e})=>{let i=e.matchAll(t.state,1e3);return!i||!i.length?!1:(t.dispatch({selection:w.create(i.map(n=>w.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),Km=({state:t,dispatch:e})=>{let i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:r}=i.main,s=[],o=0;for(let l=new Ki(t.doc,t.sliceDoc(n,r));!l.next().done;){if(s.length>1e3)return!1;l.value.from==n&&(o=s.length),s.push(w.range(l.value.from,l.value.to))}return e(t.update({selection:w.create(s,o),userEvent:"select.search.matches"})),!0},ac=Ji((t,{query:e})=>{let{state:i}=t,{from:n,to:r}=i.selection.main;if(i.readOnly)return!1;let s=e.nextMatch(i,n,n);if(!s)return!1;let o=s,l=[],a,c,h=[];o.from==n&&o.to==r&&(c=i.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:c}),o=e.nextMatch(i,o.from,o.to),h.push(L.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+".")));let f=t.state.changes(l);return o&&(a=w.single(o.from,o.to).map(f),h.push(ho(t,o)),h.push(i.facet(ui).scrollToMatch(a.main,t))),t.dispatch({changes:f,selection:a,effects:h,userEvent:"input.replace"}),!0}),Um=Ji((t,{query:e})=>{if(t.state.readOnly)return!1;let i=e.matchAll(t.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!i.length)return!1;let n=t.state.phrase("replaced $ matches",i.length)+".";return t.dispatch({changes:i,effects:L.announce.of(n),userEvent:"input.replace.all"}),!0});function lo(t){return t.state.facet(ui).createPanel(t)}function ao(t,e){var i,n,r,s,o;let l=t.selection.main,a=l.empty||l.to>l.from+100?"":t.sliceDoc(l.from,l.to);if(e&&!a)return e;let c=t.facet(ui);return new oc({search:((i=e==null?void 0:e.literal)!==null&&i!==void 0?i:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(r=e==null?void 0:e.literal)!==null&&r!==void 0?r:c.literal,regexp:(s=e==null?void 0:e.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function hc(t){let e=ji(t,lo);return e&&e.dom.querySelector("[main-field]")}function cc(t){let e=hc(t);e&&e==t.root.activeElement&&e.select()}var fc=t=>{let e=t.state.field(At,!1);if(e&&e.panel){let i=hc(t);if(i&&i!=t.root.activeElement){let n=ao(t.state,e.query.spec);n.valid&&t.dispatch({effects:Gi.of(n)}),i.focus(),i.select()}}else t.dispatch({effects:[so.of(!0),e?Gi.of(ao(t.state,e.query.spec)):K.appendConfig.of(Xm)]});return!0},uc=t=>{let e=t.state.field(At,!1);if(!e||!e.panel)return!1;let i=ji(t,lo);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:so.of(!1)}),!0},Gm=[{key:"Mod-f",run:fc,scope:"editor search-panel"},{key:"F3",run:lr,shift:ar,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:lr,shift:ar,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:uc,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Km},{key:"Mod-Alt-g",run:Pm},{key:"Mod-d",run:Fm,preventDefault:!0}],Jm=class{constructor(t){this.view=t;let e=this.query=t.state.field(At).query.spec;this.commit=this.commit.bind(this),this.searchField=X("input",{value:e.search,placeholder:Ae(t,"Find"),"aria-label":Ae(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=X("input",{value:e.replace,placeholder:Ae(t,"Replace"),"aria-label":Ae(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=X("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=X("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=X("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit});function i(n,r,s){return X("button",{class:"cm-button",name:n,onclick:r,type:"button"},s)}this.dom=X("div",{onkeydown:n=>this.keydown(n),class:"cm-search"},[this.searchField,i("next",()=>lr(t),[Ae(t,"next")]),i("prev",()=>ar(t),[Ae(t,"previous")]),i("select",()=>qm(t),[Ae(t,"all")]),X("label",null,[this.caseField,Ae(t,"match case")]),X("label",null,[this.reField,Ae(t,"regexp")]),X("label",null,[this.wordField,Ae(t,"by word")]),...t.state.readOnly?[]:[X("br"),this.replaceField,i("replace",()=>ac(t),[Ae(t,"replace")]),i("replaceAll",()=>Um(t),[Ae(t,"replace all")])],X("button",{name:"close",onclick:()=>uc(t),"aria-label":Ae(t,"close"),type:"button"},["×"])])}commit(){let t=new oc({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:Gi.of(t)}))}keydown(t){lm(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?ar:lr)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),ac(this.view))}update(t){for(let e of t.transactions)for(let i of e.effects)i.is(Gi)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(ui).top}};function Ae(t,e){return t.state.phrase(e)}var hr=30,cr=/[\s\.,:;?!]/;function ho(t,{from:e,to:i}){let n=t.state.doc.lineAt(e),r=t.state.doc.lineAt(i).to,s=Math.max(n.from,e-hr),o=Math.min(r,i+hr),l=t.state.sliceDoc(s,o);if(s!=n.from){for(let a=0;a<hr;a++)if(!cr.test(l[a+1])&&cr.test(l[a])){l=l.slice(a);break}}if(o!=r){for(let a=l.length-1;a>l.length-hr;a--)if(!cr.test(l[a-1])&&cr.test(l[a])){l=l.slice(0,a);break}}return L.announce.of(`${t.state.phrase("current match")}. ${l} ${t.state.phrase("on line")} ${n.number}.`)}var Ym=L.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"}}),Xm=[At,Ei.low(jm),Ym],Qm=1024,Zm=0,co=class{constructor(t,e){this.from=t,this.to=e}},W=class{constructor(t={}){this.id=Zm++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=Pe.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}};W.closedBy=new W({deserialize:t=>t.split(" ")}),W.openedBy=new W({deserialize:t=>t.split(" ")}),W.group=new W({deserialize:t=>t.split(" ")}),W.isolate=new W({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),W.contextHash=new W({perNode:!0}),W.lookAhead=new W({perNode:!0}),W.mounted=new W({perNode:!0});var fr=class{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[W.mounted.id]}},e0=Object.create(null),Pe=class Bd{constructor(e,i,n,r=0){this.name=e,this.props=i,this.id=n,this.flags=r}static define(e){let i=e.props&&e.props.length?Object.create(null):e0,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new Bd(e.name||"",i,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");i[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let i=this.prop(W.group);return i?i.indexOf(e)>-1:!1}return this.id==e}static match(e){let i=Object.create(null);for(let n in e)for(let r of n.split(" "))i[r]=e[n];return n=>{for(let r=n.prop(W.group),s=-1;s<(r?r.length:0);s++){let o=i[s<0?n.name:r[s]];if(o)return o}}}};Pe.none=new Pe("",Object.create(null),0,8);var t0=class Pd{constructor(e){this.types=e;for(let i=0;i<e.length;i++)if(e[i].id!=i)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let i=[];for(let n of this.types){let r=null;for(let s of e){let o=s(n);o&&(r||(r=Object.assign({},n.props)),r[o[0].id]=o[1])}i.push(r?new Pe(n.name,r,n.id,n.flags):n)}return new Pd(i)}},ur=new WeakMap,dc=new WeakMap,me;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"})(me||(me={}));var le=class pl{constructor(e,i,n,r,s){if(this.type=e,this.children=i,this.positions=n,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=fr.get(this);if(e&&!e.overlay)return e.tree.toString();let i="";for(let n of this.children){let r=n.toString();r&&(i&&(i+=","),i+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(i.length?"("+i+")":""):i}cursor(e=0){return new po(this.topNode,e)}cursorAt(e,i=0,n=0){let r=ur.get(this)||this.topNode,s=new po(r);return s.moveTo(e,i),ur.set(this,s._tree),s}get topNode(){return new Tt(this,0,0,null)}resolve(e,i=0){let n=Yi(ur.get(this)||this.topNode,e,i,!1);return ur.set(this,n),n}resolveInner(e,i=0){let n=Yi(dc.get(this)||this.topNode,e,i,!0);return dc.set(this,n),n}resolveStack(e,i=0){return s0(this,e,i)}iterate(e){let{enter:i,leave:n,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&me.IncludeAnonymous)>0;for(let a=this.cursor(o|me.IncludeAnonymous);;){let c=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||i(a)!==!1)){if(a.firstChild())continue;c=!0}for(;c&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let i in this.props)e.push([+i,this.props[i]]);return e}balance(e={}){return this.children.length<=8?this:mo(Pe.none,this.children,this.positions,0,this.children.length,0,this.length,(i,n,r)=>new pl(this.type,i,n,r,this.propValues),e.makeTree||((i,n,r)=>new pl(Pe.none,i,n,r)))}static build(e){return o0(e)}};le.empty=new le(Pe.none,[],[],0);var i0=class Rd{constructor(e,i){this.buffer=e,this.index=i}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Rd(this.buffer,this.index)}},gi=class Nd{constructor(e,i,n){this.buffer=e,this.length=i,this.set=n}get type(){return Pe.none}toString(){let e=[];for(let i=0;i<this.buffer.length;)e.push(this.childString(i)),i=this.buffer[i+3];return e.join(",")}childString(e){let i=this.buffer[e],n=this.buffer[e+3],r=this.set.types[i],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,n==e)return s;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,i,n,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=i&&!(pc(s,r,o[a+1],o[a+2])&&(l=a,n>0));a=o[a+3]);return l}slice(e,i,n){let r=this.buffer,s=new Uint16Array(i-e),o=0;for(let l=e,a=0;l<i;){s[a++]=r[l++],s[a++]=r[l++]-n;let c=s[a++]=r[l++]-n;s[a++]=r[l++]-e,o=Math.max(o,c)}return new Nd(s,o,this.set)}};function pc(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function Yi(t,e,i,n){for(var r;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let o=!n&&t instanceof Tt&&t.index<0?null:t.parent;if(!o)return t;t=o}let s=n?0:me.IgnoreOverlays;if(n)for(let o=t,l=o.parent;l;o=l,l=o.parent)o instanceof Tt&&o.index<0&&((r=l.enter(e,i,s))===null||r===void 0?void 0:r.from)!=o.from&&(t=l);for(;;){let o=t.enter(e,i,s);if(!o)return t;t=o}}var gc=class{cursor(t=0){return new po(this,t)}getChild(t,e=null,i=null){let n=mc(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return mc(this,t,e,i)}resolve(t,e=0){return Yi(this,t,e,!1)}resolveInner(t,e=0){return Yi(this,t,e,!0)}matchContext(t){return fo(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let n=e.lastChild;if(!n||n.to!=e.to)break;n.type.isError&&n.from==n.to?(i=e,e=n.prevSibling):e=n}return i}get node(){return this}get next(){return this.parent}},Tt=class _r extends gc{constructor(e,i,n,r){super(),this._tree=e,this.from=i,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,i,n,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,c=i>0?l.length:-1;e!=c;e+=i){let h=l[e],f=a[e]+o.from;if(pc(r,n,f,f+h.length)){if(h instanceof gi){if(s&me.ExcludeBuffers)continue;let u=h.findChild(0,h.buffer.length,i,n-f,r);if(u>-1)return new uo(new n0(o,h,e,f),null,u)}else if(s&me.IncludeAnonymous||!h.type.isAnonymous||go(h)){let u;if(!(s&me.IgnoreMounts)&&(u=fr.get(h))&&!u.overlay)return new _r(u.tree,f,e,o);let d=new _r(h,f,e,o);return s&me.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(i<0?h.children.length-1:0,i,n,r)}}}if(s&me.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+i:e=i<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,i,n=0){let r;if(!(n&me.IgnoreOverlays)&&(r=fr.get(this._tree))&&r.overlay){let s=e-this.from;for(let{from:o,to:l}of r.overlay)if((i>0?o<=s:o<s)&&(i<0?l>=s:l>s))return new _r(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,i,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function mc(t,e,i,n){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(i!=null){for(let o=!1;!o;)if(o=r.type.is(i),!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function fo(t,e,i=e.length-1){for(let n=t;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}var n0=class{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}},uo=class dn extends gc{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,i,n){super(),this.context=e,this._parent=i,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,i,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,i-this.context.start,n);return s<0?null:new dn(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,i,n=0){if(n&me.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],i>0?1:-1,e-this.context.start,i);return s<0?null:new dn(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,i=e.buffer[this.index+3];return i<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new dn(this.context,this._parent,i):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,i=this._parent?this._parent.index+4:0;return this.index==i?this.externalSibling(-1):new dn(this.context,this._parent,e.findChild(i,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],i=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];e.push(n.slice(r,s,o)),i.push(0)}return new le(this.type,e,i,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function vc(t){if(!t.length)return null;let e=0,i=t[0];for(let s=1;s<t.length;s++){let o=t[s];(o.from>i.from||o.to<i.to)&&(i=o,e=s)}let n=i instanceof Tt&&i.index<0?null:i.parent,r=t.slice();return n?r[e]=n:r.splice(e,1),new r0(r,i)}var r0=class{constructor(t,e){this.heads=t,this.node=e}get next(){return vc(this.heads)}};function s0(t,e,i){let n=t.resolveInner(e,i),r=null;for(let s=n instanceof Tt?n:n.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[n])).push(o.resolve(e,i)),s=o}else{let o=fr.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new Tt(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[n])).push(Yi(l,e,i,!1))}}return r?vc(r):n}var po=class{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof Tt)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return t?t instanceof Tt?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?i&me.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&me.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&me.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(e.findChild(n,this.index,-1,0,4))}else{let n=e.buffer[this.index+3];if(n<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(n.buffer.buffer[r+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;{index:e,_parent:i}=i)if(e>-1)for(let r=e+t,s=t<0?-1:i._tree.children.length;r!=s;r+=t){let o=i._tree.children[r];if(this.mode&me.IncludeAnonymous||o instanceof gi||!o.type.isAnonymous||go(o))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)e:for(let n=this.index,r=this.stack.length;r>=0;){for(let s=t;s;s=s._parent)if(s.index==n){if(n==this.index)return s;e=s,i=r+1;break e}n=this.stack[--r]}for(let n=i;n<this.stack.length;n++)e=new uo(this.buffer,e,this.stack[n]);return this.bufferNode=new uo(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&e&&e(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return fo(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,r=this.stack.length-1;n>=0;r--){if(r<0)return fo(this._tree,t,n);let s=i[e.buffer[this.stack[r]]];if(!s.isAnonymous){if(t[n]&&t[n]!=s.name)return!1;n--}}return!0}};function go(t){return t.children.some(e=>e instanceof gi||!e.type.isAnonymous||go(e))}function o0(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:r=Qm,reused:s=[],minRepeatType:o=n.types.length}=t,l=Array.isArray(i)?new i0(i,i.length):i,a=n.types,c=0,h=0;function f(E,H,C,B,V,$){let{id:I,start:O,end:R,size:F}=l,te=h,Ye=c;for(;F<0;)if(l.next(),F==-1){let ct=s[I];C.push(ct),B.push(O-E);return}else if(F==-3){c=I;return}else if(F==-4){h=I;return}else throw new RangeError(`Unrecognized record size: ${F}`);let Nt=a[I],Gt,It,xl=O-E;if(R-O<=r&&(It=m(l.pos-H,V))){let ct=new Uint16Array(It.size-It.skip),De=l.pos-It.size,Xe=ct.length;for(;l.pos>De;)Xe=v(It.start,ct,Xe);Gt=new gi(ct,R-It.start,n),xl=It.start-E}else{let ct=l.pos-F;l.next();let De=[],Xe=[],Ft=I>=o?I:-1,Jt=0,Cn=R;for(;l.pos>ct;)Ft>=0&&l.id==Ft&&l.size>=0?(l.end<=Cn-r&&(p(De,Xe,O,Jt,l.end,Cn,Ft,te,Ye),Jt=De.length,Cn=l.end),l.next()):$>2500?u(O,ct,De,Xe):f(O,ct,De,Xe,Ft,$+1);if(Ft>=0&&Jt>0&&Jt<De.length&&p(De,Xe,O,Jt,O,Cn,Ft,te,Ye),De.reverse(),Xe.reverse(),Ft>-1&&Jt>0){let kl=d(Nt,Ye);Gt=mo(Nt,De,Xe,0,De.length,0,R-O,kl,kl)}else Gt=g(Nt,De,Xe,R-O,te-R,Ye)}C.push(Gt),B.push(xl)}function u(E,H,C,B){let V=[],$=0,I=-1;for(;l.pos>H;){let{id:O,start:R,end:F,size:te}=l;if(te>4)l.next();else{if(I>-1&&R<I)break;I<0&&(I=F-r),V.push(O,R,F),$++,l.next()}}if($){let O=new Uint16Array($*4),R=V[V.length-2];for(let F=V.length-3,te=0;F>=0;F-=3)O[te++]=V[F],O[te++]=V[F+1]-R,O[te++]=V[F+2]-R,O[te++]=te;C.push(new gi(O,V[2]-R,n)),B.push(R-E)}}function d(E,H){return(C,B,V)=>{let $=0,I=C.length-1,O,R;if(I>=0&&(O=C[I])instanceof le){if(!I&&O.type==E&&O.length==V)return O;(R=O.prop(W.lookAhead))&&($=B[I]+O.length+R)}return g(E,C,B,V,$,H)}}function p(E,H,C,B,V,$,I,O,R){let F=[],te=[];for(;E.length>B;)F.push(E.pop()),te.push(H.pop()+C-V);E.push(g(n.types[I],F,te,$-V,O-$,R)),H.push(V-C)}function g(E,H,C,B,V,$,I){if($){let O=[W.contextHash,$];I=I?[O].concat(I):[O]}if(V>25){let O=[W.lookAhead,V];I=I?[O].concat(I):[O]}return new le(E,H,C,B,I)}function m(E,H){let C=l.fork(),B=0,V=0,$=0,I=C.end-r,O={size:0,start:0,skip:0};e:for(let R=C.pos-E;C.pos>R;){let F=C.size;if(C.id==H&&F>=0){O.size=B,O.start=V,O.skip=$,$+=4,B+=4,C.next();continue}let te=C.pos-F;if(F<0||te<R||C.start<I)break;let Ye=C.id>=o?4:0,Nt=C.start;for(C.next();C.pos>te;){if(C.size<0)if(C.size==-3)Ye+=4;else break e;else C.id>=o&&(Ye+=4);C.next()}V=Nt,B+=F,$+=Ye}return(H<0||B==E)&&(O.size=B,O.start=V,O.skip=$),O.size>4?O:void 0}function v(E,H,C){let{id:B,start:V,end:$,size:I}=l;if(l.next(),I>=0&&B<o){let O=C;if(I>4){let R=l.pos-(I-4);for(;l.pos>R;)C=v(E,H,C)}H[--C]=O,H[--C]=$-E,H[--C]=V-E,H[--C]=B}else I==-3?c=B:I==-4&&(h=B);return C}let y=[],S=[];for(;l.pos>0;)f(t.start||0,t.bufferStart||0,y,S,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:y.length?S[0]+y[0].length:0;return new le(a[t.topID],y.reverse(),S.reverse(),k)}var yc=new WeakMap;function dr(t,e){if(!t.isAnonymous||e instanceof gi||e.type!=t)return 1;let i=yc.get(e);if(i==null){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof le)){i=1;break}i+=dr(t,n)}yc.set(e,i)}return i}function mo(t,e,i,n,r,s,o,l,a){let c=0;for(let p=n;p<r;p++)c+=dr(t,e[p]);let h=Math.ceil(c*1.5/8),f=[],u=[];function d(p,g,m,v,y){for(let S=m;S<v;){let k=S,E=g[S],H=dr(t,p[S]);for(S++;S<v;S++){let C=dr(t,p[S]);if(H+C>=h)break;H+=C}if(S==k+1){if(H>h){let C=p[k];d(C.children,C.positions,0,C.children.length,g[k]+y);continue}f.push(p[k])}else{let C=g[S-1]+p[S-1].length-E;f.push(mo(t,p,g,k,S,E,C,null,a))}u.push(E+y-s)}}return d(e,i,n,r,0),(l||a)(f,u,o)}var pr=class gl{constructor(e,i,n,r,s=!1,o=!1){this.from=e,this.to=i,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,i=[],n=!1){let r=[new gl(0,e.length,e,0,!1,n)];for(let s of i)s.to>e.length&&r.push(s);return r}static applyChanges(e,i,n=128){if(!i.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,c=0;;l++){let h=l<i.length?i[l]:null,f=h?h.fromA:1e9;if(f-a>=n)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||c){let d=Math.max(u.from,a)-c,p=Math.min(u.to,f)-c;u=d>=p?null:new gl(d,p,u.tree,u.offset+c,l>0,!!h)}if(u&&r.push(u),o.to>f)break;o=s<e.length?e[s++]:null}if(!h)break;a=h.toA,c=h.toA-h.toB}return r}},bc=class{startParse(t,e,i){return typeof t=="string"&&(t=new l0(t)),i=i?i.length?i.map(n=>new co(n.from,n.to)):[new co(0,0)]:[new co(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let r=n.advance();if(r)return r}}},l0=class{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}},Ub=new W({perNode:!0}),a0=0,Re=class ml{constructor(e,i,n,r){this.name=e,this.set=i,this.base=n,this.modified=r,this.id=a0++}toString(){let{name:e}=this;for(let i of this.modified)i.name&&(e=`${i.name}(${e})`);return e}static define(e,i){let n=typeof e=="string"?e:"?";if(e instanceof ml&&(i=e),i!=null&&i.base)throw new Error("Can not derive from a modified tag");let r=new ml(n,[],null,[]);if(r.set.push(r),i)for(let s of i.set)r.set.push(s);return r}static defineModifier(e){let i=new wc(e);return n=>n.modified.indexOf(i)>-1?n:wc.get(n.base||n,n.modified.concat(i).sort((r,s)=>r.id-s.id))}},h0=0,wc=class Id{constructor(e){this.name=e,this.instances=[],this.id=h0++}static get(e,i){if(!i.length)return e;let n=i[0].instances.find(l=>l.base==e&&c0(i,l.modified));if(n)return n;let r=[],s=new Re(e.name,r,e,i);for(let l of i)l.instances.push(s);let o=f0(i);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(Id.get(l,a));return s}};function c0(t,e){return t.length==e.length&&t.every((i,n)=>i==e[n])}function f0(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,r=e.length;n<r;n++)e.push(e[n].concat(t[i]));return e.sort((i,n)=>n.length-i.length)}function u0(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let r of i.split(" "))if(r){let s=[],o=2,l=r;for(let f=0;;){if(l=="..."&&f>0&&f+3==r.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+r);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==r.length)break;let d=r[f++];if(f==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);l=r.slice(f)}let a=s.length-1,c=s[a];if(!c)throw new RangeError("Invalid path: "+r);let h=new gr(n,o,a>0?s.slice(0,a):null);e[c]=h.sort(e[c])}}return xc.add(e)}var xc=new W,gr=class{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}};gr.empty=new gr([],2,null);function kc(t,e){let i=Object.create(null);for(let s of t)if(!Array.isArray(s.tag))i[s.tag.id]=s.class;else for(let o of s.tag)i[o.id]=s.class;let{scope:n,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let c=i[a.id];if(c){o=o?o+" "+c:c;break}}return o},scope:n}}function d0(t,e){let i=null;for(let n of t){let r=n.style(e);r&&(i=i?i+" "+r:r)}return i}function p0(t,e,i,n=0,r=t.length){let s=new g0(n,Array.isArray(e)?e:[e],i);s.highlightRange(t.cursor(),n,r,"",s.highlighters),s.flush(r)}var g0=class{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,r){let{type:s,from:o,to:l}=t;if(o>=i||l<=e)return;s.isTop&&(r=this.highlighters.filter(u=>!u.scope||u.scope(s)));let a=n,c=m0(t)||gr.empty,h=d0(r,c.tags);if(h&&(a&&(a+=" "),a+=h,c.mode==1&&(n+=(n?" ":"")+h)),this.startSpan(Math.max(e,o),a),c.opaque)return;let f=t.tree&&t.tree.prop(W.mounted);if(f&&f.overlay){let u=t.node.enter(f.overlay[0].from+o,1),d=this.highlighters.filter(g=>!g.scope||g.scope(f.tree.type)),p=t.firstChild();for(let g=0,m=o;;g++){let v=g<f.overlay.length?f.overlay[g]:null,y=v?v.from+o:l,S=Math.max(e,m),k=Math.min(i,y);if(S<k&&p)for(;t.from<k&&(this.highlightRange(t,S,k,n,r),this.startSpan(Math.min(k,t.to),a),!(t.to>=y||!t.nextSibling())););if(!v||y>i)break;m=v.to+o,m>e&&(this.highlightRange(u.cursor(),Math.max(e,v.from+o),Math.min(i,m),"",d),this.startSpan(Math.min(i,m),a))}p&&t.parent()}else if(t.firstChild()){f&&(n="");do if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,r),this.startSpan(Math.min(i,t.to),a)}while(t.nextSibling());t.parent()}}};function m0(t){let e=t.type.prop(xc);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}var A=Re.define,mr=A(),Mt=A(),Sc=A(Mt),Cc=A(Mt),Dt=A(),vr=A(Dt),vo=A(Dt),it=A(),_t=A(it),nt=A(),rt=A(),yo=A(),Xi=A(yo),yr=A(),x={comment:mr,lineComment:A(mr),blockComment:A(mr),docComment:A(mr),name:Mt,variableName:A(Mt),typeName:Sc,tagName:A(Sc),propertyName:Cc,attributeName:A(Cc),className:A(Mt),labelName:A(Mt),namespace:A(Mt),macroName:A(Mt),literal:Dt,string:vr,docString:A(vr),character:A(vr),attributeValue:A(vr),number:vo,integer:A(vo),float:A(vo),bool:A(Dt),regexp:A(Dt),escape:A(Dt),color:A(Dt),url:A(Dt),keyword:nt,self:A(nt),null:A(nt),atom:A(nt),unit:A(nt),modifier:A(nt),operatorKeyword:A(nt),controlKeyword:A(nt),definitionKeyword:A(nt),moduleKeyword:A(nt),operator:rt,derefOperator:A(rt),arithmeticOperator:A(rt),logicOperator:A(rt),bitwiseOperator:A(rt),compareOperator:A(rt),updateOperator:A(rt),definitionOperator:A(rt),typeOperator:A(rt),controlOperator:A(rt),punctuation:yo,separator:A(yo),bracket:Xi,angleBracket:A(Xi),squareBracket:A(Xi),paren:A(Xi),brace:A(Xi),content:it,heading:_t,heading1:A(_t),heading2:A(_t),heading3:A(_t),heading4:A(_t),heading5:A(_t),heading6:A(_t),contentSeparator:A(it),list:A(it),quote:A(it),emphasis:A(it),strong:A(it),link:A(it),monospace:A(it),strikethrough:A(it),inserted:A(),deleted:A(),changed:A(),invalid:A(),meta:yr,documentMeta:A(yr),annotation:A(yr),processingInstruction:A(yr),definition:Re.defineModifier("definition"),constant:Re.defineModifier("constant"),function:Re.defineModifier("function"),standard:Re.defineModifier("standard"),local:Re.defineModifier("local"),special:Re.defineModifier("special")};for(let t in x){let e=x[t];e instanceof Re&&(e.name=t)}var Gb=kc([{tag:x.link,class:"tok-link"},{tag:x.heading,class:"tok-heading"},{tag:x.emphasis,class:"tok-emphasis"},{tag:x.strong,class:"tok-strong"},{tag:x.keyword,class:"tok-keyword"},{tag:x.atom,class:"tok-atom"},{tag:x.bool,class:"tok-bool"},{tag:x.url,class:"tok-url"},{tag:x.labelName,class:"tok-labelName"},{tag:x.inserted,class:"tok-inserted"},{tag:x.deleted,class:"tok-deleted"},{tag:x.literal,class:"tok-literal"},{tag:x.string,class:"tok-string"},{tag:x.number,class:"tok-number"},{tag:[x.regexp,x.escape,x.special(x.string)],class:"tok-string2"},{tag:x.variableName,class:"tok-variableName"},{tag:x.local(x.variableName),class:"tok-variableName tok-local"},{tag:x.definition(x.variableName),class:"tok-variableName tok-definition"},{tag:x.special(x.variableName),class:"tok-variableName2"},{tag:x.definition(x.propertyName),class:"tok-propertyName tok-definition"},{tag:x.typeName,class:"tok-typeName"},{tag:x.namespace,class:"tok-namespace"},{tag:x.className,class:"tok-className"},{tag:x.macroName,class:"tok-macroName"},{tag:x.propertyName,class:"tok-propertyName"},{tag:x.operator,class:"tok-operator"},{tag:x.comment,class:"tok-comment"},{tag:x.meta,class:"tok-meta"},{tag:x.invalid,class:"tok-invalid"},{tag:x.punctuation,class:"tok-punctuation"}]),bo,mi=new W;function v0(t){return P.define({combine:t?e=>e.concat(t):void 0})}var y0=new W,Ne=class{constructor(t,e,i=[],n=""){this.data=t,this.name=n,ie.prototype.hasOwnProperty("tree")||Object.defineProperty(ie.prototype,"tree",{get(){return Se(this)}}),this.parser=e,this.extension=[vi.of(this),ie.languageData.of((r,s,o)=>{let l=Ac(r,s,o),a=l.type.prop(mi);if(!a)return[];let c=r.facet(a),h=l.type.prop(y0);if(h){let f=l.resolve(s-l.from,o);for(let u of h)if(u.test(f,r)){let d=r.facet(u.facet);return u.type=="replace"?d:d.concat(c)}}return c})].concat(i)}isActiveAt(t,e,i=-1){return Ac(t,e,i).type.prop(mi)==this.data}findRegions(t){let e=t.facet(vi);if((e==null?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(r,s)=>{if(r.prop(mi)==this.data){i.push({from:s,to:s+r.length});return}let o=r.prop(W.mounted);if(o){if(o.tree.prop(mi)==this.data){if(o.overlay)for(let l of o.overlay)i.push({from:l.from+s,to:l.to+s});else i.push({from:s,to:s+r.length});return}else if(o.overlay){let l=i.length;if(n(o.tree,o.overlay[0].from+s),i.length>l)return}}for(let l=0;l<r.children.length;l++){let a=r.children[l];a instanceof le&&n(a,r.positions[l]+s)}};return n(Se(t),0),i}get allowsNesting(){return!0}};Ne.setState=K.define();function Ac(t,e,i){let n=t.facet(vi),r=Se(t).topNode;if(!n||n.allowsNesting)for(let s=r;s;s=s.enter(e,i,me.ExcludeBuffers))s.type.isTop&&(r=s);return r}function Se(t){let e=t.field(Ne.state,!1);return e?e.tree:le.empty}function b0(t,e,i=50){var n;let r=(n=t.field(Ne.state,!1))===null||n===void 0?void 0:n.context;if(!r)return null;let s=r.viewport;r.updateViewport({from:0,to:e});let o=r.isDone(e)||r.work(i,e)?r.tree:null;return r.updateViewport(s),o}var w0=class{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}},Qi=null,wo=class vl{constructor(e,i,n=[],r,s,o,l,a){this.parser=e,this.state=i,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,i,n){return new vl(e,i,[],le.empty,0,n,[],null)}startParse(){return this.parser.startParse(new w0(this.state.doc),this.fragments)}work(e,i){return i!=null&&i>=this.state.doc.length&&(i=void 0),this.tree!=le.empty&&this.isDone(i!=null?i:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),i!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>i)&&i<this.state.doc.length&&this.parse.stopAt(i);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(pr.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(i!=null?i:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,i;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(i=this.parse.advance()););}),this.treeLen=e,this.tree=i,this.fragments=this.withoutTempSkipped(pr.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let i=Qi;Qi=this;try{return e()}finally{Qi=i}}withoutTempSkipped(e){for(let i;i=this.tempSkipped.pop();)e=Tc(e,i.from,i.to);return e}changes(e,i){let{fragments:n,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((c,h,f,u)=>a.push({fromA:c,toA:h,fromB:f,toB:u})),n=pr.applyChanges(n,a),r=le.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let h=e.mapPos(c.from,1),f=e.mapPos(c.to,-1);h<f&&l.push({from:h,to:f})}}}return new vl(this.parser,i,n,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let i=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:r,to:s}=this.skipped[n];r<e.to&&s>e.from&&(this.fragments=Tc(this.fragments,r,s),this.skipped.splice(n--,1))}return this.skipped.length>=i?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,i){this.skipped.push({from:e,to:i})}static getSkippingParser(e){return new class extends bc{createParse(i,n,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=Qi;if(a){for(let c of r)a.tempSkipped.push(c);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new le(Pe.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let i=this.fragments;return this.treeLen>=e&&i.length&&i[0].from==0&&i[0].to>=e}static get(){return Qi}};function Tc(t,e,i){return pr.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}var xo=class yl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let i=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),i.viewport.to);return i.work(20,n)||i.takeTree(),new yl(i)}static init(e){let i=Math.min(3e3,e.doc.length),n=wo.create(e.facet(vi).parser,e,{from:0,to:i});return n.work(20,i)||n.takeTree(),new yl(n)}};Ne.state=Oe.define({create:xo.init,update(t,e){for(let i of e.effects)if(i.is(Ne.setState))return i.value;return e.startState.facet(vi)!=e.state.facet(vi)?xo.init(e.state):t.apply(e)}});var Mc=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(Mc=t=>{let e=-1,i=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});var ko=typeof navigator!="undefined"&&(!((bo=navigator.scheduling)===null||bo===void 0)&&bo.isInputPending)?()=>navigator.scheduling.isInputPending():null,x0=je.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let i=this.view.state.field(Ne.state).context;(i.updateViewport(e.view.viewport)||this.view.viewport.to>i.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(i)}scheduleWork(){if(this.working)return;let{state:e}=this.view,i=e.field(Ne.state);(i.tree!=i.context.tree||!i.context.isDone(e.doc.length))&&(this.working=Mc(this.work))}work(e){this.working=null;let i=Date.now();if(this.chunkEnd<i&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=i+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,s=n.field(Ne.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!ko?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&n.doc.length>r+1e3,a=s.context.work(()=>ko&&ko()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-i,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Ne.setState.of(new xo(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(i=>Le(this.view.state,i)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),vi=P.define({combine(t){return t.length?t[0]:null},enables:t=>[Ne.state,x0,L.contentAttributes.compute([t],e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}})]}),k0=class{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}},S0=P.define(),Zi=P.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(i=>i!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function jt(t){let e=t.facet(Zi);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function en(t,e){let i="",n=t.tabSize,r=t.facet(Zi)[0];if(r==" "){for(;e>=n;)i+=" ",e-=n;r=" "}for(let s=0;s<e;s++)i+=r;return i}function So(t,e){t instanceof ie&&(t=new br(t));for(let n of t.state.facet(S0)){let r=n(t,e);if(r!==void 0)return r}let i=Se(t.state);return i.length>=e?C0(t,i,e):null}var br=class{constructor(t,e={}){this.state=t,this.options=e,this.unit=jt(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return n!=null&&n>=i.from&&n<=i.to?r&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),r=this.countColumn(i,t-n),s=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return s>-1&&(r+=s-this.countColumn(i,i.search(/\S|$/))),r}countColumn(t,e=t.length){return Bn(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let s=r(n);if(s>-1)return s}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Dc=new W;function C0(t,e,i){let n=e.resolveStack(i),r=e.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(r!=n.node){let s=[];for(let o=r;o&&!(o.from<n.node.from||o.to>n.node.to||o.from==n.node.from&&o.type==n.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)n={node:s[o],next:n}}return Oc(n,t,i)}function Oc(t,e,i){for(let n=t;n;n=n.next){let r=T0(n.node);if(r)return r(D0.create(e,i,n))}return 0}function A0(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function T0(t){let e=t.type.prop(Dc);if(e)return e;let i=t.firstChild,n;if(i&&(n=i.type.prop(W.closedBy))){let r=t.lastChild,s=r&&n.indexOf(r.name)>-1;return o=>L0(o,!0,1,void 0,s&&!A0(o)?r.from:void 0)}return t.parent==null?M0:null}function M0(){return 0}var D0=class Fd extends br{constructor(e,i,n){super(e.state,e.options),this.base=e,this.pos=i,this.context=n}get node(){return this.context.node}static create(e,i,n){return new Fd(e,i,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let i=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(i.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(O0(n,e))break;i=this.state.doc.lineAt(n.from)}return this.lineIndent(i.from)}continue(){return Oc(this.context.next,this.base,this.pos)}};function O0(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function E0(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(i.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=i.to;;){let a=e.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let c=/^ */.exec(s.text.slice(i.to-s.from))[0].length;return{from:i.from,to:i.to+c}}l=a.to}}function L0(t,e,i,n,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=n&&s.slice(o,o+n.length)==n||r==t.pos+o,a=e?E0(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*i)}var B0=200;function P0(){return ie.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let i=t.newDoc,{head:n}=t.newSelection.main,r=i.lineAt(n);if(n>r.from+B0)return t;let s=i.sliceString(r.from,n);if(!e.some(c=>c.test(s)))return t;let{state:o}=t,l=-1,a=[];for(let{head:c}of o.selection.ranges){let h=o.doc.lineAt(c);if(h.from==l)continue;l=h.from;let f=So(o,h.from);if(f==null)continue;let u=/^\s*/.exec(h.text)[0],d=en(o,f);u!=d&&a.push({from:h.from,to:h.from+u.length,insert:d})}return a.length?[t,{changes:a,sequential:!0}]:t})}var Co=class Hd{constructor(e,i){this.specs=e;let n;function r(l){let a=yt.newName();return(n||(n=Object.create(null)))["."+a]=l,a}const s=typeof i.all=="string"?i.all:i.all?r(i.all):void 0,o=i.scope;this.scope=o instanceof Ne?l=>l.prop(mi)==o.data:o?l=>l==o:void 0,this.style=kc(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=n?new yt(n):null,this.themeType=i.themeType}static define(e,i){return new Hd(e,i||{})}},Ao=P.define(),Ec=P.define({combine(t){return t.length?[t[0]]:null}});function To(t){let e=t.facet(Ao);return e.length?e:t.facet(Ec)}function Lc(t,e){let i=[N0],n;return t instanceof Co&&(t.module&&i.push(L.styleModule.of(t.module)),n=t.themeType),e!=null&&e.fallback?i.push(Ec.of(t)):n?i.push(Ao.computeN([L.darkTheme],r=>r.facet(L.darkTheme)==(n=="dark")?[t]:[])):i.push(Ao.of(t)),i}var R0=class{constructor(t){this.markCache=Object.create(null),this.tree=Se(t.state),this.decorations=this.buildDeco(t,To(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=Se(t.state),i=To(t.state),n=i!=To(t.startState),{viewport:r}=t.view,s=t.changes.mapPos(this.decoratedTo,1);e.length<r.to&&!n&&e.type==this.tree.type&&s>=r.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=r.to)}buildDeco(t,e){if(!e||!this.tree.length)return U.none;let i=new ei;for(let{from:n,to:r}of t.visibleRanges)p0(this.tree,e,(s,o,l)=>{i.add(s,o,this.markCache[l]||(this.markCache[l]=U.mark({class:l})))},n,r);return i.finish()}},N0=Ei.high(je.fromClass(R0,{decorations:t=>t.decorations})),I0=Co.define([{tag:x.meta,color:"#404740"},{tag:x.link,textDecoration:"underline"},{tag:x.heading,textDecoration:"underline",fontWeight:"bold"},{tag:x.emphasis,fontStyle:"italic"},{tag:x.strong,fontWeight:"bold"},{tag:x.strikethrough,textDecoration:"line-through"},{tag:x.keyword,color:"#708"},{tag:[x.atom,x.bool,x.url,x.contentSeparator,x.labelName],color:"#219"},{tag:[x.literal,x.inserted],color:"#164"},{tag:[x.string,x.deleted],color:"#a11"},{tag:[x.regexp,x.escape,x.special(x.string)],color:"#e40"},{tag:x.definition(x.variableName),color:"#00f"},{tag:x.local(x.variableName),color:"#30a"},{tag:[x.typeName,x.namespace],color:"#085"},{tag:x.className,color:"#167"},{tag:[x.special(x.variableName),x.macroName],color:"#256"},{tag:x.definition(x.propertyName),color:"#00c"},{tag:x.comment,color:"#940"},{tag:x.invalid,color:"#f00"}]),F0=1e4,H0="()[]{}",V0=new W;function Mo(t,e,i){let n=t.prop(e<0?W.openedBy:W.closedBy);if(n)return n;if(t.name.length==1){let r=i.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[i[r+e]]}return null}function Do(t){let e=t.type.prop(V0);return e?e(t.node):t}function yi(t,e,i,n={}){let r=n.maxScanDistance||F0,s=n.brackets||H0,o=Se(t),l=o.resolveInner(e,i);for(let a=l;a;a=a.parent){let c=Mo(a.type,i,s);if(c&&a.from<a.to){let h=Do(a);if(h&&(i>0?e>=h.from&&e<h.to:e>h.from&&e<=h.to))return W0(t,e,i,a,h,c,s)}}return $0(t,e,i,o,l.type,r,s)}function W0(t,e,i,n,r,s,o){let l=n.parent,a={from:r.from,to:r.to},c=0,h=l==null?void 0:l.cursor();if(h&&(i<0?h.childBefore(n.from):h.childAfter(n.to)))do if(i<0?h.to<=n.from:h.from>=n.to){if(c==0&&s.indexOf(h.type.name)>-1&&h.from<h.to){let f=Do(h);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(Mo(h.type,i,o))c++;else if(Mo(h.type,-i,o)){if(c==0){let f=Do(h);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}c--}}while(i<0?h.prevSibling():h.nextSibling());return{start:a,matched:!1}}function $0(t,e,i,n,r,s,o){let l=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=i>0)return null;let c={from:i<0?e-1:e,to:i>0?e+1:e},h=t.doc.iterRange(e,i>0?t.doc.length:0),f=0;for(let u=0;!h.next().done&&u<=s;){let d=h.value;i<0&&(u+=d.length);let p=e+u*i;for(let g=i>0?0:d.length-1,m=i>0?d.length:-1;g!=m;g+=i){let v=o.indexOf(d[g]);if(!(v<0||n.resolveInner(p+g,1).type!=r))if(v%2==0==i>0)f++;else{if(f==1)return{start:c,end:{from:p+g,to:p+g+1},matched:v>>1==a>>1};f--}}i>0&&(u+=d.length)}return h.done?{start:c,matched:!1}:null}function Bc(t,e,i,n=0,r=0){e==null&&(e=t.search(/[^\s\u00a0]/),e==-1&&(e=t.length));let s=r;for(let o=n;o<e;o++)t.charCodeAt(o)==9?s+=i-s%i:s++;return s}var Pc=class{constructor(t,e,i,n){this.string=t,this.tabSize=e,this.indentUnit=i,this.overrideIndent=n,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e=this.string.charAt(this.pos),i;if(typeof t=="string"?i=e==t:i=e&&(t instanceof RegExp?t.test(e):t(e)),i)return++this.pos,e}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Bc(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:Bc(this.string,null,this.tabSize)}match(t,e,i){if(typeof t=="string"){let n=s=>i?s.toLowerCase():s,r=this.string.substr(this.pos,t.length);return n(r)==n(t)?(e!==!1&&(this.pos+=t.length),!0):null}else{let n=this.string.slice(this.pos).match(t);return n&&n.index>0?null:(n&&e!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}};function z0(t){return{name:t.name||"",token:t.token,blankLine:t.blankLine||(()=>{}),startState:t.startState||(()=>!0),copyState:t.copyState||_0,indent:t.indent||(()=>null),languageData:t.languageData||{},tokenTable:t.tokenTable||Eo,mergeTokens:t.mergeTokens!==!1}}function _0(t){if(typeof t!="object")return t;let e={};for(let i in t){let n=t[i];e[i]=n instanceof Array?n.slice():n}return e}var Rc=new WeakMap,j0=class Vd extends Ne{constructor(e){let i=v0(e.languageData),n=z0(e),r,s=new class extends bc{createParse(o,l,a){return new K0(r,o,l,a)}};super(i,s,[],e.name),this.topNode=J0(i,this),r=this,this.streamParser=n,this.stateAfter=new W({perNode:!0}),this.tokenTable=e.tokenTable?new Wc(n.tokenTable):G0}static define(e){return new Vd(e)}getIndent(e){let i,{overrideIndentation:n}=e.options;n&&(i=Rc.get(e.state),i!=null&&i<e.pos-1e4&&(i=void 0));let r=Oo(this,e.node.tree,e.node.from,e.node.from,i!=null?i:e.pos),s,o;if(r?(o=r.state,s=r.pos+1):(o=this.streamParser.startState(e.unit),s=e.node.from),e.pos-s>1e4)return null;for(;s<e.pos;){let a=e.state.doc.lineAt(s),c=Math.min(e.pos,a.to);if(a.length){let h=n?n(a.from):-1,f=new Pc(a.text,e.state.tabSize,e.unit,h<0?void 0:h);for(;f.pos<c-a.from;)Ic(this.streamParser.token,f,o)}else this.streamParser.blankLine(o,e.unit);if(c==e.pos)break;s=a.to+1}let l=e.lineAt(e.pos);return n&&i==null&&Rc.set(e.state,l.from),this.streamParser.indent(o,/^\s*(.*)/.exec(l.text)[1],e)}get allowsNesting(){return!1}};function Oo(t,e,i,n,r){let s=i>=n&&i+e.length<=r&&e.prop(t.stateAfter);if(s)return{state:t.streamParser.copyState(s),pos:i+e.length};for(let o=e.children.length-1;o>=0;o--){let l=e.children[o],a=i+e.positions[o],c=l instanceof le&&a<r&&Oo(t,l,a,n,r);if(c)return c}return null}function Nc(t,e,i,n,r){if(r&&i<=0&&n>=e.length)return e;!r&&i==0&&e.type==t.topNode&&(r=!0);for(let s=e.children.length-1;s>=0;s--){let o=e.positions[s],l=e.children[s],a;if(o<n&&l instanceof le){if(!(a=Nc(t,l,i-o,n-o,r)))break;return r?new le(e.type,e.children.slice(0,s).concat(a),e.positions.slice(0,s+1),o+a.length):a}}return null}function q0(t,e,i,n,r){for(let s of e){let o=s.from+(s.openStart?25:0),l=s.to-(s.openEnd?25:0),a=o<=i&&l>i&&Oo(t,s.tree,0-s.offset,i,l),c;if(a&&a.pos<=n&&(c=Nc(t,s.tree,i+s.offset,a.pos+s.offset,!1)))return{state:a.state,tree:c}}return{state:t.streamParser.startState(r?jt(r):4),tree:le.empty}}var K0=class{constructor(t,e,i,n){this.lang=t,this.input=e,this.fragments=i,this.ranges=n,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=n[n.length-1].to;let r=wo.get(),s=n[0].from,{state:o,tree:l}=q0(t,i,s,this.to,r==null?void 0:r.state);this.state=o,this.parsedPos=this.chunkStart=s+l.length;for(let a=0;a<l.children.length;a++)this.chunks.push(l.children[a]),this.chunkPos.push(l.positions[a]);r&&this.parsedPos<r.viewport.from-1e5&&n.some(a=>a.from<=r.viewport.from&&a.to>=r.viewport.from)&&(this.state=this.lang.streamParser.startState(jt(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let t=wo.get(),e=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(e,this.chunkStart+2048);for(t&&(i=Math.min(i,t.viewport.to));this.parsedPos<i;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)e==`
|
|
12
|
-
`&&(e="");else{let i=e.indexOf(`
|
|
13
|
-
`);i>-1&&(e=e.slice(0,i))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),i=t+e.length;for(let n=this.rangeIndex;;){let r=this.ranges[n].to;if(r>=i||(e=e.slice(0,r-(i-e.length)),n++,n==this.ranges.length))break;let s=this.ranges[n].from,o=this.lineAfter(s);e+=o,i=s+o.length}return{line:e,end:i}}skipGapsTo(t,e,i){for(;;){let n=this.ranges[this.rangeIndex].to,r=t+e;if(i>0?n>r:n>=r)break;let s=this.ranges[++this.rangeIndex].from;e+=s-n}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,i,n){let r=4;if(this.ranges.length>1){n=this.skipGapsTo(e,n,1),e+=n;let o=this.chunk.length;n=this.skipGapsTo(i,n,-1),i+=n,r+=this.chunk.length-o}let s=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&r==4&&s>=0&&this.chunk[s]==t&&this.chunk[s+2]==e?this.chunk[s+2]=i:this.chunk.push(t,e,i,r),n}parseLine(t){let{line:e,end:i}=this.nextLine(),n=0,{streamParser:r}=this.lang,s=new Pc(e,t?t.state.tabSize:4,t?jt(t.state):2);if(s.eol())r.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let o=Ic(r.token,s,this.state);if(o&&(n=this.emitToken(this.lang.tokenTable.resolve(o),this.parsedPos+s.start,this.parsedPos+s.pos,n)),s.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=le.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:U0,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new le(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new le(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Ic(t,e,i){e.start=e.pos;for(let n=0;n<10;n++){let r=t(e,i);if(e.pos>e.start)return r}throw new Error("Stream parser failed to advance stream.")}var Eo=Object.create(null),tn=[Pe.none],U0=new t0(tn),Fc=[],Hc=Object.create(null),Vc=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Vc[t]=$c(Eo,e);var Wc=class{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Vc)}resolve(t){return t?this.table[t]||(this.table[t]=$c(this.extra,t)):0}},G0=new Wc(Eo);function Lo(t,e){Fc.indexOf(t)>-1||(Fc.push(t),console.warn(e))}function $c(t,e){let i=[];for(let l of e.split(" ")){let a=[];for(let c of l.split(".")){let h=t[c]||x[c];h?typeof h=="function"?a.length?a=a.map(h):Lo(c,`Modifier ${c} used at start of tag`):a.length?Lo(c,`Tag ${c} used as modifier`):a=Array.isArray(h)?h:[h]:Lo(c,`Unknown highlighting tag ${c}`)}for(let c of a)i.push(c)}if(!i.length)return 0;let n=e.replace(/ /g,"_"),r=n+" "+i.map(l=>l.id),s=Hc[r];if(s)return s.id;let o=Hc[r]=Pe.define({id:tn.length,name:n,props:[u0({[n]:i})]});return tn.push(o),o.id}function J0(t,e){let i=Pe.define({id:tn.length,name:"Document",props:[mi.add(()=>t),Dc.add(()=>n=>e.getIndent(n))],top:!0});return tn.push(i),i}var Yb={rtl:U.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:oe.RTL}),ltr:U.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:oe.LTR}),auto:U.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})},Y0=ft.define();function X0(t,e,i,n){let{main:r}=t.selection,s=i-r.from,o=n-r.from;return Object.assign(Object.assign({},t.changeByRange(l=>{if(l!=r&&i!=n&&t.sliceDoc(l.from+s,l.from+o)!=t.sliceDoc(i,n))return{range:l};let a=t.toText(e);return{changes:{from:l.from+s,to:n==r.from?l.to:l.from+o,insert:a},range:w.cursor(l.from+s+a.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}var Xb=typeof navigator=="object"&&/Win/.test(navigator.platform),zc=new class extends Vt{};zc.startSide=1,zc.endSide=-1;var Qb=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Q0=["zh-hans","zh-hant"],Z0="https://testingcf.jsdelivr.net",_c=typeof document=="object"?document.createElement("textarea"):void 0,ev=t=>(_c.innerHTML=t,_c.value),Bo=new Map,Po=(t,e,i)=>{if(Bo.has(t))return Bo.get(t);const n=new Promise(r=>{const s=/^https?:\/\//iu.test(t)?t:`${Z0}/${t}`;let o=globalThis;for(const l of e.split("."))o=o==null?void 0:o[l];if(o)r();else if(i&&typeof define=="function"&&"amd"in define){const l=globalThis.require;l.config({paths:{[e]:s}}),l([e],a=>{Object.assign(globalThis,{[e]:a}),r()})}else{const l=document.createElement("script");l.src=s,l.onload=()=>{r()},document.head.append(l)}});return Bo.set(t,n),n},tv=t=>JSON.parse(String(localStorage.getItem(t))),jc=(t,e)=>{localStorage.setItem(t,JSON.stringify(e))},iv=async(t,e,i,n,r,s=(o=>(o=tv(r))!=null?o:{})())=>{const{version:l,lang:a}=s,c=Array.isArray(i)?i:[i];if(l===e&&c.includes(a))return s;for(const h of c){const f=h.toLowerCase();if(n.includes(f))try{const u=await fetch(`${t}/${f}.json`);return Object.assign(s,await u.json(),{version:e,lang:h}),jc(r,s),s}catch{}}throw new Error(`Failed to fetch the localization for ${c[0]}.`)},qc=!1,Kc=!1,Uc=async(t,e,i)=>{const n="extensions/dist";let r=i||`npm/wikiparser-node/${n}/base.min.js`;if(r.endsWith(".js")||(r=`${r}${r.endsWith("/")?"":"/"}${n}/base.js`),await Po(r,"wikiparse"),await Po(`${wikiparse.CDN}/${n}/lsp.js`,"wikiparse.LanguageService"),!qc&&typeof t=="function"){qc=!0;try{wikiparse.setConfig(await t())}catch{}}if(!Kc&&e){Kc=!0;const s="wikiparse-i18n",{version:o}=wikiparse;try{wikiparse.setI18N(await iv(`${wikiparse.CDN}/i18n`,o,e,Q0,s))}catch{jc(s,{version:o,lang:"en"})}}},Ro=new WeakMap,Gc=(t,e,i,n)=>{if(Uc(i,n),typeof wikiparse!="object"||!wikiparse.LanguageService||Ro.has(t))return Ro.get(t);const r=new wikiparse.LanguageService(e);return Ro.set(t,r),r},nv="wiktionary|wiki(?:pedia|books|news|quote|source|versity|voyage)",rv=t=>t.replace(/[{}]/gu,e=>e==="{"?"{":"}");function st(t){const e=new Map,i=new WeakMap;return n=>{const r=typeof n=="string"?e:i;if(r.has(n)){const o=r.get(n);return o.lastIndex=0,o}const s=t(n);return r.set(n,s),s}}var Ie=new Set(["align"]),Jc=new Set(["cite"]),Yc=new Set(["cite","datetime"]),Xc=new Set(["width"]),sv=new Set(["axis","align","bgcolor","height","width","valign"]),Qc=new Set([...sv,"abbr","headers","scope","rowspan","colspan"]),wr=new Set(["type"]),ov=new Set(["summary","align","bgcolor","cellpadding","cellspacing","frame","rules","width"]),lv=new Set(["clear"]),av=new Set(["bgcolor","align","valign"]),No=new Set(["qid","forcemathmode","type","display"]),Zc=new Set(["enclose","inline","lang","line","linelinks","style","class","id","dir","copy","highlight","start"]),ot=new Set,hv=new Set(["id","class","style","lang","dir","title","tabindex","aria-describedby","aria-flowto","aria-hidden","aria-label","aria-labelledby","aria-level","aria-owns","role","about","property","resource","datatype","typeof","itemid","itemprop","itemref","itemscope","itemtype"]),cv={div:Ie,h1:Ie,h2:Ie,h3:Ie,h4:Ie,h5:Ie,h6:Ie,blockquote:Jc,q:Jc,p:Ie,br:lv,pre:Xc,ins:Yc,del:Yc,ul:wr,ol:new Set(["type","start","reversed"]),li:new Set(["type","value"]),table:new Set([...ov,"border"]),caption:Ie,tr:av,td:Qc,th:Qc,font:new Set(["size","color","face"]),hr:Xc,data:new Set(["value"]),time:new Set(["datetime"]),meta:new Set(["itemprop","content"]),link:new Set(["itemprop","href","title"]),gallery:wr,poem:Ie,categorytree:Ie,combooption:Ie,math:ot,chem:ot,ce:ot,img:new Set(["alt","src","width","height","loading","srcset"])},fv={gallery:new Set(["mode","showfilename","caption","perrow","widths","heights","showthumbnails"]),poem:new Set(["compact"]),categorytree:new Set(["hideroot","onlyroot","depth","mode","hideprefix","namespaces","showcount","notranslations"]),combooption:new Set(["name","for","inline"]),nowiki:ot,indicator:new Set(["name"]),langconvert:new Set(["from","to"]),ref:new Set(["group","name","follow","dir","details"]),references:new Set(["group","responsive"]),charinsert:new Set(["label"]),choose:new Set(["uncached","before","after"]),option:new Set(["weight"]),imagemap:ot,inputbox:ot,templatestyles:new Set(["src","wrapper"]),dynamicpagelist:ot,poll:new Set(["id","show-results-before-voting"]),sm2:wr,flashmp3:wr,score:new Set(["line_width_inches","lang","override_midi","raw","note-language","override_audio","override_ogg","sound","vorbis"]),seo:new Set(["title","title_mode","title_separator","keywords","description","robots","google_bot","image","image_width","image_height","image_alt","type","site_name","locale","section","author","published_time","twitter_site"]),tab:new Set(["nested","name","index","class","block","inline","openname","closename","collapsed","dropdown","style","bgcolor","container","id","title"]),tabs:new Set(["plain","class","container","id","title","style"]),combobox:new Set(["placeholder","value","id","class","text","dropdown","style"]),math:new Set([...No,"chem"]),chem:No,ce:No,hiero:ot,phonos:new Set(["ipa","class","text","lang","wikibase","file"]),section:new Set(["begin","end"]),source:Zc,syntaxhighlight:Zc,templatedata:ot,timeline:new Set(["method","font"]),quiz:new Set(["display","shuffleanswers","points","shuffle","case"]),languages:ot},uv=new Set(["msg","raw","subst","safesubst"]),Io=[["b","bdi","del","i","ins","u","font","big","small","sub","sup","h1","h2","h3","h4","h5","h6","cite","code","em","s","strike","strong","tt","var","div","center","blockquote","ol","ul","dl","table","caption","pre","ruby","rb","rp","rt","rtc","p","span","abbr","dfn","kbd","samp","data","time","mark","tr","td","th","q","bdo"],["li","dt","dd"],["br","wbr","hr","meta","link"]],ef=Io.flat(),tf=Io[2],nf=Io[1],M={apostrophes:"mw-apostrophes",comment:"mw-comment",convertBracket:"mw-convert-bracket",convertDelimiter:"mw-convert-delimiter",convertFlag:"mw-convert-flag",convertLang:"mw-convert-lang",doubleUnderscore:"mw-double-underscore",em:"mw-em",error:"mw-error",extLink:"mw-extlink",extLinkBracket:"mw-extlink-bracket",extLinkProtocol:"mw-extlink-protocol",extLinkText:"mw-extlink-text",extTag:"mw-exttag",extTagAttribute:"mw-exttag-attribute",extTagAttributeValue:"mw-exttag-attribute-value",extTagBracket:"mw-exttag-bracket",extTagName:"mw-exttag-name",fileDelimiter:"mw-file-delimiter",fileText:"mw-file-text",freeExtLink:"mw-free-extlink",freeExtLinkProtocol:"mw-free-extlink-protocol",hr:"mw-hr",htmlEntity:"mw-entity",htmlTagAttribute:"mw-htmltag-attribute",htmlTagAttributeValue:"mw-htmltag-attribute-value",htmlTagBracket:"mw-htmltag-bracket",htmlTagName:"mw-htmltag-name",ignored:"mw-ignored",imageParameter:"mw-image-parameter",linkBracket:"mw-link-bracket",linkDelimiter:"mw-link-delimiter",linkPageName:"mw-link-pagename",linkText:"mw-link-text",linkToSection:"mw-link-tosection",list:"mw-list",magicLink:"mw-magic-link",pageName:"mw-pagename",parserFunction:"mw-parserfunction",parserFunctionBracket:"mw-parserfunction-bracket",parserFunctionDelimiter:"mw-parserfunction-delimiter",parserFunctionName:"mw-parserfunction-name",redirect:"mw-redirect",section:"mw-section",sectionHeader:"mw-section-header",signature:"mw-signature",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableBracket:"mw-table-bracket",tableCaption:"mw-table-caption",tableDefinition:"mw-table-definition",tableDefinitionValue:"mw-table-definition-value",tableDelimiter:"mw-table-delimiter",tableDelimiter2:"mw-table-delimiter2",tableTd:"mw-table-td",tableTh:"mw-table-th",template:"mw-template",templateArgumentName:"mw-template-argument-name",templateBracket:"mw-template-bracket",templateDelimiter:"mw-template-delimiter",templateName:"mw-template-name",templateVariable:"mw-templatevariable",templateVariableBracket:"mw-templatevariable-bracket",templateVariableDelimiter:"mw-templatevariable-delimiter",templateVariableName:"mw-templatevariable-name"},dv=(()=>{const t={variable:x.variableName,"variable-2":x.special(x.variableName),"string-2":x.special(x.string),def:x.definition(x.variableName),tag:x.tagName,attribute:x.attributeName,type:x.typeName,builtin:x.standard(x.variableName),qualifier:x.modifier,error:x.invalid,header:x.heading,property:x.propertyName};for(const e of Object.values(M))t[e]=Re.define();return t})(),pv=class{constructor(t){this.tags=t.includes("translate")?t.filter(e=>e!=="tvar"):t,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,this.readyTokens=[],this.oldToken=null,this.mark=null}},bi=(t,e,i)=>t.nTemplate===e.nTemplate&&t.nExt===e.nExt&&t.nVar===e.nVar&&t.nLink===e.nLink&&t.nExtLink===e.nExtLink&&t.extName===e.extName&&(i||t.extName!=="mediawiki"||bi(t.extState,e.extState)),gv=(t,e)=>{t.nTemplate=e.nTemplate,t.nExt=e.nExt,t.nVar=e.nVar,t.nLink=e.nLink,t.nExtLink=e.nExtLink,t.extName=e.extName},wi=(t,e)=>{const i=e.tokenize(t,e);return Array.isArray(i)?i[0]:i},Ot=(t,e,i=!1)=>({tokenize:t,stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nExt:0,nVar:0,nLink:0,nExtLink:0,lbrack:!1,bold:!1,italic:!1,dt:{n:0,html:0},sof:i,redirect:!1,imgLink:!1,data:new pv(e)}),xr=t=>{const e={...t};for(const[i,n]of Object.entries(t))Array.isArray(n)?e[i]=[...n]:i==="extState"?e[i]=(t.extName&&t.extMode&&t.extMode.copyState||xr)(n):i!=="data"&&n&&typeof n=="object"&&(e[i]={...n});return e},mv=t=>typeof document!="object"||t.startsWith("#")||[...ev(`&${t}`)].length===1,J=(t,...e)=>{t.stack.unshift(...e.slice(1),t.tokenize),t.tokenize=e[0]},Y=t=>{t.tokenize=t.stack.shift()},qt=(t,e,i)=>t.sol()&&(e&&t.match(/^\s*(?::+\s*)?\{\|/u,!1)||t.match(/^(?:-{4}|=)/u,!1)||!i&&/[*#;:]/u.test(t.peek()||"")),ee=(t,e)=>{const i={"'":"'(?!')","{":String.raw`\{(?!\{)`,"}":String.raw`\}(?!\})`,"<":e?"<(?!!--)":"<(?!!--|/?[a-z])","~":"~~?(?!~)",_:"_(?!_)","[":String.raw`\[(?!\[)`,"]":String.raw`\](?!\])`,"/":"/(?!>)","-":String.raw`-(?!\{(?!\{))`};if(typeof e=="object"){const{data:{tags:n}}=e;i["<"]=String.raw`<(?!!--${n.includes("onlyinclude")?"|onlyinclude>":""}|(?:${n.filter(r=>r!=="onlyinclude").join("|")})(?:[\s/>]|$))`}return[...t].map(n=>i[n]).join("|")},Fo=t=>{const{dt:e}=t;return!!e.n&&e.html===0&&!t.bold&&!t.italic&&bi(e,t,!0)},rf=(t="")=>{const e="~{'";return String.raw`[^&${e}\p{Zs}[\]<>"${t}]|&(?![lg]t;)|${ee(e)}`},sf=t=>String.raw`.,;:!?\\${t?"":")"}`,G=(t,e)=>function(...i){const n=t.apply(this,i);return Object.defineProperty(n,"name",{value:e.name}),n.args=i,n},of=(t,e)=>{var i;return(typeof t=="string"?t:`${t[0]} ${e.bold||(i=e.dt)!=null&&i.n?M.strong:""} ${e.italic?M.em:""}`).trim().replace(/\s{2,}/gu," ")||" "},se=(t,e,i)=>{let n="";switch(e.nTemplate){case 0:break;case 1:n+="-template";break;case 2:n+="-template2";break;default:n+="-template3";break}switch(e.nExt){case 0:break;case 1:n+="-ext";break;case 2:n+="-ext2";break;default:n+="-ext3";break}if((e.nLink||e.nExtLink)&&(n+="-link"),i){e[i]--;const{dt:r}=e;r!=null&&r.n&&e[i]<r[i]&&(r.n=0)}return(n&&`mw${n}-ground `)+t},T=(t,e,i)=>se(M[t],e,i),fe=(t,e,i)=>[se(t,e,i)],Et=(t,e,i)=>fe(M[t],e,i),vv=(t,e)=>{const i=t.pos,n=t.string.slice(0,i-3),r=n.slice(-1),s=n.slice(-2,-1),{data:o}=e;if(r===" "){if(o.firstMultiLetterWord||o.firstSpace)return;o.firstSpace=i}else if(s===" ")o.firstSingleLetterWord=i;else{if(o.firstMultiLetterWord)return;o.firstMultiLetterWord=i}o.mark=i},Ho=t=>String.raw`(?:${t?"":String.raw`\||`}\{(?:\{\s*|\s*\()!\s*\}\})`,Vo=t=>{const e=t.peek();return e==="'"||e==='"'?e.repeat(2):""},kr=t=>t.name==="inTemplateArgument"&&t.args[0]?"=":"",Wo=(t,e)=>{if(e&&t.sol())return!0;const i=t.peek();return!!(i&&!i.trim())},yv=new Set(["syntaxhighlight","source","pre"]),bv=new Set(["raw","msg","filepath","localurl","localurle","fullurl","fullurle","canonicalurl","canonicalurle","int","msgnw"]),lf=new Set(["subst","safesubst"]),wv=new RegExp(`^(?:[^&[<{~'-]|${ee("<{~'-")})+`,"iu"),xv=new RegExp(`^(?:[^|{}<]|${ee("{}<",!0)})+`,"u"),kv=new RegExp(`^(?:[^|[&:}{<~'_-]|${ee("}{<~'_-")})+`,"iu"),Sv=new RegExp(`^(?:[^|[&}{<~'_-]|${ee("}{<~'_-")})+`,"iu"),Cv=new RegExp(`^(?:[^&'{[<~_:-]|${ee("'{[<~_-")})+`,"iu"),Av=new RegExp(`^(?:[^&={<]|${ee("{<")})+`,"iu"),af=/^\s*(?:[|!]|\{\{\s*![!)+-]?\s*\}\})/u,hf="[{'<-",Sr="{<",cf="'<~_{-",ff="{/",uf=[!1,!0].map(t=>{const e=sf(t),i=rf(e);return new RegExp(`^(?:${i}|[${e}]+(?=${i}))*`,"u")}),Tv=[!1,!0].map(t=>new RegExp(String.raw`^:*\s*(?=\{${Ho(t)})`,"u")),Mv=[!1,!0].map(t=>new RegExp(String.raw`^${Ho(t)}\s*`,"u")),Dv=[!1,!0].map(t=>new RegExp(String.raw`^\s*(:+\s*)?(?=\{${Ho(t)})`,"u")),Ov=[!1,!0].map(t=>{const e=`]'{<${t?"~":"["}-`;return new RegExp(`^(?:[^&${t?"[|":""}\\${e}]|${ee(e)})+`,"iu")}),$o=[new RegExp(String.raw`^(?:[<>{}]|%(?:3[ce]|[57][bd])|${ee("[]")})+`,"iu"),new RegExp(String.raw`^(?:\}|${ee("[]{")})+`,"u"),new RegExp(String.raw`^(?:[>}]|%(?:3[ce]|[57][bd])|${ee("[]{<")})+`,"iu")],Ev=["","="].map(t=>new RegExp(String.raw`^(?:[^\s&${Sr}${t}]|${ee(Sr)})+`,"iu")),Lv=[!1,!0].map(t=>new RegExp(String.raw`^(?:[^|{}<${t?"[&~'_:-":""}]|\}(?!\}\})|${t?ee("{<~'_-"):ee("{<",!0)})+`,"iu")),Bv=["","[&","[&:"].map(t=>st(e=>new RegExp(`^(?:[^|${t}${e}]|${ee(e)})+`,"iu"))),Pv=st(t=>new RegExp(String.raw`^(?:[^\]&${t}${hf}]|${ee(hf)})+`,"iu")),Rv=st(t=>new RegExp(`^(?:${rf(t)})+`,"u")),Nv=st(t=>new RegExp(`^(?:[^&${Sr}${t}]|${ee(Sr)})+`,"iu")),Iv=st(t=>new RegExp(`^(?:[^[&${t}${cf}]|${ee(cf)})+`,"iu")),df=st(t=>new RegExp(`^(?:[^<>&${ff}${t}]|${ee(ff)})+`,"u")),Fv=st(t=>new RegExp(`^(?:[^<>&={/${t}]|${ee("{/")})+`,"u")),Hv=st(t=>new RegExp(`^(?:[^>/${t}]|${ee("/")})+`,"u")),Vv=st(t=>t==="onlyinclude"?/<\/onlyinclude(?:>|$)/u:new RegExp(String.raw`</${t}\s*(?:>|$)`,"iu")),Wv=st(t=>new RegExp(String.raw`^(?:[^<]|<(?!${t}(?:[\s/>]|$)))+`,"iu")),$v=(hd=[G],ad=[G],ld=[G],od=[G],sd=[G],rd=[G],nd=[G],id=[G],td=[G],ed=[G],Zu=[G],Qu=[G],Xu=[G],Yu=[G],Ju=[G],Gu=[G],Uu=[G],Ku=[G],qu=[G],ju=[G],_u=[G],zu=[G],$u=[G],Wu=[G],Vu=[G],Hu=[G],Fu=[G],Iu=[G],Nu=[G],Ru=[G],z=class{constructor(t){Ml(_,5,this);const{urlProtocols:e,permittedHtmlTags:i,implicitlyClosedHtmlTags:n,tags:r,nsid:s,variants:o,functionSynonyms:[l],redirection:a=["#REDIRECT"],img:c={}}=t;this.config=t,this.tokenTable={...dv},this.hiddenTable={},this.permittedHtmlTags=new Set([...ef,...i!=null?i:[]]),this.voidHtmlTags=new Set([...tf,...n!=null?n:[]]),this.urlProtocols=new RegExp(String.raw`^(?:${e})(?=[^\p{Zs}[\]<>"])`,"iu"),this.linkRegex=new RegExp(String.raw`^\[(?!${e})\s*`,"iu"),this.fileRegex=new RegExp(String.raw`^(?:${Object.entries(s).filter(([,h])=>h===6).map(([h])=>h).join("|")})\s*:`,"iu"),this.redirectRegex=new RegExp(String.raw`^\s*(?:${a.join("|")})(\s*:)?\s*(?=\[\[|$)`,"iu"),this.img=Object.keys(c).filter(h=>!/\$1./u.test(h)),this.imgRegex=new RegExp(String.raw`^(?:${this.img.filter(h=>h.endsWith("$1")).map(h=>h.slice(0,-2)).join("|")}|(?:${this.img.filter(h=>!h.endsWith("$1")).join("|")}|(?:\d+x?|\d*x\d+)\s*(?:px)?px)\s*(?=\||\]\]|$))`,"u"),this.tags=[...Object.keys(r),"includeonly","noinclude","onlyinclude"],this.convertRegex=new RegExp(String.raw`^(?:[^}|;&='{[<~_-]|\}(?!-)|=(?!>)|\[(?!\[|${e})|${ee("'{<~_-")})+`,"iu"),this.convertSemicolon=o&&new RegExp(String.raw`^;\s*(?=(?:[^;]*?=>\s*)?(?:${o.join("|")})\s*:|(?:$|\}-))`,"iu"),this.convertLang=o&&new RegExp(String.raw`^(?:=>\s*)?(?:${o.join("|")})\s*:`,"iu"),this.hasVariants=!!(o!=null&&o.length),this.preRegex=[!1,!0].map(h=>new RegExp(String.raw`^(?:[^<&-]|-${this.hasVariants?String.raw`(?!\{)`:""}|<(?!${h?"/":""}nowiki>))+`,"iu")),this.substRegex=new RegExp(String.raw`^\s*(?:(${Object.entries(l).filter(([,h])=>lf.has(h)).map(([h])=>h+(h.endsWith(":")?"":":")).join("|")})\s*)?`,"iu"),this.autocompleteNamespaces={0:"",6:"File:",8:"MediaWiki:",10:"Template:",274:"Widget:",828:"Module:"},this.registerGroundTokens()}addToken(t,e=!1,i){var n,r,s;(s=(n=this[e?"hiddenTable":"tokenTable"])[r=`mw-${t}`])!=null||(n[r]=Re.define(i))}registerGroundTokens(){const t=["ext","ext-link","ext2","ext2-link","ext3","ext3-link","link","template-ext","template-ext-link","template-ext2","template-ext2-link","template-ext3","template-ext3-link","template","template-link","template2-ext","template2-ext-link","template2-ext2","template2-ext2-link","template2-ext3","template2-ext3-link","template2","template2-link","template3-ext","template3-ext-link","template3-ext2","template3-ext2-link","template3-ext3","template3-ext3-link","template3","template3-link"];for(const e of t)this.addToken(`${e}-ground`);for(let e=1;e<7;e++)this.addToken(`section--${e}`);for(const e of this.tags)this.addToken(`tag-${e}`,e!=="nowiki"&&e!=="pre"),this.addToken(`ext-${e}`,!0);for(const e of this.permittedHtmlTags)this.addToken(`html-${e}`,!0);for(const e in this.autocompleteNamespaces)Number.isInteger(Number(e))&&this.addToken(`function-${e}`,!0)}inChars({length:t},e){return(i,n)=>(i.pos+=t,Y(n),T(e,n))}inStr(t,e,i="error"){return(n,r)=>n.match(t,!!e)?(Y(r),e?T(e,r):""):(n.skipTo(t)||n.skipToEnd(),T(i,r))}eatWikiText(t){t in M&&(t=M[t]);const e=/^(?:(?:RFC|PMID)[\p{Zs}\t]+\d+|ISBN[\p{Zs}\t]+(?:97[89][\p{Zs}\t-]?)?(?:\d[\p{Zs}\t-]?){9}[\dxX])\b/u;return(i,n)=>{var s,o;let r;if(i.eol())return"";if(i.sol()){if(n.sof){if(i.match(/^\s+$/u))return"";n.sof=!1;const a=i.match(this.redirectRegex);if(a)return n.redirect={colon:!a[1]},M.redirect}else if(n.redirect){if(i.match(/^\s+(?=$|\[\[)/u))return"";if(n.redirect.colon&&i.match(/^\s*:\s*(?=$|\[\[)/u))return n.redirect.colon=!1,M.redirect;n.redirect=!1}r=i.next();const l=["inTemplateArgument","inParserFunctionArgument","inVariable"].includes(n.tokenize.name);switch(r){case"#":case";":case"*":return i.backUp(1),this.eatList(i,n);case":":return i.match(Tv[l?1:0])?(J(n,this.eatStartTable),T("list",n)):this.eatList(i,n);case"=":{const a=i.match(/^(={0,5})(.+?(=\1\s*)(?:<!--(?!.*-->\s*\S).*)?)$/u);if(a)return i.backUp(a[2].length),J(n,this.inSectionHeader(a[3])),se(`${M.sectionHeader} mw-section--${a[1].length+1}`,n);break}case"{":if(i.match(Mv[l?1:0]))return J(n,this.inTableDefinition()),T("tableBracket",n);break;case"-":if(i.match(/^-{3,}/u))return M.hr;break;default:if(!r.trim()){const a=i.match(Dv[l?1:0]);if(a)return J(n,this.eatStartTable),se(a[1]?M.list:"",n);if(r===" "&&!/^ \s*(?=<!--)(?:\s|<!--(?:(?!-->).)*-->)+$/u.test(i.string))return M.skipFormatting}}}else r=i.next();switch(r){case"~":if(i.match(/^~{2,4}/u))return M.signature;break;case"<":{if(i.match("!--"))return J(n,this.inComment),T("comment",n);const l=!!i.eat("/"),a=i.match(/^([a-z][^\s/>]*)>?/iu,!1);if(a){const c=a[1].toLowerCase();if((a[0]==="onlyinclude>"||c!=="onlyinclude")&&n.data.tags.includes(c))return this.eatExtTag(c,l,n);if(this.permittedHtmlTags.has(c))return this.eatHtmlTag(c,l,n)}break}case"{":{if(i.match(/^\{\{(?!\{|[^{}]*\}\}(?!\}))\s*/u))return n.nVar++,J(n,this.inVariable()),T("templateVariableBracket",n);if(i.match(/^\{(?!\{(?!\{))/u))return(s=this.eatTransclusion(i,n))!=null?s:fe(t,n);break}case"_":{const{pos:l}=i;switch(i.eatWhile("_"),i.pos-l){case 0:break;case 1:return this.eatDoubleUnderscore(t,i,n);default:return i.eol()||i.backUp(2),fe(t,n)}break}case"[":if(i.match(this.linkRegex)){const{redirect:l}=n;if(l||/[^[\]|]/u.test(i.peek()||""))return n.nLink++,n.lbrack=void 0,J(n,this.inLink(!l&&!!i.match(this.fileRegex,!1))),T("linkBracket",n);if(i.match("]]"))return fe(t,n)}else{const l=i.match(this.urlProtocols,!1);if(l)return n.nExtLink++,J(n,this.eatExternalLinkProtocol(l[0],!1)),T("extLinkBracket",n)}break;case"'":{const l=this.eatApostrophes(n)(i,n);if(l)return l;break}case":":if(Fo(n))return n.dt.n--,T("list",n);break;case"&":return fe(this.eatEntity(i,t),n);case"-":if((o=this.config.variants)!=null&&o.length&&i.match(/^\{(?!\{)\s*/u))return J(n,this.inConvert(t,!0)),T("convertBracket",n)}if(n.stack.length===0){if(r!=="_"){/[\p{L}\p{N}]/u.test(r)?i.backUp(1):i.eatWhile(/[^\p{L}\p{N}_&'{[<~:-]/u);const l=i.match(this.urlProtocols,!1);if(l)return J(n,this.eatExternalLinkProtocol(l[0])),fe(t,n);const a=i.match(e,!1);if(a)return J(n,this.inChars(a[0],"magicLink")),fe(t,n)}i.eatWhile(/[\p{L}\p{N}]/u)}return fe(t,n)}}eatApostrophes(t){return(e,i)=>e.match(/^'*(?='{5})/u)||e.match(/^'''(?!')/u,!1)?!1:e.match("''''")?(t.bold=!t.bold,t.italic=!t.italic,T("apostrophes",i)):e.match("''")?(t===i&&i.data.firstSingleLetterWord===null&&vv(e,i),t.bold=!t.bold,T("apostrophes",i)):e.eat("'")?(t.italic=!t.italic,T("apostrophes",i)):!1}eatExternalLinkProtocol({length:t},e=!0){return(i,n)=>(i.pos+=t,n.tokenize=e?this.eatFreeExternalLink:this.inExternalLink(),T(e?"freeExtLinkProtocol":"extLinkProtocol",n))}inExternalLink(t){return(e,i)=>{const n=i.stack[0],r=kr(n),s=["inTemplateArgument","inParserFunctionArgument","inVariable","inTableCell"].includes(n.name),o=(s?"|":"")+r,l=e.peek();return e.sol()||e.match(/^\p{Zs}*\]/u)||s&&l==="|"||r&&l==="="?(Y(i),T("extLinkBracket",i,"nExtLink")):t?e.match(Pv(o))?Et("extLinkText",i):this.eatWikiText("extLinkText")(e,i):e.match(Rv(o))?T("extLink",i):(i.tokenize=this.inExternalLink(!0),"")}}eatFreeExternalLink(t,e){const i=t.match(uf[0]);return!t.eol()&&i[0].includes("(")&&sf().includes(t.peek())&&t.match(uf[1]),Y(e),Et("freeExtLink",e)}inLink(t,e){const i=e?M[t?"error":"linkToSection"]:`${M.linkPageName} ${M.pageName}`,n=e?/^(?:[^|<[\]{}]|<(?!!--|\/?[a-z]))+/iu:/^(?:&#(?:\d+|x[a-f\d]+);|[^#|<>[\]{}%]|%(?!3[ce]|[57][bd]))+/iu;let r;return(s,o)=>{if(s.sol()||r&&s.pos>r||s.match(/^\s*\]\]/u)||s.match(/^\[\[/u,!1))return o.redirect=!1,o.lbrack=!1,Y(o),T("linkBracket",o,"nLink");r=void 0;const l=s.eatSpace(),{redirect:a}=o;if(!e&&s.match(/^#\s*/u))return o.tokenize=this.inLink(t,!0),Et(t?"error":"linkToSection",o);if(s.match(/^\|\s*/u)){o.tokenize=this.inLinkText(t);let h=a?"error":"linkDelimiter";return t&&(h="fileDelimiter",this.toEatImageParameter(s,o)),T(h,o)}let c;return a?[c]=$o:e?[,c]=$o:[,,c]=$o,s.match(c)?Et("error",o):a?(s.match(/^(?:[^|<>[\]{}%]|%(?!3[ce]|[57][bd]))+/iu),fe(i,o)):s.match(n)||l?fe(i,o):(s.match(/^<(?!(?:includeonly|noinclude)(?:\/?>|\s|$))[/a-z]/iu,!1)&&!s.match(/^<onlyinclude>/u,!1)&&(r=s.pos+1),this.eatWikiText(e?i:"error")(s,o))}}inLinkText(t,e){const i={bold:!1,italic:!1},n=Ov[t?1:0];return(r,s)=>{var f;const o=`${M[t?"fileText":"linkText"]} ${i.bold?M.strong:""} ${i.italic?M.em:""} ${t&&s.imgLink?M.pageName:""}`,{redirect:l,lbrack:a}=s,c=r.match("]]");if(c||!t&&r.match("[[",!1)||!e&&((f=s.stack[0])==null?void 0:f.name)==="inTableCell"&&r.sol()&&r.match(af,!1))return e?fe(o,s):c&&!l&&a&&r.peek()==="]"?(r.backUp(1),s.lbrack=!1,fe(o,s)):(s.redirect=!1,s.lbrack=!1,Y(s),T("linkBracket",s,"nLink"));if(l)return r.skipTo("]]")||r.skipToEnd(),T("error",s);if(t&&r.match(/^\|\s*/u))return this.toEatImageParameter(r,s),T("fileDelimiter",s);if(r.match(/^'(?=')/u))return this.eatApostrophes(i)(r,s)||fe(o,s);if(t&&qt(r,!0,!0)||r.sol()&&r.match("{|",!1))return this.eatWikiText(o)(r,s);const h=r.match(n);return a===void 0&&(h!=null&&h[0].includes("["))&&(s.lbrack=!0),h?fe(o,s):this.eatWikiText(o)(r,s)}}toEatImageParameter(t,e){var n;e.imgLink=!1;const i=t.match(this.imgRegex,!1);i&&(((n=this.config.img)==null?void 0:n[`${i[0]}$1`])==="img_link"&&(e.imgLink=!0),J(e,this.inChars(i[0],"imageParameter")))}eatList(t,e){const i=t.match(/^[*#;:]*/u),{dt:n}=e;return i[0].includes(";")&&(n.n=i[0].split(";").length-1,gv(n,e)),T("list",e)}eatDoubleUnderscore(t,e,i){const{config:{doubleUnderscore:n}}=this,r=e.match(/^[\p{L}\p{N}_]+?__/u);if(r){if(Object.prototype.hasOwnProperty.call(n[0],`__${r[0].toLowerCase()}`)||Object.prototype.hasOwnProperty.call(n[1],`__${r[0]}`))return M.doubleUnderscore;e.eol()||e.backUp(2)}return fe(t,i)}get eatStartTable(){return(t,e)=>(t.match(/^(?:\{\||\{\{(?:\{\s*|\s*\()!\s*\}\})\s*/u),e.tokenize=this.inTableDefinition(),T("tableBracket",e))}inTableDefinition(t,e){const i=e===void 0?`${M.tableDefinition} mw-html-${t?"tr":"table"}`:M.tableDefinitionValue;return(n,r)=>{if(n.sol())return r.tokenize=this.inTable,"";const s=r.stack[0],o=kr(s);return o&&n.peek()==="="?(Y(r),""):n.match(/^(?:&|\{\{|<(?:!--|\/?[a-z]))/iu,!1)?this.eatWikiText(i)(n,r):e?(n.eat(e[0])?r.tokenize=this.inTableDefinition(t,e[1]):n.match(Nv(o+e[0])),se(i,r)):e===""?Wo(n)?(r.tokenize=this.inTableDefinition(t),""):(n.match(Ev[o?1:0]),se(i,r)):n.match(/^=\s*/u)?(r.tokenize=this.inTableDefinition(t,Vo(n)),se(i,r)):(n.match(Av),se(i,r))}}get inTable(){return(t,e)=>{if(t.sol()){t.eatSpace();const i=t.match(/^(?:\||\{\{\s*!([!)+-])?\s*\}\})/u);if(i)return i[1]==="-"||!i[1]&&t.eat("-")?(t.match(/^-*\s*/u),e.tokenize=this.inTableDefinition(!0),T("tableDelimiter",e)):i[1]==="+"||!i[1]&&t.match(/^\+\s*/u)?(e.tokenize=this.inTableCell(M.tableCaption),T("tableDelimiter",e)):i[1]===")"||!i[1]&&t.eat("}")?(Y(e),T("tableBracket",e)):(t.eatSpace(),e.tokenize=this.inTableCell(M.tableTd,i[1]!=="!"),T("tableDelimiter",e));if(t.match(/^!\s*/u))return e.tokenize=this.inTableCell(M.tableTh),T("tableDelimiter",e);if(qt(t,!0))return this.eatWikiText("error")(t,e)}return t.match(Cv)?Et("error",e):this.eatWikiText("error")(t,e)}}inTableCell(t,e=!0,i=!0){return(n,r)=>{if(n.sol()){if(n.match(af,!1))return r.tokenize=this.inTable,"";if(i)return r.tokenize=this.inTableCell(t,!1,!1),"";if(qt(n,!0))return this.eatWikiText(t)(n,r)}if(i){if(n.match(/^(?:(?:\||\{\{\s*!\s*\}\}){2}|\{\{\s*!!\s*\}\})\s*/u)||t===M.tableTh&&n.match(/^!!\s*/u))return r.bold=!1,r.italic=!1,e||(r.tokenize=this.inTableCell(t)),T("tableDelimiter",r);if(e&&n.match(/^(?:\||\{\{\s*!\s*\}\})\s*/u))return r.bold=!1,r.italic=!1,r.tokenize=this.inTableCell(t,!1),T("tableDelimiter2",r);e&&n.match("[[",!1)&&(r.tokenize=this.inTableCell(t,!1))}const s=r.stack[0],o=kr(s);return o&&n.peek()==="="?(Y(r),""):n.match(Iv((i?"|!":":")+o))?fe(t,r):this.eatWikiText(t)(n,r)}}inSectionHeader(t){return(e,i)=>e.sol()?(Y(i),""):e.match(wv)?(e.eol()?(e.backUp(t.length),i.tokenize=this.inStr(t,"sectionHeader")):e.match(/^<!--(?!.*?-->.*?=)/u,!1)&&(e.backUp(t.length),i.tokenize=this.inStr("<!--",!1,"sectionHeader")),T("section",i)):this.eatWikiText("section")(e,i)}get inComment(){return this.inStr("-->","comment","comment")}eatExtTag(t,e,i){return e?(J(i,this.inStr(">","error")),T("error",i)):(J(i,this.eatTagName(t)),T("extTagBracket",i))}eatHtmlTag(t,e,i){if(e){const{dt:n,inHtmlTag:r}=i;if(n.n&&n.html&&n.html--,t===r[0])r.shift();else{J(i,this.inStr(">","error"));const s=r.lastIndexOf(t);return s!==-1&&r.splice(s,1),T("error",i)}}return J(i,this.eatTagName(t,e,!0)),T("htmlTagBracket",i)}eatTagName(t,e,i){return(n,r)=>(n.match(t,!0,!0),n.eatSpace(),i?(r.tokenize=e?this.inStr(">","htmlTagBracket"):this.inHtmlTagAttribute(t),T("htmlTagName",r)):(r.tokenize=e?this.inStr(">","extTagBracket"):this.inExtTagAttribute(t),T("extTagName",r)))}inHtmlTagAttribute(t,e){const i=e===void 0?`${M.htmlTagAttribute} mw-html-${t}`:M.htmlTagAttributeValue;return(n,r)=>{var a;if(n.match(new RegExp(`^${ee("<",r)}`,"iu"),!1))return Y(r),"";const s=n.match(/^\/?>/u);if(s)return!this.voidHtmlTags.has(t)&&(s[0]===">"||!nf.includes(t))&&(r.inHtmlTag.unshift(t),r.dt.html++),Y(r),T("htmlTagBracket",r);const o=r.stack[0],l=(["inTemplateArgument","inParserFunctionArgument","inVariable"].includes(o.name)?"|":"")+kr(o);return l.includes((a=n.peek())!=null?a:"")?(Y(r),""):n.match(/^(?:[&<]|\{\{)/u,!1)?this.eatWikiText(i)(n,r):e?(n.eat(e[0])?r.tokenize=this.inHtmlTagAttribute(t,e[1]):n.match(df(l+e[0])),se(i,r)):e===""?Wo(n,!0)?(r.tokenize=this.inHtmlTagAttribute(t),""):(n.match(df(String.raw`\s${l}`)),se(i,r)):n.match(/^=\s*/u)?(r.tokenize=this.inHtmlTagAttribute(t,Vo(n)),se(i,r)):(n.match(Fv(l)),se(i,r))}}inExtTagAttribute(t,e,i,n){const r=`${M.extTagAttribute} mw-ext-${t}`,s=(o,l,a)=>{const c=o.match(a);if(i){let h=c[0].trim().toLowerCase();h==="js"&&(h="javascript"),h in this&&(l.extMode=this[h]())}return se(M.extTagAttributeValue+(n?` ${M.pageName}`:""),l)};return(o,l)=>{if(o.match("/>"))return l.extMode=!1,Y(l),T("extTagBracket",l);if(o.eat(">")){const{config:{tagModes:c}}=this;return l.extName=t,l.extMode||(l.extMode=t in c&&c[t]in this&&this[c[t]](l.data.tags.filter(h=>h!==t))),l.extMode&&(l.extState=l.extMode.startState(0)),l.tokenize=this.eatExtTagArea(t),T("extTagBracket",l)}else if(e){if(o.eat(e[0])){const[,c]=e;return l.tokenize=this.inExtTagAttribute(t,c,i&&!!c,n&&!!c),T("extTagAttributeValue",l)}return s(o,l,Hv(e[0]))}else{if(e==="")return Wo(o,!0)?(l.tokenize=this.inExtTagAttribute(t),""):s(o,l,/^(?:[^>/\s]|\/(?!>))+/u);if(o.match(/^=\s*/u))return l.tokenize=this.inExtTagAttribute(t,Vo(o),i,n),se(r,l)}const a=o.match(/^(?:[^>/=]|\/(?!>))+/u);return o.peek()==="="&&(l.tokenize=this.inExtTagAttribute(t,void 0,yv.has(t)&&/(?:^|\s)lang\s*$/iu.test(a[0]),t==="templatestyles"&&/(?:^|\s)src\s*$/iu.test(a[0]))),se(r,l)}}eatExtTagArea(t){return(e,i)=>{const{pos:n}=e,r=e.string.slice(n).search(Vv(t));if(r===0)return e.match("</"),i.tokenize=this.eatTagName(t,!0),i.extName=!1,i.extMode=!1,i.extState=!1,T("extTagBracket",i);let s="";return r!==-1&&(s=e.string,e.string=s.slice(0,n+r)),J(i,this.inExtTokens(s)),""}}inExtTokens(t){return(e,i)=>{var r;let n;return i.extMode===!1?(n=`mw-tag-${i.extName} ${M.extTag}`,e.skipToEnd()):n=`mw-tag-${i.extName} ${(r=i.extMode.token(e,i.extState))!=null?r:""}`,e.eol()&&(t&&(e.string=t),Y(i)),n}}inVariable(t=0){let e="comment";t===0?e="templateVariableName":t===1&&(e="templateVariable");const i=Lv[t===1?1:0];return(n,r)=>{const s=n.sol();return n.eatSpace(),n.eol()?se("",r):n.eat("|")?(t<2&&(r.tokenize=this.inVariable(t+1)),T("templateVariableDelimiter",r)):n.match(/^\}{2,3}/u)?(Y(r),T("templateVariableBracket",r,"nVar")):n.match("<!--")?(J(r,this.inComment),T("comment",r)):t===0&&s?(r.nVar--,Y(r),n.pos=0,""):t===1&&qt(n)||!n.match(i)?this.eatWikiText(e)(n,r):(t===1?Et:T)(e,r)}}eatTransclusion(t,e){const[{length:i},n]=t.match(this.substRegex),r=n?[this.inSubst(n)]:[];if(t.peek()==="#")return t.backUp(i),e.nExt++,J(e,...r,this.inParserFunctionName()),T("parserFunctionBracket",e);const s=t.match(/^([^}<{|::]+)(.?)/u,!1);if(s){const[,o,l]=s,a=l===":";let c=o;a?c+=":":l!==":"&&(c=o.trim());const h=c.toLowerCase(),{config:{functionSynonyms:f,variableIDs:u,functionHooks:d}}=this,p=Object.prototype.hasOwnProperty.call(f[1],c)&&f[1][c]||Object.prototype.hasOwnProperty.call(f[0],h)&&f[0][h];if((!l||a||l===":"||l==="}")&&p&&!lf.has(p)&&(a||l===":"||!u||u.includes(p))&&(!a&&l!==":"||!d||d.includes(p)||uv.has(p)))return t.backUp(i),e.nExt++,J(e,...r,this.inParserFunctionName()),T("parserFunctionBracket",e)}if(!t.match("}}"))return t.backUp(i),e.nTemplate++,J(e,...r,this.inTemplatePageName()),T("templateBracket",e)}inSubst(t){return(e,i)=>t?(e.eatSpace(),e.match(t),e.backUp(1),i.tokenize=this.inSubst(),T("parserFunctionName",i)):(e.next(),Y(i),T("parserFunctionDelimiter",i))}inParserFunctionName(t,e,i){return(n,r)=>{var c;const s=n.sol(),o=n.eatSpace();if(n.eol())return se("",r);if(n.eat("}"))return Y(r),T(n.eat("}")?"parserFunctionBracket":"error",r,"nExt");if(n.match("<!--"))return J(r,this.inComment),T("comment",r);if(s)return r.nExt--,Y(r),n.pos=0,"";const l=n.eat(/[::|]/u);if(l)return r.tokenize=this.inParserFunctionArgument(t,e,i),T(o||l==="|"?"error":"parserFunctionDelimiter",r);const a=n.match(/^(?:[^::}{|<>[\]\s]|\s(?![::]))+/u);if(a){const h=a[0].trim().toLowerCase()+(n.peek()===":"?":":""),{config:{functionSynonyms:[f]}}=this;if(h.startsWith("#"))switch((c=f[h])!=null?c:f[h.slice(1)]){case"invoke":r.tokenize=this.inParserFunctionName(2);break;case"widget":r.tokenize=this.inParserFunctionName(1);break;case"switch":r.tokenize=this.inParserFunctionName(void 0,1);break;case"tag":r.tokenize=this.inParserFunctionName(void 0,2);break;case"ifexist":case"lst":case"lstx":case"lsth":r.tokenize=this.inParserFunctionName(1/0)}else{const u=f[h];if(bv.has(u)){let d=0;switch(u){case"filepath":d=6;break;case"int":d=8;break;case"raw":case"msg":case"msgnw":d=10}r.tokenize=this.inParserFunctionName(1/0,1/0,d)}}return T("parserFunctionName",r)}return Y(r),se("",r,"nExt")}}inTemplatePageName(t,e){const i=e?M.error:`${M.templateName} ${M.pageName}`,n="{}<",r=e?xv:/^(?:&#(?:\d+|x[a-f\d]+);|[^|{}<>[\]#%]|%(?![\da-f]{2}))+/iu;return(s,o)=>{const l=s.sol(),a=s.eatSpace();return s.eol()?se("",o):s.match("}}")?(Y(o),T("templateBracket",o,"nTemplate")):s.match("<!--")?(J(o,this.inComment),T("comment",o)):s.match(/^<\/?onlyinclude>/u)||s.match(/^<(?:(?:includeonly|noinclude)(?:\s[^>]*)?\/?>|\/(?:includeonly|noinclude)\s*>)/iu)?T("comment",o):s.eat("|")?(o.tokenize=this.inTemplateArgument(!0),T("templateDelimiter",o)):t&&l?(o.nTemplate--,Y(o),s.pos=0,""):!e&&s.eat("#")?(o.tokenize=this.inTemplatePageName(!0,!0),T("error",o)):!e&&s.match(new RegExp(String.raw`^(?:[>[\]]|%[\da-f]{2}|${ee(n,o)})+`,"iu"))?T("error",o):!e&&s.peek()==="<"?(Y(o),se("",o,"nTemplate")):a&&!t?se("",o):s.match(r)?(t||(o.tokenize=this.inTemplatePageName(!0,e)),se(i,o)):a?se(i,o):this.eatWikiText(i)(s,o)}}inParserFunctionArgument(t,e=t!=null?t:1/0,i=0){if(e===0)return this.inTemplateArgument(!0,!0);const n=e===2?"}{<":"}{<~'_-";let r=`${M.parserFunction} ${t?M.pageName:""}`;switch(t){case 1:r+=" mw-function-274";break;case 2:r+=" mw-function-828";break;case 1/0:r+=` mw-function-${i}`}return(s,o)=>s.eat("|")?(t?o.tokenize=this.inParserFunctionArgument(void 0,t-1):e!==1/0&&(o.tokenize=this.inParserFunctionArgument(void 0,e-1)),T("parserFunctionDelimiter",o)):s.match("}}")?(Y(o),T("parserFunctionBracket",o,"nExt")):!qt(s)&&s.match(Bv[t?0:Number(Fo(o))+1](n))?se(r,o):this.eatWikiText("parserFunction")(s,o)}inTemplateArgument(t,e){const i=e?"parserFunction":"template";return(n,r)=>{const s=n.eatSpace();if(n.eol())return T(i,r);if(n.eat("|"))return t||(r.tokenize=this.inTemplateArgument(!0,e)),T(e?"parserFunctionDelimiter":"templateDelimiter",r);if(n.match("}}",!1))return s?T(i,r):(n.pos+=2,Y(r),T(e?"parserFunctionBracket":"templateBracket",r,e?"nExt":"nTemplate"));if(n.sol()&&n.peek()==="="){const o=this.eatWikiText(i)(n,r);if(o.includes(M.sectionHeader))return o;n.pos=0}return t&&n.match(new RegExp(`^(?:[^=|}{[<]|${ee("}{[<",r)})*=`,"iu"))?(r.tokenize=this.inTemplateArgument(!1,e),T("templateArgumentName",r)):qt(n)&&n.peek()!=="="?this.eatWikiText(i)(n,r):n.match(Fo(r)?kv:Sv)||s?T(i,r):this.eatWikiText(i)(n,r)}}inConvert(t,e,i=!0,n){return(r,s)=>{const o=r.eatSpace();return r.match("}-")?(Y(s),T("convertBracket",s)):e&&r.match(/^[;\sa-z-]*(?=\|)/iu)?(s.tokenize=this.inConvert(t,!1,!0,n),J(s,this.inStr("|","convertDelimiter")),T("convertFlag",s)):r.match(this.convertSemicolon)?((e||!i)&&(s.tokenize=this.inConvert(t,!1,!0,n)),T("convertDelimiter",s)):i&&r.match(this.convertLang)?(s.tokenize=this.inConvert(t,!1,!1,n),T("convertLang",s)):n?r.match("-{",!1)?this.eatWikiText(t)(r,s):(r.match(/^(?:(?:[^};=-]|\}(?!-)|=(?!>)|-(?!\{))+|;|=>)/u),fe(t,s)):!qt(r,!0)&&r.match(this.convertRegex)||o?fe(t,s):this.eatWikiText(t)(r,s)}}eatEntity(t,e){const i=t.match(/^(?:#x[a-f\d]+|#\d+|[a-z\d]+);/iu);return i&&mv(i[0])?M.htmlEntity:e}mediawiki(t){return{startState:()=>Ot(this.eatWikiText(""),t!=null?t:this.tags,t===void 0),copyState:xr,token(e,i){const{data:n}=i,{readyTokens:r}=n;let{oldToken:s}=n;for(;s&&(e.pos>s.pos||e.pos===s.pos&&i.tokenize!==s.state.tokenize);)s=r.shift();if(e.pos===(s==null?void 0:s.pos)&&e.string===s.string&&bi(i,s.state)){const{pos:l,string:a,state:{bold:c,italic:h,...f},style:u}=r[0];if(Object.assign(i,f),!(i.extName&&i.extMode)&&i.nLink===0&&typeof u=="string"&&u.includes(M.apostrophes)){if(n.mark===l){n.mark=null,e.string=a.slice(0,l-2);const p=i.tokenize(e,i);return e.string=a,s.pos++,n.oldToken=s,of(p,i)}const d=l-e.pos;d!==3&&(i.italic=!i.italic),d!==2&&(i.bold=!i.bold)}else typeof u=="string"&&u.includes(M.tableDelimiter)&&(i.bold=!1,i.italic=!1);return n.oldToken=r.shift(),e.pos=l,e.string=a,of(u,i)}else e.sol()&&(i.bold=!1,i.italic=!1,i.dt.n=0,i.dt.html=0,n.firstSingleLetterWord=null,n.firstMultiLetterWord=null,n.firstSpace=null,i.tokenize.name==="inExtTokens"&&(Y(i),Y(i),i.extName=!1,i.extMode=!1,i.extState=!1));r.length=0,n.mark=null,n.oldToken={pos:e.pos,string:e.string,state:xr(i),style:""};const{start:o}=e;do{e.start=e.pos;const l=e.peek(),a=i.tokenize(e,i);if(typeof a=="string"&&a.includes(M.templateArgumentName))for(let c=r.length-1;c>=0;c--){const h=r[c];if(bi(i,h.state,!0)){const f=typeof h.style=="string"&&h.style.split(" "),u=f&&f.indexOf(M.template);if(u!==!1&&u!==-1)f[u]=M.templateArgumentName,h.style=f.join(" ");else if(f&&f.includes(M.templateDelimiter))break}}else if(typeof a=="string"&&a.includes(M.tableDelimiter2))for(let c=r.length-1;c>=0;c--){const h=r[c];if(bi(i,h.state,!0)){const{style:f}=h,u=typeof f=="string",d=!u&&f[0].split(" ").find(p=>p&&!p.endsWith("-ground"));if(d&&d.startsWith("mw-table-"))h.style=`${f[0].replace("mw-table-","mw-html-")} ${M.tableDefinition}`;else if(u&&f.includes(M.tableDelimiter))break}}else if(l==="|"&&typeof a=="string"&&a.includes(M.convertDelimiter)){let c=0;for(let h=r.length-1;h>=0;h--){const f=r[h];if(bi(i,f.state,!0)){const{style:u}=f;if(typeof u=="string"&&u.includes(M.convertBracket)){if(c+=f.char==="-"?1:-1,c===1)break}else typeof u=="object"&&(f.style=u[0]+(u[0].includes(M.convertFlag)?"":` ${M.convertFlag}`))}}}r.push({pos:e.pos,char:l,string:e.string,state:xr(i),style:a})}while(!e.eol());return(!i.bold||!i.italic)&&(n.mark=null),e.start=o,e.pos=n.oldToken.pos,e.string=n.oldToken.string,Object.assign(i,n.oldToken.state),""},blankLine(e){e.extName&&e.extMode&&e.extMode.blankLine&&e.extMode.blankLine(e.extState,0)},indent(e,i,n){return e.extName&&e.extMode&&e.extMode.indent?e.extMode.indent(e.extState,i,n):null},...t?void 0:{tokenTable:{...this.tokenTable,...this.hiddenTable,"":Re.define()}}}}"text/mediawiki"(t){return this.mediawiki(t)}"text/nowiki"(){return{startState(){return{}},token:t=>t.eatWhile(/[^&]/u)?"":(t.next(),this.eatEntity(t,""))}}inPre(t){return(e,i)=>e.match(t?/^<\/nowiki>/iu:/^<nowiki>/iu)?(i.tokenize=this.inPre(!t),M.ignored):this.hasVariants&&e.match("-{")?(J(i,this.inConvert("",!0,!0,!0)),M.convertBracket):e.eat("&")?this.eatEntity(e,""):(e.match(this.preRegex[t?1:0]),"")}"text/pre"(){return{startState:()=>Ot(this.inPre(),[]),token:wi}}inNested(t){const e=t==="ref"?/^(?:\{|(?:[^<{]|\{(?!\{)|<(?!!--|ref(?:[\s/>]|$)))+)/iu:Wv(t);return(i,n)=>{var r;if(t==="ref"){if(i.match("<!--"))return J(n,this.inComment),T("comment",n);if(i.match(/^\{{3}(?!\{|[^{}]*\}\}(?!\}))\s*/u))return J(n,this.inVariable()),M.templateVariableBracket;if(i.match(/^\{\{(?!\{(?!\{))/u))return(r=this.eatTransclusion(i,n))!=null?r:M.ignored}return i.match(e)?M.ignored:(i.eat("<"),J(n,this.eatTagName(t)),M.extTagBracket)}}"text/references"(t){return{startState:()=>Ot(this.inNested("ref"),t),token:wi}}"text/choose"(t){return{startState:()=>Ot(this.inNested("option"),t),token:wi}}"text/combobox"(t){return{startState:()=>Ot(this.inNested("combooption"),t),token:wi}}get inInputbox(){return(t,e)=>t.match("<!--")?(J(e,this.inComment),M.comment):(t.match(/^(?:[^<]|<(?!!--))+/u),"")}"text/inputbox"(){return{startState:()=>Ot(this.inInputbox,[]),token:wi}}inGallery(t){const e=t?M.error:`${M.linkPageName} ${M.pageName}`,i=t?/^(?:[[}\]]|\{(?!\{))+/u:/^(?:[>[}\]]|\{(?!\{)|<(?!!--))+/u,n=t?/^(?:[^|<[\]{}]|<(?!!--))+/u:/^(?:&#(?:\d+|x[a-f\d]+);|[^#|<>[\]{}])+/u;return(r,s)=>{const o=r.eatSpace();return!t&&r.match(/^#\s*/u)?(s.tokenize=this.inGallery(!0),Et("error",s)):r.match(/^\|\s*/u)?(s.tokenize=this.inLinkText(!0,!0),this.toEatImageParameter(r,s),T("fileDelimiter",s)):r.match(i)?Et("error",s):r.match(n)||o?fe(e,s):this.eatWikiText(t?e:"error")(r,s)}}"text/gallery"(t){return{startState:()=>Ot(this.inGallery(),t),token:(e,i)=>(e.sol()&&Object.assign(i,Ot(this.inGallery(),i.data.tags)),wi(e,i))}}},_=Al(null),j(_,1,"inChars",hd,z),j(_,1,"inStr",ad,z),j(_,1,"eatWikiText",ld,z),j(_,1,"eatApostrophes",od,z),j(_,1,"eatExternalLinkProtocol",sd,z),j(_,1,"inExternalLink",rd,z),j(_,1,"inLink",nd,z),j(_,1,"inLinkText",id,z),j(_,2,"eatStartTable",td,z),j(_,1,"inTableDefinition",ed,z),j(_,2,"inTable",Zu,z),j(_,1,"inTableCell",Qu,z),j(_,1,"inSectionHeader",Xu,z),j(_,2,"inComment",Yu,z),j(_,1,"eatTagName",Ju,z),j(_,1,"inHtmlTagAttribute",Gu,z),j(_,1,"inExtTagAttribute",Uu,z),j(_,1,"eatExtTagArea",Ku,z),j(_,1,"inExtTokens",qu,z),j(_,1,"inVariable",ju,z),j(_,1,"inSubst",_u,z),j(_,1,"inParserFunctionName",zu,z),j(_,1,"inTemplatePageName",$u,z),j(_,1,"inParserFunctionArgument",Wu,z),j(_,1,"inTemplateArgument",Vu,z),j(_,1,"inConvert",Hu,z),j(_,1,"inPre",Fu,z),j(_,1,"inNested",Iu,z),j(_,2,"inInputbox",Nu,z),j(_,1,"inGallery",Ru,z),Kr(_,z),z),zv=class{get closing(){return mf(this.first,this.type,this.state,!0)}get selfClosing(){return tf.includes(this.name)||(this.type==="ext"||nf.includes(this.name))&&mf(this.last,this.type,this.state)}get from(){const{first:{from:t,to:e},state:i}=this;return t+i.sliceDoc(t,e).lastIndexOf("<")}get to(){const{last:{from:t,to:e},state:i}=this;return t+i.sliceDoc(t,e).indexOf(">")+1}constructor(t,e,i,n,r){this.type=t,this.name=e,this.first=i,this.last=n,this.state=r}},pf=t=>{const e=new RegExp(`-htmltag-${t}`,"u"),i=new RegExp(`-exttag-${t}`,"u");return({name:n},r)=>(r==="ext"?i:e).test(n)},Cr=pf("bracket"),gf=pf("name"),mf=(t,e,i,n)=>Cr(t,e)&&i.sliceDoc(t.from,t.to)[n?"endsWith":"startsWith"]("/"),_v=(t,{from:e,to:i})=>t.sliceDoc(e,i).trim().toLowerCase(),jv=(t,e)=>{const i=e.name.includes("exttag")?"ext":"html";let{nextSibling:n,prevSibling:r}=e,s=gf(e,i)?e:null;for(;n&&!Cr(n,i);)({nextSibling:n}=n);if(!n||Cr(n,i)&&t.sliceDoc(n.from,n.from+1)==="<")return null;for(;r&&!Cr(r,i);)s!=null||(s=gf(r,i)?r:null),{prevSibling:r}=r;const o=_v(t,s);return new zv(i,o,r,n,t)},qv=(t,e)=>{const i=t.sliceDoc(e.from,e.to);return[i.split("{{").length-1,1-i.split("}}").length]},Kv=new RegExp(String.raw`\.(?:${nv})\.org$`,"u"),Uv=(t,e,i,n)=>{let{label:r}=e;const s=r.charAt(0).toLowerCase();t.state.sliceDoc(i,i+1)===s&&(r=s+r.slice(1)),t.dispatch({...X0(t.state,r,i,n),annotations:Y0.of(e)})},de=(t,e)=>(Array.isArray(e)?e:[e]).some(i=>t.has(i in M?M[i]:i)),Gv=(cd=class extends $v{constructor(e){super(e);ue(this,Ut);const{urlProtocols:i,nsid:n,functionSynonyms:r,doubleUnderscore:s}=e;this.nsRegex=new RegExp(String.raw`^(${Object.keys(n).filter(Boolean).join("|").replace(/_/gu," ")})\s*:\s*`,"iu"),this.functionSynonyms=r.flatMap((o,l)=>Object.keys(o).map(a=>({type:l?"constant":"function",label:a}))),this.doubleUnderscore=s.flatMap(Object.keys).map(o=>({type:"constant",label:o})),this.extTags=this.tags.map(o=>({type:"type",label:o})),this.htmlTags=ef.filter(o=>!this.tags.includes(o)).map(o=>({type:"type",label:o})),this.protocols=i.split("|").map(o=>({type:"namespace",label:o.replace(/\\\//gu,"/")})),this.imgKeys=this.img.map(o=>o.endsWith("$1")?{type:"property",label:o.slice(0,-2),detail:"$1"}:{type:"keyword",label:o}),this.htmlAttrs=[...[...hv].map(o=>({type:"property",label:o})),{type:"variable",label:"data-",detail:"*"},{type:"namespace",label:"xmlns:",detail:"*"}],this.elementAttrs=new Map(Object.entries(cv).map(([o,l])=>[o,[...l].map(a=>({type:"property",label:a}))])),this.extAttrs=new Map(Object.entries(fv).map(([o,l])=>[o,[...l].map(a=>({type:"property",label:a}))]))}getTagStyles(){return Object.keys(this.tokenTable).map(e=>({tag:this.tokenTable[e],class:`cm-${e}`}))}mediawiki(e){const i=super.mediawiki(e);return i.languageData={closeBrackets:{brackets:["(","[","{",'"'],before:")]}>"},autocomplete:this.completionSource},i}get completionSource(){return async e=>{var v,y,S,k,E,H;const{state:i,pos:n,explicit:r}=e,s=Se(i).resolve(n,-1),o=new Set(s.name.split("_")),l=de(o,"parserFunctionName"),a=i.sliceDoc(s.from,n).trimStart(),c=n-a.length;let{prevSibling:h}=s;if(r||l&&a.includes("#")||Kv.test(location.hostname)){const C=/^[^|{}<>[\]#]*$/u;if(l||de(o,"templateName")){const O=a.includes(":")?[]:[...this.functionSynonyms],R=(v=await ce(this,Ut,bl).call(this,a,10))!=null?v:{offset:0,options:[]};return O.push(...R.options),O.length===0?null:{from:c+R.offset,options:O,validFor:C}}else if(r&&de(o,"templateBracket")&&e.matchBefore(/\{\{$/u))return{from:n,options:this.functionSynonyms,validFor:C};const B=de(o,"pageName")&&de(o,"parserFunction")||0;if(B&&a.trim()||de(o,"linkPageName")){let O="";B&&(O=this.autocompleteNamespaces[[...o].find(F=>F.startsWith("mw-function-")).slice(12)]);const R=await ce(this,Ut,bl).call(this,O+a);if(R)B?O==="Module:"&&(R.options=R.options.filter(({label:F})=>!F.endsWith("/doc"))):R.options=R.options.map(F=>({...F,apply:Uv}));else return null;return{from:c+R.offset-(B&&O.length),options:R.options,validFor:C}}const V=de(o,"templateArgumentName"),$=h==null?void 0:h.name.includes(M.templateDelimiter),I=de(o,"templateDelimiter")||de(o,"templateBracket")&&$;if(this.tags.includes("templatedata")&&(I||V&&!a.includes("=")||de(o,"template")&&$)){let O=-1,R="";for(;h;){const{name:F,from:te,to:Ye}=h;if(F.includes(M.templateBracket)){const[Nt,Gt]=qv(i,h);if(O+=Nt,O>=0)break;O+=Gt}else if(O===-1&&F.includes(M.templateName))R=i.sliceDoc(te,Ye)+R;else if(R&&!F.includes(M.comment)){h=null;break}({prevSibling:h}=h)}if(h&&R){const F=V&&i.sliceDoc(n,s.to).trim()==="="?"":"=",te=await ce(this,Ut,Wd).call(this,I?"":a,R,F);if(te&&te.options.length>0)return{from:I?n:c+te.offset,options:te.options,validFor:/^[^|{}=]*$/u}}}}const f=de(o,["htmlTagName","extTagName"]),u=r&&e.matchBefore(/\s$/u),d=/^[a-z]*$/iu;if(f&&u||de(o,["htmlTagAttribute","extTagAttribute","tableDefinition"])){const C=f?a.trim():/mw-(?:ext|html)-([a-z]+)/u.exec(s.name)[1],B=u||e.matchBefore(de(o,"tableDefinition")?/[\s|-][a-z]+$/iu:/\s[a-z]+$/iu);return B&&(B.from<c||/^\s/u.test(B.text))?{from:B.from+1,options:[...C==="meta"||C==="link"||C in this.config.tags&&!this.elementAttrs.has(C)?[]:this.htmlAttrs,...(y=this.elementAttrs.get(C))!=null?y:[],...(S=this.extAttrs.get(C))!=null?S:[]],validFor:d}:null}else if(r&&de(o,["tableTd","tableTh","tableCaption"])){const[,C]=/mw-table-([a-z]+)/u.exec(s.name),B=e.matchBefore(/[\s|!+][a-z]*$/iu);if(B&&(B.from<c||/^\s/u.test(B.text)))return{from:B.from+1,options:[...this.htmlAttrs,...(k=this.elementAttrs.get(C))!=null?k:[]],validFor:d}}else if(de(o,["comment","templateVariableName","templateName","linkPageName","linkToSection","extLink"]))return null;let p=e.matchBefore(/__(?:(?!__)[\p{L}\p{N}_])*$/u);if(p)return{from:p.from,options:this.doubleUnderscore,validFor:/^[\p{L}\p{N}]*$/u};p=e.matchBefore(/<\/?[a-z\d]*$/iu);const g=[...o].filter(C=>C.startsWith("mw-tag-")).map(C=>C.slice(7));if(p&&(r||p.to-p.from>1)){const C=/^[a-z\d]*$/iu;if(p.text[1]==="/"){const B=e.matchBefore(/<[a-z\d]+(?:\s[^<>]*)?>(?:(?!<\/?[a-z]).)*<\/[a-z\d]*$/iu),V=(H=/^<([a-z\d]+)/iu.exec((E=B==null?void 0:B.text)!=null?E:""))==null?void 0:H[1].toLowerCase(),$=g[g.length-1],I=/^\s*>/u.test(i.sliceDoc(n)),O=[...this.htmlTags.filter(({label:F})=>!this.voidHtmlTags.has(F)),...$?[{type:"type",label:$,boost:50}]:[]],R=this.permittedHtmlTags.has(V)&&O.findIndex(({label:F})=>F===V);return R!==!1&&R!==-1&&O.splice(R,1,{type:"type",label:V,boost:99}),{from:p.from+2,options:I?O:O.map(F=>({...F,apply:`${F.label}>`})),validFor:C}}return{from:p.from+1,options:[...this.htmlTags,...this.extTags.filter(({label:B})=>!g.includes(B))],validFor:C}}const m=r&&de(o,"fileDelimiter");if(m||de(o,"fileText")&&(h!=null&&h.name.includes(M.fileDelimiter))&&!a.includes("[")){const C=i.sliceDoc(n,n+1)==="=";return{from:m?n:h.to,options:C?this.imgKeys.map(B=>({...B,apply:B.label.replace(/=$/u,"")})):this.imgKeys,validFor:/^[^|{}<>[\]$]*$/u}}else if(!de(o,["linkText","extLinkText"])&&(p=e.matchBefore(/(?:^|[^[])\[[a-z:/]*$/iu),p&&(r||!p.text.endsWith("["))))return{from:p.from+(p.text[1]==="["?2:1),options:this.protocols,validFor:/^[a-z:/]*$/iu};return null}}},Ut=new WeakSet,bl=async function(e,i=0){const{config:{linkSuggest:n,nsid:r},nsRegex:s}=this;if(typeof n!="function"||/[|{}<>[\]#]/u.test(e))return;let o=!1,l=e,a=0;if(l.startsWith("/"))i=0,o=!0;else{if(l=l.replace(/_/gu," "),[{length:a}]=/^\s*/u.exec(l),l=l.slice(a),l.startsWith(":")){const[{length:u}]=/^:\s*/u.exec(l);a+=u,l=l.slice(u),i=0}if(!l)return;const f=s.exec(l);if(f){const[{length:u},d]=f;i=r[d.replace(/ /gu,"_").toLowerCase()]||1,a+=u,l=`${i===-2?"File":d}:${l.slice(u)}`}}const c=e.slice(a).includes("_");return{offset:a,options:(await n(l,i,o)).map(([h])=>({type:"text",label:c?h.replace(/ /gu,"_"):h}))}},Wd=async function(e,i,n){const{config:{paramSuggest:r}}=this;return i&&typeof r=="function"&&!/[|{}<>[\]]/u.test(i)?{offset:/^\s*/u.exec(e)[0].length,options:(await r(i)).map(([s,o])=>({type:"variable",label:s+n,detail:o}))}:void 0},cd),Jv=t=>{const e=new Gv(t),i=j0.define(e.mediawiki()),n=Lc(Co.define(e.getTagStyles()));return new k0(i,n)},Yv=t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),n=_o(t.state,i.from);return n.line?Xv(t):n.block?Zv(t):!1};function zo(t,e){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let r=t(e,i);return r?(n(i.update(r)),!0):!1}}var Xv=zo(iy,0),Qv=zo(vf,0),Zv=zo((t,e)=>vf(t,e,ty(e)),0);function _o(t,e){let i=t.languageDataAt("commentTokens",e,1);return i.length?i[0]:{}}var nn=50;function ey(t,{open:e,close:i},n,r){let s=t.sliceDoc(n-nn,n),o=t.sliceDoc(r,r+nn),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,c=s.length-l;if(s.slice(c-e.length,c)==e&&o.slice(a,a+i.length)==i)return{open:{pos:n-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let h,f;r-n<=2*nn?h=f=t.sliceDoc(n,r):(h=t.sliceDoc(n,n+nn),f=t.sliceDoc(r-nn,r));let u=/^\s*/.exec(h)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-i.length;return h.slice(u,u+e.length)==e&&f.slice(p,p+i.length)==i?{open:{pos:n+u+e.length,margin:/\s/.test(h.charAt(u+e.length))?1:0},close:{pos:r-d-i.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function ty(t){let e=[];for(let i of t.selection.ranges){let n=t.doc.lineAt(i.from),r=i.to<=n.to?n:t.doc.lineAt(i.to);r.from>n.from&&r.from==i.to&&(r=i.to==n.to+1?n:t.doc.lineAt(i.to-1));let s=e.length-1;s>=0&&e[s].to>n.from?e[s].to=r.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return e}function vf(t,e,i=e.selection.ranges){let n=i.map(s=>_o(e,s.from).block);if(!n.every(s=>s))return null;let r=i.map((s,o)=>ey(e,n[o],s.from,s.to));if(t!=2&&!r.every(s=>s))return{changes:e.changes(i.map((s,o)=>r[o]?[]:[{from:s.from,insert:n[o].open+" "},{from:s.to,insert:" "+n[o].close}]))};if(t!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=n[o],{open:c,close:h}=l;s.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:h.pos-h.margin,to:h.pos+a.close.length})}return{changes:s}}return null}function iy(t,e,i=e.selection.ranges){let n=[],r=-1;for(let{from:s,to:o}of i){let l=n.length,a=1e9,c=_o(e,s).line;if(c){for(let h=s;h<=o;){let f=e.doc.lineAt(h);if(f.from>r&&(s==o||o>f.from)){r=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+c.length)==c?u:-1;u<f.text.length&&u<a&&(a=u),n.push({line:f,comment:p,token:c,indent:u,empty:d,single:!1})}h=f.to+1}if(a<1e9)for(let h=l;h<n.length;h++)n[h].indent<n[h].line.text.length&&(n[h].indent=a);n.length==l+1&&(n[l].single=!0)}}if(t!=2&&n.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:c,empty:h,single:f}of n)(f||!h)&&s.push({from:l.from+c,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&n.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of n)if(l>=0){let c=o.from+l,h=c+a.length;o.text[h-o.from]==" "&&h++,s.push({from:c,to:h})}return{changes:s}}return null}var jo=ft.define(),ny=ft.define(),ry=P.define(),yf=P.define({combine(t){return Bi(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,i)=>i},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,i)=>(n,r)=>e(n,r)||i(n,r)})}}),bf=Oe.define({create(){return rn.empty},update(t,e){let i=e.state.facet(yf),n=e.annotation(jo);if(n){let a=pt.fromTransaction(e,n.selection),c=n.side,h=c==0?t.undone:t.done;return a?h=Mr(h,h.length,i.minDepth,a):h=kf(h,e.startState.selection),new rn(c==0?n.rest:h,c==0?h:n.rest)}let r=e.annotation(ny);if((r=="full"||r=="before")&&(t=t.isolate()),e.annotation(xe.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=pt.fromTransaction(e),o=e.annotation(xe.time),l=e.annotation(xe.userEvent);return s?t=t.addChanges(s,o,l,i,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,i.newGroupDelay)),(r=="full"||r=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new rn(t.done.map(pt.fromJSON),t.undone.map(pt.fromJSON))}});function sy(t={}){return[bf,yf.of(t),L.domEventHandlers({beforeinput(e,i){let n=e.inputType=="historyUndo"?wf:e.inputType=="historyRedo"?Tr:null;return n?(e.preventDefault(),n(i)):!1}})]}function Ar(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let r=i.field(bf,!1);if(!r)return!1;let s=r.pop(t,i,e);return s?(n(s),!0):!1}}var wf=Ar(0,!1),Tr=Ar(1,!1),oy=Ar(0,!0),ly=Ar(1,!0),pt=class pn{constructor(e,i,n,r,s){this.changes=e,this.effects=i,this.mapped=n,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new pn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,i,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(i=this.mapped)===null||i===void 0?void 0:i.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new pn(e.changes&&_e.fromJSON(e.changes),[],e.mapped&&Qt.fromJSON(e.mapped),e.startSelection&&w.fromJSON(e.startSelection),e.selectionsAfter.map(w.fromJSON))}static fromTransaction(e,i){let n=Fe;for(let r of e.startState.facet(ry)){let s=r(e);s.length&&(n=n.concat(s))}return!n.length&&e.changes.empty?null:new pn(e.changes.invert(e.startState.doc),n,void 0,i||e.startState.selection,Fe)}static selection(e){return new pn(void 0,Fe,void 0,void 0,e)}};function Mr(t,e,i,n){let r=e+1>i+20?e-i-1:0,s=t.slice(r,e);return s.push(n),s}function ay(t,e){let i=[],n=!1;return t.iterChangedRanges((r,s)=>i.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<i.length;){let c=i[a++],h=i[a++];l>=c&&o<=h&&(n=!0)}}),n}function hy(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((i,n)=>i.empty!=e.ranges[n].empty).length===0}function xf(t,e){return t.length?e.length?t.concat(e):t:e}var Fe=[],cy=200;function kf(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-cy));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),Mr(t,t.length-1,1e9,i.setSelAfter(n)))}else return[pt.selection([e])]}function fy(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function qo(t,e){if(!t.length)return t;let i=t.length,n=Fe;for(;i;){let r=uy(t[i-1],e,n);if(r.changes&&!r.changes.empty||r.effects.length){let s=t.slice(0,i);return s[i-1]=r,s}else e=r.mapped,i--,n=r.selectionsAfter}return n.length?[pt.selection(n)]:Fe}function uy(t,e,i){let n=xf(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):Fe,i);if(!t.changes)return pt.selection(n);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new pt(r,K.mapEffects(t.effects,e),o,t.startSelection.map(s),n)}var dy=/^(input\.type|delete)($|\.)/,rn=class gn{constructor(e,i,n=0,r=void 0){this.done=e,this.undone=i,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new gn(this.done,this.undone):this}addChanges(e,i,n,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!n||dy.test(n))&&(!l.selectionsAfter.length&&i-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,ay(l.changes,e.changes))||n=="input.type.compose")?o=Mr(o,o.length-1,r.minDepth,new pt(e.changes.compose(l.changes),xf(K.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,Fe)):o=Mr(o,o.length,r.minDepth,e),new gn(o,Fe,i,n)}addSelection(e,i,n,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Fe;return s.length>0&&i-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&hy(s[s.length-1],e)?this:new gn(kf(this.done,e),this.undone,i,n)}addMapping(e){return new gn(qo(this.done,e),qo(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,i,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||i.selection;if(n&&s.selectionsAfter.length)return i.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:jo.of({side:e,rest:fy(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?Fe:r.slice(0,r.length-1);return s.mapped&&(l=qo(l,s.mapped)),i.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:jo.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};rn.empty=new rn(Fe,Fe);var py=[{key:"Mod-z",run:wf,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Tr,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Tr,preventDefault:!0},{key:"Mod-u",run:oy,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:ly,preventDefault:!0}];function xi(t,e){return w.create(t.ranges.map(e),t.mainIndex)}function lt(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Ue({state:t,dispatch:e},i){let n=xi(t.selection,i);return n.eq(t.selection,!0)?!1:(e(lt(t,n)),!0)}function Dr(t,e){return w.cursor(e?t.to:t.from)}function Sf(t,e){return Ue(t,i=>i.empty?t.moveByChar(i,e):Dr(i,e))}function ye(t){return t.textDirectionAt(t.state.selection.main.head)==oe.LTR}var Cf=t=>Sf(t,!ye(t)),Af=t=>Sf(t,ye(t));function Tf(t,e){return Ue(t,i=>i.empty?t.moveByGroup(i,e):Dr(i,e))}var gy=t=>Tf(t,!ye(t)),my=t=>Tf(t,ye(t)),Zb=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function vy(t,e,i){if(e.type.prop(i))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Or(t,e,i){let n=Se(t).resolveInner(e.head),r=i?W.closedBy:W.openedBy;for(let a=e.head;;){let c=i?n.childAfter(a):n.childBefore(a);if(!c)break;vy(t,c,r)?n=c:a=i?c.to:c.from}let s=n.type.prop(r),o,l;return s&&(o=i?yi(t,n.from,1):yi(t,n.to,-1))&&o.matched?l=i?o.end.to:o.end.from:l=i?n.to:n.from,w.cursor(l,i?-1:1)}var yy=t=>Ue(t,e=>Or(t.state,e,!ye(t))),by=t=>Ue(t,e=>Or(t.state,e,ye(t)));function Mf(t,e){return Ue(t,i=>{if(!i.empty)return Dr(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)})}var Df=t=>Mf(t,!1),Of=t=>Mf(t,!0);function Ef(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,i=0,n=0,r;if(e){for(let s of t.state.facet(L.scrollMargins)){let o=s(t);o!=null&&o.top&&(i=Math.max(o==null?void 0:o.top,i)),o!=null&&o.bottom&&(n=Math.max(o==null?void 0:o.bottom,n))}r=t.scrollDOM.clientHeight-i-n}else r=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:i,marginBottom:n,selfScroll:e,height:Math.max(t.defaultLineHeight,r-5)}}function Lf(t,e){let i=Ef(t),{state:n}=t,r=xi(n.selection,o=>o.empty?t.moveVertically(o,e,i.height):Dr(o,e));if(r.eq(n.selection))return!1;let s;if(i.selfScroll){let o=t.coordsAtPos(n.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+i.marginTop,c=l.bottom-i.marginBottom;o&&o.top>a&&o.bottom<c&&(s=L.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return t.dispatch(lt(n,r),{effects:s}),!0}var Bf=t=>Lf(t,!1),Ko=t=>Lf(t,!0);function Lt(t,e,i){let n=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,i);if(r.head==e.head&&r.head!=(i?n.to:n.from)&&(r=t.moveToLineBoundary(e,i,!1)),!i&&r.head==n.from&&n.length){let s=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;s&&e.head!=n.from+s&&(r=w.cursor(n.from+s))}return r}var wy=t=>Ue(t,e=>Lt(t,e,!0)),xy=t=>Ue(t,e=>Lt(t,e,!1)),ky=t=>Ue(t,e=>Lt(t,e,!ye(t))),Sy=t=>Ue(t,e=>Lt(t,e,ye(t))),Cy=t=>Ue(t,e=>w.cursor(t.lineBlockAt(e.head).from,1)),Ay=t=>Ue(t,e=>w.cursor(t.lineBlockAt(e.head).to,-1));function Ty(t,e,i){let n=!1,r=xi(t.selection,s=>{let o=yi(t,s.head,-1)||yi(t,s.head,1)||s.head>0&&yi(t,s.head-1,1)||s.head<t.doc.length&&yi(t,s.head+1,-1);if(!o||!o.end)return s;n=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return i?w.range(s.anchor,l):w.cursor(l)});return n?(e(lt(t,r)),!0):!1}var My=({state:t,dispatch:e})=>Ty(t,e,!1);function He(t,e){let i=xi(t.state.selection,n=>{let r=e(n);return w.range(n.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return i.eq(t.state.selection)?!1:(t.dispatch(lt(t.state,i)),!0)}function Pf(t,e){return He(t,i=>t.moveByChar(i,e))}var Rf=t=>Pf(t,!ye(t)),Nf=t=>Pf(t,ye(t));function If(t,e){return He(t,i=>t.moveByGroup(i,e))}var Dy=t=>If(t,!ye(t)),Oy=t=>If(t,ye(t)),Ey=t=>He(t,e=>Or(t.state,e,!ye(t))),Ly=t=>He(t,e=>Or(t.state,e,ye(t)));function Ff(t,e){return He(t,i=>t.moveVertically(i,e))}var Hf=t=>Ff(t,!1),Vf=t=>Ff(t,!0);function Wf(t,e){return He(t,i=>t.moveVertically(i,e,Ef(t).height))}var $f=t=>Wf(t,!1),zf=t=>Wf(t,!0),By=t=>He(t,e=>Lt(t,e,!0)),Py=t=>He(t,e=>Lt(t,e,!1)),Ry=t=>He(t,e=>Lt(t,e,!ye(t))),Ny=t=>He(t,e=>Lt(t,e,ye(t))),Iy=t=>He(t,e=>w.cursor(t.lineBlockAt(e.head).from)),Fy=t=>He(t,e=>w.cursor(t.lineBlockAt(e.head).to)),_f=({state:t,dispatch:e})=>(e(lt(t,{anchor:0})),!0),jf=({state:t,dispatch:e})=>(e(lt(t,{anchor:t.doc.length})),!0),qf=({state:t,dispatch:e})=>(e(lt(t,{anchor:t.selection.main.anchor,head:0})),!0),Kf=({state:t,dispatch:e})=>(e(lt(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),Hy=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),Vy=({state:t,dispatch:e})=>{let i=Lr(t).map(({from:n,to:r})=>w.range(n,Math.min(r+1,t.doc.length)));return e(t.update({selection:w.create(i),userEvent:"select"})),!0},Wy=({state:t,dispatch:e})=>{let i=xi(t.selection,n=>{let r=Se(t),s=r.resolveStack(n.from,1);if(n.empty){let o=r.resolveStack(n.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<n.from&&l.to>=n.to||l.to>n.to&&l.from<=n.from)&&o.next)return w.range(l.to,l.from)}return n});return i.eq(t.selection)?!1:(e(lt(t,i)),!0)},$y=({state:t,dispatch:e})=>{let i=t.selection,n=null;return i.ranges.length>1?n=w.create([i.main]):i.main.empty||(n=w.create([w.cursor(i.main.head)])),n?(e(lt(t,n)),!0):!1};function sn(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:n}=t,r=n.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(i="delete.backward",a=Er(t,a,!1)):a>o&&(i="delete.forward",a=Er(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Er(t,o,!1),l=Er(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:w.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(t.dispatch(n.update(r,{scrollIntoView:!0,userEvent:i,effects:i=="delete.selection"?L.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function Er(t,e,i){if(t instanceof L)for(let n of t.state.facet(L.atomicRanges).map(r=>r(t)))n.between(e,e,(r,s)=>{r<e&&s>e&&(e=i?s:r)});return e}var Uf=(t,e,i)=>sn(t,n=>{let r=n.from,{state:s}=t,o=s.doc.lineAt(r),l,a;if(i&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(l[l.length-1]==" ")return r-1;let c=Bn(l,s.tabSize),h=c%jt(s)||jt(s);for(let f=0;f<h&&l[l.length-1-f]==" ";f++)r--;a=r}else a=pe(o.text,r-o.from,e,e)+o.from,a==r&&o.number!=(e?s.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=pe(o.text,a-o.from,!1,!1)+o.from);return a}),Uo=t=>Uf(t,!1,!0),Gf=t=>Uf(t,!0,!1),Jf=(t,e)=>sn(t,i=>{let n=i.head,{state:r}=t,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let l=null;;){if(n==(e?s.to:s.from)){n==i.head&&s.number!=(e?r.doc.lines:1)&&(n+=e?1:-1);break}let a=pe(s.text,n-s.from,e)+s.from,c=s.text.slice(Math.min(n,a)-s.from,Math.max(n,a)-s.from),h=o(c);if(l!=null&&h!=l)break;(c!=" "||n!=i.head)&&(l=h),n=a}return n}),Yf=t=>Jf(t,!1),zy=t=>Jf(t,!0),_y=t=>sn(t,e=>{let i=t.lineBlockAt(e.head).to;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}),jy=t=>sn(t,e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)}),qy=t=>sn(t,e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}),Ky=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:q.of(["",""])},range:w.cursor(n.from)}));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0},Uy=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(n=>{if(!n.empty||n.from==0||n.from==t.doc.length)return{range:n};let r=n.from,s=t.doc.lineAt(r),o=r==s.from?r-1:pe(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:pe(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:t.doc.slice(r,l).append(t.doc.slice(o,r))},range:w.cursor(l)}});return i.changes.empty?!1:(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Lr(t){let e=[],i=-1;for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=t.doc.lineAt(n.to);if(!n.empty&&n.to==s.from&&(s=t.doc.lineAt(n.to-1)),i>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(n)}else e.push({from:r.from,to:s.to,ranges:[n]});i=s.number+1}return e}function Xf(t,e,i){if(t.readOnly)return!1;let n=[],r=[];for(let s of Lr(t)){if(i?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(i?s.to+1:s.from-1),l=o.length+1;if(i){n.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let a of s.ranges)r.push(w.range(Math.min(t.doc.length,a.anchor+l),Math.min(t.doc.length,a.head+l)))}else{n.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let a of s.ranges)r.push(w.range(a.anchor-l,a.head-l))}}return n.length?(e(t.update({changes:n,scrollIntoView:!0,selection:w.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}var Gy=({state:t,dispatch:e})=>Xf(t,e,!1),Jy=({state:t,dispatch:e})=>Xf(t,e,!0);function Qf(t,e,i){if(t.readOnly)return!1;let n=[];for(let r of Lr(t))i?n.push({from:r.from,insert:t.doc.slice(r.from,r.to)+t.lineBreak}):n.push({from:r.to,insert:t.lineBreak+t.doc.slice(r.from,r.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var Yy=({state:t,dispatch:e})=>Qf(t,e,!1),Xy=({state:t,dispatch:e})=>Qf(t,e,!0),Qy=t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(Lr(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),n=xi(e.selection,r=>{let s;if(t.lineWrapping){let o=t.lineBlockAt(r.head),l=t.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(r,!0,s)}).map(i);return t.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Zy(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i=Se(t).resolveInner(e),n=i.childBefore(e),r=i.childAfter(e),s;return n&&r&&n.to<=e&&r.from>=e&&(s=n.type.prop(W.closedBy))&&s.indexOf(r.name)>-1&&t.doc.lineAt(n.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(n.to,r.from))?{from:n.to,to:r.from}:null}var Zf=eu(!1),eb=eu(!0);function eu(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!t&&s==o&&Zy(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let c=new br(e,{simulateBreak:s,simulateDoubleBreak:!!a}),h=So(c,s);for(h==null&&(h=Bn(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let f=["",en(e,h)];return a&&f.push(en(e,c.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:q.of(f)},range:w.cursor(s+1+f[1].length)}});return i(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Go(t,e){let i=-1;return t.changeByRange(n=>{let r=[];for(let o=n.from;o<=n.to;){let l=t.doc.lineAt(o);l.number>i&&(n.empty||n.to>l.from)&&(e(l,r,n),i=l.number),o=l.to+1}let s=t.changes(r);return{changes:r,range:w.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}var tb=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new br(t,{overrideIndentation:s=>{let o=i[s];return o==null?-1:o}}),r=Go(t,(s,o,l)=>{let a=So(n,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let c=/^\s*/.exec(s.text)[0],h=en(t,a);(c!=h||l.from<s.from+c.length)&&(i[s.from]=a,o.push({from:s.from,to:s.from+c.length,insert:h}))});return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0},tu=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Go(t,(i,n)=>{n.push({from:i.from,insert:t.facet(Zi)})}),{userEvent:"input.indent"})),!0),iu=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Go(t,(i,n)=>{let r=/^\s*/.exec(i.text)[0];if(!r)return;let s=Bn(r,t.tabSize),o=0,l=en(t,Math.max(0,s-jt(t)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;n.push({from:i.from+o,to:i.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),ib=t=>(t.setTabFocusMode(),!0),nb=[{key:"Ctrl-b",run:Cf,shift:Rf,preventDefault:!0},{key:"Ctrl-f",run:Af,shift:Nf},{key:"Ctrl-p",run:Df,shift:Hf},{key:"Ctrl-n",run:Of,shift:Vf},{key:"Ctrl-a",run:Cy,shift:Iy},{key:"Ctrl-e",run:Ay,shift:Fy},{key:"Ctrl-d",run:Gf},{key:"Ctrl-h",run:Uo},{key:"Ctrl-k",run:_y},{key:"Ctrl-Alt-h",run:Yf},{key:"Ctrl-o",run:Ky},{key:"Ctrl-t",run:Uy},{key:"Ctrl-v",run:Ko}],rb=[{key:"ArrowLeft",run:Cf,shift:Rf,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:gy,shift:Dy,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:ky,shift:Ry,preventDefault:!0},{key:"ArrowRight",run:Af,shift:Nf,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:my,shift:Oy,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Sy,shift:Ny,preventDefault:!0},{key:"ArrowUp",run:Df,shift:Hf,preventDefault:!0},{mac:"Cmd-ArrowUp",run:_f,shift:qf},{mac:"Ctrl-ArrowUp",run:Bf,shift:$f},{key:"ArrowDown",run:Of,shift:Vf,preventDefault:!0},{mac:"Cmd-ArrowDown",run:jf,shift:Kf},{mac:"Ctrl-ArrowDown",run:Ko,shift:zf},{key:"PageUp",run:Bf,shift:$f},{key:"PageDown",run:Ko,shift:zf},{key:"Home",run:xy,shift:Py,preventDefault:!0},{key:"Mod-Home",run:_f,shift:qf},{key:"End",run:wy,shift:By,preventDefault:!0},{key:"Mod-End",run:jf,shift:Kf},{key:"Enter",run:Zf,shift:Zf},{key:"Mod-a",run:Hy},{key:"Backspace",run:Uo,shift:Uo},{key:"Delete",run:Gf},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Yf},{key:"Mod-Delete",mac:"Alt-Delete",run:zy},{mac:"Mod-Backspace",run:jy},{mac:"Mod-Delete",run:qy}].concat(nb.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),sb=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:yy,shift:Ey},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:by,shift:Ly},{key:"Alt-ArrowUp",run:Gy},{key:"Shift-Alt-ArrowUp",run:Yy},{key:"Alt-ArrowDown",run:Jy},{key:"Shift-Alt-ArrowDown",run:Xy},{key:"Escape",run:$y},{key:"Mod-Enter",run:eb},{key:"Alt-l",mac:"Ctrl-l",run:Vy},{key:"Mod-i",run:Wy,preventDefault:!0},{key:"Mod-[",run:iu},{key:"Mod-]",run:tu},{key:"Mod-Alt-\\",run:tb},{key:"Shift-Mod-k",run:Qy},{key:"Shift-Mod-\\",run:My},{key:"Mod-/",run:Yv},{key:"Alt-A",run:Qv},{key:"Ctrl-m",mac:"Shift-Alt-m",run:ib}].concat(rb),ob={key:"Tab",run:tu,shift:iu},nu=class{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}},on=class $d{constructor(e,i,n){this.diagnostics=e,this.panel=i,this.selected=n}static init(e,i,n){let r=n.facet(at).markerFilter;r&&(e=r(e,n));let s=e.slice().sort((h,f)=>h.from-f.from||h.to-f.to),o=new ei,l=[],a=0;for(let h=0;;){let f=h==s.length?null:s[h];if(!f&&!l.length)break;let u,d;for(l.length?(u=a,d=l.reduce((g,m)=>Math.min(g,m.to),f&&f.from>u?f.from:1e8)):(u=f.from,d=f.to,l.push(f),h++);h<s.length;){let g=s[h];if(g.from==u&&(g.to>g.from||g.to==u))l.push(g),h++,d=Math.min(g.to,d);else{d=Math.min(g.from,d);break}}let p=du(l);if(l.some(g=>g.from==g.to||g.from==g.to-1&&n.doc.lineAt(g.from).to==g.from))o.add(u,u,U.widget({widget:new gb(p),diagnostics:l.slice()}));else{let g=l.reduce((m,v)=>v.markClass?m+" "+v.markClass:m,"");o.add(u,d,U.mark({class:"cm-lintRange cm-lintRange-"+p+g,diagnostics:l.slice(),inclusiveEnd:l.some(m=>m.to>d)}))}a=d;for(let g=0;g<l.length;g++)l[g].to<=a&&l.splice(g--,1)}let c=o.finish();return new $d(c,i,ki(c))}};function ki(t,e=null,i=0){let n=null;return t.between(i,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!n)n=new nu(r,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new nu(n.from,s,n.diagnostic)}}),n}function ru(t,e){let i=e.pos,n=e.end||i,r=t.state.facet(at).hideOn(t,i,n);if(r!=null)return r;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(ln))||t.changes.touchesRange(s.from,Math.max(s.to,n)))}function su(t,e){return t.field(Te,!1)?e:e.concat(K.appendConfig.of(mu))}function lb(t,e){return{effects:su(t,[ln.of(e)])}}var ln=K.define(),Jo=K.define(),ou=K.define(),Te=Oe.define({create(){return new on(U.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let i=t.diagnostics.map(e.changes),n=null,r=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);n=ki(i,t.selected.diagnostic,s)||ki(i,null,s)}!i.size&&r&&e.state.facet(at).autoPanel&&(r=null),t=new on(i,r,n)}for(let i of e.effects)if(i.is(ln)){let n=e.state.facet(at).autoPanel?i.value.length?Yo.open:null:t.panel;t=on.init(i.value,n,e.state)}else i.is(Jo)?t=new on(t.diagnostics,i.value?Yo.open:null,t.selected):i.is(ou)&&(t=new on(t.diagnostics,t.panel,i.value));return t},provide:t=>[ci.from(t,e=>e.panel),L.decorations.from(t,e=>e.diagnostics)]}),ab=U.mark({class:"cm-lintRange cm-lintRange-active"});function hb(t,e,i){let{diagnostics:n}=t.state.field(Te),r,s=-1,o=-1;n.between(e-(i<0?1:0),e+(i>0?1:0),(a,c,{spec:h})=>{if(e>=a&&e<=c&&(a==c||(e>a||i>0)&&(e<c||i<0)))return r=h.diagnostics,s=a,o=c,!1});let l=t.state.facet(at).tooltipFilter;return r&&l&&(r=l(r,t.state)),r?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create(){return{dom:lu(t,r)}}}:null}function lu(t,e){return X("ul",{class:"cm-tooltip-lint"},e.map(i=>fu(t,i,!1)))}var cb=t=>{let e=t.state.field(Te,!1);(!e||!e.panel)&&t.dispatch({effects:su(t.state,[Jo.of(!0)])});let i=ji(t,Yo.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},au=t=>{let e=t.state.field(Te,!1);return!e||!e.panel?!1:(t.dispatch({effects:Jo.of(!1)}),!0)},hu=t=>{let e=t.state.field(Te,!1);if(!e)return!1;let i=t.state.selection.main,n=e.diagnostics.iter(i.to+1);return!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==i.from&&n.to==i.to)?!1:(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},fb=[{key:"Mod-Shift-m",run:cb,preventDefault:!0},{key:"F8",run:hu}],ub=je.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(at);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:e}=this.view,{sources:i}=e.facet(at);i.length&&db(i.map(n=>Promise.resolve(n(this.view))),n=>{this.view.state.doc==e.doc&&this.view.dispatch(lb(this.view.state,n.reduce((r,s)=>r.concat(s))))},n=>{Le(this.view.state,n)})}}update(t){let e=t.state.facet(at);(t.docChanged||e!=t.startState.facet(at)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function db(t,e,i){let n=[],r=-1;for(let s of t)s.then(o=>{n.push(o),clearTimeout(r),n.length==t.length?e(n):r=setTimeout(()=>e(n),200)},i)}var at=P.define({combine(t){return Object.assign({sources:t.map(e=>e.source).filter(e=>e!=null)},Bi(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,i)=>e?i?n=>e(n)||i(n):e:i}))}});function pb(t,e={}){return[at.of({source:t,config:e}),ub,mu]}function cu(t){let e=[];if(t)e:for(let{name:i}of t){for(let n=0;n<i.length;n++){let r=i[n];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function fu(t,e,i){var n;let r=i?cu(e.actions):[];return X("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},X("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((s,o)=>{let l=!1,a=u=>{if(u.preventDefault(),l)return;l=!0;let d=ki(t.state.field(Te).diagnostics,e);d&&s.apply(t,d.from,d.to)},{name:c}=s,h=r[o]?c.indexOf(r[o]):-1,f=h<0?c:[c.slice(0,h),X("u",c.slice(h,h+1)),c.slice(h+1)];return X("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${c}${h<0?"":` (access key "${r[o]})"`}.`},f)}),e.source&&X("div",{class:"cm-diagnosticSource"},e.source))}var gb=class extends Vn{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return X("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},uu=class{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=fu(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Yo=class zd{constructor(e){this.view=e,this.items=[];let i=r=>{if(r.keyCode==27)au(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=cu(s.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==r.keyCode){let a=ki(this.view.state.field(Te).diagnostics,s);a&&s.actions[l].apply(e,a.from,a.to)}}else return;r.preventDefault()},n=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=X("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:i,onclick:n}),this.dom=X("div",{class:"cm-panel-lint"},this.list,X("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>au(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Te).selected;if(!e)return-1;for(let i=0;i<this.items.length;i++)if(this.items[i].diagnostic==e.diagnostic)return i;return-1}update(){let{diagnostics:e,selected:i}=this.view.state.field(Te),n=0,r=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:c})=>{for(let h of c.diagnostics){if(o.has(h))continue;o.add(h);let f=-1,u;for(let d=n;d<this.items.length;d++)if(this.items[d].diagnostic==h){f=d;break}f<0?(u=new uu(this.view,h),this.items.splice(n,0,u),r=!0):(u=this.items[f],f>n&&(this.items.splice(n,f-n),r=!0)),i&&u.diagnostic==i.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),s=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new uu(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let c=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/c:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function i(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)i();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)i()}moveSelection(e){if(this.selectedIndex<0)return;let i=this.view.state.field(Te),n=ki(i.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:ou.of(n)})}static open(e){return new zd(e)}};function Br(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function Pr(t){return Br(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var mb=L.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Pr("#d11")},".cm-lintRange-warning":{backgroundImage:Pr("orange")},".cm-lintRange-info":{backgroundImage:Pr("#999")},".cm-lintRange-hint":{backgroundImage:Pr("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function vb(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function du(t){let e="hint",i=1;for(let n of t){let r=vb(n.severity);r>i&&(i=r,e=n.severity)}return e}var pu=class extends dt{constructor(t){super(),this.diagnostics=t,this.severity=du(t)}toDOM(t){let e=document.createElement("div");e.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,n=t.state.facet(Rr).tooltipFilter;return n&&(i=n(i,t.state)),i.length&&(e.onmouseover=()=>bb(t,e,i)),e}};function yb(t,e){let i=n=>{let r=e.getBoundingClientRect();if(!(n.clientX>r.left-10&&n.clientX<r.right+10&&n.clientY>r.top-10&&n.clientY<r.bottom+10)){for(let s=n.target;s;s=s.parentNode)if(s.nodeType==1&&s.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",i),t.state.field(gu)&&t.dispatch({effects:Qo.of(null)})}};window.addEventListener("mousemove",i)}function bb(t,e,i){function n(){let o=t.elementAtHeight(e.getBoundingClientRect().top+5-t.documentTop);t.coordsAtPos(o.from)&&t.dispatch({effects:Qo.of({pos:o.from,above:!1,clip:!1,create(){return{dom:lu(t,i),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,yb(t,e)}let{hoverTime:r}=t.state.facet(Rr),s=setTimeout(n,r);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(n,r)}}function wb(t,e){let i=Object.create(null);for(let r of e){let s=t.lineAt(r.from);(i[s.from]||(i[s.from]=[])).push(r)}let n=[];for(let r in i)n.push(new pu(i[r]).range(+r));return ne.of(n,!0)}var xb=xm({class:"cm-gutter-lint",markers:t=>t.state.field(Xo),widgetMarker:(t,e,i)=>{let n=[];return t.state.field(Xo).between(i.from,i.to,(r,s,o)=>{r>i.from&&r<i.to&&n.push(...o.diagnostics)}),n.length?new pu(n):null}}),Xo=Oe.define({create(){return ne.empty},update(t,e){t=t.map(e.changes);let i=e.state.facet(Rr).markerFilter;for(let n of e.effects)if(n.is(ln)){let r=n.value;i&&(r=i(r||[],e.state)),t=wb(e.state.doc,r.slice(0))}return t}}),Qo=K.define(),gu=Oe.define({create(){return null},update(t,e){return t&&e.docChanged&&(t=ru(e,t)?null:Object.assign(Object.assign({},t),{pos:e.changes.mapPos(t.pos)})),e.effects.reduce((i,n)=>n.is(Qo)?n.value:i,t)},provide:t=>Xs.from(t)}),kb=L.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Br('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:Br('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:Br('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),mu=[Te,L.decorations.compute([Te],t=>{let{selected:e,panel:i}=t.field(Te);return!e||!i||e.from==e.to?U.none:U.set([ab.range(e.from,e.to)])}),vm(hb,{hideOn:ru}),mb],Rr=P.define({combine(t){return Bi(t,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function Sb(t={}){return[Rr.of(t),Xo,xb,kb,gu]}var Zo=()=>L.contentAttributes.of({spellcheck:"true"}),vu={plain:Zo},el={},Nr={},yu=[],bu=[],an={statusBar(){return[]},detectIndent(t,e){return e},foldHandler(){return()=>{}}},Cb=new Set(["closeBrackets","autocompletion","signatureHelp"]),hn={},tl={},wu=(fd=class{constructor(t,e="plain",i,n=!0){ue(this,he);ue(this,Ve);ue(this,mn,new Qe);ue(this,Kt,new Qe);ue(this,vn,new Qe);ue(this,yn,new Qe);ue(this,bn,new Qe);ue(this,wn,new Qe);ue(this,xn,new Qe);ue(this,kn,new Qe);ue(this,N);ue(this,We);ue(this,Pt,!1);ue(this,Rt,new Set);ue(this,Ci," ");ue(this,Sn);$e(this,Ve,t),$e(this,We,e),n&&this.initialize(i)}get textarea(){return b(this,Ve)}get view(){return b(this,N)}get lang(){return b(this,We)}get visible(){return b(this,Pt)&&this.textarea.isConnected}initialize(t){var p;let e;const{textarea:i,lang:n}=this,{value:r,dir:s,accessKey:o,tabIndex:l,lang:a,readOnly:c}=i,h=[b(this,mn).of(ce(this,he,wl).call(this,t)),b(this,Kt).of((p=hn[n])!=null?p:[]),b(this,vn).of([]),b(this,yn).of(L.editorAttributes.of({dir:s})),b(this,wn).of([]),b(this,xn).of(ie.phrases.of(tl)),b(this,kn).of(L.lineWrapping),Lc(I0),L.contentAttributes.of({accesskey:o,tabindex:String(l)}),L.editorAttributes.of({lang:a}),Dm(),Lm(),hi.of([...sb,...Gm,{key:"Mod-Shift-x",run:()=>{const g=i.dir==="rtl"?"ltr":"rtl";return i.dir=g,ce(this,he,mt).call(this,b(this,yn).reconfigure(L.editorAttributes.of({dir:g}))),!0}}]),L.theme({".cm-panels":{direction:document.dir}}),L.updateListener.of(({state:{doc:g},startState:{doc:m},docChanged:v,focusChanged:y})=>{v&&(clearTimeout(e),e=setTimeout(()=>{i.value=g.toString(),i.dispatchEvent(new Event("input"))},400),m.toString().trim()||this.setIndent(b(this,Ci))),y&&i.dispatchEvent(new Event(b(this,N).hasFocus?"focus":"blur"))}),...c?[ie.readOnly.of(!0),ie.transactionFilter.of(g=>g.docChanged?[]:g),L.theme({'input[type="color"]':{pointerEvents:"none"}})]:[sy(),P0(),b(this,bn).of(Zi.of(an.detectIndent(r,b(this,Ci),n))),hi.of([...py,ob,{win:"Ctrl-Shift-z",run:Tr,preventDefault:!0}])]];$e(this,N,new L({extensions:h,doc:r}));const{fontSize:f,lineHeight:u,border:d}=getComputedStyle(i);i.before(b(this,N).dom),ce(this,he,jr).call(this),b(this,N).dom.style.border=d,b(this,N).scrollDOM.style.fontSize=f,b(this,N).scrollDOM.style.lineHeight=u,this.toggle(!0),b(this,N).dom.addEventListener("click",an.foldHandler(b(this,N))),this.prefer({})}async setLanguage(t="plain",e){var i;if($e(this,We,t),b(this,N)){const n=ce(this,he,wl).call(this,e);ce(this,he,mt).call(this,[b(this,mn).reconfigure(n),b(this,Kt).reconfigure((i=hn[t])!=null?i:[])]),ce(this,he,jr).call(this,!!hn[t]),this.prefer({})}}lint(t){const e=t?[pb(async({state:i})=>{const n=await t(i);if(i.readOnly)for(const r of n)delete r.actions;return n}),Sb(),hi.of(fb),an.statusBar(this,t.fixer)]:[];t?hn[b(this,We)]=e:delete hn[b(this,We)],b(this,N)&&(ce(this,he,mt).call(this,b(this,Kt).reconfigure(e)),ce(this,he,jr).call(this,!!t))}update(){if(b(this,N)){const t=ce(this,he,_d).call(this);if(t){const e=b(this,N).plugin(t[1]);e.set=!0,e.force()}}}hasPreference(t){return b(this,Rt).has(t)}prefer(t){if(Array.isArray(t))$e(this,Rt,new Set(t.filter(e=>Object.prototype.hasOwnProperty.call(el,e))));else for(const[e,i]of Object.entries(t))i&&Object.prototype.hasOwnProperty.call(el,e)?b(this,Rt).add(e):b(this,Rt).delete(e);if(b(this,N)){const{readOnly:e}=b(this,N).state;ce(this,he,mt).call(this,b(this,vn).reconfigure([...b(this,Rt)].filter(i=>!e||!Cb.has(i)).map(i=>{const[n,r={}]=el[i];return n(r[b(this,We)],this)})))}}setIndent(t){b(this,N)?ce(this,he,mt).call(this,b(this,bn).reconfigure(Zi.of(an.detectIndent(b(this,N).state.doc,t,b(this,We))))):$e(this,Ci,t)}setLineWrapping(t){b(this,N)&&ce(this,he,mt).call(this,b(this,kn).reconfigure(t?L.lineWrapping:[]))}async getLinter(t){var e;return(e=Nr[b(this,We)])==null?void 0:e.call(Nr,t,b(this,N),b(this,Sn))}setContent(t,e){b(this,N)&&b(this,N).dispatch({changes:{from:0,to:b(this,N).state.doc.length,insert:t},filter:!e})}toggle(t=!b(this,Pt)){if(b(this,N)){if(t&&!b(this,Pt)){const{value:e,selectionStart:i,selectionEnd:n,scrollTop:r,offsetHeight:s,style:{height:o}}=b(this,Ve),l=document.activeElement===b(this,Ve);this.setContent(e),b(this,N).dom.style.height=s?`${s}px`:o,b(this,N).dom.style.removeProperty("display"),b(this,Ve).style.display="none",b(this,N).requestMeasure(),b(this,N).dispatch({selection:{anchor:i,head:n}}),l&&b(this,N).focus(),requestAnimationFrame(()=>{b(this,N).scrollDOM.scrollTop=r})}else if(!t&&b(this,Pt)){const{state:{selection:{main:{from:e,to:i,head:n}}},hasFocus:r}=b(this,N),{scrollDOM:{scrollTop:s}}=b(this,N);b(this,N).dom.style.setProperty("display","none","important"),b(this,Ve).style.display="",b(this,Ve).setSelectionRange(e,i,n===i?"forward":"backward"),r&&b(this,Ve).focus(),requestAnimationFrame(()=>{b(this,Ve).scrollTop=s})}}else return;$e(this,Pt,t)}destroy(){if(this.visible&&this.toggle(!1),b(this,N)){for(const t of bu)t(b(this,N));b(this,N).destroy()}Object.setPrototypeOf(this,null)}extraKeys(t){b(this,N)&&ce(this,he,mt).call(this,b(this,wn).reconfigure(hi.of(t)))}localize(t){Object.assign(tl,t),b(this,N)&&ce(this,he,mt).call(this,b(this,xn).reconfigure(ie.phrases.of(tl)))}getNodeAt(t){var e;return b(this,N)&&((e=b0(b(this,N).state,t))==null?void 0:e.resolve(t,1))}scrollTo(t){if(b(this,N)){const e=t!=null?t:b(this,N).state.selection.main,i=L.scrollIntoView(typeof e=="number"||e instanceof Di?e:w.range(e.anchor,e.head));i.value.isSnapshot=!0,b(this,N).dispatch({effects:i})}}static replaceSelections(t,e){const{state:i}=t;t.dispatch(i.changeByRange(({from:n,to:r})=>{const s=e(i.sliceDoc(n,r),{from:n,to:r});if(typeof s=="string")return{range:w.range(n,n+s.length),changes:{from:n,to:r,insert:s}};const[o,l,a=l]=s;return{range:w.range(l,a),changes:{from:n,to:r,insert:o}}}))}},Ve=new WeakMap,mn=new WeakMap,Kt=new WeakMap,vn=new WeakMap,yn=new WeakMap,bn=new WeakMap,wn=new WeakMap,xn=new WeakMap,kn=new WeakMap,N=new WeakMap,We=new WeakMap,Pt=new WeakMap,Rt=new WeakMap,Ci=new WeakMap,Sn=new WeakMap,he=new WeakSet,wl=function(t){var i;const e=((i=vu[b(this,We)])!=null?i:Zo)(t);return $e(this,Sn,e.nestedMWLanguage),e},mt=function(t){b(this,N).dispatch({effects:t})},jr=function(t){b(this,N).dom.style.minHeight=t?"calc(100px + 2em)":"2em"},_d=function(){return b(this,Kt).get(b(this,N).state)[0]},fd),Ir=(t,e)=>{const i=t.line(e.line+1);return Math.min(i.from+e.character,i.to)},Ab=tp(ip(),1);async function xu(t,e,i,n){const r=i&&("extends"in i||"rules"in i),s=r?i.rules:i,o=r&&"extends"in i&&i.extends!=="stylelint-config-recommended"&&!(Array.isArray(i.extends)&&i.extends.includes("stylelint-config-recommended"))?s!=null?s:{}:{...Ab.rules,...s},l={rules:o,computeEditInfo:!0,fix:n||!1};if(r&&(i.rules=o),n)return(await t.lint({code:e,config:l})).code;const[a]=(await t.lint({code:e,config:l})).results;return a.warnings.filter(({text:c})=>!c.startsWith("Unknown rule "))}var Fr=(t,e,i)=>i===void 0?Math.min(t[1],t[0]+Math.max(0,e)):e===-2?t[0]:e===0?t[1]:t[0]+i,ku=({type:t,tag:e},i)=>`${t==="ext-attr"?"div":e}#${i}{
|
|
14
|
-
`,Su=(t,e)=>{const i=t.slice(0,e).split(`
|
|
15
|
-
`);return{line:i.length-1,character:i[i.length-1].length}},Cu=t=>!!(t&&("extends"in t||"rules"in t)),Tb=async(t,e)=>{await Uc(t==null?void 0:t.getConfig,t==null?void 0:t.i18n);const i=Gc(e,t==null?void 0:t.include),n=await Mb(),r=async(s,o)=>{var p,g;const l=(p=o==null?void 0:o.defaultSeverity)!=null?p:2,a=(await i.provideDiagnostics(s)).filter(({code:m,severity:v})=>{var y;return Number((y=o==null?void 0:o[m])!=null?y:l)>+(v===2)}),c="findStyleTokens"in i&&(o==null?void 0:o["invalid-css"])!=="0"?await i.findStyleTokens():[];if(c.length===0)return a;const h=c.map((m,v)=>`${ku(m,v)}${rv(m.childNodes[1].childNodes[0].data).replace(/\n/gu," ")}
|
|
16
|
-
}`),f=o==null?void 0:o.css,u=Cu(f),d={};for(const[m,v]of Object.entries((g=u?f.rules:f)!=null?g:{}))v||(d[m]=v);return[...a,...(await n(h.join(`
|
|
17
|
-
`),u?{...f,rules:d}:d)).map(({line:m,column:v,endLine:y,endColumn:S,rule:k,severity:E,text:H,fix:C})=>{const B=Math.ceil(m/3),{length:V}=ku(c[B-1],B),{range:$}=c[B-1].childNodes[1].childNodes[0],I=Fr($,m-3*B,v-1),O={from:I,to:y===void 0?I:Fr($,y-3*B,S-1),severity:E==="error"?1:2,source:"Stylelint",code:k,message:H};if(C){const R=h.slice(0,B-1).join(`
|
|
18
|
-
`).length+1+V;O.data=[{range:{start:Su(s,Fr($,C.range[0]-R)),end:Su(s,Fr($,C.range[1]-R))},newText:C.text,title:"Fix: Stylelint",fix:!0}]}return O})]};return"resolveCodeAction"in i&&(r.fixer=async(s,o)=>(await i.resolveCodeAction(o)).edit.changes[""][0].newText),r},Mb=async(t="npm/@bhsd/stylelint-browserify")=>{await Po(t,"stylelint");const e=async(i,n)=>{const r=await xu(stylelint,i,n);return e.config=n&&!Cu(n)?{rules:n}:n,r};return e.fixer=(i,n)=>{var r,s;if(!e.config)throw new Error("Fixer unavailable!");return xu(stylelint,i,n?{extends:[],rules:{[n]:(s=(r=e.config.rules)==null?void 0:r[n])!=null?s:!0}}:e.config,!0)},e},Au=(t,e)=>typeof t=="function"?t(e):t,Tu=(t,e,i,n=0)=>{if(n===0)return Ir(t,{line:e-1,character:i-1});const r=t.lineAt(n);return Ir(t,{line:r.number+e-2,character:(e===1?n-r.from:0)+i-1})},Db=(t,e,i,n,r,s=0,o=1/0)=>{const l=Tu(t,e,i,s);return{from:l,to:n===void 0?Math.min(o,l+1):Tu(t,n,r,s)}},Ob=async(t,e,i,n,r=0,s)=>(await t(e,i)).map(({severity:o,code:l,message:a,range:c,from:h,to:f,data:u=[],source:d})=>({source:d,severity:o===2?"warning":"error",message:d==="Stylelint"?a:`${a} (${l})`,actions:u.map(({title:p,range:g,newText:m})=>({name:p,apply(v){v.dispatch({changes:{from:Ir(n,g.start),to:Ir(n,g.end),insert:m}})}})),...h===void 0?Db(n,c.start.line+1,c.start.character+1,c.end.line+1,c.end.character+1,r,s):{from:h+r,to:(f!=null?f:h)+r}})),Eb=async(t,e)=>{const i=await Tb(await Au(t),e),n=async({doc:r})=>Ob(i,r.toString(),await Au(t,!0),r);return i.fixer&&(n.fixer=(r,s)=>i.fixer("",s)),n},Lb={onlyinclude:"mediawiki",includeonly:"mediawiki",noinclude:"mediawiki",pre:"text/pre",nowiki:"text/nowiki",indicator:"mediawiki",poem:"mediawiki",ref:"mediawiki",references:"text/references",gallery:"text/gallery",poll:"mediawiki",tabs:"mediawiki",tab:"mediawiki",choose:"text/choose",option:"mediawiki",combobox:"text/combobox",combooption:"mediawiki",inputbox:"text/inputbox"},Bb=({variable:t,parserFunction:[e,i,...n],protocol:r,nsid:s,functionHook:o,variants:l,redirection:a,ext:c,doubleUnderscore:[h,f,u,d],img:p},g)=>({tags:Object.fromEntries(c.map(m=>[m,!0])),tagModes:g,doubleUnderscore:[Object.fromEntries((u&&h.length===0?Object.keys(u):h).map(m=>[`__${m}__`,!0])),Object.fromEntries((d&&f.length===0?Object.keys(d):f).map(m=>[`__${m}__`,!0]))],functionHooks:o,variableIDs:t,functionSynonyms:[{...e,...Object.fromEntries(n.flat().map(m=>[m,m]))},Array.isArray(i)?Object.fromEntries(i.map(m=>[m,m.toLowerCase()])):{...i}],urlProtocols:`${r}|//`,nsid:s,img:Object.fromEntries(Object.entries(p).map(([m,v])=>[m,`img_${v}`])),variants:l,redirection:a}),il=U.mark({class:"cm-bidi-isolate cm-bidi-ltr",bidiIsolate:oe.LTR}),Mu=U.mark({class:"cm-bidi-isolate"}),Du=({visibleRanges:t,state:e,textDirection:i})=>{const n=new ei;if(i===oe.RTL)for(const{from:r,to:s}of t){let o=Se(e).resolve(r,1),l=0,a=0,c=0;for(;o&&o.to<=s;){const{name:h,from:f,to:u,nextSibling:d}=o;if(/-(?:ext|html)tag-bracket/u.test(h)&&e.sliceDoc(f,u).includes("<")){const p=jv(e,d);p&&n.add(p.from,p.to,il)}else!l&&!a&&h.includes(M.tableDefinition)?/-html-(?:table|tr)/u.test(h)?(a=e.doc.lineAt(f).to,n.add(f,a,il)):l=f:a&&f>a?a=0:l&&h.includes(M.tableDelimiter2)?(n.add(l,f,il),l=0):/-(?:template|parserfunction)-delimiter/u.test(h)?(c&&n.add(c,f,Mu),c=u):c&&/-(?:template|parserfunction)-bracket/u.test(h)&&(e.sliceDoc(f,f+1)==="}"&&n.add(c,f,Mu),c=0);o=o.nextSibling}}return n.finish()},Pb=je.fromClass(class{constructor(t){this.isolates=Du(t),this.tree=Se(t.state),this.dir=t.textDirection}update({docChanged:t,viewportChanged:e,state:i,view:n}){const r=Se(i),{textDirection:s}=n;(t||e||r!==this.tree||s!==this.dir)&&(this.isolates=Du(n),this.tree=r,this.dir=s)}},{provide(t){const e=i=>{var n,r;return(r=(n=i.plugin(t))==null?void 0:n.isolates)!=null?r:U.none};return Ei.lowest([L.decorations.of(e),L.bidiIsolatedRanges.of(e)])}}),Rb=[{key:"Ctrl-8",pre:"<blockquote>",post:"</blockquote>",desc:"blockquote"},{key:"Mod-.",pre:"<sup>",post:"</sup>",desc:"sup"},{key:"Mod-,",pre:"<sub>",post:"</sub>",desc:"sub"},{key:"Ctrl-,",pre:"<sub>",post:"</sub>",desc:"sub"},{key:"Mod-Shift-6",pre:"<code>",post:"</code>",desc:"code"},{key:"Ctrl-Shift-5",pre:"<s>",post:"</s>",desc:"s"},{key:"Mod-u",pre:"<u>",post:"</u>",desc:"u"},{key:"Mod-k",pre:"[[",post:"]]",desc:"link"},{key:"Mod-i",pre:"''",post:"''",desc:"italic"},{key:"Mod-b",pre:"'''",post:"'''",desc:"bold"},{key:"Mod-Shift-k",pre:"<ref>",post:"</ref>",desc:"ref"},{key:"Mod-/",pre:"<!-- ",post:" -->",desc:"comment"},{key:"Ctrl-0",splitlines:!0,desc:"heading 0"},...new Array(6).fill(0).map((t,e)=>({key:`Ctrl-${e+1}`,pre:`${"=".repeat(e+1)} `,post:` ${"=".repeat(e+1)}`,splitlines:!0,desc:`heading ${e+1}`})),{key:"Ctrl-7",pre:" ",splitlines:!0,desc:"pre"}],Nb=(t,e,i)=>{const n=t.split(`
|
|
19
|
-
`);return n.map(r=>{var o,l;const s=((l=(o=/^(={1,6})(.+)\1\s*$/u.exec(r))==null?void 0:o[2])!=null?l:r).trim();return e===" "||n.length===1||r.trim()?e+s+i:s}).join(`
|
|
20
|
-
`)},Ib=({key:t,pre:e="",post:i="",splitlines:n})=>({key:t,run(r){const{state:s}=r;return r.dispatch(s.changeByRange(({from:o,to:l})=>{if(n){const h=s.doc.lineAt(o).from,f=s.doc.lineAt(l).to,u=Nb(s.sliceDoc(h,f),e,i);return{range:w.range(h,h+u.length),changes:{from:h,to:f,insert:u}}}const a=e+s.sliceDoc(o,l)+i,c=o+a.length;return{range:o===l?w.range(o+e.length,c-i.length):w.range(c,c),changes:{from:o,to:l,insert:a}}})),!0},preventDefault:!0}),Fb=hi.of(Rb.map(Ib)),Hb=(()=>{const t=document.createElement("div");return t.textContent="Fix all auto-fixable problems",t})();function nl(t,e,i){const n=document.createElement("div"),r=document.createElement("div");if(n.className=`cm-status-${e}`,e==="fix")r.className="cm-status-fix-disabled",n.title="Fix all",n.append(r),i&&n.addEventListener("click",({clientX:s,clientY:o})=>{if(r.className==="cm-status-fix-enabled"){const{bottom:l,left:a}=t.dom.getBoundingClientRect();i.style.bottom=`${l-o+5}px`,i.style.left=`${s-20-a}px`,i.style.display="block",i.focus()}});else{r.className=`cm-lint-marker-${e}`;const s=document.createElement("div");s.textContent="0",n.append(r,s),n.addEventListener("click",()=>{var o;(o=n.parentElement)!=null&&o.classList.contains("cm-status-worker-enabled")&&(hu(t),t.focus())})}return n}var Ou=(t,e,i)=>{i.lastChild.textContent=String(t.filter(({severity:n})=>n===e).length)},Vb=t=>{var e;return(e=t.actions)==null?void 0:e.some(({name:i})=>i==="fix"||i.startsWith("Fix:"))},Wb=(t,{name:e,isActionable:i})=>t.hasPreference(e)&&i(t),Eu=(t,e)=>{t.toggle("cm-status-fix-enabled",e),t.toggle("cm-status-fix-disabled",!e)},Lu=(t,e)=>t.filter(({from:i,to:n})=>i<=e.to&&n>=e.from),Bu=(t,e,i,n)=>{var s;const r=Lu(e,i);if(r.length===0)n.textContent="";else{const o=(s=r.find(({from:a,to:c})=>a<=i.head&&c>=i.head))!=null?s:r[0],l=t.view;n.textContent=o.message,o.actions&&n.append(...o.actions.map(({name:a,apply:c})=>{const h=document.createElement("button");return h.type="button",h.className="cm-diagnosticAction",h.textContent=a,h.addEventListener("click",f=>{f.preventDefault(),c(l,o.from,o.to)}),h}))}},Pu=(t,e,i,n,r,s)=>{if(r){const o=yu.filter(h=>Wb(t,h)),l=new Set(s&&Lu(e,i).filter(Vb).map(({message:h})=>{var f;return(f=/ \(([^()]+)\)$/u.exec(h))==null?void 0:f[1]}).filter(Boolean));if(o.length===0&&l.size===0){Eu(n,!1);return}Eu(n,!0);const a=o.flatMap(({getItems:h})=>h(t)),c=[...l].map(h=>{const f=document.createElement("div");return f.textContent=`Fix all ${h} problems`,f.dataset.rule=h,f});l.size>0&&c.push(Hb),r.replaceChildren(...a,...c)}},$b=(t,e)=>ci.of(i=>{let n=[],r;!i.state.readOnly&&(e||yu.length>0)&&(r=document.createElement("div"),r.className="cm-status-fix-menu",r.tabIndex=-1,e&&r.addEventListener("click",({target:d})=>{d!==r&&(async()=>{const{doc:p}=i.state,g=await e(p,d.dataset.rule);g!==p.toString()&&i.dispatch({changes:{from:0,to:p.length,insert:g}}),i.focus()})()}),r.addEventListener("focusout",()=>{r.style.display="none"}),i.dom.append(r));const s=document.createElement("div"),o=document.createElement("div"),l=document.createElement("div"),a=document.createElement("div"),c=nl(i,"error"),h=nl(i,"warning"),f=nl(i,"fix",r),{classList:u}=f.firstChild;return o.className="cm-status-worker",o.append(c,h,f),l.className="cm-status-message",a.className="cm-status-line",a.textContent="0:0",s.className="cm-panel cm-panel-status",s.append(o,l,a),{dom:s,update({state:{selection:{main:d},doc:p},transactions:g,docChanged:m,selectionSet:v}){for(const y of g)for(const S of y.effects)S.is(ln)&&(n=S.value,o.classList.toggle("cm-status-worker-enabled",n.length>0),Ou(n,"error",c),Ou(n,"warning",h),Bu(t,n,d,l),Pu(t,n,d,u,r,e));if(m||v){Bu(t,n,d,l),Pu(t,n,d,u,r,e);const{number:y,from:S}=p.lineAt(d.head);a.textContent=`${y}:${d.head-S}`,d.empty||(a.textContent+=` (${d.to-d.from})`)}}}}),zb=(t,e)=>{Nr[t]=e,an.statusBar=$b},_b=()=>{wu.getMwConfig=t=>Bb(t,Lb),vu.mediawiki=t=>[Jv(t),Zo(),Pb,Fb],zb("mediawiki",Eb),bu.push(t=>{var e;return(e=Gc(t))==null?void 0:e.destroy()})};_b();/**
|
|
21
|
-
* @file Configuration for the MediaWiki highlighting mode for CodeMirror.
|
|
22
|
-
* @author MusikAnimal and others
|
|
23
|
-
* @license GPL-2.0-or-later
|
|
24
|
-
* @see https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror
|
|
25
|
-
*//**
|
|
26
|
-
* @author pastakhov, MusikAnimal, Bhsd and others
|
|
27
|
-
* @license GPL-2.0-or-later
|
|
28
|
-
* @see https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror
|
|
29
|
-
*//**
|
|
30
|
-
* @author MusikAnimal, Bhsd and others
|
|
31
|
-
* @license GPL-2.0-or-later
|
|
32
|
-
* @see https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror
|
|
33
|
-
*//**
|
|
34
|
-
* @author MusikAnimal
|
|
35
|
-
* @license GPL-2.0-or-later
|
|
36
|
-
* @see https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror
|
|
37
|
-
*/export{wu as CodeMirror6};
|