const __vite__fileDeps=["./index-DnnaNnpE.js","./index-BOCEPdsd.js","./index-C7PS0jJm.js","./index-Bo0Yq5bb.css","./Check-BiRlaMNo.js","./Copy-CxQ9EyK2.js","./IconButtonWrapper.svelte_svelte_type_style_lang-BOpxTcdu.js","./IconButtonWrapper-EOzMzU45.css","./MarkdownCode.svelte_svelte_type_style_lang-3tofWDHK.js","./prism-python-qapVsvY8.js","./MarkdownCode-DPiWQnAx.css","./IconButton-B-aAVSzy.js","./Download-DVtk-Jv3.js","./DownloadLink-IzUam-rM.js","./context-TgWPFwN2.js","./file-url-DgijyRSD.js","./DownloadLink-CqD3Uu0l.css","./IconButtonWrapper-Cg16aIPK.js","./index-B1gfMDT9.js","./StreamingBar.svelte_svelte_type_style_lang-CDNxkBIr.js","./StreamingBar-DOagx4HU.css","./Clear-By3xiIwg.js","./Code-DGNrTu_I.js","./Block-DZqtZLFP.js","./BlockLabel-DqHge3FF.js","./Empty-CxRQfWXb.js","./Example-Wp-_4AVX.js","./Example-oomIF0ca.css","./index-t1IveIWW.js","./index-CpAE4MbP.js","./index-Bjous_T4.js","./index-nxrZbU9P.js","./frontmatter-BHlTarA4.js","./yaml-DsCXHVTH.js","./index-Vj2viUie.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]); import{_ as re}from"./index-C7PS0jJm.js";import{C as un}from"./Check-BiRlaMNo.js";import{C as Yr}from"./Copy-CxQ9EyK2.js";import"./IconButtonWrapper.svelte_svelte_type_style_lang-BOpxTcdu.js";import"./MarkdownCode.svelte_svelte_type_style_lang-3tofWDHK.js";import{I as Ql}from"./IconButton-B-aAVSzy.js";import{D as Xr}from"./Download-DVtk-Jv3.js";import{D as Uc}from"./DownloadLink-IzUam-rM.js";import{I as Gc}from"./IconButtonWrapper-Cg16aIPK.js";import{S as Jc}from"./index-B1gfMDT9.js";import{C as Zl}from"./Code-DGNrTu_I.js";import"./StreamingBar.svelte_svelte_type_style_lang-CDNxkBIr.js";import{B as Yc}from"./Block-DZqtZLFP.js";import{B as Xc}from"./BlockLabel-DqHge3FF.js";import{E as Qc}from"./Empty-CxRQfWXb.js";import Zc from"./Example-Wp-_4AVX.js";class N{constructor(){}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){let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),Ge.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let i=[];return this.decompose(e,t,i,0),Ge.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),s=new gi(this),r=new gi(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new gi(this,e)}iterRange(e,t=this.length){return new ea(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ta(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?N.empty:e.length<=32?new Y(e):Ge.from(Y.split(e,[]))}}class Y extends N{constructor(e,t=ef(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new tf(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new Y(Qr(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=sn(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new Y(l,o.length+r.length));else{let a=l.length>>1;i.push(new Y(l.slice(0,a)),new Y(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof Y))return super.replace(e,t,i);let s=sn(this.text,sn(i.text,Qr(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new Y(s,r):Ge.from(Y.split(s,[]),r)}sliceString(e,t=this.length,i=` `){let s="";for(let r=0,o=0;r<=t&&oe&&o&&(s+=i),er&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,i.length==32&&(t.push(new Y(i,s)),i=[],s=-1);return s>-1&&t.push(new Y(i,s)),t}}class Ge extends N{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,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,s);s=l+1,i=a+1}}decompose(e,t,i,s){for(let r=0,o=0;o<=t&&r=o){let h=s&((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(i.lines=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>h>>6){let c=this.children.slice();return c[s]=a,new Ge(c,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=` `){let s="";for(let r=0,o=0;re&&r&&(s+=i),eo&&(s+=l.sliceString(e-o,t-o,i)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Ge))return 0;let i=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return i;let a=this.children[s],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,s)=>i+s.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 Y(d,t)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,l=[],a=0,h=-1,c=[];function f(d){let p;if(d.lines>r&&d instanceof Ge)for(let g of d.children)f(g);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof Y&&a&&(p=c[c.length-1])instanceof Y&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new Y(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>s&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:Ge.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new Ge(l,t)}}N.empty=new Y([""],0);function ef(n){let e=-1;for(let t of n)e+=t.length+1;return e}function sn(n,e,t=0,i=1e9){for(let s=0,r=0,o=!0;r=t&&(a>i&&(l=l.slice(0,i-s)),s0?1:(e instanceof Y?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,l=s instanceof Y?s.text.length:s.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=` `,this;e--}else if(s instanceof Y){let a=s.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=s.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 Y?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 ea{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new gi(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:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.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 ta{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(N.prototype[Symbol.iterator]=function(){return this.iter()},gi.prototype[Symbol.iterator]=ea.prototype[Symbol.iterator]=ta.prototype[Symbol.iterator]=function(){return this});class tf{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}let jt="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(n=>n?parseInt(n,36):1);for(let n=1;nn)return jt[e-1]<=n;return!1}function Zr(n){return n>=127462&&n<=127487}const eo=8205;function Me(n,e,t=!0,i=!0){return(t?ia:sf)(n,e,i)}function ia(n,e,t){if(e==n.length)return e;e&&na(n.charCodeAt(e))&&sa(n.charCodeAt(e-1))&&e--;let i=ue(n,e);for(e+=Te(i);e=0&&Zr(ue(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function sf(n,e,t){for(;e>0;){let i=ia(n,e-2,t);if(i=56320&&n<57344}function sa(n){return n>=55296&&n<56320}function ue(n,e){let t=n.charCodeAt(e);if(!sa(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return na(i)?(t-55296<<10)+(i-56320)+65536:t}function ra(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Te(n){return n<65536?1:2}const vs=/\r\n?|\n/;var he=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(he||(he={}));class Qe{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-s);r+=l}else{if(i!=he.Simple&&h>=e&&(i==he.TrackDel&&se||i==he.TrackBefore&&se))return null;if(h>e||h==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i=0&&s<=t&&l>=e)return st?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t=0?":"+s:"")}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 Qe(e)}static create(e){return new Qe(e)}}class Q extends Qe{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 Ss(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return Cs(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;i.length0&&ht(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;ou||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?N.of(d.split(i||vs)):d:N.empty,g=p.length;if(f==u&&g==0)return;fo&&fe(s,f-o,-1),fe(s,u-f,g),ht(r,s,p),o=u}}return h(e),a(!l),l}static empty(e){return new Q(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;sl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length=0&&t<=0&&t==n[s+1]?n[s]+=e:e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function ht(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(s,h,r,c,f),s=h,r=c}}}function Cs(n,e,t,i=!1){let s=[],r=i?[]:null,o=new ki(n),l=new ki(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);fe(s,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class ki{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?N.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?N.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 Ct{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&16?this.to:this.from}get head(){return this.flags&16?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&4?-1:this.flags&8?1:0}get bidiLevel(){let e=this.flags&3;return e==3?null:e}get goalColumn(){let e=this.flags>>5;return e==33554431?void 0:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new Ct(i,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return w.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return w.range(this.anchor,i)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return w.range(e.anchor,e.head)}static create(e,t,i){return new Ct(e,t,i)}}class w{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:w.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;te.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 w(e.ranges.map(t=>Ct.fromJSON(t)),e.main)}static single(e,t=e){return new w([w.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,s=0;se?4:0))}static normalized(e,t=0){let i=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(i);for(let s=1;sr.head?w.range(a,l):w.range(l,a))}}return new w(e,t)}}function la(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let wr=0;class O{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=wr++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}static define(e={}){return new O(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:xr),!!e.static,e.enables)}of(e){return new rn([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new rn(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new rn(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function xr(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class rn{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=wr++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||As(f,c)){let d=i(f);if(l?!to(d,f.values[o],s):!s(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d=i(f),p=u.config.address[r];if(p!=null){let g=pn(u,p);if(this.dependencies.every(y=>y instanceof O?u.facet(y)===f.facet(y):y instanceof ke?u.field(y,!1)==f.field(y,!1):!0)||(l?to(d,g,s):s(d,g)))return f.values[o]=g,0}return f.values[o]=d,1}}}}function to(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[a.id]),s=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;ci===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(io).find(i=>i.field==this);return(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,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,io.of({field:this,create:e})]}get extension(){return this}}const vt={lowest:4,low:3,default:2,high:1,highest:0};function ri(n){return e=>new aa(e,n)}const Pi={highest:ri(vt.highest),high:ri(vt.high),default:ri(vt.default),low:ri(vt.low),lowest:ri(vt.lowest)};class aa{constructor(e,t){this.inner=e,this.prec=t}}class Bn{of(e){return new Ms(this,e)}reconfigure(e){return Bn.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Ms{constructor(e,t){this.compartment=e,this.inner=t}}class dn{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let u of of(e,t,o))u instanceof ke?s.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of s)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i?.config.facets;for(let u in r){let d=r[u],p=d[0].facet,g=c&&c[u]||[];if(d.every(y=>y.type==0))if(l[p.id]=a.length<<1|1,xr(g,d))a.push(i.facet(p));else{let y=p.combine(d.map(b=>b.value));a.push(i&&p.compare(y,i.facet(p))?i.facet(p):y)}else{for(let y of d)y.type==0?(l[y.id]=a.length<<1|1,a.push(y.value)):(l[y.id]=h.length<<1,h.push(b=>y.dynamicSlot(b)));l[p.id]=h.length<<1,h.push(y=>rf(y,p,d))}}let f=h.map(u=>u(l));return new dn(e,o,f,l,a,r)}}function of(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof Ms&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof Ms){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 aa)r(o.inner,o.prec);else if(o instanceof ke)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof rn)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,vt.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(n,vt.default),i.reduce((o,l)=>o.concat(l))}function yi(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function pn(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const ha=O.define(),ca=O.define({combine:n=>n.some(e=>e),static:!0}),fa=O.define({combine:n=>n.length?n[0]:void 0,static:!0}),ua=O.define(),da=O.define(),pa=O.define(),ma=O.define({combine:n=>n.length?n[0]:!1});class Nt{constructor(e,t){this.type=e,this.value=t}static define(){return new lf}}class lf{of(e){return new Nt(this,e)}}class af{constructor(e){this.map=e}of(e){return new L(this,e)}}class L{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 L(this.type,t)}is(e){return this.type==e}static define(e={}){return new af(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}}L.reconfigure=L.define();L.appendConfig=L.define();class Z{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&la(i,t.newLength),r.some(l=>l.type==Z.time)||(this.annotations=r.concat(Z.time.of(Date.now())))}static create(e,t,i,s,r,o){return new Z(e,t,i,s,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(Z.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Z.time=Nt.define();Z.userEvent=Nt.define();Z.addToHistory=Nt.define();Z.remote=Nt.define();function hf(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i=n[i]))r=n[i++],o=n[i++];else if(s=0;s--){let r=i[s](n);r instanceof Z?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Z?n=r[0]:n=ya(e,Kt(r),!1)}return n}function ff(n){let e=n.startState,t=e.facet(pa),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=ga(i,Ds(e,r,n.changes.newLength),!0))}return i==n?n:Z.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const uf=[];function Kt(n){return n==null?uf:Array.isArray(n)?n:[n]}var Be=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(Be||(Be={}));const df=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Ts;try{Ts=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function pf(n){if(Ts)return Ts.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||df.test(t)))return!0}return!1}function mf(n){return e=>{if(!/\S/.test(e))return Be.Space;if(pf(e))return Be.Word;for(let t=0;t-1)return Be.Word;return Be.Other}}class I{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;ls.set(a,l)),t=null),s.set(o.value.compartment,o.value.extension)):o.is(L.reconfigure)?(t=null,i=o.value):o.is(L.appendConfig)&&(t=null,i=Kt(i).concat(o.value));let r;t?r=e.startState.values.slice():(t=dn.resolve(i,s,this),r=new I(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,a)=>a.reconfigure(l,this),null).values),new I(t,e.newDoc,e.newSelection,r,(o,l)=>l.update(o,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:w.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=Kt(i.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return I.create({doc:e.doc,selection:w.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=dn.resolve(e.extensions||[],new Map),i=e.doc instanceof N?e.doc:N.of((e.doc||"").split(t.staticFacet(I.lineSeparator)||vs)),s=e.selection?e.selection instanceof w?e.selection:w.single(e.selection.anchor,e.selection.head):w.single(0);return la(s,i.length),t.staticFacet(ca)||(s=s.asSingle()),new I(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(I.tabSize)}get lineBreak(){return this.facet(I.lineSeparator)||` `}get readOnly(){return this.facet(ma)}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,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let s=[];for(let r of this.facet(ha))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){return mf(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=Me(t,o,!1);if(r(t.slice(a,o))!=Be.Word)break;o=a}for(;ln.length?n[0]:4});I.lineSeparator=fa;I.readOnly=ma;I.phrases=O.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(s=>n[s]==e[s])}});I.languageData=ha;I.changeFilter=ua;I.transactionFilter=da;I.transactionExtender=pa;Bn.reconfigure=L.define();function Vt(n,e,t={}){let i={};for(let s of n)for(let r of Object.keys(s)){let o=s[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 s in e)i[s]===void 0&&(i[s]=e[s]);return i}class Tt{eq(e){return this==e}range(e,t=e){return Os.create(e,t,this)}}Tt.prototype.startSide=Tt.prototype.endSide=0;Tt.prototype.point=!1;Tt.prototype.mapMode=he.TrackDel;let Os=class ba{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new ba(e,t,i)}};function Bs(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class kr{constructor(e,t,i,s){this.from=e,this.to=t,this.value=i,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,s=0){let r=i?this.to:this.from;for(let o=s,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,s){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,r);rd||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),s.push(u-o),r.push(d-o))}return{mapped:i.length?new kr(s,r,i,l):null,pos:o}}}class F{constructor(e,t,i,s){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=s}static create(e,t,i,s){return new F(e,t,i,s)}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:s=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(Bs)),this.isEmpty)return t.length?F.of(t):this;let l=new wa(this,null,-1).goto(0),a=0,h=[],c=new Ot;for(;l.value||a=0){let f=t[a++];c.addInner(f.from,f.to,f.value)||h.push(f)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||rl.to||r=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 vi.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return vi.from(e).goto(t)}static compare(e,t,i,s,r=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),a=no(o,l,i),h=new oi(o,a,r),c=new oi(l,a,r);i.iterGaps((f,u,d)=>so(h,f,c,u,d,s)),i.empty&&i.length==0&&so(h,0,c,0,0,s)}static eq(e,t,i=0,s){s==null&&(s=1e9);let r=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=no(r,o),a=new oi(r,l,0).goto(i),h=new oi(o,l,0).goto(i);for(;;){if(a.to!=h.to||!Es(a.active,h.active)||a.point&&(!h.point||!a.point.eq(h.point)))return!1;if(a.to>s)return!0;a.next(),h.next()}}static spans(e,t,i,s,r=-1){let o=new oi(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point?(s.point(l,h,o.point,o.activeForPoint(o.to),a,o.pointRank),a=o.openEnd(h)+(o.to>h?1:0)):h>l&&(s.span(l,h,o.active,a),a=o.openEnd(h)),o.to>i)break;l=o.to,o.next()}return a}static of(e,t=!1){let i=new Ot;for(let s of e instanceof Os?[e]:t?gf(e):e)i.add(s.from,s.to,s.value);return i.finish()}}F.empty=new F([],[],null,-1);function gf(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(Bs);e=i}return n}F.empty.nextLayer=F.empty;class Ot{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}finishChunk(e){this.chunks.push(new kr(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=[])}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new Ot)).add(e,t,i)}addInner(e,t,i){let s=e-this.lastTo||i.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<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(F.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=F.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function no(n,e,t){let i=new Map;for(let r of n)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&s.push(new wa(o,t,i,r));return s.length==1?s[0]:new vi(s)}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--)jn(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--)jn(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(),jn(this.heap,0)}}}function jn(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let s=n[i];if(i+1=0&&(s=n[i+1],i++),t.compare(s)<0)break;n[i]=t,n[e]=s,e=i}}class oi{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=vi.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){Fi(this.active,e),Fi(this.activeTo,e),Fi(this.activeRank,e),this.minActive=ro(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:s,rank:r}=this.cursor;for(;t-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Fi(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(i),this.cursor.frome&&s++,this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&!(this.activeRank[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 so(n,e,t,i,s,r){n.goto(e),t.goto(i);let o=i+s,l=i,a=i-e;for(;;){let h=n.to+a-t.to||n.endSide-t.endSide,c=h<0?n.to+a:t.to,f=Math.min(c,o);if(n.point||t.point?n.point&&t.point&&(n.point==t.point||n.point.eq(t.point))&&Es(n.activeForPoint(n.to+a),t.activeForPoint(t.to))||r.comparePoint(l,f,n.point,t.point):f>l&&!Es(n.active,t.active)&&r.compareRange(l,f,n.active,t.active),c>o)break;l=c,h<=0&&n.next(),h>=0&&t.next()}}function Es(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function ro(n,e){let t=-1,i=1e9;for(let s=0;s=e)return s;if(s==n.length)break;r+=n.charCodeAt(s)==9?t-r%t:1,s=Me(n,s)}return i===!0?-1:n.length}const Ls="ͼ",oo=typeof Symbol>"u"?"__"+Ls:Symbol.for(Ls),Rs=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),lo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class dt{constructor(e,t){this.rules=[];let{finish:i}=t||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&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(y=>g.replace(/&/,y))).reduce((g,y)=>g.concat(y)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(s(d),p,c,u)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+p+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=lo[oo]||1;return lo[oo]=e+1,Ls+e.toString(36)}static mount(e,t,i){let s=e[Rs],r=i&&i.nonce;s?r&&s.setNonce(r):s=new yf(e,r),s.mount(Array.isArray(t)?t:[t])}}let ao=new Map;class yf{constructor(e,t){let i=e.ownerDocument||e,s=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let r=ao.get(i);if(r)return e.adoptedStyleSheets=[r.sheet,...e.adoptedStyleSheets],e[Rs]=r;this.sheet=new s.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],ao.set(i,this)}else{this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);let r=e.head||e;r.insertBefore(this.styleTag,r.firstChild)}this.modules=[],e[Rs]=this}mount(e){let t=this.sheet,i=0,s=0;for(let r=0;r-1&&(this.modules.splice(l,1),s--,l=-1),l==-1){if(this.modules.splice(s++,0,o),t)for(let a=0;a",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},bf=typeof navigator<"u"&&/Mac/.test(navigator.platform),wf=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ae=0;ae<10;ae++)pt[48+ae]=pt[96+ae]=String(ae);for(var ae=1;ae<=24;ae++)pt[ae+111]="F"+ae;for(var ae=65;ae<=90;ae++)pt[ae]=String.fromCharCode(ae+32),Si[ae]=String.fromCharCode(ae);for(var Kn in pt)Si.hasOwnProperty(Kn)||(Si[Kn]=pt[Kn]);function xf(n){var e=bf&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||wf&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Si:pt)[n.keyCode]||n.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}function mn(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Jt(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function kf(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function on(n,e){if(!e.anchorNode)return!1;try{return Jt(n,e.anchorNode)}catch{return!1}}function Ci(n){return n.nodeType==3?Yt(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function gn(n,e,t,i){return t?ho(n,e,t,i,-1)||ho(n,e,t,i,1):!1}function yn(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function ho(n,e,t,i,s){for(;;){if(n==t&&e==i)return!0;if(e==(s<0?0:Ai(n))){if(n.nodeName=="DIV")return!1;let r=n.parentNode;if(!r||r.nodeType!=1)return!1;e=yn(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=s<0?Ai(n):0}else return!1}}function Ai(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}const xa={left:0,right:0,top:0,bottom:0};function vr(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function vf(n){return{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Sf(n,e,t,i,s,r,o,l){let a=n.ownerDocument,h=a.defaultView||window;for(let c=n;c;)if(c.nodeType==1){let f,u=c==a.body;if(u)f=vf(h);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let g=c.getBoundingClientRect();f={left:g.left,right:g.left+c.clientWidth,top:g.top,bottom:g.top+c.clientHeight}}let d=0,p=0;if(s=="nearest")e.top0&&e.bottom>f.bottom+p&&(p=e.bottom-f.bottom+p+o)):e.bottom>f.bottom&&(p=e.bottom-f.bottom+o,t<0&&e.top-p0&&e.right>f.right+d&&(d=e.right-f.right+d+r)):e.right>f.right&&(d=e.right-f.right+r,t<0&&e.leftt)return f.domBoundsAround(e,t,h);if(u>=e&&s==-1&&(s=a,r=h),h>t&&f.dom.parentNode==this.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:r,to:l<0?i+this.length:l,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o=0?this.children[o].dom:null}}markDirty(e=!1){this.dirty|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.dirty|=2),t.dirty&1)return;t.dirty|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.dirty&&this.markParentsDirty(!0))}setDOM(e){this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=Sr){this.markDirty();for(let s=e;sthis.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function Ca(n,e,t,i,s,r,o,l,a){let{children:h}=n,c=h.length?h[e]:null,f=r.length?r[r.length-1]:null,u=f?f.breakAfter:o;if(!(e==i&&c&&!o&&!u&&r.length<2&&c.merge(t,s,r.length?f:null,t==0,l,a))){if(i0&&(!o&&r.length&&c.merge(t,c.length,r[0],!1,l,0)?c.breakAfter=r.shift().breakAfter:(t2);var D={mac:mo||/Mac/.test(Ae.platform),windows:/Win/.test(Ae.platform),linux:/Linux|X11/.test(Ae.platform),ie:En,ie_version:Ma?_s.documentMode||6:Ns?+Ns[1]:Is?+Is[1]:0,gecko:uo,gecko_version:uo?+(/Firefox\/(\d+)/.exec(Ae.userAgent)||[0,0])[1]:0,chrome:!!Un,chrome_version:Un?+Un[1]:0,ios:mo,android:/Android\b/.test(Ae.userAgent),webkit:po,safari:Da,webkit_version:po?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:_s.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const Df=256;class mt extends j{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,i){return i&&(!(i instanceof mt)||this.length-(t-e)+i.length>Df)?!1:(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new mt(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new de(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return Vs(this.dom,e,t)}}class et extends j{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let s of t)s.setParent(this)}setAttrs(e){if(va(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.dirty|=6)}sync(e){this.dom?this.dirty&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e)}merge(e,t,i,s,r,o){return i&&(!(i instanceof et&&i.mark.eq(this.mark))||e&&r<=0||te&&t.push(i=e&&(s=r),i=a,r++}let o=this.length-e;return this.length=e,s>-1&&(this.children.length=s,this.markDirty()),new et(this.mark,t,o)}domAtPos(e){return Ba(this,e)}coordsAt(e,t){return Pa(this,e,t)}}function Vs(n,e,t){let i=n.nodeValue.length;e>i&&(e=i);let s=e,r=e,o=0;e==0&&t<0||e==i&&t>=0?D.chrome||D.gecko||(e?(s--,o=1):r=0)?0:l.length-1];return D.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?vr(a,o<0):a||null}class ct extends j{constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}static create(e,t,i){return new(e.customView||ct)(e,t,i)}split(e){let t=ct.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(){(!this.dom||!this.widget.updateDOM(this.dom))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,i,s,r,o){return i&&(!(i instanceof ct)||!this.widget.compare(i.widget)||e>0&&r<=0||t0?i.length-1:0;s=i[r],!(e>0?r==0:r==i.length-1||s.top0?-1:1);return this.length?s:vr(s,this.side>0)}get isEditable(){return!1}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Ta extends ct{domAtPos(e){let{topView:t,text:i}=this.widget;return t?Fs(e,0,t,i,(s,r)=>s.domAtPos(r),s=>new de(i,Math.min(s,i.nodeValue.length))):new de(i,Math.min(e,i.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(e,t){let{topView:i,text:s}=this.widget;return i?Oa(e,t,i,s):Math.min(t,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(e,t){let{topView:i,text:s}=this.widget;return i?Fs(e,t,i,s,(r,o,l)=>r.coordsAt(o,l),(r,o)=>Vs(s,r,o)):Vs(s,e,t)}destroy(){var e;super.destroy(),(e=this.widget.topView)===null||e===void 0||e.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}}function Fs(n,e,t,i,s,r){if(t instanceof et){for(let o=t.dom.firstChild;o;o=o.nextSibling){let l=j.get(o);if(!l)return r(n,e);let a=Jt(o,i),h=l.length+(a?i.nodeValue.length:0);if(n0?-1:1);return i&&i.topt.top?{left:t.left,right:t.right,top:i.top,bottom:i.bottom}:t}get overrideDOMText(){return N.empty}}mt.prototype.children=ct.prototype.children=Xt.prototype.children=Sr;function Tf(n,e){let t=n.parent,i=t?t.children.indexOf(n):-1;for(;t&&i>=0;)if(e<0?i>0:ir&&e0;r--){let o=i[r-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let r=s;r0&&e instanceof et&&s.length&&(i=s[s.length-1])instanceof et&&i.mark.eq(e.mark)?Ea(i,e.children[0],t-1):(s.push(e),e.setParent(n)),n.length+=e.length}function Pa(n,e,t){let i=null,s=-1,r=null,o=-1;function l(h,c){for(let f=0,u=0;f=c&&(d.children.length?l(d,c-u):!r&&(p>c||u==p&&d.getSide()>0)?(r=d,o=c-u):(u0?3e8:-4e8:t>0?1e8:-1e8,new Bt(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,s;if(e.isBlockGap)i=-5e8,s=4e8;else{let{start:r,end:o}=La(e,t);i=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new Bt(e,i,s,t,e.widget||null,!0)}static line(e){return new Ri(e)}static set(e,t=!1){return F.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}P.none=F.empty;class Pn extends P{constructor(e){let{start:t,end:i}=La(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){return this==e||e instanceof Pn&&this.tagName==e.tagName&&this.class==e.class&&Cr(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)}}Pn.prototype.point=!1;class Ri extends P{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Ri&&Cr(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)}}Ri.prototype.mapMode=he.TrackBefore;Ri.prototype.point=!0;class Bt extends P{constructor(e,t,i,s,r,o){super(t,i,r,e),this.block=s,this.isReplace=o,this.mapMode=s?t<=0?he.TrackBefore:he.TrackAfter:he.TrackDel}get type(){return this.startSide=5}eq(e){return e instanceof Bt&&Bf(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)}}Bt.prototype.point=!0;function La(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function Bf(n,e){return n==e||!!(n&&e&&n.compare(e))}function zs(n,e,t,i=0){let s=t.length-1;s>=0&&t[s]+i>=n?t[s]=Math.max(t[s],e):t.push(n,e)}class ye extends j{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,s,r,o){if(i){if(!(i instanceof ye))return!1;this.dom||i.transferDOM(this)}return s&&this.setDeco(i?i.attrs:null),Aa(this,e,t,i?i.children:[],r,o),!0}split(e){let t=new ye;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i,off:s}=this.childPos(e);s&&(t.append(this.children[i].split(s),0),this.children[i].merge(s,this.children[i].length,null,!1,0,0),i++);for(let r=i;r0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Cr(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Ea(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=Hs(t,this.attrs||{})),i&&(this.attrs=Hs({class:i},this.attrs||{}))}domAtPos(e){return Ba(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.dirty|=6)}sync(e){var t;this.dom?this.dirty&4&&(va(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Ws(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e);let i=this.dom.lastChild;for(;i&&j.get(i)instanceof et;)i=i.lastChild;if(!i||!this.length||i.nodeName!="BR"&&((t=j.get(i))===null||t===void 0?void 0:t.isEditable)==!1&&(!D.ios||!this.children.some(s=>s instanceof mt))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0;for(let t of this.children){if(!(t instanceof mt)||/[^ -~]/.test(t.text))return null;let i=Ci(t.dom);if(i.length!=1)return null;e+=i[0].width}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length}:null}coordsAt(e,t){return Pa(this,e,t)}become(e){return!1}get type(){return W.Text}static find(e,t){for(let i=0,s=0;i=t){if(r instanceof ye)return r;if(o>t)break}s=o+r.breakAfter}return null}}class Dt extends j{constructor(e,t,i){super(),this.widget=e,this.length=t,this.type=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,s,r,o){return i&&(!(i instanceof Dt)||!this.widget.compare(i.widget)||e>0&&r<=0||t0;){if(this.textOff==this.text.length){let{value:r,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer([]),this.curLine=null,e--;continue}else this.text=r,this.textOff=0}let s=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(0,i)),this.getLine().append(Wi(new mt(this.text.slice(this.textOff,this.textOff+s)),t),i),this.atCursorPos=!0,this.textOff+=s,e-=s,i=0}}span(e,t,i,s){this.buildText(t-e,i,s),this.pos=t,this.openStart<0&&(this.openStart=s)}point(e,t,i,s,r,o){if(this.disallowBlockEffectsFor[o]&&i instanceof Bt){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(i instanceof Bt)if(i.block){let{type:a}=i;a==W.WidgetAfter&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Dt(i.widget||new go("div"),l,a))}else{let a=ct.create(i.widget||new go("span"),l,l?0:i.startSide),h=this.atCursorPos&&!a.isEditable&&r<=s.length&&(e0),c=!a.isEditable&&(en.some(e=>e)}),Ha=O.define({combine:n=>n.some(e=>e)});class bn{constructor(e,t="nearest",i="nearest",s=5,r=5){this.range=e,this.y=t,this.x=i,this.yMargin=s,this.xMargin=r}map(e){return e.empty?this:new bn(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}}const yo=L.define({map:(n,e)=>n.map(e)});function He(n,e,t){let i=n.facet(Na);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 Ln=O.define({combine:n=>n.length?n[0]:!0});let Ef=0;const ui=O.define();class pe{constructor(e,t,i,s){this.id=e,this.create=t,this.domEventHandlers=i,this.extension=s(this)}static define(e,t){const{eventHandlers:i,provide:s,decorations:r}=t||{};return new pe(Ef++,e,i,o=>{let l=[ui.of(o)];return r&&l.push(Mi.of(a=>{let h=a.plugin(o);return h?r(h):P.none})),s&&l.push(s(o)),l})}static fromClass(e,t){return pe.define(i=>new e(i),t)}}class Gn{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}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(He(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.create(e)}catch(t){He(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){He(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Wa=O.define(),za=O.define(),Mi=O.define(),$a=O.define(),qa=O.define(),di=O.define();class Ze{constructor(e,t,i,s){this.fromA=e,this.toA=t,this.fromB=i,this.toB=s}join(e){return new Ze(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 s=e[t-1];if(!(s.fromA>i.toA)){if(s.toAc)break;r+=2}if(!a)return i;new Ze(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,l=a.toB}}}class wn{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=Q.empty(this.startState.doc.length);for(let o of i)this.changes=this.changes.compose(o.changes);let s=[];this.changes.iterChangedRanges((o,l,a,h)=>s.push(new Ze(o,l,a,h))),this.changedRanges=s;let r=e.hasFocus;r!=e.inputState.notifiedFocused&&(e.inputState.notifiedFocused=r,this.flags|=1)}static create(e,t,i){return new wn(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>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}}var U=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(U||(U={}));const qs=U.LTR,Pf=U.RTL;function ja(n){let e=[];for(let t=0;t=t){if(l.level==i)return o;(r<0||(s!=0?s<0?l.fromt:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}const K=[];function Nf(n,e){let t=n.length,i=e==qs?1:2,s=e==qs?2:1;if(!n||i==1&&!If.test(n))return Ka(t);for(let o=0,l=i,a=i;o=0;u-=3)if(ze[u+1]==-c){let d=ze[u+2],p=d&2?i:d&4?d&1?s:i:0;p&&(K[o]=K[ze[u]]=p),l=u;break}}else{if(ze.length==189)break;ze[l++]=o,ze[l++]=h,ze[l++]=a}else if((f=K[o])==2||f==1){let u=f==i;a=u?0:1;for(let d=l-3;d>=0;d-=3){let p=ze[d+2];if(p&2)break;if(u)ze[d+2]|=2;else{if(p&4)break;ze[d+2]|=4}}}for(let o=0;ol;){let c=h,f=K[--h]!=2;for(;h>l&&f==(K[h-1]!=2);)h--;r.push(new Gt(h,c,f?2:1))}else r.push(new Gt(l,o,0))}else for(let o=0;o1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(e){if(e.cmIgnore)return;let t=j.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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+Math.min(t,i.offset))}}function bo(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}class wo{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class xo extends j{constructor(e){super(),this.view=e,this.compositionDeco=P.none,this.decorations=[],this.dynamicDecorationMap=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new ye],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Ze(0,0,0,e.state.doc.length)],0)}get editorView(){return this.view}get length(){return this.view.state.doc.length}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:o,toA:l})=>lthis.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.view.inputState.composing<0?this.compositionDeco=P.none:(e.transactions.length||this.dirty)&&(this.compositionDeco=Hf(this.view,e.changes)),(D.ie||D.chrome)&&!this.compositionDeco.size&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,s=this.updateDeco(),r=qf(i,s,e.changes);return t=Ze.extendWithRanges(t,r),this.dirty==0&&t.length==0?!1:(this.updateInner(t,e.startState.doc.length),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t);let{observer:i}=this.view;i.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=D.chrome||D.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(r),this.dirty=0,r&&(r.written||i.selectionRange.focusNode!=r.node)&&(this.forceSelection=!0),this.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to=0?e[s]:null;if(!r)break;let{fromA:o,toA:l,fromB:a,toB:h}=r,{content:c,breakAtStart:f,openStart:u,openEnd:d}=Ar.build(this.view.state.doc,a,h,this.decorations,this.dynamicDecorationMap),{i:p,off:g}=i.findPos(l,1),{i:y,off:b}=i.findPos(o,-1);Ca(this,y,b,p,g,c,f,u,d)}}updateSelection(e=!1,t=!1){if((e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange(),!(t||this.mayControlSelection()))return;let i=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,r=this.domAtPos(s.anchor),o=s.empty?r:this.domAtPos(s.head);if(D.gecko&&s.empty&&Ff(r)){let a=document.createTextNode("");this.view.observer.ignore(()=>r.node.insertBefore(a,r.node.childNodes[r.offset]||null)),r=o=new de(a,0),i=!0}let l=this.view.observer.selectionRange;(i||!l.focusNode||!gn(r.node,r.offset,l.anchorNode,l.anchorOffset)||!gn(o.node,o.offset,l.focusNode,l.focusOffset))&&(this.view.observer.ignore(()=>{D.android&&D.chrome&&this.dom.contains(l.focusNode)&&jf(l.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let a=mn(this.view.root);if(a)if(s.empty){if(D.gecko){let h=zf(r.node,r.offset);if(h&&h!=3){let c=Ya(r.node,r.offset,h==1?1:-1);c&&(r=new de(c,h==1?0:c.nodeValue.length))}}a.collapse(r.node,r.offset),s.bidiLevel!=null&&l.cursorBidiLevel!=null&&(l.cursorBidiLevel=s.bidiLevel)}else if(a.extend){a.collapse(r.node,r.offset);try{a.extend(o.node,o.offset)}catch{}}else{let h=document.createRange();s.anchor>s.head&&([r,o]=[o,r]),h.setEnd(o.node,o.offset),h.setStart(r.node,r.offset),a.removeAllRanges(),a.addRange(h)}}),this.view.observer.setSelectionRange(r,o)),this.impreciseAnchor=r.precise?null:new de(l.anchorNode,l.anchorOffset),this.impreciseHead=o.precise?null:new de(l.focusNode,l.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:e}=this,t=e.state.selection.main,i=mn(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=ye.find(this,t.head);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 c=this.domAtPos(t.head+t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(s,r)}mayControlSelection(){let e=this.view.root.activeElement;return e==this.dom||on(this.dom,this.view.observer.selectionRange)&&!(e&&this.dom.contains(e))}nearest(e){for(let t=e;t;){let i=j.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;to||e==o&&r.type!=W.WidgetBefore&&r.type!=W.WidgetAfter&&(!s||t==2||this.children[s-1].breakAfter||this.children[s-1].type==W.WidgetBefore&&t>-2))return r.coordsAt(e-o,t);i=o}}measureVisibleLineHeights(e){let t=[],{from:i,to:s}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==U.LTR;for(let h=0,c=0;cs)break;if(h>=i){let d=f.dom.getBoundingClientRect();if(t.push(d.height),o){let p=f.dom.lastChild,g=p?Ci(p):[];if(g.length){let y=g[g.length-1],b=a?y.right-d.left:d.right-y.left;b>l&&(l=b,this.minWidth=r,this.minWidthFrom=h,this.minWidthTo=u)}}}h=u+f.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?U.RTL:U.LTR}measureTextSize(){for(let s of this.children)if(s instanceof ye){let r=s.measureTextSize();if(r)return r}let e=document.createElement("div"),t,i;return e.className="cm-line",e.style.width="99999px",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let s=Ci(e.firstChild)[0];t=e.getBoundingClientRect().height,i=s?s.width/27:7,e.remove()}),{lineHeight:t,charWidth:i}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Sa(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],o=r?r.from-1:this.length;if(o>i){let l=t.lineBlockAt(o).bottom-t.lineBlockAt(i).top;e.push(P.replace({widget:new ko(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return P.set(e)}updateDeco(){let e=this.view.state.facet(Mi).map((t,i)=>(this.dynamicDecorationMap[i]=typeof t=="function")?t(this.view):t);for(let t=e.length;tt.anchor?-1:1),s;if(!i)return;!t.empty&&(s=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let r=0,o=0,l=0,a=0;for(let c of this.view.state.facet(qa).map(f=>f(this.view)))if(c){let{left:f,right:u,top:d,bottom:p}=c;f!=null&&(r=Math.max(r,f)),u!=null&&(o=Math.max(o,u)),d!=null&&(l=Math.max(l,d)),p!=null&&(a=Math.max(a,p))}let h={left:i.left-r,top:i.top-l,right:i.right+o,bottom:i.bottom+a};Sf(this.view.scrollDOM,h,t.head0&&t<=0)n=n.childNodes[e-1],e=Ai(n);else if(n.nodeType==1&&e=0)n=n.childNodes[e],e=0;else return null}}function zf(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e0;){let h=Me(s.text,o,!1);if(i(s.text.slice(h,o))!=a)break;o=h}for(;ln?e.left-n:Math.max(0,n-e.right)}function Gf(n,e){return e.top>n?e.top-n:Math.max(0,n-e.bottom)}function Jn(n,e){return n.tope.top+1}function vo(n,e){return en.bottom?{top:n.top,left:n.left,right:n.right,bottom:e}:n}function Ks(n,e,t){let i,s,r,o,l=!1,a,h,c,f;for(let p=n.firstChild;p;p=p.nextSibling){let g=Ci(p);for(let y=0;yx||o==x&&r>k)&&(i=p,s=b,r=k,o=x,l=!k||(k>0?y0)),k==0?t>b.bottom&&(!c||c.bottomb.top)&&(h=p,f=b):c&&Jn(c,b)?c=So(c,b.bottom):f&&Jn(f,b)&&(f=vo(f,b.top))}}if(c&&c.bottom>=t?(i=a,s=c):f&&f.top<=t&&(i=h,s=f),!i)return{node:n,offset:0};let u=Math.max(s.left,Math.min(s.right,e));if(i.nodeType==3)return Co(i,u,t);if(l&&i.contentEditable!="false")return Ks(i,u,t);let d=Array.prototype.indexOf.call(n.childNodes,i)+(e>=(s.left+s.right)/2?1:0);return{node:n,offset:d}}function Co(n,e,t){let i=n.nodeValue.length,s=-1,r=1e9,o=0;for(let l=0;lt?c.top-t:t-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&f=(c.left+c.right)/2,d=u;if((D.chrome||D.gecko)&&Yt(n,l).getBoundingClientRect().left==c.right&&(d=!u),f<=0)return{node:n,offset:l+(d?1:0)};s=l+(d?1:0),r=f}}}return{node:n,offset:s>-1?s:o>0?n.nodeValue.length:0}}function Xa(n,{x:e,y:t},i,s=-1){var r;let o=n.contentDOM.getBoundingClientRect(),l=o.top+n.viewState.paddingTop,a,{docHeight:h}=n.viewState,c=t-l;if(c<0)return 0;if(c>h)return n.state.doc.length;for(let b=n.defaultLineHeight/2,k=!1;a=n.elementAtHeight(c),a.type!=W.Text;)for(;c=s>0?a.bottom+b:a.top-b,!(c>=0&&c<=h);){if(k)return i?null:0;k=!0,s=-s}t=l+c;let f=a.from;if(fn.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:i?null:Ao(n,o,a,e,t);let u=n.dom.ownerDocument,d=n.root.elementFromPoint?n.root:u,p=d.elementFromPoint(e,t);p&&!n.contentDOM.contains(p)&&(p=null),p||(e=Math.max(o.left+1,Math.min(o.right-1,e)),p=d.elementFromPoint(e,t),p&&!n.contentDOM.contains(p)&&(p=null));let g,y=-1;if(p&&((r=n.docView.nearest(p))===null||r===void 0?void 0:r.isEditable)!=!1){if(u.caretPositionFromPoint){let b=u.caretPositionFromPoint(e,t);b&&({offsetNode:g,offset:y}=b)}else if(u.caretRangeFromPoint){let b=u.caretRangeFromPoint(e,t);b&&({startContainer:g,startOffset:y}=b,(!n.contentDOM.contains(g)||D.safari&&Jf(g,y,e)||D.chrome&&Yf(g,y,e))&&(g=void 0))}}if(!g||!n.docView.dom.contains(g)){let b=ye.find(n.docView,f);if(!b)return c>a.top+a.height/2?a.to:a.from;({node:g,offset:y}=Ks(b.dom,e,t))}return n.docView.posFromDOM(g,y)}function Ao(n,e,t,i,s){let r=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=Math.floor((s-t.top)/n.defaultLineHeight);r+=l*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+Ps(o,r,n.state.tabSize)}function Jf(n,e,t){let i;if(n.nodeType!=3||e!=(i=n.nodeValue.length))return!1;for(let s=n.nextSibling;s;s=s.nextSibling)if(s.nodeType!=1||s.nodeName!="BR")return!1;return Yt(n,i-1,i).getBoundingClientRect().left>t}function Yf(n,e,t){if(e!=0)return!1;for(let s=n;;){let r=s.parentNode;if(!r||r.nodeType!=1||r.firstChild!=s)return!1;if(r.classList.contains("cm-line"))break;s=r}let i=n.nodeType==1?n.getBoundingClientRect():Yt(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function Xf(n,e,t,i){let s=n.state.doc.lineAt(e.head),r=!i||!n.lineWrapping?null:n.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let a=n.dom.getBoundingClientRect(),h=n.textDirectionAt(s.from),c=n.posAtCoords({x:t==(h==U.LTR)?a.right-1:a.left+1,y:(r.top+r.bottom)/2});if(c!=null)return w.cursor(c,t?-1:1)}let o=ye.find(n.docView,e.head),l=o?t?o.posAtEnd:o.posAtStart:t?s.to:s.from;return w.cursor(l,t?-1:1)}function Mo(n,e,t,i){let s=n.state.doc.lineAt(e.head),r=n.bidiSpans(s),o=n.textDirectionAt(s.from);for(let l=e,a=null;;){let h=Vf(s,r,o,l,t),c=Ua;if(!h){if(s.number==(t?n.state.doc.lines:1))return l;c=` `,s=n.state.doc.line(s.number+(t?1:-1)),r=n.bidiSpans(s),h=w.cursor(t?s.from:s.to)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function Qf(n,e,t){let i=n.state.charCategorizer(e),s=i(t);return r=>{let o=i(r);return s==Be.Space&&(s=o),s==o}}function Zf(n,e,t,i){let s=e.head,r=t?1:-1;if(s==(t?n.state.doc.length:0))return w.cursor(s,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(s),c=n.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let d=n.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(s-d.from))),l=(r<0?d.top:d.bottom)+c}let f=a.left+o,u=i??n.defaultLineHeight>>1;for(let d=0;;d+=10){let p=l+(u+d)*r,g=Xa(n,{x:f,y:p},!1,r);if(pa.bottom||(r<0?gs))return w.cursor(g,e.assoc,void 0,o)}}function Yn(n,e,t){let i=n.state.facet($a).map(s=>s(n));for(;;){let s=!1;for(let r of i)r.between(t.from-1,t.from+1,(o,l,a)=>{t.from>o&&t.fromt.from?w.cursor(o,1):w.cursor(l,-1),s=!0)});if(!s)return t}}class eu{constructor(e){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.mouseSelection=null;for(let t in ie){let i=ie[t];e.contentDOM.addEventListener(t,s=>{!Do(e,s)||this.ignoreDuringComposition(s)||t=="keydown"&&this.keydown(e,s)||(this.mustFlushObserver(s)&&e.observer.forceFlush(),this.runCustomHandlers(t,e,s)?s.preventDefault():i(e,s))},Us[t]),this.registeredEvents.push(t)}D.chrome&&D.chrome_version==102&&e.scrollDOM.addEventListener("wheel",()=>{this.chromeScrollHack<0?e.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1,e.contentDOM.style.pointerEvents=""},100)},{passive:!0}),this.notifiedFocused=e.hasFocus,D.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,t){var i;let s;this.customHandlers=[];for(let r of t)if(s=(i=r.update(e).spec)===null||i===void 0?void 0:i.domEventHandlers){this.customHandlers.push({plugin:r.value,handlers:s});for(let o in s)this.registeredEvents.indexOf(o)<0&&o!="scroll"&&(this.registeredEvents.push(o),e.contentDOM.addEventListener(o,l=>{Do(e,l)&&this.runCustomHandlers(o,e,l)&&l.preventDefault()}))}}runCustomHandlers(e,t,i){for(let s of this.customHandlers){let r=s.handlers[e];if(r)try{if(r.call(s.plugin,i,t)||i.defaultPrevented)return!0}catch(o){He(t.state,o)}}return!1}runScrollHandlers(e,t){this.lastScrollTop=e.scrollDOM.scrollTop,this.lastScrollLeft=e.scrollDOM.scrollLeft;for(let i of this.customHandlers){let s=i.handlers.scroll;if(s)try{s.call(i.plugin,t,e)}catch(r){He(e.state,r)}}}keydown(e,t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&Date.now()s.keyCode==t.keyCode))&&!t.ctrlKey||tu.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=i||t,setTimeout(()=>this.flushIOSKey(e),250),!0):!1}flushIOSKey(e){let t=this.pendingIOSKey;return t?(this.pendingIOSKey=void 0,Ut(e.contentDOM,t.key,t.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:D.safari&&!D.ios&&Date.now()-this.compositionEndedAt<100?(this.compositionEndedAt=0,!0):!1:!1}mustFlushObserver(e){return e.type=="keydown"&&e.keyCode!=229}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const Qa=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],tu="dthko",Za=[16,17,18,20,91,92,224,225];class iu{constructor(e,t,i,s){this.view=e,this.style=i,this.mustSelect=s,this.lastEvent=t;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)&&nu(e,t),this.dragMove=su(e,t),this.dragging=ru(e,t)&&nh(t)==1?null:!1,this.dragging===!1&&(t.preventDefault(),this.select(t))}move(e){if(e.buttons==0)return this.destroy();this.dragging===!1&&this.select(this.lastEvent=e)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}select(e){let t=this.style.get(e,this.extend,this.multiple);(this.mustSelect||!t.eq(this.view.state.selection)||t.main.assoc!=this.view.state.selection.main.assoc)&&this.view.dispatch({selection:t,userEvent:"select.pointer",scrollIntoView:!0}),this.mustSelect=!1}update(e){e.docChanged&&this.dragging&&(this.dragging=this.dragging.map(e.changes)),this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function nu(n,e){let t=n.state.facet(Ra);return t.length?t[0](e):D.mac?e.metaKey:e.ctrlKey}function su(n,e){let t=n.state.facet(_a);return t.length?t[0](e):D.mac?!e.altKey:!e.ctrlKey}function ru(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=mn(n.root);if(!i||i.rangeCount==0)return!0;let s=i.getRangeAt(0).getClientRects();for(let r=0;r=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Do(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=j.get(t))&&i.ignoreEvent(e))return!1;return!0}const ie=Object.create(null),Us=Object.create(null),eh=D.ie&&D.ie_version<15||D.ios&&D.webkit_version<604;function ou(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),th(n,t.value)},50)}function th(n,e){let{state:t}=n,i,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Gs!=null&&t.selection.ranges.every(a=>a.empty)&&Gs==r.toString()){let a=-1;i=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:w.cursor(h.from+f.length)}})}else o?i=t.changeByRange(a=>{let h=r.line(s++);return{changes:{from:a.from,to:a.to,insert:h.text},range:w.cursor(a.from+h.length)}}):i=t.replaceSelection(r);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}ie.keydown=(n,e)=>{n.inputState.setSelectionOrigin("select"),e.keyCode==27?n.inputState.lastEscPress=Date.now():Za.indexOf(e.keyCode)<0&&(n.inputState.lastEscPress=0)};ie.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};ie.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};Us.touchstart=Us.touchmove={passive:!0};ie.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return;let t=null;for(let i of n.state.facet(Ia))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=hu(n,e)),t){let i=n.root.activeElement!=n.contentDOM;i&&n.observer.ignore(()=>ka(n.contentDOM)),n.inputState.startMouseSelection(new iu(n,e,t,i))}};function To(n,e,t,i){if(i==1)return w.cursor(e,t);if(i==2)return Kf(n.state,e,t);{let s=ye.find(n.docView,e),r=n.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,l=s?s.posAtEnd:r.to;return ln>=e.top&&n<=e.bottom,Oo=(n,e,t)=>ih(e,t)&&n>=t.left&&n<=t.right;function lu(n,e,t,i){let s=ye.find(n.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(r==0)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&Oo(t,i,o))return-1;let l=s.coordsAt(r,1);return l&&Oo(t,i,l)?1:o&&ih(i,o)?-1:1}function Bo(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:lu(n,t,e.clientX,e.clientY)}}const au=D.ie&&D.ie_version<=11;let Eo=null,Po=0,Lo=0;function nh(n){if(!au)return n.detail;let e=Eo,t=Lo;return Eo=n,Lo=Date.now(),Po=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(Po+1)%3:1}function hu(n,e){let t=Bo(n,e),i=nh(e),s=n.state.selection,r=t,o=e;return{update(l){l.docChanged&&(t.pos=l.changes.mapPos(t.pos),s=s.map(l.changes),o=null)},get(l,a,h){let c;o&&l.clientX==o.clientX&&l.clientY==o.clientY?c=r:(c=r=Bo(n,l),o=l);let f=To(n,c.pos,c.bias,i);if(t.pos!=c.pos&&!a){let u=To(n,t.pos,t.bias,i),d=Math.min(u.from,f.from),p=Math.max(u.to,f.to);f=d1&&s.ranges.some(u=>u.eq(f))?cu(s,f):h?s.addRange(f):w.create([f])}}}function cu(n,e){for(let t=0;;t++)if(n.ranges[t].eq(e))return w.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}ie.dragstart=(n,e)=>{let{selection:{main:t}}=n.state,{mouseSelection:i}=n.inputState;i&&(i.dragging=t),e.dataTransfer&&(e.dataTransfer.setData("Text",n.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove")};function Ro(n,e,t,i){if(!t)return;let s=n.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:r}=n.inputState,o=i&&r&&r.dragging&&r.dragMove?{from:r.dragging.from,to:r.dragging.to}:null,l={from:s,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"})}ie.drop=(n,e)=>{if(!e.dataTransfer)return;if(n.state.readOnly)return e.preventDefault();let t=e.dataTransfer.files;if(t&&t.length){e.preventDefault();let i=Array(t.length),s=0,r=()=>{++s==t.length&&Ro(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(t[o])}}else Ro(n,e,e.dataTransfer.getData("Text"),!0)};ie.paste=(n,e)=>{if(n.state.readOnly)return e.preventDefault();n.observer.flush();let t=eh?null:e.clipboardData;t?(th(n,t.getData("text/plain")),e.preventDefault()):ou(n)};function fu(n,e){let t=n.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(),n.focus()},50)}function uu(n){let e=[],t=[],i=!1;for(let s of n.selection.ranges)s.empty||(e.push(n.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of n.selection.ranges){let o=n.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),s=o.number}i=!0}return{text:e.join(n.lineBreak),ranges:t,linewise:i}}let Gs=null;ie.copy=ie.cut=(n,e)=>{let{text:t,ranges:i,linewise:s}=uu(n.state);if(!t&&!s)return;Gs=s?t:null;let r=eh?null:e.clipboardData;r?(e.preventDefault(),r.clearData(),r.setData("text/plain",t)):fu(n,t),e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"})};function sh(n){setTimeout(()=>{n.hasFocus!=n.inputState.notifiedFocused&&n.update([])},10)}ie.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),sh(n)};ie.blur=n=>{n.observer.clearSelectionRange(),sh(n)};ie.compositionstart=ie.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0)};ie.compositionend=n=>{n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionFirstChange=null,D.chrome&&D.android&&n.observer.flushSoon(),setTimeout(()=>{n.inputState.composing<0&&n.docView.compositionDeco.size&&n.update([])},50)};ie.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};ie.beforeinput=(n,e)=>{var t;let i;if(D.chrome&&D.android&&(i=Qa.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var r;(((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}};const _o=["pre-wrap","normal","pre-line","break-spaces"];class du{constructor(){this.doc=N.empty,this.lineWrapping=!1,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=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)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return _o.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,l=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=i,this.lineLength=s,l){this.heightSamples={};for(let a=0;a0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>ln&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return be.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,s){let r=this;for(let o=s.length-1;o>=0;o--){let{fromA:l,toA:a,fromB:h,toB:c}=s[o],f=r.lineAt(l,q.ByPosNoHeight,t,0,0),u=f.to>=a?f:r.lineAt(a,q.ByPosNoHeight,t,0,0);for(c+=u.to-a,a=u.to;o>0&&f.from<=s[o-1].toA;)l=s[o-1].fromA,h=s[o-1].fromB,o--,lr*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,s-=l.size}else if(r>s*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(s=r&&o(this.blockAt(0,i,s,r))}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more&&this.setHeight(e,s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Ce extends rh{constructor(e,t){super(e,t,W.Text),this.collapsed=0,this.widgetHeight=0}replace(e,t,i){let s=i[0];return i.length==1&&(s instanceof Ce||s instanceof le&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof le?s=new Ce(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):be.of(i)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more?this.setHeight(e,s.heights[s.index++]):(i||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class le extends be{constructor(e){super(e,0)}lines(e,t){let i=e.lineAt(t).number,s=e.lineAt(t+this.length).number;return{firstLine:i,lastLine:s,lineHeight:this.height/(s-i+1)}}blockAt(e,t,i,s){let{firstLine:r,lastLine:o,lineHeight:l}=this.lines(t,s),a=Math.max(0,Math.min(o-r,Math.floor((e-i)/l))),{from:h,length:c}=t.line(r+a);return new ut(h,c,i+l*a,l,W.Text)}lineAt(e,t,i,s,r){if(t==q.ByHeight)return this.blockAt(e,i,s,r);if(t==q.ByPosNoHeight){let{from:f,to:u}=i.lineAt(e);return new ut(f,u-f,0,0,W.Text)}let{firstLine:o,lineHeight:l}=this.lines(i,r),{from:a,length:h,number:c}=i.lineAt(e);return new ut(a,h,s+l*(c-o),l,W.Text)}forEachLine(e,t,i,s,r,o){let{firstLine:l,lineHeight:a}=this.lines(i,r);for(let h=Math.max(e,r),c=Math.min(r+this.length,t);h<=c;){let f=i.lineAt(h);h==e&&(s+=a*(f.number-l)),o(new ut(f.from,f.length,s,a,W.Text)),s+=a,h=f.to+1}}replace(e,t,i){let s=this.length-t;if(s>0){let r=i[i.length-1];r instanceof le?i[i.length-1]=new le(r.length+s):i.push(null,new le(s-1))}if(e>0){let r=i[0];r instanceof le?i[0]=new le(e+r.length):i.unshift(new le(e-1),null)}return be.of(i)}decomposeLeft(e,t){t.push(new le(e-1),null)}decomposeRight(e,t){t.push(null,new le(this.length-e-1))}updateHeight(e,t=0,i=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let o=[],l=Math.max(t,s.from),a=-1,h=e.heightChanged;for(s.from>t&&o.push(new le(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let f=e.doc.lineAt(l).length;o.length&&o.push(null);let u=s.heights[s.index++];a==-1?a=u:Math.abs(u-a)>=ln&&(a=-2);let d=new Ce(f,u);d.outdated=!1,o.push(d),l+=f+1}l<=r&&o.push(null,new le(r-l).updateHeight(e,l));let c=be.of(o);return e.heightChanged=h||a<0||Math.abs(c.height-this.height)>=ln||Math.abs(a-this.lines(e.doc,t).lineHeight)>=ln,c}else(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class mu extends be{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,s){let r=i+this.left.height;return el))return h;let c=t==q.ByPosNoHeight?q.ByPosNoHeight:q.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,s,r).join(h)}forEachLine(e,t,i,s,r,o){let l=s+this.left.height,a=r+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,q.ByPos,i,s,r);e=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 s=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of i)r.push(l);if(e>0&&Io(r,o-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,s=i+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e2*t.size||t.size>2*e.size?be.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=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,s){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return s&&s.from<=t+r.length&&s.more?a=r=r.updateHeight(e,t,i,s):r.updateHeight(e,t,i),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(e,l,i,s):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 Io(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof le&&(i=n[e+1])instanceof le&&n.splice(e-1,3,new le(t.length+1+i.length))}const gu=5;class Mr{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),s=this.nodes[this.nodes.length-1];s instanceof Ce?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Ce(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=gu)&&this.addLineDeco(s,r)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new Ce(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new le(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);return this.nodes.push(t),t}addBlock(e){this.enterLine(),e.type==W.WidgetAfter&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,e.type!=W.WidgetBefore&&(this.covering=e)}addLineDeco(e,t){let i=this.ensureLine();i.length+=t,i.collapsed+=t,i.widgetHeight=Math.max(i.widgetHeight,e),this.writtenTo=this.pos=this.pos+t}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)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=h==n.parentNode?u.bottom:Math.min(a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.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 xu(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Xn{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof t!="function"),this.heightMap=be.empty().applyChanges(this.stateDeco,N.empty,this.heightOracle.setDoc(e.doc),[new Ze(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=P.set(this.lineGaps.map(t=>t.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let s=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new zi(r,o))}}this.viewports=e.sort((i,s)=>i.from-s.from),this.scaler=this.heightMap.height<=7e6?Vo:new Cu(this.heightOracle.doc,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.state.doc,0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:pi(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Mi).filter(h=>typeof h!="function");let s=e.changedRanges,r=Ze.extendWithRanges(s,yu(i,this.stateDeco,e?e.changes:Q.empty(this.state.doc.length))),o=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=o&&(e.flags|=2);let l=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let a=!e.changes.empty||e.flags&2||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,this.updateForViewport(),a&&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(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ha)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?U.RTL:U.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),l=o||this.mustMeasureContent||this.contentDOMHeight!=t.clientHeight;this.contentDOMHeight=t.clientHeight,this.mustMeasureContent=!1;let a=0,h=0,c=parseInt(i.paddingTop)||0,f=parseInt(i.paddingBottom)||0;(this.paddingTop!=c||this.paddingBottom!=f)&&(this.paddingTop=c,this.paddingBottom=f,a|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,a|=8);let u=(this.printing?xu:wu)(t,this.paddingTop),d=u.top-this.pixelViewport.top,p=u.bottom-this.pixelViewport.bottom;this.pixelViewport=u;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let y=t.clientWidth;if((this.contentDOMWidth!=y||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=y,this.editorHeight=e.scrollDOM.clientHeight,a|=8),l){let k=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(k)&&(o=!0),o||s.lineWrapping&&Math.abs(y-this.contentDOMWidth)>s.charWidth){let{lineHeight:x,charWidth:C}=e.docView.measureTextSize();o=x>0&&s.refresh(r,x,C,y/C,k),o&&(e.docView.minWidth=0,a|=8)}d>0&&p>0?h=Math.max(d,p):d<0&&p<0&&(h=Math.min(d,p)),s.heightChanged=!1;for(let x of this.viewports){let C=x.from==this.viewport.from?k:e.docView.measureVisibleLineHeights(x);this.heightMap=o?be.empty().applyChanges(this.stateDeco,N.empty,this.heightOracle,[new Ze(0,0,0,e.state.doc.length)]):this.heightMap.updateHeight(s,0,o,new pu(x.from,C))}s.heightChanged&&(a|=2)}let b=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return b&&(this.viewport=this.getViewport(h,this.scrollTarget)),this.updateForViewport(),(a&2||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),a}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)),s=this.heightMap,r=this.state.doc,{visibleTop:o,visibleBottom:l}=this,a=new zi(s.lineAt(o-i*1e3,q.ByHeight,r,0,0).from,s.lineAt(l+(1-i)*1e3,q.ByHeight,r,0,0).to);if(t){let{head:h}=t.range;if(ha.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=s.lineAt(h,q.ByPos,r,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h=l+Math.max(10,Math.min(i,250)))&&s>o-2*1e3&&r>1,o=s<<1;if(this.defaultTextDirection!=U.LTR&&!i)return[];let l=[],a=(h,c,f,u)=>{if(c-hh&&yy.from>=f.from&&y.to<=f.to&&Math.abs(y.from-h)y.fromb));if(!g){if(cy.from<=c&&y.to>=c)){let y=t.moveToLineBoundary(w.cursor(c),!1,!0).head;y>h&&(c=y)}g=new Xn(h,c,this.gapSize(f,h,c,u))}l.push(g)};for(let h of this.viewportLines){if(h.lengthh.from&&a(h.from,u,h,c),dt.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];F.spans(e,this.viewport.from,this.viewport.to,{span(s,r){t.push({from:s,to:r})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((s,r)=>s.from!=t[r].from||s.to!=t[r].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||pi(this.heightMap.lineAt(e,q.ByPos,this.state.doc,0,0),this.scaler)}lineBlockAtHeight(e){return pi(this.heightMap.lineAt(this.scaler.fromDOM(e),q.ByHeight,this.state.doc,0,0),this.scaler)}elementAtHeight(e){return pi(this.heightMap.blockAt(this.scaler.fromDOM(e),this.state.doc,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class zi{constructor(e,t){this.from=e,this.to=t}}function vu(n,e,t){let i=[],s=n,r=0;return F.spans(t,n,e,{span(){},point(o,l){o>s&&(i.push({from:s,to:o}),r+=o-s),s=l}},20),s=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let s=0;;s++){let{from:r,to:o}=e[s],l=o-r;if(i<=l)return r+i;i-=l}}function qi(n,e){let t=0;for(let{from:i,to:s}of n.ranges){if(e<=s){t+=e-i;break}t+=s-i}return t/n.total}function Su(n,e){for(let t of n)if(e(t))return t}const Vo={toDOM(n){return n},fromDOM(n){return n},scale:1};class Cu{constructor(e,t,i){let s=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,q.ByPos,e,0,0).top,c=t.lineAt(a,q.ByPos,e,0,0).bottom;return s+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s);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,s=0;;t++){let r=tpi(s,e)):n.type)}const ji=O.define({combine:n=>n.join(" ")}),Js=O.define({combine:n=>n.indexOf(!0)>-1}),Ys=dt.newName(),oh=dt.newName(),lh=dt.newName(),ah={"&light":"."+oh,"&dark":"."+lh};function Xs(n,e,t){return new dt(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,s=>{if(s=="&")return n;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):n+" "+i}})}const Au=Xs("."+Ys,{"&.cm-editor":{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},".cm-content":{margin:0,flexGrow:2,flexShrink:0,minHeight:"100%",display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",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 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .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":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&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",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&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},"&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-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"},".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"}},ah);class Mu{constructor(e,t,i,s){this.typeOver=s,this.bounds=null,this.text="";let{impreciseHead:r,impreciseAnchor:o}=e.docView;if(t>-1&&!e.state.readOnly&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let l=r||o?[]:Tu(e),a=new Ga(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Ou(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!Jt(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),h=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!Jt(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset);this.newSel=w.single(h,a)}}}function hh(n,e){let t,{newSel:i}=e,s=n.state.selection.main;if(e.bounds){let{from:r,to:o}=e.bounds,l=s.from,a=null;(n.inputState.lastKeyCode===8&&n.inputState.lastKeyTime>Date.now()-100||D.android&&e.text.length=s.from&&t.to<=s.to&&(t.from!=s.from||t.to!=s.to)&&s.to-s.from-(t.to-t.from)<=4?t={from:s.from,to:s.to,insert:n.state.doc.slice(s.from,t.from).append(t.insert).append(n.state.doc.slice(t.to,s.to))}:(D.mac||D.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())?(i&&t.insert.length==2&&(i=w.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:N.of([" "])}):D.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==` `&&n.lineWrapping&&(i&&(i=w.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:N.of([" "])}),t){let r=n.state;if(D.ios&&n.inputState.flushIOSKey(n)||D.android&&(t.from==s.from&&t.to==s.to&&t.insert.length==1&&t.insert.lines==2&&Ut(n.contentDOM,"Enter",13)||t.from==s.from-1&&t.to==s.to&&t.insert.length==0&&Ut(n.contentDOM,"Backspace",8)||t.from==s.from&&t.to==s.to+1&&t.insert.length==0&&Ut(n.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();if(n.state.facet(Va).some(h=>h(n,t.from,t.to,o)))return!0;n.inputState.composing>=0&&n.inputState.composing++;let l;if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!i||i.main.empty&&i.main.from==t.from+t.insert.length)&&n.inputState.composing<0){let h=s.fromt.to?r.sliceDoc(t.to,s.to):"";l=r.replaceSelection(n.state.toText(h+t.insert.sliceString(0,void 0,n.state.lineBreak)+c))}else{let h=r.changes(t),c=i&&!r.selection.main.eq(i.main)&&i.main.to<=h.newLength?i.main:void 0;if(r.selection.ranges.length>1&&n.inputState.composing>=0&&t.to<=s.to&&t.to>=s.to-10){let f=n.state.sliceDoc(t.from,t.to),u=Ja(n)||n.state.doc.lineAt(s.head),d=s.to-t.to,p=s.to-s.from;l=r.changeByRange(g=>{if(g.from==s.from&&g.to==s.to)return{changes:h,range:c||g.map(h)};let y=g.to-d,b=y-f.length;if(g.to-g.from!=p||n.state.sliceDoc(b,y)!=f||u&&g.to>=u.from&&g.from<=u.to)return{range:g};let k=r.changes({from:b,to:y,insert:t.insert}),x=g.to-s.to;return{changes:k,range:c?w.range(Math.max(0,c.anchor+x),Math.max(0,c.head+x)):g.map(k)}})}else l={changes:h,selection:c&&r.selection.replaceRange(c)}}let a="input.type";return n.composing&&(a+=".compose",n.inputState.compositionFirstChange&&(a+=".start",n.inputState.compositionFirstChange=!1)),n.dispatch(l,{scrollIntoView:!0,userEvent:a}),!0}else if(i&&!i.main.eq(s)){let r=!1,o="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(r=!0),o=n.inputState.lastSelectionOrigin),n.dispatch({selection:i,scrollIntoView:r,userEvent:o}),!0}else return!1}function Du(n,e,t,i){let s=Math.min(n.length,e.length),r=0;for(;r0&&l>0&&n.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=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function Tu(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}=n.observer.selectionRange;return t&&(e.push(new wo(t,i)),(s!=t||r!=i)&&e.push(new wo(s,r))),e}function Ou(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?w.single(t+e,i+e):null}const Bu={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Qn=D.ie&&D.ie_version<=11;class Eu{constructor(e){this.view=e,this.active=!1,this.selectionRange=new Cf,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.resize=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(D.ie&&D.ie_version<=11||D.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()}),Qn&&(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),typeof ResizeObserver=="function"&&(this.resize=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){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")))},{}),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.runScrollHandlers(this.view,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){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,s=this.selectionRange;if(i.state.facet(Ln)?i.root.activeElement!=this.dom:!on(i.dom,s))return;let r=s.anchorNode&&i.docView.nearest(s.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(D.ie&&D.ie_version<=11||D.android&&D.chrome)&&!i.state.selection.main.empty&&s.focusNode&&gn(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=D.safari&&e.root.nodeType==11&&kf(this.dom.ownerDocument)==this.dom&&Pu(this.view)||mn(e.root);if(!t||this.selectionRange.eq(t))return!1;let i=on(this.dom,t);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),!this.flush()&&r.force&&Ut(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}processRecords(){let e=this.queue;for(let r of this.observer.takeRecords())e.push(r);e.length&&(this.queue=[]);let t=-1,i=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!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:s}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),s=this.selectionChanged&&on(this.dom,this.selectionRange);return e<0&&!s?null:(e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new Mu(this.view,e,t,i))}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return!1;let i=this.view.state,s=hh(this.view,t);return this.view.state==i&&this.view.update([]),s}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.dirty|=4),e.type=="childList"){let i=Fo(t,e.previousSibling||e.target.previousSibling,-1),s=Fo(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:s?t.posBefore(s):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),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),e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}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.resize)===null||i===void 0||i.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function Fo(n,e,t){for(;e;){let i=j.get(e);if(i&&i.parent==n)return i;let s=e.parentNode;e=s!=n.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function Pu(n){let e=null;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}if(n.contentDOM.addEventListener("beforeinput",t,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let i=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,l=n.docView.domAtPos(n.state.selection.main.anchor);return gn(l.node,l.offset,r,o)&&([i,s,r,o]=[r,o,i,s]),{anchorNode:i,anchorOffset:s,focusNode:r,focusOffset:o}}class B{constructor(e={}){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.style.cssText="position: absolute; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=e.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=e.root||Af(e.parent)||document,this.viewState=new No(e.state||I.create(e)),this.plugins=this.state.facet(ui).map(t=>new Gn(t));for(let t of this.plugins)t.update(this);this.observer=new Eu(this),this.inputState=new eu(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new xo(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}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.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...e){this._dispatch(e.length==1&&e[0]instanceof Z?e[0]:this.state.update(...e))}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,s,r=this.state;for(let h of e){if(h.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=h.state}if(this.destroyed){this.viewState.state=r;return}let o=this.observer.delayedAndroidKey,l=null;if(o?(this.observer.clearDelayedAndroidKey(),l=this.observer.readChange(),(l&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(l=null)):this.observer.clear(),r.facet(I.phrases)!=this.state.facet(I.phrases))return this.setState(r);s=wn.create(this,r,e);let a=this.viewState.scrollTarget;try{this.updateState=2;for(let h of e){if(a&&(a=a.map(h.changes)),h.scrollIntoView){let{main:c}=h.state.selection;a=new bn(c.empty?c:w.cursor(c.head,c.head>c.anchor?-1:1))}for(let c of h.effects)c.is(yo)&&(a=c.value)}this.viewState.update(s,a),this.bidiCache=xn.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(di)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(ji)!=s.state.facet(ji)&&(this.viewState.mustMeasureContent=!0),(t||i||a||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!s.empty)for(let h of this.state.facet($s))h(s);l&&!hh(this,l)&&o.force&&Ut(this.contentDOM,o.key,o.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 No(e),this.plugins=e.facet(ui).map(i=>new Gn(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView=new xo(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(ui),i=e.state.facet(ui);if(t!=i){let s=[];for(let r of i){let o=t.indexOf(r);if(o<0)s.push(new Gn(r));else{let l=this.plugins[o];l.mustUpdate=e,s.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,{scrollHeight:i,scrollTop:s,clientHeight:r}=this.scrollDOM,o=s>i-r-4?i:s;try{for(let l=0;;l++){this.updateState=1;let a=this.viewport,h=this.viewState.lineBlockAtHeight(o),c=this.viewState.measure(this);if(!c&&!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 f=[];c&4||([this.measureRequests,f]=[f,this.measureRequests]);let u=f.map(y=>{try{return y.read(this)}catch(b){return He(this.state,b),Ho}}),d=wn.create(this,this.state,[]),p=!1,g=!1;d.flags|=c,t?t.flags|=c:t=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),p=this.docView.update(d));for(let y=0;y1||y<-1)&&(this.scrollDOM.scrollTop+=y,g=!0)}if(p&&this.docView.updateSelection(!0),this.viewport.from==a.from&&this.viewport.to==a.to&&!g&&this.measureRequests.length==0)break}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet($s))l(t)}get themeClasses(){return Ys+" "+(this.state.facet(Js)?lh:oh)+" "+this.state.facet(ji)}updateAttrs(){let e=Wo(this,Wa,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Ln)?"true":"false",class:"cm-content",style:`${D.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Wo(this,za,t);let i=this.observer.ignore(()=>{let s=Ws(this.contentDOM,this.contentAttrs,t),r=Ws(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let s of i.effects)if(s.is(B.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(di),dt.mount(this.root,this.styleModules.concat(Au).reverse())}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(e.key!=null){for(let t=0;ti.spec==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}}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 Yn(this,e,Mo(this,e,t,i))}moveByGroup(e,t){return Yn(this,e,Mo(this,e,t,i=>Qf(this,e.head,i)))}moveToLineBoundary(e,t,i=!0){return Xf(this,e,t,i)}moveVertically(e,t,i){return Yn(this,e,Zf(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),Xa(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 s=this.state.doc.lineAt(e),r=this.bidiSpans(s),o=r[Gt.find(r,e-s.from,-1,t)];return vr(i,o.dir==U.LTR==t>0)}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(Fa)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Lu)return Ka(e.length);let t=this.textDirectionAt(e.from);for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t)return s.order;let i=Nf(e.text,t);return this.bidiCache.push(new xn(e.from,e.to,t,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||D.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ka(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(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return yo.of(new bn(typeof e=="number"?w.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}static domEventHandlers(e){return pe.define(()=>({}),{eventHandlers:e})}static theme(e,t){let i=dt.newName(),s=[ji.of(i),di.of(Xs(`.${i}`,e))];return t&&t.dark&&s.push(Js.of(!0)),s}static baseTheme(e){return Pi.lowest(di.of(Xs("."+Ys,e,ah)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),s=i&&j.get(i)||j.get(e);return((t=s?.rootView)===null||t===void 0?void 0:t.view)||null}}B.styleModule=di;B.inputHandler=Va;B.perLineTextDirection=Fa;B.exceptionSink=Na;B.updateListener=$s;B.editable=Ln;B.mouseSelectionStyle=Ia;B.dragMovesSelection=_a;B.clickAddsSelectionRange=Ra;B.decorations=Mi;B.atomicRanges=$a;B.scrollMargins=qa;B.darkTheme=Js;B.contentAttributes=za;B.editorAttributes=Wa;B.lineWrapping=B.contentAttributes.of({class:"cm-lineWrapping"});B.announce=L.define();const Lu=4096,Ho={};class xn{constructor(e,t,i,s){this.from=e,this.to=t,this.dir=i,this.order=s}static update(e,t){if(t.empty)return e;let i=[],s=e.length?e[e.length-1].dir:U.LTR;for(let r=Math.max(0,e.length-10);r=0;s--){let r=i[s],o=typeof r=="function"?r(n):r;o&&Hs(o,t)}return t}const Ru=D.mac?"mac":D.windows?"win":D.linux?"linux":"key";function _u(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let s,r,o,l;for(let a=0;ai.concat(s),[]))),t}let at=null;const Vu=4e3;function Fu(n,e=Ru){let t=Object.create(null),i=Object.create(null),s=(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)=>{var c,f;let u=t[o]||(t[o]=Object.create(null)),d=l.split(/ (?!$)/).map(y=>_u(y,e));for(let y=1;y{let x=at={view:k,prefix:b,scope:o};return setTimeout(()=>{at==x&&(at=null)},Vu),!0}]})}let p=d.join(" ");s(p,!1);let g=u[p]||(u[p]={preventDefault:!1,run:((f=(c=u._any)===null||c===void 0?void 0:c.run)===null||f===void 0?void 0:f.slice())||[]});a&&g.run.push(a),h&&(g.preventDefault=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=t[h]||(t[h]=Object.create(null));c._any||(c._any={preventDefault:!1,run:[]});for(let f in c)c[f].run.push(o.any)}let a=o[e]||o.key;if(a)for(let h of l)r(h,a,o.run,o.preventDefault),o.shift&&r(h,"Shift-"+a,o.shift,o.preventDefault)}return t}function Hu(n,e,t,i){let s=xf(e),r=ue(s,0),o=Te(r)==s.length&&s!=" ",l="",a=!1;at&&at.view==t&&at.scope==i&&(l=at.prefix+" ",(a=Za.indexOf(e.keyCode)<0)&&(at=null));let h=new Set,c=p=>{if(p){for(let g of p.run)if(!h.has(g)&&(h.add(g),g(t,e)))return!0;p.preventDefault&&(a=!0)}return!1},f=n[i],u,d;if(f){if(c(f[l+Ki(s,e,!o)]))return!0;if(o&&(e.shiftKey||e.altKey||e.metaKey||r>127)&&(u=pt[e.keyCode])&&u!=s){if(c(f[l+Ki(u,e,!0)]))return!0;if(e.shiftKey&&(d=Si[e.keyCode])!=s&&d!=u&&c(f[l+Ki(d,e,!1)]))return!0}else if(o&&e.shiftKey&&c(f[l+Ki(s,e,!0)]))return!0;if(c(f._any))return!0}return a}const ch=!D.ios,mi=O.define({combine(n){return Vt(n,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Wu(n={}){return[mi.of(n),zu,$u,Ha.of(!0)]}class fh{constructor(e,t,i,s,r){this.left=e,this.top=t,this.width=i,this.height=s,this.className=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width>=0&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}}const zu=pe.fromClass(class{constructor(n){this.view=n,this.rangePieces=[],this.cursors=[],this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.selectionLayer=n.scrollDOM.appendChild(document.createElement("div")),this.selectionLayer.className="cm-selectionLayer",this.selectionLayer.setAttribute("aria-hidden","true"),this.cursorLayer=n.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),n.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){this.cursorLayer.style.animationDuration=this.view.state.facet(mi).cursorBlinkRate+"ms"}update(n){let e=n.startState.facet(mi)!=n.state.facet(mi);(e||n.selectionSet||n.geometryChanged||n.viewportChanged)&&this.view.requestMeasure(this.measureReq),n.transactions.some(t=>t.scrollIntoView)&&(this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink"),e&&this.setBlinkRate()}readPos(){let{state:n}=this.view,e=n.facet(mi),t=n.selection.ranges.map(s=>s.empty?[]:qu(this.view,s)).reduce((s,r)=>s.concat(r)),i=[];for(let s of n.selection.ranges){let r=s==n.selection.main;if(s.empty?!r||ch:e.drawRangeCursor){let o=ju(this.view,s,r);o&&i.push(o)}}return{rangePieces:t,cursors:i}}drawSel({rangePieces:n,cursors:e}){if(n.length!=this.rangePieces.length||n.some((t,i)=>!t.eq(this.rangePieces[i]))){this.selectionLayer.textContent="";for(let t of n)this.selectionLayer.appendChild(t.draw());this.rangePieces=n}if(e.length!=this.cursors.length||e.some((t,i)=>!t.eq(this.cursors[i]))){let t=this.cursorLayer.children;if(t.length!==e.length){this.cursorLayer.textContent="";for(const i of e)this.cursorLayer.appendChild(i.draw())}else e.forEach((i,s)=>i.adjust(t[s]));this.cursors=e}}destroy(){this.selectionLayer.remove(),this.cursorLayer.remove()}}),uh={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};ch&&(uh[".cm-line"].caretColor="transparent !important");const $u=Pi.highest(B.theme(uh));function dh(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==U.LTR?e.left:e.right-n.scrollDOM.clientWidth)-n.scrollDOM.scrollLeft,top:e.top-n.scrollDOM.scrollTop}}function $o(n,e,t){let i=w.cursor(e);return{from:Math.max(t.from,n.moveToLineBoundary(i,!1,!0).from),to:Math.min(t.to,n.moveToLineBoundary(i,!0,!0).from),type:W.Text}}function qo(n,e){let t=n.lineBlockAt(e);if(Array.isArray(t.type)){for(let i of t.type)if(i.to>e||i.to==e&&(i.to==t.to||i.type==W.Text))return i}return t}function qu(n,e){if(e.to<=n.viewport.from||e.from>=n.viewport.to)return[];let t=Math.max(e.from,n.viewport.from),i=Math.min(e.to,n.viewport.to),s=n.textDirection==U.LTR,r=n.contentDOM,o=r.getBoundingClientRect(),l=dh(n),a=window.getComputedStyle(r.firstChild),h=o.left+parseInt(a.paddingLeft)+Math.min(0,parseInt(a.textIndent)),c=o.right-parseInt(a.paddingRight),f=qo(n,t),u=qo(n,i),d=f.type==W.Text?f:null,p=u.type==W.Text?u:null;if(n.lineWrapping&&(d&&(d=$o(n,t,d)),p&&(p=$o(n,i,p))),d&&p&&d.from==p.from)return y(b(e.from,e.to,d));{let x=d?b(e.from,null,d):k(f,!1),C=p?b(null,e.to,p):k(u,!0),M=[];return(d||f).to<(p||u).from-1?M.push(g(h,x.bottom,c,C.top)):x.bottomS&&$.from=ge)break;X>G&&_(Math.max(ve,G),x==null&&ve<=S,Math.min(X,ge),C==null&&X>=V,ne.dir)}if(G=ee.to+1,G>=ge)break}return H.length==0&&_(S,x==null,V,C==null,n.textDirection),{top:T,bottom:E,horizontal:H}}function k(x,C){let M=o.top+(C?x.top:x.bottom);return{top:M,bottom:M,horizontal:[]}}}function ju(n,e,t){let i=n.coordsAtPos(e.head,e.assoc||1);if(!i)return null;let s=dh(n);return new fh(i.left-s.left,i.top-s.top,-1,i.bottom-i.top,t?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary")}function jo(n,e,t,i,s){e.lastIndex=0;for(let r=n.iterRange(t,i),o=t,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=e.exec(r.value);)s(o+l.index,l)}function Ku(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:s,to:r}of t)s=Math.max(n.state.doc.lineAt(s).from,s-e),r=Math.min(n.state.doc.lineAt(r).to,r+e),i.length&&i[i.length-1].to>=s?i[i.length-1].to=r:i.push({from:s,to:r});return i}class Uu{constructor(e){const{regexp:t,decoration:i,decorate:s,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(l,a,h,c)=>s(c,h,h+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,h,c)=>{let f=i(l,a,h);f&&c(h,h+l[0].length,f)};else if(i)this.addMatch=(l,a,h,c)=>c(h,h+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new Ot,i=t.add.bind(t);for(let{from:s,to:r}of Ku(e,this.maxLength))jo(e.state.doc,this.regexp,s,r,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>e.view.viewport.from&&l1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),i,s):t}updateRange(e,t,i,s){for(let r of e.visibleRanges){let o=Math.max(r.from,i),l=Math.min(r.to,s);if(l>o){let a=e.state.doc.lineAt(o),h=a.toa.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;lu.push(b.range(g,y));if(a==h)for(this.regexp.lastIndex=c-a.from;(d=this.regexp.exec(a.text))&&d.indexthis.addMatch(y,e,g,p));t=t.update({filterFrom:c,filterTo:f,filter:(g,y)=>gf,add:u})}}return t}}const Qs=/x/.unicode!=null?"gu":"g",Gu=new RegExp(`[\0-\b --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,Qs),Ju={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Zn=null;function Yu(){var n;if(Zn==null&&typeof document<"u"&&document.body){let e=document.body.style;Zn=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Zn||!1}const an=O.define({combine(n){let e=Vt(n,{render:null,specialChars:Gu,addSpecialChars:null});return(e.replaceTabs=!Yu())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Qs)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Qs)),e}});function Xu(n={}){return[an.of(n),Qu()]}let Ko=null;function Qu(){return Ko||(Ko=pe.fromClass(class{constructor(n){this.view=n,this.decorations=P.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(an)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new Uu({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:s}=t.state,r=ue(e[0],0);if(r==9){let o=s.lineAt(i),l=t.state.tabSize,a=Li(o.text,l,i-o.from);return P.replace({widget:new id((l-a%l)*this.view.defaultCharacterWidth)})}return this.decorationCache[r]||(this.decorationCache[r]=P.replace({widget:new td(n,r)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(an);n.startState.facet(an)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const Zu="•";function ed(n){return n>=32?Zu:n==10?"␤":String.fromCharCode(9216+n)}class td extends tt{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=ed(this.code),i=e.state.phrase("Control character")+" "+(Ju[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class id extends tt{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}class nd extends tt{constructor(e){super(),this.content=e}toDOM(){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content),typeof this.content=="string"?e.setAttribute("aria-label","placeholder "+this.content):e.setAttribute("aria-hidden","true"),e}ignoreEvent(){return!1}}function sd(n){return pe.fromClass(class{constructor(e){this.view=e,this.placeholder=P.set([P.widget({widget:new nd(n),side:1}).range(0)])}get decorations(){return this.view.state.doc.length?P.none:this.placeholder}},{decorations:e=>e.decorations})}const Zs=2e3;function rd(n,e,t){let i=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>Zs||t.off>Zs||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=i;a<=s;a++){let h=n.doc.line(a);h.length<=l&&r.push(w.range(h.from+o,h.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=i;a<=s;a++){let h=n.doc.line(a),c=Ps(h.text,o,n.tabSize,!0);if(c<0)r.push(w.cursor(h.to));else{let f=Ps(h.text,l,n.tabSize);r.push(w.range(h.from+c,h.from+f))}}}return r}function od(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function Uo(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),s=t-i.from,r=s>Zs?-1:s==i.length?od(n,e.clientX):Li(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:r,off:s}}function ld(n,e){let t=Uo(n,e),i=n.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(s.changes)}},get(s,r,o){let l=Uo(n,s);if(!l)return i;let a=rd(n.state,t,l);return a.length?o?w.create(a.concat(i.ranges)):w.create(a):i}}:null}function ad(n){let e=t=>t.altKey&&t.button==0;return B.mouseSelectionStyle.of((t,i)=>e(i)?ld(t,i):null)}const hd={Alt:[18,n=>n.altKey],Control:[17,n=>n.ctrlKey],Shift:[16,n=>n.shiftKey],Meta:[91,n=>n.metaKey]},cd={style:"cursor: crosshair"};function fd(n={}){let[e,t]=hd[n.key||"Alt"],i=pe.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventHandlers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[i,B.contentAttributes.of(s=>{var r;return!((r=s.plugin(i))===null||r===void 0)&&r.isDown?cd:null})]}const es="-10000px";class ph{constructor(e,t,i){this.facet=t,this.createTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(s=>s),this.tooltipViews=this.tooltips.map(i)}update(e){var t;let i=e.state.facet(this.facet),s=i.filter(o=>o);if(i===this.input){for(let o of this.tooltipViews)o.update&&o.update(e);return!1}let r=[];for(let o=0;o{var e,t,i;return{position:D.ios?"absolute":((e=n.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||ud}}}),mh=pe.fromClass(class{constructor(n){this.view=n,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(ts);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new ph(n,Dr,t=>this.createTooltip(t)),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(ts);if(i.position!=this.position){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n){let e=n.create(this.view);if(e.dom.classList.add("cm-tooltip"),n.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=es,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var n,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(n=t.destroy)===null||n===void 0||n.call(t);(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=this.view.dom.getBoundingClientRect();return{editor:n,parent:this.parent?this.container.getBoundingClientRect():n,pos:this.manager.tooltips.map((e,t)=>{let i=this.manager.tooltipViews[t];return i.getCoords?i.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(ts).tooltipSpace(this.view)}}writeMeasure(n){let{editor:e,space:t}=n,i=[];for(let s=0;s=Math.min(e.bottom,t.bottom)||a.rightMath.min(e.right,t.right)+.1){l.style.top=es;continue}let c=r.arrow?o.dom.querySelector(".cm-tooltip-arrow"):null,f=c?7:0,u=h.right-h.left,d=h.bottom-h.top,p=o.offset||pd,g=this.view.textDirection==U.LTR,y=h.width>t.right-t.left?g?t.left:t.right-h.width:g?Math.min(a.left-(c?14:0)+p.x,t.right-u):Math.max(t.left,a.left-u+(c?14:0)-p.x),b=!!r.above;!r.strictSide&&(b?a.top-(h.bottom-h.top)-p.yt.bottom)&&b==t.bottom-a.bottom>a.top-t.top&&(b=!b);let k=b?a.top-d-f-p.y:a.bottom+f+p.y,x=y+u;if(o.overlap!==!0)for(let C of i)C.lefty&&C.topk&&(k=b?C.top-d-2-f:C.bottom+f+2);this.position=="absolute"?(l.style.top=k-n.parent.top+"px",l.style.left=y-n.parent.left+"px"):(l.style.top=k+"px",l.style.left=y+"px"),c&&(c.style.left=`${a.left+(g?p.x:-p.x)-(y+14-7)}px`),o.overlap!==!0&&i.push({left:y,top:k,right:x,bottom:k+d}),l.classList.toggle("cm-tooltip-above",b),l.classList.toggle("cm-tooltip-below",!b),o.positioned&&o.positioned()}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=es}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),dd=B.baseTheme({".cm-tooltip":{zIndex:100},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),pd={x:0,y:0},Dr=O.define({enables:[mh,dd]}),kn=O.define();class Tr{constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new ph(e,kn,t=>this.createHostedView(t))}static create(e){return new Tr(e)}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned()}update(e){this.manager.update(e)}}const md=Dr.compute([kn],n=>{let e=n.facet(kn).filter(t=>t);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.filter(t=>t.end!=null).map(t=>t.end)),create:Tr.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class gd{constructor(e,t,i,s,r){this.view=e,this.source=t,this.field=i,this.setHover=s,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let e=Date.now()-this.lastMove.time;ei.bottom||e.xi.right+this.view.defaultCharacterWidth)return;let s=this.view.bidiSpans(this.view.state.doc.lineAt(t)).find(l=>l.from<=t&&l.to>=t),r=s&&s.dir==U.RTL?-1:1,o=this.source(this.view,t,e.x{this.pending==l&&(this.pending=null,a&&this.view.dispatch({effects:this.setHover.of(a)}))},a=>He(this.view.state,a,"hover tooltip"))}else o&&this.view.dispatch({effects:this.setHover.of(o)})}mousemove(e){var t;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let i=this.active;if(i&&!yd(this.lastMove.target)||this.pending){let{pos:s}=i||this.pending,r=(t=i?.end)!==null&&t!==void 0?t:s;(s==r?this.view.posAtCoords(this.lastMove)!=s:!bd(this.view,s,r,e.clientX,e.clientY,6))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active&&this.view.dispatch({effects:this.setHover.of(null)})}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function yd(n){for(let e=n;e;e=e.parentNode)if(e.nodeType==1&&e.classList.contains("cm-tooltip"))return!0;return!1}function bd(n,e,t,i,s,r){let o=document.createRange(),l=n.domAtPos(e),a=n.domAtPos(t);o.setEnd(a.node,a.offset),o.setStart(l.node,l.offset);let h=o.getClientRects();o.detach();for(let c=0;ckn.from(s)});return[i,pe.define(s=>new gd(s,n,i,t,e.hoverTime||300)),md]}function xd(n,e){let t=n.plugin(mh);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const kd=L.define(),Go=O.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function vd(n,e){let t=n.plugin(gh),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const gh=pe.fromClass(class{constructor(n){this.input=n.state.facet(er),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(Go);this.top=new Ui(n,!0,e.topContainer),this.bottom=new Ui(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(Go);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Ui(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ui(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(er);if(t!=this.input){let i=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),c;h<0?(c=a(n.view),l.push(c)):(c=this.panels[h],c.update&&c.update(n)),s.push(c),(c.top?r:o).push(c)}this.specs=i,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>B.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Ui{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Jo(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Jo(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Jo(n){let e=n.nextSibling;return n.remove(),e}const er=O.define({enables:gh});class gt extends Tt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}gt.prototype.elementClass="";gt.prototype.toDOM=void 0;gt.prototype.mapMode=he.TrackBefore;gt.prototype.startSide=gt.prototype.endSide=-1;gt.prototype.point=!0;const is=O.define(),Sd={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>F.empty,lineMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},bi=O.define();function Cd(n){return[yh(),bi.of(Object.assign(Object.assign({},Sd),n))]}const Yo=O.define({combine:n=>n.some(e=>e)});function yh(n){return[Ad]}const Ad=pe.fromClass(class{constructor(n){this.view=n,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight+"px",this.gutters=n.state.facet(bi).map(e=>new Qo(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet(Yo),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}n.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(Yo)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&this.dom.remove();let t=F.iter(this.view.state.facet(is),this.view.viewport.from),i=[],s=this.gutters.map(r=>new Md(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks){let o;if(Array.isArray(r.type)){for(let l of r.type)if(l.type==W.Text){o=l;break}}else o=r.type==W.Text?r:void 0;if(o){i.length&&(i=[]),bh(t,i,r.from);for(let l of s)l.line(this.view,o,i)}}for(let r of s)r.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(bi),t=n.state.facet(bi),i=n.docChanged||n.heightChanged||n.viewportChanged||!F.eq(n.startState.facet(is),n.state.facet(is),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(n)&&(i=!0);else{i=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new Qo(this.view,r)):(this.gutters[o].update(n),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)this.dom.appendChild(r.dom);this.gutters=s}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>B.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==U.LTR?{left:t.dom.offsetWidth}:{right:t.dom.offsetWidth}})});function Xo(n){return Array.isArray(n)?n:[n]}function bh(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class Md{constructor(e,t,i){this.gutter=e,this.height=i,this.localMarkers=[],this.i=0,this.cursor=F.iter(e.markers,t.from)}line(e,t,i){this.localMarkers.length&&(this.localMarkers=[]),bh(this.cursor,this.localMarkers,t.from);let s=i.length?this.localMarkers.concat(i):this.localMarkers,r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;if(s.length==0&&!o.config.renderEmptyElements)return;let l=t.top-this.height;if(this.i==o.elements.length){let a=new wh(e,t.height,l,s);o.elements.push(a),o.dom.appendChild(a.dom)}else o.elements[this.i].update(e,t.height,l,s);this.height=t.bottom,this.i++}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Qo{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,s=>{let r=e.lineBlockAtHeight(s.clientY-e.documentTop);t.domEventHandlers[i](e,r,s)&&s.preventDefault()});this.markers=Xo(t.markers(e)),t.initialSpacer&&(this.spacer=new wh(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=Xo(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let i=e.view.viewport;return!F.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 wh{constructor(e,t,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,s)}update(e,t,i,s){this.height!=t&&(this.dom.style.height=(this.height=t)+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Dd(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let i="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=rr(l,a,h)||o(l,a,h):o}return i}})}});class ns extends gt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function ss(n,e){return n.state.facet(zt).formatNumber(e,n.state)}const Od=bi.compute([zt],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Td)},lineMarker(e,t,i){return i.some(s=>s.toDOM)?null:new ns(ss(e,e.state.doc.lineAt(t.from).number))},lineMarkerChange:e=>e.startState.facet(zt)!=e.state.facet(zt),initialSpacer(e){return new ns(ss(e,Zo(e.state.doc.lines)))},updateSpacer(e,t){let i=ss(t.view,Zo(t.view.state.doc.lines));return i==e.number?e:new ns(i)},domEventHandlers:n.facet(zt).domEventHandlers}));function Bd(n={}){return[zt.of(n),yh(),Od]}function Zo(n){let e=9;for(;e{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=we.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}R.closedBy=new R({deserialize:n=>n.split(" ")});R.openedBy=new R({deserialize:n=>n.split(" ")});R.group=new R({deserialize:n=>n.split(" ")});R.contextHash=new R({perNode:!0});R.lookAhead=new R({perNode:!0});R.mounted=new R({perNode:!0});class Ld{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}}const Rd=Object.create(null);class we{constructor(e,t,i,s=0){this.name=e,this.props=t,this.id=i,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):Rd,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new we(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),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 s}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(R.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 s of i.split(" "))t[s]=e[i];return i=>{for(let s=i.prop(R.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?i.name:s[r]];if(o)return o}}}}we.none=new we("",Object.create(null),0,8);class Or{constructor(e){this.types=e;for(let t=0;t=s&&(o.type.isAnonymous||t(o)!==!1)){if(o.firstChild())continue;l=!0}for(;l&&i&&!o.type.isAnonymous&&i(o),!o.nextSibling();){if(!o.parent())return;l=!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:Pr(we.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,s)=>new z(this.type,t,i,s,this.propValues),e.makeTree||((t,i,s)=>new z(we.none,t,i,s)))}static build(e){return Id(e)}}z.empty=new z(we.none,[],[],0);class Br{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 Br(this.buffer,this.index)}}class Ft{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return we.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return l}slice(e,t,i){let s=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function kh(n,e){let t=n.childBefore(e);for(;t;){let i=t.lastChild;if(!i||i.to!=t.to)break;i.type.isError&&i.from==i.to?(n=t,t=i.prevSibling):t=i}return n}function Qt(n,e,t,i){for(var s;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from;if(xh(s,i,f,f+c.length)){if(c instanceof Ft){if(r&J.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,t,i-f,s);if(u>-1)return new Ye(new _d(o,c,e,f),null,u)}else if(r&J.IncludeAnonymous||!c.type.isAnonymous||Er(c)){let u;if(!(r&J.IgnoreMounts)&&c.props&&(u=c.prop(R.mounted))&&!u.overlay)return new Re(u.tree,f,e,o);let d=new Re(c,f,e,o);return r&J.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?c.children.length-1:0,t,i,s)}}}if(r&J.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)}enter(e,t,i=0){let s;if(!(i&J.IgnoreOverlays)&&(s=this._tree.prop(R.mounted))&&s.overlay){let r=e-this.from;for(let{from:o,to:l}of s.overlay)if((t>0?o<=r:o=r:l>r))return new Re(s.tree,s.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}cursor(e=0){return new Di(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return Qt(this,e,t,!1)}resolveInner(e,t=0){return Qt(this,e,t,!0)}enterUnfinishedNodesBefore(e){return kh(this,e)}getChild(e,t=null,i=null){let s=vn(this,e,t,i);return s.length?s[0]:null}getChildren(e,t=null,i=null){return vn(this,e,t,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return Sn(this,e)}}function vn(n,e,t,i){let s=n.cursor(),r=[];if(!s.firstChild())return r;if(t!=null){for(;!s.type.is(t);)if(!s.nextSibling())return r}for(;;){if(i!=null&&s.type.is(i))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return i==null?r:[]}}function Sn(n,e,t=e.length-1){for(let i=n.parent;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 _d{constructor(e,t,i,s){this.parent=e,this.buffer=t,this.index=i,this.start=s}}class Ye{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){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:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new Ye(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)}enter(e,t,i=0){if(i&J.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new Ye(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 Ye(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 Ye(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new Di(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let o=i.buffer[this.index+1];e.push(i.slice(s,r,o)),t.push(0)}return new z(this.type,e,t,this.to-this.from)}resolve(e,t=0){return Qt(this,e,t,!1)}resolveInner(e,t=0){return Qt(this,e,t,!0)}enterUnfinishedNodesBefore(e){return kh(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,i=null){let s=vn(this,e,t,i);return s.length?s[0]:null}getChildren(e,t=null,i=null){return vn(this,e,t,i)}get node(){return this}matchContext(e){return Sn(this,e)}}class Di{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Re)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:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=i+s.buffer[e+1],this.to=i+s.buffer[e+2],!0}yield(e){return e?e instanceof Re?(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:s}=this.buffer,r=s.findChild(this.index+4,s.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&J.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&J.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&J.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 s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(s)}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:s}=this;if(s){if(e>0){if(this.index-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&J.IncludeAnonymous||l instanceof Ft||!l.type.isAnonymous||Er(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=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,i=r+1;break e}s=this.stack[--r]}for(let s=i;s=0;r--){if(r<0)return Sn(this.node,e,s);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}}function Er(n){return n.children.some(e=>e instanceof Ft||!e.type.isAnonymous||Er(e))}function Id(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:s=Ed,reused:r=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new Br(t,t.length):t,a=i.types,h=0,c=0;function f(C,M,T,E,H){let{id:_,start:S,end:V,size:$}=l,G=c;for(;$<0;)if(l.next(),$==-1){let X=r[_];T.push(X),E.push(S-C);return}else if($==-3){h=_;return}else if($==-4){c=_;return}else throw new RangeError(`Unrecognized record size: ${$}`);let ge=a[_],ee,ne,ve=S-C;if(V-S<=s&&(ne=g(l.pos-M,H))){let X=new Uint16Array(ne.size-ne.skip),A=l.pos-ne.size,te=X.length;for(;l.pos>A;)te=y(ne.start,X,te);ee=new Ft(X,V-ne.start,i),ve=ne.start-C}else{let X=l.pos-$;l.next();let A=[],te=[],se=_>=o?_:-1,Ie=0,wt=V;for(;l.pos>X;)se>=0&&l.id==se&&l.size>=0?(l.end<=wt-s&&(d(A,te,S,Ie,l.end,wt,se,G),Ie=A.length,wt=l.end),l.next()):f(S,X,A,te,se);if(se>=0&&Ie>0&&Ie-1&&Ie>0){let Vi=u(ge);ee=Pr(ge,A,te,0,A.length,0,V-S,Vi,Vi)}else ee=p(ge,A,te,V-S,G-V)}T.push(ee),E.push(ve)}function u(C){return(M,T,E)=>{let H=0,_=M.length-1,S,V;if(_>=0&&(S=M[_])instanceof z){if(!_&&S.type==C&&S.length==E)return S;(V=S.prop(R.lookAhead))&&(H=T[_]+S.length+V)}return p(C,M,T,E,H)}}function d(C,M,T,E,H,_,S,V){let $=[],G=[];for(;C.length>E;)$.push(C.pop()),G.push(M.pop()+T-H);C.push(p(i.types[S],$,G,_-H,V-_)),M.push(H-T)}function p(C,M,T,E,H=0,_){if(h){let S=[R.contextHash,h];_=_?[S].concat(_):[S]}if(H>25){let S=[R.lookAhead,H];_=_?[S].concat(_):[S]}return new z(C,M,T,E,_)}function g(C,M){let T=l.fork(),E=0,H=0,_=0,S=T.end-s,V={size:0,start:0,skip:0};e:for(let $=T.pos-C;T.pos>$;){let G=T.size;if(T.id==M&&G>=0){V.size=E,V.start=H,V.skip=_,_+=4,E+=4,T.next();continue}let ge=T.pos-G;if(G<0||ge<$||T.start=o?4:0,ne=T.start;for(T.next();T.pos>ge;){if(T.size<0)if(T.size==-3)ee+=4;else break e;else T.id>=o&&(ee+=4);T.next()}H=ne,E+=G,_+=ee}return(M<0||E==C)&&(V.size=E,V.start=H,V.skip=_),V.size>4?V:void 0}function y(C,M,T){let{id:E,start:H,end:_,size:S}=l;if(l.next(),S>=0&&E4){let $=l.pos-(S-4);for(;l.pos>$;)T=y(C,M,T)}M[--T]=V,M[--T]=_-C,M[--T]=H-C,M[--T]=E}else S==-3?h=E:S==-4&&(c=E);return T}let b=[],k=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,b,k,-1);let x=(e=n.length)!==null&&e!==void 0?e:b.length?k[0]+b[0].length:0;return new z(a[n.topID],b.reverse(),k.reverse(),x)}const tl=new WeakMap;function hn(n,e){if(!n.isAnonymous||e instanceof Ft||e.type!=n)return 1;let t=tl.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof z)){t=1;break}t+=hn(n,i)}tl.set(e,t)}return t}function Pr(n,e,t,i,s,r,o,l,a){let h=0;for(let p=i;p=c)break;T+=E}if(x==C+1){if(T>c){let E=p[C];d(E.children,E.positions,0,E.children.length,g[C]+k);continue}f.push(p[C])}else{let E=g[x-1]+p[x-1].length-M;f.push(Pr(n,p,g,C,x,M,E,null,a))}u.push(M+k-r)}}return d(e,t,i,s,0),(l||a)(f,u,o)}class jy{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let s=this.map.get(e);s||this.map.set(e,s=new Map),s.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof Ye?this.setBuffer(e.context.buffer,e.index,t):e instanceof Re&&this.map.set(e.tree,t)}get(e){return e instanceof Ye?this.getBuffer(e.context.buffer,e.index):e instanceof Re?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class st{constructor(e,t,i,s,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=s,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 s=[new st(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&s.push(r);return s}static applyChanges(e,t,i=128){if(!t.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l=i)for(;o&&o.from=u.from||f<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,f)-h;u=d>=p?null:new st(d,p,u.tree,u.offset+h,l>0,!!c)}if(u&&s.push(u),o.to>f)break;o=rnew Ee(s.from,s.to)):[new Ee(0,0)]:[new Ee(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let s=this.startParse(e,t,i);for(;;){let r=s.advance();if(r)return r}}}class Nd{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)}}function Ky(n){return(e,t,i,s)=>new Fd(e,n,t,i,s)}class il{constructor(e,t,i,s,r){this.parser=e,this.parse=t,this.overlay=i,this.target=s,this.ranges=r}}class Vd{constructor(e,t,i,s,r,o,l){this.parser=e,this.predicate=t,this.mounts=i,this.index=s,this.start=r,this.target=o,this.prev=l,this.depth=0,this.ranges=[]}}const tr=new R({perNode:!0});class Fd{constructor(e,t,i,s,r){this.nest=t,this.input=i,this.fragments=s,this.ranges=r,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let s of this.inner)s.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new z(i.type,i.children,i.positions,i.length,i.propValues.concat([[tr,this.stoppedAt]]))),i}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[R.mounted.id]=new Ld(t,e.overlay,e.parser),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;tc.frag.from<=s.from&&c.frag.to>=s.to&&c.mount.overlay);if(h)for(let c of h.mount.overlay){let f=c.from+h.pos,u=c.to+h.pos;f>=s.from&&u<=s.to&&!t.ranges.some(d=>d.fromf)&&t.ranges.push({from:f,to:u})}}l=!1}else if(i&&(o=Hd(i.ranges,s.from,s.to)))l=o!=2;else if(!s.type.isAnonymous&&s.fromnew Ee(f.from-s.from,f.to-s.from)):null,s.tree,c)),r.overlay?c.length&&(i={ranges:c,depth:0,prev:i}):l=!1}}else t&&(a=t.predicate(s))&&(a===!0&&(a=new Ee(s.from,s.to)),a.fromnew Ee(c.from-t.start,c.to-t.start)),t.target,h)),t=t.prev}i&&!--i.depth&&(i=i.prev)}}}}function Hd(n,e,t){for(let i of n){if(i.from>=t)break;if(i.to>e)return i.from<=e&&i.to>=t?2:1}return 0}function nl(n,e,t,i,s,r){if(e=e.to);i++);let o=s.children[i],l=o.buffer;function a(h,c,f,u,d){let p=h;for(;l[p+2]+r<=e.from;)p=l[p+3];let g=[],y=[];nl(o,h,p,g,y,u);let b=l[p+1],k=l[p+2],x=b+r==e.from&&k+r==e.to&&l[p]==e.type.id;return g.push(x?e.toTree():a(p+4,l[p+3],o.set.types[l[p]],b,k-b)),y.push(b-u),nl(o,l[p+3],c,g,y,u),new z(f,g,y,d)}s.children[i]=a(0,l.length,we.none,0,o.length);for(let h=0;h<=t;h++)n.childAfter(e.from)}class sl{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(J.IncludeAnonymous|J.IgnoreMounts)}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from=e&&t.enter(i,1,J.IgnoreOverlays|J.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof z)t=t.children[0];else break}return!1}}class zd{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let i=this.curFrag=e[0];this.curTo=(t=i.tree.prop(tr))!==null&&t!==void 0?t:i.to,this.inner=new sl(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(tr))!==null&&e!==void 0?e:t.to,this.inner=new sl(t.tree,-t.offset)}}findMounts(e,t){var i;let s=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let r=this.inner.cursor.node;r;r=r.parent){let o=(i=r.tree)===null||i===void 0?void 0:i.prop(R.mounted);if(o&&o.parser==t)for(let l=this.fragI;l=r.to)break;a.tree==this.curFrag.tree&&s.push({frag:a,pos:r.from-a.offset,mount:o})}}}return s}}function rl(n,e){let t=null,i=e;for(let s=1,r=0;s=l)break;a.to<=o||(t||(i=t=e.slice()),a.froml&&t.splice(r+1,0,new Ee(l,a.to))):a.to>l?t[r--]=new Ee(l,a.to):t.splice(r--,1))}}return i}function $d(n,e,t,i){let s=0,r=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let c=s==n.length?1e9:o?n[s].to:n[s].from,f=r==e.length?1e9:l?e[r].to:e[r].from;if(o!=l){let u=Math.max(a,t),d=Math.min(c,f,i);unew Ee(u.from+i,u.to+i)),f=$d(e,c,a,h);for(let u=0,d=a;;u++){let p=u==f.length,g=p?h:f[u].from;if(g>d&&t.push(new st(d,g,s.tree,-o,r.from>=d||r.openStart,r.to<=g||r.openEnd)),p)break;d=f[u].to}}else t.push(new st(a,h,s.tree,-o,r.from>=o||r.openStart,r.to<=l||r.openEnd))}return t}let qd=0;class Ue{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=qd++}static define(e){if(e?.base)throw new Error("Can not derive from a modified tag");let t=new Ue([],null,[]);if(t.set.push(t),e)for(let i of e.set)t.set.push(i);return t}static defineModifier(){let e=new Cn;return t=>t.modified.indexOf(e)>-1?t:Cn.get(t.base||t,t.modified.concat(e).sort((i,s)=>i.id-s.id))}}let jd=0;class Cn{constructor(){this.instances=[],this.id=jd++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&Kd(t,l.modified));if(i)return i;let s=[],r=new Ue(s,e,t);for(let l of t)l.instances.push(r);let o=Ud(t);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(Cn.get(l,a));return r}}function Kd(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function Ud(n){let e=[[]];for(let t=0;ti.length-t.length)}function Gd(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let s of t.split(" "))if(s){let r=[],o=2,l=s;for(let f=0;;){if(l=="..."&&f>0&&f+3==s.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+s);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==s.length)break;let d=s[f++];if(f==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(f)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+s);let c=new An(i,o,a>0?r.slice(0,a):null);e[h]=c.sort(e[h])}}return Sh.add(e)}const Sh=new R;class An{constructor(e,t,i,s){this.tags=e,this.mode=t,this.context=i,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=s;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 Jd(n,e){let t=null;for(let i of n){let s=i.style(e);s&&(t=t?t+" "+s:s)}return t}function Yd(n,e,t,i=0,s=n.length){let r=new Xd(i,Array.isArray(e)?e:[e],t);r.highlightRange(n.cursor(),i,s,"",r.highlighters),r.flush(s)}class Xd{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,s,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=s,c=Qd(e)||An.empty,f=Jd(r,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(s+=(s?" ":"")+f)),this.startSpan(e.from,h),c.opaque)return;let u=e.tree&&e.tree.prop(R.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(y=>!y.scope||y.scope(u.tree.type)),g=e.firstChild();for(let y=0,b=l;;y++){let k=y=x||!e.nextSibling())););if(!k||x>i)break;b=k.to+l,b>t&&(this.highlightRange(d.cursor(),Math.max(t,k.from+l),Math.min(i,b),s,p),this.startSpan(b,h))}g&&e.parent()}else if(e.firstChild()){do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,s,r),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}}function Qd(n){let e=n.type.prop(Sh);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const v=Ue.define,Ji=v(),ot=v(),ll=v(ot),al=v(ot),lt=v(),Yi=v(lt),rs=v(lt),je=v(),xt=v(je),$e=v(),qe=v(),ir=v(),li=v(ir),Xi=v(),m={comment:Ji,lineComment:v(Ji),blockComment:v(Ji),docComment:v(Ji),name:ot,variableName:v(ot),typeName:ll,tagName:v(ll),propertyName:al,attributeName:v(al),className:v(ot),labelName:v(ot),namespace:v(ot),macroName:v(ot),literal:lt,string:Yi,docString:v(Yi),character:v(Yi),attributeValue:v(Yi),number:rs,integer:v(rs),float:v(rs),bool:v(lt),regexp:v(lt),escape:v(lt),color:v(lt),url:v(lt),keyword:$e,self:v($e),null:v($e),atom:v($e),unit:v($e),modifier:v($e),operatorKeyword:v($e),controlKeyword:v($e),definitionKeyword:v($e),moduleKeyword:v($e),operator:qe,derefOperator:v(qe),arithmeticOperator:v(qe),logicOperator:v(qe),bitwiseOperator:v(qe),compareOperator:v(qe),updateOperator:v(qe),definitionOperator:v(qe),typeOperator:v(qe),controlOperator:v(qe),punctuation:ir,separator:v(ir),bracket:li,angleBracket:v(li),squareBracket:v(li),paren:v(li),brace:v(li),content:je,heading:xt,heading1:v(xt),heading2:v(xt),heading3:v(xt),heading4:v(xt),heading5:v(xt),heading6:v(xt),contentSeparator:v(je),list:v(je),quote:v(je),emphasis:v(je),strong:v(je),link:v(je),monospace:v(je),strikethrough:v(je),inserted:v(),deleted:v(),changed:v(),invalid:v(),meta:Xi,documentMeta:v(Xi),annotation:v(Xi),processingInstruction:v(Xi),definition:Ue.defineModifier(),constant:Ue.defineModifier(),function:Ue.defineModifier(),standard:Ue.defineModifier(),local:Ue.defineModifier(),special:Ue.defineModifier()};Ch([{tag:m.link,class:"tok-link"},{tag:m.heading,class:"tok-heading"},{tag:m.emphasis,class:"tok-emphasis"},{tag:m.strong,class:"tok-strong"},{tag:m.keyword,class:"tok-keyword"},{tag:m.atom,class:"tok-atom"},{tag:m.bool,class:"tok-bool"},{tag:m.url,class:"tok-url"},{tag:m.labelName,class:"tok-labelName"},{tag:m.inserted,class:"tok-inserted"},{tag:m.deleted,class:"tok-deleted"},{tag:m.literal,class:"tok-literal"},{tag:m.string,class:"tok-string"},{tag:m.number,class:"tok-number"},{tag:[m.regexp,m.escape,m.special(m.string)],class:"tok-string2"},{tag:m.variableName,class:"tok-variableName"},{tag:m.local(m.variableName),class:"tok-variableName tok-local"},{tag:m.definition(m.variableName),class:"tok-variableName tok-definition"},{tag:m.special(m.variableName),class:"tok-variableName2"},{tag:m.definition(m.propertyName),class:"tok-propertyName tok-definition"},{tag:m.typeName,class:"tok-typeName"},{tag:m.namespace,class:"tok-namespace"},{tag:m.className,class:"tok-className"},{tag:m.macroName,class:"tok-macroName"},{tag:m.propertyName,class:"tok-propertyName"},{tag:m.operator,class:"tok-operator"},{tag:m.comment,class:"tok-comment"},{tag:m.meta,class:"tok-meta"},{tag:m.invalid,class:"tok-invalid"},{tag:m.punctuation,class:"tok-punctuation"}]);var os;const At=new R;function Ah(n){return O.define({combine:n?e=>e.concat(n):void 0})}const Zd=new R;class Pe{constructor(e,t,i=[],s=""){this.data=e,this.name=s,I.prototype.hasOwnProperty("tree")||Object.defineProperty(I.prototype,"tree",{get(){return ce(this)}}),this.parser=t,this.extension=[yt.of(this),I.languageData.of((r,o,l)=>{let a=hl(r,o,l),h=a.type.prop(At);if(!h)return[];let c=r.facet(h),f=a.type.prop(Zd);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return hl(e,t,i).type.prop(At)==this.data}findRegions(e){let t=e.facet(yt);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop(At)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(R.mounted);if(l){if(l.tree.prop(At)==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(s(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;ai.isTop?t:void 0)]}),e.name)}configure(e,t){return new nr(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ce(n){let e=n.field(Pe.state,!1);return e?e.tree:z.empty}class ep{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=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let ai=null;class Zt{constructor(e,t,i=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Zt(e,t,[],z.empty,0,i,[],null)}startParse(){return this.parser.startParse(new ep(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=z.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=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(st.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=ai;ai=this;try{return e()}finally{ai=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=cl(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=st.applyChanges(i,a),s=z.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 c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);ce.from&&(this.fragments=cl(this.fragments,s,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 vh{createParse(t,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=ai;if(a){for(let h of s)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new z(we.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 ai}}function cl(n,e,t){return st.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class ei{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 ei(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Zt.create(e.facet(yt).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new ei(i)}}Pe.state=ke.define({create:ei.init,update(n,e){for(let t of e.effects)if(t.is(Pe.setState))return t.value;return e.startState.facet(yt)!=e.state.facet(yt)?ei.init(e.state):n.apply(e)}});let Mh=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Mh=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const ls=typeof navigator<"u"&&(!((os=navigator.scheduling)===null||os===void 0)&&os.isInputPending)?()=>navigator.scheduling.isInputPending():null,tp=pe.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(Pe.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Pe.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Mh(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnds+1e3,a=r.context.work(()=>ls&&ls()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Pe.setState.of(new ei(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=>He(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()}}}),yt=O.define({combine(n){return n.length?n[0]:null},enables:n=>[Pe.state,tp,B.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class Gy{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class Dh{constructor(e,t,i,s,r,o=void 0){this.name=e,this.alias=t,this.extensions=i,this.filename=s,this.loadFunc=r,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:i}=e;if(!t){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(i)}return new Dh(e.name,(e.alias||[]).concat(e.name).map(s=>s.toLowerCase()),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let s of e)if(s.filename&&s.filename.test(t))return s;let i=/\.([^.]+)$/.exec(t);if(i){for(let s of e)if(s.extensions.indexOf(i[1])>-1)return s}return null}static matchLanguageName(e,t,i=!0){t=t.toLowerCase();for(let s of e)if(s.alias.some(r=>r==t))return s;if(i)for(let s of e)for(let r of s.alias){let o=t.indexOf(r);if(o>-1&&(r.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+r.length])))return s}return null}}const Th=O.define(),_n=O.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Et(n){let e=n.facet(_n);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Ti(n,e){let t="",i=n.tabSize,s=n.facet(_n)[0];if(s==" "){for(;e>=i;)t+=" ",e-=i;s=" "}for(let r=0;r=i.from&&s<=i.to?r&&s==e?{text:"",from:e}:(t<0?s-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return Li(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const ip=new R;function np(n,e,t){return Oh(e.resolveInner(t).enterUnfinishedNodesBefore(t),t,n)}function sp(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function rp(n){let e=n.type.prop(ip);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(R.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>Bh(o,!0,1,void 0,r&&!sp(o)?s.from:void 0)}return n.parent==null?op:null}function Oh(n,e,t){for(;n;n=n.parent){let i=rp(n);if(i)return i(Rr.create(t,e,n))}return null}function op(){return 0}class Rr extends In{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.node=i}static create(e,t,i){return new Rr(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){let e=this.state.doc.lineAt(this.node.from);for(;;){let t=this.node.resolve(e.from);for(;t.parent&&t.parent.from==t.from;)t=t.parent;if(lp(t,this.node))break;e=this.state.doc.lineAt(t.from)}return this.lineIndent(e.from)}continue(){let e=this.node.parent;return e?Oh(e,this.pos,this.base):0}}function lp(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function ap(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped)return a.fromBh(i,e,t,n)}function Bh(n,e,t,i,s){let r=n.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||s==n.pos+o,a=e?ap(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}const Yy=n=>n.baseIndent;function Xy({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const hp=200;function cp(){return I.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,s=t.lineAt(i);if(i>s.from+hp)return n;let r=t.sliceString(s.from,i);if(!e.some(h=>h.test(r)))return n;let{state:o}=n,l=-1,a=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==l)continue;l=c.from;let f=Lr(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],d=Ti(o,f);u!=d&&a.push({from:c.from,to:c.from+u.length,insert:d})}return a.length?[n,{changes:a,sequential:!0}]:n})}const fp=O.define(),up=new R;function Qy(n){let e=n.firstChild,t=n.lastChild;return e&&e.tot)continue;if(r&&o.from=e&&a.to>t&&(r=a)}}return r}function pp(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function Mn(n,e,t){for(let i of n.facet(fp)){let s=i(n,e,t);if(s)return s}return dp(n,e,t)}function Eh(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const Nn=L.define({map:Eh}),_i=L.define({map:Eh});function Ph(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const Pt=ke.define({create(){return P.none},update(n,e){n=n.map(e.changes);for(let t of e.effects)t.is(Nn)&&!mp(n,t.value.from,t.value.to)?n=n.update({add:[fl.range(t.value.from,t.value.to)]}):t.is(_i)&&(n=n.update({filter:(i,s)=>t.value.from!=i||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:i}=e.selection.main;n.between(i,i,(s,r)=>{si&&(t=!0)}),t&&(n=n.update({filterFrom:i,filterTo:i,filter:(s,r)=>r<=i||s>=i}))}return n},provide:n=>B.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,s)=>{t.push(i,s)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{(!s||s.from>r)&&(s={from:r,to:o})}),s}function mp(n,e,t){let i=!1;return n.between(e,e,(s,r)=>{s==e&&r==t&&(i=!0)}),i}function Lh(n,e){return n.field(Pt,!1)?e:e.concat(L.appendConfig.of(_h()))}const gp=n=>{for(let e of Ph(n)){let t=Mn(n.state,e.from,e.to);if(t)return n.dispatch({effects:Lh(n.state,[Nn.of(t),Rh(n,t)])}),!0}return!1},yp=n=>{if(!n.state.field(Pt,!1))return!1;let e=[];for(let t of Ph(n)){let i=Dn(n.state,t.from,t.to);i&&e.push(_i.of(i),Rh(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function Rh(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,s=n.state.doc.lineAt(e.to).number;return B.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${s}.`)}const bp=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(Pt,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,s)=>{t.push(_i.of({from:i,to:s}))}),n.dispatch({effects:t}),!0},xp=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:gp},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:yp},{key:"Ctrl-Alt-[",run:bp},{key:"Ctrl-Alt-]",run:wp}],kp={placeholderDOM:null,placeholderText:"…"},vp=O.define({combine(n){return Vt(n,kp)}});function _h(n){return[Pt,Ap]}const fl=P.replace({widget:new class extends tt{toDOM(n){let{state:e}=n,t=e.facet(vp),i=r=>{let o=n.lineBlockAt(n.posAtDOM(r.target)),l=Dn(n.state,o.from,o.to);l&&n.dispatch({effects:_i.of(l)}),r.preventDefault()};if(t.placeholderDOM)return t.placeholderDOM(n,i);let s=document.createElement("span");return s.textContent=t.placeholderText,s.setAttribute("aria-label",e.phrase("folded code")),s.title=e.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}}}),Sp={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class as extends gt{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Cp(n={}){let e=Object.assign(Object.assign({},Sp),n),t=new as(e,!0),i=new as(e,!1),s=pe.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(yt)!=o.state.facet(yt)||o.startState.field(Pt,!1)!=o.state.field(Pt,!1)||ce(o.startState)!=ce(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new Ot;for(let a of o.viewportLineBlocks){let h=Dn(o.state,a.from,a.to)?i:Mn(o.state,a.from,a.to)?t:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:r}=e;return[s,Cd({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(s))===null||l===void 0?void 0:l.markers)||F.empty},initialSpacer(){return new as(e,!1)},domEventHandlers:Object.assign(Object.assign({},r),{click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let h=Dn(o.state,l.from,l.to);if(h)return o.dispatch({effects:_i.of(h)}),!0;let c=Mn(o.state,l.from,l.to);return c?(o.dispatch({effects:Nn.of(c)}),!0):!1}})}),_h()]}const Ap=B.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class ii{constructor(e,t){this.specs=e;let i;function s(l){let a=dt.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof Pe?l=>l.prop(At)==o.data:o?l=>l==o:void 0,this.style=Ch(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new dt(i):null,this.themeType=t.themeType}static define(e,t){return new ii(e,t||{})}}const sr=O.define(),Ih=O.define({combine(n){return n.length?[n[0]]:null}});function hs(n){let e=n.facet(sr);return e.length?e:n.facet(Ih)}function _r(n,e){let t=[Dp],i;return n instanceof ii&&(n.module&&t.push(B.styleModule.of(n.module)),i=n.themeType),e?.fallback?t.push(Ih.of(n)):i?t.push(sr.computeN([B.darkTheme],s=>s.facet(B.darkTheme)==(i=="dark")?[n]:[])):t.push(sr.of(n)),t}class Mp{constructor(e){this.markCache=Object.create(null),this.tree=ce(e.state),this.decorations=this.buildDeco(e,hs(e.state))}update(e){let t=ce(e.state),i=hs(e.state),s=i!=hs(e.startState);t.length{i.add(o,l,this.markCache[a]||(this.markCache[a]=P.mark({class:a})))},s,r);return i.finish()}}const Dp=Pi.high(pe.fromClass(Mp,{decorations:n=>n.decorations})),Tp=ii.define([{tag:m.meta,color:"#404740"},{tag:m.link,textDecoration:"underline"},{tag:m.heading,textDecoration:"underline",fontWeight:"bold"},{tag:m.emphasis,fontStyle:"italic"},{tag:m.strong,fontWeight:"bold"},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.keyword,color:"#708"},{tag:[m.atom,m.bool,m.url,m.contentSeparator,m.labelName],color:"#219"},{tag:[m.literal,m.inserted],color:"#164"},{tag:[m.string,m.deleted],color:"#a11"},{tag:[m.regexp,m.escape,m.special(m.string)],color:"#e40"},{tag:m.definition(m.variableName),color:"#00f"},{tag:m.local(m.variableName),color:"#30a"},{tag:[m.typeName,m.namespace],color:"#085"},{tag:m.className,color:"#167"},{tag:[m.special(m.variableName),m.macroName],color:"#256"},{tag:m.definition(m.propertyName),color:"#00c"},{tag:m.comment,color:"#940"},{tag:m.invalid,color:"#f00"}]),Op=1e4,Bp="()[]{}",Ep=new R;function rr(n,e,t){let i=n.prop(e<0?R.openedBy:R.closedBy);if(i)return i;if(n.name.length==1){let s=t.indexOf(n.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function or(n){let e=n.type.prop(Ep);return e?e(n.node):n}function $t(n,e,t,i={}){let s=i.maxScanDistance||Op,r=i.brackets||Bp,o=ce(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=rr(a.type,t,r);if(h&&a.from0?e>=c.from&&ec.from&&e<=c.to))return Pp(n,e,t,a,c,h,r)}}return Lp(n,e,t,o,l.type,s,r)}function Pp(n,e,t,i,s,r,o){let l=i.parent,a={from:s.from,to:s.to},h=0,c=l?.cursor();if(c&&(t<0?c.childBefore(i.from):c.childAfter(i.to)))do if(t<0?c.to<=i.from:c.from>=i.to){if(h==0&&r.indexOf(c.type.name)>-1&&c.from0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=r;){let d=c.value;t<0&&(u+=d.length);let p=e+u*t;for(let g=t>0?0:d.length-1,y=t>0?d.length:-1;g!=y;g+=t){let b=o.indexOf(d[g]);if(!(b<0||i.resolveInner(p+g,1).type!=s))if(b%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:p+g,to:p+g+1},matched:b>>1==a>>1};f--}}t>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}function ul(n,e,t,i=0,s=0){e==null&&(e=n.search(/[^\s\u00a0]/),e==-1&&(e=n.length));let r=s;for(let o=i;o=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.post}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPosi?o.toLowerCase():o,r=this.string.substr(this.pos,e.length);return s(r)==s(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let s=this.string.slice(this.pos).match(e);return s&&s.index>0?null:(s&&t!==!1&&(this.pos+=s[0].length),s)}}current(){return this.string.slice(this.start,this.pos)}}function Rp(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||_p,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||Nr}}function _p(n){if(typeof n!="object")return n;let e={};for(let t in n){let i=n[t];e[t]=i instanceof Array?i.slice():i}return e}const dl=new WeakMap;class Ve extends Pe{constructor(e){let t=Ah(e.languageData),i=Rp(e),s,r=new class extends vh{createParse(o,l,a){return new Np(s,o,l,a)}};super(t,r,[Th.of((o,l)=>this.getIndent(o,l))],e.name),this.topNode=Hp(t),s=this,this.streamParser=i,this.stateAfter=new R({perNode:!0}),this.tokenTable=e.tokenTable?new Wh(i.tokenTable):Fp}static define(e){return new Ve(e)}getIndent(e,t){let i=ce(e.state),s=i.resolve(t);for(;s&&s.type!=this.topNode;)s=s.parent;if(!s)return null;let r,{overrideIndentation:o}=e.options;o&&(r=dl.get(e.state),r!=null&&r1e4)return null;for(;a=i&&t+e.length<=s&&e.prop(n.stateAfter);if(r)return{state:n.streamParser.copyState(r),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let l=e.children[o],a=t+e.positions[o],h=l instanceof z&&a=e.length)return e;!s&&e.type==n.topNode&&(s=!0);for(let r=e.children.length-1;r>=0;r--){let o=e.positions[r],l=e.children[r],a;if(ot&&Ir(n,s.tree,0-s.offset,t,o),a;if(l&&(a=Vh(n,s.tree,t+s.offset,l.pos+s.offset,!1)))return{state:l.state,tree:a}}return{state:n.streamParser.startState(i?Et(i):4),tree:z.empty}}class Np{constructor(e,t,i,s){this.lang=e,this.input=t,this.fragments=i,this.ranges=s,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=s[s.length-1].to;let r=Zt.get(),o=s[0].from,{state:l,tree:a}=Ip(e,i,o,r?.state);this.state=l,this.parsedPos=this.chunkStart=o+a.length;for(let h=0;h=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==` `&&(t="");else{let i=t.indexOf(` `);i>-1&&(t=t.slice(0,i))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),i=e+t.length;for(let s=this.rangeIndex;;){let r=this.ranges[s].to;if(r>=i||(t=t.slice(0,r-(i-t.length)),s++,s==this.ranges.length))break;let o=this.ranges[s].from,l=this.lineAfter(o);t+=l,i=o+l.length}return{line:t,end:i}}skipGapsTo(e,t,i){for(;;){let s=this.ranges[this.rangeIndex].to,r=e+t;if(i>0?s>r:s>=r)break;let o=this.ranges[++this.rangeIndex].from;t+=o-s}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to1){r=this.skipGapsTo(t,r,1),t+=r;let o=this.chunk.length;r=this.skipGapsTo(i,r,-1),i+=r,s+=this.chunk.length-o}return this.chunk.push(e,t,i,s),r}parseLine(e){let{line:t,end:i}=this.nextLine(),s=0,{streamParser:r}=this.lang,o=new Nh(t,e?e.state.tabSize:4,e?Et(e.state):2);if(o.eol())r.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=Fh(r.token,o,this.state);if(l&&(s=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,4,s)),o.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPose.start)return s}throw new Error("Stream parser failed to advance stream.")}const Nr=Object.create(null),Oi=[we.none],Vp=new Or(Oi),pl=[],Hh=Object.create(null);for(let[n,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"]])Hh[n]=zh(Nr,e);class Wh{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Hh)}resolve(e){return e?this.table[e]||(this.table[e]=zh(this.extra,e)):0}}const Fp=new Wh(Nr);function cs(n,e){pl.indexOf(n)>-1||(pl.push(n),console.warn(e))}function zh(n,e){let t=null;for(let r of e.split(".")){let o=n[r]||m[r];o?typeof o=="function"?t?t=o(t):cs(r,`Modifier ${r} used at start of tag`):t?cs(r,`Tag ${r} used as modifier`):t=o:cs(r,`Unknown highlighting tag ${r}`)}if(!t)return 0;let i=e.replace(/ /g,"_"),s=we.define({id:Oi.length,name:i,props:[Gd({[i]:t})]});return Oi.push(s),s.id}function Hp(n){let e=we.define({id:Oi.length,name:"Document",props:[At.add(()=>n)]});return Oi.push(e),e}const Wp=n=>{let e=Fr(n.state);return e.line?zp(n):e.block?qp(n):!1};function Vr(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=n(e,t);return s?(i(t.update(s)),!0):!1}}const zp=Vr(Up,0),$p=Vr($h,0),qp=Vr((n,e)=>$h(n,e,Kp(e)),0);function Fr(n,e=n.selection.main.head){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}const hi=50;function jp(n,{open:e,close:t},i,s){let r=n.sliceDoc(i-hi,i),o=n.sliceDoc(s,s+hi),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:s+a,margin:a&&1}};let c,f;s-i<=2*hi?c=f=n.sliceDoc(i,s):(c=n.sliceDoc(i,i+hi),f=n.sliceDoc(s-hi,s));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return c.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function Kp(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),s=t.to<=i.to?i:n.doc.lineAt(t.to),r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=s.to:e.push({from:i.from,to:s.to})}return e}function $h(n,e,t=e.selection.ranges){let i=t.map(r=>Fr(e,r.from).block);if(!i.every(r=>r))return null;let s=t.map((r,o)=>jp(e,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,l;os&&(r==o||o>c.from)){s=c.from;let f=Fr(e,h).line;if(!f)continue;let u=/^\s*/.exec(c.text)[0].length,d=u==c.length,p=c.text.slice(u,u+f.length)==f?u:-1;ur.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&r.push({from:l.from+h,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=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,c=h+a.length;o.text[c-o.from]==" "&&c++,r.push({from:h,to:c})}return{changes:r}}return null}const lr=Nt.define(),Gp=Nt.define(),Jp=O.define(),qh=O.define({combine(n){return Vt(n,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})}});function Yp(n){let e=0;return n.iterChangedRanges((t,i)=>e=i),e}const jh=ke.define({create(){return Xe.empty},update(n,e){let t=e.state.facet(qh),i=e.annotation(lr);if(i){let a=e.docChanged?w.single(Yp(e.changes)):void 0,h=xe.fromTransaction(e,a),c=i.side,f=c==0?n.undone:n.done;return h?f=Tn(f,f.length,t.minDepth,h):f=Gh(f,e.startState.selection),new Xe(c==0?i.rest:f,c==0?f:i.rest)}let s=e.annotation(Gp);if((s=="full"||s=="before")&&(n=n.isolate()),e.annotation(Z.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=xe.fromTransaction(e),o=e.annotation(Z.time),l=e.annotation(Z.userEvent);return r?n=n.addChanges(r,o,l,t.newGroupDelay,t.minDepth):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new Xe(n.done.map(xe.fromJSON),n.undone.map(xe.fromJSON))}});function Xp(n={}){return[jh,qh.of(n),B.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Kh:e.inputType=="historyRedo"?ar:null;return i?(e.preventDefault(),i(t)):!1}})]}function Vn(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(jh,!1);if(!s)return!1;let r=s.pop(n,t,e);return r?(i(r),!0):!1}}const Kh=Vn(0,!1),ar=Vn(1,!1),Qp=Vn(0,!0),Zp=Vn(1,!0);class xe{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new xe(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new xe(e.changes&&Q.fromJSON(e.changes),[],e.mapped&&Qe.fromJSON(e.mapped),e.startSelection&&w.fromJSON(e.startSelection),e.selectionsAfter.map(w.fromJSON))}static fromTransaction(e,t){let i=Le;for(let s of e.startState.facet(Jp)){let r=s(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new xe(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Le)}static selection(e){return new xe(void 0,Le,void 0,void 0,e)}}function Tn(n,e,t,i){let s=e+1>t+20?e-t-1:0,r=n.slice(s,e);return r.push(i),r}function em(n,e){let t=[],i=!1;return n.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a=h&&o<=c&&(i=!0)}}),i}function tm(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Uh(n,e){return n.length?e.length?n.concat(e):n:e}const Le=[],im=200;function Gh(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-im));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Tn(n,n.length-1,1e9,t.setSelAfter(i)))}else return[xe.selection([e])]}function nm(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function fs(n,e){if(!n.length)return n;let t=n.length,i=Le;for(;t;){let s=sm(n[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[xe.selection(i)]:Le}function sm(n,e,t){let i=Uh(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):Le,t);if(!n.changes)return xe.selection(i);let s=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new xe(s,L.mapEffects(n.effects,e),o,n.startSelection.map(r),i)}const rm=/^(input\.type|delete)($|\.)/;class Xe{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new Xe(this.done,this.undone):this}addChanges(e,t,i,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||rm.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):Fn(t,e))}function me(n){return n.textDirectionAt(n.state.selection.main.head)==U.LTR}const Yh=n=>Jh(n,!me(n)),Xh=n=>Jh(n,me(n));function Qh(n,e){return We(n,t=>t.empty?n.moveByGroup(t,e):Fn(t,e))}const lm=n=>Qh(n,!me(n)),am=n=>Qh(n,me(n));function hm(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Hn(n,e,t){let i=ce(n).resolveInner(e.head),s=t?R.closedBy:R.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;hm(n,h,s)?i=h:a=t?h.to:h.from}let r=i.type.prop(s),o,l;return r&&(o=t?$t(n,i.from,1):$t(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,w.cursor(l,t?-1:1)}const cm=n=>We(n,e=>Hn(n.state,e,!me(n))),fm=n=>We(n,e=>Hn(n.state,e,me(n)));function Zh(n,e){return We(n,t=>{if(!t.empty)return Fn(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const ec=n=>Zh(n,!1),tc=n=>Zh(n,!0);function ic(n){return Math.max(n.defaultLineHeight,Math.min(n.dom.clientHeight,innerHeight)-5)}function nc(n,e){let{state:t}=n,i=ni(t.selection,l=>l.empty?n.moveVertically(l,e,ic(n)):Fn(l,e));if(i.eq(t.selection))return!1;let s=n.coordsAtPos(t.selection.main.head),r=n.scrollDOM.getBoundingClientRect(),o;return s&&s.top>r.top&&s.bottomnc(n,!1),hr=n=>nc(n,!0);function bt(n,e,t){let i=n.lineBlockAt(e.head),s=n.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=n.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(s=w.cursor(i.from+r))}return s}const um=n=>We(n,e=>bt(n,e,!0)),dm=n=>We(n,e=>bt(n,e,!1)),pm=n=>We(n,e=>bt(n,e,!me(n))),mm=n=>We(n,e=>bt(n,e,me(n))),gm=n=>We(n,e=>w.cursor(n.lineBlockAt(e.head).from,1)),ym=n=>We(n,e=>w.cursor(n.lineBlockAt(e.head).to,-1));function bm(n,e,t){let i=!1,s=ni(n.selection,r=>{let o=$t(n,r.head,-1)||$t(n,r.head,1)||r.head>0&&$t(n,r.head-1,1)||r.headbm(n,e);function _e(n,e){let t=ni(n.state.selection,i=>{let s=e(i);return w.range(i.anchor,s.head,s.goalColumn)});return t.eq(n.state.selection)?!1:(n.dispatch(it(n.state,t)),!0)}function sc(n,e){return _e(n,t=>n.moveByChar(t,e))}const rc=n=>sc(n,!me(n)),oc=n=>sc(n,me(n));function lc(n,e){return _e(n,t=>n.moveByGroup(t,e))}const xm=n=>lc(n,!me(n)),km=n=>lc(n,me(n)),vm=n=>_e(n,e=>Hn(n.state,e,!me(n))),Sm=n=>_e(n,e=>Hn(n.state,e,me(n)));function ac(n,e){return _e(n,t=>n.moveVertically(t,e))}const hc=n=>ac(n,!1),cc=n=>ac(n,!0);function fc(n,e){return _e(n,t=>n.moveVertically(t,e,ic(n)))}const gl=n=>fc(n,!1),yl=n=>fc(n,!0),Cm=n=>_e(n,e=>bt(n,e,!0)),Am=n=>_e(n,e=>bt(n,e,!1)),Mm=n=>_e(n,e=>bt(n,e,!me(n))),Dm=n=>_e(n,e=>bt(n,e,me(n))),Tm=n=>_e(n,e=>w.cursor(n.lineBlockAt(e.head).from)),Om=n=>_e(n,e=>w.cursor(n.lineBlockAt(e.head).to)),bl=({state:n,dispatch:e})=>(e(it(n,{anchor:0})),!0),wl=({state:n,dispatch:e})=>(e(it(n,{anchor:n.doc.length})),!0),xl=({state:n,dispatch:e})=>(e(it(n,{anchor:n.selection.main.anchor,head:0})),!0),kl=({state:n,dispatch:e})=>(e(it(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Bm=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Em=({state:n,dispatch:e})=>{let t=zn(n).map(({from:i,to:s})=>w.range(i,Math.min(s+1,n.doc.length)));return e(n.update({selection:w.create(t),userEvent:"select"})),!0},Pm=({state:n,dispatch:e})=>{let t=ni(n.selection,i=>{var s;let r=ce(n).resolveInner(i.head,1);for(;!(r.from=i.to||r.to>i.to&&r.from<=i.from||!(!((s=r.parent)===null||s===void 0)&&s.parent));)r=r.parent;return w.range(r.to,r.from)});return e(it(n,t)),!0},Lm=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=w.create([t.main]):t.main.empty||(i=w.create([w.cursor(t.main.head)])),i?(e(it(n,i)),!0):!1};function Wn(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(o);ao&&(t="delete.forward",a=Qi(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Qi(n,o,!1),l=Qi(n,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:w.cursor(o)}});return s.changes.empty?!1:(n.dispatch(i.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?B.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Qi(n,e,t){if(n instanceof B)for(let i of n.state.facet(B.atomicRanges).map(s=>s(n)))i.between(e,e,(s,r)=>{se&&(e=t?r:s)});return e}const uc=(n,e)=>Wn(n,t=>{let{state:i}=n,s=i.doc.lineAt(t),r,o;if(!e&&t>s.from&&tuc(n,!1),dc=n=>uc(n,!0),pc=(n,e)=>Wn(n,t=>{let i=t,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t&&r.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let a=Me(r.text,i-r.from,e)+r.from,h=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t)&&(l=c),i=a}return i}),mc=n=>pc(n,!1),Rm=n=>pc(n,!0),gc=n=>Wn(n,e=>{let t=n.lineBlockAt(e).to;return eWn(n,e=>{let t=n.lineBlockAt(e).from;return e>t?t:Math.max(0,e-1)}),Im=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:N.of(["",""])},range:w.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Nm=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:Me(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:Me(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:n.doc.slice(s,l).append(n.doc.slice(o,s))},range:w.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function zn(n){let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:s.from,to:r.to,ranges:[i]});t=r.number+1}return e}function yc(n,e,t){if(n.readOnly)return!1;let i=[],s=[];for(let r of zn(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.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+n.lineBreak});for(let a of r.ranges)s.push(w.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let a of r.ranges)s.push(w.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:w.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Vm=({state:n,dispatch:e})=>yc(n,e,!1),Fm=({state:n,dispatch:e})=>yc(n,e,!0);function bc(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of zn(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Hm=({state:n,dispatch:e})=>bc(n,e,!1),Wm=({state:n,dispatch:e})=>bc(n,e,!0),zm=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(zn(e).map(({from:s,to:r})=>(s>0?s--:rn.moveVertically(s,!0)).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function $m(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=ce(n).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),r;return i&&s&&i.to<=e&&s.from>=e&&(r=i.type.prop(R.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from?{from:i.to,to:s.from}:null}const qm=wc(!1),jm=wc(!0);function wc(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!n&&r==o&&$m(e,r);n&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new In(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=Lr(h,r);for(c==null&&(c=/^\s*/.exec(e.doc.lineAt(r).text)[0].length);ol.from&&r{let s=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,s,i),t=l.number),o=l.to+1}let r=n.changes(s);return{changes:s,range:w.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const Km=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new In(n,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=Hr(n,(r,o,l)=>{let a=Lr(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],c=Ti(n,a);(h!=c||l.fromn.readOnly?!1:(e(n.update(Hr(n,(t,i)=>{i.push({from:t.from,insert:n.facet(_n)})}),{userEvent:"input.indent"})),!0),kc=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Hr(n,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=Li(s,n.tabSize),o=0,l=Ti(n,Math.max(0,r-Et(n)));for(;o({mac:n.key,run:n.run,shift:n.shift}))),Jm=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:cm,shift:vm},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:fm,shift:Sm},{key:"Alt-ArrowUp",run:Vm},{key:"Shift-Alt-ArrowUp",run:Hm},{key:"Alt-ArrowDown",run:Fm},{key:"Shift-Alt-ArrowDown",run:Wm},{key:"Escape",run:Lm},{key:"Mod-Enter",run:jm},{key:"Alt-l",mac:"Ctrl-l",run:Em},{key:"Mod-i",run:Pm,preventDefault:!0},{key:"Mod-[",run:kc},{key:"Mod-]",run:xc},{key:"Mod-Alt-\\",run:Km},{key:"Shift-Mod-k",run:zm},{key:"Shift-Mod-\\",run:wm},{key:"Mod-/",run:Wp},{key:"Alt-A",run:$p}].concat(Gm),Ym={key:"Tab",run:xc,shift:kc},Xm="#2E3235",Ke="#DDDDDD",wi="#B9D2FF",Zi="#b0b0b0",Qm="#e0e0e0",vc="#808080",us="#000000",Zm="#A54543",Sc="#fc6d24",kt="#fda331",ds="#8abeb7",vl="#b5bd68",ci="#6fb3d2",fi="#cc99cc",eg="#6987AF",Sl=Sc,Cl="#292d30",en=wi+"30",tg=Xm,ps=Ke,ig="#202325",Al=Ke,ng=B.theme({"&":{color:Ke,backgroundColor:tg},".cm-content":{caretColor:Al},".cm-cursor, .cm-dropCursor":{borderLeftColor:Al},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ig},".cm-panels":{backgroundColor:Cl,color:Zi},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:wi,outline:`1px solid ${Zi}`,color:us},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:Qm,color:us},".cm-activeLine":{backgroundColor:en},".cm-selectionMatch":{backgroundColor:en},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${Zi}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:wi,color:us},".cm-gutters":{borderRight:"1px solid #ffffff10",color:vc,backgroundColor:Cl},".cm-activeLineGutter":{backgroundColor:en},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:wi},".cm-tooltip":{border:"none",backgroundColor:ps},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:ps,borderBottomColor:ps},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:en,color:Zi}}},{dark:!0}),sg=ii.define([{tag:m.keyword,color:kt},{tag:[m.name,m.deleted,m.character,m.propertyName,m.macroName],color:vl},{tag:[m.variableName],color:ci},{tag:[m.function(m.variableName)],color:kt},{tag:[m.labelName],color:Sc},{tag:[m.color,m.constant(m.name),m.standard(m.name)],color:kt},{tag:[m.definition(m.name),m.separator],color:fi},{tag:[m.brace],color:fi},{tag:[m.annotation],color:Sl},{tag:[m.number,m.changed,m.annotation,m.modifier,m.self,m.namespace],color:kt},{tag:[m.typeName,m.className],color:ci},{tag:[m.operator,m.operatorKeyword],color:fi},{tag:[m.tagName],color:kt},{tag:[m.squareBracket],color:fi},{tag:[m.angleBracket],color:fi},{tag:[m.attributeName],color:ci},{tag:[m.regexp],color:kt},{tag:[m.quote],color:Ke},{tag:[m.string],color:vl},{tag:m.link,color:eg,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[m.url,m.escape,m.special(m.string)],color:ds},{tag:[m.meta],color:Zm},{tag:[m.comment],color:vc,fontStyle:"italic"},{tag:m.monospace,color:Ke},{tag:m.strong,fontWeight:"bold",color:kt},{tag:m.emphasis,fontStyle:"italic",color:ci},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.heading,fontWeight:"bold",color:Ke},{tag:m.special(m.heading1),fontWeight:"bold",color:Ke},{tag:m.heading1,fontWeight:"bold",color:Ke},{tag:[m.heading2,m.heading3,m.heading4],fontWeight:"bold",color:Ke},{tag:[m.heading5,m.heading6],color:Ke},{tag:[m.atom,m.bool,m.special(m.variableName)],color:ds},{tag:[m.processingInstruction,m.inserted],color:ds},{tag:[m.contentSeparator],color:ci},{tag:m.invalid,color:wi,borderBottom:`1px dotted ${Sl}`}]),rg=[ng,_r(sg)],Ml="#2e3440",Wr="#3b4252",Dl="#434c5e",tn="#4c566a",Tl="#e5e9f0",fr="#eceff4",ms="#8fbcbb",Ol="#88c0d0",og="#81a1c1",Ne="#5e81ac",lg="#bf616a",Wt="#d08770",gs="#ebcb8b",Bl="#a3be8c",ag="#b48ead",El="#d30102",zr=fr,ys=zr,hg="#ffffff",bs=Wr,cg=zr,Pl=Wr,fg=B.theme({"&":{color:Ml,backgroundColor:hg},".cm-content":{caretColor:Pl},".cm-cursor, .cm-dropCursor":{borderLeftColor:Pl},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:cg},".cm-panels":{backgroundColor:zr,color:tn},".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 ${tn}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:Tl},".cm-activeLine":{backgroundColor:ys},".cm-selectionMatch":{backgroundColor:Tl},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${tn}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:fr},".cm-gutters":{backgroundColor:fr,color:Ml,border:"none"},".cm-activeLineGutter":{backgroundColor:ys},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:bs},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:bs,borderBottomColor:bs},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:ys,color:tn}}},{dark:!1}),ug=ii.define([{tag:m.keyword,color:Ne},{tag:[m.name,m.deleted,m.character,m.propertyName,m.macroName],color:Wt},{tag:[m.variableName],color:Wt},{tag:[m.function(m.variableName)],color:Ne},{tag:[m.labelName],color:og},{tag:[m.color,m.constant(m.name),m.standard(m.name)],color:Ne},{tag:[m.definition(m.name),m.separator],color:Bl},{tag:[m.brace],color:ms},{tag:[m.annotation],color:El},{tag:[m.number,m.changed,m.annotation,m.modifier,m.self,m.namespace],color:Ol},{tag:[m.typeName,m.className],color:gs},{tag:[m.operator,m.operatorKeyword],color:Bl},{tag:[m.tagName],color:ag},{tag:[m.squareBracket],color:lg},{tag:[m.angleBracket],color:Wt},{tag:[m.attributeName],color:gs},{tag:[m.regexp],color:Ne},{tag:[m.quote],color:Wr},{tag:[m.string],color:Wt},{tag:m.link,color:ms,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[m.url,m.escape,m.special(m.string)],color:Wt},{tag:[m.meta],color:Ol},{tag:[m.comment],color:Dl,fontStyle:"italic"},{tag:m.strong,fontWeight:"bold",color:Ne},{tag:m.emphasis,fontStyle:"italic",color:Ne},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.heading,fontWeight:"bold",color:Ne},{tag:m.special(m.heading1),fontWeight:"bold",color:Ne},{tag:m.heading1,fontWeight:"bold",color:Ne},{tag:[m.heading2,m.heading3,m.heading4],fontWeight:"bold",color:Ne},{tag:[m.heading5,m.heading6],color:Ne},{tag:[m.atom,m.bool,m.special(m.variableName)],color:Wt},{tag:[m.processingInstruction,m.inserted],color:ms},{tag:[m.contentSeparator],color:gs},{tag:m.invalid,color:Dl,borderBottom:`1px dotted ${El}`}]),dg=[fg,_r(ug)];function Ll(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function pg(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;rtypeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:pg(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function Zy(n,e){return t=>{for(let i=ce(t.state).resolveInner(t.pos,-1);i;i=i.parent)if(n.indexOf(i.name)>-1)return null;return e(t)}}class Rl{constructor(e,t,i){this.completion=e,this.source=t,this.match=i}}function ur(n){return n.selection.main.head}function gg(n,e,t,i){return Object.assign(Object.assign({},n.changeByRange(s=>{if(s==n.selection.main)return{changes:{from:t,to:i,insert:e},range:w.cursor(t+e.length)};let r=i-t;return!s.empty||r&&n.sliceDoc(s.from-r,s.from)!=n.sliceDoc(t,i)?{range:s}:{changes:{from:s.from-r,to:s.from,insert:e},range:w.cursor(s.from-r+e.length)}})),{userEvent:"input.complete"})}function Cc(n,e){const t=e.completion.apply||e.completion.label;let i=e.source;typeof t=="string"?n.dispatch(gg(n.state,t,i.from,i.to)):t(n,e.completion,i.from,i.to)}const _l=new WeakMap;function yg(n){if(!Array.isArray(n))return n;let e=_l.get(n);return e||_l.set(n,e=mg(n)),e}class bg{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[];for(let t=0;t=48&&M<=57||M>=97&&M<=122?2:M>=65&&M<=90?1:0:(T=ra(M))!=T.toLowerCase()?1:T!=T.toUpperCase()?2:0;(!k||E==1&&y||C==0&&E!=0)&&(t[f]==M||i[f]==M&&(u=!0)?o[f++]=k:o.length&&(b=!1)),C=E,k+=Te(M)}return f==a&&o[0]==0&&b?this.result(-100+(u?-200:0),o,e):d==a&&p==0?[-200-e.length,0,g]:l>-1?[-700-e.length,l,l+this.pattern.length]:d==a?[-900-e.length,p,g]:f==a?this.result(-100+(u?-200:0)+-700+(b?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[e-i.length],r=1;for(let o of t){let l=o+(this.astral?Te(ue(i,o)):1);r>1&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return s}}const Lt=O.define({combine(n){return Vt(n,{activateOnTyping:!0,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,optionClass:(e,t)=>i=>wg(e(i),t(i)),addToOptions:(e,t)=>e.concat(t)})}});function wg(n,e){return n?e?n+" "+e:n:e}function xg(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s){let r=document.createElement("span");r.className="cm-completionLabel";let{label:o}=t,l=0;for(let a=1;al&&r.appendChild(document.createTextNode(o.slice(l,h)));let f=r.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(o.slice(h,c))),f.className="cm-completionMatchedText",l=c}return lt.position-i.position).map(t=>t.render)}function Il(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}class kg{constructor(e,t){this.view=e,this.stateField=t,this.info=null,this.placeInfo={read:()=>this.measureInfo(),write:l=>this.positionInfo(l),key:this};let i=e.state.field(t),{options:s,selected:r}=i.open,o=e.state.facet(Lt);this.optionContent=xg(o),this.optionClass=o.optionClass,this.range=Il(s.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.dom.addEventListener("mousedown",l=>{for(let a=l.target,h;a&&a!=this.dom;a=a.parentNode)if(a.nodeName=="LI"&&(h=/-(\d+)$/.exec(a.id))&&+h[1]{this.info&&this.view.requestMeasure(this.placeInfo)})}mount(){this.updateSel()}update(e){e.state.field(this.stateField)!=e.startState.field(this.stateField)&&this.updateSel()}positioned(){this.info&&this.view.requestMeasure(this.placeInfo)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected=this.range.to)&&(this.range=Il(t.options.length,t.selected,this.view.state.facet(Lt).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t.options,e.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfo)})),this.updateSelectedOption(t.selected)){this.info&&(this.info.remove(),this.info=null);let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let r=typeof s=="string"?document.createTextNode(s):s(i);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o)}).catch(o=>He(this.view.state,o,"completion info")):this.addInfoPane(r)}}addInfoPane(e){let t=this.info=document.createElement("div");t.className="cm-tooltip cm-completionInfo",t.appendChild(e),this.dom.appendChild(t),this.view.requestMeasure(this.placeInfo)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&Sg(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.ownerDocument.defaultView||window,i=this.dom.getBoundingClientRect(),s=this.info.getBoundingClientRect(),r=e.getBoundingClientRect();if(r.top>Math.min(t.innerHeight,i.bottom)-10||r.bottom=s.height||p>i.top?c=r.bottom-i.top+"px":f=i.bottom-r.top+"px"}return{top:c,bottom:f,maxWidth:h,class:a?o?"left-narrow":"right-narrow":l?"left":"right"}}positionInfo(e){this.info&&(e?(this.info.style.top=e.top,this.info.style.bottom=e.bottom,this.info.style.maxWidth=e.maxWidth,this.info.className="cm-tooltip cm-completionInfo cm-completionInfo-"+e.class):this.info.style.top="-1e6px")}createListBox(e,t,i){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions"));for(let r=i.from;rnew kg(e,n)}function Sg(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect();i.topt.bottom&&(n.scrollTop+=i.bottom-t.bottom)}function Nl(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function Cg(n,e){let t=[],i=0;for(let l of n)if(l.hasResult())if(l.result.filter===!1){let a=l.result.getMatch;for(let h of l.result.options){let c=[1e9-i++];if(a)for(let f of a(h))c.push(f);t.push(new Rl(h,l,c))}}else{let a=new bg(e.sliceDoc(l.from,l.to)),h;for(let c of l.result.options)(h=a.match(c.label))&&(c.boost!=null&&(h[0]+=c.boost),t.push(new Rl(c,l,h)))}let s=[],r=null,o=e.facet(Lt).compareCompletions;for(let l of t.sort((a,h)=>h.match[0]-a.match[0]||o(a.completion,h.completion)))!r||r.label!=l.completion.label||r.detail!=l.completion.detail||r.type!=null&&l.completion.type!=null&&r.type!=l.completion.type||r.apply!=l.completion.apply?s.push(l):Nl(l.completion)>Nl(r)&&(s[s.length-1]=l),r=l.completion;return s}class xi{constructor(e,t,i,s,r){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new xi(this.options,Vl(t,e),this.tooltip,this.timestamp,e)}static build(e,t,i,s,r){let o=Cg(e,t);if(!o.length)return null;let l=t.facet(Lt).selectOnOpen?0:-1;if(s&&s.selected!=l&&s.selected!=-1){let a=s.options[s.selected].completion;for(let h=0;hh.hasResult()?Math.min(a,h.from):a,1e8),create:vg(Ii),above:r.aboveCursor},s?s.timestamp:Date.now(),l)}map(e){return new xi(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected)}}class On{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new On(Dg,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Lt),r=(i.override||t.languageDataAt("autocomplete",ur(t)).map(yg)).map(l=>(this.active.find(h=>h.source==l)||new nt(l,this.active.some(h=>h.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((l,a)=>l==this.active[a])&&(r=this.active);let o=e.selection||r.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!Ag(r,this.active)?xi.build(r,t,this.id,this.open,i):this.open&&e.docChanged?this.open.map(e.changes):this.open;!o&&r.every(l=>l.state!=1)&&r.some(l=>l.hasResult())&&(r=r.map(l=>l.hasResult()?new nt(l.source,0):l));for(let l of e.effects)l.is(Dc)&&(o=o&&o.setSelected(l.value,this.id));return r==this.active&&o==this.open?this:new On(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:Mg}}function Ag(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}const Dg=[];function Tg(n){return n.isUserEvent("input.type")?"input":n.isUserEvent("delete.backward")?"delete":null}class nt{constructor(e,t,i=-1){this.source=e,this.state=t,this.explicitPos=i}hasResult(){return!1}update(e,t){let i=Tg(e),s=this;i?s=s.handleUserEvent(e,i,t):e.docChanged?s=s.handleChange(e):e.selection&&s.state!=0&&(s=new nt(s.source,0));for(let r of e.effects)if(r.is(Ac))s=new nt(s.source,1,r.value?ur(e.state):-1);else if(r.is(Mc))s=new nt(s.source,0);else if(r.is(Og))for(let o of r.value)o.source==s.source&&(s=o);return s}handleUserEvent(e,t,i){return t=="delete"||!i.activateOnTyping?this.map(e.changes):new nt(this.source,1)}handleChange(e){return e.changes.touchesRange(ur(e.startState))?new nt(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new nt(this.source,this.state,e.mapPos(this.explicitPos))}}const Ac=L.define(),Mc=L.define(),Og=L.define({map(n,e){return n.map(t=>t.map(e))}}),Dc=L.define(),Ii=ke.define({create(){return On.start()},update(n,e){return n.update(e)},provide:n=>[Dr.from(n,e=>e.tooltip),B.contentAttributes.from(n,e=>e.attrs)]});function nn(n,e="option"){return t=>{let i=t.state.field(Ii,!1);if(!i||!i.open||Date.now()-i.open.timestamp-1?i.open.selected+s*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:Dc.of(l)}),!0}}const Bg=n=>{let e=n.state.field(Ii,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||Date.now()-e.open.timestampn.state.field(Ii,!1)?(n.dispatch({effects:Ac.of(!0)}),!0):!1,Pg=n=>{let e=n.state.field(Ii,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Mc.of(null)}),!0)},Lg=B.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",listStyle:"none",margin:0,padding:0,"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Rg{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}}class $r{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,he.TrackDel),i=e.mapPos(this.to,1,he.TrackDel);return t==null||i==null?null:new $r(this.field,t,i)}}class qr{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let h=o,c=/^\t*/.exec(a)[0].length;for(let f=0;fnew $r(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],s=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",h=-1;for(let c=0;c=h&&f.field++}s.push(new Rg(h,i.length,r.index,r.index+a.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}for(let l;l=/([$#])\\{/.exec(o);){o=o.slice(0,l.index)+l[1]+"{"+o.slice(l.index+l[0].length);for(let a of s)a.line==i.length&&a.from>l.index&&(a.from--,a.to--)}i.push(o)}return new qr(i,s)}}let _g=P.widget({widget:new class extends tt{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),Ig=P.mark({class:"cm-snippetField"});class si{constructor(e,t){this.ranges=e,this.active=t,this.deco=P.set(e.map(i=>(i.from==i.to?_g:Ig).range(i.from,i.to)))}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}return new si(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const Ni=L.define({map(n,e){return n&&n.map(e)}}),Ng=L.define(),Bi=ke.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(Ni))return t.value;if(t.is(Ng)&&n)return new si(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>B.decorations.from(n,e=>e?e.deco:P.none)});function jr(n,e){return w.create(n.filter(t=>t.field==e).map(t=>w.range(t.from,t.to)))}function Vg(n){let e=qr.parse(n);return(t,i,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),a={changes:{from:s,to:r,insert:N.of(o)},scrollIntoView:!0};if(l.length&&(a.selection=jr(l,0)),l.length>1){let h=new si(l,0),c=a.effects=[Ni.of(h)];t.state.field(Bi,!1)===void 0&&c.push(L.appendConfig.of([Bi,$g,qg,Lg]))}t.dispatch(t.state.update(a))}}function Tc(n){return({state:e,dispatch:t})=>{let i=e.field(Bi,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return t(e.update({selection:jr(i.ranges,s),effects:Ni.of(r?null:new si(i.ranges,s))})),!0}}const Fg=({state:n,dispatch:e})=>n.field(Bi,!1)?(e(n.update({effects:Ni.of(null)})),!0):!1,Hg=Tc(1),Wg=Tc(-1),zg=[{key:"Tab",run:Hg,shift:Wg},{key:"Escape",run:Fg}],Fl=O.define({combine(n){return n.length?n[0]:zg}}),$g=Pi.highest(Rn.compute([Fl],n=>n.facet(Fl)));function eb(n,e){return Object.assign(Object.assign({},e),{apply:Vg(n)})}const qg=B.domEventHandlers({mousedown(n,e){let t=e.state.field(Bi,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==t.active?!1:(e.dispatch({selection:jr(t.ranges,s.field),effects:Ni.of(t.ranges.some(r=>r.field>s.field)?new si(t.ranges,s.field):null)}),!0)}}),Ei={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Mt=L.define({map(n,e){let t=e.mapPos(n,-1,he.TrackAfter);return t??void 0}}),Kr=L.define({map(n,e){return e.mapPos(n)}}),Ur=new class extends Tt{};Ur.startSide=1;Ur.endSide=-1;const Oc=ke.define({create(){return F.empty},update(n,e){if(e.selection){let t=e.state.doc.lineAt(e.selection.main.head).from,i=e.startState.doc.lineAt(e.startState.selection.main.head).from;t!=e.changes.mapPos(i,-1)&&(n=F.empty)}n=n.map(e.changes);for(let t of e.effects)t.is(Mt)?n=n.update({add:[Ur.range(t.value,t.value+1)]}):t.is(Kr)&&(n=n.update({filter:i=>i!=t.value}));return n}});function jg(){return[Ug,Oc]}const ws="()[]{}<>";function Bc(n){for(let e=0;e{if((Kg?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&Te(ue(i,0))==1||e!=s.from||t!=s.to)return!1;let r=Yg(n.state,i);return r?(n.dispatch(r),!0):!1}),Gg=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=Ec(n,n.selection.main.head).brackets||Ei.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let l=Xg(n.doc,o.head);for(let a of i)if(a==l&&$n(n.doc,o.head)==Bc(ue(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:w.cursor(o.head-a.length)}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},Jg=[{key:"Backspace",run:Gg}];function Yg(n,e){let t=Ec(n,n.selection.main.head),i=t.brackets||Ei.brackets;for(let s of i){let r=Bc(ue(s,0));if(e==s)return r==s?e0(n,s,i.indexOf(s+s+s)>-1,t):Qg(n,s,r,t.before||Ei.before);if(e==r&&Pc(n,n.selection.main.from))return Zg(n,s,r)}return null}function Pc(n,e){let t=!1;return n.field(Oc).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function $n(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Te(ue(t,0)))}function Xg(n,e){let t=n.sliceString(e-2,e);return Te(ue(t,0))==t.length?t:t.slice(1)}function Qg(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Mt.of(o.to+e.length),range:w.range(o.anchor+e.length,o.head+e.length)};let l=$n(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Mt.of(o.head+e.length),range:w.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Zg(n,e,t){let i=null,s=n.selection.ranges.map(r=>r.empty&&$n(n.doc,r.head)==t?w.cursor(r.head+t.length):i=r);return i?null:n.update({selection:w.create(s,n.selection.mainIndex),scrollIntoView:!0,effects:n.selection.ranges.map(({from:r})=>Kr.of(r))})}function e0(n,e,t,i){let s=i.stringPrefixes||Ei.stringPrefixes,r=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Mt.of(l.to+e.length),range:w.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=$n(n.doc,a),c;if(h==e){if(Hl(n,a))return{changes:{insert:e+e,from:a},effects:Mt.of(a+e.length),range:w.cursor(a+e.length)};if(Pc(n,a)){let f=t&&n.sliceDoc(a,a+e.length*3)==e+e+e;return{range:w.cursor(a+e.length*(f?3:1)),effects:Kr.of(a)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(c=Wl(n,a-2*e.length,s))>-1&&Hl(n,c))return{changes:{insert:e+e+e+e,from:a},effects:Mt.of(a+e.length),range:w.cursor(a+e.length)};if(n.charCategorizer(a)(h)!=Be.Word&&Wl(n,a,s)>-1&&!t0(n,a,e,s))return{changes:{insert:e+e,from:a},effects:Mt.of(a+e.length),range:w.cursor(a+e.length)}}return{range:r=l}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Hl(n,e){let t=ce(n).resolveInner(e+1);return t.parent&&t.from==e}function t0(n,e,t,i){let s=ce(n).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=s.firstChild;for(;c&&c.from==s.from&&c.to-c.from>t.length+a;){if(n.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=s.to==e&&s.parent;if(!h)break;s=h}return!1}function Wl(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=Be.Word)return e;for(let s of t){let r=e-s.length;if(n.sliceDoc(r,e)==s&&i(n.sliceDoc(r-1,r))!=Be.Word)return r}return-1}const i0=[{key:"Ctrl-Space",run:Eg},{key:"Escape",run:Pg},{key:"ArrowDown",run:nn(!0)},{key:"ArrowUp",run:nn(!1)},{key:"PageDown",run:nn(!0,"page")},{key:"PageUp",run:nn(!1,"page")},{key:"Enter",run:Bg}];function Je(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=t[i];typeof s=="string"?n.setAttribute(i,s):s!=null&&(n[i]=s)}e++}for(;el.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?P.widget({widget:new d0(l),diagnostic:l}).range(l.from):P.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity},diagnostic:l}).range(l.from,l.to)),!0);return new St(o,t,ti(o))}}function ti(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new n0(s,r,o.diagnostic),!1}),i}function s0(n,e){return!!(n.effects.some(t=>t.is(Gr))||n.changes.touchesRange(e.pos))}function Rc(n,e){return n.field(De,!1)?e:e.concat(L.appendConfig.of([De,B.decorations.compute([De],t=>{let{selected:i,panel:s}=t.field(De);return!i||!s||i.from==i.to?P.none:P.set([o0.range(i.from,i.to)])}),wd(l0,{hideOn:s0}),m0]))}function r0(n,e){return{effects:Rc(n,[Gr.of(e)])}}const Gr=L.define(),Jr=L.define(),_c=L.define(),De=ke.define({create(){return new St(P.none,null,null)},update(n,e){if(e.docChanged){let t=n.diagnostics.map(e.changes),i=null;if(n.selected){let s=e.changes.mapPos(n.selected.from,1);i=ti(t,n.selected.diagnostic,s)||ti(t,null,s)}n=new St(t,n.panel,i)}for(let t of e.effects)t.is(Gr)?n=St.init(t.value,n.panel,e.state):t.is(Jr)?n=new St(n.diagnostics,t.value?qn.open:null,n.selected):t.is(_c)&&(n=new St(n.diagnostics,n.panel,t.value));return n},provide:n=>[er.from(n,e=>e.panel),B.decorations.from(n,e=>e.diagnostics)]}),o0=P.mark({class:"cm-lintRange cm-lintRange-active"});function l0(n,e,t){let{diagnostics:i}=n.state.field(De),s=[],r=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{e>=a&&e<=h&&(a==h||(e>a||t>0)&&(eNc(n,t,!1)))}const h0=n=>{let e=n.state.field(De,!1);(!e||!e.panel)&&n.dispatch({effects:Rc(n.state,[Jr.of(!0)])});let t=vd(n,qn.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},zl=n=>{let e=n.state.field(De,!1);return!e||!e.panel?!1:(n.dispatch({effects:Jr.of(!1)}),!0)},c0=n=>{let e=n.state.field(De,!1);if(!e)return!1;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},f0=[{key:"Mod-Shift-m",run:h0},{key:"F8",run:c0}],u0=pe.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(qt);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let n=Date.now();if(nPromise.resolve(i(this.view)))).then(i=>{let s=i.reduce((r,o)=>r.concat(o));this.view.state.doc==e.doc&&this.view.dispatch(r0(this.view.state,s))},i=>{He(this.view.state,i)})}}update(n){let e=n.state.facet(qt);(n.docChanged||e!=n.startState.facet(qt))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),qt=O.define({combine(n){return Object.assign({sources:n.map(e=>e.source)},Vt(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null}))},enables:u0});function Ic(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;ir.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function Nc(n,e,t){var i;let s=t?Ic(e.actions):[];return Je("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Je("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=f=>{f.preventDefault();let u=ti(n.state.field(De).diagnostics,e);u&&r.apply(n,u.from,u.to)},{name:a}=r,h=s[o]?a.indexOf(s[o]):-1,c=h<0?a:[a.slice(0,h),Je("u",a.slice(h,h+1)),a.slice(h+1)];return Je("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${a}${h<0?"":` (access key "${s[o]})"`}.`},c)}),e.source&&Je("div",{class:"cm-diagnosticSource"},e.source))}class d0 extends tt{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return Je("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class $l{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Nc(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class qn{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)zl(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=Ic(r.actions);for(let l=0;l{for(let r=0;rzl(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(De).selected;if(!e)return-1;for(let t=0;t{let h=-1,c;for(let f=i;fi&&(this.items.splice(i,h-i),s=!0)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),r=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),i++});i({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{o.topl.bottom&&(this.list.scrollTop+=o.bottom-l.bottom)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(De),i=ti(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:_c.of(i)})}static open(e){return new qn(e)}}function p0(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function xs(n){return p0(``,'width="6" height="3"')}const m0=B.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:xs("#d11")},".cm-lintRange-warning":{backgroundImage:xs("orange")},".cm-lintRange-info":{backgroundImage:xs("#999")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),g0=[Xu(),Xp(),Cp(),Wu(),I.allowMultipleSelections.of(!0),cp(),_r(Tp,{fallback:!0}),jg(),ad(),fd(),Rn.of([...Jg,...Jm,...om,...xp,...i0,...f0])],y0=["standardSQL","msSQL","mySQL","mariaDB","sqlite","cassandra","plSQL","hive","pgSQL","gql","gpSQL","sparkSQL","esper"],ql={python:()=>re(()=>import("./index-DnnaNnpE.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]),import.meta.url).then(n=>n.python()),c:()=>re(()=>import("./clike-CFERkOWz.js"),[],import.meta.url).then(n=>Ve.define(n.c)),cpp:()=>re(()=>import("./clike-CFERkOWz.js"),[],import.meta.url).then(n=>Ve.define(n.cpp)),markdown:async()=>{const[n,e]=await Promise.all([re(()=>import("./index-t1IveIWW.js"),__vite__mapDeps([28,29,1,30,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,31]),import.meta.url),re(()=>import("./frontmatter-BHlTarA4.js"),__vite__mapDeps([32,33,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]),import.meta.url)]);return n.markdown({extensions:[e.frontmatter]})},json:()=>re(()=>import("./index-Vj2viUie.js"),__vite__mapDeps([34,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]),import.meta.url).then(n=>n.json()),html:()=>re(()=>import("./index-CpAE4MbP.js"),__vite__mapDeps([29,1,30,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,31]),import.meta.url).then(n=>n.html()),css:()=>re(()=>import("./index-Bjous_T4.js"),__vite__mapDeps([30,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]),import.meta.url).then(n=>n.css()),javascript:()=>re(()=>import("./index-nxrZbU9P.js"),__vite__mapDeps([31,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]),import.meta.url).then(n=>n.javascript()),jinja2:()=>re(()=>import("./jinja2-C4DGRd-O.js"),[],import.meta.url).then(n=>Ve.define(n.jinja2)),typescript:()=>re(()=>import("./index-nxrZbU9P.js"),__vite__mapDeps([31,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]),import.meta.url).then(n=>n.javascript({typescript:!0})),yaml:()=>re(()=>import("./yaml-DsCXHVTH.js"),[],import.meta.url).then(n=>Ve.define(n.yaml)),dockerfile:()=>re(()=>import("./dockerfile-C8FRPiPq.js"),[],import.meta.url).then(n=>Ve.define(n.dockerFile)),shell:()=>re(()=>import("./shell-bahM2fKw.js"),[],import.meta.url).then(n=>Ve.define(n.shell)),r:()=>re(()=>import("./r-DUYO_cvP.js"),[],import.meta.url).then(n=>Ve.define(n.r)),sql:()=>re(()=>import("./sql-C4g8LzGK.js"),[],import.meta.url).then(n=>Ve.define(n.standardSQL)),...Object.fromEntries(y0.map(n=>["sql-"+n,()=>re(()=>import("./sql-C4g8LzGK.js"),[],import.meta.url).then(e=>Ve.define(e[n]))]))},b0={py:"python",md:"markdown",js:"javascript",ts:"typescript",sh:"shell"};async function w0(n){const e=ql[n]||ql[b0[n]]||void 0;if(e)return e()}const{SvelteComponent:x0,append:k0,attr:ks,binding_callbacks:v0,detach:S0,element:jl,flush:Se,init:C0,insert:A0,noop:Kl,safe_not_equal:M0}=window.__gradio__svelte__internal,{createEventDispatcher:D0,onMount:T0}=window.__gradio__svelte__internal;function O0(n){let e,t,i;return{c(){e=jl("div"),t=jl("div"),ks(t,"class",i="codemirror-wrapper "+n[0]+" svelte-scxcch"),ks(e,"class","wrap svelte-scxcch")},m(s,r){A0(s,e,r),k0(e,t),n[15](t)},p(s,r){r[0]&1&&i!==(i="codemirror-wrapper "+s[0]+" svelte-scxcch")&&ks(t,"class",i)},i:Kl,o:Kl,d(s){s&&S0(e),n[15](null)}}}function B0(n){let e=n.dom.querySelectorAll(".cm-gutterElement");if(e.length===0)return null;for(var t=0;t(x=E(),()=>x?.destroy()));function X(A){v0[A?"unshift":"push"](()=>{k=A,t(1,k)})}return n.$$set=A=>{"class_names"in A&&t(0,i=A.class_names),"value"in A&&t(2,s=A.value),"dark_mode"in A&&t(3,r=A.dark_mode),"basic"in A&&t(4,o=A.basic),"language"in A&&t(5,l=A.language),"lines"in A&&t(6,a=A.lines),"max_lines"in A&&t(7,h=A.max_lines),"extensions"in A&&t(8,c=A.extensions),"use_tab"in A&&t(9,f=A.use_tab),"readonly"in A&&t(10,u=A.readonly),"placeholder"in A&&t(11,d=A.placeholder),"wrap_lines"in A&&t(12,p=A.wrap_lines),"show_line_numbers"in A&&t(13,g=A.show_line_numbers)},n.$$.update=()=>{n.$$.dirty[0]&32&&C(l),n.$$.dirty[0]&17408&&ve(),n.$$.dirty[0]&4&&M(s)},T(),[i,k,s,r,o,l,a,h,c,f,u,d,p,g,b,X]}class P0 extends x0{constructor(e){super(),C0(this,e,E0,O0,M0,{class_names:0,value:2,dark_mode:3,basic:4,language:5,lines:6,max_lines:7,extensions:8,use_tab:9,readonly:10,placeholder:11,wrap_lines:12,show_line_numbers:13},null,[-1,-1])}get class_names(){return this.$$.ctx[0]}set class_names(e){this.$$set({class_names:e}),Se()}get value(){return this.$$.ctx[2]}set value(e){this.$$set({value:e}),Se()}get dark_mode(){return this.$$.ctx[3]}set dark_mode(e){this.$$set({dark_mode:e}),Se()}get basic(){return this.$$.ctx[4]}set basic(e){this.$$set({basic:e}),Se()}get language(){return this.$$.ctx[5]}set language(e){this.$$set({language:e}),Se()}get lines(){return this.$$.ctx[6]}set lines(e){this.$$set({lines:e}),Se()}get max_lines(){return this.$$.ctx[7]}set max_lines(e){this.$$set({max_lines:e}),Se()}get extensions(){return this.$$.ctx[8]}set extensions(e){this.$$set({extensions:e}),Se()}get use_tab(){return this.$$.ctx[9]}set use_tab(e){this.$$set({use_tab:e}),Se()}get readonly(){return this.$$.ctx[10]}set readonly(e){this.$$set({readonly:e}),Se()}get placeholder(){return this.$$.ctx[11]}set placeholder(e){this.$$set({placeholder:e}),Se()}get wrap_lines(){return this.$$.ctx[12]}set wrap_lines(e){this.$$set({wrap_lines:e}),Se()}get show_line_numbers(){return this.$$.ctx[13]}set show_line_numbers(e){this.$$set({show_line_numbers:e}),Se()}}const Vc=P0,{SvelteComponent:L0,create_component:R0,destroy_component:_0,flush:I0,init:N0,mount_component:V0,safe_not_equal:F0,transition_in:H0,transition_out:W0}=window.__gradio__svelte__internal,{onDestroy:z0}=window.__gradio__svelte__internal;function $0(n){let e,t;return e=new Ql({props:{Icon:n[0]?un:Yr}}),e.$on("click",n[1]),{c(){R0(e.$$.fragment)},m(i,s){V0(e,i,s),t=!0},p(i,[s]){const r={};s&1&&(r.Icon=i[0]?un:Yr),e.$set(r)},i(i){t||(H0(e.$$.fragment,i),t=!0)},o(i){W0(e.$$.fragment,i),t=!1},d(i){_0(e,i)}}}function q0(n,e,t){let i=!1,{value:s}=e,r;function o(){t(0,i=!0),r&&clearTimeout(r),r=setTimeout(()=>{t(0,i=!1)},2e3)}async function l(){"clipboard"in navigator&&(await navigator.clipboard.writeText(s),o())}return z0(()=>{r&&clearTimeout(r)}),n.$$set=a=>{"value"in a&&t(2,s=a.value)},[i,l,s]}class j0 extends L0{constructor(e){super(),N0(this,e,q0,$0,F0,{value:2})}get value(){return this.$$.ctx[2]}set value(e){this.$$set({value:e}),I0()}}const Fc=j0,{SvelteComponent:K0,create_component:Hc,destroy_component:Wc,flush:Ul,init:U0,mount_component:zc,safe_not_equal:G0,transition_in:$c,transition_out:qc}=window.__gradio__svelte__internal,{onDestroy:J0}=window.__gradio__svelte__internal;function Y0(n){let e,t;return e=new Ql({props:{Icon:n[0]?un:Xr}}),{c(){Hc(e.$$.fragment)},m(i,s){zc(e,i,s),t=!0},p(i,s){const r={};s&1&&(r.Icon=i[0]?un:Xr),e.$set(r)},i(i){t||($c(e.$$.fragment,i),t=!0)},o(i){qc(e.$$.fragment,i),t=!1},d(i){Wc(e,i)}}}function X0(n){let e,t;return e=new Uc({props:{download:"file."+n[2],href:n[1],$$slots:{default:[Y0]},$$scope:{ctx:n}}}),e.$on("click",n[3]),{c(){Hc(e.$$.fragment)},m(i,s){zc(e,i,s),t=!0},p(i,[s]){const r={};s&4&&(r.download="file."+i[2]),s&2&&(r.href=i[1]),s&129&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||($c(e.$$.fragment,i),t=!0)},o(i){qc(e.$$.fragment,i),t=!1},d(i){Wc(e,i)}}}function Q0(n){return{py:"py",python:"py",md:"md",markdown:"md",json:"json",html:"html",css:"css",js:"js",javascript:"js",ts:"ts",typescript:"ts",yaml:"yaml",yml:"yml",dockerfile:"dockerfile",sh:"sh",shell:"sh",r:"r",c:"c",cpp:"cpp"}[n]||"txt"}function Z0(n,e,t){let i,s,{value:r}=e,{language:o}=e,l=!1,a;function h(){t(0,l=!0),a&&clearTimeout(a),a=setTimeout(()=>{t(0,l=!1)},2e3)}return J0(()=>{a&&clearTimeout(a)}),n.$$set=c=>{"value"in c&&t(4,r=c.value),"language"in c&&t(5,o=c.language)},n.$$.update=()=>{n.$$.dirty&32&&t(2,i=Q0(o)),n.$$.dirty&16&&t(1,s=URL.createObjectURL(new Blob([r])))},[l,s,i,h,r,o]}class ey extends K0{constructor(e){super(),U0(this,e,Z0,X0,G0,{value:4,language:5})}get value(){return this.$$.ctx[4]}set value(e){this.$$set({value:e}),Ul()}get language(){return this.$$.ctx[5]}set language(e){this.$$set({language:e}),Ul()}}const jc=ey,{SvelteComponent:ty,create_component:dr,destroy_component:pr,detach:iy,flush:Gl,init:ny,insert:sy,mount_component:mr,safe_not_equal:ry,space:oy,transition_in:gr,transition_out:yr}=window.__gradio__svelte__internal;function ly(n){let e,t,i,s;return e=new jc({props:{value:n[0],language:n[1]}}),i=new Fc({props:{value:n[0]}}),{c(){dr(e.$$.fragment),t=oy(),dr(i.$$.fragment)},m(r,o){mr(e,r,o),sy(r,t,o),mr(i,r,o),s=!0},p(r,o){const l={};o&1&&(l.value=r[0]),o&2&&(l.language=r[1]),e.$set(l);const a={};o&1&&(a.value=r[0]),i.$set(a)},i(r){s||(gr(e.$$.fragment,r),gr(i.$$.fragment,r),s=!0)},o(r){yr(e.$$.fragment,r),yr(i.$$.fragment,r),s=!1},d(r){r&&iy(t),pr(e,r),pr(i,r)}}}function ay(n){let e,t;return e=new Gc({props:{$$slots:{default:[ly]},$$scope:{ctx:n}}}),{c(){dr(e.$$.fragment)},m(i,s){mr(e,i,s),t=!0},p(i,[s]){const r={};s&7&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(gr(e.$$.fragment,i),t=!0)},o(i){yr(e.$$.fragment,i),t=!1},d(i){pr(e,i)}}}function hy(n,e,t){let{value:i}=e,{language:s}=e;return n.$$set=r=>{"value"in r&&t(0,i=r.value),"language"in r&&t(1,s=r.language)},[i,s]}class cy extends ty{constructor(e){super(),ny(this,e,hy,ay,ry,{value:0,language:1})}get value(){return this.$$.ctx[0]}set value(e){this.$$set({value:e}),Gl()}get language(){return this.$$.ctx[1]}set language(e){this.$$set({language:e}),Gl()}}const Kc=cy,{SvelteComponent:fy,add_flush_callback:uy,assign:dy,bind:py,binding_callbacks:my,check_outros:Jl,create_component:Rt,destroy_component:_t,detach:cn,empty:gy,flush:oe,get_spread_object:yy,get_spread_update:by,group_outros:Yl,init:wy,insert:fn,mount_component:It,safe_not_equal:xy,space:br,transition_in:Oe,transition_out:Fe}=window.__gradio__svelte__internal,{afterUpdate:ky}=window.__gradio__svelte__internal;function Xl(n){let e,t;return e=new Xc({props:{Icon:Zl,show_label:n[9],label:n[8],float:!1}}),{c(){Rt(e.$$.fragment)},m(i,s){It(e,i,s),t=!0},p(i,s){const r={};s&512&&(r.show_label=i[9]),s&256&&(r.label=i[8]),e.$set(r)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){Fe(e.$$.fragment,i),t=!1},d(i){_t(e,i)}}}function vy(n){let e,t,i,s,r;e=new Kc({props:{language:n[2],value:n[0]}});function o(a){n[19](a)}let l={language:n[2],lines:n[3],max_lines:n[4],dark_mode:n[16],wrap_lines:n[13],show_line_numbers:n[14],readonly:!n[15]};return n[0]!==void 0&&(l.value=n[0]),i=new Vc({props:l}),my.push(()=>py(i,"value",o)),i.$on("blur",n[20]),i.$on("focus",n[21]),{c(){Rt(e.$$.fragment),t=br(),Rt(i.$$.fragment)},m(a,h){It(e,a,h),fn(a,t,h),It(i,a,h),r=!0},p(a,h){const c={};h&4&&(c.language=a[2]),h&1&&(c.value=a[0]),e.$set(c);const f={};h&4&&(f.language=a[2]),h&8&&(f.lines=a[3]),h&16&&(f.max_lines=a[4]),h&8192&&(f.wrap_lines=a[13]),h&16384&&(f.show_line_numbers=a[14]),h&32768&&(f.readonly=!a[15]),!s&&h&1&&(s=!0,f.value=a[0],uy(()=>s=!1)),i.$set(f)},i(a){r||(Oe(e.$$.fragment,a),Oe(i.$$.fragment,a),r=!0)},o(a){Fe(e.$$.fragment,a),Fe(i.$$.fragment,a),r=!1},d(a){a&&cn(t),_t(e,a),_t(i,a)}}}function Sy(n){let e,t;return e=new Qc({props:{unpadded_box:!0,size:"large",$$slots:{default:[Cy]},$$scope:{ctx:n}}}),{c(){Rt(e.$$.fragment)},m(i,s){It(e,i,s),t=!0},p(i,s){const r={};s&8388608&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){Fe(e.$$.fragment,i),t=!1},d(i){_t(e,i)}}}function Cy(n){let e,t;return e=new Zl({}),{c(){Rt(e.$$.fragment)},m(i,s){It(e,i,s),t=!0},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){Fe(e.$$.fragment,i),t=!1},d(i){_t(e,i)}}}function Ay(n){let e,t,i,s,r,o,l;const a=[{autoscroll:n[1].autoscroll},{i18n:n[1].i18n},n[10]];let h={};for(let p=0;p{c=null}),Jl());let b=s;s=d(p),s===b?u[s].p(p,g):(Yl(),Fe(u[b],1,1,()=>{u[b]=null}),Jl(),r=u[s],r?r.p(p,g):(r=u[s]=f[s](p),r.c()),Oe(r,1),r.m(o.parentNode,o))},i(p){l||(Oe(e.$$.fragment,p),Oe(c),Oe(r),l=!0)},o(p){Fe(e.$$.fragment,p),Fe(c),Fe(r),l=!1},d(p){p&&(cn(t),cn(i),cn(o)),_t(e,p),c&&c.d(p),u[s].d(p)}}}function My(n){let e,t;return e=new Yc({props:{height:n[4]&&"fit-content",variant:"solid",padding:!1,elem_id:n[5],elem_classes:n[6],visible:n[7],scale:n[11],min_width:n[12],$$slots:{default:[Ay]},$$scope:{ctx:n}}}),{c(){Rt(e.$$.fragment)},m(i,s){It(e,i,s),t=!0},p(i,[s]){const r={};s&16&&(r.height=i[4]&&"fit-content"),s&32&&(r.elem_id=i[5]),s&64&&(r.elem_classes=i[6]),s&128&&(r.visible=i[7]),s&2048&&(r.scale=i[11]),s&4096&&(r.min_width=i[12]),s&8447775&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){Fe(e.$$.fragment,i),t=!1},d(i){_t(e,i)}}}function Dy(n,e,t){let{gradio:i}=e,{value:s=""}=e,{value_is_output:r=!1}=e,{language:o=""}=e,{lines:l=5}=e,{max_lines:a=void 0}=e,{elem_id:h=""}=e,{elem_classes:c=[]}=e,{visible:f=!0}=e,{label:u=i.i18n("code.code")}=e,{show_label:d=!0}=e,{loading_status:p}=e,{scale:g=null}=e,{min_width:y=void 0}=e,{wrap_lines:b=!1}=e,{show_line_numbers:k=!0}=e,{interactive:x}=e,C=i.theme==="dark";function M(){i.dispatch("change",s),r||i.dispatch("input")}ky(()=>{t(17,r=!1)});const T=()=>i.dispatch("clear_status",p);function E(S){s=S,t(0,s)}const H=()=>i.dispatch("blur"),_=()=>i.dispatch("focus");return n.$$set=S=>{"gradio"in S&&t(1,i=S.gradio),"value"in S&&t(0,s=S.value),"value_is_output"in S&&t(17,r=S.value_is_output),"language"in S&&t(2,o=S.language),"lines"in S&&t(3,l=S.lines),"max_lines"in S&&t(4,a=S.max_lines),"elem_id"in S&&t(5,h=S.elem_id),"elem_classes"in S&&t(6,c=S.elem_classes),"visible"in S&&t(7,f=S.visible),"label"in S&&t(8,u=S.label),"show_label"in S&&t(9,d=S.show_label),"loading_status"in S&&t(10,p=S.loading_status),"scale"in S&&t(11,g=S.scale),"min_width"in S&&t(12,y=S.min_width),"wrap_lines"in S&&t(13,b=S.wrap_lines),"show_line_numbers"in S&&t(14,k=S.show_line_numbers),"interactive"in S&&t(15,x=S.interactive)},n.$$.update=()=>{n.$$.dirty&1&&M()},[s,i,o,l,a,h,c,f,u,d,p,g,y,b,k,x,C,r,T,E,H,_]}class Ty extends fy{constructor(e){super(),wy(this,e,Dy,My,xy,{gradio:1,value:0,value_is_output:17,language:2,lines:3,max_lines:4,elem_id:5,elem_classes:6,visible:7,label:8,show_label:9,loading_status:10,scale:11,min_width:12,wrap_lines:13,show_line_numbers:14,interactive:15})}get gradio(){return this.$$.ctx[1]}set gradio(e){this.$$set({gradio:e}),oe()}get value(){return this.$$.ctx[0]}set value(e){this.$$set({value:e}),oe()}get value_is_output(){return this.$$.ctx[17]}set value_is_output(e){this.$$set({value_is_output:e}),oe()}get language(){return this.$$.ctx[2]}set language(e){this.$$set({language:e}),oe()}get lines(){return this.$$.ctx[3]}set lines(e){this.$$set({lines:e}),oe()}get max_lines(){return this.$$.ctx[4]}set max_lines(e){this.$$set({max_lines:e}),oe()}get elem_id(){return this.$$.ctx[5]}set elem_id(e){this.$$set({elem_id:e}),oe()}get elem_classes(){return this.$$.ctx[6]}set elem_classes(e){this.$$set({elem_classes:e}),oe()}get visible(){return this.$$.ctx[7]}set visible(e){this.$$set({visible:e}),oe()}get label(){return this.$$.ctx[8]}set label(e){this.$$set({label:e}),oe()}get show_label(){return this.$$.ctx[9]}set show_label(e){this.$$set({show_label:e}),oe()}get loading_status(){return this.$$.ctx[10]}set loading_status(e){this.$$set({loading_status:e}),oe()}get scale(){return this.$$.ctx[11]}set scale(e){this.$$set({scale:e}),oe()}get min_width(){return this.$$.ctx[12]}set min_width(e){this.$$set({min_width:e}),oe()}get wrap_lines(){return this.$$.ctx[13]}set wrap_lines(e){this.$$set({wrap_lines:e}),oe()}get show_line_numbers(){return this.$$.ctx[14]}set show_line_numbers(e){this.$$set({show_line_numbers:e}),oe()}get interactive(){return this.$$.ctx[15]}set interactive(e){this.$$set({interactive:e}),oe()}}const tb=Object.freeze(Object.defineProperty({__proto__:null,BaseCode:Vc,BaseCopy:Fc,BaseDownload:jc,BaseExample:Zc,BaseWidget:Kc,default:Ty},Symbol.toStringTag,{value:"Module"}));export{Zd as A,Zy as B,mg as C,Ed as D,w as E,tb as F,J as I,nr as L,Or as N,vh as P,Ve as S,z as T,we as a,R as b,Qy as c,Jy as d,Gy as e,up as f,Ue as g,ce as h,ip as i,Pi as j,Rn as k,Pe as l,Ah as m,At as n,fp as o,Ky as p,Dh as q,Zt as r,Gd as s,m as t,Ep as u,B as v,Xy as w,jy as x,eb as y,Yy as z}; //# sourceMappingURL=Index-DUjLYZTL.js.map