@bhsd/codemirror-mediawiki
Version:
Modified CodeMirror mode based on wikimedia/mediawiki-extensions-CodeMirror
5 lines • 688 kB
JavaScript
var cy=Object.create;var _o=Object.defineProperty;var fy=Object.getOwnPropertyDescriptor;var Bc=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Bi=t=>{throw TypeError(t)};var uy=(t,e,i)=>e in t?_o(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var _c=(t,e)=>_o(t,"name",{value:e,configurable:!0});var Lc=t=>{var e;return[,,,cy((e=t==null?void 0:t[Bc("metadata")])!=null?e:null)]},jc=["class","method","getter","setter","accessor","field","value","get","set"],Zr=t=>t!==void 0&&typeof t!="function"?Bi("Function expected"):t,dy=(t,e,i,r,n)=>({kind:jc[t],name:e,metadata:r,addInitializer:s=>i._?Bi("Already initialized"):n.push(Zr(s||null))}),Bo=(t,e)=>uy(e,Bc("metadata"),t[3]),Nc=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)e&1?s[n].call(i):r=s[n].call(i,r);return r},H=(t,e,i,r,n,s)=>{var o,a,l,h,c,f=e&7,u=!!(e&8),d=!!(e&16),p=f>3?t.length+1:f?u?1:2:0,O=jc[f+5],g=f>3&&(t[p-1]=[]),b=t[p]||(t[p]=[]),v=f&&(!d&&!u&&(n=n.prototype),f<5&&(f>3||!d)&&fy(f<4?n:{get[i](){return Q(this,s)},set[i](y){return ct(this,s,y)}},i));f?d&&f<4&&_c(s,(f>2?"set ":f>1?"get ":"")+i):_c(n,i);for(var S=r.length-1;S>=0;S--)h=dy(f,i,l={},t[3],b),f&&(h.static=u,h.private=d,c=h.access={has:d?y=>py(n,y):y=>i in y},f^3&&(c.get=d?y=>(f^1?Q:ke)(y,n,f^4?s:v.get):y=>y[i]),f>2&&(c.set=d?(y,x)=>ct(y,n,x,f^4?s:v.set):(y,x)=>y[i]=x)),a=(0,r[S])(f?f<4?d?s:v[O]:f>4?void 0:{get:v.get,set:v.set}:n,h),l._=1,f^4||a===void 0?Zr(a)&&(f>4?g.unshift(a):f?d?s=a:v[O]=a:n=a):typeof a!="object"||a===null?Bi("Object expected"):(Zr(o=a.get)&&(v.get=o),Zr(o=a.set)&&(v.set=o),Zr(o=a.init)&&g.unshift(o));return f||Bo(t,n),v&&_o(n,i,v),d?f^4?s:v:n};var Lo=(t,e,i)=>e.has(t)||Bi("Cannot "+i),py=(t,e)=>Object(e)!==e?Bi('Cannot use the "in" operator on this value'):t.has(e),Q=(t,e,i)=>(Lo(t,e,"read from private field"),i?i.call(t):e.get(t)),Se=(t,e,i)=>e.has(t)?Bi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),ct=(t,e,i,r)=>(Lo(t,e,"write to private field"),r?r.call(t,i):e.set(t,i),i),ke=(t,e,i)=>(Lo(t,e,"access private method"),i);var Ib,Gb,Ub,Fb,Hb,Kb,Jb,ev,tv,iv,rv,nv,sv,ov,av,lv,hv,cv,fv,uv,dv,pv,Ov,mv,gv,bv,vv,yv,Sv,kv,F,I,Vi,Dc,oy,wv,lt,qn,Yi,Dn,Yn,Vn,_n,Bn,Ln,jn,V,ht,Si,ki,Cr,Nn,ve,Yc,ei,Vo,hy,xv,Qv,Pv,$v,Oy=Object.create,zc=Object.defineProperty,my=Object.getOwnPropertyDescriptor,Ic=Object.getOwnPropertyNames,gy=Object.getPrototypeOf,by=Object.prototype.hasOwnProperty,vy=(t,e)=>function(){return e||(0,t[Ic(t)[0]])((e={exports:{}}).exports,e),e.exports},yy=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ic(e))!by.call(t,n)&&n!==i&&zc(t,n,{get:()=>e[n],enumerable:!(r=my(e,n))||r.enumerable});return t},Sy=(t,e,i)=>(i=t!=null?Oy(gy(t)):{},yy(e||!t||!t.__esModule?zc(i,"default",{value:t,enumerable:!0}):i,t)),ky=vy({"../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}}}}),jo=[],Gc=[];(()=>{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?Gc:jo).push(i=i+t[e])})();function wy(t){if(t<768)return!1;for(let e=0,i=jo.length;;){let r=e+i>>1;if(t<jo[r])i=r;else if(t>=Gc[r])e=r+1;else return!0;if(e==i)return!1}}function Uc(t){return t>=127462&&t<=127487}var Fc=8205;function xy(t,e,i=!0,r=!0){return(i?Hc:Qy)(t,e,r)}function Hc(t,e,i){if(e==t.length)return e;e&&Kc(t.charCodeAt(e))&&Jc(t.charCodeAt(e-1))&&e--;let r=No(t,e);for(e+=ef(r);e<t.length;){let n=No(t,e);if(r==Fc||n==Fc||i&&wy(n))e+=ef(n),r=n;else if(Uc(n)){let s=0,o=e-2;for(;o>=0&&Uc(No(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function Qy(t,e,i){for(;e>0;){let r=Hc(t,e-2,i);if(r<e)return r;e--}return 0}function No(t,e){let i=t.charCodeAt(e);if(!Jc(i)||e+1==t.length)return i;let r=t.charCodeAt(e+1);return Kc(r)?(i-55296<<10)+(r-56320)+65536:i}function Kc(t){return t>=56320&&t<57344}function Jc(t){return t>=55296&&t<56320}function ef(t){return t<65536?1:2}var G=class Tv{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,r){[e,i]=Li(this,e,i);let n=[];return this.decompose(0,e,n,2),r.length&&r.decompose(0,r.length,n,3),this.decompose(i,this.length,n,1),In.from(n,this.length-(i-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,i=this.length){[e,i]=Li(this,e,i);let r=[];return this.decompose(e,i,r,0),In.from(r,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),r=this.length-this.scanIdentical(e,-1),n=new Ar(this),s=new Ar(e);for(let o=i,a=i;;){if(n.next(o),s.next(o),o=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(a+=n.value.length,n.done||a>=r)return!0}}iter(e=1){return new Ar(this,e)}iterRange(e,i=this.length){return new rf(this,e,i)}iterLines(e,i){let r;if(e==null)r=this.iter();else{i==null&&(i=this.lines+1);let n=this.line(e).from;r=this.iterRange(n,Math.max(n,i==this.lines+1?this.length:i<=1?0:this.line(i-1).to))}return new nf(r)}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]?Tv.empty:e.length<=32?new ft(e):In.from(ft.split(e,[]))}},ft=class Vt extends G{constructor(e,i=Py(e)){super(),this.text=e,this.length=i}get lines(){return this.text.length}get children(){return null}lineInner(e,i,r,n){for(let s=0;;s++){let o=this.text[s],a=n+o.length;if((i?r:a)>=e)return new $y(n,a,r,o);n=a+1,r++}}decompose(e,i,r,n){let s=e<=0&&i>=this.length?this:new Vt(tf(this.text,e,i),Math.min(i,this.length)-Math.max(0,e));if(n&1){let o=r.pop(),a=Gn(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new Vt(a,o.length+s.length));else{let l=a.length>>1;r.push(new Vt(a.slice(0,l)),new Vt(a.slice(l)))}}else r.push(s)}replace(e,i,r){if(!(r instanceof Vt))return super.replace(e,i,r);[e,i]=Li(this,e,i);let n=Gn(this.text,Gn(r.text,tf(this.text,0,e)),i),s=this.length+r.length-(i-e);return n.length<=32?new Vt(n,s):In.from(Vt.split(n,[]),s)}sliceString(e,i=this.length,r=`
`){[e,i]=Li(this,e,i);let n="";for(let s=0,o=0;s<=i&&o<this.text.length;o++){let a=this.text[o],l=s+a.length;s>e&&o&&(n+=r),e<l&&i>s&&(n+=a.slice(Math.max(0,e-s),i-s)),s=l+1}return n}flatten(e){for(let i of this.text)e.push(i)}scanIdentical(){return 0}static split(e,i){let r=[],n=-1;for(let s of e)r.push(s),n+=s.length+1,r.length==32&&(i.push(new Vt(r,n)),r=[],n=-1);return n>-1&&i.push(new Vt(r,n)),i}},In=class Tr extends G{constructor(e,i){super(),this.children=e,this.length=i,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,i,r,n){for(let s=0;;s++){let o=this.children[s],a=n+o.length,l=r+o.lines-1;if((i?l:a)>=e)return o.lineInner(e,i,r,n);n=a+1,r=l+1}}decompose(e,i,r,n){for(let s=0,o=0;o<=i&&s<this.children.length;s++){let a=this.children[s],l=o+a.length;if(e<=l&&i>=o){let h=n&((o<=e?1:0)|(l>=i?2:0));o>=e&&l<=i&&!h?r.push(a):a.decompose(e-o,i-o,r,h)}o=l+1}}replace(e,i,r){if([e,i]=Li(this,e,i),r.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],a=s+o.length;if(e>=s&&i<=a){let l=o.replace(e-s,i-s,r),h=this.lines-o.lines+l.lines;if(l.lines<h>>4&&l.lines>h>>6){let c=this.children.slice();return c[n]=l,new Tr(c,this.length-(i-e)+r.length)}return super.replace(s,a,l)}s=a+1}return super.replace(e,i,r)}sliceString(e,i=this.length,r=`
`){[e,i]=Li(this,e,i);let n="";for(let s=0,o=0;s<this.children.length&&o<=i;s++){let a=this.children[s],l=o+a.length;o>e&&s&&(n+=r),e<l&&i>o&&(n+=a.sliceString(e-o,i-o,r)),o=l+1}return n}flatten(e){for(let i of this.children)i.flatten(e)}scanIdentical(e,i){if(!(e instanceof Tr))return 0;let r=0,[n,s,o,a]=i>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=i,s+=i){if(n==o||s==a)return r;let l=this.children[n],h=e.children[s];if(l!=h)return r+l.scanIdentical(h,i);r+=l.length+1}}static from(e,i=e.reduce((r,n)=>r+n.length+1,-1)){let r=0;for(let d of e)r+=d.lines;if(r<32){let d=[];for(let p of e)p.flatten(d);return new ft(d,i)}let n=Math.max(32,r>>5),s=n<<1,o=n>>1,a=[],l=0,h=-1,c=[];function f(d){let p;if(d.lines>s&&d instanceof Tr)for(let O of d.children)f(O);else d.lines>o&&(l>o||!l)?(u(),a.push(d)):d instanceof ft&&l&&(p=c[c.length-1])instanceof ft&&d.lines+p.lines<=32?(l+=d.lines,h+=d.length+1,c[c.length-1]=new ft(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>n&&u(),l+=d.lines,h+=d.length+1,c.push(d))}function u(){l!=0&&(a.push(c.length==1?c[0]:Tr.from(c,h)),h=-1,l=c.length=0)}for(let d of e)f(d);return u(),a.length==1?a[0]:new Tr(a,i)}};G.empty=new ft([""],0);function Py(t){let e=-1;for(let i of t)e+=i.length+1;return e}function Gn(t,e,i=0,r=1e9){for(let n=0,s=0,o=!0;s<t.length&&n<=r;s++){let a=t[s],l=n+a.length;l>=i&&(l>r&&(a=a.slice(0,r-n)),n<i&&(a=a.slice(i-n)),o?(e[e.length-1]+=a,o=!1):e.push(a)),n=l+1}return e}function tf(t,e,i){return Gn(t,[""],e,i)}var Ar=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 ft?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],n=this.offsets[i],s=n>>1,o=r instanceof ft?r.text.length:r.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((n&1)==(e>0?0:1)){if(this.offsets[i]+=e,t==0)return this.lineBreak=!0,this.value=`
`,this;t--}else if(r instanceof ft){let a=r.text[s+(e<0?-1:0)];if(this.offsets[i]+=e,a.length>Math.max(0,t))return this.value=t==0?a:e>0?a.slice(t):a.slice(0,a.length-t),this;t-=a.length}else{let a=r.children[s+(e<0?-1:0)];t>a.length?(t-=a.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(e>0?1:(a instanceof ft?a.text.length:a.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}},rf=class{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new Ar(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:r}=this.cursor.next(t);return this.pos+=(r.length+t)*e,this.value=r.length<=i?r:e<0?r.slice(r.length-i):r.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!=""}},nf=class{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:r}=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=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol!="undefined"&&(G.prototype[Symbol.iterator]=function(){return this.iter()},Ar.prototype[Symbol.iterator]=rf.prototype[Symbol.iterator]=nf.prototype[Symbol.iterator]=function(){return this});var $y=class{constructor(t,e,i,r){this.from=t,this.to=e,this.number=i,this.text=r}get length(){return this.to-this.from}};function Li(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,r=!0){return xy(t,e,i,r)}function Ty(t){return t>=56320&&t<57344}function Cy(t){return t>=55296&&t<56320}function He(t,e){let i=t.charCodeAt(e);if(!Cy(i)||e+1==t.length)return i;let r=t.charCodeAt(e+1);return Ty(r)?(i-55296<<10)+(r-56320)+65536:i}function zo(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function Bt(t){return t<65536?1:2}var Io=/\r\n?|\n/,$e=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})($e||($e={})),ji=class Xo{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 r=this.sections[i+1];e+=r<0?this.sections[i]:r}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let i=0,r=0,n=0;i<this.sections.length;){let s=this.sections[i++],o=this.sections[i++];o<0?(e(r,n,s),n+=s):n+=o,r+=s}}iterChangedRanges(e,i=!1){Go(this,e,i)}get invertedDesc(){let e=[];for(let i=0;i<this.sections.length;){let r=this.sections[i++],n=this.sections[i++];n<0?e.push(r,n):e.push(n,r)}return new Xo(e)}composeDesc(e){return this.empty?e:e.empty?this:sf(this,e)}mapDesc(e,i=!1){return e.empty?this:Uo(this,e,i)}mapPos(e,i=-1,r=$e.Simple){let n=0,s=0;for(let o=0;o<this.sections.length;){let a=this.sections[o++],l=this.sections[o++],h=n+a;if(l<0){if(h>e)return s+(e-n);s+=a}else{if(r!=$e.Simple&&h>=e&&(r==$e.TrackDel&&n<e&&h>e||r==$e.TrackBefore&&n<e||r==$e.TrackAfter&&h>e))return null;if(h>e||h==e&&i<0&&!a)return e==n||i<0?s:s+l;s+=l}n=h}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return s}touchesRange(e,i=e){for(let r=0,n=0;r<this.sections.length&&n<=i;){let s=this.sections[r++],o=this.sections[r++],a=n+s;if(o>=0&&n<=i&&a>=e)return n<e&&a>i?"cover":!0;n=a}return!1}toString(){let e="";for(let i=0;i<this.sections.length;){let r=this.sections[i++],n=this.sections[i++];e+=(e?" ":"")+r+(n>=0?":"+n:"")}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 Xo(e)}static create(e){return new Xo(e)}},ut=class yi extends ji{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 Go(this,(i,r,n,s,o)=>e=e.replace(n,n+(r-i),o),!1),e}mapDesc(e,i=!1){return Uo(this,e,i,!0)}invert(e){let i=this.sections.slice(),r=[];for(let n=0,s=0;n<i.length;n+=2){let o=i[n],a=i[n+1];if(a>=0){i[n]=a,i[n+1]=o;let l=n>>1;for(;r.length<l;)r.push(G.empty);r.push(o?e.slice(s,s+o):G.empty)}s+=o}return new yi(i,r)}compose(e){return this.empty?e:e.empty?this:sf(this,e,!0)}map(e,i=!1){return e.empty?this:Uo(this,e,i,!0)}iterChanges(e,i=!1){Go(this,e,i)}get desc(){return ji.create(this.sections)}filter(e){let i=[],r=[],n=[],s=new Rr(this);e:for(let o=0,a=0;;){let l=o==e.length?1e9:e[o++];for(;a<l||a==l&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,l-a);Te(n,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;Te(i,c,f),f>0&&ti(r,i,s.text),s.forward(c),a+=c}let h=e[o++];for(;a<h;){if(s.done)break e;let c=Math.min(s.len,h-a);Te(i,c,-1),Te(n,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),a+=c}}return{changes:new yi(i,r),filtered:ji.create(n)}}toJSON(){let e=[];for(let i=0;i<this.sections.length;i+=2){let r=this.sections[i],n=this.sections[i+1];n<0?e.push(r):n==0?e.push([r]):e.push([r].concat(this.inserted[i>>1].toJSON()))}return e}static of(e,i,r){let n=[],s=[],o=0,a=null;function l(c=!1){if(!c&&!n.length)return;o<i&&Te(n,i-o,-1);let f=new yi(n,s);a=a?a.compose(f.map(a)):f,n=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof yi){if(c.length!=i)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${i})`);l(),a=a?a.compose(c.map(a)):c}else{let{from:f,to:u=f,insert:d}=c;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"?G.of(d.split(r||Io)):d:G.empty,O=p.length;if(f==u&&O==0)return;f<o&&l(),f>o&&Te(n,f-o,-1),Te(n,u-f,O),ti(s,n,p),o=u}}return h(e),l(!a),a}static empty(e){return new yi(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let i=[],r=[];for(let n=0;n<e.length;n++){let s=e[n];if(typeof s=="number")i.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,a)=>a&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)i.push(s[0],0);else{for(;r.length<n;)r.push(G.empty);r[n]=G.of(s.slice(1)),i.push(s[0],r[n].length)}}}return new yi(i,r)}static createSet(e,i){return new yi(e,i)}};function Te(t,e,i,r=!1){if(e==0&&i<=0)return;let n=t.length-2;n>=0&&i<=0&&i==t[n+1]?t[n]+=e:n>=0&&e==0&&t[n]==0?t[n+1]+=i:r?(t[n]+=e,t[n+1]+=i):t.push(e,i)}function ti(t,e,i){if(i.length==0)return;let r=e.length-2>>1;if(r<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<r;)t.push(G.empty);t.push(i)}}function Go(t,e,i){let r=t.inserted;for(let n=0,s=0,o=0;o<t.sections.length;){let a=t.sections[o++],l=t.sections[o++];if(l<0)n+=a,s+=a;else{let h=n,c=s,f=G.empty;for(;h+=a,c+=l,l&&r&&(f=f.append(r[o-2>>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)a=t.sections[o++],l=t.sections[o++];e(n,h,s,c,f),n=h,s=c}}}function Uo(t,e,i,r=!1){let n=[],s=r?[]:null,o=new Rr(t),a=new Rr(e);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let h=Math.min(o.len,a.len);Te(n,h,-1),o.forward(h),a.forward(h)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len<o.len||a.len==o.len&&!i))){let h=a.len;for(Te(n,a.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&l<o.i&&o.len<=c&&(Te(n,0,o.ins),s&&ti(s,n,o.text),l=o.i),o.forward(c),h-=c}a.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(a.ins==-1){let f=Math.min(c,a.len);h+=f,c-=f,a.forward(f)}else if(a.ins==0&&a.len<c)c-=a.len,a.next();else break;Te(n,h,l<o.i?o.ins:0),s&&l<o.i&&ti(s,n,o.text),l=o.i,o.forward(o.len-c)}else{if(o.done&&a.done)return s?ut.createSet(n,s):ji.create(n);throw new Error("Mismatched change set lengths")}}}function sf(t,e,i=!1){let r=[],n=i?[]:null,s=new Rr(t),o=new Rr(e);for(let a=!1;;){if(s.done&&o.done)return n?ut.createSet(r,n):ji.create(r);if(s.ins==0)Te(r,s.len,0,a),s.next();else if(o.len==0&&!o.done)Te(r,0,o.ins,a),n&&ti(n,r,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let l=Math.min(s.len2,o.len),h=r.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;Te(r,l,c,a),n&&c&&ti(n,r,o.text)}else o.ins==-1?(Te(r,s.off?0:s.len,l,a),n&&ti(n,r,s.textBit(l))):(Te(r,s.off?0:s.len,o.off?0:o.ins,a),n&&!o.off&&ti(n,r,o.text));a=(s.ins>l||o.ins>=0&&o.len>l)&&(a||r.length>h),s.forward2(l),o.forward(l)}}}}var Rr=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?G.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?G.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)}},Xr=class bc{constructor(e,i,r){this.from=e,this.to=i,this.flags=r}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 r,n;return this.empty?r=n=e.mapPos(this.from,i):(r=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),r==this.from&&n==this.to?this:new bc(r,n,this.flags)}extend(e,i=e){if(e<=this.anchor&&i>=this.anchor)return k.range(e,i);let r=Math.abs(e-this.anchor)>Math.abs(i-this.anchor)?e:i;return k.range(this.anchor,r)}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 k.range(e.anchor,e.head)}static create(e,i,r){return new bc(e,i,r)}},k=class Ie{constructor(e,i){this.ranges=e,this.mainIndex=i}map(e,i=-1){return e.empty?this:Ie.create(this.ranges.map(r=>r.map(e,i)),this.mainIndex)}eq(e,i=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(e.ranges[r],i))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new Ie([this.main],0)}addRange(e,i=!0){return Ie.create([e].concat(this.ranges),i?0:this.mainIndex+1)}replaceRange(e,i=this.mainIndex){let r=this.ranges.slice();return r[i]=e,Ie.create(r,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 Ie(e.ranges.map(i=>Xr.fromJSON(i)),e.main)}static single(e,i=e){return new Ie([Ie.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 r=0,n=0;n<e.length;n++){let s=e[n];if(s.empty?s.from<=r:s.from<r)return Ie.normalized(e.slice(),i);r=s.to}return new Ie(e,i)}static cursor(e,i=0,r,n){return Xr.create(e,e,(i==0?0:i<0?8:16)|(r==null?7:Math.min(6,r))|(n!=null?n:16777215)<<6)}static range(e,i,r,n){let s=(r!=null?r:16777215)<<6|(n==null?7:Math.min(6,n));return i<e?Xr.create(i,e,48|s):Xr.create(e,i,(i>e?8:0)|s)}static normalized(e,i=0){let r=e[i];e.sort((n,s)=>n.from-s.from),i=e.indexOf(r);for(let n=1;n<e.length;n++){let s=e[n],o=e[n-1];if(s.empty?s.from<=o.to:s.from<o.to){let a=o.from,l=Math.max(s.to,o.to);n<=i&&i--,e.splice(--n,2,s.anchor>s.head?Ie.range(l,a):Ie.range(a,l))}}return new Ie(e,i)}};function of(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}var Fo=0,X=class Cv{constructor(e,i,r,n,s){this.combine=e,this.compareInput=i,this.compare=r,this.isStatic=n,this.id=Fo++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new Cv(e.combine||(i=>i),e.compareInput||((i,r)=>i===r),e.compare||(e.combine?(i,r)=>i===r:Ho),!!e.static,e.enables)}of(e){return new Un([],this,0,e)}compute(e,i){if(this.isStatic)throw new Error("Can't compute a static facet");return new Un(e,this,1,i)}computeN(e,i){if(this.isStatic)throw new Error("Can't compute a static facet");return new Un(e,this,2,i)}from(e,i){return i||(i=r=>r),this.compute([e],r=>i(r.field(e)))}};function Ho(t,e){return t==e||t.length==e.length&&t.every((i,r)=>i===e[r])}var Un=class{constructor(t,e,i,r){this.dependencies=t,this.facet=e,this.type=i,this.value=r,this.id=Fo++}dynamicSlot(t){var e;let i=this.value,r=this.facet.compareInput,n=this.id,s=t[n]>>1,o=this.type==2,a=!1,l=!1,h=[];for(let c of this.dependencies)c=="doc"?a=!0:c=="selection"?l=!0:(((e=t[c.id])!==null&&e!==void 0?e:1)&1)==0&&h.push(t[c.id]);return{create(c){return c.values[s]=i(c),1},update(c,f){if(a&&f.docChanged||l&&(f.docChanged||f.selection)||Ko(c,h)){let u=i(c);if(o?!af(u,c.values[s],r):!r(u,c.values[s]))return c.values[s]=u,1}return 0},reconfigure:(c,f)=>{let u,d=f.config.address[n];if(d!=null){let p=Hn(f,d);if(this.dependencies.every(O=>O instanceof X?f.facet(O)===c.facet(O):O instanceof me?f.field(O,!1)==c.field(O,!1):!0)||(o?af(u=i(c),p,r):r(u=i(c),p)))return c.values[s]=p,0}else u=i(c);return c.values[s]=u,1}}}};function af(t,e,i){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!i(t[r],e[r]))return!1;return!0}function Ko(t,e){let i=!1;for(let r of e)Mr(t,r)&1&&(i=!0);return i}function Zy(t,e,i){let r=i.map(l=>t[l.id]),n=i.map(l=>l.type),s=r.filter(l=>!(l&1)),o=t[e.id]>>1;function a(l){let h=[];for(let c=0;c<r.length;c++){let f=Hn(l,r[c]);if(n[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(l){for(let h of r)Mr(l,h);return l.values[o]=a(l),1},update(l,h){if(!Ko(l,s))return 0;let c=a(l);return e.compare(c,l.values[o])?0:(l.values[o]=c,1)},reconfigure(l,h){let c=Ko(l,r),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Ho(i,f))return l.values[o]=u,0;let d=a(l);return e.compare(d,u)?(l.values[o]=u,0):(l.values[o]=d,1)}}}var Fn=X.define({static:!0}),me=class Zv{constructor(e,i,r,n,s){this.id=e,this.createF=i,this.updateF=r,this.compareF=n,this.spec=s,this.provides=void 0}static define(e){let i=new Zv(Fo++,e.create,e.update,e.compare||((r,n)=>r===n),e);return e.provide&&(i.provides=e.provide(i)),i}create(e){let i=e.facet(Fn).find(r=>r.field==this);return((i==null?void 0:i.create)||this.createF)(e)}slot(e){let i=e[this.id]>>1;return{create:r=>(r.values[i]=this.create(r),1),update:(r,n)=>{let s=r.values[i],o=this.updateF(s,n);return this.compareF(s,o)?0:(r.values[i]=o,1)},reconfigure:(r,n)=>{let s=r.facet(Fn),o=n.facet(Fn),a;return(a=s.find(l=>l.field==this))&&a!=o.find(l=>l.field==this)?(r.values[i]=a.create(r),1):n.config.address[this.id]!=null?(r.values[i]=n.field(this),0):(r.values[i]=this.create(r),1)}}}init(e){return[this,Fn.of({field:this,create:e})]}get extension(){return this}},xi={lowest:4,low:3,default:2,high:1,highest:0};function Wr(t){return e=>new lf(e,t)}var Lt={highest:Wr(xi.highest),high:Wr(xi.high),default:Wr(xi.default),low:Wr(xi.low),lowest:Wr(xi.lowest)},lf=class{constructor(t,e){this.inner=t,this.prec=e}},dt=class Av{of(e){return new Jo(this,e)}reconfigure(e){return Av.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Jo=class{constructor(t,e){this.compartment=t,this.inner=e}},hf=class Rv{constructor(e,i,r,n,s,o){for(this.base=e,this.compartments=i,this.dynamicSlots=r,this.address=n,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<r.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,r){let n=[],s=Object.create(null),o=new Map;for(let u of Ay(e,i,o))u instanceof me?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let a=Object.create(null),l=[],h=[];for(let u of n)a[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=r==null?void 0:r.config.facets;for(let u in s){let d=s[u],p=d[0].facet,O=c&&c[u]||[];if(d.every(g=>g.type==0))if(a[p.id]=l.length<<1|1,Ho(O,d))l.push(r.facet(p));else{let g=p.combine(d.map(b=>b.value));l.push(r&&p.compare(g,r.facet(p))?r.facet(p):g)}else{for(let g of d)g.type==0?(a[g.id]=l.length<<1|1,l.push(g.value)):(a[g.id]=h.length<<1,h.push(b=>g.dynamicSlot(b)));a[p.id]=h.length<<1,h.push(g=>Zy(g,p,d))}}let f=h.map(u=>u(a));return new Rv(e,o,f,a,l,s)}};function Ay(t,e,i){let r=[[],[],[],[],[]],n=new Map;function s(o,a){let l=n.get(o);if(l!=null){if(l<=a)return;let h=r[l].indexOf(o);h>-1&&r[l].splice(h,1),o instanceof Jo&&i.delete(o.compartment)}if(n.set(o,a),Array.isArray(o))for(let h of o)s(h,a);else if(o instanceof Jo){if(i.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;i.set(o.compartment,h),s(h,a)}else if(o instanceof lf)s(o.inner,o.prec);else if(o instanceof me)r[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof Un)r[a].push(o),o.facet.extensions&&s(o.facet.extensions,xi.default);else{let h=o.extension;if(!h)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(h,a)}}return s(t,xi.default),r.reduce((o,a)=>o.concat(a))}function Mr(t,e){if(e&1)return 2;let i=e>>1,r=t.status[i];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[i]=4;let n=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|n}function Hn(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}var cf=X.define(),ea=X.define({combine:t=>t.some(e=>e),static:!0}),ff=X.define({combine:t=>t.length?t[0]:void 0,static:!0}),uf=X.define(),df=X.define(),pf=X.define(),Of=X.define({combine:t=>t.length?t[0]:!1}),jt=class{constructor(t,e){this.type=t,this.value=e}static define(){return new Ry}},Ry=class{of(t){return new jt(this,t)}},Xy=class{constructor(t){this.map=t}of(t){return new L(this,t)}},L=class Xv{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 Xv(this.type,i)}is(e){return this.type==e}static define(e={}){return new Xy(e.map||(i=>i))}static mapEffects(e,i){if(!e.length)return e;let r=[];for(let n of e){let s=n.map(i);s&&r.push(s)}return r}};L.reconfigure=L.define(),L.appendConfig=L.define();var Ae=class Cn{constructor(e,i,r,n,s,o){this.startState=e,this.changes=i,this.selection=r,this.effects=n,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&of(r,i.newLength),s.some(a=>a.type==Cn.time)||(this.annotations=s.concat(Cn.time.of(Date.now())))}static create(e,i,r,n,s,o){return new Cn(e,i,r,n,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]=="."))}};Ae.time=jt.define(),Ae.userEvent=jt.define(),Ae.addToHistory=jt.define(),Ae.remote=jt.define();function Wy(t,e){let i=[];for(let r=0,n=0;;){let s,o;if(r<t.length&&(n==e.length||e[n]>=t[r]))s=t[r++],o=t[r++];else if(n<e.length)s=e[n++],o=e[n++];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 mf(t,e,i){var r;let n,s,o;return i?(n=e.changes,s=ut.empty(e.changes.length),o=t.changes.compose(e.changes)):(n=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(s):(r=t.selection)===null||r===void 0?void 0:r.map(n),effects:L.mapEffects(t.effects,n).concat(L.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function ta(t,e,i){let r=e.selection,n=Ni(e.annotations);return e.userEvent&&(n=n.concat(Ae.userEvent.of(e.userEvent))),{changes:e.changes instanceof ut?e.changes:ut.of(e.changes||[],i,t.facet(ff)),selection:r&&(r instanceof k?r:k.single(r.anchor,r.head)),effects:Ni(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function gf(t,e,i){let r=ta(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;r=mf(r,ta(t,e[s],o?r.changes.newLength:t.doc.length),o)}let n=Ae.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return Ey(i?My(n):n)}function My(t){let e=t.startState,i=!0;for(let n of e.facet(uf)){let s=n(t);if(s===!1){i=!1;break}Array.isArray(s)&&(i=i===!0?s:Wy(i,s))}if(i!==!0){let n,s;if(i===!1)s=t.changes.invertedDesc,n=ut.empty(e.doc.length);else{let o=t.changes.filter(i);n=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}t=Ae.create(e,n,t.selection&&t.selection.map(s),L.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let r=e.facet(df);for(let n=r.length-1;n>=0;n--){let s=r[n](t);s instanceof Ae?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Ae?t=s[0]:t=gf(e,Ni(s),!1)}return t}function Ey(t){let e=t.startState,i=e.facet(pf),r=t;for(let n=i.length-1;n>=0;n--){let s=i[n](t);s&&Object.keys(s).length&&(r=mf(r,ta(e,s,t.changes.newLength),!0))}return r==t?t:Ae.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}var qy=[];function Ni(t){return t==null?qy:Array.isArray(t)?t:[t]}var ce=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ce||(ce={})),Dy=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,ia;try{ia=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Yy(t){if(ia)return ia.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||Dy.test(i)))return!0}return!1}function Vy(t){return e=>{if(!/\S/.test(e))return ce.Space;if(Yy(e))return ce.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return ce.Word;return ce.Other}}var ae=class Qt{constructor(e,i,r,n,s,o){this.config=e,this.doc=i,this.selection=r,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)Mr(this,a<<1);this.computeSlot=null}field(e,i=!0){let r=this.config.address[e.id];if(r==null){if(i)throw new RangeError("Field is not present in this state");return}return Mr(this,r),Hn(this,r)}update(...e){return gf(this,e,!0)}applyTransaction(e){let i=this.config,{base:r,compartments:n}=i;for(let a of e.effects)a.is(dt.reconfigure)?(i&&(n=new Map,i.compartments.forEach((l,h)=>n.set(h,l)),i=null),n.set(a.value.compartment,a.value.extension)):a.is(L.reconfigure)?(i=null,r=a.value):a.is(L.appendConfig)&&(i=null,r=Ni(r).concat(a.value));let s;i?s=e.startState.values.slice():(i=hf.resolve(r,n,this),s=new Qt(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(l,h)=>h.reconfigure(l,this),null).values);let o=e.startState.facet(ea)?e.newSelection:e.newSelection.asSingle();new Qt(i,e.newDoc,o,s,(a,l)=>l.update(a,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:k.cursor(i.from+e.length)}))}changeByRange(e){let i=this.selection,r=e(i.ranges[0]),n=this.changes(r.changes),s=[r.range],o=Ni(r.effects);for(let a=1;a<i.ranges.length;a++){let l=e(i.ranges[a]),h=this.changes(l.changes),c=h.map(n);for(let u=0;u<a;u++)s[u]=s[u].map(c);let f=n.mapDesc(h,!0);s.push(l.range.map(f)),n=n.compose(c),o=L.mapEffects(o,c).concat(L.mapEffects(Ni(l.effects),f))}return{changes:n,selection:k.create(s,i.mainIndex),effects:o}}changes(e=[]){return e instanceof ut?e:ut.of(e,this.doc.length,this.facet(Qt.lineSeparator))}toText(e){return G.of(e.split(this.facet(Qt.lineSeparator)||Io))}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:(Mr(this,i),Hn(this,i))}toJSON(e){let i={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let r in e){let n=e[r];n instanceof me&&this.config.address[n.id]!=null&&(i[r]=n.spec.toJSON(this.field(e[r]),this))}return i}static fromJSON(e,i={},r){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(r){for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)){let o=r[s],a=e[s];n.push(o.init(l=>o.spec.fromJSON(a,l)))}}return Qt.create({doc:e.doc,selection:k.fromJSON(e.selection),extensions:i.extensions?n.concat([i.extensions]):n})}static create(e={}){let i=hf.resolve(e.extensions||[],new Map),r=e.doc instanceof G?e.doc:G.of((e.doc||"").split(i.staticFacet(Qt.lineSeparator)||Io)),n=e.selection?e.selection instanceof k?e.selection:k.single(e.selection.anchor,e.selection.head):k.single(0);return of(n,r.length),i.staticFacet(ea)||(n=n.asSingle()),new Qt(i,r,n,i.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Qt.tabSize)}get lineBreak(){return this.facet(Qt.lineSeparator)||`
`}get readOnly(){return this.facet(Of)}phrase(e,...i){for(let r of this.facet(Qt.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return i.length&&(e=e.replace(/\$(\$|\d*)/g,(r,n)=>{if(n=="$")return"$";let s=+(n||1);return!s||s>i.length?r:i[s-1]})),e}languageDataAt(e,i,r=-1){let n=[];for(let s of this.facet(cf))for(let o of s(this,i,r))Object.prototype.hasOwnProperty.call(o,e)&&n.push(o[e]);return n}charCategorizer(e){return Vy(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:i,from:r,length:n}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-r,a=e-r;for(;o>0;){let l=Pe(i,o,!1);if(s(i.slice(l,o))!=ce.Word)break;o=l}for(;a<n;){let l=Pe(i,a);if(s(i.slice(a,l))!=ce.Word)break;a=l}return o==a?null:k.range(o+r,a+r)}};ae.allowMultipleSelections=ea,ae.tabSize=X.define({combine:t=>t.length?t[0]:4}),ae.lineSeparator=ff,ae.readOnly=Of,ae.phrases=X.define({compare(t,e){let i=Object.keys(t),r=Object.keys(e);return i.length==r.length&&i.every(n=>t[n]==e[n])}}),ae.languageData=cf,ae.changeFilter=uf,ae.transactionFilter=df,ae.transactionExtender=pf,dt.reconfigure=L.define();function pt(t,e,i={}){let r={};for(let n of t)for(let s of Object.keys(n)){let o=n[s],a=r[s];if(a===void 0)r[s]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(i,s))r[s]=i[s](a,o);else throw new Error("Config merge conflict for field "+s)}for(let n in e)r[n]===void 0&&(r[n]=e[n]);return r}var Qi=class{eq(t){return this==t}range(t,e=t){return ra.create(t,e,this)}};Qi.prototype.startSide=Qi.prototype.endSide=0,Qi.prototype.point=!1,Qi.prototype.mapMode=$e.TrackDel;var ra=class Wv{constructor(e,i,r){this.from=e,this.to=i,this.value=r}static create(e,i,r){return new Wv(e,i,r)}};function na(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}var _y=class Mv{constructor(e,i,r,n){this.from=e,this.to=i,this.value=r,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(e,i,r,n=0){let s=r?this.to:this.from;for(let o=n,a=s.length;;){if(o==a)return o;let l=o+a>>1,h=s[l]-e||(r?this.value[l].endSide:this.value[l].startSide)-i;if(l==o)return h>=0?o:a;h>=0?a=l:o=l+1}}between(e,i,r,n){for(let s=this.findIndex(i,-1e9,!0),o=this.findIndex(r,1e9,!1,s);s<o;s++)if(n(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,i){let r=[],n=[],s=[],o=-1,a=-1;for(let l=0;l<this.value.length;l++){let h=this.value[l],c=this.from[l]+e,f=this.to[l]+e,u,d;if(c==f){let p=i.mapPos(c,h.startSide,h.mapMode);if(p==null||(u=d=p,h.startSide!=h.endSide&&(d=i.mapPos(c,h.endSide),d<u)))continue}else if(u=i.mapPos(c,h.startSide),d=i.mapPos(f,h.endSide),u>d||u==d&&h.startSide>0&&h.endSide<=0)continue;(d-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(a=Math.max(a,d-u)),r.push(h),n.push(u-o),s.push(d-o))}return{mapped:r.length?new Mv(n,s,r,a):null,pos:o}}},te=class Jt{constructor(e,i,r,n){this.chunkPos=e,this.chunk=i,this.nextLayer=r,this.maxPoint=n}static create(e,i,r,n){return new Jt(e,i,r,n)}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:r=!1,filterFrom:n=0,filterTo:s=this.length}=e,o=e.filter;if(i.length==0&&!o)return this;if(r&&(i=i.slice().sort(na)),this.isEmpty)return i.length?Jt.of(i):this;let a=new vf(this,null,-1).goto(0),l=0,h=[],c=new Nt;for(;a.value||l<i.length;)if(l<i.length&&(a.from-i[l].from||a.startSide-i[l].value.startSide)>=0){let f=i[l++];c.addInner(f.from,f.to,f.value)||h.push(f)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(l==i.length||this.chunkEnd(a.chunkIndex)<i[l].from)&&(!o||n>this.chunkEnd(a.chunkIndex)||s<this.chunkPos[a.chunkIndex])&&c.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!o||n>a.to||s<a.from||o(a.from,a.to,a.value))&&(c.addInner(a.from,a.to,a.value)||h.push(ra.create(a.from,a.to,a.value))),a.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?Jt.empty:this.nextLayer.update({add:h,filter:o,filterFrom:n,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let i=[],r=[],n=-1;for(let o=0;o<this.chunk.length;o++){let a=this.chunkPos[o],l=this.chunk[o],h=e.touchesRange(a,a+l.length);if(h===!1)n=Math.max(n,l.maxPoint),i.push(l),r.push(e.mapPos(a));else if(h===!0){let{mapped:c,pos:f}=l.map(a,e);c&&(n=Math.max(n,c.maxPoint),i.push(c),r.push(f))}}let s=this.nextLayer.map(e);return i.length==0?s:new Jt(r,i,s||Jt.empty,n)}between(e,i,r){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],o=this.chunk[n];if(i>=s&&e<=s+o.length&&o.between(s,e-s,i-s,r)===!1)return}this.nextLayer.between(e,i,r)}}iter(e=0){return sa.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,i=0){return sa.from(e).goto(i)}static compare(e,i,r,n,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=i.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=bf(o,a,r),h=new Er(o,l,s),c=new Er(a,l,s);r.iterGaps((f,u,d)=>yf(h,f,c,u,d,n)),r.empty&&r.length==0&&yf(h,0,c,0,0,n)}static eq(e,i,r=0,n){n==null&&(n=999999999);let s=e.filter(c=>!c.isEmpty&&i.indexOf(c)<0),o=i.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let a=bf(s,o),l=new Er(s,a,0).goto(r),h=new Er(o,a,0).goto(r);for(;;){if(l.to!=h.to||!aa(l.active,h.active)||l.point&&(!h.point||!l.point.eq(h.point)))return!1;if(l.to>n)return!0;l.next(),h.next()}}static spans(e,i,r,n,s=-1){let o=new Er(e,null,s).goto(i),a=i,l=o.openStart;for(;;){let h=Math.min(o.to,r);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFrom<i?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,l);n.point(a,h,o.point,c,f,o.pointRank),l=Math.min(o.openEnd(h),c.length)}else h>a&&(n.span(a,h,o.active,l),l=o.openEnd(h));if(o.to>r)return l+(o.point&&o.to>r?1:0);a=o.to,o.next()}}static of(e,i=!1){let r=new Nt;for(let n of e instanceof ra?[e]:i?By(e):e)r.add(n.from,n.to,n.value);return r.finish()}static join(e){if(!e.length)return Jt.empty;let i=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let n=e[r];n!=Jt.empty;n=n.nextLayer)i=new Jt(n.chunkPos,n.chunk,i,Math.max(n.maxPoint,i.maxPoint));return i}};te.empty=new te([],[],null,-1);function By(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let r=t[i];if(na(e,r)>0)return t.slice().sort(na);e=r}return t}te.empty.nextLayer=te.empty;var Nt=class Ev{finishChunk(e){this.chunks.push(new _y(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,r){this.addInner(e,i,r)||(this.nextLayer||(this.nextLayer=new Ev)).add(e,i,r)}addInner(e,i,r){let n=e-this.lastTo||r.startSide-this.last.endSide;if(n<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return n<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=r,this.lastFrom=e,this.lastTo=i,this.value.push(r),r.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 r=i.value.length-1;return this.last=i.value[r],this.lastFrom=i.from[r]+e,this.lastTo=i.to[r]+e,!0}finish(){return this.finishInner(te.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let i=te.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,i}};function bf(t,e,i){let r=new Map;for(let s of t)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&r.set(s.chunk[o],s.chunkPos[o]);let n=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let a=r.get(s.chunk[o]);a!=null&&(i?i.mapPos(a):a)==s.chunkPos[o]&&!(i!=null&&i.touchesRange(a,a+s.chunk[o].length))&&n.add(s.chunk[o])}return n}var vf=class{constructor(t,e,i,r=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=r}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 r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<t||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}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}},sa=class qv{constructor(e){this.heap=e}static from(e,i=null,r=-1){let n=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=r&&n.push(new vf(o,i,r,s));return n.length==1?n[0]:new qv(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,i=-1e9){for(let r of this.heap)r.goto(e,i);for(let r=this.heap.length>>1;r>=0;r--)oa(this.heap,r);return this.next(),this}forward(e,i){for(let r of this.heap)r.forward(e,i);for(let r=this.heap.length>>1;r>=0;r--)oa(this.heap,r);(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(),oa(this.heap,0)}}};function oa(t,e){for(let i=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let n=t[r];if(r+1<t.length&&n.compare(t[r+1])>=0&&(n=t[r+1],r++),i.compare(n)<0)break;t[r]=i,t[e]=n,e=r}}var Er=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,th