(()=>{let t,e;class i{lineAt(t){if(t<0||t>this.length)throw RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=c(this,t,e);let s=[];return this.decompose(0,t,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(e,this.length,s,1),n.from(s,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=c(this,t,e);let i=[];return this.decompose(t,e,i,0),n.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),s=new o(this),n=new o(t);for(let t=e,r=e;;){if(s.next(t),n.next(t),t=0,s.lineBreak!=n.lineBreak||s.done!=n.done||s.value!=n.value)return!1;if(r+=s.value.length,s.done||r>=i)return!0}}iter(t=1){return new o(this,t)}iterRange(t,e=this.length){return new h(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let s=this.line(t).from;i=this.iterRange(s,Math.max(s,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new l(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new s(t):n.from(s.split(t,[])):i.empty}}class s extends i{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,s){for(let n=0;;n++){let r=this.text[n],o=s+r.length;if((e?i:o)>=t)return new a(s,o,i,r);s=o+1,i++}}decompose(t,e,i,n){let o=t<=0&&e>=this.length?this:new s(r(this.text,[""],t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=r(o.text,t.text.slice(),0,o.length);if(e.length<=32)i.push(new s(e,t.length+o.length));else{let t=e.length>>1;i.push(new s(e.slice(0,t)),new s(e.slice(t)))}}else i.push(o)}replace(t,e,i){if(!(i instanceof s))return super.replace(t,e,i);[t,e]=c(this,t,e);let o=r(this.text,r(i.text,r(this.text,[""],0,t)),e),h=this.length+i.length-(e-t);return o.length<=32?new s(o,h):n.from(s.split(o,[]),h)}sliceString(t,e=this.length,i="\n"){[t,e]=c(this,t,e);let s="";for(let n=0,r=0;n<=e&&rt&&r&&(s+=i),tn&&(s+=o.slice(Math.max(0,t-n),e-n)),n=h+1}return s}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new s(i,n)),i=[],n=-1);return n>-1&&e.push(new s(i,n)),e}}class n extends i{constructor(t,e){for(let i of(super(),this.children=t,this.length=e,this.lines=0,t))this.lines+=i.lines}lineInner(t,e,i,s){for(let n=0;;n++){let r=this.children[n],o=s+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,s);s=o+1,i=h+1}}decompose(t,e,i,s){for(let n=0,r=0;r<=e&&n=r){let n=s&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!n?i.push(o):o.decompose(t-r,e-r,i,n)}r=h+1}}replace(t,e,i){if([t,e]=c(this,t,e),i.lines=r&&e<=h){let l=o.replace(t-r,e-r,i),a=this.lines-o.lines+l.lines;if(l.lines>4&&l.lines>a>>6){let r=this.children.slice();return r[s]=l,new n(r,this.length-(e-t)+i.length)}return super.replace(r,h,l)}r=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=c(this,t,e);let s="";for(let n=0,r=0;nt&&n&&(s+=i),tr&&(s+=o.sliceString(t-r,e-r,i)),r=h+1}return s}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof n))return 0;let i=0,[s,r,o,h]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;s+=e,r+=e){if(s==o||r==h)return i;let n=this.children[s],l=t.children[r];if(n!=l)return i+n.scanIdentical(l,e);i+=n.length+1}}static from(t,e=t.reduce((t,e)=>t+e.length+1,-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new s(i,e)}let r=Math.max(32,i>>5),o=r<<1,h=r>>1,l=[],a=0,c=-1,f=[];function d(){0!=a&&(l.push(1==f.length?f[0]:n.from(f,c)),c=-1,a=f.length=0)}for(let e of t)!function t(e){let i;if(e.lines>o&&e instanceof n)for(let i of e.children)t(i);else e.lines>h&&(a>h||!a)?(d(),l.push(e)):e instanceof s&&a&&(i=f[f.length-1])instanceof s&&e.lines+i.lines<=32?(a+=e.lines,c+=e.length+1,f[f.length-1]=new s(i.text.concat(e.text),i.length+1+e.length)):(a+e.lines>r&&d(),a+=e.lines,c+=e.length+1,f.push(e))}(e);return d(),1==l.length?l[0]:new n(l,e)}}function r(t,e,i=0,s=1e9){for(let n=0,r=0,o=!0;r=i&&(l>s&&(h=h.slice(0,s-n)),n0?1:(t instanceof s?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,h=n instanceof s?n.text.length:n.children.length;if(o==(e>0?h:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof s){let s=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let r=n.children[o+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof s?r.text.length:r.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class h{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new o(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:s}=this.cursor.next(t);return this.pos+=(s.length+t)*e,this.value=s.length<=i?s:e<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class l{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:s}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(i.prototype[Symbol.iterator]=function(){return this.iter()},o.prototype[Symbol.iterator]=h.prototype[Symbol.iterator]=l.prototype[Symbol.iterator]=function(){return this});class a{constructor(t,e,i,s){this.from=t,this.to=e,this.number=i,this.text=s}get length(){return this.to-this.from}}function c(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}let f=/*@__PURE__*/"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(t=>t?parseInt(t,36):1);for(let t=1;t=127462&&t<=127487}function u(t,e,i=!0,s=!0){return(i?p:function(t,e,i){for(;e>0;){let s=p(t,e-2,i);if(st)return f[e-1]<=t;return!1}(n))e+=w(n),s=n;else if(d(n)){let i=0,s=e-2;for(;s>=0&&d(v(t,s));)i++,s-=2;if(i%2==0)break;e+=2}else break}return e}function g(t){return t>=56320&&t<57344}function m(t){return t>=55296&&t<56320}function v(t,e){let i=t.charCodeAt(e);if(!m(i)||e+1==t.length)return i;let s=t.charCodeAt(e+1);return g(s)?(i-55296<<10)+(s-56320)+65536:i}function w(t){return t<65536?1:2}let b=/\r\n?|\n/;var y,k,x,S,C,P,A,M,O,T,D,E=((P=E||(E={}))[P.Simple=0]="Simple",P[P.TrackDel=1]="TrackDel",P[P.TrackBefore=2]="TrackBefore",P[P.TrackAfter=3]="TrackAfter",P);class R{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;et)return n+(t-s);n+=o}else{if(i!=E.Simple&&l>=t&&(i==E.TrackDel&&st||i==E.TrackBefore&&st))return null;if(l>t||l==t&&e<0&&!o)return t==s||e<0?n:n+h;n+=h}s=l}if(t>s)throw RangeError(`Position ${t} is out of range for changeset of length ${s}`);return n}touchesRange(t,e=t){for(let i=0,s=0;i=0&&s<=e&&o>=t)return!(se)||"cover";s=o}return!1}toString(){let t="";for(let e=0;e=0?":"+s:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(t=>"number"!=typeof t))throw RangeError("Invalid JSON representation of ChangeDesc");return new R(t)}static create(t){return new R(t)}}class B extends R{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw RangeError("Applying change set to a document with the wrong length");return I(this,(e,i,s,n,r)=>t=t.replace(s,s+(i-e),r),!1),t}mapDesc(t,e=!1){return V(this,t,e,!0)}invert(t){let e=this.sections.slice(),s=[];for(let n=0,r=0;n=0){e[n]=h,e[n+1]=o;let l=n>>1;for(;s.length0&&L(i,e,n.text),n.forward(t),o+=t}let l=t[r++];for(;o>1].toJSON()))}return t}static of(t,e,s){let n=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!n.length)return;oh||t<0||h>e)throw RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let f=c?"string"==typeof c?i.of(c.split(s||b)):c:i.empty,d=f.length;if(t==h&&0==d)return;to&&N(n,t-o,-1),N(n,h-t,d),L(r,n,f),o=h}}(t),l(!h),h}static empty(t){return new B(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError("Invalid JSON representation of ChangeSet");let e=[],s=[];for(let n=0;ne&&"string"!=typeof t))throw RangeError("Invalid JSON representation of ChangeSet");else if(1==r.length)e.push(r[0],0);else{for(;s.length=0&&i<=0&&i==t[n+1]?t[n]+=e:0==e&&0==t[n]?t[n+1]+=i:s?(t[n]+=e,t[n+1]+=i):t.push(e,i)}function L(t,e,s){if(0==s.length)return;let n=e.length-2>>1;if(n>1])),!s&&h!=t.sections.length&&!(t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,f,d),r=c,o=f}}}function V(t,e,i,s=!1){let n=[],r=s?[]:null,o=new F(t),h=new F(e);for(let t=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);N(n,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(h.len=0&&t=0){let e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else if(0==h.ins&&h.lene||o.ins>=0&&o.len>e)&&(t||s.length>i),r.forward2(e),o.forward(e)}}else N(s,0,o.ins,t),n&&L(n,s,o.text),o.next()}}class F{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i>1;return e>=t.length?i.empty:t[e]}textBit(t){let{inserted:e}=this.set,s=this.i-2>>1;return s>=e.length&&!t?i.empty:e[s].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class H{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 0xffffff==t?void 0:t}map(t,e=-1){let i,s;return this.empty?i=s=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),s=t.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new H(i,s,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return z.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return z.range(this.anchor,i)}eq(t,e=!1){return this.anchor==t.anchor&&this.head==t.head&&(!e||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw RangeError("Invalid JSON representation for SelectionRange");return z.range(t.anchor,t.head)}static create(t,e,i){return new H(t,e,i)}}class z{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:z.create(this.ranges.map(i=>i.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;it.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw RangeError("Invalid JSON representation for EditorSelection");return new z(t.ranges.map(t=>H.fromJSON(t)),t.main)}static single(t,e=t){return new z([z.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw RangeError("A selection needs at least one range");for(let i=0,s=0;st?8:0)|n)}static normalized(t,e=0){let i=t[e];t.sort((t,e)=>t.from-e.from),e=t.indexOf(i);for(let i=1;is.head?z.range(o,r):z.range(r,o))}}return new z(t,e)}}function _(t,e){for(let i of t.ranges)if(i.to>e)throw RangeError("Selection points outside of document")}let q=0;class j{constructor(t,e,i,s,n){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=s,this.id=q++,this.default=t([]),this.extensions="function"==typeof n?n(this):n}get reader(){return this}static define(t={}){return new j(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:Y),!!t.static,t.enables)}of(t){return new K([],this,0,t)}compute(t,e){if(this.isStatic)throw Error("Can't compute a static facet");return new K(t,this,1,e)}computeN(t,e){if(this.isStatic)throw Error("Can't compute a static facet");return new K(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],i=>e(i.field(t)))}}function Y(t,e){return t==e||t.length==e.length&&t.every((t,i)=>t===e[i])}class K{constructor(t,e,i,s){this.dependencies=t,this.facet=e,this.type=i,this.value=s,this.id=q++}dynamicSlot(t){var e;let i=this.value,s=this.facet.compareInput,n=this.id,r=t[n]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:((null!==(e=t[i.id])&&void 0!==e?e:1)&1)==0&&a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||$(t,a)){let e=i(t);if(o?!X(e,t.values[r],s):!s(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[n];if(null!=l){let n=tr(e,l);if(this.dependencies.every(i=>i instanceof j?e.facet(i)===t.facet(i):!(i instanceof Q)||e.field(i,!1)==t.field(i,!1))||(o?X(h=i(t),n,s):s(h=i(t),n)))return t.values[r]=n,0}else h=i(t);return t.values[r]=h,1}}}}function X(t,e,i){if(t.length!=e.length)return!1;for(let s=0;st===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(U).find(t=>t.field==this);return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let s=t.values[e],n=this.updateF(s,i);return this.compareF(s,n)?0:(t.values[e]=n,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,U.of({field:this,create:t})]}get extension(){return this}}let G={lowest:4,low:3,default:2,high:1,highest:0};function J(t){return e=>new tt(e,t)}let Z={highest:/*@__PURE__*/J(G.highest),high:/*@__PURE__*/J(G.high),default:/*@__PURE__*/J(G.default),low:/*@__PURE__*/J(G.low),lowest:/*@__PURE__*/J(G.lowest)};class tt{constructor(t,e){this.inner=t,this.prec=e}}class te{of(t){return new ti(this,t)}reconfigure(t){return te.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class ti{constructor(t,e){this.compartment=t,this.inner=e}}class ts{constructor(t,e,i,s,n,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=s,this.staticValues=n,this.facets=r,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,e,i){let s,n,r=[],o=Object.create(null),h=new Map;for(let i of(s=[[],[],[],[],[]],n=new Map,!function t(i,r){let o=n.get(i);if(null!=o){if(o<=r)return;let t=s[o].indexOf(i);t>-1&&s[o].splice(t,1),i instanceof ti&&h.delete(i.compartment)}if(n.set(i,r),Array.isArray(i))for(let e of i)t(e,r);else if(i instanceof ti){if(h.has(i.compartment))throw RangeError("Duplicate use of compartment in extensions");let s=e.get(i.compartment)||i.inner;h.set(i.compartment,s),t(s,r)}else if(i instanceof tt)t(i.inner,i.prec);else if(i instanceof Q)s[r].push(i),i.provides&&t(i.provides,r);else if(i instanceof K)s[r].push(i),i.facet.extensions&&t(i.facet.extensions,G.default);else{let e=i.extension;if(!e)throw Error(`Unrecognized extension value in extension set (${i}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);t(e,r)}}(t,G.default),s.reduce((t,e)=>t.concat(e))))i instanceof Q?r.push(i):(o[i.facet.id]||(o[i.facet.id]=[])).push(i);let l=Object.create(null),a=[],c=[];for(let t of r)l[t.id]=c.length<<1,c.push(e=>t.slot(e));let f=null==i?void 0:i.config.facets;for(let t in o){let e=o[t],s=e[0].facet,n=f&&f[t]||[];if(e.every(t=>0==t.type)){if(l[s.id]=a.length<<1|1,Y(n,e))a.push(i.facet(s));else{let t=s.combine(e.map(t=>t.value));a.push(i&&s.compare(t,i.facet(s))?i.facet(s):t)}}else{for(let t of e)0==t.type?(l[t.id]=a.length<<1|1,a.push(t.value)):(l[t.id]=c.length<<1,c.push(e=>t.dynamicSlot(e)));l[s.id]=c.length<<1,c.push(t=>(function(t,e,i){let s=i.map(e=>t[e.id]),n=i.map(t=>t.type),r=s.filter(t=>!(1&t)),o=t[e.id]>>1;function h(t){let i=[];for(let e=0;et(l)),l,a,o)}}function tn(t,e){if(1&e)return 2;let i=e>>1,s=t.status[i];if(4==s)throw Error("Cyclic dependency between fields and/or facets");if(2&s)return s;t.status[i]=4;let n=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|n}function tr(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}let to=/*@__PURE__*/j.define(),th=/*@__PURE__*/j.define({combine:t=>t.some(t=>t),static:!0}),tl=/*@__PURE__*/j.define({combine:t=>t.length?t[0]:void 0,static:!0}),ta=/*@__PURE__*/j.define(),tc=/*@__PURE__*/j.define(),tf=/*@__PURE__*/j.define(),td=/*@__PURE__*/j.define({combine:t=>!!t.length&&t[0]});class tu{constructor(t,e){this.type=t,this.value=e}static define(){return new tp}}class tp{of(t){return new tu(this,t)}}class tg{constructor(t){this.map=t}of(t){return new tm(this,t)}}class tm{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new tm(this.type,e)}is(t){return this.type==t}static define(t={}){return new tg(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let s of t){let t=s.map(e);t&&i.push(t)}return i}}tm.reconfigure=/*@__PURE__*/tm.define(),tm.appendConfig=/*@__PURE__*/tm.define();class tv{constructor(t,e,i,s,n,r){this.startState=t,this.changes=e,this.selection=i,this.effects=s,this.annotations=n,this.scrollIntoView=r,this._doc=null,this._state=null,i&&_(i,e.newLength),n.some(t=>t.type==tv.time)||(this.annotations=n.concat(tv.time.of(Date.now())))}static create(t,e,i,s,n,r){return new tv(t,e,i,s,n,r)}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(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(tv.userEvent);return!!(e&&(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function tw(t,e,i){var s;let n,r,o;return i?(n=e.changes,r=B.empty(e.changes.length),o=t.changes.compose(e.changes)):(n=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(r):null===(s=t.selection)||void 0===s?void 0:s.map(n),effects:tm.mapEffects(t.effects,n).concat(tm.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function tb(t,e,i){let s=e.selection,n=tk(e.annotations);return e.userEvent&&(n=n.concat(tv.userEvent.of(e.userEvent))),{changes:e.changes instanceof B?e.changes:B.of(e.changes||[],i,t.facet(tl)),selection:s&&(s instanceof z?s:z.single(s.anchor,s.head)),effects:tk(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}tv.time=/*@__PURE__*/tu.define(),tv.userEvent=/*@__PURE__*/tu.define(),tv.addToHistory=/*@__PURE__*/tu.define(),tv.remote=/*@__PURE__*/tu.define();let ty=[];function tk(t){return null==t?ty:Array.isArray(t)?t:[t]}var tx=((y=tx||(tx={}))[y.Word=0]="Word",y[y.Space=1]="Space",y[y.Other=2]="Other",y);let tS=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{t=/*@__PURE__*/RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}class tC{constructor(t,e,i,s,n,r){this.config=t,this.doc=e,this.selection=i,this.values=s,this.status=t.statusTemplate.slice(),this.computeSlot=n,r&&(r._state=this);for(let t=0;t=0;n--){let r=i[n](t);r&&Object.keys(r).length&&(s=tw(s,tb(e,r,t.changes.newLength),!0))}return s==t?t:tv.create(e,t.changes,t.selection,s.effects,s.annotations,s.scrollIntoView)}(s?function(e){let i=e.startState,s=!0;for(let t of i.facet(ta)){let i=t(e);if(!1===i){s=!1;break}Array.isArray(i)&&(s=!0===s?i:function(t,e){let i=[];for(let s=0,n=0;;){let r,o;if(s=t[s]))r=t[s++],o=t[s++];else{if(!(n=0;s--){let r=n[s](e);e=r instanceof tv?r:Array.isArray(r)&&1==r.length&&r[0]instanceof tv?r[0]:t(i,tk(r),!1)}return e}(r):r)}(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:s,compartments:n}=i;for(let e of t.effects)e.is(te.reconfigure)?(i&&(n=new Map,i.compartments.forEach((t,e)=>n.set(e,t)),i=null),n.set(e.value.compartment,e.value.extension)):e.is(tm.reconfigure)?(i=null,s=e.value):e.is(tm.appendConfig)&&(i=null,s=tk(s).concat(e.value));e=i?t.startState.values.slice():new tC(i=ts.resolve(s,n,this),this.doc,this.selection,i.dynamicSlots.map(()=>null),(t,e)=>e.reconfigure(t,this),null).values;let r=t.startState.facet(th)?t.newSelection:t.newSelection.asSingle();new tC(i,t.newDoc,r,e,(e,i)=>i.update(e,t),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:z.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),s=this.changes(i.changes),n=[i.range],r=tk(i.effects);for(let i=1;in.spec.fromJSON(r,t)))}}return tC.create({doc:t.doc,selection:z.fromJSON(t.selection),extensions:e.extensions?s.concat([e.extensions]):s})}static create(t={}){let e=ts.resolve(t.extensions||[],new Map),s=t.doc instanceof i?t.doc:i.of((t.doc||"").split(e.staticFacet(tC.lineSeparator)||b)),n=t.selection?t.selection instanceof z?t.selection:z.single(t.selection.anchor,t.selection.head):z.single(0);return _(n,s.length),e.staticFacet(th)||(n=n.asSingle()),new tC(e,s,n,e.dynamicSlots.map(()=>null),(t,e)=>e.create(t),null)}get tabSize(){return this.facet(tC.tabSize)}get lineBreak(){return this.facet(tC.lineSeparator)||"\n"}get readOnly(){return this.facet(td)}phrase(t,...e){for(let e of this.facet(tC.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(t,i)=>{if("$"==i)return"$";let s=+(i||1);return!s||s>e.length?t:e[s-1]})),t}languageDataAt(t,e,i=-1){let s=[];for(let n of this.facet(to))for(let r of n(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&s.push(r[t]);return s}charCategorizer(e){var i;return i=this.languageDataAt("wordChars",e).join(""),e=>{if(!/\S/.test(e))return tx.Space;if(function(e){if(t)return t.test(e);for(let t=0;t"€"&&(i.toUpperCase()!=i.toLowerCase()||tS.test(i)))return!0}return!1}(e))return tx.Word;for(let t=0;t-1)return tx.Word;return tx.Other}}wordAt(t){let{text:e,from:i,length:s}=this.doc.lineAt(t),n=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=u(e,r,!1);if(n(e.slice(t,r))!=tx.Word)break;r=t}for(;ot.length?t[0]:4}),tC.lineSeparator=tl,tC.readOnly=td,tC.phrases=/*@__PURE__*/j.define({compare(t,e){let i=Object.keys(t),s=Object.keys(e);return i.length==s.length&&i.every(i=>t[i]==e[i])}}),tC.languageData=to,tC.changeFilter=ta,tC.transactionFilter=tc,tC.transactionExtender=tf,te.reconfigure=/*@__PURE__*/tm.define();class tA{eq(t){return this==t}range(t,e=t){return tM.create(t,e,this)}}tA.prototype.startSide=tA.prototype.endSide=0,tA.prototype.point=!1,tA.prototype.mapMode=E.TrackDel;class tM{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new tM(t,e,i)}}function tO(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class tT{constructor(t,e,i,s){this.from=t,this.to=e,this.value=i,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,s=0){let n=i?this.to:this.from;for(let r=s,o=n.length;;){if(r==o)return r;let s=r+o>>1,h=n[s]-t||(i?this.value[s].endSide:this.value[s].startSide)-e;if(s==r)return h>=0?r:o;h>=0?o=s:r=s+1}}between(t,e,i,s){for(let n=this.findIndex(e,-1e9,!0),r=this.findIndex(i,1e9,!1,n);n(d=e.mapPos(c,l.endSide))||f==d&&l.startSide>0&&l.endSide<=0)continue;0>(d-f||l.endSide-l.startSide)||(r<0&&(r=f),l.point&&(o=Math.max(o,d-f)),i.push(l),s.push(f-r),n.push(d-r))}return{mapped:i.length?new tT(s,n,i,o):null,pos:r}}}class tD{constructor(t,e,i,s){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=s}static create(t,e,i,s){return new tD(t,e,i,s)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:s=0,filterTo:n=this.length}=t,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(tO)),this.isEmpty)return e.length?tD.of(e):this;let o=new tB(this,null,-1).goto(0),h=0,l=[],a=new tE;for(;o.value||h=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndexthis.chunkEnd(o.chunkIndex)||no.to||n=n&&t<=n+r.length&&!1===r.between(n,t-n,e-n,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return tN.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return tN.from(t).goto(e)}static compare(t,e,i,s,n=-1){let r=t.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=n),o=e.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=n),h=tR(r,o,i),l=new tI(r,h,n),a=new tI(o,h,n);i.iterGaps((t,e,i)=>tV(l,t,a,e,i,s)),i.empty&&0==i.length&&tV(l,0,a,0,0,s)}static eq(t,e,i=0,s){null==s&&(s=0x3b9ac9ff);let n=t.filter(t=>!t.isEmpty&&0>e.indexOf(t)),r=e.filter(e=>!e.isEmpty&&0>t.indexOf(e));if(n.length!=r.length)return!1;if(!n.length)return!0;let o=tR(n,r),h=new tI(n,o,0).goto(i),l=new tI(r,o,0).goto(i);for(;;){if(h.to!=l.to||!tW(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>s)return!0;h.next(),l.next()}}static spans(t,e,i,s,n=-1){let r=new tI(t,null,n).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),n=r.pointFromo&&(s.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new tE;for(let s of t instanceof tM?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i0)return t.slice().sort(tO);e=s}return t}(t):t)i.add(s.from,s.to,s.value);return i.finish()}static join(t){if(!t.length)return tD.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let s=t[i];s!=tD.empty;s=s.nextLayer)e=new tD(s.chunkPos,s.chunk,e,Math.max(s.maxPoint,e.maxPoint));return e}}tD.empty=/*@__PURE__*/new tD([],[],null,-1),tD.empty.nextLayer=tD.empty;class tE{finishChunk(t){this.chunks.push(new tT(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,t&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new tE)).add(t,e,i)}addInner(t,e,i){let s=t-this.lastTo||i.startSide-this.last.endSide;if(s<=0&&0>(t-this.lastFrom||i.startSide-this.last.startSide))throw Error("Ranges must be added sorted by `from` position and `startSide`");return!(s<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if(0>(t-this.lastTo||e.value[0].startSide-this.last.endSide))return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(tD.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=tD.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function tR(t,e,i){let s=new Map;for(let e of t)for(let t=0;t(this.to-t||this.endSide-e)&&this.gotoInner(t,e,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&s.push(new tB(r,e,i,n));return 1==s.length?s[0]:new tN(s)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)tL(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)tL(this.heap,t);0>(this.to-t||this.value.endSide-e)&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),tL(this.heap,0)}}}function tL(t,e){for(let i=t[e];;){let s=(e<<1)+1;if(s>=t.length)break;let n=t[s];if(s+1=0&&(n=t[s+1],s++),0>i.compare(n))break;t[s]=i,t[e]=n,e=s}}class tI{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=tN.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&0>(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e);)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){tF(this.active,t),tF(this.activeTo,t),tF(this.activeRank,t),this.minActive=tz(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:s,rank:n}=this.cursor;for(;e0;)e++;tH(this.active,e,i),tH(this.activeTo,e,s),tH(this.activeRank,e,n),t&&tH(t,e,this.cursor.from),this.minActive=tz(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&0>(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)){if(this.activeTo[s]>t){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&tF(i,s)}else if(this.cursor.value){if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let t=this.cursor.value;if(t.point){if(e&&this.cursor.to==this.to&&this.cursor.from=0&&i[e]=0&&!(this.activeRank[i]t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function tV(t,e,i,s,n,r){t.goto(e),i.goto(s);let o=s+n,h=s,l=s-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,s=e<0?t.to+l:i.to,n=Math.min(s,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&tW(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,n,t.point,i.point):n>h&&!tW(t.active,i.active)&&r.compareRange(h,n,t.active,i.active),s>o)break;h=s,e<=0&&t.next(),e>=0&&i.next()}}function tW(t,e){if(t.length!=e.length)return!1;for(let i=0;i=e;i--)t[i+1]=t[i];t[e]=i}function tz(t,e){let i=-1,s=1e9;for(let n=0;n(e[n]-s||t[n].endSide-t[i].endSide)&&(i=n,s=e[n]);return i}let t_="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),tq="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),tj="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class tY{constructor(t,e){this.rules=[];let{finish:i}=e||{};function s(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}for(let e in t)!function t(e,n,r,o){let h=[],l=/^@(\w+)\b/.exec(e[0]),a=l&&"keyframes"==l[1];if(l&&null==n)return r.push(e[0]+";");for(let i in n){let o=n[i];if(/&/.test(i))t(i.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((t,e)=>t.concat(e)),o,r);else if(o&&"object"==typeof o){if(!l)throw RangeError("The value of a property ("+i+") should be a primitive value.");t(s(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+o+";")}(h.length||a)&&r.push((!i||l||o?e:e.map(i)).join(", ")+" {"+h.join(" ")+"}")}(s(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=tj[t_]||1;return tj[t_]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let s=t[tq],n=i&&i.nonce;s?n&&s.setNonce(n):s=new tX(t,n),s.mount(Array.isArray(e)?e:[e],t)}}let tK=new Map;class tX{constructor(t,e){let i=t.ownerDocument||t,s=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&s.CSSStyleSheet){let e=tK.get(i);if(e)return t[tq]=e;this.sheet=new s.CSSStyleSheet,tK.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[tq]=this}mount(t,e){let i=this.sheet,s=0,n=0;for(let e=0;e-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),i)for(let t=0;te.adoptedStyleSheets.indexOf(this.sheet)&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{let t="";for(let e=0;e",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},tQ="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),tG="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),tJ=0;tJ<10;tJ++)t$[48+tJ]=t$[96+tJ]=String(tJ);for(var tJ=1;tJ<=24;tJ++)t$[tJ+111]="F"+tJ;for(var tJ=65;tJ<=90;tJ++)t$[tJ]=String.fromCharCode(tJ+32),tU[tJ]=String.fromCharCode(tJ);for(var tZ in t$)tU.hasOwnProperty(tZ)||(tU[tZ]=t$[tZ]);function t0(t){return(11==t.nodeType?t.getSelection?t:t.ownerDocument:t).getSelection()}function t1(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function t2(t,e){if(!e.anchorNode)return!1;try{return t1(t,e.anchorNode)}catch(t){return!1}}function t3(t){return 3==t.nodeType?en(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function t4(t,e,i,s){return!!i&&(t6(t,e,i,s,-1)||t6(t,e,i,s,1))}function t5(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function t8(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function t6(t,e,i,s,n){for(;;){if(t==i&&e==s)return!0;if(e==(n<0?0:t9(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=t5(t)+(n<0?0:1),t=i}else{if(1!=t.nodeType||1==(t=t.childNodes[e+(n<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=n<0?t9(t):0}}}function t9(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function t7(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function et(t,e){let i=e.width/t.offsetWidth,s=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||1>Math.abs(e.width-t.offsetWidth))&&(i=1),(s>.995&&s<1.005||!isFinite(s)||1>Math.abs(e.height-t.offsetHeight))&&(s=1),{scaleX:i,scaleY:s}}class ee{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?t9(e):0),i,Math.min(t.focusOffset,i?t9(i):0))}set(t,e,i,s){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=s}}let ei=null;function es(t){if(t.setActive)return t.setActive();if(ei)return t.focus(ei);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==ei?{get preventScroll(){return ei={preventScroll:!0},!0}}:void 0),!ei){ei=!1;for(let t=0;tMath.max(1,t.scrollHeight-t.clientHeight-4)}function el(t,e){for(let i=t,s=e;;){if(3==i.nodeType&&s>0)return{node:i,offset:s};if(1==i.nodeType&&s>0){if("false"==i.contentEditable)return null;s=t9(i=i.childNodes[s-1])}else{if(!i.parentNode||t8(i))return null;s=t5(i),i=i.parentNode}}}function ea(t,e){for(let i=t,s=e;;){if(3==i.nodeType&&se)return i.domBoundsAround(t,e,l);if(c>=t&&-1==s&&(s=h,n=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:n,to:o<0?i+this.length:o,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r=0?this.children[r].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=ef){this.markDirty();for(let s=t;si.indexOf(t)&&t.destroy()}i.length<250?this.children.splice(t,e-t,...i):this.children=[].concat(this.children.slice(0,t),i,this.children.slice(e));for(let t=0;tthis.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function eg(t,e,i,s,n,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,f=r.length?r[r.length-1]:null,d=f?f.breakAfter:o;if(!(e==s&&c&&!o&&!d&&r.length<2&&c.merge(i,n,r.length?f:null,0==i,h,l))){if(s0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,0)?c.breakAfter=r.shift().breakAfter:(i2);var eO={mac:eM||/*@__PURE__*//Mac/.test(ev.platform),windows:/*@__PURE__*//Win/.test(ev.platform),linux:/*@__PURE__*//Linux|X11/.test(ev.platform),ie:ex,ie_version:ey?ew.documentMode||6:ek?+ek[1]:eb?+eb[1]:0,gecko:eS,gecko_version:eS?+/*@__PURE__*/(/Firefox\/(\d+)/.exec(ev.userAgent)||[0,0])[1]:0,chrome:!!eC,chrome_version:eC?+eC[1]:0,ios:eM,android:/*@__PURE__*//Android\b/.test(ev.userAgent),webkit:eP,safari:eA,webkit_version:eP?+/*@__PURE__*/(/\bAppleWebKit\/(\d+)/.exec(ev.userAgent)||[0,0])[1]:0,tabSize:null!=ew.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class eT extends ed{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags)&&(!i||i instanceof eT&&!(this.length-(e-t)+i.length>256)&&!(8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new eT(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new ec(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return function(t,e,i){let s=t.nodeValue.length;e>s&&(e=s);let n=e,r=e,o=0;0==e&&i<0||e==s&&i>=0?!(eO.chrome||eO.gecko)&&(e?(n--,o=1):r=0)?0:h.length-1];return eO.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,t=>t.width)||l),o?t7(l,o<0):l||null}(this.dom,t,e)}}class eD extends ed{constructor(t,e=[],i=0){for(let s of(super(),this.mark=t,this.children=e,this.length=i,e))s.setParent(this)}setAttrs(t){if(eo(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!((this.flags|t.flags)&8)}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,s,n,r){return(!i||!!(i instanceof eD&&i.mark.eq(this.mark))&&(!t||!(n<=0))&&(!(et&&e.push(i=t&&(s=n),i=o,n++}let r=this.length-t;return this.length=t,s>-1&&(this.children.length=s,this.markDirty()),new eD(this.mark,e,r)}domAtPos(t){return eB(this,t)}coordsAt(t,e){return eN(this,t,e)}}class eE extends ed{static create(t,e,i){return new eE(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=eE.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,s,n,r){return(!i||i instanceof eE&&!!this.widget.compare(i.widget)&&(!(t>0)||!(n<=0))&&(!(e0)?ec.before(this.dom):ec.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let s=this.dom.getClientRects(),n=null;if(!s.length)return null;let r=this.side?this.side<0:t>0;for(let e=r?s.length-1:0;n=s[e],t>0?0!=e:e!=s.length-1&&!(n.top0?ec.before(this.dom):ec.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return i.empty}get isHidden(){return!0}}function eB(t,e){let i=t.dom,{children:s}=t,n=0;for(let t=0;n=r.getSide())){if(e>t&&e0;t--){let e=s[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=n;t=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(f>h||a==f&&c.getSide()>0)?(r=c,o=h-a):(ac.getSide()&&!c.isHidden)&&(s=c,n=h-a)),a=f}}(t,e);let h=(i<0?s:r)||s||r;return h?h.coordsAt(Math.max(0,h==s?n:o),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=t3(e);return i[i.length-1]||null}(t)}function eL(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}eT.prototype.children=eE.prototype.children=eR.prototype.children=ef;let eI=/*@__PURE__*/Object.create(null);function eV(t,e,i){if(t==e)return!0;t||(t=eI),e||(e=eI);let s=Object.keys(t),n=Object.keys(e);if(s.length-(i&&s.indexOf(i)>-1?1:0)!=n.length-(i&&n.indexOf(i)>-1?1:0))return!1;for(let r of s)if(r!=i&&(-1==n.indexOf(r)||t[r]!==e[r]))return!1;return!0}function eW(t,e,i){let s=!1;if(e)for(let n in e)i&&n in i||(s=!0,"style"==n?t.style.cssText="":t.removeAttribute(n));if(i)for(let n in i)e&&e[n]==i[n]||(s=!0,"style"==n?t.style.cssText=i[n]:t.setAttribute(n,i[n]));return s}class eF{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return -1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var eH=((k=eH||(eH={}))[k.Text=0]="Text",k[k.WidgetBefore=1]="WidgetBefore",k[k.WidgetAfter=2]="WidgetAfter",k[k.WidgetRange=3]="WidgetRange",k);class ez extends tA{constructor(t,e,i,s){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=s}get heightRelevant(){return!1}static mark(t){return new e_(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new ej(t,e,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,i,s;if(t.isBlockGap)i=-5e8,s=4e8;else{let{start:n,end:r}=eY(t,e);i=(n?e?-3e8:-1:5e8)-1,s=(r?e?2e8:1:-6e8)+1}return new ej(t,i,s,e,t.widget||null,!0)}static line(t){return new eq(t)}static set(t,e=!1){return tD.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}ez.none=tD.empty;class e_ extends ez{constructor(t){let{start:e,end:i}=eY(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof e_&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&eV(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw RangeError("Mark decorations may not be empty");return super.range(t,e)}}e_.prototype.point=!1;class eq extends ez{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof eq&&this.spec.class==t.spec.class&&eV(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}eq.prototype.mapMode=E.TrackBefore,eq.prototype.point=!0;class ej extends ez{constructor(t,e,i,s,n,r){super(e,i,n,t),this.block=s,this.isReplace=r,this.mapMode=s?e<=0?E.TrackBefore:E.TrackAfter:E.TrackDel}get type(){return this.startSide!=this.endSide?eH.WidgetRange:this.startSide<=0?eH.WidgetBefore:eH.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){var e,i;return t instanceof ej&&((e=this.widget)==(i=t.widget)||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function eY(t,e=!1){let{inclusiveStart:i,inclusiveEnd:s}=t;return null==i&&(i=t.inclusive),null==s&&(s=t.inclusive),{start:null!=i?i:e,end:null!=s?s:e}}function eK(t,e,i,s=0){let n=i.length-1;n>=0&&i[n]+s>=t?i[n]=Math.max(i[n],e):i.push(t,e)}ej.prototype.point=!0;class eX extends ed{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,s,n,r){if(i){if(!(i instanceof eX))return!1;this.dom||i.transferDOM(this)}return s&&this.setDeco(i?i.attrs:null),em(this,t,e,i?i.children.slice():[],n,r),!0}split(t){let e=new eX;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i:i,off:s}=this.childPos(t);s&&(e.append(this.children[i].split(s),0),this.children[i].merge(s,this.children[i].length,null,!1,0,0),i++);for(let t=i;t0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){eV(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){!function t(e,i,s){let n,{children:r}=e;s>0&&i instanceof eD&&r.length&&(n=r[r.length-1])instanceof eD&&n.mark.eq(i.mark)?t(n,i.children[0],s-1):(r.push(i),i.setParent(e)),e.length+=i.length}(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=eL(e,this.attrs||{})),i&&(this.attrs=eL({class:i},this.attrs||{}))}domAtPos(t){return eB(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(eo(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),void 0!==this.prevAttrs&&(eW(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let s=this.dom.lastChild;for(;s&&ed.get(s)instanceof eD;)s=s.lastChild;if(!s||!this.length||"BR"!=s.nodeName&&(null===(i=ed.get(s))||void 0===i?void 0:i.isEditable)==!1&&(!eO.ios||!this.children.some(t=>t instanceof eT))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t=0,e;for(let i of this.children){if(!(i instanceof eT)||/[^ -~]/.test(i.text))return null;let s=t3(i.dom);if(1!=s.length)return null;t+=s[0].width,e=s[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(t,e){let i=eN(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(2>Math.abs(e-t.lineHeight)&&t.textHeight=e){if(n instanceof eX)return n;if(r>e)break}s=r+n.breakAfter}return null}}class e$ extends ed{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,s,n,r){return(!i||i instanceof e$&&!!this.widget.compare(i.widget)&&(!(t>0)||!(n<=0))&&(!(e0)}}class eU extends eF{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class eQ{constructor(t,e,i,s){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=s,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof e$&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new eX),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(eG(new eR(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof e$||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:s}=this.cursor.next(this.skip);if(this.skip=0,s)throw Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let s=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(eG(new eT(this.text.slice(this.textOff,this.textOff+s)),e),i),this.atCursorPos=!0,this.textOff+=s,t-=s,i=0}}span(t,e,i,s){this.buildText(e-t,i,s),this.pos=e,this.openStart<0&&(this.openStart=s)}point(t,e,i,s,n,r){if(this.disallowBlockEffectsFor[r]&&i instanceof ej){if(i.block)throw RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw RangeError("Decorations that replace line breaks may not be specified via plugins")}let o=e-t;if(i instanceof ej){if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new e$(i.widget||eJ.block,o,i));else{let r=eE.create(i.widget||eJ.inline,o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&n<=s.length&&(t0),l=!r.isEditable&&(ts.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(s),h&&(a.append(eG(new eR(1),s),n),n=s.length+Math.max(0,n-s.length)),a.append(eG(r,s),n),this.atCursorPos=l,this.pendingBuffer=l?ts.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=s.slice())}}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=n)}static build(t,e,i,s,n){let r=new eQ(t,e,i,n);return r.openEnd=tD.spans(s,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function eG(t,e){for(let i of e)t=new eD(i,[t],t.length);return t}class eJ extends eF{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}eJ.inline=/*@__PURE__*/new eJ("span"),eJ.block=/*@__PURE__*/new eJ("div");var eZ=((x=eZ||(eZ={}))[x.LTR=0]="LTR",x[x.RTL=1]="RTL",x);let e0=eZ.LTR,e1=eZ.RTL;function e2(t){let e=[];for(let i=0;i=e){if(o.level==i)return r;(n<0||(0!=s?s<0?o.frome:t[n].level>o.level))&&(n=r)}}if(n<0)throw RangeError("Index out of range");return n}}let it=[];function ie(t){return[new e7(0,t,0)]}let ii="",is=/*@__PURE__*/j.define(),ir=/*@__PURE__*/j.define(),io=/*@__PURE__*/j.define(),ih=/*@__PURE__*/j.define(),il=/*@__PURE__*/j.define(),ia=/*@__PURE__*/j.define(),ic=/*@__PURE__*/j.define(),id=/*@__PURE__*/j.define(),iu=/*@__PURE__*/j.define(),ip=/*@__PURE__*/j.define({combine:t=>t.some(t=>t)}),ig=/*@__PURE__*/j.define({combine:t=>t.some(t=>t)}),im=/*@__PURE__*/j.define();class iv{constructor(t,e="nearest",i="nearest",s=5,n=5,r=!1){this.range=t,this.y=e,this.x=i,this.yMargin=s,this.xMargin=n,this.isSnapshot=r}map(t){return t.empty?this:new iv(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new iv(z.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}let iw=/*@__PURE__*/tm.define({map:(t,e)=>t.map(e)}),ib=/*@__PURE__*/tm.define();function iy(t,e,i){let s=t.facet(ih);s.length?s[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}let ik=/*@__PURE__*/j.define({combine:t=>!t.length||t[0]}),ix=0,iS=/*@__PURE__*/j.define();class iC{constructor(t,e,i,s,n){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=s,this.extension=n(this)}static define(t,e){let{eventHandlers:i,eventObservers:s,provide:n,decorations:r}=e||{};return new iC(ix++,t,i,s,t=>{let e=[iS.of(t)];return r&&e.push(iO.of(e=>{let i=e.plugin(t);return i?r(i):ez.none})),n&&e.push(n(t)),e})}static fromClass(t,e){return iC.define(e=>new t(e),e)}}class iP{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(iy(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){iy(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){iy(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}let iA=/*@__PURE__*/j.define(),iM=/*@__PURE__*/j.define(),iO=/*@__PURE__*/j.define(),iT=/*@__PURE__*/j.define(),iD=/*@__PURE__*/j.define(),iE=/*@__PURE__*/j.define();function iR(t,e){let i=t.state.facet(iE);if(!i.length)return i;let s=i.map(e=>e instanceof Function?e(t):e),n=[];return tD.spans(s,e.from,e.to,{point(){},span(t,i,s,r){let o=t-e.from,h=i-e.from,l=n;for(let t=s.length-1;t>=0;t--,r--){let i=s[t].spec.bidiIsolate,n;if(null==i&&(i=function(t,e,i){for(let s=e;s0&&l.length&&(n=l[l.length-1]).to==o&&n.direction==i)n.to=h,l=n.inner;else{let t={from:o,to:h,direction:i,inner:[]};l.push(t),l=t.inner}}}}),n}let iB=/*@__PURE__*/j.define();function iN(t){let e=0,i=0,s=0,n=0;for(let r of t.state.facet(iB)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(s=Math.max(s,o.top)),null!=o.bottom&&(n=Math.max(n,o.bottom)))}return{left:e,right:i,top:s,bottom:n}}let iL=/*@__PURE__*/j.define();class iI{constructor(t,e,i,s){this.fromA=t,this.toA=e,this.fromB=i,this.toB=s}join(t){return new iI(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let s=t[e-1];if(!(s.fromA>i.toA)){if(s.toAa)break;n+=2}if(!h)return i;new iI(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class iV{constructor(t,e,i){for(let s of(this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=B.empty(this.startState.doc.length),i))this.changes=this.changes.compose(s.changes);let s=[];this.changes.iterChangedRanges((t,e,i,n)=>s.push(new iI(t,e,i,n))),this.changedRanges=s}static create(t,e,i){return new iV(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}class iW extends ed{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=ez.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new eX],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new iI(0,0,0,t.state.doc.length)],0,null)}update(t){var e,i,s,n,r,o;let h,l;let a=t.changedRanges;this.minWidth>0&&a.length&&(a.every(({fromA:t,toA:e})=>ethis.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let c=-1;!(this.view.inputState.composing>=0)||this.view.observer.editContext||((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?c=this.domChanged.newSel.head:(i=t.changes,s=this.hasComposition,h=!1,s&&i.iterChangedRanges((t,e)=>{ts.from&&(h=!0)}),h||t.selectionSet||(c=t.state.selection.main.head)));let f=c>-1?function(t,e,i){let s=iF(t,i);if(!s)return null;let{node:n,from:r,to:o}=s,h=n.nodeValue;if(/[\n\r]/.test(h)||t.state.doc.sliceString(s.from,s.to)!=h)return null;let l=e.invertedDesc,a=new iI(l.mapPos(r),l.mapPos(o),r,o),c=[];for(let e=n.parentNode;;e=e.parentNode){let i=ed.get(e);if(i instanceof eD)c.push({node:e,deco:i.mark});else{if(i instanceof eX||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:a,text:n,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new e_({inclusive:!0,attributes:function(t){let e=Object.create(null);for(let i=0;i{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=eO.chrome||eO.ios?{node:s.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||s.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(t=>t.flags&=-9);let n=[];if(this.view.viewport.from||this.view.viewport.to=0?s[t]:null;if(!e)break;let{fromA:r,toA:o,fromB:h,toB:l}=e,a,c,f,d;if(i&&i.range.fromBh){let t=eQ.build(this.view.state.doc,h,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=eQ.build(this.view.state.doc,i.range.toB,l,this.decorations,this.dynamicDecorationMap);c=t.breakAtStart,f=t.openStart,d=e.openEnd;let s=this.compositionView(i);e.breakAtStart?s.breakAfter=1:e.content.length&&s.merge(s.length,s.length,e.content[0],!1,e.openStart,0)&&(s.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&s.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),a=t.content.concat(s).concat(e.content)}else({content:a,breakAtStart:c,openStart:f,openEnd:d}=eQ.build(this.view.state.doc,h,l,this.decorations,this.dynamicDecorationMap));let{i:u,off:p}=n.findPos(o,1),{i:g,off:m}=n.findPos(r,-1);eg(this,g,m,u,p,a,c,f,d)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){for(let e of(this.editContextFormatting=this.editContextFormatting.map(t.changes),t.transactions))for(let t of e.effects)t.is(ib)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new eT(t.text.nodeValue);for(let{deco:i}of(e.flags|=8,t.marks))e=new eD(i,[e],e.length);let i=new eX;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some(t=>7&t.flags)?1:0),this.markedForComposition.add(e);let i=ed.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),s=this.children[i.i];e(t.line,s);for(let n=t.marks.length-1;n>=-1;n--)i=s.childPos(i.off,1),s=s.children[i.i],e(n>=0?t.marks[n].node:t.text,s)}updateSelection(t=!1,e=!1){var i;(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let s=this.view.root.activeElement,n=s==this.dom,r=!n&&t2(this.dom,this.view.observer.selectionRange)&&!(s&&this.dom.contains(s));if(!(n||e||r))return;let o=this.forceSelection;this.forceSelection=!1;let h=this.view.state.selection.main,l=this.moveToLine(this.domAtPos(h.anchor)),a=h.empty?l:this.moveToLine(this.domAtPos(h.head));if(eO.gecko&&h.empty&&!this.hasComposition&&1==(i=l).node.nodeType&&i.node.firstChild&&(0==i.offset||"false"==i.node.childNodes[i.offset-1].contentEditable)&&(i.offset==i.node.childNodes.length||"false"==i.node.childNodes[i.offset].contentEditable)){let t=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(t,l.node.childNodes[l.offset]||null)),l=a=new ec(t,0),o=!0}let c=this.view.observer.selectionRange;!o&&c.focusNode&&(t4(l.node,l.offset,c.anchorNode,c.anchorOffset)&&t4(a.node,a.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,h))||(this.view.observer.ignore(()=>{eO.android&&eO.chrome&&this.dom.contains(c.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=t0(this.view.root);if(t){if(h.empty){if(eO.gecko){var e,i;let t=(e=l.node,i=l.offset,1!=e.nodeType?0:(i&&"false"==e.childNodes[i-1].contentEditable?1:0)|(ih.head&&([l,a]=[a,l]),e.setEnd(a.node,a.offset),e.setStart(l.node,l.offset),t.removeAllRanges(),t.addRange(e)}}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(l,a)),this.impreciseAnchor=l.precise?null:new ec(c.anchorNode,c.anchorOffset),this.impreciseHead=a.precise?null:new ec(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&t4(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=t0(t.root),{anchorNode:s,anchorOffset:n}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let r=eX.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(s,n)}moveToLine(t){let e=this.dom,i;if(t.node!=e)return t;for(let s=t.offset;!i&&s=0;s--){let t=ed.get(e.childNodes[s]);t instanceof eX&&(i=t.domAtPos(t.length))}return i?new ec(i.node,i.offset,!0):t}nearest(t){for(let e=t;e;){let t=ed.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e=0;r--){let o=this.children[r],h=n-o.breakAfter,l=h-o.length;if(ht||o.covers(1))&&(!i||o instanceof eX&&!(i instanceof eX&&e>=0)))i=o,s=l;else if(i&&l==t&&h==t&&o instanceof e$&&2>Math.abs(e)){if(o.deco.startSide<0)break;r&&(i=null)}n=l}return i?i.coordsAt(t-s,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),s=this.children[e];if(!(s instanceof eX))return null;for(;s.children.length;){let{i:t,off:e}=s.childPos(i,1);for(;;t++){if(t==s.children.length)return null;if((s=s.children[t]).length)break}i=e}if(!(s instanceof eT))return null;let n=u(s.text,i);if(n==i)return null;let r=en(s.dom,i,n).getClientRects();for(let t=0;tMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==eZ.LTR;for(let t=0,l=0;ls)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),r){let e=a.dom.lastChild,s=e?t3(e):[];if(s.length){let e=s[s.length-1],r=h?e.right-i.left:i.right-e.left;r>o&&(o=r,this.minWidth=n,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?eZ.RTL:eZ.LTR}measureTextSize(){for(let t of this.children)if(t instanceof eX){let e=t.measureTextSize();if(e)return e}let t=document.createElement("div"),e,i,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(t);let n=t3(t.firstChild)[0];e=t.getBoundingClientRect().height,i=n?n.width/27:7,s=n?n.height:e,t.remove()}),{lineHeight:e,charWidth:i,textHeight:s}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new ep(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,s=0;;s++){let n=s==e.viewports.length?null:e.viewports[s],r=n?n.from-1:this.length;if(r>i){let s=(e.lineBlockAt(r).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(ez.replace({widget:new eU(s),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!n)break;i=n.to+1}return ez.set(t)}updateDeco(){let t=1,e=this.view.state.facet(iO).map(e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e),i=!1,s=this.view.state.facet(iT).map((t,e)=>{let s="function"==typeof t;return s&&(i=!0),s?t(this.view):t});for(s.length&&(this.dynamicDecorationMap[t++]=i,e.push(tD.join(s))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];te.anchor?-1:1),s;if(!i)return;!e.empty&&(s=this.coordsAt(e.anchor,e.anchor>e.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 n=iN(this.view),r={left:i.left-n.left,top:i.top-n.top,right:i.right+n.right,bottom:i.bottom+n.bottom},{offsetWidth:o,offsetHeight:h}=this.view.scrollDOM;!function(t,e,i,s,n,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t,f=!1;c&&!f;)if(1==c.nodeType){let t,d=c==l.body,u=1,p=1;if(d)t=function(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:u,scaleY:p}=et(c,e)),t={left:e.left,right:e.left+c.clientWidth*u,top:e.top,bottom:e.top+c.clientHeight*p}}let g=0,m=0;if("nearest"==n)e.top0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+m+o)):e.bottom>t.bottom&&(m=e.bottom-t.bottom+o,i<0&&e.top-m0&&e.right>t.right+g&&(g=e.right-t.right+g+r)):e.right>t.right&&(g=e.right-t.right+r,i<0&&e.leftMath.abs(t-g)&&(s="nearest"),i&&1>Math.abs(i-m)&&(n="nearest")}}if(d)break;c=c.assignedSlot||c.parentNode}else if(11==c.nodeType)c=c.host;else break}(this.view.scrollDOM,r,e.heade.top+1}function i_(t,e){return et.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function ij(t,e,i){let s=t.nodeValue.length,n=-1,r=1e9,o=0;for(let h=0;hi?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c=(a.left+a.right)/2,s=i;if((eO.chrome||eO.gecko)&&en(t,h).getBoundingClientRect().left==a.right&&(s=!i),c<=0)return{node:t,offset:h+(s?1:0)};n=h+(s?1:0),r=c}}}return{node:t,offset:n>-1?n:o>0?t.nodeValue.length:0}}function iY(t,e,i,s=-1){var n,r;let o=t.contentDOM.getBoundingClientRect(),h=o.top+t.viewState.paddingTop,l,{docHeight:a}=t.viewState,{x:c,y:f}=e,d=f-h;if(d<0)return 0;if(d>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,n=!1;(l=t.elementAtHeight(d)).type!=eH.Text;)for(;!((d=s>0?l.bottom+e:l.top-e)>=0)||!(d<=a);){if(n)return i?null:0;n=!0,s=-s}f=h+d;let u=l.from;if(ut.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:iK(t,o,l,c,f);let p=t.dom.ownerDocument,g=t.root.elementFromPoint?t.root:p,m=g.elementFromPoint(c,f);m&&!t.contentDOM.contains(m)&&(m=null),!m&&(c=Math.max(o.left+1,Math.min(o.right-1,c)),(m=g.elementFromPoint(c,f))&&!t.contentDOM.contains(m)&&(m=null));let v,w=-1;if(m&&(null===(n=t.docView.nearest(m))||void 0===n?void 0:n.isEditable)!=!1){if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,f);t&&({offsetNode:v,offset:w}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,f);e&&({startContainer:v,startOffset:w}=e,(!t.contentDOM.contains(v)||eO.safari&&function(t,e,i){let s;if(3!=t.nodeType||e!=(s=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return en(t,s-1,s).getBoundingClientRect().left>i}(v,w,c)||eO.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}return i-(1==t.nodeType?t.getBoundingClientRect():en(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}(v,w,c))&&(v=void 0))}v&&(w=Math.min(t9(v),w))}if(!v||!t.docView.dom.contains(v)){let e=eX.find(t.docView,u);if(!e)return d>l.top+l.height/2?l.to:l.from;({node:v,offset:w}=function t(e,i,s){let n,r,o,h,l,a,c,f,d=!1;for(let g=e.firstChild;g;g=g.nextSibling){let e=t3(g);for(let m=0;mi?u.left-i:Math.max(0,i-u.right),b=(p=v).top>s?p.top-s:Math.max(0,s-p.bottom);if(0==w&&0==b)return 3==g.nodeType?ij(g,i,s):t(g,i,s);if(!l||f>b||f==b&&c>w){l=g,a=v,c=w,f=b;let t=b?s0?m0)}0==w?s>v.bottom&&(!o||o.bottomv.top)&&(r=g,h=v):o&&iz(o,v)?o=iq(o,v.bottom):h&&iz(h,v)&&(h=i_(h,v.top))}}if(o&&o.bottom>=s?(l=n,a=o):h&&h.top<=s&&(l=r,a=h),!l)return{node:e,offset:0};let g=Math.max(a.left,Math.min(a.right,i));if(3==l.nodeType)return ij(l,g,s);if(d&&"false"!=l.contentEditable)return t(l,g,s);let m=Array.prototype.indexOf.call(e.childNodes,l)+(i>=(a.left+a.right)/2?1:0);return{node:e,offset:m}}(e.dom,c,f))}let b=t.docView.nearest(v);if(!b)return null;if(!b.isWidget||(null===(r=b.dom)||void 0===r?void 0:r.nodeType)!=1)return b.localPosFromDOM(v,w)+b.posAtStart;{let t=b.dom.getBoundingClientRect();return e.y1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;r+=Math.floor((n-i.top-(t.defaultLineHeight-e)*.5)/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,s){for(let s=0,n=0;;){if(n>=e)return s;if(s==t.length)break;n+=9==t.charCodeAt(s)?i-n%i:1,s=u(t,s)}return t.length}(o,r,t.state.tabSize)}function iX(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type)){for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==eH.Text))return t}return i}function i$(t,e,i,s){let n=t.state.doc.lineAt(e.head),r=t.bidiSpans(n),o=t.textDirectionAt(n.from);for(let h=e,l=null;;){let e=function(t,e,i,s,n){var r;let o=s.head-t.from,h=e7.find(e,o,null!==(r=s.bidiLevel)&&void 0!==r?r:-1,s.assoc),l=e[h],a=l.side(n,i);if(o==a){let t=h+=n?1:-1;if(t<0||t>=e.length)return null;o=(l=e[h=t]).side(!n,i),a=l.side(n,i)}let c=u(t.text,o,l.forward(n,i));(cl.to)&&(c=a),ii=t.text.slice(Math.min(o,c),Math.max(o,c));let f=h==(n?e.length-1:0)?null:e[h+(n?1:-1)];return f&&c==a&&f.level+(n?0:1){if(e>t&&ee(t)),i.from,e.head>i.from?-1:1);return s==i.from?i:z.cursor(s,st)&&this.lineBreak(),s=n}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let n=-1,r=1,o;if(this.lineSeparator?(n=e.indexOf(this.lineSeparator,i),r=this.lineSeparator.length):(o=s.exec(e))&&(n=o.index,r=o[0].length),this.append(e.slice(i,n<0?e.length:n)),n<0)break;if(this.lineBreak(),r>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=r-1);i=n+r}}readNode(t){if(t.cmIgnore)return;let e=ed.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(!function(t,e,i){for(;;){if(!e||i-1;let{impreciseHead:n,impreciseAnchor:r}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=n||r?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r}=t.observer.selectionRange;return i&&(e.push(new iJ(i,s)),(n!=i||r!=s)&&e.push(new iJ(n,r))),e}(t),i=new iG(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,s=2==t.length?t[1].pos:i;return i>-1&&s>-1?z.single(i+e,s+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=n&&n.node==e.focusNode&&n.offset==e.focusOffset||!t1(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),s=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!t1(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),o=t.viewport;if((eO.ios||eO.chrome)&&t.state.selection.main.empty&&i!=s&&(o.from>0||o.toDate.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:h}=e.bounds,l=r.from,a=null;(8===o||eO.android&&e.text.length0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==s){let t=Math.max(0,r-Math.min(o,h));i-=o+t-r}if(o=o?r-i:0;r-=t,h=r+(h-o),o=r}else if(h=h?r-i:0;r-=t,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}(t.state.doc.sliceString(n,h,"￿"),e.text,l-n,a);c&&(eO.chrome&&13==o&&c.toB==c.from+2&&"￿￿"==e.text.slice(c.from,c.toB)&&c.toB--,s={from:n+c.from,to:n+c.toA,insert:i.of(e.text.slice(c.from,c.toB).split("￿"))})}else n&&(!t.hasFocus&&t.state.facet(ik)||n.main.eq(r))&&(n=null);if(!s&&!n)return!1;if(!s&&e.typeOver&&!r.empty&&n&&n.main.empty?s={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,r.to)}:s&&s.from>=r.from&&s.to<=r.to&&(s.from!=r.from||s.to!=r.to)&&r.to-r.from-(s.to-s.from)<=4?s={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,s.from).append(s.insert).append(t.state.doc.slice(s.to,r.to))}:(eO.mac||eO.android)&&s&&s.from==s.to&&s.from==r.head-1&&/^\. ?$/.test(s.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==s.insert.length&&(n=z.single(n.main.anchor-1,n.main.head-1)),s={from:r.from,to:r.to,insert:i.of([" "])}):eO.chrome&&s&&s.from==s.to&&s.from==r.head&&"\n "==s.insert.toString()&&t.lineWrapping&&(n&&(n=z.single(n.main.anchor-1,n.main.head-1)),s={from:r.from,to:r.to,insert:i.of([" "])}),s)return i1(t,s,n,o);if(!n||n.main.eq(r))return!1;{let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}}function i1(t,e,i,s=-1){let n;if(eO.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(eO.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&" "==t.state.sliceDoc(e.from,r.from))&&1==e.insert.length&&2==e.insert.lines&&er(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&0==e.insert.length||8==s&&e.insert.lengthr.head)&&er(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&0==e.insert.length&&er(t.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let h=()=>n||(n=function(t,e,i){let s,n=t.state,r=n.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=r.frome.to?n.sliceDoc(e.to,r.to):"";s=n.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=n.changes(e),h=i&&i.main.to<=o.newLength?i.main:void 0;if(n.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let l=t.state.sliceDoc(e.from,e.to),a,c=i&&iF(t,i.main.head);if(c){let t=e.insert.length-(e.to-e.from);a={from:c.from,to:c.to-t}}else a=t.state.doc.lineAt(r.head);let f=r.to-e.to,d=r.to-r.from;s=n.changeByRange(i=>{if(i.from==r.from&&i.to==r.to)return{changes:o,range:h||i.map(o)};let s=i.to-f,c=s-l.length;if(i.to-i.from!=d||t.state.sliceDoc(c,s)!=l||i.to>=a.from&&i.from<=a.to)return{range:i};let u=n.changes({from:c,to:s,insert:e.insert}),p=i.to-r.to;return{changes:u,range:h?z.range(Math.max(0,h.anchor+p),Math.max(0,h.head+p)):i.map(u)}})}else s={changes:o,selection:h&&n.selection.replaceRange(h)}}let o="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,o+=".compose",t.inputState.compositionFirstChange&&(o+=".start",t.inputState.compositionFirstChange=!1)),n.update(s,{userEvent:o,scrollIntoView:!0})}(t,e,i));return t.state.facet(ia).some(i=>i(t,e.from,e.to,o,h))||t.dispatch(h()),!0}class i2{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){var e;this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,eO.safari&&t.contentDOM.addEventListener("input",()=>null),eO.gecko&&(e=t.contentDOM.ownerDocument,sv.has(e)||(sv.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{})))}handleEvent(t){!(!function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i=e.target,s;i!=t.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(s=ed.get(i))&&s.ignoreEvent(e))return!1;return!0}(this.view,t)||this.ignoreDuringComposition(t))&&("keydown"==t.type&&this.keydown(t)||this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=function(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec;if(t&&t.domEventHandlers)for(let s in t.domEventHandlers){let n=t.domEventHandlers[s];n&&i(s).handlers.push(i3(e.value,n))}if(t&&t.domEventObservers)for(let s in t.domEventObservers){let n=t.domEventObservers[s];n&&i(s).observers.push(i3(e.value,n))}}for(let t in i7)i(t).handlers.push(i7[t]);for(let t in st)i(t).observers.push(st[t]);return e}(t),i=this.handlers,s=this.view.contentDOM;for(let t in e)if("scroll"!=t){let n=!e[t].handlers.length,r=i[t];r&&!r.handlers.length!=n&&(s.removeEventListener(t,this.handleEvent),r=null),r||s.addEventListener(t,this.handleEvent,{passive:n})}for(let t in i)"scroll"==t||e[t]||s.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){let e;return this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),!!(9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))||((this.tabFocusMode>0&&27!=t.keyCode&&0>i8.indexOf(t.keyCode)&&(this.tabFocusMode=-1),eO.android&&eO.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))?(this.view.observer.delayAndroidKey(t.key,t.keyCode),!0):eO.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((e=i4.find(e=>e.keyCode==t.keyCode))&&!t.ctrlKey||i5.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0):(229!=t.keyCode&&this.view.observer.forceFlush(),!1))}flushIOSKey(t){let e=this.pendingIOSKey;return!(!e||"Enter"==e.key&&t&&t.from0||!!(eO.safari&&!eO.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function i3(t,e){return(i,s)=>{try{return e.call(t,s,i)}catch(t){iy(i.state,t)}}}let i4=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],i5="dthko",i8=[16,17,18,20,91,92,224,225];function i6(t){return .7*Math.max(0,t)+8}class i9{constructor(t,e,i,s){let n;this.view=t,this.startEvent=e,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=function(t){let e=t.ownerDocument,i,s;for(let n=t.parentNode;n&&n!=e.body&&(!i||!s);)if(1==n.nodeType)!s&&n.scrollHeight>n.clientHeight&&(s=n),!i&&n.scrollWidth>n.clientWidth&&(i=n),n=n.assignedSlot||n.parentNode;else if(11==n.nodeType)n=n.host;else break;return{x:i,y:s}}(t.contentDOM),this.atoms=t.state.facet(iD).map(e=>e(t));let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(tC.allowMultipleSelections)&&((n=t.state.facet(is)).length?n[0](e):eO.mac?e.metaKey:e.ctrlKey),this.dragging=!!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let s=t0(t.root);if(!s||0==s.rangeCount)return!0;let n=s.getRangeAt(0).getClientRects();for(let t=0;t=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)&&1==sf(e)&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&10>Math.max(Math.abs((e=this.startEvent).clientX-t.clientX),Math.abs(e.clientY-t.clientY)))return;this.select(this.lastEvent=t);let i=0,s=0,n=0,r=0,o=this.view.win.innerWidth,h=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:h}=this.scrollParents.y.getBoundingClientRect());let l=iN(this.view);t.clientX-l.left<=n+6?i=-i6(n-t.clientX):t.clientX+l.right>=o-6&&(i=i6(t.clientX-o)),t.clientY-l.top<=r+6?s=-i6(r-t.clientY):t.clientY+l.bottom>=h-6&&(s=i6(t.clientY-h)),this.setScrollSpeed(i,s)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;it.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}let i7=/*@__PURE__*/Object.create(null),st=/*@__PURE__*/Object.create(null),se=eO.ie&&eO.ie_version<15||eO.ios&&eO.webkit_version<604;function si(t,e,i){for(let s of t.facet(e))i=s(i,t);return i}function ss(t,e){e=si(t.state,id,e);let{state:i}=t,s,n=1,r=i.toText(e),o=r.lines==i.selection.ranges.length;if(null!=su&&i.selection.ranges.every(t=>t.empty)&&su==r.toString()){let t=-1;s=i.changeByRange(s=>{let h=i.doc.lineAt(s.from);if(h.from==t)return{range:s};t=h.from;let l=i.toText((o?r.line(n++).text:e)+i.lineBreak);return{changes:{from:h.from,insert:l},range:z.cursor(s.from+l.length)}})}else s=o?i.changeByRange(t=>{let e=r.line(n++);return{changes:{from:t.from,to:t.to,insert:e.text},range:z.cursor(t.from+e.length)}}):i.replaceSelection(r);t.dispatch(s,{userEvent:"input.paste",scrollIntoView:!0})}function sn(t,e,i,s){if(1==s)return z.cursor(e,i);{if(2==s)return function(t,e,i=1){let s=t.charCategorizer(e),n=t.doc.lineAt(e),r=e-n.from;if(0==n.length)return z.cursor(e);0==r?i=1:r==n.length&&(i=-1);let o=r,h=r;i<0?o=u(n.text,r,!1):h=u(n.text,r);let l=s(n.text.slice(o,h));for(;o>0;){let t=u(n.text,o,!1);if(s(n.text.slice(t,o))!=l)break;o=t}for(;h{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},i7.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),st.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},st.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},i7.mousedown=(t,e)=>{let i,s,n;if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let r=null;for(let i of t.state.facet(io))if(r=i(t,e))break;if(r||0!=e.button||(i=so(t,e),s=sf(e),n=t.state.selection,r={update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),n=n.map(t.changes))},get(e,r,o){let h=so(t,e),l,a=sn(t,h.pos,h.bias,s);if(i.pos!=h.pos&&!r){let e=sn(t,i.pos,i.bias,s),n=Math.min(e.from,a.from),r=Math.max(e.to,a.to);a=n1&&(l=function(t,e){for(let i=0;i=e)return z.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(n,h.pos))?l:o?n.addRange(a):z.create([a])}}),r){let i=!t.hasFocus;t.inputState.startMouseSelection(new i9(t,e,r,i)),i&&t.observer.ignore(()=>{es(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}return!1};let sr=(t,e,i)=>e>=i.top&&e<=i.bottom&&t>=i.left&&t<=i.right;function so(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:function(t,e,i,s){let n=eX.find(t.docView,e);if(!n)return 1;let r=e-n.posAtStart;if(0==r)return 1;if(r==n.length)return -1;let o=n.coordsAt(r,-1);if(o&&sr(i,s,o))return -1;let h=n.coordsAt(r,1);return h&&sr(i,s,h)?1:o&&o.bottom>=s?-1:1}(t,i,e.clientX,e.clientY)}}let sh=eO.ie&&eO.ie_version<=11,sl=null,sa=0,sc=0;function sf(t){if(!sh)return t.detail;let e=sl,i=sc;return sl=t,sc=Date.now(),sa=!e||i>Date.now()-400&&2>Math.abs(e.clientX-t.clientX)&&2>Math.abs(e.clientY-t.clientY)?(sa+1)%3:1}function sd(t,e,i,s){let n;if(!(i=si(t.state,id,i)))return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,h=s&&o&&((n=t.state.facet(ir)).length?n[0](e):eO.mac?!e.altKey:!e.ctrlKey)?{from:o.from,to:o.to}:null,l={from:r,insert:i},a=t.state.changes(h?[h,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:h?"move.drop":"input.drop"}),t.inputState.draggedContent=null}i7.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let s=t.docView.nearest(e.target);if(s&&s.isWidget){let t=s.posAtStart,e=t+s.length;(t>=i.to||e<=i.from)&&(i=z.range(t,e))}}let{inputState:s}=t;return s.mouseSelection&&(s.mouseSelection.dragging=!0),s.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",si(t.state,iu,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1},i7.dragend=t=>(t.inputState.draggedContent=null,!1),i7.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let s=Array(i.length),n=0,r=()=>{++n==i.length&&sd(t,e,s.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let t=0;t{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(s[t]=e.result),r()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return sd(t,e,i,!0),!0}return!1},i7.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=se?null:e.clipboardData;return i?(ss(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{t.focus(),i.remove(),ss(t,i.value)},50)}(t),!1)};let su=null;i7.copy=i7.cut=(t,e)=>{let{text:i,ranges:s,linewise:n}=function(t){let e=[],i=[],s=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),i.push(s));if(!e.length){let n=-1;for(let{from:s}of t.selection.ranges){let r=t.doc.lineAt(s);r.number>n&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),n=r.number}s=!0}return{text:si(t,iu,e.join(t.lineBreak)),ranges:i,linewise:s}}(t.state);if(!i&&!n)return!1;su=n?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:s,scrollIntoView:!0,userEvent:"delete.cut"});let r=se?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",i),!0):(!function(t,e){let i=t.dom.parentNode;if(!i)return;let s=i.appendChild(document.createElement("textarea"));s.style.cssText="position: fixed; left: -10000px; top: 10px",s.value=e,s.focus(),s.selectionEnd=e.length,s.selectionStart=0,setTimeout(()=>{s.remove(),t.focus()},50)}(t,i),!1)};let sp=/*@__PURE__*/tu.define();function sg(t,e){let i=[];for(let s of t.facet(ic)){let n=s(t,e);n&&i.push(n)}return i?t.update({effects:i,annotations:sp.of(!0)}):null}function sm(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=sg(t.state,e);i?t.dispatch(i):t.update([])}},10)}st.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),sm(t)},st.blur=t=>{t.observer.clearSelectionRange(),sm(t)},st.compositionstart=st.compositionupdate=t=>{!t.observer.editContext&&(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},st.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,eO.chrome&&eO.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},st.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},i7.beforeinput=(t,e)=>{var i,s;let n;if("insertReplacementText"==e.inputType&&t.observer.editContext){let s=null===(i=e.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),n=e.getTargetRanges();if(s&&n.length){let e=n[0],i=t.posAtDOM(e.startContainer,e.startOffset),r=t.posAtDOM(e.endContainer,e.endOffset);return i1(t,{from:i,to:r,insert:t.state.toText(s)},null),!0}}if(eO.chrome&&eO.android&&(n=i4.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(s=window.visualViewport)||void 0===s?void 0:s.height)||0;setTimeout(()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return eO.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),eO.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout(()=>st.compositionend(t,e),20),!1};let sv=/*@__PURE__*/new Set,sw=["pre-wrap","normal","pre-line","break-spaces"],sb=!1;class sy{constructor(t){this.lineWrapping=t,this.doc=i.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return sw.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=s,this.lineLength=n,h){this.heightSamples={};for(let t=0;t0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>.001&&(sb=!0),this.height=t)}replace(t,e,i){return sC.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,s){let n=this,r=i.doc;for(let o=s.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=s[o],f=n.lineAt(h,sS.ByPosNoHeight,i.setDoc(e),0,0),d=f.to>=l?f:n.lineAt(l,sS.ByPosNoHeight,i,0,0);for(c+=d.to-l,l=d.to;o>0&&f.from<=s[o-1].toA;)h=s[o-1].fromA,a=s[o-1].fromB,o--,h2*n){let n=t[e-1];n.break?t.splice(--e,1,n.left,null,n.right):t.splice(--e,1,n.left,n.right),i+=1+n.break,s-=n.size}else if(n>2*s){let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,n-=e.size}else break}else if(s=n&&r(this.blockAt(0,i,s,n))}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more&&this.setHeight(s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class sM extends sA{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,s){return new sx(s,this.length,i,this.height,this.breaks)}replace(t,e,i){let s=i[0];return 1==i.length&&(s instanceof sM||s instanceof sO&&4&s.flags)&&10>Math.abs(this.length-s.length)?(s instanceof sO?s=new sM(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):sC.of(i)}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more?this.setHeight(s.heights[s.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class sO extends sC{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,n=s-i+1,r,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*n);r=e/n,this.length>n+1&&(o=(this.height-e)/(this.length-n-1))}else r=this.height/n;return{firstLine:i,lastLine:s,perLine:r,perChar:o}}blockAt(t,e,i,s){let{firstLine:n,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,s);if(e.lineWrapping){let n=s+(t0){let t=i[i.length-1];t instanceof sO?i[i.length-1]=new sO(t.length+s):i.push(null,new sO(s-1))}if(t>0){let e=i[0];e instanceof sO?i[0]=new sO(t+e.length):i.unshift(new sO(t-1),null)}return sC.of(i)}decomposeLeft(t,e){e.push(new sO(t-1),null)}decomposeRight(t,e){e.push(null,new sO(this.length-t-1))}updateHeight(t,e=0,i=!1,s){let n=e+this.length;if(s&&s.from<=e+this.length&&s.more){let i=[],r=Math.max(e,s.from),o=-1;for(s.from>e&&i.push(new sO(s.from-e-1).updateHeight(t,e));r<=n&&s.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let n=s.heights[s.index++];-1==o?o=n:Math.abs(n-o)>=.001&&(o=-2);let h=new sM(e,n);h.outdated=!1,i.push(h),r+=e+1}r<=n&&i.push(null,new sO(n-r).updateHeight(t,r));let h=sC.of(i);return(o<0||Math.abs(h.height-this.height)>=.001||Math.abs(o-this.heightMetrics(t,e).perLine)>=.001)&&(sb=!0),sP(this,h)}return(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class sT extends sC{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,s){let n=i+this.left.height;return to))return l;let a=e==sS.ByPosNoHeight?sS.ByPosNoHeight:sS.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,s,n).join(l)}forEachLine(t,e,i,s,n,r){let o=s+this.left.height,h=n+this.left.length+this.break;if(this.break)t=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,sS.ByPos,i,s,n);t=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let s=this.left.length+this.break;if(ethis.left.length)return this.balanced(this.left,this.right.replace(t-s,e-s,i));let n=[];t>0&&this.decomposeLeft(t,n);let r=n.length;for(let t of i)n.push(t);if(t>0&&sD(n,r-1),e=++i&&e.push(null),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,s=i+this.break;if(t>=s)return this.right.decomposeRight(t-s,e);t2*e.size||e.size>2*t.size?sC.of(this.break?[t,null,e]:[t,e]):(this.left=sP(this.left,t),this.right=sP(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,s){let{left:n,right:r}=this,o=e+n.length+this.break,h=null;return(s&&s.from<=e+n.length&&s.more?h=n=n.updateHeight(t,e,i,s):n.updateHeight(t,e,i),s&&s.from<=o+r.length&&s.more?h=r=r.updateHeight(t,o,i,s):r.updateHeight(t,o,i),h)?this.balanced(n,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function sD(t,e){let i,s;null==t[e]&&(i=t[e-1])instanceof sO&&(s=t[e+1])instanceof sO&&t.splice(e-1,3,new sO(i.length+1+s.length))}class sE{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof sM?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new sM(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t=5)&&this.addLineDeco(s,n,r)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTot&&this.nodes.push(new sM(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new sO(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof sM)return t;let e=new sM(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,t),s.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof sM||this.isCovered?(this.writtenTo"function"!=typeof t&&"cm-lineWrapping"==t.class);this.heightOracle=new sy(e),this.stateDeco=t.facet(iO).filter(t=>"function"!=typeof t),this.heightMap=sC.empty().applyChanges(this.stateDeco,i.empty,this.heightOracle.setDoc(t.doc),[new iI(0,0,0,t.doc.length)]);for(let t=0;t<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());t++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ez.set(this.lineGaps.map(t=>t.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let s=i?e.head:e.anchor;if(!t.some(({from:t,to:e})=>s>=t&&s<=e)){let{from:e,to:i}=this.lineBlockAt(s);t.push(new sI(e,i))}}return this.viewports=t.sort((t,e)=>t.from-e.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?sF:new sH(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(sz(t,this.scaler))})}update(t,e=null){var i,s;let n;this.state=t.state;let r=this.stateDeco;this.stateDeco=this.state.facet(iO).filter(t=>"function"!=typeof t);let o=t.changedRanges,h=iI.extendWithRanges(o,(i=this.stateDeco,s=t?t.changes:B.empty(this.state.doc.length),n=new sR,tD.compare(r,i,s,n,0),n.changes)),l=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);sb=!1,this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),h),(this.heightMap.height!=l||sb)&&(t.flags|=2),a?(this.scrollAnchorPos=t.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let c=h.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.headc.to)||!this.viewportIsAppropriate(c))&&(c=this.getViewport(0,e));let f=c.from!=this.viewport.from||c.to!=this.viewport.to;this.viewport=c,t.flags|=this.updateForViewport(),(f||!t.changes.empty||2&t.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(ig)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,s=window.getComputedStyle(e),n=this.heightOracle,r=s.whiteSpace;this.defaultTextDirection="rtl"==s.direction?eZ.RTL:eZ.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,c=0;if(h.width&&h.height){let{scaleX:t,scaleY:i}=et(e,h);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,a|=8,o=l=!0)}let f=(parseInt(s.paddingTop)||0)*this.scaleY,d=(parseInt(s.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=d)&&(this.paddingTop=f,this.paddingBottom=d,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8);let u=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=u&&(this.scrollAnchorHeight=-1,this.scrollTop=u),this.scrolledToBottom=eh(t.scrollDOM);let p=(this.printing?function(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}:function(t,e){let i=t.getBoundingClientRect(),s=t.ownerDocument,n=s.defaultView||window,r=Math.max(0,i.left),o=Math.min(n.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(n.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=s.body;)if(1==e.nodeType){let i=e,s=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=s.overflow){let s=i.getBoundingClientRect();r=Math.max(r,s.left),o=Math.min(o,s.right),h=Math.max(h,s.top),l=Math.min(e==t.parentNode?n.innerHeight:l,s.bottom)}e="absolute"==s.position||"fixed"==s.position?i.offsetParent:i.parentNode}else if(11==e.nodeType)e=e.host;else break;return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}})(e,this.paddingTop),g=p.top-this.pixelViewport.top,m=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let w=h.width;if((this.contentDOMWidth!=w||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=h.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(w-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:s,textHeight:h}=t.docView.measureTextSize();(o=i>0&&n.refresh(r,i,s,h,w/s,e))&&(t.docView.minWidth=0,a|=8)}for(let s of(g>0&&m>0?c=Math.max(g,m):g<0&&m<0&&(c=Math.min(g,m)),sb=!1,this.viewports)){let r=s.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(s);this.heightMap=(o?sC.empty().applyChanges(this.stateDeco,i.empty,this.heightOracle,[new iI(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new sk(s.from,r))}sb&&(a|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return b&&(2&a&&(a|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),a|=this.updateForViewport()),(2&a||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),s=this.heightMap,n=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new sI(s.lineAt(r-1e3*i,sS.ByHeight,n,0,0).from,s.lineAt(o+(1-i)*1e3,sS.ByHeight,n,0,0).to);if(e){let{head:t}=e.range;if(th.to){let i=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),r=s.lineAt(t,sS.ByPos,n,0,0),o;o="center"==e.y?(r.top+r.bottom)/2-i/2:"start"==e.y||"nearest"==e.y&&t=o+Math.max(10,Math.min(i,250)))&&s>r-2e3&&n>1,r=s<<1;if(this.defaultTextDirection!=eZ.LTR&&!i)return[];let o=[],h=(s,r,l,a)=>{if(r-ss&&tt.from>=l.from&&t.to<=l.to&&Math.abs(t.from-s)t.frome));if(!d){if(rt.from<=r&&t.to>=r)){let t=e.moveToLineBoundary(z.cursor(r),!1,!0).head;t>s&&(r=t)}let t=this.gapSize(l,s,r,a),n=i||t<2e6?t:2e6;d=new sB(s,r,t,n)}o.push(d)},l=e=>{var n,o,l;let a,c,f,d,u;if(e.lengthd&&(f.push({from:d,to:t}),u+=t-d),d=e}},20),d2e6)for(let i of t)i.from>=e.from&&i.frome.from&&h(e.from,a,e,p),ct.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];tD.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some((t,i)=>t.from!=e[i].from||t.to!=e[i].to);return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||sz(this.heightMap.lineAt(t,sS.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||sz(this.heightMap.lineAt(this.scaler.fromDOM(t),sS.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return sz(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class sI{constructor(t,e){this.from=t,this.to=e}}function sV({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let s=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:n}=e[t],r=n-i;if(s<=r)return i+s;s-=r}}function sW(t,e){let i=0;for(let{from:s,to:n}of t.ranges){if(e<=n){i+=e-s;break}i+=n-s}return i/t.total}let sF={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};class sH{constructor(t,e,i){let s=0,n=0,r=0;for(let o of(this.viewports=i.map(({from:i,to:n})=>{let r=e.lineAt(i,sS.ByPos,t,0,0).top,o=e.lineAt(n,sS.ByPos,t,0,0).bottom;return s+=o-r,{from:i,to:n,top:r,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(e.height-s),this.viewports))o.domTop=r+(o.top-n)*this.scale,r=o.domBottom=o.domTop+(o.bottom-o.top),n=o.bottom}toDOM(t){for(let e=0,i=0,s=0;;e++){let n=ee.from==t.viewports[i].from&&e.to==t.viewports[i].to)}}function sz(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),s=e.toDOM(t.bottom);return new sx(t.from,t.length,i,s-i,Array.isArray(t._content)?t._content.map(t=>sz(t,e)):t._content)}let s_=/*@__PURE__*/j.define({combine:t=>t.join(" ")}),sq=/*@__PURE__*/j.define({combine:t=>t.indexOf(!0)>-1}),sj=/*@__PURE__*/tY.newName(),sY=/*@__PURE__*/tY.newName(),sK=/*@__PURE__*/tY.newName(),sX={"&light":"."+sY,"&dark":"."+sK};function s$(t,e,i){return new tY(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,e=>{if("&"==e)return t;if(!i||!i[e])throw RangeError(`Unsupported selector: ${e}`);return i[e]}):t+" "+e})}let sU=/*@__PURE__*/s$("."+sj,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart: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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-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-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},sX),sQ={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},sG=eO.ie&&eO.ie_version<=11;class sJ{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new ee,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let t of e)this.queue.push(t);(eO.ie&&eO.ie_version<=11||eO.ios&&t.composing)&&e.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&!1!==t.constructor.EDIT_CONTEXT&&!(eO.chrome&&eO.chrome_version<126)&&(this.editContext=new s1(t),t.state.facet(ik)&&(t.contentDOM.editContext=this.editContext.editContext)),sG&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var t;(null===(t=this.view.docView)||void 0===t?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")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){("change"!=t.type&&t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){for(let e of(this.gapIntersection.disconnect(),t))this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(ik)?i.root.activeElement!=this.dom:!t2(this.dom,s))return;let n=s.anchorNode&&i.docView.nearest(s.anchorNode);if(n&&n.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(eO.ie&&eO.ie_version<=11||eO.android&&eO.chrome)&&!i.state.selection.main.empty&&s.focusNode&&t4(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=t0(t.root);if(!e)return!1;let i=eO.safari&&11==t.root.nodeType&&t.root.activeElement==this.dom&&function(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return s0(t,i)}let i=null;function s(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",s,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",s,!0),i?s0(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let s=t2(this.dom,i);return s&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime{let t=this.delayedAndroidKey;t&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&er(this.dom,t.key,t.keyCode))})),this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,s=!1;for(let n of t){let t=this.readMutation(n);t&&(t.typeOver&&(s=!0),-1==e?{from:e,to:i}=t:(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:s}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),s=this.selectionChanged&&t2(this.dom,this.selectionRange);if(t<0&&!s)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let n=new iZ(this.view,t,e,i);return this.view.docView.domChanged={newSel:n.newSel?n.newSel.main:null},n}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,s=i0(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),s}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.flags|=4),"childList"==t.type){let i=sZ(e,t.previousSibling||t.target.previousSibling,-1),s=sZ(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:s?e.posBefore(s):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(ik)!=t.state.facet(ik)&&(t.view.contentDOM.editContext=t.state.facet(ik)?this.editContext.editContext:null))}destroy(){var t,e,i;for(let s of(this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),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),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function sZ(t,e,i){for(;e;){let s=ed.get(e);if(s&&s.parent==t)return s;let n=e.parentNode;e=n!=t.dom?n:i>0?e.nextSibling:e.previousSibling}return null}function s0(t,e){let i=e.startContainer,s=e.startOffset,n=e.endContainer,r=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return t4(o.node,o.offset,n,r)&&([i,s,n,r]=[n,r,i,s]),{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r}}class s1{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});for(let s in this.handlers.textupdate=e=>{let{anchor:s}=t.state.selection.main,n=this.toEditorPos(e.updateRangeStart),r=this.toEditorPos(e.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:e.updateRangeStart,editorBase:n,drifted:!1});let o={from:n,to:r,insert:i.of(e.text.split("\n"))};o.from==this.from&&sthis.to&&(o.to=s),(o.from!=o.to||o.insert.length)&&(this.pendingContextChange=o,t.state.readOnly||i1(t,o,z.single(this.toEditorPos(e.selectionStart),this.toEditorPos(e.selectionEnd))),this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)))},this.handlers.characterboundsupdate=i=>{let s=[],n=null;for(let e=this.toEditorPos(i.rangeStart),r=this.toEditorPos(i.rangeEnd);e{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,s=t.underlineThickness;if("None"!=e&&"None"!=s){let n=`text-decoration: underline ${"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${"Thin"==s?1:2}px`;i.push(ez.mark({attributes:{style:n}}).range(this.toEditorPos(t.rangeStart),this.toEditorPos(t.rangeEnd)))}}t.dispatch({effects:ib.of(ez.set(i))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:e}=this.composing;this.composing=null,e&&this.reset(t.state)}},this.handlers)e.addEventListener(s,this.handlers[s]);this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=t0(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,s=this.pendingContextChange;return t.changes.iterChanges((n,r,o,h,l)=>{if(i)return;let a=l.length-(r-n);if(s&&r>=s.to){if(s.from==n&&s.to==r&&s.insert.eq(l)){s=this.pendingContextChange=null,e+=a,this.to+=a;return}s=null,this.revertPending(t.state)}if(n+=e,(r+=e)<=this.from)this.from+=a,this.to+=a;else if(nthis.to||this.to-this.from+l.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(n),this.toContextPos(r),l.toString()),this.to+=a}e+=a}),s&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange;this.composing&&(this.composing.drifted||t.transactions.some(t=>!t.isUserEvent("input.type")&&t.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state):(this.pendingContextChange=null,this.reset(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),s=this.toContextPos(e.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(i,s)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to3e4)}toEditorPos(t){let e=this.composing;return e&&e.drifted?e.editorBase+(t-e.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class s2{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}constructor(t={}){var 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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;for(let e of(this.dispatchTransactions=t.dispatchTransactions||i&&(t=>t.forEach(t=>i(t,this)))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new sL(t.state||tC.create(t)),t.scrollTo&&t.scrollTo.is(iw)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(iS).map(t=>new iP(t)),this.plugins))e.update(this);this.observer=new sJ(this),this.inputState=new i2(this),this.inputState.ensureHandlers(this.plugins),this.docView=new iW(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(e=document.fonts)||void 0===e?void 0:e.ready)&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let e=1==t.length&&t[0]instanceof tv?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,i=!1,s,n=this.state;for(let e of t){if(e.startState!=n)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=e.state}if(this.destroyed){this.viewState.state=n;return}let r=this.hasFocus,o=0,h=null;t.some(t=>t.annotation(sp))?(this.inputState.notifiedFocused=r,o=1):r==this.inputState.notifiedFocused||(this.inputState.notifiedFocused=r,(h=sg(n,r))||(o=1));let l=this.observer.delayedAndroidKey,a=null;if(l?(this.observer.clearDelayedAndroidKey(),((a=this.observer.readChange())&&!this.state.doc.eq(n.doc)||!this.state.selection.eq(n.selection))&&(a=null)):this.observer.clear(),n.facet(tC.phrases)!=this.state.facet(tC.phrases))return this.setState(n);s=iV.create(this,n,t),s.flags|=o;let c=this.viewState.scrollTarget;try{for(let e of(this.updateState=2,t)){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new iv(t.empty?t:z.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(iw)&&(c=t.value.clip(this.state))}this.viewState.update(s,c),this.bidiCache=s5.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),e=this.docView.update(s),this.state.facet(iL)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(t=>t.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(s_)!=s.state.facet(s_)&&(this.viewState.mustMeasureContent=!0),(e||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!s.empty)for(let t of this.state.facet(il))try{t(s)}catch(t){iy(this.state,t,"update listener")}(h||a)&&Promise.resolve().then(()=>{h&&this.state==h.startState&&this.dispatch(h),a&&!i0(this,a)&&l.force&&er(this.contentDOM,l.key,l.keyCode)})}setState(t){if(0!=this.updateState)throw Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);for(let e of(this.viewState=new sL(t),this.plugins=t.facet(iS).map(t=>new iP(t)),this.pluginMap.clear(),this.plugins))e.update(this);this.docView.destroy(),this.docView=new iW(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(iS),i=t.state.facet(iS);if(e!=i){let s=[];for(let n of i){let i=e.indexOf(n);if(i<0)s.push(new iP(n));else{let e=this.plugins[i];e.mustUpdate=t,s.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,s=i.scrollTop*this.scaleY,{scrollAnchorPos:n,scrollAnchorHeight:r}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(r<0){if(eh(i))n=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(s);n=t.from,r=t.top}}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];4&o||([this.measureRequests,h]=[h,this.measureRequests]);let l=h.map(t=>{try{return t.read(this)}catch(t){return iy(this.state,t),s4}}),a=iV.create(this,this.state,[]),c=!1;a.flags|=o,e?e.flags|=o:e=a,this.updateState=2,!a.empty&&(this.updatePlugins(a),this.inputState.update(a),this.updateAttrs(),(c=this.docView.update(a))&&this.docViewUpdate());for(let t=0;t1||t<-1){s+=t,i.scrollTop=s/this.scaleY,r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(il))t(e)}get themeClasses(){return sj+" "+(this.state.facet(sq)?sK:sY)+" "+this.state.facet(s_)}updateAttrs(){let t=s8(this,iA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(ik)?"true":"false",class:"cm-content",style:`${eO.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),s8(this,iM,e);let i=this.observer.ignore(()=>{let i=eW(this.contentDOM,this.contentAttrs,e),s=eW(this.dom,this.editorAttrs,t);return i||s});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)t.is(s2.announce)&&(e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value)}mountStyles(){this.styleModules=this.state.facet(iL);let t=this.state.facet(s2.cspNonce);tY.mount(this.root,this.styleModules.concat(sU).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(2==this.updateState)throw Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t&&!(this.measureRequests.indexOf(t)>-1)){if(null!=t.key){for(let e=0;ee.spec==t)||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return iQ(this,t,i$(this,t,e,i))}moveByGroup(t,e){return iQ(this,t,i$(this,t,e,e=>{var i;let s,n;return i=t.head,n=(s=this.state.charCategorizer(i))(e),t=>{let e=s(t);return n==tx.Space&&(n=e),n==e}}))}visualLineSide(t,e){let i=this.bidiSpans(t),s=this.textDirectionAt(t.from),n=i[e?i.length-1:0];return z.cursor(n.side(e,s)+t.from,n.forward(!e,s)?1:-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,s){let n=iX(t,e.head),r=s&&n.type==eH.Text&&(t.lineWrapping||n.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),s=t.textDirectionAt(n.from),o=t.posAtCoords({x:i==(s==eZ.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=o)return z.cursor(o,i?-1:1)}return z.cursor(i?n.to:n.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return iQ(this,t,function(t,e,i,s){let n=e.head,r=i?1:-1;if(n==(i?t.state.doc.length:0))return z.cursor(n,e.assoc);let o=e.goalColumn,h,l=t.contentDOM.getBoundingClientRect(),a=t.coordsAtPos(n,e.assoc||-1),c=t.documentTop;if(a)null==o&&(o=a.left-l.left),h=r<0?a.top:a.bottom;else{let e=t.viewState.lineBlockAt(n);null==o&&(o=Math.min(l.right-l.left,t.defaultCharacterWidth*(n-e.from))),h=(r<0?e.top:e.bottom)+c}let f=l.left+o,d=null!=s?s:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=h+(d+e)*r,s=iY(t,{x:f,y:i},!1,r);if(il.bottom||(r<0?sn)){let e=t.docView.coordsForChar(s),n=!e||i0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(ip)||tthis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>s3)return ie(t.length);let e=this.textDirectionAt(t.from),i;for(let s of this.bidiCache)if(s.from==t.from&&s.dir==e&&(s.fresh||function t(e,i){if(e.length!=i.length)return!1;for(let s=0;sit.length;)it[it.length]=256;let s=[],n=e==e0?0:1;return function t(e,i,s,n,r,o,h){let l=i%2?2:1;(function(t,e,i,s,n){for(let r=0;r<=s.length;r++){let o=r?s[r-1].to:e,h=r=0;t-=3)if(e8[t+1]==-s){let i=e8[t+2],s=2&i?n:4&i?1&i?r:n:0;s&&(it[e]=it[e8[t]]=s),h=t;break}}else if(189==e8.length)break;else e8[h++]=e,e8[h++]=i,e8[h++]=l}else if(2==(o=it[e])||1==o){let t=o==n;l=t?0:1;for(let e=h-3;e>=0;e-=3){let i=e8[e+2];if(2&i)break;if(t)e8[e+2]|=2;else{if(4&i)break;e8[e+2]|=4}}}}}(e,r,o,n,l),function(t,e,i,s){for(let n=0,r=s;n<=i.length;n++){let o=n?i[n-1].to:t,h=nl;)e==r&&(e=i[--s].from,r=s?i[s-1].to:t),it[--e]=c;l=o}else r=o,l++}}}(r,o,n,l),function e(i,s,n,r,o,h,l){let a=r%2?2:1;if(r%2==o%2)for(let c=s,f=0;cc&&l.push(new e7(c,e.from,p)),t(i,e.direction==e0!=!(p%2)?r+1:r,o,e.inner,e.from,e.to,l),c=e.to),g=e.to}else if(g==n||(s?it[g]!=a:it[g]==a))break;else g++;u?e(i,c,g,r+1,o,u,l):cs;){let n=!0,d=!1;if(!f||c>h[f-1].to){let t=it[c-1];t!=a&&(n=!1,d=16==t)}let u=n||1!=a?null:[],p=n?r:r+1,g=c;e:for(;;)if(f&&g==h[f-1].to){if(d)break;let e=h[--f];if(!n)for(let t=e.from,i=f;;){if(t==s)break e;if(i&&h[i-1].to==t)t=h[--i].from;else if(it[t-1]==a)break e;else break}u?u.push(e):(e.toDate.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{es(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of(this.root.activeElement==this.contentDOM&&this.contentDOM.blur(),this.plugins))t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return iw.of(new iv("number"==typeof t?z.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return iw.of(new iv(z.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return iC.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return iC.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=tY.newName(),s=[s_.of(i),iL.of(s$(`.${i}`,t))];return e&&e.dark&&s.push(sq.of(!0)),s}static baseTheme(t){return Z.lowest(iL.of(s$("."+sj,t,sX)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),s=i&&ed.get(i)||ed.get(t);return(null===(e=null==s?void 0:s.rootView)||void 0===e?void 0:e.view)||null}}s2.styleModule=iL,s2.inputHandler=ia,s2.clipboardInputFilter=id,s2.clipboardOutputFilter=iu,s2.scrollHandler=im,s2.focusChangeEffect=ic,s2.perLineTextDirection=ip,s2.exceptionSink=ih,s2.updateListener=il,s2.editable=ik,s2.mouseSelectionStyle=io,s2.dragMovesSelection=ir,s2.clickAddsSelectionRange=is,s2.decorations=iO,s2.outerDecorations=iT,s2.atomicRanges=iD,s2.bidiIsolatedRanges=iE,s2.scrollMargins=iB,s2.darkTheme=sq,s2.cspNonce=/*@__PURE__*/j.define({combine:t=>t.length?t[0]:""}),s2.contentAttributes=iM,s2.editorAttributes=iA,s2.lineWrapping=/*@__PURE__*/s2.contentAttributes.of({class:"cm-lineWrapping"}),s2.announce=/*@__PURE__*/tm.define();let s3=4096,s4={};class s5{constructor(t,e,i,s,n,r){this.from=t,this.to=e,this.dir=i,this.isolates=s,this.fresh=n,this.order=r}static update(t,e){if(e.empty&&!t.some(t=>t.fresh))return t;let i=[],s=t.length?t[t.length-1].dir:eZ.LTR;for(let n=Math.max(0,t.length-10);n=0;n--){let e=s[n],r="function"==typeof e?e(t):e;r&&eL(r,i)}return i}let s6=eO.mac?"mac":eO.windows?"win":eO.linux?"linux":"key";function s9(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}let s7=/*@__PURE__*/Z.default(/*@__PURE__*/s2.domEventHandlers({keydown:(t,e)=>{var i,s,n,r,o;let h,l,a,c,f,d,u,p,g,m,b,y,k;return i=(h=e.state.facet(nt),(l=ne.get(h))||ne.set(h,l=function(t,e=s6){let i=Object.create(null),s=Object.create(null),n=(t,e)=>{let i=s[t];if(null==i)s[t]=e;else if(i!=e)throw Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},r=(t,s,r,o,h)=>{var l,a;let c=i[t]||(i[t]=Object.create(null)),f=s.split(/ (?!$)/).map(t=>(function(t,e){let i,s,n,r;let o=t.split(/-(?!$)/),h=o[o.length-1];"Space"==h&&(h=" ");for(let t=0;t{let s=ni={view:e,prefix:i,scope:t};return setTimeout(()=>{ni==s&&(ni=null)},4e3),!0}]})}let d=f.join(" ");n(d,!1);let u=c[d]||(c[d]={preventDefault:!1,stopPropagation:!1,run:(null===(a=null===(l=c._any)||void 0===l?void 0:l.run)||void 0===a?void 0:a.slice())||[]});r&&u.run.push(r),o&&(u.preventDefault=!0),h&&(u.stopPropagation=!0)};for(let s of t){let t=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:n}=s;for(let e in t)t[e].run.push(t=>n(t,ns))}let n=s[e]||s.key;if(n)for(let e of t)r(e,n,s.run,s.preventDefault,s.stopPropagation),s.shift&&r(e,"Shift-"+n,s.shift,s.preventDefault,s.stopPropagation)}return i}(h.reduce((t,e)=>t.concat(e),[]))),l),s=t,n=e,r="editor",ns=s,c=w(v(a=("Esc"==(o=!(tQ&&s.metaKey&&s.shiftKey&&!s.ctrlKey&&!s.altKey||tG&&s.shiftKey&&s.key&&1==s.key.length||"Unidentified"==s.key)&&s.key||(s.shiftKey?tU:t$)[s.keyCode]||s.key||"Unidentified")&&(o="Escape"),"Del"==o&&(o="Delete"),"Left"==o&&(o="ArrowLeft"),"Up"==o&&(o="ArrowUp"),"Right"==o&&(o="ArrowRight"),"Down"==o&&(o="ArrowDown"),o),0))==a.length&&" "!=a,f="",d=!1,u=!1,p=!1,ni&&ni.view==n&&ni.scope==r&&(f=ni.prefix+" ",0>i8.indexOf(s.keyCode)&&(u=!0,ni=null)),g=new Set,m=t=>{if(t){for(let e of t.run)if(!g.has(e)&&(g.add(e),e(n)))return t.stopPropagation&&(p=!0),!0;t.preventDefault&&(t.stopPropagation&&(p=!0),u=!0)}return!1},(b=i[r])&&(m(b[f+s9(a,s,!c)])?d=!0:c&&(s.altKey||s.metaKey||s.ctrlKey)&&!(eO.windows&&s.ctrlKey&&s.altKey)&&(y=t$[s.keyCode])&&y!=a?m(b[f+s9(y,s,!0)])?d=!0:s.shiftKey&&(k=tU[s.keyCode])!=a&&k!=y&&m(b[f+s9(k,s,!1)])&&(d=!0):c&&s.shiftKey&&m(b[f+s9(a,s,!0)])&&(d=!0),!d&&m(b._any)&&(d=!0)),u&&(d=!0),d&&p&&s.stopPropagation(),ns=null,d}})),nt=/*@__PURE__*/j.define({enables:s7}),ne=/*@__PURE__*/new WeakMap,ni=null,ns=null;class nn{constructor(t,e,i,s,n){this.className=t,this.left=e,this.top=i,this.width=s,this.height=n}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className==this.className&&(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",null!=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,i){if(!i.empty)return function(t,e,i){if(i.to<=t.viewport.from||i.from>=t.viewport.to)return[];let s=Math.max(i.from,t.viewport.from),n=Math.min(i.to,t.viewport.to),r=t.textDirection==eZ.LTR,o=t.contentDOM,h=o.getBoundingClientRect(),l=nr(t),a=o.querySelector(".cm-line"),c=a&&window.getComputedStyle(a),f=h.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),d=h.right-(c?parseInt(c.paddingRight):0),u=iX(t,s),p=iX(t,n),g=u.type==eH.Text?u:null,m=p.type==eH.Text?p:null;if(g&&(t.lineWrapping||u.widgetLineBreaks)&&(g=no(t,s,1,g)),m&&(t.lineWrapping||p.widgetLineBreaks)&&(m=no(t,n,-1,m)),g&&m&&g.from==m.from&&g.to==m.to)return w(b(i.from,i.to,g));{let e=g?b(i.from,null,g):y(u,!1),s=m?b(null,i.to,m):y(p,!0),n=[];return(g||u).to<(m||p).from-(g&&m?1:0)||u.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2a&&s.from=r)break;h>n&&l(Math.max(t,n),null==e&&t<=a,Math.min(h,r),null==i&&h>=c,o.dir)}if((n=s.to+1)>=r)break}return 0==h.length&&l(a,null==e,c,null==i,t.textDirection),{top:n,bottom:o,horizontal:h}}function y(t,e){let i=h.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(t,e,i);{let s=t.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let n=nr(t);return[new nn(e,s.left-n.left,s.top-n.top,null,s.bottom-s.top)]}}}function nr(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==eZ.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function no(t,e,i,s){let n=t.coordsAtPos(e,2*i);if(!n)return s;let r=t.dom.getBoundingClientRect(),o=(n.top+n.bottom)/2,h=t.posAtCoords({x:r.left+1,y:o}),l=t.posAtCoords({x:r.right-1,y:o});return null==h||null==l?s:{from:Math.max(s.from,Math.min(h,l)),to:Math.min(s.to,Math.max(h,l))}}/*@__PURE__*/j.define();let nh=!eO.ios,nl=(/*@__PURE__*/j.define({combine:t=>tP(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}),{".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}});nh&&(nl[".cm-line"].caretColor=nl[".cm-content"].caretColor="transparent !important"),/*@__PURE__*/Z.highest(/*@__PURE__*/s2.theme(nl));let na=/*@__PURE__*/tm.define({map:(t,e)=>null==t?null:e.mapPos(t)});/*@__PURE__*/Q.define({create:()=>null,update:(t,e)=>(null!=t&&(t=e.changes.mapPos(t)),e.effects.reduce((t,e)=>e.is(na)?e.value:t,t))});let nc=null!=/x/.unicode?"gu":"g",nf=/*@__PURE__*/RegExp("[\0-\b\n-\x1f-Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]",nc),nd=null;/*@__PURE__*/j.define({combine(t){let e=tP(t,{render:null,specialChars:nf,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==nd&&"undefined"!=typeof document&&document.body){let e=document.body.style;nd=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)!=null}return nd||!1}())&&(e.specialChars=RegExp(" |"+e.specialChars.source,nc)),e.addSpecialChars&&(e.specialChars=RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,nc)),e}});let nu="-10000px";class np{constructor(t,e,i,s){this.facet=e,this.createTooltipView=i,this.removeTooltipView=s,this.input=t.state.facet(e),this.tooltips=this.input.filter(t=>t);let n=null;this.tooltipViews=this.tooltips.map(t=>n=i(t,n))}update(t,e){var i;let s=t.state.facet(this.facet),n=s.filter(t=>t);if(s===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let r=[],o=e?[]:null;for(let i=0;ir.indexOf(t)&&(this.removeTooltipView(t),null===(i=t.destroy)||void 0===i||i.call(t));return e&&(o.forEach((t,i)=>e[i]=t),e.length=o.length),this.input=s,this.tooltips=n,this.tooltipViews=r,!0}}function ng(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}let nm=/*@__PURE__*/j.define({combine:t=>{var e,i,s;return{position:eO.ios?"absolute":(null===(e=t.find(t=>t.position))||void 0===e?void 0:e.position)||"fixed",parent:(null===(i=t.find(t=>t.parent))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(s=t.find(t=>t.tooltipSpace))||void 0===s?void 0:s.tooltipSpace)||ng}}}),nv=/*@__PURE__*/new WeakMap,nw=/*@__PURE__*/iC.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(nm);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new np(t,nk,(t,e)=>this.createTooltip(t,e),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver)for(let t of(this.intersectionObserver.disconnect(),this.manager.tooltipViews))this.intersectionObserver.observe(t.dom)}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let i=e||t.geometryChanged,s=t.state.facet(nm);if(s.position!=this.position&&!this.madeAbsolute){for(let t of(this.position=s.position,this.manager.tooltipViews))t.dom.style.position=this.position;i=!0}if(s.parent!=this.parent){for(let t of(this.parent&&this.container.remove(),this.parent=s.parent,this.createContainer(),this.manager.tooltipViews))this.container.appendChild(t.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t,e){let i=t.create(this.view),s=e?e.dom:null;if(i.dom.classList.add("cm-tooltip"),t.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",i.dom.appendChild(t)}return i.dom.style.position=this.position,i.dom.style.top=nu,i.dom.style.left="0px",this.container.insertBefore(i.dom,s),i.mount&&i.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(i.dom),i}destroy(){var t,e,i;for(let e of(this.view.win.removeEventListener("resize",this.measureSoon),this.manager.tooltipViews))e.dom.remove(),null===(t=e.destroy)||void 0===t||t.call(e);this.parent&&this.container.remove(),null===(e=this.resizeObserver)||void 0===e||e.disconnect(),null===(i=this.intersectionObserver)||void 0===i||i.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,i=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(eO.gecko)i=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==nu&&"0px"==t.style.left){let e=t.getBoundingClientRect();i=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(i||"absolute"==this.position){if(this.parent){let i=this.parent.getBoundingClientRect();i.width&&i.height&&(t=i.width/this.parent.offsetWidth,e=i.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState)}let s=this.view.scrollDOM.getBoundingClientRect(),n=iN(this.view);return{visible:{left:s.left+n.left,top:s.top+n.top,right:s.right-n.right,bottom:s.bottom-n.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((t,e)=>{let i=this.manager.tooltipViews[e];return i.getCoords?i.getCoords(t.pos):this.view.coordsAtPos(t.pos)}),size:this.manager.tooltipViews.map(({dom:t})=>t.getBoundingClientRect()),space:this.view.state.facet(nm).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:i}}writeMeasure(t){var e;if(t.makeAbsolute)for(let t of(this.madeAbsolute=!0,this.position="absolute",this.manager.tooltipViews))t.dom.style.position="absolute";let{visible:i,space:s,scaleX:n,scaleY:r}=t,o=[];for(let h=0;h=Math.min(i.bottom,s.bottom)||f.rightMath.min(i.right,s.right)+.1)){c.style.top=nu;continue}let u=l.arrow?a.dom.querySelector(".cm-tooltip-arrow"):null,p=u?7:0,g=d.right-d.left,m=null!==(e=nv.get(a))&&void 0!==e?e:d.bottom-d.top,v=a.offset||ny,w=this.view.textDirection==eZ.LTR,b=d.width>s.right-s.left?w?s.left:s.right-d.width:w?Math.max(s.left,Math.min(f.left-(u?14:0)+v.x,s.right-g)):Math.min(Math.max(s.left,f.left-g+(u?14:0)-v.x),s.right-g),y=this.above[h];!l.strictSide&&(y?f.top-m-p-v.ys.bottom)&&y==s.bottom-f.bottom>f.top-s.top&&(y=this.above[h]=!y);let k=(y?f.top-s.top:s.bottom-f.bottom)-p;if(kb&&t.topx&&(x=y?t.top-m-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(x-t.parent.top)/r+"px",c.style.left=(b-t.parent.left)/n+"px"):(c.style.top=x/r+"px",c.style.left=b/n+"px"),u){let t=f.left+(w?v.x:-v.x)-(b+14-7);u.style.left=t/n+"px"}!0!==a.overlap&&o.push({left:b,top:x,right:S,bottom:x+m}),c.classList.toggle("cm-tooltip-above",y),c.classList.toggle("cm-tooltip-below",!y),a.positioned&&a.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=nu}},{eventObservers:{scroll(){this.maybeMeasure()}}}),nb=/*@__PURE__*/s2.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",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"}}}),ny={x:0,y:0},nk=/*@__PURE__*/j.define({enables:[nw,nb]}),nx=/*@__PURE__*/j.define({combine:t=>t.reduce((t,e)=>t.concat(e),[])});class nS{static create(t){return new nS(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new np(t,nx,(t,e)=>this.createHostedView(t,e),t=>t.dom.remove())}createHostedView(t,e){let i=t.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,e?e.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)null===(t=e.destroy)||void 0===t||t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let s=i[t];if(void 0!==s){if(void 0===e)e=s;else if(e!==s)return}}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}/*@__PURE__*/tm.define();let nC=/*@__PURE__*/j.define({combine(t){let e,i;for(let s of t)e=e||s.topContainer,i=i||s.bottomContainer;return{topContainer:e,bottomContainer:i}}}),nP=/*@__PURE__*/iC.fromClass(class{constructor(t){this.input=t.state.facet(nO),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(e=>e(t));let e=t.state.facet(nC);for(let i of(this.top=new nA(t,!0,e.topContainer),this.bottom=new nA(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top)),this.panels))i.dom.classList.add("cm-panel"),i.mount&&i.mount()}update(t){let e=t.state.facet(nC);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new nA(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new nA(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(nO);if(i!=this.input){let e=i.filter(t=>t),s=[],n=[],r=[],o=[];for(let i of e){let e=this.specs.indexOf(i),h;e<0?(h=i(t.view),o.push(h)):(h=this.panels[e]).update&&h.update(t),s.push(h),(h.top?n:r).push(h)}for(let t of(this.specs=e,this.panels=s,this.top.sync(n),this.bottom.sync(r),o))t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>s2.scrollMargins.of(e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class nA{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&0>t.indexOf(e)&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length){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 t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=nM(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=nM(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function nM(t){let e=t.nextSibling;return t.remove(),e}let nO=/*@__PURE__*/j.define({enables:nP});class nT extends tA{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}nT.prototype.elementClass="",nT.prototype.toDOM=void 0,nT.prototype.mapMode=E.TrackBefore,nT.prototype.startSide=nT.prototype.endSide=-1,nT.prototype.point=!0;let nD=/*@__PURE__*/j.define(),nE=/*@__PURE__*/j.define(),nR=/*@__PURE__*/j.define(),nB=/*@__PURE__*/j.define({combine:t=>t.some(t=>t)}),nN=/*@__PURE__*/iC.fromClass(class{constructor(t){for(let e of(this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(nR).map(e=>new nW(t,e)),this.gutters))this.dom.appendChild(e.dom);this.fixed=!t.state.facet(nB),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,s=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(s<(i.to-i.from)*.8)}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(nB)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let i=tD.iter(this.view.state.facet(nD),this.view.viewport.from),s=[],n=this.gutters.map(t=>new nV(t,this.view.viewport,-this.view.documentPadding.top));for(let t of this.view.viewportLineBlocks)if(s.length&&(s=[]),Array.isArray(t.type)){let e=!0;for(let r of t.type)if(r.type==eH.Text&&e){for(let t of(nI(i,s,r.from),n))t.line(this.view,r,s);e=!1}else if(r.widget)for(let t of n)t.widget(this.view,r)}else if(t.type==eH.Text)for(let e of(nI(i,s,t.from),n))e.line(this.view,t,s);else if(t.widget)for(let e of n)e.widget(this.view,t);for(let t of n)t.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(nR),i=t.state.facet(nR),s=t.docChanged||t.heightChanged||t.viewportChanged||!tD.eq(t.startState.facet(nD),t.state.facet(nD),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(s=!0);else{s=!0;let n=[];for(let s of i){let i=e.indexOf(s);i<0?n.push(new nW(this.view,s)):(this.gutters[i].update(t),n.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),0>n.indexOf(t)&&t.destroy();for(let t of n)this.dom.appendChild(t.dom);this.gutters=n}return s}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>s2.scrollMargins.of(e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==eZ.LTR?{left:i.dom.offsetWidth*e.scaleX}:{right:i.dom.offsetWidth*e.scaleX}:null})});function nL(t){return Array.isArray(t)?t:[t]}function nI(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class nV{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=tD.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:s}=this,n=(e.top-this.height)/t.scaleY,r=e.height/t.scaleY;if(this.i==s.elements.length){let e=new nF(t,r,n,i);s.elements.push(e),s.dom.appendChild(e.dom)}else s.elements[this.i].update(t,r,n,i);this.height=e.bottom,this.i++}line(t,e,i){let s=[];nI(this.cursor,s,e.from),i.length&&(s=s.concat(i));let n=this.gutter.config.lineMarker(t,e,s);n&&s.unshift(n);let r=this.gutter;(0!=s.length||r.config.renderEmptyElements)&&this.addElement(t,e,s)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),s=i?[i]:null;for(let i of t.state.facet(nE)){let n=i(t,e.widget,e);n&&(s||(s=[])).push(n)}s&&this.addElement(t,e,s)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class nW{constructor(t,e){for(let i in this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:""),e.domEventHandlers)this.dom.addEventListener(i,s=>{let n=s.target,r;if(n!=this.dom&&this.dom.contains(n)){for(;n.parentNode!=this.dom;)n=n.parentNode;let t=n.getBoundingClientRect();r=(t.top+t.bottom)/2}else r=s.clientY;let o=t.lineBlockAtHeight(r-t.documentTop);e.domEventHandlers[i](t,o,s)&&s.preventDefault()});this.markers=nL(e.markers(t)),e.initialSpacer&&(this.spacer=new nF(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=nL(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!tD.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class nF{constructor(t,e,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,s)}update(t,e,i,s){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),!function(t,e){if(t.length!=e.length)return!1;for(let i=0;itP(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let s=i[t],n=e[t];i[t]=s?(t,e,i)=>s(t,e,i)||n(t,e,i):n}return i}})});class nq extends nT{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function nj(t,e){return t.state.facet(n_).formatNumber(e,t.state)}let nY=/*@__PURE__*/nR.compute([n_],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(nH),lineMarker:(t,e,i)=>i.some(t=>t.toDOM)?null:new nq(nj(t,t.state.doc.lineAt(e.from).number)),widgetMarker:(t,e,i)=>{for(let s of t.state.facet(nz)){let n=s(t,e,i);if(n)return n}return null},lineMarkerChange:t=>t.startState.facet(n_)!=t.state.facet(n_),initialSpacer:t=>new nq(nj(t,nX(t.state.doc.lines))),updateSpacer(t,e){let i=nj(e.view,nX(e.view.state.doc.lines));return i==t.number?t:new nq(i)},domEventHandlers:t.facet(n_).domEventHandlers}));function nK(t={}){return[n_.of(t),[nN],nY]}function nX(t){let e=9;for(;e{throw Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=nZ.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}nQ.closedBy=new nQ({deserialize:t=>t.split(" ")}),nQ.openedBy=new nQ({deserialize:t=>t.split(" ")}),nQ.group=new nQ({deserialize:t=>t.split(" ")}),nQ.isolate=new nQ({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw RangeError("Invalid value for isolate: "+t);return t||"auto"}}),nQ.contextHash=new nQ({perNode:!0}),nQ.lookAhead=new nQ({perNode:!0}),nQ.mounted=new nQ({perNode:!0});class nG{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[nQ.mounted.id]}}let nJ=Object.create(null);class nZ{constructor(t,e,i,s=0){this.name=t,this.props=e,this.id=i,this.flags=s}static define(t){let e=t.props&&t.props.length?Object.create(null):nJ,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),s=new nZ(t.name||"",e,t.id,i);if(t.props){for(let i of t.props)if(Array.isArray(i)||(i=i(s)),i){if(i[0].perNode)throw RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}}return s}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(nQ.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let s of i.split(" "))e[s]=t[i];return t=>{for(let i=t.prop(nQ.group),s=-1;s<(i?i.length:0);s++){let n=e[s<0?t.name:i[s]];if(n)return n}}}}nZ.none=new nZ("",Object.create(null),0,8);class n0{constructor(t){this.types=t;for(let e=0;e=e){let o=new n7(r.tree,r.overlay[0].from+t.from,-1,t);(n||(n=[s])).push(n6(o,e,i,!1))}}return n?rn(n):s}(this,t,e)}iterate(t){let{enter:e,leave:i,from:s=0,to:n=this.length}=t,r=t.mode||0,o=(r&A.IncludeAnonymous)>0;for(let t=this.cursor(r|A.IncludeAnonymous);;){let r=!1;if(t.from<=n&&t.to>=s&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:rc(nZ.none,this.children,this.positions,0,this.children.length,0,this.length,(t,e,i)=>new n3(this.type,t,e,i,this.propValues),t.makeTree||((t,e,i)=>new n3(nZ.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:s,maxBufferLength:n=1024,reused:r=[],minRepeatType:o=s.types.length}=t,h=Array.isArray(i)?new n4(i,i.length):i,l=s.types,a=0,c=0;function f(t,e,i,n,r,o,h,l,a){let c=[],f=[];for(;t.length>n;)c.push(t.pop()),f.push(e.pop()+i-r);t.push(d(s.types[h],c,f,o-r,l-o,a)),e.push(r-i)}function d(t,e,i,s,n,r,o){if(r){let t=[nQ.contextHash,r];o=o?[t].concat(o):[t]}if(n>25){let t=[nQ.lookAhead,n];o=o?[t].concat(o):[t]}return new n3(t,e,i,s,o)}let u=[],p=[];for(;h.pos>0;)!function t(e,i,u,p,g,m){let{id:v,start:w,end:b,size:y}=h,k=c,x=a;for(;y<0;){if(h.next(),-1==y){let t=r[v];u.push(t),p.push(w-e);return}if(-3==y){a=v;return}if(-4==y){c=v;return}throw RangeError(`Unrecognized record size: ${y}`)}let S=l[v],C,P,A=w-e;if(b-w<=n&&(P=function(t,e){let i=h.fork(),s=0,r=0,l=0,a=i.end-n,c={size:0,start:0,skip:0};i:for(let n=i.pos-t;i.pos>n;){let t=i.size;if(i.id==e&&t>=0){c.size=s,c.start=r,c.skip=l,l+=4,s+=4,i.next();continue}let h=i.pos-t;if(t<0||h=o?4:0,d=i.start;for(i.next();i.pos>h;){if(i.size<0){if(-3==i.size)f+=4;else break i}else i.id>=o&&(f+=4);i.next()}r=d,s+=t,l+=f}return(e<0||s==t)&&(c.size=s,c.start=r,c.skip=l),c.size>4?c:void 0}(h.pos-i,g))){let t=new Uint16Array(P.size-P.skip),i=h.pos-P.size,n=t.length;for(;h.pos>i;)n=function t(e,i,s){let{id:n,start:r,end:l,size:f}=h;if(h.next(),f>=0&&n4){let n=h.pos-(f-4);for(;h.pos>n;)s=t(e,i,s)}i[--s]=o,i[--s]=l-e,i[--s]=r-e,i[--s]=n}else -3==f?a=n:-4==f&&(c=n);return s}(P.start,t,n);C=new n5(t,b-P.start,s),A=P.start-e}else{let e=h.pos-y;h.next();let i=[],r=[],l=v>=o?v:-1,a=0,c=b;for(;h.pos>e;)l>=0&&h.id==l&&h.size>=0?(h.end<=c-n&&(f(i,r,w,a,h.end,c,l,k,x),a=i.length,c=h.end),h.next()):m>2500?function(t,e,i,r){let o=[],l=0,a=-1;for(;h.pos>e;){let{id:t,start:e,end:i,size:s}=h;if(s>4)h.next();else if(a>-1&&e=0;t-=3)e[i++]=o[t],e[i++]=o[t+1]-n,e[i++]=o[t+2]-n,e[i++]=i;i.push(new n5(e,o[2]-n,s)),r.push(n-t)}}(w,e,i,r):t(w,e,i,r,l,m+1);if(l>=0&&a>0&&a-1&&a>0){let t=function(t,e){return(i,s,n)=>{let r=0,o=i.length-1,h,l;if(o>=0&&(h=i[o])instanceof n3){if(!o&&h.type==t&&h.length==n)return h;(l=h.prop(nQ.lookAhead))&&(r=s[o]+h.length+l)}return d(t,i,s,n,r,e)}}(S,x);C=rc(S,i,r,0,i.length,0,b-w,t,t)}else C=d(S,i,r,b-w,k-b,x)}u.push(C),p.push(A)}(t.start||0,t.bufferStart||0,u,p,-1,0);let g=null!==(e=t.length)&&void 0!==e?e:u.length?p[0]+u[0].length:0;return new n3(l[t.topID],u.reverse(),p.reverse(),g)}(t)}}n3.empty=new n3(nZ.none,[],[],0);class n4{constructor(t,e){this.buffer=t,this.index=e}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 n4(this.buffer,this.index)}}class n5{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return nZ.none}toString(){let t=[];for(let e=0;e0)));h=r[h+3]);return o}slice(t,e,i){let s=this.buffer,n=new Uint16Array(e-t),r=0;for(let o=t,h=0;o=e&&ie;case 1:return i<=e&&s>e;case 2:return s>e;case 4:return!0}}function n6(t,e,i,s){for(var n;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to0?o.length:-1;t!=l;t+=e){let l=o[t],a=h[t]+r.from;if(n8(s,i,a,a+l.length)){if(l instanceof n5){if(n&A.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,e,i-a,s);if(o>-1)return new rs(new ri(r,l,t,a),null,o)}else if(n&A.IncludeAnonymous||!l.type.isAnonymous||rh(l)){let o;if(!(n&A.IgnoreMounts)&&(o=nG.get(l))&&!o.overlay)return new n7(o.tree,a,t,r);let h=new n7(l,a,t,r);return n&A.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(e<0?l.children.length-1:0,e,i,s)}}}if(n&A.IncludeAnonymous||!r.type.isAnonymous||(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,!(r=r._parent)))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(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let s;if(!(i&A.IgnoreOverlays)&&(s=nG.get(this._tree))&&s.overlay){let i=t-this.from;for(let{from:t,to:n}of s.overlay)if((e>0?t<=i:t=i:n>i))return new n7(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function rt(t,e,i,s){let n=t.cursor(),r=[];if(!n.firstChild())return r;if(null!=i){for(let t=!1;!t;)if(t=n.type.is(i),!n.nextSibling())return r}for(;;){if(null!=s&&n.type.is(s))return r;if(n.type.is(e)&&r.push(n.node),!n.nextSibling())return null==s?r:[]}}function re(t,e,i=e.length-1){for(let s=t;i>=0;s=s.parent){if(!s)return!1;if(!s.type.isAnonymous){if(e[i]&&e[i]!=s.name)return!1;i--}}return!0}class ri{constructor(t,e,i,s){this.parent=t,this.buffer=e,this.index=i,this.start=s}}class rs extends n9{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(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.context.start,i);return n<0?null:new rs(this.context,this,n)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&A.ExcludeBuffers)return null;let{buffer:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return n<0?null:new rs(this.context,this,n)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new rs(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new rs(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,s=this.index+4,n=i.buffer[this.index+3];if(n>s){let r=i.buffer[this.index+1];t.push(i.slice(s,n,r)),e.push(0)}return new n3(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function rn(t){if(!t.length)return null;let e=0,i=t[0];for(let s=1;si.from||n.to0){if(this.index-1)for(let s=e+t,n=t<0?-1:i._tree.children.length;s!=n;s+=t){let t=i._tree.children[s];if(this.mode&A.IncludeAnonymous||t instanceof n5||!t.type.isAnonymous||rh(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to=0;){for(let r=t;r;r=r._parent)if(r.index==s){if(s==this.index)return r;e=r,i=n+1;break i}s=this.stack[--n]}for(let t=i;t=0;n--){if(n<0)return re(this._tree,t,s);let r=i[e.buffer[this.stack[n]]];if(!r.isAnonymous){if(t[s]&&t[s]!=r.name)return!1;s--}}return!0}}function rh(t){return t.children.some(t=>t instanceof n5||!t.type.isAnonymous||rh(t))}let rl=new WeakMap;function ra(t,e){if(!t.isAnonymous||e instanceof n5||e.type!=t)return 1;let i=rl.get(e);if(null==i){for(let s of(i=1,e.children)){if(s.type!=t||!(s instanceof n3)){i=1;break}i+=ra(t,s)}rl.set(e,i)}return i}function rc(t,e,i,s,n,r,o,h,l){let a=0;for(let i=s;i=c)break;p+=e}if(a==n+1){if(p>c){let t=i[n];e(t.children,t.positions,0,t.children.length,s[n]+h);continue}f.push(i[n])}else{let e=s[a-1]+i[a-1].length-u;f.push(rc(t,i,s,n,a,u,e,null,l))}d.push(u+h-r)}}(e,i,s,n,0),(h||l)(f,d,o)}class rf{constructor(t,e,i,s,n=!1,r=!1){this.from=t,this.to=e,this.tree=i,this.offset=s,this.open=(n?1:0)|(r?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let s=[new rf(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&s.push(i);return s}static applyChanges(t,e,i=128){if(!e.length)return t;let s=[],n=1,r=t.length?t[0]:null;for(let o=0,h=0,l=0;;o++){let a=o=i)for(;r&&r.from=e.from||c<=e.to||l){let t=Math.max(e.from,h)-l,i=Math.min(e.to,c)-l;e=t>=i?null:new rf(t,i,e.tree,e.offset+l,o>0,!!a)}if(e&&s.push(e),r.to>c)break;r=nnew nU(t.from,t.to)):[new nU(0,0)]:[new nU(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let s=this.startParse(t,e,i);for(;;){let t=s.advance();if(t)return t}}}class ru{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new nQ({perNode:!0});let rp=0;class rg{constructor(t,e,i,s){this.name=t,this.set=e,this.base=i,this.modified=s,this.id=rp++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){if(t instanceof rg&&(e=t),null==e?void 0:e.base)throw Error("Can not derive from a modified tag");let i=new rg("string"==typeof t?t:"?",[],null,[]);if(i.set.push(i),e)for(let t of e.set)i.set.push(t);return i}static defineModifier(t){let e=new rv(t);return t=>t.modified.indexOf(e)>-1?t:rv.get(t.base||t,t.modified.concat(e).sort((t,e)=>t.id-e.id))}}let rm=0;class rv{constructor(t){this.name=t,this.instances=[],this.id=rm++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(i=>{var s;return i.base==t&&(s=i.modified,e.length==s.length&&e.every((t,e)=>t==s[e]))});if(i)return i;let s=[],n=new rg(t.name,s,t,e);for(let t of e)t.instances.push(n);let r=function(t){let e=[[]];for(let i=0;ie.length-t.length)}(e);for(let e of t.set)if(!e.modified.length)for(let t of r)s.push(rv.get(e,t));return n}}function rw(t){let e=Object.create(null);for(let i in t){let s=t[i];for(let t of(Array.isArray(s)||(s=[s]),i.split(" ")))if(t){let i=[],n=2,r=t;for(let e=0;;){if("..."==r&&e>0&&e+3==t.length){n=1;break}let s=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!s)throw RangeError("Invalid path: "+t);if(i.push("*"==s[0]?"":'"'==s[0][0]?JSON.parse(s[0]):s[0]),(e+=s[0].length)==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){n=0;break}if("/"!=o)throw RangeError("Invalid path: "+t);r=t.slice(e)}let o=i.length-1,h=i[o];if(!h)throw RangeError("Invalid path: "+t);let l=new ry(s,n,o>0?i.slice(0,o):null);e[h]=l.sort(e[h])}}return rb.add(e)}let rb=new nQ;class ry{constructor(t,e,i,s){this.tags=t,this.mode=e,this.context=i,this.next=s}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth{let e=n;for(let s of t)for(let t of s.set){let s=i[t.id];if(s){e=e?e+" "+s:s;break}}return e},scope:s}}ry.empty=new ry([],2,null);class rx{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,s,n){let{type:r,from:o,to:h}=t;if(o>=i||h<=e)return;r.isTop&&(n=this.highlighters.filter(t=>!t.scope||t.scope(r)));let l=s,a=function(t){let e=t.type.prop(rb);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||ry.empty,c=function(t,e){let i=null;for(let s of t){let t=s.style(e);t&&(i=i?i+" "+t:t)}return i}(n,a.tags);if(c&&(l&&(l+=" "),l+=c,1==a.mode&&(s+=(s?" ":"")+c)),this.startSpan(Math.max(e,o),l),a.opaque)return;let f=t.tree&&t.tree.prop(nQ.mounted);if(f&&f.overlay){let r=t.node.enter(f.overlay[0].from+o,1),a=this.highlighters.filter(t=>!t.scope||t.scope(f.tree.type)),c=t.firstChild();for(let d=0,u=o;;d++){let p=d=g)&&t.nextSibling()););if(!p||g>i)break;(u=p.to+o)>e&&(this.highlightRange(r.cursor(),Math.max(e,p.from+o),Math.min(i,u),"",a),this.startSpan(Math.min(i,u),l))}c&&t.parent()}else if(t.firstChild()){f&&(s="");do{if(t.to<=e)continue;if(t.from>=i)break;this.highlightRange(t,e,i,s,n),this.startSpan(Math.min(i,t.to),l)}while(t.nextSibling())t.parent()}}}let rS=rg.define,rC=rS(),rP=rS(),rA=rS(rP),rM=rS(rP),rO=rS(),rT=rS(rO),rD=rS(rO),rE=rS(),rR=rS(rE),rB=rS(),rN=rS(),rL=rS(),rI=rS(rL),rV=rS(),rW={comment:rC,lineComment:rS(rC),blockComment:rS(rC),docComment:rS(rC),name:rP,variableName:rS(rP),typeName:rA,tagName:rS(rA),propertyName:rM,attributeName:rS(rM),className:rS(rP),labelName:rS(rP),namespace:rS(rP),macroName:rS(rP),literal:rO,string:rT,docString:rS(rT),character:rS(rT),attributeValue:rS(rT),number:rD,integer:rS(rD),float:rS(rD),bool:rS(rO),regexp:rS(rO),escape:rS(rO),color:rS(rO),url:rS(rO),keyword:rB,self:rS(rB),null:rS(rB),atom:rS(rB),unit:rS(rB),modifier:rS(rB),operatorKeyword:rS(rB),controlKeyword:rS(rB),definitionKeyword:rS(rB),moduleKeyword:rS(rB),operator:rN,derefOperator:rS(rN),arithmeticOperator:rS(rN),logicOperator:rS(rN),bitwiseOperator:rS(rN),compareOperator:rS(rN),updateOperator:rS(rN),definitionOperator:rS(rN),typeOperator:rS(rN),controlOperator:rS(rN),punctuation:rL,separator:rS(rL),bracket:rI,angleBracket:rS(rI),squareBracket:rS(rI),paren:rS(rI),brace:rS(rI),content:rE,heading:rR,heading1:rS(rR),heading2:rS(rR),heading3:rS(rR),heading4:rS(rR),heading5:rS(rR),heading6:rS(rR),contentSeparator:rS(rE),list:rS(rE),quote:rS(rE),emphasis:rS(rE),strong:rS(rE),link:rS(rE),monospace:rS(rE),strikethrough:rS(rE),inserted:rS(),deleted:rS(),changed:rS(),invalid:rS(),meta:rV,documentMeta:rS(rV),annotation:rS(rV),processingInstruction:rS(rV),definition:rg.defineModifier("definition"),constant:rg.defineModifier("constant"),function:rg.defineModifier("function"),standard:rg.defineModifier("standard"),local:rg.defineModifier("local"),special:rg.defineModifier("special")};for(let t in rW){let e=rW[t];e instanceof rg&&(e.name=t)}rk([{tag:rW.link,class:"tok-link"},{tag:rW.heading,class:"tok-heading"},{tag:rW.emphasis,class:"tok-emphasis"},{tag:rW.strong,class:"tok-strong"},{tag:rW.keyword,class:"tok-keyword"},{tag:rW.atom,class:"tok-atom"},{tag:rW.bool,class:"tok-bool"},{tag:rW.url,class:"tok-url"},{tag:rW.labelName,class:"tok-labelName"},{tag:rW.inserted,class:"tok-inserted"},{tag:rW.deleted,class:"tok-deleted"},{tag:rW.literal,class:"tok-literal"},{tag:rW.string,class:"tok-string"},{tag:rW.number,class:"tok-number"},{tag:[rW.regexp,rW.escape,rW.special(rW.string)],class:"tok-string2"},{tag:rW.variableName,class:"tok-variableName"},{tag:rW.local(rW.variableName),class:"tok-variableName tok-local"},{tag:rW.definition(rW.variableName),class:"tok-variableName tok-definition"},{tag:rW.special(rW.variableName),class:"tok-variableName2"},{tag:rW.definition(rW.propertyName),class:"tok-propertyName tok-definition"},{tag:rW.typeName,class:"tok-typeName"},{tag:rW.namespace,class:"tok-namespace"},{tag:rW.className,class:"tok-className"},{tag:rW.macroName,class:"tok-macroName"},{tag:rW.propertyName,class:"tok-propertyName"},{tag:rW.operator,class:"tok-operator"},{tag:rW.comment,class:"tok-comment"},{tag:rW.meta,class:"tok-meta"},{tag:rW.invalid,class:"tok-invalid"},{tag:rW.punctuation,class:"tok-punctuation"}]);let rF=/*@__PURE__*/new nQ,rH=/*@__PURE__*/new nQ;class rz{constructor(t,e,i=[],s=""){this.data=t,this.name=s,tC.prototype.hasOwnProperty("tree")||Object.defineProperty(tC.prototype,"tree",{get(){return rj(this)}}),this.parser=e,this.extension=[rZ.of(this),tC.languageData.of((t,e,i)=>{let s=r_(t,e,i),n=s.type.prop(rF);if(!n)return[];let r=t.facet(n),o=s.type.prop(rH);if(o){let n=s.resolve(e-s.from,i);for(let e of o)if(e.test(n,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(r)}}return r})].concat(i)}isActiveAt(t,e,i=-1){return r_(t,e,i).type.prop(rF)==this.data}findRegions(t){let e=t.facet(rZ);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],s=(t,e)=>{if(t.prop(rF)==this.data){i.push({from:e,to:e+t.length});return}let n=t.prop(nQ.mounted);if(n){if(n.tree.prop(rF)==this.data){if(n.overlay)for(let t of n.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(n.overlay){let t=i.length;if(s(n.tree,n.overlay[0].from+e),i.length>t)return}}for(let i=0;it.concat(e):void 0}));return new rq(i,t.parser.configure({props:[rF.add(t=>t.isTop?i:void 0)]}),t.name)}configure(t,e){return new rq(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function rj(t){let e=t.field(rz.state,!1);return e?e.tree:n3.empty}class rY{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let rK=null;class rX{constructor(t,e,i=[],s,n,r,o,h){this.parser=t,this.state=e,this.fragments=i,this.tree=s,this.treeLen=n,this.viewport=r,this.skipped=o,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new rX(t,e,[],n3.empty,0,i,[],null)}startParse(){return this.parser.startParse(new rY(this.state.doc),this.fragments)}work(t,e){return(null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=n3.empty&&this.isDone(null!=e?e:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(rf.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=rK;rK=this;try{return t()}finally{rK=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=r$(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:s,treeLen:n,viewport:r,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,i,s,n)=>e.push({fromA:t,toA:i,fromB:s,toB:n})),i=rf.applyChanges(i,e),s=n3.empty,n=0,r={from:t.mapPos(r.from,-1),to:t.mapPos(r.to,1)},this.skipped.length)for(let e of(o=[],this.skipped)){let i=t.mapPos(e.from,1),s=t.mapPos(e.to,-1);it.from&&(this.fragments=r$(this.fragments,i,s),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends rd{createParse(e,i,s){let n=s[0].from,r=s[s.length-1].to;return{parsedPos:n,advance(){let e=rK;if(e){for(let t of s)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=r,new n3(nZ.none,[],[],r-n)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return rK}}function r$(t,e,i){return rf.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class rU{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new rU(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=rX.create(t.facet(rZ).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new rU(i)}}rz.state=/*@__PURE__*/Q.define({create:rU.init,update(t,e){for(let t of e.effects)if(t.is(rz.setState))return t.value;return e.startState.facet(rZ)!=e.state.facet(rZ)?rU.init(e.state):t.apply(e)}});let rQ=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(rQ=t=>{let e=-1,i=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});let rG="undefined"!=typeof navigator&&(null===(M=navigator.scheduling)||void 0===M?void 0:M.isInputPending)?()=>navigator.scheduling.isInputPending():null,rJ=/*@__PURE__*/iC.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(rz.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(rz.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=rQ(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnds+1e3,h=n.context.work(()=>rG&&rG()||Date.now()>r,s+(o?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:rz.setState.of(new rU(n.context))})),this.chunkBudget>0&&!(h&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>iy(this.view.state,t)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),rZ=/*@__PURE__*/j.define({combine:t=>t.length?t[0]:null,enables:t=>[rz.state,rJ,s2.contentAttributes.compute([t],e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}})]});class r0{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}function r1(t,e){let i=e.mapPos(t.from,1),s=e.mapPos(t.to,-1);return i>=s?void 0:{from:i,to:s}}/*@__PURE__*/j.define(),/*@__PURE__*/j.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}}),/*@__PURE__*/j.define();let r2=/*@__PURE__*/tm.define({map:r1}),r3=/*@__PURE__*/tm.define({map:r1}),r4=/*@__PURE__*/Q.define({create:()=>ez.none,update(t,e){for(let i of(t=t.map(e.changes),e.effects))if(i.is(r2)&&!function(t,e,i){let s=!1;return t.between(e,e,(t,n)=>{t==e&&n==i&&(s=!0)}),s}(t,i.value.from,i.value.to)){let{preparePlaceholder:s}=e.state.facet(r8),n=s?ez.replace({widget:new r7(s(e.state,i.value))}):r9;t=t.update({add:[n.range(i.value.from,i.value.to)]})}else i.is(r3)&&(t=t.update({filter:(t,e)=>i.value.from!=t||i.value.to!=e,filterFrom:i.value.from,filterTo:i.value.to}));if(e.selection){let i=!1,{head:s}=e.selection.main;t.between(s,s,(t,e)=>{ts&&(i=!0)}),i&&(t=t.update({filterFrom:s,filterTo:s,filter:(t,e)=>e<=s||t>=s}))}return t},provide:t=>s2.decorations.from(t),toJSON(t,e){let i=[];return t.between(0,e.doc.length,(t,e)=>{i.push(t,e)}),i},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw RangeError("Invalid JSON for fold state");let e=[];for(let i=0;itP(t,r5)});function r6(t,e){let{state:i}=t,s=i.facet(r8),n=e=>{var i,s,n,r;let o,h=t.lineBlockAt(t.posAtDOM(e.target)),l=(i=t.state,s=h.from,n=h.to,o=null,null===(r=i.field(r4,!1))||void 0===r||r.between(s,n,(t,e)=>{(!o||o.from>t)&&(o={from:t,to:e})}),o);l&&t.dispatch({effects:r3.of(l)}),e.preventDefault()};if(s.placeholderDOM)return s.placeholderDOM(t,n,e);let r=document.createElement("span");return r.textContent=s.placeholderText,r.setAttribute("aria-label",i.phrase("folded code")),r.title=i.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=n,r}let r9=/*@__PURE__*/ez.replace({widget:/*@__PURE__*/new class extends eF{toDOM(t){return r6(t,null)}}});class r7 extends eF{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return r6(t,this.value)}}/*@__PURE__*/s2.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 ot{constructor(t,e){let i;function s(t){let e=tY.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;let n="string"==typeof e.all?e.all:e.all?s(e.all):void 0,r=e.scope;this.scope=r instanceof rz?t=>t.prop(rF)==r.data:r?t=>t==r:void 0,this.style=rk(t.map(t=>({tag:t.tag,class:t.class||s(Object.assign({},t,{tag:null}))})),{all:n}).style,this.module=i?new tY(i):null,this.themeType=e.themeType}static define(t,e){return new ot(t,e||{})}}let oe=/*@__PURE__*/j.define(),oi=/*@__PURE__*/j.define({combine:t=>t.length?[t[0]]:null});function os(t){let e=t.facet(oe);return e.length?e:t.facet(oi)}function on(t,e){let i=[or],s;return t instanceof ot&&(t.module&&i.push(s2.styleModule.of(t.module)),s=t.themeType),(null==e?void 0:e.fallback)?i.push(oi.of(t)):s?i.push(oe.computeN([s2.darkTheme],e=>e.facet(s2.darkTheme)==("dark"==s)?[t]:[])):i.push(oe.of(t)),i}let or=/*@__PURE__*/Z.high(/*@__PURE__*/iC.fromClass(class{constructor(t){this.markCache=Object.create(null),this.tree=rj(t.state),this.decorations=this.buildDeco(t,os(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=rj(t.state),i=os(t.state),s=i!=os(t.startState),{viewport:n}=t.view,r=t.changes.mapPos(this.decoratedTo,1);e.length=n.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=r):(e!=this.tree||t.viewportChanged||s)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=n.to)}buildDeco(t,e){if(!e||!this.tree.length)return ez.none;let i=new tE;for(let{from:s,to:n}of t.visibleRanges)!function(t,e,i,s=0,n=t.length){let r=new rx(s,Array.isArray(e)?e:[e],i);r.highlightRange(t.cursor(),s,n,"",r.highlighters),r.flush(n)}(this.tree,e,(t,e,s)=>{i.add(t,e,this.markCache[s]||(this.markCache[s]=ez.mark({class:s})))},s,n);return i.finish()}},{decorations:t=>t.decorations}));rW.meta,rW.link,rW.heading,rW.emphasis,rW.strong,rW.strikethrough,rW.keyword,rW.atom,rW.bool,rW.url,rW.contentSeparator,rW.labelName,rW.literal,rW.inserted,rW.string,rW.deleted,rW.regexp,rW.escape,/*@__PURE__*/rW.special(rW.string),/*@__PURE__*/rW.definition(rW.variableName),/*@__PURE__*/rW.local(rW.variableName),rW.typeName,rW.namespace,rW.className,/*@__PURE__*/rW.special(rW.variableName),rW.macroName,/*@__PURE__*/rW.definition(rW.propertyName),rW.comment,rW.invalid,/*@__PURE__*/s2.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}});let oo="()[]{}",oh=/*@__PURE__*/j.define({combine:t=>tP(t,{afterCursor:!0,brackets:oo,maxScanDistance:1e4,renderMatch:oc})}),ol=/*@__PURE__*/ez.mark({class:"cm-matchingBracket"}),oa=/*@__PURE__*/ez.mark({class:"cm-nonmatchingBracket"});function oc(t){let e=[],i=t.matched?ol:oa;return e.push(i.range(t.start.from,t.start.to)),t.end&&e.push(i.range(t.end.from,t.end.to)),e}/*@__PURE__*/Q.define({create:()=>ez.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let i=[],s=e.state.facet(oh);for(let t of e.state.selection.ranges){if(!t.empty)continue;let n=op(e.state,t.head,-1,s)||t.head>0&&op(e.state,t.head-1,1,s)||s.afterCursor&&(op(e.state,t.head,1,s)||t.heads2.decorations.from(t)});let of=/*@__PURE__*/new nQ;function od(t,e,i){let s=t.prop(e<0?nQ.openedBy:nQ.closedBy);if(s)return s;if(1==t.name.length){let s=i.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[i[s+e]]}return null}function ou(t){let e=t.type.prop(of);return e?e(t.node):t}function op(t,e,i,s={}){let n=s.maxScanDistance||1e4,r=s.brackets||oo,o=rj(t),h=o.resolveInner(e,i);for(let t=h;t;t=t.parent){let s=od(t.type,i,r);if(s&&t.from0?e>=n.from&&en.from&&e<=n.to))return function(t,e,i,s,n,r,o){let h=s.parent,l={from:n.from,to:n.to},a=0,c=null==h?void 0:h.cursor();if(c&&(i<0?c.childBefore(s.from):c.childAfter(s.to)))do if(i<0?c.to<=s.from:c.from>=s.to){if(0==a&&r.indexOf(c.type.name)>-1&&c.from0)return null;let a={from:i<0?e-1:e,to:i>0?e+1:e},c=t.doc.iterRange(e,i>0?t.doc.length:0),f=0;for(let t=0;!c.next().done&&t<=r;){let r=c.value;i<0&&(t+=r.length);let h=e+t*i;for(let t=i>0?0:r.length-1,e=i>0?r.length:-1;t!=e;t+=i){let e=o.indexOf(r[t]);if(!(e<0)&&s.resolveInner(h+t,1).type==n){if(e%2==0==i>0)f++;else{if(1==f)return{start:a,end:{from:h+t,to:h+t+1},matched:e>>1==l>>1};f--}}}i>0&&(t+=r.length)}return c.done?{start:a,matched:!1}:null}(t,e,i,o,h.type,n,r)}let og=/*@__PURE__*/Object.create(null),om=[nZ.none],ov=[],ow=/*@__PURE__*/Object.create(null),ob=/*@__PURE__*/Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])ob[t]=/*@__PURE__*/function(t,e){let i=[];for(let s of e.split(" ")){let e=[];for(let i of s.split(".")){let s=t[i]||rW[i];s?"function"==typeof s?e.length?e=e.map(s):oy(i,`Modifier ${i} used at start of tag`):e.length?oy(i,`Tag ${i} used as modifier`):e=Array.isArray(s)?s:[s]:oy(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let s=e.replace(/ /g,"_"),n=s+" "+i.map(t=>t.id),r=ow[n];if(r)return r.id;let o=ow[n]=nZ.define({id:om.length,name:s,props:[rw({[s]:i})]});return om.push(o),o.id}(og,e);function oy(t,e){ov.indexOf(t)>-1||(ov.push(t),console.warn(e))}function ok(t){return t.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(t)}function ox(t){for(let e=t.iter();!e.next().done;)if(ok(e.value))return!0;return!1}let oS=/*@__PURE__*/j.define({combine:t=>t.some(t=>t)});function oC(t,e,i){let s=new tE,n=t.visibleRanges;for(let{from:r,to:o}of(i||(n=function(t,e){let i=e.iter(),s=0,n=[],r=null;for(let{from:e,to:o}of t)if(!r||!(r.to>e)||!((e=r.to)>=o))for(s+i.value.lengtht-10?r.to=Math.min(o,e):n.push(r={from:t,to:Math.min(o,e)})),e>=o)break;s=e,i.next()}return n}(n,t.state.doc)),n))e.iterate({enter:t=>{let e=t.type.prop(nQ.isolate);e&&s.add(t.from,t.to,oP[e])},from:r,to:o});return s.finish()}/*@__PURE__*/iC.fromClass(class{constructor(t){this.always=t.state.facet(oS)||t.textDirection!=eZ.LTR||t.state.facet(s2.perLineTextDirection),this.hasRTL=!this.always&&ox(t.state.doc),this.tree=rj(t.state),this.decorations=this.always||this.hasRTL?oC(t,this.tree,this.always):ez.none}update(t){var e;let i,s=t.state.facet(oS)||t.view.textDirection!=eZ.LTR||t.state.facet(s2.perLineTextDirection);if(s||this.hasRTL||(e=t.changes,i=!1,e.iterChanges((t,e,s,n,r)=>{!i&&ox(r)&&(i=!0)}),!i)||(this.hasRTL=!0),!s&&!this.hasRTL)return;let n=rj(t.state);(s!=this.always||n!=this.tree||t.docChanged||t.viewportChanged)&&(this.tree=n,this.always=s,this.decorations=oC(t.view,n,s))}},{provide:t=>{function e(e){var i,s;return null!==(s=null===(i=e.plugin(t))||void 0===i?void 0:i.decorations)&&void 0!==s?s:ez.none}return[s2.outerDecorations.of(e),Z.lowest(s2.bidiIsolatedRanges.of(e))]}});let oP={rtl:/*@__PURE__*/ez.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:eZ.RTL}),ltr:/*@__PURE__*/ez.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:eZ.LTR}),auto:/*@__PURE__*/ez.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var oA={},oM=oA={};function oO(){throw Error("setTimeout has not been defined")}function oT(){throw Error("clearTimeout has not been defined")}function oD(t){if(O===setTimeout)return setTimeout(t,0);if((O===oO||!O)&&setTimeout)return O=setTimeout,setTimeout(t,0);try{return O(t,0)}catch(e){try{return O.call(null,t,0)}catch(e){return O.call(this,t,0)}}}!function(){try{O="function"==typeof setTimeout?setTimeout:oO}catch(t){O=oO}try{T="function"==typeof clearTimeout?clearTimeout:oT}catch(t){T=oT}}();var oE=[],oR=!1,oB=-1;function oN(){oR&&D&&(oR=!1,D.length?oE=D.concat(oE):oB=-1,oE.length&&oL())}function oL(){if(!oR){var t=oD(oN);oR=!0;for(var e=oE.length;e;){for(D=oE,oE=[];++oB1)for(var i=1;ie%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let s=t.parser.context;return new oW(t,[],e,i,i,0,[],0,s?new oF(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let i=t>>19,s=65535&t,{parser:n}=this.p,r=this.reducePos=2e3&&!(null===(e=this.p.parser.nodeSet.types[s])||void 0===e?void 0:e.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=a):this.p.lastBigReductionSizeh;)this.stack.pop();this.reduceContext(s,l)}storeNode(t,e,i,s=4,n=!1){if(0==t&&(!this.stack.length||this.stack[this.stack.length-1]0&&0==t.buffer[s-4]&&t.buffer[s-1]>-1){if(e==i)return;if(t.buffer[s-2]>=e){t.buffer[s-2]=i;return}}}if(n&&this.pos!=i){let n=this.buffer.length;if(n>0&&0!=this.buffer[n-4]){let t=!1;for(let e=n;e>0&&this.buffer[e-2]>i;e-=4)if(this.buffer[e-1]>=0){t=!0;break}if(t)for(;n>0&&this.buffer[n-2]>i;)this.buffer[n]=this.buffer[n-4],this.buffer[n+1]=this.buffer[n-3],this.buffer[n+2]=this.buffer[n-2],this.buffer[n+3]=this.buffer[n-1],n-=4,s>4&&(s-=4)}this.buffer[n]=t,this.buffer[n+1]=e,this.buffer[n+2]=i,this.buffer[n+3]=s}else this.buffer.push(t,e,i,s)}shift(t,e,i,s){if(131072&t)this.pushState(65535&t,this.pos);else if((262144&t)==0){let{parser:n}=this.p;(s>this.pos||e<=n.maxNode)&&(this.pos=s,n.stateFlag(t,1)||(this.reducePos=s)),this.pushState(t,i),this.shiftContext(e,i),e<=n.maxNode&&this.buffer.push(e,i,s,4)}else this.pos=s,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,s,4)}apply(t,e,i,s){65536&t?this.reduce(t):this.shift(t,e,i,s)}useNode(t,e){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let s=this.pos;this.reducePos=this.pos=s+t.length,this.pushState(e,s),this.buffer.push(i,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(;e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let i=t.buffer.slice(e),s=t.bufferBase+e;for(;t&&s==t.bufferBase;)t=t.parent;return new oW(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,i?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new oH(this);;){let i=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(0==i)return!1;if((65536&i)==0)return!0;e.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let i=[];for(let s=0,n;s1&e&&t==s)||i.push(e[t],s)}e=i}let i=[];for(let t=0;t>19,s=65535&e,n=this.stack.length-3*i;if(n<0||0>t.getGoto(this.stack[n],s,!1)){let t=this.findForcedReduction();if(null==t)return!1;e=t}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],i=(s,n)=>{if(!e.includes(s))return e.push(s),t.allActions(s,e=>{if(393216&e);else if(65536&e){let i=(e>>19)-n;if(i>1){let s=65535&e,n=this.stack.length-3*i;if(n>=0&&t.getGoto(this.stack[n],s,!1)>=0)return i<<19|65536|s}}else{let t=i(e,n+1);if(null!=t)return t}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(3!=this.stack.length)return!1;let{parser:t}=this.p;return 65535==t.data[t.stateSlot(this.state,1)]&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;ethis.lookAhead&&(this.emitLookAhead(),this.lookAhead=t)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class oF{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class oH{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t>>19;0==e?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(e-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],65535&t,!0);this.state=i}}class oz{constructor(t,e,i){this.stack=t,this.pos=e,this.index=i,this.buffer=t.buffer,0==this.index&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new oz(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;null!=t&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new oz(this.stack,this.pos,this.index)}}function o_(t,e=Uint16Array){if("string"!=typeof t)return t;let i=null;for(let s=0,n=0;s=92&&e--,e>=34&&e--;let n=e-32;if(n>=46&&(n-=46,i=!0),r+=n,i)break;r*=46}i?i[n++]=r:i=new e(r)}return i}class oq{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}let oj=new oq;class oY{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=oj,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let i=this.range,s=this.rangeIndex,n=this.pos+t;for(;ni.to:n>=i.to;){if(s==this.ranges.length-1)return null;let t=this.ranges[++s];n+=t.from-i.to,i=t}return n}clipPos(t){if(t>=this.range.from&&tt)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,i,s;if(e>=0&&e=this.chunk2Pos&&ie.to&&(this.chunk2=this.chunk2.slice(0,e.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(null==i||i=this.chunk2Pos&&this.posthis.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=oj,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let i="";for(let s of this.ranges){if(s.from>=e)break;s.to>t&&(i+=this.input.read(Math.max(s.from,t),Math.min(s.to,e)))}return i}}class oK{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;oX(this.data,t,e,this.id,i.data,i.tokenPrecTable)}}function oX(t,e,i,s,n,r){let o=0,h=1<0){let i=t[s];if(l.allows(i)&&(-1==e.token.value||e.token.value==i||function(t,e,i,s){let n=o$(i,s,e);return n<0||o$(i,s,t)a&&65535==t[i+3*c-3]){o=t[i+3*c-1];continue}for(;a>1,r=i+n+(n<<1),h=t[r],l=t[r+1]||65536;if(s=l)a=n+1;else{o=t[r+2],e.advance();continue i}}break}}function o$(t,e,i){for(let s=e,n;65535!=(n=t[s]);s++)if(n==i)return s-e;return -1}oK.prototype.contextual=oK.prototype.fallback=oK.prototype.extend=!1,(class{constructor(t,e,i){this.precTable=e,this.elseToken=i,this.data="string"==typeof t?o_(t):t}token(t,e){let i=t.pos,s=0;for(;;){let i=t.next<0,n=t.resolveOffset(1,1);if(oX(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(null==this.elseToken)return;if(!i&&s++,null==n)break;t.reset(n,t.token)}s&&(t.reset(i,t.token),t.acceptToken(this.elseToken,s))}}).prototype.contextual=oK.prototype.fallback=oK.prototype.extend=!1;let oU=void 0!==oA&&oA.env&&/\bparse\b/.test(void 0),oQ=null;function oG(t,e,i){let s=t.cursor(A.IncludeAnonymous);for(s.moveTo(e);;)if(!(i<0?s.childBefore(e):s.childAfter(e)))for(;;){if((i<0?s.toe)&&!s.type.isError)return i<0?Math.max(0,Math.min(s.to-1,e-25)):Math.min(t.length,Math.max(s.from+1,e+25));if(i<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return i<0?0:t.length}}class oJ{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?oG(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?oG(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(tt)return this.nextStart=r,null;if(n instanceof n3){if(r==t){if(r=Math.max(this.safeFrom,t)&&(this.trees.push(n),this.start.push(r),this.index.push(0))}else this.index[e]++,this.nextStart=r+n.length}}}class oZ{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(t=>new oq)}getActions(t){let e=0,i=null,{parser:s}=t.p,{tokenizers:n}=s,r=s.stateSlot(t.state,3),o=t.curContext?t.curContext.hash:0,h=0;for(let s=0;sa.end+25&&(h=Math.max(a.lookAhead,h)),0!=a.value)){let s=e;if(a.extended>-1&&(e=this.addActions(t,a.extended,a.end,e)),e=this.addActions(t,a.value,a.end,e),!l.extend&&(i=a,e>s))break}}for(;this.actions.length>e;)this.actions.pop();return h&&t.setLookAhead(h),i||t.pos!=this.stream.end||((i=new oq).value=t.p.parser.eofTerm,i.start=i.end=t.pos,e=this.addActions(t,i.value,i.end,e)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new oq,{pos:i,p:s}=t;return e.start=i,e.end=Math.min(i+1,s.stream.end),e.value=i==s.stream.end?s.parser.eofTerm:0,e}updateCachedToken(t,e,i){let s=this.stream.clipPos(i.pos);if(e.token(this.stream.reset(s,t),i),t.value>-1){let{parser:e}=i.p;for(let s=0;s=0&&i.p.parser.dialect.allows(n>>1)){(1&n)==0?t.value=n>>1:t.extended=n>>1;break}}}else t.value=0,t.end=this.stream.clipPos(s+1)}putAction(t,e,i,s){for(let e=0;e4*t.bufferLength?new oJ(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t,e,i=this.stacks,s=this.minStackPos,n=this.stacks=[];if(this.bigReductionCount>300&&1==i.length){let[t]=i;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;rs)n.push(o);else{if(this.advanceStack(o,n,i))continue;t||(t=[],e=[]),t.push(o);let s=this.tokens.getMainToken(o);e.push(s.value,s.end)}break}}if(!n.length){let e=t&&function(t){let e=null;for(let i of t){let t=i.p.stoppedAt;(i.pos==i.p.stream.end||null!=t&&i.pos>t)&&i.p.parser.stateFlag(i.state,2)&&(!e||e.scorethis.stoppedAt?t[0]:this.runRecovery(t,e,n);if(i)return oU&&console.log("Force-finish "+this.stackID(i)),this.stackToTree(i.forceAll())}if(this.recovering){let t=1==this.recovering?1:3*this.recovering;if(n.length>t)for(n.sort((t,e)=>e.score-t.score);n.length>t;)n.pop();n.some(t=>t.reducePos>s)&&this.recovering--}else if(n.length>1){s:for(let t=0;t500&&s.buffer.length>500){if((e.score-s.score||e.buffer.length-s.buffer.length)>0)n.splice(i--,1);else{n.splice(t--,1);continue s}}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let t=1;t ":"";if(null!=this.stoppedAt&&s>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let e=t.curContext&&t.curContext.tracker.strict,i=e?t.curContext.hash:0;for(let o=this.fragments.nodeAt(s);o;){let s=this.parser.nodeSet.types[o.type.id]==o.type?n.getGoto(t.state,o.type.id):-1;if(s>-1&&o.length&&(!e||(o.prop(nQ.contextHash)||0)==i))return t.useNode(o,s),oU&&console.log(r+this.stackID(t)+` (via reuse of ${n.getName(o.type.id)})`),!0;if(!(o instanceof n3)||0==o.children.length||o.positions[0]>0)break;let h=o.children[0];if(h instanceof n3&&0==o.positions[0])o=h;else break}}let o=n.stateSlot(t.state,4);if(o>0)return t.reduce(o),oU&&console.log(r+this.stackID(t)+` (via always-reduce ${n.getName(65535&o)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let h=this.tokens.getActions(t);for(let o=0;os?e.push(d):i.push(d)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return o1(t,e),!0}}runRecovery(t,e,i){let s=null,n=!1;for(let r=0;r ":"";if(o.deadEnd&&(n||(n=!0,o.restart(),oU&&console.log(a+this.stackID(o)+" (restarted)"),this.advanceFully(o,i))))continue;let c=o.split(),f=a;for(let t=0;c.forceReduce()&&t<10&&(oU&&console.log(f+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,i));t++)oU&&(f=this.stackID(c)+" -> ");for(let t of o.recoverByInsert(h))oU&&console.log(a+this.stackID(t)+" (via recover-insert)"),this.advanceFully(t,i);this.stream.end>o.pos?(l==o.pos&&(l++,h=0),o.recoverByDelete(h,l),oU&&console.log(a+this.stackID(o)+` (via recover-delete ${this.parser.getName(h)})`),o1(o,i)):(!s||s.scoret.topRules[e][1]),s=[];for(let t=0;t=0)n(s,t,e[i++]);else{let r=e[i+-s];for(let o=-s;o>0;o--)n(e[i++],t,r);i++}}}this.nodeSet=new n0(e.map((e,n)=>nZ.define({name:n>=this.minRepeatTerm?void 0:e,id:n,props:s[n],top:i.indexOf(n)>-1,error:0==n,skipped:t.skippedNodes&&t.skippedNodes.indexOf(n)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=1024;let r=o_(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let t=0;t"number"==typeof t?new oK(r,t):t),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,i){let s=new o0(this,t,e,i);for(let n of this.wrappers)s=n(s,t,e,i);return s}getGoto(t,e,i=!1){let s=this.goto;if(e>=s[0])return -1;for(let n=s[e+1];;){let e=s[n++],r=1&e,o=s[n++];if(r&&i)return o;for(let i=n+(e>>1);n0}validAction(t,e){return!!this.allActions(t,t=>t==e||null)}allActions(t,e){let i=this.stateSlot(t,4),s=i?e(i):void 0;for(let i=this.stateSlot(t,1);null==s;i+=3){if(65535==this.data[i]){if(1==this.data[i+1])i=o4(this.data,i+2);else break}s=e(o4(this.data,i+1))}return s}nextStates(t){let e=[];for(let i=this.stateSlot(t,1);;i+=3){if(65535==this.data[i]){if(1==this.data[i+1])i=o4(this.data,i+2);else break}if((1&this.data[i+2])==0){let t=this.data[i+1];e.some((e,i)=>1&i&&e==t)||e.push(this.data[i],t)}}return e}configure(t){let e=Object.assign(Object.create(o3.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw RangeError(`Invalid top rule name ${t.top}`);e.top=i}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(e=>{let i=t.tokenizers.find(t=>t.from==e);return i?i.to:e})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((i,s)=>{let n=t.specializers.find(t=>t.from==i.external);if(!n)return i;let r=Object.assign(Object.assign({},i),{external:n.to});return e.specializers[s]=o5(r),r})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),null!=t.strict&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),null!=t.bufferLength&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return null==e?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),i=e.map(()=>!1);if(t)for(let s of t.split(" ")){let t=e.indexOf(s);t>=0&&(i[t]=!0)}let s=null;for(let t=0;tt.external(i,s)<<1|e}return t.get}let o8=rw({KeywordControl:rW.controlKeyword,SupportFunction:rW.function(rW.keyword),KeywordOther:rW.keyword,EntityNameType:rW.typeName,ReasoningPhrase:rW.meta,Comment:rW.lineComment,OpenParen:rW.paren,CloseParen:rW.paren,OpenBrace:rW.brace,CloseBrace:rW.brace,OpenBracket:rW.squareBracket,CloseBracket:rW.squareBracket}),o6=o3.deserialize({version:14,states:"!jOQOPOOOOOO'#Cl'#ClOOOO'#Cj'#CjQQOPOOOQOPO'#ClOQOPO'#ClOQOPO'#ClOOOO-E6h-E6hOoOPO,59WOvOPO,59WO}OPO,59WOOOO1G.r1G.r",stateData:"!d~OQPORPOSPOTPOUPOVPOWSOYTO[UO~OXZO~PQOZZO~PQO]ZO~PQOVUQRSTWXYZ[]W~",goto:"!OaPPPPPPPPPPPPPPbPtQROWVRWXYQWSQXTRYUaQORSTUWXY",nodeNames:"⚠ Program KeywordControl SupportFunction KeywordOther EntityNameType ReasoningPhrase Comment OpenParen CloseParen OpenBrace CloseBrace OpenBracket CloseBracket",maxTerm:16,propSources:[o8],skippedNodes:[0],repeatNodeCount:1,tokenData:"Nd~Rmvw!|xy#Ryz#W![!]#]!}#O#z#P#Q$P#T#U$U#U#V(O#V#W)l#W#X3U#X#Y5W#Y#Z8]#Z#[8{#[#]9_#]#^:g#`#a>Y#a#b>f#b#c?R#c#d?j#d#e@o#e#fA}#f#gBZ#g#hFu#h#iJT#i#jLR#j#kLk#k#lMv#o#pNY#q#rN_~#ROQ~~#WOW~~#]OX~~#`P![!]#c~#hSV~OY#cZ;'S#c;'S;=`#t<%lO#c~#wP;=`<%l#c~$PO[~~$UO]~~$XR#b#c$b#g#h%Y#h#i'r~$eQ#W#X$k#h#i$p~$pOS~~$sP#c#d$v~$yP#b#c$|~%PP#m#n%S~%VP#a#b$k~%_QS~#g#h%e#m#n'S~%hQ#c#d%n#i#j&v~%qP#V#W%t~%wP#]#^%z~%}P#T#U&Q~&TP#h#i&W~&ZP#]#^&^~&aP#j#k&d~&gP#]#^&j~&mP#h#i&p~&sP#m#n$k~&yP#a#b&|~'PP#X#Y$k~'VP#a#b'Y~']P#a#b'`~'cP#X#Y'f~'iP#h#i'l~'oP#f#g&p~'uP#h#i'x~'{P#f#g$k~(RQ#X#Y(X#m#n(}~([Rpq$k#Z#[(e#]#^(q~(hP#]#^(k~(nP#b#c$k~(tP#b#c(w~(zP#Z#[!|~)SUU~OY(}Z!](}!^#Q(}#R;'S(};'S;=`)f<%lO(}~)iP;=`<%l(}~)oR#T#U)x#`#a+P#c#d+|~){Q#b#c*R#g#h*q~*UP#V#W*X~*[P#X#Y*_~*bP#`#a*e~*hP#X#Y*k~*nP#W#X$k~*tP#X#Y*w~*|PT~#g#h$k~+SP#i#j+V~+YP#g#h+]~+`P#h#i+c~+fP#X#Y+i~+lP#f#g+o~+tPS~#g#h+w~+|OR~~,PS#[#],]#a#b,{#b#c.W#f#g2l~,`P#X#Y,c~,fP#f#g,i~,lP#X#Y,o~,rP#b#c,u~,xP#V#W&|~-OQ#a#b-U#d#e-b~-XP#i#j-[~-_P#h#i%z~-eP#T#U-h~-kP#h#i-n~-qP#]#^-t~-wP#U#V-z~-}P#]#^.Q~.TP#`#a&d~.ZR#b#c.d#g#h/l#h#i1j~.gP#X#Y.j~.mP#V#W.p~.sP#h#i.v~.yP#X#Y.|~/PP#W#X/S~/VP#b#c/Y~/]P#X#Y/`~/cP#g#h/f~/iP#g#h$k~/oQ#]#^/u#h#i0n~/xQ#W#X0O#g#h0U~0RP#X#Y'x~0XP#h#i0[~0_P#X#Y0b~0eP#b#c0h~0kP#V#W&p~0qP#f#g0t~0wP#i#j0z~0}P#V#W1Q~1TP#h#i1W~1ZP#c#d1^~1aP#f#g1d~1gP#g#h+w~1mP#f#g1p~1sP#T#U1v~1yP#W#X1|~2PP#]#^2S~2VP#V#W2Y~2]P#h#i2`~2cP#]#^2f~2iP#c#d(k~2oP#f#g2r~2uP#X#Y2x~2{P#V#W3O~3RP#h#i/S~3XP#X#Y3[~3_P#Y#Z3b~3gRS~#Y#Z3p#]#^4S#d#e5Q~3sP#i#j3v~3yP#b#c3|~4PP#V#W$k~4VP#b#c4Y~4]P#]#^4`~4cP#h#i4f~4iP#]#^4l~4oP#c#d4r~4uP#b#c4x~4}PR~#g#h+w~5TP#f#g*e~5ZR#b#c5d#e#f6O#l#m6}~5gQ#W#X5m#j#k5r~5rOT~~5uP#]#^5x~5{P#f#g2f~6RP#i#j6U~6XP#T#U6[~6_P#`#a6b~6eQ#]#^6k#g#h$k~6nP#h#i6q~6tP#]#^6w~6zP#X#Y1d~7QRpq!|#]#^7Z#d#e7g~7^P#g#h7a~7dP#h#i,i~7jP#T#U7m~7pP#b#c7s~7vP#g#h7y~7|P#]#^8P~8SP#c#d8V~8YP#b#c1d~8`R#c#d8i#f#g8o#i#j3v~8lP#f#g!|~8rP#c#d8u~8xP#a#b(}~9OP#]#^9R~9UP#j#k9X~9[P#X#Y(k~9bQ#X#Y9h#c#d:T~9kQ#b#c,u#f#g9q~9tP#X#Y9w~9zP#U#V9}~:QP#m#n5m~:WP#`#a:Z~:^P#W#X:a~:dP#g#h!|~:jV#W#X;P#Y#Z;i#a#b;r#b#c<[#f#g=^#g#h>S#h#i$k~;SP#X#Y;V~;YP#a#b;]~;`P#d#e;c~;fP#c#d7a~;lQpq$k#Y#Z!|~;uP#d#e;x~;{P#`#aPP#l#m&W~>VPpq$k~>]P#X#Y>`~>cP#h#i$k~>iQ#X#Y>o#c#d>{~>rP#T#U>u~>xP#b#c/f~?OP#W#X&|~?UP#c#d?X~?[Q#h#i?b#k#l5m~?gPQ~#T#U4`~?mS#Y#Z$k#f#g!|#h#i?y#j#k0O~?|P#[#]@P~@SP#X#Y@V~@YP#f#g@]~@`P#k#l@c~@fP#]#^@i~@lP#g#h&|~@rQ#X#Y'x#f#g@x~@{Q#X#Y*k#c#dAR~AUR#^#_A_#c#dAk#j#kAq~AbP#X#YAe~AhP#V#W&Q~AnP#Y#Z5m~AtP#]#^Aw~AzP#W#X*e~BQP#i#jBT~BWP#T#U$k~B^P#X#YBa~BdU#V#WBv#W#XCf#Y#Z=p#Z#[DO#e#fEa#g#hFc~ByP#c#dB|~CPP#b#cCS~CVP#g#hCY~C]P#]#^C`~CcP#W#X0O~CiP#X#YCl~CoP#Y#ZCr~CuP#]#^Cx~C{P#b#c&|~DRP#]#^DU~DXP#g#hD[~D_P#h#iDb~DeP#f#gDh~DkP#T#UDn~DqP#h#iDt~DwP#]#^Dz~D}P#c#dEQ~ETP#b#cEW~EZQpq+w#g#h+w~EdP#i#jEg~EjP#]#^Em~EpP#f#gEs~EvP#X#YEy~E|P#a#bFP~FSP#X#YFV~FYP#b#cF]~F`P#h#i1d~FfP#X#YFi~FlP#f#gFo~FrP#j#k&|~FxT#V#WGX#]#^Gq#h#iHm#i#jIR#m#nIz~G[P#[#]G_~GbP#X#YGe~GhP#a#bGk~GnP#X#Y4x~GtP#Z#[Gw~GzP#b#cG}~HQP#T#UHT~HWP#h#iHZ~H^P#i#jHa~HdP#f#gHg~HjP#X#Y+w~HrPQ~#f#gHu~HxP#i#jH{~IOP#V#W>`~IUQ#V#WI[#d#eIb~I_P#[#]$k~IeP#d#eIh~IkP#c#dIn~IqP#g#hIt~IwP#X#Y5m~I}Q#a#b'Y#b#c$p~JWR#T#UJa#[#]Jg#f#gKi~JdP#_#`&|~JjR#T#U>`#X#YJs#i#j/f~JvR#b#c$k#c#dKP#g#hKc~KSP#f#gKV~KYP#X#YK]~K`P#a#b4x~KfP#]#^/f~KlP#T#UKo~KrP#b#cKu~KxP#g#hK{~LOP#]#^&Q~LUP#b#cLX~L[P#]#^L_~LbP#e#fLe~LhP#i#j=W~LnP#c#dLq~LtP#V#WLw~LzP#T#UL}~MQP#U#VMT~MWP#i#jMZ~M^P#`#aMa~MdP#T#UMg~MjP#f#gMm~MpQ#]#^6w#m#n+w~MyP#[#]M|~NPP#X#YNS~NVP#f#g&|~N_OY~~NdOZ~",tokenizers:[0],topRules:{Program:[0,1]},tokenPrec:52}),o9=ot.define([{tag:rW.controlKeyword,class:"control-keyword"},{tag:rW.function(rW.keyword),class:"function-keyword"},{tag:rW.keyword,class:"general-keyword"},{tag:rW.typeName,class:"type-name"},{tag:rW.meta,class:"meta-info"},{tag:rW.lineComment,class:"line-comment"},{tag:rW.paren,class:"paren"},{tag:rW.brace,class:"brace"},{tag:rW.squareBracket,class:"square-bracket"}]),o7=o6.configure({props:[o8]}),ht=rq.define({parser:o7}),he=new te,hi=window.editors=window.editors||{},hs=window.lineNumberConfigs=window.lineNumberConfigs||{},hn=window.editorOrder=window.editorOrder||[],hr=tm.define(),ho=Q.define({create:()=>ez.none,update(t,e){for(let i of(t=t.map(e.changes),e.effects))i.is(hr)&&(t=t.update({add:i.value}));return t},provide:t=>s2.decorations.from(t)});document.addEventListener("DOMContentLoaded",function(){window.mizarInitialized=!0;let t=document.querySelectorAll(".mizarWrapper");if(0===t.length){console.warn("No Mizar blocks found.");return}t.forEach(t=>{let e=t.id.replace("mizarBlock","");t.querySelector(".editor-container").firstChild||function(t,e){let i=t.querySelector(".editor-container");i.id=`editorContainer${e}`;let s=i.getAttribute("data-content"),n=document.createElement("div");n.innerHTML=s;let r=n.textContent||n.innerText||"",o=new te;hs[e]=o;let h=new s2({state:tC.create({doc:r,extensions:[o.of(nK({formatNumber:t=>`${t+function(t){let e=1;for(let i of hn){if(i===t)break;e+=hi[i].state.doc.lines}return e}(e)-1}`})),he.of(s2.editable.of(!1)),on(o9),iC.fromClass(class{constructor(t){this.decorations=this.buildDecorations(t)}update(t){(t.docChanged||t.viewportChanged)&&(this.decorations=this.buildDecorations(t.view))}buildDecorations(t){let e=new tE,i=[],s=["bracket-color-0","bracket-color-1","bracket-color-2","bracket-color-3","bracket-color-4"];return rj(t.state).iterate({enter:({type:t,from:n,to:r})=>{if(t.is("OpenParen")||t.is("OpenBrace")||t.is("OpenBracket")){i.push({type:t,from:n,to:r});let o=i.length%s.length;e.add(n,r,ez.mark({class:s[o]}))}else if((t.is("CloseParen")||t.is("CloseBrace")||t.is("CloseBracket"))&&i.pop()){let t=(i.length+1)%s.length;e.add(n,r,ez.mark({class:s[t]}))}}}),e.finish()}},{decorations:t=>t.decorations}),s2.updateListener.of(t=>{t.docChanged&&function(){let t=1;for(let e of hn){let i=hi[e],s=t,n=nK({formatNumber:t=>`${t+s-1}`});i.dispatch({effects:hs[e].reconfigure(n)}),t+=i.state.doc.lines}}()}),hl,ho,on(o9),new r0(ht)]}),parent:i});window.editors[e]=h,hn.push(e);let l=t.querySelector('button[id^="editButton"]'),a=t.querySelector('button[id^="compileButton"]'),c=t.querySelector('button[id^="resetButton"]');l.addEventListener("click",()=>{h.dispatch({effects:he.reconfigure(s2.editable.of(!0))}),l.style.display="none",a.style.display="inline",c.style.display="inline"}),a.addEventListener("click",()=>{t.isRequestInProgress||(t.isRequestInProgress=!0,hc(t,hh,e))}),c.addEventListener("click",async()=>{let t=i.getAttribute("data-content"),e=document.createElement("div");e.innerHTML=t;let s=e.textContent||e.innerText||"";h.dispatch({changes:{from:0,to:h.state.doc.length,insert:s}}),h.dispatch({effects:he.reconfigure(s2.editable.of(!1))}),l.style.display="inline",a.style.display="none",c.style.display="none",h.dispatch({effects:hh.of(null)}),h.dispatch({effects:hr.of([])});try{let t;let e=await fetch(DOKU_BASE+"lib/exe/ajax.php?call=clear_temp_files",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"}}),i=await e.text();try{t=JSON.parse(i)}catch(t){throw Error("Server returned a non-JSON response: "+i)}t.success?console.log(t.message):console.error("Failed to clear temporary files:",t.message)}catch(t){console.error("Error clearing temporary files:",t)}}),h.dom.addEventListener("keydown",t=>{if("Enter"===t.key&&h.state.facet(s2.editable)){t.preventDefault();let e=h.state.update({changes:{from:h.state.selection.main.head,insert:"\n"}});h.dispatch(e)}})}(t,e)})},{once:!0});let hh=tm.define(),hl=Q.define({create:()=>null,update(t,e){for(let i of e.effects)i.is(hh)&&(t=i.value);return t},provide:t=>nO.from(t,t=>t?e=>{let i=document.createElement("div");return i.innerHTML=t,i.className="cm-error-panel",{dom:i}}:null)});function ha(t){let e=1;for(let i of hn){let s=hi[i],n=s.state.doc.lines;if(t>=e&&t",s.dispatch({effects:e.of(n)}),n.includes("❌")?s.dom.querySelector(".cm-error-panel").style.backgroundColor="#fcc":s.dom.querySelector(".cm-error-panel").style.backgroundColor="#ccffcc"},t.eventSource.addEventListener("compileFinished",()=>{hf(t)}),t.eventSource.addEventListener("compileErrors",function(t){try{let s=JSON.parse(t.data),n=hi[i].state.field(hl)||"",r={};for(let t in s.forEach(function(t){let{line:e,column:i,message:s}=t,o=`[Ln ${e}, Col ${i}]`;n+=`\u{274C} ${s} ${o}
`;let h=ha(e);if(h){let{editor:t,localLine:n}=h,o=t.state.doc.line(n),l=o.from+(i-1),a=l+1;if(l>=o.from&&a<=o.to){let n=ez.mark({class:"error-underline",attributes:{title:`${s} (Ln ${e}, Col ${i})`}}).range(l,a),o=Object.keys(hi).find(e=>hi[e]===t);r[o]||(r[o]=[]),r[o].push(n)}}}),r){let e=hi[t],i=r[t];i.length>0&&e.dispatch({effects:hr.of(i.sort((t,e)=>t.from-e.from))})}hi[i].dispatch({effects:[e.of(n)]}),n.includes("❌")?hi[i].dom.querySelector(".cm-error-panel").style.backgroundColor="#fcc":hi[i].dom.querySelector(".cm-error-panel").style.backgroundColor="#ccffcc",hi[i].dom.querySelector(".cm-error-panel").querySelectorAll(".error-link").forEach(t=>{t.addEventListener("click",function(e){e.preventDefault();let i=parseInt(t.getAttribute("data-line"),10),s=ha(i);if(s){let{editor:t,localLine:e}=s;!function(t,e){let i=t.state.doc.line(e);t.dispatch({scrollIntoView:{from:i.from,to:i.to}})}(t,e)}})})}catch(e){console.error("Failed to parse error data:",e),console.error("Event data:",t.data)}}),t.eventSource.onerror=()=>{t.eventSource.close(),t.isRequestInProgress=!1,hf(t)}}catch(e){console.error("Fetch error: ",e),t.isRequestInProgress=!1}}function hf(t){let e=t.querySelector('[id^="compileButton"]'),i=t.querySelector('[id^="resetButton"]');e.style.display="none",i.style.display="inline-block",t.isRequestInProgress=!1}window.createMizarFile=async function(t){let e=function(){let t="";for(let e of hn){let i=hi[e];i&&i.state&&(t+=i.state.doc.toString()+"\n")}return t}();if(!e){console.error("Error: Combined content is empty.");return}try{let i=await fetch(DOKU_BASE+"lib/exe/ajax.php?call=create_combined_file",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"content="+encodeURIComponent(e)+"&filename="+encodeURIComponent(t)});if(!i.ok){console.error("Failed to create file: Network response was not ok");return}let s=await i.json();if(s.success){console.log("File created successfully:",t);let e=window.open("","_blank");e.document.write(`
${s.data.content}
`),e.document.title=t;let i=new Blob([s.data.content],{type:"text/plain"}),n=URL.createObjectURL(i),r=e.document.createElement("a");r.href=n,r.download=t,r.textContent="⬇️ Click here to download the file",r.style.display="block",r.style.marginTop="10px",e.document.body.appendChild(r),e.addEventListener("unload",()=>{URL.revokeObjectURL(n)})}else console.error("Failed to create file:",s.message)}catch(t){console.error("Error creating file:",t)}},document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".copy-button").forEach(t=>{t.addEventListener("click",t=>{let e=t.currentTarget,i=e.dataset.mizarid,s=i.replace("mizarBlock","");if(!hi[s]){console.error("エディタが見つかりません: ",i);return}let n=hi[s].state.doc.toString();navigator.clipboard.writeText(n).then(()=>{e.textContent="Copied!",e.disabled=!0,setTimeout(()=>{e.textContent="Copy",e.disabled=!1},2e3)}).catch(t=>{console.error("コピーに失敗しました: ",t)})})})})})(); //# sourceMappingURL=script.js.map