whistle.mock-plugins 1.4.0-beta.2 → 1.4.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkwhistle_mock_plugins=self.webpackChunkwhistle_mock_plugins||[]).push([[602],{365:(t,e,i)=>{i.d(e,{PH:()=>p,Qj:()=>d,Z6:()=>h,cF:()=>s,fI:()=>c,iX:()=>B,rr:()=>E,uY:()=>o});const s=1024;let n=0;class r{constructor(t,e){this.from=t,this.to=e}}class o{constructor(t={}){this.id=n++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=h.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}o.closedBy=new o({deserialize:t=>t.split(" ")}),o.openedBy=new o({deserialize:t=>t.split(" ")}),o.group=new o({deserialize:t=>t.split(" ")}),o.isolate=new o({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),o.contextHash=new o({perNode:!0}),o.lookAhead=new o({perNode:!0}),o.mounted=new o({perNode:!0});class l{constructor(t,e,i,s=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=s}static get(t){return t&&t.props&&t.props[o.mounted.id]}}const a=Object.create(null);class h{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):a,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),s=new h(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 new 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(o.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(o.group),s=-1;s<(i?i.length:0);s++){let n=e[s<0?t.name:i[s]];if(n)return n}}}}h.none=new h("",Object.create(null),0,8);class c{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let s=null;for(let e of t){let t=e(i);if(t){s||(s=Object.assign({},i.props));let e=t[1],n=t[0];n.combine&&n.id in s&&(e=n.combine(s[n.id],e)),s[n.id]=e}}e.push(s?new h(i.name,s,i.id,i.flags):i)}return new c(e)}}const u=new WeakMap,f=new WeakMap;var d;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"}(d||(d={}));class p{constructor(t,e,i,s,n){if(this.type=t,this.children=e,this.positions=i,this.length=s,this.props=null,n&&n.length){this.props=Object.create(null);for(let[t,e]of n)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=l.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new O(this.topNode,t)}cursorAt(t,e=0,i=0){let s=u.get(this)||this.topNode,n=new O(s);return n.moveTo(t,e),u.set(this,n._tree),n}get topNode(){return new y(this,0,0,null)}resolve(t,e=0){let i=w(u.get(this)||this.topNode,t,e,!1);return u.set(this,i),i}resolveInner(t,e=0){let i=w(f.get(this)||this.topNode,t,e,!0);return f.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let s=t.resolveInner(e,i),n=null;for(let t=s instanceof y?s:s.context.parent;t;t=t.parent)if(t.index<0){let r=t.parent;(n||(n=[s])).push(r.resolve(e,i)),t=r}else{let r=l.get(t.tree);if(r&&r.overlay&&r.overlay[0].from<=e&&r.overlay[r.overlay.length-1].to>=e){let o=new y(r.tree,r.overlay[0].from+t.from,-1,t);(n||(n=[s])).push(w(o,e,i,!1))}}return n?A(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&d.IncludeAnonymous)>0;for(let t=this.cursor(r|d.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:P(h.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new p(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new p(h.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:r=s,reused:l=[],minRepeatType:a=n.types.length}=t,h=Array.isArray(i)?new m(i,i.length):i,c=n.types,u=0,f=0;function d(t,e,i,s,m,x){let{id:k,start:S,end:C,size:A}=h,M=f,O=u;if(A<0){if(h.next(),-1==A){let e=l[k];return i.push(e),void s.push(S-t)}if(-3==A)return void(u=k);if(-4==A)return void(f=k);throw new RangeError(`Unrecognized record size: ${A}`)}let T,D,R=c[k],E=S-t;if(C-S<=r&&(D=function(t,e){let i=h.fork(),s=0,n=0,o=0,l=i.end-r,c={size:0,start:0,skip:0};t:for(let r=i.pos-t;i.pos>r;){let t=i.size;if(i.id==e&&t>=0){c.size=s,c.start=n,c.skip=o,o+=4,s+=4,i.next();continue}let h=i.pos-t;if(t<0||h<r||i.start<l)break;let u=i.id>=a?4:0,f=i.start;for(i.next();i.pos>h;){if(i.size<0){if(-3!=i.size&&-4!=i.size)break t;u+=4}else i.id>=a&&(u+=4);i.next()}n=f,s+=t,o+=u}return(e<0||s==t)&&(c.size=s,c.start=n,c.skip=o),c.size>4?c:void 0}(h.pos-e,m))){let e=new Uint16Array(D.size-D.skip),i=h.pos-D.size,s=e.length;for(;h.pos>i;)s=y(D.start,e,s);T=new g(e,C-D.start,n),E=D.start-t}else{let t=h.pos-A;h.next();let e=[],i=[],s=k>=a?k:-1,n=0,l=C,c=M;for(;h.pos>t;)s>=0&&h.id==s&&h.size>=0?(h.end<=l-r&&(w(e,i,S,n,h.end,l,s,c,O),n=e.length,l=h.end,c=f),h.next()):x>2500?v(S,t,e,i):d(S,t,e,i,s,x+1);if(s>=0&&n>0&&n<e.length&&w(e,i,S,n,S,l,s,c,O),e.reverse(),i.reverse(),s>-1&&n>0){let t=function(t,e){return(i,s,n)=>{let r,l,a=0,h=i.length-1;if(h>=0&&(r=i[h])instanceof p){if(!h&&r.type==t&&r.length==n)return r;(l=r.prop(o.lookAhead))&&(a=s[h]+r.length+l-n)}return b(t,i,s,n,a,e)}}(R,O);T=P(R,e,i,0,e.length,0,C-S,t,t)}else T=b(R,e,i,C-S,M-C,O)}i.push(T),s.push(E)}function v(t,e,i,s){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<a)break;a<0&&(a=i-r),o.push(t,e,i),l++,h.next()}}if(l){let e=new Uint16Array(4*l),r=o[o.length-2];for(let t=o.length-3,i=0;t>=0;t-=3)e[i++]=o[t],e[i++]=o[t+1]-r,e[i++]=o[t+2]-r,e[i++]=i;i.push(new g(e,o[2]-r,n)),s.push(r-t)}}function w(t,e,i,s,r,o,l,a,h){let c=[],u=[];for(;t.length>s;)c.push(t.pop()),u.push(e.pop()+i-r);t.push(b(n.types[l],c,u,o-r,a-o,h)),e.push(r-i)}function b(t,e,i,s,n,r,l){if(r){let t=[o.contextHash,r];l=l?[t].concat(l):[t]}if(n>25){let t=[o.lookAhead,n];l=l?[t].concat(l):[t]}return new p(t,e,i,s,l)}function y(t,e,i){let{id:s,start:n,end:r,size:o}=h;if(h.next(),o>=0&&s<a){let l=i;if(o>4){let s=h.pos-(o-4);for(;h.pos>s;)i=y(t,e,i)}e[--i]=l,e[--i]=r-t,e[--i]=n-t,e[--i]=s}else-3==o?u=s:-4==o&&(f=s);return i}let x=[],k=[];for(;h.pos>0;)d(t.start||0,t.bufferStart||0,x,k,-1,0);let S=null!==(e=t.length)&&void 0!==e?e:x.length?k[0]+x[0].length:0;return new p(c[t.topID],x.reverse(),k.reverse(),S)}(t)}}p.empty=new p(h.none,[],[],0);class m{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 m(this.buffer,this.index)}}class g{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return h.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],s=this.set.types[e],n=s.name;if(/\W/.test(n)&&!s.isError&&(n=JSON.stringify(n)),i==(t+=4))return n;let r=[];for(;t<i;)r.push(this.childString(t)),t=this.buffer[t+3];return n+"("+r.join(",")+")"}findChild(t,e,i,s,n){let{buffer:r}=this,o=-1;for(let l=t;l!=e&&!(v(n,s,r[l+1],r[l+2])&&(o=l,i>0));l=r[l+3]);return o}slice(t,e,i){let s=this.buffer,n=new Uint16Array(e-t),r=0;for(let o=t,l=0;o<e;){n[l++]=s[o++],n[l++]=s[o++]-i;let e=n[l++]=s[o++]-i;n[l++]=s[o++]-t,r=Math.max(r,e)}return new g(n,r,this.set)}}function v(t,e,i,s){switch(t){case-2:return i<e;case-1:return s>=e&&i<e;case 0:return i<e&&s>e;case 1:return i<=e&&s>e;case 2:return s>e;case 4:return!0}}function w(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.to<e);){let e=!s&&t instanceof y&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=s?0:d.IgnoreOverlays;if(s)for(let s=t,o=s.parent;o;s=o,o=s.parent)s instanceof y&&s.index<0&&(null===(n=o.enter(e,i,r))||void 0===n?void 0:n.from)!=s.from&&(t=o);for(;;){let s=t.enter(e,i,r);if(!s)return t;t=s}}class b{cursor(t=0){return new O(this,t)}getChild(t,e=null,i=null){let s=x(this,t,e,i);return s.length?s[0]:null}getChildren(t,e=null,i=null){return x(this,t,e,i)}resolve(t,e=0){return w(this,t,e,!1)}resolveInner(t,e=0){return w(this,t,e,!0)}matchContext(t){return k(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(i=e,e=t.prevSibling):e=t}return i}get node(){return this}get next(){return this.parent}}class y extends b{constructor(t,e,i,s){super(),this._tree=t,this.from=e,this.index=i,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,s,n=0){for(let r=this;;){for(let{children:o,positions:a}=r._tree,h=e>0?o.length:-1;t!=h;t+=e){let h,c=o[t],u=a[t]+r.from;if(n&d.EnterBracketed&&c instanceof p&&(h=l.get(c))&&!h.overlay&&h.bracketed&&i>=u&&i<=u+c.length||v(s,i,u,u+c.length))if(c instanceof g){if(n&d.ExcludeBuffers)continue;let o=c.findChild(0,c.buffer.length,e,i-u,s);if(o>-1)return new C(new S(r,c,t,u),null,o)}else if(n&d.IncludeAnonymous||!c.type.isAnonymous||T(c)){let o;if(!(n&d.IgnoreMounts)&&(o=l.get(c))&&!o.overlay)return new y(o.tree,u,t,r);let a=new y(c,u,t,r);return n&d.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(e<0?c.children.length-1:0,e,i,s,n)}}if(n&d.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)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)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let s;if(!(i&d.IgnoreOverlays)&&(s=l.get(this._tree))&&s.overlay){let n=t-this.from,r=i&d.EnterBracketed&&s.bracketed;for(let{from:t,to:i}of s.overlay)if((e>0||r?t<=n:t<n)&&(e<0||r?i>=n:i>n))return new y(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 x(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 k(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 S{constructor(t,e,i,s){this.parent=t,this.buffer=e,this.index=i,this.start=s}}class C extends b{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 C(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)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&d.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 C(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 C(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 C(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 p(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function A(t){if(!t.length)return null;let e=0,i=t[0];for(let s=1;s<t.length;s++){let n=t[s];(n.from>i.from||n.to<i.to)&&(i=n,e=s)}let s=i instanceof y&&i.index<0?null:i.parent,n=t.slice();return s?n[e]=s:n.splice(e,1),new M(n,i)}class M{constructor(t,e){this.heads=t,this.node=e}get next(){return A(this.heads)}}class O{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~d.EnterBracketed,t instanceof y)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:s}=this.buffer;return this.type=e||s.set.types[s.buffer[t]],this.from=i+s.buffer[t+1],this.to=i+s.buffer[t+2],!0}yield(t){return!!t&&(t instanceof y?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:s}=this.buffer,n=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.buffer.start,i);return!(n<0)&&(this.stack.push(this.index),this.yieldBuf(n))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&d.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&d.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&d.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:s}=this;if(s){if(t>0){if(this.index<s.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(s.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=s)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-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&d.IncludeAnonymous||t instanceof g||!t.type.isAnonymous||T(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<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let s=this.index,n=this.stack.length;n>=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 t}s=this.stack[--n]}for(let t=i;t<this.stack.length;t++)e=new C(this.buffer,e,this.stack[t]);return this.bufferNode=new C(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let s=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&e&&e(this),s=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,s=!0}}}matchContext(t){if(!this.buffer)return k(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let s=t.length-1,n=this.stack.length-1;s>=0;n--){if(n<0)return k(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 T(t){return t.children.some((t=>t instanceof g||!t.type.isAnonymous||T(t)))}const D=new WeakMap;function R(t,e){if(!t.isAnonymous||e instanceof g||e.type!=t)return 1;let i=D.get(e);if(null==i){i=1;for(let s of e.children){if(s.type!=t||!(s instanceof p)){i=1;break}i+=R(t,s)}D.set(e,i)}return i}function P(t,e,i,s,n,r,o,l,a){let h=0;for(let i=s;i<n;i++)h+=R(t,e[i]);let c=Math.ceil(1.5*h/8),u=[],f=[];return function e(i,s,n,o,l){for(let h=n;h<o;){let n=h,d=s[h],p=R(t,i[h]);for(h++;h<o;h++){let e=R(t,i[h]);if(p+e>=c)break;p+=e}if(h==n+1){if(p>c){let t=i[n];e(t.children,t.positions,0,t.children.length,s[n]+l);continue}u.push(i[n])}else{let e=s[h-1]+i[h-1].length-d;u.push(P(t,i,s,n,h,d,e,null,a))}f.push(d+l-r)}}(e,i,s,n,0),(l||a)(u,f,o)}class E{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 E(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,l=0,a=0;;o++){let h=o<e.length?e[o]:null,c=h?h.fromA:1e9;if(c-l>=i)for(;r&&r.from<c;){let e=r;if(l>=e.from||c<=e.to||a){let t=Math.max(e.from,l)-a,i=Math.min(e.to,c)-a;e=t>=i?null:new E(t,i,e.tree,e.offset+a,o>0,!!h)}if(e&&s.push(e),r.to>c)break;r=n<t.length?t[n++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return s}}class B{startParse(t,e,i){return"string"==typeof t&&(t=new L(t)),i=i?i.length?i.map((t=>new r(t.from,t.to))):[new r(0,0)]:[new r(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 L{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 o({perNode:!0})},1419:(t,e,i)=>{i.d(e,{$w:()=>w,bu:()=>k});var s=i(6898),n=i(1638),r=i(3748);class o{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}}class l{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let r=i.facet(y).markerFilter;r&&(t=r(t,i));let o=t.slice().sort(((t,e)=>t.from-e.from||t.to-e.to)),h=new n.vB,c=[],u=0,f=i.doc.iter(),d=0,p=i.doc.length;for(let t=0;;){let e,i,n=t==o.length?null:o[t];if(!n&&!c.length)break;if(c.length)e=u,i=c.reduce(((t,e)=>Math.min(t,e.to)),n&&n.from>e?n.from:1e8);else{if(e=n.from,e>p)break;i=n.to,c.push(n),t++}for(;t<o.length;){let s=o[t];if(s.from!=e||!(s.to>s.from||s.to==e)){i=Math.min(s.from,i);break}c.push(s),t++,i=Math.min(s.to,i)}i=Math.min(i,p);let r=!1;if(c.some((t=>t.from==e&&(t.to==i||i==p)))&&(r=e==i,!r&&i-e<10)){let t=e-(d+f.value.length);t>0&&(f.next(t),d=e);for(let t=e;;){if(t>=i){r=!0;break}if(!f.lineBreak&&d+f.value.length>t)break;t=d+f.value.length,d+=f.value.length,f.next()}}let l=P(c);if(r)h.add(e,e,s.NZ.widget({widget:new A(l),diagnostics:c.slice()}));else{let t=c.reduce(((t,e)=>e.markClass?t+" "+e.markClass:t),"");h.add(e,i,s.NZ.mark({class:"cm-lintRange cm-lintRange-"+l+t,diagnostics:c.slice(),inclusiveEnd:c.some((t=>t.to>i))}))}if(u=i,u==p)break;for(let t=0;t<c.length;t++)c[t].to<=u&&c.splice(t--,1)}let m=h.finish();return new l(m,e,a(m))}}function a(t,e=null,i=0){let s=null;return t.between(i,1e9,((t,i,{spec:n})=>{if(!(e&&n.diagnostics.indexOf(e)<0))if(s){if(n.diagnostics.indexOf(s.diagnostic)<0)return!1;s=new o(s.from,i,s.diagnostic)}else s=new o(t,i,e||n.diagnostics[0])})),s}function h(t,e){return t.field(d,!1)?e:e.concat(n.Pe.appendConfig.of(B))}const c=n.Pe.define(),u=n.Pe.define(),f=n.Pe.define(),d=n.sU.define({create:()=>new l(s.NZ.none,null,null),update(t,e){if(e.docChanged&&t.diagnostics.size){let i=t.diagnostics.map(e.changes),s=null,n=t.panel;if(t.selected){let n=e.changes.mapPos(t.selected.from,1);s=a(i,t.selected.diagnostic,n)||a(i,null,n)}!i.size&&n&&e.state.facet(y).autoPanel&&(n=null),t=new l(i,n,s)}for(let i of e.effects)if(i.is(c)){let s=e.state.facet(y).autoPanel?i.value.length?O.open:null:t.panel;t=l.init(i.value,s,e.state)}else i.is(u)?t=new l(t.diagnostics,i.value?O.open:null,t.selected):i.is(f)&&(t=new l(t.diagnostics,t.panel,i.value));return t},provide:t=>[s.S7.from(t,(t=>t.panel)),s.Lz.decorations.from(t,(t=>t.diagnostics))]}),p=s.NZ.mark({class:"cm-lintRange cm-lintRange-active"});function m(t,e,i){let s,{diagnostics:n}=t.state.field(d),r=-1,o=-1;n.between(e-(i<0?1:0),e+(i>0?1:0),((t,n,{spec:l})=>{if(e>=t&&e<=n&&(t==n||(e>t||i>0)&&(e<n||i<0)))return s=l.diagnostics,r=t,o=n,!1}));let l=t.state.facet(y).tooltipFilter;return s&&l&&(s=l(s,t.state)),s?{pos:r,end:o,above:!0,create:()=>({dom:g(t,s)})}:null}function g(t,e){return(0,r.A)("ul",{class:"cm-tooltip-lint"},e.map((e=>C(t,e,!1))))}const v=t=>{let e=t.state.field(d,!1);return!(!e||!e.panel||(t.dispatch({effects:u.of(!1)}),0))},w=[{key:"Mod-Shift-m",run:t=>{let e=t.state.field(d,!1);e&&e.panel||t.dispatch({effects:h(t.state,[u.of(!0)])});let i=(0,s.ld)(t,O.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:t=>{let e=t.state.field(d,!1);if(!e)return!1;let i=t.state.selection.main,n=a(e.diagnostics,null,i.to+1);return!(!n&&(n=a(e.diagnostics,null,0),!n||n.from==i.from&&n.to==i.to)||(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),(0,s.ab)(t,n.from,1,{tooltip:E,until:t=>t.docChanged||t.newSelection.main.head<n.from||t.newSelection.main.head>n.to}),0))}}],b=s.Z9.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(y);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:t}=this.view,{sources:e}=t.facet(y);e.length&&function(t,e,i){let s=[],n=-1;for(let r of t)r.then((i=>{s.push(i),clearTimeout(n),s.length==t.length?e(s):n=setTimeout((()=>e(s)),200)}),i)}(e.map((t=>Promise.resolve(t(this.view)))),(e=>{this.view.state.doc==t.doc&&this.view.dispatch(function(t,e){return{effects:h(t,[c.of(e)])}}(this.view.state,e.reduce(((t,e)=>t.concat(e)))))}),(t=>{(0,s.c_)(this.view.state,t)}))}}update(t){let e=t.state.facet(y);(t.docChanged||e!=t.startState.facet(y)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),y=n.sj.define({combine:t=>({sources:t.map((t=>t.source)).filter((t=>null!=t)),...(0,n.QR)(t.map((t=>t.config)),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:x,tooltipFilter:x,needsRefresh:(t,e)=>t?e?i=>t(i)||e(i):t:e,hideOn:(t,e)=>t?e?(i,s,n)=>t(i,s,n)||e(i,s,n):t:e,autoPanel:(t,e)=>t||e})})});function x(t,e){return t?e?(i,s)=>e(t(i,s),s):t:e}function k(t,e={}){return[y.of({source:t,config:e}),b,B]}function S(t){let e=[];if(t)t:for(let{name:i}of t){for(let t=0;t<i.length;t++){let s=i[t];if(/[a-zA-Z]/.test(s)&&!e.some((t=>t.toLowerCase()==s.toLowerCase()))){e.push(s);continue t}}e.push("")}return e}function C(t,e,i){var s;let n=i?S(e.actions):[];return(0,r.A)("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},(0,r.A)("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),null===(s=e.actions)||void 0===s?void 0:s.map(((i,s)=>{let o=!1,l=s=>{if(s.preventDefault(),o)return;o=!0;let n=a(t.state.field(d).diagnostics,e);n&&i.apply(t,n.from,n.to)},{name:h}=i,c=n[s]?h.indexOf(n[s]):-1,u=c<0?h:[h.slice(0,c),(0,r.A)("u",h.slice(c,c+1)),h.slice(c+1)],f=i.markClass?" "+i.markClass:"";return(0,r.A)("button",{type:"button",class:"cm-diagnosticAction"+f,onclick:l,onmousedown:l,"aria-label":` Action: ${h}${c<0?"":` (access key "${n[s]})"`}.`},u)})),e.source&&(0,r.A)("div",{class:"cm-diagnosticSource"},e.source))}class A extends s.xO{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return(0,r.A)("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class M{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=C(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class O{constructor(t){this.view=t,this.items=[],this.list=(0,r.A)("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e=>{if(!(e.ctrlKey||e.altKey||e.metaKey)){if(27==e.keyCode)v(this.view),this.view.focus();else if(38==e.keyCode||33==e.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==e.keyCode||34==e.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==e.keyCode)this.moveSelection(0);else if(35==e.keyCode)this.moveSelection(this.items.length-1);else if(13==e.keyCode)this.view.focus();else{if(!(e.keyCode>=65&&e.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:i}=this.items[this.selectedIndex],s=S(i.actions);for(let n=0;n<s.length;n++)if(s[n].toUpperCase().charCodeAt(0)==e.keyCode){let e=a(this.view.state.field(d).diagnostics,i);e&&i.actions[n].apply(t,e.from,e.to)}}}e.preventDefault()}},onclick:t=>{for(let e=0;e<this.items.length;e++)this.items[e].dom.contains(t.target)&&this.moveSelection(e)}}),this.dom=(0,r.A)("div",{class:"cm-panel-lint"},this.list,(0,r.A)("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>v(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(d).selected;if(!t)return-1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}update(){let{diagnostics:t,selected:e}=this.view.state.field(d),i=0,s=!1,n=null,r=new Set;for(t.between(0,this.view.state.doc.length,((t,o,{spec:l})=>{for(let t of l.diagnostics){if(r.has(t))continue;r.add(t);let o,l=-1;for(let e=i;e<this.items.length;e++)if(this.items[e].diagnostic==t){l=e;break}l<0?(o=new M(this.view,t),this.items.splice(i,0,o),s=!0):(o=this.items[l],l>i&&(this.items.splice(i,l-i),s=!0)),e&&o.diagnostic==e.diagnostic?o.dom.hasAttribute("aria-selected")||(o.dom.setAttribute("aria-selected","true"),n=o):o.dom.hasAttribute("aria-selected")&&o.dom.removeAttribute("aria-selected"),i++}}));i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();0==this.items.length&&(this.items.push(new M(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),n?(this.list.setAttribute("aria-activedescendant",n.id),this.view.requestMeasure({key:this,read:()=>({sel:n.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:t,panel:e})=>{let i=e.height/this.list.offsetHeight;t.top<e.top?this.list.scrollTop-=(e.top-t.top)/i:t.bottom>e.bottom&&(this.list.scrollTop+=(t.bottom-e.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let t=this.list.firstChild;function e(){let e=t;t=e.nextSibling,e.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;t!=i.dom;)e();t=i.dom.nextSibling}else this.list.insertBefore(i.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=a(this.view.state.field(d).diagnostics,this.items[t].diagnostic);e&&this.view.dispatch({selection:{anchor:e.from,head:e.to},scrollIntoView:!0,effects:f.of(e)})}static open(t){return new O(t)}}function T(t){return function(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const D=s.Lz.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:T("#f11")},".cm-lintRange-warning":{backgroundImage:T("orange")},".cm-lintRange-info":{backgroundImage:T("#999")},".cm-lintRange-hint":{backgroundImage:T("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function R(t){return"error"==t?4:"warning"==t?3:"info"==t?2:1}function P(t){let e="hint",i=1;for(let s of t){let t=R(s.severity);t>i&&(i=t,e=s.severity)}return e}s.wJ;const E=(0,s.Ux)(m,{hideOn:function(t,e){let i=e.pos,s=e.end||i,n=t.state.facet(y).hideOn(t,i,s);if(null!=n)return n;let r=t.startState.doc.lineAt(e.pos);return!(!t.effects.some((t=>t.is(c)))&&!t.changes.touchesRange(r.from,Math.max(r.to,s)))}}),B=[d,s.Lz.decorations.compute([d],(t=>{let{selected:e,panel:i}=t.field(d);return e&&i&&e.from!=e.to?s.NZ.set([p.range(e.from,e.to)]):s.NZ.none})),E,D]},1638:(t,e,i)=>{i.d(e,{YH:()=>ft,Gu:()=>P,VR:()=>E,Je:()=>St,xx:()=>tt,OF:()=>H,$t:()=>Mt,sj:()=>j,iR:()=>R,Nb:()=>J,om:()=>Bt,vB:()=>Nt,FB:()=>Tt,Pe:()=>mt,sU:()=>G,EY:()=>m,ZX:()=>gt,vS:()=>M,Fh:()=>T,QR:()=>Ot,y$:()=>Kt,zK:()=>A,kn:()=>Yt,MK:()=>O});let s=[],n=[];function r(t){if(t<768)return!1;for(let e=0,i=s.length;;){let r=e+i>>1;if(t<s[r])i=r;else{if(!(t>=n[r]))return!0;e=r+1}if(e==i)return!1}}function o(t){return t>=127462&&t<=127487}(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map((t=>t?parseInt(t,36):1));for(let e=0,i=0;e<t.length;e++)(e%2?n:s).push(i+=t[e])})();const l=8205;function a(t,e,i=!0,s=!0){return(i?h:c)(t,e,s)}function h(t,e,i){if(e==t.length)return e;e&&f(t.charCodeAt(e))&&d(t.charCodeAt(e-1))&&e--;let s=u(t,e);for(e+=p(s);e<t.length;){let n=u(t,e);if(s==l||n==l||i&&r(n))e+=p(n),s=n;else{if(!o(n))break;{let i=0,s=e-2;for(;s>=0&&o(u(t,s));)i++,s-=2;if(i%2==0)break;e+=2}}}return e}function c(t,e,i){for(;e>1;){let s=h(t,e-2,i);if(s<e)return s;e--}return 0}function u(t,e){let i=t.charCodeAt(e);if(!d(i)||e+1==t.length)return i;let s=t.charCodeAt(e+1);return f(s)?s-56320+(i-55296<<10)+65536:i}function f(t){return t>=56320&&t<57344}function d(t){return t>=55296&&t<56320}function p(t){return t<65536?1:2}class m{lineAt(t){if(t<0||t>this.length)throw new 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 new 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),v.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),v.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 y(this),n=new y(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 y(this,t)}iterRange(t,e=this.length){return new x(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 k(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new g(t):v.from(g.split(t,[])):m.empty}}class g extends m{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 S(s,o,i,r);s=o+1,i++}}decompose(t,e,i,s){let n=t<=0&&e>=this.length?this:new g(b(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&s){let t=i.pop(),e=w(n.text,t.text.slice(),0,n.length);if(e.length<=32)i.push(new g(e,t.length+n.length));else{let t=e.length>>1;i.push(new g(e.slice(0,t)),new g(e.slice(t)))}}else i.push(n)}replace(t,e,i){if(!(i instanceof g))return super.replace(t,e,i);[t,e]=C(this,t,e);let s=w(this.text,w(i.text,b(this.text,0,t)),e),n=this.length+i.length-(e-t);return s.length<=32?new g(s,n):v.from(g.split(s,[]),n)}sliceString(t,e=this.length,i="\n"){[t,e]=C(this,t,e);let s="";for(let n=0,r=0;n<=e&&r<this.text.length;r++){let o=this.text[r],l=n+o.length;n>t&&r&&(s+=i),t<l&&e>n&&(s+=o.slice(Math.max(0,t-n),e-n)),n=l+1}return s}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],s=-1;for(let n of t)i.push(n),s+=n.length+1,32==i.length&&(e.push(new g(i,s)),i=[],s=-1);return s>-1&&e.push(new g(i,s)),e}}class v extends m{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,s){for(let n=0;;n++){let r=this.children[n],o=s+r.length,l=i+r.lines-1;if((e?l:o)>=t)return r.lineInner(t,e,i,s);s=o+1,i=l+1}}decompose(t,e,i,s){for(let n=0,r=0;r<=e&&n<this.children.length;n++){let o=this.children[n],l=r+o.length;if(t<=l&&e>=r){let n=s&((r<=t?1:0)|(l>=e?2:0));r>=t&&l<=e&&!n?i.push(o):o.decompose(t-r,e-r,i,n)}r=l+1}}replace(t,e,i){if([t,e]=C(this,t,e),i.lines<this.lines)for(let s=0,n=0;s<this.children.length;s++){let r=this.children[s],o=n+r.length;if(t>=n&&e<=o){let l=r.replace(t-n,e-n,i),a=this.lines-r.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let n=this.children.slice();return n[s]=l,new v(n,this.length-(e-t)+i.length)}return super.replace(n,o,l)}n=o+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;n<this.children.length&&r<=e;n++){let o=this.children[n],l=r+o.length;r>t&&n&&(s+=i),t<l&&e>r&&(s+=o.sliceString(t-r,e-r,i)),r=l+1}return s}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof v))return 0;let i=0,[s,n,r,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;s+=e,n+=e){if(s==r||n==o)return i;let l=this.children[s],a=t.children[n];if(l!=a)return i+l.scanIdentical(a,e);i+=l.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 g(i,e)}let s=Math.max(32,i>>5),n=s<<1,r=s>>1,o=[],l=0,a=-1,h=[];function c(t){let e;if(t.lines>n&&t instanceof v)for(let e of t.children)c(e);else t.lines>r&&(l>r||!l)?(u(),o.push(t)):t instanceof g&&l&&(e=h[h.length-1])instanceof g&&t.lines+e.lines<=32?(l+=t.lines,a+=t.length+1,h[h.length-1]=new g(e.text.concat(t.text),e.length+1+t.length)):(l+t.lines>s&&u(),l+=t.lines,a+=t.length+1,h.push(t))}function u(){0!=l&&(o.push(1==h.length?h[0]:v.from(h,a)),a=-1,l=h.length=0)}for(let e of t)c(e);return u(),1==o.length?o[0]:new v(o,e)}}function w(t,e,i=0,s=1e9){for(let n=0,r=0,o=!0;r<t.length&&n<=s;r++){let l=t[r],a=n+l.length;a>=i&&(a>s&&(l=l.slice(0,s-n)),n<i&&(l=l.slice(i-n)),o?(e[e.length-1]+=l,o=!1):e.push(l)),n=a+1}return e}function b(t,e,i){return w(t,[""],e,i)}m.empty=new g([""],0);class y{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof g?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],n=this.offsets[i],r=n>>1,o=s instanceof g?s.text.length:s.children.length;if(r==(e>0?o: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&n)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(s instanceof g){let n=s.text[r+(e<0?-1:0)];if(this.offsets[i]+=e,n.length>Math.max(0,t))return this.value=0==t?n:e>0?n.slice(t):n.slice(0,n.length-t),this;t-=n.length}else{let n=s.children[r+(e<0?-1:0)];t>n.length?(t-=n.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(n),this.offsets.push(e>0?1:(n instanceof g?n.text.length:n.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class x{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new y(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 k{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&&(m.prototype[Symbol.iterator]=function(){return this.iter()},y.prototype[Symbol.iterator]=x.prototype[Symbol.iterator]=k.prototype[Symbol.iterator]=function(){return this});class S{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))]}function A(t,e,i=!0,s=!0){return a(t,e,i,s)}function M(t,e){let i=t.charCodeAt(e);if(!((s=i)>=55296&&s<56320&&e+1!=t.length))return i;var s;let n=t.charCodeAt(e+1);return function(t){return t>=56320&&t<57344}(n)?n-56320+(i-55296<<10)+65536:i}function O(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function T(t){return t<65536?1:2}const D=/\r\n?|\n/;var R=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(R||(R={}));class P{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,s=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?(t(i,s,n),s+=n):s+=r,i+=n}}iterChangedRanges(t,e=!1){N(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],s=this.sections[e++];s<0?t.push(i,s):t.push(s,i)}return new P(t)}composeDesc(t){return this.empty?t:t.empty?this:F(this,t)}mapDesc(t,e=!1){return t.empty?this:I(this,t,e)}mapPos(t,e=-1,i=R.Simple){let s=0,n=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],l=this.sections[r++],a=s+o;if(l<0){if(a>t)return n+(t-s);n+=o}else{if(i!=R.Simple&&a>=t&&(i==R.TrackDel&&s<t&&a>t||i==R.TrackBefore&&s<t||i==R.TrackAfter&&a>t))return null;if(a>t||a==t&&e<0&&!o)return t==s||e<0?n:n+l;n+=l}s=a}if(t>s)throw new 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<this.sections.length&&s<=e;){let n=s+this.sections[i++];if(this.sections[i++]>=0&&s<=e&&n>=t)return!(s<t&&n>e)||"cover";s=n}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],s=this.sections[e++];t+=(t?" ":"")+i+(s>=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 new RangeError("Invalid JSON representation of ChangeDesc");return new P(t)}static create(t){return new P(t)}}class E extends P{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return N(this,((e,i,s,n,r)=>t=t.replace(s,s+(i-e),r)),!1),t}mapDesc(t,e=!1){return I(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,n=0;s<e.length;s+=2){let r=e[s],o=e[s+1];if(o>=0){e[s]=o,e[s+1]=r;let l=s>>1;for(;i.length<l;)i.push(m.empty);i.push(r?t.slice(n,n+r):m.empty)}n+=r}return new E(e,i)}compose(t){return this.empty?t:t.empty?this:F(this,t,!0)}map(t,e=!1){return t.empty?this:I(this,t,e,!0)}iterChanges(t,e=!1){N(this,t,e)}get desc(){return P.create(this.sections)}filter(t){let e=[],i=[],s=[],n=new W(this);t:for(let r=0,o=0;;){let l=r==t.length?1e9:t[r++];for(;o<l||o==l&&0==n.len;){if(n.done)break t;let t=Math.min(n.len,l-o);B(s,t,-1);let r=-1==n.ins?-1:0==n.off?n.ins:0;B(e,t,r),r>0&&L(i,e,n.text),n.forward(t),o+=t}let a=t[r++];for(;o<a;){if(n.done)break t;let t=Math.min(n.len,a-o);B(e,t,-1),B(s,t,-1==n.ins?-1:0==n.off?n.ins:0),n.forward(t),o+=t}}return{changes:new E(e,i),filtered:P.create(s)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],s=this.sections[e+1];s<0?t.push(i):0==s?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let s=[],n=[],r=0,o=null;function l(t=!1){if(!t&&!s.length)return;r<e&&B(s,e-r,-1);let i=new E(s,n);o=o?o.compose(i.map(o)):i,s=[],n=[],r=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof E){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),o=o?o.compose(a.map(o)):a}else{let{from:t,to:o=t,insert:h}=a;if(t>o||t<0||o>e)throw new RangeError(`Invalid change range ${t} to ${o} (in doc of length ${e})`);let c=h?"string"==typeof h?m.of(h.split(i||D)):h:m.empty,u=c.length;if(t==o&&0==u)return;t<r&&l(),t>r&&B(s,t-r,-1),B(s,o-t,u),L(n,s,c),r=o}}(t),l(!o),o}static empty(t){return new E(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let n=t[s];if("number"==typeof n)e.push(n,-1);else{if(!Array.isArray(n)||"number"!=typeof n[0]||n.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==n.length)e.push(n[0],0);else{for(;i.length<s;)i.push(m.empty);i[s]=m.of(n.slice(1)),e.push(n[0],i[s].length)}}}return new E(e,i)}static createSet(t,e){return new E(t,e)}}function B(t,e,i,s=!1){if(0==e&&i<=0)return;let n=t.length-2;n>=0&&i<=0&&i==t[n+1]?t[n]+=e:n>=0&&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,i){if(0==i.length)return;let s=e.length-2>>1;if(s<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<s;)t.push(m.empty);t.push(i)}}function N(t,e,i){let s=t.inserted;for(let n=0,r=0,o=0;o<t.sections.length;){let l=t.sections[o++],a=t.sections[o++];if(a<0)n+=l,r+=l;else{let h=n,c=r,u=m.empty;for(;h+=l,c+=a,a&&s&&(u=u.append(s[o-2>>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(n,h,r,c,u),n=h,r=c}}}function I(t,e,i,s=!1){let n=[],r=s?[]:null,o=new W(t),l=new W(e);for(let t=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(-1==o.ins&&-1==l.ins){let t=Math.min(o.len,l.len);B(n,t,-1),o.forward(t),l.forward(t)}else if(l.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(l.len<o.len||l.len==o.len&&!i))){let e=l.len;for(B(n,l.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(B(n,0,o.ins),r&&L(r,n,o.text),t=o.i),o.forward(i),e-=i}l.next()}else{if(!(o.ins>=0)){if(o.done&&l.done)return r?E.createSet(n,r):P.create(n);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==l.ins){let t=Math.min(i,l.len);e+=t,i-=t,l.forward(t)}else{if(!(0==l.ins&&l.len<i))break;i-=l.len,l.next()}B(n,e,t<o.i?o.ins:0),r&&t<o.i&&L(r,n,o.text),t=o.i,o.forward(o.len-i)}}}}function F(t,e,i=!1){let s=[],n=i?[]:null,r=new W(t),o=new W(e);for(let t=!1;;){if(r.done&&o.done)return n?E.createSet(s,n):P.create(s);if(0==r.ins)B(s,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=s.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;B(s,e,i,t),n&&i&&L(n,s,o.text)}else-1==o.ins?(B(s,r.off?0:r.len,e,t),n&&L(n,s,r.textBit(e))):(B(s,r.off?0:r.len,o.off?0:o.ins,t),n&&!o.off&&L(n,s,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||s.length>i),r.forward2(e),o.forward(e)}}else B(s,0,o.ins,t),n&&L(n,s,o.text),o.next()}}class W{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?m.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?m.empty:e[i].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 z{constructor(t,e,i,s){this.from=t,this.to=e,this.flags=i,this.goalColumn=s}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 undirectional(){return(64&this.flags)>0}get bidiLevel(){let t=7&this.flags;return 7==t?null: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 z(i,s,this.flags,this.goalColumn)}extend(t,e=t,i=0){if(t<=this.anchor&&e>=this.anchor)return H.range(t,e,void 0,void 0,i);let s=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return H.range(this.anchor,s,void 0,void 0,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||this.goalColumn!=t.goalColumn||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 new RangeError("Invalid JSON representation for SelectionRange");return H.range(t.anchor,t.head)}static create(t,e,i,s){return new z(t,e,i,s)}}class H{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:H.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;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new H([this.main],0)}addRange(t,e=!0){return H.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,H.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((t=>t.toJSON())),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new H(t.ranges.map((t=>z.fromJSON(t))),t.main)}static single(t,e=t){return new H([H.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;s<t.length;s++){let n=t[s];if(n.empty?n.from<=i:n.from<i)return H.normalized(t.slice(),e);i=n.to}return new H(t,e)}static cursor(t,e=0,i,s){return z.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i)),s)}static range(t,e,i,s,n){let r=null==s?7:Math.min(6,s);return n||t==e||(n=e<t?1:-1),n&&(r|=n<0?8:16),e<t?z.create(e,t,32|r,i):z.create(t,e,r,i)}static undirectionalRange(t,e){return z.create(t,e,64,void 0)}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;i<t.length;i++){let s=t[i],n=t[i-1];if(s.empty?s.from<=n.to:s.from<n.to){let r=n.from,o=Math.max(s.to,n.to);i<=e&&e--,t.splice(--i,2,s.anchor>s.head?H.range(o,r):H.range(r,o))}}return new H(t,e)}}function V(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let _=0;class j{constructor(t,e,i,s,n){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=s,this.id=_++,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:q),!!t.static,t.enables)}of(t){return new $([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new $(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new $(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function q(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class ${constructor(t,e,i,s){this.dependencies=t,this.facet=e,this.type=i,this.value=s,this.id=_++}dynamicSlot(t){var e;let i=this.value,s=this.facet.compareInput,n=this.id,r=t[n]>>1,o=2==this.type,l=!1,a=!1,h=[];for(let i of this.dependencies)"doc"==i?l=!0:"selection"==i?a=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||h.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(l&&e.docChanged||a&&(e.docChanged||e.selection)||Y(t,h)){let e=i(t);if(o?!K(e,t.values[r],s):!s(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let l,a=e.config.address[n];if(null!=a){let n=nt(e,a);if(this.dependencies.every((i=>i instanceof j?e.facet(i)===t.facet(i):!(i instanceof G)||e.field(i,!1)==t.field(i,!1)))||(o?K(l=i(t),n,s):s(l=i(t),n)))return t.values[r]=n,0}else l=i(t);return t.values[r]=l,1}}}get extension(){return this}}function K(t,e,i){if(t.length!=e.length)return!1;for(let s=0;s<t.length;s++)if(!i(t[s],e[s]))return!1;return!0}function Y(t,e){let i=!1;for(let s of e)1&st(t,s)&&(i=!0);return i}function U(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 l(t){let i=[];for(let e=0;e<s.length;e++){let r=nt(t,s[e]);if(2==n[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of s)st(t,e);return t.values[o]=l(t),1},update(t,i){if(!Y(t,r))return 0;let s=l(t);return e.compare(s,t.values[o])?0:(t.values[o]=s,1)},reconfigure(t,n){let r=Y(t,s),a=n.config.facets[e.id],h=n.facet(e);if(a&&!r&&q(i,a))return t.values[o]=h,0;let c=l(t);return e.compare(c,h)?(t.values[o]=h,0):(t.values[o]=c,1)}}}const Q=j.define({static:!0});class G{constructor(t,e,i,s,n){this.id=t,this.createF=e,this.updateF=i,this.compareF=s,this.spec=n,this.provides=void 0}static define(t){let e=new G(_++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(Q).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)=>{let s,n=t.facet(Q),r=i.facet(Q);return(s=n.find((t=>t.field==this)))&&s!=r.find((t=>t.field==this))?(t.values[e]=s.create(t),1):null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}}init(t){return[this,Q.of({field:this,create:t})]}get extension(){return this}}function X(t){return e=>new Z(e,t)}const J={highest:X(0),high:X(1),default:X(2),low:X(3),lowest:X(4)};class Z{constructor(t,e){this.inner=t,this.prec=e}get extension(){return this}}class tt{of(t){return new et(this,t)}reconfigure(t){return tt.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class et{constructor(t,e){this.compartment=t,this.inner=e}get extension(){return this}}class it{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<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let s=[],n=Object.create(null),r=new Map;for(let i of function(t,e,i){let s=[[],[],[],[],[]],n=new Map;return function t(r,o){let l=n.get(r);if(null!=l){if(l<=o)return;let t=s[l].indexOf(r);t>-1&&s[l].splice(t,1),r instanceof et&&i.delete(r.compartment)}if(n.set(r,o),Array.isArray(r))for(let e of r)t(e,o);else if(r instanceof et){if(i.has(r.compartment))throw new RangeError("Duplicate use of compartment in extensions");let s=e.get(r.compartment)||r.inner;i.set(r.compartment,s),t(s,o)}else if(r instanceof Z)t(r.inner,r.prec);else if(r instanceof G)s[o].push(r),r.provides&&t(r.provides,o);else if(r instanceof $)s[o].push(r),r.facet.extensions&&t(r.facet.extensions,2);else{let e=r.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${r}).`);if(e==r)throw new Error(`Unrecognized extension value in extension set (${r}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);t(e,o)}}(t,2),s.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof G?s.push(i):(n[i.facet.id]||(n[i.facet.id]=[])).push(i);let o=Object.create(null),l=[],a=[];for(let t of s)o[t.id]=a.length<<1,a.push((e=>t.slot(e)));let h=null==i?void 0:i.config.facets;for(let t in n){let e=n[t],s=e[0].facet,r=h&&h[t]||[];if(e.every((t=>0==t.type)))if(o[s.id]=l.length<<1|1,q(r,e))l.push(i.facet(s));else{let t=s.combine(e.map((t=>t.value)));l.push(i&&s.compare(t,i.facet(s))?i.facet(s):t)}else{for(let t of e)0==t.type?(o[t.id]=l.length<<1|1,l.push(t.value)):(o[t.id]=a.length<<1,a.push((e=>t.dynamicSlot(e))));o[s.id]=a.length<<1,a.push((t=>U(t,s,e)))}}let c=a.map((t=>t(o)));return new it(t,r,c,o,l,n)}}function st(t,e){if(1&e)return 2;let i=e>>1,s=t.status[i];if(4==s)throw new 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 nt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const rt=j.define(),ot=j.define({combine:t=>t.some((t=>t)),static:!0}),lt=j.define({combine:t=>t.length?t[0]:void 0,static:!0}),at=j.define(),ht=j.define(),ct=j.define(),ut=j.define({combine:t=>!!t.length&&t[0]});class ft{constructor(t,e){this.type=t,this.value=e}static define(){return new dt}}class dt{of(t){return new ft(this,t)}}class pt{constructor(t){this.map=t}of(t){return new mt(this,t)}}class mt{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 mt(this.type,e)}is(t){return this.type==t}static define(t={}){return new pt(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}}mt.reconfigure=mt.define(),mt.appendConfig=mt.define();class gt{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&&V(i,e.newLength),n.some((t=>t.type==gt.time))||(this.annotations=n.concat(gt.time.of(Date.now())))}static create(t,e,i,s,n,r){return new gt(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(gt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function vt(t,e){let i=[];for(let s=0,n=0;;){let r,o;if(s<t.length&&(n==e.length||e[n]>=t[s]))r=t[s++],o=t[s++];else{if(!(n<e.length))return i;r=e[n++],o=e[n++]}!i.length||i[i.length-1]<r?i.push(r,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function wt(t,e,i){var s;let n,r,o;return i?(n=e.changes,r=E.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:mt.mapEffects(t.effects,n).concat(mt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function bt(t,e,i){let s=e.selection,n=kt(e.annotations);return e.userEvent&&(n=n.concat(gt.userEvent.of(e.userEvent))),{changes:e.changes instanceof E?e.changes:E.of(e.changes||[],i,t.facet(lt)),selection:s&&(s instanceof H?s:H.single(s.anchor,s.head)),effects:kt(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function yt(t,e,i){let s=bt(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let n=1;n<e.length;n++){!1===e[n].filter&&(i=!1);let r=!!e[n].sequential;s=wt(s,bt(t,e[n],r?s.changes.newLength:t.doc.length),r)}let n=gt.create(t,s.changes,s.selection,s.effects,s.annotations,s.scrollIntoView);return function(t){let e=t.startState,i=e.facet(ct),s=t;for(let n=i.length-1;n>=0;n--){let r=i[n](t);r&&Object.keys(r).length&&(s=wt(s,bt(e,r,t.changes.newLength),!0))}return s==t?t:gt.create(e,t.changes,t.selection,s.effects,s.annotations,s.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let s of e.facet(at)){let e=s(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:vt(i,e))}if(!0!==i){let s,n;if(!1===i)n=t.changes.invertedDesc,s=E.empty(e.doc.length);else{let e=t.changes.filter(i);s=e.changes,n=e.filtered.mapDesc(e.changes).invertedDesc}t=gt.create(e,s,t.selection&&t.selection.map(n),mt.mapEffects(t.effects,n),t.annotations,t.scrollIntoView)}let s=e.facet(ht);for(let i=s.length-1;i>=0;i--){let n=s[i](t);t=n instanceof gt?n:Array.isArray(n)&&1==n.length&&n[0]instanceof gt?n[0]:yt(e,kt(n),!1)}return t}(n):n)}gt.time=ft.define(),gt.userEvent=ft.define(),gt.addToHistory=ft.define(),gt.remote=ft.define();const xt=[];function kt(t){return null==t?xt:Array.isArray(t)?t:[t]}var St=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(St||(St={}));const Ct=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let At;try{At=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}class Mt{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<this.config.dynamicSlots.length;t++)st(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return st(this,i),nt(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return yt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:s,compartments:n}=i;for(let e of t.effects)e.is(tt.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(mt.reconfigure)?(i=null,s=e.value):e.is(mt.appendConfig)&&(i=null,s=kt(s).concat(e.value));i?e=t.startState.values.slice():(i=it.resolve(s,n,this),e=new Mt(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values);let r=t.startState.facet(ot)?t.newSelection:t.newSelection.asSingle();new Mt(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:H.cursor(e.from+t.length,-1)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),s=this.changes(i.changes),n=[i.range],r=kt(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),l=this.changes(o.changes),a=l.map(s);for(let t=0;t<i;t++)n[t]=n[t].map(a);let h=s.mapDesc(l,!0);n.push(o.range.map(h)),s=s.compose(a),r=mt.mapEffects(r,a).concat(mt.mapEffects(kt(o.effects),h))}return{changes:s,selection:H.create(n,e.mainIndex),effects:r}}changes(t=[]){return t instanceof E?t:E.of(t,this.doc.length,this.facet(Mt.lineSeparator))}toText(t){return m.of(t.split(this.facet(Mt.lineSeparator)||D))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(st(this,e),nt(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let s=t[i];s instanceof G&&null!=this.config.address[s.id]&&(e[i]=s.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let n=i[e],r=t[e];s.push(n.init((t=>n.spec.fromJSON(r,t))))}return Mt.create({doc:t.doc,selection:H.fromJSON(t.selection),extensions:e.extensions?s.concat([e.extensions]):s})}static create(t={}){let e=it.resolve(t.extensions||[],new Map),i=t.doc instanceof m?t.doc:m.of((t.doc||"").split(e.staticFacet(Mt.lineSeparator)||D)),s=t.selection?t.selection instanceof H?t.selection:H.single(t.selection.anchor,t.selection.head):H.single(0);return V(s,i.length),e.staticFacet(ot)||(s=s.asSingle()),new Mt(e,i,s,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(Mt.tabSize)}get lineBreak(){return this.facet(Mt.lineSeparator)||"\n"}get readOnly(){return this.facet(ut)}phrase(t,...e){for(let e of this.facet(Mt.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(rt))for(let r of n(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&s.push(r[t]);return s}charCategorizer(t){let e=this.languageDataAt("wordChars",t);return i=e.length?e[0]:"",t=>{if(!/\S/.test(t))return St.Space;if(function(t){if(At)return At.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||Ct.test(i)))return!0}return!1}(t))return St.Word;for(let e=0;e<i.length;e++)if(t.indexOf(i[e])>-1)return St.Word;return St.Other};var i}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=A(e,r,!1);if(n(e.slice(t,r))!=St.Word)break;r=t}for(;o<s;){let t=A(e,o);if(n(e.slice(o,t))!=St.Word)break;o=t}return r==o?null:H.range(r+i,o+i)}}function Ot(t,e,i={}){let s={};for(let e of t)for(let t of Object.keys(e)){let n=e[t],r=s[t];if(void 0===r)s[t]=n;else if(r===n||void 0===n);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);s[t]=i[t](r,n)}}for(let t in e)void 0===s[t]&&(s[t]=e[t]);return s}Mt.allowMultipleSelections=ot,Mt.tabSize=j.define({combine:t=>t.length?t[0]:4}),Mt.lineSeparator=lt,Mt.readOnly=ut,Mt.phrases=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]))}}),Mt.languageData=rt,Mt.changeFilter=at,Mt.transactionFilter=ht,Mt.transactionExtender=ct,tt.reconfigure=mt.define();class Tt{eq(t){return this==t}range(t,e=t){return Rt.create(t,e,this)}}function Dt(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}Tt.prototype.startSide=Tt.prototype.endSide=0,Tt.prototype.point=!1,Tt.prototype.mapMode=R.TrackDel;class Rt{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Rt(t,e,i)}}function Pt(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Et{constructor(t,e,i,s){this.from=t,this.to=e,this.value=i,this.maxPoint=s}get length(){return Lt(this.to)}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,l=n[s]-t||(i?this.value[s].endSide:this.value[s].startSide)-e;if(s==r)return l>=0?r:o;l>=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<r;n++)if(!1===s(this.from[n]+t,this.to[n]+t,this.value[n]))return!1}map(t,e,i,s,n){let r=[],o=[],l=[],a=-1,h=-1;t:for(let c=0;c<this.value.length;c++){let u,f,d=this.value[c],p=this.from[c]+t,m=this.to[c]+t;if(p==m){let t=e.mapPos(p,d.startSide,d.mapMode);if(null==t)continue;if(u=f=t,d.startSide!=d.endSide&&(f=e.mapPos(p,d.endSide),f<u))continue}else if(u=e.mapPos(p,d.startSide),f=e.mapPos(m,d.endSide),u>f||u==f&&d.startSide>0&&d.endSide<=0)continue;if(!((f-u||d.endSide-d.startSide)<0))if(a<0&&(a=u),d.point&&(h=Math.max(h,f-u)),(u-i||d.startSide-s)>=0)r.push(d),o.push(u-a),l.push(f-a),i=f,s=d.endSide;else{if(u==f)for(let t=r.length;t>0;t--){if((u-(l[t-1]+a)||d.startSide-r[t-1].endSide)>=0){r.splice(t,0,d),o.splice(t,0,u-a),l.splice(t,0,f-a);continue t}if((u-(o[t-1]+a)||d.endSide-r[t-1].startSide)>0)break}n(u,f,d)}}return{mapped:r.length?new Et(o,l,r,h):null,pos:a}}}class Bt{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 Bt(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(Pt)),this.isEmpty)return e.length?Bt.of(e):this;let o=new Ft(this,null,-1).goto(0),l=0,a=[],h=new Nt;for(;o.value||l<e.length;)if(l<e.length&&(o.from-e[l].from||o.startSide-e[l].value.startSide)>=0){let t=e[l++];h.addInner(t.from,t.to,t.value,!1)||a.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(l==e.length||this.chunkEnd(o.chunkIndex)<e[l].from)&&(!r||s>this.chunkEnd(o.chunkIndex)||n<this.chunkPos[o.chunkIndex])&&h.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||s>o.to||n<o.from||r(o.from,o.to,o.value))&&(h.addInner(o.from,o.to,o.value,!1)||a.push(Rt.create(o.from,o.to,o.value))),o.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?Bt.empty:this.nextLayer.update({add:a,filter:r,filterFrom:s,filterTo:n}))}map(t){if(t.empty||this.isEmpty)return this;let e,i=[],s=[],n=-1,r=(t,i,s)=>{e||(e=new Nt),e.addRange(t,i,s,!1)};for(let e=0;e<this.chunk.length;e++){let o=this.chunkPos[e],l=this.chunk[e],a=t.touchesRange(o,o+l.length);if(!1===a)n=Math.max(n,l.maxPoint),i.push(l),s.push(t.mapPos(o));else if(!0===a){let[e,a]=i.length?[Lt(s)+Lt(i).length,Lt(Lt(i).value).endSide]:[-1,-1],{mapped:h,pos:c}=l.map(o,t,e,a,r);h&&(n=Math.max(n,h.maxPoint),i.push(h),s.push(c))}}let o=this.nextLayer.map(t);return e&&(o=e.finishInner(o)),0==i.length?o:new Bt(s,i,o||Bt.empty,n)}between(t,e,i){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let n=this.chunkPos[s],r=this.chunk[s];if(e>=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 Wt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Wt.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)),l=It(r,o,i),a=new Ht(r,l,n),h=new Ht(o,l,n);i.iterGaps(((t,e,i)=>Vt(a,t,h,e,i,s))),i.empty&&0==i.length&&Vt(a,0,h,0,0,s)}static eq(t,e,i=0,s){null==s&&(s=999999999);let n=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(n.length!=r.length)return!1;if(!n.length)return!0;let o=It(n,r),l=new Ht(n,o,0).goto(i),a=new Ht(r,o,0).goto(i);for(;;){if(l.to!=a.to||!_t(l.active,a.active)||l.point&&(!a.point||!Dt(l.point,a.point)))return!1;if(l.to>s)return!0;l.next(),a.next()}}static spans(t,e,i,s,n=-1){let r=new Ht(t,null,n).goto(e),o=e,l=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),n=r.pointFrom<e?i.length+1:r.point.startSide<0?i.length:Math.min(i.length,l);s.point(o,t,r.point,i,n,r.pointRank),l=Math.min(r.openEnd(t),i.length)}else t>o&&(s.span(o,t,r.active,l),l=r.openEnd(t));if(r.to>i)return l+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Nt;for(let s of t instanceof Rt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let s=t[i];if(Pt(e,s)>0)return t.slice().sort(Pt);e=s}return t}(t):t)i.add(s.from,s.to,s.value);return i.finish()}static join(t){if(!t.length)return Bt.empty;let e=Lt(t);for(let i=t.length-2;i>=0;i--)for(let s=t[i];s!=Bt.empty;s=s.nextLayer)e=new Bt(s.chunkPos,s.chunk,e,Math.max(s.maxPoint,e.maxPoint));return e}}function Lt(t){return t[t.length-1]}Bt.empty=new Bt([],[],null,-1),Bt.empty.nextLayer=Bt.empty;class Nt{finishChunk(t){this.chunks.push(new Et(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.addRange(t,e,i,!0)}addRange(t,e,i,s){this.addInner(t,e,i,s)||(this.nextLayer||(this.nextLayer=new Nt)).addRange(t,e,i,s)}addInner(t,e,i,s){let n=t-this.lastTo||i.startSide-this.last.endSide;if(s&&n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<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((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)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(Bt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Bt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function It(t,e,i){let s=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&s.set(e.chunk[t],e.chunkPos[t]);let n=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=s.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||n.add(t.chunk[e])}return n}class Ft{constructor(t,e,i,s=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=s}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<s)&&this.setRangeIndex(s)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Wt{constructor(t){this.heap=t}static from(t,e=null,i=-1){let s=[];for(let n=0;n<t.length;n++)for(let r=t[n];!r.isEmpty;r=r.nextLayer)r.maxPoint>=i&&s.push(new Ft(r,e,i,n));return 1==s.length?s[0]:new Wt(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--)zt(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--)zt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&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(),zt(this.heap,0)}}}function zt(t,e){for(let i=t[e];;){let s=1+(e<<1);if(s>=t.length)break;let n=t[s];if(s+1<t.length&&n.compare(t[s+1])>=0&&(n=t[s+1],s++),i.compare(n)<0)break;t[s]=i,t[e]=n,e=s}}class Ht{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=Wt.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){jt(this.active,t),jt(this.activeTo,t),jt(this.activeRank,t),this.minActive=$t(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:s,rank:n}=this.cursor;for(;e<this.activeRank.length&&(n-this.activeRank[e]||s-this.activeTo[e])>0;)e++;qt(this.active,e,i),qt(this.activeTo,e,s),qt(this.activeRank,e,n),t&&qt(t,e,this.cursor.from),this.minActive=$t(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&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>t){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&jt(i,s)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}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<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Vt(t,e,i,s,n,r){t.goto(e),i.goto(s);let o=s+n,l=s,a=s-e,h=!!r.boundChange;for(let e=!1;;){let s=t.to+a-i.to,n=s||t.endSide-i.endSide,c=n<0?t.to+a:i.to,u=Math.min(c,o);if(t.point||i.point?(t.point&&i.point&&Dt(t.point,i.point)&&_t(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(l,u,t.point,i.point),e=!1):(e&&(r.boundChange(l),e=!1),u>l&&!_t(t.active,i.active)&&r.compareRange(l,u,t.active,i.active),h&&u<o&&(s||t.openEnd(c)!=i.openEnd(c))&&(e=!0)),c>o)break;l=c,n<=0&&t.next(),n>=0&&i.next()}}function _t(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!Dt(t[i],e[i]))return!1;return!0}function jt(t,e){for(let i=e,s=t.length-1;i<s;i++)t[i]=t[i+1];t.pop()}function qt(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function $t(t,e){let i=-1,s=1e9;for(let n=0;n<e.length;n++)(e[n]-s||t[n].endSide-t[i].endSide)<0&&(i=n,s=e[n]);return i}function Kt(t,e,i=t.length){let s=0;for(let n=0;n<i&&n<t.length;)9==t.charCodeAt(n)?(s+=e-s%e,n++):(s++,n=A(t,n));return s}function Yt(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=A(t,s)}return!0===s?-1:t.length}},2999:(t,e,i)=>{i.d(e,{Pq:()=>E,cp:()=>R});var s=i(365);class n{constructor(t,e,i,s,n,r,o,l,a,h=0,c){this.p=t,this.stack=e,this.state=i,this.reducePos=s,this.pos=n,this.score=r,this.buffer=o,this.bufferBase=l,this.curContext=a,this.lookAhead=h,this.parent=c}toString(){return`[${this.stack.filter(((t,e)=>e%3==0)).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let s=t.parser.context;return new n(t,[],e,i,i,0,[],0,s?new r(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<this.pos-25&&this.setLookAhead(this.pos),o=n.dynamicPrecedence(s);if(o&&(this.score+=o),0==i)return s<n.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(n.getGoto(this.state,s,!0),this.reducePos),s<n.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,r?8:4,!0),void this.reduceContext(s,this.reducePos);let l=this.stack.length-3*(i-1)-(262144&t?6:0),a=l?this.stack[l-2]:this.p.ranges[0].from;s<n.minRepeatTerm&&a==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let h=this.reducePos-a;h>=2e3&&!(null===(e=this.p.parser.nodeSet.types[s])||void 0===e?void 0:e.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSize<h&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=h));let c=l?this.stack[l-1]:0,u=this.bufferBase+this.buffer.length-c;if(s<n.minRepeatTerm||131072&t){let t=n.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,a,t,u+4,!0)}if(262144&t)this.state=this.stack[l];else{let t=this.stack[l-3];this.state=n.getGoto(t,s,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(s,a)}storeNode(t,e,i,s=4,n=!1){if(0==t&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let t=this.buffer.length;if(t>0&&0==this.buffer[t-4]&&this.buffer[t-1]>-1){if(e==i)return;if(this.buffer[t-2]>=e)return void(this.buffer[t-2]=i)}}if(n&&this.pos!=i){let n=this.buffer.length;if(n>0&&(0!=this.buffer[n-4]||this.buffer[n-1]<0)){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)this.pos=s,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,s,4);else{let n=t,{parser:r}=this.p;this.pos=s;let o=r.stateFlag(n,1);!o&&(s>i||e<=r.maxNode)&&(this.reducePos=s),this.pushState(n,o?i:Math.min(i,this.reducePos)),this.shiftContext(e,i),e<=r.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,i){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=t)&&(this.p.reused.push(t),s++);let n=this.reducePos=this.pos=i+t.length;this.pushState(e,i),this.buffer.push(s,i,n,-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-4]&&(e-=4);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 n(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 o(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))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,n=0;n<e.length;n+=2)(s=e[n+1])!=this.state&&this.p.parser.hasAction(s,t)&&i.push(e[n],s);if(this.stack.length<120)for(let t=0;i.length<8&&t<e.length;t+=2){let s=e[t+1];i.some(((t,e)=>1&e&&t==s))||i.push(e[t],s)}e=i}let i=[];for(let t=0;t<e.length&&i.length<4;t+=2){let s=e[t+1];if(s==this.state)continue;let n=this.split();n.pushState(s,this.pos),n.storeNode(0,n.pos,n.pos,4,!0),n.shiftContext(e[t],this.pos),n.reducePos=this.pos,n.score-=200,i.push(n)}return i}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if(!(65536&e))return!1;if(!t.validAction(this.state,e)){let i=e>>19,s=65535&e,n=this.stack.length-3*i;if(n<0||t.getGoto(this.stack[n],s,!1)<0){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;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||-3!=this.buffer[t])&&this.storeNode(this.curContext.hash,this.reducePos,this.reducePos,-3,!0)}emitLookAhead(){let t=this.buffer.length-1;(t<0||-4!=this.buffer[t])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new r(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return!(t<=this.lookAhead||(this.emitLookAhead(),this.lookAhead=t,0))}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class r{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class o{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=65535&t,i=t>>19;0==i?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(i-1);let s=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=s}}class l{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 l(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 l(this.stack,this.pos,this.index)}}function a(t,e=Uint16Array){if("string"!=typeof t)return t;let i=null;for(let s=0,n=0;s<t.length;){let r=0;for(;;){let e=t.charCodeAt(s++),i=!1;if(126==e){r=65535;break}e>=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 h{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const c=new h;class u{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=c,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(;n<i.from;){if(!s)return null;let t=this.ranges[--s];n-=i.from-t.to,i=t}for(;e<0?n>i.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&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e,i,s=this.chunkOff+t;if(s>=0&&s<this.chunk.length)e=this.pos+t,i=this.chunk.charCodeAt(s);else{let s=this.resolveOffset(t,1);if(null==s)return-1;if(e=s,e>=this.chunk2Pos&&e<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(e-this.chunk2Pos);else{let t=this.rangeIndex,s=this.range;for(;s.to<=e;)s=this.ranges[++t];this.chunk2=this.input.chunk(this.chunk2Pos=e),e+this.chunk2.length>s.to&&(this.chunk2=this.chunk2.slice(0,s.to-e)),i=this.chunk2.charCodeAt(0)}}return e>=this.token.lookAhead&&(this.token.lookAhead=e+1),i}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(null==i||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=i}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.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=c,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(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 f{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;!function(t,e,i,s,n,r){let o=0,l=1<<s,{dialect:a}=i.p.parser;t:for(;l&t[o];){let i=t[o+1];for(let s=o+3;s<i;s+=2)if((t[s+1]&l)>0){let i=t[s];if(a.allows(i)&&(-1==e.token.value||e.token.value==i||p(i,e.token.value,n,r))){e.acceptToken(i);break}}let s=e.next,h=0,c=t[o+2];if(!(e.next<0&&c>h&&65535==t[i+3*c-3])){for(;h<c;){let n=h+c>>1,r=i+n+(n<<1),l=t[r],a=t[r+1]||65536;if(s<l)c=n;else{if(!(s>=a)){o=t[r+2],e.advance();continue t}h=n+1}}break}o=t[i+3*c-1]}}(this.data,t,e,this.id,i.data,i.tokenPrecTable)}}function d(t,e,i){for(let s,n=e;65535!=(s=t[n]);n++)if(s==i)return n-e;return-1}function p(t,e,i,s){let n=d(i,s,e);return n<0||d(i,s,t)<n}f.prototype.contextual=f.prototype.fallback=f.prototype.extend=!1,f.prototype.fallback=f.prototype.extend=!1;const m="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let g=null;function v(t,e,i){let n=t.cursor(s.Qj.IncludeAnonymous);for(n.moveTo(e);;)if(!(i<0?n.childBefore(e):n.childAfter(e)))for(;;){if((i<0?n.to<e:n.from>e)&&!n.type.isError)return i<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(t.length,Math.max(n.from+1,e+25));if(i<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return i<0?0:t.length}}class w{constructor(t,e){this.fragments=t,this.minRepeat=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.lastRepeat=null,this.lastRepeatPos=-1,this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?v(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?v(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(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let i=this.trees[e],n=this.index[e];if(n==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[n],o=this.start[e]+i.positions[n];if(o>t)return this.nextStart=o,null;if(r instanceof s.PH){let i=o>this.lastRepeatPos&&r.type.id>=this.minRepeat;if(o==t||i){let e,n=o+r.length;if(o>=this.safeFrom&&n<=this.safeTo&&(!(e=r.prop(s.uY.lookAhead))||n+e<this.fragment.to)){if(i&&(this.lastRepeat=r,this.lastRepeatPos=o),o==t)return r}else if(o==t)return null}this.index[e]++,o+r.length>=Math.max(this.safeFrom,t)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+r.length}}}class b{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map((t=>new h))}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,l=0;for(let s=0;s<n.length;s++){if(!(1<<s&r))continue;let a=n[s],h=this.tokens[s];if((!i||a.fallback)&&((a.contextual||h.start!=t.pos||h.mask!=r||h.context!=o)&&(this.updateCachedToken(h,a,t),h.mask=r,h.context=o),h.lookAhead>h.end+25&&(l=Math.max(h.lookAhead,l)),0!=h.value)){let s=e;if(h.extended>-1&&(e=this.addActions(t,h.extended,h.end,e)),e=this.addActions(t,h.value,h.end,e),!a.extend&&(i=h,e>s))break}}for(;this.actions.length>e;)this.actions.pop();return l&&t.setLookAhead(l),i||t.pos!=this.stream.end||(i=new h,i.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 h,{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<e.specialized.length;s++)if(e.specialized[s]==t.value){let n=e.specializers[s](this.stream.read(t.start,t.end),i);if(n>=0&&i.p.parser.dialect.allows(n>>1)){1&n?t.extended=n>>1:t.value=n>>1;break}}}else t.value=0,t.end=this.stream.clipPos(s+1)}putAction(t,e,i,s){for(let e=0;e<s;e+=3)if(this.actions[e]==t)return s;return this.actions[s++]=t,this.actions[s++]=e,this.actions[s++]=i,s}addActions(t,e,i,s){let{state:n}=t,{parser:r}=t.p,{data:o}=r;for(let t=0;t<2;t++)for(let l=r.stateSlot(n,t?2:1);;l+=3){if(65535==o[l]){if(1!=o[l+1]){0==s&&2==o[l+1]&&(s=this.putAction(C(o,l+2),e,i,s));break}l=C(o,l+2)}o[l]==e&&(s=this.putAction(C(o,l+1),e,i,s))}return s}}class y{constructor(t,e,i,s){this.parser=t,this.input=e,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new u(e,s),this.tokens=new b(t,this.stream),this.topTerm=t.top[1];let{from:r}=s[0];this.stacks=[n.start(this,t.top[0],r)],this.fragments=i.length&&this.stream.end-r>4*t.bufferLength?new w(i,t.minRepeatTerm):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;r<i.length;r++){let o=i[r];for(;;){if(this.tokens.mainToken=null,o.pos>s)n.push(o);else{if(this.advanceStack(o,n,i))continue;{t||(t=[],e=[]),t.push(o);let i=this.tokens.getMainToken(o);e.push(i.value,i.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.score<i.score)&&(e=i)}return e}(t);if(e)return m&&console.log("Finish with "+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw m&&t&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+s);this.recovering||(this.recovering=5)}if(this.recovering&&t){let i=null!=this.stoppedAt&&t[0].pos>this.stoppedAt?t[0]:this.runRecovery(t,e,n);if(i)return m&&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){t:for(let t=0;t<n.length-1;t++){let e=n[t];for(let i=t+1;i<n.length;i++){let s=n[i];if(e.sameState(s)||e.buffer.length>500&&s.buffer.length>500){if(!((e.score-s.score||e.buffer.length-s.buffer.length)>0)){n.splice(t--,1);continue t}n.splice(i--,1)}}}n.length>12&&(n.sort(((t,e)=>e.score-t.score)),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let t=1;t<n.length;t++)n[t].pos<this.minStackPos&&(this.minStackPos=n[t].pos);return null}stopAt(t){if(null!=this.stoppedAt&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}tryReuse(t,e,i,n){if(!i)return null;let r=t.curContext&&t.curContext.tracker.strict,o=r?t.curContext.hash:0;for(;i;){let l=this.parser.nodeSet.types[i.type.id]!=i.type?-1:this.parser.getGoto(t.state,i.type.id);if(l>-1&&i.length&&(!r||(i.prop(s.uY.contextHash)||0)==o))return t.useNode(i,l,e),i;if(0==i.children.length||i.positions[0]>0)break;let a=i.children[0];if(!(a instanceof s.PH&&(!n||a.type.id>=this.parser.minRepeatTerm)))break;i=a}return null}advanceStack(t,e,i){let s=t.pos,{parser:n}=this,r=m?this.stackID(t)+" -> ":"";if(null!=this.stoppedAt&&s>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let e=t.reducePos<s&&t.buffer.length&&t.buffer[t.buffer.length-2]<=t.reducePos&&this.fragments.lastRepeatPos==t.reducePos&&this.tryReuse(t,t.reducePos,this.fragments.lastRepeat,!0)||this.tryReuse(t,s,this.fragments.nodeAt(s),!1);if(e)return m&&console.log(r+this.stackID(t)+` (via reuse of ${n.getName(e.type.id)})`),!0}let o=n.stateSlot(t.state,4);if(o>0)return t.reduce(o),m&&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 l=this.tokens.getActions(t);for(let o=0;o<l.length;){let a=l[o++],h=l[o++],c=l[o++],u=o==l.length||!i,f=u?t:t.split(),d=this.tokens.mainToken;if(f.apply(a,h,d?d.start:f.pos,c),m&&console.log(r+this.stackID(f)+` (via ${65536&a?`reduce of ${n.getName(65535&a)}`:"shift"} for ${n.getName(h)} @ ${s}${f==t?"":", split"})`),u)return!0;f.pos>s?e.push(f):i.push(f)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return x(t,e),!0}}runRecovery(t,e,i){let s=null,n=!1;for(let r=0;r<t.length;r++){let o=t[r],l=e[r<<1],a=e[1+(r<<1)],h=m?this.stackID(o)+" -> ":"";if(o.deadEnd){if(n)continue;if(n=!0,o.restart(),m&&console.log(h+this.stackID(o)+" (restarted)"),this.advanceFully(o,i))continue}let c=o.split(),u=h;for(let t=0;t<10&&c.forceReduce()&&(m&&console.log(u+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,i));t++)m&&(u=this.stackID(c)+" -> ");for(let t of o.recoverByInsert(l))m&&console.log(h+this.stackID(t)+" (via recover-insert)"),this.advanceFully(t,i);this.stream.end>o.pos?(a==o.pos&&(a++,l=0),o.recoverByDelete(l,a),m&&console.log(h+this.stackID(o)+` (via recover-delete ${this.parser.getName(l)})`),x(o,i)):(!s||s.score<c.score)&&(s=c)}return s}stackToTree(t){return t.close(),s.PH.build({buffer:l.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(g||(g=new WeakMap)).get(t);return e||g.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function x(t,e){for(let i=0;i<e.length;i++){let s=e[i];if(s.pos==t.pos&&s.sameState(t))return void(e[i].score<t.score&&(e[i]=t))}e.push(t)}class k{constructor(t,e,i){this.source=t,this.flags=e,this.disabled=i}allows(t){return!this.disabled||0==this.disabled[t]}}class S extends s.iX{constructor(t){if(super(),this.wrappers=[],14!=t.version)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let i=0;i<t.repeatNodeCount;i++)e.push("");let i=Object.keys(t.topRules).map((e=>t.topRules[e][1])),n=[];for(let t=0;t<e.length;t++)n.push([]);function r(t,e,i){n[t].push([e,e.deserialize(String(i))])}if(t.nodeProps)for(let e of t.nodeProps){let t=e[0];"string"==typeof t&&(t=s.uY[t]);for(let i=1;i<e.length;){let s=e[i++];if(s>=0)r(s,t,e[i++]);else{let n=e[i+-s];for(let o=-s;o>0;o--)r(e[i++],t,n);i++}}}this.nodeSet=new s.fI(e.map(((e,r)=>s.Z6.define({name:r>=this.minRepeatTerm?void 0:e,id:r,props:n[r],top:i.indexOf(r)>-1,error:0==r,skipped:t.skippedNodes&&t.skippedNodes.indexOf(r)>-1})))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=s.cF;let o=a(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let t=0;t<this.specializerSpecs.length;t++)this.specialized[t]=this.specializerSpecs[t].term;this.specializers=this.specializerSpecs.map(A),this.states=a(t.states,Uint32Array),this.data=a(t.stateData),this.goto=a(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map((t=>"number"==typeof t?new f(o,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 y(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);n<i;n++)if(s[n]==t)return o;if(r)return-1}}hasAction(t,e){let i=this.data;for(let s=0;s<2;s++)for(let n,r=this.stateSlot(t,s?2:1);;r+=3){if(65535==(n=i[r])){if(1!=i[r+1]){if(2==i[r+1])return C(i,r+2);break}n=i[r=C(i,r+2)]}if(n==e||0==n)return C(i,r+1)}return 0}stateSlot(t,e){return this.states[6*t+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}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])break;i=C(this.data,i+2)}s=e(C(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])break;i=C(this.data,i+2)}if(!(1&this.data[i+2])){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(S.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new 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]=A(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;t<e.length;t++)if(!i[t])for(let i,n=this.dialects[e[t]];65535!=(i=this.data[n++]);)(s||(s=new Uint8Array(this.maxTerm+1)))[i]=1;return new k(t,i,s)}static deserialize(t){return new S(t)}}function C(t,e){return t[e]|t[e+1]<<16}function A(t){if(t.external){let e=t.extend?1:0;return(i,s)=>t.external(i,s)<<1|e}return t.get}var M=i(3720);const O=(0,M.pn)({String:M._A.string,Number:M._A.number,"True False":M._A.bool,PropertyName:M._A.propertyName,Null:M._A.null,", :":M._A.separator,"[ ]":M._A.squareBracket,"{ }":M._A.brace}),T=S.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[O],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});var D=i(4576);const R=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const i=function(t,e){let i;return(i=t.message.match(/at position (\d+)/))?Math.min(+i[1],e.length):(i=t.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+i[1]).from+ +i[2]-1,e.length):0}(e,t.state.doc);return[{from:i,message:e.message,severity:"error",to:i}]}return[]},P=D.bj.define({name:"json",parser:T.configure({props:[D.Oh.add({Object:(0,D.mz)({except:/^\s*\}/}),Array:(0,D.mz)({except:/^\s*\]/})}),D.b_.add({"Object Array":D.yd})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function E(){return new D.Yy(P)}},3720:(t,e,i)=>{i.d(e,{DM:()=>f,_A:()=>D,az:()=>u,pn:()=>a});var s=i(365);let n=0;class r{constructor(t,e,i,s){this.name=t,this.set=e,this.base=i,this.modified=s,this.id=n++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i="string"==typeof t?t:"?";if(t instanceof r&&(e=t),null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let s=new r(i,[],null,[]);if(s.set.push(s),e)for(let t of e.set)s.set.push(t);return s}static defineModifier(t){let e=new l(t);return t=>t.modified.indexOf(e)>-1?t:l.get(t.base||t,t.modified.concat(e).sort(((t,e)=>t.id-e.id)))}}let o=0;class l{constructor(t){this.name=t,this.instances=[],this.id=o++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(s=e,n=i.modified,s.length==n.length&&s.every(((t,e)=>t==n[e])));var s,n}));if(i)return i;let s=[],n=new r(t.name,s,t,e);for(let t of e)t.instances.push(n);let o=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let s=0,n=e.length;s<n;s++)e.push(e[s].concat(t[i]));return e.sort(((t,e)=>e.length-t.length))}(e);for(let e of t.set)if(!e.modified.length)for(let t of o)s.push(l.get(e,t));return n}}function a(t){let e=Object.create(null);for(let i in t){let s=t[i];Array.isArray(s)||(s=[s]);for(let t of 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 new RangeError("Invalid path: "+t);if(i.push("*"==s[0]?"":'"'==s[0][0]?JSON.parse(s[0]):s[0]),e+=s[0].length,e==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){n=0;break}if("/"!=o)throw new RangeError("Invalid path: "+t);r=t.slice(e)}let o=i.length-1,l=i[o];if(!l)throw new RangeError("Invalid path: "+t);let a=new c(s,n,o>0?i.slice(0,o):null);e[l]=a.sort(e[l])}}return h.add(e)}const h=new s.uY({combine(t,e){let i,s,n;for(;t||e;){if(!t||e&&t.depth<=e.depth?(n=e,e=e.next):(n=t,t=t.next),i&&i.mode==n.mode&&!n.context&&!i.context)continue;let r=new c(n.tags,n.mode,n.context);i?i.next=r:s=r,i=r}return s}});class c{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<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function u(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:s,all:n=null}=e||{};return{style:t=>{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}}function f(t,e,i,s=0,n=t.length){let r=new d(s,Array.isArray(e)?e:[e],i);r.highlightRange(t.cursor(),s,n,"",r.highlighters),r.flush(n)}c.empty=new c([],2,null);class d{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,r){let{type:o,from:l,to:a}=t;if(l>=i||a<=e)return;o.isTop&&(r=this.highlighters.filter((t=>!t.scope||t.scope(o))));let u=n,f=function(t){let e=t.type.prop(h);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||c.empty,d=function(t,e){let i=null;for(let s of t){let t=s.style(e);t&&(i=i?i+" "+t:t)}return i}(r,f.tags);if(d&&(u&&(u+=" "),u+=d,1==f.mode&&(n+=(n?" ":"")+d)),this.startSpan(Math.max(e,l),u),f.opaque)return;let p=t.tree&&t.tree.prop(s.uY.mounted);if(p&&p.overlay){let s=t.node.enter(p.overlay[0].from+l,1),o=this.highlighters.filter((t=>!t.scope||t.scope(p.tree.type))),h=t.firstChild();for(let c=0,f=l;;c++){let d=c<p.overlay.length?p.overlay[c]:null,m=d?d.from+l:a,g=Math.max(e,f),v=Math.min(i,m);if(g<v&&h)for(;t.from<v&&(this.highlightRange(t,g,v,n,r),this.startSpan(Math.min(v,t.to),u),!(t.to>=m)&&t.nextSibling()););if(!d||m>i)break;f=d.to+l,f>e&&(this.highlightRange(s.cursor(),Math.max(e,d.from+l),Math.min(i,f),"",o),this.startSpan(Math.min(i,f),u))}h&&t.parent()}else if(t.firstChild()){p&&(n="");do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,r),this.startSpan(Math.min(i,t.to),u)}}while(t.nextSibling());t.parent()}}}const p=r.define,m=p(),g=p(),v=p(g),w=p(g),b=p(),y=p(b),x=p(b),k=p(),S=p(k),C=p(),A=p(),M=p(),O=p(M),T=p(),D={comment:m,lineComment:p(m),blockComment:p(m),docComment:p(m),name:g,variableName:p(g),typeName:v,tagName:p(v),propertyName:w,attributeName:p(w),className:p(g),labelName:p(g),namespace:p(g),macroName:p(g),literal:b,string:y,docString:p(y),character:p(y),attributeValue:p(y),number:x,integer:p(x),float:p(x),bool:p(b),regexp:p(b),escape:p(b),color:p(b),url:p(b),keyword:C,self:p(C),null:p(C),atom:p(C),unit:p(C),modifier:p(C),operatorKeyword:p(C),controlKeyword:p(C),definitionKeyword:p(C),moduleKeyword:p(C),operator:A,derefOperator:p(A),arithmeticOperator:p(A),logicOperator:p(A),bitwiseOperator:p(A),compareOperator:p(A),updateOperator:p(A),definitionOperator:p(A),typeOperator:p(A),controlOperator:p(A),punctuation:M,separator:p(M),bracket:O,angleBracket:p(O),squareBracket:p(O),paren:p(O),brace:p(O),content:k,heading:S,heading1:p(S),heading2:p(S),heading3:p(S),heading4:p(S),heading5:p(S),heading6:p(S),contentSeparator:p(k),list:p(k),quote:p(k),emphasis:p(k),strong:p(k),link:p(k),monospace:p(k),strikethrough:p(k),inserted:p(),deleted:p(),changed:p(),invalid:p(),meta:T,documentMeta:p(T),annotation:p(T),processingInstruction:p(T),definition:r.defineModifier("definition"),constant:r.defineModifier("constant"),function:r.defineModifier("function"),standard:r.defineModifier("standard"),local:r.defineModifier("local"),special:r.defineModifier("special")};for(let t in D){let e=D[t];e instanceof r&&(e.name=t)}u([{tag:D.link,class:"tok-link"},{tag:D.heading,class:"tok-heading"},{tag:D.emphasis,class:"tok-emphasis"},{tag:D.strong,class:"tok-strong"},{tag:D.keyword,class:"tok-keyword"},{tag:D.atom,class:"tok-atom"},{tag:D.bool,class:"tok-bool"},{tag:D.url,class:"tok-url"},{tag:D.labelName,class:"tok-labelName"},{tag:D.inserted,class:"tok-inserted"},{tag:D.deleted,class:"tok-deleted"},{tag:D.literal,class:"tok-literal"},{tag:D.string,class:"tok-string"},{tag:D.number,class:"tok-number"},{tag:[D.regexp,D.escape,D.special(D.string)],class:"tok-string2"},{tag:D.variableName,class:"tok-variableName"},{tag:D.local(D.variableName),class:"tok-variableName tok-local"},{tag:D.definition(D.variableName),class:"tok-variableName tok-definition"},{tag:D.special(D.variableName),class:"tok-variableName2"},{tag:D.definition(D.propertyName),class:"tok-propertyName tok-definition"},{tag:D.typeName,class:"tok-typeName"},{tag:D.namespace,class:"tok-namespace"},{tag:D.className,class:"tok-className"},{tag:D.macroName,class:"tok-macroName"},{tag:D.propertyName,class:"tok-propertyName"},{tag:D.operator,class:"tok-operator"},{tag:D.comment,class:"tok-comment"},{tag:D.meta,class:"tok-meta"},{tag:D.invalid,class:"tok-invalid"},{tag:D.punctuation,class:"tok-punctuation"}])},3748:(t,e,i)=>{function s(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var s in i)if(Object.prototype.hasOwnProperty.call(i,s)){var r=i[s];"string"==typeof r?t.setAttribute(s,r):null!=r&&(t[s]=r)}e++}for(;e<arguments.length;e++)n(t,arguments[e]);return t}function n(t,e){if("string"==typeof e)t.appendChild(document.createTextNode(e));else if(null==e);else if(null!=e.nodeType)t.appendChild(e);else{if(!Array.isArray(e))throw new RangeError("Unsupported child node: "+e);for(var i=0;i<e.length;i++)n(t,e[i])}}i.d(e,{A:()=>s})},4528:(t,e,i)=>{i.d(e,{Eo:()=>X,gN:()=>v,pi:()=>Q});var s=i(6898),n=i(1638),r=i(3748);const o="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class l{constructor(t,e,i=0,s=t.length,n,r){this.test=r,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,s),this.bufferStart=i,this.normalize=n?t=>n(o(t)):o,this.query=this.normalize(e)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return(0,n.vS)(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=(0,n.MK)(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=(0,n.Fh)(t);let s=this.normalize(e);if(s.length)for(let t=0,n=i,r=!0;;t++){let i=s.charCodeAt(t),o=this.match(i,n,r,this.bufferPos+this.bufferStart,t==s.length-1);if(o)return this.value=o,this;if(t==s.length-1)break;r&&t<e.length&&e.charCodeAt(t)==i?n++:r=!1}}}match(t,e,i,s,n){let r=null;for(let e=0;e<this.matches.length;){let i=this.matches[e],o=!1;this.query.charCodeAt(i.index)==t&&(i.index==this.query.length-1?r={from:i.from,to:s,precise:n&&i.precise}:(i.index++,o=!0)),o?e++:this.matches.splice(e,1)}return this.query.charCodeAt(0)==t&&(1==this.query.length?r={from:e,to:s,precise:i&&n}:this.matches.push({from:e,index:1,precise:i})),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}}"undefined"!=typeof Symbol&&(l.prototype[Symbol.iterator]=function(){return this});const a={from:-1,to:-1,match:/.*/.exec(""),precise:!0},h="gm"+(null==/x/.unicode?"":"u");class c{constructor(t,e,i,s=0,n=t.length){if(this.text=t,this.to=n,this.curLine="",this.done=!1,this.value=a,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new d(t,e,i,s,n);this.re=new RegExp(e,h+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=t.iter();let r=t.lineAt(s);this.curLineStart=r.from,this.matchPos=p(t,s),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let i=this.curLineStart+e.index,s=i+e[0].length;if(this.matchPos=p(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<s||i>this.value.to)&&(!this.test||this.test(i,s,e)))return this.value={from:i,to:s,precise:!0,match:e},this;t=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),t=0}}}}const u=new WeakMap;class f{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,i){let s=u.get(t);if(!s||s.from>=i||s.to<=e){let s=new f(e,t.sliceString(e,i));return u.set(t,s),s}if(s.from==e&&s.to==i)return s;let{text:n,from:r}=s;return r>e&&(n=t.sliceString(e,r)+n,r=e),s.to<i&&(n+=t.sliceString(s.to,i)),u.set(t,new f(r,n)),new f(e,n.slice(e-r,i-r))}}class d{constructor(t,e,i,s,n){this.text=t,this.to=n,this.done=!1,this.value=a,this.matchPos=p(t,s),this.re=new RegExp(e,h+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=f.get(t,s,this.chunkEnd(s+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let t=this.flat.from+e.index,i=t+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,i,e)))return this.value={from:t,to:i,precise:!0,match:e},this.matchPos=p(this.text,i+(t==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=f.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function p(t,e){if(e>=t.length)return e;let i,s=t.lineAt(e);for(;e<s.to&&(i=s.text.charCodeAt(e-s.from))>=56320&&i<57344;)e++;return e}"undefined"!=typeof Symbol&&(c.prototype[Symbol.iterator]=d.prototype[Symbol.iterator]=function(){return this});const m={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},g=n.sj.define({combine:t=>(0,n.QR)(t,m,{highlightWordAroundCursor:(t,e)=>t||e,minSelectionLength:Math.min,maxMatches:Math.min})});function v(t){let e=[k,x];return t&&e.push(g.of(t)),e}const w=s.NZ.mark({class:"cm-selectionMatch"}),b=s.NZ.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function y(t,e,i,s){return!(0!=i&&t(e.sliceDoc(i-1,i))==n.Je.Word||s!=e.doc.length&&t(e.sliceDoc(s,s+1))==n.Je.Word)}const x=s.Z9.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(g),{state:i}=t,r=i.selection;if(r.ranges.length>1)return s.NZ.none;let o,a=r.main,h=null;if(a.empty){if(!e.highlightWordAroundCursor)return s.NZ.none;let t=i.wordAt(a.head);if(!t)return s.NZ.none;h=i.charCategorizer(a.head),o=i.sliceDoc(t.from,t.to)}else{let t=a.to-a.from;if(t<e.minSelectionLength||t>200)return s.NZ.none;if(e.wholeWords){if(o=i.sliceDoc(a.from,a.to),h=i.charCategorizer(a.head),!y(h,i,a.from,a.to)||!function(t,e,i,s){return t(e.sliceDoc(i,i+1))==n.Je.Word&&t(e.sliceDoc(s-1,s))==n.Je.Word}(h,i,a.from,a.to))return s.NZ.none}else if(o=i.sliceDoc(a.from,a.to),!o)return s.NZ.none}let c=[];for(let n of t.visibleRanges){let t=new l(i.doc,o,n.from,n.to);for(;!t.next().done;){let{from:n,to:r}=t.value;if((!h||y(h,i,n,r))&&(a.empty&&n<=a.from&&r>=a.to?c.push(b.range(n,r)):(n>=a.to||r<=a.from)&&c.push(w.range(n,r)),c.length>e.maxMatches))return s.NZ.none}}return s.NZ.set(c)}},{decorations:t=>t.decorations}),k=s.Lz.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),S=n.sj.define({combine:t=>(0,n.QR)(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new J(t),scrollToMatch:t=>s.Lz.scrollIntoView(t)})});class C{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||function(t){try{return new RegExp(t,h),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord,this.test=t.test}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,((t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"))}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord&&this.test==t.test}create(){return this.regexp?new P(this):new O(this)}getCursor(t,e=0,i){let s=t.doc?t:n.$t.create({doc:t});return null==i&&(i=s.doc.length),this.regexp?T(this,s,e,i):M(this,s,e,i)}}class A{constructor(t){this.spec=t}}function M(t,e,i,s){let r;var o,a;return t.wholeWord&&(o=e.doc,a=e.charCategorizer(e.selection.main.head),r=(t,e,i,s)=>((s>t||s+i.length<e)&&(s=Math.max(0,t-2),i=o.sliceString(s,Math.min(o.length,e+2))),!(a(D(i,t-s))==n.Je.Word&&a(R(i,t-s))==n.Je.Word||a(R(i,e-s))==n.Je.Word&&a(D(i,e-s))==n.Je.Word))),t.test&&(r=function(t,e,i){return(s,n,r,o)=>{if(i&&!i(s,n,r,o))return!1;let l=s>=o&&n<=o+r.length?r.slice(s-o,n-o):e.doc.sliceString(s,n);return t(l,e,s,n)}}(t.test,e,r)),new l(e.doc,t.unquoted,i,s,t.caseSensitive?void 0:t=>t.toLowerCase(),r)}class O extends A{constructor(t){super(t)}nextMatch(t,e,i){let s=M(this.spec,t,i,t.doc.length).nextOverlapping();if(s.done){let i=Math.min(t.doc.length,e+this.spec.unquoted.length);s=M(this.spec,t,0,i).nextOverlapping()}return s.done||s.value.from==e&&s.value.to==i?null:s.value}prevMatchInRange(t,e,i){for(let s=i;;){let i=Math.max(e,s-1e4-this.spec.unquoted.length),n=M(this.spec,t,i,s),r=null;for(;!n.nextOverlapping().done;)r=n.value;if(r)return r;if(i==e)return null;s-=1e4}}prevMatch(t,e,i){let s=this.prevMatchInRange(t,0,e);return s||(s=this.prevMatchInRange(t,Math.max(0,i-this.spec.unquoted.length),t.doc.length)),!s||s.from==e&&s.to==i?null:s}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let i=M(this.spec,t,0,t.doc.length),s=[];for(;!i.next().done;){if(s.length>=e)return null;s.push(i.value)}return s}highlight(t,e,i,s){let n=M(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!n.next().done;)s(n.value.from,n.value.to)}}function T(t,e,i,s){let r;var o;return t.wholeWord&&(o=e.charCategorizer(e.selection.main.head),r=(t,e,i)=>!i[0].length||(o(D(i.input,i.index))!=n.Je.Word||o(R(i.input,i.index))!=n.Je.Word)&&(o(R(i.input,i.index+i[0].length))!=n.Je.Word||o(D(i.input,i.index+i[0].length))!=n.Je.Word)),t.test&&(r=function(t,e,i){return(s,n,r)=>(!i||i(s,n,r))&&t(r[0],e,s,n)}(t.test,e,r)),new c(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:r},i,s)}function D(t,e){return t.slice((0,n.zK)(t,e,!1),e)}function R(t,e){return t.slice(e,(0,n.zK)(t,e))}class P extends A{nextMatch(t,e,i){let s=T(this.spec,t,i,t.doc.length).next();return s.done&&(s=T(this.spec,t,0,e).next()),s.done?null:s.value}prevMatchInRange(t,e,i){for(let s=1;;s++){let n=Math.max(e,i-1e4*s),r=T(this.spec,t,n,i),o=null;for(;!r.next().done;)o=r.value;if(o&&(n==e||o.from>n+10))return o;if(n==e)return null}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,((e,i)=>{if("&"==i)return t.match[0];if("$"==i)return"$";for(let e=i.length;e>0;e--){let s=+i.slice(0,e);if(s>0&&s<t.match.length)return t.match[s]+i.slice(e)}return e}))}matchAll(t,e){let i=T(this.spec,t,0,t.doc.length),s=[];for(;!i.next().done;){if(s.length>=e)return null;s.push(i.value)}return s}highlight(t,e,i,s){let n=T(this.spec,t,Math.max(0,e-250),Math.min(i+250,t.doc.length));for(;!n.next().done;)s(n.value.from,n.value.to)}}const E=n.Pe.define(),B=n.Pe.define(),L=n.sU.define({create:t=>new N(K(t).create(),null),update(t,e){for(let i of e.effects)i.is(E)?t=new N(i.value.create(),t.panel):i.is(B)&&(t=new N(t.query,i.value?$:null));return t},provide:t=>s.S7.from(t,(t=>t.panel))});class N{constructor(t,e){this.query=t,this.panel=e}}const I=s.NZ.mark({class:"cm-searchMatch"}),F=s.NZ.mark({class:"cm-searchMatch cm-searchMatch-selected"}),W=s.Z9.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(L))}update(t){let e=t.state.field(L);(e!=t.startState.field(L)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return s.NZ.none;let{view:i}=this,r=new n.vB;for(let e=0,s=i.visibleRanges,n=s.length;e<n;e++){let{from:o,to:l}=s[e];for(;e<n-1&&l>s[e+1].from-500;)l=s[++e].to;t.highlight(i.state,o,l,((t,e)=>{let s=i.state.selection.ranges.some((i=>i.from==t&&i.to==e));r.add(t,e,s?F:I)}))}return r.finish()}},{decorations:t=>t.decorations});function z(t){return e=>{let i=e.state.field(L,!1);return i&&i.query.spec.valid?t(e,i):Q(e)}}const H=z(((t,{query:e})=>{let{to:i}=t.state.selection.main,s=e.nextMatch(t.state,i,i);if(!s)return!1;let r=n.OF.single(s.from,s.to),o=t.state.facet(S);return t.dispatch({selection:r,effects:[it(t,s),o.scrollToMatch(r.main,t)],userEvent:"select.search"}),U(t),!0})),V=z(((t,{query:e})=>{let{state:i}=t,{from:s}=i.selection.main,r=e.prevMatch(i,s,s);if(!r)return!1;let o=n.OF.single(r.from,r.to),l=t.state.facet(S);return t.dispatch({selection:o,effects:[it(t,r),l.scrollToMatch(o.main,t)],userEvent:"select.search"}),U(t),!0})),_=z(((t,{query:e})=>{let i=e.matchAll(t.state,1e3);return!(!i||!i.length||(t.dispatch({selection:n.OF.create(i.map((t=>n.OF.range(t.from,t.to)))),userEvent:"select.search.matches"}),0))})),j=z(((t,{query:e})=>{let{state:i}=t,{from:r,to:o}=i.selection.main;if(i.readOnly)return!1;let l=e.nextMatch(i,r,r);if(!l)return!1;let a,h,c=l,u=[],f=[];c.precise?c.from==r&&c.to==o&&(h=i.toText(e.getReplacement(c)),u.push({from:c.from,to:c.to,insert:h}),c=e.nextMatch(i,c.from,c.to),f.push(s.Lz.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(r).number)+"."))):c=e.nextMatch(i,c.from,c.to);let d=t.state.changes(u);return c&&(a=n.OF.single(c.from,c.to).map(d),f.push(it(t,c)),f.push(i.facet(S).scrollToMatch(a.main,t))),t.dispatch({changes:d,selection:a,effects:f,userEvent:"input.replace"}),!0})),q=z(((t,{query:e})=>{if(t.state.readOnly)return!1;let i=[];for(let s of e.matchAll(t.state,1e9)){let{from:t,to:n,precise:r}=s;r&&i.push({from:t,to:n,insert:e.getReplacement(s)})}if(!i.length)return!1;let n=t.state.phrase("replaced $ matches",i.length)+".";return t.dispatch({changes:i,effects:s.Lz.announce.of(n),userEvent:"input.replace.all"}),!0}));function $(t){return t.state.facet(S).createPanel(t)}function K(t,e){var i,s,n,r,o;let l=t.selection.main,a=l.empty||l.to>l.from+100?"":t.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=t.facet(S);return new C({search:(null!==(i=null==e?void 0:e.literal)&&void 0!==i?i:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!==(s=null==e?void 0:e.caseSensitive)&&void 0!==s?s:h.caseSensitive,literal:null!==(n=null==e?void 0:e.literal)&&void 0!==n?n:h.literal,regexp:null!==(r=null==e?void 0:e.regexp)&&void 0!==r?r:h.regexp,wholeWord:null!==(o=null==e?void 0:e.wholeWord)&&void 0!==o?o:h.wholeWord})}function Y(t){let e=(0,s.ld)(t,$);return e&&e.dom.querySelector("[main-field]")}function U(t){let e=Y(t);e&&e==t.root.activeElement&&e.select()}const Q=t=>{let e=t.state.field(L,!1);if(e&&e.panel){let i=Y(t);if(i&&i!=t.root.activeElement){let s=K(t.state,e.query.spec);s.valid&&t.dispatch({effects:E.of(s)}),i.focus(),i.select()}}else t.dispatch({effects:[B.of(!0),e?E.of(K(t.state,e.query.spec)):n.Pe.appendConfig.of(nt)]});return!0},G=t=>{let e=t.state.field(L,!1);if(!e||!e.panel)return!1;let i=(0,s.ld)(t,$);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:B.of(!1)}),!0},X=[{key:"Mod-f",run:Q,scope:"editor search-panel"},{key:"F3",run:H,shift:V,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:H,shift:V,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:G,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:t,dispatch:e})=>{let i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:s,to:r}=i.main,o=[],a=0;for(let e=new l(t.doc,t.sliceDoc(s,r));!e.next().done;){if(o.length>1e3)return!1;e.value.from==s&&(a=o.length),o.push(n.OF.range(e.value.from,e.value.to))}return e(t.update({selection:n.OF.create(o,a),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:t=>{let e=(0,s.rC)(t,"cm-goto-line");if(e){let t=e.dom.querySelector("input[type=text]");return t&&t.select(),!0}let{state:i}=t,r=String(i.doc.lineAt(t.state.selection.main.head).number),{close:o,result:l}=(0,s.ui)(t,{class:"cm-goto-line",label:i.phrase("Go to line"),input:{type:"text",name:"line",value:r},focus:!0,submitLabel:i.phrase("go")});return l.then((e=>{let r=e&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.elements.line.value);if(!r)return void t.dispatch({effects:o});let l=i.doc.lineAt(i.selection.main.head),[,a,h,c,u]=r,f=c?+c.slice(1):0,d=h?+h:l.number;if(h&&u){let t=d/100;a&&(t=t*("-"==a?-1:1)+l.number/i.doc.lines),d=Math.round(i.doc.lines*t)}else h&&a&&(d=d*("-"==a?-1:1)+l.number);let p=i.doc.line(Math.max(1,Math.min(i.doc.lines,d))),m=n.OF.cursor(p.from+Math.max(0,Math.min(f,p.length)));t.dispatch({effects:[o,s.Lz.scrollIntoView(m.from,{y:"center"})],selection:m})})),!0}},{key:"Mod-d",run:({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some((t=>t.from===t.to)))return(({state:t,dispatch:e})=>{let{selection:i}=t,s=n.OF.create(i.ranges.map((e=>t.wordAt(e.head)||n.OF.cursor(e.head))),i.mainIndex);return!s.eq(i)&&(e(t.update({selection:s})),!0)})({state:t,dispatch:e});let r=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some((e=>t.sliceDoc(e.from,e.to)!=r)))return!1;let o=function(t,e){let{main:i,ranges:s}=t.selection,n=t.wordAt(i.head),r=n&&n.from==i.from&&n.to==i.to;for(let i=!1,n=new l(t.doc,e,s[s.length-1].to);;){if(n.next(),!n.done){if(i&&s.some((t=>t.from==n.value.from)))continue;if(r){let e=t.wordAt(n.value.from);if(!e||e.from!=n.value.from||e.to!=n.value.to)continue}return n.value}if(i)return null;n=new l(t.doc,e,0,Math.max(0,s[s.length-1].from-1)),i=!0}}(t,r);return!!o&&(e(t.update({selection:t.selection.addRange(n.OF.range(o.from,o.to),!1),effects:s.Lz.scrollIntoView(o.to)})),!0)},preventDefault:!0}];class J{constructor(t){this.view=t;let e=this.query=t.state.field(L).query.spec;function i(t,e,i){return(0,r.A)("button",{class:"cm-button",name:t,onclick:e,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=(0,r.A)("input",{value:e.search,placeholder:Z(t,"Find"),"aria-label":Z(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=(0,r.A)("input",{value:e.replace,placeholder:Z(t,"Replace"),"aria-label":Z(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=(0,r.A)("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=(0,r.A)("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=(0,r.A)("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=(0,r.A)("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,i("next",(()=>H(t)),[Z(t,"next")]),i("prev",(()=>V(t)),[Z(t,"previous")]),i("select",(()=>_(t)),[Z(t,"all")]),(0,r.A)("label",null,[this.caseField,Z(t,"match case")]),(0,r.A)("label",null,[this.reField,Z(t,"regexp")]),(0,r.A)("label",null,[this.wordField,Z(t,"by word")]),...t.state.readOnly?[]:[(0,r.A)("br"),this.replaceField,i("replace",(()=>j(t)),[Z(t,"replace")]),i("replaceAll",(()=>q(t)),[Z(t,"replace all")])],(0,r.A)("button",{name:"close",onclick:()=>G(t),"aria-label":Z(t,"close"),type:"button"},["×"])])}commit(){let t=new C({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:E.of(t)}))}keydown(t){(0,s.TS)(this.view,t,"search-panel")?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?V:H)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),j(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(E)&&!t.value.eq(this.query)&&this.setQuery(t.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(S).top}}function Z(t,e){return t.state.phrase(e)}const tt=30,et=/[\s\.,:;?!]/;function it(t,{from:e,to:i}){let n=t.state.doc.lineAt(e),r=t.state.doc.lineAt(i).to,o=Math.max(n.from,e-tt),l=Math.min(r,i+tt),a=t.state.sliceDoc(o,l);if(o!=n.from)for(let t=0;t<tt;t++)if(!et.test(a[t+1])&&et.test(a[t])){a=a.slice(t);break}if(l!=r)for(let t=a.length-1;t>a.length-tt;t--)if(!et.test(a[t-1])&&et.test(a[t])){a=a.slice(0,t);break}return s.Lz.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${n.number}.`)}const st=s.Lz.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),nt=[L,n.Nb.low(W),st]},4576:(t,e,i)=>{i.d(e,{cr:()=>pt,KB:()=>R,bj:()=>d,Yy:()=>C,SG:()=>Pt,mz:()=>F,Zt:()=>xt,hY:()=>et,Lv:()=>ft,yd:()=>_,f7:()=>st,b_:()=>V,tp:()=>O,_v:()=>D,Oh:()=>P,WD:()=>z,EI:()=>T,Xt:()=>M,jU:()=>Nt,y9:()=>wt,mv:()=>p,_I:()=>it});var s,n=i(365),r=i(1638),o=i(6898),l=i(3720),a=i(7417);const h=new n.uY;const c=new n.uY;class u{constructor(t,e,i=[],s=""){this.data=t,this.name=s,r.$t.prototype.hasOwnProperty("tree")||Object.defineProperty(r.$t.prototype,"tree",{get(){return p(this)}}),this.parser=e,this.extension=[S.of(this),r.$t.languageData.of(((t,e,i)=>{let s=f(t,e,i),n=s.type.prop(h);if(!n)return[];let r=t.facet(n),o=s.type.prop(c);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 f(t,e,i).type.prop(h)==this.data}findRegions(t){let e=t.facet(S);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(h)==this.data)return void i.push({from:e,to:e+t.length});let r=t.prop(n.uY.mounted);if(r){if(r.tree.prop(h)==this.data){if(r.overlay)for(let t of r.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(r.overlay){let t=i.length;if(s(r.tree,r.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let r=t.children[i];r instanceof n.PH&&s(r,t.positions[i]+e)}};return s(p(t),0),i}get allowsNesting(){return!0}}function f(t,e,i){let s=t.facet(S),r=p(t).topNode;if(!s||s.allowsNesting)for(let t=r;t;t=t.enter(e,i,n.Qj.ExcludeBuffers|n.Qj.EnterBracketed))t.type.isTop&&(r=t);return r}u.setState=r.Pe.define();class d extends u{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=(i=t.languageData,r.sj.define({combine:i?t=>t.concat(i):void 0}));var i;return new d(e,t.parser.configure({props:[h.add((t=>t.isTop?e:void 0))]}),t.name)}configure(t,e){return new d(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function p(t){let e=t.field(u.state,!1);return e?e.tree:n.PH.empty}class m{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let g=null;class v{constructor(t,e,i=[],s,n,r,o,l){this.parser=t,this.state=e,this.fragments=i,this.tree=s,this.treeLen=n,this.viewport=r,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new v(t,e,[],n.PH.empty,0,i,[],null)}startParse(){return this.parser.startParse(new m(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=n.PH.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.state.doc.length&&this.parse.stopAt(e);;){let s=this.parse.advance();if(s){if(this.fragments=this.withoutTempSkipped(n.rr.addTree(s,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=s,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}}))}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=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(n.rr.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=g;g=this;try{return t()}finally{g=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=w(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:l}=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=n.rr.applyChanges(i,e),s=n.PH.empty,r=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){l=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),s=t.mapPos(e.to,-1);i<s&&l.push({from:i,to:s})}}}return new v(this.parser,e,i,s,r,o,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:i,to:s}=this.skipped[e];i<t.to&&s>t.from&&(this.fragments=w(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 n.iX{createParse(e,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let e=g;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=o,new n.PH(n.Z6.none,[],[],o-r)},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 g}}function w(t,e,i){return n.rr.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class b{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 b(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=v.create(t.facet(S).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new b(i)}}u.state=r.sU.define({create:b.init,update(t,e){for(let t of e.effects)if(t.is(u.setState))return t.value;return e.startState.facet(S)!=e.state.facet(S)?b.init(e.state):t.apply(e)}});let y=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(y=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const x="undefined"!=typeof navigator&&(null===(s=navigator.scheduling)||void 0===s?void 0:s.isInputPending)?()=>navigator.scheduling.isInputPending():null,k=o.Z9.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(u.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(u.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=y(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:s}}=this.view,n=i.field(u.state);if(n.tree==n.context.tree&&n.context.isDone(s+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,t&&!x?Math.max(25,t.timeRemaining()-5):1e9),o=n.context.treeLen<s&&i.doc.length>s+1e3,l=n.context.work((()=>x&&x()||Date.now()>r),s+(o?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:u.setState.of(new b(n.context))})),this.chunkBudget>0&&(!l||o)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>(0,o.c_)(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()}}}),S=r.sj.define({combine:t=>t.length?t[0]:null,enables:t=>[u.state,k,o.Lz.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});class C{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}const A=r.sj.define(),M=r.sj.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 new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function O(t){let e=t.facet(M);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function T(t,e){let i="",s=t.tabSize,n=t.facet(M)[0];if("\t"==n){for(;e>=s;)i+="\t",e-=s;n=" "}for(let t=0;t<e;t++)i+=n;return i}function D(t,e){t instanceof r.$t&&(t=new R(t));for(let i of t.state.facet(A)){let s=i(t,e);if(void 0!==s)return s}let i=p(t.state);return i.length>=e?function(t,e,i){let s=e.resolveStack(i),n=e.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(n!=s.node){let t=[];for(let e=n;e&&!(e.from<s.node.from||e.to>s.node.to||e.from==s.node.from&&e.type==s.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)s={node:t[e],next:s}}return E(s,t,i)}(t,i,e):null}class R{constructor(t,e={}){this.state=t,this.options=e,this.unit=O(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:s,simulateDoubleBreak:n}=this.options;return null!=s&&s>=i.from&&s<=i.to?n&&s==t?{text:"",from:t}:(e<0?s<t:s<=t)?{text:i.text.slice(s-i.from),from:s}:{text:i.text.slice(0,s-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:s}=this.lineAt(t,e);return i.slice(t-s,Math.min(i.length,t+100-s))}column(t,e=1){let{text:i,from:s}=this.lineAt(t,e),n=this.countColumn(i,t-s),r=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return r>-1&&(n+=r-this.countColumn(i,i.search(/\S|$/))),n}countColumn(t,e=t.length){return(0,r.y$)(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:s}=this.lineAt(t,e),n=this.options.overrideIndentation;if(n){let t=n(s);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const P=new n.uY;function E(t,e,i){for(let s=t;s;s=s.next){let t=B(s.node);if(t)return t(N.create(e,i,s))}return 0}function B(t){let e=t.type.prop(P);if(e)return e;let i,s=t.firstChild;if(s&&(i=s.type.prop(n.uY.closedBy))){let e=t.lastChild,s=e&&i.indexOf(e.name)>-1;return t=>function(t,e,i,s,n){let r=t.textAfter,o=r.match(/^\s*/)[0].length,l=s&&r.slice(o,o+s.length)==s||n==t.pos+o,a=e?function(t){let e=t.node,i=e.childAfter(e.from),s=e.lastChild;if(!i)return null;let n=t.options.simulateBreak,r=t.state.doc.lineAt(i.from),o=null==n||n<=r.from?r.to:Math.min(r.to,n);for(let t=i.to;;){let n=e.childAfter(t);if(!n||n==s)return null;if(!n.type.isSkipped){if(n.from>=o)return null;let t=/^ */.exec(r.text.slice(i.to-r.from))[0].length;return{from:i.from,to:i.to+t}}t=n.to}}(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*i)}(t,!0,1,void 0,s&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void 0)}return null==t.parent?L:null}function L(){return 0}class N extends R{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new N(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(I(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return E(this.context.next,this.base,this.pos)}}function I(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function F({except:t,units:e=1}={}){return i=>{let s=t&&t.test(i.textAfter);return i.baseIndent+(s?0:e*i.unit)}}const W=200;function z(){return r.$t.transactionFilter.of((t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let i=t.newDoc,{head:s}=t.newSelection.main,n=i.lineAt(s);if(s>n.from+W)return t;let r=i.sliceString(n.from,s);if(!e.some((t=>t.test(r))))return t;let{state:o}=t,l=-1,a=[];for(let{head:t}of o.selection.ranges){let e=o.doc.lineAt(t);if(e.from==l)continue;l=e.from;let i=D(o,e.from);if(null==i)continue;let s=/^\s*/.exec(e.text)[0],n=T(o,i);s!=n&&a.push({from:e.from,to:e.from+s.length,insert:n})}return a.length?[t,{changes:a,sequential:!0}]:t}))}const H=r.sj.define(),V=new n.uY;function _(t){let e=t.firstChild,i=t.lastChild;return e&&e.to<i.from?{from:e.to,to:i.type.isError?t.to:i.from}:null}function j(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function q(t,e,i){for(let s of t.facet(H)){let n=s(t,e,i);if(n)return n}return function(t,e,i){let s=p(t);if(s.length<i)return null;let n=null;for(let r=s.resolveStack(i,1);r;r=r.next){let o=r.node;if(o.to<=i||o.from>i)continue;if(n&&o.from<e)break;let l=o.type.prop(V);if(l&&(o.to<s.length-50||s.length==t.doc.length||!j(o))){let s=l(o,t);s&&s.from<=i&&s.from>=e&&s.to>i&&(n=s)}}return n}(t,e,i)}function $(t,e){let i=e.mapPos(t.from,1),s=e.mapPos(t.to,-1);return i>=s?void 0:{from:i,to:s}}const K=r.Pe.define({map:$}),Y=r.Pe.define({map:$});function U(t){let e=[];for(let{head:i}of t.state.selection.ranges)e.some((t=>t.from<=i&&t.to>=i))||e.push(t.lineBlockAt(i));return e}const Q=r.sU.define({create:()=>o.NZ.none,update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges(((e,i)=>t=G(t,e,i))),t=t.map(e.changes);let i=[];for(let s of e.effects)s.is(K)&&!J(t,s.value.from,s.value.to)?i.push(s.value):s.is(Y)&&(t=t.update({filter:(t,e)=>s.value.from!=t||s.value.to!=e,filterFrom:s.value.from,filterTo:s.value.to}));if(i.length){let{preparePlaceholder:s}=e.state.facet(rt),n=i.map((t=>(s?o.NZ.replace({widget:new ht(s(e.state,t))}):at).range(t.from,t.to)));t=t.update({add:n})}return e.selection&&(t=G(t,e.selection.main.head)),t},provide:t=>o.Lz.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 new RangeError("Invalid JSON for fold state");let e=[];for(let i=0;i<t.length;){let s=t[i++],n=t[i++];if("number"!=typeof s||"number"!=typeof n)throw new RangeError("Invalid JSON for fold state");e.push(at.range(s,n))}return o.NZ.set(e,!0)}});function G(t,e,i=e){let s=!1;return t.between(e,i,((t,n)=>{t<i&&n>e&&(s=!0)})),s?t.update({filterFrom:e,filterTo:i,filter:(t,s)=>t>=i||s<=e}):t}function X(t,e,i){var s;let n=null;return null===(s=t.field(Q,!1))||void 0===s||s.between(e,i,((t,e)=>{(!n||n.from>t)&&(n={from:t,to:e})})),n}function J(t,e,i){let s=!1;return t.between(e,e,((t,n)=>{t==e&&n==i&&(s=!0)})),s}function Z(t,e){return t.field(Q,!1)?e:e.concat(r.Pe.appendConfig.of(ot()))}function tt(t,e,i=!0){let s=t.state.doc.lineAt(e.from).number,n=t.state.doc.lineAt(e.to).number;return o.Lz.announce.of(`${t.state.phrase(i?"Folded lines":"Unfolded lines")} ${s} ${t.state.phrase("to")} ${n}.`)}const et=t=>{let{state:e}=t,i=[];for(let s=0;s<e.doc.length;){let n=t.lineBlockAt(s),r=q(e,n.from,n.to);r&&i.push(K.of(r)),s=(r?t.lineBlockAt(r.to):n).to+1}return i.length&&t.dispatch({effects:Z(t.state,i)}),!!i.length},it=t=>{let e=t.state.field(Q,!1);if(!e||!e.size)return!1;let i=[];return e.between(0,t.state.doc.length,((t,e)=>{i.push(Y.of({from:t,to:e}))})),t.dispatch({effects:i}),!0},st=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:t=>{for(let e of U(t)){let i=q(t.state,e.from,e.to);if(i)return t.dispatch({effects:Z(t.state,[K.of(i),tt(t,i)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:t=>{if(!t.state.field(Q,!1))return!1;let e=[];for(let i of U(t)){let s=X(t.state,i.from,i.to);s&&e.push(Y.of(s),tt(t,s,!1))}return e.length&&t.dispatch({effects:e}),e.length>0}},{key:"Ctrl-Alt-[",run:et},{key:"Ctrl-Alt-]",run:it}],nt={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},rt=r.sj.define({combine:t=>(0,r.QR)(t,nt)});function ot(t){let e=[Q,dt];return t&&e.push(rt.of(t)),e}function lt(t,e){let{state:i}=t,s=i.facet(rt),n=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),s=X(t.state,i.from,i.to);s&&t.dispatch({effects:Y.of(s)}),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}const at=o.NZ.replace({widget:new class extends o.xO{toDOM(t){return lt(t,null)}}});class ht extends o.xO{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return lt(t,this.value)}}const ct={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ut extends o.wJ{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function ft(t={}){let e={...ct,...t},i=new ut(e,!0),s=new ut(e,!1),n=o.Z9.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(S)!=t.state.facet(S)||t.startState.field(Q,!1)!=t.state.field(Q,!1)||p(t.startState)!=p(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new r.vB;for(let n of t.viewportLineBlocks){let r=X(t.state,n.from,n.to)?s:q(t.state,n.from,n.to)?i:null;r&&e.add(n.from,n.from,r)}return e.finish()}}),{domEventHandlers:l}=e;return[n,(0,o.cU)({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(n))||void 0===e?void 0:e.markers)||r.om.empty},initialSpacer:()=>new ut(e,!1),domEventHandlers:{...l,click:(t,e,i)=>{if(l.click&&l.click(t,e,i))return!0;let s=X(t.state,e.from,e.to);if(s)return t.dispatch({effects:Y.of(s)}),!0;let n=q(t.state,e.from,e.to);return!!n&&(t.dispatch({effects:K.of(n)}),!0)}}}),ot()]}const dt=o.Lz.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 pt{constructor(t,e){let i;function s(t){let e=a.G.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const n="string"==typeof e.all?e.all:e.all?s(e.all):void 0,r=e.scope;this.scope=r instanceof u?t=>t.prop(h)==r.data:r?t=>t==r:void 0,this.style=(0,l.az)(t.map((t=>({tag:t.tag,class:t.class||s(Object.assign({},t,{tag:null}))}))),{all:n}).style,this.module=i?new a.G(i):null,this.themeType=e.themeType}static define(t,e){return new pt(t,e||{})}}const mt=r.sj.define(),gt=r.sj.define({combine:t=>t.length?[t[0]]:null});function vt(t){let e=t.facet(mt);return e.length?e:t.facet(gt)}function wt(t,e){let i,s=[yt];return t instanceof pt&&(t.module&&s.push(o.Lz.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?s.push(gt.of(t)):i?s.push(mt.computeN([o.Lz.darkTheme],(e=>e.facet(o.Lz.darkTheme)==("dark"==i)?[t]:[]))):s.push(mt.of(t)),s}class bt{constructor(t){this.markCache=Object.create(null),this.tree=p(t.state),this.decorations=this.buildDeco(t,vt(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=p(t.state),i=vt(t.state),s=i!=vt(t.startState),{viewport:n}=t.view,r=t.changes.mapPos(this.decoratedTo,1);e.length<n.to&&!s&&e.type==this.tree.type&&r>=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 o.NZ.none;let i=new r.vB;for(let{from:s,to:n}of t.visibleRanges)(0,l.DM)(this.tree,e,((t,e,s)=>{i.add(t,e,this.markCache[s]||(this.markCache[s]=o.NZ.mark({class:s})))}),s,n);return i.finish()}}const yt=r.Nb.high(o.Z9.fromClass(bt,{decorations:t=>t.decorations})),xt=pt.define([{tag:l._A.meta,color:"#404740"},{tag:l._A.link,textDecoration:"underline"},{tag:l._A.heading,textDecoration:"underline",fontWeight:"bold"},{tag:l._A.emphasis,fontStyle:"italic"},{tag:l._A.strong,fontWeight:"bold"},{tag:l._A.strikethrough,textDecoration:"line-through"},{tag:l._A.keyword,color:"#708"},{tag:[l._A.atom,l._A.bool,l._A.url,l._A.contentSeparator,l._A.labelName],color:"#219"},{tag:[l._A.literal,l._A.inserted],color:"#164"},{tag:[l._A.string,l._A.deleted],color:"#a11"},{tag:[l._A.regexp,l._A.escape,l._A.special(l._A.string)],color:"#e40"},{tag:l._A.definition(l._A.variableName),color:"#00f"},{tag:l._A.local(l._A.variableName),color:"#30a"},{tag:[l._A.typeName,l._A.namespace],color:"#085"},{tag:l._A.className,color:"#167"},{tag:[l._A.special(l._A.variableName),l._A.macroName],color:"#256"},{tag:l._A.definition(l._A.propertyName),color:"#00c"},{tag:l._A.comment,color:"#940"},{tag:l._A.invalid,color:"#f00"}]),kt=o.Lz.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),St=1e4,Ct="()[]{}",At=r.sj.define({combine:t=>(0,r.QR)(t,{afterCursor:!0,brackets:Ct,maxScanDistance:St,renderMatch:Tt})}),Mt=o.NZ.mark({class:"cm-matchingBracket"}),Ot=o.NZ.mark({class:"cm-nonmatchingBracket"});function Tt(t){let e=[],i=t.matched?Mt:Ot;return e.push(i.range(t.start.from,t.start.to)),t.end&&e.push(i.range(t.end.from,t.end.to)),e}function Dt(t){let e=[],i=t.facet(At);for(let s of t.selection.ranges){if(!s.empty)continue;let n=Nt(t,s.head,-1,i)||s.head>0&&Nt(t,s.head-1,1,i)||i.afterCursor&&(Nt(t,s.head,1,i)||s.head<t.doc.length&&Nt(t,s.head+1,-1,i));n&&(e=e.concat(i.renderMatch(n,t)))}return o.NZ.set(e,!0)}const Rt=[o.Z9.fromClass(class{constructor(t){this.paused=!1,this.decorations=Dt(t.state)}update(t){(t.docChanged||t.selectionSet||this.paused)&&(t.view.composing?(this.decorations=this.decorations.map(t.changes),this.paused=!0):(this.decorations=Dt(t.state),this.paused=!1))}},{decorations:t=>t.decorations}),kt];function Pt(t={}){return[At.of(t),Rt]}const Et=new n.uY;function Bt(t,e,i){let s=t.prop(e<0?n.uY.openedBy:n.uY.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 Lt(t){let e=t.type.prop(Et);return e?e(t.node):t}function Nt(t,e,i,s={}){let n=s.maxScanDistance||St,r=s.brackets||Ct,o=p(t),l=o.resolveInner(e,i);for(let t=l;t;t=t.parent){let s=Bt(t.type,i,r);if(s&&t.from<t.to){let n=Lt(t);if(n&&(i>0?e>=n.from&&e<n.to:e>n.from&&e<=n.to))return It(0,0,i,t,n,s,r)}}return function(t,e,i,s,n,r,o){if(i<0?!e:e==t.doc.length)return null;let l=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=i>0)return null;let h={from:i<0?e-1:e,to:i>0?e+1:e},c=t.doc.iterRange(e,i>0?t.doc.length:0),u=0;for(let t=0;!c.next().done&&t<=r;){let r=c.value;i<0&&(t+=r.length);let l=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(l+t,1).type!=n))if(e%2==0==i>0)u++;else{if(1==u)return{start:h,end:{from:l+t,to:l+t+1},matched:e>>1==a>>1};u--}}i>0&&(t+=r.length)}return c.done?{start:h,matched:!1}:null}(t,e,i,o,l.type,n,r)}function It(t,e,i,s,n,r,o){let l=s.parent,a={from:n.from,to:n.to},h=0,c=null==l?void 0:l.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==h&&r.indexOf(c.type.name)>-1&&c.from<c.to){let t=Lt(c);return{start:a,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(Bt(c.type,i,o))h++;else if(Bt(c.type,-i,o)){if(0==h){let t=Lt(c);return{start:a,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}h--}}}while(i<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}const Ft=Object.create(null),Wt=[n.Z6.none],zt=[],Ht=Object.create(null),Vt=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"]])Vt[t]=jt(Ft,e);function _t(t,e){zt.indexOf(t)>-1||(zt.push(t),console.warn(e))}function jt(t,e){let i=[];for(let s of e.split(" ")){let e=[];for(let i of s.split(".")){let s=t[i]||l._A[i];s?"function"==typeof s?e.length?e=e.map(s):_t(i,`Modifier ${i} used at start of tag`):e.length?_t(i,`Tag ${i} used as modifier`):e=Array.isArray(s)?s:[s]:_t(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let s=e.replace(/ /g,"_"),r=s+" "+i.map((t=>t.id)),o=Ht[r];if(o)return o.id;let a=Ht[r]=n.Z6.define({id:Wt.length,name:s,props:[(0,l.pn)({[s]:i})]});return Wt.push(a),a.id}o.OP.RTL,o.OP.LTR},4879:(t,e,i)=>{i.d(e,{oQ:()=>_e});var s=i(6898),n=i(1638),r=i(4576),o=i(365);function l(t,e){return({state:i,dispatch:s})=>{if(i.readOnly)return!1;let n=t(e,i);return!!n&&(s(i.update(n)),!0)}}const a=l(p,0),h=l(d,0),c=l(((t,e)=>d(t,e,function(t){let e=[];for(let i of t.selection.ranges){let s=t.doc.lineAt(i.from),n=i.to<=s.to?s:t.doc.lineAt(i.to);n.from>s.from&&n.from==i.to&&(n=i.to==s.to+1?s:t.doc.lineAt(i.to-1));let r=e.length-1;r>=0&&e[r].to>s.from?e[r].to=n.to:e.push({from:s.from+/^\s*/.exec(s.text)[0].length,to:n.to})}return e}(e))),0);function u(t,e){let i=t.languageDataAt("commentTokens",e,1);return i.length?i[0]:{}}const f=50;function d(t,e,i=e.selection.ranges){let s=i.map((t=>u(e,t.from).block));if(!s.every((t=>t)))return null;let n=i.map(((t,i)=>function(t,{open:e,close:i},s,n){let r,o,l=t.sliceDoc(s-f,s),a=t.sliceDoc(n,n+f),h=/\s*$/.exec(l)[0].length,c=/^\s*/.exec(a)[0].length,u=l.length-h;if(l.slice(u-e.length,u)==e&&a.slice(c,c+i.length)==i)return{open:{pos:s-h,margin:h&&1},close:{pos:n+c,margin:c&&1}};n-s<=2*f?r=o=t.sliceDoc(s,n):(r=t.sliceDoc(s,s+f),o=t.sliceDoc(n-f,n));let d=/^\s*/.exec(r)[0].length,p=/\s*$/.exec(o)[0].length,m=o.length-p-i.length;return r.slice(d,d+e.length)==e&&o.slice(m,m+i.length)==i?{open:{pos:s+d+e.length,margin:/\s/.test(r.charAt(d+e.length))?1:0},close:{pos:n-p-i.length,margin:/\s/.test(o.charAt(m-1))?1:0}}:null}(e,s[i],t.from,t.to)));if(2!=t&&!n.every((t=>t)))return{changes:e.changes(i.map(((t,e)=>n[e]?[]:[{from:t.from,insert:s[e].open+" "},{from:t.to,insert:" "+s[e].close}])))};if(1!=t&&n.some((t=>t))){let t=[];for(let e,i=0;i<n.length;i++)if(e=n[i]){let n=s[i],{open:r,close:o}=e;t.push({from:r.pos-n.open.length,to:r.pos+r.margin},{from:o.pos-o.margin,to:o.pos+n.close.length})}return{changes:t}}return null}function p(t,e,i=e.selection.ranges){let s=[],n=-1;t:for(let{from:t,to:r}of i){let i,o=s.length,l=1e9;for(let o=t;o<=r;){let a=e.doc.lineAt(o);if(null==i&&(i=u(e,a.from).line,!i))continue t;if(a.from>n&&(t==r||r>a.from)){n=a.from;let t=/^\s*/.exec(a.text)[0].length,e=t==a.length,r=a.text.slice(t,t+i.length)==i?t:-1;t<a.text.length&&t<l&&(l=t),s.push({line:a,comment:r,token:i,indent:t,empty:e,single:!1})}o=a.to+1}if(l<1e9)for(let t=o;t<s.length;t++)s[t].indent<s[t].line.text.length&&(s[t].indent=l);s.length==o+1&&(s[o].single=!0)}if(2!=t&&s.some((t=>t.comment<0&&(!t.empty||t.single)))){let t=[];for(let{line:e,token:i,indent:n,empty:r,single:o}of s)!o&&r||t.push({from:e.from+n,insert:i+" "});let i=e.changes(t);return{changes:i,selection:e.selection.map(i,1)}}if(1!=t&&s.some((t=>t.comment>=0))){let t=[];for(let{line:e,comment:i,token:n}of s)if(i>=0){let s=e.from+i,r=s+n.length;" "==e.text[r-e.from]&&r++,t.push({from:s,to:r})}return{changes:t}}return null}const m=n.YH.define(),g=n.YH.define(),v=n.sj.define(),w=n.sj.define({combine:t=>(0,n.QR)(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,s)=>t(i,s)||e(i,s)})}),b=n.sU.define({create:()=>I.empty,update(t,e){let i=e.state.facet(w),s=e.annotation(m);if(s){let n=M.fromTransaction(e,s.selection),r=s.side,o=0==r?t.undone:t.done;return o=n?O(o,o.length,i.minDepth,n):P(o,e.startState.selection),new I(0==r?s.rest:o,0==r?o:s.rest)}let r=e.annotation(g);if("full"!=r&&"before"!=r||(t=t.isolate()),!1===e.annotation(n.ZX.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let o=M.fromTransaction(e),l=e.annotation(n.ZX.time),a=e.annotation(n.ZX.userEvent);return o?t=t.addChanges(o,l,a,i,e):e.selection&&(t=t.addSelection(e.startState.selection,l,a,i.newGroupDelay)),"full"!=r&&"after"!=r||(t=t.isolate()),t},toJSON:t=>({done:t.done.map((t=>t.toJSON())),undone:t.undone.map((t=>t.toJSON()))}),fromJSON:t=>new I(t.done.map(M.fromJSON),t.undone.map(M.fromJSON))});function y(t={}){return[b,w.of(t),s.Lz.domEventHandlers({beforeinput(t,e){let i="historyUndo"==t.inputType?k:"historyRedo"==t.inputType?S:null;return!!i&&(t.preventDefault(),i(e))}})]}function x(t,e){return function({state:i,dispatch:s}){if(!e&&i.readOnly)return!1;let n=i.field(b,!1);if(!n)return!1;let r=n.pop(t,i,e);return!!r&&(s(r),!0)}}const k=x(0,!1),S=x(1,!1),C=x(0,!0),A=x(1,!0);class M{constructor(t,e,i,s,n){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=s,this.selectionsAfter=n}setSelAfter(t){return new M(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(e=this.mapped)||void 0===e?void 0:e.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map((t=>t.toJSON()))}}static fromJSON(t){return new M(t.changes&&n.VR.fromJSON(t.changes),[],t.mapped&&n.Gu.fromJSON(t.mapped),t.startSelection&&n.OF.fromJSON(t.startSelection),t.selectionsAfter.map(n.OF.fromJSON))}static fromTransaction(t,e){let i=D;for(let e of t.startState.facet(v)){let s=e(t);s.length&&(i=i.concat(s))}return!i.length&&t.changes.empty?null:new M(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,D)}static selection(t){return new M(void 0,D,void 0,void 0,t)}}function O(t,e,i,s){let n=e+1>i+20?e-i-1:0,r=t.slice(n,e);return r.push(s),r}function T(t,e){return t.length?e.length?t.concat(e):t:e}const D=[],R=200;function P(t,e){if(t.length){let i=t[t.length-1],s=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-R));return s.length&&s[s.length-1].eq(e)?t:(s.push(e),O(t,t.length-1,1e9,i.setSelAfter(s)))}return[M.selection([e])]}function E(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function B(t,e){if(!t.length)return t;let i=t.length,s=D;for(;i;){let n=L(t[i-1],e,s);if(n.changes&&!n.changes.empty||n.effects.length){let e=t.slice(0,i);return e[i-1]=n,e}e=n.mapped,i--,s=n.selectionsAfter}return s.length?[M.selection(s)]:D}function L(t,e,i){let s=T(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):D,i);if(!t.changes)return M.selection(s);let r=t.changes.map(e),o=e.mapDesc(t.changes,!0),l=t.mapped?t.mapped.composeDesc(o):o;return new M(r,n.Pe.mapEffects(t.effects,e),l,t.startSelection.map(o),s)}const N=/^(input\.type|delete)($|\.)/;class I{constructor(t,e,i=0,s=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new I(this.done,this.undone):this}addChanges(t,e,i,s,r){let o=this.done,l=o[o.length-1];return o=l&&l.changes&&!l.changes.empty&&t.changes&&(!i||N.test(i))&&(!l.selectionsAfter.length&&e-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,function(t,e){let i=[],s=!1;return t.iterChangedRanges(((t,e)=>i.push(t,e))),e.iterChangedRanges(((t,e,n,r)=>{for(let t=0;t<i.length;){let e=i[t++],o=i[t++];r>=e&&n<=o&&(s=!0)}})),s}(l.changes,t.changes))||"input.type.compose"==i)?O(o,o.length-1,s.minDepth,new M(t.changes.compose(l.changes),T(n.Pe.mapEffects(t.effects,l.changes),l.effects),l.mapped,l.startSelection,D)):O(o,o.length,s.minDepth,t),new I(o,D,e,i)}addSelection(t,e,i,s){let n=this.done.length?this.done[this.done.length-1].selectionsAfter:D;return n.length>0&&e-this.prevTime<s&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&(r=n[n.length-1],o=t,r.ranges.length==o.ranges.length&&0===r.ranges.filter(((t,e)=>t.empty!=o.ranges[e].empty)).length)?this:new I(P(this.done,t),this.undone,e,i);var r,o}addMapping(t){return new I(B(this.done,t),B(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let s=0==t?this.done:this.undone;if(0==s.length)return null;let n=s[s.length-1],r=n.selectionsAfter[0]||(n.startSelection?n.startSelection.map(n.changes.invertedDesc,1):e.selection);if(i&&n.selectionsAfter.length)return e.update({selection:n.selectionsAfter[n.selectionsAfter.length-1],annotations:m.of({side:t,rest:E(s),selection:r}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(n.changes){let i=1==s.length?D:s.slice(0,s.length-1);return n.mapped&&(i=B(i,n.mapped)),e.update({changes:n.changes,selection:n.startSelection,effects:n.effects,annotations:m.of({side:t,rest:i,selection:r}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}I.empty=new I(D,D);const F=[{key:"Mod-z",run:k,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:S,preventDefault:!0},{linux:"Ctrl-Shift-z",run:S,preventDefault:!0},{key:"Mod-u",run:C,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:A,preventDefault:!0}];function W(t,e){return n.OF.create(t.ranges.map(e),t.mainIndex)}function z(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function H({state:t,dispatch:e},i){let s=W(t.selection,i);return!s.eq(t.selection,!0)&&(e(z(t,s)),!0)}function V(t,e){return n.OF.cursor(e?t.to:t.from)}function _(t,e){return H(t,(i=>i.empty?t.moveByChar(i,e):V(i,e)))}function j(t){return t.textDirectionAt(t.state.selection.main.head)==s.OP.LTR}const q=t=>_(t,!j(t)),$=t=>_(t,j(t));function K(t,e){return H(t,(i=>i.empty?t.moveByGroup(i,e):V(i,e)))}function Y(t,e,i){if(e.type.prop(i))return!0;let s=e.to-e.from;return s&&(s>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function U(t,e,i){let s,l,a=(0,r.mv)(t).resolveInner(e.head),h=i?o.uY.closedBy:o.uY.openedBy;for(let s=e.head;;){let e=i?a.childAfter(s):a.childBefore(s);if(!e)break;Y(t,e,h)?a=e:s=i?e.to:e.from}return l=a.type.prop(h)&&(s=i?(0,r.jU)(t,a.from,1):(0,r.jU)(t,a.to,-1))&&s.matched?i?s.end.to:s.end.from:i?a.to:a.from,n.OF.cursor(l,i?-1:1)}function Q(t,e){return H(t,(i=>{if(!i.empty)return V(i,e);let s=t.moveVertically(i,e);return s.head!=i.head?s:t.moveToLineBoundary(i,e)}))}"undefined"!=typeof Intl&&Intl.Segmenter;const G=t=>Q(t,!1),X=t=>Q(t,!0);function J(t){let e,i=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,r=0;if(i){for(let e of t.state.facet(s.Lz.scrollMargins)){let i=e(t);(null==i?void 0:i.top)&&(n=Math.max(null==i?void 0:i.top,n)),(null==i?void 0:i.bottom)&&(r=Math.max(null==i?void 0:i.bottom,r))}e=t.scrollDOM.clientHeight-n-r}else e=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:i,height:Math.max(t.defaultLineHeight,e-5)}}function Z(t,e){let i,n=J(t),{state:r}=t,o=W(r.selection,(i=>i.empty?t.moveVertically(i,e,n.height):V(i,e)));if(o.eq(r.selection))return!1;if(n.selfScroll){let e=t.coordsAtPos(r.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+n.marginTop,h=l.bottom-n.marginBottom;e&&e.top>a&&e.bottom<h&&(i=s.Lz.scrollIntoView(o.main.head,{y:"start",yMargin:e.top-a}))}return t.dispatch(z(r,o),{effects:i}),!0}const tt=t=>Z(t,!1),et=t=>Z(t,!0);function it(t,e,i){let s=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,i);if(r.head==e.head&&r.head!=(i?s.to:s.from)&&(r=t.moveToLineBoundary(e,i,!1)),!i&&r.head==s.from&&s.length){let i=/^\s*/.exec(t.state.sliceDoc(s.from,Math.min(s.from+100,s.to)))[0].length;i&&e.head!=s.from+i&&(r=n.OF.cursor(s.from+i))}return r}function st(t,e,i){let s=W(t.state.selection,(t=>{t.undirectional&&t.head>=t.anchor!=e&&(t=n.OF.range(t.head,t.anchor));let s=i(t);return n.OF.range(t.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)}));return!s.eq(t.state.selection)&&(t.dispatch(z(t.state,s)),!0)}function nt(t,e){return st(t,e,(i=>t.moveByChar(i,e)))}const rt=t=>nt(t,!j(t)),ot=t=>nt(t,j(t));function lt(t,e){return st(t,e,(i=>t.moveByGroup(i,e)))}function at(t,e){return st(t,e,(i=>t.moveVertically(i,e)))}const ht=t=>at(t,!1),ct=t=>at(t,!0);function ut(t,e){return st(t,e,(i=>t.moveVertically(i,e,J(t).height)))}const ft=t=>ut(t,!1),dt=t=>ut(t,!0),pt=({state:t,dispatch:e})=>(e(z(t,{anchor:0})),!0),mt=({state:t,dispatch:e})=>(e(z(t,{anchor:t.doc.length})),!0),gt=({state:t,dispatch:e})=>(e(z(t,{anchor:t.selection.main.anchor,head:0})),!0),vt=({state:t,dispatch:e})=>(e(z(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function wt(t,e){let{state:i}=t,s=i.selection,r=i.selection.ranges.slice();for(let s of i.selection.ranges){let n=i.doc.lineAt(s.head);if(e?n.to<t.state.doc.length:n.from>0)for(let i=s;;){let s=t.moveVertically(i,e);if(s.head<n.from||s.head>n.to){r.some((t=>t.head==s.head))||r.push(s);break}if(s.head==i.head)break;i=s}}return r.length!=s.ranges.length&&(t.dispatch(z(i,n.OF.create(r,r.length-1))),!0)}function bt(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:r}=t,o=r.changeByRange((s=>{let{from:r,to:o}=s;if(r==o){let n=e(s);n<r?(i="delete.backward",n=yt(t,n,!1)):n>r&&(i="delete.forward",n=yt(t,n,!0)),r=Math.min(r,n),o=Math.max(o,n)}else r=yt(t,r,!1),o=yt(t,o,!0);return r==o?{range:s}:{changes:{from:r,to:o},range:n.OF.cursor(r,r<s.head?-1:1)}}));return!o.changes.empty&&(t.dispatch(r.update(o,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?s.Lz.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function yt(t,e,i){if(t instanceof s.Lz)for(let n of t.state.facet(s.Lz.atomicRanges).map((e=>e(t))))n.between(e,e,((t,s)=>{t<e&&s>e&&(e=i?s:t)}));return e}const xt=(t,e,i)=>bt(t,(s=>{let o,l,a=s.from,{state:h}=t,c=h.doc.lineAt(a);if(i&&!e&&a>c.from&&a<c.from+200&&!/[^ \t]/.test(o=c.text.slice(0,a-c.from))){if("\t"==o[o.length-1])return a-1;let t=(0,n.y$)(o,h.tabSize)%(0,r.tp)(h)||(0,r.tp)(h);for(let e=0;e<t&&" "==o[o.length-1-e];e++)a--;l=a}else l=(0,n.zK)(c.text,a-c.from,e,e)+c.from,l==a&&c.number!=(e?h.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(c.text.slice(l-c.from,a-c.from))&&(l=(0,n.zK)(c.text,l-c.from,!1,!1)+c.from);return l})),kt=t=>xt(t,!1,!0),St=t=>xt(t,!0,!1),Ct=(t,e)=>bt(t,(i=>{let s=i.head,{state:r}=t,o=r.doc.lineAt(s),l=r.charCategorizer(s);for(let t=null;;){if(s==(e?o.to:o.from)){s==i.head&&o.number!=(e?r.doc.lines:1)&&(s+=e?1:-1);break}let a=(0,n.zK)(o.text,s-o.from,e)+o.from,h=o.text.slice(Math.min(s,a)-o.from,Math.max(s,a)-o.from),c=l(h);if(null!=t&&c!=t)break;" "==h&&s==i.head||(t=c),s=a}return s})),At=t=>Ct(t,!1);function Mt(t){let e=[],i=-1;for(let s of t.selection.ranges){let n=t.doc.lineAt(s.from),r=t.doc.lineAt(s.to);if(s.empty||s.to!=r.from||(r=t.doc.lineAt(s.to-1)),i>=n.number){let t=e[e.length-1];t.to=r.to,t.ranges.push(s)}else e.push({from:n.from,to:r.to,ranges:[s]});i=r.number+1}return e}function Ot(t,e,i){if(t.readOnly)return!1;let s=[],r=[];for(let e of Mt(t)){if(i?e.to==t.doc.length:0==e.from)continue;let o=t.doc.lineAt(i?e.to+1:e.from-1),l=o.length+1;if(i){s.push({from:e.to,to:o.to},{from:e.from,insert:o.text+t.lineBreak});for(let i of e.ranges)r.push(n.OF.range(Math.min(t.doc.length,i.anchor+l),Math.min(t.doc.length,i.head+l)))}else{s.push({from:o.from,to:e.from},{from:e.to,insert:t.lineBreak+o.text});for(let t of e.ranges)r.push(n.OF.range(t.anchor-l,t.head-l))}}return!!s.length&&(e(t.update({changes:s,scrollIntoView:!0,selection:n.OF.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0)}function Tt(t,e,i){if(t.readOnly)return!1;let s=[];for(let e of Mt(t))i?s.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):s.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});let n=t.changes(s);return e(t.update({changes:n,selection:t.selection.map(n,i?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Dt=Rt(!1);function Rt(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let s=e.changeByRange((i=>{let{from:s,to:l}=i,a=e.doc.lineAt(s),h=!t&&s==l&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i,s=(0,r.mv)(t).resolveInner(e),n=s.childBefore(e),l=s.childAfter(e);return n&&l&&n.to<=e&&l.from>=e&&(i=n.type.prop(o.uY.closedBy))&&i.indexOf(l.name)>-1&&t.doc.lineAt(n.to).from==t.doc.lineAt(l.from).from&&!/\S/.test(t.sliceDoc(n.to,l.from))?{from:n.to,to:l.from}:null}(e,s);t&&(s=l=(l<=a.to?a:e.doc.lineAt(l)).to);let c=new r.KB(e,{simulateBreak:s,simulateDoubleBreak:!!h}),u=(0,r._v)(c,s);for(null==u&&(u=(0,n.y$)(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));l<a.to&&/\s/.test(a.text[l-a.from]);)l++;h?({from:s,to:l}=h):s>a.from&&s<a.from+100&&!/\S/.test(a.text.slice(0,s))&&(s=a.from);let f=["",(0,r.EI)(e,u)];return h&&f.push((0,r.EI)(e,c.lineIndent(a.from,-1))),{changes:{from:s,to:l,insert:n.EY.of(f)},range:n.OF.cursor(s+1+f[1].length)}}));return i(e.update(s,{scrollIntoView:!0,userEvent:"input"})),!0}}function Pt(t,e){let i=-1;return t.changeByRange((s=>{let r=[];for(let n=s.from;n<=s.to;){let o=t.doc.lineAt(n);o.number>i&&(s.empty||s.to>o.from)&&(e(o,r,s),i=o.number),n=o.to+1}let o=t.changes(r);return{changes:r,range:n.OF.range(o.mapPos(s.anchor,1),o.mapPos(s.head,1))}}))}const Et=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>H(t,(e=>U(t.state,e,!j(t)))),shift:t=>{let e=!j(t);return st(t,e,(i=>U(t.state,i,e)))}},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>H(t,(e=>U(t.state,e,j(t)))),shift:t=>{let e=j(t);return st(t,e,(i=>U(t.state,i,e)))}},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>Ot(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>Tt(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>Ot(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>Tt(t,e,!0)},{key:"Mod-Alt-ArrowUp",run:t=>wt(t,!1)},{key:"Mod-Alt-ArrowDown",run:t=>wt(t,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,s=null;return i.ranges.length>1?s=n.OF.create([i.main]):i.main.empty||(s=n.OF.create([n.OF.cursor(i.main.head)])),!!s&&(e(z(t,s)),!0)}},{key:"Mod-Enter",run:Rt(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let i=Mt(t).map((({from:e,to:i})=>n.OF.undirectionalRange(e,Math.min(i+1,t.doc.length))));return e(t.update({selection:n.OF.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let i=W(t.selection,(e=>{let i=(0,r.mv)(t),s=i.resolveStack(e.from,1);if(e.empty){let t=i.resolveStack(e.from,-1);t.node.from>=s.node.from&&t.node.to<=s.node.to&&(s=t)}for(let t=s;t;t=t.next){let{node:i}=t;if((i.from<e.from&&i.to>=e.to||i.to>e.to&&i.from<=e.from)&&t.next)return n.OF.undirectionalRange(i.from,i.to)}return e}));return!i.eq(t.selection)&&(e(z(t,i)),!0)},preventDefault:!0},{key:"Mod-[",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(Pt(t,((e,i)=>{let s=/^\s*/.exec(e.text)[0];if(!s)return;let o=(0,n.y$)(s,t.tabSize),l=0,a=(0,r.EI)(t,Math.max(0,o-(0,r.tp)(t)));for(;l<s.length&&l<a.length&&s.charCodeAt(l)==a.charCodeAt(l);)l++;i.push({from:e.from+l,to:e.from+s.length,insert:a.slice(l)})})),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(Pt(t,((e,i)=>{i.push({from:e.from,insert:t.facet(r.Xt)})})),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),s=new r.KB(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),n=Pt(t,((e,n,o)=>{let l=(0,r._v)(s,e.from);if(null==l)return;/\S/.test(e.text)||(l=0);let a=/^\s*/.exec(e.text)[0],h=(0,r.EI)(t,l);(a!=h||o.from<e.from+a.length)&&(i[e.from]=l,n.push({from:e.from,to:e.from+a.length,insert:h}))}));return n.changes.empty||e(t.update(n,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(Mt(e).map((({from:t,to:i})=>(t>0?t--:i<e.doc.length&&i++,{from:t,to:i})))),s=W(e.selection,(e=>{let i;if(t.lineWrapping){let s=t.lineBlockAt(e.head),n=t.coordsAtPos(e.head,e.assoc||1);n&&(i=s.bottom+t.documentTop-n.bottom+t.defaultLineHeight/2)}return t.moveVertically(e,!0,i)})).map(i);return t.dispatch({changes:i,selection:s,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>function(t,e,i){let s=!1,o=W(t.selection,(e=>{let o=(0,r.jU)(t,e.head,-1)||(0,r.jU)(t,e.head,1)||e.head>0&&(0,r.jU)(t,e.head-1,1)||e.head<t.doc.length&&(0,r.jU)(t,e.head+1,-1);if(!o||!o.end)return e;s=!0;let l=o.start.from==e.head?o.end.to:o.end.from;return i?n.OF.range(e.anchor,l):n.OF.cursor(l)}));return!!s&&(e(z(t,o)),!0)}(t,e,!1)},{key:"Mod-/",run:t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),s=u(t.state,i.from);return s.line?a(t):!!s.block&&c(t)}},{key:"Alt-A",mac:"Ctrl-A",run:h},{key:"Ctrl-m",mac:"Shift-Alt-m",run:t=>(t.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:q,shift:rt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>K(t,!j(t)),shift:t=>lt(t,!j(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>H(t,(e=>it(t,e,!j(t)))),shift:t=>{let e=!j(t);return st(t,e,(i=>it(t,i,e)))},preventDefault:!0},{key:"ArrowRight",run:$,shift:ot,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>K(t,j(t)),shift:t=>lt(t,j(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>H(t,(e=>it(t,e,j(t)))),shift:t=>{let e=j(t);return st(t,e,(i=>it(t,i,e)))},preventDefault:!0},{key:"ArrowUp",run:G,shift:ht,preventDefault:!0},{mac:"Cmd-ArrowUp",run:pt,shift:gt},{mac:"Ctrl-ArrowUp",run:tt,shift:ft},{key:"ArrowDown",run:X,shift:ct,preventDefault:!0},{mac:"Cmd-ArrowDown",run:mt,shift:vt},{mac:"Ctrl-ArrowDown",run:et,shift:dt},{key:"PageUp",run:tt,shift:ft},{key:"PageDown",run:et,shift:dt},{key:"Home",run:t=>H(t,(e=>it(t,e,!1))),shift:t=>st(t,!1,(e=>it(t,e,!1))),preventDefault:!0},{key:"Mod-Home",run:pt,shift:gt},{key:"End",run:t=>H(t,(e=>it(t,e,!0))),shift:t=>st(t,!0,(e=>it(t,e,!0))),preventDefault:!0},{key:"Mod-End",run:mt,shift:vt},{key:"Enter",run:Dt,shift:Dt},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:kt,shift:kt,preventDefault:!0},{key:"Delete",run:St,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:At,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>Ct(t,!0),preventDefault:!0},{mac:"Mod-Backspace",run:t=>bt(t,(e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)})),preventDefault:!0},{mac:"Mod-Delete",run:t=>bt(t,(e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)})),preventDefault:!0}].concat([{key:"Ctrl-b",run:q,shift:rt,preventDefault:!0},{key:"Ctrl-f",run:$,shift:ot},{key:"Ctrl-p",run:G,shift:ht},{key:"Ctrl-n",run:X,shift:ct},{key:"Ctrl-a",run:t=>H(t,(e=>t.moveToLineBoundary(e,!1,!1))),shift:t=>st(t,!1,(e=>n.OF.cursor(t.lineBlockAt(e.head).from)))},{key:"Ctrl-e",run:t=>H(t,(e=>t.moveToLineBoundary(e,!0,!1))),shift:t=>st(t,!0,(e=>n.OF.cursor(t.lineBlockAt(e.head).to)))},{key:"Ctrl-d",run:St},{key:"Ctrl-h",run:kt},{key:"Ctrl-k",run:t=>bt(t,(e=>{let i=t.lineBlockAt(e.head).to;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}))},{key:"Ctrl-Alt-h",run:At},{key:"Ctrl-o",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:n.EY.of(["",""])},range:n.OF.cursor(t.from)})));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange((e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let i=e.from,s=t.doc.lineAt(i),r=i==s.from?i-1:(0,n.zK)(s.text,i-s.from,!1)+s.from,o=i==s.to?i+1:(0,n.zK)(s.text,i-s.from,!0)+s.from;return{changes:{from:r,to:o,insert:t.doc.slice(i,o).append(t.doc.slice(r,i))},range:n.OF.cursor(o)}}));return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:et}].map((t=>({mac:t.key,run:t.run,shift:t.shift})))));var Bt=i(4528);class Lt{constructor(t,e,i,s){this.state=t,this.pos=e,this.explicit=i,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=(0,r.mv)(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),s=e.text.slice(i-e.from,this.pos-e.from),n=s.search(Wt(t,!1));return n<0?null:{from:i+n,to:this.pos,text:s.slice(n)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,i){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Nt(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}class It{constructor(t,e,i,s){this.completion=t,this.source=e,this.match=i,this.score=s}}function Ft(t){return t.selection.main.from}function Wt(t,e){var i;let{source:s}=t,n=e&&"^"!=s[0],r="$"!=s[s.length-1];return n||r?new RegExp(`${n?"^":""}(?:${s})${r?"$":""}`,null!==(i=t.flags)&&void 0!==i?i:t.ignoreCase?"i":""):t}const zt=n.YH.define();function Ht(t,e,i,s){let{main:r}=t.selection,o=i-r.from,l=s-r.from;return{...t.changeByRange((a=>{if(a!=r&&i!=s&&t.sliceDoc(a.from+o,a.from+l)!=t.sliceDoc(i,s))return{range:a};let h=t.toText(e);return{changes:{from:a.from+o,to:s==r.from?a.to:a.from+l,insert:h},range:n.OF.cursor(a.from+o+h.length)}})),scrollIntoView:!0,userEvent:"input.complete"}}const Vt=new WeakMap;function _t(t){if(!Array.isArray(t))return t;let e=Vt.get(t);return e||Vt.set(t,e=function(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[i,s]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),i=Object.create(null);for(let{label:s}of t){e[s[0]]=!0;for(let t=1;t<s.length;t++)i[s[t]]=!0}let s=Nt(e)+Nt(i)+"*$";return[new RegExp("^"+s),new RegExp(s)]}(e);return t=>{let n=t.matchBefore(s);return n||t.explicit?{from:n?n.from:t.pos,options:e,validFor:i}:null}}(t)),e}const jt=n.Pe.define(),qt=n.Pe.define();class $t{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=(0,n.vS)(t,e),s=(0,n.Fh)(i);this.chars.push(i);let r=t.slice(e,e+s),o=r.toUpperCase();this.folded.push((0,n.vS)(o==r?r.toLowerCase():o,0)),e+=s}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:s,precise:r,byWord:o}=this;if(1==e.length){let s=(0,n.vS)(t,0),r=(0,n.Fh)(s),o=r==t.length?0:-100;if(s==e[0]);else{if(s!=i[0])return null;o+=-200}return this.ret(o,[0,r])}let l=t.indexOf(this.pattern);if(0==l)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=e.length,h=0;if(l<0){for(let r=0,o=Math.min(t.length,200);r<o&&h<a;){let o=(0,n.vS)(t,r);o!=e[h]&&o!=i[h]||(s[h++]=r),r+=(0,n.Fh)(o)}if(h<a)return null}let c=0,u=0,f=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(t),v=!0;for(let s=0,h=Math.min(t.length,200),w=0;s<h&&u<a;){let h=(0,n.vS)(t,s);l<0&&(c<a&&h==e[c]&&(r[c++]=s),d<a&&(h==e[d]||h==i[d]?(0==d&&(p=s),m=s+1,d++):d=0));let b,y=h<255?h>=48&&h<=57||h>=97&&h<=122?2:h>=65&&h<=90?1:0:(b=(0,n.MK)(h))!=b.toLowerCase()?1:b!=b.toUpperCase()?2:0;(!s||1==y&&g||0==w&&0!=y)&&(e[u]==h||i[u]==h&&(f=!0)?o[u++]=s:o.length&&(v=!1)),w=y,s+=(0,n.Fh)(h)}return u==a&&0==o[0]&&v?this.result((f?-200:0)-100,o,t):d==a&&0==p?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):l>-1?this.ret(-700-t.length,[l,l+this.pattern.length]):d==a?this.ret(-900-t.length,[p,m]):u==a?this.result((f?-200:0)-100-700+(v?0:-1100),o,t):2==e.length?null:this.result((s[0]?-700:0)-200-1100,s,t)}result(t,e,i){let s=[],r=0;for(let t of e){let e=t+(this.astral?(0,n.Fh)((0,n.vS)(i,t)):1);r&&s[r-1]==t?s[r-1]=e:(s[r++]=t,s[r++]=e)}return this.ret(t-i.length,s)}}class Kt{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const Yt=n.sj.define({combine:t=>(0,n.QR)(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Qt,filterStrict:!1,compareCompletions:(t,e)=>(t.sortText||t.label).localeCompare(e.sortText||e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>Ut(t(i),e(i)),optionClass:(t,e)=>i=>Ut(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function Ut(t,e){return t?e?t+" "+e:t:e}function Qt(t,e,i,n,r,o){let l,a,h=t.textDirection==s.OP.RTL,c=h,u=!1,f="top",d=e.left-r.left,p=r.right-e.right,m=n.right-n.left,g=n.bottom-n.top;if(c&&d<Math.min(m,p)?c=!1:!c&&p<Math.min(m,d)&&(c=!0),m<=(c?d:p))l=Math.max(r.top,Math.min(i.top,r.bottom-g))-e.top,a=Math.min(400,c?d:p);else{u=!0,a=Math.min(400,(h?e.right:r.right-e.left)-30);let t=r.bottom-e.bottom;t>=g||t>e.top?l=i.bottom-e.top:(f="bottom",l=e.bottom-i.top)}return{style:`${f}: ${l/((e.bottom-e.top)/o.offsetHeight)}px; max-width: ${a/((e.right-e.left)/o.offsetWidth)}px`,class:"cm-completionInfo-"+(u?h?"left-narrow":"right-narrow":c?"left":"right")}}const Gt=n.Pe.define();function Xt(t,e,i){if(t<=i)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/i);return{from:t*i,to:(t+1)*i}}let s=Math.ceil((t-e)/i);return{from:t-s*i,to:t-(s-1)*i}}class Jt{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let s=t.state.field(e),{options:n,selected:r}=s.open,o=t.state.facet(Yt);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map((t=>"cm-completionIcon-"+t))),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,i,s){let n=document.createElement("span");n.className="cm-completionLabel";let r=t.displayLabel||t.label,o=0;for(let t=0;t<s.length;){let e=s[t++],i=s[t++];e>o&&n.appendChild(document.createTextNode(r.slice(o,e)));let l=n.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(r.slice(e,i))),l.className="cm-completionMatchedText",o=i}return o<r.length&&n.appendChild(document.createTextNode(r.slice(o))),n},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort(((t,e)=>t.position-e.position)).map((t=>t.render))}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Xt(n.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(i=>{let{options:s}=t.state.field(e).open;for(let e,n=i.target;n&&n!=this.dom;n=n.parentNode)if("LI"==n.nodeName&&(e=/-(\d+)$/.exec(n.id))&&+e[1]<s.length)return this.applyCompletion(t,s[+e[1]]),void i.preventDefault();if(i.target==this.list){let e=this.list.classList.contains("cm-completionListIncompleteTop")&&i.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&i.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=e&&(t.dispatch({effects:Gt.of(e)}),i.preventDefault())}})),this.dom.addEventListener("focusout",(e=>{let i=t.state.field(this.stateField,!1);i&&i.tooltip&&t.state.facet(Yt).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:qt.of(null)})})),this.showOptions(n,s.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(t){var e;let i=t.state.field(this.stateField),s=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=s){let{options:n,selected:r,disabled:o}=i.open;s.open&&s.open.options==n||(this.range=Xt(n.length,r,t.state.facet(Yt).maxRenderedOptions),this.showOptions(n,i.id)),this.updateSel(),o!=(null===(e=s.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;(e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=Xt(e.options.length,e.selected,this.view.state.facet(Yt).maxRenderedOptions),this.showOptions(e.options,t.id));let i=this.updateSelectedOption(e.selected);if(i){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:r}=n;if(!r)return;let o="string"==typeof r?document.createTextNode(r):r(n);if(!o)return;"then"in o?o.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)})).catch((t=>(0,s.c_)(this.view.state,t,"completion info"))):(this.addInfoPane(o,n),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=t.nodeType)i.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:s}=t;i.appendChild(e),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)"LI"==i.nodeName&&i.id?s==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby")):s--;return e&&function(t,e){let i=t.getBoundingClientRect(),s=e.getBoundingClientRect(),n=i.height/t.offsetHeight;s.top<i.top?t.scrollTop-=(i.top-s.top)/n:s.bottom>i.bottom&&(t.scrollTop+=(s.bottom-i.bottom)/n)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=t.getBoundingClientRect(),n=this.space;if(!n){let t=this.dom.ownerDocument.documentElement;n={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return s.top>Math.min(n.bottom,e.bottom)-10||s.bottom<Math.max(n.top,e.top)+10?null:this.view.state.facet(Yt).positionInfo(this.view,e,s,i,n,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const s=document.createElement("ul");s.id=e,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",(t=>{t.target==s&&t.preventDefault()}));let n=null;for(let r=i.from;r<i.to;r++){let{completion:o,match:l}=t[r],{section:a}=o;if(a){let t="string"==typeof a?a:a.name;t!=n&&(r>i.from||0==i.from)&&(n=t,"string"!=typeof a&&a.header?s.appendChild(a.header(a)):s.appendChild(document.createElement("completion-section")).textContent=t)}const h=s.appendChild(document.createElement("li"));h.id=e+"-"+r,h.setAttribute("role","option");let c=this.optionClass(o);c&&(h.className=c);for(let t of this.optionContent){let e=t(o,this.view.state,this.view,l);e&&h.appendChild(e)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Zt(t,e){return i=>new Jt(i,t,e)}function te(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class ee{constructor(t,e,i,s,n,r){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=s,this.selected=n,this.disabled=r}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new ee(this.options,re(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,s,n,r){if(s&&!r&&t.some((t=>t.isPending)))return s.setDisabled();let o=function(t,e){let i=[],s=null,n=null,r=t=>{i.push(t);let{section:e}=t.completion;if(e){s||(s=[]);let t="string"==typeof e?e:e.name;s.some((e=>e.name==t))||s.push("string"==typeof e?{name:t}:e)}},o=e.facet(Yt);for(let s of t)if(s.hasResult()){let t=s.result.getMatch;if(!1===s.result.filter)for(let e of s.result.options)r(new It(e,s.source,t?t(e):[],1e9-i.length));else{let i,l=e.sliceDoc(s.from,s.to),a=o.filterStrict?new Kt(l):new $t(l);for(let e of s.result.options)if(i=a.match(e.label)){let o=e.displayLabel?t?t(e,i.matched):[]:i.matched,l=i.score+(e.boost||0);if(r(new It(e,s.source,o,l)),"object"==typeof e.section&&"dynamic"===e.section.rank){let{name:t}=e.section;n||(n=Object.create(null)),n[t]=Math.max(l,n[t]||-1e9)}}}}if(s){let t=Object.create(null),e=0,r=(t,e)=>("dynamic"===t.rank&&"dynamic"===e.rank?n[e.name]-n[t.name]:0)||("number"==typeof t.rank?t.rank:1e9)-("number"==typeof e.rank?e.rank:1e9)||(t.name<e.name?-1:1);for(let i of s.sort(r))e-=1e5,t[i.name]=e;for(let e of i){let{section:i}=e.completion;i&&(e.score+=t["string"==typeof i?i:i.name])}}let l=[],a=null,h=o.compareCompletions;for(let t of i.sort(((t,e)=>e.score-t.score||h(t.completion,e.completion)))){let e=t.completion;!a||a.label!=e.label||a.detail!=e.detail||null!=a.type&&null!=e.type&&a.type!=e.type||a.apply!=e.apply||a.boost!=e.boost?l.push(t):te(t.completion)>te(a)&&(l[l.length-1]=t),a=t.completion}return l}(t,e);if(!o.length)return s&&t.some((t=>t.isPending))?s.setDisabled():null;let l=e.facet(Yt).selectOnOpen?0:-1;if(s&&s.selected!=l&&-1!=s.selected){let t=s.options[s.selected].completion;for(let e=0;e<o.length;e++)if(o[e].completion==t){l=e;break}}return new ee(o,re(i,l),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:de,above:n.aboveCursor},s?s.timestamp:Date.now(),l,!1)}map(t){return new ee(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new ee(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class ie{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new ie(oe,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(Yt),s=(i.override||e.languageDataAt("autocomplete",Ft(e)).map(_t)).map((e=>(this.active.find((t=>t.source==e))||new ae(e,this.active.some((t=>0!=t.state))?1:0)).update(t,i)));s.length==this.active.length&&s.every(((t,e)=>t==this.active[e]))&&(s=this.active);let n=this.open,r=t.effects.some((t=>t.is(ce)));n&&t.docChanged&&(n=n.map(t.changes)),t.selection||s.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!function(t,e){if(t==e)return!0;for(let i=0,s=0;;){for(;i<t.length&&!t[i].hasResult();)i++;for(;s<e.length&&!e[s].hasResult();)s++;let n=i==t.length,r=s==e.length;if(n||r)return n==r;if(t[i++].result!=e[s++].result)return!1}}(s,this.active)||r?n=ee.build(s,e,this.id,n,i,r):n&&n.disabled&&!s.some((t=>t.isPending))&&(n=null),!n&&s.every((t=>!t.isPending))&&s.some((t=>t.hasResult()))&&(s=s.map((t=>t.hasResult()?new ae(t.source,0):t)));for(let e of t.effects)e.is(Gt)&&(n=n&&n.setSelected(e.value,this.id));return s==this.active&&n==this.open?this:new ie(s,this.id,n)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?se:ne}}const se={"aria-autocomplete":"list"},ne={};function re(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const oe=[];function le(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(zt);if(i&&e.activateOnCompletion(i))return 12}let i=t.isUserEvent("input.type");return i&&e.activateOnTyping?5:i?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class ae{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let i=le(t,e),s=this;(8&i||16&i&&this.touches(t))&&(s=new ae(s.source,0)),4&i&&0==s.state&&(s=new ae(this.source,1)),s=s.updateFor(t,i);for(let e of t.effects)if(e.is(jt))s=new ae(s.source,1,e.value);else if(e.is(qt))s=new ae(s.source,0);else if(e.is(ce))for(let t of e.value)t.source==s.source&&(s=t);return s}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Ft(t.state))}}class he extends ae{constructor(t,e,i,s,n,r){super(t,3,e),this.limit=i,this.result=s,this.from=n,this.to=r}hasResult(){return!0}updateFor(t,e){var i;if(!(3&e))return this.map(t.changes);let s=this.result;s.map&&!t.changes.empty&&(s=s.map(s,t.changes));let n=t.changes.mapPos(this.from),r=t.changes.mapPos(this.to,1),o=Ft(t.state);if(o>r||!s||2&e&&(Ft(t.startState)==this.from||o<this.limit))return new ae(this.source,4&e?1:0);let l=t.changes.mapPos(this.limit);return function(t,e,i,s){if(!t)return!1;let n=e.sliceDoc(i,s);return"function"==typeof t?t(n,i,s,e):Wt(t,!0).test(n)}(s.validFor,t.state,n,r)?new he(this.source,this.explicit,l,s,n,r):s.update&&(s=s.update(s,n,r,new Lt(t.state,o,!1)))?new he(this.source,this.explicit,l,s,s.from,null!==(i=s.to)&&void 0!==i?i:Ft(t.state)):new ae(this.source,1,this.explicit)}map(t){if(t.empty)return this;let e=this.result.map?this.result.map(this.result,t):this.result;return e?new he(this.source,this.explicit,t.mapPos(this.limit),e,t.mapPos(this.from),t.mapPos(this.to,1)):new ae(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const ce=n.Pe.define({map:(t,e)=>t.map((t=>t.map(e)))}),ue=n.sU.define({create:()=>ie.start(),update:(t,e)=>t.update(e),provide:t=>[s.DK.from(t,(t=>t.tooltip)),s.Lz.contentAttributes.from(t,(t=>t.attrs))]});function fe(t,e){const i=e.completion.apply||e.completion.label;let s=t.state.field(ue).active.find((t=>t.source==e.source));return s instanceof he&&("string"==typeof i?t.dispatch({...Ht(t.state,i,s.from,s.to),annotations:zt.of(e.completion)}):i(t,e.completion,s.from,s.to),!0)}const de=Zt(ue,fe);function pe(t,e="option"){return i=>{let n=i.state.field(ue,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(Yt).interactionDelay)return!1;let r,o=1;"page"==e&&(r=(0,s.Eg)(i,n.open.tooltip))&&(o=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:l}=n.open.options,a=n.open.selected>-1?n.open.selected+o*(t?1:-1):t?0:l-1;return a<0?a="page"==e?0:l-1:a>=l&&(a="page"==e?l-1:0),i.dispatch({effects:Gt.of(a)}),!0}}const me=t=>!!t.state.field(ue,!1)&&(t.dispatch({effects:jt.of(!0)}),!0);class ge{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const ve=s.Z9.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(ue).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(ue),i=t.state.facet(Yt);if(!t.selectionSet&&!t.docChanged&&t.startState.field(ue)==e)return;let n=t.transactions.some((t=>{let e=le(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)}));for(let e=0;e<this.running.length;e++){let i=this.running[e];if(n||i.context.abortOnDocChange&&t.docChanged||i.updates.length+t.transactions.length>50&&Date.now()-i.time>1e3){for(let t of i.context.abortListeners)try{t()}catch(t){(0,s.c_)(this.view.state,t)}i.context.abortListeners=null,this.running.splice(e--,1)}else i.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(jt)))))&&(this.pendingStart=!0);let r=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>t.isPending&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),r):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(ue);for(let t of e.active)t.isPending&&!this.running.some((e=>e.active.source==t.source))&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(Yt).updateSyncTime))}startQuery(t){let{state:e}=this.view,i=Ft(e),n=new Lt(e,i,t.explicit,this.view),r=new ge(t,n);this.running.push(r),Promise.resolve(t.source(n)).then((t=>{r.context.aborted||(r.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:qt.of(null)}),(0,s.c_)(this.view.state,t)}))}scheduleAccept(){this.running.every((t=>void 0!==t.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(Yt).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(Yt),s=this.view.state.field(ue);for(let n=0;n<this.running.length;n++){let r=this.running[n];if(void 0===r.done)continue;if(this.running.splice(n--,1),r.done){let s=Ft(r.updates.length?r.updates[0].startState:this.view.state),n=Math.min(s,r.done.from+(r.active.explicit?0:1)),o=new he(r.active.source,r.active.explicit,n,r.done,r.done.from,null!==(t=r.done.to)&&void 0!==t?t:s);for(let t of r.updates)o=o.update(t,i);if(o.hasResult()){e.push(o);continue}}let o=s.active.find((t=>t.source==r.active.source));if(o&&o.isPending)if(null==r.done){let t=new ae(r.active.source,0);for(let e of r.updates)t=t.update(e,i);t.isPending||e.push(t)}else this.startQuery(o)}(e.length||s.open&&s.open.disabled)&&this.view.dispatch({effects:ce.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(ue,!1);if(e&&e.tooltip&&this.view.state.facet(Yt).closeOnBlur){let i=e.open&&(0,s.Eg)(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:qt.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:jt.of(!1)})),20),this.composing=0}}}),we="object"==typeof navigator&&/Win/.test(navigator.platform),be=n.Nb.highest(s.Lz.domEventHandlers({keydown(t,e){let i=e.state.field(ue,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||!t.key||t.key.length>1||t.ctrlKey&&(!we||!t.altKey)||t.metaKey)return!1;let s=i.open.options[i.open.selected],n=i.active.find((t=>t.source==s.source)),r=s.completion.commitCharacters||n.result.commitCharacters;return r&&r.indexOf(t.key)>-1&&fe(e,s),!1}})),ye=s.Lz.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),xe={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},ke=n.Pe.define({map(t,e){let i=e.mapPos(t,-1,n.iR.TrackAfter);return null==i?void 0:i}}),Se=new class extends n.FB{};Se.startSide=1,Se.endSide=-1;const Ce=n.sU.define({create:()=>n.om.empty,update(t,e){if(t=t.map(e.changes),e.selection){let i=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=i.from&&t<=i.to})}for(let i of e.effects)i.is(ke)&&(t=t.update({add:[Se.range(i.value,i.value+1)]}));return t}}),Ae="()[]{}<>«»»«[]{}";function Me(t){for(let e=0;e<16;e+=2)if(Ae.charCodeAt(e)==t)return Ae.charAt(e+1);return(0,n.MK)(t<128?t:t+1)}function Oe(t,e){return t.languageDataAt("closeBrackets",e)[0]||xe}const Te="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),De=s.Lz.inputHandler.of(((t,e,i,s)=>{if((Te?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let r=t.state.selection.main;if(s.length>2||2==s.length&&1==(0,n.Fh)((0,n.vS)(s,0))||e!=r.from||i!=r.to)return!1;let o=function(t,e){let i=Oe(t,t.selection.main.head),s=i.brackets||xe.brackets;for(let r of s){let o=Me((0,n.vS)(r,0));if(e==r)return o==r?Ne(t,r,s.indexOf(r+r+r)>-1,i):Be(t,r,o,i.before||xe.before);if(e==o&&Pe(t,t.selection.main.from))return Le(t,0,o)}return null}(t.state,s);return!!o&&(t.dispatch(o),!0)})),Re=[{key:"Backspace",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Oe(t,t.selection.main.head).brackets||xe.brackets,s=null,r=t.changeByRange((e=>{if(e.empty){let s=function(t,e){let i=t.sliceString(e-2,e);return(0,n.Fh)((0,n.vS)(i,0))==i.length?i:i.slice(1)}(t.doc,e.head);for(let r of i)if(r==s&&Ee(t.doc,e.head)==Me((0,n.vS)(r,0)))return{changes:{from:e.head-r.length,to:e.head+r.length},range:n.OF.cursor(e.head-r.length)}}return{range:s=e}}));return s||e(t.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s}}];function Pe(t,e){let i=!1;return t.field(Ce).between(0,t.doc.length,(t=>{t==e&&(i=!0)})),i}function Ee(t,e){let i=t.sliceString(e,e+2);return i.slice(0,(0,n.Fh)((0,n.vS)(i,0)))}function Be(t,e,i,s){let r=null,o=t.changeByRange((o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:i,from:o.to}],effects:ke.of(o.to+e.length),range:n.OF.range(o.anchor+e.length,o.head+e.length)};let l=Ee(t.doc,o.head);return!l||/\s/.test(l)||s.indexOf(l)>-1?{changes:{insert:e+i,from:o.head},effects:ke.of(o.head+e.length),range:n.OF.cursor(o.head+e.length)}:{range:r=o}}));return r?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Le(t,e,i){let s=null,r=t.changeByRange((e=>e.empty&&Ee(t.doc,e.head)==i?{changes:{from:e.head,to:e.head+i.length,insert:i},range:n.OF.cursor(e.head+i.length)}:s={range:e}));return s?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Ne(t,e,i,s){let o=s.stringPrefixes||xe.stringPrefixes,l=null,a=t.changeByRange((s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:e,from:s.to}],effects:ke.of(s.to+e.length),range:n.OF.range(s.anchor+e.length,s.head+e.length)};let a,h=s.head,c=Ee(t.doc,h);if(c==e){if(Ie(t,h))return{changes:{insert:e+e,from:h},effects:ke.of(h+e.length),range:n.OF.cursor(h+e.length)};if(Pe(t,h)){let s=i&&t.sliceDoc(h,h+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:h,to:h+s.length,insert:s},range:n.OF.cursor(h+s.length)}}}else{if(i&&t.sliceDoc(h-2*e.length,h)==e+e&&(a=Fe(t,h-2*e.length,o))>-1&&Ie(t,a))return{changes:{insert:e+e+e+e,from:h},effects:ke.of(h+e.length),range:n.OF.cursor(h+e.length)};if(t.charCategorizer(h)(c)!=n.Je.Word&&Fe(t,h,o)>-1&&!function(t,e,i,s){let n=(0,r.mv)(t).resolveInner(e,-1),o=s.reduce(((t,e)=>Math.max(t,e.length)),0);for(let r=0;r<5;r++){let r=t.sliceDoc(n.from,Math.min(n.to,n.from+i.length+o)),l=r.indexOf(i);if(!l||l>-1&&s.indexOf(r.slice(0,l))>-1){let e=n.firstChild;for(;e&&e.from==n.from&&e.to-e.from>i.length+l;){if(t.sliceDoc(e.to-i.length,e.to)==i)return!1;e=e.firstChild}return!0}let a=n.to==e&&n.parent;if(!a)break;n=a}return!1}(t,h,e,o))return{changes:{insert:e+e,from:h},effects:ke.of(h+e.length),range:n.OF.cursor(h+e.length)}}return{range:l=s}}));return l?null:t.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Ie(t,e){let i=(0,r.mv)(t).resolveInner(e+1);return i.parent&&i.from==e}function Fe(t,e,i){let s=t.charCategorizer(e);if(s(t.sliceDoc(e-1,e))!=n.Je.Word)return e;for(let r of i){let i=e-r.length;if(t.sliceDoc(i,e)==r&&s(t.sliceDoc(i-1,i))!=n.Je.Word)return i}return-1}function We(t={}){return[be,ue,Yt.of(t),ve,He,ye]}const ze=[{key:"Ctrl-Space",run:me},{mac:"Alt-`",run:me},{mac:"Alt-i",run:me},{key:"Escape",run:t=>{let e=t.state.field(ue,!1);return!(!e||!e.active.some((t=>0!=t.state))||(t.dispatch({effects:qt.of(null)}),0))}},{key:"ArrowDown",run:pe(!0)},{key:"ArrowUp",run:pe(!1)},{key:"PageDown",run:pe(!0,"page")},{key:"PageUp",run:pe(!1,"page")},{key:"Enter",run:t=>{let e=t.state.field(ue,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(Yt).interactionDelay)&&fe(t,e.open.options[e.open.selected])}}],He=n.Nb.highest(s.w4.computeN([Yt],(t=>t.facet(Yt).defaultKeymap?[ze]:[])));var Ve=i(1419);const _e=(()=>[(0,s.$K)(),(0,s.Wu)(),(0,s.N$)(),y(),(0,r.Lv)(),(0,s.VH)(),(0,s.A)(),n.$t.allowMultipleSelections.of(!0),(0,r.WD)(),(0,r.y9)(r.Zt,{fallback:!0}),(0,r.SG)(),[De,Ce],We(),(0,s.D4)(),(0,s.HJ)(),(0,s.dz)(),(0,Bt.gN)(),s.w4.of([...Re,...Et,...Bt.Eo,...F,...r.f7,...ze,...Ve.$w])])()},6898:(t,e,i)=>{i.d(e,{NZ:()=>P,OP:()=>ut,Lz:()=>xs,wJ:()=>er,Z9:()=>Qt,xO:()=>D,ab:()=>Vn,HJ:()=>kn,VH:()=>$s,A:()=>en,rC:()=>Xn,ld:()=>$n,Eg:()=>_n,cU:()=>or,dz:()=>pn,Wu:()=>Ar,N$:()=>cn,Ux:()=>Hn,w4:()=>Ds,$K:()=>xr,c_:()=>$t,D4:()=>bn,TS:()=>Es,ui:()=>Gn,S7:()=>Qn,DK:()=>Bn});for(var s=i(1638),n=i(7417),r={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},o={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},l="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),a="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),h=0;h<10;h++)r[48+h]=r[96+h]=String(h);for(h=1;h<=24;h++)r[h+111]="F"+h;for(h=65;h<=90;h++)r[h]=String.fromCharCode(h+32),o[h]=String.fromCharCode(h);for(var c in r)o.hasOwnProperty(c)||(o[c]=r[c]);var u=i(3748);let f="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},d="undefined"!=typeof document?document:{documentElement:{style:{}}};const p=/Edge\/(\d+)/.exec(f.userAgent),m=/MSIE \d/.test(f.userAgent),g=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(f.userAgent),v=!!(m||g||p),w=!v&&/gecko\/(\d+)/i.test(f.userAgent),b=!v&&/Chrome\/(\d+)/.exec(f.userAgent),y="webkitFontSmoothing"in d.documentElement.style,x=!v&&/Apple Computer/.test(f.vendor),k=x&&(/Mobile\/\w+/.test(f.userAgent)||f.maxTouchPoints>2);var S={mac:k||/Mac/.test(f.platform),windows:/Win/.test(f.platform),linux:/Linux|X11/.test(f.platform),ie:v,ie_version:m?d.documentMode||6:g?+g[1]:p?+p[1]:0,gecko:w,gecko_version:w?+(/Firefox\/(\d+)/.exec(f.userAgent)||[0,0])[1]:0,chrome:!!b,chrome_version:b?+b[1]:0,ios:k,android:/Android\b/.test(f.userAgent),webkit:y,webkit_version:y?+(/\bAppleWebKit\/(\d+)/.exec(f.userAgent)||[0,0])[1]:0,safari:x,safari_version:x?+(/\bVersion\/(\d+(\.\d+)?)/.exec(f.userAgent)||[0,0])[1]:0,tabSize:null!=d.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function C(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}const A=Object.create(null);function M(t,e,i){if(t==e)return!0;t||(t=A),e||(e=A);let s=Object.keys(t),n=Object.keys(e);if(s.length-0!=n.length-0)return!1;for(let r of s)if(r!=i&&(-1==n.indexOf(r)||t[r]!==e[r]))return!1;return!0}function O(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}function T(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let s=t.attributes[i];e[s.name]=s.value}return e}class D{eq(t){return!1}updateDOM(t,e,i){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 R=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(R||(R={}));class P extends s.FB{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 L(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,s=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:n,end:r}=N(t,s);e=(n?s?-3e8:-1:5e8)-1,i=1+(r?s?2e8:1:-6e8)}return new L(t,e,i,s,t.widget||null,!0)}static line(t){return new B(t)}static set(t,e=!1){return s.om.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}P.none=s.om.empty;class E extends P{constructor(t){let{start:e,end:i}=N(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?C(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||A}eq(t){return this==t||t instanceof E&&this.tagName==t.tagName&&M(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}E.prototype.point=!1;class B extends P{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof B&&this.spec.class==t.spec.class&&M(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}B.prototype.mapMode=s.iR.TrackBefore,B.prototype.point=!0;class L extends P{constructor(t,e,i,n,r,o){super(e,i,r,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?s.iR.TrackBefore:s.iR.TrackAfter:s.iR.TrackDel}get type(){return this.startSide!=this.endSide?R.WidgetRange:this.startSide<=0?R.WidgetBefore:R.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof L&&((e=this.widget)==(i=t.widget)||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function N(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 I(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)}L.prototype.point=!0;class F extends s.FB{constructor(t,e,i){super(),this.tagName=t,this.attributes=e,this.rank=i}eq(t){return t==this||t instanceof F&&this.tagName==t.tagName&&M(this.attributes,t.attributes)}static create(t){return new F(t.tagName,t.attributes||A,null==t.rank?50:Math.max(0,Math.min(t.rank,100)))}static set(t,e=!1){return s.om.of(t,e)}}F.prototype.startSide=F.prototype.endSide=-1;const W=t=>1==t.nodeType,z=t=>3==t.nodeType;function H(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function V(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function _(t,e){if(!e.anchorNode)return!1;try{return V(t,e.anchorNode)}catch(t){return!1}}function j(t){return z(t)?rt(t,0,t.nodeValue.length).getClientRects():W(t)?t.getClientRects():[]}function q(t,e,i,s){return!!i&&(Y(t,e,i,s,-1)||Y(t,e,i,s,1))}function $(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function K(t){return W(t)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function Y(t,e,i,s,n){for(;;){if(t==i&&e==s)return!0;if(e==(n<0?0:U(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||!W(i))return!1;e=$(t)+(n<0?0:1),t=i}else{if(!W(t))return!1;if(t=t.childNodes[e+(n<0?-1:0)],W(t)&&("IMG"==t.nodeName||"BR"==t.nodeName||"false"==t.contentEditable))return!1;e=n<0?U(t):0}}}function U(t){return z(t)?t.nodeValue.length:t.childNodes.length}function Q(t,e){let{left:i,right:s}=t;if(i==s)return t;let n=e?i:s;return{left:n,right:n,top:t.top,bottom:t.bottom}}function G(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function X(t,e){let i=e.width/t.offsetWidth,s=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(s>.995&&s<1.005||!isFinite(s)||Math.abs(e.height-t.offsetHeight)<1)&&(s=1),{scaleX:i,scaleY:s}}function J(t,e=!0){let i=t.ownerDocument,s=null,n=null;for(let r=t.parentNode;r&&r!=i.body&&(e&&!s||!n);)if(W(r))!n&&r.scrollHeight>r.clientHeight&&/scroll|auto/.test(getComputedStyle(r).overflowY)&&(n=r),e&&!s&&r.scrollWidth>r.clientWidth&&/scroll|auto/.test(getComputedStyle(r).overflowX)&&(s=r),r=r.assignedSlot||r.parentNode;else{if(11!=r.nodeType)break;r=r.host}return{x:s,y:n}}class Z{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?U(e):0),i,Math.min(t.focusOffset,i?U(i):0))}set(t,e,i,s){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=s}}function tt(t){let e=[];for(let i=t;i;i=11==i.nodeType?i.host:i.parentNode)W(i)&&e.push({node:i,left:i.scrollLeft,top:i.scrollTop});return e}function et(t,e=!0){for(let{node:i,left:s,top:n}of t)e&&i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}let it,st=null;function nt(t){if(t.setActive)return t.setActive();if(st)return t.focus(st);let e=tt(t);t.focus(null==st?{get preventScroll(){return st={preventScroll:!0},!0}}:void 0),st||(st=!1,et(e))}function rt(t,e,i=e){let s=it||(it=document.createRange());return s.setEnd(t,i),s.setStart(t,e),s}function ot(t,e,i,s){let n={key:e,code:e,keyCode:i,which:i,cancelable:!0};s&&({altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,metaKey:n.metaKey}=s);let r=new KeyboardEvent("keydown",n);r.synthetic=!0,t.dispatchEvent(r);let o=new KeyboardEvent("keyup",n);return o.synthetic=!0,t.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function lt(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function at(t,e){for(let i=t,s=e;;){if(z(i)&&s>0)return{node:i,offset:s};if(W(i)&&s>0){if("false"==i.contentEditable)return null;i=i.childNodes[s-1],s=U(i)}else{if(!i.parentNode||K(i))return null;s=$(i),i=i.parentNode}}}function ht(t,e){for(let i=t,s=e;;){if(z(i)&&s<i.nodeValue.length)return{node:i,offset:s};if(W(i)&&s<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[s],s=0}else{if(!i.parentNode||K(i))return null;s=$(i)+1,i=i.parentNode}}}S.safari&&S.safari_version>=26&&(st=!1);class ct{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new ct(t.parentNode,$(t),e)}static after(t,e){return new ct(t.parentNode,$(t)+1,e)}}var ut=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(ut||(ut={}));const ft=ut.LTR,dt=ut.RTL;function pt(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const mt=pt("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),gt=pt("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),vt=Object.create(null),wt=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);vt[e]=i,vt[i]=-e}function bt(t){return t<=247?mt[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?gt[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const yt=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class xt{get dir(){return this.level%2?dt:ft}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,s){let n=-1;for(let r=0;r<t.length;r++){let o=t[r];if(o.from<=e&&o.to>=e){if(o.level==i)return r;(n<0||(0!=s?s<0?o.from<e:o.to>e:t[n].level>o.level))&&(n=r)}}if(n<0)throw new RangeError("Index out of range");return n}}function kt(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let s=t[i],n=e[i];if(s.from!=n.from||s.to!=n.to||s.direction!=n.direction||!kt(s.inner,n.inner))return!1}return!0}const St=[];function Ct(t,e,i,s,n,r,o){let l=s%2?2:1;if(s%2==n%2)for(let a=e,h=0;a<i;){let e=!0,c=!1;if(h==r.length||a<r[h].from){let t=St[a];t!=l&&(e=!1,c=16==t)}let u=e||1!=l?null:[],f=e?s:s+1,d=a;t:for(;;)if(h<r.length&&d==r[h].from){if(c)break t;let p=r[h];if(!e)for(let t=p.to,e=h+1;;){if(t==i)break t;if(!(e<r.length&&r[e].from==t)){if(St[t]==l)break t;break}t=r[e++].to}h++,u?u.push(p):(p.from>a&&o.push(new xt(a,p.from,f)),At(t,p.direction==ft!=!(f%2)?s+1:s,n,p.inner,p.from,p.to,o),a=p.to),d=p.to}else{if(d==i||(e?St[d]!=l:St[d]==l))break;d++}u?Ct(t,a,d,s+1,n,u,o):a<d&&o.push(new xt(a,d,f)),a=d}else for(let a=i,h=r.length;a>e;){let i=!0,c=!1;if(!h||a>r[h-1].to){let t=St[a-1];t!=l&&(i=!1,c=16==t)}let u=i||1!=l?null:[],f=i?s:s+1,d=a;t:for(;;)if(h&&d==r[h-1].to){if(c)break t;let p=r[--h];if(!i)for(let t=p.from,i=h;;){if(t==e)break t;if(!i||r[i-1].to!=t){if(St[t-1]==l)break t;break}t=r[--i].from}u?u.push(p):(p.to<a&&o.push(new xt(p.to,a,f)),At(t,p.direction==ft!=!(f%2)?s+1:s,n,p.inner,p.from,p.to,o),a=p.from),d=p.from}else{if(d==e||(i?St[d-1]!=l:St[d-1]==l))break;d--}u?Ct(t,d,a,s+1,n,u,o):d<a&&o.push(new xt(d,a,f)),a=d}}function At(t,e,i,s,n,r,o){let l=e%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,l=r<s.length?s[r].from:i,a=r?256:n;for(let e=o,i=a,s=a;e<l;e++){let n=bt(t.charCodeAt(e));512==n?n=i:8==n&&4==s&&(n=16),St[e]=4==n?2:n,7&n&&(s=n),i=n}for(let t=o,e=a,s=a;t<l;t++){let n=St[t];if(128==n)t<l-1&&e==St[t+1]&&24&e?n=St[t]=e:St[t]=256;else if(64==n){let n=t+1;for(;n<l&&64==St[n];)n++;let r=t&&8==e||n<i&&8==St[n]?1==s?1:8:256;for(let e=t;e<n;e++)St[e]=r;t=n-1}else 8==n&&1==s&&(St[t]=1);e=n,7&n&&(s=n)}}}(t,n,r,s,l),function(t,e,i,s,n){let r=1==n?2:1;for(let o=0,l=0,a=0;o<=s.length;o++){let h=o?s[o-1].to:e,c=o<s.length?s[o].from:i;for(let e,i,s,o=h;o<c;o++)if(i=vt[e=t.charCodeAt(o)])if(i<0){for(let t=l-3;t>=0;t-=3)if(wt[t+1]==-i){let e=wt[t+2],i=2&e?n:4&e?1&e?r:n:0;i&&(St[o]=St[wt[t]]=i),l=t;break}}else{if(189==wt.length)break;wt[l++]=o,wt[l++]=e,wt[l++]=a}else if(2==(s=St[o])||1==s){let t=s==n;a=t?0:1;for(let e=l-3;e>=0;e-=3){let i=wt[e+2];if(2&i)break;if(t)wt[e+2]|=2;else{if(4&i)break;wt[e+2]|=4}}}}}(t,n,r,s,l),function(t,e,i,s){for(let n=0,r=s;n<=i.length;n++){let o=n?i[n-1].to:t,l=n<i.length?i[n].from:e;for(let a=o;a<l;){let o=St[a];if(256==o){let o=a+1;for(;;)if(o==l){if(n==i.length)break;o=i[n++].to,l=n<i.length?i[n].from:e}else{if(256!=St[o])break;o++}let h=1==r,c=h==(1==(o<e?St[o]:s))?h?1:2:s;for(let e=o,s=n,r=s?i[s-1].to:t;e>a;)e==r&&(e=i[--s].from,r=s?i[s-1].to:t),St[--e]=c;a=o}else r=o,a++}}}(n,r,s,l),Ct(t,n,r,e,i,s,o)}function Mt(t){return[new xt(0,t,0)]}let Ot="";function Tt(t,e,i,n,r){var o;if(!t.length)return null;let l,a=n.head-t.from;if(n.head==t.from&&n.assoc<0){if(!r)return null;a=e[l=0].side(!1,i)}else if(n.head==t.to&&n.assoc>0){if(r)return null;a=e[l=e.length-1].side(!0,i)}else l=xt.find(e,a,null!==(o=n.bidiLevel)&&void 0!==o?o:-1,n.assoc);let h=e[l],c=h.side(r,i);if(a==c){let t=l+=r?1:-1;if(t<0||t>=e.length)return null;h=e[l=t],a=h.side(!r,i),c=h.side(r,i)}let u=(0,s.zK)(t.text,a,h.forward(r,i));(u<h.from||u>h.to)&&(u=c),Ot=t.text.slice(Math.min(a,u),Math.max(a,u));let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];if(u==c){if(!f)return r?s.OF.cursor(t.to,1):s.OF.cursor(t.from,-1);if(f.level+(r?0:1)<h.level)return s.OF.cursor(f.side(!r,i)+t.from,f.forward(r,i)?1:-1,f.level)}return s.OF.cursor(u+t.from,h.forward(r,i)?-1:1,h.level)}function Dt(t,e,i){for(let s=e;s<i;s++){let e=bt(t.charCodeAt(s));if(1==e)return ft;if(2==e||4==e)return dt}}const Rt=s.sj.define(),Pt=s.sj.define(),Et=s.sj.define(),Bt=s.sj.define(),Lt=s.sj.define(),Nt=s.sj.define(),It=s.sj.define(),Ft=s.sj.define(),Wt=s.sj.define(),zt=s.sj.define({combine:t=>t.some((t=>t))}),Ht=s.sj.define({combine:t=>t.some((t=>t))}),Vt=s.sj.define();class _t{constructor(t,e,i,s,n,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 _t(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 _t(s.OF.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const jt=s.Pe.define({map:(t,e)=>t.map(e)}),qt=s.Pe.define();function $t(t,e,i){let s=t.facet(Bt);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))}const Kt=s.sj.define({combine:t=>!t.length||t[0]});let Yt=0;const Ut=s.sj.define({combine:t=>t.filter(((e,i)=>{for(let s=0;s<i;s++)if(t[s].plugin==e.plugin)return!1;return!0}))});class Qt{constructor(t,e,i,s,n){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=s,this.baseExtensions=n(this),this.extension=this.baseExtensions.concat(Ut.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(Ut.of({plugin:this,arg:t}))}static define(t,e){const{eventHandlers:i,eventObservers:s,provide:n,decorations:r}=e||{};return new Qt(Yt++,t,i,s,(t=>{let e=[];return r&&e.push(Zt.of((e=>{let i=e.plugin(t);return i?r(i):P.none}))),n&&e.push(n(t)),e}))}static fromClass(t,e){return Qt.define(((e,i)=>new t(e,i)),e)}}class Gt{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if($t(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.plugin.create(t,this.spec.arg)}catch(e){$t(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){$t(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Xt=s.sj.define(),Jt=s.sj.define(),Zt=s.sj.define(),te=s.sj.define(),ee=s.sj.define(),ie=s.sj.define(),se=s.sj.define();function ne(t,e){let i=t.state.facet(se);if(!i.length)return i;let n=i.map((e=>e instanceof Function?e(t):e)),r=[];return s.om.spans(n,e.from,e.to,{point(){},span(t,i,s,n){let o=t-e.from,l=i-e.from,a=r;for(let t=s.length-1;t>=0;t--,n--){let e,i=s[t].spec.bidiIsolate;if(n>0&&a.length&&(e=a[a.length-1]).to==o&&e.direction==i)e.to=l,a=e.inner;else{let t={from:o,to:l,direction:i,inner:[]};a.push(t),a=t.inner}}}}),re(e.text,r)}function re(t,e){for(let i of e){if(null==i.direction){for(let e=i.from,s=0;e<i.to;s++){let n=s<i.inner.length?i.inner[s]:null,r=Dt(t,e,n?n.from:i.to);if(r){i.direction=r;break}if(!n)break;e=n.to}null==i.direction&&(i.direction=ut.LTR)}re(t,i.inner)}return e}const oe=s.sj.define();function le(t){let e=0,i=0,s=0,n=0;for(let r of t.state.facet(oe)){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}}const ae=s.sj.define();class he{constructor(t,e,i,s){this.fromA=t,this.toA=e,this.fromB=i,this.toB=s}join(t){return new he(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.toA<i.fromA)break;i=i.join(s),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let s=0,n=0,r=0;;){let o=s<t.length?t[s].fromB:1e9,l=n<e.length?e[n]:1e9,a=Math.min(o,l);if(1e9==a)break;let h=a+r,c=a,u=h;for(;;)if(n<e.length&&e[n]<=c){let i=e[n+1];n+=2,c=Math.max(c,i);for(let e=s;e<t.length&&t[e].fromB<=c;e++)r=t[e].toA-t[e].toB;u=Math.max(u,i+r)}else{if(!(s<t.length&&t[s].fromB<=c))break;{let e=t[s++];c=Math.max(c,e.toB),u=Math.max(u,e.toA),r=e.toA-e.toB}}i.push(new he(h,u,a,c))}return i}}class ce{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=s.VR.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new he(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new ce(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&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}}const ue=[];class fe{constructor(t,e,i=0){this.dom=t,this.length=e,this.flags=i,this.parent=null,t.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return ue}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(t){if(this.flags|=2,4&this.flags){this.flags&=-5;let t=this.domAttrs;t&&function(t,e){for(let i=t.attributes.length-1;i>=0;i--){let s=t.attributes[i].name;null==e[s]&&t.removeAttribute(s)}for(let i in e){let s=e[i];"style"==i?t.style.cssText=s:t.getAttribute(i)!=s&&t.setAttribute(i,s)}}(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(t){this.dom=t,t.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t,e=this.posAtStart){let i=e;for(let e of this.children){if(e==t)return i;i+=e.length+e.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}covers(t){return!0}coordsIn(t,e,i){return null}domPosFor(t,e){let i=$(this.dom),s=this.length?t>0:e>0;return new ct(this.parent.dom,i+(s?1:0),0==t||t==this.length)}markDirty(t){this.flags&=-3,t&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let t=this;t;t=t.parent)if(t instanceof me)return t;return null}static get(t){return t.cmTile}}class de extends fe{constructor(t){super(t,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(t){this.children.push(t),t.parent=this}sync(t){if(2&this.flags)return;super.sync(t);let e,i=this.dom,s=null,n=(null==t?void 0:t.node)==i?t:null,r=0;for(let o of this.children){if(o.sync(t),r+=o.length+o.breakAfter,e=s?s.nextSibling:i.firstChild,n&&e!=o.dom&&(n.written=!0),o.dom.parentNode==i)for(;e&&e!=o.dom;)e=pe(e);else i.insertBefore(o.dom,e);s=o.dom}for(e=s?s.nextSibling:i.firstChild,n&&e&&(n.written=!0);e;)e=pe(e);this.length=r}}function pe(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class me extends de{constructor(t,e){super(e),this.view=t}owns(t){for(;t;t=t.parent)if(t==this)return!0;return!1}isBlock(){return!0}nearest(t){for(;;){if(!t)return null;let e=fe.get(t);if(e&&this.owns(e))return e;t=t.parentNode}}blockTiles(t){for(let e=[],i=this,s=0,n=0;;)if(s==i.children.length){if(!e.length)return;i=i.parent,i.breakAfter&&n++,s=e.pop()}else{let r=i.children[s++];if(r instanceof ge)e.push(s),i=r,s=0;else{let e=n+r.length,i=t(r,n);if(void 0!==i)return i;n=e+r.breakAfter}}}resolveBlock(t,e){let i,s,n=-1,r=-1;if(this.blockTiles(((o,l)=>{let a=l+o.length;if(t>=l&&t<=a){if(o.isWidget()&&e>=-1&&e<=1){if(32&o.flags)return!0;16&o.flags&&(i=void 0)}(l<t||t==a&&(e<-1?o.length:o.covers(1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,n=t-l),(a>t||t==l&&(e>1?o.length:o.covers(-1)))&&(!s||!o.isWidget()&&s.isWidget())&&(s=o,r=t-l)}})),!i&&!s)throw new Error("No tile at position "+t);return i&&e<0||!s?{tile:i,offset:n}:{tile:s,offset:r}}}class ge extends de{constructor(t,e){super(t),this.wrapper=e}isBlock(){return!0}covers(t){return!!this.children.length&&(t<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(t,e){let i=new ge(e||document.createElement(t.tagName),t);return e||(i.flags|=4),i}}class ve extends de{constructor(t,e){super(t),this.attrs=e}isLine(){return!0}static start(t,e,i){let s=new ve(e||document.createElement("div"),t);return e&&i||(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(t,e,i=!1){let s=null,n=-1,r=null,o=-1;!function t(l,a){for(let h=0,c=0;h<l.children.length&&c<=a;h++){let u=l.children[h],f=c+u.length;f>=a&&(u.isComposite()?t(u,a-c):(!r||i&&r.isHidden&&(e>0&&!(32&r.flags)||i&&we(r,u)))&&(f>a||32&u.flags&&e<=1)?(r=u,o=a-c):(c<a||16&u.flags&&(!i||!u.isHidden)&&e>=-1)&&(s=u,n=a-c)),c=f}}(this,t);let l=(e<0?s:r)||s||r;return l?{tile:l,offset:l==s?n:o}:null}coordsIn(t,e,i){let s=this.resolveInline(t,e,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),e,i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=j(e);return i[i.length-1]||null}(this)}domIn(t,e){let i=this.resolveInline(t,e);if(i){let{tile:t,offset:s}=i;if(this.dom.contains(t.dom))return t.isText()?new ct(t.dom,Math.min(t.dom.nodeValue.length,s)):t.domPosFor(s,16&t.flags?1:32&t.flags?-1:e);let n=i.tile.parent,r=!1;for(let t of n.children){if(r)return new ct(t.dom,0);t==i.tile&&(r=!0)}}return new ct(this.dom,0)}}function we(t,e){let i=t.coordsIn(0,1),s=e.coordsIn(0,1);return i&&s&&s.top<i.bottom}class be extends de{constructor(t,e){super(t),this.mark=e}get domAttrs(){return this.mark.attrs}static of(t,e){let i=new be(e||document.createElement(t.tagName),t);return e||(i.flags|=4),i}}class ye extends fe{constructor(t,e){super(t,e.length),this.text=e}sync(t){2&this.flags||(super.sync(t),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(t,e,i){let s=this.dom.nodeValue.length;t>s&&(t=s);let n=t,r=t,o=0;0==t&&e<0||t==s&&e>=0?S.chrome||S.gecko||(t?(n--,o=1):r<s&&(r++,o=-1)):e<0?n--:r<s&&r++;let l=rt(this.dom,n,r).getClientRects();if(!l.length)return null;let a=l[(o?o<0:e>=0)?0:l.length-1];return S.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(l,(t=>t.width))||a),null==i?a:Q(a,(o?o>0:e<0)==i)}static of(t,e){let i=new ye(e||document.createTextNode(t),t);return e||(i.flags|=2),i}}class xe extends fe{constructor(t,e,i,s){super(t,e,s),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(t){return!(48&this.flags)&&(this.flags&(t<0?64:128))>0}coordsIn(t,e){return this.coordsInWidget(t,e,!1)}coordsInWidget(t,e,i){let s=this.widget.coordsAt(this.dom,t,e);if(s)return s;if(i)return Q(this.dom.getBoundingClientRect(),this.length?0==t:e<=0);{let e=this.dom.getClientRects(),i=null;if(!e.length)return null;let s=!!(16&this.flags)||!(32&this.flags)&&t>0;for(let n=s?e.length-1:0;i=e[n],!(t>0?0==n:n==e.length-1||i.top<i.bottom);n+=s?-1:1);return Q(i,!s)}}get overrideDOMText(){if(!this.length)return s.EY.empty;let{root:t}=this;if(!t)return s.EY.empty;let e=this.posAtStart;return t.view.state.doc.slice(e,e+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,e,i,s,n){return n||(n=t.toDOM(e),t.editable||(n.contentEditable="false")),new xe(n,i,t,s)}}class ke extends fe{constructor(t){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),super(e,0,t)}get isHidden(){return!0}get overrideDOMText(){return s.EY.empty}coordsIn(t,e,i){let s=this.dom.getBoundingClientRect();return null==i?s:Q(s,e>0==i)}}class Se{constructor(t){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=t}advance(t,e,i){let{tile:s,index:n,beforeBreak:r,parents:o}=this;for(;t||e>0;)if(s.isComposite())if(r){if(!t)break;i&&i.break(),t--,r=!1}else if(n==s.children.length){if(!t&&!o.length)break;i&&i.leave(s),r=!!s.breakAfter,({tile:s,index:n}=o.pop()),n++}else{let l=s.children[n],a=l.breakAfter;!(e>0?l.length<=t:l.length<t)||i&&!1===i.skip(l,0,l.length)&&l.isComposite?(o.push({tile:s,index:n}),s=l,n=0,i&&l.isComposite()&&i.enter(l)):(r=!!a,n++,t-=l.length)}else{let e=s.length;if(n<e&&t){let r=Math.min(t,e-n);i&&i.skip(s,n,n+r),t-=r,n+=r}if(n==e)r=!!s.breakAfter,({tile:s,index:n}=o.pop()),n++;else if(!t)break}return this.tile=s,this.index=n,this.beforeBreak=r,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Ce{constructor(t,e,i,s){this.from=t,this.to=e,this.wrapper=i,this.rank=s}}class Ae{constructor(t,e,i){this.cache=t,this.root=e,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(t,e,i,s){var n;this.flushBuffer();let r=this.ensureMarks(e,i),o=r.lastChild;o&&o.isText()&&!(8&o.flags)&&o.length+t.length<512?(this.cache.reused.set(o,2),(r.children[r.children.length-1]=new ye(o.dom,o.text+t)).parent=r):r.append(s||ye.of(t,null===(n=this.cache.find(ye))||void 0===n?void 0:n.dom)),this.pos+=t.length,this.afterWidget=null}addComposition(t,e){let i=this.curLine;i.dom!=e.line.dom&&(i.setDOM(this.cache.reused.has(e.line)?Ee(e.line.dom):e.line.dom),this.cache.reused.set(e.line,2));let s=i;for(let t=e.marks.length-1;t>=0;t--){let i=e.marks[t],n=s.lastChild;if(n instanceof be&&n.mark.eq(i.mark))n.dom!=i.dom&&n.setDOM(Ee(i.dom)),s=n;else{let{dom:t}=i;this.cache.reused.get(i)&&fe.get(i.dom)&&(t=Ee(i.dom));let e=be.of(i.mark,t);s.append(e),s=e}this.cache.reused.set(i,2)}let n=fe.get(t.text);n&&this.cache.reused.set(n,2);let r=new ye(t.text,t.text.nodeValue);r.flags|=8,this.pos=t.range.toB,s.append(r)}addInlineWidget(t,e,i){let s=this.afterWidget&&48&t.flags&&(48&this.afterWidget.flags)==(48&t.flags);s||this.flushBuffer();let n=this.ensureMarks(e,i);s||16&t.flags||n.append(this.getBuffer(1)),n.append(t),this.pos+=t.length,this.afterWidget=t}addMark(t,e,i){this.flushBuffer(),this.ensureMarks(e,i).append(t),this.pos+=t.length,this.afterWidget=null}addBlockWidget(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}continueWidget(t){(this.afterWidget||this.lastBlock).length+=t,this.pos+=t}addLineStart(t,e){var i;t||(t=Pe);let s=ve.start(t,e||(null===(i=this.cache.find(ve))||void 0===i?void 0:i.dom),!!e);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(t){this.blockPosCovered()||this.addLineStart(t)}ensureLine(t){this.curLine||this.addLineStart(t)}ensureMarks(t,e){var i;let s=this.curLine;for(let n=t.length-1;n>=0;n--){let r,o=t[n];if(e>0&&(r=s.lastChild)&&r instanceof be&&r.mark.eq(o))s=r,e--;else{let t=be.of(o,null===(i=this.cache.find(be,(t=>t.mark.eq(o))))||void 0===i?void 0:i.dom);s.append(t),s=t,e=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let t=this.curLine.lastChild;t&&Re(this.curLine,!1)&&("BR"==t.dom.nodeName||!t.isWidget()||S.ios&&Re(this.curLine,!0))||this.curLine.append(this.cache.findWidget(Le,0,32)||new xe(Le.toDOM(),0,Le,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let t=this.wrappers.length-1;t>=0;t--)this.wrappers[t].to<this.pos&&this.wrappers.splice(t,1);for(let t=this.blockWrappers;t.value&&t.from<=this.pos;t.next())if(t.to>=this.pos){let e=102*t.rank+t.value.rank,i=new Ce(t.from,t.to,t.value,e),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-i.rank||this.wrappers[s-1].to-i.to)<0;)s--;this.wrappers.splice(s,0,i)}this.wrapperPos=this.pos}getBlockPos(){var t;this.updateBlockWrappers();let e=this.root;for(let i of this.wrappers){let s=e.lastChild;if(i.from<this.pos&&s instanceof ge&&s.wrapper.eq(i.wrapper))e=s;else{let s=ge.of(i.wrapper,null===(t=this.cache.find(ge,(t=>t.wrapper.eq(i.wrapper))))||void 0===t?void 0:t.dom);e.append(s),e=s}}return e}blockPosCovered(){let t=this.lastBlock;return null!=t&&!t.breakAfter&&(!t.isWidget()||(160&t.flags)>0)}getBuffer(t){let e=2|(t<0?16:32),i=this.cache.find(ke,void 0,1);return i&&(i.flags=e),i||new ke(e)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Me{constructor(t){this.skipCount=0,this.text="",this.textOff=0,this.cursor=t.iter()}skip(t){this.textOff+t<=this.text.length?this.textOff+=t:(this.skipCount+=t-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(t){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:s}=this.cursor.next(this.skipCount);if(this.skipCount=0,s)throw new Error("Ran out of text content when drawing inline views");this.text=e;let n=this.textOff=Math.min(t,e.length);return i?null:e.slice(0,n)}let e=Math.min(this.text.length,this.textOff+t),i=this.text.slice(this.textOff,e);return this.textOff=e,i}}const Oe=[xe,ve,ye,be,ke,ge,me];for(let t=0;t<Oe.length;t++)Oe[t].bucket=t;class Te{constructor(t){this.view=t,this.buckets=Oe.map((()=>[])),this.index=Oe.map((()=>0)),this.reused=new Map}add(t){let e=t.constructor.bucket,i=this.buckets[e];i.length<6?i.push(t):i[this.index[e]=(this.index[e]+1)%6]=t}find(t,e,i=2){let s=t.bucket,n=this.buckets[s],r=this.index[s];for(let t=0;t<n.length;t++){let o=(t+r)%n.length,l=n[o];if((!e||e(l))&&!this.reused.has(l))return n.splice(o,1),o<r&&this.index[s]--,this.reused.set(l,i),l}return null}findWidget(t,e,i){let s=this.buckets[0];if(s.length)for(let n=0,r=0;;n++){if(n==s.length){if(r)return null;r=1,n=0}let o=s[n];if(!this.reused.has(o)&&(0==r?o.widget.compare(t):o.widget.constructor==t.constructor&&t.updateDOM(o.dom,this.view,o.widget)))return s.splice(n,1),n<this.index[0]&&this.index[0]--,o.widget==t&&o.length==e&&(497&o.flags)==i?(this.reused.set(o,1),o):(this.reused.set(o,2),new xe(o.dom,e,t,-498&o.flags|i))}}reuse(t){return this.reused.set(t,1),t}maybeReuse(t,e=2){if(!this.reused.has(t))return this.reused.set(t,e),t.dom}clear(){for(let t=0;t<this.buckets.length;t++)this.buckets[t].length=this.index[t]=0}}class De{constructor(t,e,i,n,r){this.view=t,this.decorations=n,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new Te(t),this.text=new Me(t.state.doc),this.builder=new Ae(this.cache,new me(t,t.contentDOM),s.om.iter(i)),this.cache.reused.set(e,2),this.old=new Se(e),this.reuseWalker={skip:(t,e,i)=>{if(this.cache.add(t),t.isComposite())return!1},enter:t=>this.cache.add(t),leave:()=>{},break:()=>{}}}run(t,e){let i=e&&this.getCompositionContext(e.text);for(let s=0,n=0,r=0;;){let o=r<t.length?t[r++]:null,l=o?o.fromA:this.old.root.length;if(l>s){let t=l-s;this.preserve(t,!r,!o),s=l,n+=t}if(!o)break;e&&o.fromA<=e.range.fromA&&o.toA>=e.range.toA?(this.forward(o.fromA,e.range.fromA,e.range.fromA<e.range.toA?1:-1),this.emit(n,e.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(e,i),this.text.skip(e.range.toB-e.range.fromB),this.forward(e.range.fromA,o.toA),this.emit(e.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(n,o.toB)),n=o.toB,s=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(t,e,i){let s=function(t){let e=[];for(let i=t.parents.length;i>1;i--){let s=i==t.parents.length?t.tile:t.parents[i].tile;s instanceof be&&e.push(s.mark)}return e}(this.old),n=this.openMarks;this.old.advance(t,i?1:-1,{skip:(t,e,i)=>{if(t.isWidget())if(this.openWidget)this.builder.continueWidget(i-e);else{let r=i>0||e<t.length?xe.of(t.widget,this.view,i-e,496&t.flags,this.cache.maybeReuse(t)):this.cache.reuse(t);256&r.flags?(r.flags&=-2,this.builder.addBlockWidget(r)):(this.builder.ensureLine(null),this.builder.addInlineWidget(r,s,n),n=s.length)}else if(t.isText())this.builder.ensureLine(null),e||i!=t.length||this.cache.reused.has(t)?(this.cache.add(t),this.builder.addText(t.text.slice(e,i),s,n)):this.builder.addText(t.text,s,n,this.cache.reuse(t)),n=s.length;else if(t.isLine())t.flags&=-2,this.cache.reused.set(t,1),this.builder.addLine(t);else if(t instanceof ke)this.cache.add(t);else{if(!(t instanceof be))return!1;this.builder.ensureLine(null),this.builder.addMark(t,s,n),this.cache.reused.set(t,1),n=s.length}this.openWidget=!1},enter:t=>{t.isLine()?this.builder.addLineStart(t.attrs,this.cache.maybeReuse(t)):(this.cache.add(t),t instanceof be&&s.unshift(t.mark)),this.openWidget=!1},leave:t=>{t.isLine()?s.length&&(s.length=n=0):t instanceof be&&(s.shift(),n=Math.min(n,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(t)}emit(t,e){let i=null,n=this.builder,r=-1,o=s.om.spans(this.decorations,t,e,{point:(t,e,s,o,l,a)=>{if(s instanceof L){if(this.disallowBlockEffectsFor[a]){if(s.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.view.state.doc.lineAt(t).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=o.length,l>o.length)n.continueWidget(e-t);else{let r=s.widget||(s.block?Be.block:Be.inline),a=function(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}(s),h=this.cache.findWidget(r,e-t,a)||xe.of(r,this.view,e-t,a);s.block?(s.startSide>0&&n.addLineStartIfNotCovered(i),n.addBlockWidget(h)):(n.ensureLine(i),n.addInlineWidget(h,o,l))}i=null}else i=function(t,e){let i=e.spec.attributes,s=e.spec.class;return i||s?(t||(t={class:"cm-line"}),i&&C(i,t),s&&(t.class+=" "+s),t):t}(i,s);e>t&&this.text.skip(e-t)},span:(t,e,s,o)=>{for(let r=t;r<e;){let l=this.text.next(Math.min(512,e-r));null==l?(n.addLineStartIfNotCovered(i),n.addBreak(),r++):(n.ensureLine(i),n.addText(l,s,r==t?o:s.length),r+=l.length),i=null}r=s.length}});r>-1&&(this.openWidget=o>r),this.openWidget||n.addLineStartIfNotCovered(i),this.openMarks=o}forward(t,e,i=1){e-t<=10?this.old.advance(e-t,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(e-t-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(t){let e=[],i=null;for(let s=t.parentNode;;s=s.parentNode){let t=fe.get(s);if(s==this.view.contentDOM)break;t instanceof be?e.push(t):(null==t?void 0:t.isLine())?i=t:t instanceof ge||("DIV"!=s.nodeName||i?i||e.push(be.of(new E({tagName:s.nodeName.toLowerCase(),attributes:T(s)}),s)):i=new ve(s,Pe))}return i?{line:i,marks:e}:null}}function Re(t,e){let i=t=>{for(let s of t.children)if((e?s.isText():s.length)||i(s))return!0;return!1};return i(t)}const Pe={class:"cm-line"};function Ee(t){let e=fe.get(t);return e&&e.setDOM(t.cloneNode()),t}class Be extends D{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}}Be.inline=new Be("span"),Be.block=new Be("div");const Le=new class extends D{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Ne{constructor(t){this.view=t,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=P.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new me(t,t.contentDOM),this.updateInner([new he(0,0,0,t.state.doc.length)],null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every((({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo))?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:function(t,e){let i=!1;return e&&t.iterChangedRanges(((t,s)=>{t<e.to&&s>e.from&&(i=!0)})),i}(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let r=n>-1?function(t,e,i){let s=Fe(t,i);if(!s)return null;let{node:n,from:r,to:o}=s,l=n.nodeValue;if(/[\n\r]/.test(l))return null;if(t.state.doc.sliceString(s.from,s.to)!=l)return null;let a=e.invertedDesc;return{range:new he(a.mapPos(r),a.mapPos(o),r,o),text:n}}(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:e,to:s}=this.hasComposition;i=new he(e,s,t.changes.mapPos(e,-1),t.changes.mapPos(s,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(S.ie||S.chrome)&&!r&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=function(t,e,i){let n=new We;return s.om.compare(t,e,i,n),n.changes}(o,this.decorations,t.changes);a.length&&(i=he.extendWithRanges(i,a));let h=function(t,e,i){let n=new ze;return s.om.compare(t,e,i,n),n.changes}(l,this.blockWrappers,t.changes);return h.length&&(i=he.extendWithRanges(i,h)),r&&!i.some((t=>t.fromA<=r.range.fromA&&t.toA>=r.range.toA))&&(i=r.range.addToSet(i.slice())),!(2&this.tile.flags&&0==i.length||(this.updateInner(i,r),t.transactions.length&&(this.lastUpdate=Date.now()),0))}updateInner(t,e){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore((()=>{if(e||t.length){let i=this.tile,s=new De(this.view,i,this.blockWrappers,this.decorations,this.dynamicDecorationMap);e&&fe.get(e.text)&&s.cache.reused.set(fe.get(e.text),2),this.tile=s.run(t,e),Ie(i,s.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=S.chrome||S.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),!s||!s.written&&i.selectionRange.focusNode==s.node&&this.tile.dom.contains(s.node)||(this.forceSelection=!0),this.tile.dom.style.height=""}));let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.tile.children)t.isWidget()&&t.widget instanceof He&&s.push(t.dom);i.updateGaps(s)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let t of e.effects)t.is(qt)&&(this.editContextFormatting=t.value)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let{dom:i}=this.tile,s=this.view.root.activeElement,n=s==i,r=!n&&!(this.view.state.facet(Kt)||i.tabIndex>-1)&&_(i,this.view.observer.selectionRange)&&!(s&&i.contains(s));if(!(n||e||r))return;let o=this.forceSelection;this.forceSelection=!1;let l,a,h=this.view.state.selection.main;if(h.empty?a=l=this.inlineDOMNearPos(h.anchor,h.assoc||1):(a=this.inlineDOMNearPos(h.head,h.head==h.from?1:-1),l=this.inlineDOMNearPos(h.anchor,h.anchor==h.from?1:-1)),S.gecko&&h.empty&&!this.hasComposition&&W((c=l).node)&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable)){let t=document.createTextNode("");this.view.observer.ignore((()=>l.node.insertBefore(t,l.node.childNodes[l.offset]||null))),l=a=new ct(t,0),o=!0}var c;let u=this.view.observer.selectionRange;!o&&u.focusNode&&(q(l.node,l.offset,u.anchorNode,u.anchorOffset)&&q(a.node,a.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,h))||(this.view.observer.ignore((()=>{S.android&&S.chrome&&i.contains(u.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(W(i)&&"false"==i.contentEditable)return!0;return!1}(u.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let t=H(this.view.root);if(t)if(h.empty){if(S.gecko){let t=(e=l.node,n=l.offset,W(e)?(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0):0);if(t&&3!=t){let e=(1==t?at:ht)(l.node,l.offset);e&&(l=new ct(e.node,e.offset))}}t.collapse(l.node,l.offset),null!=h.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=h.bidiLevel)}else if(t.extend){t.collapse(l.node,l.offset);try{t.extend(a.node,a.offset)}catch(t){}}else{let e=document.createRange();h.anchor>h.head&&([l,a]=[a,l]),e.setEnd(a.node,a.offset),e.setStart(l.node,l.offset),t.removeAllRanges(),t.addRange(e)}var e,n;r&&this.view.root.activeElement==i&&(i.blur(),s&&s.focus())})),this.view.observer.setSelectionRange(l,a)),this.impreciseAnchor=l.precise?null:new ct(u.anchorNode,u.anchorOffset),this.impreciseHead=a.precise?null:new ct(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&q(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=H(t.root),{anchorNode:s,anchorOffset:n}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=this.lineAt(e.head,e.assoc);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let l=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(e.head+e.assoc,e.assoc);i.collapse(h.node,h.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)}posFromDOM(t,e){let i=this.tile.nearest(t);if(!i)return 2&this.tile.dom.compareDocumentPosition(t)?0:this.view.state.doc.length;let s=i.posAtStart;if(!i.isComposite())return i.isText()?t==i.dom?s+e:s+(e?i.length:0):s;{let n;if(t==i.dom)n=i.dom.childNodes[e];else{let s=0==U(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==i.dom)break;0==s&&e.firstChild!=e.lastChild&&(s=t==e.firstChild?-1:1),t=e}n=s<0?t:t.nextSibling}if(n==i.dom.firstChild)return s;for(;n&&!fe.get(n);)n=n.nextSibling;if(!n)return s+i.length;for(let t=0,e=s;;t++){let s=i.children[t];if(s.dom==n)return e;e+=s.length+s.breakAfter}}}domAtPos(t,e){let{tile:i,offset:s}=this.tile.resolveBlock(t,e);return i.isWidget()?i.domPosFor(s,e):i.domIn(s,e)}inlineDOMNearPos(t,e){let i,s,n=-1,r=!1,o=-1,l=!1;return this.tile.blockTiles(((e,a)=>{if(e.isWidget()){if(32&e.flags&&a>=t)return!0;16&e.flags&&(r=!0)}else{let h=a+e.length;if(a<=t&&(i=e,n=t-a,r=h<t),h>=t&&!s&&(s=e,o=t-a,l=a>t),a>t&&s)return!0}})),i||s?(r&&s?i=null:l&&i&&(s=null),i&&e<0||!s?i.domIn(n,e):s.domIn(o,e)):this.domAtPos(t,e)}coordsAt(t,e,i){let{tile:s,offset:n}=this.tile.resolveBlock(t,e);return s.isWidget()?s.widget instanceof He?null:s.coordsInWidget(n,e,!0):s.coordsIn(n,e,i)}lineAt(t,e){let{tile:i}=this.tile.resolveBlock(t,e);return i.isLine()?i:null}coordsForChar(t){let{tile:e,offset:i}=this.tile.resolveBlock(t,1);return e.isLine()?function t(e,i){if(e.isComposite())for(let s of e.children){if(s.length>=i){let e=t(s,i);if(e)return e}if((i-=s.length)<0)break}else if(e.isText()&&i<e.length){let t=(0,s.zK)(e.text,i);if(t==i)return null;let n=rt(e.dom,i,t).getClientRects();for(let t=0;t<n.length;t++){let e=n[t];if(t==n.length-1||e.top<e.bottom&&e.left<e.right)return e}}return null}(e,i):null}measureVisibleLineHeights(t){let e=[],{from:i,to:s}=t,n=this.view.contentDOM.clientWidth,r=n>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==ut.LTR,a=0,h=(t,c,u)=>{for(let f=0;f<t.children.length&&!(c>s);f++){let s=t.children[f],d=c+s.length,p=s.dom.getBoundingClientRect(),{height:m}=p;if(u&&!f&&(a+=p.top-u.top),s instanceof ge)d>i&&h(s,c,p);else if(c>=i&&(a>0&&e.push(-a),e.push(m+a),a=0,r)){let t=s.dom.lastChild,e=t?j(t):[];if(e.length){let t=e[e.length-1],i=l?t.right-p.left:p.right-t.left;i>o&&(o=i,this.minWidth=n,this.minWidthFrom=c,this.minWidthTo=d)}}u&&f==t.children.length-1&&(a+=u.bottom-p.bottom),c=d+s.breakAfter}};return h(this.tile,0,null),e}textDirectionAt(t){let{tile:e}=this.tile.resolveBlock(t,1);return"rtl"==getComputedStyle(e.dom).direction?ut.RTL:ut.LTR}measureTextSize(){let t=this.tile.blockTiles((t=>{if(t.isLine()&&t.children.length&&t.length<=20){let e,i=0;for(let s of t.children){if(!s.isText()||/[^ -~]/.test(s.text))return;let t=j(s.dom);if(1!=t.length)return;i+=t[0].width,e=t[0].height}if(i)return{lineHeight:t.dom.getBoundingClientRect().height,charWidth:i/t.length,textHeight:e}}}));if(t)return t;let e,i,s,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.tile.dom.appendChild(n);let t=j(n.firstChild)[0];e=n.getBoundingClientRect().height,i=t&&t.width?t.width/27:7,s=t&&t.height?t.height:e,n.remove()})),{lineHeight:e,charWidth:i,textHeight:s}}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.view.state.doc.length;if(r>i){let s=(e.lineBlockAt(r).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(P.replace({widget:new He(s),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!n)break;i=n.to+1}return P.set(t)}updateDeco(){let t=1,e=this.view.state.facet(Zt).map((e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e)),i=!1,n=this.view.state.facet(ee).map(((t,e)=>{let s="function"==typeof t;return s&&(i=!0),s?t(this.view):t}));for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(s.om.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;this.blockWrappers=this.view.state.facet(te).map((t=>"function"==typeof t?t(this.view):t))}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}for(let e of this.view.state.facet(Vt))try{if(e(this.view,t.range,t))return!0}catch(t){$t(this.view.state,t,"scroll handler")}let e,{range:i}=t,s=this.coordsAt(i.head,i.assoc||(i.head>i.anchor?-1:1));if(!s)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(s={left:Math.min(s.left,e.left),top:Math.min(s.top,e.top),right:Math.max(s.right,e.right),bottom:Math.max(s.bottom,e.bottom)});let n=le(this.view),r={left:s.left-n.left,top:s.top-n.top,right:s.right+n.right,bottom:s.bottom+n.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;if(function(t,e,i,s,n,r,o,l){let a=t.ownerDocument,h=a.defaultView||window;for(let c=t,u=!1;c&&!u;)if(W(c)){let t,f=c==a.body,d=1,p=1,m=!0,g=!0;if(f)t=G(h);else{let e=getComputedStyle(c);if(/^(fixed|sticky)$/.test(e.position)&&(u=!0),(c.scrollHeight<=c.clientHeight||!/auto|scroll/.test(e.overflowY))&&(g=!1),(c.scrollWidth<=c.clientWidth||!/auto|scroll/.test(e.overflowX))&&(m=!1),!m&&!g){c=c.assignedSlot||c.parentNode;continue}let i=c.getBoundingClientRect();({scaleX:d,scaleY:p}=X(c,i)),t={left:i.left,right:i.left+c.clientWidth*d,top:i.top,bottom:i.top+c.clientHeight*p}}let v=0,w=0;if(g)if("nearest"==n)e.top<t.top+o?(w=e.top-(t.top+o),i>0&&e.bottom>t.bottom+w&&(w=e.bottom-t.bottom+o)):e.bottom>t.bottom-o&&(w=e.bottom-t.bottom+o,i<0&&e.top-w<t.top&&(w=e.top-(t.top+o)));else{let s=e.bottom-e.top,r=t.bottom-t.top;w=("center"==n&&s<=r?e.top+s/2-r/2:"start"==n||"center"==n&&i<0?e.top-o:e.bottom-r+o)-t.top}if(m&&("nearest"==s?e.left<t.left+r?(v=e.left-(t.left+r),i>0&&e.right>t.right+v&&(v=e.right-t.right+r)):e.right>t.right-r&&(v=e.right-t.right+r,i<0&&e.left<t.left+v&&(v=e.left-(t.left+r))):v=("center"==s?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==s==l?e.left-r:e.right-(t.right-t.left)+r)-t.left),v||w)if(f)h.scrollBy(v,w);else{let t=0,i=0;if(w){let t=c.scrollTop;c.scrollTop+=w/p,i=(c.scrollTop-t)*p}if(v){let e=c.scrollLeft;c.scrollLeft+=v/d,t=(c.scrollLeft-e)*d}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-v)<1&&(s="nearest"),i&&Math.abs(i-w)<1&&(n="nearest")}if(f)break;(e.top<t.top||e.bottom>t.bottom||e.left<t.left||e.right>t.right)&&(e={left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),top:Math.max(e.top,t.top),bottom:Math.min(e.bottom,t.bottom)}),c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,l),-l),this.view.textDirection==ut.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(s.top>window.visualViewport.offsetTop+window.visualViewport.height||s.bottom<window.visualViewport.offsetTop)){let t=this.view.docView.lineAt(i.head,1);if(t){let e=tt(t.dom);t.dom.scrollIntoView({block:"nearest"}),et(e,!1)}}}lineHasWidget(t){let e=t=>t.isWidget()||t.children.some(e);return e(this.tile.resolveBlock(t,1).tile)}destroy(){Ie(this.tile)}}function Ie(t,e){let i=null==e?void 0:e.get(t);if(1!=i){null==i&&t.destroy();for(let i of t.children)Ie(i,e)}}function Fe(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let s=at(i.focusNode,i.focusOffset),n=ht(i.focusNode,i.focusOffset),r=s||n;if(n&&s&&n.node!=s.node){let e=fe.get(n.node);if(!e||e.isText()&&e.text!=n.node.nodeValue)r=n;else if(t.docView.lastCompositionAfterCursor){let t=fe.get(s.node);!t||t.isText()&&t.text!=s.node.nodeValue||(r=n)}}if(t.docView.lastCompositionAfterCursor=r!=s,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}let We=class{constructor(){this.changes=[]}compareRange(t,e){I(t,e,this.changes)}comparePoint(t,e){I(t,e,this.changes)}boundChange(t){I(t,t,this.changes)}};class ze{constructor(){this.changes=[]}compareRange(t,e){I(t,e,this.changes)}comparePoint(){}boundChange(t){I(t,t,this.changes)}}class He extends D{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}}function Ve(t,e,i){let s=t.lineBlockAt(e);if(Array.isArray(s.type)){let t;for(let n of s.type){if(n.from>e)break;if(!(n.to<e)){if(n.from<e&&n.to>e)return n;t&&(n.type!=R.Text||t.type==n.type&&!(i<0?n.from<e:n.to>e))||(t=n)}}return t||s}return s}function _e(t,e,i,n){let r=t.state.doc.lineAt(e.head),o=t.bidiSpans(r),l=t.textDirectionAt(r.from);for(let a=e,h=null;;){let e=Tt(r,o,l,a,i),c=Ot;if(!e){if(r.number==(i?t.state.doc.lines:1))return a;c="\n",r=t.state.doc.line(r.number+(i?1:-1)),o=t.bidiSpans(r),e=i?s.OF.cursor(r.from,-1):s.OF.cursor(r.to,1)}if(h){if(!h(c))return a}else{if(!n)return e;h=n(c)}a=e}}function je(t,e,i){for(;;){let s=0;for(let n of t)n.between(e-1,e+1,((t,n,r)=>{if(e>t&&e<n){let r=s||i||(e-t<n-e?-1:1);e=r<0?t:n,s=r}}));if(!s)return e}}function qe(t,e){let i=null;for(let n=0;n<e.ranges.length;n++){let r=e.ranges[n],o=null;if(r.empty){let e=je(t,r.from,0);e!=r.from&&(o=s.OF.cursor(e,-1))}else{let e=je(t,r.from,-1),i=je(t,r.to,1);e==r.from&&i==r.to||(o=r.undirectional?s.OF.undirectionalRange(r.from,r.to):s.OF.range(r.from==r.anchor?e:i,r.from==r.head?e:i))}o&&(i||(i=e.ranges.slice()),i[n]=o)}return i?s.OF.create(i,e.mainIndex):e}function $e(t,e,i){let n=je(t.state.facet(ie).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:s.OF.cursor(n,n<i.from?1:-1)}class Ke{constructor(t,e){this.pos=t,this.assoc=e}}function Ye(t,e,i,n){let r,o=t.contentDOM.getBoundingClientRect(),l=o.top+t.viewState.paddingTop,{x:a,y:h}=e,c=h-l;for(;;){if(c<0)return new Ke(0,1);if(c>t.viewState.docHeight)return new Ke(t.state.doc.length,-1);if(r=t.elementAtHeight(c),null==n)break;if(r.type==R.Text){if(n<0?r.to<t.viewport.from:r.from>t.viewport.to)break;let e=t.docView.coordsAt(n<0?r.from:r.to,n>0?-1:1);if(e&&(n<0?e.top<=c+l:e.bottom>=c+l))break}let e=t.viewState.heightOracle.textHeight/2;c=n>0?r.bottom+e:r.top-e}if(t.viewport.from>=r.to||t.viewport.to<=r.from){if(i)return null;if(r.type==R.Text){let e=function(t,e,i,n,r){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;o+=Math.floor((r-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let l=t.state.sliceDoc(i.from,i.to);return i.from+(0,s.kn)(l,o,t.state.tabSize)}(t,o,r,a,h);return new Ke(e,e==r.from?1:-1)}}if(r.type!=R.Text)return c<(r.top+r.bottom)/2?new Ke(r.from,1):new Ke(r.to,-1);let u=t.docView.lineAt(r.from,2);return u&&u.length==r.length||(u=t.docView.lineAt(r.from,-2)),new Ue(t,a,h,t.textDirectionAt(r.from)).scanTile(u,r.from)}class Ue{constructor(t,e,i,s){this.view=t,this.x=e,this.y=i,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(t){return(!this.line||this.line.from>t||this.line.to<t)&&(this.line=this.view.state.doc.lineAt(t),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(t,e){let{line:i,spans:s}=this.bidiSpansAt(t);return s[xt.find(s,t-i.from,-1,e)].level==this.baseDir}dirAt(t,e){let{line:i,spans:s}=this.bidiSpansAt(t);return s[xt.find(s,t-i.from,-1,e)].dir}bidiIn(t,e){let{spans:i,line:s}=this.bidiSpansAt(t);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+s.from<e)}scan(t,e,i=!1){let s,n,r,o=0,l=t.length-1,a=new Set,h=this.bidiIn(t[0],t[l]),c=-1,u=1e9;t:for(;o<l;){let i=l-o,f=o+l>>1;e:if(a.has(f)){for(let t=1;t<i;t++){let e=f+t;if(e>=l&&(e-=i),!a.has(e)){f=e;break e}}break t}a.add(f);let d=e(f),p=0;if(d)for(let t=0;t<d.length;t++){let e=d[t];if(!(0==e.width&&d.length>1))if(e.bottom<this.y)(!s||s.bottom<e.bottom)&&(s=e),p=1;else if(e.top>this.y)(!n||n.top>e.top)&&(n=e),p=-1;else{let t=e.left>this.x?this.x-e.left:e.right<this.x?this.x-e.right:0,i=Math.abs(t);i<u&&(c=f,u=i,r=e),t&&(p=t<0==(this.baseDir==ut.LTR)?-1:1)}}-1!=p||h&&!this.baseDirAt(t[f],1)?1!=p||h&&!this.baseDirAt(t[f+1],-1)||(o=f+1):l=f}if(!r){if(!n&&!s)return{i:0,after:!1};let i=s&&(!n||this.y-s.bottom<n.top-this.y)?s:n;return this.y=(i.top+i.bottom)/2,this.scan(t,e,!0)}if(u&&!i){let{top:i,bottom:o}=r;if(s&&s.bottom>(i+i+o)/3)return this.y=s.bottom-1,this.scan(t,e,!0);if(n&&n.top<(i+o+o)/3)return this.y=n.top+1,this.scan(t,e,!0)}let f=(h?this.dirAt(t[c],1):this.baseDir)==ut.LTR;return{i:c,after:this.x>(r.left+r.right)/2==f}}scanText(t,e){let i=[];for(let n=0;n<t.length;n=(0,s.zK)(t.text,n))i.push(e+n);i.push(e+t.length);let n=this.scan(i,(s=>{let n=i[s]-e,r=i[s+1]-e;return rt(t.dom,n,r).getClientRects()}));return n.after?new Ke(i[n.i+1],-1):new Ke(i[n.i],1)}scanTile(t,e){if(!t.length)return new Ke(e,1);if(1==t.children.length){let i=t.children[0];if(i.isText())return this.scanText(i,e);if(i.isComposite())return this.scanTile(i,e)}let i=[e];for(let s=0,n=e;s<t.children.length;s++)i.push(n+=t.children[s].length);let s=this.scan(i,(e=>{let i=t.children[e];return 48&i.flags?null:(W(i.dom)?i.dom:rt(i.dom,0,i.length)).getClientRects()})),n=t.children[s.i],r=i[s.i];return n.isText()?this.scanText(n,r):n.isComposite()?this.scanTile(n,r):s.after?new Ke(i[s.i+1],-1):new Ke(r,1)}}const Qe="￿";class Ge{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineSeparator=e.state.facet(s.$t.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Qe}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let s=t;;){this.findPointBefore(i,s);let t=this.text.length;this.readNode(s);let n=fe.get(s),r=s.nextSibling;if(r==e){(null==n?void 0:n.breakAfter)&&!r&&i!=this.view.contentDOM&&this.lineBreak();break}let o=fe.get(r);(n&&o?n.breakAfter:(n?n.breakAfter:K(s))||K(r)&&("BR"!=s.nodeName||(null==n?void 0:n.isWidget()))&&this.text.length>t)&&!Je(r,e)&&this.lineBreak(),s=r}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,r=-1,o=1;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(n=s.exec(e))&&(r=n.index,o=n[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=o-1);i=r+o}}readNode(t){let e=fe.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 z(t)?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():W(t)&&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)(z(t)?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(Xe(t,i.node,i.offset)?e:0))}}function Xe(t,e,i){for(;;){if(!e||i<U(e))return!1;if(e==t)return!0;i=$(e)+1,e=e.parentNode}}function Je(t,e){let i;for(;t!=e&&t;t=t.nextSibling){let e=fe.get(t);if(!(null==e?void 0:e.isWidget()))return!1;e&&(i||(i=[])).push(e)}if(i)for(let t of i){let e=t.overrideDOMText;if(null==e?void 0:e.length)return!1}return!0}class Ze{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class ti{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:r,impreciseAnchor:o}=t.docView,l=t.state.selection;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=ei(t.docView.tile,e,i,0))){let e=r||o?[]: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 Ze(i,s)),n==i&&r==s||e.push(new Ze(n,r))),e}(t),i=new Ge(e,t);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,n=2==t.length?t[1].pos:i;return i<0||n<0?null:i==n?s.OF.create([s.OF.cursor(n+e,-1)]):s.OF.single(i+e,n+e)}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=r&&r.node==e.focusNode&&r.offset==e.focusOffset||!V(t.contentDOM,e.focusNode)?l.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=o&&o.node==e.anchorNode&&o.offset==e.anchorOffset||!V(t.contentDOM,e.anchorNode)?l.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),a=t.viewport;if((S.ios||S.chrome)&&i!=n&&Math.min(i,n)<=l.main.from&&Math.max(i,n)>=l.main.to&&(a.from>0||a.to<t.state.doc.length)){let e=Math.min(i,n),s=Math.max(i,n),r=a.from-e,o=a.to-s;0!=r&&1!=r&&0!=e||0!=o&&-1!=o&&s!=t.state.doc.length||(i=0,n=t.state.doc.length)}if(t.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(s.OF.range(n,i));else if(t.lineWrapping&&n==i&&(!l.main.empty||l.main.head!=i)&&t.inputState.lastTouchTime>Date.now()-100){let e=t.coordsAtPos(i,-1),n=0;e&&(n=t.inputState.lastTouchY<=e.bottom?-1:1),this.newSel=s.OF.create([s.OF.cursor(i,n)])}else this.newSel=s.OF.single(n,i)}}}function ei(t,e,i,s){if(t.isComposite()){let n=-1,r=-1,o=-1,l=-1;for(let a=0,h=s,c=s;a<t.children.length;a++){let s=t.children[a],u=h+s.length;if(h<e&&u>i)return ei(s,e,i,h);if(u>=e&&-1==n&&(n=a,r=h),h>i&&s.dom.parentNode==t.dom){o=a,l=c;break}c=u,h=u+s.breakAfter}return{from:r,to:l<0?s+t.length:l,startDOM:(n?t.children[n-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o<t.children.length&&o>=0?t.children[o].dom:null}}return t.isText()?{from:s,to:s+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function ii(t,e){let i,{newSel:n}=e,{state:r}=t,o=r.selection.main,l=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:t,to:n}=e.bounds,a=o.from,h=null;(8===l||S.android&&e.text.length<n-t)&&(a=o.to,h="end");let c,u,f=r.doc.sliceString(t,n,Qe);!o.empty&&o.from>=t&&o.to<=n&&(e.typeOver||f!=e.text)&&f.slice(0,o.from-t)==e.text.slice(0,o.from-t)&&f.slice(o.to-t)==e.text.slice(c=e.text.length-(f.length-(o.to-t)))?i={from:o.from,to:o.to,insert:s.EY.of(e.text.slice(o.from-t,c).split(Qe))}:(u=ni(f,e.text,a-t,h))&&(S.chrome&&13==l&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==Qe+Qe&&u.toB--,i={from:t+u.from,to:t+u.toA,insert:s.EY.of(e.text.slice(u.from,u.toB).split(Qe))})}else n&&(!t.hasFocus&&r.facet(Kt)||ri(n,o))&&(n=null);if(!i&&!n)return!1;if((S.mac||S.android)&&i&&i.from==i.to&&i.from==o.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=s.OF.single(n.main.anchor-1,n.main.head-1)),i={from:i.from,to:i.to,insert:s.EY.of([i.insert.toString().replace("."," ")])}):r.doc.lineAt(o.from).to<o.to&&t.docView.lineHasWidget(o.to)&&t.inputState.insertingTextAt>Date.now()-50?i={from:o.from,to:o.to,insert:r.toText(t.inputState.insertingText)}:S.chrome&&i&&i.from==i.to&&i.from==o.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=s.OF.single(n.main.anchor-1,n.main.head-1)),i={from:o.from,to:o.to,insert:s.EY.of([" "])}),i)return si(t,i,n,l);if(n&&!ri(n,o)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin,"select.pointer"==i&&(n=qe(r.facet(ie).map((e=>e(t))),n))),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function si(t,e,i,n=-1){if(S.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(S.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&&ot(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&0==e.insert.length||8==n&&e.insert.length<e.to-e.from&&e.to>r.head)&&ot(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&0==e.insert.length&&ot(t.contentDOM,"Delete",46)))return!0;let o,l=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let a=()=>o||(o=function(t,e,i){let n,r=t.state,o=r.selection.main,l=-1;if(e.from==e.to&&e.from<o.from||e.from>o.to){let i=e.from<o.from?-1:1,s=i<0?o.from:o.to,n=je(r.facet(ie).map((e=>e(t))),s,i);e.from==n&&(l=n)}if(l>-1)n={changes:e,selection:s.OF.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=o.from<e.from?r.sliceDoc(o.from,e.from):"",s=o.to>e.to?r.sliceDoc(e.to,o.to):"";n=r.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+s))}else{let l=r.changes(e),a=i&&i.main.to<=l.newLength?i.main:void 0;if(r.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let h,c=t.state.sliceDoc(e.from,e.to),u=i&&Fe(t,i.main.head);if(u){let t=e.insert.length-(e.to-e.from);h={from:u.from,to:u.to-t}}else h=t.state.doc.lineAt(o.head);let f=o.to-e.to;n=r.changeByRange((i=>{if(i.from==o.from&&i.to==o.to)return{changes:l,range:a||i.map(l)};let n=i.to-f,u=n-c.length;if(t.state.sliceDoc(u,n)!=c||n>=h.from&&u<=h.to)return{range:i};let d=r.changes({from:u,to:n,insert:e.insert}),p=i.to-o.to;return{changes:d,range:a?s.OF.range(Math.max(0,a.anchor+p),Math.max(0,a.head+p)):i.map(d)}}))}else n={changes:l,selection:a&&r.selection.replaceRange(a)}}let a="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,a+=".compose",t.inputState.compositionFirstChange&&(a+=".start",t.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:a,scrollIntoView:!0})}(t,e,i));return t.state.facet(Nt).some((i=>i(t,e.from,e.to,l,a)))||t.dispatch(a()),!0}function ni(t,e,i,s){let n=Math.min(t.length,e.length),r=0;for(;r<n&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==n&&t.length==e.length)return null;let o=t.length,l=e.length;for(;o>0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;return"end"==s&&(i-=o+Math.max(0,r-Math.min(o,l))-r),o<r&&t.length<e.length?(r-=i<=r&&i>=o?r-i:0,l=r+(l-o),o=r):l<r&&(r-=i<=r&&i>=l?r-i:0,o=r+(o-l),l=r),{from:r,toA:o,toB:l}}function ri(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class oi{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,S.safari&&t.contentDOM.addEventListener("input",(()=>null)),S.gecko&&function(t){Ri.has(t)||(Ri.add(t),t.addEventListener("copy",(()=>{})),t.addEventListener("cut",(()=>{})))}(t.contentDOM.ownerDocument)}handleEvent(t){(function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,s=e.target;s!=t.contentDOM;s=s.parentNode)if(!s||11==s.nodeType||(i=fe.get(s))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||(0!=this.view.updateState?Promise.resolve().then((()=>this.runHandlers(t.type,t))):this.runHandlers(t.type,t)))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let 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=ai(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&&n!=!r.handlers.length&&(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){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=t.keyCode&&ui.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),S.android&&S.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;if(S.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&(hi.some((e=>e.keyCode==t.keyCode))&&!t.ctrlKey||ci.indexOf(t.key)>-1&&t.ctrlKey)){let i={ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey,shiftKey:t.shiftKey};i.shiftKey&&S.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&(e=this.view.win).visualViewport&&e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85&&(i.shiftKey=!1);let s=this.pendingIOSKey={key:t.key,keyCode:t.keyCode,mods:i};return setTimeout((()=>{this.pendingIOSKey==s&&this.flushIOSKey()}),50),!0}var e;return 229!=t.keyCode&&this.view.observer.forceFlush(),!1}flushIOSKey(t){let e=this.pendingIOSKey;return!(!e||this.view.observer.pendingRecords().length)&&!("Enter"==e.key&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString()))&&(this.pendingIOSKey=void 0,ot(this.view.contentDOM,e.key,e.keyCode,e.mods))}ignoreDuringComposition(t){return!(!/^key/.test(t.type)||t.synthetic)&&(this.composing>0||!!(S.safari&&!S.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 li(t,e){return(i,s)=>{try{return e.call(t,s,i)}catch(t){$t(i.state,t)}}}function ai(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,s=t&&t.plugin.domEventHandlers,n=t&&t.plugin.domEventObservers;if(s)for(let t in s){let n=s[t];n&&i(t).handlers.push(li(e.value,n))}if(n)for(let t in n){let s=n[t];s&&i(t).observers.push(li(e.value,s))}}for(let t in pi)i(t).handlers.push(pi[t]);for(let t in mi)i(t).observers.push(mi[t]);return e}const hi=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ci="dthko",ui=[16,17,18,20,91,92,224,225];function fi(t){return.7*Math.max(0,t)+8}class di{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=J(t.contentDOM),this.atoms=t.state.facet(ie).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(s.$t.allowMultipleSelections)&&function(t,e){let i=t.state.facet(Rt);return i.length?i[0](e):S.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let s=H(t.root);if(!s||0==s.rangeCount)return!0;let n=s.getRangeAt(0).getClientRects();for(let t=0;t<n.length;t++){let i=n[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=Ci(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(e=this.startEvent,i=t,Math.max(Math.abs(e.clientX-i.clientX),Math.abs(e.clientY-i.clientY))<10))return;var e,i;this.select(this.lastEvent=t);let s=0,n=0,r=0,o=0,l=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:l}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:a}=this.scrollParents.y.getBoundingClientRect());let h=le(this.view);t.clientX-h.left<=r+6?s=-fi(r-t.clientX):t.clientX+h.right>=l-6&&(s=fi(t.clientX-l)),t.clientY-h.top<=o+6?n=-fi(o-t.clientY):t.clientY+h.bottom>=a-6&&(n=fi(t.clientY-a)),this.setScrollSpeed(s,n)}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)}select(t){let{view:e}=this,i=qe(this.atoms,this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some((t=>t.isUserEvent("input.type")))?this.destroy():this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}const pi=Object.create(null),mi=Object.create(null),gi=S.ie&&S.ie_version<15||S.ios&&S.webkit_version<604;function vi(t,e,i){for(let s of t.facet(e))i=s(i,t);return i}function wi(t,e){e=vi(t.state,Ft,e);let i,{state:n}=t,r=1,o=n.toText(e),l=o.lines==n.selection.ranges.length;if(null!=Mi&&n.selection.ranges.every((t=>t.empty))&&Mi==o.toString()){let t=-1;i=n.changeByRange((i=>{let a=n.doc.lineAt(i.from);if(a.from==t)return{range:i};t=a.from;let h=n.toText((l?o.line(r++).text:e)+n.lineBreak);return{changes:{from:a.from,insert:h},range:s.OF.cursor(i.from+h.length,-1)}}))}else i=l?n.changeByRange((t=>{let e=o.line(r++);return{changes:{from:t.from,to:t.to,insert:e.text},range:s.OF.cursor(t.from+e.length,-1)}})):n.replaceSelection(o);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function bi(t,e,i,n){if(1==n)return s.OF.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),r=t.doc.lineAt(e),o=e-r.from;if(0==r.length)return s.OF.cursor(e);0==o?i=1:o==r.length&&(i=-1);let l=o,a=o;i<0?l=(0,s.zK)(r.text,o,!1):a=(0,s.zK)(r.text,o);let h=n(r.text.slice(l,a));for(;l>0;){let t=(0,s.zK)(r.text,l,!1);if(n(r.text.slice(t,l))!=h)break;l=t}for(;a<r.length;){let t=(0,s.zK)(r.text,a);if(n(r.text.slice(a,t))!=h)break;a=t}return s.OF.undirectionalRange(l+r.from,a+r.from)}(t.state,e,i);{let n=t.docView.lineAt(e,i),r=t.state.doc.lineAt(n?n.posAtEnd:e),o=n?n.posAtStart:r.from,l=n?n.posAtEnd:r.to;return l<t.state.doc.length&&l==r.to&&l++,s.OF.undirectionalRange(o,l)}}mi.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,S.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},mi.wheel=mi.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},pi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),mi.touchstart=(t,e)=>{let i=t.inputState,s=e.targetTouches[0];i.touchActive=!0,i.lastTouchTime=Date.now(),s&&(i.lastTouchX=s.clientX,i.lastTouchY=s.clientY),i.setSelectionOrigin("select.pointer")},mi.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},mi.touchend=(t,e)=>{t.inputState.touchActive=!1},pi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let s of t.state.facet(Et))if(i=s(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),n=Ci(e),r=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),r=r.map(t.changes))},get(e,o,l){let a,h=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),c=bi(t,h.pos,h.assoc,n);if(i.pos!=h.pos&&!o){let e=bi(t,i.pos,i.assoc,n),r=Math.min(e.from,c.from),o=Math.max(e.to,c.to);c=r<c.from?s.OF.range(r,o,c.assoc):s.OF.range(o,r,c.assoc)}return o?r.replaceRange(r.main.extend(c.from,c.to,c.assoc)):l&&1==n&&r.ranges.length>1&&(a=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:r}=t.ranges[i];if(n<=e&&r>=e)return s.OF.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}(r,h.pos))?a:l?r.addRange(c):s.OF.create([c])}}}(t,e)),i){let s=!t.hasFocus;t.inputState.startMouseSelection(new di(t,e,i,s)),s&&t.observer.ignore((()=>{nt(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()}));let n=t.inputState.mouseSelection;if(n)return n.start(e),!1===n.dragging}else t.inputState.setSelectionOrigin("select.pointer");return!1};const yi=S.ie&&S.ie_version<=11;let xi=null,ki=0,Si=0;function Ci(t){if(!yi)return t.detail;let e=xi,i=Si;return xi=t,Si=Date.now(),ki=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(ki+1)%3:1}function Ai(t,e,i,s){if(!(i=vi(t.state,Ft,i)))return;let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=t.inputState,o=s&&r&&function(t,e){let i=t.state.facet(Pt);return i.length?i[0](e):S.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:r.from,to:r.to}:null,l={from:n,insert:i},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(n,-1),head:a.mapPos(n,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}pi.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.tile.nearest(e.target);if(n&&n.isWidget()){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=s.OF.undirectionalRange(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",vi(t.state,Wt,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1},pi.dragend=t=>(t.inputState.draggedContent=null,!1),pi.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&&Ai(t,e,s.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=r,e.onload=()=>{/[\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 Ai(t,e,i,!0),!0}return!1},pi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=gi?null:e.clipboardData;return i?(wi(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(),wi(t,i.value)}),50)}(t),!1)};let Mi=null;pi.copy=pi.cut=(t,e)=>{if(!_(t.contentDOM,t.observer.selectionRange))return!1;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:vi(t,Wt,e.join(t.lineBreak)),ranges:i,linewise:s}}(t.state);if(!i&&!n)return!1;Mi=n?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:s,scrollIntoView:!0,userEvent:"delete.cut"});let r=gi?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)};const Oi=s.YH.define();function Ti(t,e){let i=[];for(let s of t.facet(It)){let n=s(t,e);n&&i.push(n)}return i.length?t.update({effects:i,annotations:Oi.of(!0)}):null}function Di(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Ti(t.state,e);i?t.dispatch(i):t.update([])}}),10)}mi.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),Di(t)},mi.blur=t=>{t.observer.clearSelectionRange(),Di(t)},mi.compositionstart=mi.compositionupdate=(t,e)=>{if(!t.observer.editContext&&(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0)){let{main:e}=t.state.selection;e.empty||t.lineBlockAt(e.from).from==t.lineBlockAt(e.to).from||t.state.readOnly||t.dispatch({changes:t.state.selection.ranges.filter((t=>!t.empty)).map((t=>({from:t.from,to:t.to}))),userEvent:"input"}),t.inputState.composing=0}},mi.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,S.chrome&&S.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50))},mi.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},pi.beforeinput=(t,e)=>{var i,s;if("insertText"!=e.inputType&&"insertCompositionText"!=e.inputType||(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),"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 si(t,{from:i,to:r,insert:t.state.toText(s)},null),!0}}let n;if(S.chrome&&S.android&&(n=hi.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 S.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),S.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout((()=>mi.compositionend(t,e)),20),!1};const Ri=new Set,Pi=["pre-wrap","normal","pre-line","break-spaces"];let Ei=!1;function Bi(){Ei=!1}class Li{constructor(t){this.lineWrapping=t,this.doc=s.EY.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)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Pi.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let s=t[i];s<0?i++:this.heightSamples[Math.floor(10*s)]||(e=!0,this.heightSamples[Math.floor(10*s)]=!0)}return e}refresh(t,e,i,s,n,r){let o=Pi.indexOf(t)>-1,l=Math.abs(e-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=s,this.lineLength=n,l){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return l}}class Ni{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Ii{constructor(t,e,i,s,n){this.from=t,this.length=e,this.top=i,this.height=s,this._content=n}get type(){return"number"==typeof this._content?R.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof L?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Ii(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var Fi=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(Fi||(Fi={}));const Wi=.001;class zi{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>Wi&&(Ei=!0),this.height=t)}replace(t,e,i){return zi.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:l,toA:a,fromB:h,toB:c}=s[o],u=n.lineAt(l,Fi.ByPosNoHeight,i.setDoc(e),0,0),f=u.to>=a?u:n.lineAt(a,Fi.ByPosNoHeight,i,0,0);for(c+=f.to-a,a=f.to;o>0&&u.from<=s[o-1].toA;)l=s[o-1].fromA,h=s[o-1].fromB,o--,l<u.from&&(u=n.lineAt(l,Fi.ByPosNoHeight,i,0,0));h+=u.from-l,l=u.from;let d=Yi.build(i.setDoc(r),t,h,c);n=Hi(n,n.replace(l,a,d))}return n.updateHeight(i,0)}static empty(){return new ji(0,0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,s=0,n=0;for(;;)if(e==i)if(s>2*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))break;{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 if(s<n){let i=t[e++];i&&(s+=i.size)}else{let e=t[--i];e&&(n+=e.size)}let r=!1;return null==t[e-1]?(r=!0,e--):null==t[e]&&(r=!0,i++),new $i(zi.of(t.slice(0,e)),r,zi.of(t.slice(i)))}}function Hi(t,e){return t==e?t:(t.constructor!=e.constructor&&(Ei=!0),e)}zi.prototype.size=1;const Vi=P.replace({});class _i extends zi{constructor(t,e,i){super(t,e),this.deco=i,this.spaceAbove=0}mainBlock(t,e){return new Ii(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(t,e,i,s){return this.spaceAbove&&t<i+this.spaceAbove?new Ii(s,0,i,this.spaceAbove,Vi):this.mainBlock(i,s)}lineAt(t,e,i,s,n){let r=this.mainBlock(s,n);return this.spaceAbove?this.blockAt(0,i,s,n).join(r):r}forEachLine(t,e,i,s,n,r){t<=n+this.length&&e>=n&&r(this.lineAt(0,Fi.ByPos,i,s,n))}setMeasuredHeight(t){let e=t.heights[t.index++];e<0?(this.spaceAbove=-e,e=t.heights[t.index++]):this.spaceAbove=0,this.setHeight(e)}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ji extends _i{constructor(t,e,i){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(t,e){return new Ii(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,e,i){let s=i[0];return 1==i.length&&(s instanceof ji||s instanceof qi&&4&s.flags)&&Math.abs(this.length-s.length)<10?(s instanceof qi?s=new ji(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):zi.of(i)}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more?this.setMeasuredHeight(s):(i||this.outdated)&&(this.spaceAbove=0,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 qi extends zi{constructor(t){super(t,0)}heightMetrics(t,e){let i,s=t.doc.lineAt(e).number,n=t.doc.lineAt(e+this.length).number,r=n-s+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:s,lastLine:n,perLine:i,perChar:o}}blockAt(t,e,i,s){let{firstLine:n,lastLine:r,perLine:o,perChar:l}=this.heightMetrics(e,s);if(e.lineWrapping){let n=s+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),r=e.doc.lineAt(n),a=o+r.length*l,h=Math.max(i,t-a/2);return new Ii(r.from,r.length,h,a,0)}{let s=Math.max(0,Math.min(r-n,Math.floor((t-i)/o))),{from:l,length:a}=e.doc.line(n+s);return new Ii(l,a,i+o*s,o,0)}}lineAt(t,e,i,s,n){if(e==Fi.ByHeight)return this.blockAt(t,i,s,n);if(e==Fi.ByPosNoHeight){let{from:e,to:s}=i.doc.lineAt(t);return new Ii(e,s-e,0,0,0)}let{firstLine:r,perLine:o,perChar:l}=this.heightMetrics(i,n),a=i.doc.lineAt(t),h=o+a.length*l,c=a.number-r,u=s+o*c+l*(a.from-n-c);return new Ii(a.from,a.length,Math.max(s,Math.min(u,s+this.height-h)),h,0)}forEachLine(t,e,i,s,n,r){t=Math.max(t,n),e=Math.min(e,n+this.length);let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,n);for(let h=t,c=s;h<=e;){let e=i.doc.lineAt(h);if(h==t){let i=e.number-o;c+=l*i+a*(t-n-i)}let s=l+a*e.length;r(new Ii(e.from,e.length,c,s,0)),c+=s,h=e.to+1}}replace(t,e,i){let s=this.length-e;if(s>0){let t=i[i.length-1];t instanceof qi?i[i.length-1]=new qi(t.length+s):i.push(null,new qi(s-1))}if(t>0){let e=i[0];e instanceof qi?i[0]=new qi(t+e.length):i.unshift(new qi(t-1),null)}return zi.of(i)}decomposeLeft(t,e){e.push(new qi(t-1),null)}decomposeRight(t,e){e.push(null,new qi(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 qi(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++],l=0;n<0&&(l=-n,n=s.heights[s.index++]),-1==o?o=n:Math.abs(n-o)>=Wi&&(o=-2);let a=new ji(e,n,l);a.outdated=!1,i.push(a),r+=e+1}r<=n&&i.push(null,new qi(n-r).updateHeight(t,r));let l=zi.of(i);return(o<0||Math.abs(l.height-this.height)>=Wi||Math.abs(o-this.heightMetrics(t,e).perLine)>=Wi)&&(Ei=!0),Hi(this,l)}return(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class $i extends zi{constructor(t,e,i){super(t.length+(e?1:0)+i.length,t.height+i.height,(e?1:0)|(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 t<n?this.left.blockAt(t,e,i,s):this.right.blockAt(t,e,n,s+this.left.length+this.break)}lineAt(t,e,i,s,n){let r=s+this.left.height,o=n+this.left.length+this.break,l=e==Fi.ByHeight?t<r:t<o,a=l?this.left.lineAt(t,e,i,s,n):this.right.lineAt(t,e,i,r,o);if(this.break||(l?a.to<o:a.from>o))return a;let h=e==Fi.ByPosNoHeight?Fi.ByPosNoHeight:Fi.ByPos;return l?a.join(this.right.lineAt(o,h,i,r,o)):this.left.lineAt(o,h,i,s,n).join(a)}forEachLine(t,e,i,s,n,r){let o=s+this.left.height,l=n+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,i,s,n,r),e>=l&&this.right.forEachLine(t,e,i,o,l,r);else{let a=this.lineAt(l,Fi.ByPos,i,s,n);t<a.from&&this.left.forEachLine(t,Math.min(e,a.from-1),i,s,n,r),a.to>=t&&a.from<=e&&r(a),e>a.to&&this.right.forEachLine(Math.max(t,a.to+1),e,i,o,l,r)}}replace(t,e,i){let s=this.left.length+this.break;if(e<s)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-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&&Ki(n,r-1),e<this.length){let t=n.length;this.decomposeRight(e,n),Ki(n,t)}return zi.of(n)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,s=i+this.break;if(t>=s)return this.right.decomposeRight(t-s,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<s&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?zi.of(this.break?[t,null,e]:[t,e]):(this.left=Hi(this.left,t),this.right=Hi(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,l=null;return s&&s.from<=e+n.length&&s.more?l=n=n.updateHeight(t,e,i,s):n.updateHeight(t,e,i),s&&s.from<=o+r.length&&s.more?l=r=r.updateHeight(t,o,i,s):r.updateHeight(t,o,i),l?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 Ki(t,e){let i,s;null==t[e]&&(i=t[e-1])instanceof qi&&(s=t[e+1])instanceof qi&&t.splice(e-1,3,new qi(i.length+1+s.length))}class Yi{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 ji?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new ji(t-this.pos,-1,0)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let s=i.widget?i.widget.estimatedHeight:0,n=i.widget?i.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new _i(r,s,i)):(r||n||s>=5)&&this.addLineDeco(s,n,r)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new ji(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,e){let i=new qi(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 ji)return t;let e=new ji(0,-1,0);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 ji||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new ji(0,-1,0));let i=t;for(let t of this.nodes)t instanceof ji&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let r=new Yi(i,t);return s.om.spans(e,i,n,r,0),r.finish(i)}}class Ui{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,s){(t<e||i&&i.heightRelevant||s&&s.heightRelevant)&&I(t,e,this.changes,5)}}function Qi(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),l=Math.max(0,i.top),a=Math.min(n.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=s.body;)if(W(e)){let i=window.getComputedStyle(e);if((e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)&&"visible"!=i.overflow){let i=e.getBoundingClientRect();r=Math.max(r,i.left),o=Math.min(o,i.right),l=Math.max(l,i.top),a=Math.min(e==t.parentNode?n.innerHeight:a,i.bottom)}e="absolute"==i.position||"fixed"==i.position?e.offsetParent:e.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:l-(i.top+e),bottom:Math.max(l,a)-(i.top+e)}}function Gi(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class Xi{constructor(t,e,i,s){this.from=t,this.to=e,this.size=i,this.displaySize=s}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let s=t[i],n=e[i];if(s.from!=n.from||s.to!=n.to||s.size!=n.size)return!1}return!0}draw(t,e){return P.replace({widget:new Ji(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class Ji extends D{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class Zi{constructor(t,e){this.view=t,this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=ss,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ut.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=e.facet(Jt).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new Li(i),this.stateDeco=ns(e),this.heightMap=zi.empty().applyChanges(this.stateDeco,s.EY.empty,this.heightOracle.setDoc(e.doc),[new he(0,0,0,e.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=P.set(this.lineGaps.map((t=>t.draw(this,!1)))),this.scrollParent=t.scrollDOM,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 ts(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?ss:rs.get(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(os(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=ns(this.state);let n=t.changedRanges,r=he.extendWithRanges(n,function(t,e,i){let n=new Ui;return s.om.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:s.VR.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Bi(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||Ei)&&(t.flags|=2),l?(this.scrollAnchorPos=t.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=r.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<a.from||e.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,t.flags|=this.updateForViewport(),(h||!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(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&(t.selectionSet||t.focusChanged)&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(Ht)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:t}=this,e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?ut.RTL:ut.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||"refresh"===this.mustMeasureContent,l=e.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:t,scaleY:i}=X(e,l);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,h|=16,o=a=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==u&&this.paddingBottom==f||(this.paddingTop=u,this.paddingBottom=f,h|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(a=!0),this.editorWidth=t.scrollDOM.clientWidth,h|=16);let d=J(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=lt(this.scrollParent||t.win);let m=(this.printing?Gi:Qi)(e,this.paddingTop),g=m.top-this.pixelViewport.top,v=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(t){let e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||window;return e.left<i.innerWidth&&e.right>0&&e.top<i.innerHeight&&e.bottom>0}(t.dom))return 0;let b=l.width;if(this.contentDOMWidth==b&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=l.width,this.editorHeight=t.scrollDOM.clientHeight,h|=16),a){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(b-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:s,textHeight:l}=t.docView.measureTextSize();o=i>0&&n.refresh(r,i,s,l,Math.max(5,b/s),e),o&&(t.docView.minWidth=0,h|=16)}g>0&&v>0?c=Math.max(g,v):g<0&&v<0&&(c=Math.min(g,v)),Bi();for(let i of this.viewports){let r=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?zi.empty().applyChanges(this.stateDeco,s.EY.empty,this.heightOracle,[new he(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new Ni(i.from,r))}Ei&&(h|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(2&h&&(h|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),h|=this.updateForViewport()),(2&h||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),h}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,l=new ts(s.lineAt(r-1e3*i,Fi.ByHeight,n,0,0).from,s.lineAt(o+1e3*(1-i),Fi.ByHeight,n,0,0).to);if(e){let{head:t}=e.range;if(t<l.from||t>l.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=s.lineAt(t,Fi.ByPos,n,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<l.from?o.top:o.bottom-r,l=new ts(s.lineAt(i-500,Fi.ByHeight,n,0,0).from,s.lineAt(i+r+500,Fi.ByHeight,n,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),s=e.mapPos(t.to,1);return new ts(this.heightMap.lineAt(i,Fi.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,Fi.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(t,Fi.ByPos,this.heightOracle,0,0),{bottom:n}=this.heightMap.lineAt(e,Fi.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:o}=this;return(0==t||s<=r-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||n>=o+Math.max(10,Math.min(i,250)))&&s>r-2e3&&n<o+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let s of t)e.touchesRange(s.from,s.to)||i.push(new Xi(e.mapPos(s.from),e.mapPos(s.to),s.size,s.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,r=n>>1,o=n<<1;if(this.defaultTextDirection!=ut.LTR&&!i)return[];let l=[],a=(n,o,h,c)=>{if(o-n<r)return;let u=this.state.selection.main,f=[u.from];u.empty||f.push(u.to);for(let t of f)if(t>n&&t<o)return a(n,t-10,h,c),void a(t+10,o,h,c);let d=function(t,e){for(let i of t)if(e(i))return i}(t,(t=>t.from>=h.from&&t.to<=h.to&&Math.abs(t.from-n)<r&&Math.abs(t.to-o)<r&&!f.some((e=>t.from<e&&t.to>e))));if(!d){if(o<h.to&&e&&i&&e.visibleRanges.some((t=>t.from<=o&&t.to>=o))){let t=e.moveToLineBoundary(s.OF.cursor(o),!1,!0).head;t>n&&(o=t)}let t=this.gapSize(h,n,o,c);d=new Xi(n,o,t,i||t<2e6?t:2e6)}l.push(d)},h=e=>{if(e.length<o||e.type!=R.Text)return;let r=function(t,e,i){let n=[],r=t,o=0;return s.om.spans(i,t,e,{span(){},point(t,e){t>r&&(n.push({from:r,to:t}),o+=t-r),r=e}},20),r<e&&(n.push({from:r,to:e}),o+=e-r),{total:o,ranges:n}}(e.from,e.to,this.stateDeco);if(r.total<o)return;let l,h,c=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let t,i,s=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let n=is(r,c),o=((this.visibleBottom-this.visibleTop)/2+s)/e.height;t=n-o,i=n+o}else t=(this.visibleTop-e.top-s)/e.height,i=(this.visibleBottom-e.top+s)/e.height;l=es(r,t),h=es(r,i)}else{let i=r.total*this.heightOracle.charWidth,s=n*this.heightOracle.charWidth,o=0;if(i>2e6)for(let i of t)i.from>=e.from&&i.from<e.to&&i.size!=i.displaySize&&i.from*this.heightOracle.charWidth+o<this.pixelViewport.left&&(o=i.size-i.displaySize);let a,u,f=this.pixelViewport.left+o,d=this.pixelViewport.right+o;if(null!=c){let t=is(r,c),e=((d-f)/2+s)/i;a=t-e,u=t+e}else a=(f-s)/i,u=(d+s)/i;l=es(r,a),h=es(r,u)}l>e.from&&a(e.from,l,e,r),h<e.to&&a(h,e.to,e,r)};for(let t of this.viewportLines)Array.isArray(t.type)?t.type.forEach(h):h(t);return l}gapSize(t,e,i,s){let n=is(s,i)-is(s,e);return this.heightOracle.lineWrapping?t.height*n:s.total*this.heightOracle.charWidth*n}updateLineGaps(t){Xi.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=P.set(t.map((t=>t.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];s.om.spans(e,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let e=0;e<i.length&&!(8&n);e++){let s=this.visibleRanges[e],r=i[e];s.from==r.from&&s.to==r.to||(n|=4,t&&t.mapPos(s.from,-1)==r.from&&t.mapPos(s.to,1)==r.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||os(this.heightMap.lineAt(t,Fi.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))||os(this.heightMap.lineAt(this.scaler.fromDOM(t),Fi.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+12-this.paddingTop);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return os(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 ts{constructor(t,e){this.from=t,this.to=e}}function es({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 is(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}const ss={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};function ns(t){let e=t.facet(Zt).filter((t=>"function"!=typeof t)),i=t.facet(ee).filter((t=>"function"!=typeof t));return i.length&&e.push(s.om.join(i)),e}class rs{constructor(t,e){this.scale=t,this.viewports=e}static get(t,e,i){let s=0,n=0,r=0,o=i.map((({from:i,to:n})=>{let r=e.lineAt(i,Fi.ByPos,t,0,0).top,o=e.lineAt(n,Fi.ByPos,t,0,0).bottom;return s+=o-r,{from:i,to:n,top:r,bottom:o,domTop:0,domBottom:0}}));if(e.height-s<10)return ss;let l=(7e6-s)/(e.height-s);for(let t of o)t.domTop=r+(t.top-n)*l,r=t.domBottom=t.domTop+(t.bottom-t.top),n=t.bottom;return new rs(l,o)}toDOM(t){for(let e=0,i=0,s=0;;e++){let n=e<this.viewports.length?this.viewports[e]:null;if(!n||t<n.top)return s+(t-i)*this.scale;if(t<=n.bottom)return n.domTop+(t-n.top);i=n.bottom,s=n.domBottom}}fromDOM(t){for(let e=0,i=0,s=0;;e++){let n=e<this.viewports.length?this.viewports[e]:null;if(!n||t<n.domTop)return i+(t-s)/this.scale;if(t<=n.domBottom)return n.top+(t-n.domTop);i=n.bottom,s=n.domBottom}}eq(t){return t instanceof rs&&this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every(((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to))}}function os(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),s=e.toDOM(t.bottom);return new Ii(t.from,t.length,i,s-i,Array.isArray(t._content)?t._content.map((t=>os(t,e))):t._content)}const ls=s.sj.define({combine:t=>t.join(" ")}),as=s.sj.define({combine:t=>t.indexOf(!0)>-1}),hs=n.G.newName(),cs=n.G.newName(),us=n.G.newName(),fs={"&light":"."+cs,"&dark":"."+us};function ds(t,e,i){return new n.G(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const ps=ds("."+hs,{"&":{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":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"baseline",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},fs),ms={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},gs=S.ie&&S.ie_version<=11;class vs{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new Z,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);(S.ie&&S.ie_version<=11||S.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||!S.android||!1===t.constructor.EDIT_CONTEXT||S.chrome&&S.chrome_version<126||(this.editContext=new ys(t),t.state.facet(Kt)&&(t.contentDOM.editContext=this.editContext.editContext)),gs&&(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)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(this.pendingRecords().length>0),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])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(Kt)?i.root.activeElement!=this.dom:!_(this.dom,s))return;let n=s.anchorNode&&i.docView.tile.nearest(s.anchorNode);n&&n.isWidget()&&n.widget.ignoreEvent(t)?e||(this.selectionChanged=!1):(S.ie&&S.ie_version<=11||S.android&&S.chrome)&&!i.state.selection.main.empty&&s.focusNode&&q(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=H(t.root);if(!e)return!1;let i=S.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 bs(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?bs(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let s=_(this.dom,i);return s&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,s=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=s)return!1;for(s=Math.min(s,U(i));;)if(s){if(!W(i))return!1;let t=i.childNodes[s-1];"false"==t.contentEditable?s--:(i=t,s=U(i))}else{if(i==t)return!0;s=$(i),i=i.parentNode}}(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),s&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(W(i))!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,ms),gs&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),gs&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;t&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&ot(this.dom,t.key,t.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,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&&_(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 ti(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.selectionChanged,i=this.readChange();if(!i)return this.view.requestMeasure(),!1;let s=this.view.state,n=ii(this.view,i);return this.view.state==s&&(i.domChanged||e)&&this.view.update([]),n}readMutation(t){let e=this.view.docView.tile.nearest(t.target);if(!e||e.isWidget())return null;if(e.markDirty("attributes"==t.type),"childList"==t.type){let i=ws(e,t.previousSibling||t.target.previousSibling,-1),s=ws(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(Kt)!=t.state.facet(Kt)&&(t.view.contentDOM.editContext=t.state.facet(Kt)?this.editContext.editContext:null))}destroy(){var t,e,i;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();for(let t of this.scrollTargets)t.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 ws(t,e,i){for(;e;){let s=fe.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 bs(t,e){let i=e.startContainer,s=e.startOffset,n=e.endContainer,r=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return q(o.node,o.offset,n,r)&&([i,s,n,r]=[n,r,i,s]),{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r}}class ys{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=i=>{let n=t.state.selection.main,{anchor:r,head:o}=n,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>i.text.length;l==this.from&&r<this.from?l=r:a==this.to&&r>this.to&&(a=r);let c=ni(t.state.sliceDoc(l,a),i.text,(h?n.from:n.to)-l,h?"end":null);if(!c){let e=s.OF.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));return void(ri(e,n)||t.dispatch({selection:e,userEvent:"select"}))}let u={from:c.from+l,to:c.toA+l,insert:s.EY.of(i.text.slice(c.from,c.toB).split("\n"))};if((S.mac||S.android)&&u.from==o-1&&/^\. ?$/.test(i.text)&&"off"==t.contentDOM.getAttribute("autocorrect")&&(u={from:l,to:a,insert:s.EY.of([i.text.replace("."," ")])}),this.pendingContextChange=u,!t.state.readOnly){let e=this.to-this.from+(u.to-u.from+u.insert.length);si(t,u,s.OF.single(this.toEditorPos(i.selectionStart,e),this.toEditorPos(i.selectionEnd,e)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),u.from<u.to&&!u.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(e.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let s=[],n=null;for(let e=this.toEditorPos(i.rangeStart),r=this.toEditorPos(i.rangeEnd);e<r;e++){let i=t.coordsForChar(e);n=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||n||new DOMRect,s.push(n)}e.updateCharacterBounds(i.rangeStart,s)},this.handlers.textformatupdate=e=>{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,s=t.underlineThickness;if(!/none/i.test(e)&&!/none/i.test(s)){let n=this.toEditorPos(t.rangeStart),r=this.toEditorPos(t.rangeEnd);if(n<r){let t=`text-decoration: underline ${/^[a-z]/.test(e)?e+" ":"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${/thin/i.test(s)?1:2}px`;i.push(P.mark({attributes:{style:t}}).range(n,r))}}}t.dispatch({effects:qt.of(P.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)}};for(let t in this.handlers)e.addEventListener(t,this.handlers[t]);this.measureReq={read:t=>{let e=H(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,l,a)=>{if(i)return;let h=a.length-(r-n);if(s&&r>=s.to){if(s.from==n&&s.to==r&&s.insert.eq(a))return s=this.pendingContextChange=null,e+=h,void(this.to+=h);s=null,this.revertPending(t.state)}if(n+=e,(r+=e)<=this.from)this.from+=h,this.to+=h;else if(n<this.to){if(n<this.from||r>this.to||this.to-this.from+a.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(n),this.toContextPos(r),a.toString()),this.to+=h}e+=h})),s&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some((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.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class xs{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(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.clearAnnouncement=-1,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;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 Zi(this,t.state||s.$t.create(t)),t.scrollTo&&t.scrollTo.is(jt)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ut).map((t=>new Gt(t)));for(let t of this.plugins)t.update(this);this.observer=new vs(this),this.inputState=new oi(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Ne(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.viewState.mustMeasureContent="refresh",this.requestMeasure()}))}dispatch(...t){let e=1==t.length&&t[0]instanceof s.ZX?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 new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,r=this.state;for(let e of t){if(e.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=e.state}if(this.destroyed)return void(this.viewState.state=r);let o=this.hasFocus,l=0,a=null;t.some((t=>t.annotation(Oi)))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Ti(r,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(s.$t.phrases)!=this.state.facet(s.$t.phrases))return this.setState(r);e=ce.create(this,r,t),e.flags|=l;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(u&&(u=u.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection,{x:i,y:n}=this.state.facet(xs.cursorScrollMargin);u=new _t(t.empty?t:s.OF.cursor(t.head,t.head>t.anchor?-1:1),"nearest","nearest",n,i)}for(let t of e.effects)t.is(jt)&&(u=t.value.clip(this.state))}this.viewState.update(e,u),this.bidiCache=Cs.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(ae)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(ls)!=e.state.facet(ls)&&(this.viewState.mustMeasureContent=!0),(i||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!e.empty)for(let t of this.state.facet(Lt))try{t(e)}catch(t){$t(this.state,t,"update listener")}(a||c)&&Promise.resolve().then((()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!ii(this,c)&&h.force&&ot(this.contentDOM,h.key,h.keyCode)}))}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new Zi(this,t),this.plugins=t.facet(Ut).map((t=>new Gt(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new Ne(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(Ut),i=t.state.facet(Ut);if(e!=i){let s=[];for(let n of i){let i=e.indexOf(n);if(i<0)s.push(new Gt(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<this.plugins.length;t++)this.plugins[t].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(t){$t(this.state,t,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:n,scrollAnchorHeight:r,scaleY:o}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(r<0){if(lt(i||this.win))n=-1,r=this.viewState.heightMap.height/this.viewState.scaleY;else{let t=this.viewState.scrollAnchorAt(s);n=t.from,r=t.top}o=this.viewState.scaleY}this.updateState=1;let l=this.viewState.measure();if(!l&&!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 a=[];4&l||([this.measureRequests,a]=[a,this.measureRequests]);let h=a.map((t=>{try{return t.read(this)}catch(t){return $t(this.state,t),Ss}})),c=ce.create(this,this.state,[]),u=!1;c.flags|=l,e?e.flags|=l:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c),u&&this.docViewUpdate());for(let t=0;t<a.length;t++)if(h[t]!=Ss)try{let e=a[t];e.write&&e.write(h[t],this)}catch(t){$t(this.state,t)}if(u&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,r=-1;continue}{let t=(n<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(n).top)/this.viewState.scaleY-r/o;if((t>1||t<-1)&&!(S.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s+=t,i?n<0?i.scrollTop=i.scrollHeight:i.scrollTop+=t:this.win.scrollBy(0,t),r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(Lt))t(e)}get themeClasses(){return hs+" "+(this.state.facet(as)?us:cs)+" "+this.state.facet(ls)}updateAttrs(){let t=As(this,Xt,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Kt)?"true":"false",class:"cm-content",style:`${S.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),As(this,Jt,e);let i=this.observer.ignore((()=>{let i=O(this.contentDOM,this.contentAttrs,e),s=O(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(xs.announce)&&(e&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout((()=>{this.announceDOM.textContent=" "}),200),e=!1),this.announceDOM.appendChild(document.createElement("div")).textContent=t.value)}mountStyles(){this.styleModules=this.state.facet(ae);let t=this.state.facet(xs.cspNonce);n.G.mount(this.root,this.styleModules.concat(ps).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(2==this.updateState)throw new 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){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.plugin==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 $e(this,t,_e(this,t,e,i))}moveByGroup(t,e){return $e(this,t,_e(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),r=n(i);return t=>{let e=n(t);return r==s.Je.Space&&(r=e),r==e}}(this,t.head,e))))}visualLineSide(t,e){return e?s.OF.cursor(t.to,1):s.OF.cursor(t.from,-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let r=Ve(t,e.head,e.assoc||-1),o=n&&r.type==R.Text&&(t.lineWrapping||r.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(r.from),l=t.posAndSideAtCoords({x:i==(n==ut.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(l)return s.OF.cursor(l.pos,l.assoc)}return s.OF.cursor(i?r.to:r.from,i?1:-1)}(this,t,e,i)}moveVertically(t,e,i){return $e(this,t,function(t,e,i,n){let r=e.head,o=i?1:-1;if(r==(i?t.state.doc.length:0))return s.OF.cursor(r,e.assoc);let l,a=e.goalColumn,h=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(r,e.assoc||((e.empty?i:e.head==e.from)?1:-1)),u=t.documentTop;if(c)null==a&&(a=c.left-h.left),l=o<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(r);null==a&&(a=Math.min(h.right-h.left,t.defaultCharacterWidth*(r-e.from))),l=(o<0?e.top:e.bottom)+u}let f=h.left+a,d=t.viewState.heightOracle.textHeight>>1,p=null!=n?n:d;for(let e=0;;e+=d){let n=l+(p+e)*o,r=Ye(t,{x:f,y:n},!1,o);if(i?n>h.bottom:n<h.top)return s.OF.cursor(r.pos,r.assoc);let c=t.coordsAtPos(r.pos,r.assoc),u=c?(c.top+c.bottom)/2:0;if(!c||(i?u>l:u<l))return s.OF.cursor(r.pos,r.assoc,void 0,a)}}(this,t,e,i))}domAtPos(t,e=1){return this.docView.domAtPos(t,e)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){this.readMeasured();let i=Ye(this,t,e);return i&&i.pos}posAndSideAtCoords(t,e=!0){return this.readMeasured(),Ye(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.state.doc.lineAt(t),s=this.bidiSpans(i),n=s[xt.find(s,t-i.from,-1,e)];return i.length&&(t==i.from&&e<0||t==i.to&&e>0)&&n.dir!=this.textDirectionAt(i.from)&&(t==i.to?(t=i.from+n.from,e=1):(t=i.from+n.to,e=-1)),this.docView.coordsAt(t,e,n.dir==ut.RTL)}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(zt)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>ks)return Mt(t.length);let e,i=this.textDirectionAt(t.from);for(let s of this.bidiCache)if(s.from==t.from&&s.dir==i&&(s.fresh||kt(s.isolates,e=ne(this,t))))return s.order;e||(e=ne(this,t));let s=function(t,e,i){if(!t)return[new xt(0,0,e==dt?1:0)];if(e==ft&&!i.length&&!yt.test(t))return Mt(t.length);if(i.length)for(;t.length>St.length;)St[St.length]=256;let s=[],n=e==ft?0:1;return At(t,n,n,i,0,t.length,s),s}(t.text,i,e);return this.bidiCache.push(new Cs(t.from,t.to,i,e,!0,s)),s}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||S.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{nt(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(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){var i,n,r,o;return jt.of(new _t("number"==typeof t?s.OF.cursor(t):t,null!==(i=e.y)&&void 0!==i?i:"nearest",null!==(n=e.x)&&void 0!==n?n:"nearest",null!==(r=e.yMargin)&&void 0!==r?r:5,null!==(o=e.xMargin)&&void 0!==o?o:5))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return jt.of(new _t(s.OF.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 Qt.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return Qt.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=n.G.newName(),s=[ls.of(i),ae.of(ds(`.${i}`,t))];return e&&e.dark&&s.push(as.of(!0)),s}static baseTheme(t){return s.Nb.lowest(ae.of(ds("."+hs,t,fs)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),s=i&&fe.get(i)||fe.get(t);return(null===(e=null==s?void 0:s.root)||void 0===e?void 0:e.view)||null}}xs.styleModule=ae,xs.inputHandler=Nt,xs.clipboardInputFilter=Ft,xs.clipboardOutputFilter=Wt,xs.scrollHandler=Vt,xs.focusChangeEffect=It,xs.perLineTextDirection=zt,xs.exceptionSink=Bt,xs.updateListener=Lt,xs.editable=Kt,xs.mouseSelectionStyle=Et,xs.dragMovesSelection=Pt,xs.clickAddsSelectionRange=Rt,xs.decorations=Zt,xs.blockWrappers=te,xs.outerDecorations=ee,xs.atomicRanges=ie,xs.bidiIsolatedRanges=se,xs.cursorScrollMargin=s.sj.define({combine:t=>{let e=5,i=5;for(let s of t)"number"==typeof s?e=i=s:({x:e,y:i}=s);return{x:e,y:i}}}),xs.scrollMargins=oe,xs.darkTheme=as,xs.cspNonce=s.sj.define({combine:t=>t.length?t[0]:""}),xs.contentAttributes=Jt,xs.editorAttributes=Xt,xs.lineWrapping=xs.contentAttributes.of({class:"cm-lineWrapping"}),xs.announce=s.Pe.define();const ks=4096,Ss={};class Cs{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:ut.LTR;for(let n=Math.max(0,t.length-10);n<t.length;n++){let r=t[n];r.dir!=s||e.touchesRange(r.from,r.to)||i.push(new Cs(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return i}}function As(t,e,i){for(let s=t.state.facet(e),n=s.length-1;n>=0;n--){let e=s[n],r="function"==typeof e?e(t):e;r&&C(r,i)}return i}const Ms=S.mac?"mac":S.windows?"win":S.linux?"linux":"key";function Os(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}const Ts=s.Nb.default(xs.domEventHandlers({keydown:(t,e)=>Is(Ps(e.state),t,e,"editor")})),Ds=s.sj.define({enables:Ts}),Rs=new WeakMap;function Ps(t){let e=t.facet(Ds),i=Rs.get(e);return i||Rs.set(e,i=function(t,e=Ms){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 new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},r=(t,s,r,o,l)=>{var a,h;let c=i[t]||(i[t]=Object.create(null)),u=s.split(/ (?!$)/).map((t=>function(t,e){const i=t.split(/-(?!$)/);let s,n,r,o,l=i[i.length-1];"Space"==l&&(l=" ");for(let t=0;t<i.length-1;++t){const l=i[t];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))s=!0;else if(/^(c|ctrl|control)$/i.test(l))n=!0;else if(/^s(hift)?$/i.test(l))r=!0;else{if(!/^mod$/i.test(l))throw new Error("Unrecognized modifier name: "+l);"mac"==e?o=!0:n=!0}}return s&&(l="Alt-"+l),n&&(l="Ctrl-"+l),o&&(l="Meta-"+l),r&&(l="Shift-"+l),l}(t,e)));for(let e=1;e<u.length;e++){let i=u.slice(0,e).join(" ");n(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[e=>{let s=Bs={view:e,prefix:i,scope:t};return setTimeout((()=>{Bs==s&&(Bs=null)}),Ls),!0}]})}let f=u.join(" ");n(f,!1);let d=c[f]||(c[f]={preventDefault:!1,stopPropagation:!1,run:(null===(h=null===(a=c._any)||void 0===a?void 0:a.run)||void 0===h?void 0:h.slice())||[]});r&&d.run.push(r),o&&(d.preventDefault=!0),l&&(d.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}(e.reduce(((t,e)=>t.concat(e)),[]))),i}function Es(t,e,i){return Is(Ps(t.state),e,t,i)}let Bs=null;const Ls=4e3;let Ns=null;function Is(t,e,i,n){Ns=e;let h=function(t){var e=!(l&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||a&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?o:r)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(e),c=(0,s.vS)(h,0),u=(0,s.Fh)(c)==h.length&&" "!=h,f="",d=!1,p=!1,m=!1;Bs&&Bs.view==i&&Bs.scope==n&&(f=Bs.prefix+" ",ui.indexOf(e.keyCode)<0&&(p=!0,Bs=null));let g,v,w=new Set,b=t=>{if(t){for(let e of t.run)if(!w.has(e)&&(w.add(e),e(i)))return t.stopPropagation&&(m=!0),!0;t.preventDefault&&(t.stopPropagation&&(m=!0),p=!0)}return!1},y=t[n];return y&&(b(y[f+Os(h,e,!u)])?d=!0:!u||!(e.altKey||e.metaKey||e.ctrlKey)||S.windows&&e.ctrlKey&&e.altKey||S.mac&&e.altKey&&!e.ctrlKey&&!e.metaKey||!(g=r[e.keyCode])||g==h?u&&e.shiftKey&&b(y[f+Os(h,e,!0)])&&(d=!0):(b(y[f+Os(g,e,!0)])||e.shiftKey&&(v=o[e.keyCode])!=h&&v!=g&&b(y[f+Os(v,e,!1)]))&&(d=!0),!d&&b(y._any)&&(d=!0)),p&&(d=!0),d&&m&&e.stopPropagation(),Ns=null,d}class Fs{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){let s=t.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let n=Ws(t);return[new Fs(e,s.left-n.left,s.top-n.top,null,s.bottom-s.top)]}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==ut.LTR,o=t.contentDOM,l=o.getBoundingClientRect(),a=Ws(t),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),u=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),f=l.right-(c?parseInt(c.paddingRight):0),d=Ve(t,s,1),p=Ve(t,n,-1),m=d.type==R.Text?d:null,g=p.type==R.Text?p:null;if(m&&(t.lineWrapping||d.widgetLineBreaks)&&(m=zs(t,s,1,m)),g&&(t.lineWrapping||p.widgetLineBreaks)&&(g=zs(t,n,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return w(b(i.from,i.to,m));{let e=m?b(i.from,null,m):y(d,!1),s=g?b(null,i.to,g):y(p,!0),n=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2<s.top?n.push(v(u,e.bottom,f,s.top)):e.bottom<s.top&&t.elementAtHeight((e.bottom+s.top)/2).type==R.Text&&(e.bottom=s.top=(e.bottom+s.top)/2),w(e).concat(n).concat(w(s))}function v(t,i,s,n){return new Fs(e,t-a.left,i-a.top,Math.max(0,s-t),n-i)}function w({top:t,bottom:e,horizontal:i}){let s=[];for(let n=0;n<i.length;n+=2)s.push(v(i[n],t,i[n+1],e));return s}function b(e,i,s){let n=1e9,o=-1e9,l=[];function a(e,i,a,h,c){let d=t.coordsAtPos(e,e==s.to?-2:2),p=t.coordsAtPos(a,a==s.from?2:-2);d&&p&&(n=Math.min(d.top,p.top,n),o=Math.max(d.bottom,p.bottom,o),c==ut.LTR?l.push(r&&i?u:d.left,r&&h?f:p.right):l.push(!r&&h?u:p.left,!r&&i?f:d.right))}let h=null!=e?e:s.from,c=null!=i?i:s.to;for(let s of t.visibleRanges)if(s.to>h&&s.from<c)for(let n=Math.max(s.from,h),r=Math.min(s.to,c);;){let s=t.state.doc.lineAt(n);for(let o of t.bidiSpans(s)){let t=o.from+s.from,l=o.to+s.from;if(t>=r)break;l>n&&a(Math.max(t,n),null==e&&t<=h,Math.min(l,r),null==i&&l>=c,o.dir)}if(n=s.to+1,n>=r)break}return 0==l.length&&a(h,null==e,c,null==i,t.textDirection),{top:n,bottom:o,horizontal:l}}function y(t,e){let i=l.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(t,e,i)}}function Ws(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==ut.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function zs(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,l=t.posAtCoords({x:r.left+1,y:o}),a=t.posAtCoords({x:r.right-1,y:o});return null==l||null==a?s:{from:Math.max(s.from,Math.min(l,a)),to:Math.min(s.to,Math.max(l,a))}}class Hs{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(Vs)!=t.state.facet(Vs)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){!1!==this.layer.updateOnDocViewUpdate&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(Vs);for(;e<i.length&&i[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;t==this.scaleX&&e==this.scaleY||(this.scaleX=t,this.scaleY=e,this.dom.style.transform=`scale(${1/t}, ${1/e})`)}draw(t){if(t.length!=this.drawn.length||t.some(((t,e)=>{return i=t,s=this.drawn[e],!(i.constructor==s.constructor&&i.eq(s));var i,s}))){let e=this.dom.firstChild,i=0;for(let s of t)s.update&&e&&s.constructor&&this.drawn[i].constructor&&s.update(e,this.drawn[i])?(e=e.nextSibling,i++):this.dom.insertBefore(s.draw(),e);for(;e;){let t=e.nextSibling;e.remove(),e=t}this.drawn=t,S.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Vs=s.sj.define();function _s(t){return[Qt.define((e=>new Hs(e,t))),Vs.of(t)]}const js=!S.ios,qs=s.sj.define({combine:t=>(0,s.QR)(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function $s(t={}){return[qs.of(t),Ys,Qs,Xs,Ht.of(!0)]}function Ks(t){return t.startState.facet(qs)!=t.state.facet(qs)}const Ys=_s({above:!0,markers(t){let{state:e}=t,i=e.facet(qs),n=[];for(let r of e.selection.ranges){let o=r==e.selection.main;if(r.empty||i.drawRangeCursor&&!(o&&S.ios&&i.iosSelectionHandles)){let e=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=r.empty?r:s.OF.cursor(r.head,r.assoc);for(let s of Fs.forRange(t,e,i))n.push(s)}}return n},update(t,e){t.transactions.some((t=>t.selection))&&(e.style.animationName="cm-blink"==e.style.animationName?"cm-blink2":"cm-blink");let i=Ks(t);return i&&Us(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){Us(e.state,t)},class:"cm-cursorLayer"});function Us(t,e){e.style.animationDuration=t.facet(qs).cursorBlinkRate+"ms"}const Qs=_s({above:!1,markers(t){let e=[],{main:i,ranges:n}=t.state.selection;for(let s of n)if(!s.empty&&(js||s!=i))for(let i of Fs.forRange(t,"cm-selectionBackground",s))e.push(i);if(S.ios&&!i.empty&&t.state.facet(qs).iosSelectionHandles){for(let n of Fs.forRange(t,"cm-selectionHandle cm-selectionHandle-start",s.OF.cursor(i.from,1)))e.push(n);for(let n of Fs.forRange(t,"cm-selectionHandle cm-selectionHandle-end",s.OF.cursor(i.to,1)))e.push(n)}return e},update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||Ks(t),class:"cm-selectionLayer"}),Gs=S.gecko&&153==S.gecko_version?"#ffffff01":"transparent",Xs=s.Nb.highest(xs.theme({".cm-line":{...js?{"& ::selection, &::selection":{backgroundColor:`${Gs} !important`}}:{},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important",...js?{"&::selection, & ::selection":{backgroundColor:"Highlight !important"}}:{}}}})),Js=s.Pe.define({map:(t,e)=>null==t?null:e.mapPos(t)}),Zs=s.sU.define({create:()=>null,update:(t,e)=>(null!=t&&(t=e.changes.mapPos(t)),e.effects.reduce(((t,e)=>e.is(Js)?e.value:t),t))}),tn=Qt.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let i=t.state.field(Zs);null==i?null!=this.cursor&&(null===(e=this.cursor)||void 0===e||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(Zs)!=i||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:t}=this,e=t.state.field(Zs),i=null!=e&&t.coordsAtPos(e);if(!i)return null;let s=t.scrollDOM.getBoundingClientRect();return{left:i.left-s.left+t.scrollDOM.scrollLeft*t.scaleX,top:i.top-s.top+t.scrollDOM.scrollTop*t.scaleY,height:i.bottom-i.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:i}=this.view;t?(this.cursor.style.left=t.left/e+"px",this.cursor.style.top=t.top/i+"px",this.cursor.style.height=t.height/i+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(Zs)!=t&&this.view.dispatch({effects:Js.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){t.target!=this.view.contentDOM&&this.view.contentDOM.contains(t.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function en(){return[Zs,tn]}function sn(t,e,i,s,n){e.lastIndex=0;for(let r,o=t.iterRange(i,s),l=i;!o.next().done;l+=o.value.length)if(!o.lineBreak)for(;r=e.exec(o.value);)n(l+r.index,r)}class nn{constructor(t){const{regexp:e,decoration:i,decorate:s,boundary:n,maxLength:r=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,s)this.addMatch=(t,e,i,n)=>s(n,i,i+t[0].length,t,e);else if("function"==typeof i)this.addMatch=(t,e,s,n)=>{let r=i(t,e,s);r&&n(s,s+t[0].length,r)};else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(t,e,s,n)=>n(s,s+t[0].length,i)}this.boundary=n,this.maxLength=r}createDeco(t){let e=new s.vB,i=e.add.bind(e);for(let{from:e,to:s}of function(t,e){let i=t.visibleRanges;if(1==i.length&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let s=[];for(let{from:n,to:r}of i)n=Math.max(t.state.doc.lineAt(n).from,n-e),r=Math.min(t.state.doc.lineAt(r).to,r+e),s.length&&s[s.length-1].to>=n?s[s.length-1].to=r:s.push({from:n,to:r});return s}(t,this.maxLength))sn(t.state.doc,this.regexp,e,s,((e,s)=>this.addMatch(s,t,e,i)));return e.finish()}updateDeco(t,e){let i=1e9,s=-1;return t.docChanged&&t.changes.iterChanges(((e,n,r,o)=>{o>=t.view.viewport.from&&r<=t.view.viewport.to&&(i=Math.min(r,i),s=Math.max(o,s))})),t.viewportMoved||s-i>1e3?this.createDeco(t.view):s>-1?this.updateRange(t.view,e.map(t.changes),i,s):e}updateRange(t,e,i,s){for(let n of t.visibleRanges){let r=Math.max(n.from,i),o=Math.min(n.to,s);if(o>=r){let i=t.state.doc.lineAt(r),s=i.to<o?t.state.doc.lineAt(o):i,l=Math.max(n.from,i.from),a=Math.min(n.to,s.to);if(this.boundary){for(;r>i.from;r--)if(this.boundary.test(i.text[r-1-i.from])){l=r;break}for(;o<s.to;o++)if(this.boundary.test(s.text[o-s.from])){a=o;break}}let h,c=[],u=(t,e,i)=>c.push(i.range(t,e));if(i==s)for(this.regexp.lastIndex=l-i.from;(h=this.regexp.exec(i.text))&&h.index<a-i.from;)this.addMatch(h,t,h.index+i.from,u);else sn(t.state.doc,this.regexp,l,a,((e,i)=>this.addMatch(i,t,e,u)));e=e.update({filterFrom:l,filterTo:a,filter:(t,e)=>t<l||e>a,add:c})}}return e}}const rn=null!=/x/.unicode?"gu":"g",on=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",rn),ln={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let an=null;const hn=s.sj.define({combine(t){let e=(0,s.QR)(t,{render:null,specialChars:on,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==an&&"undefined"!=typeof document&&document.body){let e=document.body.style;an=null!=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)}return an||!1}())&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,rn)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,rn)),e}});function cn(t={}){return[hn.of(t),un||(un=Qt.fromClass(class{constructor(t){this.view=t,this.decorations=P.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(hn)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new nn({regexp:t.specialChars,decoration:(e,i,n)=>{let{doc:r}=i.state,o=(0,s.vS)(e[0],0);if(9==o){let t=r.lineAt(n),e=i.state.tabSize,o=(0,s.y$)(t.text,e,n-t.from);return P.replace({widget:new dn((e-o%e)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=P.replace({widget:new fn(t,o)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(hn);t.startState.facet(hn)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))]}let un=null;class fn extends D{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=function(t){return t>=32?"•":10==t?"␤":String.fromCharCode(9216+t)}(this.code),i=t.state.phrase("Control character")+" "+(ln[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,e);if(s)return s;let n=document.createElement("span");return n.textContent=e,n.title=i,n.setAttribute("aria-label",i),n.className="cm-specialChar",n}ignoreEvent(){return!1}}class dn extends D{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent="\t",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function pn(){return gn}const mn=P.line({class:"cm-activeLine"}),gn=Qt.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let s of t.state.selection.ranges){let n=t.lineBlockAt(s.head);n.from>e&&(i.push(mn.range(n.from)),e=n.from)}return P.set(i)}},{decorations:t=>t.decorations}),vn=2e3;function wn(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(i),r=i-n.from,o=r>vn?-1:r==n.length?function(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}(t,e.clientX):(0,s.y$)(n.text,t.state.tabSize,i-n.from);return{line:n.number,col:o,off:r}}function bn(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return xs.mouseSelectionStyle.of(((t,i)=>e(i)?function(t,e){let i=wn(t,e),n=t.state.selection;return i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from),s=t.state.doc.lineAt(e);i={line:s.number,col:i.col,off:Math.min(i.off,s.length)},n=n.map(t.changes)}},get(e,r,o){let l=wn(t,e);if(!l)return n;let a=function(t,e,i){let n=Math.min(e.line,i.line),r=Math.max(e.line,i.line),o=[];if(e.off>vn||i.off>vn||e.col<0||i.col<0){let l=Math.min(e.off,i.off),a=Math.max(e.off,i.off);for(let e=n;e<=r;e++){let i=t.doc.line(e);i.length<=a&&o.push(s.OF.range(i.from+l,i.to+a))}}else{let l=Math.min(e.col,i.col),a=Math.max(e.col,i.col);for(let e=n;e<=r;e++){let i=t.doc.line(e),n=(0,s.kn)(i.text,l,t.tabSize,!0);if(n<0)o.push(s.OF.cursor(i.to));else{let e=(0,s.kn)(i.text,a,t.tabSize);o.push(s.OF.range(i.from+n,i.from+e))}}}return o}(t.state,i,l);return a.length?o?s.OF.create(a.concat(n.ranges)):s.OF.create(a):n}}:null}(t,i):null))}const yn={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},xn={style:"cursor: crosshair"};function kn(t={}){let[e,i]=yn[t.key||"Alt"],s=Qt.fromClass(class{constructor(t){this.view=t,this.isDown=!1}set(t){this.isDown!=t&&(this.isDown=t,this.view.update([]))}},{eventObservers:{keydown(t){this.set(t.keyCode==e||i(t))},keyup(t){t.keyCode!=e&&i(t)||this.set(!1)},mousemove(t){this.set(i(t))}}});return[s,xs.contentAttributes.of((t=>{var e;return(null===(e=t.plugin(s))||void 0===e?void 0:e.isDown)?xn:null}))]}const Sn="-10000px";class Cn{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;i<n.length;i++){let s=n[i],l=-1;if(s){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==s.create&&(l=t)}if(l<0)r[i]=this.createTooltipView(s,i?r[i-1]:null),o&&(o[i]=!!s.above);else{let s=r[i]=this.tooltipViews[l];o&&(o[i]=e[l]),s.update&&s.update(t)}}}for(let t of this.tooltipViews)r.indexOf(t)<0&&(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 An(t){let e=t.dom.ownerDocument.documentElement,i=e.clientWidth,s=getComputedStyle(e);if(!/stable/.test(s.scrollbarGutter||""))return{left:0,right:i};let n=e.getBoundingClientRect(),r=t.win.scrollX;return{left:Math.max(0,n.left+r-parseFloat(s.marginLeft)),right:Math.min(i,n.right+r+parseFloat(s.marginRight))}}function Mn(t){let{left:e,right:i}=An(t);return{top:0,left:e,right:i,bottom:t.dom.ownerDocument.documentElement.clientHeight}}const On=s.sj.define({combine:t=>{var e,i,s;return{position:S.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)||Mn}}}),Tn=new WeakMap,Dn=Qt.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(On);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 Cn(t,Bn,((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){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout((()=>{this.measureTimeout=-1,this.maybeMeasure()}),50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let i=e||t.geometryChanged,s=t.state.facet(On);if(s.position!=this.position&&!this.madeAbsolute){this.position=s.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;i=!0}if(s.parent!=this.parent){this.parent&&this.container.remove(),this.parent=s.parent,this.createContainer();for(let t of 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=Sn,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;this.view.win.removeEventListener("resize",this.measureSoon);for(let e of 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,s=0;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(S.safari){let e=t.getBoundingClientRect();i=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}else i=!!t.offsetParent&&t.offsetParent!=this.container.ownerDocument.body}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);else s=An(this.view).left;let n=this.view.scrollDOM.getBoundingClientRect(),r=le(this.view);return{visible:{left:n.left+r.left,top:n.top+r.top,right:n.right-r.right,bottom:n.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map(((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(On).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:i,fixedLeft:s}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let t of this.manager.tooltipViews)t.dom.style.position="absolute"}let{visible:i,space:s,scaleX:n,scaleY:r}=t,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,u=t.pos[l],f=t.size[l];if(!u||!1!==a.clip&&(u.bottom<=Math.max(i.top,s.top)||u.top>=Math.min(i.bottom,s.bottom)||u.right<Math.max(i.left,s.left)-.1||u.left>Math.min(i.right,s.right)+.1)){c.style.top=Sn;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=f.right-f.left,g=null!==(e=Tn.get(h))&&void 0!==e?e:f.bottom-f.top,v=h.offset||En,w=this.view.textDirection==ut.LTR,b=f.width>s.right-s.left?w?s.left:s.right-f.width:w?Math.max(s.left,Math.min(u.left-(d?14:0)+v.x,s.right-m)):Math.min(Math.max(s.left,u.left-m+(d?14:0)-v.x),s.right-m),y=this.above[l];!a.strictSide&&(y?u.top-g-p-v.y<s.top:u.bottom+g+p+v.y>s.bottom)&&y==s.bottom-u.bottom>u.top-s.top&&(y=this.above[l]=!y);let x=(y?u.top-s.top:s.bottom-u.bottom)-p;if(x<g&&!1!==h.resize){if(x<this.view.defaultLineHeight){c.style.top=Sn;continue}Tn.set(h,g),c.style.height=(g=x)/r+"px"}else c.style.height&&(c.style.height="");let k=y?u.top-g-p-v.y:u.bottom+p+v.y,S=b+m;if(!0!==h.overlap)for(let t of o)t.left<S&&t.right>b&&t.top<k+g&&t.bottom>k&&(k=y?t.top-g-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(k-t.parent.top)/r+"px",Rn(c,(b-t.parent.left)/n)):(c.style.top=k/r+"px",Rn(c,(b-t.fixedLeft)/n)),d){let t=u.left+(w?v.x:-v.x)-(b+14-7);d.style.left=t/n+"px"}!0!==h.overlap&&o.push({left:b,top:k,right:S,bottom:k+g}),c.classList.toggle("cm-tooltip-above",y),c.classList.toggle("cm-tooltip-below",!y),h.positioned&&h.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=Sn}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Rn(t,e){let i=parseInt(t.style.left,10);(isNaN(i)||Math.abs(e-i)>1)&&(t.style.left=e+"px")}const Pn=xs.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"}}}),En={x:0,y:0},Bn=s.sj.define({enables:[Dn,Pn]}),Ln=s.sj.define({combine:t=>t.reduce(((t,e)=>t.concat(e)),[])});class Nn{static create(t){return new Nn(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Cn(t,Ln,((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")}}const In=Bn.compute([Ln],(t=>{let e=t.facet(Ln);return 0===e.length?null:{pos:Math.min(...e.map((t=>t.pos))),end:Math.max(...e.map((t=>{var e;return null!==(e=t.end)&&void 0!==e?e:t.pos}))),create:Nn.create,above:e[0].above,arrow:e.some((t=>t.arrow))}})),Fn=s.sj.define();class Wn{constructor(t,e,i,s,n,r){this.view=t,this.source=e,this.field=i,this.locked=s,this.setHover=n,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(t){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout((()=>this.startHover()),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,i=t.docView.tile.nearest(e.target);if(!i)return;let s,n=1;if(i.isWidget())s=i.posAtStart;else{if(s=t.posAtCoords(e),null==s)return;let i=t.coordsAtPos(s);if(!i||e.y<i.top||e.y>i.bottom||e.x<i.left-t.defaultCharacterWidth||e.x>i.right+t.defaultCharacterWidth)return;let r=t.bidiSpans(t.state.doc.lineAt(s)).find((t=>t.from<=s&&t.to>=s)),o=r&&r.dir==ut.RTL?-1:1;n=e.x<i.left?-o:o}this.activateHover(t,s,n)}activateHover(t,e,i,s){let n=this.source(t,e,i),r=e=>{if(e&&(!Array.isArray(e)||e.length)){let i=Array.isArray(e)?e:[e];s&&this.locked.set(i,s),t.dispatch({effects:this.setHover.of(i)})}};if(n&&"then"in n){let i=this.pending={pos:e};n.then((t=>{this.pending==i&&(this.pending=null,r(t))}),(e=>$t(t.state,e,"hover tooltip")))}else r(n)}get tooltip(){let t=this.view.plugin(Dn),e=t?t.manager.tooltips.findIndex((t=>t.create==Nn.create)):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:n}=this;if(s.length&&!this.locked.has(s)&&n&&!function(t,e){let i,{left:s,right:n,top:r,bottom:o}=t.getBoundingClientRect();if(i=t.querySelector(".cm-tooltip-arrow")){let t=i.getBoundingClientRect();r=Math.min(t.top,r),o=Math.max(t.bottom,o)}return e.clientX>=s-zn&&e.clientX<=n+zn&&e.clientY>=r-zn&&e.clientY<=o+zn}(n.dom,t)||this.pending){let{pos:n}=s[0]||this.pending,r=null!==(i=null===(e=s[0])||void 0===e?void 0:e.end)&&void 0!==i?i:n;(n==r?this.view.posAtCoords(this.lastMove)==n:function(t,e,i,s,n){let r=t.scrollDOM.getBoundingClientRect(),o=t.documentTop+t.documentPadding.top+t.contentHeight;if(r.left>s||r.right<s||r.top>n||Math.min(r.bottom,o)<n)return!1;let l=t.posAtCoords({x:s,y:n},!1);return l>=e&&l<=i}(this.view,n,r,t.clientX,t.clientY))||(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e.length&&!this.locked.has(e)){let{tooltip:e}=this;e&&e.dom.contains(t.relatedTarget)?this.watchTooltipLeave(e.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e);let{active:s}=this;!s.length||this.locked.has(s)||this.view.dom.contains(i.relatedTarget)||this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const zn=4;function Hn(t,e={}){let i=s.Pe.define(),n=new WeakMap,r=s.sU.define({create:()=>[],update(t,o){let l=n.get(t);if(t.length&&(e.hideOnChange&&(o.docChanged||o.selection)||l&&l(o)?t=[]:e.hideOn&&(t=t.filter((t=>!e.hideOn(o,t))))),o.docChanged&&t.length){let e=[];for(let i of t){let t=o.changes.mapPos(i.pos,-1,s.iR.TrackDel);if(null!=t){let s=Object.assign(Object.create(null),i);s.pos=t,null!=s.end&&(s.end=o.changes.mapPos(s.end)),e.push(s)}}t=e}for(let e of o.effects)e.is(i)&&(t=e.value,l=void 0),(e.is(jn)&&!e.value||e.value==r)&&(t=[]);return t.length&&l&&n.set(t,l),t},provide:t=>Ln.from(t)});const o=Qt.define((s=>new Wn(s,t,r,n,i,e.hoverTime||300)));return{active:r,extension:[r,o,Fn.of(o),In]}}function Vn(t,e,i,s={}){var n;let r=t.state.facet(Fn).map((e=>t.plugin(e))).filter((t=>!!t));if(s.tooltip&&s.tooltip.active){let t=r.find((t=>t.field==s.tooltip.active));t&&(r=[t])}for(let o of r)o.activateHover(t,e,i,null!==(n=s.until)&&void 0!==n?n:()=>!1)}function _n(t,e){let i=t.plugin(Dn);if(!i)return null;let s=i.manager.tooltips.indexOf(e);return s<0?null:i.manager.tooltipViews[s]}const jn=s.Pe.define(),qn=s.sj.define({combine(t){let e,i;for(let s of t)e=e||s.topContainer,i=i||s.bottomContainer;return{topContainer:e,bottomContainer:i}}});function $n(t,e){let i=t.plugin(Kn),s=i?i.specs.indexOf(e):-1;return s>-1?i.panels[s]:null}const Kn=Qt.fromClass(class{constructor(t){this.input=t.state.facet(Qn),this.specs=this.input.filter((t=>t)),this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(qn);this.top=new Yn(t,!0,e.topContainer),this.bottom=new Yn(t,!1,e.bottomContainer),this.top.sync(this.panels.filter((t=>t.top))),this.bottom.sync(this.panels.filter((t=>!t.top)));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(t){let e=t.state.facet(qn);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Yn(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Yn(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Qn);if(i!=this.input){let e=i.filter((t=>t)),s=[],n=[],r=[],o=[];for(let i of e){let e,l=this.specs.indexOf(i);l<0?(e=i(t.view),o.push(e)):(e=this.panels[l],e.update&&e.update(t)),s.push(e),(e.top?n:r).push(e)}this.specs=e,this.panels=s,this.top.sync(n),this.bottom.sync(r);for(let t of 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=>xs.scrollMargins.of((e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class Yn{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";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=Un(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Un(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 Un(t){let e=t.nextSibling;return t.remove(),e}const Qn=s.sj.define({enables:Kn});function Gn(t,e){let i,n=new Promise((t=>i=t)),r=t=>function(t,e,i){let s=e.content?e.content(t,(()=>l(null))):null;if(!s){if(s=(0,u.A)("form"),e.input){let t=(0,u.A)("input",e.input);/^(text|password|number|email|tel|url)$/.test(t.type)&&t.classList.add("cm-textfield"),t.name||(t.name="input"),s.appendChild((0,u.A)("label",(e.label||"")+": ",t))}else s.appendChild(document.createTextNode(e.label||""));s.appendChild(document.createTextNode(" ")),s.appendChild((0,u.A)("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let n="FORM"==s.nodeName?[s]:s.querySelectorAll("form");for(let t=0;t<n.length;t++){let e=n[t];e.addEventListener("keydown",(t=>{27==t.keyCode?(t.preventDefault(),l(null)):13==t.keyCode&&(t.preventDefault(),l(e))})),e.addEventListener("submit",(t=>{t.preventDefault(),l(e)}))}let r=(0,u.A)("div",s,(0,u.A)("button",{onclick:()=>l(null),"aria-label":t.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");let o="string"==typeof e.focus?s.querySelector(e.focus):e.focus?s.querySelector("input")||s.querySelector("button"):null;function l(e){r.contains(r.ownerDocument.activeElement)&&t.focus(),i(e)}return{dom:r,top:e.top,mount:()=>{o&&("select"in o?o.select():"focus"in o&&o.focus())},destroy:()=>i(null)}}(t,e,i);t.state.field(Jn,!1)?t.dispatch({effects:Zn.of(r)}):t.dispatch({effects:s.Pe.appendConfig.of(Jn.init((()=>[r])))});let o=tr.of(r);return{close:o,result:n.then((e=>((t.win.queueMicrotask||(e=>t.win.setTimeout(e,10)))((()=>{t.state.field(Jn).indexOf(r)>-1&&t.dispatch({effects:o})})),e)))}}function Xn(t,e){let i=t.state.field(Jn,!1)||[];for(let s of i){let i=$n(t,s);if(i&&i.dom.classList.contains(e))return i}return null}const Jn=s.sU.define({create:()=>[],update(t,e){for(let i of e.effects)i.is(Zn)?t=[i.value].concat(t):i.is(tr)&&(t=t.filter((t=>t!=i.value)));return t},provide:t=>Qn.computeN([t],(e=>e.field(t)))}),Zn=s.Pe.define(),tr=s.Pe.define();class er extends s.FB{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}er.prototype.elementClass="",er.prototype.toDOM=void 0,er.prototype.mapMode=s.iR.TrackBefore,er.prototype.startSide=er.prototype.endSide=-1,er.prototype.point=!0;const ir=s.sj.define(),sr=s.sj.define(),nr={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>s.om.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},rr=s.sj.define();function or(t){return[ar(),rr.of({...nr,...t})]}const lr=s.sj.define({combine:t=>t.some((t=>t))});function ar(t){let e=[hr];return t&&!1===t.fixed&&e.push(lr.of(!0)),e}const hr=Qt.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(rr).map((e=>new dr(t,e))),this.fixed=!t.state.facet(lr);for(let t of this.gutters)"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,s=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(s<.8*(i.to-i.from))}if(t.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(lr)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let i=s.om.iter(this.view.state.facet(ir),this.view.viewport.from),n=[],r=this.gutters.map((t=>new fr(t,this.view.viewport,-this.view.documentPadding.top)));for(let t of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(t.type)){let e=!0;for(let s of t.type)if(s.type==R.Text&&e){ur(i,n,s.from);for(let t of r)t.line(this.view,s,n);e=!1}else if(s.widget)for(let t of r)t.widget(this.view,s)}else if(t.type==R.Text){ur(i,n,t.from);for(let e of r)e.line(this.view,t,n)}else if(t.widget)for(let e of r)e.widget(this.view,t);for(let t of r)t.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(rr),i=t.state.facet(rr),n=t.docChanged||t.heightChanged||t.viewportChanged||!s.om.eq(t.startState.facet(ir),t.state.facet(ir),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(n=!0);else{n=!0;let s=[];for(let n of i){let i=e.indexOf(n);i<0?s.push(new dr(this.view,n)):(this.gutters[i].update(t),s.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),s.indexOf(t)<0&&t.destroy();for(let t of s)"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.gutters=s}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>xs.scrollMargins.of((e=>{let i=e.plugin(t);if(!i||0==i.gutters.length||!i.fixed)return null;let s=i.dom.offsetWidth*e.scaleX,n=i.domAfter?i.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==ut.LTR?{left:s,right:n}:{right:s,left:n}}))});function cr(t){return Array.isArray(t)?t:[t]}function ur(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class fr{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=s.om.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 pr(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=[];ur(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(sr)){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 dr{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,(s=>{let n,r=s.target;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let t=r.getBoundingClientRect();n=(t.top+t.bottom)/2}else n=s.clientY;let o=t.lineBlockAtHeight(n-t.documentTop);e.domEventHandlers[i](t,o,s)&&s.preventDefault()}));this.markers=cr(e.markers(t)),e.initialSpacer&&(this.spacer=new pr(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=cr(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!s.om.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 pr{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;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}(this.markers,s)||this.setMarkers(t,s)}setMarkers(t,e){let i="cm-gutterElement",s=this.dom.firstChild;for(let n=0,r=0;;){let o=r,l=n<e.length?e[n++]:null,a=!1;if(l){let t=l.elementClass;t&&(i+=" "+t);for(let t=r;t<this.markers.length;t++)if(this.markers[t].compare(l)){o=t,a=!0;break}}else o=this.markers.length;for(;r<o;){let t=this.markers[r++];if(t.toDOM){t.destroy(s);let e=s.nextSibling;s.remove(),s=e}}if(!l)break;l.toDOM&&(a?s=s.nextSibling:this.dom.insertBefore(l.toDOM(t),s)),a&&r++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}const mr=s.sj.define(),gr=s.sj.define(),vr=s.sj.define({combine:t=>(0,s.QR)(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 wr extends er{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function br(t,e){return t.state.facet(vr).formatNumber(e,t.state)}const yr=rr.compute([vr],(t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(mr),lineMarker:(t,e,i)=>i.some((t=>t.toDOM))?null:new wr(br(t,t.state.doc.lineAt(e.from).number)),widgetMarker:(t,e,i)=>{for(let s of t.state.facet(gr)){let n=s(t,e,i);if(n)return n}return null},lineMarkerChange:t=>t.startState.facet(vr)!=t.state.facet(vr),initialSpacer:t=>new wr(br(t,kr(t.state.doc.lines))),updateSpacer(t,e){let i=br(e.view,kr(e.view.state.doc.lines));return i==t.number?t:new wr(i)},domEventHandlers:t.facet(vr).domEventHandlers,side:"before"})));function xr(t={}){return[vr.of(t),ar(),yr]}function kr(t){let e=9;for(;e<t;)e=10*e+9;return e}const Sr=new class extends er{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Cr=ir.compute(["selection"],(t=>{let e=[],i=-1;for(let s of t.selection.ranges){let n=t.doc.lineAt(s.head).from;n>i&&(i=n,e.push(Sr.range(n)))}return s.om.of(e)}));function Ar(){return Cr}},7417:(t,e,i)=>{i.d(e,{G:()=>o});const s="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),n="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class o{constructor(t,e){this.rules=[];let{finish:i}=e||{};function s(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function n(t,e,r,o){let l=[],a=/^@(\w+)\b/.exec(t[0]),h=a&&"keyframes"==a[1];if(a&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))n(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!a)throw new RangeError("The value of a property ("+i+") should be a primitive value.");n(s(i),o,l,h)}else null!=o&&l.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(l.length||h)&&r.push((!i||a||o?t:t.map(i)).join(", ")+" {"+l.join(" ")+"}")}for(let e in t)n(s(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=r[s]||1;return r[s]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let s=t[n],r=i&&i.nonce;s?r&&s.setNonce(r):s=new a(t,r),s.mount(Array.isArray(e)?e:[e],t)}}let l=new Map;class a{constructor(t,e){let i=t.ownerDocument||t,s=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&s.CSSStyleSheet){let e=l.get(i);if(e)return t[n]=e;this.sheet=new s.CSSStyleSheet,l.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[n]=this}mount(t,e){let i=this.sheet,s=0,n=0,r=!1;for(let e=0;e<t.length;e++){let o=t[e],l=this.modules.indexOf(o);if(l<n&&l>-1&&(this.modules.splice(l,1),r=!0,n--,l=-1),-1==l){if(this.modules.splice(n++,0,o),r=!0,i)for(let t=0;t<o.rules.length;t++)i.insertRule(o.rules[t],s++)}else{for(;n<l;)s+=this.modules[n++].rules.length;s+=o.rules.length,n++}}if(i)e.adoptedStyleSheets.indexOf(this.sheet)<0&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{if(r){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}let t=e.head||e;this.styleTag.parentNode!=t&&t.insertBefore(this.styleTag,t.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}}}]);