@duckcodeailabs/dql-cli 0.1.7 → 0.1.8
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/dist/assets/dql-notebook/assets/codemirror-CHXCUnwU.js +11 -0
- package/dist/assets/dql-notebook/assets/index-BqahXnjO.js +158 -0
- package/dist/assets/dql-notebook/assets/react-CRB3T2We.js +32 -0
- package/dist/assets/dql-notebook/index.html +17 -0
- package/dist/commands/notebook.js +3 -3
- package/dist/commands/notebook.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
let zn=[],No=[];(()=>{let s="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,t=0;e<s.length;e++)(e%2?No:zn).push(t=t+s[e])})();function Va(s){if(s<768)return!1;for(let e=0,t=zn.length;;){let i=e+t>>1;if(s<zn[i])t=i;else if(s>=No[i])e=i+1;else return!0;if(e==t)return!1}}function rr(s){return s>=127462&&s<=127487}const or=8205;function za(s,e,t=!0,i=!0){return(t?Wo:Qa)(s,e,i)}function Wo(s,e,t){if(e==s.length)return e;e&&Fo(s.charCodeAt(e))&&Ho(s.charCodeAt(e-1))&&e--;let i=yn(s,e);for(e+=lr(i);e<s.length;){let n=yn(s,e);if(i==or||n==or||t&&Va(n))e+=lr(n),i=n;else if(rr(n)){let r=0,o=e-2;for(;o>=0&&rr(yn(s,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function Qa(s,e,t){for(;e>0;){let i=Wo(s,e-2,t);if(i<e)return i;e--}return 0}function yn(s,e){let t=s.charCodeAt(e);if(!Ho(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return Fo(i)?(t-55296<<10)+(i-56320)+65536:t}function Fo(s){return s>=56320&&s<57344}function Ho(s){return s>=55296&&s<56320}function lr(s){return s<65536?1:2}class E{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,t,i){[e,t]=Mt(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),De.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Mt(this,e,t);let i=[];return this.decompose(e,t,i,0),De.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new qt(this),r=new qt(e);for(let o=t,l=t;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(e=1){return new qt(this,e)}iterRange(e,t=this.length){return new Vo(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new zo(i)}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]?E.empty:e.length<=32?new U(e):De.from(U.split(e,[]))}}class U extends E{constructor(e,t=qa(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.text[r],l=n+o.length;if((t?i:l)>=e)return new Ka(n,l,i,o);n=l+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new U(ar(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),l=Ti(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new U(l,o.length+r.length));else{let a=l.length>>1;i.push(new U(l.slice(0,a)),new U(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof U))return super.replace(e,t,i);[e,t]=Mt(this,e,t);let n=Ti(this.text,Ti(i.text,ar(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new U(n,r):De.from(U.split(n,[]),r)}sliceString(e,t=this.length,i=`
|
|
2
|
+
`){[e,t]=Mt(this,e,t);let n="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(n+=i),e<a&&t>r&&(n+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,i.length==32&&(t.push(new U(i,n)),i=[],n=-1);return n>-1&&t.push(new U(i,n)),t}}class De extends E{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.children[r],l=n+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,n);n=l+1,i=a+1}}decompose(e,t,i,n){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let h=n&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=Mt(this,e,t),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let f=this.children.slice();return f[n]=a,new De(f,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
3
|
+
`){[e,t]=Mt(this,e,t);let n="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(n+=i),e<a&&t>o&&(n+=l.sliceString(e-o,t-o,i)),o=a+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof De))return 0;let i=0,[n,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==o||r==l)return i;let a=this.children[n],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new U(d,t)}let n=Math.max(32,i>>5),r=n<<1,o=n>>1,l=[],a=0,h=-1,f=[];function c(d){let p;if(d.lines>r&&d instanceof De)for(let g of d.children)c(g);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof U&&a&&(p=f[f.length-1])instanceof U&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,f[f.length-1]=new U(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>n&&u(),a+=d.lines,h+=d.length+1,f.push(d))}function u(){a!=0&&(l.push(f.length==1?f[0]:De.from(f,h)),h=-1,a=f.length=0)}for(let d of e)c(d);return u(),l.length==1?l[0]:new De(l,t)}}E.empty=new U([""],0);function qa(s){let e=-1;for(let t of s)e+=t.length+1;return e}function Ti(s,e,t=0,i=1e9){for(let n=0,r=0,o=!0;r<s.length&&n<=i;r++){let l=s[r],a=n+l.length;a>=t&&(a>i&&(l=l.slice(0,i-n)),n<t&&(l=l.slice(t-n)),o?(e[e.length-1]+=l,o=!1):e.push(l)),n=a+1}return e}function ar(s,e,t){return Ti(s,[""],e,t)}class qt{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof U?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,l=n instanceof U?n.text.length:n.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
4
|
+
`,this;e--}else if(n instanceof U){let a=n.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=n.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof U?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Vo{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new qt(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class zo{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(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<"u"&&(E.prototype[Symbol.iterator]=function(){return this.iter()},qt.prototype[Symbol.iterator]=Vo.prototype[Symbol.iterator]=zo.prototype[Symbol.iterator]=function(){return this});class Ka{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function Mt(s,e,t){return e=Math.max(0,Math.min(s.length,e)),[e,Math.max(e,Math.min(s.length,t))]}function te(s,e,t=!0,i=!0){return za(s,e,t,i)}function Ua(s){return s>=56320&&s<57344}function ja(s){return s>=55296&&s<56320}function $a(s,e){let t=s.charCodeAt(e);if(!ja(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return Ua(i)?(t-55296<<10)+(i-56320)+65536:t}function Ga(s){return s<65536?1:2}const Qn=/\r\n?|\n/;var ue=(function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s})(ue||(ue={}));class Fe{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,n,r),n+=r):n+=o,i+=r}}iterChangedRanges(e,t=!1){qn(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new Fe(e)}composeDesc(e){return this.empty?e:e.empty?this:Qo(this,e)}mapDesc(e,t=!1){return e.empty?this:Kn(this,e,t)}mapPos(e,t=-1,i=ue.Simple){let n=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=n+l;if(a<0){if(h>e)return r+(e-n);r+=l}else{if(i!=ue.Simple&&h>=e&&(i==ue.TrackDel&&n<e&&h>e||i==ue.TrackBefore&&n<e||i==ue.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==n||t<0?r:r+a;r+=a}n=h}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let r=this.sections[i++],o=this.sections[i++],l=n+r;if(o>=0&&n<=t&&l>=e)return n<e&&l>t?"cover":!0;n=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Fe(e)}static create(e){return new Fe(e)}}class X extends Fe{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return qn(this,(t,i,n,r,o)=>e=e.replace(n,n+(i-t),o),!1),e}mapDesc(e,t=!1){return Kn(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n<t.length;n+=2){let o=t[n],l=t[n+1];if(l>=0){t[n]=l,t[n+1]=o;let a=n>>1;for(;i.length<a;)i.push(E.empty);i.push(o?e.slice(r,r+o):E.empty)}r+=o}return new X(t,i)}compose(e){return this.empty?e:e.empty?this:Qo(this,e,!0)}map(e,t=!1){return e.empty?this:Kn(this,e,t,!0)}iterChanges(e,t=!1){qn(this,e,t)}get desc(){return Fe.create(this.sections)}filter(e){let t=[],i=[],n=[],r=new _t(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let f=Math.min(r.len,a-l);ee(n,f,-1);let c=r.ins==-1?-1:r.off==0?r.ins:0;ee(t,f,c),c>0&&je(i,t,r.text),r.forward(f),l+=f}let h=e[o++];for(;l<h;){if(r.done)break e;let f=Math.min(r.len,h-l);ee(t,f,-1),ee(n,f,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(f),l+=f}}return{changes:new X(t,i),filtered:Fe.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):n==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],o=0,l=null;function a(f=!1){if(!f&&!n.length)return;o<t&&ee(n,t-o,-1);let c=new X(n,r);l=l?l.compose(c.map(l)):c,n=[],r=[],o=0}function h(f){if(Array.isArray(f))for(let c of f)h(c);else if(f instanceof X){if(f.length!=t)throw new RangeError(`Mismatched change set length (got ${f.length}, expected ${t})`);a(),l=l?l.compose(f.map(l)):f}else{let{from:c,to:u=c,insert:d}=f;if(c>u||c<0||u>t)throw new RangeError(`Invalid change range ${c} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?E.of(d.split(i||Qn)):d:E.empty,g=p.length;if(c==u&&g==0)return;c<o&&a(),c>o&&ee(n,c-o,-1),ee(n,u-c,g),je(r,n,p),o=u}}return h(e),a(!l),l}static empty(e){return new X(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<n;)i.push(E.empty);i[n]=E.of(r.slice(1)),t.push(r[0],i[n].length)}}}return new X(t,i)}static createSet(e,t){return new X(e,t)}}function ee(s,e,t,i=!1){if(e==0&&t<=0)return;let n=s.length-2;n>=0&&t<=0&&t==s[n+1]?s[n]+=e:n>=0&&e==0&&s[n]==0?s[n+1]+=t:i?(s[n]+=e,s[n+1]+=t):s.push(e,t)}function je(s,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<s.length)s[s.length-1]=s[s.length-1].append(t);else{for(;s.length<i;)s.push(E.empty);s.push(t)}}function qn(s,e,t){let i=s.inserted;for(let n=0,r=0,o=0;o<s.sections.length;){let l=s.sections[o++],a=s.sections[o++];if(a<0)n+=l,r+=l;else{let h=n,f=r,c=E.empty;for(;h+=l,f+=a,a&&i&&(c=c.append(i[o-2>>1])),!(t||o==s.sections.length||s.sections[o+1]<0);)l=s.sections[o++],a=s.sections[o++];e(n,h,r,f,c),n=h,r=f}}}function Kn(s,e,t,i=!1){let n=[],r=i?[]:null,o=new _t(s),l=new _t(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 h=Math.min(o.len,l.len);ee(n,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(ee(n,l.ins,-1);h;){let f=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=f&&(ee(n,0,o.ins),r&&je(r,n,o.text),a=o.i),o.forward(f),h-=f}l.next()}else if(o.ins>=0){let h=0,f=o.len;for(;f;)if(l.ins==-1){let c=Math.min(f,l.len);h+=c,f-=c,l.forward(c)}else if(l.ins==0&&l.len<f)f-=l.len,l.next();else break;ee(n,h,a<o.i?o.ins:0),r&&a<o.i&&je(r,n,o.text),a=o.i,o.forward(o.len-f)}else{if(o.done&&l.done)return r?X.createSet(n,r):Fe.create(n);throw new Error("Mismatched change set lengths")}}}function Qo(s,e,t=!1){let i=[],n=t?[]:null,r=new _t(s),o=new _t(e);for(let l=!1;;){if(r.done&&o.done)return n?X.createSet(i,n):Fe.create(i);if(r.ins==0)ee(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)ee(i,0,o.ins,l),n&&je(n,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let f=o.ins==-1?-1:o.off?0:o.ins;ee(i,a,f,l),n&&f&&je(n,i,o.text)}else o.ins==-1?(ee(i,r.off?0:r.len,a,l),n&&je(n,i,r.textBit(a))):(ee(i,r.off?0:r.len,o.off?0:o.ins,l),n&&!o.off&&je(n,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class _t{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[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:e}=this.set,t=this.i-2>>1;return t>=e.length?E.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?E.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class lt{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}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,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new lt(i,n,this.flags)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return b.range(e,t,void 0,void 0,i);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return b.range(this.anchor,n,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!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 b.range(e.anchor,e.head)}static create(e,t,i){return new lt(e,t,i)}}class b{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:b.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new b([this.main],0)}addRange(e,t=!0){return b.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,b.create(i,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 b(e.ranges.map(t=>lt.fromJSON(t)),e.main)}static single(e,t=e){return new b([b.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let r=e[n];if(r.empty?r.from<=i:r.from<i)return b.normalized(e.slice(),t);i=r.to}return new b(e,t)}static cursor(e,t=0,i,n){return lt.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(n??16777215)<<6)}static range(e,t,i,n,r){let o=(i??16777215)<<6|(n==null?7:Math.min(6,n));return!r&&e!=t&&(r=t<e?1:-1),t<e?lt.create(t,e,48|o):lt.create(e,t,(r?r<0?8:16:0)|o)}static normalized(e,t=0){let i=e[t];e.sort((n,r)=>n.from-r.from),t=e.indexOf(i);for(let n=1;n<e.length;n++){let r=e[n],o=e[n-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?b.range(a,l):b.range(l,a))}}return new b(e,t)}}function qo(s,e){for(let t of s.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Ps=0;class A{constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=Ps++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new A(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Ls),!!e.static,e.enables)}of(e){return new Bi([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Bi(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Bi(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Ls(s,e){return s==e||s.length==e.length&&s.every((t,i)=>t===e[i])}class Bi{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=Ps++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,f=[];for(let c of this.dependencies)c=="doc"?a=!0:c=="selection"?h=!0:(((t=e[c.id])!==null&&t!==void 0?t:1)&1)==0&&f.push(e[c.id]);return{create(c){return c.values[o]=i(c),1},update(c,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||Un(c,f)){let d=i(c);if(l?!hr(d,c.values[o],n):!n(d,c.values[o]))return c.values[o]=d,1}return 0},reconfigure:(c,u)=>{let d,p=u.config.address[r];if(p!=null){let g=Wi(u,p);if(this.dependencies.every(m=>m instanceof A?u.facet(m)===c.facet(m):m instanceof pt?u.field(m,!1)==c.field(m,!1):!0)||(l?hr(d=i(c),g,n):n(d=i(c),g)))return c.values[o]=g,0}else d=i(c);return c.values[o]=d,1}}}}function hr(s,e,t){if(s.length!=e.length)return!1;for(let i=0;i<s.length;i++)if(!t(s[i],e[i]))return!1;return!0}function Un(s,e){let t=!1;for(let i of e)Kt(s,i)&1&&(t=!0);return t}function _a(s,e,t){let i=t.map(a=>s[a.id]),n=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=s[e.id]>>1;function l(a){let h=[];for(let f=0;f<i.length;f++){let c=Wi(a,i[f]);if(n[f]==2)for(let u of c)h.push(u);else h.push(c)}return e.combine(h)}return{create(a){for(let h of i)Kt(a,h);return a.values[o]=l(a),1},update(a,h){if(!Un(a,r))return 0;let f=l(a);return e.compare(f,a.values[o])?0:(a.values[o]=f,1)},reconfigure(a,h){let f=Un(a,i),c=h.config.facets[e.id],u=h.facet(e);if(c&&!f&&Ls(t,c))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)}}}const ci=A.define({static:!0});class pt{constructor(e,t,i,n,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(e){let t=new pt(Ps++,e.create,e.update,e.compare||((i,n)=>i===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ci).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,n)=>{let r=i.values[t],o=this.updateF(r,n);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,n)=>{let r=i.facet(ci),o=n.facet(ci),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):n.config.address[this.id]!=null?(i.values[t]=n.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,ci.of({field:this,create:e})]}get extension(){return this}}const ot={lowest:4,low:3,default:2,high:1,highest:0};function Nt(s){return e=>new Ko(e,s)}const Rs={highest:Nt(ot.highest),high:Nt(ot.high),default:Nt(ot.default),low:Nt(ot.low),lowest:Nt(ot.lowest)};class Ko{constructor(e,t){this.inner=e,this.prec=t}}class sn{of(e){return new jn(this,e)}reconfigure(e){return sn.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class jn{constructor(e,t){this.compartment=e,this.inner=t}}class Ni{constructor(e,t,i,n,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n=[],r=Object.create(null),o=new Map;for(let u of Xa(e,t,o))u instanceof pt?n.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of n)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let f=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],p=d[0].facet,g=f&&f[u]||[];if(d.every(m=>m.type==0))if(l[p.id]=a.length<<1|1,Ls(g,d))a.push(i.facet(p));else{let m=p.combine(d.map(y=>y.value));a.push(i&&p.compare(m,i.facet(p))?i.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]=h.length<<1,h.push(y=>m.dynamicSlot(y)));l[p.id]=h.length<<1,h.push(m=>_a(m,p,d))}}let c=h.map(u=>u(l));return new Ni(e,o,c,l,a,r)}}function Xa(s,e,t){let i=[[],[],[],[],[]],n=new Map;function r(o,l){let a=n.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof jn&&t.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof jn){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof Ko)r(o.inner,o.prec);else if(o instanceof pt)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Bi)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,ot.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.`);r(h,l)}}return r(s,ot.default),i.reduce((o,l)=>o.concat(l))}function Kt(s,e){if(e&1)return 2;let t=e>>1,i=s.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[t]=4;let n=s.computeSlot(s,s.config.dynamicSlots[t]);return s.status[t]=2|n}function Wi(s,e){return e&1?s.config.staticValues[e>>1]:s.values[e>>1]}const Uo=A.define(),$n=A.define({combine:s=>s.some(e=>e),static:!0}),jo=A.define({combine:s=>s.length?s[0]:void 0,static:!0}),$o=A.define(),Go=A.define(),_o=A.define(),Xo=A.define({combine:s=>s.length?s[0]:!1});class Rt{constructor(e,t){this.type=e,this.value=t}static define(){return new Ya}}class Ya{of(e){return new Rt(this,e)}}class Ja{constructor(e){this.map=e}of(e){return new _(this,e)}}class _{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new _(this.type,t)}is(e){return this.type==e}static define(e={}){return new Ja(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let r=n.map(t);r&&i.push(r)}return i}}_.reconfigure=_.define();_.appendConfig=_.define();class ie{constructor(e,t,i,n,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&qo(i,t.newLength),r.some(l=>l.type==ie.time)||(this.annotations=r.concat(ie.time.of(Date.now())))}static create(e,t,i,n,r,o){return new ie(e,t,i,n,r,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 t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(ie.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}ie.time=Rt.define();ie.userEvent=Rt.define();ie.addToHistory=Rt.define();ie.remote=Rt.define();function Za(s,e){let t=[];for(let i=0,n=0;;){let r,o;if(i<s.length&&(n==e.length||e[n]>=s[i]))r=s[i++],o=s[i++];else if(n<e.length)r=e[n++],o=e[n++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Yo(s,e,t){var i;let n,r,o;return t?(n=e.changes,r=X.empty(e.changes.length),o=s.changes.compose(e.changes)):(n=e.changes.map(s.changes),r=s.changes.mapDesc(e.changes,!0),o=s.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(r):(i=s.selection)===null||i===void 0?void 0:i.map(n),effects:_.mapEffects(s.effects,n).concat(_.mapEffects(e.effects,r)),annotations:s.annotations.length?s.annotations.concat(e.annotations):e.annotations,scrollIntoView:s.scrollIntoView||e.scrollIntoView}}function Gn(s,e,t){let i=e.selection,n=vt(e.annotations);return e.userEvent&&(n=n.concat(ie.userEvent.of(e.userEvent))),{changes:e.changes instanceof X?e.changes:X.of(e.changes||[],t,s.facet(jo)),selection:i&&(i instanceof b?i:b.single(i.anchor,i.head)),effects:vt(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function Jo(s,e,t){let i=Gn(s,e.length?e[0]:{},s.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=Yo(i,Gn(s,e[r],o?i.changes.newLength:s.doc.length),o)}let n=ie.create(s,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return th(t?eh(n):n)}function eh(s){let e=s.startState,t=!0;for(let n of e.facet($o)){let r=n(s);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:Za(t,r))}if(t!==!0){let n,r;if(t===!1)r=s.changes.invertedDesc,n=X.empty(e.doc.length);else{let o=s.changes.filter(t);n=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}s=ie.create(e,n,s.selection&&s.selection.map(r),_.mapEffects(s.effects,r),s.annotations,s.scrollIntoView)}let i=e.facet(Go);for(let n=i.length-1;n>=0;n--){let r=i[n](s);r instanceof ie?s=r:Array.isArray(r)&&r.length==1&&r[0]instanceof ie?s=r[0]:s=Jo(e,vt(r),!1)}return s}function th(s){let e=s.startState,t=e.facet(_o),i=s;for(let n=t.length-1;n>=0;n--){let r=t[n](s);r&&Object.keys(r).length&&(i=Yo(i,Gn(e,r,s.changes.newLength),!0))}return i==s?s:ie.create(e,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}const ih=[];function vt(s){return s==null?ih:Array.isArray(s)?s:[s]}var We=(function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s})(We||(We={}));const nh=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let _n;try{_n=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function sh(s){if(_n)return _n.test(s);for(let e=0;e<s.length;e++){let t=s[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||nh.test(t)))return!0}return!1}function rh(s){return e=>{if(!/\S/.test(e))return We.Space;if(sh(e))return We.Word;for(let t=0;t<s.length;t++)if(e.indexOf(s[t])>-1)return We.Word;return We.Other}}class I{constructor(e,t,i,n,r,o){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Kt(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Kt(this,i),Wi(this,i)}update(...e){return Jo(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:n}=t;for(let l of e.effects)l.is(sn.reconfigure)?(t&&(n=new Map,t.compartments.forEach((a,h)=>n.set(h,a)),t=null),n.set(l.value.compartment,l.value.extension)):l.is(_.reconfigure)?(t=null,i=l.value):l.is(_.appendConfig)&&(t=null,i=vt(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=Ni.resolve(i,n,this),r=new I(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet($n)?e.newSelection:e.newSelection.asSingle();new I(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:b.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],o=vt(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),f=h.map(n);for(let u=0;u<l;u++)r[u]=r[u].map(f);let c=n.mapDesc(h,!0);r.push(a.range.map(c)),n=n.compose(f),o=_.mapEffects(o,f).concat(_.mapEffects(vt(a.effects),c))}return{changes:n,selection:b.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof X?e:X.of(e,this.doc.length,this.facet(I.lineSeparator))}toText(e){return E.of(e.split(this.facet(I.lineSeparator)||Qn))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Kt(this,t),Wi(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof pt&&this.config.address[n.id]!=null&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];n.push(o.init(a=>o.spec.fromJSON(l,a)))}}return I.create({doc:e.doc,selection:b.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=Ni.resolve(e.extensions||[],new Map),i=e.doc instanceof E?e.doc:E.of((e.doc||"").split(t.staticFacet(I.lineSeparator)||Qn)),n=e.selection?e.selection instanceof b?e.selection:b.single(e.selection.anchor,e.selection.head):b.single(0);return qo(n,i.length),t.staticFacet($n)||(n=n.asSingle()),new I(t,i,n,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(I.tabSize)}get lineBreak(){return this.facet(I.lineSeparator)||`
|
|
5
|
+
`}get readOnly(){return this.facet(Xo)}phrase(e,...t){for(let i of this.facet(I.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,n)=>{if(n=="$")return"$";let r=+(n||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let n=[];for(let r of this.facet(Uo))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&n.push(o[e]);return n}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return rh(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:n}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=te(t,o,!1);if(r(t.slice(a,o))!=We.Word)break;o=a}for(;l<n;){let a=te(t,l);if(r(t.slice(l,a))!=We.Word)break;l=a}return o==l?null:b.range(o+i,l+i)}}I.allowMultipleSelections=$n;I.tabSize=A.define({combine:s=>s.length?s[0]:4});I.lineSeparator=jo;I.readOnly=Xo;I.phrases=A.define({compare(s,e){let t=Object.keys(s),i=Object.keys(e);return t.length==i.length&&t.every(n=>s[n]==e[n])}});I.languageData=Uo;I.changeFilter=$o;I.transactionFilter=Go;I.transactionExtender=_o;sn.reconfigure=_.define();function oh(s,e,t={}){let i={};for(let n of s)for(let r of Object.keys(n)){let o=n[r],l=i[r];if(l===void 0)i[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,r))i[r]=t[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let n in e)i[n]===void 0&&(i[n]=e[n]);return i}class Ge{eq(e){return this==e}range(e,t=e){return Xn.create(e,t,this)}}Ge.prototype.startSide=Ge.prototype.endSide=0;Ge.prototype.point=!1;Ge.prototype.mapMode=ue.TrackDel;function Es(s,e){return s==e||s.constructor==e.constructor&&s.eq(e)}let Xn=class Zo{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Zo(e,t,i)}};function Yn(s,e){return s.from-e.from||s.value.startSide-e.value.startSide}class Is{constructor(e,t,i,n){this.from=e,this.to=t,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,n=0){let r=i?this.to:this.from;for(let o=n,l=r.length;;){if(o==l)return o;let a=o+l>>1,h=r[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,i,n){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,r);r<o;r++)if(n(this.from[r]+e,this.to[r]+e,this.value[r])===!1)return!1}map(e,t){let i=[],n=[],r=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let h=this.value[a],f=this.from[a]+e,c=this.to[a]+e,u,d;if(f==c){let p=t.mapPos(f,h.startSide,h.mapMode);if(p==null||(u=d=p,h.startSide!=h.endSide&&(d=t.mapPos(f,h.endSide),d<u)))continue}else if(u=t.mapPos(f,h.startSide),d=t.mapPos(c,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&&(l=Math.max(l,d-u)),i.push(h),n.push(u-o),r.push(d-o))}return{mapped:i.length?new Is(n,r,i,l):null,pos:o}}}class R{constructor(e,t,i,n){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=n}static create(e,t,i,n){return new R(e,t,i,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 t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:n=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(Yn)),this.isEmpty)return t.length?R.of(t):this;let l=new el(this,null,-1).goto(0),a=0,h=[],f=new Xt;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let c=t[a++];f.addInner(c.from,c.to,c.value)||h.push(c)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||n>this.chunkEnd(l.chunkIndex)||r<this.chunkPos[l.chunkIndex])&&f.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||n>l.to||r<l.from||o(l.from,l.to,l.value))&&(f.addInner(l.from,l.to,l.value)||h.push(Xn.create(l.from,l.to,l.value))),l.next());return f.finishInner(this.nextLayer.isEmpty&&!h.length?R.empty:this.nextLayer.update({add:h,filter:o,filterFrom:n,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],n=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],h=e.touchesRange(l,l+a.length);if(h===!1)n=Math.max(n,a.maxPoint),t.push(a),i.push(e.mapPos(l));else if(h===!0){let{mapped:f,pos:c}=a.map(l,e);f&&(n=Math.max(n,f.maxPoint),t.push(f),i.push(c))}}let r=this.nextLayer.map(e);return t.length==0?r:new R(i,t,r||R.empty,n)}between(e,t,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let r=this.chunkPos[n],o=this.chunk[n];if(t>=r&&e<=r+o.length&&o.between(r,e-r,t-r,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Yt.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Yt.from(e).goto(t)}static compare(e,t,i,n,r=-1){let o=e.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=r),l=t.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=r),a=fr(o,l,i),h=new Wt(o,a,r),f=new Wt(l,a,r);i.iterGaps((c,u,d)=>cr(h,c,f,u,d,n)),i.empty&&i.length==0&&cr(h,0,f,0,0,n)}static eq(e,t,i=0,n){n==null&&(n=999999999);let r=e.filter(f=>!f.isEmpty&&t.indexOf(f)<0),o=t.filter(f=>!f.isEmpty&&e.indexOf(f)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=fr(r,o),a=new Wt(r,l,0).goto(i),h=new Wt(o,l,0).goto(i);for(;;){if(a.to!=h.to||!Jn(a.active,h.active)||a.point&&(!h.point||!Es(a.point,h.point)))return!1;if(a.to>n)return!0;a.next(),h.next()}}static spans(e,t,i,n,r=-1){let o=new Wt(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let f=o.activeForPoint(o.to),c=o.pointFrom<t?f.length+1:o.point.startSide<0?f.length:Math.min(f.length,a);n.point(l,h,o.point,f,c,o.pointRank),a=Math.min(o.openEnd(h),f.length)}else h>l&&(n.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new Xt;for(let n of e instanceof Xn?[e]:t?lh(e):e)i.add(n.from,n.to,n.value);return i.finish()}static join(e){if(!e.length)return R.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let n=e[i];n!=R.empty;n=n.nextLayer)t=new R(n.chunkPos,n.chunk,t,Math.max(n.maxPoint,t.maxPoint));return t}}R.empty=new R([],[],null,-1);function lh(s){if(s.length>1)for(let e=s[0],t=1;t<s.length;t++){let i=s[t];if(Yn(e,i)>0)return s.slice().sort(Yn);e=i}return s}R.empty.nextLayer=R.empty;class Xt{finishChunk(e){this.chunks.push(new Is(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,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new Xt)).add(e,t,i)}addInner(e,t,i){let n=e-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(e-this.lastFrom||i.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(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(R.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=R.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function fr(s,e,t){let i=new Map;for(let r of s)for(let o=0;o<r.chunk.length;o++)r.chunk[o].maxPoint<=0&&i.set(r.chunk[o],r.chunkPos[o]);let n=new Set;for(let r of e)for(let o=0;o<r.chunk.length;o++){let l=i.get(r.chunk[o]);l!=null&&(t?t.mapPos(l):l)==r.chunkPos[o]&&!(t!=null&&t.touchesRange(l,l+r.chunk[o].length))&&n.add(r.chunk[o])}return n}class el{constructor(e,t,i,n=0){this.layer=e,this.skip=t,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(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,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)<e||n.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==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=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Yt{constructor(e){this.heap=e}static from(e,t=null,i=-1){let n=[];for(let r=0;r<e.length;r++)for(let o=e[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&n.push(new el(o,t,i,r));return n.length==1?n[0]:new Yt(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)kn(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)kn(this.heap,i);(this.to-e||this.value.endSide-t)<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(),kn(this.heap,0)}}}function kn(s,e){for(let t=s[e];;){let i=(e<<1)+1;if(i>=s.length)break;let n=s[i];if(i+1<s.length&&n.compare(s[i+1])>=0&&(n=s[i+1],i++),t.compare(n)<0)break;s[i]=t,s[e]=n,e=i}}class Wt{constructor(e,t,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=Yt.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){ui(this.active,e),ui(this.activeTo,e),ui(this.activeRank,e),this.minActive=ur(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:n,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||n-this.activeTo[t])>0;)t++;di(this.active,t,i),di(this.activeTo,t,n),di(this.activeRank,t,r),e&&di(e,t,this.cursor.from),this.minActive=ur(this.active,this.activeTo)}next(){let e=this.to,t=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]>e){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&ui(i,n)}else if(this.cursor.value)if(this.cursor.from>e){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(t&&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]<e;n--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function cr(s,e,t,i,n,r){s.goto(e),t.goto(i);let o=i+n,l=i,a=i-e,h=!!r.boundChange;for(let f=!1;;){let c=s.to+a-t.to,u=c||s.endSide-t.endSide,d=u<0?s.to+a:t.to,p=Math.min(d,o);if(s.point||t.point?(s.point&&t.point&&Es(s.point,t.point)&&Jn(s.activeForPoint(s.to),t.activeForPoint(t.to))||r.comparePoint(l,p,s.point,t.point),f=!1):(f&&r.boundChange(l),p>l&&!Jn(s.active,t.active)&&r.compareRange(l,p,s.active,t.active),h&&p<o&&(c||s.openEnd(d)!=t.openEnd(d))&&(f=!0)),d>o)break;l=d,u<=0&&s.next(),u>=0&&t.next()}}function Jn(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++)if(s[t]!=e[t]&&!Es(s[t],e[t]))return!1;return!0}function ui(s,e){for(let t=e,i=s.length-1;t<i;t++)s[t]=s[t+1];s.pop()}function di(s,e,t){for(let i=s.length-1;i>=e;i--)s[i+1]=s[i];s[e]=t}function ur(s,e){let t=-1,i=1e9;for(let n=0;n<e.length;n++)(e[n]-i||s[n].endSide-s[t].endSide)<0&&(t=n,i=e[n]);return t}function rn(s,e,t=s.length){let i=0;for(let n=0;n<t&&n<s.length;)s.charCodeAt(n)==9?(i+=e-i%e,n++):(i++,n=te(s,n));return i}function ah(s,e,t,i){for(let n=0,r=0;;){if(r>=e)return n;if(n==s.length)break;r+=s.charCodeAt(n)==9?t-r%t:1,n=te(s,n)}return s.length}const Zn="ͼ",dr=typeof Symbol>"u"?"__"+Zn:Symbol.for(Zn),es=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),pr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class _e{constructor(e,t){this.rules=[];let{finish:i}=t||{};function n(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,h){let f=[],c=/^@(\w+)\b/.exec(o[0]),u=c&&c[1]=="keyframes";if(c&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))r(d.split(/,\s*/).map(g=>o.map(m=>g.replace(/&/,m))).reduce((g,m)=>g.concat(m)),p,a);else if(p&&typeof p=="object"){if(!c)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(n(d),p,f,u)}else p!=null&&f.push(d.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+p+";")}(f.length||u)&&a.push((i&&!c&&!h?o.map(i):o).join(", ")+" {"+f.join(" ")+"}")}for(let o in e)r(n(o),e[o],this.rules)}getRules(){return this.rules.join(`
|
|
6
|
+
`)}static newName(){let e=pr[dr]||1;return pr[dr]=e+1,Zn+e.toString(36)}static mount(e,t,i){let n=e[es],r=i&&i.nonce;n?r&&n.setNonce(r):n=new hh(e,r),n.mount(Array.isArray(t)?t:[t],e)}}let gr=new Map;class hh{constructor(e,t){let i=e.ownerDocument||e,n=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let r=gr.get(i);if(r)return e[es]=r;this.sheet=new n.CSSStyleSheet,gr.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[es]=this}mount(e,t){let i=this.sheet,n=0,r=0;for(let o=0;o<e.length;o++){let l=e[o],a=this.modules.indexOf(l);if(a<r&&a>-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,l),i)for(let h=0;h<l.rules.length;h++)i.insertRule(l.rules[h],n++)}else{for(;r<a;)n+=this.modules[r++].rules.length;n+=l.rules.length,r++}}if(i)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
|
|
7
|
+
`;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var Xe={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:"'"},Jt={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},fh=typeof navigator<"u"&&/Mac/.test(navigator.platform),ch=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Z=0;Z<10;Z++)Xe[48+Z]=Xe[96+Z]=String(Z);for(var Z=1;Z<=24;Z++)Xe[Z+111]="F"+Z;for(var Z=65;Z<=90;Z++)Xe[Z]=String.fromCharCode(Z+32),Jt[Z]=String.fromCharCode(Z);for(var bn in Xe)Jt.hasOwnProperty(bn)||(Jt[bn]=Xe[bn]);function uh(s){var e=fh&&s.metaKey&&s.shiftKey&&!s.ctrlKey&&!s.altKey||ch&&s.shiftKey&&s.key&&s.key.length==1||s.key=="Unidentified",t=!e&&s.key||(s.shiftKey?Jt:Xe)[s.keyCode]||s.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}let se=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},ts=typeof document<"u"?document:{documentElement:{style:{}}};const is=/Edge\/(\d+)/.exec(se.userAgent),tl=/MSIE \d/.test(se.userAgent),ns=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(se.userAgent),on=!!(tl||ns||is),mr=!on&&/gecko\/(\d+)/i.test(se.userAgent),xn=!on&&/Chrome\/(\d+)/.exec(se.userAgent),dh="webkitFontSmoothing"in ts.documentElement.style,ss=!on&&/Apple Computer/.test(se.vendor),yr=ss&&(/Mobile\/\w+/.test(se.userAgent)||se.maxTouchPoints>2);var v={mac:yr||/Mac/.test(se.platform),windows:/Win/.test(se.platform),linux:/Linux|X11/.test(se.platform),ie:on,ie_version:tl?ts.documentMode||6:ns?+ns[1]:is?+is[1]:0,gecko:mr,gecko_version:mr?+(/Firefox\/(\d+)/.exec(se.userAgent)||[0,0])[1]:0,chrome:!!xn,chrome_version:xn?+xn[1]:0,ios:yr,android:/Android\b/.test(se.userAgent),webkit_version:dh?+(/\bAppleWebKit\/(\d+)/.exec(se.userAgent)||[0,0])[1]:0,safari:ss,safari_version:ss?+(/\bVersion\/(\d+(\.\d+)?)/.exec(se.userAgent)||[0,0])[1]:0,tabSize:ts.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Ns(s,e){for(let t in s)t=="class"&&e.class?e.class+=" "+s.class:t=="style"&&e.style?e.style+=";"+s.style:e[t]=s[t];return e}const Fi=Object.create(null);function Ws(s,e,t){if(s==e)return!0;s||(s=Fi),e||(e=Fi);let i=Object.keys(s),n=Object.keys(e);if(i.length-0!=n.length-0)return!1;for(let r of i)if(r!=t&&(n.indexOf(r)==-1||s[r]!==e[r]))return!1;return!0}function ph(s,e){for(let t=s.attributes.length-1;t>=0;t--){let i=s.attributes[t].name;e[i]==null&&s.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?s.style.cssText=i:s.getAttribute(t)!=i&&s.setAttribute(t,i)}}function kr(s,e,t){let i=!1;if(e)for(let n in e)t&&n in t||(i=!0,n=="style"?s.style.cssText="":s.removeAttribute(n));if(t)for(let n in t)e&&e[n]==t[n]||(i=!0,n=="style"?s.style.cssText=t[n]:s.setAttribute(n,t[n]));return i}function gh(s){let e=Object.create(null);for(let t=0;t<s.attributes.length;t++){let i=s.attributes[t];e[i.name]=i.value}return e}class ln{eq(e){return!1}updateDOM(e,t,i){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var le=(function(s){return s[s.Text=0]="Text",s[s.WidgetBefore=1]="WidgetBefore",s[s.WidgetAfter=2]="WidgetAfter",s[s.WidgetRange=3]="WidgetRange",s})(le||(le={}));class G extends Ge{constructor(e,t,i,n){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(e){return new ri(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new ft(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,n;if(e.isBlockGap)i=-5e8,n=4e8;else{let{start:r,end:o}=il(e,t);i=(r?t?-3e8:-1:5e8)-1,n=(o?t?2e8:1:-6e8)+1}return new ft(e,i,n,t,e.widget||null,!0)}static line(e){return new oi(e)}static set(e,t=!1){return R.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}G.none=R.empty;class ri extends G{constructor(e){let{start:t,end:i}=il(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Ns(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Fi}eq(e){return this==e||e instanceof ri&&this.tagName==e.tagName&&Ws(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}ri.prototype.point=!1;class oi extends G{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof oi&&this.spec.class==e.spec.class&&Ws(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}oi.prototype.mapMode=ue.TrackBefore;oi.prototype.point=!0;class ft extends G{constructor(e,t,i,n,r,o){super(t,i,r,e),this.block=n,this.isReplace=o,this.mapMode=n?t<=0?ue.TrackBefore:ue.TrackAfter:ue.TrackDel}get type(){return this.startSide!=this.endSide?le.WidgetRange:this.startSide<=0?le.WidgetBefore:le.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof ft&&mh(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}ft.prototype.point=!0;function il(s,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=s;return t==null&&(t=s.inclusive),i==null&&(i=s.inclusive),{start:t??e,end:i??e}}function mh(s,e){return s==e||!!(s&&e&&s.compare(e))}function St(s,e,t,i=0){let n=t.length-1;n>=0&&t[n]+i>=s?t[n]=Math.max(t[n],e):t.push(s,e)}class Zt extends Ge{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof Zt&&this.tagName==e.tagName&&Ws(this.attributes,e.attributes)}static create(e){return new Zt(e.tagName,e.attributes||Fi)}static set(e,t=!1){return R.of(e,t)}}Zt.prototype.startSide=Zt.prototype.endSide=-1;function ei(s){let e;return s.nodeType==11?e=s.getSelection?s:s.ownerDocument:e=s,e.getSelection()}function rs(s,e){return e?s==e||s.contains(e.nodeType!=1?e.parentNode:e):!1}function Ut(s,e){if(!e.anchorNode)return!1;try{return rs(s,e.anchorNode)}catch{return!1}}function Di(s){return s.nodeType==3?ti(s,0,s.nodeValue.length).getClientRects():s.nodeType==1?s.getClientRects():[]}function jt(s,e,t,i){return t?br(s,e,t,i,-1)||br(s,e,t,i,1):!1}function Ye(s){for(var e=0;;e++)if(s=s.previousSibling,!s)return e}function Hi(s){return s.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(s.nodeName)}function br(s,e,t,i,n){for(;;){if(s==t&&e==i)return!0;if(e==(n<0?0:Ve(s))){if(s.nodeName=="DIV")return!1;let r=s.parentNode;if(!r||r.nodeType!=1)return!1;e=Ye(s)+(n<0?0:1),s=r}else if(s.nodeType==1){if(s=s.childNodes[e+(n<0?-1:0)],s.nodeType==1&&s.contentEditable=="false")return!1;e=n<0?Ve(s):0}else return!1}}function Ve(s){return s.nodeType==3?s.nodeValue.length:s.childNodes.length}function Vi(s,e){let t=e?s.left:s.right;return{left:t,right:t,top:s.top,bottom:s.bottom}}function yh(s){let e=s.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:s.innerWidth,top:0,bottom:s.innerHeight}}function nl(s,e){let t=e.width/s.offsetWidth,i=e.height/s.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-s.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-s.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function kh(s,e,t,i,n,r,o,l){let a=s.ownerDocument,h=a.defaultView||window;for(let f=s,c=!1;f&&!c;)if(f.nodeType==1){let u,d=f==a.body,p=1,g=1;if(d)u=yh(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(f).position)&&(c=!0),f.scrollHeight<=f.clientHeight&&f.scrollWidth<=f.clientWidth){f=f.assignedSlot||f.parentNode;continue}let w=f.getBoundingClientRect();({scaleX:p,scaleY:g}=nl(f,w)),u={left:w.left,right:w.left+f.clientWidth*p,top:w.top,bottom:w.top+f.clientHeight*g}}let m=0,y=0;if(n=="nearest")e.top<u.top?(y=e.top-(u.top+o),t>0&&e.bottom>u.bottom+y&&(y=e.bottom-u.bottom+o)):e.bottom>u.bottom&&(y=e.bottom-u.bottom+o,t<0&&e.top-y<u.top&&(y=e.top-(u.top+o)));else{let w=e.bottom-e.top,S=u.bottom-u.top;y=(n=="center"&&w<=S?e.top+w/2-S/2:n=="start"||n=="center"&&t<0?e.top-o:e.bottom-S+o)-u.top}if(i=="nearest"?e.left<u.left?(m=e.left-(u.left+r),t>0&&e.right>u.right+m&&(m=e.right-u.right+r)):e.right>u.right&&(m=e.right-u.right+r,t<0&&e.left<u.left+m&&(m=e.left-(u.left+r))):m=(i=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:i=="start"==l?e.left-r:e.right-(u.right-u.left)+r)-u.left,m||y)if(d)h.scrollBy(m,y);else{let w=0,S=0;if(y){let L=f.scrollTop;f.scrollTop+=y/g,S=(f.scrollTop-L)*g}if(m){let L=f.scrollLeft;f.scrollLeft+=m/p,w=(f.scrollLeft-L)*p}e={left:e.left-w,top:e.top-S,right:e.right-w,bottom:e.bottom-S},w&&Math.abs(w-m)<1&&(i="nearest"),S&&Math.abs(S-y)<1&&(n="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)}),f=f.assignedSlot||f.parentNode}else if(f.nodeType==11)f=f.host;else break}function sl(s,e=!0){let t=s.ownerDocument,i=null,n=null;for(let r=s.parentNode;r&&!(r==t.body||(!e||i)&&n);)if(r.nodeType==1)!n&&r.scrollHeight>r.clientHeight&&(n=r),e&&!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}}class bh{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?Ve(t):0),i,Math.min(e.focusOffset,i?Ve(i):0))}set(e,t,i,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=n}}let st=null;v.safari&&v.safari_version>=26&&(st=!1);function rl(s){if(s.setActive)return s.setActive();if(st)return s.focus(st);let e=[];for(let t=s;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(s.focus(st==null?{get preventScroll(){return st={preventScroll:!0},!0}}:void 0),!st){st=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],r=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=r&&(i.scrollLeft=r)}}}let xr;function ti(s,e,t=e){let i=xr||(xr=document.createRange());return i.setEnd(s,t),i.setStart(s,e),i}function Ct(s,e,t,i){let n={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,metaKey:n.metaKey}=i);let r=new KeyboardEvent("keydown",n);r.synthetic=!0,s.dispatchEvent(r);let o=new KeyboardEvent("keyup",n);return o.synthetic=!0,s.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function xh(s){for(;s;){if(s&&(s.nodeType==9||s.nodeType==11&&s.host))return s;s=s.assignedSlot||s.parentNode}return null}function wh(s,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,Ve(t));;)if(i){if(t.nodeType!=1)return!1;let n=t.childNodes[i-1];n.contentEditable=="false"?i--:(t=n,i=Ve(t))}else{if(t==s)return!0;i=Ye(t),t=t.parentNode}}function ol(s){return s instanceof Window?s.pageYOffset>Math.max(0,s.document.documentElement.scrollHeight-s.innerHeight-4):s.scrollTop>Math.max(1,s.scrollHeight-s.clientHeight-4)}function ll(s,e){for(let t=s,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=Ve(t)}else if(t.parentNode&&!Hi(t))i=Ye(t),t=t.parentNode;else return null}}function al(s,e){for(let t=s,i=e;;){if(t.nodeType==3&&i<t.nodeValue.length)return{node:t,offset:i};if(t.nodeType==1&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!Hi(t))i=Ye(t)+1,t=t.parentNode;else return null}}class xe{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new xe(e.parentNode,Ye(e),t)}static after(e,t){return new xe(e.parentNode,Ye(e)+1,t)}}var j=(function(s){return s[s.LTR=0]="LTR",s[s.RTL=1]="RTL",s})(j||(j={}));const ct=j.LTR,Fs=j.RTL;function hl(s){let e=[];for(let t=0;t<s.length;t++)e.push(1<<+s[t]);return e}const vh=hl("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Sh=hl("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),os=Object.create(null),Oe=[];for(let s of["()","[]","{}"]){let e=s.charCodeAt(0),t=s.charCodeAt(1);os[e]=t,os[t]=-e}function fl(s){return s<=247?vh[s]:1424<=s&&s<=1524?2:1536<=s&&s<=1785?Sh[s-1536]:1774<=s&&s<=2220?4:8192<=s&&s<=8204?256:64336<=s&&s<=65023?4:1}const Ch=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Le{get dir(){return this.level%2?Fs:ct}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,n){let r=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(r<0||(n!=0?n<0?l.from<t:l.to>t:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function cl(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++){let i=s[t],n=e[t];if(i.from!=n.from||i.to!=n.to||i.direction!=n.direction||!cl(i.inner,n.inner))return!1}return!0}const N=[];function Ah(s,e,t,i,n){for(let r=0;r<=i.length;r++){let o=r?i[r-1].to:e,l=r<i.length?i[r].from:t,a=r?256:n;for(let h=o,f=a,c=a;h<l;h++){let u=fl(s.charCodeAt(h));u==512?u=f:u==8&&c==4&&(u=16),N[h]=u==4?2:u,u&7&&(c=u),f=u}for(let h=o,f=a,c=a;h<l;h++){let u=N[h];if(u==128)h<l-1&&f==N[h+1]&&f&24?u=N[h]=f:N[h]=256;else if(u==64){let d=h+1;for(;d<l&&N[d]==64;)d++;let p=h&&f==8||d<t&&N[d]==8?c==1?1:8:256;for(let g=h;g<d;g++)N[g]=p;h=d-1}else u==8&&c==1&&(N[h]=1);f=u,u&7&&(c=u)}}}function Oh(s,e,t,i,n){let r=n==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,f=o<i.length?i[o].from:t;for(let c=h,u,d,p;c<f;c++)if(d=os[u=s.charCodeAt(c)])if(d<0){for(let g=l-3;g>=0;g-=3)if(Oe[g+1]==-d){let m=Oe[g+2],y=m&2?n:m&4?m&1?r:n:0;y&&(N[c]=N[Oe[g]]=y),l=g;break}}else{if(Oe.length==189)break;Oe[l++]=c,Oe[l++]=u,Oe[l++]=a}else if((p=N[c])==2||p==1){let g=p==n;a=g?0:1;for(let m=l-3;m>=0;m-=3){let y=Oe[m+2];if(y&2)break;if(g)Oe[m+2]|=2;else{if(y&4)break;Oe[m+2]|=4}}}}}function Mh(s,e,t,i){for(let n=0,r=i;n<=t.length;n++){let o=n?t[n-1].to:s,l=n<t.length?t[n].from:e;for(let a=o;a<l;){let h=N[a];if(h==256){let f=a+1;for(;;)if(f==l){if(n==t.length)break;f=t[n++].to,l=n<t.length?t[n].from:e}else if(N[f]==256)f++;else break;let c=r==1,u=(f<e?N[f]:i)==1,d=c==u?c?1:2:i;for(let p=f,g=n,m=g?t[g-1].to:s;p>a;)p==m&&(p=t[--g].from,m=g?t[g-1].to:s),N[--p]=d;a=f}else r=h,a++}}}function ls(s,e,t,i,n,r,o){let l=i%2?2:1;if(i%2==n%2)for(let a=e,h=0;a<t;){let f=!0,c=!1;if(h==r.length||a<r[h].from){let g=N[a];g!=l&&(f=!1,c=g==16)}let u=!f&&l==1?[]:null,d=f?i:i+1,p=a;e:for(;;)if(h<r.length&&p==r[h].from){if(c)break e;let g=r[h];if(!f)for(let m=g.to,y=h+1;;){if(m==t)break e;if(y<r.length&&r[y].from==m)m=r[y++].to;else{if(N[m]==l)break e;break}}if(h++,u)u.push(g);else{g.from>a&&o.push(new Le(a,g.from,d));let m=g.direction==ct!=!(d%2);as(s,m?i+1:i,n,g.inner,g.from,g.to,o),a=g.to}p=g.to}else{if(p==t||(f?N[p]!=l:N[p]==l))break;p++}u?ls(s,a,p,i+1,n,u,o):a<p&&o.push(new Le(a,p,d)),a=p}else for(let a=t,h=r.length;a>e;){let f=!0,c=!1;if(!h||a>r[h-1].to){let g=N[a-1];g!=l&&(f=!1,c=g==16)}let u=!f&&l==1?[]:null,d=f?i:i+1,p=a;e:for(;;)if(h&&p==r[h-1].to){if(c)break e;let g=r[--h];if(!f)for(let m=g.from,y=h;;){if(m==e)break e;if(y&&r[y-1].to==m)m=r[--y].from;else{if(N[m-1]==l)break e;break}}if(u)u.push(g);else{g.to<a&&o.push(new Le(g.to,a,d));let m=g.direction==ct!=!(d%2);as(s,m?i+1:i,n,g.inner,g.from,g.to,o),a=g.from}p=g.from}else{if(p==e||(f?N[p-1]!=l:N[p-1]==l))break;p--}u?ls(s,p,a,i+1,n,u,o):p<a&&o.push(new Le(p,a,d)),a=p}}function as(s,e,t,i,n,r,o){let l=e%2?2:1;Ah(s,n,r,i,l),Oh(s,n,r,i,l),Mh(n,r,i,l),ls(s,n,r,e,t,i,o)}function Th(s,e,t){if(!s)return[new Le(0,0,e==Fs?1:0)];if(e==ct&&!t.length&&!Ch.test(s))return ul(s.length);if(t.length)for(;s.length>N.length;)N[N.length]=256;let i=[],n=e==ct?0:1;return as(s,n,n,t,0,s.length,i),i}function ul(s){return[new Le(0,s,0)]}let dl="";function Bh(s,e,t,i,n){var r;let o=i.head-s.from,l=Le.find(e,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),a=e[l],h=a.side(n,t);if(o==h){let u=l+=n?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!n,t),h=a.side(n,t)}let f=te(s.text,o,a.forward(n,t));(f<a.from||f>a.to)&&(f=h),dl=s.text.slice(Math.min(o,f),Math.max(o,f));let c=l==(n?e.length-1:0)?null:e[l+(n?1:-1)];return c&&f==h&&c.level+(n?0:1)<a.level?b.cursor(c.side(!n,t)+s.from,c.forward(n,t)?1:-1,c.level):b.cursor(f+s.from,a.forward(n,t)?-1:1,a.level)}function Dh(s,e,t){for(let i=e;i<t;i++){let n=fl(s.charCodeAt(i));if(n==1)return ct;if(n==2||n==4)return Fs}return ct}const pl=A.define(),gl=A.define(),ml=A.define(),yl=A.define(),hs=A.define(),kl=A.define(),bl=A.define(),Hs=A.define(),Vs=A.define(),xl=A.define({combine:s=>s.some(e=>e)}),Ph=A.define({combine:s=>s.some(e=>e)}),wl=A.define();class At{constructor(e,t="nearest",i="nearest",n=5,r=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new At(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 At(b.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const pi=_.define({map:(s,e)=>s.map(e)}),vl=_.define();function Re(s,e,t){let i=s.facet(yl);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const Ne=A.define({combine:s=>s.length?s[0]:!0});let Lh=0;const kt=A.define({combine(s){return s.filter((e,t)=>{for(let i=0;i<t;i++)if(s[i].plugin==e.plugin)return!1;return!0})}});class ze{constructor(e,t,i,n,r){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(kt.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(kt.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:i,eventObservers:n,provide:r,decorations:o}=t||{};return new ze(Lh++,e,i,n,l=>{let a=[];return o&&a.push(an.of(h=>{let f=h.plugin(l);return f?o(f):G.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return ze.define((i,n)=>new e(i,n),t)}}class wn{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(Re(t.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(e,this.spec.arg)}catch(t){Re(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){Re(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Sl=A.define(),zs=A.define(),an=A.define(),Cl=A.define(),Qs=A.define(),li=A.define(),Al=A.define();function wr(s,e){let t=s.state.facet(Al);if(!t.length)return t;let i=t.map(r=>r instanceof Function?r(s):r),n=[];return R.spans(i,e.from,e.to,{point(){},span(r,o,l,a){let h=r-e.from,f=o-e.from,c=n;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=Dh(e.text,h,f)),a>0&&c.length&&(p=c[c.length-1]).to==h&&p.direction==d)p.to=f,c=p.inner;else{let g={from:h,to:f,direction:d,inner:[]};c.push(g),c=g.inner}}}}),n}const Ol=A.define();function Ml(s){let e=0,t=0,i=0,n=0;for(let r of s.state.facet(Ol)){let o=r(s);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(n=Math.max(n,o.bottom)))}return{left:e,right:t,top:i,bottom:n}}const zt=A.define();class ge{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new ge(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 t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let n=0,r=0,o=0;;){let l=n<e.length?e[n].fromB:1e9,a=r<t.length?t[r]:1e9,h=Math.min(l,a);if(h==1e9)break;let f=h+o,c=h,u=f;for(;;)if(r<t.length&&t[r]<=c){let d=t[r+1];r+=2,c=Math.max(c,d);for(let p=n;p<e.length&&e[p].fromB<=c;p++)o=e[p].toA-e[p].toB;u=Math.max(u,d+o)}else if(n<e.length&&e[n].fromB<=c){let d=e[n++];c=Math.max(c,d.toB),u=Math.max(u,d.toA),o=d.toA-d.toB}else break;i.push(new ge(f,u,h,c))}return i}}class zi{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=X.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let n=[];this.changes.iterChangedRanges((r,o,l,a)=>n.push(new ge(r,o,l,a))),this.changedRanges=n}static create(e,t,i){return new zi(e,t,i)}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}}const Rh=[];class K{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Rh}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&ph(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;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}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let i=Ye(this.dom),n=this.length?e>0:t>0;return new xe(this.parent.dom,i+(n?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fn)return e;return null}static get(e){return e.cmTile}}class hn extends K{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,n,r=(e==null?void 0:e.node)==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,n=i?i.nextSibling:t.firstChild,r&&n!=l.dom&&(r.written=!0),l.dom.parentNode==t)for(;n&&n!=l.dom;)n=vr(n);else t.insertBefore(l.dom,n);i=l.dom}for(n=i?i.nextSibling:t.firstChild,r&&n&&(r.written=!0);n;)n=vr(n);this.length=o}}function vr(s){let e=s.nextSibling;return s.parentNode.removeChild(s),e}class fn extends hn{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=K.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,n=0,r=0;;)if(n==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&r++,n=t.pop()}else{let o=i.children[n++];if(o instanceof He)t.push(n),i=o,n=0;else{let l=r+o.length,a=e(o,r);if(a!==void 0)return a;r=l+o.breakAfter}}}resolveBlock(e,t){let i,n=-1,r,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(e>=a&&e<=h){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(a<e||e==h&&(t<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,n=e-a),(h>e||e==a&&(t>1?l.length:l.covers(-1)))&&(!r||!l.isWidget()&&r.isWidget())&&(r=l,o=e-a)}}),!i&&!r)throw new Error("No tile at position "+e);return i&&t<0||!r?{tile:i,offset:n}:{tile:r,offset:o}}}class He extends hn{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new He(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Tt extends hn{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let n=new Tt(t||document.createElement("div"),e);return(!t||!i)&&(n.flags|=4),n}get domAttrs(){return this.attrs}resolveInline(e,t,i){let n=null,r=-1,o=null,l=-1;function a(f,c){for(let u=0,d=0;u<f.children.length&&d<=c;u++){let p=f.children[u],g=d+p.length;g>=c&&(p.isComposite()?a(p,c-d):(!o||o.isHidden&&(t>0||i&&Ih(o,p)))&&(g>c||p.flags&32)?(o=p,l=c-d):(d<c||p.flags&16&&!p.isHidden)&&(n=p,r=c-d)),d=g}}a(this,e);let h=(t<0?n:o)||n||o;return h?{tile:h,offset:h==n?r:l}:null}coordsIn(e,t){let i=this.resolveInline(e,t,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),t):Eh(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:n,offset:r}=i;if(this.dom.contains(n.dom))return n.isText()?new xe(n.dom,Math.min(n.dom.nodeValue.length,r)):n.domPosFor(r,n.flags&16?1:n.flags&32?-1:t);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new xe(a.dom,0);a==i.tile&&(l=!0)}}return new xe(this.dom,0)}}function Eh(s){let e=s.dom.lastChild;if(!e)return s.dom.getBoundingClientRect();let t=Di(e);return t[t.length-1]||null}function Ih(s,e){let t=s.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.top<t.bottom}class oe extends hn{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new oe(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class at extends K{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let i=this.dom.nodeValue.length;e>i&&(e=i);let n=e,r=e,o=0;e==0&&t<0||e==i&&t>=0?v.chrome||v.gecko||(e?(n--,o=1):r<i&&(r++,o=-1)):t<0?n--:r<i&&r++;let l=ti(this.dom,n,r).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return v.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?Vi(a,o<0):a||null}static of(e,t){let i=new at(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class ut extends K{constructor(e,t,i,n){super(e,t,n),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;if(i)return Vi(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?r.length-1:0;o=r[a],!(e>0?a==0:a==r.length-1||o.top<o.bottom);a+=l?-1:1);return Vi(o,!l)}}get overrideDOMText(){if(!this.length)return E.empty;let{root:e}=this;if(!e)return E.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,n,r){return r||(r=e.toDOM(t),e.editable||(r.contentEditable="false")),new ut(r,i,e,n)}}class Qi extends K{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return E.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class Nh{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:n,index:r,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(n.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(r==n.children.length){if(!e&&!l.length)break;i&&i.leave(n),o=!!n.breakAfter,{tile:n,index:r}=l.pop(),r++}else{let a=n.children[r],h=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!i||i.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!h,r++,e-=a.length):(l.push({tile:n,index:r}),n=a,r=0,i&&a.isComposite()&&i.enter(a))}else if(r==n.length)o=!!n.breakAfter,{tile:n,index:r}=l.pop(),r++;else if(e){let a=Math.min(e,n.length-r);i&&i.skip(n,r,r+a),e-=a,r+=a}else break;return this.tile=n,this.index=r,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Wh{constructor(e,t,i,n){this.from=e,this.to=t,this.wrapper=i,this.rank=n}}class Fh{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,n){var r;this.flushBuffer();let o=this.ensureMarks(t,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new at(l.dom,l.text+e);a.parent=o}else o.append(n||at.of(e,(r=this.cache.find(at))===null||r===void 0?void 0:r.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?vn(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let n=i;for(let l=t.marks.length-1;l>=0;l--){let a=t.marks[l],h=n.lastChild;if(h instanceof oe&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM(vn(a.dom)),n=h;else{if(this.cache.reused.get(a)){let c=K.get(a.dom);c&&c.setDOM(vn(a.dom))}let f=oe.of(a.mark,a.dom);n.append(f),n=f}this.cache.reused.set(a,2)}let r=K.get(e.text);r&&this.cache.reused.set(r,2);let o=new at(e.text,e.text.nodeValue);o.flags|=8,n.append(o)}addInlineWidget(e,t,i){let n=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);n||this.flushBuffer();let r=this.ensureMarks(t,i);!n&&!(e.flags&16)&&r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=Tl);let n=Tt.start(e,t||((i=this.cache.find(Tt))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let n=this.curLine;for(let r=e.length-1;r>=0;r--){let o=e[r],l;if(t>0&&(l=n.lastChild)&&l instanceof oe&&l.mark.eq(o))n=l,t--;else{let a=oe.of(o,(i=this.cache.find(oe,h=>h.mark.eq(o)))===null||i===void 0?void 0:i.dom);n.append(a),n=a,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Sr(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(v.ios&&Sr(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Sn,0,32)||new ut(Sn.toDOM(),0,Sn,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new Wh(e.from,e.to,e.value,e.rank),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-t.rank||this.wrappers[i-1].to-t.to)<0;)i--;this.wrappers.splice(i,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let n=t.lastChild;if(i.from<this.pos&&n instanceof He&&n.wrapper.eq(i.wrapper))t=n;else{let r=He.of(i.wrapper,(e=this.cache.find(He,o=>o.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Qi,void 0,1);return i&&(i.flags=t),i||new Qi(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Hh{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:n,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=n;let l=this.textOff=Math.min(e,n.length);return r?null:n.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const qi=[ut,Tt,at,oe,Qi,He,fn];for(let s=0;s<qi.length;s++)qi[s].bucket=s;class Vh{constructor(e){this.view=e,this.buckets=qi.map(()=>[]),this.index=qi.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let n=e.bucket,r=this.buckets[n],o=this.index[n];for(let l=r.length-1;l>=0;l--){let a=(l+o)%r.length,h=r[a];if((!t||t(h))&&!this.reused.has(h))return r.splice(a,1),a<o&&this.index[n]--,this.reused.set(h,i),h}return null}findWidget(e,t,i){let n=this.buckets[0];if(n.length)for(let r=0,o=0;;r++){if(r==n.length){if(o)return null;o=1,r=0}let l=n[r];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view,l.widget)))return n.splice(r,1),r<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new ut(l.dom,t,e,l.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class zh{constructor(e,t,i,n,r){this.view=e,this.decorations=n,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new Vh(e),this.text=new Hh(e.state.doc),this.builder=new Fh(this.cache,new fn(e,e.contentDOM),R.iter(i)),this.cache.reused.set(t,2),this.old=new Nh(t),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let n=0,r=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>n){let h=a-n;this.preserve(h,!o,!l),n=a,r+=h}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(r,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(r,l.toB)),r=l.toB,n=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let n=Kh(this.old),r=this.openMarks;this.old.advance(e,i?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l<o.length?ut.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,n,r),r=n.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,n,r,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),n,r)),r=n.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Qi)this.cache.add(o);else if(o instanceof oe)this.builder.ensureLine(null),this.builder.addMark(o,n,r),this.cache.reused.set(o,1),r=n.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof oe&&n.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?n.length&&(n.length=r=0):o instanceof oe&&(n.shift(),r=Math.min(r,n.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,n=this.builder,r=0,o=R.spans(this.decorations,e,t,{point:(l,a,h,f,c,u)=>{if(h instanceof ft){if(this.disallowBlockEffectsFor[u]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=f.length,c>f.length)n.continueWidget(a-l);else{let d=h.widget||(h.block?Bt.block:Bt.inline),p=Qh(h),g=this.cache.findWidget(d,a-l,p)||ut.of(d,this.view,a-l,p);h.block?(h.startSide>0&&n.addLineStartIfNotCovered(i),n.addBlockWidget(g)):(n.ensureLine(i),n.addInlineWidget(g,f,c))}i=null}else i=qh(i,h);a>l&&this.text.skip(a-l)},span:(l,a,h,f)=>{for(let c=l;c<a;){let u=this.text.next(Math.min(512,a-c));u==null?(n.addLineStartIfNotCovered(i),n.addBreak(),c++):(n.ensureLine(i),n.addText(u,h,c==l?f:h.length),c+=u.length),i=null}}});n.addLineStartIfNotCovered(i),this.openWidget=o>r,this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let n=e.parentNode;;n=n.parentNode){let r=K.get(n);if(n==this.view.contentDOM)break;r instanceof oe?t.push(r):r!=null&&r.isLine()?i=r:r instanceof He||(n.nodeName=="DIV"&&!i&&n!=this.view.contentDOM?i=new Tt(n,Tl):i||t.push(oe.of(new ri({tagName:n.nodeName.toLowerCase(),attributes:gh(n)}),n)))}return{line:i,marks:t}}}function Sr(s,e){let t=i=>{for(let n of i.children)if((e?n.isText():n.length)||t(n))return!0;return!1};return t(s)}function Qh(s){let e=s.isReplace?(s.startSide<0?64:0)|(s.endSide>0?128:0):s.startSide>0?32:16;return s.block&&(e|=256),e}const Tl={class:"cm-line"};function qh(s,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(s||(s={class:"cm-line"}),t&&Ns(t,s),i&&(s.class+=" "+i)),s}function Kh(s){let e=[];for(let t=s.parents.length;t>1;t--){let i=t==s.parents.length?s.tile:s.parents[t].tile;i instanceof oe&&e.push(i.mark)}return e}function vn(s){let e=K.get(s);return e&&e.setDOM(s.cloneNode()),s}class Bt extends ln{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Bt.inline=new Bt("span");Bt.block=new Bt("div");const Sn=new class extends ln{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Cr{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=G.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.updateDeco(),this.tile=new fn(e,e.contentDOM),this.updateInner([new ge(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:f,toA:c})=>c<this.minWidthFrom||f>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?n=this.domChanged.newSel.head:!Zh(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?jh(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:f,to:c}=this.hasComposition;i=new ge(f,c,e.changes.mapPos(f,-1),e.changes.mapPos(c,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(v.ie||v.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=_h(o,this.decorations,e.changes);a.length&&(i=ge.extendWithRanges(i,a));let h=Yh(l,this.blockWrappers,e.changes);return h.length&&(i=ge.extendWithRanges(i,h)),r&&!i.some(f=>f.fromA<=r.range.fromA&&f.toA>=r.range.toA)&&(i=r.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new zh(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&K.get(t.text)&&l.cache.reused.set(K.get(t.text),2),this.tile=l.run(e,t),fs(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=v.chrome||v.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||i.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.tile.children)r.isWidget()&&r.widget instanceof Cn&&n.push(r.dom);i.updateGaps(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(vl)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,n=this.view.root.activeElement,r=n==i,o=!r&&!(this.view.state.facet(Ne)||i.tabIndex>-1)&&Ut(i,this.view.observer.selectionRange)&&!(n&&i.contains(n));if(!(r||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,f;if(a.empty?f=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(f=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),v.gecko&&a.empty&&!this.hasComposition&&Uh(h)){let u=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(u,h.node.childNodes[h.offset]||null)),h=f=new xe(u,0),l=!0}let c=this.view.observer.selectionRange;(l||!c.focusNode||(!jt(h.node,h.offset,c.anchorNode,c.anchorOffset)||!jt(f.node,f.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,a))&&(this.view.observer.ignore(()=>{v.android&&v.chrome&&i.contains(c.focusNode)&&Jh(c.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let u=ei(this.view.root);if(u)if(a.empty){if(v.gecko){let d=$h(h.node,h.offset);if(d&&d!=3){let p=(d==1?ll:al)(h.node,h.offset);p&&(h=new xe(p.node,p.offset))}}u.collapse(h.node,h.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(h.node,h.offset);try{u.extend(f.node,f.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,f]=[f,h]),d.setEnd(f.node,f.offset),d.setStart(h.node,h.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(h,f)),this.impreciseAnchor=h.precise?null:new xe(c.anchorNode,c.anchorOffset),this.impreciseHead=f.precise?null:new xe(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&jt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=ei(e.root),{anchorNode:n,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let f=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(f.node,f.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&i.collapse(n,r)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let n=i.posAtStart;if(i.isComposite()){let r;if(e==i.dom)r=i.dom.childNodes[t];else{let o=Ve(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?r=e:r=e.nextSibling}if(r==i.dom.firstChild)return n;for(;r&&!K.get(r);)r=r.nextSibling;if(!r)return n+i.length;for(let o=0,l=n;;o++){let a=i.children[o];if(a.dom==r)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?n+t:n+(t?i.length:0):n}domAtPos(e,t){let{tile:i,offset:n}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(e,t):i.domIn(n,t)}inlineDOMNearPos(e,t){let i,n=-1,r=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,f)=>{if(h.isWidget()){if(h.flags&32&&f>=e)return!0;h.flags&16&&(r=!0)}else{let c=f+h.length;if(f<=e&&(i=h,n=e-f,r=c<e),c>=e&&!o&&(o=h,l=e-f,a=f>e),f>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(r&&o?i=null:a&&i&&(o=null),i&&t<0||!o?i.domIn(n,t):o.domIn(l,t))}coordsAt(e,t){let{tile:i,offset:n}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof Cn?null:i.coordsInWidget(n,t,!0):i.coordsIn(n,t)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function n(r,o){if(r.isComposite())for(let l of r.children){if(l.length>=o){let a=n(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(r.isText()&&o<r.length){let l=te(r.text,o);if(l==o)return null;let a=ti(r.dom,o,l).getClientRects();for(let h=0;h<a.length;h++){let f=a[h];if(h==a.length-1||f.top<f.bottom&&f.left<f.right)return f}}return null}return n(t,i)}measureVisibleLineHeights(e){let t=[],{from:i,to:n}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==j.LTR,h=0,f=(c,u,d)=>{for(let p=0;p<c.children.length&&!(u>n);p++){let g=c.children[p],m=u+g.length,y=g.dom.getBoundingClientRect(),{height:w}=y;if(d&&!p&&(h+=y.top-d.top),g instanceof He)m>i&&f(g,u,y);else if(u>=i&&(h>0&&t.push(-h),t.push(w+h),h=0,o)){let S=g.dom.lastChild,L=S?Di(S):[];if(L.length){let M=L[L.length-1],O=a?M.right-y.left:y.right-M.left;O>l&&(l=O,this.minWidth=r,this.minWidthFrom=u,this.minWidthTo=m)}}d&&p==c.children.length-1&&(h+=d.bottom-y.bottom),u=m+g.breakAfter}};return f(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?j.RTL:j.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let f=Di(h.dom);if(f.length!=1)return;l+=f[0].width,a=f[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),i,n,r;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.tile.dom.appendChild(t);let o=Di(t.firstChild)[0];i=t.getBoundingClientRect().height,n=o&&o.width?o.width/27:7,r=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:n,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let r=n==t.viewports.length?null:t.viewports[n],o=r?r.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(G.replace({widget:new Cn(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return G.set(e)}updateDeco(){let e=1,t=this.view.state.facet(an).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),i=!1,n=this.view.state.facet(Qs).map((r,o)=>{let l=typeof r=="function";return l&&(i=!0),l?r(this.view):r});for(n.length&&(this.dynamicDecorationMap[e++]=i,t.push(R.join(n))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(Cl).map(r=>typeof r=="function"?r(this.view):r)}scrollIntoView(e){var t;if(e.isSnapshot){let f=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=f.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let f of this.view.state.facet(wl))try{if(f(this.view,e.range,e))return!0}catch(c){Re(this.view.state,c,"scroll handler")}let{range:i}=e,n=this.coordsAt(i.head,(t=i.assoc)!==null&&t!==void 0?t:i.empty?0:i.head>i.anchor?-1:1),r;if(!n)return;!i.empty&&(r=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let o=Ml(this.view),l={left:n.left-o.left,top:n.top-o.top,right:n.right+o.right,bottom:n.bottom+o.bottom},{offsetWidth:a,offsetHeight:h}=this.view.scrollDOM;if(kh(this.view.scrollDOM,l,i.head<i.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,a),-a),Math.max(Math.min(e.yMargin,h),-h),this.view.textDirection==j.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let f=this.view.docView.lineAt(i.head,1);f&&f.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let t=i=>i.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){fs(this.tile)}}function fs(s,e){let t=e==null?void 0:e.get(s);if(t!=1){t==null&&s.destroy();for(let i of s.children)fs(i,e)}}function Uh(s){return s.node.nodeType==1&&s.node.firstChild&&(s.offset==0||s.node.childNodes[s.offset-1].contentEditable=="false")&&(s.offset==s.node.childNodes.length||s.node.childNodes[s.offset].contentEditable=="false")}function Bl(s,e){let t=s.observer.selectionRange;if(!t.focusNode)return null;let i=ll(t.focusNode,t.focusOffset),n=al(t.focusNode,t.focusOffset),r=i||n;if(n&&i&&n.node!=i.node){let l=K.get(n.node);if(!l||l.isText()&&l.text!=n.node.nodeValue)r=n;else if(s.docView.lastCompositionAfterCursor){let a=K.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(r=n)}}if(s.docView.lastCompositionAfterCursor=r!=i,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function jh(s,e,t){let i=Bl(s,t);if(!i)return null;let{node:n,from:r,to:o}=i,l=n.nodeValue;if(/[\n\r]/.test(l)||s.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new ge(a.mapPos(r),a.mapPos(o),r,o),text:n}}function $h(s,e){return s.nodeType!=1?0:(e&&s.childNodes[e-1].contentEditable=="false"?1:0)|(e<s.childNodes.length&&s.childNodes[e].contentEditable=="false"?2:0)}let Gh=class{constructor(){this.changes=[]}compareRange(e,t){St(e,t,this.changes)}comparePoint(e,t){St(e,t,this.changes)}boundChange(e){St(e,e,this.changes)}};function _h(s,e,t){let i=new Gh;return R.compare(s,e,t,i),i.changes}class Xh{constructor(){this.changes=[]}compareRange(e,t){St(e,t,this.changes)}comparePoint(){}boundChange(e){St(e,e,this.changes)}}function Yh(s,e,t){let i=new Xh;return R.compare(s,e,t,i),i.changes}function Jh(s,e){for(let t=s;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Zh(s,e){let t=!1;return e&&s.iterChangedRanges((i,n)=>{i<e.to&&n>e.from&&(t=!0)}),t}class Cn extends ln{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function ef(s,e,t=1){let i=s.charCategorizer(e),n=s.doc.lineAt(e),r=e-n.from;if(n.length==0)return b.cursor(e);r==0?t=1:r==n.length&&(t=-1);let o=r,l=r;t<0?o=te(n.text,r,!1):l=te(n.text,r);let a=i(n.text.slice(o,l));for(;o>0;){let h=te(n.text,o,!1);if(i(n.text.slice(h,o))!=a)break;o=h}for(;l<n.length;){let h=te(n.text,l);if(i(n.text.slice(l,h))!=a)break;l=h}return b.range(o+n.from,l+n.from)}function tf(s,e,t,i,n){let r=Math.round((i-e.left)*s.defaultCharacterWidth);if(s.lineWrapping&&t.height>s.defaultLineHeight*1.5){let l=s.viewState.heightOracle.textHeight,a=Math.floor((n-t.top-(s.defaultLineHeight-l)*.5)/l);r+=a*s.viewState.heightOracle.lineLength}let o=s.state.sliceDoc(t.from,t.to);return t.from+ah(o,r,s.state.tabSize)}function nf(s,e,t){let i=s.lineBlockAt(e);if(Array.isArray(i.type)){let n;for(let r of i.type){if(r.from>e)break;if(!(r.to<e)){if(r.from<e&&r.to>e)return r;(!n||r.type==le.Text&&(n.type!=r.type||(t<0?r.from<e:r.to>e)))&&(n=r)}}return n||i}return i}function sf(s,e,t,i){let n=nf(s,e.head,e.assoc||-1),r=!i||n.type!=le.Text||!(s.lineWrapping||n.widgetLineBreaks)?null:s.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head);if(r){let o=s.dom.getBoundingClientRect(),l=s.textDirectionAt(n.from),a=s.posAtCoords({x:t==(l==j.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return b.cursor(a,t?-1:1)}return b.cursor(t?n.to:n.from,t?-1:1)}function Ar(s,e,t,i){let n=s.state.doc.lineAt(e.head),r=s.bidiSpans(n),o=s.textDirectionAt(n.from);for(let l=e,a=null;;){let h=Bh(n,r,o,l,t),f=dl;if(!h){if(n.number==(t?s.state.doc.lines:1))return l;f=`
|
|
8
|
+
`,n=s.state.doc.line(n.number+(t?1:-1)),r=s.bidiSpans(n),h=s.visualLineSide(n,!t)}if(a){if(!a(f))return l}else{if(!i)return h;a=i(f)}l=h}}function rf(s,e,t){let i=s.state.charCategorizer(e),n=i(t);return r=>{let o=i(r);return n==We.Space&&(n=o),n==o}}function of(s,e,t,i){let n=e.head,r=t?1:-1;if(n==(t?s.state.doc.length:0))return b.cursor(n,e.assoc);let o=e.goalColumn,l,a=s.contentDOM.getBoundingClientRect(),h=s.coordsAtPos(n,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),f=s.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let p=s.viewState.lineBlockAt(n);o==null&&(o=Math.min(a.right-a.left,s.defaultCharacterWidth*(n-p.from))),l=(r<0?p.top:p.bottom)+f}let c=a.left+o,u=s.viewState.heightOracle.textHeight>>1,d=i??u;for(let p=0;;p+=u){let g=l+(d+p)*r,m=cs(s,{x:c,y:g},!1,r);if(t?g>a.bottom:g<a.top)return b.cursor(m.pos,m.assoc);let y=s.coordsAtPos(m.pos,m.assoc),w=y?(y.top+y.bottom)/2:0;if(!y||(t?w>l:w<l))return b.cursor(m.pos,m.assoc,void 0,o)}}function $t(s,e,t){for(;;){let i=0;for(let n of s)n.between(e-1,e+1,(r,o,l)=>{if(e>r&&e<o){let a=i||t||(e-r<o-e?-1:1);e=a<0?r:o,i=a}});if(!i)return e}}function Dl(s,e){let t=null;for(let i=0;i<e.ranges.length;i++){let n=e.ranges[i],r=null;if(n.empty){let o=$t(s,n.from,0);o!=n.from&&(r=b.cursor(o,-1))}else{let o=$t(s,n.from,-1),l=$t(s,n.to,1);(o!=n.from||l!=n.to)&&(r=b.range(n.from==n.anchor?o:l,n.from==n.head?o:l))}r&&(t||(t=e.ranges.slice()),t[i]=r)}return t?b.create(t,e.mainIndex):e}function An(s,e,t){let i=$t(s.state.facet(li).map(n=>n(s)),t.from,e.head>t.from?-1:1);return i==t.from?t:b.cursor(i,i<t.from?1:-1)}class Pe{constructor(e,t){this.pos=e,this.assoc=t}}function cs(s,e,t,i){let n=s.contentDOM.getBoundingClientRect(),r=n.top+s.viewState.paddingTop,{x:o,y:l}=e,a=l-r,h;for(;;){if(a<0)return new Pe(0,1);if(a>s.viewState.docHeight)return new Pe(s.state.doc.length,-1);if(h=s.elementAtHeight(a),i==null)break;if(h.type==le.Text){if(i<0?h.to<s.viewport.from:h.from>s.viewport.to)break;let u=s.docView.coordsAt(i<0?h.from:h.to,i>0?-1:1);if(u&&(i<0?u.top<=a+r:u.bottom>=a+r))break}let c=s.viewState.heightOracle.textHeight/2;a=i>0?h.bottom+c:h.top-c}if(s.viewport.from>=h.to||s.viewport.to<=h.from){if(t)return null;if(h.type==le.Text){let c=tf(s,n,h,o,l);return new Pe(c,c==h.from?1:-1)}}if(h.type!=le.Text)return a<(h.top+h.bottom)/2?new Pe(h.from,1):new Pe(h.to,-1);let f=s.docView.lineAt(h.from,2);return(!f||f.length!=h.length)&&(f=s.docView.lineAt(h.from,-2)),new lf(s,o,l,s.textDirectionAt(h.from)).scanTile(f,h.from)}class lf{constructor(e,t,i,n){this.view=e,this.x=t,this.y=i,this.baseDir=n,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[Le.find(n,e-i.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[Le.find(n,e-i.from,-1,t)].dir}bidiIn(e,t){let{spans:i,line:n}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+n.from<t)}scan(e,t){let i=0,n=e.length-1,r=new Set,o=this.bidiIn(e[0],e[n]),l,a,h=-1,f=1e9,c;e:for(;i<n;){let d=n-i,p=i+n>>1;t:if(r.has(p)){let m=i+Math.floor(Math.random()*d);for(let y=0;y<d;y++){if(!r.has(m)){p=m;break t}m++,m==n&&(m=i)}break e}r.add(p);let g=t(p);if(g)for(let m=0;m<g.length;m++){let y=g[m],w=0;if(!(y.width==0&&g.length>1)){if(y.bottom<this.y)(!l||l.bottom<y.bottom)&&(l=y),w=1;else if(y.top>this.y)(!a||a.top>y.top)&&(a=y),w=-1;else{let S=y.left>this.x?this.x-y.left:y.right<this.x?this.x-y.right:0,L=Math.abs(S);L<f&&(h=p,f=L,c=y),S&&(w=S<0==(this.baseDir==j.LTR)?-1:1)}w==-1&&(!o||this.baseDirAt(e[p],1))?n=p:w==1&&(!o||this.baseDirAt(e[p+1],-1))&&(i=p+1)}}}if(!c){let d=l&&(!a||this.y-l.bottom<a.top-this.y)?l:a;return this.y=(d.top+d.bottom)/2,this.scan(e,t)}let u=(o?this.dirAt(e[h],1):this.baseDir)==j.LTR;return{i:h,after:this.x>(c.left+c.right)/2==u}}scanText(e,t){let i=[];for(let r=0;r<e.length;r=te(e.text,r))i.push(t+r);i.push(t+e.length);let n=this.scan(i,r=>{let o=i[r]-t,l=i[r+1]-t;return ti(e.dom,o,l).getClientRects()});return n.after?new Pe(i[n.i+1],-1):new Pe(i[n.i],1)}scanTile(e,t){if(!e.length)return new Pe(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let i=[t];for(let l=0,a=t;l<e.children.length;l++)i.push(a+=e.children[l].length);let n=this.scan(i,l=>{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:ti(a.dom,0,a.length)).getClientRects()}),r=e.children[n.i],o=i[n.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):n.after?new Pe(i[n.i+1],-1):new Pe(o,1)}}const yt="";class af{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(I.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=yt}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let n=e;;){this.findPointBefore(i,n);let r=this.text.length;this.readNode(n);let o=K.get(n),l=n.nextSibling;if(l==t){o!=null&&o.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=K.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Hi(n))||Hi(l)&&(n.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>r)&&!ff(l,t)&&this.lineBreak(),n=l}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=n.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(e){let t=K.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(hf(e,i.node,i.offset)?t:0))}}function hf(s,e,t){for(;;){if(!e||t<Ve(e))return!1;if(e==s)return!0;t=Ye(e)+1,e=e.parentNode}}function ff(s,e){let t;for(;!(s==e||!s);s=s.nextSibling){let i=K.get(s);if(!(i!=null&&i.isWidget()))return!1;i&&(t||(t=[])).push(i)}if(t)for(let i of t){let n=i.overrideDOMText;if(n!=null&&n.length)return!1}return!0}class Or{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class cf{constructor(e,t,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Pl(e.docView.tile,t,i,0))){let a=r||o?[]:df(e),h=new af(a,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=pf(a,this.bounds.from)}else{let a=e.observer.selectionRange,h=r&&r.node==a.focusNode&&r.offset==a.focusOffset||!rs(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),f=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!rs(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),c=e.viewport;if((v.ios||v.chrome)&&l.main.empty&&h!=f&&(c.from>0||c.to<e.state.doc.length)){let u=Math.min(h,f),d=Math.max(h,f),p=c.from-u,g=c.to-d;(p==0||p==1||u==0)&&(g==0||g==-1||d==e.state.doc.length)&&(h=0,f=e.state.doc.length)}if(e.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(b.range(f,h));else if(e.lineWrapping&&f==h&&!(l.main.empty&&l.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let u=e.coordsAtPos(h,-1),d=0;u&&(d=e.inputState.lastTouchY<=u.bottom?-1:1),this.newSel=b.create([b.cursor(h,d)])}else this.newSel=b.single(f,h)}}}function Pl(s,e,t,i){if(s.isComposite()){let n=-1,r=-1,o=-1,l=-1;for(let a=0,h=i,f=i;a<s.children.length;a++){let c=s.children[a],u=h+c.length;if(h<e&&u>t)return Pl(c,e,t,h);if(u>=e&&n==-1&&(n=a,r=h),h>t&&c.dom.parentNode==s.dom){o=a,l=f;break}f=u,h=u+c.breakAfter}return{from:r,to:l<0?i+s.length:l,startDOM:(n?s.children[n-1].dom.nextSibling:null)||s.dom.firstChild,endDOM:o<s.children.length&&o>=0?s.children[o].dom:null}}else return s.isText()?{from:i,to:i+s.length,startDOM:s.dom,endDOM:s.dom.nextSibling}:null}function Ll(s,e){let t,{newSel:i}=e,{state:n}=s,r=n.selection.main,o=s.inputState.lastKeyTime>Date.now()-100?s.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,h=r.from,f=null;(o===8||v.android&&e.text.length<a-l)&&(h=r.to,f="end");let c=n.doc.sliceString(l,a,yt),u,d;!r.empty&&r.from>=l&&r.to<=a&&(e.typeOver||c!=e.text)&&c.slice(0,r.from-l)==e.text.slice(0,r.from-l)&&c.slice(r.to-l)==e.text.slice(u=e.text.length-(c.length-(r.to-l)))?t={from:r.from,to:r.to,insert:E.of(e.text.slice(r.from-l,u).split(yt))}:(d=Rl(c,e.text,h-l,f))&&(v.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==yt+yt&&d.toB--,t={from:l+d.from,to:l+d.toA,insert:E.of(e.text.slice(d.from,d.toB).split(yt))})}else i&&(!s.hasFocus&&n.facet(Ne)||Ki(i,r))&&(i=null);if(!t&&!i)return!1;if((v.mac||v.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&s.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=b.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:E.of([t.insert.toString().replace("."," ")])}):n.doc.lineAt(r.from).to<r.to&&s.docView.lineHasWidget(r.to)&&s.inputState.insertingTextAt>Date.now()-50?t={from:r.from,to:r.to,insert:n.toText(s.inputState.insertingText)}:v.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
|
|
9
|
+
`&&s.lineWrapping&&(i&&(i=b.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:E.of([" "])}),t)return qs(s,t,i,o);if(i&&!Ki(i,r)){let l=!1,a="select";return s.inputState.lastSelectionTime>Date.now()-50&&(s.inputState.lastSelectionOrigin=="select"&&(l=!0),a=s.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=Dl(n.facet(li).map(h=>h(s)),i))),s.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function qs(s,e,t,i=-1){if(v.ios&&s.inputState.flushIOSKey(e))return!0;let n=s.state.selection.main;if(v.android&&(e.to==n.to&&(e.from==n.from||e.from==n.from-1&&s.state.sliceDoc(e.from,n.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ct(s.contentDOM,"Enter",13)||(e.from==n.from-1&&e.to==n.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>n.head)&&Ct(s.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&e.insert.length==0&&Ct(s.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();s.inputState.composing>=0&&s.inputState.composing++;let o,l=()=>o||(o=uf(s,e,t));return s.state.facet(kl).some(a=>a(s,e.from,e.to,r,l))||s.dispatch(l()),!0}function uf(s,e,t){let i,n=s.state,r=n.selection.main,o=-1;if(e.from==e.to&&e.from<r.from||e.from>r.to){let a=e.from<r.from?-1:1,h=a<0?r.from:r.to,f=$t(n.facet(li).map(c=>c(s)),h,a);e.from==f&&(o=f)}if(o>-1)i={changes:e,selection:b.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&s.inputState.composing<0){let a=r.from<e.from?n.sliceDoc(r.from,e.from):"",h=r.to>e.to?n.sliceDoc(e.to,r.to):"";i=n.replaceSelection(s.state.toText(a+e.insert.sliceString(0,void 0,s.state.lineBreak)+h))}else{let a=n.changes(e),h=t&&t.main.to<=a.newLength?t.main:void 0;if(n.selection.ranges.length>1&&(s.inputState.composing>=0||s.inputState.compositionPendingChange)&&e.to<=r.to+10&&e.to>=r.to-10){let f=s.state.sliceDoc(e.from,e.to),c,u=t&&Bl(s,t.main.head);if(u){let p=e.insert.length-(e.to-e.from);c={from:u.from,to:u.to-p}}else c=s.state.doc.lineAt(r.head);let d=r.to-e.to;i=n.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:a,range:h||p.map(a)};let g=p.to-d,m=g-f.length;if(s.state.sliceDoc(m,g)!=f||g>=c.from&&m<=c.to)return{range:p};let y=n.changes({from:m,to:g,insert:e.insert}),w=p.to-r.to;return{changes:y,range:h?b.range(Math.max(0,h.anchor+w),Math.max(0,h.head+w)):p.map(y)}})}else i={changes:a,selection:h&&n.selection.replaceRange(h)}}let l="input.type";return(s.composing||s.inputState.compositionPendingChange&&s.inputState.compositionEndedAt>Date.now()-50)&&(s.inputState.compositionPendingChange=!1,l+=".compose",s.inputState.compositionFirstChange&&(l+=".start",s.inputState.compositionFirstChange=!1)),n.update(i,{userEvent:l,scrollIntoView:!0})}function Rl(s,e,t,i){let n=Math.min(s.length,e.length),r=0;for(;r<n&&s.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==n&&s.length==e.length)return null;let o=s.length,l=e.length;for(;o>0&&l>0&&s.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o<r&&s.length<e.length){let a=t<=r&&t>=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l<r){let a=t<=r&&t>=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function df(s){let e=[];if(s.root.activeElement!=s.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}=s.observer.selectionRange;return t&&(e.push(new Or(t,i)),(n!=t||r!=i)&&e.push(new Or(n,r))),e}function pf(s,e){if(s.length==0)return null;let t=s[0].pos,i=s.length==2?s[1].pos:t;return t>-1&&i>-1?b.single(t+e,i+e):null}function Ki(s,e){return e.head==s.main.head&&e.anchor==s.main.anchor}class gf{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=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.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,v.safari&&e.contentDOM.addEventListener("input",()=>null),v.gecko&&Df(e.contentDOM.ownerDocument)}handleEvent(e){!Sf(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let n of i.observers)n(this.view,t);for(let n of i.handlers){if(t.defaultPrevented)break;if(n(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=mf(e),i=this.handlers,n=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=i[r];l&&o!=!l.handlers.length&&(n.removeEventListener(r,this.handleEvent),l=null),l||n.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!t[r]&&n.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Il.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),v.android&&v.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return v.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=El.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||yf.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Ct(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:v.safari&&!v.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Mr(s,e){return(t,i)=>{try{return e.call(s,i,t)}catch(n){Re(t.state,n)}}}function mf(s){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of s){let n=i.spec,r=n&&n.plugin.domEventHandlers,o=n&&n.plugin.domEventObservers;if(r)for(let l in r){let a=r[l];a&&t(l).handlers.push(Mr(i.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(Mr(i.value,a))}}for(let i in ve)t(i).handlers.push(ve[i]);for(let i in ae)t(i).observers.push(ae[i]);return e}const El=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],yf="dthko",Il=[16,17,18,20,91,92,224,225],gi=6;function mi(s){return Math.max(0,s)*.7+8}function kf(s,e){return Math.max(Math.abs(s.clientX-e.clientX),Math.abs(s.clientY-e.clientY))}class bf{constructor(e,t,i,n){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=sl(e.contentDOM),this.atoms=e.state.facet(li).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(I.allowMultipleSelections)&&xf(e,t),this.dragging=vf(e,t)&&Fl(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&kf(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,n=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Ml(this.view);e.clientX-a.left<=n+gi?t=-mi(n-e.clientX):e.clientX+a.right>=o-gi&&(t=mi(e.clientX-o)),e.clientY-a.top<=r+gi?i=-mi(r-e.clientY):e.clientY+a.bottom>=l-gi&&(i=mi(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=Dl(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function xf(s,e){let t=s.state.facet(pl);return t.length?t[0](e):v.mac?e.metaKey:e.ctrlKey}function wf(s,e){let t=s.state.facet(gl);return t.length?t[0](e):v.mac?!e.altKey:!e.ctrlKey}function vf(s,e){let{main:t}=s.state.selection;if(t.empty)return!1;let i=ei(s.root);if(!i||i.rangeCount==0)return!0;let n=i.getRangeAt(0).getClientRects();for(let r=0;r<n.length;r++){let o=n[r];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Sf(s,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=s.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=K.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const ve=Object.create(null),ae=Object.create(null),Nl=v.ie&&v.ie_version<15||v.ios&&v.webkit_version<604;function Cf(s){let e=s.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{s.focus(),t.remove(),Wl(s,t.value)},50)}function cn(s,e,t){for(let i of s.facet(e))t=i(t,s);return t}function Wl(s,e){e=cn(s.state,Hs,e);let{state:t}=s,i,n=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(us!=null&&t.selection.ranges.every(a=>a.empty)&&us==r.toString()){let a=-1;i=t.changeByRange(h=>{let f=t.doc.lineAt(h.from);if(f.from==a)return{range:h};a=f.from;let c=t.toText((o?r.line(n++).text:e)+t.lineBreak);return{changes:{from:f.from,insert:c},range:b.cursor(h.from+c.length)}})}else o?i=t.changeByRange(a=>{let h=r.line(n++);return{changes:{from:a.from,to:a.to,insert:h.text},range:b.cursor(a.from+h.length)}}):i=t.replaceSelection(r);s.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}ae.scroll=s=>{s.inputState.lastScrollTop=s.scrollDOM.scrollTop,s.inputState.lastScrollLeft=s.scrollDOM.scrollLeft};ae.wheel=ae.mousewheel=s=>{s.inputState.lastWheelEvent=Date.now()};ve.keydown=(s,e)=>(s.inputState.setSelectionOrigin("select"),e.keyCode==27&&s.inputState.tabFocusMode!=0&&(s.inputState.tabFocusMode=Date.now()+2e3),!1);ae.touchstart=(s,e)=>{let t=s.inputState,i=e.targetTouches[0];t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};ae.touchmove=s=>{s.inputState.setSelectionOrigin("select.pointer")};ve.mousedown=(s,e)=>{if(s.observer.flush(),s.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of s.state.facet(ml))if(t=i(s,e),t)break;if(!t&&e.button==0&&(t=Of(s,e)),t){let i=!s.hasFocus;s.inputState.startMouseSelection(new bf(s,e,t,i)),i&&s.observer.ignore(()=>{rl(s.contentDOM);let r=s.root.activeElement;r&&!r.contains(s.contentDOM)&&r.blur()});let n=s.inputState.mouseSelection;if(n)return n.start(e),n.dragging===!1}else s.inputState.setSelectionOrigin("select.pointer");return!1};function Tr(s,e,t,i){if(i==1)return b.cursor(e,t);if(i==2)return ef(s.state,e,t);{let n=s.docView.lineAt(e,t),r=s.state.doc.lineAt(n?n.posAtEnd:e),o=n?n.posAtStart:r.from,l=n?n.posAtEnd:r.to;return l<s.state.doc.length&&l==r.to&&l++,b.range(o,l)}}const Af=v.ie&&v.ie_version<=11;let Br=null,Dr=0,Pr=0;function Fl(s){if(!Af)return s.detail;let e=Br,t=Pr;return Br=s,Pr=Date.now(),Dr=!e||t>Date.now()-400&&Math.abs(e.clientX-s.clientX)<2&&Math.abs(e.clientY-s.clientY)<2?(Dr+1)%3:1}function Of(s,e){let t=s.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=Fl(e),n=s.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),n=n.map(r.changes))},get(r,o,l){let a=s.posAndSideAtCoords({x:r.clientX,y:r.clientY},!1),h,f=Tr(s,a.pos,a.assoc,i);if(t.pos!=a.pos&&!o){let c=Tr(s,t.pos,t.assoc,i),u=Math.min(c.from,f.from),d=Math.max(c.to,f.to);f=u<f.from?b.range(u,d,f.assoc):b.range(d,u,f.assoc)}return o?n.replaceRange(n.main.extend(f.from,f.to,f.assoc)):l&&i==1&&n.ranges.length>1&&(h=Mf(n,a.pos))?h:l?n.addRange(f):b.create([f])}}}function Mf(s,e){for(let t=0;t<s.ranges.length;t++){let{from:i,to:n}=s.ranges[t];if(i<=e&&n>=e)return b.create(s.ranges.slice(0,t).concat(s.ranges.slice(t+1)),s.mainIndex==t?0:s.mainIndex-(s.mainIndex>t?1:0))}return null}ve.dragstart=(s,e)=>{let{selection:{main:t}}=s.state;if(e.target.draggable){let n=s.docView.tile.nearest(e.target);if(n&&n.isWidget()){let r=n.posAtStart,o=r+n.length;(r>=t.to||o<=t.from)&&(t=b.range(r,o))}}let{inputState:i}=s;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",cn(s.state,Vs,s.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};ve.dragend=s=>(s.inputState.draggedContent=null,!1);function Lr(s,e,t,i){if(t=cn(s.state,Hs,t),!t)return;let n=s.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=s.inputState,o=i&&r&&wf(s,e)?{from:r.from,to:r.to}:null,l={from:n,insert:t},a=s.state.changes(o?[o,l]:l);s.focus(),s.dispatch({changes:a,selection:{anchor:a.mapPos(n,-1),head:a.mapPos(n,1)},userEvent:o?"move.drop":"input.drop"}),s.inputState.draggedContent=null}ve.drop=(s,e)=>{if(!e.dataTransfer)return!1;if(s.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),n=0,r=()=>{++n==t.length&&Lr(s,e,i.filter(o=>o!=null).join(s.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=r,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Lr(s,e,i,!0),!0}return!1};ve.paste=(s,e)=>{if(s.state.readOnly)return!0;s.observer.flush();let t=Nl?null:e.clipboardData;return t?(Wl(s,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Cf(s),!1)};function Tf(s,e){let t=s.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),s.focus()},50)}function Bf(s){let e=[],t=[],i=!1;for(let n of s.selection.ranges)n.empty||(e.push(s.sliceDoc(n.from,n.to)),t.push(n));if(!e.length){let n=-1;for(let{from:r}of s.selection.ranges){let o=s.doc.lineAt(r);o.number>n&&(e.push(o.text),t.push({from:o.from,to:Math.min(s.doc.length,o.to+1)})),n=o.number}i=!0}return{text:cn(s,Vs,e.join(s.lineBreak)),ranges:t,linewise:i}}let us=null;ve.copy=ve.cut=(s,e)=>{if(!Ut(s.contentDOM,s.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:n}=Bf(s.state);if(!t&&!n)return!1;us=n?t:null,e.type=="cut"&&!s.state.readOnly&&s.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=Nl?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(Tf(s,t),!1)};const Hl=Rt.define();function Vl(s,e){let t=[];for(let i of s.facet(bl)){let n=i(s,e);n&&t.push(n)}return t.length?s.update({effects:t,annotations:Hl.of(!0)}):null}function zl(s){setTimeout(()=>{let e=s.hasFocus;if(e!=s.inputState.notifiedFocused){let t=Vl(s.state,e);t?s.dispatch(t):s.update([])}},10)}ae.focus=s=>{s.inputState.lastFocusTime=Date.now(),!s.scrollDOM.scrollTop&&(s.inputState.lastScrollTop||s.inputState.lastScrollLeft)&&(s.scrollDOM.scrollTop=s.inputState.lastScrollTop,s.scrollDOM.scrollLeft=s.inputState.lastScrollLeft),zl(s)};ae.blur=s=>{s.observer.clearSelectionRange(),zl(s)};ae.compositionstart=ae.compositionupdate=s=>{s.observer.editContext||(s.inputState.compositionFirstChange==null&&(s.inputState.compositionFirstChange=!0),s.inputState.composing<0&&(s.inputState.composing=0))};ae.compositionend=s=>{s.observer.editContext||(s.inputState.composing=-1,s.inputState.compositionEndedAt=Date.now(),s.inputState.compositionPendingKey=!0,s.inputState.compositionPendingChange=s.observer.pendingRecords().length>0,s.inputState.compositionFirstChange=null,v.chrome&&v.android?s.observer.flushSoon():s.inputState.compositionPendingChange?Promise.resolve().then(()=>s.observer.flush()):setTimeout(()=>{s.inputState.composing<0&&s.docView.hasComposition&&s.update([])},50))};ae.contextmenu=s=>{s.inputState.lastContextMenu=Date.now()};ve.beforeinput=(s,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(s.inputState.insertingText=e.data,s.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&s.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let l=o[0],a=s.posAtDOM(l.startContainer,l.startOffset),h=s.posAtDOM(l.endContainer,l.endOffset);return qs(s,{from:a,to:h,insert:s.state.toText(r)},null),!0}}let n;if(v.chrome&&v.android&&(n=El.find(r=>r.inputType==e.inputType))&&(s.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let r=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&s.hasFocus&&(s.contentDOM.blur(),s.focus())},100)}return v.ios&&e.inputType=="deleteContentForward"&&s.observer.flushSoon(),v.safari&&e.inputType=="insertText"&&s.inputState.composing>=0&&setTimeout(()=>ae.compositionend(s,e),20),!1};const Rr=new Set;function Df(s){Rr.has(s)||(Rr.add(s),s.addEventListener("copy",()=>{}),s.addEventListener("cut",()=>{}))}const Er=["pre-wrap","normal","pre-line","break-spaces"];let Dt=!1;function Ir(){Dt=!1}class Pf{constructor(e){this.lineWrapping=e,this.doc=E.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Er.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let n=e[i];n<0?i++:this.heightSamples[Math.floor(n*10)]||(t=!0,this.heightSamples[Math.floor(n*10)]=!0)}return t}refresh(e,t,i,n,r,o){let l=Er.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l||Math.abs(i-this.charWidth)>.1;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=n,this.lineLength=r,a){this.heightSamples={};for(let h=0;h<o.length;h++){let f=o[h];f<0?h++:this.heightSamples[Math.floor(f*10)]=!0}}return a}}class Lf{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class be{constructor(e,t,i,n,r){this.from=e,this.length=t,this.top=i,this.height=n,this._content=r}get type(){return typeof this._content=="number"?le.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 ft?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new be(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var F=(function(s){return s[s.ByPos=0]="ByPos",s[s.ByHeight=1]="ByHeight",s[s.ByPosNoHeight=2]="ByPosNoHeight",s})(F||(F={}));const Pi=.001;class re{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}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)>Pi&&(Dt=!0),this.height=e)}replace(e,t,i){return re.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let r=this,o=i.doc;for(let l=n.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:f,toB:c}=n[l],u=r.lineAt(a,F.ByPosNoHeight,i.setDoc(t),0,0),d=u.to>=h?u:r.lineAt(h,F.ByPosNoHeight,i,0,0);for(c+=d.to-h,h=d.to;l>0&&u.from<=n[l-1].toA;)a=n[l-1].fromA,f=n[l-1].fromB,l--,a<u.from&&(u=r.lineAt(a,F.ByPosNoHeight,i,0,0));f+=u.from-a,a=u.from;let p=Ks.build(i.setDoc(o),e,f,c);r=Ui(r,r.replace(a,h,p))}return r.updateHeight(i,0)}static empty(){return new ce(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,n=0,r=0;for(;;)if(t==i)if(n>r*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,n-=l.size}else if(r>n*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(n<r){let l=e[t++];l&&(n+=l.size)}else{let l=e[--i];l&&(r+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new Ef(re.of(e.slice(0,t)),o,re.of(e.slice(i)))}}function Ui(s,e){return s==e?s:(s.constructor!=e.constructor&&(Dt=!0),e)}re.prototype.size=1;const Rf=G.replace({});class Ql extends re{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new be(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,n){return this.spaceAbove&&e<i+this.spaceAbove?new be(n,0,i,this.spaceAbove,Rf):this.mainBlock(i,n)}lineAt(e,t,i,n,r){let o=this.mainBlock(n,r);return this.spaceAbove?this.blockAt(0,i,n,r).join(o):o}forEachLine(e,t,i,n,r,o){e<=r+this.length&&t>=r&&o(this.lineAt(0,F.ByPos,i,n,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more&&this.setMeasuredHeight(n),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ce extends Ql{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new be(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let n=i[0];return i.length==1&&(n instanceof ce||n instanceof J&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof J?n=new ce(n.length,this.height,this.spaceAbove):n.height=this.height,this.outdated||(n.outdated=!1),n):re.of(i)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more?this.setMeasuredHeight(n):(i||this.outdated)&&(this.spaceAbove=0,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:""})`}}class J extends re{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,r=n-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:n,perLine:o,perChar:l}}blockAt(e,t,i,n){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,n);if(t.lineWrapping){let h=n+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),f=t.doc.lineAt(h),c=l+f.length*a,u=Math.max(i,e-c/2);return new be(f.from,f.length,u,c,0)}else{let h=Math.max(0,Math.min(o-r,Math.floor((e-i)/l))),{from:f,length:c}=t.doc.line(r+h);return new be(f,c,i+l*h,l,0)}}lineAt(e,t,i,n,r){if(t==F.ByHeight)return this.blockAt(e,i,n,r);if(t==F.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(e);return new be(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,r),h=i.doc.lineAt(e),f=l+h.length*a,c=h.number-o,u=n+l*c+a*(h.from-r-c);return new be(h.from,h.length,Math.max(n,Math.min(u,n+this.height-f)),f,0)}forEachLine(e,t,i,n,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,r);for(let f=e,c=n;f<=t;){let u=i.doc.lineAt(f);if(f==e){let p=u.number-l;c+=a*p+h*(e-r-p)}let d=a+h*u.length;o(new be(u.from,u.length,c,d,0)),c+=d,f=u.to+1}}replace(e,t,i){let n=this.length-t;if(n>0){let r=i[i.length-1];r instanceof J?i[i.length-1]=new J(r.length+n):i.push(null,new J(n-1))}if(e>0){let r=i[0];r instanceof J?i[0]=new J(e+r.length):i.unshift(new J(e-1),null)}return re.of(i)}decomposeLeft(e,t){t.push(new J(e-1),null)}decomposeRight(e,t){t.push(null,new J(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let r=t+this.length;if(n&&n.from<=t+this.length&&n.more){let o=[],l=Math.max(t,n.from),a=-1;for(n.from>t&&o.push(new J(n.from-t-1).updateHeight(e,t));l<=r&&n.more;){let f=e.doc.lineAt(l).length;o.length&&o.push(null);let c=n.heights[n.index++],u=0;c<0&&(u=-c,c=n.heights[n.index++]),a==-1?a=c:Math.abs(c-a)>=Pi&&(a=-2);let d=new ce(f,c,u);d.outdated=!1,o.push(d),l+=f+1}l<=r&&o.push(null,new J(r-l).updateHeight(e,l));let h=re.of(o);return(a<0||Math.abs(h.height-this.height)>=Pi||Math.abs(a-this.heightMetrics(e,t).perLine)>=Pi)&&(Dt=!0),Ui(this,h)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Ef extends re{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,n){let r=i+this.left.height;return e<r?this.left.blockAt(e,t,i,n):this.right.blockAt(e,t,r,n+this.left.length+this.break)}lineAt(e,t,i,n,r){let o=n+this.left.height,l=r+this.left.length+this.break,a=t==F.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,i,n,r):this.right.lineAt(e,t,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let f=t==F.ByPosNoHeight?F.ByPosNoHeight:F.ByPos;return a?h.join(this.right.lineAt(l,f,i,o,l)):this.left.lineAt(l,f,i,n,r).join(h)}forEachLine(e,t,i,n,r,o){let l=n+this.left.height,a=r+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,n,r,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,F.ByPos,i,n,r);e<h.from&&this.left.forEachLine(e,h.from-1,i,n,r,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,l,a,o)}}replace(e,t,i){let n=this.left.length+this.break;if(t<n)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of i)r.push(l);if(e>0&&Nr(r,o-1),t<this.length){let l=r.length;this.decomposeRight(t,r),Nr(r,l)}return re.of(r)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<n&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?re.of(this.break?[e,null,t]:[e,t]):(this.left=Ui(this.left,e),this.right=Ui(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,n){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return n&&n.from<=t+r.length&&n.more?a=r=r.updateHeight(e,t,i,n):r.updateHeight(e,t,i),n&&n.from<=l+o.length&&n.more?a=o=o.updateHeight(e,l,i,n):o.updateHeight(e,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Nr(s,e){let t,i;s[e]==null&&(t=s[e-1])instanceof J&&(i=s[e+1])instanceof J&&s.splice(e-1,3,new J(t.length+1+i.length))}const If=5;class Ks{constructor(e,t){this.pos=e,this.oracle=t,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,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof ce?n.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ce(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,r=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new Ql(o,n,i)):(o||r||n>=If)&&this.addLineDeco(n,r,o)}else t>e&&this.span(e,t);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:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,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 ce(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new J(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ce)return e;let t=new ce(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof ce)&&!this.isCovered?this.nodes.push(new ce(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let n of this.nodes)n instanceof ce&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(e,t,i,n){let r=new Ks(i,e);return R.spans(t,i,n,r,0),r.finish(i)}}function Nf(s,e,t){let i=new Wf;return R.compare(s,e,t,i,0),i.changes}class Wf{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,n){(e<t||i&&i.heightRelevant||n&&n.heightRelevant)&&St(e,t,this.changes,5)}}function Ff(s,e){let t=s.getBoundingClientRect(),i=s.ownerDocument,n=i.defaultView||window,r=Math.max(0,t.left),o=Math.min(n.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(n.innerHeight,t.bottom);for(let h=s.parentNode;h&&h!=i.body;)if(h.nodeType==1){let f=h,c=window.getComputedStyle(f);if((f.scrollHeight>f.clientHeight||f.scrollWidth>f.clientWidth)&&c.overflow!="visible"){let u=f.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==s.parentNode?n.innerHeight:a,u.bottom)}h=c.position=="absolute"||c.position=="fixed"?f.offsetParent:f.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Hf(s){let e=s.getBoundingClientRect(),t=s.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function Vf(s,e){let t=s.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class On{constructor(e,t,i,n){this.from=e,this.to=t,this.size=i,this.displaySize=n}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let n=e[i],r=t[i];if(n.from!=r.from||n.to!=r.to||n.size!=r.size)return!1}return!0}draw(e,t){return G.replace({widget:new zf(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class zf extends ln{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Wr{constructor(e,t){this.view=e,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.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Fr,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=j.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=t.facet(zs).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new Pf(i),this.stateDeco=Hr(t),this.heightMap=re.empty().applyChanges(this.stateDeco,E.empty,this.heightOracle.setDoc(t.doc),[new ge(0,0,0,t.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=G.set(this.lineGaps.map(n=>n.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>n>=r&&n<=o)){let{from:r,to:o}=this.lineBlockAt(n);e.push(new yi(r,o))}}return this.viewports=e.sort((i,n)=>i.from-n.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Fr:new Us(this.heightOracle,this.heightMap,this.viewports),e.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,e=>{this.viewportLines.push(Qt(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Hr(this.state);let n=e.changedRanges,r=ge.extendWithRanges(n,Nf(i,this.stateDeco,e?e.changes:X.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Ir(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||Dt)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ph)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?j.RTL:j.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,f=0;if(l.width&&l.height){let{scaleX:M,scaleY:O}=nl(t,l);(M>.005&&Math.abs(this.scaleX-M)>.005||O>.005&&Math.abs(this.scaleY-O)>.005)&&(this.scaleX=M,this.scaleY=O,h|=16,o=a=!0)}let c=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=u)&&(this.paddingTop=c,this.paddingBottom=u,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let d=sl(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=ol(this.scrollParent||e.win);let g=(this.printing?Vf:Ff)(t,this.paddingTop),m=g.top-this.pixelViewport.top,y=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(a=!0)),!this.inView&&!this.scrollTarget&&!Hf(e.dom))return 0;let S=l.width;if((this.contentDOMWidth!=S||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),a){let M=e.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(M)&&(o=!0),o||n.lineWrapping&&Math.abs(S-this.contentDOMWidth)>n.charWidth){let{lineHeight:O,charWidth:C,textHeight:H}=e.docView.measureTextSize();o=O>0&&n.refresh(r,O,C,H,Math.max(5,S/C),M),o&&(e.docView.minWidth=0,h|=16)}m>0&&y>0?f=Math.max(m,y):m<0&&y<0&&(f=Math.min(m,y)),Ir();for(let O of this.viewports){let C=O.from==this.viewport.from?M:e.docView.measureVisibleLineHeights(O);this.heightMap=(o?re.empty().applyChanges(this.stateDeco,E.empty,this.heightOracle,[new ge(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new Lf(O.from,C))}Dt&&(h|=2)}let L=!this.viewportIsAppropriate(this.viewport,f)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return L&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(f,this.scrollTarget),h|=this.updateForViewport()),(h&2||L)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new yi(n.lineAt(o-i*1e3,F.ByHeight,r,0,0).from,n.lineAt(l+(1-i)*1e3,F.ByHeight,r,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let f=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=n.lineAt(h,F.ByPos,r,0,0),u;t.y=="center"?u=(c.top+c.bottom)/2-f/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=c.top:u=c.bottom-f,a=new yi(n.lineAt(u-1e3/2,F.ByHeight,r,0,0).from,n.lineAt(u+f+1e3/2,F.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),n=t.mapPos(e.to,1);return new yi(this.heightMap.lineAt(i,F.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,F.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(e,F.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,F.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||n<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||r>=l+Math.max(10,Math.min(i,250)))&&n>o-2*1e3&&r<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let n of e)t.touchesRange(n.from,n.to)||i.push(new On(t.mapPos(n.from),t.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,r=n>>1,o=n<<1;if(this.defaultTextDirection!=j.LTR&&!i)return[];let l=[],a=(f,c,u,d)=>{if(c-f<r)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let y of g)if(y>f&&y<c){a(f,y-10,u,d),a(y+10,c,u,d);return}let m=qf(e,y=>y.from>=u.from&&y.to<=u.to&&Math.abs(y.from-f)<r&&Math.abs(y.to-c)<r&&!g.some(w=>y.from<w&&y.to>w));if(!m){if(c<u.to&&t&&i&&t.visibleRanges.some(S=>S.from<=c&&S.to>=c)){let S=t.moveToLineBoundary(b.cursor(c),!1,!0).head;S>f&&(c=S)}let y=this.gapSize(u,f,c,d),w=i||y<2e6?y:2e6;m=new On(f,c,y,w)}l.push(m)},h=f=>{if(f.length<o||f.type!=le.Text)return;let c=Qf(f.from,f.to,this.stateDeco);if(c.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let g=n/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,y;if(u!=null){let w=bi(c,u),S=((this.visibleBottom-this.visibleTop)/2+g)/f.height;m=w-S,y=w+S}else m=(this.visibleTop-f.top-g)/f.height,y=(this.visibleBottom-f.top+g)/f.height;d=ki(c,m),p=ki(c,y)}else{let g=c.total*this.heightOracle.charWidth,m=n*this.heightOracle.charWidth,y=0;if(g>2e6)for(let O of e)O.from>=f.from&&O.from<f.to&&O.size!=O.displaySize&&O.from*this.heightOracle.charWidth+y<this.pixelViewport.left&&(y=O.size-O.displaySize);let w=this.pixelViewport.left+y,S=this.pixelViewport.right+y,L,M;if(u!=null){let O=bi(c,u),C=((S-w)/2+m)/g;L=O-C,M=O+C}else L=(w-m)/g,M=(S+m)/g;d=ki(c,L),p=ki(c,M)}d>f.from&&a(f.from,d,f,c),p<f.to&&a(p,f.to,f,c)};for(let f of this.viewportLines)Array.isArray(f.type)?f.type.forEach(h):h(f);return l}gapSize(e,t,i,n){let r=bi(n,i)-bi(n,t);return this.heightOracle.lineWrapping?e.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(e){On.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=G.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];R.spans(t,this.viewport.from,this.viewport.to,{span(r,o){i.push({from:r,to:o})},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 o=this.visibleRanges[r],l=i[r];(o.from!=l.from||o.to!=l.to)&&(n|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Qt(this.heightMap.lineAt(e,F.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Qt(this.heightMap.lineAt(this.scaler.fromDOM(e),F.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Qt(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class yi{constructor(e,t){this.from=e,this.to=t}}function Qf(s,e,t){let i=[],n=s,r=0;return R.spans(t,s,e,{span(){},point(o,l){o>n&&(i.push({from:n,to:o}),r+=o-n),n=l}},20),n<e&&(i.push({from:n,to:e}),r+=e-n),{total:r,ranges:i}}function ki({total:s,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(s*t);for(let n=0;;n++){let{from:r,to:o}=e[n],l=o-r;if(i<=l)return r+i;i-=l}}function bi(s,e){let t=0;for(let{from:i,to:n}of s.ranges){if(e<=n){t+=e-i;break}t+=n-i}return t/s.total}function qf(s,e){for(let t of s)if(e(t))return t}const Fr={toDOM(s){return s},fromDOM(s){return s},scale:1,eq(s){return s==this}};function Hr(s){let e=s.facet(an).filter(i=>typeof i!="function"),t=s.facet(Qs).filter(i=>typeof i!="function");return t.length&&e.push(R.join(t)),e}class Us{constructor(e,t,i){let n=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,F.ByPos,e,0,0).top,f=t.lineAt(a,F.ByPos,e,0,0).bottom;return n+=f-h,{from:l,to:a,top:h,bottom:f,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return n+(e-i)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);i=r.bottom,n=r.domBottom}}fromDOM(e){for(let t=0,i=0,n=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return i+(e-n)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);i=r.bottom,n=r.domBottom}}eq(e){return e instanceof Us?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function Qt(s,e){if(e.scale==1)return s;let t=e.toDOM(s.top),i=e.toDOM(s.bottom);return new be(s.from,s.length,t,i-t,Array.isArray(s._content)?s._content.map(n=>Qt(n,e)):s._content)}const xi=A.define({combine:s=>s.join(" ")}),ds=A.define({combine:s=>s.indexOf(!0)>-1}),ps=_e.newName(),ql=_e.newName(),Kl=_e.newName(),Ul={"&light":"."+ql,"&dark":"."+Kl};function gs(s,e,t){return new _e(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,n=>{if(n=="&")return s;if(!t||!t[n])throw new RangeError(`Unsupported selector: ${n}`);return t[n]}):s+" "+i}})}const Kf=gs("."+ps,{"&":{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-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".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"}},Ul),Uf={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Mn=v.ie&&v.ie_version<=11;class jf{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new bh,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=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(v.ie&&v.ie_version<=11||v.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&v.android&&e.constructor.EDIT_CONTEXT!==!1&&!(v.chrome&&v.chrome_version<126)&&(this.editContext=new Gf(e),e.state.facet(Ne)&&(e.contentDOM.editContext=this.editContext.editContext)),Mn&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.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 t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.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(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(Ne)?i.root.activeElement!=this.dom:!Ut(this.dom,n))return;let r=n.anchorNode&&i.docView.tile.nearest(n.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(v.ie&&v.ie_version<=11||v.android&&v.chrome)&&!i.state.selection.main.empty&&n.focusNode&&jt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=ei(e.root);if(!t)return!1;let i=v.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&$f(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let n=Ut(this.dom,i);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&wh(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Uf),Mn&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Mn&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){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&&Ct(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,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 e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(n=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:n}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),n=this.selectionChanged&&Ut(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new cf(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,n=Ll(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!Ki(this.view.state.selection,t.newSel.main))&&this.view.update([]),n}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=Vr(t,e.previousSibling||e.target.previousSibling,-1),n=Vr(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Ne)!=e.state.facet(Ne)&&(e.view.contentDOM.editContext=e.state.facet(Ne)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.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 Vr(s,e,t){for(;e;){let i=K.get(e);if(i&&i.parent==s)return i;let n=e.parentNode;e=n!=s.dom?n:t>0?e.nextSibling:e.previousSibling}return null}function zr(s,e){let t=e.startContainer,i=e.startOffset,n=e.endContainer,r=e.endOffset,o=s.docView.domAtPos(s.state.selection.main.anchor,1);return jt(o.node,o.offset,n,r)&&([t,i,n,r]=[n,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}}function $f(s,e){if(e.getComposedRanges){let n=e.getComposedRanges(s.root)[0];if(n)return zr(s,n)}let t=null;function i(n){n.preventDefault(),n.stopImmediatePropagation(),t=n.getTargetRanges()[0]}return s.contentDOM.addEventListener("beforeinput",i,!0),s.dom.ownerDocument.execCommand("indent"),s.contentDOM.removeEventListener("beforeinput",i,!0),t?zr(s,t):null}class Gf{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let n=e.state.selection.main,{anchor:r,head:o}=n,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>i.text.length;l==this.from&&r<this.from?l=r:a==this.to&&r>this.to&&(a=r);let f=Rl(e.state.sliceDoc(l,a),i.text,(h?n.from:n.to)-l,h?"end":null);if(!f){let u=b.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Ki(u,n)||e.dispatch({selection:u,userEvent:"select"});return}let c={from:f.from+l,to:f.toA+l,insert:E.of(i.text.slice(f.from,f.toB).split(`
|
|
10
|
+
`))};if((v.mac||v.android)&&c.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:l,to:a,insert:E.of([i.text.replace("."," ")])}),this.pendingContextChange=c,!e.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);qs(e,c,b.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),c.from<c.to&&!c.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let n=[],r=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=e.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,n.push(r)}t.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=i=>{let n=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(r.rangeStart),h=this.toEditorPos(r.rangeEnd);if(a<h){let f=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;n.push(G.mark({attributes:{style:f}}).range(a,h))}}}e.dispatch({effects:vl.of(G.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let n=ei(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,n=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,h)=>{if(i)return;let f=h.length-(o-r);if(n&&o>=n.to)if(n.from==r&&n.to==o&&n.insert.eq(h)){n=this.pendingContextChange=null,t+=f,this.to+=f;return}else n=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=f,this.to+=f;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=f}t+=f}),n&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(n=>!n.isUserEvent("input.type")&&n.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class B{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 t;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:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(n=>n.forEach(r=>i(r,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||xh(e.parent)||document,this.viewState=new Wr(this,e.state||I.create(e)),e.scrollTo&&e.scrollTo.is(pi)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(kt).map(n=>new wn(n));for(let n of this.plugins)n.update(this);this.observer=new jf(this),this.inputState=new gf(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Cr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof ie?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,n,r=this.state;for(let u of e){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(Hl))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Vl(r,o),a||(l=1));let h=this.observer.delayedAndroidKey,f=null;if(h?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(f=null)):this.observer.clear(),r.facet(I.phrases)!=this.state.facet(I.phrases))return this.setState(r);n=zi.create(this,r,e),n.flags|=l;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(c&&(c=c.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection;c=new At(d.empty?d:b.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of u.effects)d.is(pi)&&(c=d.value.clip(this.state))}this.viewState.update(n,c),this.bidiCache=ji.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(zt)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(xi)!=n.state.facet(xi)&&(this.viewState.mustMeasureContent=!0),(t||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let u of this.state.facet(hs))try{u(n)}catch(d){Re(this.state,d,"update listener")}(a||f)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),f&&!Ll(this,f)&&h.force&&Ct(this.contentDOM,h.key,h.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 t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Wr(this,e),this.plugins=e.facet(kt).map(i=>new wn(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Cr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(kt),i=e.state.facet(kt);if(t!=i){let n=[];for(let r of i){let o=t.indexOf(r);if(o<0)n.push(new wn(r));else{let l=this.plugins[o];l.mustUpdate=e,n.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=e;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){Re(this.state,i,"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 t=null,i=this.viewState.scrollParent,n=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(n-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(ol(i||this.win))r=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(n);r=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();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 h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let f=h.map(d=>{try{return d.read(this)}catch(p){return Re(this.state,p),Qr}}),c=zi.create(this,this.state,[]),u=!1;c.flags|=a,t?t.flags|=a:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c),u&&this.docViewUpdate());for(let d=0;d<h.length;d++)if(f[d]!=Qr)try{let p=h[d];p.write&&p.write(f[d],this)}catch(p){Re(this.state,p)}if(u&&this.docView.updateSelection(!0),!c.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=((r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o)/this.scaleY;if((p>1||p<-1)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){n=n+p,i?i.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(hs))l(t)}get themeClasses(){return ps+" "+(this.state.facet(ds)?Kl:ql)+" "+this.state.facet(xi)}updateAttrs(){let e=qr(this,Sl,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Ne)?"true":"false",class:"cm-content",style:`${v.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),qr(this,zs,t);let i=this.observer.ignore(()=>{let n=kr(this.contentDOM,this.contentAttrs,t),r=kr(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let n of i.effects)if(n.is(B.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(zt);let e=this.state.facet(B.cspNonce);_e.mount(this.root,this.styleModules.concat(Kf).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 t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.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,t,i){return An(this,e,Ar(this,e,t,i))}moveByGroup(e,t){return An(this,e,Ar(this,e,t,i=>rf(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),n=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return b.cursor(r.side(t,n)+e.from,r.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,i=!0){return sf(this,e,t,i)}moveVertically(e,t,i){return An(this,e,of(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=cs(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),cs(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),o=r[Le.find(r,e-n.from,-1,t)];return Vi(i,o.dir==j.LTR==t>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(xl)||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>_f)return ul(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||cl(r.isolates,i=wr(this,e))))return r.order;i||(i=wr(this,e));let n=Th(e.text,t,i);return this.bidiCache.push(new ji(e.from,e.to,t,i,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||v.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{rl(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,t={}){return pi.of(new At(typeof e=="number"?b.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return pi.of(new At(b.cursor(i.from),"start","start",i.top-e,t,!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 ze.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ze.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=_e.newName(),n=[xi.of(i),zt.of(gs(`.${i}`,e))];return t&&t.dark&&n.push(ds.of(!0)),n}static baseTheme(e){return Rs.lowest(zt.of(gs("."+ps,e,Ul)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&K.get(i)||K.get(e);return((t=n==null?void 0:n.root)===null||t===void 0?void 0:t.view)||null}}B.styleModule=zt;B.inputHandler=kl;B.clipboardInputFilter=Hs;B.clipboardOutputFilter=Vs;B.scrollHandler=wl;B.focusChangeEffect=bl;B.perLineTextDirection=xl;B.exceptionSink=yl;B.updateListener=hs;B.editable=Ne;B.mouseSelectionStyle=ml;B.dragMovesSelection=gl;B.clickAddsSelectionRange=pl;B.decorations=an;B.blockWrappers=Cl;B.outerDecorations=Qs;B.atomicRanges=li;B.bidiIsolatedRanges=Al;B.scrollMargins=Ol;B.darkTheme=ds;B.cspNonce=A.define({combine:s=>s.length?s[0]:""});B.contentAttributes=zs;B.editorAttributes=Sl;B.lineWrapping=B.contentAttributes.of({class:"cm-lineWrapping"});B.announce=_.define();const _f=4096,Qr={};class ji{constructor(e,t,i,n,r,o){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:j.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir==n&&!t.touchesRange(o.from,o.to)&&i.push(new ji(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function qr(s,e,t){for(let i=s.state.facet(e),n=i.length-1;n>=0;n--){let r=i[n],o=typeof r=="function"?r(s):r;o&&Ns(o,t)}return t}const Xf=v.mac?"mac":v.windows?"win":v.linux?"linux":"key";function Yf(s,e){const t=s.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let n,r,o,l;for(let a=0;a<t.length-1;++a){const h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))n=!0;else if(/^(c|ctrl|control)$/i.test(h))r=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+h)}return n&&(i="Alt-"+i),r&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function wi(s,e,t){return e.altKey&&(s="Alt-"+s),e.ctrlKey&&(s="Ctrl-"+s),e.metaKey&&(s="Meta-"+s),t!==!1&&e.shiftKey&&(s="Shift-"+s),s}const Jf=Rs.default(B.domEventHandlers({keydown(s,e){return nc(ec(e.state),s,e,"editor")}})),Zf=A.define({enables:Jf}),Kr=new WeakMap;function ec(s){let e=s.facet(Zf),t=Kr.get(e);return t||Kr.set(e,t=ic(e.reduce((i,n)=>i.concat(n),[]))),t}let Ue=null;const tc=4e3;function ic(s,e=Xf){let t=Object.create(null),i=Object.create(null),n=(o,l)=>{let a=i[o];if(a==null)i[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")},r=(o,l,a,h,f)=>{var c,u;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(y=>Yf(y,e));for(let y=1;y<p.length;y++){let w=p.slice(0,y).join(" ");n(w,!0),d[w]||(d[w]={preventDefault:!0,stopPropagation:!1,run:[S=>{let L=Ue={view:S,prefix:w,scope:o};return setTimeout(()=>{Ue==L&&(Ue=null)},tc),!0}]})}let g=p.join(" ");n(g,!1);let m=d[g]||(d[g]={preventDefault:!1,stopPropagation:!1,run:((u=(c=d._any)===null||c===void 0?void 0:c.run)===null||u===void 0?void 0:u.slice())||[]});a&&m.run.push(a),h&&(m.preventDefault=!0),f&&(m.stopPropagation=!0)};for(let o of s){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let f=t[h]||(t[h]=Object.create(null));f._any||(f._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:c}=o;for(let u in f)f[u].run.push(d=>c(d,ms))}let a=o[e]||o.key;if(a)for(let h of l)r(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let ms=null;function nc(s,e,t,i){ms=e;let n=uh(e),r=$a(n,0),o=Ga(r)==n.length&&n!=" ",l="",a=!1,h=!1,f=!1;Ue&&Ue.view==t&&Ue.scope==i&&(l=Ue.prefix+" ",Il.indexOf(e.keyCode)<0&&(h=!0,Ue=null));let c=new Set,u=m=>{if(m){for(let y of m.run)if(!c.has(y)&&(c.add(y),y(t)))return m.stopPropagation&&(f=!0),!0;m.preventDefault&&(m.stopPropagation&&(f=!0),h=!0)}return!1},d=s[i],p,g;return d&&(u(d[l+wi(n,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(v.windows&&e.ctrlKey&&e.altKey)&&!(v.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Xe[e.keyCode])&&p!=n?(u(d[l+wi(p,e,!0)])||e.shiftKey&&(g=Jt[e.keyCode])!=n&&g!=p&&u(d[l+wi(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+wi(n,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&f&&e.stopPropagation(),ms=null,a}function up(){return rc}const sc=G.line({class:"cm-activeLine"}),rc=ze.fromClass(class{constructor(s){this.decorations=this.getDeco(s)}update(s){(s.docChanged||s.selectionSet)&&(this.decorations=this.getDeco(s.view))}getDeco(s){let e=-1,t=[];for(let i of s.state.selection.ranges){let n=s.lineBlockAt(i.head);n.from>e&&(t.push(sc.range(n.from)),e=n.from)}return G.set(t)}},{decorations:s=>s.decorations});class dt extends Ge{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}dt.prototype.elementClass="";dt.prototype.toDOM=void 0;dt.prototype.mapMode=ue.TrackBefore;dt.prototype.startSide=dt.prototype.endSide=-1;dt.prototype.point=!0;const Tn=A.define(),oc=A.define(),Li=A.define(),Ur=A.define({combine:s=>s.some(e=>e)});function lc(s){return[ac]}const ac=ze.fromClass(class{constructor(s){this.view=s,this.domAfter=null,this.prevViewport=s.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=s.state.facet(Li).map(e=>new $r(s,e)),this.fixed=!s.state.facet(Ur);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),s.scrollDOM.insertBefore(this.dom,s.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(s){if(this.updateGutters(s)){let e=this.prevViewport,t=s.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(s.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(Ur)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=s.view.viewport}syncGutters(s){let e=this.dom.nextSibling;s&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=R.iter(this.view.state.facet(Tn),this.view.viewport.from),i=[],n=this.gutters.map(r=>new hc(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==le.Text&&o){ys(t,i,l.from);for(let a of n)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of n)a.widget(this.view,l)}else if(r.type==le.Text){ys(t,i,r.from);for(let o of n)o.line(this.view,r,i)}else if(r.widget)for(let o of n)o.widget(this.view,r);for(let r of n)r.finish();s&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(s){let e=s.startState.facet(Li),t=s.state.facet(Li),i=s.docChanged||s.heightChanged||s.viewportChanged||!R.eq(s.startState.facet(Tn),s.state.facet(Tn),s.view.viewport.from,s.view.viewport.to);if(e==t)for(let n of this.gutters)n.update(s)&&(i=!0);else{i=!0;let n=[];for(let r of t){let o=e.indexOf(r);o<0?n.push(new $r(this.view,r)):(this.gutters[o].update(s),n.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),n.indexOf(r)<0&&r.destroy();for(let r of n)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=n}return i}destroy(){for(let s of this.gutters)s.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:s=>B.scrollMargins.of(e=>{let t=e.plugin(s);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,n=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==j.LTR?{left:i,right:n}:{right:i,left:n}})});function jr(s){return Array.isArray(s)?s:[s]}function ys(s,e,t){for(;s.value&&s.from<=t;)s.from==t&&e.push(s.value),s.next()}class hc{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=R.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:n}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==n.elements.length){let l=new jl(e,o,r,i);n.elements.push(l),n.dom.appendChild(l.dom)}else n.elements[this.i].update(e,o,r,i);this.height=t.bottom,this.i++}line(e,t,i){let n=[];ys(this.cursor,n,t.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(e,t,n);r&&n.unshift(r);let o=this.gutter;n.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,n)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),n=i?[i]:null;for(let r of e.state.facet(oc)){let o=r(e,t.widget,t);o&&(n||(n=[])).push(o)}n&&this.addElement(e,t,n)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class $r{constructor(e,t){this.view=e,this.config=t,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 t.domEventHandlers)this.dom.addEventListener(i,n=>{let r=n.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=n.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,n)&&n.preventDefault()});this.markers=jr(t.markers(e)),t.initialSpacer&&(this.spacer=new jl(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=jr(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],e);n!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[n])}let i=e.view.viewport;return!R.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class jl{constructor(e,t,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,n)}update(e,t,i,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),fc(this.markers,n)||this.setMarkers(e,n)}setMarkers(e,t){let i="cm-gutterElement",n=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<t.length?t[r++]:null,h=!1;if(a){let f=a.elementClass;f&&(i+=" "+f);for(let c=o;c<this.markers.length;c++)if(this.markers[c].compare(a)){l=c,h=!0;break}}else l=this.markers.length;for(;o<l;){let f=this.markers[o++];if(f.toDOM){f.destroy(n);let c=n.nextSibling;n.remove(),n=c}}if(!a)break;a.toDOM&&(h?n=n.nextSibling:this.dom.insertBefore(a.toDOM(e),n)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function fc(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++)if(!s[t].compare(e[t]))return!1;return!0}const cc=A.define(),uc=A.define(),bt=A.define({combine(s){return oh(s,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let n in t){let r=i[n],o=t[n];i[n]=r?(l,a,h)=>r(l,a,h)||o(l,a,h):o}return i}})}});class Bn extends dt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Dn(s,e){return s.state.facet(bt).formatNumber(e,s.state)}const dc=Li.compute([bt],s=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(cc)},lineMarker(e,t,i){return i.some(n=>n.toDOM)?null:new Bn(Dn(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let n of e.state.facet(uc)){let r=n(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(bt)!=e.state.facet(bt),initialSpacer(e){return new Bn(Dn(e,Gr(e.state.doc.lines)))},updateSpacer(e,t){let i=Dn(t.view,Gr(t.view.state.doc.lines));return i==e.number?e:new Bn(i)},domEventHandlers:s.facet(bt).domEventHandlers,side:"before"}));function dp(s={}){return[bt.of(s),lc(),dc]}function Gr(s){let e=9;for(;e<s;)e=e*10+9;return e}const $l=1024;let pc=0;class Pn{constructor(e,t){this.from=e,this.to=t}}class D{constructor(e={}){this.id=pc++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=he.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}D.closedBy=new D({deserialize:s=>s.split(" ")});D.openedBy=new D({deserialize:s=>s.split(" ")});D.group=new D({deserialize:s=>s.split(" ")});D.isolate=new D({deserialize:s=>{if(s&&s!="rtl"&&s!="ltr"&&s!="auto")throw new RangeError("Invalid value for isolate: "+s);return s||"auto"}});D.contextHash=new D({perNode:!0});D.lookAhead=new D({perNode:!0});D.mounted=new D({perNode:!0});class Gt{constructor(e,t,i,n=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=n}static get(e){return e&&e.props&&e.props[D.mounted.id]}}const gc=Object.create(null);class he{constructor(e,t,i,n=0){this.name=e,this.props=t,this.id=i,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):gc,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new he(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return n}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 t=this.prop(D.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let n of i.split(" "))t[n]=e[i];return i=>{for(let n=i.prop(D.group),r=-1;r<(n?n.length:0);r++){let o=t[r<0?i.name:n[r]];if(o)return o}}}}he.none=new he("",Object.create(null),0,8);class js{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let n=null;for(let r of e){let o=r(i);if(o){n||(n=Object.assign({},i.props));let l=o[1],a=o[0];a.combine&&a.id in n&&(l=a.combine(n[a.id],l)),n[a.id]=l}}t.push(n?new he(i.name,n,i.id,i.flags):i)}return new js(t)}}const vi=new WeakMap,_r=new WeakMap;var q;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays",s[s.EnterBracketed=16]="EnterBracketed"})(q||(q={}));class ${constructor(e,t,i,n,r){if(this.type=e,this.children=t,this.positions=i,this.length=n,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Gt.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let n=i.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new bs(this.topNode,e)}cursorAt(e,t=0,i=0){let n=vi.get(this)||this.topNode,r=new bs(n);return r.moveTo(e,t),vi.set(this,r._tree),r}get topNode(){return new me(this,0,0,null)}resolve(e,t=0){let i=ii(vi.get(this)||this.topNode,e,t,!1);return vi.set(this,i),i}resolveInner(e,t=0){let i=ii(_r.get(this)||this.topNode,e,t,!0);return _r.set(this,i),i}resolveStack(e,t=0){return kc(this,e,t)}iterate(e){let{enter:t,leave:i,from:n=0,to:r=this.length}=e,o=e.mode||0,l=(o&q.IncludeAnonymous)>0;for(let a=this.cursor(o|q.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=n&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!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 t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:_s(he.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,n)=>new $(this.type,t,i,n,this.propValues),e.makeTree||((t,i,n)=>new $(he.none,t,i,n)))}static build(e){return bc(e)}}$.empty=new $(he.none,[],[],0);class $s{constructor(e,t){this.buffer=e,this.index=t}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 $s(this.buffer,this.index)}}class Je{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return he.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],n=this.set.types[t],r=n.name;if(/\W/.test(r)&&!n.isError&&(r=JSON.stringify(r)),e+=4,i==e)return r;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,i,n,r){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(Gl(r,n,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let n=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){r[a++]=n[l++],r[a++]=n[l++]-i;let h=r[a++]=n[l++]-i;r[a++]=n[l++]-e,o=Math.max(o,h)}return new Je(r,o,this.set)}}function Gl(s,e,t,i){switch(s){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function ii(s,e,t,i){for(var n;s.from==s.to||(t<1?s.from>=e:s.from>e)||(t>-1?s.to<=e:s.to<e);){let o=!i&&s instanceof me&&s.index<0?null:s.parent;if(!o)return s;s=o}let r=i?0:q.IgnoreOverlays;if(i)for(let o=s,l=o.parent;l;o=l,l=o.parent)o instanceof me&&o.index<0&&((n=l.enter(e,t,r))===null||n===void 0?void 0:n.from)!=o.from&&(s=l);for(;;){let o=s.enter(e,t,r);if(!o)return s;s=o}}class _l{cursor(e=0){return new bs(this,e)}getChild(e,t=null,i=null){let n=Xr(this,e,t,i);return n.length?n[0]:null}getChildren(e,t=null,i=null){return Xr(this,e,t,i)}resolve(e,t=0){return ii(this,e,t,!1)}resolveInner(e,t=0){return ii(this,e,t,!0)}matchContext(e){return ks(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let n=t.lastChild;if(!n||n.to!=t.to)break;n.type.isError&&n.from==n.to?(i=t,t=n.prevSibling):t=n}return i}get node(){return this}get next(){return this.parent}}class me extends _l{constructor(e,t,i,n){super(),this._tree=e,this.from=t,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,n,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let f=l[e],c=a[e]+o.from,u;if(!(!(r&q.EnterBracketed&&f instanceof $&&(u=Gt.get(f))&&!u.overlay&&u.bracketed&&i>=c&&i<=c+f.length)&&!Gl(n,i,c,c+f.length))){if(f instanceof Je){if(r&q.ExcludeBuffers)continue;let d=f.findChild(0,f.buffer.length,t,i-c,n);if(d>-1)return new $e(new mc(o,f,e,c),null,d)}else if(r&q.IncludeAnonymous||!f.type.isAnonymous||Gs(f)){let d;if(!(r&q.IgnoreMounts)&&(d=Gt.get(f))&&!d.overlay)return new me(d.tree,c,e,o);let p=new me(f,c,e,o);return r&q.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?f.children.length-1:0,t,i,n,r)}}}if(r&q.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<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)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let n;if(!(i&q.IgnoreOverlays)&&(n=Gt.get(this._tree))&&n.overlay){let r=e-this.from,o=i&q.EnterBracketed&&n.bracketed;for(let{from:l,to:a}of n.overlay)if((t>0||o?l<=r:l<r)&&(t<0||o?a>=r:a>r))return new me(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}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 Xr(s,e,t,i){let n=s.cursor(),r=[];if(!n.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=n.type.is(t),!n.nextSibling())return r}for(;;){if(i!=null&&n.type.is(i))return r;if(n.type.is(e)&&r.push(n.node),!n.nextSibling())return i==null?r:[]}}function ks(s,e,t=e.length-1){for(let i=s;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class mc{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}}class $e extends _l{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,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new $e(this.context,this,r)}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)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&q.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new $e(this.context,this,r)}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,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new $e(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new $e(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let o=i.buffer[this.index+1];e.push(i.slice(n,r,o)),t.push(0)}return new $(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Xl(s){if(!s.length)return null;let e=0,t=s[0];for(let r=1;r<s.length;r++){let o=s[r];(o.from>t.from||o.to<t.to)&&(t=o,e=r)}let i=t instanceof me&&t.index<0?null:t.parent,n=s.slice();return i?n[e]=i:n.splice(e,1),new yc(n,t)}class yc{constructor(e,t){this.heads=e,this.node=t}get next(){return Xl(this.heads)}}function kc(s,e,t){let i=s.resolveInner(e,t),n=null;for(let r=i instanceof me?i:i.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(n||(n=[i])).push(o.resolve(e,t)),r=o}else{let o=Gt.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new me(o.tree,o.overlay[0].from+r.from,-1,r);(n||(n=[i])).push(ii(l,e,t,!1))}}return n?Xl(n):i}class bs{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~q.EnterBracketed,e instanceof me)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=i+n.buffer[e+1],this.to=i+n.buffer[e+2],!0}yield(e){return e?e instanceof me?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-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(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&q.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&q.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&q.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:n}=this;if(n){if(e>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:t,parent:i}=n)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let l=i._tree.children[r];if(this.mode&q.IncludeAnonymous||l instanceof Je||!l.type.isAnonymous||Gs(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let n=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==n){if(n==this.index)return o;t=o,i=r+1;break e}n=this.stack[--r]}for(let n=i;n<this.stack.length;n++)t=new $e(this.buffer,t,this.stack[n]);return this.bufferNode=new $e(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let n=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&t&&t(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(e){if(!this.buffer)return ks(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let n=e.length-1,r=this.stack.length-1;n>=0;r--){if(r<0)return ks(this._tree,e,n);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[n]&&e[n]!=o.name)return!1;n--}}return!0}}function Gs(s){return s.children.some(e=>e instanceof Je||!e.type.isAnonymous||Gs(e))}function bc(s){var e;let{buffer:t,nodeSet:i,maxBufferLength:n=$l,reused:r=[],minRepeatType:o=i.types.length}=s,l=Array.isArray(t)?new $s(t,t.length):t,a=i.types,h=0,f=0;function c(M,O,C,H,W,Q){let{id:P,start:T,end:V,size:z}=l,Y=f,Qe=h;if(z<0)if(l.next(),z==-1){let Ee=r[P];C.push(Ee),H.push(T-M);return}else if(z==-3){h=P;return}else if(z==-4){f=P;return}else throw new RangeError(`Unrecognized record size: ${z}`);let It=a[P],hi,et,nr=T-M;if(V-T<=n&&(et=m(l.pos-O,W))){let Ee=new Uint16Array(et.size-et.skip),de=l.pos-et.size,Ae=Ee.length;for(;l.pos>de;)Ae=y(et.start,Ee,Ae);hi=new Je(Ee,V-et.start,i),nr=et.start-M}else{let Ee=l.pos-z;l.next();let de=[],Ae=[],tt=P>=o?P:-1,gt=0,fi=V;for(;l.pos>Ee;)tt>=0&&l.id==tt&&l.size>=0?(l.end<=fi-n&&(p(de,Ae,T,gt,l.end,fi,tt,Y,Qe),gt=de.length,fi=l.end),l.next()):Q>2500?u(T,Ee,de,Ae):c(T,Ee,de,Ae,tt,Q+1);if(tt>=0&>>0&><de.length&&p(de,Ae,T,gt,T,fi,tt,Y,Qe),de.reverse(),Ae.reverse(),tt>-1&>>0){let sr=d(It,Qe);hi=_s(It,de,Ae,0,de.length,0,V-T,sr,sr)}else hi=g(It,de,Ae,V-T,Y-V,Qe)}C.push(hi),H.push(nr)}function u(M,O,C,H){let W=[],Q=0,P=-1;for(;l.pos>O;){let{id:T,start:V,end:z,size:Y}=l;if(Y>4)l.next();else{if(P>-1&&V<P)break;P<0&&(P=z-n),W.push(T,V,z),Q++,l.next()}}if(Q){let T=new Uint16Array(Q*4),V=W[W.length-2];for(let z=W.length-3,Y=0;z>=0;z-=3)T[Y++]=W[z],T[Y++]=W[z+1]-V,T[Y++]=W[z+2]-V,T[Y++]=Y;C.push(new Je(T,W[2]-V,i)),H.push(V-M)}}function d(M,O){return(C,H,W)=>{let Q=0,P=C.length-1,T,V;if(P>=0&&(T=C[P])instanceof $){if(!P&&T.type==M&&T.length==W)return T;(V=T.prop(D.lookAhead))&&(Q=H[P]+T.length+V)}return g(M,C,H,W,Q,O)}}function p(M,O,C,H,W,Q,P,T,V){let z=[],Y=[];for(;M.length>H;)z.push(M.pop()),Y.push(O.pop()+C-W);M.push(g(i.types[P],z,Y,Q-W,T-Q,V)),O.push(W-C)}function g(M,O,C,H,W,Q,P){if(Q){let T=[D.contextHash,Q];P=P?[T].concat(P):[T]}if(W>25){let T=[D.lookAhead,W];P=P?[T].concat(P):[T]}return new $(M,O,C,H,P)}function m(M,O){let C=l.fork(),H=0,W=0,Q=0,P=C.end-n,T={size:0,start:0,skip:0};e:for(let V=C.pos-M;C.pos>V;){let z=C.size;if(C.id==O&&z>=0){T.size=H,T.start=W,T.skip=Q,Q+=4,H+=4,C.next();continue}let Y=C.pos-z;if(z<0||Y<V||C.start<P)break;let Qe=C.id>=o?4:0,It=C.start;for(C.next();C.pos>Y;){if(C.size<0)if(C.size==-3||C.size==-4)Qe+=4;else break e;else C.id>=o&&(Qe+=4);C.next()}W=It,H+=z,Q+=Qe}return(O<0||H==M)&&(T.size=H,T.start=W,T.skip=Q),T.size>4?T:void 0}function y(M,O,C){let{id:H,start:W,end:Q,size:P}=l;if(l.next(),P>=0&&H<o){let T=C;if(P>4){let V=l.pos-(P-4);for(;l.pos>V;)C=y(M,O,C)}O[--C]=T,O[--C]=Q-M,O[--C]=W-M,O[--C]=H}else P==-3?h=H:P==-4&&(f=H);return C}let w=[],S=[];for(;l.pos>0;)c(s.start||0,s.bufferStart||0,w,S,-1,0);let L=(e=s.length)!==null&&e!==void 0?e:w.length?S[0]+w[0].length:0;return new $(a[s.topID],w.reverse(),S.reverse(),L)}const Yr=new WeakMap;function Ri(s,e){if(!s.isAnonymous||e instanceof Je||e.type!=s)return 1;let t=Yr.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=s||!(i instanceof $)){t=1;break}t+=Ri(s,i)}Yr.set(e,t)}return t}function _s(s,e,t,i,n,r,o,l,a){let h=0;for(let p=i;p<n;p++)h+=Ri(s,e[p]);let f=Math.ceil(h*1.5/8),c=[],u=[];function d(p,g,m,y,w){for(let S=m;S<y;){let L=S,M=g[S],O=Ri(s,p[S]);for(S++;S<y;S++){let C=Ri(s,p[S]);if(O+C>=f)break;O+=C}if(S==L+1){if(O>f){let C=p[L];d(C.children,C.positions,0,C.children.length,g[L]+w);continue}c.push(p[L])}else{let C=g[S-1]+p[S-1].length-M;c.push(_s(s,p,g,L,S,M,C,null,a))}u.push(M+w-r)}}return d(e,t,i,n,0),(l||a)(c,u,o)}class ht{constructor(e,t,i,n,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let n=[new ht(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&n.push(r);return n}static applyChanges(e,t,i=128){if(!t.length)return e;let n=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let f=l<t.length?t[l]:null,c=f?f.fromA:1e9;if(c-a>=i)for(;o&&o.from<c;){let u=o;if(a>=u.from||c<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,c)-h;u=d>=p?null:new ht(d,p,u.tree,u.offset+h,l>0,!!f)}if(u&&n.push(u),o.to>c)break;o=r<e.length?e[r++]:null}if(!f)break;a=f.toA,h=f.toA-f.toB}return n}}class Yl{startParse(e,t,i){return typeof e=="string"&&(e=new xc(e)),i=i?i.length?i.map(n=>new Pn(n.from,n.to)):[new Pn(0,0)]:[new Pn(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let n=this.startParse(e,t,i);for(;;){let r=n.advance();if(r)return r}}}class xc{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new D({perNode:!0});let wc=0;class pe{constructor(e,t,i,n){this.name=e,this.set=t,this.base=i,this.modified=n,this.id=wc++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof pe&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let n=new pe(i,[],null,[]);if(n.set.push(n),t)for(let r of t.set)n.set.push(r);return n}static defineModifier(e){let t=new $i(e);return i=>i.modified.indexOf(t)>-1?i:$i.get(i.base||i,i.modified.concat(t).sort((n,r)=>n.id-r.id))}}let vc=0;class $i{constructor(e){this.name=e,this.instances=[],this.id=vc++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&Sc(t,l.modified));if(i)return i;let n=[],r=new pe(e.name,n,e,t);for(let l of t)l.instances.push(r);let o=Cc(t);for(let l of e.set)if(!l.modified.length)for(let a of o)n.push($i.get(l,a));return r}}function Sc(s,e){return s.length==e.length&&s.every((t,i)=>t==e[i])}function Cc(s){let e=[[]];for(let t=0;t<s.length;t++)for(let i=0,n=e.length;i<n;i++)e.push(e[i].concat(s[t]));return e.sort((t,i)=>i.length-t.length)}function Jl(s){let e=Object.create(null);for(let t in s){let i=s[t];Array.isArray(i)||(i=[i]);for(let n of t.split(" "))if(n){let r=[],o=2,l=n;for(let c=0;;){if(l=="..."&&c>0&&c+3==n.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+n);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),c+=u[0].length,c==n.length)break;let d=n[c++];if(c==n.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+n);l=n.slice(c)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+n);let f=new ni(i,o,a>0?r.slice(0,a):null);e[h]=f.sort(e[h])}}return Zl.add(e)}const Zl=new D({combine(s,e){let t,i,n;for(;s||e;){if(!s||e&&s.depth>=e.depth?(n=e,e=e.next):(n=s,s=s.next),t&&t.mode==n.mode&&!n.context&&!t.context)continue;let r=new ni(n.tags,n.mode,n.context);t?t.next=r:i=r,t=r}return i}});class ni{constructor(e,t,i,n){this.tags=e,this.mode=t,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}ni.empty=new ni([],2,null);function ea(s,e){let t=Object.create(null);for(let r of s)if(!Array.isArray(r.tag))t[r.tag.id]=r.class;else for(let o of r.tag)t[o.id]=r.class;let{scope:i,all:n=null}=e||{};return{style:r=>{let o=n;for(let l of r)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function Ac(s,e){let t=null;for(let i of s){let n=i.style(e);n&&(t=t?t+" "+n:n)}return t}function Oc(s,e,t,i=0,n=s.length){let r=new Mc(i,Array.isArray(e)?e:[e],t);r.highlightRange(s.cursor(),i,n,"",r.highlighters),r.flush(n)}class Mc{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,n,r){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=n,f=Tc(e)||ni.empty,c=Ac(r,f.tags);if(c&&(h&&(h+=" "),h+=c,f.mode==1&&(n+=(n?" ":"")+c)),this.startSpan(Math.max(t,l),h),f.opaque)return;let u=e.tree&&e.tree.prop(D.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(m=>!m.scope||m.scope(u.tree.type)),g=e.firstChild();for(let m=0,y=l;;m++){let w=m<u.overlay.length?u.overlay[m]:null,S=w?w.from+l:a,L=Math.max(t,y),M=Math.min(i,S);if(L<M&&g)for(;e.from<M&&(this.highlightRange(e,L,M,n,r),this.startSpan(Math.min(M,e.to),h),!(e.to>=S||!e.nextSibling())););if(!w||S>i)break;y=w.to+l,y>t&&(this.highlightRange(d.cursor(),Math.max(t,w.from+l),Math.min(i,y),"",p),this.startSpan(Math.min(i,y),h))}g&&e.parent()}else if(e.firstChild()){u&&(n="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,n,r),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}}function Tc(s){let e=s.type.prop(Zl);for(;e&&e.context&&!s.matchContext(e.context);)e=e.next;return e||null}const x=pe.define,Si=x(),qe=x(),Jr=x(qe),Zr=x(qe),Ke=x(),Ci=x(Ke),Ln=x(Ke),Be=x(),it=x(Be),Me=x(),Te=x(),xs=x(),Ft=x(xs),Ai=x(),k={comment:Si,lineComment:x(Si),blockComment:x(Si),docComment:x(Si),name:qe,variableName:x(qe),typeName:Jr,tagName:x(Jr),propertyName:Zr,attributeName:x(Zr),className:x(qe),labelName:x(qe),namespace:x(qe),macroName:x(qe),literal:Ke,string:Ci,docString:x(Ci),character:x(Ci),attributeValue:x(Ci),number:Ln,integer:x(Ln),float:x(Ln),bool:x(Ke),regexp:x(Ke),escape:x(Ke),color:x(Ke),url:x(Ke),keyword:Me,self:x(Me),null:x(Me),atom:x(Me),unit:x(Me),modifier:x(Me),operatorKeyword:x(Me),controlKeyword:x(Me),definitionKeyword:x(Me),moduleKeyword:x(Me),operator:Te,derefOperator:x(Te),arithmeticOperator:x(Te),logicOperator:x(Te),bitwiseOperator:x(Te),compareOperator:x(Te),updateOperator:x(Te),definitionOperator:x(Te),typeOperator:x(Te),controlOperator:x(Te),punctuation:xs,separator:x(xs),bracket:Ft,angleBracket:x(Ft),squareBracket:x(Ft),paren:x(Ft),brace:x(Ft),content:Be,heading:it,heading1:x(it),heading2:x(it),heading3:x(it),heading4:x(it),heading5:x(it),heading6:x(it),contentSeparator:x(Be),list:x(Be),quote:x(Be),emphasis:x(Be),strong:x(Be),link:x(Be),monospace:x(Be),strikethrough:x(Be),inserted:x(),deleted:x(),changed:x(),invalid:x(),meta:Ai,documentMeta:x(Ai),annotation:x(Ai),processingInstruction:x(Ai),definition:pe.defineModifier("definition"),constant:pe.defineModifier("constant"),function:pe.defineModifier("function"),standard:pe.defineModifier("standard"),local:pe.defineModifier("local"),special:pe.defineModifier("special")};for(let s in k){let e=k[s];e instanceof pe&&(e.name=s)}ea([{tag:k.link,class:"tok-link"},{tag:k.heading,class:"tok-heading"},{tag:k.emphasis,class:"tok-emphasis"},{tag:k.strong,class:"tok-strong"},{tag:k.keyword,class:"tok-keyword"},{tag:k.atom,class:"tok-atom"},{tag:k.bool,class:"tok-bool"},{tag:k.url,class:"tok-url"},{tag:k.labelName,class:"tok-labelName"},{tag:k.inserted,class:"tok-inserted"},{tag:k.deleted,class:"tok-deleted"},{tag:k.literal,class:"tok-literal"},{tag:k.string,class:"tok-string"},{tag:k.number,class:"tok-number"},{tag:[k.regexp,k.escape,k.special(k.string)],class:"tok-string2"},{tag:k.variableName,class:"tok-variableName"},{tag:k.local(k.variableName),class:"tok-variableName tok-local"},{tag:k.definition(k.variableName),class:"tok-variableName tok-definition"},{tag:k.special(k.variableName),class:"tok-variableName2"},{tag:k.definition(k.propertyName),class:"tok-propertyName tok-definition"},{tag:k.typeName,class:"tok-typeName"},{tag:k.namespace,class:"tok-namespace"},{tag:k.className,class:"tok-className"},{tag:k.macroName,class:"tok-macroName"},{tag:k.propertyName,class:"tok-propertyName"},{tag:k.operator,class:"tok-operator"},{tag:k.comment,class:"tok-comment"},{tag:k.meta,class:"tok-meta"},{tag:k.invalid,class:"tok-invalid"},{tag:k.punctuation,class:"tok-punctuation"}]);var Rn;const xt=new D;function Bc(s){return A.define({combine:s?e=>e.concat(s):void 0})}const Dc=new D;class we{constructor(e,t,i=[],n=""){this.data=e,this.name=n,I.prototype.hasOwnProperty("tree")||Object.defineProperty(I.prototype,"tree",{get(){return ye(this)}}),this.parser=t,this.extension=[Lt.of(this),I.languageData.of((r,o,l)=>{let a=eo(r,o,l),h=a.type.prop(xt);if(!h)return[];let f=r.facet(h),c=a.type.prop(Dc);if(c){let u=a.resolve(o-a.from,l);for(let d of c)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(f)}}return f})].concat(i)}isActiveAt(e,t,i=-1){return eo(e,t,i).type.prop(xt)==this.data}findRegions(e){let t=e.facet(Lt);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(r,o)=>{if(r.prop(xt)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(D.mounted);if(l){if(l.tree.prop(xt)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(n(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<r.children.length;a++){let h=r.children[a];h instanceof $&&n(h,r.positions[a]+o)}};return n(ye(e),0),i}get allowsNesting(){return!0}}we.setState=_.define();function eo(s,e,t){let i=s.facet(Lt),n=ye(s).topNode;if(!i||i.allowsNesting)for(let r=n;r;r=r.enter(e,t,q.ExcludeBuffers|q.EnterBracketed))r.type.isTop&&(n=r);return n}class Gi extends we{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=Bc(e.languageData);return new Gi(t,e.parser.configure({props:[xt.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new Gi(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ye(s){let e=s.field(we.state,!1);return e?e.tree:$.empty}class Pc{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let Ht=null;class _i{constructor(e,t,i=[],n,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new _i(e,t,[],$.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Pc(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=$.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let n=Date.now()+e;e=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(ht.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(ht.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Ht;Ht=this;try{return e()}finally{Ht=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=to(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,f,c,u)=>a.push({fromA:h,toA:f,fromB:c,toB:u})),i=ht.applyChanges(i,a),n=$.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let f=e.mapPos(h.from,1),c=e.mapPos(h.to,-1);f<c&&l.push({from:f,to:c})}}}return new _i(this.parser,t,i,n,r,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:n,to:r}=this.skipped[i];n<e.to&&r>e.from&&(this.fragments=to(this.fragments,n,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Yl{createParse(t,i,n){let r=n[0].from,o=n[n.length-1].to;return{parsedPos:r,advance(){let a=Ht;if(a){for(let h of n)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new $(he.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Ht}}function to(s,e,t){return ht.applyChanges(s,[{fromA:e,toA:t,fromB:e,toB:t}])}class Pt{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new Pt(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=_i.create(e.facet(Lt).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new Pt(i)}}we.state=pt.define({create:Pt.init,update(s,e){for(let t of e.effects)if(t.is(we.setState))return t.value;return e.startState.facet(Lt)!=e.state.facet(Lt)?Pt.init(e.state):s.apply(e)}});let ta=s=>{let e=setTimeout(()=>s(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(ta=s=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(s,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const En=typeof navigator<"u"&&(!((Rn=navigator.scheduling)===null||Rn===void 0)&&Rn.isInputPending)?()=>navigator.scheduling.isInputPending():null,Lc=ze.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 t=this.view.state.field(we.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(we.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=ta(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,r=i.field(we.state);if(r.tree==r.context.tree&&r.context.isDone(n+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!En?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<n&&i.doc.length>n+1e3,a=r.context.work(()=>En&&En()||Date.now()>o,n+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:we.setState.of(new Pt(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Re(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Lt=A.define({combine(s){return s.length?s[0]:null},enables:s=>[we.state,Lc,B.contentAttributes.compute([s],e=>{let t=e.facet(s);return t&&t.name?{"data-language":t.name}:{}})]});class Rc{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const Ec=A.define(),Xs=A.define({combine:s=>{if(!s.length)return" ";let e=s[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(s[0]));return e}});function Xi(s){let e=s.facet(Xs);return e.charCodeAt(0)==9?s.tabSize*e.length:e.length}function Yi(s,e){let t="",i=s.tabSize,n=s.facet(Xs)[0];if(n==" "){for(;e>=i;)t+=" ",e-=i;n=" "}for(let r=0;r<e;r++)t+=n;return t}function ia(s,e){s instanceof I&&(s=new un(s));for(let i of s.state.facet(Ec)){let n=i(s,e);if(n!==void 0)return n}let t=ye(s.state);return t.length>=e?Ic(s,t,e):null}class un{constructor(e,t={}){this.state=e,this.options=t,this.unit=Xi(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return n!=null&&n>=i.from&&n<=i.to?r&&n==e?{text:"",from:e}:(t<0?n<e:n<=e)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(e,t);return i.slice(e-n,Math.min(i.length,e+100-n))}column(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.countColumn(i,e-n),o=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return o>-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return rn(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(n);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const na=new D;function Ic(s,e,t){let i=e.resolveStack(t),n=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(n!=i.node){let r=[];for(let o=n;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return sa(i,s,t)}function sa(s,e,t){for(let i=s;i;i=i.next){let n=Wc(i.node);if(n)return n(Ys.create(e,t,i))}return 0}function Nc(s){return s.pos==s.options.simulateBreak&&s.options.simulateDoubleBreak}function Wc(s){let e=s.type.prop(na);if(e)return e;let t=s.firstChild,i;if(t&&(i=t.type.prop(D.closedBy))){let n=s.lastChild,r=n&&i.indexOf(n.name)>-1;return o=>zc(o,!0,1,void 0,r&&!Nc(o)?n.from:void 0)}return s.parent==null?Fc:null}function Fc(){return 0}class Ys extends un{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new Ys(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Hc(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return sa(this.context.next,this.base,this.pos)}}function Hc(s,e){for(let t=e;t;t=t.parent)if(s==t)return!0;return!1}function Vc(s){let e=s.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let n=s.options.simulateBreak,r=s.state.doc.lineAt(t.from),o=n==null||n<=r.from?r.to:Math.min(r.to,n);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+h}}l=a.to}}function zc(s,e,t,i,n){let r=s.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||n==s.pos+o,a=Vc(s);return a?l?s.column(a.from):s.column(a.to):s.baseIndent+(l?0:s.unit*t)}function Qc({except:s,units:e=1}={}){return t=>{let i=s&&s.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const qc=new D;class dn{constructor(e,t){this.specs=e;let i;function n(l){let a=_e.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?n(t.all):void 0,o=t.scope;this.scope=o instanceof we?l=>l.prop(xt)==o.data:o?l=>l==o:void 0,this.style=ea(e.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new _e(i):null,this.themeType=t.themeType}static define(e,t){return new dn(e,t||{})}}const ws=A.define(),Kc=A.define({combine(s){return s.length?[s[0]]:null}});function In(s){let e=s.facet(ws);return e.length?e:s.facet(Kc)}function Uc(s,e){let t=[$c],i;return s instanceof dn&&(s.module&&t.push(B.styleModule.of(s.module)),i=s.themeType),i?t.push(ws.computeN([B.darkTheme],n=>n.facet(B.darkTheme)==(i=="dark")?[s]:[])):t.push(ws.of(s)),t}class jc{constructor(e){this.markCache=Object.create(null),this.tree=ye(e.state),this.decorations=this.buildDeco(e,In(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=ye(e.state),i=In(e.state),n=i!=In(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!n&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return G.none;let i=new Xt;for(let{from:n,to:r}of e.visibleRanges)Oc(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=G.mark({class:a})))},n,r);return i.finish()}}const $c=Rs.high(ze.fromClass(jc,{decorations:s=>s.decorations})),Gc=1e4,_c="()[]{}",Xc=new D;function vs(s,e,t){let i=s.prop(e<0?D.openedBy:D.closedBy);if(i)return i;if(s.name.length==1){let n=t.indexOf(s.name);if(n>-1&&n%2==(e<0?1:0))return[t[n+e]]}return null}function Ss(s){let e=s.type.prop(Xc);return e?e(s.node):s}function wt(s,e,t,i={}){let n=i.maxScanDistance||Gc,r=i.brackets||_c,o=ye(s),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=vs(a.type,t,r);if(h&&a.from<a.to){let f=Ss(a);if(f&&(t>0?e>=f.from&&e<f.to:e>f.from&&e<=f.to))return Yc(s,e,t,a,f,h,r)}}return Jc(s,e,t,o,l.type,n,r)}function Yc(s,e,t,i,n,r,o){let l=i.parent,a={from:n.from,to:n.to},h=0,f=l==null?void 0:l.cursor();if(f&&(t<0?f.childBefore(i.from):f.childAfter(i.to)))do if(t<0?f.to<=i.from:f.from>=i.to){if(h==0&&r.indexOf(f.type.name)>-1&&f.from<f.to){let c=Ss(f);return{start:a,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(vs(f.type,t,o))h++;else if(vs(f.type,-t,o)){if(h==0){let c=Ss(f);return{start:a,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}h--}}while(t<0?f.prevSibling():f.nextSibling());return{start:a,matched:!1}}function Jc(s,e,t,i,n,r,o){let l=t<0?s.sliceDoc(e-1,e):s.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},f=s.doc.iterRange(e,t>0?s.doc.length:0),c=0;for(let u=0;!f.next().done&&u<=r;){let d=f.value;t<0&&(u+=d.length);let p=e+u*t;for(let g=t>0?0:d.length-1,m=t>0?d.length:-1;g!=m;g+=t){let y=o.indexOf(d[g]);if(!(y<0||i.resolveInner(p+g,1).type!=n))if(y%2==0==t>0)c++;else{if(c==1)return{start:h,end:{from:p+g,to:p+g+1},matched:y>>1==a>>1};c--}}t>0&&(u+=d.length)}return f.done?{start:h,matched:!1}:null}const Zc=Object.create(null),io=[he.none],no=[],so=Object.create(null),eu=Object.create(null);for(let[s,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"]])eu[s]=tu(Zc,e);function Nn(s,e){no.indexOf(s)>-1||(no.push(s),console.warn(e))}function tu(s,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let f=s[h]||k[h];f?typeof f=="function"?a.length?a=a.map(f):Nn(h,`Modifier ${h} used at start of tag`):a.length?Nn(h,`Tag ${h} used as modifier`):a=Array.isArray(f)?f:[f]:Nn(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),n=i+" "+t.map(l=>l.id),r=so[n];if(r)return r.id;let o=so[n]=he.define({id:io.length,name:i,props:[Jl({[i]:t})]});return io.push(o),o.id}j.RTL,j.LTR;const iu=s=>{let{state:e}=s,t=e.doc.lineAt(e.selection.main.from),i=Zs(s.state,t.from);return i.line?nu(s):i.block?ru(s):!1};function Js(s,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let n=s(e,t);return n?(i(t.update(n)),!0):!1}}const nu=Js(au,0),su=Js(ra,0),ru=Js((s,e)=>ra(s,e,lu(e)),0);function Zs(s,e){let t=s.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const Vt=50;function ou(s,{open:e,close:t},i,n){let r=s.sliceDoc(i-Vt,i),o=s.sliceDoc(n,n+Vt),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,h=r.length-l;if(r.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:n+a,margin:a&&1}};let f,c;n-i<=2*Vt?f=c=s.sliceDoc(i,n):(f=s.sliceDoc(i,i+Vt),c=s.sliceDoc(n-Vt,n));let u=/^\s*/.exec(f)[0].length,d=/\s*$/.exec(c)[0].length,p=c.length-d-t.length;return f.slice(u,u+e.length)==e&&c.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(f.charAt(u+e.length))?1:0},close:{pos:n-d-t.length,margin:/\s/.test(c.charAt(p-1))?1:0}}:null}function lu(s){let e=[];for(let t of s.selection.ranges){let i=s.doc.lineAt(t.from),n=t.to<=i.to?i:s.doc.lineAt(t.to);n.from>i.from&&n.from==t.to&&(n=t.to==i.to+1?i:s.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=n.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:n.to})}return e}function ra(s,e,t=e.selection.ranges){let i=t.map(r=>Zs(e,r.from).block);if(!i.every(r=>r))return null;let n=t.map((r,o)=>ou(e,i[o],r.from,r.to));if(s!=2&&!n.every(r=>r))return{changes:e.changes(t.map((r,o)=>n[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(s!=1&&n.some(r=>r)){let r=[];for(let o=0,l;o<n.length;o++)if(l=n[o]){let a=i[o],{open:h,close:f}=l;r.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:f.pos-f.margin,to:f.pos+a.close.length})}return{changes:r}}return null}function au(s,e,t=e.selection.ranges){let i=[],n=-1;e:for(let{from:r,to:o}of t){let l=i.length,a=1e9,h;for(let f=r;f<=o;){let c=e.doc.lineAt(f);if(h==null&&(h=Zs(e,c.from).line,!h))continue e;if(c.from>n&&(r==o||o>c.from)){n=c.from;let u=/^\s*/.exec(c.text)[0].length,d=u==c.length,p=c.text.slice(u,u+h.length)==h?u:-1;u<c.text.length&&u<a&&(a=u),i.push({line:c,comment:p,token:h,indent:u,empty:d,single:!1})}f=c.to+1}if(a<1e9)for(let f=l;f<i.length;f++)i[f].indent<i[f].line.text.length&&(i[f].indent=a);i.length==l+1&&(i[l].single=!0)}if(s!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:f,single:c}of i)(c||!f)&&r.push({from:l.from+h,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(s!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,f=h+a.length;o.text[f-o.from]==" "&&f++,r.push({from:h,to:f})}return{changes:r}}return null}function Et(s,e){return b.create(s.ranges.map(e),s.mainIndex)}function Se(s,e){return s.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Ce({state:s,dispatch:e},t){let i=Et(s.selection,t);return i.eq(s.selection,!0)?!1:(e(Se(s,i)),!0)}function pn(s,e){return b.cursor(e?s.to:s.from)}function oa(s,e){return Ce(s,t=>t.empty?s.moveByChar(t,e):pn(t,e))}function ne(s){return s.textDirectionAt(s.state.selection.main.head)==j.LTR}const la=s=>oa(s,!ne(s)),aa=s=>oa(s,ne(s));function ha(s,e){return Ce(s,t=>t.empty?s.moveByGroup(t,e):pn(t,e))}const hu=s=>ha(s,!ne(s)),fu=s=>ha(s,ne(s));function cu(s,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(s.sliceDoc(e.from,e.to)))||e.firstChild}function gn(s,e,t){let i=ye(s).resolveInner(e.head),n=t?D.closedBy:D.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;cu(s,h,n)?i=h:a=t?h.to:h.from}let r=i.type.prop(n),o,l;return r&&(o=t?wt(s,i.from,1):wt(s,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,b.cursor(l,t?-1:1)}const uu=s=>Ce(s,e=>gn(s.state,e,!ne(s))),du=s=>Ce(s,e=>gn(s.state,e,ne(s)));function fa(s,e){return Ce(s,t=>{if(!t.empty)return pn(t,e);let i=s.moveVertically(t,e);return i.head!=t.head?i:s.moveToLineBoundary(t,e)})}const ca=s=>fa(s,!1),ua=s=>fa(s,!0);function da(s){let e=s.scrollDOM.clientHeight<s.scrollDOM.scrollHeight-2,t=0,i=0,n;if(e){for(let r of s.state.facet(B.scrollMargins)){let o=r(s);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}n=s.scrollDOM.clientHeight-t-i}else n=(s.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(s.defaultLineHeight,n-5)}}function pa(s,e){let t=da(s),{state:i}=s,n=Et(i.selection,o=>o.empty?s.moveVertically(o,e,t.height):pn(o,e));if(n.eq(i.selection))return!1;let r;if(t.selfScroll){let o=s.coordsAtPos(i.selection.main.head),l=s.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(r=B.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-a}))}return s.dispatch(Se(i,n),{effects:r}),!0}const ro=s=>pa(s,!1),Cs=s=>pa(s,!0);function Ze(s,e,t){let i=s.lineBlockAt(e.head),n=s.moveToLineBoundary(e,t);if(n.head==e.head&&n.head!=(t?i.to:i.from)&&(n=s.moveToLineBoundary(e,t,!1)),!t&&n.head==i.from&&i.length){let r=/^\s*/.exec(s.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(n=b.cursor(i.from+r))}return n}const pu=s=>Ce(s,e=>Ze(s,e,!0)),gu=s=>Ce(s,e=>Ze(s,e,!1)),mu=s=>Ce(s,e=>Ze(s,e,!ne(s))),yu=s=>Ce(s,e=>Ze(s,e,ne(s))),ku=s=>Ce(s,e=>b.cursor(s.lineBlockAt(e.head).from,1)),bu=s=>Ce(s,e=>b.cursor(s.lineBlockAt(e.head).to,-1));function xu(s,e,t){let i=!1,n=Et(s.selection,r=>{let o=wt(s,r.head,-1)||wt(s,r.head,1)||r.head>0&&wt(s,r.head-1,1)||r.head<s.doc.length&&wt(s,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return b.cursor(l)});return i?(e(Se(s,n)),!0):!1}const wu=({state:s,dispatch:e})=>xu(s,e);function ke(s,e){let t=Et(s.state.selection,i=>{let n=e(i);return b.range(i.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return t.eq(s.state.selection)?!1:(s.dispatch(Se(s.state,t)),!0)}function ga(s,e){return ke(s,t=>s.moveByChar(t,e))}const ma=s=>ga(s,!ne(s)),ya=s=>ga(s,ne(s));function ka(s,e){return ke(s,t=>s.moveByGroup(t,e))}const vu=s=>ka(s,!ne(s)),Su=s=>ka(s,ne(s)),Cu=s=>ke(s,e=>gn(s.state,e,!ne(s))),Au=s=>ke(s,e=>gn(s.state,e,ne(s)));function ba(s,e){return ke(s,t=>s.moveVertically(t,e))}const xa=s=>ba(s,!1),wa=s=>ba(s,!0);function va(s,e){return ke(s,t=>s.moveVertically(t,e,da(s).height))}const oo=s=>va(s,!1),lo=s=>va(s,!0),Ou=s=>ke(s,e=>Ze(s,e,!0)),Mu=s=>ke(s,e=>Ze(s,e,!1)),Tu=s=>ke(s,e=>Ze(s,e,!ne(s))),Bu=s=>ke(s,e=>Ze(s,e,ne(s))),Du=s=>ke(s,e=>b.cursor(s.lineBlockAt(e.head).from)),Pu=s=>ke(s,e=>b.cursor(s.lineBlockAt(e.head).to)),ao=({state:s,dispatch:e})=>(e(Se(s,{anchor:0})),!0),ho=({state:s,dispatch:e})=>(e(Se(s,{anchor:s.doc.length})),!0),fo=({state:s,dispatch:e})=>(e(Se(s,{anchor:s.selection.main.anchor,head:0})),!0),co=({state:s,dispatch:e})=>(e(Se(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),Lu=({state:s,dispatch:e})=>(e(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),Ru=({state:s,dispatch:e})=>{let t=mn(s).map(({from:i,to:n})=>b.range(i,Math.min(n+1,s.doc.length)));return e(s.update({selection:b.create(t),userEvent:"select"})),!0},Eu=({state:s,dispatch:e})=>{let t=Et(s.selection,i=>{let n=ye(s),r=n.resolveStack(i.from,1);if(i.empty){let o=n.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return b.range(l.to,l.from)}return i});return t.eq(s.selection)?!1:(e(Se(s,t)),!0)};function Sa(s,e){let{state:t}=s,i=t.selection,n=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to<s.state.doc.length:o.from>0)for(let l=r;;){let a=s.moveVertically(l,e);if(a.head<o.from||a.head>o.to){n.some(h=>h.head==a.head)||n.push(a);break}else{if(a.head==l.head)break;l=a}}}return n.length==i.ranges.length?!1:(s.dispatch(Se(t,b.create(n,n.length-1))),!0)}const Iu=s=>Sa(s,!1),Nu=s=>Sa(s,!0),Wu=({state:s,dispatch:e})=>{let t=s.selection,i=null;return t.ranges.length>1?i=b.create([t.main]):t.main.empty||(i=b.create([b.cursor(t.main.head)])),i?(e(Se(s,i)),!0):!1};function ai(s,e){if(s.state.readOnly)return!1;let t="delete.selection",{state:i}=s,n=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=Oi(s,a,!1)):a>o&&(t="delete.forward",a=Oi(s,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Oi(s,o,!1),l=Oi(s,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:b.cursor(o,o<r.head?-1:1)}});return n.changes.empty?!1:(s.dispatch(i.update(n,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?B.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Oi(s,e,t){if(s instanceof B)for(let i of s.state.facet(B.atomicRanges).map(n=>n(s)))i.between(e,e,(n,r)=>{n<e&&r>e&&(e=t?r:n)});return e}const Ca=(s,e,t)=>ai(s,i=>{let n=i.from,{state:r}=s,o=r.doc.lineAt(n),l,a;if(t&&!e&&n>o.from&&n<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,n-o.from))){if(l[l.length-1]==" ")return n-1;let h=rn(l,r.tabSize),f=h%Xi(r)||Xi(r);for(let c=0;c<f&&l[l.length-1-c]==" ";c++)n--;a=n}else a=te(o.text,n-o.from,e,e)+o.from,a==n&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,n-o.from))&&(a=te(o.text,a-o.from,!1,!1)+o.from);return a}),As=s=>Ca(s,!1,!0),Aa=s=>Ca(s,!0,!1),Oa=(s,e)=>ai(s,t=>{let i=t.head,{state:n}=s,r=n.doc.lineAt(i),o=n.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?n.doc.lines:1)&&(i+=e?1:-1);break}let a=te(r.text,i-r.from,e)+r.from,h=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),f=o(h);if(l!=null&&f!=l)break;(h!=" "||i!=t.head)&&(l=f),i=a}return i}),Ma=s=>Oa(s,!1),Fu=s=>Oa(s,!0),Hu=s=>ai(s,e=>{let t=s.lineBlockAt(e.head).to;return e.head<t?t:Math.min(s.state.doc.length,e.head+1)}),Vu=s=>ai(s,e=>{let t=s.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),zu=s=>ai(s,e=>{let t=s.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(s.state.doc.length,e.head+1)}),Qu=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=s.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:E.of(["",""])},range:b.cursor(i.from)}));return e(s.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},qu=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=s.changeByRange(i=>{if(!i.empty||i.from==0||i.from==s.doc.length)return{range:i};let n=i.from,r=s.doc.lineAt(n),o=n==r.from?n-1:te(r.text,n-r.from,!1)+r.from,l=n==r.to?n+1:te(r.text,n-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:s.doc.slice(n,l).append(s.doc.slice(o,n))},range:b.cursor(l)}});return t.changes.empty?!1:(e(s.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function mn(s){let e=[],t=-1;for(let i of s.selection.ranges){let n=s.doc.lineAt(i.from),r=s.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=s.doc.lineAt(i.to-1)),t>=n.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:n.from,to:r.to,ranges:[i]});t=r.number+1}return e}function Ta(s,e,t){if(s.readOnly)return!1;let i=[],n=[];for(let r of mn(s)){if(t?r.to==s.doc.length:r.from==0)continue;let o=s.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+s.lineBreak});for(let a of r.ranges)n.push(b.range(Math.min(s.doc.length,a.anchor+l),Math.min(s.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:s.lineBreak+o.text});for(let a of r.ranges)n.push(b.range(a.anchor-l,a.head-l))}}return i.length?(e(s.update({changes:i,scrollIntoView:!0,selection:b.create(n,s.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Ku=({state:s,dispatch:e})=>Ta(s,e,!1),Uu=({state:s,dispatch:e})=>Ta(s,e,!0);function Ba(s,e,t){if(s.readOnly)return!1;let i=[];for(let r of mn(s))t?i.push({from:r.from,insert:s.doc.slice(r.from,r.to)+s.lineBreak}):i.push({from:r.to,insert:s.lineBreak+s.doc.slice(r.from,r.to)});let n=s.changes(i);return e(s.update({changes:n,selection:s.selection.map(n,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const ju=({state:s,dispatch:e})=>Ba(s,e,!1),$u=({state:s,dispatch:e})=>Ba(s,e,!0),Gu=s=>{if(s.state.readOnly)return!1;let{state:e}=s,t=e.changes(mn(e).map(({from:n,to:r})=>(n>0?n--:r<e.doc.length&&r++,{from:n,to:r}))),i=Et(e.selection,n=>{let r;if(s.lineWrapping){let o=s.lineBlockAt(n.head),l=s.coordsAtPos(n.head,n.assoc||1);l&&(r=o.bottom+s.documentTop-l.bottom+s.defaultLineHeight/2)}return s.moveVertically(n,!0,r)}).map(t);return s.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function _u(s,e){if(/\(\)|\[\]|\{\}/.test(s.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=ye(s).resolveInner(e),i=t.childBefore(e),n=t.childAfter(e),r;return i&&n&&i.to<=e&&n.from>=e&&(r=i.type.prop(D.closedBy))&&r.indexOf(n.name)>-1&&s.doc.lineAt(i.to).from==s.doc.lineAt(n.from).from&&!/\S/.test(s.sliceDoc(i.to,n.from))?{from:i.to,to:n.from}:null}const uo=Da(!1),Xu=Da(!0);function Da(s){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(n=>{let{from:r,to:o}=n,l=e.doc.lineAt(r),a=!s&&r==o&&_u(e,r);s&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new un(e,{simulateBreak:r,simulateDoubleBreak:!!a}),f=ia(h,r);for(f==null&&(f=rn(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let c=["",Yi(e,f)];return a&&c.push(Yi(e,h.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:E.of(c)},range:b.cursor(r+1+c[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function er(s,e){let t=-1;return s.changeByRange(i=>{let n=[];for(let o=i.from;o<=i.to;){let l=s.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,n,i),t=l.number),o=l.to+1}let r=s.changes(n);return{changes:n,range:b.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const Yu=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=Object.create(null),i=new un(s,{overrideIndentation:r=>{let o=t[r];return o??-1}}),n=er(s,(r,o,l)=>{let a=ia(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],f=Yi(s,a);(h!=f||l.from<r.from+h.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+h.length,insert:f}))});return n.changes.empty||e(s.update(n,{userEvent:"indent"})),!0},Pa=({state:s,dispatch:e})=>s.readOnly?!1:(e(s.update(er(s,(t,i)=>{i.push({from:t.from,insert:s.facet(Xs)})}),{userEvent:"input.indent"})),!0),La=({state:s,dispatch:e})=>s.readOnly?!1:(e(s.update(er(s,(t,i)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let r=rn(n,s.tabSize),o=0,l=Yi(s,Math.max(0,r-Xi(s)));for(;o<n.length&&o<l.length&&n.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+n.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),Ju=s=>(s.setTabFocusMode(),!0),Zu=[{key:"Ctrl-b",run:la,shift:ma,preventDefault:!0},{key:"Ctrl-f",run:aa,shift:ya},{key:"Ctrl-p",run:ca,shift:xa},{key:"Ctrl-n",run:ua,shift:wa},{key:"Ctrl-a",run:ku,shift:Du},{key:"Ctrl-e",run:bu,shift:Pu},{key:"Ctrl-d",run:Aa},{key:"Ctrl-h",run:As},{key:"Ctrl-k",run:Hu},{key:"Ctrl-Alt-h",run:Ma},{key:"Ctrl-o",run:Qu},{key:"Ctrl-t",run:qu},{key:"Ctrl-v",run:Cs}],ed=[{key:"ArrowLeft",run:la,shift:ma,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:hu,shift:vu,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:mu,shift:Tu,preventDefault:!0},{key:"ArrowRight",run:aa,shift:ya,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:fu,shift:Su,preventDefault:!0},{mac:"Cmd-ArrowRight",run:yu,shift:Bu,preventDefault:!0},{key:"ArrowUp",run:ca,shift:xa,preventDefault:!0},{mac:"Cmd-ArrowUp",run:ao,shift:fo},{mac:"Ctrl-ArrowUp",run:ro,shift:oo},{key:"ArrowDown",run:ua,shift:wa,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ho,shift:co},{mac:"Ctrl-ArrowDown",run:Cs,shift:lo},{key:"PageUp",run:ro,shift:oo},{key:"PageDown",run:Cs,shift:lo},{key:"Home",run:gu,shift:Mu,preventDefault:!0},{key:"Mod-Home",run:ao,shift:fo},{key:"End",run:pu,shift:Ou,preventDefault:!0},{key:"Mod-End",run:ho,shift:co},{key:"Enter",run:uo,shift:uo},{key:"Mod-a",run:Lu},{key:"Backspace",run:As,shift:As,preventDefault:!0},{key:"Delete",run:Aa,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Ma,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Fu,preventDefault:!0},{mac:"Mod-Backspace",run:Vu,preventDefault:!0},{mac:"Mod-Delete",run:zu,preventDefault:!0}].concat(Zu.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),gp=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:uu,shift:Cu},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:du,shift:Au},{key:"Alt-ArrowUp",run:Ku},{key:"Shift-Alt-ArrowUp",run:ju},{key:"Alt-ArrowDown",run:Uu},{key:"Shift-Alt-ArrowDown",run:$u},{key:"Mod-Alt-ArrowUp",run:Iu},{key:"Mod-Alt-ArrowDown",run:Nu},{key:"Escape",run:Wu},{key:"Mod-Enter",run:Xu},{key:"Alt-l",mac:"Ctrl-l",run:Ru},{key:"Mod-i",run:Eu,preventDefault:!0},{key:"Mod-[",run:La},{key:"Mod-]",run:Pa},{key:"Mod-Alt-\\",run:Yu},{key:"Shift-Mod-k",run:Gu},{key:"Shift-Mod-\\",run:wu},{key:"Mod-/",run:iu},{key:"Alt-A",run:su},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Ju}].concat(ed),mp={key:"Tab",run:Pa,shift:La};var po={};class Ji{constructor(e,t,i,n,r,o,l,a,h,f=0,c){this.p=e,this.stack=t,this.state=i,this.reducePos=n,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=h,this.lookAhead=f,this.parent=c}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let n=e.parser.context;return new Ji(e,[],t,i,i,0,[],0,n?new go(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,n=e&65535,{parser:r}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=r.dynamicPrecedence(n);if(l&&(this.score+=l),i==0){this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(n,this.reducePos);return}let a=this.stack.length-(i-1)*3-(e&262144?6:0),h=a?this.stack[a-2]:this.p.ranges[0].from,f=this.reducePos-h;f>=2e3&&!(!((t=this.p.parser.nodeSet.types[n])===null||t===void 0)&&t.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=f):this.p.lastBigReductionSize<f&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=f));let c=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-c;if(n<r.minRepeatTerm||e&131072){let d=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,h,d,u+4,!0)}if(e&262144)this.state=this.stack[a];else{let d=this.stack[a-3];this.state=r.getGoto(d,n,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(n,h)}storeNode(e,t,i,n=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,l=this.buffer.length;if(l==0&&o.parent&&(l=o.bufferBase-o.parent.bufferBase,o=o.parent),l>0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(t==i)return;if(o.buffer[l-2]>=t){o.buffer[l-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(e,t,i,n);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>i;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,n>4&&(n-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=n}}shift(e,t,i,n){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let r=e,{parser:o}=this.p;this.pos=n;let l=o.stateFlag(r,1);!l&&(n>i||t<=o.maxNode)&&(this.reducePos=n),this.pushState(r,l?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,n,4)}else this.pos=n,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,n,4)}apply(e,t,i,n){e&65536?this.reduce(e):this.shift(e,t,i,n)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let n=this.pos;this.reducePos=this.pos=n+e.length,this.pushState(t,n),this.buffer.push(i,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),n=e.bufferBase+t;for(;e&&n==e.bufferBase;)e=e.parent;return new Ji(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,n,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new td(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,o;r<t.length;r+=2)(o=t[r+1])!=this.state&&this.p.parser.hasAction(o,e)&&n.push(t[r],o);if(this.stack.length<120)for(let r=0;n.length<8&&r<t.length;r+=2){let o=t[r+1];n.some((l,a)=>a&1&&l==o)||n.push(t[r],o)}t=n}let i=[];for(let n=0;n<t.length&&i.length<4;n+=2){let r=t[n+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[n],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((t&65536)==0)return!1;if(!e.validAction(this.state,t)){let i=t>>19,n=t&65535,r=this.stack.length-i*3;if(r<0||e.getGoto(this.stack[r],n,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(n,r)=>{if(!t.includes(n))return t.push(n),e.allActions(n,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,h=this.stack.length-l*3;if(h>=0&&e.getGoto(this.stack[h],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,r+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new go(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class go{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class td{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=n}}class Zi{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Zi(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}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]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Zi(this.stack,this.pos,this.index)}}function Mi(s,e=Uint16Array){if(typeof s!="string")return s;let t=null;for(let i=0,n=0;i<s.length;){let r=0;for(;;){let o=s.charCodeAt(i++),l=!1;if(o==126){r=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}t?t[n++]=r:t=new e(r)}return t}class Ei{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const mo=new Ei;class id{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=mo,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,n=this.rangeIndex,r=this.pos+e;for(;r<i.from;){if(!n)return null;let o=this.ranges[--n];r-=i.from-o.to,i=o}for(;t<0?r>i.to:r>=i.to;){if(n==this.ranges.length-1)return null;let o=this.ranges[++n];r+=o.from-i.to,i=o}return r}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,n;if(t>=0&&t<this.chunk.length)i=this.pos+e,n=this.chunk.charCodeAt(t);else{let r=this.resolveOffset(e,1);if(r==null)return-1;if(i=r,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),n=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),n}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=mo,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let n of this.ranges){if(n.from>=t)break;n.to>e&&(i+=this.input.read(Math.max(n.from,e),Math.min(n.to,t)))}return i}}class Ot{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;sd(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}Ot.prototype.contextual=Ot.prototype.fallback=Ot.prototype.extend=!1;Ot.prototype.fallback=Ot.prototype.extend=!1;class nd{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function sd(s,e,t,i,n,r){let o=0,l=1<<i,{dialect:a}=t.p.parser;e:for(;(l&s[o])!=0;){let h=s[o+1];for(let d=o+3;d<h;d+=2)if((s[d+1]&l)>0){let p=s[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||rd(p,e.token.value,n,r))){e.acceptToken(p);break}}let f=e.next,c=0,u=s[o+2];if(e.next<0&&u>c&&s[h+u*3-3]==65535){o=s[h+u*3-1];continue e}for(;c<u;){let d=c+u>>1,p=h+d+(d<<1),g=s[p],m=s[p+1]||65536;if(f<g)u=d;else if(f>=m)c=d+1;else{o=s[p+2],e.advance();continue e}}break}}function yo(s,e,t){for(let i=e,n;(n=s[i])!=65535;i++)if(n==t)return i-e;return-1}function rd(s,e,t,i){let n=yo(t,i,e);return n<0||yo(t,i,s)<n}const fe=typeof process<"u"&&po&&/\bparse\b/.test(po.LOG);let Wn=null;function ko(s,e,t){let i=s.cursor(q.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.to<e:i.from>e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(s.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:s.length}}class od{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?ko(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?ko(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let i=this.trees[t],n=this.index[t];if(n==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[n],o=this.start[t]+i.positions[n];if(o>e)return this.nextStart=o,null;if(r instanceof $){if(o==e){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(D.lookAhead);if(!a||l+a<this.fragment.to)return r}}this.index[t]++,o+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class ld{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new Ei)}getActions(e){let t=0,i=null,{parser:n}=e.p,{tokenizers:r}=n,o=n.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let h=0;h<r.length;h++){if((1<<h&o)==0)continue;let f=r[h],c=this.tokens[h];if(!(i&&!f.fallback)&&((f.contextual||c.start!=e.pos||c.mask!=o||c.context!=l)&&(this.updateCachedToken(c,f,e),c.mask=o,c.context=l),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),c.value!=0)){let u=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!f.extend&&(i=c,t>u))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new Ei,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Ei,{pos:i,p:n}=e;return t.start=i,t.end=Math.min(i+1,n.stream.end),t.value=i==n.stream.end?n.parser.eofTerm:0,t}updateCachedToken(e,t,i){let n=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(n,e),i),e.value>-1){let{parser:r}=i.p;for(let o=0;o<r.specialized.length;o++)if(r.specialized[o]==e.value){let l=r.specializers[o](this.stream.read(e.start,e.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(n+1)}putAction(e,t,i,n){for(let r=0;r<n;r+=3)if(this.actions[r]==e)return n;return this.actions[n++]=e,this.actions[n++]=t,this.actions[n++]=i,n}addActions(e,t,i,n){let{state:r}=e,{parser:o}=e.p,{data:l}=o;for(let a=0;a<2;a++)for(let h=o.stateSlot(r,a?2:1);;h+=3){if(l[h]==65535)if(l[h+1]==1)h=Ie(l,h+2);else{n==0&&l[h+1]==2&&(n=this.putAction(Ie(l,h+2),t,i,n));break}l[h]==t&&(n=this.putAction(Ie(l,h+1),t,i,n))}return n}}class ad{constructor(e,t,i,n){this.parser=e,this.input=t,this.ranges=n,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new id(t,n),this.tokens=new ld(e,this.stream),this.topTerm=e.top[1];let{from:r}=n[0];this.stacks=[Ji.start(this,e.top[0],r)],this.fragments=i.length&&this.stream.end-r>e.bufferLength*4?new od(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],n,r;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>t)i.push(l);else{if(this.advanceStack(l,i,e))continue;{n||(n=[],r=[]),n.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!i.length){let o=n&&fd(n);if(o)return fe&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw fe&&n&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&n){let o=this.stoppedAt!=null&&n[0].pos>this.stoppedAt?n[0]:this.runRecovery(n,r,i);if(o)return fe&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let l=i[o];for(let a=o+1;a<i.length;a++){let h=i[a];if(l.sameState(h)||l.buffer.length>500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let n=e.pos,{parser:r}=this,o=fe?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&n>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,f=h?e.curContext.hash:0;for(let c=this.fragments.nodeAt(n);c;){let u=this.parser.nodeSet.types[c.type.id]==c.type?r.getGoto(e.state,c.type.id):-1;if(u>-1&&c.length&&(!h||(c.prop(D.contextHash)||0)==f))return e.useNode(c,u),fe&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(c.type.id)})`),!0;if(!(c instanceof $)||c.children.length==0||c.positions[0]>0)break;let d=c.children[0];if(d instanceof $&&c.positions[0]==0)c=d;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),fe&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let h=0;h<a.length;){let f=a[h++],c=a[h++],u=a[h++],d=h==a.length||!i,p=d?e:e.split(),g=this.tokens.mainToken;if(p.apply(f,c,g?g.start:p.pos,u),fe&&console.log(o+this.stackID(p)+` (via ${(f&65536)==0?"shift":`reduce of ${r.getName(f&65535)}`} for ${r.getName(c)} @ ${n}${p==e?"":", split"})`),d)return!0;p.pos>n?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return bo(e,t),!0}}runRecovery(e,t,i){let n=null,r=!1;for(let o=0;o<e.length;o++){let l=e[o],a=t[o<<1],h=t[(o<<1)+1],f=fe?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),fe&&console.log(f+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let c=l.split(),u=f;for(let d=0;d<10&&c.forceReduce()&&(fe&&console.log(u+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,i));d++)fe&&(u=this.stackID(c)+" -> ");for(let d of l.recoverByInsert(a))fe&&console.log(f+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),fe&&console.log(f+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),bo(l,i)):(!n||n.score<c.score)&&(n=c)}return n}stackToTree(e){return e.close(),$.build({buffer:Zi.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(Wn||(Wn=new WeakMap)).get(e);return t||Wn.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function bo(s,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==s.pos&&i.sameState(s)){e[t].score<s.score&&(e[t]=s);return}}e.push(s)}class hd{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}class en extends Yl{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let i=Object.keys(e.topRules).map(l=>e.topRules[l][1]),n=[];for(let l=0;l<t.length;l++)n.push([]);function r(l,a,h){n[l].push([a,a.deserialize(String(h))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=D[a]);for(let h=1;h<l.length;){let f=l[h++];if(f>=0)r(f,a,l[h++]);else{let c=l[h+-f];for(let u=-f;u>0;u--)r(l[h++],a,c);h++}}}this.nodeSet=new js(t.map((l,a)=>he.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:n[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=$l;let o=Mi(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(xo),this.states=Mi(e.states,Uint32Array),this.data=Mi(e.stateData),this.goto=Mi(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new Ot(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let n=new ad(this,e,t,i);for(let r of this.wrappers)n=r(n,e,t,i);return n}getGoto(e,t,i=!1){let n=this.goto;if(t>=n[0])return-1;for(let r=n[t+1];;){let o=n[r++],l=o&1,a=n[r++];if(l&&i)return a;for(let h=r+(o>>1);r<h;r++)if(n[r]==e)return a;if(l)return-1}}hasAction(e,t){let i=this.data;for(let n=0;n<2;n++)for(let r=this.stateSlot(e,n?2:1),o;;r+=3){if((o=i[r])==65535)if(i[r+1]==1)o=i[r=Ie(i,r+2)];else{if(i[r+1]==2)return Ie(i,r+2);break}if(o==t||o==0)return Ie(i,r+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),n=i?t(i):void 0;for(let r=this.stateSlot(e,1);n==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Ie(this.data,r+2);else break;n=t(Ie(this.data,r+1))}return n}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Ie(this.data,i+2);else break;if((this.data[i+2]&1)==0){let n=this.data[i+1];t.some((r,o)=>o&1&&r==n)||t.push(this.data[i],n)}}return t}configure(e){let t=Object.assign(Object.create(en.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let n=e.tokenizers.find(r=>r.from==i);return n?n.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,n)=>{let r=e.specializers.find(l=>l.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return t.specializers[n]=xo(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let r of e.split(" ")){let o=t.indexOf(r);o>=0&&(i[o]=!0)}let n=null;for(let r=0;r<t.length;r++)if(!i[r])for(let o=this.dialects[t[r]],l;(l=this.data[o++])!=65535;)(n||(n=new Uint8Array(this.maxTerm+1)))[l]=1;return new hd(e,i,n)}static deserialize(e){return new en(e)}}function Ie(s,e){return s[e]|s[e+1]<<16}function fd(s){let e=null;for(let t of s){let i=t.p.stoppedAt;(t.pos==t.p.stream.end||i!=null&&t.pos>i)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function xo(s){if(s.external){let e=s.extend?1:0;return(t,i)=>s.external(t,i)<<1|e}return s.get}function wo(s){let e=Object.keys(s).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function cd(s){let e=Object.create(null),t=Object.create(null);for(let{label:n}of s){e[n[0]]=!0;for(let r=1;r<n.length;r++)t[n[r]]=!0}let i=wo(e)+wo(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function ud(s){let e=s.map(n=>typeof n=="string"?{label:n}:n),[t,i]=e.every(n=>/^\w+$/.test(n.label))?[/\w*$/,/\w+$/]:cd(e);return n=>{let r=n.matchBefore(i);return r||n.explicit?{from:r?r.from:n.pos,options:e,validFor:t}:null}}function dd(s,e){return t=>{for(let i=ye(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(s.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}const Ra=new class extends Ge{};Ra.startSide=1;Ra.endSide=-1;const pd=36,vo=1,gd=2,mt=3,Fn=4,md=5,yd=6,kd=7,bd=8,xd=9,wd=10,vd=11,Sd=12,Cd=13,Ad=14,Od=15,Md=16,Td=17,So=18,Bd=19,Ea=20,Ia=21,Co=22,Dd=23,Pd=24;function Os(s){return s>=65&&s<=90||s>=97&&s<=122||s>=48&&s<=57}function Ld(s){return s>=48&&s<=57||s>=97&&s<=102||s>=65&&s<=70}function rt(s,e,t){for(let i=!1;;){if(s.next<0)return;if(s.next==e&&!i){s.advance();return}i=t&&!i&&s.next==92,s.advance()}}function Rd(s,e){e:for(;;){if(s.next<0)return;if(s.next==36){s.advance();for(let t=0;t<e.length;t++){if(s.next!=e.charCodeAt(t))continue e;s.advance()}if(s.next==36){s.advance();return}}else s.advance()}}function Ed(s,e){let t="[{<(".indexOf(String.fromCharCode(e)),i=t<0?e:"]}>)".charCodeAt(t);for(;;){if(s.next<0)return;if(s.next==i&&s.peek(1)==39){s.advance(2);return}s.advance()}}function Ms(s,e){for(;!(s.next!=95&&!Os(s.next));)e!=null&&(e+=String.fromCharCode(s.next)),s.advance();return e}function Id(s){if(s.next==39||s.next==34||s.next==96){let e=s.next;s.advance(),rt(s,e,!1)}else Ms(s)}function Ao(s,e){for(;s.next==48||s.next==49;)s.advance();e&&s.next==e&&s.advance()}function Oo(s,e){for(;;){if(s.next==46){if(e)break;e=!0}else if(s.next<48||s.next>57)break;s.advance()}if(s.next==69||s.next==101)for(s.advance(),(s.next==43||s.next==45)&&s.advance();s.next>=48&&s.next<=57;)s.advance()}function Mo(s){for(;!(s.next<0||s.next==10);)s.advance()}function nt(s,e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)==s)return!0;return!1}const Hn=` \r
|
|
11
|
+
`;function Na(s,e,t){let i=Object.create(null);i.true=i.false=md,i.null=i.unknown=yd;for(let n of s.split(" "))n&&(i[n]=Ea);for(let n of e.split(" "))n&&(i[n]=Ia);for(let n of(t||"").split(" "))n&&(i[n]=Pd);return i}const Nd="array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying ",Wd="absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone ",Ts={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:"*+-%<>!=&|~^/",specialVar:"?",identifierQuotes:'"',caseInsensitiveIdentifiers:!1,words:Na(Wd,Nd)};function Fd(s,e,t,i){let n={};for(let r in Ts)n[r]=(s.hasOwnProperty(r)?s:Ts)[r];return e&&(n.words=Na(e,t||"",i)),n}function Wa(s){return new nd(e=>{var t;let{next:i}=e;if(e.advance(),nt(i,Hn)){for(;nt(e.next,Hn);)e.advance();e.acceptToken(pd)}else if(i==36&&s.doubleDollarQuotedStrings){let n=Ms(e,"");e.next==36&&(e.advance(),Rd(e,n),e.acceptToken(mt))}else if(i==39||i==34&&s.doubleQuotedStrings)rt(e,i,s.backslashEscapes),e.acceptToken(mt);else if(i==35&&s.hashComments||i==47&&e.next==47&&s.slashComments)Mo(e),e.acceptToken(vo);else if(i==45&&e.next==45&&(!s.spaceAfterDashes||e.peek(1)==32))Mo(e),e.acceptToken(vo);else if(i==47&&e.next==42){e.advance();for(let n=1;;){let r=e.next;if(e.next<0)break;if(e.advance(),r==42&&e.next==47){if(n--,e.advance(),!n)break}else r==47&&e.next==42&&(n++,e.advance())}e.acceptToken(gd)}else if((i==101||i==69)&&e.next==39)e.advance(),rt(e,39,!0),e.acceptToken(mt);else if((i==110||i==78)&&e.next==39&&s.charSetCasts)e.advance(),rt(e,39,s.backslashEscapes),e.acceptToken(mt);else if(i==95&&s.charSetCasts)for(let n=0;;n++){if(e.next==39&&n>1){e.advance(),rt(e,39,s.backslashEscapes),e.acceptToken(mt);break}if(!Os(e.next))break;e.advance()}else if(s.plsqlQuotingMechanism&&(i==113||i==81)&&e.next==39&&e.peek(1)>0&&!nt(e.peek(1),Hn)){let n=e.peek(1);e.advance(2),Ed(e,n),e.acceptToken(mt)}else if(nt(i,s.identifierQuotes)){const n=i==91?93:i;rt(e,n,!1),e.acceptToken(Bd)}else if(i==40)e.acceptToken(kd);else if(i==41)e.acceptToken(bd);else if(i==123)e.acceptToken(xd);else if(i==125)e.acceptToken(wd);else if(i==91)e.acceptToken(vd);else if(i==93)e.acceptToken(Sd);else if(i==59)e.acceptToken(Cd);else if(s.unquotedBitLiterals&&i==48&&e.next==98)e.advance(),Ao(e),e.acceptToken(Co);else if((i==98||i==66)&&(e.next==39||e.next==34)){const n=e.next;e.advance(),s.treatBitsAsBytes?(rt(e,n,s.backslashEscapes),e.acceptToken(Dd)):(Ao(e,n),e.acceptToken(Co))}else if(i==48&&(e.next==120||e.next==88)||(i==120||i==88)&&e.next==39){let n=e.next==39;for(e.advance();Ld(e.next);)e.advance();n&&e.next==39&&e.advance(),e.acceptToken(Fn)}else if(i==46&&e.next>=48&&e.next<=57)Oo(e,!0),e.acceptToken(Fn);else if(i==46)e.acceptToken(Ad);else if(i>=48&&i<=57)Oo(e,!1),e.acceptToken(Fn);else if(nt(i,s.operatorChars)){for(;nt(e.next,s.operatorChars);)e.advance();e.acceptToken(Od)}else if(nt(i,s.specialVar))e.next==i&&e.advance(),Id(e),e.acceptToken(Td);else if(i==58||i==44)e.acceptToken(Md);else if(Os(i)){let n=Ms(e,String.fromCharCode(i));e.acceptToken(e.next==46||e.peek(-n.length-1)==46?So:(t=s.words[n.toLowerCase()])!==null&&t!==void 0?t:So)}})}const Fa=Wa(Ts),Hd=en.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:"⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement",maxTerm:38,nodeProps:[["isolate",-4,1,2,3,19,""]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:"RORO",tokenizers:[0,Fa],topRules:{Script:[0,25]},tokenPrec:0});function Bs(s){let e=s.cursor().moveTo(s.from,-1);for(;/Comment/.test(e.name);)e.moveTo(e.from,-1);return e.node}function si(s,e){let t=s.sliceString(e.from,e.to),i=/^([`'"\[])(.*)([`'"\]])$/.exec(t);return i?i[2]:t}function tn(s){return s&&(s.name=="Identifier"||s.name=="QuotedIdentifier")}function Vd(s,e){if(e.name=="CompositeIdentifier"){let t=[];for(let i=e.firstChild;i;i=i.nextSibling)tn(i)&&t.push(si(s,i));return t}return[si(s,e)]}function To(s,e){for(let t=[];;){if(!e||e.name!=".")return t;let i=Bs(e);if(!tn(i))return t;t.unshift(si(s,i)),e=Bs(i)}}function zd(s,e){let t=ye(s).resolveInner(e,-1),i=qd(s.doc,t);return t.name=="Identifier"||t.name=="QuotedIdentifier"||t.name=="Keyword"?{from:t.from,quoted:t.name=="QuotedIdentifier"?s.doc.sliceString(t.from,t.from+1):null,parents:To(s.doc,Bs(t)),aliases:i}:t.name=="."?{from:e,quoted:null,parents:To(s.doc,t),aliases:i}:{from:e,quoted:null,parents:[],empty:!0,aliases:i}}const Qd=new Set("where group having order union intersect except all distinct limit offset fetch for".split(" "));function qd(s,e){let t;for(let n=e;!t;n=n.parent){if(!n)return null;n.name=="Statement"&&(t=n)}let i=null;for(let n=t.firstChild,r=!1,o=null;n;n=n.nextSibling){let l=n.name=="Keyword"?s.sliceString(n.from,n.to).toLowerCase():null,a=null;if(!r)r=l=="from";else if(l=="as"&&o&&tn(n.nextSibling))a=si(s,n.nextSibling);else{if(l&&Qd.has(l))break;o&&tn(n)&&(a=si(s,n))}a&&(i||(i=Object.create(null)),i[a]=Vd(s,o)),o=/Identifier$/.test(n.name)?n:null}return i}function Kd(s,e,t){return t.map(i=>({...i,label:i.label[0]==s?i.label:s+i.label+e,apply:void 0}))}const Ud=/^\w*$/,jd=/^[`'"\[]?\w*[`'"\]]?$/;function Bo(s){return s.self&&typeof s.self.label=="string"}class tr{constructor(e,t){this.idQuote=e,this.idCaseInsensitive=t,this.list=[],this.children=void 0}child(e){let t=this.children||(this.children=Object.create(null)),i=t[e];return i||(e&&!this.list.some(n=>n.label==e)&&this.list.push(Do(e,"type",this.idQuote,this.idCaseInsensitive)),t[e]=new tr(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex(i=>i.label==e.label);t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion(typeof t=="string"?Do(t,"property",this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):Bo(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let i=e[t],n=null,r=t.replace(/\\?\./g,l=>l=="."?"\0":l).split("\0"),o=this;Bo(i)&&(n=i.self,i=i.children);for(let l=0;l<r.length;l++)n&&l==r.length-1&&o.addCompletion(n),o=o.child(r[l].replace(/\\\./g,"."));o.addNamespace(i)}}}function Do(s,e,t,i){return new RegExp("^[a-z_][a-z_\\d]*$",i?"i":"").test(s)?{label:s,type:e}:{label:s,type:e,apply:t+s+Ha(t)}}function Ha(s){return s==="["?"]":s}function $d(s,e,t,i,n,r){var o;let l=((o=r==null?void 0:r.spec.identifierQuotes)===null||o===void 0?void 0:o[0])||'"',a=new tr(l,!!(r!=null&&r.spec.caseInsensitiveIdentifiers)),h=n?a.child(n):null;return a.addNamespace(s),e&&(h||a).addCompletions(e),t&&a.addCompletions(t),h&&a.addCompletions(h.list),i&&a.addCompletions((h||a).child(i).list),f=>{let{parents:c,from:u,quoted:d,empty:p,aliases:g}=zd(f.state,f.pos);if(p&&!f.explicit)return null;g&&c.length==1&&(c=g[c[0]]||c);let m=a;for(let w of c){for(;!m.children||!m.children[w];)if(m==a&&h)m=h;else if(m==h&&i)m=m.child(i);else return null;let S=m.maybeChild(w);if(!S)return null;m=S}let y=m.list;if(m==a&&g&&(y=y.concat(Object.keys(g).map(w=>({label:w,type:"constant"})))),d){let w=d[0],S=Ha(w),L=f.state.sliceDoc(f.pos,f.pos+1)==S;return{from:u,to:L?f.pos+1:void 0,options:Kd(w,S,y),validFor:jd}}else return{from:u,options:y,validFor:Ud}}}function Gd(s){return s==Ia?"type":s==Ea?"keyword":"variable"}function _d(s,e,t){let i=Object.keys(s).map(n=>t(e?n.toUpperCase():n,Gd(s[n])));return dd(["QuotedIdentifier","String","LineComment","BlockComment","."],ud(i))}let Xd=Hd.configure({props:[na.add({Statement:Qc()}),qc.add({Statement(s,e){return{from:Math.min(s.from+100,e.doc.lineAt(s.from).to),to:s.to}},BlockComment(s){return{from:s.from+2,to:s.to-2}}}),Jl({Keyword:k.keyword,Type:k.typeName,Builtin:k.standard(k.name),Bits:k.number,Bytes:k.string,Bool:k.bool,Null:k.null,Number:k.number,String:k.string,Identifier:k.name,QuotedIdentifier:k.special(k.string),SpecialVar:k.special(k.name),LineComment:k.lineComment,BlockComment:k.blockComment,Operator:k.operator,"Semi Punctuation":k.punctuation,"( )":k.paren,"{ }":k.brace,"[ ]":k.squareBracket})]});class nn{constructor(e,t,i){this.dialect=e,this.language=t,this.spec=i}get extension(){return this.language.extension}configureLanguage(e,t){return new nn(this.dialect,this.language.configure(e,t),this.spec)}static define(e){let t=Fd(e,e.keywords,e.types,e.builtin),i=Gi.define({name:"sql",parser:Xd.configure({tokenizers:[{from:Fa,to:Wa(t)}]}),languageData:{commentTokens:{line:"--",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]}}});return new nn(t,i,e)}}function Yd(s,e){return{label:s,type:e,boost:-1}}function Jd(s,e=!1,t){return _d(s.dialect.words,e,t||Yd)}function Zd(s){return s.schema?$d(s.schema,s.tables,s.schemas,s.defaultTable,s.defaultSchema,s.dialect||ir):()=>null}function ep(s){return s.schema?(s.dialect||ir).language.data.of({autocomplete:Zd(s)}):[]}function yp(s={}){let e=s.dialect||ir;return new Rc(e.language,[ep(s),e.language.data.of({autocomplete:Jd(e,s.upperCaseKeywords,s.keywordCompletion)})])}const ir=nn.define({}),tp="#e5c07b",Po="#e06c75",ip="#56b6c2",np="#ffffff",Ii="#abb2bf",Ds="#7d8799",sp="#61afef",rp="#98c379",Lo="#d19a66",op="#c678dd",lp="#21252b",Ro="#2c313a",Eo="#282c34",Vn="#353a42",ap="#3E4451",Io="#528bff",hp=B.theme({"&":{color:Ii,backgroundColor:Eo},".cm-content":{caretColor:Io},".cm-cursor, .cm-dropCursor":{borderLeftColor:Io},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ap},".cm-panels":{backgroundColor:lp,color:Ii},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Eo,color:Ds,border:"none"},".cm-activeLineGutter":{backgroundColor:Ro},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Vn},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Vn,borderBottomColor:Vn},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Ro,color:Ii}}},{dark:!0}),fp=dn.define([{tag:k.keyword,color:op},{tag:[k.name,k.deleted,k.character,k.propertyName,k.macroName],color:Po},{tag:[k.function(k.variableName),k.labelName],color:sp},{tag:[k.color,k.constant(k.name),k.standard(k.name)],color:Lo},{tag:[k.definition(k.name),k.separator],color:Ii},{tag:[k.typeName,k.className,k.number,k.changed,k.annotation,k.modifier,k.self,k.namespace],color:tp},{tag:[k.operator,k.operatorKeyword,k.url,k.escape,k.regexp,k.link,k.special(k.string)],color:ip},{tag:[k.meta,k.comment],color:Ds},{tag:k.strong,fontWeight:"bold"},{tag:k.emphasis,fontStyle:"italic"},{tag:k.strikethrough,textDecoration:"line-through"},{tag:k.link,color:Ds,textDecoration:"underline"},{tag:k.heading,fontWeight:"bold",color:Po},{tag:[k.atom,k.bool,k.special(k.variableName)],color:Lo},{tag:[k.processingInstruction,k.string,k.inserted],color:rp},{tag:k.invalid,color:np}]),kp=[hp,Uc(fp)];export{B as E,I as a,gp as d,up as h,mp as i,Zf as k,dp as l,kp as o,yp as s};
|